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

feature: check --verify-tree for verifying node_modules structure #2419

Merged
merged 11 commits into from
Jan 16, 2017

Conversation

bestander
Copy link
Member

@bestander bestander commented Jan 10, 2017

Summary

Yarn needs an independend of resolving mechanism way of verifying node_modules correctness

Test plan

Manual test plan for React Native with these modifications:

  • removed node_modules/chalk (direct and hoisted dep)
  • removed node_modules/symbol-tree (dev dep)
  • modified version of node_modules/throat
  • modified version of node_modules/babel-core/node_modules/json5
$ ../yarn/bin/yarn check --verify-tree
yarn check v0.20.0-0
error "chalk" not installed
error "inquirer#chalk" not installed
error "throat" is wrong version: expected "^3.0.0", got "2.0.0"
error "eslint#chalk" not installed
error "jest-runtime#chalk" not installed
error "babel-core#babel-code-frame#chalk" not installed
error "babel-core#json5" is wrong version: expected "^0.5.0", got "0.1.0"
error "fbjs-scripts#gulp-util#chalk" not installed
error "request#har-validator#chalk" not installed
error "eslint#table#chalk" not installed
error "jest#jest-cli#chalk" not installed
error "jest-repl#jest-runtime#chalk" not installed
error "jest-repl#jest-util#chalk" not installed
error "jest-runtime#jest-config#chalk" not installed
error "fbjs-scripts#gulp-util#fancy-log#chalk" not installed
error "jest-runtime#jest-snapshot#jest-diff#chalk" not installed
error "jest-runtime#jest-snapshot#jest-matcher-utils#chalk" not installed
error "jest#jest-cli#jest-environment-jsdom#jsdom#symbol-tree" not installed
error "jest#jest-cli#node-notifier#cli-usage#marked-terminal#chalk" not installed
error Found 19 errors.
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

$ ../yarn/bin/yarn check --integrity
yarn check v0.20.0-0
success Folder in sync.
✨  Done in 1.81s.

$ ../yarn/bin/yarn check
yarn check v0.20.0-0
error "babel-core#json5@^0.5.0" doesn't satisfy found match of "babel-core#json5@0.1.0"
error "chalk" not installed
error "throat" is wrong version: expected "3.0.0", got "2.0.0"
error "\u001b[2mjest#\u001b[22mjest-cli#throat@^3.0.0" doesn't satisfy found match of "throat@2.0.0"
error "babel-core#json5" is wrong version: expected "0.5.0", got "0.1.0"
error "\u001b[2mjsdom#\u001b[22msymbol-tree" not installed
error Found 6 errors.
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

@bestander
Copy link
Member Author

Needs cleanup and tests

@bestander bestander changed the title [WIP] feature: check --commonjs for verifying node_modules structure feature: check --commonjs for verifying node_modules structure Jan 14, 2017
@hpurmann
Copy link
Contributor

Thank you for building this!

@bestander
Copy link
Member Author

Not sure what to do with optional deps because hoisting may cause some inconsistencies, I'll probably ignore them for this round.

@bestander
Copy link
Member Author

Suggest a better name for the flag than commonjs

Copy link
Contributor

@kentaromiura kentaromiura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks pretty soundy to me, I'll rename the flag as proposed (or even a better solution), may be worthy pinging @kittens for better ideas.

while (locations.length >= 0) {
let possiblePath;
if (locations.length > 0) {
possiblePath = path.join(registry.cwd, registry.folder,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

possiblePath = path.join(
  registry.cwd, 
  registry.folder,
  locations.join(path.sep + registry.folder + path.sep)
);

@@ -15,6 +15,160 @@ export const noArguments = true;

export function setFlags(commander: Object) {
commander.option('--integrity');
commander.option('--commonjs');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @davidaurelio suggested commonjs is probably not related to node js modules resolution, let's think of a better name:

  • --resolve-correctly
  • --verify-tree
  • --check-tree

other suggestion is to unify check and pass a level variable to it, so it will be something like --check lite --check deep --check full or --check 0...--check 2 or as an array (yargs supports this, not sure what commander does) --check 1 3

@bestander bestander changed the title feature: check --commonjs for verifying node_modules structure feature: check --verify-tree for verifying node_modules structure Jan 16, 2017
@bestander bestander merged commit c98df16 into yarnpkg:master Jan 16, 2017
@edmorley
Copy link
Contributor

Could you add some documentation for this on https://yarnpkg.com/lang/en/docs/cli/check/ ? :-)

@bestander
Copy link
Member Author

bestander commented Mar 10, 2017 via email

@Simek
Copy link
Contributor

Simek commented Dec 30, 2017

Documentation still lacks information about --verify-tree flag. Should I report this as an issue to yarn/website?

@bestander
Copy link
Member Author

bestander commented Dec 30, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants