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(packages/sui-ssr): fix ssr lock file update for npm 7 #1170

Merged
merged 1 commit into from
May 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 21 additions & 6 deletions packages/sui-ssr/bin/sui-ssr-release.js
Expand Up @@ -59,12 +59,22 @@ const getCommitToTag = async () => {
}
const getNpmInstall = ({
legacyPeerDeps: hasLegacyPeerDeps,
packageLockOnly,
only: onlyScope
} = {}) => {
const only = onlyScope ? `--only=${onlyScope}` : ''
const legacyPeerDeps = hasLegacyPeerDeps ? '--legacy-peer-deps' : ''

return `npm install ${legacyPeerDeps} ${only} --package-lock-only --prefer-online --package-lock --progress false --no-bin-links false --ignore-scripts`
const installCommand = [
'npm install',
hasLegacyPeerDeps && '--legacy-peer-deps',
onlyScope && `--only=${onlyScope}`,
packageLockOnly && '--package-lock-only',
'--prefer-online',
'--package-lock',
'--progress false',
'--no-bin-links',
'--ignore-scripts'
]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ Improve readability and will avoid extra spaces when joining the array.


return installCommand.filter(Boolean).join(' ')
}
;(async () => {
const cwd = process.cwd()
Expand Down Expand Up @@ -98,10 +108,15 @@ const getNpmInstall = ({
await execute(`rm -Rf ${path.join(cwd, 'package-lock.json')}`)

if (npm7) {
/**
* Given '--package-lock-only' does not work as expected with npm 7.
* Then we need to make a clean installation to updates package-lock file used in the release.
* See: https://github.com/npm/cli/issues/2747
*/
await execute(getNpmInstall({legacyPeerDeps: npm7}))
} else {
await execute(getNpmInstall({only: 'pro'}))
await execute(getNpmInstall({only: 'dev'}))
await execute(getNpmInstall({only: 'pro', packageLockOnly: true}))
await execute(getNpmInstall({only: 'dev', packageLockOnly: true}))
}

await execute('npm version minor --no-git-tag-version')
Expand Down