@yarnpkg/plugin-essentials 4.4.5 → 4.6.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.
- package/lib/commands/add.d.ts +1 -0
- package/lib/commands/add.js +5 -0
- package/lib/commands/install.js +12 -0
- package/lib/commands/up.d.ts +1 -0
- package/lib/commands/up.js +7 -0
- package/lib/commands/why.js +31 -24
- package/package.json +7 -7
package/lib/commands/add.d.ts
CHANGED
package/lib/commands/add.js
CHANGED
|
@@ -46,6 +46,9 @@ class AddCommand extends cli_1.BaseCommand {
|
|
|
46
46
|
this.cached = clipanion_1.Option.Boolean(`--cached`, false, {
|
|
47
47
|
description: `Reuse the highest version already used somewhere within the project`,
|
|
48
48
|
});
|
|
49
|
+
this.noTimeGate = clipanion_1.Option.Boolean(`--no-time-gate`, false, {
|
|
50
|
+
description: `Disable the minimum release age check for this command`,
|
|
51
|
+
});
|
|
49
52
|
this.mode = clipanion_1.Option.String(`--mode`, {
|
|
50
53
|
description: `Change what artifacts installs generate`,
|
|
51
54
|
validator: t.isEnum(core_2.InstallMode),
|
|
@@ -55,6 +58,8 @@ class AddCommand extends cli_1.BaseCommand {
|
|
|
55
58
|
}
|
|
56
59
|
async execute() {
|
|
57
60
|
const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
|
|
61
|
+
if (this.noTimeGate)
|
|
62
|
+
configuration.useWithSource(`<cli>`, { npmMinimalAgeGate: `0` }, configuration.startingCwd, { overwrite: true });
|
|
58
63
|
const { project, workspace } = await core_2.Project.find(configuration, this.context.cwd);
|
|
59
64
|
const cache = await core_1.Cache.find(configuration);
|
|
60
65
|
if (!workspace)
|
package/lib/commands/install.js
CHANGED
|
@@ -21,6 +21,18 @@ 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,
|
|
32
|
+
}, {
|
|
33
|
+
selector: v => v < 10,
|
|
34
|
+
name: `npmMinimalAgeGate`,
|
|
35
|
+
value: `0`,
|
|
24
36
|
}];
|
|
25
37
|
// eslint-disable-next-line arca/no-default-export
|
|
26
38
|
class YarnCommand extends cli_1.BaseCommand {
|
package/lib/commands/up.d.ts
CHANGED
package/lib/commands/up.js
CHANGED
|
@@ -32,6 +32,9 @@ class UpCommand extends cli_1.BaseCommand {
|
|
|
32
32
|
this.recursive = clipanion_1.Option.Boolean(`-R,--recursive`, false, {
|
|
33
33
|
description: `Resolve again ALL resolutions for those packages`,
|
|
34
34
|
});
|
|
35
|
+
this.noTimeGate = clipanion_1.Option.Boolean(`--no-time-gate`, false, {
|
|
36
|
+
description: `Disable the minimum release age check for this command`,
|
|
37
|
+
});
|
|
35
38
|
this.mode = clipanion_1.Option.String(`--mode`, {
|
|
36
39
|
description: `Change what artifacts installs generate`,
|
|
37
40
|
validator: t.isEnum(core_2.InstallMode),
|
|
@@ -48,6 +51,8 @@ class UpCommand extends cli_1.BaseCommand {
|
|
|
48
51
|
}
|
|
49
52
|
async executeUpRecursive() {
|
|
50
53
|
const configuration = await core_3.Configuration.find(this.context.cwd, this.context.plugins);
|
|
54
|
+
if (this.noTimeGate)
|
|
55
|
+
configuration.useWithSource(`<cli>`, { npmMinimalAgeGate: `0` }, configuration.startingCwd, { overwrite: true });
|
|
51
56
|
const { project, workspace } = await core_2.Project.find(configuration, this.context.cwd);
|
|
52
57
|
const cache = await core_3.Cache.find(configuration);
|
|
53
58
|
if (!workspace)
|
|
@@ -84,6 +89,8 @@ class UpCommand extends cli_1.BaseCommand {
|
|
|
84
89
|
}
|
|
85
90
|
async executeUpClassic() {
|
|
86
91
|
const configuration = await core_3.Configuration.find(this.context.cwd, this.context.plugins);
|
|
92
|
+
if (this.noTimeGate)
|
|
93
|
+
configuration.useWithSource(`<cli>`, { npmMinimalAgeGate: `0` }, configuration.startingCwd, { overwrite: true });
|
|
87
94
|
const { project, workspace } = await core_2.Project.find(configuration, this.context.cwd);
|
|
88
95
|
const cache = await core_3.Cache.find(configuration);
|
|
89
96
|
if (!workspace)
|
package/lib/commands/why.js
CHANGED
|
@@ -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
|
|
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
|
|
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,
|
|
32
|
-
: whySimple(project,
|
|
33
|
-
|
|
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,
|
|
58
|
-
const sortedPackages =
|
|
59
|
-
return
|
|
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
|
|
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 =
|
|
79
|
-
rootChildren[key] = { value: [pkg,
|
|
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 =
|
|
90
|
+
const key = core_2.structUtils.stringifyLocator(nextPkg);
|
|
82
91
|
nodeChildren[key] = { value: [{
|
|
83
92
|
descriptor: dependency,
|
|
84
93
|
locator: nextPkg,
|
|
85
|
-
},
|
|
94
|
+
}, core_2.formatUtils.Type.DEPENDENT] };
|
|
86
95
|
}
|
|
87
96
|
}
|
|
88
97
|
return root;
|
|
89
98
|
}
|
|
90
|
-
function whyRecursive(project,
|
|
91
|
-
const sortedWorkspaces =
|
|
92
|
-
return
|
|
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.
|
|
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
|
-
?
|
|
134
|
-
:
|
|
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 =
|
|
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.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"license": "BSD-2-Clause",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
"typanion": "^3.14.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@yarnpkg/cli": "^4.
|
|
24
|
-
"@yarnpkg/core": "^4.
|
|
25
|
-
"@yarnpkg/plugin-git": "^3.
|
|
23
|
+
"@yarnpkg/cli": "^4.15.0",
|
|
24
|
+
"@yarnpkg/core": "^4.8.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.
|
|
31
|
-
"@yarnpkg/core": "^4.
|
|
32
|
-
"@yarnpkg/plugin-git": "^3.
|
|
30
|
+
"@yarnpkg/cli": "^4.15.0",
|
|
31
|
+
"@yarnpkg/core": "^4.8.0",
|
|
32
|
+
"@yarnpkg/plugin-git": "^3.2.0"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|