Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): run-ios command #2173

Merged

Conversation

TMisiukiewicz
Copy link
Collaborator

@TMisiukiewicz TMisiukiewicz commented Nov 22, 2023

Summary:

Fixing numerous small issues that could lead for potential breaking run-ios command:

  • if run-ios was called for the first time, and Pods were not installed during init, after installation it was trying to run xcodebuild command with .xcodeproj instead of .xcworkspace
  • if project with a name existed in cache, it was skipping bundle install step in run-ios
  • if --version flag was used with < 0.73, pods had trouble installing because unknown flag was used in the config (this scenario will fail unless 0.73 is latest, if you are experiencing it, it's because latest is used when --version flag is not used)

Test Plan:

  1. Follow the Contributing guide
  2. Create new app with node ../path/to/cli init RN73RC5 --version 0.73.0-rc.5
  3. When asked for installing pods, press n
  4. Once finished, use run-ios
  5. Verify pods are installed and build was successful
  6. rm -rf RN73RC5
  7. Create new app with node ../path/to/cli init RN73RC5 --version 0.73.0-rc.5
  8. When asked for installing pods, press y
  9. Once finished, use run-ios
  10. Verify build was successful

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

@TMisiukiewicz
Copy link
Collaborator Author

cc @cipolleschi

Comment on lines 397 to 398
// if the project with the name already has cache, remove the cache to avoid problems with pods installation
cacheManager.removeProjectCache(projectName);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, the same scenario could be if someone clones repo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but is there any way to prevent that in this scenario? 🤔

Comment on lines 52 to 56
const fullPath = path.resolve(getCacheRootPath(), name);

if (fs.existsSync(fullPath)) {
fs.rmSync(fullPath, {recursive: true});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add some error handling for the fs and resolve operations

@thymikee
Copy link
Member

Would appreciate tests for these scenarios 🙌🏼

@TMisiukiewicz
Copy link
Collaborator Author

@thymikee thanks for your review, done!


let dirFiles = fs.readdirSync(path.join(DIR, PROJECT_NAME));

expect(dirFiles).toContain('react-native.config.js');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could also validate what's inside

Comment on lines 61 to 65
logger.error(
`Failed to remove cache for ${name}. If you experience any issues when running freshly initialized project, please remove ${chalk.underline(
path.join(cacheRootPath, name),
)} folder manually.`,
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.error(
`Failed to remove cache for ${name}. If you experience any issues when running freshly initialized project, please remove ${chalk.underline(
path.join(cacheRootPath, name),
)} folder manually.`,
);
logger.error(
`Failed to remove cache for ${name}. If you experience any issues when running freshly initialized project, please remove the "${chalk.underline(
path.join(cacheRootPath, name),
)}" folder manually.`,
);

function removeProjectCache(name: string) {
const cacheRootPath = getCacheRootPath();
try {
const fullPath = path.resolve(cacheRootPath, name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we can move fullPath outside try catch and re-use it in catch statement.

@TMisiukiewicz TMisiukiewicz merged commit 6d61657 into react-native-community:main Nov 29, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants