@yarnpkg/plugin-essentials 3.0.0-rc.9 → 3.1.0-rc.10

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 (60) hide show
  1. package/lib/commands/add.d.ts +5 -2
  2. package/lib/commands/add.js +16 -4
  3. package/lib/commands/bin.d.ts +1 -1
  4. package/lib/commands/cache/clean.d.ts +1 -1
  5. package/lib/commands/config/get.d.ts +1 -1
  6. package/lib/commands/config/get.js +3 -3
  7. package/lib/commands/config/set.d.ts +1 -1
  8. package/lib/commands/config/set.js +9 -7
  9. package/lib/commands/config/unset.d.ts +1 -1
  10. package/lib/commands/config/unset.js +6 -6
  11. package/lib/commands/config.d.ts +1 -1
  12. package/lib/commands/config.js +2 -2
  13. package/lib/commands/dedupe.d.ts +3 -1
  14. package/lib/commands/dedupe.js +13 -3
  15. package/lib/commands/entries/clipanion.d.ts +2 -3
  16. package/lib/commands/entries/clipanion.js +3 -4
  17. package/lib/commands/entries/help.d.ts +2 -3
  18. package/lib/commands/entries/help.js +2 -2
  19. package/lib/commands/entries/run.d.ts +2 -3
  20. package/lib/commands/entries/run.js +2 -1
  21. package/lib/commands/entries/version.d.ts +2 -3
  22. package/lib/commands/entries/version.js +2 -2
  23. package/lib/commands/exec.js +7 -10
  24. package/lib/commands/explain/peerRequirements.d.ts +2 -2
  25. package/lib/commands/explain/peerRequirements.js +1 -1
  26. package/lib/commands/info.js +2 -2
  27. package/lib/commands/install.d.ts +4 -2
  28. package/lib/commands/install.js +24 -17
  29. package/lib/commands/link.d.ts +1 -1
  30. package/lib/commands/plugin/import/sources.d.ts +1 -1
  31. package/lib/commands/plugin/import/sources.js +5 -5
  32. package/lib/commands/plugin/import.d.ts +1 -1
  33. package/lib/commands/plugin/import.js +5 -5
  34. package/lib/commands/plugin/list.d.ts +1 -1
  35. package/lib/commands/plugin/list.js +1 -1
  36. package/lib/commands/plugin/remove.d.ts +1 -1
  37. package/lib/commands/plugin/runtime.d.ts +1 -1
  38. package/lib/commands/rebuild.d.ts +1 -1
  39. package/lib/commands/remove.d.ts +3 -1
  40. package/lib/commands/remove.js +16 -5
  41. package/lib/commands/run.js +6 -6
  42. package/lib/commands/runIndex.d.ts +1 -1
  43. package/lib/commands/runIndex.js +1 -1
  44. package/lib/commands/set/resolution.d.ts +1 -1
  45. package/lib/commands/set/version/sources.d.ts +1 -1
  46. package/lib/commands/set/version/sources.js +4 -4
  47. package/lib/commands/set/version.d.ts +7 -2
  48. package/lib/commands/set/version.js +45 -10
  49. package/lib/commands/unlink.d.ts +1 -1
  50. package/lib/commands/unlink.js +2 -2
  51. package/lib/commands/up.d.ts +5 -3
  52. package/lib/commands/up.js +17 -7
  53. package/lib/commands/workspace.d.ts +3 -3
  54. package/lib/commands/workspace.js +1 -1
  55. package/lib/commands/workspaces/list.d.ts +1 -1
  56. package/lib/dedupeUtils.js +1 -1
  57. package/lib/index.js +37 -37
  58. package/lib/suggestUtils.d.ts +7 -0
  59. package/lib/suggestUtils.js +30 -5
  60. package/package.json +11 -13
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
3
4
  const cli_1 = require("@yarnpkg/cli");
4
5
  const core_1 = require("@yarnpkg/core");
5
6
  const fslib_1 = require("@yarnpkg/fslib");
6
7
  const parsers_1 = require("@yarnpkg/parsers");
8
+ const ci_info_1 = (0, tslib_1.__importDefault)(require("ci-info"));
7
9
  const clipanion_1 = require("clipanion");
10
+ const t = (0, tslib_1.__importStar)(require("typanion"));
8
11
  // eslint-disable-next-line arca/no-default-export
