@yarnpkg/plugin-essentials 4.0.0-rc.15 → 4.0.0-rc.18
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 +24 -13
- package/package.json +9 -9
package/lib/commands/add.js
CHANGED
|
@@ -89,21 +89,24 @@ class AddCommand extends cli_1.BaseCommand {
|
|
|
89
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
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
|
|
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/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarnpkg/plugin-essentials",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.18",
|
|
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.18",
|
|
8
|
+
"@yarnpkg/parsers": "^3.0.0-rc.18",
|
|
9
9
|
"ci-info": "^3.2.0",
|
|
10
10
|
"clipanion": "^3.2.0-rc.10",
|
|
11
11
|
"enquirer": "^2.3.6",
|
|
@@ -16,17 +16,17 @@
|
|
|
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.18",
|
|
20
|
+
"@yarnpkg/core": "^4.0.0-rc.18",
|
|
21
|
+
"@yarnpkg/plugin-git": "^3.0.0-rc.18"
|
|
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.18",
|
|
28
|
+
"@yarnpkg/core": "^4.0.0-rc.18",
|
|
29
|
+
"@yarnpkg/plugin-git": "^3.0.0-rc.18"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|