-
Notifications
You must be signed in to change notification settings - Fork 1k
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: Run dedupe during upgrade on yarn 3 #5458
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,24 +278,29 @@ const dedupeDeps = async (task, { verbose }) => { | |
try { | ||
const yarnVersion = await getCmdMajorVersion('yarn') | ||
const npxVersion = await getCmdMajorVersion('npx') | ||
if (yarnVersion > 1) { | ||
task.skip('Deduplication is only required for <=1.x') | ||
return | ||
} | ||
let npxArgs = [] | ||
if (npxVersion > 6) { | ||
npxArgs = ['--yes'] | ||
} | ||
|
||
await execa('npx', [...npxArgs, 'yarn-deduplicate'], { | ||
const baseExecaArgsForDedupe = { | ||
shell: true, | ||
stdio: verbose ? 'inherit' : 'pipe', | ||
cwd: getPaths().base, | ||
}) | ||
} | ||
if (yarnVersion > 1) { | ||
await execa('yarn', ['dedupe'], baseExecaArgsForDedupe) | ||
} else { | ||
await execa( | ||
'npx', | ||
[...npxArgs, 'yarn-deduplicate'], | ||
baseExecaArgsForDedupe | ||
) | ||
} | ||
} catch (e) { | ||
console.log(c.error(e.message)) | ||
throw new Error( | ||
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. maybe we can print the correct command based on the yarn version? 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. We can but if for some reason regex fails for semver, that's why I kept it one simple catch. 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. The one catch is fine, but just suggesting printing different messages
|
||
'Could not finish deduplication. If the project is using yarn 1.x, please run `npx yarn-deduplicate`, before continuing' | ||
'Could not finish de-duplication. For yarn 1.x, please run `npx yarn-deduplicate`, or for yarn 3 run `yarn dedupe` before continuing' | ||
) | ||
} | ||
await yarnInstall({ verbose }) | ||
|
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.
yarn dedupe
was added in v2.2.0 so there is a chance it isn't a valid command.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.
Ah gotcha. Great catch—we don't expect users to be on yarn 2, but to be fair we don't have any documentation / checks around that fact, so there's some work to do here. A while back Danny had asked me to make a simple utility for running yarn commands given that we have to support two versions; it's probably time for me to revisit that.