Skip to content

Commit e181b90

Browse files
authored
Merge branch 'main' into use-token-for-download
2 parents fc92a59 + 1ba315d commit e181b90

File tree

16 files changed

+1130
-839
lines changed

16 files changed

+1130
-839
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1919

20-
- uses: actions/setup-node@v4
20+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
2121
with:
2222
node-version: lts/*
23+
env:
24+
SKIP_YARN_COREPACK_CHECK: 1
2325

2426
- name: Get the Yarn cache directory path
2527
id: yarn-cache-dir-path
26-
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
27-
shell: bash
28+
run: echo "dir=$(corepack yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
2829

29-
- uses: actions/cache@v4
30+
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
3031
with:
3132
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
3233
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
@@ -65,19 +66,21 @@ jobs:
6566
runs-on: ${{matrix.platform}}
6667

6768
steps:
68-
- uses: actions/checkout@v4
69+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
6970

7071
- name: "Use Node.js ${{matrix.node}}.x"
71-
uses: actions/setup-node@v4
72+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
7273
with:
7374
node-version: ${{matrix.node}}.x
75+
env:
76+
SKIP_YARN_COREPACK_CHECK: 1
7477

7578
- name: Get the Yarn cache directory path
7679
id: yarn-cache-dir-path
77-
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
78-
shell: bash
80+
run: echo "dir=$(corepack yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
81+
shell: bash # Needs explicit bash for Windows-support
7982

80-
- uses: actions/cache@v4
83+
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
8184
with:
8285
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
8386
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}

.github/workflows/publish.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
release_created: ${{ steps.release.outputs.release_created }}
2121
release_tag: ${{ steps.release.outputs.tag_name }}
2222
steps:
23-
- uses: googleapis/release-please-action@v3
23+
- uses: googleapis/release-please-action@db8f2c60ee802b3748b512940dde88eabd7b7e01 # v3.7.13
2424
id: release
2525
with:
2626
release-type: node
@@ -35,18 +35,19 @@ jobs:
3535
contents: write
3636
id-token: write
3737
steps:
38-
- uses: actions/checkout@v4
38+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3939

40-
- uses: actions/setup-node@v4
40+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
4141
with:
4242
node-version: lts/*
43+
env:
44+
SKIP_YARN_COREPACK_CHECK: 1
4345

4446
- name: Get the Yarn cache directory path
4547
id: yarn-cache-dir-path
46-
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
47-
shell: bash
48+
run: echo "dir=$(corepack yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
4849

49-
- uses: actions/cache@v4
50+
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
5051
with:
5152
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
5253
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
@@ -57,8 +58,6 @@ jobs:
5758

5859
- name: Publish to the npm registry
5960
run: corepack yarn npm publish --provenance
60-
env:
61-
YARN_NPM_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
6261

6362
- run: corepack yarn pack --out corepack.tgz
6463
- name: Add Corepack package archive to GitHub release

.github/workflows/sync.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1818

1919
- name: Install Node
20-
uses: actions/setup-node@v4
20+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
2121
with:
2222
node-version: lts/*
23+
env:
24+
SKIP_YARN_COREPACK_CHECK: 1
2325

2426
- name: "Update the package manager versions"
2527
run: |

.github/workflows/update-nock-files.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,22 @@ jobs:
4343
ACTUAL: ${{ fromJson(steps.pr_info.outputs.DATA).head_sha }}
4444
EXPECTED: ${{ inputs.head_sha }}
4545

46-
- uses: actions/checkout@v4
46+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4747
with:
4848
ref: ${{ fromJson(steps.pr_info.outputs.DATA).head_sha }}
4949

5050
- name: Install Node
51-
uses: actions/setup-node@v4
51+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
5252
with:
5353
node-version: lts/*
54+
env:
55+
SKIP_YARN_COREPACK_CHECK: 1
5456

5557
- name: Get the Yarn cache directory path
5658
id: yarn-cache-dir-path
57-
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
58-
shell: bash
59+
run: echo "dir=$(corepack yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
5960

60-
- uses: actions/cache@v4
61+
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
6162
with:
6263
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
6364
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
@@ -101,7 +102,7 @@ jobs:
101102
REMOTE_REF: ${{ fromJson(steps.pr_info.outputs.DATA).head_ref }}
102103

103104
- name: Upload `tests/nocks.db` in case of failure
104-
uses: actions/upload-artifact@v4
105+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
105106
if: ${{ failure() && steps.contains-changes.outputs.result == 'yes' }}
106107
with:
107108
name: nock

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
11
# Changelog
22

3+
## [0.34.5](https://github.com/nodejs/corepack/compare/v0.34.4...v0.34.5) (2025-11-24)
4+
5+
6+
### Bug Fixes
7+
8+
* **pnpm:** fix bin path for v11 ([#776](https://github.com/nodejs/corepack/issues/776)) ([0c8048a](https://github.com/nodejs/corepack/commit/0c8048adc61651f6eb798448675d3ecc4a7e26a9))
9+
* update package manager versions ([#773](https://github.com/nodejs/corepack/issues/773)) ([06c286b](https://github.com/nodejs/corepack/commit/06c286b5fc171e43090b5eed5cd501bc9580927f))
10+
11+
## [0.34.4](https://github.com/nodejs/corepack/compare/v0.34.3...v0.34.4) (2025-11-14)
12+
13+
14+
### Bug Fixes
15+
16+
* bump pnpm version in `config.json` ([#768](https://github.com/nodejs/corepack/issues/768)) ([99a9a6e](https://github.com/nodejs/corepack/commit/99a9a6eb1b6e918ceb896b3d558bb5ed583bdc70))
17+
* ignore devEngines version range when CLI provides a version ([#762](https://github.com/nodejs/corepack/issues/762)) ([ac518c4](https://github.com/nodejs/corepack/commit/ac518c4106f8d9ceb4e85e6c3614b1eba5d03fcb))
18+
* use `lstatSync` in `generatePosixLink` ([#767](https://github.com/nodejs/corepack/issues/767)) ([a02bea0](https://github.com/nodejs/corepack/commit/a02bea078eb584ed7492ec561626987e35386bae))
19+
20+
## [0.34.3](https://github.com/nodejs/corepack/compare/v0.34.2...v0.34.3) (2025-11-07)
21+
22+
23+
### Bug Fixes
24+
25+
* update package manager versions ([#765](https://github.com/nodejs/corepack/issues/765)) ([13a2e98](https://github.com/nodejs/corepack/commit/13a2e989ee37694a7ec1b1d60acdaa28f90642d1))
26+
* Yarn switch install support and tests ([#761](https://github.com/nodejs/corepack/issues/761)) ([d04d483](https://github.com/nodejs/corepack/commit/d04d4839aeecaf4fca989c577f6c000dc90be933))
27+
28+
## [0.34.2](https://github.com/nodejs/corepack/compare/v0.34.1...v0.34.2) (2025-10-31)
29+
30+
31+
### Bug Fixes
32+
33+
* bump package manager versions ([#754](https://github.com/nodejs/corepack/issues/754)) ([35e3869](https://github.com/nodejs/corepack/commit/35e3869f3f4d21bbfccdf78ea564ab0723d6f36f))
34+
* fix potential race condition in `node-tar` ([#757](https://github.com/nodejs/corepack/pull/757)) ([78808a7](78808a72691655fe5140c02ae41d4baef88cd9fa))
35+
36+
## [0.34.1](https://github.com/nodejs/corepack/compare/v0.34.0...v0.34.1) (2025-10-17)
37+
38+
39+
### Bug Fixes
40+
41+
* incorrect registry origin check ([#743](https://github.com/nodejs/corepack/issues/743)) ([cc840b2](https://github.com/nodejs/corepack/commit/cc840b2d232a29c225d2436d350640f0035ed28b))
42+
* update package manager versions ([#728](https://github.com/nodejs/corepack/issues/728)) ([78ce029](https://github.com/nodejs/corepack/commit/78ce0297a9152bb5c68f724821a9a0095b408334))
43+
344
## [0.34.0](https://github.com/nodejs/corepack/compare/v0.33.0...v0.34.0) (2025-07-19)
445

546

config.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"definitions": {
33
"npm": {
4-
"default": "11.4.2+sha1.6f1519a03f7e04023a957a22b812832d0c4a4b33",
4+
"default": "11.6.3+sha1.3f581bca37cbdadf2be04346c0e5b0be96cdd54b",
55
"fetchLatestFrom": {
66
"type": "npm",
77
"package": "npm"
@@ -38,7 +38,7 @@
3838
}
3939
},
4040
"pnpm": {
41-
"default": "10.13.1+sha1.aa8c167c4509c97519542ef77a09e4b8ab59fb6a",
41+
"default": "10.23.0+sha1.b4a44ab0dc2adf2e36371d11d8eb0dc78ffc976c",
4242
"fetchLatestFrom": {
4343
"type": "npm",
4444
"package": "pnpm"
@@ -76,7 +76,7 @@
7676
]
7777
}
7878
},
79-
">=6.0.0": {
79+
"6.x || 7.x || 8.x || 9.x || 10.x": {
8080
"url": "https://registry.npmjs.org/pnpm/-/pnpm-{}.tgz",
8181
"bin": {
8282
"pnpm": "./bin/pnpm.cjs",
@@ -92,6 +92,23 @@
9292
"install"
9393
]
9494
}
95+
},
96+
">=11.0.0": {
97+
"url": "https://registry.npmjs.org/pnpm/-/pnpm-{}.tgz",
98+
"bin": {
99+
"pnpm": "./bin/pnpm.mjs",
100+
"pnpx": "./bin/pnpx.mjs"
101+
},
102+
"registry": {
103+
"type": "npm",
104+
"package": "pnpm"
105+
},
106+
"commands": {
107+
"use": [
108+
"pnpm",
109+
"install"
110+
]
111+
}
95112
}
96113
}
97114
},
@@ -102,7 +119,7 @@
102119
"package": "yarn"
103120
},
104121
"transparent": {
105-
"default": "4.9.2+sha224.b8e0b161ae590950fbda696e6f3ca071362768e5280c5fbfdadf064b",
122+
"default": "4.11.0+sha224.209a3e277c6bbc03df6e4206fbfcb0c1621c27ecf0688f79a0c619f0",
106123
"commands": [
107124
[
108125
"yarn",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "corepack",
3-
"version": "0.34.0",
3+
"version": "0.34.5",
44
"homepage": "https://github.com/nodejs/corepack#readme",
55
"bugs": {
66
"url": "https://github.com/nodejs/corepack/issues"
@@ -16,7 +16,7 @@
1616
"./package.json": "./package.json"
1717
},
1818
"license": "MIT",
19-
"packageManager": "yarn@4.9.0+sha224.dce6c5df199861784bd9b0eecb2a228df97e3f18a02b1bb75ff98383",
19+
"packageManager": "yarn@4.11.0+sha224.209a3e277c6bbc03df6e4206fbfcb0c1621c27ecf0688f79a0c619f0",
2020
"devDependencies": {
2121
"@types/debug": "^4.1.5",
2222
"@types/node": "^20.4.6",

sources/Engine.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export class Engine {
244244
* project using the default package managers, and configure it so that we
245245
* don't need to ask again in the future.
246246
*/
247-
async findProjectSpec(initialCwd: string, locator: Locator | LazyLocator, {transparent = false}: {transparent?: boolean} = {}): Promise<Descriptor> {
247+
async findProjectSpec(initialCwd: string, locator: Locator | LazyLocator, {transparent = false, binaryVersion}: {transparent?: boolean, binaryVersion?: string | null} = {}): Promise<Descriptor> {
248248
// A locator is a valid descriptor (but not the other way around)
249249
const fallbackDescriptor = {name: locator.name, range: `${locator.reference}`};
250250

@@ -293,7 +293,7 @@ export class Engine {
293293
}
294294

295295
case `Found`: {
296-
const spec = result.getSpec();
296+
const spec = result.getSpec({enforceExactVersion: !binaryVersion});
297297
if (spec.name !== locator.name) {
298298
if (transparent) {
299299
if (typeof locator.reference === `function`)
@@ -344,7 +344,7 @@ export class Engine {
344344
};
345345
}
346346

347-
const descriptor = await this.findProjectSpec(cwd, fallbackLocator, {transparent: isTransparentCommand});
347+
const descriptor = await this.findProjectSpec(cwd, fallbackLocator, {transparent: isTransparentCommand, binaryVersion});
348348

349349
if (binaryVersion)
350350
descriptor.range = binaryVersion;

sources/commands/Enable.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,22 @@ export class EnableCommand extends Command<Context> {
8181
async generatePosixLink(installDirectory: string, distFolder: string, binName: string) {
8282
const file = path.join(installDirectory, binName);
8383
const symlink = path.relative(installDirectory, path.join(distFolder, `${binName}.js`));
84+
const stats = fs.lstatSync(file, {throwIfNoEntry: false});
8485

85-
if (fs.existsSync(file)) {
86-
const currentSymlink = await fs.promises.readlink(file);
86+
if (stats) {
87+
if (stats.isSymbolicLink()) {
88+
const currentSymlink = await fs.promises.readlink(file);
8789

88-
if (binName.includes(`yarn`) && corepackUtils.isYarnSwitchPath(await fs.promises.realpath(file))) {
89-
console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`);
90-
return;
91-
}
90+
if (binName.includes(`yarn`) && corepackUtils.isYarnSwitchPath(await fs.promises.realpath(file))) {
91+
console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`);
92+
return;
93+
}
9294

93-
if (currentSymlink !== symlink) {
94-
await fs.promises.unlink(file);
95-
} else {
96-
return;
95+
if (currentSymlink === symlink) {
96+
return;
97+
}
9798
}
99+
await fs.promises.unlink(file);
98100
}
99101

100102
await fs.promises.symlink(symlink, file);

sources/corepackUtils.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export async function findInstalledVersion(installTarget: string, descriptor: De
8484
try {
8585
cacheDirectory = await fs.promises.opendir(installFolder);
8686
} catch (error) {
87-
if ((error as nodeUtils.NodeError).code === `ENOENT`) {
87+
if (nodeUtils.isNodeError(error) && error.code === `ENOENT`) {
8888
return null;
8989
} else {
9090
throw error;
@@ -181,10 +181,15 @@ async function download(installTarget: string, url: string, algo: string, binPat
181181
try {
182182
await renameSafe(downloadedBin, outputFile);
183183
} catch (err) {
184-
if ((err as nodeUtils.NodeError)?.code === `ENOENT`)
184+
if (nodeUtils.isNodeError(err) && err.code === `ENOENT`)
185185
throw new Error(`Cannot locate '${binPath}' in downloaded tarball`, {cause: err});
186186

187-
throw err;
187+
// It's alright if another process downloaded the same binary in parallel
188+
if (nodeUtils.isNodeError(err) && nodeUtils.isExistError(err)) {
189+
await fs.promises.rm(downloadedBin);
190+
} else {
191+
throw err;
192+
}
188193
}
189194

190195
// Calculate the hash of the bin file
@@ -221,7 +226,7 @@ export async function installVersion(installTarget: string, locator: Locator, {s
221226
bin: corepackData.bin,
222227
};
223228
} catch (err) {
224-
if ((err as nodeUtils.NodeError)?.code !== `ENOENT`) {
229+
if (nodeUtils.isNodeError(err) && err.code !== `ENOENT`) {
225230
throw err;
226231
}
227232
}
@@ -316,9 +321,10 @@ export async function installVersion(installTarget: string, locator: Locator, {s
316321
await renameSafe(tmpFolder, installFolder);
317322
} catch (err) {
318323
if (
319-
(err as nodeUtils.NodeError).code === `ENOTEMPTY` ||
324+
nodeUtils.isNodeError(err) && (
325+
nodeUtils.isExistError(err) ||
320326
// On Windows the error code is EPERM so we check if it is a directory
321-
((err as nodeUtils.NodeError).code === `EPERM` && (await fs.promises.stat(installFolder)).isDirectory())
327+
(err.code === `EPERM` && (await fs.promises.stat(installFolder)).isDirectory()))
322328
) {
323329
debugUtils.log(`Another instance of corepack installed ${locator.name}@${locator.reference}`);
324330
await fs.promises.rm(tmpFolder, {recursive: true, force: true});
@@ -365,10 +371,7 @@ async function renameUnderWindows(oldPath: fs.PathLike, newPath: fs.PathLike) {
365371
break;
366372
} catch (err) {
367373
if (
368-
(
369-
(err as nodeUtils.NodeError).code === `ENOENT` ||
370-
(err as nodeUtils.NodeError).code === `EPERM`
371-
) &&
374+
nodeUtils.isNodeError(err) && (err.code === `ENOENT` || err.code === `EPERM`) &&
372375
i < (retries - 1)
373376
) {
374377
await setTimeoutPromise(100 * 2 ** i);

0 commit comments

Comments
 (0)