From 0b94797f96e30e46e466873fe7d437d0471cd92c Mon Sep 17 00:00:00 2001 From: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:46:08 +0200 Subject: [PATCH 1/5] fix: debug text typo (#698) --- sources/Engine.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/Engine.ts b/sources/Engine.ts index 41f965a..73b82db 100644 --- a/sources/Engine.ts +++ b/sources/Engine.ts @@ -288,7 +288,7 @@ export class Engine { await specUtils.setLocalPackageManager(path.dirname(result.target), installSpec); } - debugUtils.log(`Falling back to ${fallbackDescriptor.name}@${fallbackDescriptor.range} in the absence of "packageManage" field in ${result.target}`); + debugUtils.log(`Falling back to ${fallbackDescriptor.name}@${fallbackDescriptor.range} in the absence of "packageManager" field in ${result.target}`); return fallbackDescriptor; } From aefde28a631356bfdec91795d2c60be07dbf5be3 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 9 Apr 2025 17:48:07 +0200 Subject: [PATCH 2/5] chore(publish): add `--provenance` (#701) --- .github/workflows/publish.yml | 8 +++++--- package.json | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f436856..4f57f18 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,6 +29,8 @@ jobs: needs: release-please if: ${{ needs.release-please.outputs.release_created }} runs-on: ubuntu-latest + permissions: + id-token: write steps: - uses: actions/checkout@v4 @@ -48,10 +50,10 @@ jobs: restore-keys: | ${{runner.os}}-yarn- + - run: corepack yarn install --immutable + - name: Publish to the npm registry - run: | - corepack yarn install --immutable - corepack yarn npm publish + run: corepack yarn npm publish --provenance env: YARN_NPM_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/package.json b/package.json index 59162a0..6d8f3dd 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "./package.json": "./package.json" }, "license": "MIT", - "packageManager": "yarn@4.6.0+sha512.5383cc12567a95f1d668fbe762dfe0075c595b4bfff433be478dbbe24e05251a8e8c3eb992a986667c1d53b6c3a9c85b8398c35a960587fbd9fa3a0915406728", + "packageManager": "yarn@4.9.0+sha224.dce6c5df199861784bd9b0eecb2a228df97e3f18a02b1bb75ff98383", "devDependencies": { "@types/debug": "^4.1.5", "@types/node": "^20.4.6", From 2b43f2613571c67aebc7ce39bb1217816d842520 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 00:19:14 +0200 Subject: [PATCH 3/5] build(deps): bump vite from 6.2.3 to 6.2.6 (#702) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.3 to 6.2.6. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.2.6/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.2.6/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.2.6 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index b2a26d9..24a209f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4304,8 +4304,8 @@ __metadata: linkType: hard "vite@npm:^5.0.0 || ^6.0.0": - version: 6.2.3 - resolution: "vite@npm:6.2.3" + version: 6.2.6 + resolution: "vite@npm:6.2.6" dependencies: esbuild: "npm:^0.25.0" fsevents: "npm:~2.3.3" @@ -4351,7 +4351,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: 10c0/ba6ad7e83e5a63fb0b6f62d3a3963624b8784bdc1bfa2a83e16cf268fb58c76bd9f8e69f39ed34bf8711cdb8fd7702916f878781da53c232c34ef7a85e0600cf + checksum: 10c0/68a2ed3e61bdd654c59b817b4f3203065241c66d1739faa707499130f3007bc3a666c7a8320a4198e275e62b5e4d34d9b78a6533f69e321d366e76f5093b2071 languageName: node linkType: hard From 273237a110ce4eabe4ba704482fb528abe5642ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 May 2025 00:37:14 +0200 Subject: [PATCH 4/5] build(deps): bump vite from 6.2.6 to 6.3.4 (#705) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.6 to 6.3.4. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.3.4/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.3.4 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 214 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 128 insertions(+), 86 deletions(-) diff --git a/yarn.lock b/yarn.lock index 24a209f..48c5c45 100644 --- a/yarn.lock +++ b/yarn.lock @@ -390,135 +390,142 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-android-arm-eabi@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-android-arm-eabi@npm:4.34.8" +"@rollup/rollup-android-arm-eabi@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.40.1" conditions: os=android & cpu=arm languageName: node linkType: hard -"@rollup/rollup-android-arm64@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-android-arm64@npm:4.34.8" +"@rollup/rollup-android-arm64@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-android-arm64@npm:4.40.1" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-arm64@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-darwin-arm64@npm:4.34.8" +"@rollup/rollup-darwin-arm64@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-darwin-arm64@npm:4.40.1" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-x64@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-darwin-x64@npm:4.34.8" +"@rollup/rollup-darwin-x64@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-darwin-x64@npm:4.40.1" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@rollup/rollup-freebsd-arm64@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-freebsd-arm64@npm:4.34.8" +"@rollup/rollup-freebsd-arm64@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-freebsd-arm64@npm:4.40.1" conditions: os=freebsd & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-freebsd-x64@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-freebsd-x64@npm:4.34.8" +"@rollup/rollup-freebsd-x64@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-freebsd-x64@npm:4.40.1" conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@rollup/rollup-linux-arm-gnueabihf@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.34.8" +"@rollup/rollup-linux-arm-gnueabihf@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.40.1" conditions: os=linux & cpu=arm & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-arm-musleabihf@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.34.8" +"@rollup/rollup-linux-arm-musleabihf@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.40.1" conditions: os=linux & cpu=arm & libc=musl languageName: node linkType: hard -"@rollup/rollup-linux-arm64-gnu@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.34.8" +"@rollup/rollup-linux-arm64-gnu@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.40.1" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-arm64-musl@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-linux-arm64-musl@npm:4.34.8" +"@rollup/rollup-linux-arm64-musl@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.40.1" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-linux-loongarch64-gnu@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-linux-loongarch64-gnu@npm:4.34.8" +"@rollup/rollup-linux-loongarch64-gnu@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-linux-loongarch64-gnu@npm:4.40.1" conditions: os=linux & cpu=loong64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-powerpc64le-gnu@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.34.8" +"@rollup/rollup-linux-powerpc64le-gnu@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.40.1" conditions: os=linux & cpu=ppc64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-riscv64-gnu@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.34.8" +"@rollup/rollup-linux-riscv64-gnu@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.40.1" conditions: os=linux & cpu=riscv64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-s390x-gnu@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.34.8" +"@rollup/rollup-linux-riscv64-musl@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-linux-riscv64-musl@npm:4.40.1" + conditions: os=linux & cpu=riscv64 & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-linux-s390x-gnu@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.40.1" conditions: os=linux & cpu=s390x & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-gnu@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-linux-x64-gnu@npm:4.34.8" +"@rollup/rollup-linux-x64-gnu@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.40.1" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-musl@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-linux-x64-musl@npm:4.34.8" +"@rollup/rollup-linux-x64-musl@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.40.1" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-win32-arm64-msvc@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.34.8" +"@rollup/rollup-win32-arm64-msvc@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.40.1" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-win32-ia32-msvc@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.34.8" +"@rollup/rollup-win32-ia32-msvc@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.40.1" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@rollup/rollup-win32-x64-msvc@npm:4.34.8": - version: 4.34.8 - resolution: "@rollup/rollup-win32-x64-msvc@npm:4.34.8" +"@rollup/rollup-win32-x64-msvc@npm:4.40.1": + version: 4.40.1 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.40.1" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -561,7 +568,14 @@ __metadata: languageName: node linkType: hard -"@types/estree@npm:1.0.6, @types/estree@npm:^1.0.0, @types/estree@npm:^1.0.6": +"@types/estree@npm:1.0.7": + version: 1.0.7 + resolution: "@types/estree@npm:1.0.7" + checksum: 10c0/be815254316882f7c40847336cd484c3bc1c3e34f710d197160d455dc9d6d050ffbf4c3bc76585dba86f737f020ab20bdb137ebe0e9116b0c86c7c0342221b8c + languageName: node + linkType: hard + +"@types/estree@npm:^1.0.0, @types/estree@npm:^1.0.6": version: 1.0.6 resolution: "@types/estree@npm:1.0.6" checksum: 10c0/cdfd751f6f9065442cd40957c07fd80361c962869aa853c1c2fd03e101af8b9389d8ff4955a43a6fcfa223dd387a089937f95be0f3eec21ca527039fd2d9859a @@ -1978,6 +1992,18 @@ __metadata: languageName: node linkType: hard +"fdir@npm:^6.4.4": + version: 6.4.4 + resolution: "fdir@npm:6.4.4" + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + checksum: 10c0/6ccc33be16945ee7bc841e1b4178c0b4cf18d3804894cb482aa514651c962a162f96da7ffc6ebfaf0df311689fb70091b04dd6caffe28d56b9ebdc0e7ccadfdd + languageName: node + linkType: hard + "file-entry-cache@npm:^8.0.0": version: 8.0.0 resolution: "file-entry-cache@npm:8.0.0" @@ -3508,30 +3534,31 @@ __metadata: languageName: node linkType: hard -"rollup@npm:^4.30.1": - version: 4.34.8 - resolution: "rollup@npm:4.34.8" +"rollup@npm:^4.34.9": + version: 4.40.1 + resolution: "rollup@npm:4.40.1" dependencies: - "@rollup/rollup-android-arm-eabi": "npm:4.34.8" - "@rollup/rollup-android-arm64": "npm:4.34.8" - "@rollup/rollup-darwin-arm64": "npm:4.34.8" - "@rollup/rollup-darwin-x64": "npm:4.34.8" - "@rollup/rollup-freebsd-arm64": "npm:4.34.8" - "@rollup/rollup-freebsd-x64": "npm:4.34.8" - "@rollup/rollup-linux-arm-gnueabihf": "npm:4.34.8" - "@rollup/rollup-linux-arm-musleabihf": "npm:4.34.8" - "@rollup/rollup-linux-arm64-gnu": "npm:4.34.8" - "@rollup/rollup-linux-arm64-musl": "npm:4.34.8" - "@rollup/rollup-linux-loongarch64-gnu": "npm:4.34.8" - "@rollup/rollup-linux-powerpc64le-gnu": "npm:4.34.8" - "@rollup/rollup-linux-riscv64-gnu": "npm:4.34.8" - "@rollup/rollup-linux-s390x-gnu": "npm:4.34.8" - "@rollup/rollup-linux-x64-gnu": "npm:4.34.8" - "@rollup/rollup-linux-x64-musl": "npm:4.34.8" - "@rollup/rollup-win32-arm64-msvc": "npm:4.34.8" - "@rollup/rollup-win32-ia32-msvc": "npm:4.34.8" - "@rollup/rollup-win32-x64-msvc": "npm:4.34.8" - "@types/estree": "npm:1.0.6" + "@rollup/rollup-android-arm-eabi": "npm:4.40.1" + "@rollup/rollup-android-arm64": "npm:4.40.1" + "@rollup/rollup-darwin-arm64": "npm:4.40.1" + "@rollup/rollup-darwin-x64": "npm:4.40.1" + "@rollup/rollup-freebsd-arm64": "npm:4.40.1" + "@rollup/rollup-freebsd-x64": "npm:4.40.1" + "@rollup/rollup-linux-arm-gnueabihf": "npm:4.40.1" + "@rollup/rollup-linux-arm-musleabihf": "npm:4.40.1" + "@rollup/rollup-linux-arm64-gnu": "npm:4.40.1" + "@rollup/rollup-linux-arm64-musl": "npm:4.40.1" + "@rollup/rollup-linux-loongarch64-gnu": "npm:4.40.1" + "@rollup/rollup-linux-powerpc64le-gnu": "npm:4.40.1" + "@rollup/rollup-linux-riscv64-gnu": "npm:4.40.1" + "@rollup/rollup-linux-riscv64-musl": "npm:4.40.1" + "@rollup/rollup-linux-s390x-gnu": "npm:4.40.1" + "@rollup/rollup-linux-x64-gnu": "npm:4.40.1" + "@rollup/rollup-linux-x64-musl": "npm:4.40.1" + "@rollup/rollup-win32-arm64-msvc": "npm:4.40.1" + "@rollup/rollup-win32-ia32-msvc": "npm:4.40.1" + "@rollup/rollup-win32-x64-msvc": "npm:4.40.1" + "@types/estree": "npm:1.0.7" fsevents: "npm:~2.3.2" dependenciesMeta: "@rollup/rollup-android-arm-eabi": @@ -3560,6 +3587,8 @@ __metadata: optional: true "@rollup/rollup-linux-riscv64-gnu": optional: true + "@rollup/rollup-linux-riscv64-musl": + optional: true "@rollup/rollup-linux-s390x-gnu": optional: true "@rollup/rollup-linux-x64-gnu": @@ -3576,7 +3605,7 @@ __metadata: optional: true bin: rollup: dist/bin/rollup - checksum: 10c0/b9e711e33413112fbb761107c3fddc4561dfc74335c393542a829a85ccfb2763bfd17bf2422d84a2e9bee7646e5367018973e97005fdf64e49c2e209612f0eb6 + checksum: 10c0/11c44b5ef9b3fd521c5501b3f1c36af4ca07821aeff41d41f45336eee324d8f5b46c1a92189f5c8cd146bc21ac10418d57cb4571637ea09aced1ae831a2a4ae0 languageName: node linkType: hard @@ -4061,6 +4090,16 @@ __metadata: languageName: node linkType: hard +"tinyglobby@npm:^0.2.13": + version: 0.2.13 + resolution: "tinyglobby@npm:0.2.13" + dependencies: + fdir: "npm:^6.4.4" + picomatch: "npm:^4.0.2" + checksum: 10c0/ef07dfaa7b26936601d3f6d999f7928a4d1c6234c5eb36896bb88681947c0d459b7ebe797022400e555fe4b894db06e922b95d0ce60cb05fd827a0a66326b18c + languageName: node + linkType: hard + "tinypool@npm:^1.0.2": version: 1.0.2 resolution: "tinypool@npm:1.0.2" @@ -4304,13 +4343,16 @@ __metadata: linkType: hard "vite@npm:^5.0.0 || ^6.0.0": - version: 6.2.6 - resolution: "vite@npm:6.2.6" + version: 6.3.4 + resolution: "vite@npm:6.3.4" dependencies: esbuild: "npm:^0.25.0" + fdir: "npm:^6.4.4" fsevents: "npm:~2.3.3" + picomatch: "npm:^4.0.2" postcss: "npm:^8.5.3" - rollup: "npm:^4.30.1" + rollup: "npm:^4.34.9" + tinyglobby: "npm:^0.2.13" peerDependencies: "@types/node": ^18.0.0 || ^20.0.0 || >=22.0.0 jiti: ">=1.21.0" @@ -4351,7 +4393,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: 10c0/68a2ed3e61bdd654c59b817b4f3203065241c66d1739faa707499130f3007bc3a666c7a8320a4198e275e62b5e4d34d9b78a6533f69e321d366e76f5093b2071 + checksum: 10c0/f1534a3f42d14b30e11c58e5e451903d965d5f5ba18d8c81f9df208589e3d2c65535abaa3268d3963573174b8e056ea7bc445f567622c65fcdf98eb4acc1bf4e languageName: node linkType: hard From 77fff3c1f3b99c19dcf89cab736d8fb5f1ef85d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Fri, 16 May 2025 19:14:38 +0200 Subject: [PATCH 5/5] Disables auto-pinning by default (#709) * Disables auto-pinning by default * Updates tests * Updates the README --- README.md | 4 +- sources/Engine.ts | 2 +- tests/main.test.ts | 91 +++++++++++++++++++++++----------------------- 3 files changed, 49 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 67d396d..079746e 100644 --- a/README.md +++ b/README.md @@ -286,8 +286,8 @@ same major line. Should you need to upgrade to a new major, use an explicit package manager, and to not update the Last Known Good version when it downloads a new version of the same major line. -- `COREPACK_ENABLE_AUTO_PIN` can be set to `0` to prevent Corepack from - updating the `packageManager` field when it detects that the local package +- `COREPACK_ENABLE_AUTO_PIN` can be set to `1` to instruct Corepack to + update the `packageManager` field when it detects that the local package doesn't list it. In general we recommend to always list a `packageManager` field (which you can easily set through `corepack use [name]@[version]`), as it ensures that your project installs are always deterministic. diff --git a/sources/Engine.ts b/sources/Engine.ts index 73b82db..208d5a8 100644 --- a/sources/Engine.ts +++ b/sources/Engine.ts @@ -274,7 +274,7 @@ export class Engine { if (typeof locator.reference === `function`) fallbackDescriptor.range = await locator.reference(); - if (process.env.COREPACK_ENABLE_AUTO_PIN !== `0`) { + if (process.env.COREPACK_ENABLE_AUTO_PIN === `1`) { const resolved = await this.resolveDescriptor(fallbackDescriptor, {allowTags: true}); if (resolved === null) throw new UsageError(`Failed to successfully resolve '${fallbackDescriptor.range}' to a valid ${fallbackDescriptor.name} release`); diff --git a/tests/main.test.ts b/tests/main.test.ts index 2560089..80f1176 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -648,25 +648,7 @@ for (const name of SupportedPackageManagerSet) { } describe(`when called on a project without any defined packageManager`, () => { - it(`should append the field to package.json by default`, async () => { - await xfs.mktempPromise(async cwd => { - await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), { - // empty package.json file - }); - - await runCli(cwd, [`yarn`]); - - const data = await xfs.readJsonPromise(ppath.join(cwd, `package.json` as Filename)); - - expect(data).toMatchObject({ - packageManager: `yarn@${config.definitions.yarn.default}`, - }); - }); - }); - - it(`should not modify package.json if disabled by env`, async () => { - process.env.COREPACK_ENABLE_AUTO_PIN = `0`; - + it(`should not modify package.json by default`, async () => { await xfs.mktempPromise(async cwd => { await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), { // empty package.json file @@ -680,7 +662,25 @@ describe(`when called on a project without any defined packageManager`, () => { }); }); - it(`should not modify package.json if disabled by .corepack.env`, async t => { + it(`should modify package.json if enabled by env`, async () => { + process.env.COREPACK_ENABLE_AUTO_PIN = `1`; + + await xfs.mktempPromise(async cwd => { + await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), { + // empty package.json file + }); + + await runCli(cwd, [`yarn`]); + + const data = await xfs.readJsonPromise(ppath.join(cwd, `package.json` as Filename)); + + expect(data).toMatchObject({ + packageManager: expect.stringMatching(/^yarn@/), + }); + }); + }); + + it(`should modify package.json if enabled by .corepack.env`, async t => { // Skip that test on Node.js 18.x as it lacks support for .env files. if (process.version.startsWith(`v18.`)) t.skip(); @@ -688,33 +688,34 @@ describe(`when called on a project without any defined packageManager`, () => { await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), { // empty package.json file }); - await xfs.writeFilePromise(ppath.join(cwd, `.corepack.env` as Filename), `COREPACK_ENABLE_AUTO_PIN=0\n`); - - await runCli(cwd, [`yarn`]); - - const data = await xfs.readJsonPromise(ppath.join(cwd, `package.json` as Filename)); - - expect(Object.hasOwn(data, `packageManager`)).toBeFalsy(); - }); - }); - it(`should modify package.json if .corepack.env if disabled`, async () => { - process.env.COREPACK_ENV_FILE = `0`; - - await xfs.mktempPromise(async cwd => { - await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), { - // empty package.json file - }); - await xfs.writeFilePromise(ppath.join(cwd, `.corepack.env` as Filename), `COREPACK_ENABLE_AUTO_PIN=0\n`); + await xfs.writeFilePromise(ppath.join(cwd, `.corepack.env` as Filename), `COREPACK_ENABLE_AUTO_PIN=1\n`); await runCli(cwd, [`yarn`]); const data = await xfs.readJsonPromise(ppath.join(cwd, `package.json` as Filename)); expect(data).toMatchObject({ - packageManager: `yarn@${config.definitions.yarn.default}`, + packageManager: expect.stringMatching(/^yarn@/), }); }); }); + + it(`should not modify package.json if .corepack.env is disabled`, async () => { + process.env.COREPACK_ENV_FILE = `0`; + + await xfs.mktempPromise(async cwd => { + await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), { + // empty package.json file + }); + await xfs.writeFilePromise(ppath.join(cwd, `.corepack.env` as Filename), `COREPACK_ENABLE_AUTO_PIN=1\n`); + + await runCli(cwd, [`yarn`]); + + const data = await xfs.readJsonPromise(ppath.join(cwd, `package.json` as Filename)); + + expect(Object.hasOwn(data, `packageManager`)).toBeFalsy(); + }); + }); }); it(`should allow updating the pinned version using the "corepack install -g" command`, async () => { @@ -1302,7 +1303,7 @@ it(`should download latest pnpm from custom registry`, async () => { await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({ exitCode: 0, stdout: `pnpm: Hello from custom registry\n`, - stderr: expect.stringContaining(`! The local project doesn't define a 'packageManager' field. Corepack will now add one referencing pnpm@1.9998.9999+sha1.`), + stderr: ``, }); // Should keep working with cache @@ -1335,7 +1336,7 @@ describe(`should pick up COREPACK_INTEGRITY_KEYS from env`, () => { await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({ exitCode: 0, stdout: `pnpm: Hello from custom registry\n`, - stderr: expect.stringContaining(`The local project doesn't define a 'packageManager' field`), + stderr: ``, }); }); }); @@ -1358,7 +1359,7 @@ describe(`should pick up COREPACK_INTEGRITY_KEYS from env`, () => { await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({ exitCode: 0, stdout: `pnpm: Hello from custom registry\n`, - stderr: expect.stringContaining(`The local project doesn't define a 'packageManager' field`), + stderr: ``, }); }); }); @@ -1385,7 +1386,7 @@ describe(`should pick up COREPACK_INTEGRITY_KEYS from env`, () => { await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({ exitCode: 0, stdout: `pnpm: Hello from custom registry\n`, - stderr: expect.stringContaining(`The local project doesn't define a 'packageManager' field`), + stderr: ``, }); }); }); @@ -1408,7 +1409,7 @@ describe(`should pick up COREPACK_INTEGRITY_KEYS from env`, () => { await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({ exitCode: 0, stdout: `pnpm: Hello from custom registry\n`, - stderr: expect.stringContaining(`The local project doesn't define a 'packageManager' field`), + stderr: ``, }); }); }); @@ -1434,7 +1435,7 @@ describe(`should pick up COREPACK_INTEGRITY_KEYS from env`, () => { await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({ exitCode: 0, stdout: `pnpm: Hello from custom registry\n`, - stderr: expect.stringContaining(`The local project doesn't define a 'packageManager' field`), + stderr: ``, }); }); }); @@ -1458,7 +1459,7 @@ describe(`should pick up COREPACK_INTEGRITY_KEYS from env`, () => { await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({ exitCode: 0, stdout: `pnpm: Hello from custom registry\n`, - stderr: expect.stringContaining(`The local project doesn't define a 'packageManager' field`), + stderr: ``, }); }); });