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(ci): should not use package-lock config #4364

Merged
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
2 changes: 2 additions & 0 deletions docs/content/using-npm/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,8 @@ When package package-locks are disabled, automatic pruning of extraneous
modules will also be disabled. To remove extraneous modules with
package-locks disabled use `npm prune`.

This configuration does not affect `npm ci`.

<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

Expand Down
1 change: 1 addition & 0 deletions lib/commands/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class CI extends ArboristWorkspaceCmd {
const where = this.npm.prefix
const opts = {
...this.npm.flatOptions,
packageLock: true, // npm ci should never skip lock files
path: where,
log,
save: false, // npm ci should never modify the lockfile or package.json
Expand Down
2 changes: 2 additions & 0 deletions lib/utils/config/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,8 @@ define('package-lock', {
When package package-locks are disabled, automatic pruning of extraneous
modules will also be disabled. To remove extraneous modules with
package-locks disabled use \`npm prune\`.
This configuration does not affect \`npm ci\`.
`,
flatten: (key, obj, flatOptions) => {
flatten(key, obj, flatOptions)
Expand Down
2 changes: 2 additions & 0 deletions tap-snapshots/test/lib/utils/config/definitions.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,8 @@ will also prevent _writing_ \`package-lock.json\` if \`save\` is true.
When package package-locks are disabled, automatic pruning of extraneous
modules will also be disabled. To remove extraneous modules with
package-locks disabled use \`npm prune\`.

This configuration does not affect \`npm ci\`.
`

exports[`test/lib/utils/config/definitions.js TAP > config description for package-lock-only 1`] = `
Expand Down
2 changes: 2 additions & 0 deletions tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,8 @@ When package package-locks are disabled, automatic pruning of extraneous
modules will also be disabled. To remove extraneous modules with
package-locks disabled use \`npm prune\`.

This configuration does not affect \`npm ci\`.

<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

Expand Down
3 changes: 2 additions & 1 deletion test/lib/commands/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ t.test('should throw ECIGLOBAL', async t => {
})

t.test('should remove existing node_modules before installing', async t => {
t.plan(2)
t.plan(3)
const testDir = t.testdir({
node_modules: {
'some-file': 'some contents',
Expand All @@ -212,6 +212,7 @@ t.test('should remove existing node_modules before installing', async t => {
'@npmcli/arborist': function () {
this.loadVirtual = () => Promise.resolve(true)
this.reify = async (options) => {
t.equal(options.packageLock, true, 'npm ci should never ignore lock')
t.equal(options.save, false, 'npm ci should never save')
// check if node_modules was removed before reifying
const contents = await readdir(testDir)
Expand Down