@yarnpkg/cli 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yarnpkg/cli",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "license": "BSD-2-Clause",
5
5
  "main": "./lib/index.js",
6
6
  "exports": {
@@ -8,14 +8,14 @@
8
8
  "./package.json": "./package.json"
9
9
  },
10
10
  "dependencies": {
11
- "@yarnpkg/core": "^4.0.3",
11
+ "@yarnpkg/core": "^4.0.4",
12
12
  "@yarnpkg/fslib": "^3.0.2",
13
13
  "@yarnpkg/libzip": "^3.0.1",
14
- "@yarnpkg/parsers": "^3.0.0",
15
- "@yarnpkg/plugin-compat": "^4.0.2",
14
+ "@yarnpkg/parsers": "^3.0.1",
15
+ "@yarnpkg/plugin-compat": "^4.0.4",
16
16
  "@yarnpkg/plugin-constraints": "^4.0.2",
17
17
  "@yarnpkg/plugin-dlx": "^4.0.0",
18
- "@yarnpkg/plugin-essentials": "^4.1.0",
18
+ "@yarnpkg/plugin-essentials": "^4.1.1",
19
19
  "@yarnpkg/plugin-exec": "^3.0.0",
20
20
  "@yarnpkg/plugin-file": "^3.0.0",
21
21
  "@yarnpkg/plugin-git": "^3.0.0",
@@ -26,16 +26,16 @@
26
26
  "@yarnpkg/plugin-link": "^3.0.0",
27
27
  "@yarnpkg/plugin-nm": "^4.0.2",
28
28
  "@yarnpkg/plugin-npm": "^3.0.1",
29
- "@yarnpkg/plugin-npm-cli": "^4.0.2",
29
+ "@yarnpkg/plugin-npm-cli": "^4.0.3",
30
30
  "@yarnpkg/plugin-pack": "^4.0.0",
31
31
  "@yarnpkg/plugin-patch": "^4.0.1",
32
- "@yarnpkg/plugin-pnp": "^4.0.2",
32
+ "@yarnpkg/plugin-pnp": "^4.0.3",
33
33
  "@yarnpkg/plugin-pnpm": "^2.0.0",
34
34
  "@yarnpkg/plugin-stage": "^4.0.0",
35
- "@yarnpkg/plugin-typescript": "^4.0.0",
36
- "@yarnpkg/plugin-version": "^4.0.1",
35
+ "@yarnpkg/plugin-typescript": "^4.1.0",
36
+ "@yarnpkg/plugin-version": "^4.0.2",
37
37
  "@yarnpkg/plugin-workspace-tools": "^4.1.0",
38
- "@yarnpkg/shell": "^4.0.0",
38
+ "@yarnpkg/shell": "^4.0.1",
39
39
  "ci-info": "^3.2.0",
40
40
  "clipanion": "^4.0.0-rc.2",
41
41
  "semver": "^7.1.2",
@@ -44,12 +44,12 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/semver": "^7.1.0",
47
- "@yarnpkg/builder": "^4.0.0",
47
+ "@yarnpkg/builder": "^4.1.0",
48
48
  "@yarnpkg/monorepo": "^0.0.0",
49
49
  "@yarnpkg/pnpify": "^4.0.1"
50
50
  },
51
51
  "peerDependencies": {
52
- "@yarnpkg/core": "^4.0.3"
52
+ "@yarnpkg/core": "^4.0.4"
53
53
  },
