@yarnpkg/plugin-essentials 4.0.0-rc.8 → 4.0.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 (69) hide show
  1. package/lib/commands/add.d.ts +1 -1
  2. package/lib/commands/add.js +34 -25
  3. package/lib/commands/bin.d.ts +1 -1
  4. package/lib/commands/bin.js +1 -1
  5. package/lib/commands/cache/clean.d.ts +1 -1
  6. package/lib/commands/cache/clean.js +1 -1
  7. package/lib/commands/config/get.d.ts +2 -1
  8. package/lib/commands/config/get.js +4 -1
  9. package/lib/commands/config/set.d.ts +1 -1
  10. package/lib/commands/config/set.js +1 -1
  11. package/lib/commands/config/unset.d.ts +1 -1
  12. package/lib/commands/config/unset.js +1 -1
  13. package/lib/commands/config.d.ts +5 -3
  14. package/lib/commands/config.js +96 -39
  15. package/lib/commands/dedupe.d.ts +1 -1
  16. package/lib/commands/dedupe.js +7 -8
  17. package/lib/commands/entries/clipanion.js +1 -1
  18. package/lib/commands/entries/help.js +1 -1
  19. package/lib/commands/entries/version.js +1 -1
  20. package/lib/commands/exec.js +1 -1
  21. package/lib/commands/explain/peerRequirements.d.ts +2 -2
  22. package/lib/commands/explain/peerRequirements.js +4 -6
  23. package/lib/commands/explain.js +1 -1
  24. package/lib/commands/info.js +10 -18
  25. package/lib/commands/install.d.ts +1 -1
  26. package/lib/commands/install.js +245 -205
  27. package/lib/commands/link.d.ts +2 -2
  28. package/lib/commands/link.js +36 -32
  29. package/lib/commands/node.js +1 -1
  30. package/lib/commands/plugin/check.d.ts +8 -0
  31. package/lib/commands/plugin/check.js +61 -0
  32. package/lib/commands/plugin/import/sources.d.ts +3 -3
  33. package/lib/commands/plugin/import/sources.js +5 -5
  34. package/lib/commands/plugin/import.d.ts +5 -4
  35. package/lib/commands/plugin/import.js +15 -28
  36. package/lib/commands/plugin/list.d.ts +2 -2
  37. package/lib/commands/plugin/list.js +5 -6
  38. package/lib/commands/plugin/remove.d.ts +1 -1
  39. package/lib/commands/plugin/remove.js +14 -13
  40. package/lib/commands/plugin/runtime.d.ts +2 -2
  41. package/lib/commands/plugin/runtime.js +4 -4
  42. package/lib/commands/rebuild.d.ts +2 -2
  43. package/lib/commands/rebuild.js +10 -10
  44. package/lib/commands/remove.d.ts +1 -1
  45. package/lib/commands/remove.js +7 -8
  46. package/lib/commands/run.js +1 -1
  47. package/lib/commands/runIndex.d.ts +2 -2
  48. package/lib/commands/runIndex.js +3 -3
  49. package/lib/commands/set/resolution.d.ts +1 -1
  50. package/lib/commands/set/resolution.js +4 -6
  51. package/lib/commands/set/version/sources.d.ts +3 -2
  52. package/lib/commands/set/version/sources.js +21 -12
  53. package/lib/commands/set/version.d.ts +2 -3
  54. package/lib/commands/set/version.js +20 -16
  55. package/lib/commands/unlink.d.ts +1 -1
  56. package/lib/commands/unlink.js +7 -8
  57. package/lib/commands/up.d.ts +3 -3
  58. package/lib/commands/up.js +19 -17
  59. package/lib/commands/why.js +5 -13
  60. package/lib/commands/workspace.js +2 -5
  61. package/lib/commands/workspaces/list.d.ts +2 -1
  62. package/lib/commands/workspaces/list.js +8 -1
  63. package/lib/dedupeUtils.d.ts +3 -3
  64. package/lib/dedupeUtils.js +3 -5
  65. package/lib/index.d.ts +76 -1
  66. package/lib/index.js +40 -1
  67. package/lib/suggestUtils.d.ts +4 -4
  68. package/lib/suggestUtils.js +14 -12
  69. package/package.json +22 -17
