@yarnpkg/plugin-essentials 3.3.0 → 3.5.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.
Files changed (44) hide show
  1. package/lib/commands/add.js +11 -10
  2. package/lib/commands/bin.js +1 -1
  3. package/lib/commands/cache/clean.js +1 -1
  4. package/lib/commands/config/get.js +1 -1
  5. package/lib/commands/config/set.js +1 -1
  6. package/lib/commands/config/unset.js +1 -1
  7. package/lib/commands/config.js +1 -1
  8. package/lib/commands/dedupe.js +1 -1
  9. package/lib/commands/entries/clipanion.js +1 -1
  10. package/lib/commands/entries/help.js +1 -1
  11. package/lib/commands/entries/version.js +1 -1
  12. package/lib/commands/exec.js +1 -1
  13. package/lib/commands/explain/peerRequirements.js +1 -1
  14. package/lib/commands/explain.js +1 -1
  15. package/lib/commands/info.js +1 -1
  16. package/lib/commands/install.js +1 -1
  17. package/lib/commands/link.d.ts +1 -1
  18. package/lib/commands/link.js +32 -26
  19. package/lib/commands/node.js +1 -1
  20. package/lib/commands/plugin/import/sources.js +1 -1
  21. package/lib/commands/plugin/import.d.ts +0 -1
  22. package/lib/commands/plugin/import.js +1 -1
  23. package/lib/commands/plugin/list.js +1 -1
  24. package/lib/commands/plugin/remove.js +1 -1
  25. package/lib/commands/plugin/runtime.js +1 -1
  26. package/lib/commands/rebuild.js +1 -1
  27. package/lib/commands/remove.js +2 -2
  28. package/lib/commands/run.d.ts +1 -0
  29. package/lib/commands/run.js +6 -1
  30. package/lib/commands/runIndex.js +1 -1
  31. package/lib/commands/set/resolution.js +1 -1
  32. package/lib/commands/set/version/sources.js +1 -1
  33. package/lib/commands/set/version.d.ts +0 -1
  34. package/lib/commands/set/version.js +4 -4
  35. package/lib/commands/unlink.js +1 -1
  36. package/lib/commands/up.js +4 -4
  37. package/lib/commands/why.js +1 -1
  38. package/lib/commands/workspace.js +1 -1
  39. package/lib/commands/workspaces/list.js +1 -1
  40. package/lib/dedupeUtils.js +1 -1
  41. package/lib/index.d.ts +1 -0
  42. package/lib/index.js +5 -0
  43. package/lib/suggestUtils.js +4 -4
  44. package/package.json +9 -11
@@ -61,17 +61,18 @@ class AddCommand extends cli_1.BaseCommand {
61
61
  restoreResolutions: false,
62
62
  });
63
63
  const interactive = (_a = this.interactive) !== null && _a !== void 0 ? _a : configuration.get(`preferInteractive`);
64
+ const reuse = interactive || configuration.get(`preferReuse`);
64
65
  const modifier = suggestUtils.getModifier(this, project);
65
66
  const strategies = [
66
- ...interactive ? [
67
- suggestUtils.Strategy.REUSE,
68
- ] : [],
67
+ reuse ?
68
+ suggestUtils.Strategy.REUSE
69
+ : undefined,
69
70
  suggestUtils.Strategy.PROJECT,
70
- ...this.cached ? [
71
- suggestUtils.Strategy.CACHE,
72
- ] : [],
71
+ this.cached ?
72
+ suggestUtils.Strategy.CACHE
73
+ : undefined,
73
74
  suggestUtils.Strategy.LATEST,
74
- ];
75
+ ].filter((strategy) => typeof strategy !== `undefined`);
75
76
  const maxResults = interactive
76
77
  ? Infinity
77
78
  : 1;
@@ -81,9 +82,9 @@ class AddCommand extends cli_1.BaseCommand {
81
82
  : core_3.structUtils.tryParseDescriptor(pseudoDescriptor);
82
83
  const unsupportedPrefix = pseudoDescriptor.match(/^(https?:|git@github)/);
83
84
  if (unsupportedPrefix)
84
- 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.FormatType.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.FormatType.CODE)} ${core_1.formatUtils.pretty(configuration, core_3.structUtils.makeDescriptor(core_3.structUtils.makeIdent(null, `my-package`), `${unsupportedPrefix[0]}...`), core_1.FormatType.DESCRIPTOR)}`);
85
+ 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)}`);
85
86
  if (!request)
