Skip to content

Commit

Permalink
Merge pull request #1170 from SUI-Components/fix/ssr-npm7-lock-update
Browse files Browse the repository at this point in the history
fix(packages/sui-ssr): fix ssr lock file update for npm 7
  • Loading branch information
rmoralp committed May 26, 2021
2 parents 1d7d8ed + ffded0b commit bea3c96
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions packages/sui-ssr/bin/sui-ssr-release.js
Original file line number Diff line number Diff line change
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'
]

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

0 comments on commit bea3c96

Please sign in to comment.