@@ -18,5 +18,5 @@ export default class AddCommand extends BaseCommand {
18
18
  mode: InstallMode | undefined;
19
19
  silent: boolean | undefined;
20
20
  packages: string[];
21
- execute(): Promise<1 | 0>;
21
+ execute(): Promise<0 | 1>;
22
22
  }
@@ -54,7 +54,6 @@ class AddCommand extends cli_1.BaseCommand {
54
54
  this.packages = clipanion_1.Option.Rest();
55
55
  }
56
56
  async execute() {
57
- var _a;
58
57
  const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
59
58
  const { project, workspace } = await core_2.Project.find(configuration, this.context.cwd);
60
59
  const cache = await core_1.Cache.find(configuration);
@@ -64,7 +63,7 @@ class AddCommand extends cli_1.BaseCommand {
64
63
  restoreResolutions: false,
65
64
  });
66
65
  const fixed = this.fixed;
67
- const interactive = (_a = this.interactive) !== null && _a !== void 0 ? _a : configuration.get(`preferInteractive`);
66
+ const interactive = this.interactive ?? configuration.get(`preferInteractive`);
68
67
  const reuse = interactive || configuration.get(`preferReuse`);
69
68
  const modifier = suggestUtils.getModifier(this, project);
70
69
  const strategies = [
@@ -86,24 +85,27 @@ class AddCommand extends cli_1.BaseCommand {
86
85
  : core_3.structUtils.tryParseDescriptor(pseudoDescriptor);
87
86
  const unsupportedPrefix = pseudoDescriptor.match(/^(https?:|git@github)/);
88
87
  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.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)}`);
88
+ 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
89
  if (!request)
91
- 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?`);
92
- const target = suggestTarget(workspace, request, {
90
+ 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?`);
91
+ const targetList = suggestTargetList(workspace, request, {
93
92
  dev: this.dev,
94
93
  peer: this.peer,
95
94
  preferDev: this.preferDev,
96
95
  optional: this.optional,
97
96
  });
98
- const suggestions = await suggestUtils.getSuggestedDescriptors(request, { project, workspace, cache, fixed, target, modifier, strategies, maxResults });
99
- return [request, suggestions, target];
100
- }));
97
+ const results = await Promise.all(targetList.map(async (target) => {
98
+ const suggestedDescriptors = await suggestUtils.getSuggestedDescriptors(request, { project, workspace, cache, fixed, target, modifier, strategies, maxResults });
99
+ return { request, suggestedDescriptors, target };
100
+ }));
101
+ return results;
102
+ })).then(results => results.flat());
101
103
  const checkReport = await core_1.LightReport.start({
102
104
  configuration,
103
105
  stdout: this.context.stdout,
104
106
  suggestInstall: false,
105
107
  }, async (report) => {
106
- for (const [request, { suggestions, rejections }] of allSuggestions) {
108
+ for (const { request, suggestedDescriptors: { suggestions, rejections } } of allSuggestions) {
107
109
  const nonNullSuggestions = suggestions.filter(suggestion => {
108
110
  return suggestion.descriptor !== null;
109
111
  });
@@ -125,7 +127,7 @@ class AddCommand extends cli_1.BaseCommand {
125
127
  let askedQuestions = false;
126
128
  const afterWorkspaceDependencyAdditionList = [];
127
129
  const afterWorkspaceDependencyReplacementList = [];
128
- for (const [/*request*/ , { suggestions }, target] of allSuggestions) {
130
+ for (const { suggestedDescriptors: { suggestions }, target } of allSuggestions) {
129
131
  let selected;
130
132
  const nonNullSuggestions = suggestions.filter(suggestion => {
131
133
  return suggestion.descriptor !== null;
@@ -198,18 +200,16 @@ class AddCommand extends cli_1.BaseCommand {
198
200
  await configuration.triggerMultipleHooks((hooks) => hooks.afterWorkspaceDependencyReplacement, afterWorkspaceDependencyReplacementList);
199
201
  if (askedQuestions)
200
202
  this.context.stdout.write(`\n`);
201
- const installReport = await core_2.StreamReport.start({
202
- configuration,
203
+ return await project.installWithNewReport({
203
204
  json: this.json,
204
205
  stdout: this.context.stdout,
205
- includeLogs: !this.context.quiet,
206
- }, async (report) => {
207
- await project.install({ cache, report, mode: this.mode });
206
+ quiet: this.context.quiet,
207
+ }, {
208
+ cache,
209
+ mode: this.mode,
208
210
  });
209
- return installReport.exitCode();
210
211
  }
211
212
  }
212
- exports.default = AddCommand;
213
213
  AddCommand.paths = [
214
214
  [`add`],
215
215
  ];
@@ -236,7 +236,7 @@ AddCommand.usage = clipanion_1.Command.Usage({
236
236
 
237
237
  If the \`--mode=<mode>\` option is set, Yarn will change which artifacts are generated. The modes currently supported are:
238
238
 
239
- - \`skip-build\` will not run the build scripts at all. Note that this is different from setting \`enableScripts\` to false because the later 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.
239
+ - \`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
240
 
241
241
  - \`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
242
 
@@ -262,7 +262,8 @@ AddCommand.usage = clipanion_1.Command.Usage({
262
262
  `$0 add lodash-es@lodash/lodash#es`,
263
263
  ]],
