@yarnpkg/plugin-essentials 4.1.1 → 4.2.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/explain/peerRequirements.d.ts +5 -3
- package/lib/commands/explain/peerRequirements.js +132 -76
- package/lib/commands/explain.js +1 -2
- package/lib/commands/plugin/import/sources.js +1 -2
- package/lib/commands/plugin/import.d.ts +0 -1
- package/lib/commands/plugin/import.js +1 -2
- package/lib/commands/plugin/list.js +1 -2
- package/lib/commands/set/version/sources.js +2 -3
- package/lib/commands/set/version.d.ts +0 -1
- package/lib/commands/set/version.js +3 -4
- package/lib/commands/why.js +4 -4
- package/lib/dedupeUtils.js +2 -2
- package/lib/suggestUtils.js +10 -10
- package/package.json +7 -7
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { BaseCommand } from '@yarnpkg/cli';
|
|
3
2
|
import { Project } from '@yarnpkg/core';
|
|
4
3
|
import { Writable } from 'stream';
|
|
5
4
|
export default class ExplainPeerRequirementsCommand extends BaseCommand {
|
|
6
5
|
static paths: string[][];
|
|
7
6
|
static usage: import("clipanion").Usage;
|
|
8
|
-
hash: string;
|
|
7
|
+
hash: string | undefined;
|
|
9
8
|
execute(): Promise<0 | 1>;
|
|
10
9
|
}
|
|
11
|
-
export declare function
|
|
10
|
+
export declare function explainPeerRequirement(peerRequirementsHash: string, project: Project, opts: {
|
|
11
|
+
stdout: Writable;
|
|
12
|
+
}): Promise<0 | 1>;
|
|
13
|
+
export declare function explainPeerRequirements(project: Project, opts: {
|
|
12
14
|
stdout: Writable;
|
|
13
15
|
}): Promise<0 | 1>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.explainPeerRequirement = explainPeerRequirement;
|
|
4
|
+
exports.explainPeerRequirements = explainPeerRequirements;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const cli_1 = require("@yarnpkg/cli");
|
|
6
7
|
const core_1 = require("@yarnpkg/core");
|
|
@@ -11,6 +12,7 @@ class ExplainPeerRequirementsCommand extends cli_1.BaseCommand {
|
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
13
14
|
this.hash = clipanion_1.Option.String({
|
|
15
|
+
required: false,
|
|
14
16
|
validator: t.cascade(t.isString(), [
|
|
15
17
|
t.matchesRegExp(/^p[0-9a-f]{5}$/),
|
|
16
18
|
]),
|
|
@@ -23,9 +25,16 @@ class ExplainPeerRequirementsCommand extends cli_1.BaseCommand {
|
|
|
23
25
|
restoreResolutions: false,
|
|
24
26
|
});
|
|
25
27
|
await project.applyLightResolution();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
if (typeof this.hash !== `undefined`) {
|
|
29
|
+
return await explainPeerRequirement(this.hash, project, {
|
|
30
|
+
stdout: this.context.stdout,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return await explainPeerRequirements(project, {
|
|
35
|
+
stdout: this.context.stdout,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
29
38
|
}
|
|
30
39
|
}
|
|
31
40
|
ExplainPeerRequirementsCommand.paths = [
|
|
@@ -34,29 +43,51 @@ ExplainPeerRequirementsCommand.paths = [
|
|
|
34
43
|
ExplainPeerRequirementsCommand.usage = clipanion_1.Command.Usage({
|
|
35
44
|
description: `explain a set of peer requirements`,
|
|
36
45
|
details: `
|
|
37
|
-
A
|
|
46
|
+
A peer requirement represents all peer requests that a subject must satisfy when providing a requested package to requesters.
|
|
38
47
|
|
|
39
|
-
When the hash argument is specified, this command prints a detailed explanation of
|
|
48
|
+
When the hash argument is specified, this command prints a detailed explanation of the peer requirement corresponding to the hash and whether it is satisfied or not.
|
|
40
49
|
|
|
41
|
-
When used without arguments, this command lists all
|
|
50
|
+
When used without arguments, this command lists all peer requirements and the corresponding hash that can be used to get detailed information about a given requirement.
|
|
42
51
|
|
|
43
52
|
**Note:** A hash is a six-letter p-prefixed code that can be obtained from peer dependency warnings or from the list of all peer requirements (\`yarn explain peer-requirements\`).
|
|
44
53
|
`,
|
|
45
54
|
examples: [[
|
|
46
|
-
`Explain the corresponding
|
|
55
|
+
`Explain the corresponding peer requirement for a hash`,
|
|
47
56
|
`$0 explain peer-requirements p1a4ed`,
|
|
48
57
|
], [
|
|
49
|
-
`List all
|
|
58
|
+
`List all peer requirements`,
|
|
50
59
|
`$0 explain peer-requirements`,
|
|
51
60
|
]],
|
|
52
61
|
});
|
|
53
62
|
exports.default = ExplainPeerRequirementsCommand;
|
|
54
|
-
async function
|
|
63
|
+
async function explainPeerRequirement(peerRequirementsHash, project, opts) {
|
|
64
|
+
const root = project.peerRequirementNodes.get(peerRequirementsHash);
|
|
65
|
+
if (typeof root === `undefined`)
|
|
66
|
+
throw new Error(`No peerDependency requirements found for hash: "${peerRequirementsHash}"`);
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
const makeTreeNode = (request) => {
|
|
69
|
+
if (seen.has(request.requester.locatorHash)) {
|
|
70
|
+
return {
|
|
71
|
+
value: core_1.formatUtils.tuple(core_1.formatUtils.Type.DEPENDENT, { locator: request.requester, descriptor: request.descriptor }),
|
|
72
|
+
children: request.children.size > 0
|
|
73
|
+
? [{ value: core_1.formatUtils.tuple(core_1.formatUtils.Type.NO_HINT, `...`) }]
|
|
74
|
+
: [],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
seen.add(request.requester.locatorHash);
|
|
78
|
+
return {
|
|
79
|
+
value: core_1.formatUtils.tuple(core_1.formatUtils.Type.DEPENDENT, { locator: request.requester, descriptor: request.descriptor }),
|
|
80
|
+
children: Object.fromEntries(Array.from(request.children.values(), child => {
|
|
81
|
+
return [
|
|
82
|
+
core_1.structUtils.stringifyLocator(child.requester),
|
|
83
|
+
makeTreeNode(child),
|
|
84
|
+
];
|
|
85
|
+
})),
|
|
86
|
+
};
|
|
87
|
+
};
|
|
55
88
|
const warning = project.peerWarnings.find(warning => {
|
|
56
89
|
return warning.hash === peerRequirementsHash;
|
|
57
90
|
});
|
|
58
|
-
if (typeof warning === `undefined`)
|
|
59
|
-
throw new Error(`No peerDependency requirements found for hash: "${peerRequirementsHash}"`);
|
|
60
91
|
const report = await core_1.StreamReport.start({
|
|
61
92
|
configuration: project.configuration,
|
|
62
93
|
stdout: opts.stdout,
|
|
@@ -64,73 +95,98 @@ async function explainPeerRequirements(peerRequirementsHash, project, opts) {
|
|
|
64
95
|
includePrefix: false,
|
|
65
96
|
}, async (report) => {
|
|
66
97
|
const Marks = core_1.formatUtils.mark(project.configuration);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const mark = core_1.semverUtils.satisfiesWithPrereleases(warning.version, descriptor.range)
|
|
100
|
-
? Marks.Check
|
|
101
|
-
: Marks.Cross;
|
|
102
|
-
report.reportInfo(null, ` ${mark} ${core_1.structUtils.prettyLocator(project.configuration, link)} (via ${core_1.structUtils.prettyRange(project.configuration, descriptor.range)})`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
const allRanges = Array.from(warning.links.values(), locator => {
|
|
106
|
-
const pkg = project.storedPackages.get(locator.locatorHash);
|
|
107
|
-
if (typeof pkg === `undefined`)
|
|
108
|
-
throw new Error(`Assertion failed: Expected the package to be registered`);
|
|
109
|
-
const peerDependency = pkg.peerDependencies.get(warning.requested.identHash);
|
|
110
|
-
if (typeof peerDependency === `undefined`)
|
|
111
|
-
throw new Error(`Assertion failed: Expected the ident to be registered`);
|
|
112
|
-
return peerDependency.range;
|
|
113
|
-
});
|
|
114
|
-
if (allRanges.length > 1) {
|
|
115
|
-
const resolvedRange = core_1.semverUtils.simplifyRanges(allRanges);
|
|
116
|
-
report.reportSeparator();
|
|
117
|
-
if (resolvedRange === null) {
|
|
118
|
-
report.reportInfo(core_1.MessageName.UNNAMED, `Unfortunately, put together, we found no single range that can satisfy all those peer requirements.`);
|
|
119
|
-
report.reportInfo(core_1.MessageName.UNNAMED, `Your best option may be to try to upgrade some dependencies with ${core_1.formatUtils.pretty(project.configuration, `yarn up`, core_1.formatUtils.Type.CODE)}, or silence the warning via ${core_1.formatUtils.pretty(project.configuration, `logFilters`, core_1.formatUtils.Type.CODE)}.`);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
report.reportInfo(core_1.MessageName.UNNAMED, `Put together, the final range we computed is ${core_1.formatUtils.pretty(project.configuration, resolvedRange, core_1.formatUtils.Type.RANGE)}`);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
98
|
+
const mark = warning ? Marks.Cross : Marks.Check;
|
|
99
|
+
report.reportInfo(core_1.MessageName.UNNAMED, `Package ${core_1.formatUtils.pretty(project.configuration, root.subject, core_1.formatUtils.Type.LOCATOR)} is requested to provide ${core_1.formatUtils.pretty(project.configuration, root.ident, core_1.formatUtils.Type.IDENT)} by its descendants`);
|
|
100
|
+
report.reportSeparator();
|
|
101
|
+
report.reportInfo(core_1.MessageName.UNNAMED, core_1.formatUtils.pretty(project.configuration, root.subject, core_1.formatUtils.Type.LOCATOR));
|
|
102
|
+
core_1.treeUtils.emitTree({
|
|
103
|
+
children: Object.fromEntries(Array.from(root.requests.values(), request => {
|
|
104
|
+
return [
|
|
105
|
+
core_1.structUtils.stringifyLocator(request.requester),
|
|
106
|
+
makeTreeNode(request),
|
|
107
|
+
];
|
|
108
|
+
})),
|
|
109
|
+
}, {
|
|
110
|
+
configuration: project.configuration,
|
|
111
|
+
stdout: opts.stdout,
|
|
112
|
+
json: false,
|
|
113
|
+
});
|
|
114
|
+
report.reportSeparator();
|
|
115
|
+
if (root.provided.range === `missing:`) {
|
|
116
|
+
const problem = warning ? `` : ` , but all peer requests are optional`;
|
|
117
|
+
report.reportInfo(core_1.MessageName.UNNAMED, `${mark} Package ${core_1.formatUtils.pretty(project.configuration, root.subject, core_1.formatUtils.Type.LOCATOR)} does not provide ${core_1.formatUtils.pretty(project.configuration, root.ident, core_1.formatUtils.Type.IDENT)}${problem}.`);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const providedLocatorHash = project.storedResolutions.get(root.provided.descriptorHash);
|
|
121
|
+
if (!providedLocatorHash)
|
|
122
|
+
throw new Error(`Assertion failed: Expected the descriptor to be registered`);
|
|
123
|
+
const providedPackage = project.storedPackages.get(providedLocatorHash);
|
|
124
|
+
if (!providedPackage)
|
|
125
|
+
throw new Error(`Assertion failed: Expected the package to be registered`);
|
|
126
|
+
report.reportInfo(core_1.MessageName.UNNAMED, `${mark} Package ${core_1.formatUtils.pretty(project.configuration, root.subject, core_1.formatUtils.Type.LOCATOR)} provides ${core_1.formatUtils.pretty(project.configuration, root.ident, core_1.formatUtils.Type.IDENT)} with version ${core_1.structUtils.prettyReference(project.configuration, providedPackage.version ?? `0.0.0`)}, ${warning ? `which does not satisfy all requests.` : `which satisfies all requests`}`);
|
|
127
|
+
if (warning?.type === core_1.PeerWarningType.NodeNotCompatible) {
|
|
128
|
+
if (warning.range) {
|
|
129
|
+
report.reportInfo(core_1.MessageName.UNNAMED, ` The combined requested range is ${core_1.formatUtils.pretty(project.configuration, warning.range, core_1.formatUtils.Type.RANGE)}`);
|
|
125
130
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
{
|
|
129
|
-
report.reportInfo(core_1.MessageName.UNNAMED, `The ${core_1.formatUtils.pretty(project.configuration, `yarn explain peer-requirements`, core_1.formatUtils.Type.CODE)} command doesn't support this warning type yet.`);
|
|
131
|
+
else {
|
|
132
|
+
report.reportInfo(core_1.MessageName.UNNAMED, ` Unfortunately, the requested ranges have no overlap`);
|
|
130
133
|
}
|
|
131
|
-
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return report.exitCode();
|
|
138
|
+
}
|
|
139
|
+
async function explainPeerRequirements(project, opts) {
|
|
140
|
+
const report = await core_1.StreamReport.start({
|
|
141
|
+
configuration: project.configuration,
|
|
142
|
+
stdout: opts.stdout,
|
|
143
|
+
includeFooter: false,
|
|
144
|
+
includePrefix: false,
|
|
145
|
+
}, async (report) => {
|
|
146
|
+
const Marks = core_1.formatUtils.mark(project.configuration);
|
|
147
|
+
const sorted = core_1.miscUtils.sortMap(project.peerRequirementNodes, [
|
|
148
|
+
([, requirement]) => core_1.structUtils.stringifyLocator(requirement.subject),
|
|
149
|
+
([, requirement]) => core_1.structUtils.stringifyIdent(requirement.ident),
|
|
150
|
+
]);
|
|
151
|
+
for (const [, peerRequirement] of sorted.values()) {
|
|
152
|
+
if (!peerRequirement.root)
|
|
153
|
+
continue;
|
|
154
|
+
const warning = project.peerWarnings.find(warning => {
|
|
155
|
+
return warning.hash === peerRequirement.hash;
|
|
156
|
+
});
|
|
157
|
+
const allRequests = [...core_1.structUtils.allPeerRequests(peerRequirement)];
|
|
158
|
+
let andOthers;
|
|
159
|
+
if (allRequests.length > 2)
|
|
160
|
+
andOthers = ` and ${allRequests.length - 1} other dependencies`;
|
|
161
|
+
else if (allRequests.length === 2)
|
|
162
|
+
andOthers = ` and 1 other dependency`;
|
|
163
|
+
else
|
|
164
|
+
andOthers = ``;
|
|
165
|
+
if (peerRequirement.provided.range !== `missing:`) {
|
|
166
|
+
const providedResolution = project.storedResolutions.get(peerRequirement.provided.descriptorHash);
|
|
167
|
+
if (!providedResolution)
|
|
168
|
+
throw new Error(`Assertion failed: Expected the resolution to have been registered`);
|
|
169
|
+
const providedPkg = project.storedPackages.get(providedResolution);
|
|
170
|
+
if (!providedPkg)
|
|
171
|
+
throw new Error(`Assertion failed: Expected the provided package to have been registered`);
|
|
172
|
+
const message = `${core_1.formatUtils.pretty(project.configuration, peerRequirement.hash, core_1.formatUtils.Type.CODE)} → ${warning ? Marks.Cross : Marks.Check} ${core_1.structUtils.prettyLocator(project.configuration, peerRequirement.subject)} provides ${core_1.structUtils.prettyLocator(project.configuration, providedPkg)} to ${core_1.structUtils.prettyLocator(project.configuration, allRequests[0].requester)}${andOthers}`;
|
|
173
|
+
if (warning) {
|
|
174
|
+
report.reportWarning(core_1.MessageName.UNNAMED, message);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
report.reportInfo(core_1.MessageName.UNNAMED, message);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const message = `${core_1.formatUtils.pretty(project.configuration, peerRequirement.hash, core_1.formatUtils.Type.CODE)} → ${warning ? Marks.Cross : Marks.Check} ${core_1.structUtils.prettyLocator(project.configuration, peerRequirement.subject)} doesn't provide ${core_1.structUtils.prettyIdent(project.configuration, peerRequirement.ident)} to ${core_1.structUtils.prettyLocator(project.configuration, allRequests[0].requester)}${andOthers}`;
|
|
182
|
+
if (warning) {
|
|
183
|
+
report.reportWarning(core_1.MessageName.UNNAMED, message);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
report.reportInfo(core_1.MessageName.UNNAMED, message);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
132
189
|
}
|
|
133
190
|
});
|
|
134
191
|
return report.exitCode();
|
|
135
192
|
}
|
|
136
|
-
exports.explainPeerRequirements = explainPeerRequirements;
|
package/lib/commands/explain.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getErrorCodeDetails =
|
|
3
|
+
exports.getErrorCodeDetails = getErrorCodeDetails;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const cli_1 = require("@yarnpkg/cli");
|
|
6
6
|
const core_1 = require("@yarnpkg/core");
|
|
@@ -26,7 +26,6 @@ async function getErrorCodeDetails(configuration) {
|
|
|
26
26
|
return [groups.code, groups.details];
|
|
27
27
|
}));
|
|
28
28
|
}
|
|
29
|
-
exports.getErrorCodeDetails = getErrorCodeDetails;
|
|
30
29
|
// eslint-disable-next-line arca/no-default-export
|
|
31
30
|
class ExplainCommand extends cli_1.BaseCommand {
|
|
32
31
|
constructor() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildAndSavePlugin =
|
|
3
|
+
exports.buildAndSavePlugin = buildAndSavePlugin;
|
|
4
4
|
const cli_1 = require("@yarnpkg/cli");
|
|
5
5
|
const core_1 = require("@yarnpkg/core");
|
|
6
6
|
const core_2 = require("@yarnpkg/core");
|
|
@@ -91,4 +91,3 @@ async function buildAndSavePlugin(pluginSpec, { context, noMinify }, { project,
|
|
|
91
91
|
const pluginBuffer = await fslib_1.xfs.readFilePromise(pluginPath);
|
|
92
92
|
await (0, import_1.savePlugin)(pluginSpec, pluginBuffer, { project, report });
|
|
93
93
|
}
|
|
94
|
-
exports.buildAndSavePlugin = buildAndSavePlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.savePlugin =
|
|
3
|
+
exports.savePlugin = savePlugin;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const cli_1 = require("@yarnpkg/cli");
|
|
6
6
|
const core_1 = require("@yarnpkg/core");
|
|
@@ -133,4 +133,3 @@ async function savePlugin(pluginSpec, pluginBuffer, { checksum = true, project,
|
|
|
133
133
|
pluginMeta.checksum = core_2.hashUtils.makeHash(pluginBuffer);
|
|
134
134
|
await core_1.Configuration.addPlugin(project.cwd, [pluginMeta]);
|
|
135
135
|
}
|
|
136
|
-
exports.savePlugin = savePlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAvailablePlugins =
|
|
3
|
+
exports.getAvailablePlugins = getAvailablePlugins;
|
|
4
4
|
const cli_1 = require("@yarnpkg/cli");
|
|
5
5
|
const core_1 = require("@yarnpkg/core");
|
|
6
6
|
const parsers_1 = require("@yarnpkg/parsers");
|
|
@@ -13,7 +13,6 @@ async function getAvailablePlugins(configuration, version) {
|
|
|
13
13
|
return !version || core_1.semverUtils.satisfiesWithPrereleases(version, pluginData.range ?? `<4.0.0-rc.1`);
|
|
14
14
|
}));
|
|
15
15
|
}
|
|
16
|
-
exports.getAvailablePlugins = getAvailablePlugins;
|
|
17
16
|
// eslint-disable-next-line arca/no-default-export
|
|
18
17
|
class PluginListCommand extends cli_1.BaseCommand {
|
|
19
18
|
constructor() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.runWorkflow = runWorkflow;
|
|
4
|
+
exports.prepareRepo = prepareRepo;
|
|
4
5
|
const cli_1 = require("@yarnpkg/cli");
|
|
5
6
|
const core_1 = require("@yarnpkg/core");
|
|
6
7
|
const fslib_1 = require("@yarnpkg/fslib");
|
|
@@ -141,7 +142,6 @@ async function runWorkflow(workflow, { configuration, context, target }) {
|
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
|
-
exports.runWorkflow = runWorkflow;
|
|
145
145
|
async function prepareRepo(spec, { configuration, report, target }) {
|
|
146
146
|
let ready = false;
|
|
147
147
|
if (!spec.force && fslib_1.xfs.existsSync(fslib_1.ppath.join(target, `.git`))) {
|
|
@@ -164,7 +164,6 @@ async function prepareRepo(spec, { configuration, report, target }) {
|
|
|
164
164
|
await runWorkflow(cloneWorkflow(spec, target), { configuration, context: spec.context, target });
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
exports.prepareRepo = prepareRepo;
|
|
168
167
|
async function updatePlugins(context, version, { project, report, target }) {
|
|
169
168
|
const data = await (0, list_1.getAvailablePlugins)(project.configuration, version);
|
|
170
169
|
const contribPlugins = new Set(Object.keys(data));
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolveRange = resolveRange;
|
|
4
|
+
exports.resolveTag = resolveTag;
|
|
5
|
+
exports.setVersion = setVersion;
|
|
4
6
|
const tslib_1 = require("tslib");
|
|
5
7
|
const cli_1 = require("@yarnpkg/cli");
|
|
6
8
|
const core_1 = require("@yarnpkg/core");
|
|
@@ -146,14 +148,12 @@ async function resolveRange(configuration, request) {
|
|
|
146
148
|
// The tags on the website are sorted by semver descending
|
|
147
149
|
return candidates[0];
|
|
148
150
|
}
|
|
149
|
-
exports.resolveRange = resolveRange;
|
|
150
151
|
async function resolveTag(configuration, request) {
|
|
151
152
|
const data = await core_2.httpUtils.get(`https://repo.yarnpkg.com/tags`, { configuration, jsonResponse: true });
|
|
152
153
|
if (!data.latest[request])
|
|
153
154
|
throw new clipanion_1.UsageError(`Tag ${core_2.formatUtils.pretty(configuration, request, core_2.formatUtils.Type.RANGE)} not found`);
|
|
154
155
|
return data.latest[request];
|
|
155
156
|
}
|
|
156
|
-
exports.resolveTag = resolveTag;
|
|
157
157
|
async function setVersion(configuration, bundleVersion, fetchBuffer, { report, useYarnPath }) {
|
|
158
158
|
let bundleBuffer;
|
|
159
159
|
const ensureBuffer = async () => {
|
|
@@ -225,4 +225,3 @@ async function setVersion(configuration, bundleVersion, fetchBuffer, { report, u
|
|
|
225
225
|
bundleVersion: bundleVersion,
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
exports.setVersion = setVersion;
|
package/lib/commands/why.js
CHANGED
|
@@ -139,15 +139,15 @@ function whyRecursive(project, identHash, { configuration, peers }) {
|
|
|
139
139
|
};
|
|
140
140
|
const key = core_3.structUtils.stringifyLocator(pkg);
|
|
141
141
|
parentChildren[key] = node;
|
|
142
|
+
// We don't want to print the children of our transitive workspace
|
|
143
|
+
// dependencies, as they will be printed in their own top-level branch
|
|
144
|
+
if (dependency !== null && project.tryWorkspaceByLocator(pkg))
|
|
145
|
+
return;
|
|
142
146
|
// We don't want to reprint the children for a package that already got
|
|
143
147
|
// printed as part of another branch
|
|
144
148
|
if (printed.has(pkg.locatorHash))
|
|
145
149
|
return;
|
|
146
150
|
printed.add(pkg.locatorHash);
|
|
147
|
-
// We don't want to print the children of our transitive workspace
|
|
148
|
-
// dependencies, as they will be printed in their own top-level branch
|
|
149
|
-
if (dependency !== null && project.tryWorkspaceByLocator(pkg))
|
|
150
|
-
return;
|
|
151
151
|
for (const dependency of pkg.dependencies.values()) {
|
|
152
152
|
if (!peers && pkg.peerDependencies.has(dependency.identHash))
|
|
153
153
|
continue;
|
package/lib/dedupeUtils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.acceptedStrategies = exports.Strategy = void 0;
|
|
4
|
+
exports.dedupe = dedupe;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const core_1 = require("@yarnpkg/core");
|
|
6
7
|
const core_2 = require("@yarnpkg/core");
|
|
@@ -160,4 +161,3 @@ async function dedupe(project, { strategy, patterns, cache, report }) {
|
|
|
160
161
|
return dedupedPackageCount;
|
|
161
162
|
});
|
|
162
163
|
}
|
|
163
|
-
exports.dedupe = dedupe;
|
package/lib/suggestUtils.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Strategy = exports.WorkspaceModifier = exports.Modifier = exports.Target = void 0;
|
|
4
|
+
exports.getModifier = getModifier;
|
|
5
|
+
exports.extractRangeModifier = extractRangeModifier;
|
|
6
|
+
exports.applyModifier = applyModifier;
|
|
7
|
+
exports.toWorkspaceModifier = toWorkspaceModifier;
|
|
8
|
+
exports.makeWorkspaceDescriptor = makeWorkspaceDescriptor;
|
|
9
|
+
exports.findProjectDescriptors = findProjectDescriptors;
|
|
10
|
+
exports.extractDescriptorFromPath = extractDescriptorFromPath;
|
|
11
|
+
exports.getSuggestedDescriptors = getSuggestedDescriptors;
|
|
12
|
+
exports.fetchDescriptorFrom = fetchDescriptorFrom;
|
|
4
13
|
const tslib_1 = require("tslib");
|
|
5
14
|
const core_1 = require("@yarnpkg/core");
|
|
6
15
|
const core_2 = require("@yarnpkg/core");
|
|
@@ -62,20 +71,17 @@ function getModifier(flags, project) {
|
|
|
62
71
|
return Modifier.TILDE;
|
|
63
72
|
return project.configuration.get(`defaultSemverRangePrefix`);
|
|
64
73
|
}
|
|
65
|
-
exports.getModifier = getModifier;
|
|
66
74
|
const SIMPLE_SEMVER = /^([\^~]?)[0-9]+(?:\.[0-9]+){0,2}(?:-\S+)?$/;
|
|
67
75
|
function extractRangeModifier(range, { project }) {
|
|
68
76
|
const match = range.match(SIMPLE_SEMVER);
|
|
69
77
|
return match ? match[1] : project.configuration.get(`defaultSemverRangePrefix`);
|
|
70
78
|
}
|
|
71
|
-
exports.extractRangeModifier = extractRangeModifier;
|
|
72
79
|
function applyModifier(descriptor, modifier) {
|
|
73
80
|
let { protocol, source, params, selector } = core_2.structUtils.parseRange(descriptor.range);
|
|
74
81
|
if (semver_1.default.valid(selector))
|
|
75
82
|
selector = `${modifier}${descriptor.range}`;
|
|
76
83
|
return core_2.structUtils.makeDescriptor(descriptor, core_2.structUtils.makeRange({ protocol, source, params, selector }));
|
|
77
84
|
}
|
|
78
|
-
exports.applyModifier = applyModifier;
|
|
79
85
|
function toWorkspaceModifier(modifier) {
|
|
80
86
|
switch (modifier) {
|
|
81
87
|
case Modifier.CARET:
|
|
@@ -88,11 +94,9 @@ function toWorkspaceModifier(modifier) {
|
|
|
88
94
|
throw new Error(`Assertion failed: Unknown modifier: "${modifier}"`);
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
|
-
exports.toWorkspaceModifier = toWorkspaceModifier;
|
|
92
97
|
function makeWorkspaceDescriptor(workspace, modifier) {
|
|
93
98
|
return core_2.structUtils.makeDescriptor(workspace.anchoredDescriptor, `${WORKSPACE_PROTOCOL}${toWorkspaceModifier(modifier)}`);
|
|
94
99
|
}
|
|
95
|
-
exports.makeWorkspaceDescriptor = makeWorkspaceDescriptor;
|
|
96
100
|
async function findProjectDescriptors(ident, { project, target }) {
|
|
97
101
|
const matches = new Map();
|
|
98
102
|
const getDescriptorEntry = (descriptor) => {
|
|
@@ -135,7 +139,6 @@ async function findProjectDescriptors(ident, { project, target }) {
|
|
|
135
139
|
}
|
|
136
140
|
return matches;
|
|
137
141
|
}
|
|
138
|
-
exports.findProjectDescriptors = findProjectDescriptors;
|
|
139
142
|
async function extractDescriptorFromPath(path, { cwd, workspace }) {
|
|
140
143
|
// We use a temporary cache so that we don't pollute the project cache with temporary archives
|
|
141
144
|
return await makeTemporaryCache(async (cache) => {
|
|
@@ -164,7 +167,6 @@ async function extractDescriptorFromPath(path, { cwd, workspace }) {
|
|
|
164
167
|
return core_2.structUtils.makeDescriptor(manifest.name, path);
|
|
165
168
|
});
|
|
166
169
|
}
|
|
167
|
-
exports.extractDescriptorFromPath = extractDescriptorFromPath;
|
|
168
170
|
async function getSuggestedDescriptors(request, { project, workspace, cache, target, fixed, modifier, strategies, maxResults = Infinity }) {
|
|
169
171
|
if (!(maxResults >= 0))
|
|
170
172
|
throw new Error(`Invalid maxResults (${maxResults})`);
|
|
@@ -306,7 +308,6 @@ async function getSuggestedDescriptors(request, { project, workspace, cache, tar
|
|
|
306
308
|
rejections: rejected.slice(0, maxResults),
|
|
307
309
|
};
|
|
308
310
|
}
|
|
309
|
-
exports.getSuggestedDescriptors = getSuggestedDescriptors;
|
|
310
311
|
async function fetchDescriptorFrom(ident, range, { project, cache, workspace, preserveModifier = true, modifier }) {
|
|
311
312
|
const latestDescriptor = project.configuration.normalizeDependency(core_2.structUtils.makeDescriptor(ident, range));
|
|
312
313
|
const report = new core_1.ThrowReport();
|
|
@@ -354,7 +355,6 @@ async function fetchDescriptorFrom(ident, range, { project, cache, workspace, pr
|
|
|
354
355
|
}
|
|
355
356
|
return core_2.structUtils.makeDescriptor(bestLocator, core_2.structUtils.makeRange({ protocol, source, params, selector }));
|
|
356
357
|
}
|
|
357
|
-
exports.fetchDescriptorFrom = fetchDescriptorFrom;
|
|
358
358
|
async function makeTemporaryCache(cb) {
|
|
359
359
|
return await fslib_1.xfs.mktempPromise(async (cacheDir) => {
|
|
360
360
|
const configuration = core_1.Configuration.create(cacheDir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarnpkg/plugin-essentials",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"license": "BSD-2-Clause",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"./package.json": "./package.json"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@yarnpkg/fslib": "^3.0
|
|
12
|
-
"@yarnpkg/parsers": "^3.0.
|
|
11
|
+
"@yarnpkg/fslib": "^3.1.0",
|
|
12
|
+
"@yarnpkg/parsers": "^3.0.2",
|
|
13
13
|
"ci-info": "^3.2.0",
|
|
14
14
|
"clipanion": "^4.0.0-rc.2",
|
|
15
15
|
"enquirer": "^2.3.6",
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
"typanion": "^3.14.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@yarnpkg/cli": "^4.
|
|
24
|
-
"@yarnpkg/core": "^4.0
|
|
23
|
+
"@yarnpkg/cli": "^4.3.0",
|
|
24
|
+
"@yarnpkg/core": "^4.1.0",
|
|
25
25
|
"@yarnpkg/plugin-git": "^3.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/lodash": "^4.14.136",
|
|
29
29
|
"@types/micromatch": "^4.0.1",
|
|
30
30
|
"@types/semver": "^7.1.0",
|
|
31
|
-
"@yarnpkg/cli": "^4.
|
|
32
|
-
"@yarnpkg/core": "^4.0
|
|
31
|
+
"@yarnpkg/cli": "^4.3.0",
|
|
32
|
+
"@yarnpkg/core": "^4.1.0",
|
|
33
33
|
"@yarnpkg/plugin-git": "^3.0.0"
|
|
34
34
|
},
|
|
35
35
|
"repository": {
|