@yarnpkg/plugin-essentials 3.1.0-rc.8 → 3.2.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.
@@ -7,8 +7,8 @@ const core_2 = require("@yarnpkg/core");
7
7
  const core_3 = require("@yarnpkg/core");
8
8
  const clipanion_1 = require("clipanion");
9
9
  const enquirer_1 = require("enquirer");
10
- const t = (0, tslib_1.__importStar)(require("typanion"));
11
- const suggestUtils = (0, tslib_1.__importStar)(require("../suggestUtils"));
10
+ const t = tslib_1.__importStar(require("typanion"));
11
+ const suggestUtils = tslib_1.__importStar(require("../suggestUtils"));
12
12
  // eslint-disable-next-line arca/no-default-export
13
13
  class AddCommand extends cli_1.BaseCommand {
14
14
  constructor() {
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const cli_1 = require("@yarnpkg/cli");
5
5
  const core_1 = require("@yarnpkg/core");
6
6
  const clipanion_1 = require("clipanion");
7
- const get_1 = (0, tslib_1.__importDefault)(require("lodash/get"));
7
+ const get_1 = tslib_1.__importDefault(require("lodash/get"));
8
8
  const util_1 = require("util");
9
9
  // eslint-disable-next-line arca/no-default-export
10
10
  class ConfigGetCommand extends cli_1.BaseCommand {
@@ -4,9 +4,9 @@ const tslib_1 = require("tslib");
4
4
  const cli_1 = require("@yarnpkg/cli");
5
5
  const core_1 = require("@yarnpkg/core");
6
6
  const clipanion_1 = require("clipanion");
7
- const cloneDeep_1 = (0, tslib_1.__importDefault)(require("lodash/cloneDeep"));
8
- const get_1 = (0, tslib_1.__importDefault)(require("lodash/get"));
9
- const set_1 = (0, tslib_1.__importDefault)(require("lodash/set"));
7
+ const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
8
+ const get_1 = tslib_1.__importDefault(require("lodash/get"));
9
+ const set_1 = tslib_1.__importDefault(require("lodash/set"));
10
10
  const util_1 = require("util");
11
11
  // eslint-disable-next-line arca/no-default-export
12
12
  class ConfigSetCommand extends cli_1.BaseCommand {
@@ -4,9 +4,9 @@ const tslib_1 = require("tslib");
4
4
  const cli_1 = require("@yarnpkg/cli");
5
5
  const core_1 = require("@yarnpkg/core");
6
6
  const clipanion_1 = require("clipanion");
7
- const cloneDeep_1 = (0, tslib_1.__importDefault)(require("lodash/cloneDeep"));
8
- const has_1 = (0, tslib_1.__importDefault)(require("lodash/has"));
9
- const unset_1 = (0, tslib_1.__importDefault)(require("lodash/unset"));
7
+ const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
8
+ const has_1 = tslib_1.__importDefault(require("lodash/has"));
9
+ const unset_1 = tslib_1.__importDefault(require("lodash/unset"));
10
10
  // eslint-disable-next-line arca/no-default-export
11
11
  class ConfigUnsetCommand extends cli_1.BaseCommand {
12
12
  constructor() {
@@ -17,8 +17,8 @@ const tslib_1 = require("tslib");
17
17
  const cli_1 = require("@yarnpkg/cli");
18
18
  const core_1 = require("@yarnpkg/core");
19
19
  const clipanion_1 = require("clipanion");
20
- const t = (0, tslib_1.__importStar)(require("typanion"));
21
- const dedupeUtils = (0, tslib_1.__importStar)(require("../dedupeUtils"));
20
+ const t = tslib_1.__importStar(require("typanion"));
21
+ const dedupeUtils = tslib_1.__importStar(require("../dedupeUtils"));
22
22
  // eslint-disable-next-line arca/no-default-export
23
23
  class DedupeCommand extends cli_1.BaseCommand {
24
24
  constructor() {
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const cli_1 = require("@yarnpkg/cli");
6
6
  const core_1 = require("@yarnpkg/core");
7
7
  const clipanion_1 = require("clipanion");
8
- const t = (0, tslib_1.__importStar)(require("typanion"));
8
+ const t = tslib_1.__importStar(require("typanion"));
9
9
  // eslint-disable-next-line arca/no-default-export
10
10
  class ExplainPeerRequirementsCommand extends cli_1.BaseCommand {
11
11
  constructor() {
@@ -0,0 +1,10 @@
1
+ import { BaseCommand } from '@yarnpkg/cli';
2
+ import { Configuration } from '@yarnpkg/core';
3
+ export declare function getErrorCodeDetails(configuration: Configuration): Promise<Map<string, string>>;
4
+ export default class ExplainCommand extends BaseCommand {
5
+ static paths: string[][];
6
+ static usage: import("clipanion").Usage;
7
+ code: string | undefined;
8
+ json: boolean;
9
+ execute(): Promise<void>;
10
+ }
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getErrorCodeDetails = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const cli_1 = require("@yarnpkg/cli");
6
+ const core_1 = require("@yarnpkg/core");
7
+ const clipanion_1 = require("clipanion");
8
+ const t = tslib_1.__importStar(require("typanion"));
9
+ const version_1 = require("./set/version");
10
+ function getCodeName(code) {
11
+ return core_1.MessageName[(0, core_1.parseMessageName)(code)];
12
+ }
13
+ const ERROR_CODE_DOC_REGEXP = /## (?<code>YN[0-9]{4}) - `(?<name>[A-Z_]+)`\n\n(?<details>(?:.(?!##))+)/gs;
14
+ async function getErrorCodeDetails(configuration) {
15
+ const version = core_1.miscUtils.isTaggedYarnVersion(core_1.YarnVersion)
16
+ ? core_1.YarnVersion
17
+ : await (0, version_1.resolveTag)(configuration, `canary`);
18
+ const errorCodesUrl = `https://repo.yarnpkg.com/${version}/packages/gatsby/content/advanced/error-codes.md`;
19
+ const raw = await core_1.httpUtils.get(errorCodesUrl, { configuration });
20
+ return new Map(Array.from(raw.toString().matchAll(ERROR_CODE_DOC_REGEXP), ({ groups }) => {
21
+ if (!groups)
22
+ throw new Error(`Assertion failed: Expected the match to have been successful`);
23
+ const expectedName = getCodeName(groups.code);
24
+ if (groups.name !== expectedName)
25
+ throw new Error(`Assertion failed: Invalid error code data: Expected "${groups.name}" to be named "${expectedName}"`);
26
+ return [groups.code, groups.details];
27
+ }));
28
+ }
29
+ exports.getErrorCodeDetails = getErrorCodeDetails;
30
+ // eslint-disable-next-line arca/no-default-export
31
+ class ExplainCommand extends cli_1.BaseCommand {
32
+ constructor() {
33
+ super(...arguments);
34
+ this.code = clipanion_1.Option.String({
35
+ required: false,
36
+ validator: t.applyCascade(t.isString(), [
37
+ t.matchesRegExp(/^YN[0-9]{4}$/),
38
+ ]),
39
+ });
40
+ this.json = clipanion_1.Option.Boolean(`--json`, false, {
41
+ description: `Format the output as an NDJSON stream`,
42
+ });
43
+ }
44
+ async execute() {
45
+ const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
46
+ if (typeof this.code !== `undefined`) {
47
+ const name = getCodeName(this.code);
48
+ const prettyName = core_1.formatUtils.pretty(configuration, name, core_1.formatUtils.Type.CODE);
49
+ const header = this.cli.format().header(`${this.code} - ${prettyName}`);
50
+ const errorCodeDetails = await getErrorCodeDetails(configuration);
51
+ const details = errorCodeDetails.get(this.code);
52
+ const content = typeof details !== `undefined`
53
+ ? core_1.formatUtils.jsonOrPretty(this.json, configuration, core_1.formatUtils.tuple(core_1.formatUtils.Type.MARKDOWN, {
54
+ text: details,
55
+ format: this.cli.format(),
56
+ paragraphs: true,
57
+ }))
58
+ : `This error code does not have a description.\n\nYou can help us by editing this page on GitHub 🙂:\n${core_1.formatUtils.jsonOrPretty(this.json, configuration, core_1.formatUtils.tuple(core_1.formatUtils.Type.URL, `https://github.com/yarnpkg/berry/blob/master/packages/gatsby/content/advanced/error-codes.md`))}\n`;
59
+ if (this.json) {
60
+ this.context.stdout.write(`${JSON.stringify({ code: this.code, name, details: content })}\n`);
61
+ }
62
+ else {
63
+ this.context.stdout.write(`${header}\n\n${content}\n`);
64
+ }
65
+ }
66
+ else {
67
+ const tree = {
68
+ children: core_1.miscUtils.mapAndFilter(Object.entries(core_1.MessageName), ([key, value]) => {
69
+ if (Number.isNaN(Number(key)))
70
+ return core_1.miscUtils.mapAndFilter.skip;
71
+ return {
72
+ label: (0, core_1.stringifyMessageName)(Number(key)),
73
+ value: core_1.formatUtils.tuple(core_1.formatUtils.Type.CODE, value),
74
+ };
75
+ }),
76
+ };
77
+ core_1.treeUtils.emitTree(tree, { configuration, stdout: this.context.stdout, json: this.json });
78
+ }
79
+ }
80
+ }
81
+ exports.default = ExplainCommand;
82
+ ExplainCommand.paths = [
83
+ [`explain`],
84
+ ];
85
+ ExplainCommand.usage = clipanion_1.Command.Usage({
86
+ description: `explain an error code`,
87
+ details: `
88
+ When the code argument is specified, this command prints its name and its details.
89
+
90
+ When used without arguments, this command lists all error codes and their names.
91
+ `,
92
+ examples: [[
93
+ `Explain an error code`,
94
+ `$0 explain YN0006`,
95
+ ], [
96
+ `List all error codes`,
97
+ `$0 explain`,
98
+ ]],
99
+ });
@@ -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 = (0, tslib_1.__importDefault)(require("micromatch"));
8
+ const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
9
9
  // eslint-disable-next-line arca/no-default-export
10
10
  class InfoCommand extends cli_1.BaseCommand {
11
11
  constructor() {
@@ -160,7 +160,7 @@ class InfoCommand extends cli_1.BaseCommand {
160
160
  const infoTreeChildren = {};
161
161
  const infoTree = { children: infoTreeChildren };
162
162
  const fetcher = configuration.makeFetcher();
163
- const fetcherOptions = { project, fetcher, cache, checksums: project.storedChecksums, report: new core_1.ThrowReport(), skipIntegrityCheck: true };
163
+ const fetcherOptions = { project, fetcher, cache, checksums: project.storedChecksums, report: new core_1.ThrowReport(), cacheOptions: { skipIntegrityCheck: true }, skipIntegrityCheck: true };
164
164
  const builtinInfoBuilders = [
165
165
  // Manifest fields
166
166
  async (pkg, extra, registerData) => {
@@ -185,8 +185,12 @@ class InfoCommand extends cli_1.BaseCommand {
185
185
  var _a;
186
186
  if (!extra.has(`cache`))
187
187
  return;
188
+ const cacheOptions = {
189
+ mockedPackages: project.disabledLocators,
190
+ unstablePackages: project.conditionalLocators,
191
+ };
188
192
  const checksum = (_a = project.storedChecksums.get(pkg.locatorHash)) !== null && _a !== void 0 ? _a : null;
189
- const cachePath = cache.getLocatorPath(pkg, checksum);
193
+ const cachePath = cache.getLocatorPath(pkg, checksum, cacheOptions);
190
194
  let stat;
191
195
  if (cachePath !== null) {
192
196
  try {
@@ -18,5 +18,6 @@ export default class YarnCommand extends BaseCommand {
18
18
  production: boolean | undefined;
19
19
  registry: string | undefined;
20
20
  silent: boolean | undefined;
21
+ networkTimeout: string | undefined;
21
22
  execute(): Promise<1 | 0>;
22
23
  }
@@ -5,8 +5,9 @@ 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 parsers_1 = require("@yarnpkg/parsers");
8
+ const ci_info_1 = tslib_1.__importDefault(require("ci-info"));
8
9
  const clipanion_1 = require("clipanion");
9
- const t = (0, tslib_1.__importStar)(require("typanion"));
10
+ const t = tslib_1.__importStar(require("typanion"));
10
11
  // eslint-disable-next-line arca/no-default-export
11
12
  class YarnCommand extends cli_1.BaseCommand {
12
13
  constructor() {
@@ -39,14 +40,13 @@ class YarnCommand extends cli_1.BaseCommand {
39
40
  this.production = clipanion_1.Option.Boolean(`--production`, { hidden: true });
40
41
  this.registry = clipanion_1.Option.String(`--registry`, { hidden: true });
41
42
  this.silent = clipanion_1.Option.Boolean(`--silent`, { hidden: true });
43
+ this.networkTimeout = clipanion_1.Option.String(`--network-timeout`, { hidden: true });
42
44
  }
43
45
  async execute() {
44
46
  var _a;
45
47
  const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
46
48
  if (typeof this.inlineBuilds !== `undefined`)
47
49
  configuration.useWithSource(`<cli>`, { enableInlineBuilds: this.inlineBuilds }, configuration.startingCwd, { overwrite: true });
48
- const isZeitNow = !!process.env.NOW_BUILDER;
49
- const isNetlify = !!process.env.NETLIFY;
50
50
  // These variables are used in Google Cloud Platform environment
51
51
  // in process of deploying Google Cloud Functions and
52
52
  // Google App Engine
@@ -79,7 +79,7 @@ class YarnCommand extends cli_1.BaseCommand {
79
79
  // it would definitely be a configuration setting.
80
80
  if (typeof this.ignoreEngines !== `undefined`) {
81
81
  const exitCode = await reportDeprecation(`The --ignore-engines option is deprecated; engine checking isn't a core feature anymore`, {
82
- error: !isZeitNow,
82
+ error: !ci_info_1.default.VERCEL,
83
83
  });
84
84
  if (exitCode !== null) {
85
85
  return exitCode;
@@ -105,7 +105,7 @@ class YarnCommand extends cli_1.BaseCommand {
105
105
  // let someone implement this "resolver-that-reads-the-cache" logic.
106
106
  if (typeof this.preferOffline !== `undefined`) {
107
107
  const exitCode = await reportDeprecation(`The --prefer-offline flag is deprecated; use the --cached flag with 'yarn add' instead`, {
108
- error: !isZeitNow,
108
+ error: !ci_info_1.default.VERCEL,
109
109
  });
110
110
  if (exitCode !== null) {
111
111
  return exitCode;
@@ -148,13 +148,17 @@ class YarnCommand extends cli_1.BaseCommand {
148
148
  // Yarn commands would use different caches, causing unexpected behaviors.
149
149
  if (typeof this.cacheFolder !== `undefined`) {
150
150
  const exitCode = await reportDeprecation(`The cache-folder option has been deprecated; use rc settings instead`, {
151
- error: !isNetlify,
151
+ error: !ci_info_1.default.NETLIFY,
152
152
  });
153
153
  if (exitCode !== null) {
154
154
  return exitCode;
155
155
  }
156
156
  }
157
- const immutable = (_a = this.immutable) !== null && _a !== void 0 ? _a : configuration.get(`enableImmutableInstalls`);
157
+ const updateMode = this.mode === core_1.InstallMode.UpdateLockfile;
158
+ if (updateMode && (this.immutable || this.immutableCache))
159
+ throw new clipanion_1.UsageError(`${core_1.formatUtils.pretty(configuration, `--immutable`, core_1.formatUtils.Type.CODE)} and ${core_1.formatUtils.pretty(configuration, `--immutable-cache`, core_1.formatUtils.Type.CODE)} cannot be used with ${core_1.formatUtils.pretty(configuration, `--mode=update-lockfile`, core_1.formatUtils.Type.CODE)}`);
160
+ const immutable = ((_a = this.immutable) !== null && _a !== void 0 ? _a : configuration.get(`enableImmutableInstalls`)) && !updateMode;
161
+ const immutableCache = this.immutableCache && !updateMode;
158
162
  if (configuration.projectCwd !== null) {
159
163
  const fixReport = await core_1.StreamReport.start({
160
164
  configuration,
@@ -218,7 +222,7 @@ class YarnCommand extends cli_1.BaseCommand {
218
222
  }
219
223
  }
220
224
  const { project, workspace } = await core_1.Project.find(configuration, this.context.cwd);
221
- const cache = await core_1.Cache.find(configuration, { immutable: this.immutableCache, check: this.checkCache });
225
+ const cache = await core_1.Cache.find(configuration, { immutable: immutableCache, check: this.checkCache });
222
226
  if (!workspace)
223
227
  throw new cli_1.WorkspaceRequiredError(project.cwd, this.context.cwd);
224
228
  await project.restoreInstallState({
@@ -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 = (0, tslib_1.__importDefault)(require("semver"));
10
+ const semver_1 = 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");
@@ -6,9 +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 = (0, tslib_1.__importDefault)(require("micromatch"));
10
- const t = (0, tslib_1.__importStar)(require("typanion"));
11
- const suggestUtils = (0, tslib_1.__importStar)(require("../suggestUtils"));
9
+ const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
10
+ const t = tslib_1.__importStar(require("typanion"));
11
+ const suggestUtils = tslib_1.__importStar(require("../suggestUtils"));
12
12
  // eslint-disable-next-line arca/no-default-export
13
13
  class RemoveCommand extends cli_1.BaseCommand {
14
14
  constructor() {
@@ -21,11 +21,11 @@ function getBranchRef(branch) {
21
21
  const cloneWorkflow = ({ repository, branch }, target) => [
22
22
  [`git`, `init`, fslib_1.npath.fromPortablePath(target)],
23
23
  [`git`, `remote`, `add`, `origin`, repository],
24
- [`git`, `fetch`, `origin`, getBranchRef(branch)],
24
+ [`git`, `fetch`, `origin`, `--depth=1`, getBranchRef(branch)],
25
25
  [`git`, `reset`, `--hard`, `FETCH_HEAD`],
26
26
  ];
27
27
  const updateWorkflow = ({ branch }) => [
28
- [`git`, `fetch`, `origin`, getBranchRef(branch), `--force`],
28
+ [`git`, `fetch`, `origin`, `--depth=1`, getBranchRef(branch), `--force`],
29
29
  [`git`, `reset`, `--hard`, `FETCH_HEAD`],
30
30
  [`git`, `clean`, `-dfx`],
31
31
  ];
@@ -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 = (0, tslib_1.__importDefault)(require("semver"));
10
+ const semver_1 = 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() {
@@ -165,8 +165,10 @@ async function setVersion(configuration, bundleVersion, bundleBuffer, { report }
165
165
  yarnPath: projectPath,
166
166
  });
167
167
  const manifest = (await core_1.Manifest.tryFind(projectCwd)) || new core_1.Manifest();
168
- if (bundleVersion && core_2.miscUtils.isTaggedYarnVersion(bundleVersion))
169
- manifest.packageManager = `yarn@${bundleVersion}`;
168
+ manifest.packageManager = `yarn@${bundleVersion && core_2.miscUtils.isTaggedYarnVersion(bundleVersion)
169
+ ? bundleVersion
170
+ // If the version isn't tagged, we use the latest stable version as the wrapper
171
+ : await resolveTag(configuration, `stable`)}`;
170
172
  const data = {};
171
173
  manifest.exportTo(data);
172
174
  const path = fslib_1.ppath.join(projectCwd, core_1.Manifest.fileName);
@@ -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 = (0, tslib_1.__importDefault)(require("micromatch"));
8
+ const micromatch_1 = 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() {
@@ -7,9 +7,9 @@ const core_2 = require("@yarnpkg/core");
7
7
  const core_3 = require("@yarnpkg/core");
8
8
  const clipanion_1 = require("clipanion");
9
9
  const enquirer_1 = require("enquirer");
10
- const micromatch_1 = (0, tslib_1.__importDefault)(require("micromatch"));
11
- const t = (0, tslib_1.__importStar)(require("typanion"));
12
- const suggestUtils = (0, tslib_1.__importStar)(require("../suggestUtils"));
10
+ const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
11
+ const t = tslib_1.__importStar(require("typanion"));
12
+ const suggestUtils = tslib_1.__importStar(require("../suggestUtils"));
13
13
  // eslint-disable-next-line arca/no-default-export
14
14
  class UpCommand extends cli_1.BaseCommand {
15
15
  constructor() {
@@ -3,6 +3,8 @@ import { Usage } from 'clipanion';
3
3
  export default class WorkspacesListCommand extends BaseCommand {
4
4
  static paths: string[][];
5
5
  static usage: Usage;
6
+ since: string | boolean | undefined;
7
+ recursive: boolean;
6
8
  verbose: boolean;
7
9
  json: boolean;
8
10
  execute(): Promise<1 | 0>;
@@ -2,11 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cli_1 = require("@yarnpkg/cli");
4
4
  const core_1 = require("@yarnpkg/core");
5
+ const plugin_git_1 = require("@yarnpkg/plugin-git");
5
6
  const clipanion_1 = require("clipanion");
6
7
  // eslint-disable-next-line arca/no-default-export
7
8
  class WorkspacesListCommand extends cli_1.BaseCommand {
8
9
  constructor() {
9
10
  super(...arguments);
11
+ this.since = clipanion_1.Option.String(`--since`, {
12
+ description: `Only include workspaces that have been changed since the specified ref.`,
13
+ tolerateBoolean: true,
14
+ });
15
+ this.recursive = clipanion_1.Option.Boolean(`-R,--recursive`, false, {
16
+ description: `Find packages via dependencies/devDependencies instead of using the workspaces field`,
17
+ });
10
18
  this.verbose = clipanion_1.Option.Boolean(`-v,--verbose`, false, {
11
19
  description: `Also return the cross-dependencies between workspaces`,
12
20
  });
@@ -22,7 +30,15 @@ class WorkspacesListCommand extends cli_1.BaseCommand {
22
30
  json: this.json,
23
31
  stdout: this.context.stdout,
24
32
  }, async (report) => {
25
- for (const workspace of project.workspaces) {
33
+ const candidates = this.since
34
+ ? await plugin_git_1.gitUtils.fetchChangedWorkspaces({ ref: this.since, project })
35
+ : project.workspaces;
36
+ const workspaces = new Set(candidates);
37
+ if (this.recursive)
38
+ for (const dependents of [...candidates].map(candidate => candidate.getRecursiveWorkspaceDependents()))
39
+ for (const dependent of dependents)
40
+ workspaces.add(dependent);
41
+ for (const workspace of workspaces) {
26
42
  const { manifest } = workspace;
27
43
  let extra;
28
44
  if (this.verbose) {
@@ -71,6 +87,12 @@ WorkspacesListCommand.usage = clipanion_1.Command.Usage({
71
87
  category: `Workspace-related commands`,
72
88
  description: `list all available workspaces`,
73
89
  details: `
74
- This command will print the list of all workspaces in the project. If both the \`-v,--verbose\` and \`--json\` options are set, Yarn will also return the cross-dependencies between each workspaces (useful when you wish to automatically generate Buck / Bazel rules).
90
+ This command will print the list of all workspaces in the project.
91
+
92
+ - If \`--since\` is set, Yarn will only list workspaces that have been modified since the specified ref. By default Yarn will use the refs specified by the \`changesetBaseRefs\` configuration option.
93
+
94
+ - If \`-R,--recursive\` is set, Yarn will find workspaces to run the command on by recursively evaluating \`dependencies\` and \`devDependencies\` fields, instead of looking at the \`workspaces\` fields.
95
+
96
+ - If both the \`-v,--verbose\` and \`--json\` options are set, Yarn will also return the cross-dependencies between each workspaces (useful when you wish to automatically generate Buck / Bazel rules).
75
97
  `,
76
98
  });
@@ -4,7 +4,7 @@ exports.dedupe = exports.acceptedStrategies = exports.Strategy = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@yarnpkg/core");
6
6
  const core_2 = require("@yarnpkg/core");
7
- const micromatch_1 = (0, tslib_1.__importDefault)(require("micromatch"));
7
+ const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
8
8
  var Strategy;
9
9
  (function (Strategy) {
10
10
  /**
@@ -79,6 +79,9 @@ async function dedupe(project, { strategy, patterns, cache, report }) {
79
79
  project,
80
80
  report: throwReport,
81
81
  skipIntegrityCheck: true,
82
+ cacheOptions: {
83
+ skipIntegrityCheck: true,
84
+ },
82
85
  };
83
86
  const resolveOptions = {
84
87
  project,
package/lib/index.d.ts CHANGED
@@ -4,9 +4,36 @@ import * as dedupeUtils from './dedupeUtils';
4
4
  import * as suggestUtils from './suggestUtils';
5
5
  export { dedupeUtils, suggestUtils, };
6
6
  export interface Hooks {
7
+ /**
8
+ * Called when a new dependency is added to a workspace. Note that this hook
9
+ * is only called by the CLI commands like `yarn add` - manually adding the
10
+ * dependencies into the manifest and running `yarn install` won't trigger
11
+ * it.
12
+ */
7
13
  afterWorkspaceDependencyAddition?: (workspace: Workspace, target: suggestUtils.Target, descriptor: Descriptor, strategies: Array<suggestUtils.Strategy>) => Promise<void>;
14
+ /**
15
+ * Called when a dependency range is replaced inside a workspace. Note that
16
+ * this hook is only called by the CLI commands like `yarn add` - manually
17
+ * updating the dependencies from the manifest and running `yarn install`
18
+ * won't trigger it.
19
+ */
8
20
  afterWorkspaceDependencyReplacement?: (workspace: Workspace, target: suggestUtils.Target, fromDescriptor: Descriptor, toDescriptor: Descriptor) => Promise<void>;
21
+ /**
22
+ * Called when a dependency range is removed from a workspace. Note that
23
+ * this hook is only called by the CLI commands like `yarn remove` - manually
24
+ * removing the dependencies from the manifest and running `yarn install`
25
+ * won't trigger it.
26
+ */
9
27
  afterWorkspaceDependencyRemoval?: (workspace: Workspace, target: suggestUtils.Target, descriptor: Descriptor) => Promise<void>;
28
+ /**
29
+ * Called by `yarn info`. The `extra` field is the set of parameters passed
30
+ * to the `-X,--extra` flag. Calling `registerData` will add a new set of
31
+ * data that will be added to the package information.
32
+ *
33
+ * For instance, an "audit" plugin could check in `extra` whether the user
34
+ * requested audit information (via `-X audit`), and call `registerData`
35
+ * with those information (retrieved dynamically) if they did.
36
+ */
10
37
  fetchPackageInfo?: (pkg: Package, extra: Set<string>, registerData: (namespace: string, data: Array<formatUtils.Tuple> | {
11
38
  [key: string]: formatUtils.Tuple | undefined;
12
39
  }) => void) => Promise<void>;
package/lib/index.js CHANGED
@@ -4,44 +4,45 @@ exports.suggestUtils = exports.dedupeUtils = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@yarnpkg/core");
6
6
  const ci_info_1 = require("ci-info");
7
- const add_1 = (0, tslib_1.__importDefault)(require("./commands/add"));
8
- const bin_1 = (0, tslib_1.__importDefault)(require("./commands/bin"));
9
- const clean_1 = (0, tslib_1.__importDefault)(require("./commands/cache/clean"));
10
- const get_1 = (0, tslib_1.__importDefault)(require("./commands/config/get"));
11
- const set_1 = (0, tslib_1.__importDefault)(require("./commands/config/set"));
12
- const unset_1 = (0, tslib_1.__importDefault)(require("./commands/config/unset"));
13
- const config_1 = (0, tslib_1.__importDefault)(require("./commands/config"));
14
- const dedupe_1 = (0, tslib_1.__importDefault)(require("./commands/dedupe"));
15
- const clipanion_1 = (0, tslib_1.__importDefault)(require("./commands/entries/clipanion"));
16
- const help_1 = (0, tslib_1.__importDefault)(require("./commands/entries/help"));
17
- const run_1 = (0, tslib_1.__importDefault)(require("./commands/entries/run"));
18
- const version_1 = (0, tslib_1.__importDefault)(require("./commands/entries/version"));
19
- const exec_1 = (0, tslib_1.__importDefault)(require("./commands/exec"));
20
- const peerRequirements_1 = (0, tslib_1.__importDefault)(require("./commands/explain/peerRequirements"));
21
- const info_1 = (0, tslib_1.__importDefault)(require("./commands/info"));
22
- const install_1 = (0, tslib_1.__importDefault)(require("./commands/install"));
23
- const link_1 = (0, tslib_1.__importDefault)(require("./commands/link"));
24
- const node_1 = (0, tslib_1.__importDefault)(require("./commands/node"));
25
- const sources_1 = (0, tslib_1.__importDefault)(require("./commands/plugin/import/sources"));
26
- const import_1 = (0, tslib_1.__importDefault)(require("./commands/plugin/import"));
27
- const list_1 = (0, tslib_1.__importDefault)(require("./commands/plugin/list"));
28
- const remove_1 = (0, tslib_1.__importDefault)(require("./commands/plugin/remove"));
29
- const runtime_1 = (0, tslib_1.__importDefault)(require("./commands/plugin/runtime"));
30
- const rebuild_1 = (0, tslib_1.__importDefault)(require("./commands/rebuild"));
31
- const remove_2 = (0, tslib_1.__importDefault)(require("./commands/remove"));
32
- const runIndex_1 = (0, tslib_1.__importDefault)(require("./commands/runIndex"));
33
- const run_2 = (0, tslib_1.__importDefault)(require("./commands/run"));
34
- const resolution_1 = (0, tslib_1.__importDefault)(require("./commands/set/resolution"));
35
- const sources_2 = (0, tslib_1.__importDefault)(require("./commands/set/version/sources"));
36
- const version_2 = (0, tslib_1.__importDefault)(require("./commands/set/version"));
37
- const unlink_1 = (0, tslib_1.__importDefault)(require("./commands/unlink"));
38
- const up_1 = (0, tslib_1.__importDefault)(require("./commands/up"));
39
- const why_1 = (0, tslib_1.__importDefault)(require("./commands/why"));
40
- const list_2 = (0, tslib_1.__importDefault)(require("./commands/workspaces/list"));
41
- const workspace_1 = (0, tslib_1.__importDefault)(require("./commands/workspace"));
42
- const dedupeUtils = (0, tslib_1.__importStar)(require("./dedupeUtils"));
7
+ const add_1 = tslib_1.__importDefault(require("./commands/add"));
8
+ const bin_1 = tslib_1.__importDefault(require("./commands/bin"));
9
+ const clean_1 = tslib_1.__importDefault(require("./commands/cache/clean"));
10
+ const get_1 = tslib_1.__importDefault(require("./commands/config/get"));
11
+ const set_1 = tslib_1.__importDefault(require("./commands/config/set"));
12
+ const unset_1 = tslib_1.__importDefault(require("./commands/config/unset"));
13
+ const config_1 = tslib_1.__importDefault(require("./commands/config"));
14
+ const dedupe_1 = tslib_1.__importDefault(require("./commands/dedupe"));
15
+ const clipanion_1 = tslib_1.__importDefault(require("./commands/entries/clipanion"));
16
+ const help_1 = tslib_1.__importDefault(require("./commands/entries/help"));
17
+ const run_1 = tslib_1.__importDefault(require("./commands/entries/run"));
18
+ const version_1 = tslib_1.__importDefault(require("./commands/entries/version"));
19
+ const exec_1 = tslib_1.__importDefault(require("./commands/exec"));
20
+ const peerRequirements_1 = tslib_1.__importDefault(require("./commands/explain/peerRequirements"));
21
+ const explain_1 = tslib_1.__importDefault(require("./commands/explain"));
22
+ const info_1 = tslib_1.__importDefault(require("./commands/info"));
23
+ const install_1 = tslib_1.__importDefault(require("./commands/install"));
24
+ const link_1 = tslib_1.__importDefault(require("./commands/link"));
25
+ const node_1 = tslib_1.__importDefault(require("./commands/node"));
26
+ const sources_1 = tslib_1.__importDefault(require("./commands/plugin/import/sources"));
27
+ const import_1 = tslib_1.__importDefault(require("./commands/plugin/import"));
28
+ const list_1 = tslib_1.__importDefault(require("./commands/plugin/list"));
29
+ const remove_1 = tslib_1.__importDefault(require("./commands/plugin/remove"));
30
+ const runtime_1 = tslib_1.__importDefault(require("./commands/plugin/runtime"));
31
+ const rebuild_1 = tslib_1.__importDefault(require("./commands/rebuild"));
32
+ const remove_2 = tslib_1.__importDefault(require("./commands/remove"));
33
+ const runIndex_1 = tslib_1.__importDefault(require("./commands/runIndex"));
34
+ const run_2 = tslib_1.__importDefault(require("./commands/run"));
35
+ const resolution_1 = tslib_1.__importDefault(require("./commands/set/resolution"));
36
+ const sources_2 = tslib_1.__importDefault(require("./commands/set/version/sources"));
37
+ const version_2 = tslib_1.__importDefault(require("./commands/set/version"));
38
+ const unlink_1 = tslib_1.__importDefault(require("./commands/unlink"));
39
+ const up_1 = tslib_1.__importDefault(require("./commands/up"));
40
+ const why_1 = tslib_1.__importDefault(require("./commands/why"));
41
+ const list_2 = tslib_1.__importDefault(require("./commands/workspaces/list"));
42
+ const workspace_1 = tslib_1.__importDefault(require("./commands/workspace"));
43
+ const dedupeUtils = tslib_1.__importStar(require("./dedupeUtils"));
43
44
  exports.dedupeUtils = dedupeUtils;
44
- const suggestUtils = (0, tslib_1.__importStar)(require("./suggestUtils"));
45
+ const suggestUtils = tslib_1.__importStar(require("./suggestUtils"));
45
46
  exports.suggestUtils = suggestUtils;
46
47
  const plugin = {
47
48
  configuration: {
@@ -76,6 +77,7 @@ const plugin = {
76
77
  dedupe_1.default,
77
78
  exec_1.default,
78
79
  peerRequirements_1.default,
80
+ explain_1.default,
79
81
  info_1.default,
80
82
  install_1.default,
81
83
  link_1.default,
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const core_1 = require("@yarnpkg/core");
6
6
  const core_2 = require("@yarnpkg/core");
7
7
  const fslib_1 = require("@yarnpkg/fslib");
8
- const semver_1 = (0, tslib_1.__importDefault)(require("semver"));
8
+ const semver_1 = tslib_1.__importDefault(require("semver"));
9
9
  const WORKSPACE_PROTOCOL = `workspace:`;
10
10
  var Target;
11
11
  (function (Target) {
@@ -313,7 +313,7 @@ async function fetchDescriptorFrom(ident, range, { project, cache, workspace, pr
313
313
  const report = new core_1.ThrowReport();
314
314
  const fetcher = project.configuration.makeFetcher();
315
315
  const resolver = project.configuration.makeResolver();
316
- const fetchOptions = { project, fetcher, cache, checksums: project.storedChecksums, report, skipIntegrityCheck: true };
316
+ const fetchOptions = { project, fetcher, cache, checksums: project.storedChecksums, report, cacheOptions: { skipIntegrityCheck: true }, skipIntegrityCheck: true };
317
317
  const resolveOptions = { ...fetchOptions, resolver, fetchOptions };
318
318
  // The descriptor has to be bound for the resolvers that need a parent locator. (e.g. FileResolver)
319
319
  // If we didn't bind it, `yarn add ./folder` wouldn't work.
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@yarnpkg/plugin-essentials",
3
- "version": "3.1.0-rc.8",
3
+ "version": "3.2.0-rc.10",
4
4
  "license": "BSD-2-Clause",
5
5
  "main": "./lib/index.js",
6
6
  "dependencies": {
7
- "@yarnpkg/fslib": "^2.6.0-rc.8",
7
+ "@yarnpkg/fslib": "^2.6.1-rc.7",
8
8
  "@yarnpkg/json-proxy": "^2.1.1",
9
- "@yarnpkg/parsers": "^2.4.1-rc.8",
10
- "ci-info": "^2.0.0",
11
- "clipanion": "^3.0.1",
9
+ "@yarnpkg/parsers": "^2.5.0-rc.10",
10
+ "ci-info": "^3.2.0",
11
+ "clipanion": "^3.2.0-rc.4",
12
12
  "enquirer": "^2.3.6",
13
13
  "lodash": "^4.17.15",
14
14
  "micromatch": "^4.0.2",
@@ -17,17 +17,18 @@
17
17
  "typanion": "^3.3.0"
18
18
  },
19
19
  "peerDependencies": {
20
- "@yarnpkg/cli": "^3.1.0-rc.8",
21
- "@yarnpkg/core": "^3.1.0-rc.9"
20
+ "@yarnpkg/cli": "^3.2.0-rc.12",
21
+ "@yarnpkg/core": "^3.2.0-rc.12",
22
+ "@yarnpkg/plugin-git": "^2.6.0-rc.12"
22
23
  },
23
24
  "devDependencies": {
24
- "@types/ci-info": "^2",
25
25
  "@types/lodash": "^4.14.136",
26
26
  "@types/micromatch": "^4.0.1",
27
27
  "@types/semver": "^7.1.0",
28
28
  "@types/treeify": "^1.0.0",
29
- "@yarnpkg/cli": "^3.1.0-rc.8",
30
- "@yarnpkg/core": "^3.1.0-rc.9"
29
+ "@yarnpkg/cli": "^3.2.0-rc.12",
30
+ "@yarnpkg/core": "^3.2.0-rc.12",
31
+ "@yarnpkg/plugin-git": "^2.6.0-rc.12"
31
32
  },
32
33
  "repository": {
33
34
  "type": "git",
@@ -48,6 +49,6 @@
48
49
  "engines": {
49
50
  "node": ">=12 <14 || 14.2 - 14.9 || >14.10.0"
50
51
  },
51
- "stableVersion": "3.0.0",
52
+ "stableVersion": "3.1.0",
52
53
  "typings": "./lib/index.d.ts"
53
54
  }