@yarnpkg/plugin-essentials 4.0.0-rc.12 → 4.0.0-rc.16
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.js +26 -15
- package/lib/commands/info.js +1 -1
- package/lib/commands/plugin/import.d.ts +0 -1
- package/lib/commands/remove.js +1 -1
- package/lib/commands/set/version.d.ts +0 -1
- package/lib/commands/set/version.js +2 -2
- package/lib/commands/up.js +2 -2
- package/lib/dedupeUtils.js +0 -1
- package/lib/suggestUtils.js +1 -1
- package/package.json +10 -10
package/lib/commands/add.js
CHANGED
|
@@ -86,24 +86,27 @@ class AddCommand extends cli_1.BaseCommand {
|
|
|
86
86
|
: core_3.structUtils.tryParseDescriptor(pseudoDescriptor);
|
|
87
87
|
const unsupportedPrefix = pseudoDescriptor.match(/^(https?:|git@github)/);
|
|
88
88
|
if (unsupportedPrefix)
|
|
89
|
-
throw new clipanion_1.UsageError(`It seems you are trying to add a package using a ${core_1.formatUtils.pretty(configuration, `${unsupportedPrefix[0]}...`, core_1.
|
|
89
|
+
throw new clipanion_1.UsageError(`It seems you are trying to add a package using a ${core_1.formatUtils.pretty(configuration, `${unsupportedPrefix[0]}...`, core_1.formatUtils.Type.RANGE)} url; we now require package names to be explicitly specified.\nTry running the command again with the package name prefixed: ${core_1.formatUtils.pretty(configuration, `yarn add`, core_1.formatUtils.Type.CODE)} ${core_1.formatUtils.pretty(configuration, core_3.structUtils.makeDescriptor(core_3.structUtils.makeIdent(null, `my-package`), `${unsupportedPrefix[0]}...`), core_1.formatUtils.Type.DESCRIPTOR)}`);
|
|
90
90
|
if (!request)
|
|
91
|
-
throw new clipanion_1.UsageError(`The ${core_1.formatUtils.pretty(configuration, pseudoDescriptor, core_1.
|
|
92
|
-
const
|
|
91
|
+
throw new clipanion_1.UsageError(`The ${core_1.formatUtils.pretty(configuration, pseudoDescriptor, core_1.formatUtils.Type.CODE)} string didn't match the required format (package-name@range). Did you perhaps forget to explicitly reference the package name?`);
|
|
92
|
+
const targetList = suggestTargetList(workspace, request, {
|
|
93
93
|
dev: this.dev,
|
|
94
94
|
peer: this.peer,
|
|
95
95
|
preferDev: this.preferDev,
|
|
96
96
|
optional: this.optional,
|
|
97
97
|
});
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
const results = await Promise.all(targetList.map(async (target) => {
|
|
99
|
+
const suggestedDescriptors = await suggestUtils.getSuggestedDescriptors(request, { project, workspace, cache, fixed, target, modifier, strategies, maxResults });
|
|
100
|
+
return { request, suggestedDescriptors, target };
|
|
101
|
+
}));
|
|
102
|
+
return results;
|
|
103
|
+
})).then(results => results.flat());
|
|
101
104
|
const checkReport = await core_1.LightReport.start({
|
|
102
105
|
configuration,
|
|
103
106
|
stdout: this.context.stdout,
|
|
104
107
|
suggestInstall: false,
|
|
105
108
|
}, async (report) => {
|
|
106
|
-
for (const
|
|
109
|
+
for (const { request, suggestedDescriptors: { suggestions, rejections } } of allSuggestions) {
|
|
107
110
|
const nonNullSuggestions = suggestions.filter(suggestion => {
|
|
108
111
|
return suggestion.descriptor !== null;
|
|
109
112
|
});
|
|
@@ -125,7 +128,7 @@ class AddCommand extends cli_1.BaseCommand {
|
|
|
125
128
|
let askedQuestions = false;
|
|
126
129
|
const afterWorkspaceDependencyAdditionList = [];
|
|
127
130
|
const afterWorkspaceDependencyReplacementList = [];
|
|
128
|
-
for (const
|
|
131
|
+
for (const { suggestedDescriptors: { suggestions }, target } of allSuggestions) {
|
|
129
132
|
let selected;
|
|
130
133
|
const nonNullSuggestions = suggestions.filter(suggestion => {
|
|
131
134
|
return suggestion.descriptor !== null;
|
|
@@ -262,7 +265,7 @@ AddCommand.usage = clipanion_1.Command.Usage({
|
|
|
262
265
|
`$0 add lodash-es@lodash/lodash#es`,
|
|
263
266
|
]],
|
|
264
267
|
});
|
|
265
|
-
function
|
|
268
|
+
function suggestTargetList(workspace, ident, { dev, peer, preferDev, optional }) {
|
|
266
269
|
const hasRegular = workspace.manifest[suggestUtils.Target.REGULAR].has(ident.identHash);
|
|
267
270
|
const hasDev = workspace.manifest[suggestUtils.Target.DEVELOPMENT].has(ident.identHash);
|
|
268
271
|
const hasPeer = workspace.manifest[suggestUtils.Target.PEER].has(ident.identHash);
|
|
@@ -276,13 +279,21 @@ function suggestTarget(workspace, ident, { dev, peer, preferDev, optional }) {
|
|
|
276
279
|
throw new clipanion_1.UsageError(`Package "${core_3.structUtils.prettyIdent(workspace.project.configuration, ident)}" is already listed as a peer dependency - remove the -O flag or add the -P flag or remove it from your peer dependencies first`);
|
|
277
280
|
if ((dev || preferDev) && optional)
|
|
278
281
|
throw new clipanion_1.UsageError(`Package "${core_3.structUtils.prettyIdent(workspace.project.configuration, ident)}" cannot simultaneously be a dev dependency and an optional dependency`);
|
|
282
|
+
// When the program executes this line, the command is expected to be legal
|
|
283
|
+
const targetList = [];
|
|
279
284
|
if (peer)
|
|
280
|
-
|
|
285
|
+
targetList.push(suggestUtils.Target.PEER);
|
|
281
286
|
if (dev || preferDev)
|
|
282
|
-
|
|
283
|
-
if (
|
|
284
|
-
|
|
287
|
+
targetList.push(suggestUtils.Target.DEVELOPMENT);
|
|
288
|
+
if (optional)
|
|
289
|
+
targetList.push(suggestUtils.Target.REGULAR);
|
|
290
|
+
// The user explicitly define the targets
|
|
291
|
+
if (targetList.length > 0)
|
|
292
|
+
return targetList;
|
|
293
|
+
// The user does not define the targets, find it from the `workspace.manifest`
|
|
285
294
|
if (hasDev)
|
|
286
|
-
return suggestUtils.Target.DEVELOPMENT;
|
|
287
|
-
|
|
295
|
+
return [suggestUtils.Target.DEVELOPMENT];
|
|
296
|
+
if (hasPeer)
|
|
297
|
+
return [suggestUtils.Target.PEER];
|
|
298
|
+
return [suggestUtils.Target.REGULAR];
|
|
288
299
|
}
|
package/lib/commands/info.js
CHANGED
|
@@ -160,7 +160,7 @@ 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) => {
|
package/lib/commands/remove.js
CHANGED
|
@@ -89,7 +89,7 @@ class RemoveCommand extends cli_1.BaseCommand {
|
|
|
89
89
|
? `any`
|
|
90
90
|
: `this`;
|
|
91
91
|
if (unreferencedPatterns.length > 0)
|
|
92
|
-
throw new clipanion_1.UsageError(`${patterns} ${core_1.formatUtils.prettyList(configuration, unreferencedPatterns, core_1.
|
|
92
|
+
throw new clipanion_1.UsageError(`${patterns} ${core_1.formatUtils.prettyList(configuration, unreferencedPatterns, core_1.formatUtils.Type.CODE)} ${dont} match any packages referenced by ${which} workspace`);
|
|
93
93
|
if (hasChanged) {
|
|
94
94
|
await configuration.triggerMultipleHooks((hooks) => hooks.afterWorkspaceDependencyRemoval, afterWorkspaceDependencyRemovalList);
|
|
95
95
|
const report = await core_2.StreamReport.start({
|
|
@@ -61,11 +61,11 @@ class SetVersionCommand extends cli_1.BaseCommand {
|
|
|
61
61
|
const fetchBuffer = async () => {
|
|
62
62
|
const filePrefix = `file://`;
|
|
63
63
|
if (bundleRef.url.startsWith(filePrefix)) {
|
|
64
|
-
report.reportInfo(core_1.MessageName.UNNAMED, `Retrieving ${core_2.formatUtils.pretty(configuration, bundleRef.url,
|
|
64
|
+
report.reportInfo(core_1.MessageName.UNNAMED, `Retrieving ${core_2.formatUtils.pretty(configuration, bundleRef.url, core_2.formatUtils.Type.PATH)}`);
|
|
65
65
|
return await fslib_1.xfs.readFilePromise(bundleRef.url.slice(filePrefix.length));
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
68
|
-
report.reportInfo(core_1.MessageName.UNNAMED, `Downloading ${core_2.formatUtils.pretty(configuration, bundleRef.url,
|
|
68
|
+
report.reportInfo(core_1.MessageName.UNNAMED, `Downloading ${core_2.formatUtils.pretty(configuration, bundleRef.url, core_2.formatUtils.Type.URL)}`);
|
|
69
69
|
return await core_2.httpUtils.get(bundleRef.url, { configuration });
|
|
70
70
|
}
|
|
71
71
|
};
|
package/lib/commands/up.js
CHANGED
|
@@ -140,9 +140,9 @@ class UpCommand extends cli_1.BaseCommand {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
if (unreferencedPatterns.length > 1)
|
|
143
|
-
throw new clipanion_1.UsageError(`Patterns ${core_3.formatUtils.prettyList(configuration, unreferencedPatterns, core_3.
|
|
143
|
+
throw new clipanion_1.UsageError(`Patterns ${core_3.formatUtils.prettyList(configuration, unreferencedPatterns, core_3.formatUtils.Type.CODE)} don't match any packages referenced by any workspace`);
|
|
144
144
|
if (unreferencedPatterns.length > 0)
|
|
145
|
-
throw new clipanion_1.UsageError(`Pattern ${core_3.formatUtils.prettyList(configuration, unreferencedPatterns, core_3.
|
|
145
|
+
throw new clipanion_1.UsageError(`Pattern ${core_3.formatUtils.prettyList(configuration, unreferencedPatterns, core_3.formatUtils.Type.CODE)} doesn't match any packages referenced by any workspace`);
|
|
146
146
|
const allSuggestions = await Promise.all(allSuggestionsPromises);
|
|
147
147
|
const checkReport = await core_3.LightReport.start({
|
|
148
148
|
configuration,
|
package/lib/dedupeUtils.js
CHANGED
package/lib/suggestUtils.js
CHANGED
|
@@ -310,7 +310,7 @@ async function fetchDescriptorFrom(ident, range, { project, cache, workspace, pr
|
|
|
310
310
|
const report = new core_1.ThrowReport();
|
|
311
311
|
const fetcher = project.configuration.makeFetcher();
|
|
312
312
|
const resolver = project.configuration.makeResolver();
|
|
313
|
-
const fetchOptions = { project, fetcher, cache, checksums: project.storedChecksums, report, cacheOptions: { skipIntegrityCheck: true }
|
|
313
|
+
const fetchOptions = { project, fetcher, cache, checksums: project.storedChecksums, report, cacheOptions: { skipIntegrityCheck: true } };
|
|
314
314
|
const resolveOptions = { ...fetchOptions, resolver, fetchOptions };
|
|
315
315
|
// The descriptor has to be bound for the resolvers that need a parent locator. (e.g. FileResolver)
|
|
316
316
|
// If we didn't bind it, `yarn add ./folder` wouldn't work.
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarnpkg/plugin-essentials",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.16",
|
|
4
4
|
"license": "BSD-2-Clause",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@yarnpkg/fslib": "^3.0.0-rc.
|
|
8
|
-
"@yarnpkg/parsers": "^3.0.0-rc.
|
|
7
|
+
"@yarnpkg/fslib": "^3.0.0-rc.16",
|
|
8
|
+
"@yarnpkg/parsers": "^3.0.0-rc.16",
|
|
9
9
|
"ci-info": "^3.2.0",
|
|
10
10
|
"clipanion": "^3.2.0-rc.10",
|
|
11
11
|
"enquirer": "^2.3.6",
|
|
12
12
|
"lodash": "^4.17.15",
|
|
13
13
|
"micromatch": "^4.0.2",
|
|
14
14
|
"semver": "^7.1.2",
|
|
15
|
-
"tslib": "^
|
|
15
|
+
"tslib": "^2.4.0",
|
|
16
16
|
"typanion": "^3.3.0"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@yarnpkg/cli": "^4.0.0-rc.
|
|
20
|
-
"@yarnpkg/core": "^4.0.0-rc.
|
|
21
|
-
"@yarnpkg/plugin-git": "^3.0.0-rc.
|
|
19
|
+
"@yarnpkg/cli": "^4.0.0-rc.16",
|
|
20
|
+
"@yarnpkg/core": "^4.0.0-rc.16",
|
|
21
|
+
"@yarnpkg/plugin-git": "^3.0.0-rc.16"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/lodash": "^4.14.136",
|
|
25
25
|
"@types/micromatch": "^4.0.1",
|
|
26
26
|
"@types/semver": "^7.1.0",
|
|
27
|
-
"@yarnpkg/cli": "^4.0.0-rc.
|
|
28
|
-
"@yarnpkg/core": "^4.0.0-rc.
|
|
29
|
-
"@yarnpkg/plugin-git": "^3.0.0-rc.
|
|
27
|
+
"@yarnpkg/cli": "^4.0.0-rc.16",
|
|
28
|
+
"@yarnpkg/core": "^4.0.0-rc.16",
|
|
29
|
+
"@yarnpkg/plugin-git": "^3.0.0-rc.16"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|