Skip to content

Commit d559d6d

Browse files
committed
feat(config): Add --lockfile-version config option
Depends on @npmcli/[email protected] Re: npm/rfcs#434 PR-URL: #3880 Credit: @isaacs Close: #3880 Reviewed-by: @wraithgar
1 parent 13aed70 commit d559d6d

File tree

5 files changed

+104
-0
lines changed

5 files changed

+104
-0
lines changed

docs/content/using-npm/config.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,31 @@ When passed to `npm config` this refers to which config file to use.
969969
<!-- automatically generated, do not edit manually -->
970970
<!-- see lib/utils/config/definitions.js -->
971971

972+
#### `lockfile-version`
973+
974+
* Default: Version 2 if no lockfile or current lockfile version less than or
975+
equal to 2, otherwise maintain current lockfile version
976+
* Type: null, 1, 2, or 3
977+
978+
Set the lockfile format version to be used in package-lock.json and
979+
npm-shrinkwrap-json files. Possible options are:
980+
981+
1: The lockfile version used by npm versions 5 and 6. Lacks some data that
982+
is used during the install, resulting in slower and possibly less
983+
deterministic installs. Prevents lockfile churn when interoperating with
984+
older npm versions.
985+
986+
2: The default lockfile version used by npm version 7. Includes both the
987+
version 1 lockfile data and version 3 lockfile data, for maximum determinism
988+
and interoperability, at the expense of more bytes on disk.
989+
990+
3: Only the new lockfile information introduced in npm version 7. Smaller on
991+
disk than lockfile version 2, but not interoperable with older npm versions.
992+
Ideal if all users are on npm version 7 and higher.
993+
994+
<!-- automatically generated, do not edit manually -->
995+
<!-- see lib/utils/config/definitions.js -->
996+
972997
#### `loglevel`
973998

974999
* Default: "notice"

lib/utils/config/definitions.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,33 @@ define('location', {
11421142
},
11431143
})
11441144

1145+
define('lockfile-version', {
1146+
default: null,
1147+
type: [null, 1, 2, 3],
1148+
defaultDescription: `
1149+
Version 2 if no lockfile or current lockfile version less than or equal to
1150+
2, otherwise maintain current lockfile version
1151+
`,
1152+
description: `
1153+
Set the lockfile format version to be used in package-lock.json and
1154+
npm-shrinkwrap-json files. Possible options are:
1155+
1156+
1: The lockfile version used by npm versions 5 and 6. Lacks some data that
1157+
is used during the install, resulting in slower and possibly less
1158+
deterministic installs. Prevents lockfile churn when interoperating with
1159+
older npm versions.
1160+
1161+
2: The default lockfile version used by npm version 7. Includes both the
1162+
version 1 lockfile data and version 3 lockfile data, for maximum
1163+
determinism and interoperability, at the expense of more bytes on disk.
1164+
1165+
3: Only the new lockfile information introduced in npm version 7. Smaller
1166+
on disk than lockfile version 2, but not interoperable with older npm
1167+
versions. Ideal if all users are on npm version 7 and higher.
1168+
`,
1169+
flatten,
1170+
})
1171+
11451172
define('loglevel', {
11461173
default: 'notice',
11471174
type: [

tap-snapshots/test/lib/config.js.test.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ exports[`test/lib/config.js TAP config list --json > output matches snapshot 1`]
8686
"link": false,
8787
"local-address": null,
8888
"location": "user",
89+
"lockfile-version": null,
8990
"loglevel": "notice",
9091
"logs-max": 10,
9192
"long": false,
@@ -236,6 +237,7 @@ legacy-peer-deps = false
236237
link = false
237238
local-address = null
238239
location = "user"
240+
lockfile-version = null
239241
loglevel = "notice"
240242
logs-max = 10
241243
; long = false ; overridden by cli

tap-snapshots/test/lib/utils/config/definitions.js.test.cjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Array [
8282
"link",
8383
"local-address",
8484
"location",
85+
"lockfile-version",
8586
"loglevel",
8687
"logs-max",
8788
"long",
@@ -1041,6 +1042,30 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for locat
10411042
When passed to \`npm config\` this refers to which config file to use.
10421043
`
10431044

1045+
exports[`test/lib/utils/config/definitions.js TAP > config description for lockfile-version 1`] = `
1046+
#### \`lockfile-version\`
1047+
1048+
* Default: Version 2 if no lockfile or current lockfile version less than or
1049+
equal to 2, otherwise maintain current lockfile version
1050+
* Type: null, 1, 2, or 3
1051+
1052+
Set the lockfile format version to be used in package-lock.json and
1053+
npm-shrinkwrap-json files. Possible options are:
1054+
1055+
1: The lockfile version used by npm versions 5 and 6. Lacks some data that
1056+
is used during the install, resulting in slower and possibly less
1057+
deterministic installs. Prevents lockfile churn when interoperating with
1058+
older npm versions.
1059+
1060+
2: The default lockfile version used by npm version 7. Includes both the
1061+
version 1 lockfile data and version 3 lockfile data, for maximum determinism
1062+
and interoperability, at the expense of more bytes on disk.
1063+
1064+
3: Only the new lockfile information introduced in npm version 7. Smaller on
1065+
disk than lockfile version 2, but not interoperable with older npm versions.
1066+
Ideal if all users are on npm version 7 and higher.
1067+
`
1068+
10441069
exports[`test/lib/utils/config/definitions.js TAP > config description for loglevel 1`] = `
10451070
#### \`loglevel\`
10461071

tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,31 @@ When passed to \`npm config\` this refers to which config file to use.
843843
<!-- automatically generated, do not edit manually -->
844844
<!-- see lib/utils/config/definitions.js -->
845845
846+
#### \`lockfile-version\`
847+
848+
* Default: Version 2 if no lockfile or current lockfile version less than or
849+
equal to 2, otherwise maintain current lockfile version
850+
* Type: null, 1, 2, or 3
851+
852+
Set the lockfile format version to be used in package-lock.json and
853+
npm-shrinkwrap-json files. Possible options are:
854+
855+
1: The lockfile version used by npm versions 5 and 6. Lacks some data that
856+
is used during the install, resulting in slower and possibly less
857+
deterministic installs. Prevents lockfile churn when interoperating with
858+
older npm versions.
859+
860+
2: The default lockfile version used by npm version 7. Includes both the
861+
version 1 lockfile data and version 3 lockfile data, for maximum determinism
862+
and interoperability, at the expense of more bytes on disk.
863+
864+
3: Only the new lockfile information introduced in npm version 7. Smaller on
865+
disk than lockfile version 2, but not interoperable with older npm versions.
866+
Ideal if all users are on npm version 7 and higher.
867+
868+
<!-- automatically generated, do not edit manually -->
869+
<!-- see lib/utils/config/definitions.js -->
870+
846871
#### \`loglevel\`
847872
848873
* Default: "notice"

0 commit comments

Comments
 (0)