86
- throw new clipanion_1.UsageError(`The ${core_1.formatUtils.pretty(configuration, pseudoDescriptor, core_1.FormatType.CODE)} string didn't match the required format (package-name@range). Did you perhaps forget to explicitly reference the package name?`);
87
+ 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?`);
87
88
  const targetList = suggestTargetList(workspace, request, {
88
89
  dev: this.dev,
89
90
  peer: this.peer,
@@ -207,7 +208,6 @@ class AddCommand extends cli_1.BaseCommand {
207
208
  return installReport.exitCode();
208
209
  }
209
210
  }
210
- exports.default = AddCommand;
211
211
  AddCommand.paths = [
212
212
  [`add`],
213
213
  ];
@@ -260,6 +260,7 @@ AddCommand.usage = clipanion_1.Command.Usage({
260
260
  `$0 add lodash-es@lodash/lodash#es`,
261
261
  ]],
262
262
  });
263
+ exports.default = AddCommand;
263
264
  function suggestTargetList(workspace, ident, { dev, peer, preferDev, optional }) {
264
265
  const hasRegular = workspace.manifest[suggestUtils.Target.REGULAR].has(ident.identHash);
265
266
  const hasDev = workspace.manifest[suggestUtils.Target.DEVELOPMENT].has(ident.identHash);
@@ -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;
@@ -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;
@@ -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
  ];
@@ -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;
@@ -7,9 +7,9 @@ class HelpCommand extends cli_1.BaseCommand {
7
7
  this.context.stdout.write(this.cli.usage(null));
8
8
  }
9
9
  }
10
- exports.default = HelpCommand;
11
10
  HelpCommand.paths = [
12
11
  [`help`],
13
12
  [`--help`],
14
13
  [`-h`],
15
14
  ];
15
+ exports.default = HelpCommand;
@@ -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;
@@ -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;
@@ -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);
@@ -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;
@@ -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;
@@ -246,7 +246,6 @@ class YarnCommand extends cli_1.BaseCommand {
246
246
  return report.exitCode();
247
247
  }
248
248
  }
249
- exports.default = YarnCommand;
250
249
  YarnCommand.paths = [
251
250
  [`install`],
252
251
  clipanion_1.Command.Default,
@@ -291,6 +290,7 @@ YarnCommand.usage = clipanion_1.Command.Usage({
291
290
  `$0 install --immutable --immutable-cache --check-cache`,
292
291
  ]],
293
292
  });
293
+ exports.default = YarnCommand;
294
294
  const MERGE_CONFLICT_ANCESTOR = `|||||||`;
295
295
  const MERGE_CONFLICT_END = `>>>>>>>`;
296
296
  const MERGE_CONFLICT_SEP = `=======`;
@@ -6,6 +6,6 @@ export default class LinkCommand extends BaseCommand {
6
6
  all: boolean;
7
7
  private: boolean;
8
8
  relative: boolean;
9
- destination: string;
9
+ destinations: string[];
10
10
  execute(): Promise<1 | 0>;
11
11
  }