264
264
  });
265
- function suggestTarget(workspace, ident, { dev, peer, preferDev, optional }) {
265
+ exports.default = AddCommand;
266
+ function suggestTargetList(workspace, ident, { dev, peer, preferDev, optional }) {
266
267
  const hasRegular = workspace.manifest[suggestUtils.Target.REGULAR].has(ident.identHash);
267
268
  const hasDev = workspace.manifest[suggestUtils.Target.DEVELOPMENT].has(ident.identHash);
268
269
  const hasPeer = workspace.manifest[suggestUtils.Target.PEER].has(ident.identHash);
@@ -276,13 +277,21 @@ function suggestTarget(workspace, ident, { dev, peer, preferDev, optional }) {
276
277
  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
278
  if ((dev || preferDev) && optional)
278
279
  throw new clipanion_1.UsageError(`Package "${core_3.structUtils.prettyIdent(workspace.project.configuration, ident)}" cannot simultaneously be a dev dependency and an optional dependency`);
280
+ // When the program executes this line, the command is expected to be legal
281
+ const targetList = [];
279
282
  if (peer)
280
- return suggestUtils.Target.PEER;
283
+ targetList.push(suggestUtils.Target.PEER);
281
284
  if (dev || preferDev)
282
- return suggestUtils.Target.DEVELOPMENT;
283
- if (hasRegular)
284
- return suggestUtils.Target.REGULAR;
285
+ targetList.push(suggestUtils.Target.DEVELOPMENT);
286
+ if (optional)
287
+ targetList.push(suggestUtils.Target.REGULAR);
288
+ // The user explicitly define the targets
289
+ if (targetList.length > 0)
290
+ return targetList;
291
+ // The user does not define the targets, find it from the `workspace.manifest`
285
292
  if (hasDev)
286
- return suggestUtils.Target.DEVELOPMENT;
287
- return suggestUtils.Target.REGULAR;
293
+ return [suggestUtils.Target.DEVELOPMENT];
294
+ if (hasPeer)
295
+ return [suggestUtils.Target.PEER];
296
+ return [suggestUtils.Target.REGULAR];
288
297
  }
@@ -6,5 +6,5 @@ export default class BinCommand extends BaseCommand {
6
6
  verbose: boolean;
7
7
  json: boolean;
8
8
  name: string | undefined;
9
- execute(): Promise<1 | 0>;
9
+ execute(): Promise<0 | 1>;
10
10
  }
@@ -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;
@@ -5,5 +5,5 @@ export default class CacheCleanCommand extends BaseCommand {
5
5
  static usage: Usage;
6
6
  mirror: boolean;
7
7
  all: boolean;
8
- execute(): Promise<1 | 0>;
8
+ execute(): Promise<0 | 1>;
9
9
  }
@@ -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;
@@ -3,8 +3,9 @@ import { Usage } from 'clipanion';
3
3
  export default class ConfigGetCommand extends BaseCommand {
4
4
  static paths: string[][];
5
5
  static usage: Usage;
6
+ why: boolean;
6
7
  json: boolean;
7
8
  unsafe: boolean;
8
9
  name: string;
9
- execute(): Promise<1 | 0>;
10
+ execute(): Promise<0 | 1>;
10
11
  }
@@ -10,6 +10,9 @@ const util_1 = require("util");
10
10
  class ConfigGetCommand extends cli_1.BaseCommand {
11
11
  constructor() {
12
12
  super(...arguments);
13
+ this.why = clipanion_1.Option.Boolean(`--why`, false, {
14
+ description: `Print the explanation for why a setting has its value`,
15
+ });
13
16
  this.json = clipanion_1.Option.Boolean(`--json`, false, {
14
17
  description: `Format the output as an NDJSON stream`,
15
18
  });
@@ -57,7 +60,6 @@ class ConfigGetCommand extends cli_1.BaseCommand {
57
60
  return report.exitCode();
58
61
  }
59
62
  }
60
- exports.default = ConfigGetCommand;
61
63
  ConfigGetCommand.paths = [
62
64
  [`config`, `get`],
63
65
  ];
@@ -85,3 +87,4 @@ ConfigGetCommand.usage = clipanion_1.Command.Usage({
85
87
  `yarn config get packageExtensions --json`,
86
88
  ]],
87
89
  });
90
+ exports.default = ConfigGetCommand;
@@ -7,5 +7,5 @@ export default class ConfigSetCommand extends BaseCommand {
7
7
  home: boolean;
8
8
  name: string;
9
9
  value: string;
10
- execute(): Promise<1 | 0>;
10
+ execute(): Promise<0 | 1>;
11
11
  }
@@ -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;
@@ -5,5 +5,5 @@ export default class ConfigUnsetCommand extends BaseCommand {
5
5
  static usage: Usage;
6
6
  home: boolean;
7
7
  name: string;
8
- execute(): Promise<1 | 0>;
8
+ execute(): Promise<0 | 1>;
9
9
  }
@@ -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;
@@ -3,8 +3,10 @@ import { Usage } from 'clipanion';
3
3
  export default class ConfigCommand extends BaseCommand {
4
4
  static paths: string[][];
5
5
  static usage: Usage;
6
- verbose: boolean;
7
- why: boolean;
6
+ noDefaults: boolean;
8
7
  json: boolean;
9
- execute(): Promise<1 | 0>;
8
+ verbose: boolean | undefined;
9
+ why: boolean | undefined;
10
+ names: string[];
11
+ execute(): Promise<0 | 1>;
10
12
  }
@@ -2,31 +2,50 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cli_1 = require("@yarnpkg/cli");
4
4
  const core_1 = require("@yarnpkg/core");
5
- const core_2 = require("@yarnpkg/core");
5
+ const fslib_1 = require("@yarnpkg/fslib");
6
6
  const clipanion_1 = require("clipanion");
7
7
  const util_1 = require("util");
8
8
  // eslint-disable-next-line arca/no-default-export
9
9
  class ConfigCommand extends cli_1.BaseCommand {
10
10
  constructor() {
11
11
  super(...arguments);
12
- this.verbose = clipanion_1.Option.Boolean(`-v,--verbose`, false, {
13
- description: `Print the setting description on top of the regular key/value information`,
14
- });
15
- this.why = clipanion_1.Option.Boolean(`--why`, false, {
16
- description: `Print the reason why a setting is set a particular way`,
12
+ this.noDefaults = clipanion_1.Option.Boolean(`--no-defaults`, false, {
13
+ description: `Omit the default values from the display`,
17
14
  });
18
15
  this.json = clipanion_1.Option.Boolean(`--json`, false, {
19
16
  description: `Format the output as an NDJSON stream`,
20
17
  });
18
+ // Legacy flags; will emit errors or warnings when used
19
+ this.verbose = clipanion_1.Option.Boolean(`-v,--verbose`, { hidden: true });
20
+ this.why = clipanion_1.Option.Boolean(`--why`, { hidden: true });
21
+ this.names = clipanion_1.Option.Rest();
21
22
  }
22
23
  async execute() {
23
24
  const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins, {
24
25
  strict: false,
25
26
  });
27
+ const deprecationExitCode = await (0, core_1.reportOptionDeprecations)({
28
+ configuration,
29
+ stdout: this.context.stdout,
30
+ forceError: this.json,
31
+ }, [{
32
+ option: this.verbose,
33
+ message: `The --verbose option is deprecated, the settings' descriptions are now always displayed`,
34
+ }, {
35
+ option: this.why,
36
+ message: `The --why option is deprecated, the settings' sources are now always displayed`,
37
+ }]);
38
+ if (deprecationExitCode !== null)
39
+ return deprecationExitCode;
40
+ const names = this.names.length > 0
41
+ ? [...new Set(this.names)].sort()
42
+ : [...configuration.settings.keys()].sort();
43
+ let trailingValue;
26
44
  const report = await core_1.StreamReport.start({
27
45
  configuration,
28
46
  json: this.json,
29
47
  stdout: this.context.stdout,
48
+ includeFooter: false,
30
49
  }, async (report) => {
31
50
  if (configuration.invalid.size > 0 && !this.json) {
32
51
  for (const [key, source] of configuration.invalid)
@@ -34,58 +53,95 @@ class ConfigCommand extends cli_1.BaseCommand {
34
53
  report.reportSeparator();
35
54
  }
36
55
  if (this.json) {
37
- const keys = core_2.miscUtils.sortMap(configuration.settings.keys(), key => key);
38
- for (const key of keys) {
39
- const data = configuration.settings.get(key);
40
- const effective = configuration.getSpecial(key, {
56
+ for (const name of names) {
57
+ const data = configuration.settings.get(name);
58
+ if (typeof data === `undefined`)
59
+ report.reportError(core_1.MessageName.INVALID_CONFIGURATION_KEY, `No configuration key named "${name}"`);
60
+ const effective = configuration.getSpecial(name, {
41
61
  hideSecrets: true,
42
62
  getNativePaths: true,
43
63
  });
44
- const source = configuration.sources.get(key);
45
- if (this.verbose) {
46
- report.reportJson({ key, effective, source });
47
- }
48
- else {
49
- report.reportJson({ key, effective, source, ...data });
50
- }
64
+ const source = configuration.sources.get(name) ?? `<default>`;
65
+ const sourceAsNativePath = source && source[0] !== `<`
66
+ ? fslib_1.npath.fromPortablePath(source)
67
+ : source;
68
+ report.reportJson({ key: name, effective, source: sourceAsNativePath, ...data });
51
69
  }
52
70
  }
53
71
  else {
54
- const keys = core_2.miscUtils.sortMap(configuration.settings.keys(), key => key);
55
- const maxKeyLength = keys.reduce((max, key) => Math.max(max, key.length), 0);
56
72
  const inspectConfig = {
57
73
  breakLength: Infinity,
58
74
  colors: configuration.get(`enableColors`),
59
75
  maxArrayLength: 2,
60
76
  };
61
- if (this.why || this.verbose) {
62
- const keysAndDescriptions = keys.map(key => {
63
- const setting = configuration.settings.get(key);
64
- if (!setting)
65
- throw new Error(`Assertion failed: This settings ("${key}") should have been registered`);
66
- const description = this.why
67
- ? configuration.sources.get(key) || `<default>`
68
- : setting.description;
69
- return [key, description];
70
- });
71
- const maxDescriptionLength = keysAndDescriptions.reduce((max, [, description]) => {
72
- return Math.max(max, description.length);
73
- }, 0);
74
- for (const [key, description] of keysAndDescriptions) {
75
- report.reportInfo(null, `${key.padEnd(maxKeyLength, ` `)} ${description.padEnd(maxDescriptionLength, ` `)} ${(0, util_1.inspect)(configuration.getSpecial(key, { hideSecrets: true, getNativePaths: true }), inspectConfig)}`);
77
+ const configTreeChildren = {};
78
+ const configTree = { children: configTreeChildren };
79
+ for (const name of names) {
80
+ if (this.noDefaults && !configuration.sources.has(name))
81
+ continue;
82
+ const setting = configuration.settings.get(name);
83
+ const source = configuration.sources.get(name) ?? `<default>`;
84
+ const value = configuration.getSpecial(name, { hideSecrets: true, getNativePaths: true });
85
+ const fields = {
86
+ Description: {
87
+ label: `Description`,
88
+ value: core_1.formatUtils.tuple(core_1.formatUtils.Type.MARKDOWN, { text: setting.description, format: this.cli.format(), paragraphs: false }),
89
+ },
90
+ Source: {
91
+ label: `Source`,
92
+ value: core_1.formatUtils.tuple(source[0] === `<` ? core_1.formatUtils.Type.CODE : core_1.formatUtils.Type.PATH, source),
93
+ },
94
+ };
95
+ configTreeChildren[name] = {
96
+ value: core_1.formatUtils.tuple(core_1.formatUtils.Type.CODE, name),
97
+ children: fields,
98
+ };
99
+ const setValueTo = (node, value) => {
100
+ for (const [key, subValue] of value) {
101
+ if (subValue instanceof Map) {
102
+ const subFields = {};
103
+ node[key] = { children: subFields };
104
+ setValueTo(subFields, subValue);
105
+ }
106
+ else {
107
+ node[key] = {
108
+ label: key,
109
+ value: core_1.formatUtils.tuple(core_1.formatUtils.Type.NO_HINT, (0, util_1.inspect)(subValue, inspectConfig)),
110
+ };
111
+ }
112
+ }
113
+ };
114
+ if (value instanceof Map) {
115
+ setValueTo(fields, value);
76
116
  }
77
- }
78
- else {
79
- for (const key of keys) {
80
- report.reportInfo(null, `${key.padEnd(maxKeyLength, ` `)} ${(0, util_1.inspect)(configuration.getSpecial(key, { hideSecrets: true, getNativePaths: true }), inspectConfig)}`);
117
+ else {
118
+ fields.Value = {
119
+ label: `Value`,
120
+ value: core_1.formatUtils.tuple(core_1.formatUtils.Type.NO_HINT, (0, util_1.inspect)(value, inspectConfig)),
121
+ };
81
122
  }
82
123
  }
124
+ if (names.length !== 1)
125
+ trailingValue = undefined;
126
+ core_1.treeUtils.emitTree(configTree, {
127
+ configuration,
128
+ json: this.json,
129
+ stdout: this.context.stdout,
130
+ separators: 2,
131
+ });
83
132
  }
84
133
  });
134
+ if (!this.json && typeof trailingValue !== `undefined`) {
135
+ const name = names[0];
136
+ const value = (0, util_1.inspect)(configuration.getSpecial(name, { hideSecrets: true, getNativePaths: true }), {
137
+ colors: configuration.get(`enableColors`),
138
+ });
139
+ this.context.stdout.write(`\n`);
140
+ this.context.stdout.write(`${value}\n`);
141
+ }
85
142
  return report.exitCode();
86
143
  }
87
144
  }
88
- exports.default = ConfigCommand;
89
145
  ConfigCommand.paths = [
90
146
  [`config`],
91
147
  ];
@@ -99,3 +155,4 @@ ConfigCommand.usage = clipanion_1.Command.Usage({
99
155
  `$0 config`,
100
156
  ]],
101
157
  });
158
+ exports.default = ConfigCommand;
@@ -22,5 +22,5 @@ export default class DedupeCommand extends BaseCommand {
22
22
  json: boolean;
23
23
  mode: InstallMode | undefined;
24
24
  patterns: string[];
25
- execute(): Promise<1 | 0>;
25
+ execute(): Promise<0 | 1>;
26
26
  }
@@ -61,18 +61,16 @@ class DedupeCommand extends cli_1.BaseCommand {
61
61
  return dedupedPackageCount ? 1 : 0;
62
62
  }
63
63
  else {
64
- const installReport = await core_1.StreamReport.start({
65
- configuration,
66
- stdout: this.context.stdout,
64
+ return await project.installWithNewReport({
67
65
  json: this.json,
68
- }, async (report) => {
69
- await project.install({ cache, report, mode: this.mode });
66
+ stdout: this.context.stdout,
67
+ }, {
68
+ cache,
69
+ mode: this.mode,
70
70
  });
71
- return installReport.exitCode();
72
71
  }
73
72
  }
74
73
  }
75
- exports.default = DedupeCommand;
76
74
  DedupeCommand.paths = [
77
75
  [`dedupe`],
78
76
  ];
@@ -91,7 +89,7 @@ DedupeCommand.usage = clipanion_1.Command.Usage({
91
89
 
92
90
  If the \`--mode=<mode>\` option is set, Yarn will change which artifacts are generated. The modes currently supported are:
93
91
 
94
- - \`skip-build\` will not run the build scripts at all. Note that this is different from setting \`enableScripts\` to false because the later 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.
92
+ - \`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
93
 
96
94
  - \`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
95
 
@@ -124,3 +122,4 @@ DedupeCommand.usage = clipanion_1.Command.Usage({
124
122
  `$0 dedupe --check`,
125
123
  ]],
126
124
  });
125
+ 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;
@@ -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<1 | 0>;
9
+ execute(): Promise<0 | 1>;
10
10
  }
11
11
  export declare function explainPeerRequirements(peerRequirementsHash: string, project: Project, opts: {
12
12
  stdout: Writable;
13
- }): Promise<1 | 0>;
13
+ }): Promise<0 | 1>;
@@ -35,7 +35,6 @@ class ExplainPeerRequirementsCommand extends cli_1.BaseCommand {
35
35
  stdout: this.context.stdout,
36
36
  includeFooter: false,
37
37
  }, async (report) => {
38
- var _a;
39
38
  const sortCriterias = [
40
39
  ([, requirement]) => core_1.structUtils.stringifyLocator(project.storedPackages.get(requirement.subject)),
41
40
  ([, requirement]) => core_1.structUtils.stringifyIdent(requirement.requested),
@@ -47,7 +46,7 @@ class ExplainPeerRequirementsCommand extends cli_1.BaseCommand {
47
46
  const rootRequester = project.storedPackages.get(requirement.rootRequester);
48
47
  if (typeof rootRequester === `undefined`)
49
48
  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;
49
+ const providedDescriptor = subject.dependencies.get(requirement.requested.identHash) ?? null;
51
50
  const prettyHash = core_1.formatUtils.pretty(configuration, hash, core_1.formatUtils.Type.CODE);
52
51
  const prettySubject = core_1.structUtils.prettyLocator(configuration, subject);
53
52
  const prettyIdent = core_1.structUtils.prettyIdent(configuration, requirement.requested);
@@ -62,7 +61,6 @@ class ExplainPeerRequirementsCommand extends cli_1.BaseCommand {
62
61
  return report.exitCode();
63
62
  }
64
63
  }
65
- exports.default = ExplainPeerRequirementsCommand;
66
64
  ExplainPeerRequirementsCommand.paths = [
67
65
  [`explain`, `peer-requirements`],
68
66
  ];
@@ -85,6 +83,7 @@ ExplainPeerRequirementsCommand.usage = clipanion_1.Command.Usage({
85
83
  `$0 explain peer-requirements`,
86
84
  ]],
87
85
  });
86
+ exports.default = ExplainPeerRequirementsCommand;
88
87
  async function explainPeerRequirements(peerRequirementsHash, project, opts) {
89
88
  const { configuration } = project;
90
89
  const requirement = project.peerRequirements.get(peerRequirementsHash);
@@ -95,14 +94,13 @@ async function explainPeerRequirements(peerRequirementsHash, project, opts) {
95
94
  stdout: opts.stdout,
96
95
  includeFooter: false,
97
96
  }, async (report) => {
98
- var _a, _b;
99
97
  const subject = project.storedPackages.get(requirement.subject);
100
98
  if (typeof subject === `undefined`)
101
99
  throw new Error(`Assertion failed: Expected the subject package to have been registered`);
102
100
  const rootRequester = project.storedPackages.get(requirement.rootRequester);
103
101
  if (typeof rootRequester === `undefined`)
104
102
  throw new Error(`Assertion failed: Expected the root package to have been registered`);
105
- const providedDescriptor = (_a = subject.dependencies.get(requirement.requested.identHash)) !== null && _a !== void 0 ? _a : null;
103
+ const providedDescriptor = subject.dependencies.get(requirement.requested.identHash) ?? null;
106
104
  const providedResolution = providedDescriptor !== null
107
105
  ? project.storedResolutions.get(providedDescriptor.descriptorHash)
108
106
  : null;
@@ -130,7 +128,7 @@ async function explainPeerRequirements(peerRequirementsHash, project, opts) {
130
128
  const satisfiesAllRanges = allRequesters.every(({ peerDependency }) => {
131
129
  return core_1.semverUtils.satisfiesWithPrereleases(provided.version, peerDependency.range);
132
130
  });
133
- report.reportInfo(core_1.MessageName.UNNAMED, `${core_1.structUtils.prettyLocator(configuration, subject)} provides ${core_1.structUtils.prettyLocator(configuration, provided)} with version ${core_1.structUtils.prettyReference(configuration, (_b = provided.version) !== null && _b !== void 0 ? _b : `<missing>`)}, which ${satisfiesAllRanges ? `satisfies` : `doesn't satisfy`} the following requirements:`);
131
+ report.reportInfo(core_1.MessageName.UNNAMED, `${core_1.structUtils.prettyLocator(configuration, subject)} provides ${core_1.structUtils.prettyLocator(configuration, provided)} with version ${core_1.structUtils.prettyReference(configuration, provided.version ?? `<missing>`)}, which ${satisfiesAllRanges ? `satisfies` : `doesn't satisfy`} the following requirements:`);
134
132
  }
135
133
  else {
136
134
  report.reportInfo(core_1.MessageName.UNNAMED, `${core_1.structUtils.prettyLocator(configuration, subject)} doesn't provide ${core_1.structUtils.prettyIdent(configuration, requirement.requested)}, breaking the following requirements:`);
@@ -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;