@yarnpkg/plugin-essentials 4.0.0-rc.9 → 4.0.1
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 -1
- package/lib/commands/add.js +34 -25
- package/lib/commands/bin.d.ts +1 -1
- package/lib/commands/bin.js +1 -1
- package/lib/commands/cache/clean.d.ts +1 -1
- package/lib/commands/cache/clean.js +1 -1
- package/lib/commands/config/get.d.ts +2 -1
- package/lib/commands/config/get.js +4 -1
- package/lib/commands/config/set.d.ts +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/unset.d.ts +1 -1
- package/lib/commands/config/unset.js +1 -1
- package/lib/commands/config.d.ts +5 -3
- package/lib/commands/config.js +96 -39
- package/lib/commands/dedupe.d.ts +1 -1
- package/lib/commands/dedupe.js +7 -8
- package/lib/commands/entries/clipanion.js +1 -1
- package/lib/commands/entries/help.js +1 -1
- package/lib/commands/entries/version.js +1 -1
- package/lib/commands/exec.js +1 -1
- package/lib/commands/explain/peerRequirements.d.ts +3 -3
- package/lib/commands/explain/peerRequirements.js +75 -106
- package/lib/commands/explain.js +1 -1
- package/lib/commands/info.js +10 -18
- package/lib/commands/install.d.ts +1 -1
- package/lib/commands/install.js +245 -205
- package/lib/commands/link.d.ts +2 -2
- package/lib/commands/link.js +36 -32
- package/lib/commands/node.js +1 -1
- package/lib/commands/plugin/check.d.ts +8 -0
- package/lib/commands/plugin/check.js +61 -0
- package/lib/commands/plugin/import/sources.d.ts +3 -3
- package/lib/commands/plugin/import/sources.js +5 -5
- package/lib/commands/plugin/import.d.ts +5 -4
- package/lib/commands/plugin/import.js +15 -28
- package/lib/commands/plugin/list.d.ts +2 -2
- package/lib/commands/plugin/list.js +5 -6
- package/lib/commands/plugin/remove.d.ts +1 -1
- package/lib/commands/plugin/remove.js +14 -13
- package/lib/commands/plugin/runtime.d.ts +2 -2
- package/lib/commands/plugin/runtime.js +4 -4
- package/lib/commands/rebuild.d.ts +2 -2
- package/lib/commands/rebuild.js +10 -10
- package/lib/commands/remove.d.ts +1 -1
- package/lib/commands/remove.js +7 -8
- package/lib/commands/run.js +1 -1
- package/lib/commands/runIndex.d.ts +2 -2
- package/lib/commands/runIndex.js +3 -3
- package/lib/commands/set/resolution.d.ts +1 -1
- package/lib/commands/set/resolution.js +4 -6
- package/lib/commands/set/version/sources.d.ts +3 -2
- package/lib/commands/set/version/sources.js +21 -12
- package/lib/commands/set/version.d.ts +2 -3
- package/lib/commands/set/version.js +20 -16
- package/lib/commands/unlink.d.ts +1 -1
- package/lib/commands/unlink.js +7 -8
- package/lib/commands/up.d.ts +3 -3
- package/lib/commands/up.js +19 -17
- package/lib/commands/why.js +5 -13
- package/lib/commands/workspace.js +2 -5
- package/lib/commands/workspaces/list.d.ts +2 -1
- package/lib/commands/workspaces/list.js +8 -1
- package/lib/dedupeUtils.d.ts +3 -3
- package/lib/dedupeUtils.js +3 -5
- package/lib/index.d.ts +76 -1
- package/lib/index.js +40 -1
- package/lib/suggestUtils.d.ts +4 -4
- package/lib/suggestUtils.js +14 -12
- package/package.json +22 -17
|
@@ -11,8 +11,7 @@ class ExplainPeerRequirementsCommand extends cli_1.BaseCommand {
|
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments);
|
|
13
13
|
this.hash = clipanion_1.Option.String({
|
|
14
|
-
|
|
15
|
-
validator: t.applyCascade(t.isString(), [
|
|
14
|
+
validator: t.cascade(t.isString(), [
|
|
16
15
|
t.matchesRegExp(/^p[0-9a-f]{5}$/),
|
|
17
16
|
]),
|
|
18
17
|
});
|
|
@@ -23,46 +22,12 @@ class ExplainPeerRequirementsCommand extends cli_1.BaseCommand {
|
|
|
23
22
|
await project.restoreInstallState({
|
|
24
23
|
restoreResolutions: false,
|
|
25
24
|
});
|
|
26
|
-
// peerRequirements aren't stored inside the install state
|
|
27
25
|
await project.applyLightResolution();
|
|
28
|
-
|
|
29
|
-
return await explainPeerRequirements(this.hash, project, {
|
|
30
|
-
stdout: this.context.stdout,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
const report = await core_1.StreamReport.start({
|
|
34
|
-
configuration,
|
|
26
|
+
return await explainPeerRequirements(this.hash, project, {
|
|
35
27
|
stdout: this.context.stdout,
|
|
36
|
-
includeFooter: false,
|
|
37
|
-
}, async (report) => {
|
|
38
|
-
var _a;
|
|
39
|
-
const sortCriterias = [
|
|
40
|
-
([, requirement]) => core_1.structUtils.stringifyLocator(project.storedPackages.get(requirement.subject)),
|
|
41
|
-
([, requirement]) => core_1.structUtils.stringifyIdent(requirement.requested),
|
|
42
|
-
];
|
|
43
|
-
for (const [hash, requirement] of core_1.miscUtils.sortMap(project.peerRequirements, sortCriterias)) {
|
|
44
|
-
const subject = project.storedPackages.get(requirement.subject);
|
|
45
|
-
if (typeof subject === `undefined`)
|
|
46
|
-
throw new Error(`Assertion failed: Expected the subject package to have been registered`);
|
|
47
|
-
const rootRequester = project.storedPackages.get(requirement.rootRequester);
|
|
48
|
-
if (typeof rootRequester === `undefined`)
|
|
49
|
-
throw new Error(`Assertion failed: Expected the root package to have been registered`);
|
|
50
|
-
const providedDescriptor = (_a = subject.dependencies.get(requirement.requested.identHash)) !== null && _a !== void 0 ? _a : null;
|
|
51
|
-
const prettyHash = core_1.formatUtils.pretty(configuration, hash, core_1.formatUtils.Type.CODE);
|
|
52
|
-
const prettySubject = core_1.structUtils.prettyLocator(configuration, subject);
|
|
53
|
-
const prettyIdent = core_1.structUtils.prettyIdent(configuration, requirement.requested);
|
|
54
|
-
const prettyRoot = core_1.structUtils.prettyIdent(configuration, rootRequester);
|
|
55
|
-
const descendantCount = requirement.allRequesters.length - 1;
|
|
56
|
-
const pluralized = `descendant${descendantCount === 1 ? `` : `s`}`;
|
|
57
|
-
const maybeDescendants = descendantCount > 0 ? ` and ${descendantCount} ${pluralized}` : ``;
|
|
58
|
-
const provides = providedDescriptor !== null ? `provides` : `doesn't provide`;
|
|
59
|
-
report.reportInfo(null, `${prettyHash} → ${prettySubject} ${provides} ${prettyIdent} to ${prettyRoot}${maybeDescendants}`);
|
|
60
|
-
}
|
|
61
28
|
});
|
|
62
|
-
return report.exitCode();
|
|
63
29
|
}
|
|
64
30
|
}
|
|
65
|
-
exports.default = ExplainPeerRequirementsCommand;
|
|
66
31
|
ExplainPeerRequirementsCommand.paths = [
|
|
67
32
|
[`explain`, `peer-requirements`],
|
|
68
33
|
];
|
|
@@ -85,81 +50,85 @@ ExplainPeerRequirementsCommand.usage = clipanion_1.Command.Usage({
|
|
|
85
50
|
`$0 explain peer-requirements`,
|
|
86
51
|
]],
|
|
87
52
|
});
|
|
53
|
+
exports.default = ExplainPeerRequirementsCommand;
|
|
88
54
|
async function explainPeerRequirements(peerRequirementsHash, project, opts) {
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
55
|
+
const warning = project.peerWarnings.find(warning => {
|
|
56
|
+
return warning.hash === peerRequirementsHash;
|
|
57
|
+
});
|
|
58
|
+
if (typeof warning === `undefined`)
|
|
92
59
|
throw new Error(`No peerDependency requirements found for hash: "${peerRequirementsHash}"`);
|
|
93
60
|
const report = await core_1.StreamReport.start({
|
|
94
|
-
configuration,
|
|
61
|
+
configuration: project.configuration,
|
|
95
62
|
stdout: opts.stdout,
|
|
96
63
|
includeFooter: false,
|
|
64
|
+
includePrefix: false,
|
|
97
65
|
}, async (report) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
66
|
+
const Marks = core_1.formatUtils.mark(project.configuration);
|
|
67
|
+
switch (warning.type) {
|
|
68
|
+
case core_1.PeerWarningType.NotCompatibleAggregate:
|
|
69
|
+
{
|
|
70
|
+
report.reportInfo(core_1.MessageName.UNNAMED, `We have a problem with ${core_1.formatUtils.pretty(project.configuration, warning.requested, core_1.formatUtils.Type.IDENT)}, which is provided with version ${core_1.structUtils.prettyReference(project.configuration, warning.version)}.`);
|
|
71
|
+
report.reportInfo(core_1.MessageName.UNNAMED, `It is needed by the following direct dependencies of workspaces in your project:`);
|
|
72
|
+
report.reportSeparator();
|
|
73
|
+
for (const dependent of warning.requesters.values()) {
|
|
74
|
+
const dependentPkg = project.storedPackages.get(dependent.locatorHash);
|
|
75
|
+
if (!dependentPkg)
|
|
76
|
+
throw new Error(`Assertion failed: Expected the package to be registered`);
|
|
77
|
+
const descriptor = dependentPkg?.peerDependencies.get(warning.requested.identHash);
|
|
78
|
+
if (!descriptor)
|
|
79
|
+
throw new Error(`Assertion failed: Expected the package to list the peer dependency`);
|
|
80
|
+
const mark = core_1.semverUtils.satisfiesWithPrereleases(warning.version, descriptor.range)
|
|
81
|
+
? Marks.Check
|
|
82
|
+
: Marks.Cross;
|
|
83
|
+
report.reportInfo(null, ` ${mark} ${core_1.structUtils.prettyLocator(project.configuration, dependent)} (via ${core_1.structUtils.prettyRange(project.configuration, descriptor.range)})`);
|
|
84
|
+
}
|
|
85
|
+
const transitiveLinks = [...warning.links.values()].filter(link => {
|
|
86
|
+
return !warning.requesters.has(link.locatorHash);
|
|
87
|
+
});
|
|
88
|
+
if (transitiveLinks.length > 0) {
|
|
89
|
+
report.reportSeparator();
|
|
90
|
+
report.reportInfo(core_1.MessageName.UNNAMED, `However, those packages themselves have more dependencies listing ${core_1.structUtils.prettyIdent(project.configuration, warning.requested)} as peer dependency:`);
|
|
91
|
+
report.reportSeparator();
|
|
92
|
+
for (const link of transitiveLinks) {
|
|
93
|
+
const linkPkg = project.storedPackages.get(link.locatorHash);
|
|
94
|
+
if (!linkPkg)
|
|
95
|
+
throw new Error(`Assertion failed: Expected the package to be registered`);
|
|
96
|
+
const descriptor = linkPkg?.peerDependencies.get(warning.requested.identHash);
|
|
97
|
+
if (!descriptor)
|
|
98
|
+
throw new Error(`Assertion failed: Expected the package to list the peer dependency`);
|
|
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
|
+
}
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
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.`);
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
163
132
|
}
|
|
164
133
|
});
|
|
165
134
|
return report.exitCode();
|
package/lib/commands/explain.js
CHANGED
|
@@ -78,7 +78,6 @@ class ExplainCommand extends cli_1.BaseCommand {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
exports.default = ExplainCommand;
|
|
82
81
|
ExplainCommand.paths = [
|
|
83
82
|
[`explain`],
|
|
84
83
|
];
|
|
@@ -97,3 +96,4 @@ ExplainCommand.usage = clipanion_1.Command.Usage({
|
|
|
97
96
|
`$0 explain`,
|
|
98
97
|
]],
|
|
99
98
|
});
|
|
99
|
+
exports.default = ExplainCommand;
|
package/lib/commands/info.js
CHANGED
|
@@ -160,11 +160,10 @@ class InfoCommand extends cli_1.BaseCommand {
|
|
|
160
160
|
const infoTreeChildren = {};
|
|
161
161
|
const infoTree = { children: infoTreeChildren };
|
|
162
162
|
const fetcher = configuration.makeFetcher();
|
|
163
|
-
const fetcherOptions = { project, fetcher, cache, checksums: project.storedChecksums, report: new core_1.ThrowReport(), cacheOptions: { skipIntegrityCheck: true }
|
|
163
|
+
const fetcherOptions = { project, fetcher, cache, checksums: project.storedChecksums, report: new core_1.ThrowReport(), cacheOptions: { skipIntegrityCheck: true } };
|
|
164
164
|
const builtinInfoBuilders = [
|
|
165
165
|
// Manifest fields
|
|
166
166
|
async (pkg, extra, registerData) => {
|
|
167
|
-
var _a, _b;
|
|
168
167
|
if (!extra.has(`manifest`))
|
|
169
168
|
return;
|
|
170
169
|
const fetchResult = await fetcher.fetch(pkg, fetcherOptions);
|
|
@@ -173,28 +172,23 @@ class InfoCommand extends cli_1.BaseCommand {
|
|
|
173
172
|
manifest = await core_1.Manifest.find(fetchResult.prefixPath, { baseFs: fetchResult.packageFs });
|
|
174
173
|
}
|
|
175
174
|
finally {
|
|
176
|
-
|
|
175
|
+
fetchResult.releaseFs?.();
|
|
177
176
|
}
|
|
178
177
|
registerData(`Manifest`, {
|
|
179
178
|
[`License`]: core_1.formatUtils.tuple(core_1.formatUtils.Type.NO_HINT, manifest.license),
|
|
180
|
-
[`Homepage`]: core_1.formatUtils.tuple(core_1.formatUtils.Type.URL,
|
|
179
|
+
[`Homepage`]: core_1.formatUtils.tuple(core_1.formatUtils.Type.URL, manifest.raw.homepage ?? null),
|
|
181
180
|
});
|
|
182
181
|
},
|
|
183
182
|
// Cache info
|
|
184
183
|
async (pkg, extra, registerData) => {
|
|
185
|
-
var _a;
|
|
186
184
|
if (!extra.has(`cache`))
|
|
187
185
|
return;
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
unstablePackages: project.conditionalLocators,
|
|
191
|
-
};
|
|
192
|
-
const checksum = (_a = project.storedChecksums.get(pkg.locatorHash)) !== null && _a !== void 0 ? _a : null;
|
|
193
|
-
const cachePath = cache.getLocatorPath(pkg, checksum, cacheOptions);
|
|
186
|
+
const checksum = project.storedChecksums.get(pkg.locatorHash) ?? null;
|
|
187
|
+
const cachePath = cache.getLocatorPath(pkg, checksum);
|
|
194
188
|
let stat;
|
|
195
189
|
if (cachePath !== null) {
|
|
196
190
|
try {
|
|
197
|
-
stat = fslib_1.xfs.
|
|
191
|
+
stat = await fslib_1.xfs.statPromise(cachePath);
|
|
198
192
|
}
|
|
199
193
|
catch { }
|
|
200
194
|
}
|
|
@@ -272,10 +266,9 @@ class InfoCommand extends cli_1.BaseCommand {
|
|
|
272
266
|
}
|
|
273
267
|
if (pkg.dependencies.size > 0 && !isVirtual) {
|
|
274
268
|
registerData(`Dependencies`, [...pkg.dependencies.values()].map(dependency => {
|
|
275
|
-
var _a;
|
|
276
269
|
const resolutionHash = project.storedResolutions.get(dependency.descriptorHash);
|
|
277
270
|
const resolution = typeof resolutionHash !== `undefined`
|
|
278
|
-
?
|
|
271
|
+
? project.storedPackages.get(resolutionHash) ?? null
|
|
279
272
|
: null;
|
|
280
273
|
return core_1.formatUtils.tuple(core_1.formatUtils.Type.RESOLUTION, {
|
|
281
274
|
descriptor: dependency,
|
|
@@ -285,13 +278,12 @@ class InfoCommand extends cli_1.BaseCommand {
|
|
|
285
278
|
}
|
|
286
279
|
if (pkg.peerDependencies.size > 0 && isVirtual) {
|
|
287
280
|
registerData(`Peer dependencies`, [...pkg.peerDependencies.values()].map(peerDependency => {
|
|
288
|
-
var _a, _b;
|
|
289
281
|
const dependency = pkg.dependencies.get(peerDependency.identHash);
|
|
290
282
|
const resolutionHash = typeof dependency !== `undefined`
|
|
291
|
-
?
|
|
283
|
+
? project.storedResolutions.get(dependency.descriptorHash) ?? null
|
|
292
284
|
: null;
|
|
293
285
|
const resolution = resolutionHash !== null
|
|
294
|
-
?
|
|
286
|
+
? project.storedPackages.get(resolutionHash) ?? null
|
|
295
287
|
: null;
|
|
296
288
|
return core_1.formatUtils.tuple(core_1.formatUtils.Type.RESOLUTION, {
|
|
297
289
|
descriptor: peerDependency,
|
|
@@ -308,7 +300,6 @@ class InfoCommand extends cli_1.BaseCommand {
|
|
|
308
300
|
});
|
|
309
301
|
}
|
|
310
302
|
}
|
|
311
|
-
exports.default = InfoCommand;
|
|
312
303
|
InfoCommand.paths = [
|
|
313
304
|
[`info`],
|
|
314
305
|
];
|
|
@@ -328,3 +319,4 @@ InfoCommand.usage = clipanion_1.Command.Usage({
|
|
|
328
319
|
`$0 info lodash`,
|
|
329
320
|
]],
|
|
330
321
|
});
|
|
322
|
+
exports.default = InfoCommand;
|