@@ -9,15 +9,15 @@ class LinkCommand extends cli_1.BaseCommand {
9
9
  constructor() {
10
10
  super(...arguments);
11
11
  this.all = clipanion_1.Option.Boolean(`-A,--all`, false, {
12
- description: `Link all workspaces belonging to the target project to the current one`,
12
+ description: `Link all workspaces belonging to the target projects to the current one`,
13
13
  });
14
14
  this.private = clipanion_1.Option.Boolean(`-p,--private`, false, {
15
- description: `Also link private workspaces belonging to the target project to the current one`,
15
+ description: `Also link private workspaces belonging to the target projects to the current one`,
16
16
  });
17
17
  this.relative = clipanion_1.Option.Boolean(`-r,--relative`, false, {
18
18
  description: `Link workspaces using relative paths instead of absolute paths`,
19
19
  });
20
- this.destination = clipanion_1.Option.String();
20
+ this.destinations = clipanion_1.Option.Rest();
21
21
  }
22
22
  async execute() {
23
23
  const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
@@ -28,29 +28,35 @@ class LinkCommand extends cli_1.BaseCommand {
28
28
  await project.restoreInstallState({
29
29
  restoreResolutions: false,
30
30
  });
31
- const absoluteDestination = fslib_1.ppath.resolve(this.context.cwd, fslib_1.npath.toPortablePath(this.destination));
32
- const configuration2 = await core_1.Configuration.find(absoluteDestination, this.context.plugins, { useRc: false, strict: false });
33
- const { project: project2, workspace: workspace2 } = await core_1.Project.find(configuration2, absoluteDestination);
34
- if (project.cwd === project2.cwd)
35
- throw new clipanion_1.UsageError(`Invalid destination; Can't link the project to itself`);
36
- if (!workspace2)
37
- throw new cli_1.WorkspaceRequiredError(project2.cwd, absoluteDestination);
38
31
  const topLevelWorkspace = project.topLevelWorkspace;
39
32
  const linkedWorkspaces = [];
40
- if (this.all) {
41
- for (const workspace of project2.workspaces)
42
- if (workspace.manifest.name && (!workspace.manifest.private || this.private))
43
- linkedWorkspaces.push(workspace);
44
- if (linkedWorkspaces.length === 0) {
45
- throw new clipanion_1.UsageError(`No workspace found to be linked in the target project`);
33
+ for (const destination of this.destinations) {
34
+ const absoluteDestination = fslib_1.ppath.resolve(this.context.cwd, fslib_1.npath.toPortablePath(destination));
35
+ const configuration2 = await core_1.Configuration.find(absoluteDestination, this.context.plugins, { useRc: false, strict: false });
36
+ const { project: project2, workspace: workspace2 } = await core_1.Project.find(configuration2, absoluteDestination);
37
+ if (project.cwd === project2.cwd)
38
+ throw new clipanion_1.UsageError(`Invalid destination '${destination}'; Can't link the project to itself`);
39
+ if (!workspace2)
40
+ throw new cli_1.WorkspaceRequiredError(project2.cwd, absoluteDestination);
41
+ if (this.all) {
42
+ let found = false;
43
+ for (const workspace of project2.workspaces) {
44
+ if (workspace.manifest.name && (!workspace.manifest.private || this.private)) {
45
+ linkedWorkspaces.push(workspace);
46
+ found = true;
47
+ }
48
+ }
49
+ if (!found) {
50
+ throw new clipanion_1.UsageError(`No workspace found to be linked in the target project: ${destination}`);
51
+ }
52
+ }
53
+ else {
54
+ if (!workspace2.manifest.name)
55
+ throw new clipanion_1.UsageError(`The target workspace at '${destination}' doesn't have a name and thus cannot be linked`);
56
+ if (workspace2.manifest.private && !this.private)
57
+ throw new clipanion_1.UsageError(`The target workspace at '${destination}' is marked private - use the --private flag to link it anyway`);
58
+ linkedWorkspaces.push(workspace2);
46
59
  }
47
- }
48
- else {
49
- if (!workspace2.manifest.name)
50
- throw new clipanion_1.UsageError(`The target workspace doesn't have a name and thus cannot be linked`);
51
- if (workspace2.manifest.private && !this.private)
52
- throw new clipanion_1.UsageError(`The target workspace is marked private - use the --private flag to link it anyway`);
53
- linkedWorkspaces.push(workspace2);
54
60
  }
55
61
  for (const workspace of linkedWorkspaces) {
56
62
  const fullName = core_1.structUtils.stringifyIdent(workspace.locator);
@@ -71,7 +77,6 @@ class LinkCommand extends cli_1.BaseCommand {
71
77
  return report.exitCode();
72
78
  }
73
79
  }
74
- exports.default = LinkCommand;
75
80
  LinkCommand.paths = [
76
81
  [`link`],
77
82
  ];
@@ -81,10 +86,11 @@ LinkCommand.usage = clipanion_1.Command.Usage({
81
86
  This command will set a new \`resolutions\` field in the project-level manifest and point it to the workspace at the specified location (even if part of another project).
82
87
  `,
83
88
  examples: [[
84
- `Register a remote workspace for use in the current project`,
85
- `$0 link ~/ts-loader`,
89
+ `Register one or more remote workspaces for use in the current project`,
90
+ `$0 link ~/ts-loader ~/jest`,
86
91
  ], [
87
92
  `Register all workspaces from a remote project for use in the current project`,
88
93
  `$0 link ~/jest --all`,
89
94
  ]],
90
95
  });
96
+ exports.default = LinkCommand;
@@ -12,7 +12,6 @@ class NodeCommand extends cli_1.BaseCommand {
12
12
  return this.cli.run([`exec`, `node`, ...this.args]);
13
13
  }
14
14
  }
15
- exports.default = NodeCommand;
16
15
  NodeCommand.paths = [
17
16
  [`node`],
18
17
  ];
@@ -28,3 +27,4 @@ NodeCommand.usage = clipanion_1.Command.Usage({
28
27
  `$0 node ./my-script.js`,
29
28
  ]],
30
29
  });
30
+ exports.default = NodeCommand;
@@ -56,7 +56,6 @@ class PluginDlSourcesCommand extends cli_1.BaseCommand {
56
56
  return report.exitCode();
57
57
  }
58
58
  }
59
- exports.default = PluginDlSourcesCommand;
60
59
  PluginDlSourcesCommand.paths = [
61
60
  [`plugin`, `import`, `from`, `sources`],
62
61
  ];
@@ -76,6 +75,7 @@ PluginDlSourcesCommand.usage = clipanion_1.Command.Usage({
76
75
  `$0 plugin import from sources exec`,
77
76
  ]],
78
77
  });
