-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: Add support for yarn berry #229
Open
chloe463
wants to merge
6
commits into
bahmutov:master
Choose a base branch
from
chloe463:chloe463/feat/yarn-berry
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9c319b8
fix: Do not exit in test environment
chloe463 1692e05
fix: Use --immutable instead of --frozen-lockfile when yarn version i…
chloe463 88b54d3
fix: Fix input paths
chloe463 70d3ff8
Merge branch 'master' into chloe463/feat/yarn-berry
chloe463 dbfb79b
test(action): Add test for yarn berry
chloe463 91e352b
fix: Remove env assignment from test script
chloe463 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,7 @@ const install = (opts = {}) => { | |
} | ||
|
||
const shouldUseYarn = opts.useYarn | ||
const shouldUseYarnV1 = opts.useYarnV1 ?? true | ||
const shouldUsePackageLock = opts.usePackageLock | ||
const npmCacheFolder = opts.npmCacheFolder | ||
if (!npmCacheFolder) { | ||
|
@@ -127,7 +128,9 @@ const install = (opts = {}) => { | |
return io.which('yarn', true).then(yarnPath => { | ||
console.log('yarn at "%s"', yarnPath) | ||
|
||
const args = shouldUsePackageLock ? ['--frozen-lockfile'] : [] | ||
const args = shouldUsePackageLock | ||
? [shouldUseYarnV1 ? '--frozen-lockfile' : '--immutable'] | ||
: [] | ||
core.debug( | ||
`yarn command: "${yarnPath}" ${args} ${JSON.stringify(options)}` | ||
) | ||
|
@@ -182,6 +185,7 @@ const getLockFilename = usePackageLock => workingDirectory => { | |
|
||
const getCacheParams = ({ | ||
useYarn, | ||
useYarnV1, | ||
useRollingCache, | ||
homeDirectory, | ||
npmCacheFolder, | ||
|
@@ -199,7 +203,9 @@ const getCacheParams = ({ | |
let inputPaths, restoreKeys | ||
|
||
if (useYarn) { | ||
inputPaths = [path.join(homeDirectory, '.cache', 'yarn')] | ||
inputPaths = useYarnV1 | ||
? [path.join(homeDirectory, '.cache', 'yarn')] | ||
: [path.join(homeDirectory, '.yarn', 'berry', 'cache')] | ||
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. I ran |
||
primaryKeySegments.unshift('yarn') | ||
} else { | ||
inputPaths = [npmCacheFolder] | ||
|
@@ -225,7 +231,7 @@ const getCacheParams = ({ | |
return { primaryKey: primaryKeySegments.join('-'), inputPaths, restoreKeys } | ||
} | ||
|
||
const installInOneFolder = ({ | ||
const installInOneFolder = async ({ | ||
usePackageLock, | ||
workingDirectory, | ||
useRollingCache, | ||
|
@@ -252,13 +258,21 @@ const installInOneFolder = ({ | |
core.debug('using NPM command, not using Yarn cache paths') | ||
useYarn = false | ||
} | ||
let useYarnV1 = true | ||
if (useYarn) { | ||
const { stdout: yarnVersion } = await exec.getExecOutput('yarn', [ | ||
'--version' | ||
]) | ||
useYarnV1 = /^1/.test(yarnVersion) | ||
} | ||
|
||
// enforce the same NPM cache folder across different operating systems | ||
const homeDirectory = os.homedir() | ||
const NPM_CACHE_FOLDER = path.join(homeDirectory, '.npm') | ||
|
||
const NPM_CACHE = getCacheParams({ | ||
useYarn, | ||
useYarnV1, | ||
homeDirectory, | ||
useRollingCache, | ||
npmCacheFolder: NPM_CACHE_FOLDER, | ||
|
@@ -268,6 +282,7 @@ const installInOneFolder = ({ | |
|
||
const opts = { | ||
useYarn, | ||
useYarnV1, | ||
usePackageLock, | ||
workingDirectory, | ||
npmCacheFolder: NPM_CACHE_FOLDER, | ||
|
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
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.
--frozen-lockfile
is for v1 and--immutable
is for v2 and more.