From 16b54e922248e8ac3458b20fcf27e773e6dfaeec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caleb=20=E3=83=84=20Everett?= Date: Mon, 3 Jan 2022 13:03:02 -0800 Subject: [PATCH] feat: add lockfile resolved options --- docs/content/using-npm/config.md | 32 +++++++++++++++++++ lib/utils/config/definitions.js | 30 +++++++++++++++++ .../test/lib/commands/config.js.test.cjs | 4 +++ .../lib/utils/config/definitions.js.test.cjs | 32 +++++++++++++++++++ .../lib/utils/config/describe-all.js.test.cjs | 32 +++++++++++++++++++ 5 files changed, 130 insertions(+) diff --git a/docs/content/using-npm/config.md b/docs/content/using-npm/config.md index fe197e344dbc0..5f1c037db6ec3 100644 --- a/docs/content/using-npm/config.md +++ b/docs/content/using-npm/config.md @@ -1144,6 +1144,22 @@ variable will be set to `'production'` for all lifecycle scripts. +#### `omit-lockfile-registry-resolved` + +* Default: false +* Type: Boolean + +Set to true to omit 'resolved' key from registry dependencies in lock files. + +This setting is useful in projects that may install dependencies from +different registries but would use a lockfile to lock package versions. This +option makes installing slower because npm must fetch package manifest to +resolve the package version's tarball. See 'record-default-registry' for an +alternative. + + + + #### `otp` * Default: null @@ -1314,6 +1330,22 @@ Rebuild bundled dependencies after installation. +#### `record-default-registry` + +* Default: false +* Type: Boolean + +Set to true to replace the actual registry in urls resolved from registires +with the default registry when recording lock files. + +This setting is useful in projects that may install dependencies from +different registries but would use a lockfile to lock package versions. This +option supports registries that host tarballs at the same path. If even the +path may change see 'omit-lockfile-registry-resolved'. + + + + #### `registry` * Default: "https://registry.npmjs.org/" diff --git a/lib/utils/config/definitions.js b/lib/utils/config/definitions.js index ac8a4e2f6749d..4aad72243582c 100644 --- a/lib/utils/config/definitions.js +++ b/lib/utils/config/definitions.js @@ -2267,3 +2267,33 @@ define('yes', { the command line. `, }) + +define('omit-lockfile-registry-resolved', { + default: false, + type: Boolean, + description: ` + Set to true to omit 'resolved' key from registry dependencies in lock files. + + This setting is useful in projects that may install dependencies from + different registries but would use a lockfile to lock package versions. + This option makes installing slower because npm must fetch package manifest + to resolve the package version's tarball. + See 'record-default-registry' for an alternative. + `, + flatten, +}) + +define('record-default-registry', { + default: false, + type: Boolean, + description: ` + Set to true to replace the actual registry in urls resolved from registires + with the default registry when recording lock files. + + This setting is useful in projects that may install dependencies from + different registries but would use a lockfile to lock package versions. + This option supports registries that host tarballs at the same path. If + even the path may change see 'omit-lockfile-registry-resolved'. + `, + flatten, +}) diff --git a/tap-snapshots/test/lib/commands/config.js.test.cjs b/tap-snapshots/test/lib/commands/config.js.test.cjs index 8e97915230719..242a50e0684a2 100644 --- a/tap-snapshots/test/lib/commands/config.js.test.cjs +++ b/tap-snapshots/test/lib/commands/config.js.test.cjs @@ -156,6 +156,8 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna "workspace": [], "workspaces": null, "yes": null, + "omit-lockfile-registry-resolved": false, + "record-default-registry": false, "metrics-registry": "https://registry.npmjs.org/" } ` @@ -252,6 +254,7 @@ noproxy = [""] npm-version = "{NPM-VERSION}" offline = false omit = [] +omit-lockfile-registry-resolved = false only = null optional = null otp = null @@ -269,6 +272,7 @@ progress = true proxy = null read-only = false rebuild-bundle = true +record-default-registry = false registry = "https://registry.npmjs.org/" save = true save-bundle = false diff --git a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs b/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs index 84bb22ff0ef59..79f50c33dfbdc 100644 --- a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs +++ b/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs @@ -152,6 +152,8 @@ Array [ "workspace", "workspaces", "yes", + "omit-lockfile-registry-resolved", + "record-default-registry", ] ` @@ -1205,6 +1207,21 @@ If the resulting omit list includes \`'dev'\`, then the \`NODE_ENV\` environment variable will be set to \`'production'\` for all lifecycle scripts. ` +exports[`test/lib/utils/config/definitions.js TAP > config description for omit-lockfile-registry-resolved 1`] = ` +#### \`omit-lockfile-registry-resolved\` + +* Default: false +* Type: Boolean + +Set to true to omit 'resolved' key from registry dependencies in lock files. + +This setting is useful in projects that may install dependencies from +different registries but would use a lockfile to lock package versions. This +option makes installing slower because npm must fetch package manifest to +resolve the package version's tarball. See 'record-default-registry' for an +alternative. +` + exports[`test/lib/utils/config/definitions.js TAP > config description for only 1`] = ` #### \`only\` @@ -1394,6 +1411,21 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for rebui Rebuild bundled dependencies after installation. ` +exports[`test/lib/utils/config/definitions.js TAP > config description for record-default-registry 1`] = ` +#### \`record-default-registry\` + +* Default: false +* Type: Boolean + +Set to true to replace the actual registry in urls resolved from registires +with the default registry when recording lock files. + +This setting is useful in projects that may install dependencies from +different registries but would use a lockfile to lock package versions. This +option supports registries that host tarballs at the same path. If even the +path may change see 'omit-lockfile-registry-resolved'. +` + exports[`test/lib/utils/config/definitions.js TAP > config description for registry 1`] = ` #### \`registry\` diff --git a/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs b/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs index 3db90f7679d4e..abd9b63ae5ad4 100644 --- a/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs +++ b/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs @@ -1018,6 +1018,22 @@ variable will be set to \`'production'\` for all lifecycle scripts. +#### \`omit-lockfile-registry-resolved\` + +* Default: false +* Type: Boolean + +Set to true to omit 'resolved' key from registry dependencies in lock files. + +This setting is useful in projects that may install dependencies from +different registries but would use a lockfile to lock package versions. This +option makes installing slower because npm must fetch package manifest to +resolve the package version's tarball. See 'record-default-registry' for an +alternative. + + + + #### \`otp\` * Default: null @@ -1188,6 +1204,22 @@ Rebuild bundled dependencies after installation. +#### \`record-default-registry\` + +* Default: false +* Type: Boolean + +Set to true to replace the actual registry in urls resolved from registires +with the default registry when recording lock files. + +This setting is useful in projects that may install dependencies from +different registries but would use a lockfile to lock package versions. This +option supports registries that host tarballs at the same path. If even the +path may change see 'omit-lockfile-registry-resolved'. + + + + #### \`registry\` * Default: "https://registry.npmjs.org/"