Skip to content

Commit d9c70b9

Browse files
authored
feat!: remove --all flag (#351)
Force users to opt-in into the package managers they want to support. As more and more package managers are added to Corepack, it's more and more unlikely that our users will be interested in _all_ the package managers Corepack supports, and it is unreasonable to expect Corepack maintainers would be able to perform security audits.
1 parent 9066ea7 commit d9c70b9

File tree

10 files changed

+15
-92
lines changed

10 files changed

+15
-92
lines changed

README.md

+2-10
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ The utility commands detailed in the next section.
102102
case you'll simply run `corepack pack` to make sure that your image
103103
includes the Last Known Good release for the specified package manager.
104104

105-
- If you want to have _all_ Last Known Good releases for all package managers,
106-
just use the `--all` flag which will do just that.
107-
108105
- Or you're publishing your project to a system where the network is
109106
unavailable, in which case you'll preemptively generate a package manager
110107
archive from your local computer (using `corepack pack -o`) before storing
@@ -185,23 +182,18 @@ This command doesn't change the global version used when running the package
185182
manager from outside the project (use the \`-g,--global\` flag if you wish
186183
to do this).
187184

188-
### `corepack install <-g,--global> [--all] [... name[@<version>]]`
189-
190-
| Option | Description |
191-
| --------------------- | ------------------------------------------ |
192-
| `--all` | Install all Last Known Good releases |
185+
### `corepack install <-g,--global> [... name[@<version>]]`
193186

194187
Install the selected package managers and install them on the system.
195188

196189
Package managers thus installed will be configured as the new default when
197190
calling their respective binaries outside of projects defining the
198191
`packageManager` field.
199192

200-
### `corepack pack [--all] [... name[@<version>]]`
193+
### `corepack pack [... name[@<version>]]`
201194

202195
| Option | Description |
203196
| --------------------- | ------------------------------------------ |
204-
| `--all` | Pack all Last Known Good releases |
205197
| `--json ` | Print the output folder rather than logs |
206198
| `-o,--output ` | Path where to generate the archive |
207199

sources/commands/Base.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ import * as nodeUtils from '../nodeUtils';
88
import * as specUtils from '../specUtils';
99

1010
export abstract class BaseCommand extends Command<Context> {
11-
async resolvePatternsToDescriptors({all, patterns}: {all: boolean, patterns: Array<string>}) {
12-
if (all && patterns.length > 0)
13-
throw new UsageError(`The --all option cannot be used along with an explicit package manager specification`);
14-
15-
const resolvedSpecs = all
16-
? await this.context.engine.getDefaultDescriptors()
17-
: patterns.map(pattern => specUtils.parseSpec(pattern, `CLI arguments`, {enforceExactVersion: false}));
11+
async resolvePatternsToDescriptors({patterns}: {patterns: Array<string>}) {
12+
const resolvedSpecs = patterns.map(pattern => specUtils.parseSpec(pattern, `CLI arguments`, {enforceExactVersion: false}));
1813

1914
if (resolvedSpecs.length === 0) {
2015
const lookup = await specUtils.loadSpec(this.context.cwd);

sources/commands/InstallGlobal.ts

+10-20
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,30 @@ export class InstallGlobalCommand extends BaseCommand {
2424
`Install the latest version of Yarn 1.x and make it globally available`,
2525
`corepack install -g yarn@^1`,
2626
], [
27-
`Install the latest version of all available package managers, and make them globally available`,
28-
`corepack install -g --all`,
27+
`Install the latest version of pnpm, and make it globally available`,
28+
`corepack install -g pnpm`,
2929
]],
3030
});
3131

3232
global = Option.Boolean(`-g,--global`, {
3333
required: true,
3434
});
3535

36-
all = Option.Boolean(`--all`, false, {
37-
description: `If true, all available default package managers will be installed`,
38-
});
39-
4036
cacheOnly = Option.Boolean(`--cache-only`, false, {
4137
description: `If true, the package managers will only be cached, not set as new defaults`,
4238
});
4339

4440
args = Option.Rest();
4541

4642
async execute() {
47-
if (this.args.length === 0 && !this.all)
48-
throw new UsageError(`No package managers specified; use --all to install all available package managers, or specify one or more package managers to proceed`);
49-
50-
if (!this.all) {
51-
for (const arg of this.args) {
52-
if (arg.endsWith(`.tgz`)) {
53-
await this.installFromTarball(path.resolve(this.context.cwd, arg));
54-
} else {
55-
await this.installFromDescriptor(specUtils.parseSpec(arg, `CLI arguments`, {enforceExactVersion: false}));
56-
}
57-
}
58-
} else {
59-
for (const descriptor of await this.context.engine.getDefaultDescriptors()) {
60-
await this.installFromDescriptor(descriptor);
43+
if (this.args.length === 0)
44+
throw new UsageError(`No package managers specified`);
45+
46+
for (const arg of this.args) {
47+
if (arg.endsWith(`.tgz`)) {
48+
await this.installFromTarball(path.resolve(this.context.cwd, arg));
49+
} else {
50+
await this.installFromDescriptor(specUtils.parseSpec(arg, `CLI arguments`, {enforceExactVersion: false}));
6151
}
6252
}
6353
}

sources/commands/InstallLocal.ts

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export class InstallLocalCommand extends BaseCommand {
2020

2121
async execute() {
2222
const [descriptor] = await this.resolvePatternsToDescriptors({
23-
all: false,
2423
patterns: [],
2524
});
2625

sources/commands/Pack.ts

-8
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,9 @@ export class PackCommand extends BaseCommand {
2222
], [
2323
`Pack the latest version of Yarn 1.x inside a file named corepack.tgz`,
2424
`corepack pack yarn@^1`,
25-
], [
26-
`Pack the latest versions of all supported package managers inside a file named everything.tgz`,
27-
`corepack pack --all -o everything.tgz`,
2825
]],
2926
});
3027

31-
all = Option.Boolean(`--all`, false, {
32-
description: `If true, all available default package managers will be installed`,
33-
});
34-
3528
json = Option.Boolean(`--json`, false, {
3629
description: `If true, the path to the generated tarball will be printed on stdout`,
3730
});
@@ -44,7 +37,6 @@ export class PackCommand extends BaseCommand {
4437

4538
async execute() {
4639
const descriptors = await this.resolvePatternsToDescriptors({
47-
all: this.all,
4840
patterns: this.patterns,
4941
});
5042

sources/commands/Up.ts

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export class UpCommand extends BaseCommand {
2828

2929
async execute() {
3030
const [descriptor] = await this.resolvePatternsToDescriptors({
31-
all: false,
3231
patterns: [],
3332
});
3433

sources/commands/Use.ts

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export class UseCommand extends BaseCommand {
2424

2525
async execute() {
2626
const [descriptor] = await this.resolvePatternsToDescriptors({
27-
all: false,
2827
patterns: [this.pattern],
2928
});
3029

sources/commands/deprecated/Prepare.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ export class PrepareCommand extends Command<Context> {
1616
description: `If true, this release will become the default one for this package manager`,
1717
});
1818

19-
all = Option.Boolean(`--all`, false, {
20-
description: `If true, all available default package managers will be installed`,
21-
});
22-
2319
json = Option.Boolean(`--json`, false, {
2420
description: `If true, the output will be the path of the generated tarball`,
2521
});
@@ -32,12 +28,7 @@ export class PrepareCommand extends Command<Context> {
3228
specs = Option.Rest();
3329

3430
async execute() {
35-
if (this.all && this.specs.length > 0)
36-
throw new UsageError(`The --all option cannot be used along with an explicit package manager specification`);
37-
38-
const specs: Array<string | Descriptor> = this.all
39-
? await this.context.engine.getDefaultDescriptors()
40-
: this.specs;
31+
const specs: Array<string | Descriptor> = this.specs;
4132

4233
const installLocations: Array<string> = [];
4334

tests/main.test.ts

-33
Original file line numberDiff line numberDiff line change
@@ -403,39 +403,6 @@ it(`should always use fallback version when project spec env is disabled`, async
403403
});
404404
});
405405

406-
it(`should allow to call "corepack install -g --all" to prepare all package managers`, async () => {
407-
await xfs.mktempPromise(async cwd => {
408-
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), {
409-
// empty package.json file
410-
});
411-
412-
await expect(runCli(cwd, [`install`, `-g`, `--all`])).resolves.toMatchObject({
413-
exitCode: 0,
414-
stderr: ``,
415-
});
416-
417-
process.env.COREPACK_ENABLE_NETWORK = `0`;
418-
419-
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
420-
stdout: `${config.definitions.yarn.default.split(`+`, 1)[0]}\n`,
421-
stderr: ``,
422-
exitCode: 0,
423-
});
424-
425-
await expect(runCli(cwd, [`pnpm`, `--version`])).resolves.toMatchObject({
426-
stdout: `${config.definitions.pnpm.default.split(`+`, 1)[0]}\n`,
427-
stderr: ``,
428-
exitCode: 0,
429-
});
430-
431-
await expect(runCli(cwd, [`npm`, `--version`])).resolves.toMatchObject({
432-
stdout: `${config.definitions.npm.default.split(`+`, 1)[0]}\n`,
433-
stderr: ``,
434-
exitCode: 0,
435-
});
436-
});
437-
});
438-
439406
it(`should support disabling the network accesses from the environment`, async () => {
440407
process.env.COREPACK_ENABLE_NETWORK = `0`;
441408

tests/nock/VurwVdvlR5Rs7xQVs9UCVw-1.dat

-1
This file was deleted.

0 commit comments

Comments
 (0)