Skip to content

Commit 4672007

Browse files
authored
Merge branch 'main' into fix/registry-trailing-slash
2 parents b5f7946 + f0f4ee1 commit 4672007

43 files changed

Lines changed: 530 additions & 621 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
18+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
1919

20-
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
20+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
2121
with:
2222
node-version: lts/*
2323
env:
@@ -27,7 +27,7 @@ jobs:
2727
id: yarn-cache-dir-path
2828
run: echo "dir=$(corepack yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
2929

30-
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
30+
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
3131
with:
3232
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
3333
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
@@ -66,10 +66,10 @@ jobs:
6666
runs-on: ${{matrix.platform}}
6767

6868
steps:
69-
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
69+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
7070

7171
- name: "Use Node.js ${{matrix.node}}.x"
72-
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
72+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
7373
with:
7474
node-version: ${{matrix.node}}.x
7575
env:
@@ -80,7 +80,7 @@ jobs:
8080
run: echo "dir=$(corepack yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
8181
shell: bash # Needs explicit bash for Windows-support
8282

83-
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
83+
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
8484
with:
8585
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
8686
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}

‎.github/workflows/publish.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ jobs:
3535
contents: write
3636
id-token: write
3737
steps:
38-
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
38+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3939

40-
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
40+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
4141
with:
4242
node-version: lts/*
4343
env:
@@ -47,7 +47,7 @@ jobs:
4747
id: yarn-cache-dir-path
4848
run: echo "dir=$(corepack yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
4949

50-
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
50+
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
5151
with:
5252
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
5353
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}

‎.github/workflows/sync.yml‎

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

1616
steps:
17-
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
17+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
1818

1919
- name: Install Node
20-
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
20+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
2121
with:
2222
node-version: lts/*
2323
env:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
ACTUAL: ${{ fromJson(steps.pr_info.outputs.DATA).head_sha }}
5555
EXPECTED: ${{ inputs.head_sha }}
5656

57-
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
57+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
5858
with:
5959
ref: ${{ fromJson(steps.pr_info.outputs.DATA).head_sha }}
6060
fetch-depth: ${{ !inputs.merge_base && 1 || 0 }}
@@ -74,7 +74,7 @@ jobs:
7474
BASE_BRANCH: ${{ fromJson(steps.pr_info.outputs.DATA).base_ref }}
7575

7676
- name: Install Node
77-
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
77+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
7878
with:
7979
node-version: lts/*
8080
env:
@@ -84,7 +84,7 @@ jobs:
8484
id: yarn-cache-dir-path
8585
run: echo "dir=$(corepack yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
8686

87-
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
87+
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
8888
with:
8989
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
9090
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}

‎eslint.config.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default [
1717
name: `fetch`,
1818
message: `Use fetch from sources/httpUtils.ts`,
1919
}],
20+
'@typescript-eslint/consistent-type-imports': `error`,
2021
'@typescript-eslint/no-unused-vars': [`error`, {
2122
caughtErrors: `none`,
2223
}],

‎genlist.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {readFileSync} from 'fs';
2-
import semverCompare from 'semver/functions/compare';
2+
import semverCompare from 'semver/functions/compare.js';
33

44
const lines = readFileSync(0, `utf8`).split(/\n/).filter(line => line);
55

‎mkshims.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import cmdShim from '@zkochan/cmd-shim';
22
import fs from 'fs';
33
import path from 'path';
44

5-
import {Engine} from './sources/Engine';
6-
import {SupportedPackageManagerSet} from './sources/types';
5+
import {Engine} from './sources/Engine.ts';
6+
import {SupportedPackageManagerSet} from './sources/types.ts';
77

88
const engine = new Engine();
99

10-
const distDir = path.join(__dirname, `dist`);
11-
const shimsDir = path.join(__dirname, `shims`);
10+
const distDir = path.join(import.meta.dirname, `dist`);
11+
const shimsDir = path.join(import.meta.dirname, `shims`);
1212

1313
const physicalNodewinDir = path.join(shimsDir, `nodewin`);
1414
const virtualNodewinDir = path.join(physicalNodewinDir, `node_modules/corepack`);
@@ -59,7 +59,7 @@ async function main() {
5959

6060
// Last note: cmdShim generates shims with relative paths, so it doesn't matter
6161
// that the target files don't truly exist, as long as we mock the `stat` function.
62-
const remapPath = (p: string) => path.resolve(__dirname, path.relative(virtualNodewinDir, p));
62+
const remapPath = (p: string) => path.resolve(import.meta.dirname, path.relative(virtualNodewinDir, p));
6363

6464
const easyStatFs = Object.assign(Object.create(fs), {
6565
readFile: (p: string, encoding: BufferEncoding, cb: (err: any, str: string) => void) => fs.readFile(remapPath(p), encoding, cb),

‎package.json‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@
2323
"@types/proxy-from-env": "^1",
2424
"@types/semver": "^7.1.0",
2525
"@types/which": "^3.0.0",
26-
"@yarnpkg/eslint-config": "^3.0.0",
26+
"@yarnpkg/eslint-config": "^3.1.1",
2727
"@yarnpkg/fslib": "^3.0.0-rc.48",
2828
"@zkochan/cmd-shim": "^6.0.0",
2929
"clipanion": "patch:clipanion@npm%3A3.2.1#~/.yarn/patches/clipanion-npm-3.2.1-fc9187f56c.patch",
3030
"debug": "^4.1.1",
3131
"esbuild": "^0.28.0",
32-
"eslint": "^9.22.0",
32+
"eslint": "^10.8.1",
3333
"semver": "^7.6.3",
3434
"supports-color": "^10.0.0",
3535
"tar": "^7.5.11",
36-
"tsx": "^4.16.2",
3736
"typescript": "^5.7.3",
3837
"v8-compile-cache": "^2.3.0",
3938
"vitest": "^4.0.5",
@@ -45,11 +44,11 @@
4544
}
4645
},
4746
"scripts": {
48-
"build": "run clean && run build:bundle && tsx ./mkshims.ts",
47+
"build": "run clean && run build:bundle && node ./mkshims.ts",
4948
"build:bundle": "esbuild ./sources/_lib.ts --bundle --platform=node --target=node22.22.2 --external:corepack --outfile='./dist/lib/corepack.cjs' --resolve-extensions='.ts,.mjs,.js'",
5049
"clean": "run rimraf dist shims",
51-
"corepack": "tsx ./sources/_cli.ts",
52-
"lint": "eslint .",
50+
"corepack": "node ./sources/_cli.ts",
51+
"lint": "eslint",
5352
"prepack": "yarn build",
5453
"postpack": "run clean",
5554
"rimraf": "node -e 'for(let i=2;i<process.argv.length;i++)fs.rmSync(process.argv[i],{recursive:true,force:true});'",

‎sources/Engine.ts‎

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
import {UsageError} from 'clipanion';
2-
import fs from 'fs';
3-
import path from 'path';
4-
import process from 'process';
5-
import semverRcompare from 'semver/functions/rcompare';
6-
import semverValid from 'semver/functions/valid';
7-
import semverValidRange from 'semver/ranges/valid';
8-
9-
import defaultConfig from '../config.json';
10-
11-
import * as corepackUtils from './corepackUtils';
12-
import * as debugUtils from './debugUtils';
13-
import * as folderUtils from './folderUtils';
14-
import type {NodeError} from './nodeUtils';
15-
import * as semverUtils from './semverUtils';
16-
import * as specUtils from './specUtils';
17-
import {Config, Descriptor, LazyLocator, Locator} from './types';
18-
import {SupportedPackageManagers, SupportedPackageManagerSet} from './types';
19-
import {isSupportedPackageManager, PackageManagerSpec} from './types';
1+
import {UsageError} from 'clipanion';
2+
import fs from 'fs';
3+
import path from 'path';
4+
import process from 'process';
5+
import semverRcompare from 'semver/functions/rcompare.js';
6+
import semverValid from 'semver/functions/valid.js';
7+
import semverValidRange from 'semver/ranges/valid.js';
8+
9+
import defaultConfig from '../config.json' with {type: 'json'};
10+
11+
import * as corepackUtils from './corepackUtils.ts';
12+
import * as debugUtils from './debugUtils.ts';
13+
import * as folderUtils from './folderUtils.ts';
14+
import type {NodeError} from './nodeUtils.ts';
15+
import * as semverUtils from './semverUtils.ts';
16+
import * as specUtils from './specUtils.ts';
17+
import type {Config, Descriptor, LazyLocator, Locator} from './types.ts';
18+
import type {SupportedPackageManagers} from './types.ts';
19+
import {SupportedPackageManagerSet} from './types.ts';
20+
import type {PackageManagerSpec} from './types.ts';
21+
import {isSupportedPackageManager} from './types.ts';
2022

2123
export type PreparedPackageManagerInfo = Awaited<ReturnType<Engine[`ensurePackageManager`]>>;
2224

@@ -94,7 +96,10 @@ export async function activatePackageManager(lastKnownGood: Record<string, strin
9496
}
9597

9698
export class Engine {
97-
constructor(public config: Config = defaultConfig as Config) {
99+
config: Config;
100+
101+
constructor(config: Config = defaultConfig as Config) {
102+
this.config = config;
98103
}
99104

100105
getPackageManagerFor(binaryName: string): SupportedPackageManagers | null {
@@ -161,7 +166,7 @@ export class Engine {
161166
async getDefaultDescriptors() {
162167
const locators: Array<Descriptor> = [];
163168

164-
for (const name of SupportedPackageManagerSet as Set<SupportedPackageManagers>)
169+
for (const name of SupportedPackageManagerSet)
165170
locators.push({name, range: await this.getDefaultVersion(name)});
166171

167172
return locators;

‎sources/_cli.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import {runMain} from './main';
1+
import {runMain} from './main.ts';
22

33
runMain(process.argv.slice(2));

0 commit comments

Comments
 (0)