@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
@@ -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,32 +28,38 @@ 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
- const fullName = core_1.structUtils.stringifyIdent(workspace.locator);
62
+ const fullName = core_1.structUtils.stringifyIdent(workspace.anchoredLocator);
57
63
  const target = this.relative
58
64
  ? fslib_1.ppath.relative(project.cwd, workspace.cwd)
59
65
  : workspace.cwd;
@@ -62,16 +68,13 @@ class LinkCommand extends cli_1.BaseCommand {
62
68
  reference: `portal:${target}`,
63
69
  });
64
70
  }
65
- const report = await core_1.StreamReport.start({
66
- configuration,
71
+ return await project.installWithNewReport({
67
72
  stdout: this.context.stdout,
68
- }, async (report) => {
69
- await project.install({ cache, report });
73
+ }, {
74
+ cache,
70
75
  });
71
- return report.exitCode();
72
76
  }
73
77
  }
74
- exports.default = LinkCommand;
75
78
  LinkCommand.paths = [
76
79
  [`link`],
77
80
  ];
@@ -81,10 +84,11 @@ LinkCommand.usage = clipanion_1.Command.Usage({
81
84
  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
85
  `,
83
86
  examples: [[
84
- `Register a remote workspace for use in the current project`,
85
- `$0 link ~/ts-loader`,
87
+ `Register one or more remote workspaces for use in the current project`,
88
+ `$0 link ~/ts-loader ~/jest`,
86
89
  ], [
87
90
  `Register all workspaces from a remote project for use in the current project`,
88
91
  `$0 link ~/jest --all`,
89
92
  ]],
90
93
  });
94
+ 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;
@@ -0,0 +1,8 @@
1
+ import { BaseCommand } from '@yarnpkg/cli';
2
+ import { Usage } from 'clipanion';
3
+ export default class PluginCheckCommand extends BaseCommand {
4
+ static paths: string[][];
5
+ static usage: Usage;
6
+ json: boolean;
7
+ execute(): Promise<0 | 1>;
8
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_1 = require("@yarnpkg/cli");
4
+ const core_1 = require("@yarnpkg/core");
5
+ const clipanion_1 = require("clipanion");
6
+ // eslint-disable-next-line arca/no-default-export
7
+ class PluginCheckCommand extends cli_1.BaseCommand {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.json = clipanion_1.Option.Boolean(`--json`, false, {
11
+ description: `Format the output as an NDJSON stream`,
12
+ });
13
+ }
14
+ async execute() {
15
+ const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
16
+ const rcFiles = await core_1.Configuration.findRcFiles(this.context.cwd);
17
+ const report = await core_1.StreamReport.start({
18
+ configuration,
19
+ json: this.json,
20
+ stdout: this.context.stdout,
21
+ }, async (report) => {
22
+ for (const rcFile of rcFiles) {
23
+ if (!rcFile.data?.plugins)
24
+ continue;
25
+ for (const plugin of rcFile.data.plugins) {
26
+ if (!plugin.checksum)
27
+ continue;
28
+ if (!plugin.spec.match(/^https?:/))
29
+ continue;
30
+ const newBuffer = await core_1.httpUtils.get(plugin.spec, { configuration });
31
+ const newChecksum = core_1.hashUtils.makeHash(newBuffer);
32
+ if (plugin.checksum === newChecksum)
33
+ continue;
34
+ const prettyPath = core_1.formatUtils.pretty(configuration, plugin.path, core_1.formatUtils.Type.PATH);
35
+ const prettySpec = core_1.formatUtils.pretty(configuration, plugin.spec, core_1.formatUtils.Type.URL);
36
+ const prettyMessage = `${prettyPath} is different from the file provided by ${prettySpec}`;
37
+ report.reportJson({ ...plugin, newChecksum });
38
+ report.reportError(core_1.MessageName.UNNAMED, prettyMessage);
39
+ }
40
+ }
41
+ });
42
+ return report.exitCode();
43
+ }
44
+ }
45
+ PluginCheckCommand.paths = [
46
+ [`plugin`, `check`],
47
+ ];
48
+ PluginCheckCommand.usage = clipanion_1.Command.Usage({
49
+ category: `Plugin-related commands`,
50
+ description: `find all third-party plugins that differ from their own spec`,
51
+ details: `
52
+ Check only the plugins from https.
53
+
54
+ If this command detects any plugin differences in the CI environment, it will throw an error.
55
+ `,
56
+ examples: [[
57
+ `find all third-party plugins that differ from their own spec`,
58
+ `$0 plugin check`,
59
+ ]],
60
+ });
61
+ exports.default = PluginCheckCommand;
@@ -3,7 +3,7 @@ import { Report, CommandContext } from '@yarnpkg/core';
3
3
  import { Project } from '@yarnpkg/core';
4
4
  import { PortablePath } from '@yarnpkg/fslib';
5
5
  import { Usage } from 'clipanion';
6
- export default class PluginDlSourcesCommand extends BaseCommand {
6
+ export default class PluginImportSourcesCommand extends BaseCommand {
7
7
  static paths: string[][];
8
8
  static usage: Usage;
9
9
  installPath: string | undefined;
@@ -12,9 +12,9 @@ export default class PluginDlSourcesCommand extends BaseCommand {
12
12
  noMinify: boolean;
13
13
  force: boolean;
14
14
  name: string;
15
- execute(): Promise<1 | 0>;
15
+ execute(): Promise<0 | 1>;
16
16
  }
17
- export declare type BuildAndSavePluginsSpec = {
17
+ export type BuildAndSavePluginsSpec = {
18
18
  context: CommandContext;
19
19
  noMinify: boolean;
20
20
  };
@@ -14,7 +14,7 @@ const buildWorkflow = ({ pluginName, noMinify }, target) => [
14
14
  [`yarn`, `build:${pluginName}`, ...noMinify ? [`--no-minify`] : [], `|`],
15
15
  ];
16
16
  // eslint-disable-next-line arca/no-default-export
17
- class PluginDlSourcesCommand extends cli_1.BaseCommand {
17
+ class PluginImportSourcesCommand extends cli_1.BaseCommand {
18
18
  constructor() {
19
19
  super(...arguments);
20
20
  this.installPath = clipanion_1.Option.String(`--path`, {
@@ -47,7 +47,7 @@ class PluginDlSourcesCommand extends cli_1.BaseCommand {
47
47
  const ident = core_1.structUtils.parseIdent(this.name.replace(/^((@yarnpkg\/)?plugin-)?/, `@yarnpkg/plugin-`));
48
48
  const identStr = core_1.structUtils.stringifyIdent(ident);
49
49
  const data = await (0, list_1.getAvailablePlugins)(configuration, core_1.YarnVersion);
50
- if (!Object.prototype.hasOwnProperty.call(data, identStr))
50
+ if (!Object.hasOwn(data, identStr))
51
51
  throw new core_2.ReportError(core_2.MessageName.PLUGIN_NAME_NOT_FOUND, `Couldn't find a plugin named "${identStr}" on the remote registry. Note that only the plugins referenced on our website (https://github.com/yarnpkg/berry/blob/master/plugins.yml) can be built and imported from sources.`);
52
52
  const pluginSpec = identStr;
53
53
  await (0, sources_1.prepareRepo)(this, { configuration, report, target });
@@ -56,11 +56,10 @@ class PluginDlSourcesCommand extends cli_1.BaseCommand {
56
56
  return report.exitCode();
57
57
  }
58
58
  }
59
- exports.default = PluginDlSourcesCommand;
60
- PluginDlSourcesCommand.paths = [
59
+ PluginImportSourcesCommand.paths = [
61
60
  [`plugin`, `import`, `from`, `sources`],
62
61
  ];
63
- PluginDlSourcesCommand.usage = clipanion_1.Command.Usage({
62
+ PluginImportSourcesCommand.usage = clipanion_1.Command.Usage({
64
63
  category: `Plugin-related commands`,
65
64
  description: `build a plugin from sources`,
66
65
  details: `
@@ -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 = PluginImportSourcesCommand;
79
79
  async function buildAndSavePlugin(pluginSpec, { context, noMinify }, { project, report, target }) {
80
80
  const pluginName = pluginSpec.replace(/@yarnpkg\//, ``);
81
81
  const { configuration } = project;
@@ -1,15 +1,16 @@
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';
6
- export default class PluginDlCommand extends BaseCommand {
5
+ export default class PluginImportCommand extends BaseCommand {
7
6
  static paths: string[][];
8
7
  static usage: Usage;
9
8
  name: string;
10
- execute(): Promise<1 | 0>;
9
+ checksum: boolean;
10
+ execute(): Promise<0 | 1>;
11
11
  }
12
- export declare function savePlugin(pluginSpec: string, pluginBuffer: Buffer, { project, report }: {
12
+ export declare function savePlugin(pluginSpec: string, pluginBuffer: Buffer, { checksum, project, report }: {
13
+ checksum?: boolean;
13
14
  project: Project;
14
15
  report: Report;
15
16
  }): Promise<void>;
@@ -12,10 +12,13 @@ const url_1 = require("url");
12
12
  const vm_1 = require("vm");
13
13
  const list_1 = require("./list");
14
14
  // eslint-disable-next-line arca/no-default-export
15
- class PluginDlCommand extends cli_1.BaseCommand {
15
+ class PluginImportCommand extends cli_1.BaseCommand {
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  this.name = clipanion_1.Option.String();
19
+ this.checksum = clipanion_1.Option.Boolean(`--checksum`, true, {
20
+ description: `Whether to care if this plugin is modified`,
21
+ });
19
22
  }
20
23
  async execute() {
21
24
  const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
@@ -50,7 +53,7 @@ class PluginDlCommand extends cli_1.BaseCommand {
50
53
  throw new core_1.ReportError(core_1.MessageName.UNNAMED, `Official plugins only accept strict version references. Use an explicit URL if you wish to download them from another location.`);
51
54
  const identStr = core_2.structUtils.stringifyIdent(locator);
52
55
  const data = await (0, list_1.getAvailablePlugins)(configuration, core_2.YarnVersion);
53
- if (!Object.prototype.hasOwnProperty.call(data, identStr)) {
56
+ if (!Object.hasOwn(data, identStr)) {
54
57
  let message = `Couldn't find a plugin named ${core_2.structUtils.prettyIdent(configuration, locator)} on the remote registry.\n`;
55
58
  if (configuration.plugins.has(identStr))
56
59
  message += `A plugin named ${core_2.structUtils.prettyIdent(configuration, locator)} is already installed; possibly attempting to import a built-in plugin.`;
@@ -70,16 +73,15 @@ class PluginDlCommand extends cli_1.BaseCommand {
70
73
  report.reportInfo(core_1.MessageName.UNNAMED, `Downloading ${core_2.formatUtils.pretty(configuration, pluginUrl, `green`)}`);
71
74
  pluginBuffer = await core_2.httpUtils.get(pluginUrl, { configuration });
72
75
  }
73
- await savePlugin(pluginSpec, pluginBuffer, { project, report });
76
+ await savePlugin(pluginSpec, pluginBuffer, { checksum: this.checksum, project, report });
74
77
  });
75
78
  return report.exitCode();
76
79
  }
77
80
  }
78
- exports.default = PluginDlCommand;
79
- PluginDlCommand.paths = [
81
+ PluginImportCommand.paths = [
80
82
  [`plugin`, `import`],
81
83
  ];
82
- PluginDlCommand.usage = clipanion_1.Command.Usage({
84
+ PluginImportCommand.usage = clipanion_1.Command.Usage({
83
85
  category: `Plugin-related commands`,
84
86
  description: `download a plugin`,
85
87
  details: `
@@ -91,6 +93,8 @@ PluginDlCommand.usage = clipanion_1.Command.Usage({
91
93
  - Third-party plugins can be referenced directly through their public urls.
92
94
  - Local plugins can be referenced by their path on the disk.
93
95
 
96
+ If the \`--no-checksum\` option is set, Yarn will no longer care if the plugin is modified.
97
+
94
98
  Plugins cannot be downloaded from the npm registry, and aren't allowed to have dependencies (they need to be bundled into a single file, possibly thanks to the \`@yarnpkg/builder\` package).
95
99
  `,
96
100
  examples: [[
@@ -107,7 +111,8 @@ PluginDlCommand.usage = clipanion_1.Command.Usage({
107
111
  `$0 plugin import ./path/to/plugin.js`,
108
112
  ]],
109
113
  });
110
- async function savePlugin(pluginSpec, pluginBuffer, { project, report }) {
114
+ exports.default = PluginImportCommand;
115
+ async function savePlugin(pluginSpec, pluginBuffer, { checksum = true, project, report }) {
111
116
  const { configuration } = project;
112
117
  const vmExports = {};
113
118
  const vmModule = { exports: vmExports };
@@ -125,26 +130,8 @@ async function savePlugin(pluginSpec, pluginBuffer, { project, report }) {
125
130
  path: relativePath,
126
131
  spec: pluginSpec,
127
132
  };
128
- await core_1.Configuration.updateConfiguration(project.cwd, (current) => {
129
- const plugins = [];
130
- let hasBeenReplaced = false;
131
- for (const entry of current.plugins || []) {
132
- const userProvidedPath = typeof entry !== `string`
133
- ? entry.path
134
- : entry;
135
- const pluginPath = fslib_1.ppath.resolve(project.cwd, fslib_1.npath.toPortablePath(userProvidedPath));
136
- const { name } = core_1.miscUtils.dynamicRequire(pluginPath);
137
- if (name !== pluginName) {
138
- plugins.push(entry);
139
- }
140
- else {
141
- plugins.push(pluginMeta);
142
- hasBeenReplaced = true;
143
- }
144
- }
145
- if (!hasBeenReplaced)
146
- plugins.push(pluginMeta);
147
- return { ...current, plugins };
148
- });
133
+ if (checksum)
134
+ pluginMeta.checksum = core_2.hashUtils.makeHash(pluginBuffer);
135
+ await core_1.Configuration.addPlugin(project.cwd, [pluginMeta]);
149
136
  }
150
137
  exports.savePlugin = savePlugin;
@@ -4,9 +4,9 @@ import { Usage } from 'clipanion';
4
4
  export declare function getAvailablePlugins(configuration: Configuration, version: string | null): Promise<{
5
5
  [k: string]: any;
6
6
  }>;
7
- export default class PluginDlCommand extends BaseCommand {
7
+ export default class PluginListCommand extends BaseCommand {
8
8
  static paths: string[][];
9
9
  static usage: Usage;
10
10
  json: boolean;
11
- execute(): Promise<1 | 0>;
11
+ execute(): Promise<0 | 1>;
12
12
  }
@@ -10,13 +10,12 @@ async function getAvailablePlugins(configuration, version) {
10
10
  const raw = await core_1.httpUtils.get(REMOTE_REGISTRY, { configuration });
11
11
  const data = (0, parsers_1.parseSyml)(raw.toString());
12
12
  return Object.fromEntries(Object.entries(data).filter(([pluginName, pluginData]) => {
13
- var _a;
14
- return !version || core_1.semverUtils.satisfiesWithPrereleases(version, (_a = pluginData.range) !== null && _a !== void 0 ? _a : `<4.0.0-rc.1`);
13
+ return !version || core_1.semverUtils.satisfiesWithPrereleases(version, pluginData.range ?? `<4.0.0-rc.1`);
15
14
  }));
16
15
  }
17
16
  exports.getAvailablePlugins = getAvailablePlugins;
18
17
  // eslint-disable-next-line arca/no-default-export
19
- class PluginDlCommand extends cli_1.BaseCommand {
18
+ class PluginListCommand extends cli_1.BaseCommand {
20
19
  constructor() {
21
20
  super(...arguments);
22
21
  this.json = clipanion_1.Option.Boolean(`--json`, false, {
@@ -42,11 +41,10 @@ class PluginDlCommand extends cli_1.BaseCommand {
42
41
  return report.exitCode();
43
42
  }
44
43
  }
45
- exports.default = PluginDlCommand;
46
- PluginDlCommand.paths = [
44
+ PluginListCommand.paths = [
47
45
  [`plugin`, `list`],
48
46
  ];
49
- PluginDlCommand.usage = clipanion_1.Command.Usage({
47
+ PluginListCommand.usage = clipanion_1.Command.Usage({
50
48
  category: `Plugin-related commands`,
51
49
  description: `list the available official plugins`,
52
50
  details: `
@@ -57,3 +55,4 @@ PluginDlCommand.usage = clipanion_1.Command.Usage({
57
55
  `$0 plugin list`,
58
56
  ]],
59
57
  });
58
+ exports.default = PluginListCommand;
@@ -4,5 +4,5 @@ export default class PluginRemoveCommand extends BaseCommand {
4
4
  static paths: string[][];
5
5
  static usage: Usage;
6
6
  name: string;
7
- execute(): Promise<1 | 0>;
7
+ execute(): Promise<0 | 1>;
8
8
  }
@@ -28,24 +28,24 @@ class PluginRemoveCommand extends cli_1.BaseCommand {
28
28
  await fslib_1.xfs.removePromise(absolutePath);
29
29
  }
30
30
  report.reportInfo(core_1.MessageName.UNNAMED, `Updating the configuration...`);
31
- await core_1.Configuration.updateConfiguration(project.cwd, (current) => {
32
- if (!Array.isArray(current.plugins))
33
- return current;
34
- const plugins = current.plugins.filter((plugin) => {
35
- return plugin.path !== relativePath;
36
- });
37
- if (current.plugins.length === plugins.length)
38
- return current;
39
- return {
40
- ...current,
41
- plugins,
42
- };
31
+ await core_1.Configuration.updateConfiguration(project.cwd, {
32
+ plugins: plugins => {
33
+ if (!Array.isArray(plugins))
34
+ return plugins;
35
+ const filteredPlugins = plugins.filter((plugin) => {
36
+ return plugin.path !== relativePath;
37
+ });
38
+ if (filteredPlugins.length === 0)
39
+ return core_1.Configuration.deleteProperty;
40
+ if (filteredPlugins.length === plugins.length)
41
+ return plugins;
42
+ return filteredPlugins;
43
+ },
43
44
  });
44
45
  });
45
46
  return report.exitCode();
46
47
  }
47
48
  }
48
- exports.default = PluginRemoveCommand;
49
49
  PluginRemoveCommand.paths = [
50
50
  [`plugin`, `remove`],
51
51
  ];
@@ -65,3 +65,4 @@ PluginRemoveCommand.usage = clipanion_1.Command.Usage({
65
65
  `$0 plugin remove my-local-plugin`,
66
66
  ]],
67
67
  });
68
+ exports.default = PluginRemoveCommand;
@@ -1,8 +1,8 @@
1
1
  import { BaseCommand } from '@yarnpkg/cli';
2
2
  import { Usage } from 'clipanion';
3
- export default class PluginListCommand extends BaseCommand {
3
+ export default class PluginRuntimeCommand extends BaseCommand {
4
4
  static paths: string[][];
5
5
  static usage: Usage;
6
6
  json: boolean;
7
- execute(): Promise<1 | 0>;
7
+ execute(): Promise<0 | 1>;
8
8
  }
@@ -4,7 +4,7 @@ const cli_1 = require("@yarnpkg/cli");
4
4
  const core_1 = require("@yarnpkg/core");
5
5
  const clipanion_1 = require("clipanion");
6
6
  // eslint-disable-next-line arca/no-default-export
7
- class PluginListCommand extends cli_1.BaseCommand {
7
+ class PluginRuntimeCommand extends cli_1.BaseCommand {
8
8
  constructor() {
9
9
  super(...arguments);
10
10
  this.json = clipanion_1.Option.Boolean(`--json`, false, {
@@ -30,11 +30,10 @@ class PluginListCommand extends cli_1.BaseCommand {
30
30
  return report.exitCode();
31
31
  }
32
32
  }
33
- exports.default = PluginListCommand;
34
- PluginListCommand.paths = [
33
+ PluginRuntimeCommand.paths = [
35
34
  [`plugin`, `runtime`],
36
35
  ];
37
- PluginListCommand.usage = clipanion_1.Command.Usage({
36
+ PluginRuntimeCommand.usage = clipanion_1.Command.Usage({
38
37
  category: `Plugin-related commands`,
39
38
  description: `list the active plugins`,
40
39
  details: `
@@ -45,3 +44,4 @@ PluginListCommand.usage = clipanion_1.Command.Usage({
45
44
  `$0 plugin runtime`,
46
45
  ]],
47
46
  });
47
+ exports.default = PluginRuntimeCommand;
@@ -1,8 +1,8 @@
1
1
  import { BaseCommand } from '@yarnpkg/cli';
2
2
  import { Usage } from 'clipanion';
3
- export default class RunCommand extends BaseCommand {
3
+ export default class RebuildCommand extends BaseCommand {
4
4
  static paths: string[][];
5
5
  static usage: Usage;
6
6
  idents: string[];
7
- execute(): Promise<1 | 0>;
7
+ execute(): Promise<0 | 1>;
8
8
  }
@@ -5,7 +5,7 @@ const core_1 = require("@yarnpkg/core");
5
5
  const core_2 = require("@yarnpkg/core");
6
6
  const clipanion_1 = require("clipanion");
7
7
  // eslint-disable-next-line arca/no-default-export
8
- class RunCommand extends cli_1.BaseCommand {
8
+ class RebuildCommand extends cli_1.BaseCommand {
9
9
  constructor() {
10
10
  super(...arguments);
11
11
  this.idents = clipanion_1.Option.Rest();
@@ -30,27 +30,26 @@ class RunCommand extends cli_1.BaseCommand {
30
30
  for (const pkg of project.storedPackages.values()) {
31
31
  if (filteredIdents.has(pkg.identHash)) {
32
32
  project.storedBuildState.delete(pkg.locatorHash);
33
+ project.skippedBuilds.delete(pkg.locatorHash);
33
34
  }
34
35
  }
35
36
  }
36
37
  else {
37
38
  project.storedBuildState.clear();
39
+ project.skippedBuilds.clear();
38
40
  }
39
- const installReport = await core_1.StreamReport.start({
40
- configuration,
41
+ return await project.installWithNewReport({
41
42
  stdout: this.context.stdout,
42
- includeLogs: !this.context.quiet,
43
- }, async (report) => {
44
- await project.install({ cache, report });
43
+ quiet: this.context.quiet,
44
+ }, {
45
+ cache,
45
46
  });
46
- return installReport.exitCode();
47
47
  }
48
48
  }
49
- exports.default = RunCommand;
50
- RunCommand.paths = [
49
+ RebuildCommand.paths = [
51
50
  [`rebuild`],
52
51
  ];
53
- RunCommand.usage = clipanion_1.Command.Usage({
52
+ RebuildCommand.usage = clipanion_1.Command.Usage({
54
53
  description: `rebuild the project's native packages`,
55
54
  details: `
56
55
  This command will automatically cause Yarn to forget about previous compilations of the given packages and to run them again.
@@ -67,3 +66,4 @@ RunCommand.usage = clipanion_1.Command.Usage({
67
66
  `$0 rebuild fsevents`,
68
67
  ]],
69
68
  });
69
+ exports.default = RebuildCommand;
@@ -7,5 +7,5 @@ export default class RemoveCommand extends BaseCommand {
7
7
  all: boolean;
8
8
  mode: InstallMode | undefined;
9
9
  patterns: string[];
10
- execute(): Promise<1 | 0>;
10
+ execute(): Promise<0 | 1>;
11
11
  }
@@ -89,21 +89,19 @@ 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
- const report = await core_2.StreamReport.start({
96
- configuration,
95
+ return await project.installWithNewReport({
97
96
  stdout: this.context.stdout,
98
- }, async (report) => {
99
- await project.install({ cache, report, mode: this.mode });
97
+ }, {
98
+ cache,
99
+ mode: this.mode,
100
100
  });
101
- return report.exitCode();
102
101
  }
103
102
  return 0;
104
103
  }
105
104
  }
106
- exports.default = RemoveCommand;
107
105
  RemoveCommand.paths = [
108
106
  [`remove`],
109
107
  ];
@@ -114,7 +112,7 @@ RemoveCommand.usage = clipanion_1.Command.Usage({
114
112
 
115
113
  If the \`--mode=<mode>\` option is set, Yarn will change which artifacts are generated. The modes currently supported are:
116
114
 
117
- - \`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.
115
+ - \`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.
118
116
 
119
117
  - \`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.
120
118
 
@@ -137,3 +135,4 @@ RemoveCommand.usage = clipanion_1.Command.Usage({
137
135
  `$0 remove 'react-{dom,helmet}'`,
138
136
  ]],
139
137
  });
138
+ exports.default = RemoveCommand;
@@ -117,7 +117,6 @@ class RunCommand extends cli_1.BaseCommand {
117
117
  }
118
118
  }
119
119
  }
120
- exports.default = RunCommand;
121
120
  RunCommand.paths = [
122
121
  [`run`],
123
122
  ];
@@ -145,3 +144,4 @@ RunCommand.usage = clipanion_1.Command.Usage({
145
144
  `$0 run --inspect-brk webpack`,
146
145
  ]],
147
146
  });
147
+ exports.default = RunCommand;
@@ -1,5 +1,5 @@
1
1
  import { BaseCommand } from '@yarnpkg/cli';
2
- export default class RunCommand extends BaseCommand {
2
+ export default class RunIndexCommand extends BaseCommand {
3
3
  static paths: string[][];
4
- execute(): Promise<1 | 0>;
4
+ execute(): Promise<0 | 1>;
5
5
  }