9
12
  class YarnCommand extends cli_1.BaseCommand {
10
13
  constructor() {
@@ -24,8 +27,9 @@ class YarnCommand extends cli_1.BaseCommand {
24
27
  this.inlineBuilds = clipanion_1.Option.Boolean(`--inline-builds`, {
25
28
  description: `Verbosely print the output of the build steps of dependencies`,
26
29
  });
27
- this.skipBuilds = clipanion_1.Option.Boolean(`--skip-builds`, false, {
28
- description: `Skip the build step altogether`,
30
+ this.mode = clipanion_1.Option.String(`--mode`, {
31
+ description: `Change what artifacts installs generate`,
32
+ validator: t.isEnum(core_1.InstallMode),
29
33
  });
30
34
  // Legacy flags; will emit errors or warnings when used
31
35
  this.cacheFolder = clipanion_1.Option.String(`--cache-folder`, { hidden: true });
@@ -36,14 +40,13 @@ class YarnCommand extends cli_1.BaseCommand {
36
40
  this.production = clipanion_1.Option.Boolean(`--production`, { hidden: true });
37
41
  this.registry = clipanion_1.Option.String(`--registry`, { hidden: true });
38
42
  this.silent = clipanion_1.Option.Boolean(`--silent`, { hidden: true });
43
+ this.networkTimeout = clipanion_1.Option.String(`--network-timeout`, { hidden: true });
39
44
  }
40
45
  async execute() {
41
46
  var _a;
42
47
  const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
43
48
  if (typeof this.inlineBuilds !== `undefined`)
44
49
  configuration.useWithSource(`<cli>`, { enableInlineBuilds: this.inlineBuilds }, configuration.startingCwd, { overwrite: true });
45
- const isZeitNow = !!process.env.NOW_BUILDER;
46
- const isNetlify = !!process.env.NETLIFY;
47
50
  // These variables are used in Google Cloud Platform environment
48
51
  // in process of deploying Google Cloud Functions and
49
52
  // Google App Engine
@@ -76,7 +79,7 @@ class YarnCommand extends cli_1.BaseCommand {
76
79
  // it would definitely be a configuration setting.
77
80
  if (typeof this.ignoreEngines !== `undefined`) {
78
81
  const exitCode = await reportDeprecation(`The --ignore-engines option is deprecated; engine checking isn't a core feature anymore`, {
79
- error: !isZeitNow,
82
+ error: !ci_info_1.default.VERCEL,
80
83
  });
81
84
  if (exitCode !== null) {
82
85
  return exitCode;
@@ -102,7 +105,7 @@ class YarnCommand extends cli_1.BaseCommand {
102
105
  // let someone implement this "resolver-that-reads-the-cache" logic.
103
106
  if (typeof this.preferOffline !== `undefined`) {
104
107
  const exitCode = await reportDeprecation(`The --prefer-offline flag is deprecated; use the --cached flag with 'yarn add' instead`, {
105
- error: !isZeitNow,
108
+ error: !ci_info_1.default.VERCEL,
106
109
  });
107
110
  if (exitCode !== null) {
108
111
  return exitCode;
@@ -145,7 +148,7 @@ class YarnCommand extends cli_1.BaseCommand {
145
148
  // Yarn commands would use different caches, causing unexpected behaviors.
146
149
  if (typeof this.cacheFolder !== `undefined`) {
147
150
  const exitCode = await reportDeprecation(`The cache-folder option has been deprecated; use rc settings instead`, {
148
- error: !isNetlify,
151
+ error: !ci_info_1.default.NETLIFY,
149
152
  });
150
153
  if (exitCode !== null) {
151
154
  return exitCode;
@@ -174,7 +177,7 @@ class YarnCommand extends cli_1.BaseCommand {
174
177
  try {
175
178
  content = await fslib_1.xfs.readFilePromise(fslib_1.ppath.join(projectCwd, fslib_1.Filename.lockfile), `utf8`);
176
179
  }
177
- catch (_b) { }
180
+ catch { }
178
181
  // If migrating from a v1 install, we automatically enable the node-modules linker,
179
182
  // since that's likely what the author intended to do.
180
183
  if (content === null || content === void 0 ? void 0 : content.includes(`yarn lockfile v1`)) {
@@ -234,7 +237,7 @@ class YarnCommand extends cli_1.BaseCommand {
234
237
  stdout: this.context.stdout,
235
238
  includeLogs: true,
236
239
  }, async (report) => {
237
- await project.install({ cache, report, immutable, skipBuild: this.skipBuilds });
240
+ await project.install({ cache, report, immutable, mode: this.mode });
238
241
  });
239
242
  return report.exitCode();
240
243
  }
@@ -247,15 +250,15 @@ YarnCommand.paths = [
247
250
  YarnCommand.usage = clipanion_1.Command.Usage({
248
251
  description: `install the project dependencies`,
249
252
  details: `
250
- This command setup your project if needed. The installation is splitted in four different steps that each have their own characteristics:
253
+ This command sets up your project if needed. The installation is split into four different steps that each have their own characteristics:
251
254
 
252
255
  - **Resolution:** First the package manager will resolve your dependencies. The exact way a dependency version is privileged over another isn't standardized outside of the regular semver guarantees. If a package doesn't resolve to what you would expect, check that all dependencies are correctly declared (also check our website for more information: ).
253
256
 
254
- - **Fetch:** Then we download all the dependencies if needed, and make sure that they're all stored within our cache (check the value of \`cacheFolder\` in \`yarn config\` to see where are stored the cache files).
257
+ - **Fetch:** Then we download all the dependencies if needed, and make sure that they're all stored within our cache (check the value of \`cacheFolder\` in \`yarn config\` to see where the cache files are stored).
255
258
 
256
- - **Link:** Then we send the dependency tree information to internal plugins tasked from writing them on the disk in some form (for example by generating the .pnp.cjs file you might know).
259
+ - **Link:** Then we send the dependency tree information to internal plugins tasked with writing them on the disk in some form (for example by generating the .pnp.cjs file you might know).
257
260
 
258
- - **Build:** Once the dependency tree has been written on the disk, the package manager will now be free to run the build scripts for all packages that might need it, in a topological order compatible with the way they depend on one another.
261
+ - **Build:** Once the dependency tree has been written on the disk, the package manager will now be free to run the build scripts for all packages that might need it, in a topological order compatible with the way they depend on one another. See https://yarnpkg.com/advanced/lifecycle-scripts for detail.
259
262
 
260
263
  Note that running this command is not part of the recommended workflow. Yarn supports zero-installs, which means that as long as you store your cache and your .pnp.cjs file inside your repository, everything will work without requiring any install right after cloning your repository or switching branches.
261
264
 
@@ -267,7 +270,11 @@ YarnCommand.usage = clipanion_1.Command.Usage({
267
270
 
268
271
  If the \`--inline-builds\` option is set, Yarn will verbosely print the output of the build steps of your dependencies (instead of writing them into individual files). This is likely useful mostly for debug purposes only when using Docker-like environments.
269
272
 
270
- If the \`--skip-builds\` option is set, Yarn 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.
273
+ If the \`--mode=<mode>\` option is set, Yarn will change which artifacts are generated. The modes currently supported are:
274
+
275
+ - \`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.
276
+
277
+ - \`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.
271
278
  `,
272
279
  examples: [[
273
280
  `Install the project`,
@@ -299,8 +306,8 @@ async function autofixMergeConflicts(configuration, immutable) {
299
306
  let parsedLeft;
300
307
  let parsedRight;
301
308
  try {
302
- parsedLeft = parsers_1.parseSyml(left);
303
- parsedRight = parsers_1.parseSyml(right);
309
+ parsedLeft = (0, parsers_1.parseSyml)(left);
310
+ parsedRight = (0, parsers_1.parseSyml)(right);
304
311
  }
305
312
  catch (error) {
306
313
  throw new core_1.ReportError(core_1.MessageName.AUTOMERGE_FAILED_TO_PARSE, `The individual variants of the lockfile failed to parse`);
@@ -316,7 +323,7 @@ async function autofixMergeConflicts(configuration, immutable) {
316
323
  for (const [key, value] of Object.entries(merged))
317
324
  if (typeof value === `string`)
318
325
  delete merged[key];
319
- await fslib_1.xfs.changeFilePromise(lockfilePath, parsers_1.stringifySyml(merged), {
326
+ await fslib_1.xfs.changeFilePromise(lockfilePath, (0, parsers_1.stringifySyml)(merged), {
320
327
  automaticNewlines: true,
321
328
  });
322
329
  return true;
@@ -7,5 +7,5 @@ export default class LinkCommand extends BaseCommand {
7
7
  private: boolean;
8
8
  relative: boolean;
9
9
  destination: string;
10
- execute(): Promise<0 | 1>;
10
+ execute(): Promise<1 | 0>;
11
11
  }
@@ -12,7 +12,7 @@ export default class PluginDlSourcesCommand extends BaseCommand {
12
12
  noMinify: boolean;
13
13
  force: boolean;
14
14
  name: string;
15
- execute(): Promise<0 | 1>;
15
+ execute(): Promise<1 | 0>;
16
16
  }
17
17
  export declare type BuildAndSavePluginsSpec = {
18
18
  context: CommandContext;
@@ -38,7 +38,7 @@ class PluginDlSourcesCommand extends cli_1.BaseCommand {
38
38
  const configuration = await core_2.Configuration.find(this.context.cwd, this.context.plugins);
39
39
  const target = typeof this.installPath !== `undefined`
40
40
  ? fslib_1.ppath.resolve(this.context.cwd, fslib_1.npath.toPortablePath(this.installPath))
41
- : fslib_1.ppath.resolve(fslib_1.npath.toPortablePath(os_1.tmpdir()), `yarnpkg-sources`, core_1.hashUtils.makeHash(this.repository).slice(0, 6));
41
+ : fslib_1.ppath.resolve(fslib_1.npath.toPortablePath((0, os_1.tmpdir)()), `yarnpkg-sources`, core_1.hashUtils.makeHash(this.repository).slice(0, 6));
42
42
  const report = await core_2.StreamReport.start({
43
43
  configuration,
44
44
  stdout: this.context.stdout,
@@ -46,11 +46,11 @@ class PluginDlSourcesCommand extends cli_1.BaseCommand {
46
46
  const { project } = await core_2.Project.find(configuration, this.context.cwd);
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
- const data = await list_1.getAvailablePlugins(configuration);
49
+ const data = await (0, list_1.getAvailablePlugins)(configuration);
50
50
  if (!Object.prototype.hasOwnProperty.call(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
- await sources_1.prepareRepo(this, { configuration, report, target });
53
+ await (0, sources_1.prepareRepo)(this, { configuration, report, target });
54
54
  await buildAndSavePlugin(pluginSpec, this, { project, report, target });
55
55
  });
56
56
  return report.exitCode();
@@ -82,13 +82,13 @@ async function buildAndSavePlugin(pluginSpec, { context, noMinify }, { project,
82
82
  report.reportSeparator();
83
83
  report.reportInfo(core_2.MessageName.UNNAMED, `Building a fresh ${pluginName}`);
84
84
  report.reportSeparator();
85
- await sources_1.runWorkflow(buildWorkflow({
85
+ await (0, sources_1.runWorkflow)(buildWorkflow({
86
86
  pluginName,
87
87
  noMinify,
88
88
  }, target), { configuration, context, target });
89
89
  report.reportSeparator();
90
90
  const pluginPath = fslib_1.ppath.resolve(target, `packages/${pluginName}/bundles/${pluginSpec}.js`);
91
91
  const pluginBuffer = await fslib_1.xfs.readFilePromise(pluginPath);
92
- await import_1.savePlugin(pluginSpec, pluginBuffer, { project, report });
92
+ await (0, import_1.savePlugin)(pluginSpec, pluginBuffer, { project, report });
93
93
  }
94
94
  exports.buildAndSavePlugin = buildAndSavePlugin;
@@ -6,7 +6,7 @@ export default class PluginDlCommand extends BaseCommand {
6
6
  static paths: string[][];
7
7
  static usage: Usage;
8
8
  name: string;
9
- execute(): Promise<0 | 1>;
9
+ execute(): Promise<1 | 0>;
10
10
  }
11
11
  export declare function savePlugin(pluginSpec: string, pluginBuffer: Buffer, { project, report }: {
12
12
  project: Project;
@@ -7,7 +7,7 @@ const core_1 = require("@yarnpkg/core");
7
7
  const core_2 = require("@yarnpkg/core");
8
8
  const fslib_1 = require("@yarnpkg/fslib");
9
9
  const clipanion_1 = require("clipanion");
10
- const semver_1 = tslib_1.__importDefault(require("semver"));
10
+ const semver_1 = (0, tslib_1.__importDefault)(require("semver"));
11
11
  const url_1 = require("url");
12
12
  const vm_1 = require("vm");
13
13
  const list_1 = require("./list");
@@ -38,7 +38,7 @@ class PluginDlCommand extends cli_1.BaseCommand {
38
38
  try {
39
39
  new url_1.URL(this.name);
40
40
  }
41
- catch (_a) {
41
+ catch {
42
42
  throw new core_1.ReportError(core_1.MessageName.INVALID_PLUGIN_REFERENCE, `Plugin specifier "${this.name}" is neither a plugin name nor a valid url`);
43
43
  }
44
44
  pluginSpec = this.name;
@@ -49,7 +49,7 @@ class PluginDlCommand extends cli_1.BaseCommand {
49
49
  if (locator.reference !== `unknown` && !semver_1.default.valid(locator.reference))
50
50
  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
51
  const identStr = core_2.structUtils.stringifyIdent(locator);
52
- const data = await list_1.getAvailablePlugins(configuration);
52
+ const data = await (0, list_1.getAvailablePlugins)(configuration);
53
53
  if (!Object.prototype.hasOwnProperty.call(data, identStr))
54
54
  throw new core_1.ReportError(core_1.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 referenced by their name; any other plugin will have to be referenced through its public url (for example https://github.com/yarnpkg/berry/raw/master/packages/plugin-typescript/bin/%40yarnpkg/plugin-typescript.js).`);
55
55
  pluginSpec = identStr;
@@ -105,7 +105,7 @@ async function savePlugin(pluginSpec, pluginBuffer, { project, report }) {
105
105
  const { configuration } = project;
106
106
  const vmExports = {};
107
107
  const vmModule = { exports: vmExports };
108
- vm_1.runInNewContext(pluginBuffer.toString(), {
108
+ (0, vm_1.runInNewContext)(pluginBuffer.toString(), {
109
109
  module: vmModule,
110
110
  exports: vmExports,
111
111
  });
@@ -127,7 +127,7 @@ async function savePlugin(pluginSpec, pluginBuffer, { project, report }) {
127
127
  ? entry.path
128
128
  : entry;
129
129
  const pluginPath = fslib_1.ppath.resolve(project.cwd, fslib_1.npath.toPortablePath(userProvidedPath));
130
- const { name } = core_1.miscUtils.dynamicRequire(fslib_1.npath.fromPortablePath(pluginPath));
130
+ const { name } = core_1.miscUtils.dynamicRequire(pluginPath);
131
131
  if (name !== pluginName) {
132
132
  plugins.push(entry);
133
133
  }
@@ -8,5 +8,5 @@ export default class PluginDlCommand extends BaseCommand {
8
8
  static paths: string[][];
9
9
  static usage: Usage;
10
10
  json: boolean;
11
- execute(): Promise<0 | 1>;
11
+ execute(): Promise<1 | 0>;
12
12
  }
@@ -8,7 +8,7 @@ const clipanion_1 = require("clipanion");
8
8
  const REMOTE_REGISTRY = `https://raw.githubusercontent.com/yarnpkg/berry/master/plugins.yml`;
9
9
  async function getAvailablePlugins(configuration) {
10
10
  const raw = await core_1.httpUtils.get(REMOTE_REGISTRY, { configuration });
11
- const data = parsers_1.parseSyml(raw.toString());
11
+ const data = (0, parsers_1.parseSyml)(raw.toString());
12
12
  return data;
13
13
  }
14
14
  exports.getAvailablePlugins = getAvailablePlugins;
@@ -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<0 | 1>;
7
+ execute(): Promise<1 | 0>;
8
8
  }
@@ -4,5 +4,5 @@ export default class PluginListCommand extends BaseCommand {
4
4
  static paths: string[][];
5
5
  static usage: Usage;
6
6
  json: boolean;
7
- execute(): Promise<0 | 1>;
7
+ execute(): Promise<1 | 0>;
8
8
  }
@@ -4,5 +4,5 @@ export default class RunCommand extends BaseCommand {
4
4
  static paths: string[][];
5
5
  static usage: Usage;
6
6
  idents: string[];
7
- execute(): Promise<0 | 1>;
7
+ execute(): Promise<1 | 0>;
8
8
  }
@@ -1,9 +1,11 @@
1
1
  import { BaseCommand } from '@yarnpkg/cli';
2
+ import { InstallMode } from '@yarnpkg/core';
2
3
  import { Usage } from 'clipanion';
3
4
  export default class RemoveCommand extends BaseCommand {
4
5
  static paths: string[][];
5
6
  static usage: Usage;
6
7
  all: boolean;
8
+ mode: InstallMode | undefined;
7
9
  patterns: string[];
8
- execute(): Promise<0 | 1>;
10
+ execute(): Promise<1 | 0>;
9
11
  }
@@ -6,8 +6,9 @@ const core_1 = require("@yarnpkg/core");
6
6
  const core_2 = require("@yarnpkg/core");
7
7
  const core_3 = require("@yarnpkg/core");
8
8
  const clipanion_1 = require("clipanion");
9
- const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
10
- const suggestUtils = tslib_1.__importStar(require("../suggestUtils"));
9
+ const micromatch_1 = (0, tslib_1.__importDefault)(require("micromatch"));
10
+ const t = (0, tslib_1.__importStar)(require("typanion"));
11
+ const suggestUtils = (0, tslib_1.__importStar)(require("../suggestUtils"));
11
12
  // eslint-disable-next-line arca/no-default-export
12
13
  class RemoveCommand extends cli_1.BaseCommand {
13
14
  constructor() {
@@ -15,6 +16,10 @@ class RemoveCommand extends cli_1.BaseCommand {
15
16
  this.all = clipanion_1.Option.Boolean(`-A,--all`, false, {
16
17
  description: `Apply the operation to all workspaces from the current project`,
17
18
  });
19
+ this.mode = clipanion_1.Option.String(`--mode`, {
20
+ description: `Change what artifacts installs generate`,
21
+ validator: t.isEnum(core_2.InstallMode),
22
+ });
18
23
  this.patterns = clipanion_1.Option.Rest();
19
24
  }
20
25
  async execute() {
@@ -44,7 +49,7 @@ class RemoveCommand extends cli_1.BaseCommand {
44
49
  const pseudoIdent = core_3.structUtils.parseIdent(pattern);
45
50
  for (const workspace of affectedWorkspaces) {
46
51
  const peerDependenciesMeta = [...workspace.manifest.peerDependenciesMeta.keys()];
47
- for (const stringifiedIdent of micromatch_1.default(peerDependenciesMeta, pattern)) {
52
+ for (const stringifiedIdent of (0, micromatch_1.default)(peerDependenciesMeta, pattern)) {
48
53
  workspace.manifest.peerDependenciesMeta.delete(stringifiedIdent);
49
54
  hasChanged = true;
50
55
  isReferenced = true;
@@ -54,7 +59,7 @@ class RemoveCommand extends cli_1.BaseCommand {
54
59
  const stringifiedIdents = [...descriptors.values()].map(descriptor => {
55
60
  return core_3.structUtils.stringifyIdent(descriptor);
56
61
  });
57
- for (const stringifiedIdent of micromatch_1.default(stringifiedIdents, core_3.structUtils.stringifyIdent(pseudoIdent))) {
62
+ for (const stringifiedIdent of (0, micromatch_1.default)(stringifiedIdents, core_3.structUtils.stringifyIdent(pseudoIdent))) {
58
63
  const { identHash } = core_3.structUtils.parseIdent(stringifiedIdent);
59
64
  const removedDescriptor = descriptors.get(identHash);
60
65
  if (typeof removedDescriptor === `undefined`)
@@ -91,7 +96,7 @@ class RemoveCommand extends cli_1.BaseCommand {
91
96
  configuration,
92
97
  stdout: this.context.stdout,
93
98
  }, async (report) => {
94
- await project.install({ cache, report });
99
+ await project.install({ cache, report, mode: this.mode });
95
100
  });
96
101
  return report.exitCode();
97
102
  }
@@ -107,6 +112,12 @@ RemoveCommand.usage = clipanion_1.Command.Usage({
107
112
  details: `
108
113
  This command will remove the packages matching the specified patterns from the current workspace.
109
114
 
115
+ If the \`--mode=<mode>\` option is set, Yarn will change which artifacts are generated. The modes currently supported are:
116
+
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.
118
+
119
+ - \`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
+
110
121
  This command accepts glob patterns as arguments (if valid Idents and supported by [micromatch](https://github.com/micromatch/micromatch)). Make sure to escape the patterns, to prevent your own shell from trying to expand them.
111
122
  `,
112
123
  examples: [[
@@ -16,12 +16,12 @@ class RunCommand extends cli_1.BaseCommand {
16
16
  tolerateBoolean: true,
17
17
  description: `Forwarded to the underlying Node process when executing a binary`,
18
18
  });
19
- // This flag is mostly used to give users a way to configure node-gyp. They
20
- // just have to add it as a top-level workspace.
21
- this.topLevel = clipanion_1.Option.Boolean(`-T,--top-level`, false, { hidden: true });
22
- // Some tools (for example text editors) want to call the real binaries, not
23
- // what their users might have remapped them to in their `scripts` field.
24
- this.binariesOnly = clipanion_1.Option.Boolean(`-B,--binaries-only`, false, { hidden: true });
19
+ this.topLevel = clipanion_1.Option.Boolean(`-T,--top-level`, false, {
20
+ description: `Check the root workspace for scripts and/or binaries instead of the current one`,
21
+ });
22
+ this.binariesOnly = clipanion_1.Option.Boolean(`-B,--binaries-only`, false, {
23
+ description: `Ignore any user defined scripts and only check for binaries`,
24
+ });
25
25
  // The v1 used to print the Yarn version header when using "yarn run", which
26
26
  // was messing with the output of things like `--version` & co. We don't do
27
27
  // this anymore, but many workflows use `yarn run --silent` to make sure that
@@ -1,5 +1,5 @@
1
1
  import { BaseCommand } from '@yarnpkg/cli';
2
2
  export default class RunCommand extends BaseCommand {
3
3
  static paths: string[][];
4
- execute(): Promise<0 | 1>;
4
+ execute(): Promise<1 | 0>;
5
5
  }
@@ -26,7 +26,7 @@ class RunCommand extends cli_1.BaseCommand {
26
26
  return Math.max(max, key.length);
27
27
  }, 0);
28
28
  for (const [key, value] of scripts.entries()) {
29
- report.reportInfo(null, `${key.padEnd(maxKeyLength, ` `)} ${util_1.inspect(value, inspectConfig)}`);
29
+ report.reportInfo(null, `${key.padEnd(maxKeyLength, ` `)} ${(0, util_1.inspect)(value, inspectConfig)}`);
30
30
  }
31
31
  });
32
32
  return report.exitCode();
@@ -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<0 | 1>;
9
+ execute(): Promise<1 | 0>;
10
10
  }
@@ -12,7 +12,7 @@ export default class SetVersionSourcesCommand extends BaseCommand {
12
12
  noMinify: boolean;
13
13
  force: boolean;
14
14
  skipPlugins: boolean;
15
- execute(): Promise<0 | 1>;
15
+ execute(): Promise<1 | 0>;
16
16
  }
17
17
  export declare function runWorkflow(workflow: Array<Array<string>>, { configuration, context, target }: {
18
18
  configuration: Configuration;
@@ -63,7 +63,7 @@ class SetVersionSourcesCommand extends cli_1.BaseCommand {
63
63
  const { project } = await core_1.Project.find(configuration, this.context.cwd);
64
64
  const target = typeof this.installPath !== `undefined`
65
65
  ? fslib_1.ppath.resolve(this.context.cwd, fslib_1.npath.toPortablePath(this.installPath))
66
- : fslib_1.ppath.resolve(fslib_1.npath.toPortablePath(os_1.tmpdir()), `yarnpkg-sources`, core_1.hashUtils.makeHash(this.repository).slice(0, 6));
66
+ : fslib_1.ppath.resolve(fslib_1.npath.toPortablePath((0, os_1.tmpdir)()), `yarnpkg-sources`, core_1.hashUtils.makeHash(this.repository).slice(0, 6));
67
67
  const report = await core_1.StreamReport.start({
68
68
  configuration,
69
69
  stdout: this.context.stdout,
@@ -76,7 +76,7 @@ class SetVersionSourcesCommand extends cli_1.BaseCommand {
76
76
  report.reportSeparator();
77
77
  const bundlePath = fslib_1.ppath.resolve(target, `packages/yarnpkg-cli/bundles/yarn.js`);
78
78
  const bundleBuffer = await fslib_1.xfs.readFilePromise(bundlePath);
79
- await version_1.setVersion(configuration, `sources`, bundleBuffer, {
79
+ await (0, version_1.setVersion)(configuration, `sources`, bundleBuffer, {
80
80
  report,
81
81
  });
82
82
  if (!this.skipPlugins) {
@@ -156,11 +156,11 @@ async function prepareRepo(spec, { configuration, report, target }) {
156
156
  }
157
157
  exports.prepareRepo = prepareRepo;
158
158
  async function updatePlugins(context, { project, report, target }) {
159
- const data = await list_1.getAvailablePlugins(project.configuration);
159
+ const data = await (0, list_1.getAvailablePlugins)(project.configuration);
160
160
  const contribPlugins = new Set(Object.keys(data));
161
161
  for (const name of project.configuration.plugins.keys()) {
162
162
  if (!contribPlugins.has(name))
163
163
  continue;
164
- await sources_1.buildAndSavePlugin(name, context, { project, report, target });
164
+ await (0, sources_1.buildAndSavePlugin)(name, context, { project, report, target });
165
165
  }
166
166
  }
@@ -2,14 +2,19 @@
2
2
  import { BaseCommand } from '@yarnpkg/cli';
3
3
  import { Configuration, Report } from '@yarnpkg/core';
4
4
  import { Usage } from 'clipanion';
5
+ export declare type Tags = {
6
+ latest: Record<string, string>;
7
+ tags: Array<string>;
8
+ };
5
9
  export default class SetVersionCommand extends BaseCommand {
6
10
  static paths: string[][];
7
11
  static usage: Usage;
8
12
  onlyIfNeeded: boolean;
9
13
  version: string;
10
- execute(): Promise<0 | 1>;
14
+ execute(): Promise<1 | 0>;
11
15
  }
12
- export declare function findVersion(configuration: Configuration, request: `stable` | `canary`): Promise<any>;
16
+ export declare function resolveRange(configuration: Configuration, request: string): Promise<string>;
17
+ export declare function resolveTag(configuration: Configuration, request: `stable` | `canary`): Promise<string>;
13
18
  export declare function setVersion(configuration: Configuration, bundleVersion: string | null, bundleBuffer: Buffer, { report }: {
14
19
  report: Report;
15
20
  }): Promise<void>;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setVersion = exports.findVersion = void 0;
3
+ exports.setVersion = exports.resolveTag = exports.resolveRange = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const cli_1 = require("@yarnpkg/cli");
6
6
  const core_1 = require("@yarnpkg/core");
7
7
  const core_2 = require("@yarnpkg/core");
8
8
  const fslib_1 = require("@yarnpkg/fslib");
9
9
  const clipanion_1 = require("clipanion");
10
- const semver_1 = tslib_1.__importDefault(require("semver"));
10
+ const semver_1 = (0, tslib_1.__importDefault)(require("semver"));
11
11
  // eslint-disable-next-line arca/no-default-export
12
12
  class SetVersionCommand extends cli_1.BaseCommand {
13
13
  constructor() {
@@ -30,9 +30,9 @@ class SetVersionCommand extends cli_1.BaseCommand {
30
30
  if (this.version === `self`)
31
31
  bundleUrl = getBundlePath();
32
32
  else if (this.version === `latest` || this.version === `berry` || this.version === `stable`)
33
- bundleUrl = `https://repo.yarnpkg.com/${await findVersion(configuration, `stable`)}/packages/yarnpkg-cli/bin/yarn.js`;
33
+ bundleUrl = `https://repo.yarnpkg.com/${await resolveTag(configuration, `stable`)}/packages/yarnpkg-cli/bin/yarn.js`;
34
34
  else if (this.version === `canary`)
35
- bundleUrl = `https://repo.yarnpkg.com/${await findVersion(configuration, `canary`)}/packages/yarnpkg-cli/bin/yarn.js`;
35
+ bundleUrl = `https://repo.yarnpkg.com/${await resolveTag(configuration, `canary`)}/packages/yarnpkg-cli/bin/yarn.js`;
36
36
  else if (this.version === `classic`)
37
37
  bundleUrl = `https://nightly.yarnpkg.com/latest.js`;
38
38
  else if (this.version.match(/^\.{0,2}[\\/]/) || fslib_1.npath.isAbsolute(this.version))
@@ -42,7 +42,7 @@ class SetVersionCommand extends cli_1.BaseCommand {
42
42
  else if (core_2.semverUtils.satisfiesWithPrereleases(this.version, `^0.x || ^1.x`))
43
43
  bundleUrl = `https://github.com/yarnpkg/yarn/releases/download/v${this.version}/yarn-${this.version}.js`;
44
44
  else if (core_2.semverUtils.validRange(this.version))
45
- throw new clipanion_1.UsageError(`Support for ranges got removed - please use the exact version you want to install, or 'latest' to get the latest build available`);
45
+ bundleUrl = `https://repo.yarnpkg.com/${await resolveRange(configuration, this.version)}/packages/yarnpkg-cli/bin/yarn.js`;
46
46
  else
47
47
  throw new clipanion_1.UsageError(`Invalid version descriptor "${this.version}"`);
48
48
  const report = await core_1.StreamReport.start({
@@ -75,28 +75,64 @@ SetVersionCommand.usage = clipanion_1.Command.Usage({
75
75
  This command will download a specific release of Yarn directly from the Yarn GitHub repository, will store it inside your project, and will change the \`yarnPath\` settings from your project \`.yarnrc.yml\` file to point to the new file.
76
76
 
77
77
  A very good use case for this command is to enforce the version of Yarn used by the any single member of your team inside a same project - by doing this you ensure that you have control on Yarn upgrades and downgrades (including on your deployment servers), and get rid of most of the headaches related to someone using a slightly different version and getting a different behavior than you.
78
+
79
+ The version specifier can be:
80
+
81
+ - a tag:
82
+ - \`latest\` / \`berry\` / \`stable\` -> the most recent stable berry (\`>=2.0.0\`) release
83
+ - \`canary\` -> the most recent canary (release candidate) berry (\`>=2.0.0\`) release
84
+ - \`classic\` -> the most recent classic (\`^0.x || ^1.x\`) release
85
+
86
+ - a semver range (e.g. \`2.x\`) -> the most recent version satisfying the range (limited to berry releases)
87
+
88
+ - a semver version (e.g. \`2.4.1\`, \`1.22.1\`)
89
+
90
+ - a local file referenced through either a relative or absolute path
91
+
92
+ - \`self\` -> the version used to invoke the command
78
93
  `,
79
94
  examples: [[
80
95
  `Download the latest release from the Yarn repository`,
81
96
  `$0 set version latest`,
97
+ ], [
98
+ `Download the latest canary release from the Yarn repository`,
99
+ `$0 set version canary`,
82
100
  ], [
83
101
  `Download the latest classic release from the Yarn repository`,
84
102
  `$0 set version classic`,
103
+ ], [
104
+ `Download the most recent Yarn 3 build`,
105
+ `$0 set version 3.x`,
85
106
  ], [
86
107
  `Download a specific Yarn 2 build`,
87
108
  `$0 set version 2.0.0-rc.30`,
88
109
  ], [
89
110
  `Switch back to a specific Yarn 1 release`,
90
111
  `$0 set version 1.22.1`,
112
+ ], [
113
+ `Use a release from the local filesystem`,
114
+ `$0 set version ./yarn.cjs`,
115
+ ], [
116
+ `Download the version used to invoke the command`,
117
+ `$0 set version self`,
91
118
  ]],
92
119
  });
93
- async function findVersion(configuration, request) {
120
+ async function resolveRange(configuration, request) {
121
+ const data = await core_2.httpUtils.get(`https://repo.yarnpkg.com/tags`, { configuration, jsonResponse: true });
122
+ const candidates = data.tags.filter(version => core_2.semverUtils.satisfiesWithPrereleases(version, request));
123
+ if (candidates.length === 0)
124
+ throw new clipanion_1.UsageError(`No matching release found for range ${core_2.formatUtils.pretty(configuration, request, core_2.formatUtils.Type.RANGE)}.`);
125
+ // The tags on the website are sorted by semver descending
126
+ return candidates[0];
127
+ }
128
+ exports.resolveRange = resolveRange;
129
+ async function resolveTag(configuration, request) {
94
130
  const data = await core_2.httpUtils.get(`https://repo.yarnpkg.com/tags`, { configuration, jsonResponse: true });
95
131
  if (!data.latest[request])
96
- throw new clipanion_1.UsageError(`Tag '${request}' not found`);
132
+ throw new clipanion_1.UsageError(`Tag ${core_2.formatUtils.pretty(configuration, request, core_2.formatUtils.Type.RANGE)} not found`);
97
133
  return data.latest[request];
98
134
  }
99
- exports.findVersion = findVersion;
135
+ exports.resolveTag = resolveTag;
100
136
  async function setVersion(configuration, bundleVersion, bundleBuffer, { report }) {
101
137
  var _a;
102
138
  if (bundleVersion === null) {
@@ -123,8 +159,7 @@ async function setVersion(configuration, bundleVersion, bundleBuffer, { report }
123
159
  report.reportInfo(core_1.MessageName.UNNAMED, `Saving the new release in ${core_2.formatUtils.pretty(configuration, displayPath, `magenta`)}`);
124
160
  await fslib_1.xfs.removePromise(fslib_1.ppath.dirname(absolutePath));
125
161
  await fslib_1.xfs.mkdirPromise(fslib_1.ppath.dirname(absolutePath), { recursive: true });
126
- await fslib_1.xfs.writeFilePromise(absolutePath, bundleBuffer);
127
- await fslib_1.xfs.chmodPromise(absolutePath, 0o755);
162
+ await fslib_1.xfs.writeFilePromise(absolutePath, bundleBuffer, { mode: 0o755 });
128
163
  if (updateConfig) {
129
164
  await core_1.Configuration.updateConfiguration(projectCwd, {
130
165
  yarnPath: projectPath,
@@ -5,5 +5,5 @@ export default class UnlinkCommand extends BaseCommand {
5
5
  static usage: Usage;
6
6
  all: boolean;
7
7
  leadingArguments: string[];
8
- execute(): Promise<0 | 1>;
8
+ execute(): Promise<1 | 0>;
9
9
  }
@@ -5,7 +5,7 @@ const cli_1 = require("@yarnpkg/cli");
5
5
  const core_1 = require("@yarnpkg/core");
6
6
  const fslib_1 = require("@yarnpkg/fslib");
7
7
  const clipanion_1 = require("clipanion");
8
- const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
8
+ const micromatch_1 = (0, tslib_1.__importDefault)(require("micromatch"));
9
9
  // eslint-disable-next-line arca/no-default-export
10
10
  class UnlinkCommand extends cli_1.BaseCommand {
11
11
  constructor() {
@@ -54,7 +54,7 @@ class UnlinkCommand extends cli_1.BaseCommand {
54
54
  }
55
55
  else {
56
56
  const fullNames = [...topLevelWorkspace.manifest.resolutions.map(({ pattern }) => pattern.descriptor.fullName)];
57
- for (const fullName of micromatch_1.default(fullNames, leadingArgument)) {
57
+ for (const fullName of (0, micromatch_1.default)(fullNames, leadingArgument)) {
58
58
  workspacesToUnlink.add(fullName);
59
59
  }
60
60
  }