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(cli): run yarn install after fixing yarn.lock by deduplicating #676

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/src/commands/deduplicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ const handler = async ({ cwd }) => {
const deduped = fixDuplicates(yarnLock)
fs.writeFileSync(paths.yarnLock, deduped)

if (deduped !== yarnLock) {
reporter.info(
`Run ${chalk.bold('yarn install')} to deduplicate node_modules`
)
}

const duplicates = listDuplicates(deduped)
if (duplicates.size > 0) {
reporter.error('Failed to deduplicate the following packages:')
Expand Down
7 changes: 6 additions & 1 deletion cli/src/lib/validators/validateLockfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs')
const { reporter, prompt } = require('@dhis2/cli-helpers-engine')
const { reporter, prompt, exec } = require('@dhis2/cli-helpers-engine')
const { listDuplicates, fixDuplicates } = require('../yarnDeduplicate')

const singletonDependencies = [
Expand Down Expand Up @@ -52,6 +52,11 @@ exports.validateLockfile = async (pkg, { paths, offerFix = false }) => {
}
const dedupedYarnLock = fixDuplicates(yarnLock)
fs.writeFileSync(paths.yarnLock, dedupedYarnLock)
await exec({
cmd: 'yarn',
args: ['install'],
cwd: paths.base,
})
return listSingletonDuplicates(dedupedYarnLock).size === 0
}

Expand Down