@yarnpkg/plugin-essentials 4.0.0-rc.4 → 4.0.0-rc.41
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 +28 -17
- 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 +1 -1
- package/lib/commands/config/get.js +1 -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 +1 -1
- package/lib/commands/config.js +1 -1
- package/lib/commands/dedupe.d.ts +1 -1
- package/lib/commands/dedupe.js +2 -2
- 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 +2 -2
- package/lib/commands/explain/peerRequirements.js +1 -1
- package/lib/commands/explain.js +1 -1
- package/lib/commands/info.js +2 -2
- package/lib/commands/install.d.ts +1 -1
- package/lib/commands/install.js +60 -67
- package/lib/commands/link.d.ts +2 -2
- package/lib/commands/link.js +32 -26
- package/lib/commands/node.js +1 -1
- package/lib/commands/plugin/check.d.ts +8 -0
- package/lib/commands/plugin/check.js +62 -0
- package/lib/commands/plugin/import/sources.d.ts +3 -3
- package/lib/commands/plugin/import/sources.js +4 -4
- package/lib/commands/plugin/import.d.ts +5 -4
- package/lib/commands/plugin/import.js +14 -27
- package/lib/commands/plugin/list.d.ts +2 -2
- package/lib/commands/plugin/list.js +4 -4
- package/lib/commands/plugin/remove.d.ts +1 -1
- package/lib/commands/plugin/remove.js +1 -1
- 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 +4 -4
- package/lib/commands/remove.d.ts +1 -1
- package/lib/commands/remove.js +3 -3
- 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 +1 -1
- package/lib/commands/set/version/sources.d.ts +2 -2
- package/lib/commands/set/version/sources.js +1 -1
- package/lib/commands/set/version.d.ts +2 -3
- package/lib/commands/set/version.js +18 -12
- package/lib/commands/unlink.d.ts +1 -1
- package/lib/commands/unlink.js +1 -1
- package/lib/commands/up.d.ts +3 -3
- package/lib/commands/up.js +4 -4
- 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 +1 -2
- package/lib/index.d.ts +76 -1
- package/lib/index.js +40 -1
- package/lib/suggestUtils.d.ts +4 -4
- package/lib/suggestUtils.js +6 -6
- package/package.json +20 -14
package/lib/commands/add.d.ts
CHANGED
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;
|
|
@@ -209,7 +212,6 @@ class AddCommand extends cli_1.BaseCommand {
|
|
|
209
212
|
return installReport.exitCode();
|
|
210
213
|
}
|
|
211
214
|
}
|
|
212
|
-
exports.default = AddCommand;
|
|
213
215
|
AddCommand.paths = [
|
|
214
216
|
[`add`],
|
|
215
217
|
];
|
|
@@ -236,7 +238,7 @@ AddCommand.usage = clipanion_1.Command.Usage({
|
|
|
236
238
|
|
|
237
239
|
If the \`--mode=<mode>\` option is set, Yarn will change which artifacts are generated. The modes currently supported are:
|
|
238
240
|
|
|
239
|
-
- \`skip-build\` will not run the build scripts at all. Note that this is different from setting \`enableScripts\` to false because the
|
|
241
|
+
- \`skip-build\` will not run the build scripts at all. Note that this is different from setting \`enableScripts\` to false because the latter will disable build scripts, and thus affect the content of the artifacts generated on disk, whereas the former will just disable the build step - but not the scripts themselves, which just won't run.
|
|
240
242
|
|
|
241
243
|
- \`update-lockfile\` will skip the link step altogether, and only fetch packages that are missing from the lockfile (or that have no associated checksums). This mode is typically used by tools like Renovate or Dependabot to keep a lockfile up-to-date without incurring the full install cost.
|
|
242
244
|
|
|
@@ -262,7 +264,8 @@ AddCommand.usage = clipanion_1.Command.Usage({
|
|
|
262
264
|
`$0 add lodash-es@lodash/lodash#es`,
|
|
263
265
|
]],
|
|
264
266
|
});
|
|
265
|
-
|
|
267
|
+
exports.default = AddCommand;
|
|
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/bin.d.ts
CHANGED
package/lib/commands/bin.js
CHANGED
|
@@ -58,7 +58,6 @@ class BinCommand extends cli_1.BaseCommand {
|
|
|
58
58
|
return report.exitCode();
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
exports.default = BinCommand;
|
|
62
61
|
BinCommand.paths = [
|
|
63
62
|
[`bin`],
|
|
64
63
|
];
|
|
@@ -77,3 +76,4 @@ BinCommand.usage = clipanion_1.Command.Usage({
|
|
|
77
76
|
`$0 bin eslint`,
|
|
78
77
|
]],
|
|
79
78
|
});
|
|
79
|
+
exports.default = BinCommand;
|
|
@@ -35,7 +35,6 @@ class CacheCleanCommand extends cli_1.BaseCommand {
|
|
|
35
35
|
return report.exitCode();
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
exports.default = CacheCleanCommand;
|
|
39
38
|
CacheCleanCommand.paths = [
|
|
40
39
|
[`cache`, `clean`],
|
|
41
40
|
[`cache`, `clear`],
|
|
@@ -53,3 +52,4 @@ CacheCleanCommand.usage = clipanion_1.Command.Usage({
|
|
|
53
52
|
`$0 cache clean --mirror`,
|
|
54
53
|
]],
|
|
55
54
|
});
|
|
55
|
+
exports.default = CacheCleanCommand;
|
|
@@ -57,7 +57,6 @@ class ConfigGetCommand extends cli_1.BaseCommand {
|
|
|
57
57
|
return report.exitCode();
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
exports.default = ConfigGetCommand;
|
|
61
60
|
ConfigGetCommand.paths = [
|
|
62
61
|
[`config`, `get`],
|
|
63
62
|
];
|
|
@@ -85,3 +84,4 @@ ConfigGetCommand.usage = clipanion_1.Command.Usage({
|
|
|
85
84
|
`yarn config get packageExtensions --json`,
|
|
86
85
|
]],
|
|
87
86
|
});
|
|
87
|
+
exports.default = ConfigGetCommand;
|
|
@@ -79,7 +79,6 @@ class ConfigSetCommand extends cli_1.BaseCommand {
|
|
|
79
79
|
return report.exitCode();
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
exports.default = ConfigSetCommand;
|
|
83
82
|
ConfigSetCommand.paths = [
|
|
84
83
|
[`config`, `set`],
|
|
85
84
|
];
|
|
@@ -112,3 +111,4 @@ ConfigSetCommand.usage = clipanion_1.Command.Usage({
|
|
|
112
111
|
`yarn config set 'npmRegistries["//npm.example.com"].npmAuthToken' "ffffffff-ffff-ffff-ffff-ffffffffffff"`,
|
|
113
112
|
]],
|
|
114
113
|
});
|
|
114
|
+
exports.default = ConfigSetCommand;
|
|
@@ -57,7 +57,6 @@ class ConfigUnsetCommand extends cli_1.BaseCommand {
|
|
|
57
57
|
return report.exitCode();
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
exports.default = ConfigUnsetCommand;
|
|
61
60
|
ConfigUnsetCommand.paths = [
|
|
62
61
|
[`config`, `unset`],
|
|
63
62
|
];
|
|
@@ -77,3 +76,4 @@ ConfigUnsetCommand.usage = clipanion_1.Command.Usage({
|
|
|
77
76
|
`yarn config unset npmScopes.company.npmRegistryServer`,
|
|
78
77
|
]],
|
|
79
78
|
});
|
|
79
|
+
exports.default = ConfigUnsetCommand;
|
package/lib/commands/config.d.ts
CHANGED
package/lib/commands/config.js
CHANGED
|
@@ -85,7 +85,6 @@ class ConfigCommand extends cli_1.BaseCommand {
|
|
|
85
85
|
return report.exitCode();
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
exports.default = ConfigCommand;
|
|
89
88
|
ConfigCommand.paths = [
|
|
90
89
|
[`config`],
|
|
91
90
|
];
|
|
@@ -99,3 +98,4 @@ ConfigCommand.usage = clipanion_1.Command.Usage({
|
|
|
99
98
|
`$0 config`,
|
|
100
99
|
]],
|
|
101
100
|
});
|
|
101
|
+
exports.default = ConfigCommand;
|
package/lib/commands/dedupe.d.ts
CHANGED
package/lib/commands/dedupe.js
CHANGED
|
@@ -72,7 +72,6 @@ class DedupeCommand extends cli_1.BaseCommand {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
exports.default = DedupeCommand;
|
|
76
75
|
DedupeCommand.paths = [
|
|
77
76
|
[`dedupe`],
|
|
78
77
|
];
|
|
@@ -91,7 +90,7 @@ DedupeCommand.usage = clipanion_1.Command.Usage({
|
|
|
91
90
|
|
|
92
91
|
If the \`--mode=<mode>\` option is set, Yarn will change which artifacts are generated. The modes currently supported are:
|
|
93
92
|
|
|
94
|
-
- \`skip-build\` will not run the build scripts at all. Note that this is different from setting \`enableScripts\` to false because the
|
|
93
|
+
- \`skip-build\` will not run the build scripts at all. Note that this is different from setting \`enableScripts\` to false because the latter will disable build scripts, and thus affect the content of the artifacts generated on disk, whereas the former will just disable the build step - but not the scripts themselves, which just won't run.
|
|
95
94
|
|
|
96
95
|
- \`update-lockfile\` will skip the link step altogether, and only fetch packages that are missing from the lockfile (or that have no associated checksums). This mode is typically used by tools like Renovate or Dependabot to keep a lockfile up-to-date without incurring the full install cost.
|
|
97
96
|
|
|
@@ -124,3 +123,4 @@ DedupeCommand.usage = clipanion_1.Command.Usage({
|
|
|
124
123
|
`$0 dedupe --check`,
|
|
125
124
|
]],
|
|
126
125
|
});
|
|
126
|
+
exports.default = DedupeCommand;
|
|
@@ -33,7 +33,7 @@ class ClipanionCommand extends cli_1.BaseCommand {
|
|
|
33
33
|
this.context.stdout.write(`${JSON.stringify(clipanionDefinitions, null, 2)}\n`);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
exports.default = ClipanionCommand;
|
|
37
36
|
ClipanionCommand.paths = [
|
|
38
37
|
[`--clipanion=definitions`],
|
|
39
38
|
];
|
|
39
|
+
exports.default = ClipanionCommand;
|
|
@@ -8,8 +8,8 @@ class VersionCommand extends cli_1.BaseCommand {
|
|
|
8
8
|
this.context.stdout.write(`${core_1.YarnVersion || `<unknown>`}\n`);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
exports.default = VersionCommand;
|
|
12
11
|
VersionCommand.paths = [
|
|
13
12
|
[`-v`],
|
|
14
13
|
[`--version`],
|
|
15
14
|
];
|
|
15
|
+
exports.default = VersionCommand;
|
package/lib/commands/exec.js
CHANGED
|
@@ -24,7 +24,6 @@ class ExecCommand extends cli_1.BaseCommand {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
exports.default = ExecCommand;
|
|
28
27
|
ExecCommand.paths = [
|
|
29
28
|
[`exec`],
|
|
30
29
|
];
|
|
@@ -43,3 +42,4 @@ ExecCommand.usage = clipanion_1.Command.Usage({
|
|
|
43
42
|
`$0 exec "tsc & babel src --out-dir lib"`,
|
|
44
43
|
]],
|
|
45
44
|
});
|
|
45
|
+
exports.default = ExecCommand;
|
|
@@ -6,8 +6,8 @@ export default class ExplainPeerRequirementsCommand extends BaseCommand {
|
|
|
6
6
|
static paths: string[][];
|
|
7
7
|
static usage: import("clipanion").Usage;
|
|
8
8
|
hash: string | undefined;
|
|
9
|
-
execute(): Promise<
|
|
9
|
+
execute(): Promise<0 | 1>;
|
|
10
10
|
}
|
|
11
11
|
export declare function explainPeerRequirements(peerRequirementsHash: string, project: Project, opts: {
|
|
12
12
|
stdout: Writable;
|
|
13
|
-
}): Promise<
|
|
13
|
+
}): Promise<0 | 1>;
|
|
@@ -62,7 +62,6 @@ class ExplainPeerRequirementsCommand extends cli_1.BaseCommand {
|
|
|
62
62
|
return report.exitCode();
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
exports.default = ExplainPeerRequirementsCommand;
|
|
66
65
|
ExplainPeerRequirementsCommand.paths = [
|
|
67
66
|
[`explain`, `peer-requirements`],
|
|
68
67
|
];
|
|
@@ -85,6 +84,7 @@ ExplainPeerRequirementsCommand.usage = clipanion_1.Command.Usage({
|
|
|
85
84
|
`$0 explain peer-requirements`,
|
|
86
85
|
]],
|
|
87
86
|
});
|
|
87
|
+
exports.default = ExplainPeerRequirementsCommand;
|
|
88
88
|
async function explainPeerRequirements(peerRequirementsHash, project, opts) {
|
|
89
89
|
const { configuration } = project;
|
|
90
90
|
const requirement = project.peerRequirements.get(peerRequirementsHash);
|
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,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) => {
|
|
@@ -308,7 +308,6 @@ class InfoCommand extends cli_1.BaseCommand {
|
|
|
308
308
|
});
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
|
-
exports.default = InfoCommand;
|
|
312
311
|
InfoCommand.paths = [
|
|
313
312
|
[`info`],
|
|
314
313
|
];
|
|
@@ -328,3 +327,4 @@ InfoCommand.usage = clipanion_1.Command.Usage({
|
|
|
328
327
|
`$0 info lodash`,
|
|
329
328
|
]],
|
|
330
329
|
});
|
|
330
|
+
exports.default = InfoCommand;
|
package/lib/commands/install.js
CHANGED
|
@@ -256,7 +256,6 @@ class YarnCommand extends cli_1.BaseCommand {
|
|
|
256
256
|
return report.exitCode();
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
exports.default = YarnCommand;
|
|
260
259
|
YarnCommand.paths = [
|
|
261
260
|
[`install`],
|
|
262
261
|
clipanion_1.Command.Default,
|
|
@@ -288,7 +287,7 @@ YarnCommand.usage = clipanion_1.Command.Usage({
|
|
|
288
287
|
|
|
289
288
|
If the \`--mode=<mode>\` option is set, Yarn will change which artifacts are generated. The modes currently supported are:
|
|
290
289
|
|
|
291
|
-
- \`skip-build\` will not run the build scripts at all. Note that this is different from setting \`enableScripts\` to false because the
|
|
290
|
+
- \`skip-build\` will not run the build scripts at all. Note that this is different from setting \`enableScripts\` to false because the latter will disable build scripts, and thus affect the content of the artifacts generated on disk, whereas the former will just disable the build step - but not the scripts themselves, which just won't run.
|
|
292
291
|
|
|
293
292
|
- \`update-lockfile\` will skip the link step altogether, and only fetch packages that are missing from the lockfile (or that have no associated checksums). This mode is typically used by tools like Renovate or Dependabot to keep a lockfile up-to-date without incurring the full install cost.
|
|
294
293
|
`,
|
|
@@ -303,9 +302,7 @@ YarnCommand.usage = clipanion_1.Command.Usage({
|
|
|
303
302
|
`$0 install --immutable --immutable-cache --check-cache`,
|
|
304
303
|
]],
|
|
305
304
|
});
|
|
306
|
-
|
|
307
|
-
const MERGE_CONFLICT_END = `>>>>>>>`;
|
|
308
|
-
const MERGE_CONFLICT_SEP = `=======`;
|
|
305
|
+
exports.default = YarnCommand;
|
|
309
306
|
const MERGE_CONFLICT_START = `<<<<<<<`;
|
|
310
307
|
async function autofixMergeConflicts(configuration, immutable) {
|
|
311
308
|
if (!configuration.projectCwd)
|
|
@@ -318,22 +315,67 @@ async function autofixMergeConflicts(configuration, immutable) {
|
|
|
318
315
|
return false;
|
|
319
316
|
if (immutable)
|
|
320
317
|
throw new core_1.ReportError(core_1.MessageName.AUTOMERGE_IMMUTABLE, `Cannot autofix a lockfile when running an immutable install`);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
318
|
+
let commits = await core_1.execUtils.execvp(`git`, [`rev-parse`, `MERGE_HEAD`, `HEAD`], {
|
|
319
|
+
cwd: configuration.projectCwd,
|
|
320
|
+
});
|
|
321
|
+
if (commits.code !== 0) {
|
|
322
|
+
commits = await core_1.execUtils.execvp(`git`, [`rev-parse`, `REBASE_HEAD`, `HEAD`], {
|
|
323
|
+
cwd: configuration.projectCwd,
|
|
324
|
+
});
|
|
327
325
|
}
|
|
328
|
-
|
|
329
|
-
|
|
326
|
+
if (commits.code !== 0) {
|
|
327
|
+
commits = await core_1.execUtils.execvp(`git`, [`rev-parse`, `CHERRY_PICK_HEAD`, `HEAD`], {
|
|
328
|
+
cwd: configuration.projectCwd,
|
|
329
|
+
});
|
|
330
330
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
331
|
+
if (commits.code !== 0)
|
|
332
|
+
throw new core_1.ReportError(core_1.MessageName.AUTOMERGE_GIT_ERROR, `Git returned an error when trying to find the commits pertaining to the conflict`);
|
|
333
|
+
let variants = await Promise.all(commits.stdout.trim().split(/\n/).map(async (hash) => {
|
|
334
|
+
const content = await core_1.execUtils.execvp(`git`, [`show`, `${hash}:./${fslib_1.Filename.lockfile}`], {
|
|
335
|
+
cwd: configuration.projectCwd,
|
|
336
|
+
});
|
|
337
|
+
if (content.code !== 0)
|
|
338
|
+
throw new core_1.ReportError(core_1.MessageName.AUTOMERGE_GIT_ERROR, `Git returned an error when trying to access the lockfile content in ${hash}`);
|
|
339
|
+
try {
|
|
340
|
+
return (0, parsers_1.parseSyml)(content.stdout);
|
|
341
|
+
}
|
|
342
|
+
catch {
|
|
343
|
+
throw new core_1.ReportError(core_1.MessageName.AUTOMERGE_FAILED_TO_PARSE, `A variant of the conflicting lockfile failed to parse`);
|
|
344
|
+
}
|
|
345
|
+
}));
|
|
335
346
|
// Old-style lockfiles should be filtered out (for example when switching
|
|
336
|
-
// from a Yarn 2 branch to a Yarn 1 branch).
|
|
347
|
+
// from a Yarn 2 branch to a Yarn 1 branch).
|
|
348
|
+
variants = variants.filter(variant => {
|
|
349
|
+
return !!variant.__metadata;
|
|
350
|
+
});
|
|
351
|
+
for (const variant of variants) {
|
|
352
|
+
// Pre-lockfile v7, the entries weren't normalized (ie we had "foo@x.y.z"
|
|
353
|
+
// in the lockfile rather than "foo@npm:x.y.z")
|
|
354
|
+
if (variant.__metadata.version < 7) {
|
|
355
|
+
for (const key of Object.keys(variant)) {
|
|
356
|
+
if (key === `__metadata`)
|
|
357
|
+
continue;
|
|
358
|
+
const descriptor = core_1.structUtils.parseDescriptor(key, true);
|
|
359
|
+
const normalizedDescriptor = configuration.normalizeDependency(descriptor);
|
|
360
|
+
const newKey = core_1.structUtils.stringifyDescriptor(normalizedDescriptor);
|
|
361
|
+
if (newKey !== key) {
|
|
362
|
+
variant[newKey] = variant[key];
|
|
363
|
+
delete variant[key];
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const merged = Object.assign({}, ...variants);
|
|
369
|
+
// We must keep the lockfile version as small as necessary to force Yarn to
|
|
370
|
+
// refresh the merged-in lockfile metadata that may be missing.
|
|
371
|
+
merged.__metadata.version = Math.min(0, ...variants.map(variant => {
|
|
372
|
+
var _a;
|
|
373
|
+
return (_a = variant.__metadata.version) !== null && _a !== void 0 ? _a : Infinity;
|
|
374
|
+
}));
|
|
375
|
+
merged.__metadata.cacheKey = Math.min(0, ...variants.map(variant => {
|
|
376
|
+
var _a;
|
|
377
|
+
return (_a = variant.__metadata.cacheKey) !== null && _a !== void 0 ? _a : 0;
|
|
378
|
+
}));
|
|
337
379
|
// parse as valid YAML except that the objects become strings. We can use
|
|
338
380
|
// that to detect them. Damn, it's really ugly though.
|
|
339
381
|
for (const [key, value] of Object.entries(merged))
|
|
@@ -344,52 +386,3 @@ async function autofixMergeConflicts(configuration, immutable) {
|
|
|
344
386
|
});
|
|
345
387
|
return true;
|
|
346
388
|
}
|
|
347
|
-
function getVariants(file) {
|
|
348
|
-
const variants = [[], []];
|
|
349
|
-
const lines = file.split(/\r?\n/g);
|
|
350
|
-
let skip = false;
|
|
351
|
-
while (lines.length > 0) {
|
|
352
|
-
const line = lines.shift();
|
|
353
|
-
if (typeof line === `undefined`)
|
|
354
|
-
throw new Error(`Assertion failed: Some lines should remain`);
|
|
355
|
-
if (line.startsWith(MERGE_CONFLICT_START)) {
|
|
356
|
-
// get the first variant
|
|
357
|
-
while (lines.length > 0) {
|
|
358
|
-
const conflictLine = lines.shift();
|
|
359
|
-
if (typeof conflictLine === `undefined`)
|
|
360
|
-
throw new Error(`Assertion failed: Some lines should remain`);
|
|
361
|
-
if (conflictLine === MERGE_CONFLICT_SEP) {
|
|
362
|
-
skip = false;
|
|
363
|
-
break;
|
|
364
|
-
}
|
|
365
|
-
else if (skip || conflictLine.startsWith(MERGE_CONFLICT_ANCESTOR)) {
|
|
366
|
-
skip = true;
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
else {
|
|
370
|
-
variants[0].push(conflictLine);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
// get the second variant
|
|
374
|
-
while (lines.length > 0) {
|
|
375
|
-
const conflictLine = lines.shift();
|
|
376
|
-
if (typeof conflictLine === `undefined`)
|
|
377
|
-
throw new Error(`Assertion failed: Some lines should remain`);
|
|
378
|
-
if (conflictLine.startsWith(MERGE_CONFLICT_END)) {
|
|
379
|
-
break;
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
382
|
-
variants[1].push(conflictLine);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
else {
|
|
387
|
-
variants[0].push(line);
|
|
388
|
-
variants[1].push(line);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
return [
|
|
392
|
-
variants[0].join(`\n`),
|
|
393
|
-
variants[1].join(`\n`),
|
|
394
|
-
];
|
|
395
|
-
}
|
package/lib/commands/link.d.ts
CHANGED