@yarnpkg/cli 4.0.0-rc.9 → 4.0.1
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/boot-cli-dev.js +2 -56
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -3
- package/lib/lib.d.ts +53 -0
- package/lib/lib.js +164 -0
- package/lib/polyfills.d.ts +0 -1
- package/lib/polyfills.js +0 -3
- package/lib/tools/BaseCommand.d.ts +1 -0
- package/lib/tools/BaseCommand.js +5 -0
- package/lib/tools/getPluginConfiguration.js +0 -1
- package/package.json +46 -42
- package/lib/main.d.ts +0 -5
- package/lib/main.js +0 -150
package/lib/boot-cli-dev.js
CHANGED
|
@@ -5,61 +5,7 @@ const pnpFile = `${__dirname}/../../../.pnp.cjs`;
|
|
|
5
5
|
if (fs.existsSync(pnpFile))
|
|
6
6
|
require(pnpFile).setup();
|
|
7
7
|
|
|
8
|
-
// Adds TS support to Node
|
|
9
8
|
require(`@yarnpkg/monorepo/scripts/setup-ts-execution`);
|
|
9
|
+
require(`@yarnpkg/monorepo/scripts/setup-local-plugins`);
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
global.YARN_VERSION = `${require(`@yarnpkg/cli/package.json`).version}-dev`;
|
|
13
|
-
|
|
14
|
-
// Inject the plugins in the runtime. With Webpack that would be through
|
|
15
|
-
// val-loader which would execute pluginConfiguration.raw.js, so in Node
|
|
16
|
-
// we need to do something similar and mutate the require cache.
|
|
17
|
-
const PLUGIN_CONFIG_MODULE = `./tools/getPluginConfiguration.ts`;
|
|
18
|
-
require.cache[require.resolve(PLUGIN_CONFIG_MODULE)] = {exports: {getPluginConfiguration}};
|
|
19
|
-
|
|
20
|
-
const micromatch = require(`micromatch`);
|
|
21
|
-
|
|
22
|
-
module.exports = require(`./cli`);
|
|
23
|
-
|
|
24
|
-
function getPluginConfiguration() {
|
|
25
|
-
const folders = fs.readdirSync(`${__dirname}/../../`);
|
|
26
|
-
|
|
27
|
-
const pluginFolders = folders.filter(folder => {
|
|
28
|
-
if (!folder.startsWith(`plugin-`))
|
|
29
|
-
return false;
|
|
30
|
-
|
|
31
|
-
if (process.env.BLACKLIST && micromatch.match([folder, folder.replace(`plugin-`, ``)], process.env.BLACKLIST).length > 0) {
|
|
32
|
-
console.warn(`Disabled blacklisted plugin ${folder}`);
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let isRequirable;
|
|
37
|
-
try {
|
|
38
|
-
require(`${__dirname}/../../${folder}`);
|
|
39
|
-
isRequirable = true;
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.warn(`Disabled non-requirable plugin ${folder}: ${e.message}`);
|
|
42
|
-
isRequirable = false;
|
|
43
|
-
}
|
|
44
|
-
return isRequirable;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// Note that we don't need to populate the `modules` field, because the
|
|
48
|
-
// plugins will be loaded without being transformed by the builder wrapper,
|
|
49
|
-
// so they will simply access their own set of dependencies.
|
|
50
|
-
const pluginConfiguration = {
|
|
51
|
-
plugins: new Set(),
|
|
52
|
-
modules: new Map(),
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
for (const folder of pluginFolders) {
|
|
56
|
-
pluginConfiguration.plugins.add(`@yarnpkg/${folder}`);
|
|
57
|
-
pluginConfiguration.modules.set(`@yarnpkg/${folder}`, require(`../../${folder}`));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const {getDynamicLibs} = require(`./tools/getDynamicLibs`);
|
|
61
|
-
for (const [name, module] of getDynamicLibs())
|
|
62
|
-
pluginConfiguration.modules.set(name, module);
|
|
63
|
-
|
|
64
|
-
return pluginConfiguration;
|
|
65
|
-
}
|
|
11
|
+
require(`./cli`);
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { type CommandContext } from '@yarnpkg/core';
|
|
1
2
|
export { BaseCommand } from './tools/BaseCommand';
|
|
2
3
|
export { WorkspaceRequiredError } from './tools/WorkspaceRequiredError';
|
|
3
4
|
export { getDynamicLibs } from './tools/getDynamicLibs';
|
|
4
5
|
export { getPluginConfiguration } from './tools/getPluginConfiguration';
|
|
5
6
|
export { openWorkspace } from './tools/openWorkspace';
|
|
6
|
-
export {
|
|
7
|
+
export { type YarnCli, getCli, runExit } from './lib';
|
|
7
8
|
export { pluginCommands } from './pluginCommands';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pluginCommands = exports.
|
|
3
|
+
exports.pluginCommands = exports.runExit = exports.getCli = exports.openWorkspace = exports.getPluginConfiguration = exports.getDynamicLibs = exports.WorkspaceRequiredError = exports.BaseCommand = void 0;
|
|
4
4
|
var BaseCommand_1 = require("./tools/BaseCommand");
|
|
5
5
|
Object.defineProperty(exports, "BaseCommand", { enumerable: true, get: function () { return BaseCommand_1.BaseCommand; } });
|
|
6
6
|
var WorkspaceRequiredError_1 = require("./tools/WorkspaceRequiredError");
|
|
@@ -11,7 +11,8 @@ var getPluginConfiguration_1 = require("./tools/getPluginConfiguration");
|
|
|
11
11
|
Object.defineProperty(exports, "getPluginConfiguration", { enumerable: true, get: function () { return getPluginConfiguration_1.getPluginConfiguration; } });
|
|
12
12
|
var openWorkspace_1 = require("./tools/openWorkspace");
|
|
13
13
|
Object.defineProperty(exports, "openWorkspace", { enumerable: true, get: function () { return openWorkspace_1.openWorkspace; } });
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "
|
|
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; } });
|
|
16
17
|
var pluginCommands_1 = require("./pluginCommands");
|
|
17
18
|
Object.defineProperty(exports, "pluginCommands", { enumerable: true, get: function () { return pluginCommands_1.pluginCommands; } });
|
package/lib/lib.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
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;
|
package/lib/polyfills.d.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/polyfills.js
CHANGED
package/lib/tools/BaseCommand.js
CHANGED
|
@@ -7,5 +7,10 @@ class BaseCommand extends clipanion_1.Command {
|
|
|
7
7
|
super(...arguments);
|
|
8
8
|
this.cwd = clipanion_1.Option.String(`--cwd`, { hidden: true });
|
|
9
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
|
+
}
|
|
10
15
|
}
|
|
11
16
|
exports.BaseCommand = BaseCommand;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPluginConfiguration = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
// @ts-expect-error
|
|
6
5
|
const package_json_1 = tslib_1.__importDefault(require("@yarnpkg/cli/package.json"));
|
|
7
6
|
const getDynamicLibs_1 = require("./getDynamicLibs");
|
|
8
7
|
function getPluginConfiguration() {
|
package/package.json
CHANGED
|
@@ -1,52 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarnpkg/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"license": "BSD-2-Clause",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./lib/index.js",
|
|
8
|
+
"./package.json": "./package.json"
|
|
9
|
+
},
|
|
6
10
|
"dependencies": {
|
|
7
|
-
"@yarnpkg/core": "^4.0.
|
|
8
|
-
"@yarnpkg/fslib": "^3.0.
|
|
9
|
-
"@yarnpkg/libzip": "^3.0.0
|
|
10
|
-
"@yarnpkg/parsers": "^3.0.0
|
|
11
|
-
"@yarnpkg/plugin-compat": "^4.0.0
|
|
12
|
-
"@yarnpkg/plugin-constraints": "^4.0.
|
|
13
|
-
"@yarnpkg/plugin-dlx": "^4.0.0
|
|
14
|
-
"@yarnpkg/plugin-essentials": "^4.0.
|
|
15
|
-
"@yarnpkg/plugin-exec": "^3.0.0
|
|
16
|
-
"@yarnpkg/plugin-file": "^3.0.0
|
|
17
|
-
"@yarnpkg/plugin-git": "^3.0.0
|
|
18
|
-
"@yarnpkg/plugin-github": "^3.0.0
|
|
19
|
-
"@yarnpkg/plugin-http": "^3.0.0
|
|
20
|
-
"@yarnpkg/plugin-init": "^4.0.0
|
|
21
|
-
"@yarnpkg/plugin-interactive-tools": "^4.0.0
|
|
22
|
-
"@yarnpkg/plugin-link": "^3.0.0
|
|
23
|
-
"@yarnpkg/plugin-nm": "^4.0.0
|
|
24
|
-
"@yarnpkg/plugin-npm": "^3.0.0
|
|
25
|
-
"@yarnpkg/plugin-npm-cli": "^4.0.
|
|
26
|
-
"@yarnpkg/plugin-pack": "^4.0.0
|
|
27
|
-
"@yarnpkg/plugin-patch": "^4.0.0
|
|
28
|
-
"@yarnpkg/plugin-pnp": "^4.0.
|
|
29
|
-
"@yarnpkg/plugin-pnpm": "^2.0.0
|
|
30
|
-
"@yarnpkg/plugin-stage": "^4.0.0
|
|
31
|
-
"@yarnpkg/plugin-typescript": "^4.0.0
|
|
32
|
-
"@yarnpkg/plugin-version": "^4.0.0
|
|
33
|
-
"@yarnpkg/plugin-workspace-tools": "^4.0.
|
|
34
|
-
"@yarnpkg/shell": "^4.0.0
|
|
11
|
+
"@yarnpkg/core": "^4.0.1",
|
|
12
|
+
"@yarnpkg/fslib": "^3.0.1",
|
|
13
|
+
"@yarnpkg/libzip": "^3.0.0",
|
|
14
|
+
"@yarnpkg/parsers": "^3.0.0",
|
|
15
|
+
"@yarnpkg/plugin-compat": "^4.0.0",
|
|
16
|
+
"@yarnpkg/plugin-constraints": "^4.0.1",
|
|
17
|
+
"@yarnpkg/plugin-dlx": "^4.0.0",
|
|
18
|
+
"@yarnpkg/plugin-essentials": "^4.0.1",
|
|
19
|
+
"@yarnpkg/plugin-exec": "^3.0.0",
|
|
20
|
+
"@yarnpkg/plugin-file": "^3.0.0",
|
|
21
|
+
"@yarnpkg/plugin-git": "^3.0.0",
|
|
22
|
+
"@yarnpkg/plugin-github": "^3.0.0",
|
|
23
|
+
"@yarnpkg/plugin-http": "^3.0.0",
|
|
24
|
+
"@yarnpkg/plugin-init": "^4.0.0",
|
|
25
|
+
"@yarnpkg/plugin-interactive-tools": "^4.0.0",
|
|
26
|
+
"@yarnpkg/plugin-link": "^3.0.0",
|
|
27
|
+
"@yarnpkg/plugin-nm": "^4.0.0",
|
|
28
|
+
"@yarnpkg/plugin-npm": "^3.0.0",
|
|
29
|
+
"@yarnpkg/plugin-npm-cli": "^4.0.1",
|
|
30
|
+
"@yarnpkg/plugin-pack": "^4.0.0",
|
|
31
|
+
"@yarnpkg/plugin-patch": "^4.0.0",
|
|
32
|
+
"@yarnpkg/plugin-pnp": "^4.0.1",
|
|
33
|
+
"@yarnpkg/plugin-pnpm": "^2.0.0",
|
|
34
|
+
"@yarnpkg/plugin-stage": "^4.0.0",
|
|
35
|
+
"@yarnpkg/plugin-typescript": "^4.0.0",
|
|
36
|
+
"@yarnpkg/plugin-version": "^4.0.0",
|
|
37
|
+
"@yarnpkg/plugin-workspace-tools": "^4.0.1",
|
|
38
|
+
"@yarnpkg/shell": "^4.0.0",
|
|
35
39
|
"ci-info": "^3.2.0",
|
|
36
|
-
"clipanion": "^
|
|
40
|
+
"clipanion": "^4.0.0-rc.2",
|
|
37
41
|
"semver": "^7.1.2",
|
|
38
|
-
"tslib": "^
|
|
39
|
-
"typanion": "^3.
|
|
42
|
+
"tslib": "^2.4.0",
|
|
43
|
+
"typanion": "^3.14.0"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"@types/semver": "^7.1.0",
|
|
43
|
-
"@yarnpkg/builder": "^4.0.0
|
|
47
|
+
"@yarnpkg/builder": "^4.0.0",
|
|
44
48
|
"@yarnpkg/monorepo": "^0.0.0",
|
|
45
|
-
"@yarnpkg/pnpify": "^4.0.0
|
|
46
|
-
"micromatch": "^4.0.2"
|
|
49
|
+
"@yarnpkg/pnpify": "^4.0.0"
|
|
47
50
|
},
|
|
48
51
|
"peerDependencies": {
|
|
49
|
-
"@yarnpkg/core": "^4.0.
|
|
52
|
+
"@yarnpkg/core": "^4.0.1"
|
|
50
53
|
},
|
|
51
54
|
"scripts": {
|
|
52
55
|
"postpack": "rm -rf lib",
|
|
@@ -58,8 +61,11 @@
|
|
|
58
61
|
},
|
|
59
62
|
"publishConfig": {
|
|
60
63
|
"main": "./lib/index.js",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
64
|
+
"bin": null,
|
|
65
|
+
"exports": {
|
|
66
|
+
".": "./lib/index.js",
|
|
67
|
+
"./package.json": "./package.json"
|
|
68
|
+
}
|
|
63
69
|
},
|
|
64
70
|
"files": [
|
|
65
71
|
"/lib/**/*",
|
|
@@ -101,8 +107,6 @@
|
|
|
101
107
|
"directory": "packages/yarnpkg-cli"
|
|
102
108
|
},
|
|
103
109
|
"engines": {
|
|
104
|
-
"node": ">=
|
|
105
|
-
}
|
|
106
|
-
"stableVersion": "3.2.0",
|
|
107
|
-
"types": "./lib/index.d.ts"
|
|
110
|
+
"node": ">=18.12.0"
|
|
111
|
+
}
|
|
108
112
|
}
|
package/lib/main.d.ts
DELETED
package/lib/main.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = 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 fs_1 = require("fs");
|
|
10
|
-
const pluginCommands_1 = require("./pluginCommands");
|
|
11
|
-
function runBinary(path) {
|
|
12
|
-
const physicalPath = fslib_1.npath.fromPortablePath(path);
|
|
13
|
-
process.on(`SIGINT`, () => {
|
|
14
|
-
// We don't want SIGINT to kill our process; we want it to kill the
|
|
15
|
-
// innermost process, whose end will cause our own to exit.
|
|
16
|
-
});
|
|
17
|
-
if (physicalPath) {
|
|
18
|
-
(0, child_process_1.execFileSync)(process.execPath, [physicalPath, ...process.argv.slice(2)], {
|
|
19
|
-
stdio: `inherit`,
|
|
20
|
-
env: {
|
|
21
|
-
...process.env,
|
|
22
|
-
YARN_IGNORE_PATH: `1`,
|
|
23
|
-
YARN_IGNORE_CWD: `1`,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
(0, child_process_1.execFileSync)(physicalPath, process.argv.slice(2), {
|
|
29
|
-
stdio: `inherit`,
|
|
30
|
-
env: {
|
|
31
|
-
...process.env,
|
|
32
|
-
YARN_IGNORE_PATH: `1`,
|
|
33
|
-
YARN_IGNORE_CWD: `1`,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async function main({ binaryVersion, pluginConfiguration }) {
|
|
39
|
-
async function run() {
|
|
40
|
-
const cli = new clipanion_1.Cli({
|
|
41
|
-
binaryLabel: `Yarn Package Manager`,
|
|
42
|
-
binaryName: `yarn`,
|
|
43
|
-
binaryVersion,
|
|
44
|
-
});
|
|
45
|
-
try {
|
|
46
|
-
await exec(cli);
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
process.stdout.write(cli.error(error));
|
|
50
|
-
process.exitCode = 1;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
async function exec(cli) {
|
|
54
|
-
// Non-exhaustive known requirements:
|
|
55
|
-
// - 14.15 is the first LTS release
|
|
56
|
-
var _a, _b, _c, _d, _e;
|
|
57
|
-
const version = process.versions.node;
|
|
58
|
-
const range = `>=14.15.0`;
|
|
59
|
-
// YARN_IGNORE_NODE is special because this code needs to execute as early as possible.
|
|
60
|
-
// It's not a regular core setting because Configuration.find may use functions not available
|
|
61
|
-
// on older Node versions.
|
|
62
|
-
const ignoreNode = core_1.miscUtils.parseOptionalBoolean(process.env.YARN_IGNORE_NODE);
|
|
63
|
-
if (!ignoreNode && !core_1.semverUtils.satisfiesWithPrereleases(version, range))
|
|
64
|
-
throw 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.`);
|
|
65
|
-
// Since we only care about a few very specific settings (yarn-path and ignore-path) we tolerate extra configuration key.
|
|
66
|
-
// If we didn't, we wouldn't even be able to run `yarn config` (which is recommended in the invalid config error message)
|
|
67
|
-
const configuration = await core_1.Configuration.find(fslib_1.npath.toPortablePath(process.cwd()), pluginConfiguration, {
|
|
68
|
-
usePath: true,
|
|
69
|
-
strict: false,
|
|
70
|
-
});
|
|
71
|
-
const yarnPath = configuration.get(`yarnPath`);
|
|
72
|
-
const ignorePath = configuration.get(`ignorePath`);
|
|
73
|
-
const ignoreCwd = configuration.get(`ignoreCwd`);
|
|
74
|
-
const selfPath = fslib_1.npath.toPortablePath(fslib_1.npath.resolve(process.argv[1]));
|
|
75
|
-
const tryRead = (p) => fslib_1.xfs.readFilePromise(p).catch(() => {
|
|
76
|
-
return Buffer.of();
|
|
77
|
-
});
|
|
78
|
-
const isSameBinary = async () => yarnPath && (yarnPath === selfPath ||
|
|
79
|
-
Buffer.compare(...await Promise.all([
|
|
80
|
-
tryRead(yarnPath),
|
|
81
|
-
tryRead(selfPath),
|
|
82
|
-
])) === 0);
|
|
83
|
-
// Avoid unnecessary spawn when run directly
|
|
84
|
-
if (!ignorePath && !ignoreCwd && await isSameBinary()) {
|
|
85
|
-
process.env.YARN_IGNORE_PATH = `1`;
|
|
86
|
-
process.env.YARN_IGNORE_CWD = `1`;
|
|
87
|
-
await exec(cli);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
else if (yarnPath !== null && !ignorePath) {
|
|
91
|
-
if (!fslib_1.xfs.existsSync(yarnPath)) {
|
|
92
|
-
process.stdout.write(cli.error(new Error(`The "yarn-path" option has been set (in ${configuration.sources.get(`yarnPath`)}), but the specified location doesn't exist (${yarnPath}).`)));
|
|
93
|
-
process.exitCode = 1;
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
try {
|
|
97
|
-
runBinary(yarnPath);
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
process.exitCode = error.code || 1;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
if (ignorePath)
|
|
106
|
-
delete process.env.YARN_IGNORE_PATH;
|
|
107
|
-
const isTelemetryEnabled = configuration.get(`enableTelemetry`);
|
|
108
|
-
if (isTelemetryEnabled && !ci_info_1.isCI && process.stdout.isTTY)
|
|
109
|
-
core_1.Configuration.telemetry = new core_1.TelemetryManager(configuration, `puba9cdc10ec5790a2cf4969dd413a47270`);
|
|
110
|
-
(_a = core_1.Configuration.telemetry) === null || _a === void 0 ? void 0 : _a.reportVersion(binaryVersion);
|
|
111
|
-
for (const [name, plugin] of configuration.plugins.entries()) {
|
|
112
|
-
if (pluginCommands_1.pluginCommands.has((_c = (_b = name.match(/^@yarnpkg\/plugin-(.*)$/)) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : ``))
|
|
113
|
-
(_d = core_1.Configuration.telemetry) === null || _d === void 0 ? void 0 : _d.reportPluginName(name);
|
|
114
|
-
for (const command of plugin.commands || []) {
|
|
115
|
-
cli.register(command);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
const context = {
|
|
119
|
-
cwd: fslib_1.npath.toPortablePath(process.cwd()),
|
|
120
|
-
plugins: pluginConfiguration,
|
|
121
|
-
quiet: false,
|
|
122
|
-
stdin: process.stdin,
|
|
123
|
-
stdout: process.stdout,
|
|
124
|
-
stderr: process.stderr,
|
|
125
|
-
};
|
|
126
|
-
const command = cli.process(process.argv.slice(2), context);
|
|
127
|
-
if (!command.help)
|
|
128
|
-
(_e = core_1.Configuration.telemetry) === null || _e === void 0 ? void 0 : _e.reportCommandName(command.path.join(` `));
|
|
129
|
-
// @ts-expect-error: The cwd is a global option defined by BaseCommand
|
|
130
|
-
const cwd = command.cwd;
|
|
131
|
-
if (typeof cwd !== `undefined` && !ignoreCwd) {
|
|
132
|
-
const iAmHere = (0, fs_1.realpathSync)(process.cwd());
|
|
133
|
-
const iShouldBeHere = (0, fs_1.realpathSync)(cwd);
|
|
134
|
-
if (iAmHere !== iShouldBeHere) {
|
|
135
|
-
process.chdir(cwd);
|
|
136
|
-
await run();
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
await cli.runExit(command, context);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return run()
|
|
144
|
-
.catch(error => {
|
|
145
|
-
process.stdout.write(error.stack || error.message);
|
|
146
|
-
process.exitCode = 1;
|
|
147
|
-
})
|
|
148
|
-
.finally(() => fslib_1.xfs.rmtempPromise());
|
|
149
|
-
}
|
|
150
|
-
exports.main = main;
|