@yarnpkg/plugin-essentials 4.4.4 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,6 +21,14 @@ const LOCKFILE_MIGRATION_RULES = [{
21
21
  selector: v => v !== -1 && v < 8,
22
22
  name: `compressionLevel`,
23
23
  value: `mixed`,
24
+ }, {
25
+ selector: v => v < 9,
26
+ name: `approvedGitRepositories`,
27
+ value: [`**`],
28
+ }, {
29
+ selector: v => v < 9,
30
+ name: `enableScripts`,
31
+ value: true,
24
32
  }];
25
33
  // eslint-disable-next-line arca/no-default-export
26
34
  class YarnCommand extends cli_1.BaseCommand {
@@ -182,7 +190,7 @@ class YarnCommand extends cli_1.BaseCommand {
182
190
  const isRcBinary = semver_1.default.prerelease(core_1.YarnVersion);
183
191
  const releaseType = isRcBinary ? `canary` : `stable`;
184
192
  const candidate = data.latest[releaseType];
185
- if (semver_1.default.gt(candidate, core_1.YarnVersion)) {
193
+ if (candidate !== null && semver_1.default.gt(candidate, core_1.YarnVersion)) {
186
194
  newVersion = [releaseType, candidate];
187
195
  }
188
196
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cli_1 = require("@yarnpkg/cli");
4
4
  const core_1 = require("@yarnpkg/core");
5
5
  const core_2 = require("@yarnpkg/core");
6
- const core_3 = require("@yarnpkg/core");
7
6
  const clipanion_1 = require("clipanion");
8
7
  // eslint-disable-next-line arca/no-default-export
9
8
  class WhyCommand extends cli_1.BaseCommand {
@@ -22,15 +21,17 @@ class WhyCommand extends cli_1.BaseCommand {
22
21
  }
23
22
  async execute() {
24
23
  const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
25
- const { project, workspace } = await core_2.Project.find(configuration, this.context.cwd);
24
+ const { project, workspace } = await core_1.Project.find(configuration, this.context.cwd);
26
25
  if (!workspace)
27
26
  throw new cli_1.WorkspaceRequiredError(project.cwd, this.context.cwd);
28
27
  await project.restoreInstallState();
29
- const identHash = core_3.structUtils.parseIdent(this.package).identHash;
28
+ const descriptor = core_2.structUtils.parseDescriptor(this.package, false);
29
+ if (descriptor.range !== `unknown` && core_1.semverUtils.validRange(descriptor.range) === null)
30
+ throw new clipanion_1.UsageError(`Expected a valid semver range, got ${descriptor.range}`);
30
31
  const whyTree = this.recursive
31
- ? whyRecursive(project, identHash, { configuration, peers: this.peers })
32
- : whySimple(project, identHash, { configuration, peers: this.peers });
33
- core_3.treeUtils.emitTree(whyTree, {
32
+ ? whyRecursive(project, descriptor, { configuration, peers: this.peers })
33
+ : whySimple(project, descriptor, { configuration, peers: this.peers });
34
+ core_2.treeUtils.emitTree(whyTree, {
34
35
  configuration,
35
36
  stdout: this.context.stdout,
36
37
  json: this.json,
@@ -44,19 +45,25 @@ WhyCommand.paths = [
44
45
  WhyCommand.usage = clipanion_1.Command.Usage({
45
46
  description: `display the reason why a package is needed`,
46
47
  details: `
47
- This command prints the exact reasons why a package appears in the dependency tree.
48
+ This command prints the exact reasons why a package appears in the dependency tree. Specify a version or range to determine why the dependency tree contains a specific version of a package. This is particularly useful when trying to find out why your project depends on lower versions.
48
49
 
49
50
  If \`-R,--recursive\` is set, the listing will go in depth and will list, for each workspaces, what are all the paths that lead to the dependency. Note that the display is somewhat optimized in that it will not print the package listing twice for a single package, so if you see a leaf named "Foo" when looking for "Bar", it means that "Foo" already got printed higher in the tree.
50
51
  `,
51
52
  examples: [[
52
53
  `Explain why lodash is used in your project`,
53
54
  `$0 why lodash`,
55
+ ], [
56
+ `Explain why version 3.3.1 of lodash is in your project`,
57
+ `$0 why lodash@3.3.1`,
58
+ ], [
59
+ `Explain why version 3.X of lodash is in your project`,
60
+ `$0 why lodash@^3`,
54
61
  ]],
55
62
  });
56
63
  exports.default = WhyCommand;
57
- function whySimple(project, identHash, { configuration, peers }) {
58
- const sortedPackages = core_3.miscUtils.sortMap(project.storedPackages.values(), pkg => {
59
- return core_3.structUtils.stringifyLocator(pkg);
64
+ function whySimple(project, targetPkg, { configuration, peers }) {
65
+ const sortedPackages = core_2.miscUtils.sortMap(project.storedPackages.values(), pkg => {
66
+ return core_2.structUtils.stringifyLocator(pkg);
60
67
  });
61
68
  const rootChildren = {};
62
69
  const root = { children: rootChildren };
@@ -72,24 +79,26 @@ function whySimple(project, identHash, { configuration, peers }) {
72
79
  const nextPkg = project.storedPackages.get(resolution);
73
80
  if (!nextPkg)
74
81
  throw new Error(`Assertion failed: The package should have been registered`);
75
- if (nextPkg.identHash !== identHash)
82
+ if (!core_2.structUtils.areIdentsEqual(nextPkg, targetPkg))
83
+ continue;
84
+ if (!core_2.structUtils.isPackageInRange(nextPkg, targetPkg.range))
76
85
  continue;
77
86
  if (node === null) {
78
- const key = core_3.structUtils.stringifyLocator(pkg);
79
- rootChildren[key] = { value: [pkg, core_1.formatUtils.Type.LOCATOR], children: nodeChildren };
87
+ const key = core_2.structUtils.stringifyLocator(pkg);
88
+ rootChildren[key] = { value: [pkg, core_2.formatUtils.Type.LOCATOR], children: nodeChildren };
80
89
  }
81
- const key = core_3.structUtils.stringifyLocator(nextPkg);
90
+ const key = core_2.structUtils.stringifyLocator(nextPkg);
82
91
  nodeChildren[key] = { value: [{
83
92
  descriptor: dependency,
84
93
  locator: nextPkg,
85
- }, core_1.formatUtils.Type.DEPENDENT] };
94
+ }, core_2.formatUtils.Type.DEPENDENT] };
86
95
  }
87
96
  }
88
97
  return root;
89
98
  }
90
- function whyRecursive(project, identHash, { configuration, peers }) {
91
- const sortedWorkspaces = core_3.miscUtils.sortMap(project.workspaces, workspace => {
92
- return core_3.structUtils.stringifyLocator(workspace.anchoredLocator);
99
+ function whyRecursive(project, targetPkg, { configuration, peers }) {
100
+ const sortedWorkspaces = core_2.miscUtils.sortMap(project.workspaces, workspace => {
101
+ return core_2.structUtils.stringifyLocator(workspace.anchoredLocator);
93
102
  });
94
103
  const seen = new Set();
95
104
  const dependents = new Set();
@@ -97,13 +106,11 @@ function whyRecursive(project, identHash, { configuration, peers }) {
97
106
  if (seen.has(pkg.locatorHash))
98
107
  return dependents.has(pkg.locatorHash);
99
108
  seen.add(pkg.locatorHash);
100
- if (pkg.identHash === identHash) {
109
+ if (core_2.structUtils.areIdentsEqual(pkg, targetPkg) && core_2.structUtils.isPackageInRange(pkg, targetPkg.range)) {
101
110
  dependents.add(pkg.locatorHash);
102
111
  return true;
103
112
  }
104
113
  let depends = false;
105
- if (pkg.identHash === identHash)
106
- depends = true;
107
114
  for (const dependency of pkg.dependencies.values()) {
108
115
  if (!peers && pkg.peerDependencies.has(dependency.identHash))
109
116
  continue;
@@ -130,14 +137,14 @@ function whyRecursive(project, identHash, { configuration, peers }) {
130
137
  if (!dependents.has(pkg.locatorHash))
131
138
  return;
132
139
  const nodeValue = dependency !== null
133
- ? core_1.formatUtils.tuple(core_1.formatUtils.Type.DEPENDENT, { locator: pkg, descriptor: dependency })
134
- : core_1.formatUtils.tuple(core_1.formatUtils.Type.LOCATOR, pkg);
140
+ ? core_2.formatUtils.tuple(core_2.formatUtils.Type.DEPENDENT, { locator: pkg, descriptor: dependency })
141
+ : core_2.formatUtils.tuple(core_2.formatUtils.Type.LOCATOR, pkg);
135
142
  const nodeChildren = {};
136
143
  const node = {
137
144
  value: nodeValue,
138
145
  children: nodeChildren,
139
146
  };
140
- const key = core_3.structUtils.stringifyLocator(pkg);
147
+ const key = core_2.structUtils.stringifyLocator(pkg);
141
148
  parentChildren[key] = node;
142
149
  // We don't want to print the children of our transitive workspace
143
150
  // dependencies, as they will be printed in their own top-level branch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yarnpkg/plugin-essentials",
3
- "version": "4.4.4",
3
+ "version": "4.5.0",
4
4
  "license": "BSD-2-Clause",
5
5
  "main": "./lib/index.js",
6
6
  "exports": {
@@ -8,7 +8,7 @@
8
8
  "./package.json": "./package.json"
9
9
  },
10
10
  "dependencies": {
11
- "@yarnpkg/fslib": "^3.1.3",
11
+ "@yarnpkg/fslib": "^3.1.5",
12
12
  "@yarnpkg/parsers": "^3.0.3",
13
13
  "ci-info": "^4.0.0",
14
14
  "clipanion": "^4.0.0-rc.2",
@@ -20,16 +20,16 @@
20
20
  "typanion": "^3.14.0"
21
21
  },
22
22
  "peerDependencies": {
23
- "@yarnpkg/cli": "^4.10.0",
24
- "@yarnpkg/core": "^4.4.4",
25
- "@yarnpkg/plugin-git": "^3.1.3"
23
+ "@yarnpkg/cli": "^4.14.0",
24
+ "@yarnpkg/core": "^4.7.0",
25
+ "@yarnpkg/plugin-git": "^3.2.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/micromatch": "^4.0.1",
29
29
  "@types/semver": "^7.1.0",
30
- "@yarnpkg/cli": "^4.10.0",
31
- "@yarnpkg/core": "^4.4.4",
32
- "@yarnpkg/plugin-git": "^3.1.3"
30
+ "@yarnpkg/cli": "^4.14.0",
31
+ "@yarnpkg/core": "^4.7.0",
32
+ "@yarnpkg/plugin-git": "^3.2.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",