54
54
  "scripts": {
55
55
  "postpack": "rm -rf lib",
package/lib/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export { type CommandContext } from '@yarnpkg/core';
2
- export { BaseCommand } from './tools/BaseCommand';
3
- export { WorkspaceRequiredError } from './tools/WorkspaceRequiredError';
4
- export { getDynamicLibs } from './tools/getDynamicLibs';
5
- export { getPluginConfiguration } from './tools/getPluginConfiguration';
6
- export { openWorkspace } from './tools/openWorkspace';
7
- export { type YarnCli, getCli, runExit } from './lib';
8
- export { pluginCommands } from './pluginCommands';
package/lib/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pluginCommands = exports.runExit = exports.getCli = exports.openWorkspace = exports.getPluginConfiguration = exports.getDynamicLibs = exports.WorkspaceRequiredError = exports.BaseCommand = void 0;
4
- var BaseCommand_1 = require("./tools/BaseCommand");
5
- Object.defineProperty(exports, "BaseCommand", { enumerable: true, get: function () { return BaseCommand_1.BaseCommand; } });
6
- var WorkspaceRequiredError_1 = require("./tools/WorkspaceRequiredError");
7
- Object.defineProperty(exports, "WorkspaceRequiredError", { enumerable: true, get: function () { return WorkspaceRequiredError_1.WorkspaceRequiredError; } });
8
- var getDynamicLibs_1 = require("./tools/getDynamicLibs");
9
- Object.defineProperty(exports, "getDynamicLibs", { enumerable: true, get: function () { return getDynamicLibs_1.getDynamicLibs; } });
10
- var getPluginConfiguration_1 = require("./tools/getPluginConfiguration");
11
- Object.defineProperty(exports, "getPluginConfiguration", { enumerable: true, get: function () { return getPluginConfiguration_1.getPluginConfiguration; } });
12
- var openWorkspace_1 = require("./tools/openWorkspace");
13
- Object.defineProperty(exports, "openWorkspace", { enumerable: true, get: function () { return openWorkspace_1.openWorkspace; } });
14
- var lib_1 = require("./lib");
15
- Object.defineProperty(exports, "getCli", { enumerable: true, get: function () { return lib_1.getCli; } });
16
- Object.defineProperty(exports, "runExit", { enumerable: true, get: function () { return lib_1.runExit; } });
17
- var pluginCommands_1 = require("./pluginCommands");
18
- Object.defineProperty(exports, "pluginCommands", { enumerable: true, get: function () { return pluginCommands_1.pluginCommands; } });
package/lib/lib.d.ts DELETED
@@ -1,53 +0,0 @@
1
- /// <reference types="node" />
2
- import { CommandContext, PluginConfiguration } from '@yarnpkg/core';
3
- import { PortablePath } from '@yarnpkg/fslib';
4
- import { Cli } from 'clipanion';
5
- export type YarnCli = ReturnType<typeof getBaseCli>;
6
- declare function getBaseCli({ cwd, pluginConfiguration }: {
7
- cwd: PortablePath;
8
- pluginConfiguration: PluginConfiguration;
9
- }): Cli<CommandContext> & {
10
- defaultContext: {
11
- cwd: PortablePath;
12
- plugins: PluginConfiguration;
13
- quiet: boolean;
14
- stdin: NodeJS.ReadStream & {
15
- fd: 0;
16
- };
17
- stdout: NodeJS.WriteStream & {
18
- fd: 1;
19
- };
20
- stderr: NodeJS.WriteStream & {
21
- fd: 2;
22
- };
23
- env: NodeJS.ProcessEnv;
24
- colorDepth: number;
25
- };
26
- };
27
- export declare function getCli({ cwd, pluginConfiguration }?: {
28
- cwd?: PortablePath;
29
- pluginConfiguration?: PluginConfiguration;
30
- }): Promise<Cli<CommandContext> & {
31
- defaultContext: {
32
- cwd: PortablePath;
33
- plugins: PluginConfiguration;
34
- quiet: boolean;
35
- stdin: NodeJS.ReadStream & {
36
- fd: 0;
37
- };
38
- stdout: NodeJS.WriteStream & {
39
- fd: 1;
40
- };
41
- stderr: NodeJS.WriteStream & {
42
- fd: 2;
43
- };
44
- env: NodeJS.ProcessEnv;
45
- colorDepth: number;
46
- };
47
- }>;
48
- export declare function runExit(argv: Array<string>, { cwd, selfPath, pluginConfiguration }: {
49
- cwd: PortablePath;
50
- selfPath: PortablePath | null;
51
- pluginConfiguration: PluginConfiguration;
52
- }): Promise<void>;
53
- export {};
package/lib/lib.js DELETED
@@ -1,164 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runExit = exports.getCli = void 0;
4
- const core_1 = require("@yarnpkg/core");
5
- const fslib_1 = require("@yarnpkg/fslib");
6
- const child_process_1 = require("child_process");
7
- const ci_info_1 = require("ci-info");
8
- const clipanion_1 = require("clipanion");
9
- const pluginCommands_1 = require("./pluginCommands");
10
- const getPluginConfiguration_1 = require("./tools/getPluginConfiguration");
11
- function getBaseCli({ cwd, pluginConfiguration }) {
12
- const cli = new clipanion_1.Cli({
13
- binaryLabel: `Yarn Package Manager`,
14
- binaryName: `yarn`,
15
- binaryVersion: core_1.YarnVersion ?? `<unknown>`,
16
- });
17
- return Object.assign(cli, {
18
- defaultContext: {
19
- ...clipanion_1.Cli.defaultContext,
20
- cwd,
21
- plugins: pluginConfiguration,
22
- quiet: false,
23
- stdin: process.stdin,
24
- stdout: process.stdout,
25
- stderr: process.stderr,
26
- },
27
- });
28
- }
29
- function validateNodejsVersion(cli) {
30
- // YARN_IGNORE_NODE is special because this code needs to execute as early as possible.
31
- // It's not a regular core setting because Configuration.find may use functions not available
32
- // on older Node versions.
33
- const ignoreNode = core_1.miscUtils.parseOptionalBoolean(process.env.YARN_IGNORE_NODE);
34
- if (ignoreNode)
35
- return true;
36
- const version = process.versions.node;
37
- // Non-exhaustive known requirements:
38
- // - 18.12 is the first LTS release
39
- const range = `>=18.12.0`;
40
- if (core_1.semverUtils.satisfiesWithPrereleases(version, range))
41
- return true;
42
- const error = new clipanion_1.UsageError(`This tool requires a Node version compatible with ${range} (got ${version}). Upgrade Node, or set \`YARN_IGNORE_NODE=1\` in your environment.`);
43
- clipanion_1.Cli.defaultContext.stdout.write(cli.error(error));
44
- return false;
45
- }
46
- async function getCoreConfiguration({ selfPath, pluginConfiguration }) {
47
- // Since we only care about a few very specific settings we tolerate extra configuration key.
48
- // If we didn't, we wouldn't even be able to run `yarn config` (which is recommended in the invalid config error message)
49
- return await core_1.Configuration.find(fslib_1.npath.toPortablePath(process.cwd()), pluginConfiguration, {
50
- strict: false,
51
- usePathCheck: selfPath,
52
- });
53
- }
54
- function runYarnPath(cli, argv, { yarnPath }) {
55
- if (!fslib_1.xfs.existsSync(yarnPath)) {
56
- (cli.error(new Error(`The "yarn-path" option has been set, but the specified location doesn't exist (${yarnPath}).`)));
57
- return 1;
58
- }
59
- process.on(`SIGINT`, () => {
60
- // We don't want SIGINT to kill our process; we want it to kill the
61
- // innermost process, whose end will cause our own to exit.
62
- });
63
- const yarnPathExecOptions = {
64
- stdio: `inherit`,
65
- env: {
66
- ...process.env,
67
- YARN_IGNORE_PATH: `1`,
68
- },
69
- };
70
- try {
71
- (0, child_process_1.execFileSync)(process.execPath, [fslib_1.npath.fromPortablePath(yarnPath), ...argv], yarnPathExecOptions);
72
- }
73
- catch (err) {
74
- return err.status ?? 1;
75
- }
76
- return 0;
77
- }
78
- function checkCwd(cli, argv) {
79
- let cwd = null;
80
- let postCwdArgv = argv;
81
- if (argv.length >= 2 && argv[0] === `--cwd`) {
82
- cwd = fslib_1.npath.toPortablePath(argv[1]);
83
- postCwdArgv = argv.slice(2);
84
- }
85
- else if (argv.length >= 1 && argv[0].startsWith(`--cwd=`)) {
86
- cwd = fslib_1.npath.toPortablePath(argv[0].slice(6));
87
- postCwdArgv = argv.slice(1);
88
- }
89
- else if (argv[0] === `add` && argv[argv.length - 2] === `--cwd`) {
90
- // CRA adds `--cwd` at the end of the command; it's not ideal, but since
91
- // it's unlikely to receive more releases we can just special-case it
92
- // TODO v5: remove this special case
93
- cwd = fslib_1.npath.toPortablePath(argv[argv.length - 1]);
94
- postCwdArgv = argv.slice(0, argv.length - 2);
95
- }
96
- cli.defaultContext.cwd = cwd !== null
97
- ? fslib_1.ppath.resolve(cwd)
98
- : fslib_1.ppath.cwd();
99
- return postCwdArgv;
100
- }
101
- function initTelemetry(cli, { configuration }) {
102
- const isTelemetryEnabled = configuration.get(`enableTelemetry`);
103
- if (!isTelemetryEnabled || ci_info_1.isCI || !process.stdout.isTTY)
104
- return;
105
- core_1.Configuration.telemetry = new core_1.TelemetryManager(configuration, `puba9cdc10ec5790a2cf4969dd413a47270`);
106
- const PLUGIN_REGEX = /^@yarnpkg\/plugin-(.*)$/;
107
- for (const name of configuration.plugins.keys())
108
- if (pluginCommands_1.pluginCommands.has(name.match(PLUGIN_REGEX)?.[1] ?? ``))
109
- core_1.Configuration.telemetry?.reportPluginName(name);
110
- if (cli.binaryVersion) {
111
- core_1.Configuration.telemetry.reportVersion(cli.binaryVersion);
112
- }
113
- }
114
- function initCommands(cli, { configuration }) {
115
- for (const plugin of configuration.plugins.values()) {
116
- for (const command of plugin.commands || []) {
117
- cli.register(command);
118
- }
119
- }
120
- }
121
- async function run(cli, argv, { selfPath, pluginConfiguration }) {
122
- if (!validateNodejsVersion(cli))
123
- return 1;
124
- const configuration = await getCoreConfiguration({
125
- selfPath,
126
- pluginConfiguration,
127
- });
128
- const yarnPath = configuration.get(`yarnPath`);
129
- const ignorePath = configuration.get(`ignorePath`);
130
- if (yarnPath && !ignorePath)
131
- return runYarnPath(cli, argv, { yarnPath });
132
- delete process.env.YARN_IGNORE_PATH;
133
- const postCwdArgv = checkCwd(cli, argv);
134
- initTelemetry(cli, { configuration });
135
- initCommands(cli, { configuration });
136
- const command = cli.process(postCwdArgv, cli.defaultContext);
137
- if (!command.help)
138
- core_1.Configuration.telemetry?.reportCommandName(command.path.join(` `));
139
- return await cli.run(command, cli.defaultContext);
140
- }
141
- async function getCli({ cwd = fslib_1.ppath.cwd(), pluginConfiguration = (0, getPluginConfiguration_1.getPluginConfiguration)() } = {}) {
142
- const cli = getBaseCli({ cwd, pluginConfiguration });
143
- const configuration = await getCoreConfiguration({
144
- pluginConfiguration,
145
- selfPath: null,
146
- });
147
- initCommands(cli, { configuration });
148
- return cli;
149
- }
150
- exports.getCli = getCli;
151
- async function runExit(argv, { cwd = fslib_1.ppath.cwd(), selfPath, pluginConfiguration }) {
152
- const cli = getBaseCli({ cwd, pluginConfiguration });
153
- try {
154
- process.exitCode = await run(cli, argv, { selfPath, pluginConfiguration });
155
- }
156
- catch (error) {
157
- clipanion_1.Cli.defaultContext.stdout.write(cli.error(error));
158
- process.exitCode = 1;
159
- }
160
- finally {
161
- await fslib_1.xfs.rmtempPromise();
162
- }
163
- }
164
- exports.runExit = runExit;
@@ -1 +0,0 @@
1
- export declare const pluginCommands: Map<string, string[]>;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- // Don't modify this script directly! Instead, run:
3
- // yarn build:plugin-commands
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.pluginCommands = void 0;
6
- exports.pluginCommands = new Map([]);
File without changes
package/lib/polyfills.js DELETED
File without changes
@@ -1,7 +0,0 @@
1
- import { CommandContext } from '@yarnpkg/core';
2
- import { Command } from 'clipanion';
3
- export declare abstract class BaseCommand extends Command<CommandContext> {
4
- cwd: string | undefined;
5
- abstract execute(): Promise<number | void>;
6
- validateAndExecute(): Promise<number>;
7
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseCommand = void 0;
4
- const clipanion_1 = require("clipanion");
5
- class BaseCommand extends clipanion_1.Command {
6
- constructor() {
7
- super(...arguments);
8
- this.cwd = clipanion_1.Option.String(`--cwd`, { hidden: true });
9
- }
10
- validateAndExecute() {
11
- if (typeof this.cwd !== `undefined`)
12
- throw new clipanion_1.UsageError(`The --cwd option is ambiguous when used anywhere else than the very first parameter provided in the command line, before even the command path`);
13
- return super.validateAndExecute();
14
- }
15
- }
16
- exports.BaseCommand = BaseCommand;
@@ -1,5 +0,0 @@
1
- import { PortablePath } from '@yarnpkg/fslib';
2
- import { UsageError } from 'clipanion';
3
- export declare class WorkspaceRequiredError extends UsageError {
4
- constructor(projectCwd: PortablePath, cwd: PortablePath);
5
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkspaceRequiredError = void 0;
4
- const core_1 = require("@yarnpkg/core");
5
- const fslib_1 = require("@yarnpkg/fslib");
6
- const clipanion_1 = require("clipanion");
7
- class WorkspaceRequiredError extends clipanion_1.UsageError {
8
- constructor(projectCwd, cwd) {
9
- const relativePath = fslib_1.ppath.relative(projectCwd, cwd);
10
- const manifestPath = fslib_1.ppath.join(projectCwd, core_1.Manifest.fileName);
11
- super(`This command can only be run from within a workspace of your project (${relativePath} isn't a workspace of ${manifestPath}).`);
12
- }
13
- }
14
- exports.WorkspaceRequiredError = WorkspaceRequiredError;
@@ -1 +0,0 @@
1
- export declare const getDynamicLibs: () => Map<string, any>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDynamicLibs = void 0;
4
- const tslib_1 = require("tslib");
5
- const cli = tslib_1.__importStar(require("@yarnpkg/cli"));
6
- const core = tslib_1.__importStar(require("@yarnpkg/core"));
7
- const fslib = tslib_1.__importStar(require("@yarnpkg/fslib"));
8
- const libzip = tslib_1.__importStar(require("@yarnpkg/libzip"));
9
- const parsers = tslib_1.__importStar(require("@yarnpkg/parsers"));
10
- const shell = tslib_1.__importStar(require("@yarnpkg/shell"));
11
- const clipanion = tslib_1.__importStar(require("clipanion"));
12
- const semver = tslib_1.__importStar(require("semver"));
13
- const typanion = tslib_1.__importStar(require("typanion"));
14
- const getDynamicLibs = () => new Map([
15
- [`@yarnpkg/cli`, cli],
16
- [`@yarnpkg/core`, core],
17
- [`@yarnpkg/fslib`, fslib],
18
- [`@yarnpkg/libzip`, libzip],
19
- [`@yarnpkg/parsers`, parsers],
20
- [`@yarnpkg/shell`, shell],
21
- // Those ones are always useful
22
- [`clipanion`, clipanion],
23
- [`semver`, semver],
24
- [`typanion`, typanion],
25
- ]);
26
- exports.getDynamicLibs = getDynamicLibs;
@@ -1,2 +0,0 @@
1
- import { PluginConfiguration } from '@yarnpkg/core';
2
- export declare function getPluginConfiguration(): PluginConfiguration;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPluginConfiguration = void 0;
4
- const tslib_1 = require("tslib");
5
- const package_json_1 = tslib_1.__importDefault(require("@yarnpkg/cli/package.json"));
6
- const getDynamicLibs_1 = require("./getDynamicLibs");
7
- function getPluginConfiguration() {
8
- const plugins = new Set();
9
- for (const dependencyName of package_json_1.default[`@yarnpkg/builder`].bundles.standard)
10
- plugins.add(dependencyName);
11
- const modules = (0, getDynamicLibs_1.getDynamicLibs)();
12
- for (const plugin of plugins)
13
- modules.set(plugin, require(plugin).default);
14
- return { plugins, modules };
15
- }
16
- exports.getPluginConfiguration = getPluginConfiguration;
@@ -1,3 +0,0 @@
1
- import { Configuration } from '@yarnpkg/core';
2
- import { PortablePath } from '@yarnpkg/fslib';
3
- export declare function openWorkspace(configuration: Configuration, cwd: PortablePath): Promise<import("@yarnpkg/core").Workspace>;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openWorkspace = void 0;
4
- const core_1 = require("@yarnpkg/core");
5
- const WorkspaceRequiredError_1 = require("./WorkspaceRequiredError");
6
- async function openWorkspace(configuration, cwd) {
7
- const { project, workspace } = await core_1.Project.find(configuration, cwd);
8
- if (!workspace)
9
- throw new WorkspaceRequiredError_1.WorkspaceRequiredError(project.cwd, cwd);
10
- return workspace;
11
- }
12
- exports.openWorkspace = openWorkspace;