From 99de7191f6730fb44e4e25c0048330fbd3db5500 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 858fe4d638bed..7bcd7d170f0fd 100644 --- a/docs/content/using-npm/config.md +++ b/docs/content/using-npm/config.md @@ -1161,6 +1161,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 @@ -1333,6 +1349,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 316e737091eb4..92f7615d4f4b9 100644 --- a/lib/utils/config/definitions.js +++ b/lib/utils/config/definitions.js @@ -2304,3 +2304,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 f98e74c066269..0ef339dd03c46 100644 --- a/tap-snapshots/test/lib/commands/config.js.test.cjs +++ b/tap-snapshots/test/lib/commands/config.js.test.cjs @@ -158,6 +158,8 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna "workspaces": null, "workspaces-update": true, "yes": null, + "omit-lockfile-registry-resolved": false, + "record-default-registry": false, "metrics-registry": "https://registry.npmjs.org/" } ` @@ -255,6 +257,7 @@ noproxy = [""] npm-version = "{NPM-VERSION}" offline = false omit = [] +omit-lockfile-registry-resolved = false only = null optional = null otp = null @@ -272,6 +275,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 b18b8e7a829e6..b02e3f5726753 100644 --- a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs +++ b/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs @@ -154,6 +154,8 @@ Array [ "workspaces", "workspaces-update", "yes", + "omit-lockfile-registry-resolved", + "record-default-registry", ] ` @@ -1223,6 +1225,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\` @@ -1414,6 +1431,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 564ade46e731d..072d86a82eaf1 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 @@ -1035,6 +1035,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 @@ -1207,6 +1223,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/"