From 50af1f81c2ecc106128e9cd40984599a37cc5176 Mon Sep 17 00:00:00 2001 From: Mike Han <56001373+mhan83@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:29:02 -0600 Subject: [PATCH] fix: Don't set package-lock: false (#79) * fix: Don't set package-lock: false A later change that renames package-lock.json is effectively the same, e.g. don't install the full dependency tree when npm installing specific packages. [DEVX-2475] * update snapshots * Fix tests --- src/utils.ts | 3 --- .../unit/src/__snapshots__/utils.spec.ts.snap | 8 ------ tests/unit/src/utils.spec.ts | 27 ------------------- 3 files changed, 38 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index dfa197e..8c40819 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -58,7 +58,6 @@ export async function setUpNpmConfig( audit: false, fund: false, noproxy: 'registry.npmjs.org', - 'package-lock': false, registry: getDefaultRegistry(), 'update-notifier': false, }; @@ -131,8 +130,6 @@ export function getNpmConfig(runnerConfig: NpmConfigContainer) { const cfg: { [key: string]: string | boolean | null | undefined } = { registry: runnerConfig.npm.registry || getDefaultRegistry(), 'strict-ssl': runnerConfig.npm.strictSSL, - // Setting to false to avoid dealing with the generated file. - 'package-lock': runnerConfig.npm.packageLock === true, 'legacy-peer-deps': runnerConfig.npm.legacyPeerDeps !== 'false' && runnerConfig.npm.legacyPeerDeps !== false, diff --git a/tests/unit/src/__snapshots__/utils.spec.ts.snap b/tests/unit/src/__snapshots__/utils.spec.ts.snap index 941b2bf..a8c4eff 100644 --- a/tests/unit/src/__snapshots__/utils.spec.ts.snap +++ b/tests/unit/src/__snapshots__/utils.spec.ts.snap @@ -30,7 +30,6 @@ exports[`utils .prepareNpmEnv should be able to set strictSSL to false 1`] = ` "json": false, "legacy-peer-deps": true, "noproxy": "registry.npmjs.org", - "package-lock": false, "registry": "test.strictSSL.false", "save": false, "strict-ssl": false, @@ -52,7 +51,6 @@ exports[`utils .prepareNpmEnv should be able to set strictSSL to true 1`] = ` "json": false, "legacy-peer-deps": true, "noproxy": "registry.npmjs.org", - "package-lock": false, "registry": "test.strictSSL.true", "save": false, "strict-ssl": true, @@ -86,7 +84,6 @@ exports[`utils .prepareNpmEnv should set right registry for npm 1`] = ` "fund": false, "json": false, "noproxy": "registry.npmjs.org", - "package-lock": false, "registry": "my.registry", "save": false, "strict-ssl": true, @@ -108,7 +105,6 @@ exports[`utils .prepareNpmEnv should use default registry 1`] = ` "json": false, "legacy-peer-deps": true, "noproxy": "registry.npmjs.org", - "package-lock": false, "registry": "https://registry.npmjs.org", "save": false, "strict-ssl": undefined, @@ -130,7 +126,6 @@ exports[`utils .prepareNpmEnv should use env var for registry 1`] = ` "json": false, "legacy-peer-deps": true, "noproxy": "registry.npmjs.org", - "package-lock": false, "registry": "npmland.io", "save": false, "strict-ssl": undefined, @@ -176,7 +171,6 @@ exports[`utils .prepareNpmEnv should use true as the default value for strictSSL "json": false, "legacy-peer-deps": true, "noproxy": "registry.npmjs.org", - "package-lock": false, "registry": "https://registry.npmjs.org", "save": false, "strict-ssl": undefined, @@ -198,7 +192,6 @@ exports[`utils .prepareNpmEnv should use true as the default value for strictSSL "json": false, "legacy-peer-deps": true, "noproxy": "registry.npmjs.org", - "package-lock": false, "registry": "https://registry.npmjs.org", "save": false, "strict-ssl": undefined, @@ -220,7 +213,6 @@ exports[`utils .prepareNpmEnv should use user registry 1`] = ` "json": false, "legacy-peer-deps": true, "noproxy": "registry.npmjs.org", - "package-lock": false, "registry": "registryland.io", "save": false, "strict-ssl": undefined, diff --git a/tests/unit/src/utils.spec.ts b/tests/unit/src/utils.spec.ts index 792d2e3..0b8c87b 100644 --- a/tests/unit/src/utils.spec.ts +++ b/tests/unit/src/utils.spec.ts @@ -53,7 +53,6 @@ describe('utils', function () { expect(npmConfig).toHaveProperty('strict-ssl'); expect(npmConfig).toHaveProperty('registry'); - expect(npmConfig).toHaveProperty('package-lock'); }); it('should set strictSSL to undefined if not set', function () { @@ -76,31 +75,6 @@ describe('utils', function () { expect(npmConfig).toHaveProperty('strict-ssl', true); }); - it('should set packageLock to false by default', function () { - const npmConfig = getNpmConfig(emptyConfig); - - expect(npmConfig).toHaveProperty('package-lock', false); - }); - - it('should set packageLock from runner config', function () { - const runnerConfig: NpmConfigContainer = { - npm: { - packageLock: true, - }, - }; - let npmConfig = getNpmConfig(runnerConfig); - expect(npmConfig).toHaveProperty('package-lock', true); - - runnerConfig.npm ||= {}; - runnerConfig.npm.packageLock = false; - npmConfig = getNpmConfig(runnerConfig); - expect(npmConfig).toHaveProperty('package-lock', false); - - runnerConfig.npm.packageLock = 'truthy?'; - npmConfig = getNpmConfig(runnerConfig); - expect(npmConfig).toHaveProperty('package-lock', false); - }); - it('should set the default npm registry by default', function () { const npmConfig = getNpmConfig(emptyConfig); @@ -164,7 +138,6 @@ describe('utils', function () { const config = { registry: 'my.registry', 'strict-ssl': true, - 'package-lock': false, }; const loadSpyOn = jest.spyOn(npm, 'configure'); await setUpNpmConfig(nodeCtx, config);