78
+ exports.default = PluginDlSourcesCommand;
79
79
  async function buildAndSavePlugin(pluginSpec, { context, noMinify }, { project, report, target }) {
80
80
  const pluginName = pluginSpec.replace(/@yarnpkg\//, ``);
81
81
  const { configuration } = project;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { BaseCommand } from '@yarnpkg/cli';
4
3
  import { Project, Report } from '@yarnpkg/core';
5
4
  import { Usage } from 'clipanion';
@@ -69,7 +69,6 @@ class PluginDlCommand extends cli_1.BaseCommand {
69
69
  return report.exitCode();
70
70
  }
71
71
  }
72
- exports.default = PluginDlCommand;
73
72
  PluginDlCommand.paths = [
74
73
  [`plugin`, `import`],
75
74
  ];
@@ -101,6 +100,7 @@ PluginDlCommand.usage = clipanion_1.Command.Usage({
101
100
  `$0 plugin import ./path/to/plugin.js`,
102
101
  ]],
103
102
  });
103
+ exports.default = PluginDlCommand;
104
104
  async function savePlugin(pluginSpec, pluginBuffer, { project, report }) {
105
105
  const { configuration } = project;
106
106
  const vmExports = {};
@@ -39,7 +39,6 @@ class PluginDlCommand extends cli_1.BaseCommand {
39
39
  return report.exitCode();
40
40
  }
41
41
  }
42
- exports.default = PluginDlCommand;
43
42
  PluginDlCommand.paths = [
44
43
  [`plugin`, `list`],
45
44
  ];
@@ -54,3 +53,4 @@ PluginDlCommand.usage = clipanion_1.Command.Usage({
54
53
  `$0 plugin list`,
55
54
  ]],
56
55
  });
56
+ exports.default = PluginDlCommand;
@@ -45,7 +45,6 @@ class PluginRemoveCommand extends cli_1.BaseCommand {
45
45
  return report.exitCode();
46
46
  }
47
47
  }
48
- exports.default = PluginRemoveCommand;
49
48
  PluginRemoveCommand.paths = [
50
49
  [`plugin`, `remove`],
51
50
  ];
@@ -65,3 +64,4 @@ PluginRemoveCommand.usage = clipanion_1.Command.Usage({
65
64
  `$0 plugin remove my-local-plugin`,
66
65
  ]],
67
66
  });
67
+ exports.default = PluginRemoveCommand;
@@ -30,7 +30,6 @@ class PluginListCommand extends cli_1.BaseCommand {
30
30
  return report.exitCode();
31
31
  }
32
32
  }
33
- exports.default = PluginListCommand;
34
33
  PluginListCommand.paths = [
35
34
  [`plugin`, `runtime`],
36
35
  ];
@@ -45,3 +44,4 @@ PluginListCommand.usage = clipanion_1.Command.Usage({
45
44
  `$0 plugin runtime`,
46
45
  ]],
47
46
  });
47
+ exports.default = PluginListCommand;
@@ -46,7 +46,6 @@ class RunCommand extends cli_1.BaseCommand {
46
46
  return installReport.exitCode();
47
47
  }
48
48
  }
49
- exports.default = RunCommand;
50
49
  RunCommand.paths = [
51
50
  [`rebuild`],
52
51
  ];
@@ -67,3 +66,4 @@ RunCommand.usage = clipanion_1.Command.Usage({
67
66
  `$0 rebuild fsevents`,
68
67
  ]],
69
68
  });
