-
Notifications
You must be signed in to change notification settings - Fork 905
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
TMisiukiewicz
merged 8 commits into
react-native-community:main
from
TMisiukiewicz:fix/handle-pods
Nov 29, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c34130a
recheck Xcode project when pods are installed in run-ios
TMisiukiewicz 63ae5b8
remove existing project cache on init
TMisiukiewicz 8ffddb4
don't create config file for < 0.73
TMisiukiewicz 44a36ab
add tests for cacheManager removeCache
TMisiukiewicz 30e3ea9
cleanup tests
TMisiukiewicz e431a78
add init tests
TMisiukiewicz b77c503
test custom react-native.config.js content
TMisiukiewicz 9e550d7
update cacheManager message
TMisiukiewicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import cacheManager from '../cacheManager'; | ||
import {cleanup, getTempDirectory} from '../../../../jest/helpers'; | ||
|
||
const DIR = getTempDirectory('.react-native-cli/cache'); | ||
const projectName = 'Project1'; | ||
const fullPath = path.join(DIR, projectName); | ||
|
||
describe('cacheManager', () => { | ||
beforeEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
afterEach(() => { | ||
cleanup(DIR); | ||
}); | ||
|
||
test('should not remove cache if it does not exist', () => { | ||
jest.spyOn(fs, 'existsSync').mockReturnValue(false); | ||
jest.spyOn(fs, 'rmSync').mockImplementation(() => {}); | ||
|
||
cacheManager.removeProjectCache(projectName); | ||
|
||
expect(fs.rmSync).not.toHaveBeenCalled(); | ||
}); | ||
|
||
test('should remove cache if it exists', () => { | ||
jest.spyOn(fs, 'existsSync').mockReturnValue(true); | ||
jest.spyOn(fs, 'rmSync').mockImplementation(() => {}); | ||
jest.spyOn(path, 'resolve').mockReturnValue(fullPath); | ||
|
||
cacheManager.removeProjectCache(projectName); | ||
|
||
expect(fs.rmSync).toHaveBeenCalledWith(fullPath, {recursive: true}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import path from 'path'; | |
import fs from 'fs'; | ||
import os from 'os'; | ||
import appDirs from 'appdirsjs'; | ||
import chalk from 'chalk'; | ||
import logger from './logger'; | ||
|
||
type CacheKey = 'eTag' | 'lastChecked' | 'latestVersion' | 'dependencies'; | ||
|
@@ -48,6 +49,23 @@ function getCacheRootPath() { | |
return cachePath; | ||
} | ||
|
||
function removeProjectCache(name: string) { | ||
const cacheRootPath = getCacheRootPath(); | ||
try { | ||
const fullPath = path.resolve(cacheRootPath, name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we can move |
||
|
||
if (fs.existsSync(fullPath)) { | ||
fs.rmSync(fullPath, {recursive: true}); | ||
} | ||
} catch { | ||
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 get(name: string, key: CacheKey): string | undefined { | ||
const cache = loadCache(name); | ||
if (cache) { | ||
|
@@ -67,4 +85,6 @@ function set(name: string, key: CacheKey, value: string) { | |
export default { | ||
get, | ||
set, | ||
removeProjectCache, | ||
getCacheRootPath, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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