@yarnpkg/plugin-essentials 4.0.0-rc.5 → 4.0.0-rc.50

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 +1 -1
  8. package/lib/commands/config/get.js +1 -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 +1 -1
  14. package/lib/commands/config.js +1 -1
  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 +8 -12
  25. package/lib/commands/install.d.ts +1 -1
  26. package/lib/commands/install.js +188 -107
  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 +10 -10
  69. package/package.json +23 -17
@@ -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
  }
@@ -5,7 +5,7 @@ const core_1 = require("@yarnpkg/core");
5
5
  const core_2 = require("@yarnpkg/core");
6
6
  const util_1 = require("util");
7
7
  // eslint-disable-next-line arca/no-default-export
8
- class RunCommand extends cli_1.BaseCommand {
8
+ class RunIndexCommand extends cli_1.BaseCommand {
9
9
  async execute() {
10
10
  const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
11
11
  const { project, workspace } = await core_1.Project.find(configuration, this.context.cwd);
@@ -32,7 +32,7 @@ class RunCommand extends cli_1.BaseCommand {
32
32
  return report.exitCode();
33
33
  }
34
34
  }
35
- exports.default = RunCommand;
36
- RunCommand.paths = [
35
+ RunIndexCommand.paths = [
37
36
  [`run`],
38
37
  ];
38
+ exports.default = RunIndexCommand;
@@ -6,5 +6,5 @@ export default class SetResolutionCommand extends BaseCommand {
6
6
  save: boolean;
7
7
  descriptor: string;
8
8
  resolution: string;
9
- execute(): Promise<1 | 0>;
9
+ execute(): Promise<0 | 1>;
10
10
  }
@@ -28,16 +28,13 @@ class SetResolutionCommand extends cli_1.BaseCommand {
28
28
  project.storedDescriptors.set(fromDescriptor.descriptorHash, fromDescriptor);
29
29
  project.storedDescriptors.set(toDescriptor.descriptorHash, toDescriptor);
30
30
  project.resolutionAliases.set(fromDescriptor.descriptorHash, toDescriptor.descriptorHash);
31
- const report = await core_1.StreamReport.start({
32
- configuration,
31
+ return await project.installWithNewReport({
33
32
  stdout: this.context.stdout,
34
- }, async (report) => {
35
- await project.install({ cache, report });
33
+ }, {
34
+ cache,
36
35
  });
37
- return report.exitCode();
38
36
  }
39
37
  }
40
- exports.default = SetResolutionCommand;
41
38
  SetResolutionCommand.paths = [
42
39
  [`set`, `resolution`],
43
40
  ];
@@ -55,3 +52,4 @@ SetResolutionCommand.usage = clipanion_1.Command.Usage({
55
52
  `$0 set resolution lodash@npm:^1.2.3 1.5.0`,
56
53
  ]],
57
54
  });
55
+ exports.default = SetResolutionCommand;
@@ -9,17 +9,18 @@ export default class SetVersionSourcesCommand extends BaseCommand {
9
9
  repository: string;
10
10
  branch: string;
11
11
  plugins: string[];
12
+ dryRun: boolean;
12
13
  noMinify: boolean;
13
14
  force: boolean;
14
15
  skipPlugins: boolean;
15
- execute(): Promise<1 | 0>;
16
+ execute(): Promise<0 | 1>;
16
17
  }
17
18
  export declare function runWorkflow(workflow: Array<Array<string>>, { configuration, context, target }: {
18
19
  configuration: Configuration;
19
20
  context: CommandContext;
20
21
  target: PortablePath;
21
22
  }): Promise<void>;
22
- export declare type PrepareSpec = {
23
+ export type PrepareSpec = {
23
24
  branch: string;
24
25
  context: CommandContext;
25
26
  force: boolean;
@@ -27,10 +27,11 @@ const cloneWorkflow = ({ repository, branch }, target) => [
27
27
  const updateWorkflow = ({ branch }) => [
28
28
  [`git`, `fetch`, `origin`, `--depth=1`, getBranchRef(branch), `--force`],
29
29
  [`git`, `reset`, `--hard`, `FETCH_HEAD`],
30
- [`git`, `clean`, `-dfx`],
30
+ [`git`, `clean`, `-dfx`, `-e`, `packages/yarnpkg-cli/bundles`],
31
31
  ];
32
- const buildWorkflow = ({ plugins, noMinify }, target) => [
32
+ const buildWorkflow = ({ plugins, noMinify }, output, target) => [
33
33
  [`yarn`, `build:cli`, ...new Array().concat(...plugins.map(plugin => [`--plugin`, fslib_1.ppath.resolve(target, plugin)])), ...noMinify ? [`--no-minify`] : [], `|`],
34
+ [`mv`, `packages/yarnpkg-cli/bundles/yarn.js`, fslib_1.npath.fromPortablePath(output), `|`],
34
35
  ];
35
36
  // eslint-disable-next-line arca/no-default-export
36
37
  class SetVersionSourcesCommand extends cli_1.BaseCommand {
@@ -48,6 +49,9 @@ class SetVersionSourcesCommand extends cli_1.BaseCommand {
48
49
  this.plugins = clipanion_1.Option.Array(`--plugin`, [], {
49
50
  description: `An array of additional plugins that should be included in the bundle`,
50
51
  });
52
+ this.dryRun = clipanion_1.Option.Boolean(`-n,--dry-run`, false, {
53
+ description: `If set, the bundle will be built but not added to the project`,
54
+ });
51
55
  this.noMinify = clipanion_1.Option.Boolean(`--no-minify`, false, {
52
56
  description: `Build a bundle for development (debugging) - non-minified and non-mangled`,
53
57
  });
@@ -72,21 +76,25 @@ class SetVersionSourcesCommand extends cli_1.BaseCommand {
72
76
  report.reportSeparator();
73
77
  report.reportInfo(core_1.MessageName.UNNAMED, `Building a fresh bundle`);
74
78
  report.reportSeparator();
75
- await runWorkflow(buildWorkflow(this, target), { configuration, context: this.context, target });
76
- report.reportSeparator();
77
- const bundlePath = fslib_1.ppath.resolve(target, `packages/yarnpkg-cli/bundles/yarn.js`);
79
+ const commitHash = await core_1.execUtils.execvp(`git`, [`rev-parse`, `--short`, `HEAD`], { cwd: target, strict: true });
80
+ const bundlePath = fslib_1.ppath.join(target, `packages/yarnpkg-cli/bundles/yarn-${commitHash.stdout.trim()}.js`);
81
+ if (!fslib_1.xfs.existsSync(bundlePath)) {
82
+ await runWorkflow(buildWorkflow(this, bundlePath, target), { configuration, context: this.context, target });
83
+ report.reportSeparator();
84
+ }
78
85
  const bundleBuffer = await fslib_1.xfs.readFilePromise(bundlePath);
79
- const { bundleVersion } = await (0, version_1.setVersion)(configuration, null, async () => bundleBuffer, {
80
- report,
81
- });
82
- if (!this.skipPlugins) {
83
- await updatePlugins(this, bundleVersion, { project, report, target });
86
+ if (!this.dryRun) {
87
+ const { bundleVersion } = await (0, version_1.setVersion)(configuration, null, async () => bundleBuffer, {
88
+ report,
89
+ });
90
+ if (!this.skipPlugins) {
91
+ await updatePlugins(this, bundleVersion, { project, report, target });
92
+ }
84
93
  }
85
94
  });
86
95
  return report.exitCode();
87
96
  }
88
97
  }
89
- exports.default = SetVersionSourcesCommand;
90
98
  SetVersionSourcesCommand.paths = [
91
99
  [`set`, `version`, `from`, `sources`],
92
100
  ];
@@ -102,6 +110,7 @@ SetVersionSourcesCommand.usage = clipanion_1.Command.Usage({
102
110
  `$0 set version from sources`,
103
111
  ]],
104
112
  });
113
+ exports.default = SetVersionSourcesCommand;
105
114
  async function runWorkflow(workflow, { configuration, context, target }) {
106
115
  for (const [fileName, ...args] of workflow) {
107
116
  const usePipe = args[args.length - 1] === `|`;
@@ -141,7 +150,7 @@ async function prepareRepo(spec, { configuration, report, target }) {
141
150
  await runWorkflow(updateWorkflow(spec), { configuration, context: spec.context, target });
142
151
  ready = true;
143
152
  }
144
- catch (error) {
153
+ catch {
145
154
  report.reportSeparator();
146
155
  report.reportWarning(core_1.MessageName.UNNAMED, `Repository update failed; we'll try to regenerate it`);
147
156
  }
@@ -1,9 +1,8 @@
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';
6
- export declare type Tags = {
5
+ export type Tags = {
7
6
  latest: Record<string, string>;
8
7
  tags: Array<string>;
9
8
  };
@@ -13,7 +12,7 @@ export default class SetVersionCommand extends BaseCommand {
13
12
  useYarnPath: boolean | undefined;
14
13
  onlyIfNeeded: boolean;
15
14
  version: string;
16
- execute(): Promise<1 | 0>;
15
+ execute(): Promise<0 | 1>;
17
16
  }
18
17
  export declare function resolveRange(configuration: Configuration, request: string): Promise<string>;
19
18
  export declare function resolveTag(configuration: Configuration, request: `stable` | `canary`): Promise<string>;