69
+ exports.default = RunCommand;
@@ -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.FormatType.CODE)} ${dont} match any packages referenced by ${which} workspace`);
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({
@@ -103,7 +103,6 @@ class RemoveCommand extends cli_1.BaseCommand {
103
103
  return 0;
104
104
  }
105
105
  }
106
- exports.default = RemoveCommand;
107
106
  RemoveCommand.paths = [
108
107
  [`remove`],
109
108
  ];
@@ -137,3 +136,4 @@ RemoveCommand.usage = clipanion_1.Command.Usage({
137
136
  `$0 remove 'react-{dom,helmet}'`,
138
137
  ]],
139
138
  });
139
+ exports.default = RemoveCommand;
@@ -7,6 +7,7 @@ export default class RunCommand extends BaseCommand {
7
7
  inspectBrk: string | boolean;
8
8
  topLevel: boolean;
9
9
  binariesOnly: boolean;
10
+ require: string | undefined;
10
11
  silent: boolean | undefined;
11
12
  scriptName: string;
12
13
  args: string[];
@@ -22,6 +22,9 @@ class RunCommand extends cli_1.BaseCommand {
22
22
  this.binariesOnly = clipanion_1.Option.Boolean(`-B,--binaries-only`, false, {
23
23
  description: `Ignore any user defined scripts and only check for binaries`,
24
24
  });
25
+ this.require = clipanion_1.Option.String(`--require`, {
26
+ description: `Forwarded to the underlying Node process when executing a binary`,
27
+ });
25
28
  // The v1 used to print the Yarn version header when using "yarn run", which
26
29
  // was messing with the output of things like `--version` & co. We don't do
27
30
  // this anymore, but many workflows use `yarn run --silent` to make sure that
@@ -64,6 +67,8 @@ class RunCommand extends cli_1.BaseCommand {
64
67
  nodeArgs.push(`--inspect-brk`);
65
68
  }
66
69
  }
70
+ if (this.require)
71
+ nodeArgs.push(`--require=${this.require}`);
67
72
  return await core_2.scriptUtils.executePackageAccessibleBinary(effectiveLocator, this.scriptName, this.args, {
68
73
  cwd: this.context.cwd,
69
74
  project,
@@ -112,7 +117,6 @@ class RunCommand extends cli_1.BaseCommand {
112
117
  }
113
118
  }
114
119
  }
115
- exports.default = RunCommand;
116
120
  RunCommand.paths = [
117
121
  [`run`],
118
122
  ];
@@ -140,3 +144,4 @@ RunCommand.usage = clipanion_1.Command.Usage({
140
144
  `$0 run --inspect-brk webpack`,
141
145
  ]],
142
146
  });
147
+ exports.default = RunCommand;
@@ -32,7 +32,7 @@ class RunCommand extends cli_1.BaseCommand {
32
32
  return report.exitCode();
33
33
  }
34
34
  }
35
- exports.default = RunCommand;
36
35
  RunCommand.paths = [
37
36
  [`run`],
38
37
  ];
38
+ exports.default = RunCommand;
@@ -37,7 +37,6 @@ class SetResolutionCommand extends cli_1.BaseCommand {
37
37
  return report.exitCode();
38
38
  }
39
39
  }
40
- exports.default = SetResolutionCommand;
41
40
  SetResolutionCommand.paths = [
42
41
  [`set`, `resolution`],
43
42
  ];
@@ -55,3 +54,4 @@ SetResolutionCommand.usage = clipanion_1.Command.Usage({
55
54
  `$0 set resolution lodash@npm:^1.2.3 1.5.0`,
56
55
  ]],
57
56
  });
57
+ exports.default = SetResolutionCommand;
@@ -86,7 +86,6 @@ class SetVersionSourcesCommand extends cli_1.BaseCommand {
86
86
  return report.exitCode();
87
87
  }
88
88
  }
89
- exports.default = SetVersionSourcesCommand;
90
89
  SetVersionSourcesCommand.paths = [
91
90
  [`set`, `version`, `from`, `sources`],
92
91
  ];
@@ -102,6 +101,7 @@ SetVersionSourcesCommand.usage = clipanion_1.Command.Usage({
102
101
  `$0 set version from sources`,
103
102
  ]],
104
103
  });
104
+ exports.default = SetVersionSourcesCommand;
105
105
  async function runWorkflow(workflow, { configuration, context, target }) {
106
106
  for (const [fileName, ...args] of workflow) {
107
107
  const usePipe = args[args.length - 1] === `|`;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { BaseCommand } from '@yarnpkg/cli';
4
3
  import { Configuration, Report } from '@yarnpkg/core';
5
4
  import { Usage } from 'clipanion';
@@ -63,11 +63,11 @@ class SetVersionCommand extends cli_1.BaseCommand {
63
63
  const filePrefix = `file://`;
