@yarnpkg/plugin-essentials 3.1.0-rc.9 → 3.2.0-rc.11
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.
- package/lib/commands/add.js +2 -2
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/set.js +3 -3
- package/lib/commands/config/unset.js +3 -3
- package/lib/commands/dedupe.js +2 -2
- package/lib/commands/explain/peerRequirements.js +1 -1
- package/lib/commands/explain.d.ts +10 -0
- package/lib/commands/explain.js +99 -0
- package/lib/commands/info.js +7 -3
- package/lib/commands/install.js +8 -4
- package/lib/commands/plugin/import.js +1 -1
- package/lib/commands/remove.js +3 -3
- package/lib/commands/set/version/sources.js +2 -2
- package/lib/commands/set/version.js +5 -3
- package/lib/commands/unlink.js +1 -1
- package/lib/commands/up.js +3 -3
- package/lib/commands/workspaces/list.d.ts +2 -0
- package/lib/commands/workspaces/list.js +24 -2
- package/lib/dedupeUtils.js +4 -1
- package/lib/index.d.ts +27 -0
- package/lib/index.js +39 -37
- package/lib/suggestUtils.js +2 -2
- package/package.json +11 -9
package/lib/commands/add.js
CHANGED
|
@@ -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 =
|
|
11
|
-
const 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 =
|
|
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 =
|
|
8
|
-
const get_1 =
|
|
9
|
-
const set_1 =
|
|
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 =
|
|
8
|
-
const has_1 =
|
|
9
|
-
const unset_1 =
|
|
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() {
|
package/lib/commands/dedupe.js
CHANGED
|
@@ -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 =
|
|
21
|
-
const 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 =
|
|
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
|
+
});
|
package/lib/commands/info.js
CHANGED
|
@@ -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 =
|
|
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 {
|
package/lib/commands/install.js
CHANGED
|
@@ -5,9 +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 =
|
|
8
|
+
const ci_info_1 = tslib_1.__importDefault(require("ci-info"));
|
|
9
9
|
const clipanion_1 = require("clipanion");
|
|
10
|
-
const t =
|
|
10
|
+
const t = tslib_1.__importStar(require("typanion"));
|
|
11
11
|
// eslint-disable-next-line arca/no-default-export
|
|
12
12
|
class YarnCommand extends cli_1.BaseCommand {
|
|
13
13
|
constructor() {
|
|
@@ -154,7 +154,11 @@ class YarnCommand extends cli_1.BaseCommand {
|
|
|
154
154
|
return exitCode;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
const
|
|
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:
|
|
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 =
|
|
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");
|
package/lib/commands/remove.js
CHANGED
|
@@ -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 =
|
|
10
|
-
const t =
|
|
11
|
-
const 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 =
|
|
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
|
-
|
|
169
|
-
|
|
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);
|
package/lib/commands/unlink.js
CHANGED
|
@@ -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 =
|
|
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() {
|
package/lib/commands/up.js
CHANGED
|
@@ -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 =
|
|
11
|
-
const t =
|
|
12
|
-
const 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
|
-
|
|
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.
|
|
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
|
});
|
package/lib/dedupeUtils.js
CHANGED
|
@@ -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 =
|
|
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 =
|
|
8
|
-
const bin_1 =
|
|
9
|
-
const clean_1 =
|
|
10
|
-
const get_1 =
|
|
11
|
-
const set_1 =
|
|
12
|
-
const unset_1 =
|
|
13
|
-
const config_1 =
|
|
14
|
-
const dedupe_1 =
|
|
15
|
-
const clipanion_1 =
|
|
16
|
-
const help_1 =
|
|
17
|
-
const run_1 =
|
|
18
|
-
const version_1 =
|
|
19
|
-
const exec_1 =
|
|
20
|
-
const peerRequirements_1 =
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
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 =
|
|
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,
|
package/lib/suggestUtils.js
CHANGED
|
@@ -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 =
|
|
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.
|
|
3
|
+
"version": "3.2.0-rc.11",
|
|
4
4
|
"license": "BSD-2-Clause",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@yarnpkg/fslib": "^2.6.
|
|
7
|
+
"@yarnpkg/fslib": "^2.6.1-rc.8",
|
|
8
8
|
"@yarnpkg/json-proxy": "^2.1.1",
|
|
9
|
-
"@yarnpkg/parsers": "^2.
|
|
9
|
+
"@yarnpkg/parsers": "^2.5.0-rc.11",
|
|
10
10
|
"ci-info": "^3.2.0",
|
|
11
|
-
"clipanion": "^3.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,16 +17,18 @@
|
|
|
17
17
|
"typanion": "^3.3.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@yarnpkg/cli": "^3.
|
|
21
|
-
"@yarnpkg/core": "^3.
|
|
20
|
+
"@yarnpkg/cli": "^3.2.0-rc.13",
|
|
21
|
+
"@yarnpkg/core": "^3.2.0-rc.13",
|
|
22
|
+
"@yarnpkg/plugin-git": "^2.6.0-rc.13"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@types/lodash": "^4.14.136",
|
|
25
26
|
"@types/micromatch": "^4.0.1",
|
|
26
27
|
"@types/semver": "^7.1.0",
|
|
27
28
|
"@types/treeify": "^1.0.0",
|
|
28
|
-
"@yarnpkg/cli": "^3.
|
|
29
|
-
"@yarnpkg/core": "^3.
|
|
29
|
+
"@yarnpkg/cli": "^3.2.0-rc.13",
|
|
30
|
+
"@yarnpkg/core": "^3.2.0-rc.13",
|
|
31
|
+
"@yarnpkg/plugin-git": "^2.6.0-rc.13"
|
|
30
32
|
},
|
|
31
33
|
"repository": {
|
|
32
34
|
"type": "git",
|
|
@@ -47,6 +49,6 @@
|
|
|
47
49
|
"engines": {
|
|
48
50
|
"node": ">=12 <14 || 14.2 - 14.9 || >14.10.0"
|
|
49
51
|
},
|
|
50
|
-
"stableVersion": "3.
|
|
52
|
+
"stableVersion": "3.1.0",
|
|
51
53
|
"typings": "./lib/index.d.ts"
|
|
52
54
|
}
|