Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn on package lock json #5920

Merged
merged 2 commits into from Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions __tests__/commands/install/lockfiles.js
Expand Up @@ -326,3 +326,19 @@ test.concurrent("install should fix if lockfile patterns don't match resolved ve
expect(lockContent).toContain('left-pad-1.1.2.tgz');
});
});

test.concurrent('install should warn if a conflicting npm package-lock.json exists', (): Promise<void> => {
const fixture = 'lockfile-conflict-package-lock-json';

return runInstall({}, fixture, (config, reporter, install, getStdout) => {
expect(getStdout()).toContain('package-lock.json found');
});
});

test.concurrent('install should warn if a conflicting npm npm-shrinkwrap.json exists', (): Promise<void> => {
const fixture = 'lockfile-conflict-npm-shrinkwrap-json';

return runInstall({}, fixture, (config, reporter, install, getStdout) => {
expect(getStdout()).toContain('npm-shrinkwrap.json found');
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,5 @@
{
"dependencies": {
"left-pad": "^1.1.3"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,5 @@
{
"dependencies": {
"left-pad": "^1.1.3"
}
}
7 changes: 6 additions & 1 deletion src/cli/commands/install.js
Expand Up @@ -516,10 +516,15 @@ export class Install {
this.checkUpdate();

// warn if we have a shrinkwrap
if (await fs.exists(path.join(this.config.lockfileFolder, 'npm-shrinkwrap.json'))) {
if (await fs.exists(path.join(this.config.lockfileFolder, constants.NPM_SHRINKWRAP_FILENAME))) {
this.reporter.warn(this.reporter.lang('shrinkwrapWarning'));
}

// warn if we have an npm lockfile
if (await fs.exists(path.join(this.config.lockfileFolder, constants.NPM_LOCK_FILENAME))) {
this.reporter.warn(this.reporter.lang('npmLockfileWarning'));
}

// running a focused install in a workspace root is not allowed
if (this.flags.focus && (!this.config.workspaceRootFolder || this.config.cwd === this.config.workspaceRootFolder)) {
throw new MessageError(this.reporter.lang('workspacesFocusRootCheck'));
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Expand Up @@ -86,6 +86,7 @@ export const TARBALL_FILENAME = '.yarn-tarball.tgz';
export const CLEAN_FILENAME = '.yarnclean';

export const NPM_LOCK_FILENAME = 'package-lock.json';
export const NPM_SHRINKWRAP_FILENAME = 'npm-shrinkwrap.json';

export const DEFAULT_INDENT = ' ';
export const SINGLE_INSTANCE_PORT = 31997;
Expand Down
2 changes: 2 additions & 0 deletions src/reporters/lang/en.js
Expand Up @@ -94,6 +94,8 @@ const messages = {
couldntFindManifestIn: "Couldn't find manifest in $0.",
shrinkwrapWarning:
'npm-shrinkwrap.json found. This will not be updated or respected. See https://yarnpkg.com/en/docs/migrating-from-npm for more information.',
npmLockfileWarning:
'package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.',
lockfileOutdated: 'Outdated lockfile. Please run `yarn install` and try again.',
lockfileMerged: 'Merge conflict detected in yarn.lock and successfully merged.',
lockfileConflict:
Expand Down