64
64
  let bundleBuffer;
65
65
  if (bundleUrl.startsWith(filePrefix)) {
66
- report.reportInfo(core_1.MessageName.UNNAMED, `Downloading ${core_2.formatUtils.pretty(configuration, bundleUrl, core_1.FormatType.URL)}`);
66
+ report.reportInfo(core_1.MessageName.UNNAMED, `Downloading ${core_2.formatUtils.pretty(configuration, bundleUrl, core_2.formatUtils.Type.URL)}`);
67
67
  bundleBuffer = await fslib_1.xfs.readFilePromise(fslib_1.npath.toPortablePath(bundleUrl.slice(filePrefix.length)));
68
68
  }
69
69
  else {
70
- report.reportInfo(core_1.MessageName.UNNAMED, `Retrieving ${core_2.formatUtils.pretty(configuration, bundleUrl, core_1.FormatType.PATH)}`);
70
+ report.reportInfo(core_1.MessageName.UNNAMED, `Retrieving ${core_2.formatUtils.pretty(configuration, bundleUrl, core_2.formatUtils.Type.PATH)}`);
71
71
  bundleBuffer = await core_2.httpUtils.get(bundleUrl, { configuration });
72
72
  }
73
73
  await setVersion(configuration, null, bundleBuffer, { report });
@@ -75,7 +75,6 @@ class SetVersionCommand extends cli_1.BaseCommand {
75
75
  return report.exitCode();
76
76
  }
77
77
  }
78
- exports.default = SetVersionCommand;
79
78
  SetVersionCommand.paths = [
80
79
  [`set`, `version`],
81
80
  ];
@@ -84,7 +83,7 @@ SetVersionCommand.usage = clipanion_1.Command.Usage({
84
83
  details: `
85
84
  This command will download a specific release of Yarn directly from the Yarn GitHub repository, will store it inside your project, and will change the \`yarnPath\` settings from your project \`.yarnrc.yml\` file to point to the new file.
86
85
 
87
- A very good use case for this command is to enforce the version of Yarn used by the any single member of your team inside a same project - by doing this you ensure that you have control on Yarn upgrades and downgrades (including on your deployment servers), and get rid of most of the headaches related to someone using a slightly different version and getting a different behavior than you.
86
+ A very good use case for this command is to enforce the version of Yarn used by any single member of your team inside the same project - by doing this you ensure that you have control over Yarn upgrades and downgrades (including on your deployment servers), and get rid of most of the headaches related to someone using a slightly different version and getting different behavior.
88
87
 
89
88
  The version specifier can be:
90
89
 
@@ -130,6 +129,7 @@ SetVersionCommand.usage = clipanion_1.Command.Usage({
130
129
  `$0 set version self`,
131
130
  ]],
132
131
  });
132
+ exports.default = SetVersionCommand;
133
133
  async function resolveRange(configuration, request) {
134
134
  const data = await core_2.httpUtils.get(`https://repo.yarnpkg.com/tags`, { configuration, jsonResponse: true });
135
135
  const candidates = data.tags.filter(version => core_2.semverUtils.satisfiesWithPrereleases(version, request));
@@ -72,7 +72,6 @@ class UnlinkCommand extends cli_1.BaseCommand {
72
72
  return report.exitCode();
73
73
  }
74
74
  }
75
- exports.default = UnlinkCommand;
76
75
  UnlinkCommand.paths = [
77
76
  [`unlink`],
78
77
  ];
@@ -95,3 +94,4 @@ UnlinkCommand.usage = clipanion_1.Command.Usage({
95
94
  `$0 unlink '@babel/*' 'pkg-{a,b}'`,
96
95
  ]],
97
96
  });
97
+ exports.default = UnlinkCommand;
@@ -136,9 +136,9 @@ class UpCommand extends cli_1.BaseCommand {
136
136
  }
137
137
  }
138
138
  if (unreferencedPatterns.length > 1)
