Skip to content

Commit

Permalink
fix: Don't set package-lock: false (#79)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mhan83 authored Oct 21, 2024
1 parent f169340 commit 50af1f8
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 38 deletions.
3 changes: 0 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export async function setUpNpmConfig(
audit: false,
fund: false,
noproxy: 'registry.npmjs.org',
'package-lock': false,
registry: getDefaultRegistry(),
'update-notifier': false,
};
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 0 additions & 8 deletions tests/unit/src/__snapshots__/utils.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
27 changes: 0 additions & 27 deletions tests/unit/src/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 50af1f8

Please sign in to comment.