Skip to content

Commit 9bfded8

Browse files
committed
fix: remove npm references
1 parent 3958d26 commit 9bfded8

File tree

13 files changed

+49
-177
lines changed

13 files changed

+49
-177
lines changed

.github/workflows/sync.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@ jobs:
2222
run: |
2323
LATEST_BERRY_VERSION=$(curl https://repo.yarnpkg.com/tags | jq -r '.latest.stable')
2424
25-
LATEST_NPM=$(curl https://registry.npmjs.org/npm | jq '.["dist-tags"].latest + "+sha1." + .versions[.["dist-tags"].latest].dist.shasum')
2625
LATEST_PNPM=$(curl https://registry.npmjs.org/pnpm | jq '.["dist-tags"].latest + "+sha1." + .versions[.["dist-tags"].latest].dist.shasum')
2726
LATEST_YARN=$(curl https://registry.npmjs.org/yarn | jq '.["dist-tags"].latest + "+sha1." + .versions[.["dist-tags"].latest].dist.shasum')
2827
LATEST_BERRY=$(jq -n '$version + "+sha224." + $checksum' --arg version "$LATEST_BERRY_VERSION" --arg checksum "$(curl https://repo.yarnpkg.com/"$LATEST_BERRY_VERSION"/packages/yarnpkg-cli/bin/yarn.js | openssl dgst -sha224 | cut -d' ' -f2)")
2928
3029
git --no-pager show HEAD:config.json | jq '. * '"{
3130
definitions: {
32-
npm: {
33-
default: $LATEST_NPM,
34-
},
3531
pnpm: {
3632
default: $LATEST_PNPM,
3733
},

README.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
Corepack is a zero-runtime-dependency Node.js script that acts as a bridge
44
between Node.js projects and the package managers they are intended to be used
5-
with during development. In practical terms, **Corepack lets you use Yarn, npm,
6-
and pnpm without having to install them**.
5+
with during development. In practical terms, **Corepack lets you use Yarn and pnpm
6+
without having to install them**.
77

88
## How to Install
99

@@ -50,8 +50,8 @@ See [`CONTRIBUTING.md`](./CONTRIBUTING.md).
5050
### When Building Packages
5151

5252
Just use your package managers as you usually would. Run `yarn install` in Yarn
53-
projects, `pnpm install` in pnpm projects, and `npm` in npm projects. Corepack
54-
will catch these calls, and depending on the situation:
53+
projects and `pnpm install` in pnpm projects. Corepack will catch these calls,
54+
and depending on the situation:
5555

5656
- **If the local project is configured for the package manager you're using**,
5757
Corepack will silently download and cache the latest compatible version.
@@ -79,7 +79,7 @@ Here, `yarn` is the name of the package manager, specified at version `3.2.3`,
7979
along with the SHA-224 hash of this version for validation.
8080
`[email protected]` is required. The hash is optional but strongly
8181
recommended as a security practice. Permitted values for the package manager are
82-
`yarn`, `npm`, and `pnpm`.
82+
`yarn` and `pnpm`.
8383

8484
You can also provide a URL to a `.js` file (which will be interpreted as a
8585
CommonJS module) or a `.tgz` file (which will be interpreted as a package, and
@@ -148,9 +148,7 @@ Clears the local `COREPACK_HOME` cache directory.
148148

149149
This command will detect where Corepack is installed and will create shims next
150150
to it for each of the specified package managers (or all of them if the command
151-
is called without parameters). Note that the npm shims will not be installed
152-
unless explicitly requested, as npm is currently distributed with Node.js
153-
through other means.
151+
is called without parameters).
154152

155153
If the file system where the `corepack` binary is located is read-only, this
156154
command will fail. A workaround is to add the binaries as alias in your
@@ -161,8 +159,6 @@ alias yarn="corepack yarn"
161159
alias yarnpkg="corepack yarnpkg"
162160
alias pnpm="corepack pnpm"
163161
alias pnpx="corepack pnpx"
164-
alias npm="corepack npm"
165-
alias npx="corepack npx"
166162
```
167163

168164
On Windows PowerShell, you can add functions using the `$PROFILE` automatic
@@ -173,8 +169,6 @@ echo "function yarn { corepack yarn `$args }" >> $PROFILE
173169
echo "function yarnpkg { corepack yarnpkg `$args }" >> $PROFILE
174170
echo "function pnpm { corepack pnpm `$args }" >> $PROFILE
175171
echo "function pnpx { corepack pnpx `$args }" >> $PROFILE
176-
echo "function npm { corepack npm `$args }" >> $PROFILE
177-
echo "function npx { corepack npx `$args }" >> $PROFILE
178172
```
179173

180174
### `corepack disable [... name]`
@@ -250,7 +244,7 @@ same major line. Should you need to upgrade to a new major, use an explicit
250244
ask for user input before starting the download.
251245

252246
- `COREPACK_ENABLE_UNSAFE_CUSTOM_URLS` can be set to `1` to allow use of
253-
custom URLs to load a package manager known by Corepack (`yarn`, `npm`, and
247+
custom URLs to load a package manager known by Corepack (`yarn` and
254248
`pnpm`).
255249

256250
- `COREPACK_ENABLE_NETWORK` can be set to `0` to prevent Corepack from accessing

config.json

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,5 @@
11
{
22
"definitions": {
3-
"npm": {
4-
"default": "10.4.0+sha1.904025b4d932cfaed8799e644a1c5ae7f02729fc",
5-
"fetchLatestFrom": {
6-
"type": "npm",
7-
"package": "npm"
8-
},
9-
"transparent": {
10-
"commands": [
11-
[
12-
"npm",
13-
"init"
14-
],
15-
[
16-
"npx"
17-
]
18-
]
19-
},
20-
"ranges": {
21-
"*": {
22-
"url": "https://registry.npmjs.org/npm/-/npm-{}.tgz",
23-
"bin": {
24-
"npm": "./bin/npm-cli.js",
25-
"npx": "./bin/npx-cli.js"
26-
},
27-
"registry": {
28-
"type": "npm",
29-
"package": "npm"
30-
},
31-
"commands": {
32-
"use": [
33-
"npm",
34-
"install"
35-
]
36-
}
37-
}
38-
}
39-
},
403
"pnpm": {
414
"default": "8.15.3+sha1.64838798f519c18029c1e8a1310e16101fc2eda0",
425
"fetchLatestFrom": {

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@
8383
"./dist/yarn.js",
8484
"./dist/yarnpkg.js",
8585
"./dist/corepack.js",
86-
"./shims/npm",
87-
"./shims/npm.ps1",
88-
"./shims/npx",
89-
"./shims/npx.ps1",
9086
"./shims/pnpm",
9187
"./shims/pnpm.ps1",
9288
"./shims/pnpx",

sources/commands/Base.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import {Command, UsageError} from 'clipanion';
2-
import fs from 'fs';
32

43
import {PreparedPackageManagerInfo} from '../Engine';
54
import * as corepackUtils from '../corepackUtils';
65
import {Context} from '../main';
7-
import * as nodeUtils from '../nodeUtils';
86
import * as specUtils from '../specUtils';
97

108
export abstract class BaseCommand extends Command<Context> {

sources/commands/Disable.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {Command, Option, UsageError} from 'clipanion';
2-
import fs from 'fs';
3-
import path from 'path';
4-
import which from 'which';
1+
import {Command, Option, UsageError} from 'clipanion';
2+
import fs from 'fs';
3+
import path from 'path';
4+
import which from 'which';
55

6-
import {Context} from '../main';
7-
import type {NodeError} from '../nodeUtils';
8-
import {isSupportedPackageManager, SupportedPackageManagerSetWithoutNpm} from '../types';
6+
import {Context} from '../main';
7+
import type {NodeError} from '../nodeUtils';
8+
import {SupportedPackageManagerSet, isSupportedPackageManager} from '../types';
99

1010
export class DisableCommand extends Command<Context> {
1111
static paths = [
@@ -47,7 +47,7 @@ export class DisableCommand extends Command<Context> {
4747
installDirectory = path.dirname(await which(`corepack`));
4848

4949
const names = this.names.length === 0
50-
? SupportedPackageManagerSetWithoutNpm
50+
? SupportedPackageManagerSet
5151
: this.names;
5252

5353
for (const name of new Set(names)) {

sources/commands/Enable.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import cmdShim from '@zkochan/cmd-shim';
2-
import {Command, Option, UsageError} from 'clipanion';
3-
import fs from 'fs';
4-
import path from 'path';
5-
import which from 'which';
1+
import cmdShim from '@zkochan/cmd-shim';
2+
import {Command, Option, UsageError} from 'clipanion';
3+
import fs from 'fs';
4+
import path from 'path';
5+
import which from 'which';
66

7-
import {Context} from '../main';
8-
import {isSupportedPackageManager, SupportedPackageManagerSetWithoutNpm} from '../types';
7+
import {Context} from '../main';
8+
import {isSupportedPackageManager, SupportedPackageManagerSet} from '../types';
99

1010
export class EnableCommand extends Command<Context> {
1111
static paths = [
@@ -57,7 +57,7 @@ export class EnableCommand extends Command<Context> {
5757
throw new Error(`Assertion failed: The stub folder doesn't exist`);
5858

5959
const names = this.names.length === 0
60-
? SupportedPackageManagerSetWithoutNpm
60+
? SupportedPackageManagerSet
6161
: this.names;
6262

6363
for (const name of new Set(names)) {

sources/corepackUtils.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,6 @@ export async function runVersion(locator: Locator, installSpec: InstallSpec & {s
350350
if (!binPath)
351351
throw new Error(`Assertion failed: Unable to locate path for bin '${binName}'`);
352352

353-
// Node.js segfaults when using npm@>=9.7.0 and v8-compile-cache
354-
// $ docker run -it node:20.3.0-slim corepack [email protected] --version
355-
// [SIGSEGV]
356-
if (locator.name !== `npm` || semver.lt(locator.reference, `9.7.0`))
357-
// @ts-expect-error - No types
358-
await import(`v8-compile-cache`);
359-
360353
// We load the binary into the current process,
361354
// while making it think it was spawned.
362355

sources/types.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export type BinSpec = {[key: string]: string};
22
export type BinList = Array<string>;
33

44
export enum SupportedPackageManagers {
5-
Npm = `npm`,
65
Pnpm = `pnpm`,
76
Yarn = `yarn`,
87
}
@@ -11,13 +10,6 @@ export const SupportedPackageManagerSet = new Set<SupportedPackageManagers>(
1110
Object.values(SupportedPackageManagers),
1211
);
1312

14-
export const SupportedPackageManagerSetWithoutNpm = new Set<SupportedPackageManagers>(
15-
Object.values(SupportedPackageManagers),
16-
);
17-
18-
// npm is distributed with Node as a builtin; we don't want Corepack to override it unless the npm team is on board
19-
SupportedPackageManagerSetWithoutNpm.delete(SupportedPackageManagers.Npm);
20-
2113
export function isSupportedPackageManager(value: string): value is SupportedPackageManagers {
2214
return SupportedPackageManagerSet.has(value as SupportedPackageManagers);
2315
}

tests/Disable.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import {describe, beforeEach, it, expect} from '@jest/globals';
2-
import {Filename, ppath, xfs, npath} from '@yarnpkg/fslib';
3-
import {delimiter} from 'node:path';
4-
import process from 'node:process';
1+
import {describe, beforeEach, it, expect} from '@jest/globals';
2+
import {Filename, ppath, xfs, npath} from '@yarnpkg/fslib';
3+
import {delimiter} from 'node:path';
4+
import process from 'node:process';
55

6-
import {Engine} from '../sources/Engine';
7-
import {SupportedPackageManagerSetWithoutNpm} from '../sources/types';
6+
import {Engine} from '../sources/Engine';
7+
import {SupportedPackageManagerSet} from '../sources/types';
88

9-
import {makeBin, getBinaryNames} from './_binHelpers';
10-
import {runCli} from './_runCli';
9+
import {makeBin, getBinaryNames} from './_binHelpers';
10+
import {runCli} from './_runCli';
1111

1212
const engine = new Engine();
1313

@@ -22,7 +22,7 @@ describe(`DisableCommand`, () => {
2222
const corepackBin = await makeBin(cwd, `corepack` as Filename);
2323
const dontRemoveBin = await makeBin(cwd, `dont-remove` as Filename);
2424

25-
for (const packageManager of SupportedPackageManagerSetWithoutNpm)
25+
for (const packageManager of SupportedPackageManagerSet)
2626
for (const binName of engine.getBinariesFor(packageManager))
2727
for (const variant of getBinaryNames(binName))
2828
await makeBin(cwd, variant as Filename, {ignorePlatform: true});
@@ -47,7 +47,7 @@ describe(`DisableCommand`, () => {
4747
await xfs.mktempPromise(async cwd => {
4848
const dontRemoveBin = await makeBin(cwd, `dont-remove` as Filename);
4949

50-
for (const packageManager of SupportedPackageManagerSetWithoutNpm)
50+
for (const packageManager of SupportedPackageManagerSet)
5151
for (const binName of engine.getBinariesFor(packageManager))
5252
for (const variant of getBinaryNames(binName))
5353
await makeBin(cwd, variant as Filename, {ignorePlatform: true});
@@ -66,7 +66,7 @@ describe(`DisableCommand`, () => {
6666
await xfs.mktempPromise(async cwd => {
6767
const binNames = new Set<string>();
6868

69-
for (const packageManager of SupportedPackageManagerSetWithoutNpm)
69+
for (const packageManager of SupportedPackageManagerSet)
7070
for (const binName of engine.getBinariesFor(packageManager))
7171
for (const variant of getBinaryNames(binName))
7272
binNames.add(variant);

0 commit comments

Comments
 (0)