139
- throw new clipanion_1.UsageError(`Patterns ${core_3.formatUtils.prettyList(configuration, unreferencedPatterns, core_3.FormatType.CODE)} don't match any packages referenced by any workspace`);
139
+ 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`);
140
140
  if (unreferencedPatterns.length > 0)
141
- throw new clipanion_1.UsageError(`Pattern ${core_3.formatUtils.prettyList(configuration, unreferencedPatterns, core_3.FormatType.CODE)} doesn't match any packages referenced by any workspace`);
141
+ 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`);
142
142
  const allSuggestions = await Promise.all(allSuggestionsPromises);
143
143
  const checkReport = await core_3.LightReport.start({
144
144
  configuration,
@@ -185,7 +185,7 @@ class UpCommand extends cli_1.BaseCommand {
185
185
  ({ answer: selected } = await (0, enquirer_1.prompt)({
186
186
  type: `select`,
187
187
  name: `answer`,
188
- message: `Which range to you want to use in ${core_1.structUtils.prettyWorkspace(configuration, workspace)} ❯ ${target}?`,
188
+ message: `Which range do you want to use in ${core_1.structUtils.prettyWorkspace(configuration, workspace)} ❯ ${target}?`,
189
189
  choices: suggestions.map(({ descriptor, name, reason }) => descriptor ? {
190
190
  name,
191
191
  hint: reason,
@@ -235,7 +235,6 @@ class UpCommand extends cli_1.BaseCommand {
235
235
  return installReport.exitCode();
236
236
  }
237
237
  }
238
- exports.default = UpCommand;
239
238
  UpCommand.paths = [
240
239
  [`up`],
241
240
  ];
@@ -285,3 +284,4 @@ UpCommand.usage = clipanion_1.Command.Usage({
285
284
  UpCommand.schema = [
286
285
  t.hasKeyRelationship(`recursive`, t.KeyRelationship.Forbids, [`interactive`, `exact`, `tilde`, `caret`], { ignore: [undefined, false] }),
287
286
  ];
287
+ exports.default = UpCommand;
@@ -38,7 +38,6 @@ class WhyCommand extends cli_1.BaseCommand {
38
38
  });
39
39
  }
40
40
  }
41
- exports.default = WhyCommand;
42
41
  WhyCommand.paths = [
43
42
  [`why`],
44
43
  ];
@@ -54,6 +53,7 @@ WhyCommand.usage = clipanion_1.Command.Usage({
54
53
  `$0 why lodash`,
55
54
  ]],
56
55
  });
56
+ exports.default = WhyCommand;
57
57
  function whySimple(project, identHash, { configuration, peers }) {
58
58
  const sortedPackages = core_3.miscUtils.sortMap(project.storedPackages.values(), pkg => {
59
59
  return core_3.structUtils.stringifyLocator(pkg);
@@ -27,7 +27,6 @@ class WorkspaceCommand extends cli_1.BaseCommand {
27
27
  return this.cli.run([this.commandName, ...this.args], { cwd: workspace.cwd });
28
28
  }
29
29
  }
30
- exports.default = WorkspaceCommand;
31
30
  WorkspaceCommand.paths = [
32
31
  [`workspace`],
33
32
  ];
@@ -45,3 +44,4 @@ WorkspaceCommand.usage = clipanion_1.Command.Usage({
45
44
  `yarn workspace components run build`,
46
45
  ]],
47
46
  });
47
+ exports.default = WorkspaceCommand;
@@ -84,7 +84,6 @@ class WorkspacesListCommand extends cli_1.BaseCommand {
84
84
  return report.exitCode();
85
85
  }
86
86
  }
87
- exports.default = WorkspacesListCommand;
88
87
  WorkspacesListCommand.paths = [
89
88
  [`workspaces`, `list`],
90
89
  ];
@@ -103,3 +102,4 @@ WorkspacesListCommand.usage = clipanion_1.Command.Usage({
103
102
  - If both the \`-v,--verbose\` and \`--json\` options are set, Yarn will also return the cross-dependencies between each workspaces (useful when you wish to automatically generate Buck / Bazel rules).
104
103
  `,
105
104
  });
105
+ exports.default = WorkspacesListCommand;
@@ -15,7 +15,7 @@ var Strategy;
15
15
  * - dependencies are never downgraded
16
16
  */
17
17
  Strategy["HIGHEST"] = "highest";
18
- })(Strategy = exports.Strategy || (exports.Strategy = {}));
18
+ })(Strategy || (exports.Strategy = Strategy = {}));
19
19
  exports.acceptedStrategies = new Set(Object.values(Strategy));
