Skip to content

Commit 6ea3ff5

Browse files
authored
Disables by default the migrations (#6465)
* Disables by default the migrations * Uses boolifyWithDefaults * Makes flow happy(ier) * Fixes tests
1 parent 837704c commit 6ea3ff5

6 files changed

Lines changed: 20 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa
2020

2121
[#6464](https://github.com/yarnpkg/yarn/pull/6464) - [**Maël Nison**](https://twitter.com/arcanis)
2222

23+
- Disables by default (configurable) the automatic migration of the `integrity` field. **It will be re-enabled in 2.0.**
24+
25+
[#6465](https://github.com/yarnpkg/yarn/pull/6465) - [**Maël Nison**](https://twitter.com/arcanis)
26+
2327
- Fixes the display name of the faulty package when the NPM registry returns corrupted data
2428

2529
[#6455](https://github.com/yarnpkg/yarn/pull/6455) - [**Grey Baker**](https://github.com/greysteil)

__tests__/commands/add.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ test.concurrent('adding to the workspace root should preserve workspace packages
6565
expect(pkg.dependencies).toEqual({'left-pad': '1.1.3', 'max-safe-integer': '1.0.0'});
6666

6767
const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock')));
68-
expect(lockfile).toHaveLength(20);
68+
expect(lockfile).toHaveLength(16);
6969
expect(lockfile.indexOf('isarray@2.0.1:')).toEqual(0);
70-
expect(lockfile.indexOf('left-pad@1.1.3:')).toEqual(4);
71-
expect(lockfile.indexOf('max-safe-integer@1.0.0:')).toEqual(8);
70+
expect(lockfile.indexOf('left-pad@1.1.3:')).toEqual(3);
71+
expect(lockfile.indexOf('max-safe-integer@1.0.0:')).toEqual(6);
7272
});
7373
});
7474

@@ -432,7 +432,7 @@ test.concurrent('add with new dependency should be deterministic', async () => {
432432
const lockFileWritten = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
433433
const lockFileLines = explodeLockfile(lockFileWritten);
434434

435-
expect(lockFileLines).toHaveLength(14);
435+
expect(lockFileLines).toHaveLength(12);
436436
expect(lockFileLines.indexOf('mime-db@~1.0.1:')).toBeGreaterThanOrEqual(0);
437437
expect(lockFileLines.indexOf('mime-db@1.23.0:')).toBeGreaterThanOrEqual(0);
438438
expect(lockFileLines.indexOf('mime-types@2.0.0:')).toBeGreaterThanOrEqual(0);
@@ -471,7 +471,7 @@ test.concurrent('add with new dependency should be deterministic 2', async () =>
471471
const lockFileWritten = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
472472
const lockFileLines = explodeLockfile(lockFileWritten);
473473
// see why we don't cleanup lockfile https://github.com/yarnpkg/yarn/issues/79
474-
expect(lockFileLines).toHaveLength(14);
474+
expect(lockFileLines).toHaveLength(12);
475475

476476
const mirror = await fs.walk(path.join(config.cwd, mirrorPath));
477477
expect(mirror).toHaveLength(3);

__tests__/commands/install/integration.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ test('install should fail to authenticate on sha1 integrity mismatch', () =>
724724
message: expect.stringContaining("computed integrity doesn't match our records"),
725725
}));
726726

727-
test('install should create integrity field if not present', () =>
727+
test.skip('install should create integrity field if not present', () =>
728728
runInstall({}, 'install-update-auth-no-integrity-field', async config => {
729729
const lockFileContent = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
730730
const lockFileLines = explodeLockfile(lockFileContent);
@@ -736,7 +736,8 @@ test('install should create integrity field if not present', () =>
736736
).toEqual(2);
737737
expect(lockFileLines[2].indexOf('#893312af69b2123def71f57889001671eeb2c853')).toBeGreaterThan(0);
738738
// backwards-compatibility
739-
}));
739+
}),
740+
);
740741

741742
test('install should not create the integrity field if missing and auto-add-integrity is false', () =>
742743
runInstall({}, 'install-update-auth-no-integrity-field-no-auto-add', async config => {

__tests__/commands/remove.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ test.concurrent('removes a single scoped package', (): Promise<void> => {
110110

111111
const lockFileContent = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
112112
const lockFileLines = explodeLockfile(lockFileContent);
113-
expect(lockFileLines).toHaveLength(4);
113+
expect(lockFileLines).toHaveLength(3);
114114
});
115115
});
116116

@@ -179,7 +179,7 @@ test.concurrent('removes from workspace packages', async () => {
179179
const lockFileContent = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
180180
const lockFileLines = explodeLockfile(lockFileContent);
181181

182-
expect(lockFileLines).toHaveLength(12);
182+
expect(lockFileLines).toHaveLength(9);
183183
expect(lockFileLines[0]).toEqual('left-pad@1.1.3:');
184184
});
185185
});

src/cli/commands/install.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,15 +454,17 @@ export class Install {
454454
return false;
455455
}
456456
const lockfileClean = this.lockfile.parseResultType === 'success';
457-
const lockfileIntegrityPresent = !this.lockfile.hasEntriesExistWithoutIntegrity();
458457
const match = await this.integrityChecker.check(patterns, lockfileCache, this.flags, workspaceLayout);
459458
if (this.flags.frozenLockfile && (!lockfileClean || match.missingPatterns.length > 0)) {
460459
throw new MessageError(this.reporter.lang('frozenLockfileError'));
461460
}
462461

463462
const haveLockfile = await fs.exists(path.join(this.config.lockfileFolder, constants.LOCKFILE_FILENAME));
464463

465-
if (match.integrityMatches && haveLockfile && lockfileClean && lockfileIntegrityPresent) {
464+
const lockfileIntegrityPresent = !this.lockfile.hasEntriesExistWithoutIntegrity();
465+
const integrityBailout = lockfileIntegrityPresent || !this.config.autoAddIntegrity;
466+
467+
if (match.integrityMatches && haveLockfile && lockfileClean && integrityBailout) {
466468
this.reporter.success(this.reporter.lang('upToDate'));
467469
return true;
468470
}

src/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {Manifest, PackageRemote, WorkspacesManifestMap, WorkspacesConfig} f
66
import type PackageReference from './package-reference.js';
77
import {execFromManifest} from './util/execute-lifecycle-script.js';
88
import {resolveWithHome} from './util/path.js';
9+
import {boolifyWithDefault} from './util/conversion.js';
910
import normalizeManifest from './util/normalize-manifest/index.js';
1011
import {MessageError} from './errors.js';
1112
import * as fs from './util/fs.js';
@@ -422,7 +423,7 @@ export default class Config {
422423
this.linkFileDependencies = Boolean(this.getOption('yarn-link-file-dependencies'));
423424
this.packBuiltPackages = Boolean(this.getOption('experimental-pack-script-packages-in-mirror'));
424425

425-
this.autoAddIntegrity = !this.getOption('unsafe-disable-integrity-migration');
426+
this.autoAddIntegrity = !boolifyWithDefault(String(this.getOption('unsafe-disable-integrity-migration')), true);
426427

427428
//init & create cacheFolder, tempFolder
428429
this.cacheFolder = path.join(this._cacheRootFolder, 'v' + String(constants.CACHE_VERSION));

0 commit comments

Comments
 (0)