Skip to content

Commit

Permalink
Disables by default the migrations (#6465)
Browse files Browse the repository at this point in the history
* Disables by default the migrations

* Uses boolifyWithDefaults

* Makes flow happy(ier)

* Fixes tests
  • Loading branch information
arcanis committed Oct 2, 2018
1 parent 837704c commit 6ea3ff5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -20,6 +20,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

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

- Disables by default (configurable) the automatic migration of the `integrity` field. **It will be re-enabled in 2.0.**

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

- Fixes the display name of the faulty package when the NPM registry returns corrupted data

[#6455](https://github.com/yarnpkg/yarn/pull/6455) - [**Grey Baker**](https://github.com/greysteil)
Expand Down
10 changes: 5 additions & 5 deletions __tests__/commands/add.js
Expand Up @@ -65,10 +65,10 @@ test.concurrent('adding to the workspace root should preserve workspace packages
expect(pkg.dependencies).toEqual({'left-pad': '1.1.3', 'max-safe-integer': '1.0.0'});

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

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

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

const mirror = await fs.walk(path.join(config.cwd, mirrorPath));
expect(mirror).toHaveLength(3);
Expand Down
5 changes: 3 additions & 2 deletions __tests__/commands/install/integration.js
Expand Up @@ -724,7 +724,7 @@ test('install should fail to authenticate on sha1 integrity mismatch', () =>
message: expect.stringContaining("computed integrity doesn't match our records"),
}));

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

test('install should not create the integrity field if missing and auto-add-integrity is false', () =>
runInstall({}, 'install-update-auth-no-integrity-field-no-auto-add', async config => {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/commands/remove.js
Expand Up @@ -110,7 +110,7 @@ test.concurrent('removes a single scoped package', (): Promise<void> => {

const lockFileContent = await fs.readFile(path.join(config.cwd, 'yarn.lock'));
const lockFileLines = explodeLockfile(lockFileContent);
expect(lockFileLines).toHaveLength(4);
expect(lockFileLines).toHaveLength(3);
});
});

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

expect(lockFileLines).toHaveLength(12);
expect(lockFileLines).toHaveLength(9);
expect(lockFileLines[0]).toEqual('left-pad@1.1.3:');
});
});
Expand Down
6 changes: 4 additions & 2 deletions src/cli/commands/install.js
Expand Up @@ -454,15 +454,17 @@ export class Install {
return false;
}
const lockfileClean = this.lockfile.parseResultType === 'success';
const lockfileIntegrityPresent = !this.lockfile.hasEntriesExistWithoutIntegrity();
const match = await this.integrityChecker.check(patterns, lockfileCache, this.flags, workspaceLayout);
if (this.flags.frozenLockfile && (!lockfileClean || match.missingPatterns.length > 0)) {
throw new MessageError(this.reporter.lang('frozenLockfileError'));
}

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

if (match.integrityMatches && haveLockfile && lockfileClean && lockfileIntegrityPresent) {
const lockfileIntegrityPresent = !this.lockfile.hasEntriesExistWithoutIntegrity();
const integrityBailout = lockfileIntegrityPresent || !this.config.autoAddIntegrity;

if (match.integrityMatches && haveLockfile && lockfileClean && integrityBailout) {
this.reporter.success(this.reporter.lang('upToDate'));
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/config.js
Expand Up @@ -6,6 +6,7 @@ import type {Manifest, PackageRemote, WorkspacesManifestMap, WorkspacesConfig} f
import type PackageReference from './package-reference.js';
import {execFromManifest} from './util/execute-lifecycle-script.js';
import {resolveWithHome} from './util/path.js';
import {boolifyWithDefault} from './util/conversion.js';
import normalizeManifest from './util/normalize-manifest/index.js';
import {MessageError} from './errors.js';
import * as fs from './util/fs.js';
Expand Down Expand Up @@ -422,7 +423,7 @@ export default class Config {
this.linkFileDependencies = Boolean(this.getOption('yarn-link-file-dependencies'));
this.packBuiltPackages = Boolean(this.getOption('experimental-pack-script-packages-in-mirror'));

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

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

0 comments on commit 6ea3ff5

Please sign in to comment.