20
20
  const DEDUPE_ALGORITHMS = {
21
21
  highest: async (project, patterns, { resolver, fetcher, resolveOptions, fetchOptions }) => {
package/lib/index.d.ts CHANGED
@@ -42,6 +42,7 @@ declare module '@yarnpkg/core' {
42
42
  interface ConfigurationValueMap {
43
43
  enableImmutableInstalls: boolean;
44
44
  defaultSemverRangePrefix: `^` | `~` | ``;
45
+ preferReuse: boolean;
45
46
  }
46
47
  }
47
48
  declare const plugin: Plugin;
package/lib/index.js CHANGED
@@ -57,6 +57,11 @@ const plugin = {
57
57
  values: [`^`, `~`, ``],
58
58
  default: suggestUtils.Modifier.CARET,
59
59
  },
60
+ preferReuse: {
61
+ description: `If true, \`yarn add\` will attempt to reuse the most common dependency range in other workspaces.`,
62
+ type: core_1.SettingsType.BOOLEAN,
63
+ default: false,
64
+ },
60
65
  },
61
66
  commands: [
62
67
  clean_1.default,
@@ -12,19 +12,19 @@ var Target;
12
12
  Target["REGULAR"] = "dependencies";
13
13
  Target["DEVELOPMENT"] = "devDependencies";
14
14
  Target["PEER"] = "peerDependencies";
15
- })(Target = exports.Target || (exports.Target = {}));
15
+ })(Target || (exports.Target = Target = {}));
16
16
  var Modifier;
17
17
  (function (Modifier) {
18
18
  Modifier["CARET"] = "^";
19
19
  Modifier["TILDE"] = "~";
20
20
  Modifier["EXACT"] = "";
21
- })(Modifier = exports.Modifier || (exports.Modifier = {}));
21
+ })(Modifier || (exports.Modifier = Modifier = {}));
22
22
  var WorkspaceModifier;
23
23
  (function (WorkspaceModifier) {
24
24
  WorkspaceModifier["CARET"] = "^";
25
25
  WorkspaceModifier["TILDE"] = "~";
26
26
  WorkspaceModifier["EXACT"] = "*";
27
- })(WorkspaceModifier = exports.WorkspaceModifier || (exports.WorkspaceModifier = {}));
27
+ })(WorkspaceModifier || (exports.WorkspaceModifier = WorkspaceModifier = {}));
28
28
  var Strategy;
29
29
  (function (Strategy) {
30
30
  /**
@@ -52,7 +52,7 @@ var Strategy;
52
52
  * versions of the package that are already within our cache.
53
53
  */
54
54
  Strategy["CACHE"] = "cache";
55
- })(Strategy = exports.Strategy || (exports.Strategy = {}));
55
+ })(Strategy || (exports.Strategy = Strategy = {}));
56
56
  function getModifier(flags, project) {
57
57
  if (flags.exact)
58
58
  return Modifier.EXACT;
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@yarnpkg/plugin-essentials",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "license": "BSD-2-Clause",
5
5
  "main": "./lib/index.js",
6
6
  "dependencies": {
7
- "@yarnpkg/fslib": "^2.9.0",
8
- "@yarnpkg/json-proxy": "^2.1.1",
9
- "@yarnpkg/parsers": "^2.5.1",
7
+ "@yarnpkg/fslib": "^2.10.4",
8
+ "@yarnpkg/parsers": "^2.6.0",
10
9
  "ci-info": "^3.2.0",
11
10
  "clipanion": "3.2.0-rc.4",
12
11
  "enquirer": "^2.3.6",
@@ -17,18 +16,17 @@
17
16
  "typanion": "^3.3.0"
18
17
  },
19
18
  "peerDependencies": {
20
- "@yarnpkg/cli": "^3.3.0",
21
- "@yarnpkg/core": "^3.3.0",
22
- "@yarnpkg/plugin-git": "^2.6.3"
19
+ "@yarnpkg/cli": "^3.8.0",
20
+ "@yarnpkg/core": "^3.7.0",
21
+ "@yarnpkg/plugin-git": "^2.6.8"
23
22
  },
24
23
  "devDependencies": {
25
24
  "@types/lodash": "^4.14.136",
26
25
  "@types/micromatch": "^4.0.1",
27
26
  "@types/semver": "^7.1.0",
28
- "@types/treeify": "^1.0.0",
29
- "@yarnpkg/cli": "^3.3.0",
30
- "@yarnpkg/core": "^3.3.0",
31
- "@yarnpkg/plugin-git": "^2.6.3"
27
+ "@yarnpkg/cli": "^3.8.0",
28
+ "@yarnpkg/core": "^3.7.0",
29
+ "@yarnpkg/plugin-git": "^2.6.8"
32
30
  },
33
31
  "repository": {
34
32
  "type": "git",