test: stop reading the v11 tree from v12 tests and tooling (#18357)
## Summary Prepares for moving pnpm v11 to a maintenance branch (`release/11`), so main can carry only the current major. After this PR, nothing under `pnpm/` reads `pnpm11/` at build or test time. `pnpm11/` itself stays; deleting it is a separate PR. - **Fixtures.** The patch and sbom fixtures the CLI suite uses are copied into `pnpm/crates/cli/tests/fixtures`. - **Config parity tests.** They read a checked-in copy of the four v11 config-reader sources they parse (`pnpm/crates/config/tests/fixtures/pnpm11-config-reader`). The esm-node-path-loader golden flag is copied next to its test. v11 is maintenance-only, so a snapshot is enough. - **Test oracles.** A private `pnpm/test-oracles` package installs the published packages the Rust tests compare against: `ci-info`, `npm-packlist`, `@pnpm/fs.packlist`, and pnpm 11.29.0 as `pnpm-v11`. It is exempt from meta-updater, because `workspace:` would replace the published pins. - The packlist parity test imports the published `@pnpm/fs.packlist` and packs v12 workspace packages as its real-package corpus. - The convergence and version-switch jobs run the published v11 bundle and no longer build v11. - **node-gyp shims.** The pnpm wrapper ships its own copy. - **Source-build version.** The CLI no longer records the version from the source checkout's `pnpm11/pnpm/package.json` in `packageManagerDependencies`. That lookup only applied to source builds, and there it recorded a v11 version for a v12 binary. Released builds are unaffected, so there is no changeset. ### Trade-off The convergence tests now compare against a published v11, so the `pnpm-v11` pin has to follow the latest v11 release. It needs 11.29.0; against 11.28.13 the convergence tests fail. After the split, a fix shared by both versions keeps these jobs red until the v11 fix is released and the pin is bumped. ### Verification All of these ran with `pnpm11/` moved out of the tree: - `pnpm-config` and `pnpm-fs-packlist` tests: 1139 passed. - `pnpm-cli` unit tests plus the touched suites (patch, fetch, import_yarn_patches, lockfile_resolution_reuse, pnpr_install, repeat_install, sbom): 2349 passed. - Convergence and version-switch suites with `PNPM_V11_BUNDLE` pointing at the oracle bundle: 554 passed. Clippy with `-D warnings`, `lint:meta`, and the `test-affected` and `ts-test-scope` script tests also pass. ### Left for the PR that deletes `pnpm11/` - Root `package.json`: it depends on v11 workspace packages, so `pnpm install` fails without `pnpm11/`, and some of its scripts point into `pnpm11/`. `.meta-updater` depends on v11 packages and paths too. - v11 workflows (`ci.yml`, `test.yml`, the v11 parts of `release.yml` and `create-release-pr.yml`, `benchmark.yml`, `ecosystem-e2e.yml`), plus `CODEOWNERS`, `.coderabbit.yaml`, `.gitignore`, `.vale.ini` and `eslint.config.mjs`. - Rust comments that cite `pnpm11/...` paths, to become permalinks to `release/11`. - `pnpm/esm-loader` repository scripts and the webcontainer harness, which use a v11 checkout. - Renaming the v12 wrapper from `pacquet` to `pnpm`, once the name is free. Pending changesets that target both `pnpm` and `pacquet` must be released or split first. - AGENTS.md and skills: replace "fix both stacks in one PR" with "fix on main, backport". - pnpm/pnpm.io: `sync-docs.mjs` must tolerate a missing `pnpm11/docs` when it syncs from main. ## Checklist - [x] Added or updated tests. --- Written by an agent (Claude Code, claude-opus-5-5). 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- codesmith:footer --> --- <a href="https://dashboardbackend.blacksmith.sh/track/run-proof?expires=1797956458&installation_model_id=426870&pr_number=18357&ref=codesmith_pr_footer&repository=pnpm%2Fpnpm&return_to=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F18357&variant=show_it_working&signature=36556dda73452dd5683c8603a7f316613b8de78ebec577f5837190d0a2bf2bf9"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-show-it-working-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-show-it-working-v2-light.svg"><img alt="Show it working" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-show-it-working-v2-dark-3x.png" width="140" height="28"></picture></a> <sup><a href="https://app.blacksmith.sh/pnpm/codesmith/pnpm/pr/18357?autoLogin=true&ref=codesmith_pr_footer">Open in [code]smith</a> · Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Package-manager synchronization now uses the running pnpm version when it satisfies a version range, without relying on a local source checkout. * The Node ESM loader now retries unresolved bare imports using `NODE_PATH` and handles qualifying `.js` entry points. * Node-gyp commands now use the configured executable when provided, or the bundled version otherwise. * **Chores** * Updated comparison tests and CI workflows to use centralized test fixtures and published-package oracles. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
cd6b2d8e38
commit
664d81d95b
64 changed files with 1206 additions and 226 deletions
2
.github/scripts/ts-test-scope.test.mjs
vendored
2
.github/scripts/ts-test-scope.test.mjs
vendored
|
|
@ -101,7 +101,7 @@ test('Rust gate configuration keeps exclusions limited to approved documentation
|
|||
// Markdown under pnpr/.fixtures ships inside registry fixtures.
|
||||
const recursiveDocs = new Set(['!pnpm/docs/**', '!pnpr/docs/**'])
|
||||
assert.ok(!patterns.some(pattern => pattern.startsWith('!') && pattern.includes('**') && !recursiveDocs.has(pattern)), 'recursive exclusions only cover product documentation')
|
||||
for (const pattern of ['pnpm/**', 'pnpr/**', '.config/nextest.toml', 'fixtures/**', 'pnpm11/installing/deps-installer/test/fixtures/patch-pkg/**', 'pnpm11/deps/compliance/commands/test/sbom/fixtures/**']) {
|
||||
for (const pattern of ['pnpm/**', 'pnpr/**', '.config/nextest.toml', 'fixtures/**']) {
|
||||
assert.ok(patterns.includes(pattern), `required test input: ${pattern}`)
|
||||
}
|
||||
assert.deepEqual(docs, patterns.filter(pattern => pattern.startsWith('!')).map(pattern => pattern.slice(1)), 'docs covers every exclusion, so the spell check still runs')
|
||||
|
|
|
|||
19
.github/workflows/pacquet-ci.yml
vendored
19
.github/workflows/pacquet-ci.yml
vendored
|
|
@ -102,8 +102,6 @@ jobs:
|
|||
- '.cargo/**'
|
||||
- '.config/nextest.toml'
|
||||
- 'fixtures/**'
|
||||
- 'pnpm11/installing/deps-installer/test/fixtures/patch-pkg/**'
|
||||
- 'pnpm11/deps/compliance/commands/test/sbom/fixtures/**'
|
||||
- '.github/actions/rustup/**'
|
||||
- '.github/actions/binstall/**'
|
||||
- '.github/actions/install-crates/**'
|
||||
|
|
@ -149,15 +147,7 @@ jobs:
|
|||
- 'pnpm/crates/cli/tests/suite/version.rs'
|
||||
- 'pnpm/crates/testing-utils/**'
|
||||
- 'pnpm/crates/config/**'
|
||||
- 'pnpm11/deps/status/**'
|
||||
- 'pnpm11/exec/commands/**'
|
||||
- 'pnpm11/installing/**'
|
||||
- 'pnpm11/config/reader/**'
|
||||
- 'pnpm11/pnpm/src/**'
|
||||
- 'pnpm11/lockfile/**'
|
||||
- 'pnpm11/resolving/**'
|
||||
- 'pnpm11/releasing/commands/src/deploy/**'
|
||||
- 'pnpm11/workspace/state/**'
|
||||
- 'pnpm/test-oracles/**'
|
||||
- 'pnpr/.fixtures/**'
|
||||
- '.config/nextest.toml'
|
||||
- '.github/workflows/pacquet-ci.yml'
|
||||
|
|
@ -591,16 +581,11 @@ jobs:
|
|||
unset XDG_DATA_HOME
|
||||
just install
|
||||
|
||||
- name: Bundle pnpm v11
|
||||
run: |
|
||||
pnpm --filter pnpm exec tsc --build
|
||||
pnpm --filter pnpm run bundle
|
||||
|
||||
- name: Run the convergence harnesses through v11 and v12
|
||||
run: |
|
||||
unset PNPM_HOME
|
||||
unset XDG_DATA_HOME
|
||||
PNPM_V11_BUNDLE="$PWD/pnpm11/pnpm/dist/pnpm.mjs" \
|
||||
PNPM_V11_BUNDLE="$PWD/pnpm/test-oracles/node_modules/pnpm-v11/dist/pnpm.mjs" \
|
||||
pnpm test:rust -p pnpm-cli --run-ignored all -E 'test(/^peer_convergence::/) or test(/^repeat_install_oracle::/) or test(/^repeat_install_read_set::/) or test(/^pnpm_compatibility::/) or test(/^injected_freshness_matrix::/) or test(/^version::switches_up_to_a_newer_pnpm/) or test(/^version::v11_switches_up/)'
|
||||
|
||||
clippy:
|
||||
|
|
|
|||
8
.github/workflows/version-switch-matrix.yml
vendored
8
.github/workflows/version-switch-matrix.yml
vendored
|
|
@ -72,12 +72,6 @@ jobs:
|
|||
unset XDG_DATA_HOME
|
||||
just install
|
||||
|
||||
- name: Bundle pnpm v11
|
||||
shell: bash
|
||||
run: |
|
||||
pnpm --filter pnpm exec tsc --build
|
||||
pnpm --filter pnpm run bundle
|
||||
|
||||
- name: Switch matrix across released outer pnpm versions (11.latest, 12.0.0, 12.latest) and pins (10, 11, 12, HEAD)
|
||||
# zizmor: ignore[adhoc-packages] -- This matrix intentionally installs
|
||||
# the latest published pnpm 11 and 12 dist-tags to test cross-version
|
||||
|
|
@ -119,6 +113,6 @@ jobs:
|
|||
unset IFS
|
||||
unset PNPM_HOME
|
||||
unset XDG_DATA_HOME
|
||||
PNPM_V11_BUNDLE="$PWD/pnpm11/pnpm/dist/pnpm.mjs" \
|
||||
PNPM_V11_BUNDLE="$PWD/pnpm/test-oracles/node_modules/pnpm-v11/dist/pnpm.mjs" \
|
||||
PNPM_TEST_OUTER_CLIS="$outer_clis" \
|
||||
cargo nextest run --locked --run-ignored all -p pnpm-cli --test suite -E 'test(/^version::/)'
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ const NON_TYPESCRIPT_PKGS = new Set([
|
|||
'@pnpm/pnpr',
|
||||
'@pnpm/pnpr-ui',
|
||||
'@pnpm/esm-loader',
|
||||
// Pins published releases, which workspace: and catalog: would replace.
|
||||
'@pnpm-private/test-oracles',
|
||||
])
|
||||
|
||||
// Files that must be packed with mode 0755 in both `pnpm` and `@pnpm/exe`.
|
||||
|
|
|
|||
157
pnpm-lock.yaml
generated
157
pnpm-lock.yaml
generated
|
|
@ -1182,6 +1182,15 @@ snapshots:
|
|||
},
|
||||
},
|
||||
|
||||
"pnpm/test-oracles": {
|
||||
"devDependencies": {
|
||||
"@pnpm/fs.packlist": "1100.0.15",
|
||||
"ci-info": "catalog:",
|
||||
"npm-packlist": "catalog:",
|
||||
"pnpm-v11": "npm:pnpm@11.29.0",
|
||||
},
|
||||
},
|
||||
|
||||
"pnpm/wasm": {
|
||||
"name": "@pnpm-private/wasm-runtime",
|
||||
"dependencies": {
|
||||
|
|
@ -9497,6 +9506,11 @@ snapshots:
|
|||
"engines": {"node": ">=18.12"},
|
||||
},
|
||||
|
||||
"@pnpm/constants@1102.0.1": {
|
||||
"integrity": "sha512-vLulGZ3iRt6kHcwbGYckrUF2Rd18nfGtpFjyRgbKmEyxLcZmFTBOWKFZSEyS3VVnxFEI7bTPNOGmRC0lD4U1qg==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
},
|
||||
|
||||
"@pnpm/core-loggers@1001.0.10": {
|
||||
"integrity": "sha512-02ZMWWNmHHzAxtDiB+8AfQpnpsb+UzJLpBdGznUmSd9pwgTph19yQFyFuZ3ZGGXy1EFotd1gRO92VcStP6s+DA==",
|
||||
"engines": {"node": ">=18.12"},
|
||||
|
|
@ -9525,6 +9539,20 @@ snapshots:
|
|||
},
|
||||
},
|
||||
|
||||
"@pnpm/core-loggers@1101.0.6": {
|
||||
"integrity": "sha512-SfB8/BVdrfzNdVQ34+zkb6XP7NHsAuu5eyb/4cn4qOI0lzRPD6h99G2lpeXZBW48yvNc09gxC6cNh1+5SMvcgA==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
"peerDependencies": {
|
||||
"@pnpm/logger": {
|
||||
"specifier": "^1100.0.0",
|
||||
"version": "1100.0.0",
|
||||
},
|
||||
},
|
||||
"dependencies": {
|
||||
"@pnpm/types": "1102.1.5",
|
||||
},
|
||||
},
|
||||
|
||||
"@pnpm/create-cafs-store@1000.0.33": {
|
||||
"integrity": "sha512-ynUDVwsvZRzfmxqZ0I6bht/CZ3WMRkwWr5jOBjsUVwyuQSvj3mbse5XZXbWRM6ox2WpybMVd7unoBdOQqlvTPQ==",
|
||||
"engines": {"node": ">=18.12"},
|
||||
|
|
@ -9686,6 +9714,14 @@ snapshots:
|
|||
},
|
||||
},
|
||||
|
||||
"@pnpm/deps.peer-range@1100.1.2": {
|
||||
"integrity": "sha512-PFGNtptMRhqQd7FogcaCsfMpCkvDhFQVuO3+BnMw0PByAUPjXpE7jJMIGduRUSETb2E/zDr2PZ13cXO2OQiAeQ==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
"dependencies": {
|
||||
"semver": "7.8.6",
|
||||
},
|
||||
},
|
||||
|
||||
"@pnpm/directory-fetcher@1000.1.24": {
|
||||
"integrity": "sha512-Hoidyge60IF+e4axLHIzfeN7DAF1Upl/Xs4/TNVg5bby5oUHvy7yxvltT2wn1utMO/Lx1EqHoBAzERZhtatH6g==",
|
||||
"engines": {"node": ">=18.12"},
|
||||
|
|
@ -9723,6 +9759,14 @@ snapshots:
|
|||
},
|
||||
},
|
||||
|
||||
"@pnpm/error@1100.2.3": {
|
||||
"integrity": "sha512-UNdOlAlv26PuLzlW6Dzr6MlcCzSLTAuAVSX1QlSNTlWaHdqQWm/iEpa5HuZXGZPxpfOGQajn7/GBuDDEhqCyGQ==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
"dependencies": {
|
||||
"@pnpm/constants": "1102.0.1",
|
||||
},
|
||||
},
|
||||
|
||||
"@pnpm/exec.pkg-requires-build@1000.0.16": {
|
||||
"integrity": "sha512-IF1hAWdq61gCIbaCpy01SmoL5GLfJRC5/+qd0ZwBFdBeWEcEETCcuBYFFss71Q9OdjdTxNrNsz9apE3DPx1Tsg==",
|
||||
"engines": {"node": ">=18.12"},
|
||||
|
|
@ -9745,7 +9789,7 @@ snapshots:
|
|||
"dependencies": {
|
||||
"command-exists": "1.2.9",
|
||||
"cross-spawn": "7.0.6",
|
||||
"pnpm": "11.28.13",
|
||||
"pnpm": "11.29.0",
|
||||
},
|
||||
},
|
||||
|
||||
|
|
@ -9849,6 +9893,15 @@ snapshots:
|
|||
},
|
||||
},
|
||||
|
||||
"@pnpm/fs.graceful-fs@1100.2.7": {
|
||||
"integrity": "sha512-M8PFIwKGpNT8sGvHZCJWAQs5ORL+ht1T4y3M16mym9i6A5wkptAZ7w53kfViHA17bgcpfhGY87U4jNGEadH0Iw==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
"dependencies": {
|
||||
"@pnpm/error": "1100.2.3",
|
||||
"graceful-fs": "4.2.12",
|
||||
},
|
||||
},
|
||||
|
||||
"@pnpm/fs.hard-link-dir@1000.0.6": {
|
||||
"integrity": "sha512-8Z26HRL7YuC7jvkGMT3s5+0sJSBJ8PtldWGQ9gCPtXtjfORr7ep5V/rcTDQk6L1KzFIBuSg5NBOpxLdzJeCUCA==",
|
||||
"engines": {"node": ">=18.12"},
|
||||
|
|
@ -9921,6 +9974,23 @@ snapshots:
|
|||
},
|
||||
},
|
||||
|
||||
"@pnpm/fs.packlist@1100.0.15": {
|
||||
"integrity": "sha512-r8hMRYAqazPm18uDoPIa7XdyCqw8x8hfGcqVTxdE+YKSlu1HOxXNo0AuiQ3/2vQ0UeeUUSLIT2j8hkuBRHLaTQ==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
"peerDependencies": {
|
||||
"@pnpm/logger": {
|
||||
"version": "1100.0.0",
|
||||
"below": true,
|
||||
},
|
||||
},
|
||||
"dependencies": {
|
||||
"@pnpm/error": "1100.2.3",
|
||||
"@pnpm/workspace.project-manifest-reader": "1100.1.8",
|
||||
"is-subdir": "2.0.1",
|
||||
"npm-packlist": "10.0.4",
|
||||
},
|
||||
},
|
||||
|
||||
"@pnpm/git-fetcher@1006.0.6": {
|
||||
"integrity": "sha512-kxLOlrvwOudX7VEe6bTJz0UXTwAebqTAYz0XhlzzXeJUuWep2hQMAW7QzeQyU247ZzE4AXr88Ca1ViZyytCk/g==",
|
||||
"engines": {"node": ">=18.12"},
|
||||
|
|
@ -10534,6 +10604,25 @@ snapshots:
|
|||
},
|
||||
},
|
||||
|
||||
"@pnpm/pkg-manifest.utils@1100.4.14": {
|
||||
"integrity": "sha512-gLcW0lNjBp/F7EnrxRjnGuLQwL3+c7a8L1/TtF3irMYMVszlDC7IOeDWnNwW/I0s5J+3nltwFN34+i4SS1xMXA==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
"peerDependencies": {
|
||||
"@pnpm/logger": {
|
||||
"specifier": "^1100.0.0",
|
||||
"version": "1100.0.0",
|
||||
},
|
||||
},
|
||||
"dependencies": {
|
||||
"@pnpm/core-loggers": "1101.0.6",
|
||||
"@pnpm/deps.peer-range": "1100.1.2",
|
||||
"@pnpm/error": "1100.2.3",
|
||||
"@pnpm/types": "1102.1.5",
|
||||
"semver": "7.8.6",
|
||||
"semver-utils": "1.1.4",
|
||||
},
|
||||
},
|
||||
|
||||
"@pnpm/pnpmfile@1002.1.13": {
|
||||
"integrity": "sha512-WURiwlcbGeIUFj1woQiKKGvF+AkgENRDXV4S8BIHVox/uAT/d4MNQ/6ekQ/0kaovebsKqFftZFisHLpG4d0yww==",
|
||||
"engines": {"node": ">=18.12"},
|
||||
|
|
@ -11012,6 +11101,14 @@ snapshots:
|
|||
},
|
||||
},
|
||||
|
||||
"@pnpm/text.comments-parser@1100.0.1": {
|
||||
"integrity": "sha512-10rRwfC9ffkuS4RugetHD+AiNZLdg9ZVv0rkbr/8o14EW6Vh6ZwFwAfTOlkp3Eyse8518jVFvXXPKQKyeh9kNw==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
"dependencies": {
|
||||
"strip-comments-strings": "1.2.0",
|
||||
},
|
||||
},
|
||||
|
||||
"@pnpm/text.tree-renderer@1000.0.0": {
|
||||
"integrity": "sha512-ea/ClG7C4eJTxS2wcqj3bjXQ1zwxBd7ASTiyGR99pilLQCL8d2XOusFrnHYTmeP1couC89OULT/BZ59lmK/lPg==",
|
||||
"engines": {"node": ">=18.12"},
|
||||
|
|
@ -11036,6 +11133,11 @@ snapshots:
|
|||
"engines": {"node": ">=18.12"},
|
||||
},
|
||||
|
||||
"@pnpm/types@1102.1.5": {
|
||||
"integrity": "sha512-9F4Ql9DJ0Xpd+dgSdvC8g+3sDDpR4+zhUTW8vpAj7w1ppMguBm8XFB5OD5Ntb6a152N4/B1drP7h7awTJQkmrQ==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
},
|
||||
|
||||
"@pnpm/util.lex-comparator@3.0.2": {
|
||||
"integrity": "sha512-blFO4Ws97tWv/SNE6N39ZdGmZBrocXnBOfVp0ln4kELmns4pGPZizqyRtR8EjfOLMLstbmNCTReBoDvLz1isVg==",
|
||||
"engines": {"node": ">=18.12"},
|
||||
|
|
@ -11127,6 +11229,47 @@ snapshots:
|
|||
},
|
||||
},
|
||||
|
||||
"@pnpm/workspace.project-manifest-reader@1100.1.8": {
|
||||
"integrity": "sha512-I+AVdb+hJbxRLfKrvJexOxUPOC4hW+xUNNayALPq32q2v9EZN4S6tHV7j3vVJ4N0U4+oQvLFWP1Z0RxyShgEFA==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
"peerDependencies": {
|
||||
"@pnpm/logger": {
|
||||
"specifier": "^1100.0.0",
|
||||
"version": "1100.0.0",
|
||||
},
|
||||
},
|
||||
"dependencies": {
|
||||
"@pnpm/error": "1100.2.3",
|
||||
"@pnpm/fs.graceful-fs": "1100.2.7",
|
||||
"@pnpm/pkg-manifest.utils": "1100.4.14",
|
||||
"@pnpm/text.comments-parser": "1100.0.1",
|
||||
"@pnpm/types": "1102.1.5",
|
||||
"@pnpm/workspace.project-manifest-writer": "1100.0.24",
|
||||
"detect-indent": "7.0.2",
|
||||
"fast-deep-equal": "3.1.3",
|
||||
"is-windows": "1.0.2",
|
||||
"json5": "2.2.3",
|
||||
"p-limit": "7.3.3",
|
||||
"parse-json": "8.3.0",
|
||||
"read-yaml-file": "3.0.0",
|
||||
"strip-bom": "5.0.0",
|
||||
},
|
||||
},
|
||||
|
||||
"@pnpm/workspace.project-manifest-writer@1100.0.24": {
|
||||
"integrity": "sha512-9ZMdVd6eRWsY7NA9Z9qS0zb50mTssVfHx1tlHjUZ5wzspCGi5DuFxeewTKM7R6BOZgu4NLPeGG4BzzmDR2+UvQ==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
"dependencies": {
|
||||
"@pnpm/error": "1100.2.3",
|
||||
"@pnpm/text.comments-parser": "1100.0.1",
|
||||
"@pnpm/types": "1102.1.5",
|
||||
"@pnpm/yaml.document-sync": "1100.0.2",
|
||||
"json5": "2.2.3",
|
||||
"write-file-atomic": "7.0.1",
|
||||
"yaml": "2.9.1",
|
||||
},
|
||||
},
|
||||
|
||||
"@pnpm/workspace.read-manifest@1000.3.1": {
|
||||
"integrity": "sha512-ojO1Anf4ITL7OskuUYoLI3bldQ36XNLpG2cYQZ4F6LZbBZnRY8umW6TeWzb9h/aX8UFwYp9vWbQ8R/FaMtMEeg==",
|
||||
"engines": {"node": ">=18.12"},
|
||||
|
|
@ -11163,6 +11306,14 @@ snapshots:
|
|||
},
|
||||
},
|
||||
|
||||
"@pnpm/yaml.document-sync@1100.0.2": {
|
||||
"integrity": "sha512-DXohTVqVxIDf30cPlBczibqDnSzsAB1N9PPBMGf7EkBgiOaJNvsWkFA6QeI90XVMAkLCRjV4S6LdnhVpB8U80w==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
"dependencies": {
|
||||
"yaml": "2.9.1",
|
||||
},
|
||||
},
|
||||
|
||||
"@reflink/reflink-darwin-arm64@0.1.19": {
|
||||
"integrity": "sha512-ruy44Lpepdk1FqDz38vExBY/PVUsjxZA+chd9wozjUH9JjuDT/HEaQYA6wYN9mf041l0yLVar6BCZuWABJvHSA==",
|
||||
"engines": {"node": ">= 10"},
|
||||
|
|
@ -18998,8 +19149,8 @@ snapshots:
|
|||
"hasBin": true,
|
||||
},
|
||||
|
||||
"pnpm@11.28.13": {
|
||||
"integrity": "sha512-1cqpzc1gZ6wpAvn0TaoAsSiKc7q/Hpj083Wzp1g7GJS01J91J9qPXhUwGYuxDgOtujIaHwFUKdwpRs6KepqMZQ==",
|
||||
"pnpm@11.29.0": {
|
||||
"integrity": "sha512-2RP5s3zV/meABS6Al3Ttq7e9z2mm5tm4/Ts4vAUvqKfYkbbCAaOPtQSgf/zi5ejCYu9U+49X22LyLTU6MLyKlg==",
|
||||
"engines": {"node": ">=22.13"},
|
||||
"hasBin": true,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ packages:
|
|||
- pnpm/esm-loader
|
||||
- pnpm/npm/pnpm
|
||||
- pnpm/tasks/registry-mock
|
||||
- pnpm/test-oracles
|
||||
- pnpm/tasks/ecosystem-e2e/webcontainer
|
||||
- pnpm/wasm
|
||||
- pnpr/npm/pnpr
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ pub(crate) struct PackageManagerToSync {
|
|||
/// which overrides the manifest's own `onFail`.
|
||||
pub(crate) fn package_manager_to_sync_for_version(
|
||||
manifest: &Value,
|
||||
root_dir: &Path,
|
||||
on_fail: Option<PmOnFail>,
|
||||
running_version: &str,
|
||||
) -> Option<PackageManagerToSync> {
|
||||
|
|
@ -99,18 +98,6 @@ pub(crate) fn package_manager_to_sync_for_version(
|
|||
if !version_satisfies(running_version, wanted_version) {
|
||||
return None;
|
||||
}
|
||||
if running_version == PNPM_VERSION {
|
||||
let source_version = current_source_pnpm_version().or_else(|| pnpm_version_from(root_dir));
|
||||
if let Some(version) =
|
||||
source_version.filter(|version| version_satisfies(version, wanted_version))
|
||||
{
|
||||
return Some(PackageManagerToSync {
|
||||
specifier: wanted_version.to_string(),
|
||||
version,
|
||||
running_pnpm_for_range: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
if let Some(version) = exact_version(wanted_version) {
|
||||
return Some(PackageManagerToSync {
|
||||
specifier: wanted_version.to_string(),
|
||||
|
|
@ -245,23 +232,6 @@ pub(crate) fn should_persist_package_manager_lockfile(pm: &WantedPackageManager)
|
|||
.is_some_and(|version| version.major >= 12)
|
||||
}
|
||||
|
||||
pub(crate) fn current_source_pnpm_version() -> Option<String> {
|
||||
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
manifest_dir.ancestors().find_map(pnpm_version_from)
|
||||
}
|
||||
|
||||
fn pnpm_version_from(root_dir: &Path) -> Option<String> {
|
||||
let path = root_dir
|
||||
.join("pnpm11")
|
||||
.join("pnpm")
|
||||
.join("package.json");
|
||||
let value = read_manifest_json(&path).ok()??;
|
||||
value
|
||||
.get("version")
|
||||
.and_then(Value::as_str)
|
||||
.map(ToString::to_string)
|
||||
}
|
||||
|
||||
/// The one version `version` pins, or `None` when it pins a range, a
|
||||
/// dist-tag, or nothing at all.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -7,14 +7,12 @@ use pnpm_config::{
|
|||
PNPM_VERSION,
|
||||
PmOnFail,
|
||||
};
|
||||
use std::path::Path;
|
||||
|
||||
fn package_manager_to_sync(
|
||||
manifest: &serde_json::Value,
|
||||
root_dir: &Path,
|
||||
on_fail: Option<PmOnFail>,
|
||||
) -> Option<super::PackageManagerToSync> {
|
||||
package_manager_to_sync_for_version(manifest, root_dir, on_fail, PNPM_VERSION)
|
||||
package_manager_to_sync_for_version(manifest, on_fail, PNPM_VERSION)
|
||||
}
|
||||
|
||||
fn dev_engines_manifest(version: &str) -> serde_json::Value {
|
||||
|
|
@ -35,7 +33,7 @@ fn a_corepack_build_is_not_part_of_the_pinned_version() {
|
|||
|
||||
let pin = format!("{PNPM_VERSION}+sha512.0123456789abcdef");
|
||||
|
||||
let sync = package_manager_to_sync(&manifest, Path::new("."), None).expect("an entry to sync");
|
||||
let sync = package_manager_to_sync(&manifest, None).expect("an entry to sync");
|
||||
|
||||
assert_eq!(sync.version, PNPM_VERSION);
|
||||
// The specifier records the pin as the manifest writes it, the way the
|
||||
|
|
@ -51,7 +49,7 @@ fn a_range_pin_is_left_as_written() {
|
|||
let pm = wanted_package_manager(&manifest).expect("a pinned package manager");
|
||||
|
||||
assert_eq!(pm.version.as_deref(), Some(">=9.1.0 <9.1.2"));
|
||||
assert!(package_manager_to_sync(&manifest, Path::new("."), None).is_none());
|
||||
assert!(package_manager_to_sync(&manifest, None).is_none());
|
||||
}
|
||||
|
||||
/// Every expectation is npm's own answer, read off
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ pub(super) fn env_lockfile_sync_plan(
|
|||
pub(super) fn env_lockfile_sync_from_loaded(
|
||||
config: &Config,
|
||||
root_manifest: &Value,
|
||||
roots: &PinRoots,
|
||||
on_fail: PmOnFail,
|
||||
env_lockfile: Option<&EnvLockfile>,
|
||||
running_version: &str,
|
||||
|
|
@ -53,12 +52,9 @@ pub(super) fn env_lockfile_sync_from_loaded(
|
|||
if !config.lockfile {
|
||||
return Ok(None);
|
||||
}
|
||||
let Some(mut package_manager) = package_manager_to_sync_for_version(
|
||||
root_manifest,
|
||||
&roots.manifest,
|
||||
Some(on_fail),
|
||||
running_version,
|
||||
) else {
|
||||
let Some(mut package_manager) =
|
||||
package_manager_to_sync_for_version(root_manifest, Some(on_fail), running_version)
|
||||
else {
|
||||
return Ok(None);
|
||||
};
|
||||
if keep_locked_range_version
|
||||
|
|
|
|||
|
|
@ -201,7 +201,6 @@ fn decide_record(
|
|||
match env_lockfile_sync_from_loaded(
|
||||
settings,
|
||||
root_manifest,
|
||||
pin.roots,
|
||||
on_fail,
|
||||
pin.locked_env.as_ref(),
|
||||
pin.running_version,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ use super::{
|
|||
},
|
||||
list::RecursionLimit,
|
||||
package_manager::{
|
||||
current_source_pnpm_version,
|
||||
package_manager_to_sync_for_version,
|
||||
parse_package_manager,
|
||||
read_manifest_json,
|
||||
|
|
@ -47,10 +46,9 @@ use tempfile::TempDir;
|
|||
|
||||
fn package_manager_to_sync(
|
||||
manifest: &serde_json::Value,
|
||||
root_dir: &Path,
|
||||
on_fail: Option<PmOnFail>,
|
||||
) -> Option<super::package_manager::PackageManagerToSync> {
|
||||
package_manager_to_sync_for_version(manifest, root_dir, on_fail, PNPM_VERSION)
|
||||
package_manager_to_sync_for_version(manifest, on_fail, PNPM_VERSION)
|
||||
}
|
||||
|
||||
fn install_args(argv: &[&str]) -> InstallArgs {
|
||||
|
|
@ -351,18 +349,12 @@ fn package_manager_to_sync_preserves_dev_engine_specifier() {
|
|||
.expect("write manifest");
|
||||
|
||||
let manifest = read_manifest_json(&manifest_path).expect("read manifest").expect("manifest");
|
||||
let package_manager =
|
||||
package_manager_to_sync(&manifest, root.path(), None).expect("sync package manager");
|
||||
let package_manager = package_manager_to_sync(&manifest, None).expect("sync package manager");
|
||||
|
||||
assert_eq!(package_manager.specifier, ">=0.0.0");
|
||||
assert_eq!(
|
||||
package_manager.version,
|
||||
current_source_pnpm_version().expect("source pnpm version"),
|
||||
);
|
||||
assert_eq!(package_manager.version, pnpm_config::PNPM_VERSION);
|
||||
}
|
||||
|
||||
/// The range is built from `PNPM_VERSION` so the source checkout's version
|
||||
/// (a different major) can never satisfy it and answer first.
|
||||
#[test]
|
||||
fn package_manager_to_sync_records_the_running_version_for_a_satisfied_range_pin() {
|
||||
let root = TempDir::new().expect("tmp dir");
|
||||
|
|
@ -377,8 +369,7 @@ fn package_manager_to_sync_records_the_running_version_for_a_satisfied_range_pin
|
|||
.expect("write manifest");
|
||||
|
||||
let manifest = read_manifest_json(&manifest_path).expect("read manifest").expect("manifest");
|
||||
let package_manager =
|
||||
package_manager_to_sync(&manifest, root.path(), None).expect("sync package manager");
|
||||
let package_manager = package_manager_to_sync(&manifest, None).expect("sync package manager");
|
||||
|
||||
assert_eq!(package_manager.specifier, range);
|
||||
assert_eq!(package_manager.version, pnpm_config::PNPM_VERSION);
|
||||
|
|
@ -395,7 +386,7 @@ fn package_manager_to_sync_records_nothing_for_a_pin_nothing_satisfies() {
|
|||
.expect("write manifest");
|
||||
|
||||
let manifest = read_manifest_json(&manifest_path).expect("read manifest").expect("manifest");
|
||||
assert_eq!(package_manager_to_sync(&manifest, root.path(), None), None);
|
||||
assert_eq!(package_manager_to_sync(&manifest, None), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
7
pnpm/crates/cli/tests/fixtures/patches/console-log-replace-1st-line.patch
generated
vendored
Normal file
7
pnpm/crates/cli/tests/fixtures/patches/console-log-replace-1st-line.patch
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
diff --git a/index.js b/index.js
|
||||
index 54b6705..6c0033d 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -1,1 +1,1 @@
|
||||
-console.log('first line')
|
||||
+console.log('FIRST LINE')
|
||||
7
pnpm/crates/cli/tests/fixtures/patches/is-positive@1.0.0-binding-gyp.patch
generated
vendored
Normal file
7
pnpm/crates/cli/tests/fixtures/patches/is-positive@1.0.0-binding-gyp.patch
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
diff --git a/binding.gyp b/binding.gyp
|
||||
new file mode 100644
|
||||
index 0000000..d7ea4ac
|
||||
--- /dev/null
|
||||
+++ b/binding.gyp
|
||||
@@ -0,0 +1 @@
|
||||
+{ "targets": [] }
|
||||
7
pnpm/crates/cli/tests/fixtures/patches/is-positive@1.0.0-hooks-file.patch
generated
vendored
Normal file
7
pnpm/crates/cli/tests/fixtures/patches/is-positive@1.0.0-hooks-file.patch
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
diff --git a/.hooks b/.hooks
|
||||
new file mode 100644
|
||||
index 0000000..8c41a6a
|
||||
--- /dev/null
|
||||
+++ b/.hooks
|
||||
@@ -0,0 +1 @@
|
||||
+not a hooks directory
|
||||
21
pnpm/crates/cli/tests/fixtures/patches/is-positive@1.0.0-postinstall.patch
generated
vendored
Normal file
21
pnpm/crates/cli/tests/fixtures/patches/is-positive@1.0.0-postinstall.patch
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
diff --git a/package.json b/package.json
|
||||
index 5c708ce..3b93e9b 100644
|
||||
--- a/package.json
|
||||
+++ b/package.json
|
||||
@@ -13,7 +13,8 @@
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
- "test": "node test.js"
|
||||
+ "test": "node test.js",
|
||||
+ "postinstall": "node postinstall.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
diff --git a/postinstall.js b/postinstall.js
|
||||
new file mode 100644
|
||||
index 0000000..d12e51d
|
||||
--- /dev/null
|
||||
+++ b/postinstall.js
|
||||
@@ -0,0 +1 @@
|
||||
+require('fs').writeFileSync('postinstall-ran.txt', 'ran')
|
||||
11
pnpm/crates/cli/tests/fixtures/patches/is-positive@1.0.0.patch
generated
vendored
Normal file
11
pnpm/crates/cli/tests/fixtures/patches/is-positive@1.0.0.patch
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
diff --git a/index.js b/index.js
|
||||
index 8e020ca..ff3aee4 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -5,5 +5,6 @@ module.exports = function (n) {
|
||||
throw new TypeError('Expected a number');
|
||||
}
|
||||
|
||||
+ // patched
|
||||
return n >= 0;
|
||||
};
|
||||
10
pnpm/crates/cli/tests/fixtures/sbom-repository/package.json
generated
vendored
Normal file
10
pnpm/crates/cli/tests/fixtures/sbom-repository/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "sbom-repository-test",
|
||||
"version": "1.0.0",
|
||||
"description": "Test fixture for SBOM repository field normalization",
|
||||
"license": "ISC",
|
||||
"repository": "acme/sbom-repository-test",
|
||||
"dependencies": {
|
||||
"is-positive": "^3.1.0"
|
||||
}
|
||||
}
|
||||
24
pnpm/crates/cli/tests/fixtures/sbom-repository/pnpm-lock.yaml
generated
vendored
Normal file
24
pnpm/crates/cli/tests/fixtures/sbom-repository/pnpm-lock.yaml
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
is-positive:
|
||||
specifier: ^3.1.0
|
||||
version: 3.1.0
|
||||
|
||||
packages:
|
||||
|
||||
is-positive@3.1.0:
|
||||
resolution: {integrity: sha512-8ND1j3y9/HP94TOvGzr69/FgbkX2ruOldhLEsTWwcJVfo4oRjwemJmJxt7RJkKYH8tz7vYBP9JcKQY8CLuJ90Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
snapshots:
|
||||
|
||||
is-positive@3.1.0:
|
||||
dev: false
|
||||
9
pnpm/crates/cli/tests/fixtures/simple-sbom/package.json
generated
vendored
Normal file
9
pnpm/crates/cli/tests/fixtures/simple-sbom/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "simple-sbom-test",
|
||||
"version": "1.0.0",
|
||||
"description": "Test fixture for SBOM generation",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"is-positive": "^3.1.0"
|
||||
}
|
||||
}
|
||||
24
pnpm/crates/cli/tests/fixtures/simple-sbom/pnpm-lock.yaml
generated
vendored
Normal file
24
pnpm/crates/cli/tests/fixtures/simple-sbom/pnpm-lock.yaml
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
is-positive:
|
||||
specifier: ^3.1.0
|
||||
version: 3.1.0
|
||||
|
||||
packages:
|
||||
|
||||
is-positive@3.1.0:
|
||||
resolution: {integrity: sha512-8ND1j3y9/HP94TOvGzr69/FgbkX2ruOldhLEsTWwcJVfo4oRjwemJmJxt7RJkKYH8tz7vYBP9JcKQY8CLuJ90Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
snapshots:
|
||||
|
||||
is-positive@3.1.0:
|
||||
dev: false
|
||||
12
pnpm/crates/cli/tests/fixtures/with-dev-dependency/package.json
generated
vendored
Normal file
12
pnpm/crates/cli/tests/fixtures/with-dev-dependency/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "sbom-with-dev-dep",
|
||||
"version": "2.0.0",
|
||||
"description": "Test fixture with dev dependency",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-positive": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^4.8.4"
|
||||
}
|
||||
}
|
||||
36
pnpm/crates/cli/tests/fixtures/with-dev-dependency/pnpm-lock.yaml
generated
vendored
Normal file
36
pnpm/crates/cli/tests/fixtures/with-dev-dependency/pnpm-lock.yaml
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
is-positive:
|
||||
specifier: ^3.1.0
|
||||
version: 3.1.0
|
||||
devDependencies:
|
||||
typescript:
|
||||
specifier: ^4.8.4
|
||||
version: 4.8.4
|
||||
|
||||
packages:
|
||||
|
||||
is-positive@3.1.0:
|
||||
resolution: {integrity: sha512-8ND1j3y9/HP94TOvGzr69/FgbkX2ruOldhLEsTWwcJVfo4oRjwemJmJxt7RJkKYH8tz7vYBP9JcKQY8CLuJ90Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
typescript@4.8.4:
|
||||
resolution: {integrity: sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==}
|
||||
engines: {node: '>=4.2.0'}
|
||||
hasBin: true
|
||||
|
||||
snapshots:
|
||||
|
||||
is-positive@3.1.0:
|
||||
dev: false
|
||||
|
||||
typescript@4.8.4:
|
||||
dev: true
|
||||
8
pnpm/crates/cli/tests/fixtures/with-peer-and-real-dep/package.json
generated
vendored
Normal file
8
pnpm/crates/cli/tests/fixtures/with-peer-and-real-dep/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "sbom-peer-and-real-dep",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"is-positive": "3.1.0"
|
||||
}
|
||||
}
|
||||
8
pnpm/crates/cli/tests/fixtures/with-peer-and-real-dep/packages/pkg-a/package.json
generated
vendored
Normal file
8
pnpm/crates/cli/tests/fixtures/with-peer-and-real-dep/packages/pkg-a/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "sbom-peer-only-pkg",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {},
|
||||
"peerDependencies": {
|
||||
"is-odd": "3.0.1"
|
||||
}
|
||||
}
|
||||
7
pnpm/crates/cli/tests/fixtures/with-peer-and-real-dep/packages/pkg-b/package.json
generated
vendored
Normal file
7
pnpm/crates/cli/tests/fixtures/with-peer-and-real-dep/packages/pkg-b/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "sbom-real-dep-pkg",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"is-odd": "3.0.1"
|
||||
}
|
||||
}
|
||||
49
pnpm/crates/cli/tests/fixtures/with-peer-and-real-dep/pnpm-lock.yaml
generated
vendored
Normal file
49
pnpm/crates/cli/tests/fixtures/with-peer-and-real-dep/pnpm-lock.yaml
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
is-positive:
|
||||
specifier: 3.1.0
|
||||
version: 3.1.0
|
||||
|
||||
packages/pkg-a:
|
||||
dependencies:
|
||||
is-odd:
|
||||
specifier: 3.0.1
|
||||
version: 3.0.1
|
||||
|
||||
packages/pkg-b:
|
||||
dependencies:
|
||||
is-odd:
|
||||
specifier: 3.0.1
|
||||
version: 3.0.1
|
||||
|
||||
packages:
|
||||
|
||||
is-number@6.0.0:
|
||||
resolution: {integrity: sha512-Wu1VHeILBK8KAWJUAiSZQX94GmOE45Rg6/538fKwiloUu21KncEkYGPqob2oSZ5mUT73vLGrHQjKw3KMPwfDzg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
is-odd@3.0.1:
|
||||
resolution: {integrity: sha512-CQpnWPrDwmP1+SMHXZhtLtJv90yiyVfluGsX5iNCVkrhQtU3TQHsUWPG9wkdk9Lgd5yNpAg9jQEo90CBaXgWMA==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
is-positive@3.1.0:
|
||||
resolution: {integrity: sha512-8ND1j3y9/HP94TOvGzr69/FgbkX2ruOldhLEsTWwcJVfo4oRjwemJmJxt7RJkKYH8tz7vYBP9JcKQY8CLuJ90Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
snapshots:
|
||||
|
||||
is-number@6.0.0: {}
|
||||
|
||||
is-odd@3.0.1:
|
||||
dependencies:
|
||||
is-number: 6.0.0
|
||||
|
||||
is-positive@3.1.0: {}
|
||||
2
pnpm/crates/cli/tests/fixtures/with-peer-and-real-dep/pnpm-workspace.yaml
generated
vendored
Normal file
2
pnpm/crates/cli/tests/fixtures/with-peer-and-real-dep/pnpm-workspace.yaml
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
packages:
|
||||
- 'packages/*'
|
||||
12
pnpm/crates/cli/tests/fixtures/with-peer-dependency/package.json
generated
vendored
Normal file
12
pnpm/crates/cli/tests/fixtures/with-peer-dependency/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "sbom-with-peer-dep",
|
||||
"version": "1.0.0",
|
||||
"description": "Test fixture with a peer dependency",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-positive": "3.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"is-odd": "3.0.1"
|
||||
}
|
||||
}
|
||||
40
pnpm/crates/cli/tests/fixtures/with-peer-dependency/pnpm-lock.yaml
generated
vendored
Normal file
40
pnpm/crates/cli/tests/fixtures/with-peer-dependency/pnpm-lock.yaml
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
is-odd:
|
||||
specifier: 3.0.1
|
||||
version: 3.0.1
|
||||
is-positive:
|
||||
specifier: 3.1.0
|
||||
version: 3.1.0
|
||||
|
||||
packages:
|
||||
|
||||
is-number@6.0.0:
|
||||
resolution: {integrity: sha512-Wu1VHeILBK8KAWJUAiSZQX94GmOE45Rg6/538fKwiloUu21KncEkYGPqob2oSZ5mUT73vLGrHQjKw3KMPwfDzg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
is-odd@3.0.1:
|
||||
resolution: {integrity: sha512-CQpnWPrDwmP1+SMHXZhtLtJv90yiyVfluGsX5iNCVkrhQtU3TQHsUWPG9wkdk9Lgd5yNpAg9jQEo90CBaXgWMA==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
is-positive@3.1.0:
|
||||
resolution: {integrity: sha512-8ND1j3y9/HP94TOvGzr69/FgbkX2ruOldhLEsTWwcJVfo4oRjwemJmJxt7RJkKYH8tz7vYBP9JcKQY8CLuJ90Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
snapshots:
|
||||
|
||||
is-number@6.0.0: {}
|
||||
|
||||
is-odd@3.0.1:
|
||||
dependencies:
|
||||
is-number: 6.0.0
|
||||
|
||||
is-positive@3.1.0: {}
|
||||
8
pnpm/crates/cli/tests/fixtures/with-peer-workspace/package.json
generated
vendored
Normal file
8
pnpm/crates/cli/tests/fixtures/with-peer-workspace/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "sbom-peer-workspace",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"is-positive": "3.1.0"
|
||||
}
|
||||
}
|
||||
8
pnpm/crates/cli/tests/fixtures/with-peer-workspace/packages/pkg-a/package.json
generated
vendored
Normal file
8
pnpm/crates/cli/tests/fixtures/with-peer-workspace/packages/pkg-a/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "pkg-a",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {},
|
||||
"peerDependencies": {
|
||||
"is-odd": "3.0.1"
|
||||
}
|
||||
}
|
||||
43
pnpm/crates/cli/tests/fixtures/with-peer-workspace/pnpm-lock.yaml
generated
vendored
Normal file
43
pnpm/crates/cli/tests/fixtures/with-peer-workspace/pnpm-lock.yaml
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
is-positive:
|
||||
specifier: 3.1.0
|
||||
version: 3.1.0
|
||||
|
||||
packages/pkg-a:
|
||||
dependencies:
|
||||
is-odd:
|
||||
specifier: 3.0.1
|
||||
version: 3.0.1
|
||||
|
||||
packages:
|
||||
|
||||
is-number@6.0.0:
|
||||
resolution: {integrity: sha512-Wu1VHeILBK8KAWJUAiSZQX94GmOE45Rg6/538fKwiloUu21KncEkYGPqob2oSZ5mUT73vLGrHQjKw3KMPwfDzg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
is-odd@3.0.1:
|
||||
resolution: {integrity: sha512-CQpnWPrDwmP1+SMHXZhtLtJv90yiyVfluGsX5iNCVkrhQtU3TQHsUWPG9wkdk9Lgd5yNpAg9jQEo90CBaXgWMA==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
is-positive@3.1.0:
|
||||
resolution: {integrity: sha512-8ND1j3y9/HP94TOvGzr69/FgbkX2ruOldhLEsTWwcJVfo4oRjwemJmJxt7RJkKYH8tz7vYBP9JcKQY8CLuJ90Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
snapshots:
|
||||
|
||||
is-number@6.0.0: {}
|
||||
|
||||
is-odd@3.0.1:
|
||||
dependencies:
|
||||
is-number: 6.0.0
|
||||
|
||||
is-positive@3.1.0: {}
|
||||
2
pnpm/crates/cli/tests/fixtures/with-peer-workspace/pnpm-workspace.yaml
generated
vendored
Normal file
2
pnpm/crates/cli/tests/fixtures/with-peer-workspace/pnpm-workspace.yaml
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
packages:
|
||||
- 'packages/*'
|
||||
9
pnpm/crates/cli/tests/fixtures/workspace-sbom/app-a/package.json
generated
vendored
Normal file
9
pnpm/crates/cli/tests/fixtures/workspace-sbom/app-a/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@test/app-a",
|
||||
"version": "1.0.0",
|
||||
"description": "First workspace app",
|
||||
"dependencies": {
|
||||
"is-positive": "3.1.0",
|
||||
"shared-lib": "workspace:*"
|
||||
}
|
||||
}
|
||||
8
pnpm/crates/cli/tests/fixtures/workspace-sbom/app-b/package.json
generated
vendored
Normal file
8
pnpm/crates/cli/tests/fixtures/workspace-sbom/app-b/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "app-b",
|
||||
"version": "2.0.0",
|
||||
"description": "Second workspace app",
|
||||
"dependencies": {
|
||||
"is-negative": "2.1.0"
|
||||
}
|
||||
}
|
||||
5
pnpm/crates/cli/tests/fixtures/workspace-sbom/package.json
generated
vendored
Normal file
5
pnpm/crates/cli/tests/fixtures/workspace-sbom/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "workspace-sbom-root",
|
||||
"version": "0.0.0",
|
||||
"private": true
|
||||
}
|
||||
9
pnpm/crates/cli/tests/fixtures/workspace-sbom/pnpm-lock.yaml
generated
vendored
Normal file
9
pnpm/crates/cli/tests/fixtures/workspace-sbom/pnpm-lock.yaml
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.: {}
|
||||
4
pnpm/crates/cli/tests/fixtures/workspace-sbom/pnpm-workspace.yaml
generated
vendored
Normal file
4
pnpm/crates/cli/tests/fixtures/workspace-sbom/pnpm-workspace.yaml
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
packages:
|
||||
- app-a
|
||||
- app-b
|
||||
- shared-lib
|
||||
8
pnpm/crates/cli/tests/fixtures/workspace-sbom/shared-lib/package.json
generated
vendored
Normal file
8
pnpm/crates/cli/tests/fixtures/workspace-sbom/shared-lib/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "shared-lib",
|
||||
"version": "0.1.0",
|
||||
"description": "Shared workspace library",
|
||||
"dependencies": {
|
||||
"is-odd": "3.0.1"
|
||||
}
|
||||
}
|
||||
|
|
@ -336,9 +336,7 @@ fn fetch_runs_a_build_script_that_calls_a_sibling_dependency_bin() {
|
|||
#[test]
|
||||
fn fetch_fails_with_patch_not_found_when_a_patch_file_is_missing() {
|
||||
const PATCHED_DEP: &str = "@pnpm.e2e/console-log";
|
||||
const PATCH: &str = include_str!(
|
||||
"../../../../../pnpm11/installing/commands/test/__fixtures__/patchedDependencies/console-log-replace-1st-line.patch"
|
||||
);
|
||||
const PATCH: &str = include_str!("../fixtures/patches/console-log-replace-1st-line.patch");
|
||||
|
||||
for node_linker in ["isolated", "hoisted"] {
|
||||
let CommandTempCwd { root, workspace, npmrc_info, .. } =
|
||||
|
|
@ -396,9 +394,7 @@ fn fetch_fails_with_patch_not_found_when_a_patch_file_is_missing() {
|
|||
fn fetch_under_hoisted_defers_patches_and_builds_until_offline_install() {
|
||||
const PATCHED_DEP: &str = "@pnpm.e2e/console-log";
|
||||
const BUILT_DEP: &str = "@pnpm.e2e/pre-and-postinstall-scripts-example";
|
||||
const PATCH: &str = include_str!(
|
||||
"../../../../../pnpm11/installing/commands/test/__fixtures__/patchedDependencies/console-log-replace-1st-line.patch"
|
||||
);
|
||||
const PATCH: &str = include_str!("../fixtures/patches/console-log-replace-1st-line.patch");
|
||||
|
||||
let CommandTempCwd { root, workspace, npmrc_info, .. } =
|
||||
CommandTempCwd::init().add_mocked_registry();
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ use std::{
|
|||
process::Command,
|
||||
};
|
||||
|
||||
const IS_POSITIVE_PATCH: &str = include_str!(
|
||||
"../../../../../pnpm11/installing/deps-installer/test/fixtures/patch-pkg/is-positive@1.0.0.patch"
|
||||
);
|
||||
const IS_POSITIVE_PATCH: &str = include_str!("../fixtures/patches/is-positive@1.0.0.patch");
|
||||
|
||||
const ROOT_PATCH_PATH: &str = ".yarn/patches/is-positive-npm-1.0.0-0a1b2c3d4e.patch";
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ use std::{
|
|||
process::Command,
|
||||
};
|
||||
|
||||
const IS_POSITIVE_PATCH: &str = include_str!(
|
||||
"../../../../../pnpm11/installing/deps-installer/test/fixtures/patch-pkg/is-positive@1.0.0.patch"
|
||||
);
|
||||
const IS_POSITIVE_PATCH: &str = include_str!("../fixtures/patches/is-positive@1.0.0.patch");
|
||||
|
||||
fn pacquet_at(workspace: &Path) -> Command {
|
||||
Command::cargo_bin("pnpm").expect("find the pnpm binary").with_current_dir(workspace)
|
||||
|
|
|
|||
|
|
@ -26,26 +26,21 @@ use std::{
|
|||
};
|
||||
use tempfile::TempDir;
|
||||
|
||||
const IS_POSITIVE_PATCH: &str = include_str!(
|
||||
"../../../../../pnpm11/installing/deps-installer/test/fixtures/patch-pkg/is-positive@1.0.0.patch"
|
||||
);
|
||||
const IS_POSITIVE_PATCH: &str = include_str!("../fixtures/patches/is-positive@1.0.0.patch");
|
||||
|
||||
/// Adds a `postinstall` script the published package does not declare,
|
||||
/// plus the script it runs.
|
||||
const IS_POSITIVE_POSTINSTALL_PATCH: &str = include_str!(
|
||||
"../../../../../pnpm11/installing/deps-installer/test/fixtures/patch-pkg/is-positive@1.0.0-postinstall.patch"
|
||||
);
|
||||
const IS_POSITIVE_POSTINSTALL_PATCH: &str =
|
||||
include_str!("../fixtures/patches/is-positive@1.0.0-postinstall.patch");
|
||||
|
||||
/// Creates a `binding.gyp`, which the lifecycle runner turns into an
|
||||
/// implicit `node-gyp rebuild`.
|
||||
const IS_POSITIVE_BINDING_GYP_PATCH: &str = include_str!(
|
||||
"../../../../../pnpm11/installing/deps-installer/test/fixtures/patch-pkg/is-positive@1.0.0-binding-gyp.patch"
|
||||
);
|
||||
const IS_POSITIVE_BINDING_GYP_PATCH: &str =
|
||||
include_str!("../fixtures/patches/is-positive@1.0.0-binding-gyp.patch");
|
||||
|
||||
/// Creates a plain file named `.hooks`, which is not a hook directory.
|
||||
const IS_POSITIVE_HOOKS_FILE_PATCH: &str = include_str!(
|
||||
"../../../../../pnpm11/installing/deps-installer/test/fixtures/patch-pkg/is-positive@1.0.0-hooks-file.patch"
|
||||
);
|
||||
const IS_POSITIVE_HOOKS_FILE_PATCH: &str =
|
||||
include_str!("../fixtures/patches/is-positive@1.0.0-hooks-file.patch");
|
||||
|
||||
/// Drops the `gypfile: false` from `@pnpm.e2e/gypfile-false`, which puts the
|
||||
/// `binding.gyp` the package already ships back in scope for the implicit
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
//! Every violation of a fixture is collected before the test fails, so one
|
||||
//! run reports the whole matrix.
|
||||
//!
|
||||
//! With `PNPM_V11_BUNDLE` naming the pnpm v11 bundle (`pnpm11/pnpm/dist/pnpm.mjs`),
|
||||
//! With `PNPM_V11_BUNDLE` naming the pnpm v11 bundle (`pnpm/test-oracles/node_modules/pnpm-v11/dist/pnpm.mjs`),
|
||||
//! every fixture also runs through v11, apart from the rows that set the
|
||||
//! v12-only `autoDedupe`, and each row's fresh v11 lockfile has to equal the
|
||||
//! v12 one.
|
||||
|
|
|
|||
|
|
@ -64,9 +64,7 @@ use std::{
|
|||
time::Duration,
|
||||
};
|
||||
|
||||
const IS_POSITIVE_PATCH: &str = include_str!(
|
||||
"../../../../../pnpm11/installing/deps-installer/test/fixtures/patch-pkg/is-positive@1.0.0.patch"
|
||||
);
|
||||
const IS_POSITIVE_PATCH: &str = include_str!("../fixtures/patches/is-positive@1.0.0.patch");
|
||||
|
||||
/// Start an in-process pnpr with the fast-path endpoints on a detached
|
||||
/// thread, allowlisting `registry_url` as a public route so the client may
|
||||
|
|
|
|||
|
|
@ -27,9 +27,8 @@ use std::{
|
|||
path::Path,
|
||||
};
|
||||
|
||||
pub(crate) const IS_POSITIVE_PATCH: &str = include_str!(
|
||||
"../../../../../pnpm11/installing/deps-installer/test/fixtures/patch-pkg/is-positive@1.0.0.patch"
|
||||
);
|
||||
pub(crate) const IS_POSITIVE_PATCH: &str =
|
||||
include_str!("../fixtures/patches/is-positive@1.0.0.patch");
|
||||
|
||||
/// `version` field of the `package.json` under `workspace/relative`.
|
||||
pub(crate) fn version_of(workspace: &Path, relative: &str) -> String {
|
||||
|
|
|
|||
|
|
@ -18,14 +18,7 @@ use tempfile::TempDir;
|
|||
|
||||
fn copy_fixture(name: &str) -> TempDir {
|
||||
let tmp = TempDir::new().expect("create temp dir");
|
||||
let local_fixture = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures").join(name);
|
||||
let fixture_dir = if local_fixture.exists() {
|
||||
local_fixture
|
||||
} else {
|
||||
Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../../../pnpm11/deps/compliance/commands/test/sbom/fixtures")
|
||||
.join(name)
|
||||
};
|
||||
let fixture_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures").join(name);
|
||||
for entry in fs::read_dir(&fixture_dir).expect("read fixture dir") {
|
||||
let entry = entry.expect("read dir entry");
|
||||
let dest = tmp.path().join(entry.file_name());
|
||||
|
|
|
|||
|
|
@ -59,14 +59,14 @@ fn heroku_is_detected_by_its_node_path() {
|
|||
assert!(!detect_ci_with(&[("NODE", "/usr/bin/node")]));
|
||||
}
|
||||
|
||||
/// Every vendor in the `ci-info` release pnpm 11 depends on must be
|
||||
/// detected, so a `ci-info` upgrade that adds a vendor fails here until
|
||||
/// the Rust list catches up.
|
||||
/// Every vendor in the cataloged `ci-info` release must be detected, so a
|
||||
/// `ci-info` upgrade that adds a vendor fails here until the Rust list
|
||||
/// catches up.
|
||||
#[test]
|
||||
fn every_ci_info_vendor_is_detected() {
|
||||
let path = concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/../../../pnpm11/config/reader/node_modules/ci-info/vendors.json",
|
||||
"/../../test-oracles/node_modules/ci-info/vendors.json",
|
||||
);
|
||||
let vendors = std::fs::read_to_string(path)
|
||||
.unwrap_or_else(|error| panic!("read {path} (run `pnpm install`): {error}"));
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -10,20 +10,11 @@ use std::{
|
|||
process::Command,
|
||||
};
|
||||
|
||||
/// The TypeScript CLI asserts its derived flag against the same file
|
||||
/// (`pnpm11/exec/esm-node-path-loader/test/index.ts`), so the two stacks
|
||||
/// cannot drift apart without one of the tests failing.
|
||||
/// `import-flag.txt` is a copy of the golden file pnpm v11 asserts its
|
||||
/// derived flag against, so both CLIs inject the same `NODE_OPTIONS` value.
|
||||
#[test]
|
||||
fn flag_matches_the_golden_copy_shared_with_the_typescript_cli() {
|
||||
let path = concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/../../../pnpm11/exec/esm-node-path-loader/test/import-flag.txt",
|
||||
);
|
||||
let golden = std::fs::read_to_string(path)
|
||||
.unwrap_or_else(|err| {
|
||||
panic!("the golden flag file must be readable at {path}: {err}");
|
||||
});
|
||||
assert_eq!(esm_node_path_loader_import_flag(), golden);
|
||||
fn flag_matches_the_golden_copy_of_the_typescript_cli() {
|
||||
assert_eq!(esm_node_path_loader_import_flag(), include_str!("import-flag.txt"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ fn annotates_an_unmatchable_key_bare() {
|
|||
}
|
||||
|
||||
fn read_reader_source(file: &str) -> String {
|
||||
let path = format!("{}/../../../pnpm11/config/reader/src/{file}", env!("CARGO_MANIFEST_DIR"));
|
||||
let path = format!("{}/tests/fixtures/pnpm11-config-reader/{file}", env!("CARGO_MANIFEST_DIR"));
|
||||
std::fs::read_to_string(&path).unwrap_or_else(|err| panic!("failed to read {path}: {err}"))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
//!
|
||||
//! pnpm is the source of truth (see
|
||||
//! [`pnpm/AGENTS.md`](../../AGENTS.md#the-cardinal-rule)). Its CLI
|
||||
//! defaults live in one object literal, `defaultOptions`, in
|
||||
//! `config/reader/src/index.ts`. This test reads that literal from
|
||||
//! source at test time and compares each value against
|
||||
//! defaults live in one object literal, `defaultOptions`. This test reads
|
||||
//! that literal from a copy of pnpm v11's source,
|
||||
//! `tests/fixtures/pnpm11-config-reader/defaultOptions.ts`, and compares each value against
|
||||
//! [`Config::default()`], so a drift on either side (pnpm changing a
|
||||
//! default, or pacquet hard-coding the wrong one, the
|
||||
//! `dedupeDirectDeps` regression that broke the v11.5.1 release) fails
|
||||
|
|
@ -304,34 +304,20 @@ fn save_workspace_protocol_scalar(value: SaveWorkspaceProtocol) -> Scalar {
|
|||
}
|
||||
}
|
||||
|
||||
/// The `defaultOptions` object literal, sliced out of pnpm's
|
||||
/// config-reader source. Read live so the test tracks pnpm rather than
|
||||
/// a checked-in copy that could silently drift.
|
||||
/// The `defaultOptions` object literal, sliced out of a copy of pnpm
|
||||
/// v11's config-reader source.
|
||||
fn read_pnpm_default_options() -> String {
|
||||
let path = concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/../../../pnpm11/config/reader/src/getConfig/defaultOptions.ts",
|
||||
);
|
||||
let src = std::fs::read_to_string(path)
|
||||
.unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"read pnpm config-reader source at {path}: {err}. \
|
||||
This contract test reads pnpm's `defaultOptions` from the TypeScript \
|
||||
tree; if config/reader moved, update the path.",
|
||||
)
|
||||
});
|
||||
let src = include_str!("../tests/fixtures/pnpm11-config-reader/defaultOptions.ts");
|
||||
let marker = "const defaultOptions: Partial<KebabCaseConfig> = {";
|
||||
let start = src
|
||||
.find(marker)
|
||||
.unwrap_or_else(|| {
|
||||
panic!("`{marker}` not found in config/reader/src/getConfig/defaultOptions.ts")
|
||||
});
|
||||
.unwrap_or_else(|| panic!("`{marker}` not found in defaultOptions.ts"));
|
||||
let body = &src[start + marker.len()..];
|
||||
// The block ends at the first line that is exactly the closing brace
|
||||
// at the object's indentation (`\n}`).
|
||||
let end = body
|
||||
.find("\n}")
|
||||
.expect("unterminated `defaultOptions` object literal in config/reader/src/getConfig/defaultOptions.ts");
|
||||
.expect("unterminated `defaultOptions` object literal in defaultOptions.ts");
|
||||
body[..end].to_string()
|
||||
}
|
||||
|
||||
|
|
@ -463,7 +449,7 @@ fn pacquet_defaults_match_pnpm_cli_defaults() {
|
|||
assert_eq!(
|
||||
pacquet_value, pnpm_value,
|
||||
"default for {key:?} diverges from pnpm: pacquet={pacquet_value:?}, pnpm={pnpm_value:?} \
|
||||
(pnpm source: config/reader/src/index.ts)",
|
||||
(pnpm source: tests/fixtures/pnpm11-config-reader/defaultOptions.ts)",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
118
pnpm/crates/config/tests/fixtures/pnpm11-config-reader/defaultOptions.ts
generated
vendored
Normal file
118
pnpm/crates/config/tests/fixtures/pnpm11-config-reader/defaultOptions.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
import { isCI } from 'ci-info'
|
||||
import isWindows from 'is-windows'
|
||||
|
||||
import { getDefaultWorkspaceConcurrency } from '../concurrency.js'
|
||||
import type { ConfigWithDeprecatedSettings } from '../Config.js'
|
||||
import { npmDefaults } from '../npmDefaults.js'
|
||||
|
||||
type CamelToKebabCase<Name extends string> = Name extends `${infer Head}${infer Rest}`
|
||||
? `${Head extends Lowercase<Head> ? '' : '-'}${Lowercase<Head>}${CamelToKebabCase<Rest>}`
|
||||
: Name
|
||||
|
||||
export type KebabCaseConfig = {
|
||||
[K in keyof ConfigWithDeprecatedSettings as CamelToKebabCase<K>]: ConfigWithDeprecatedSettings[K];
|
||||
}
|
||||
|
||||
export function createDefaultOptions (workspaceDir: string | undefined): Partial<KebabCaseConfig> {
|
||||
return {
|
||||
...defaultOptions,
|
||||
'workspace-concurrency': getDefaultWorkspaceConcurrency(),
|
||||
'workspace-prefix': workspaceDir,
|
||||
'virtual-store-dir-max-length': isWindows() ? 60 : 120,
|
||||
}
|
||||
}
|
||||
|
||||
const defaultOptions: Partial<KebabCaseConfig> = {
|
||||
'auto-install-peers': true,
|
||||
bail: true,
|
||||
'catalog-mode': 'manual',
|
||||
ci: isCI,
|
||||
color: 'auto',
|
||||
'dangerously-allow-all-builds': false,
|
||||
'deploy-all-files': false,
|
||||
'dedupe-peer-dependents': true,
|
||||
'dedupe-peers': false,
|
||||
'dedupe-direct-deps': false,
|
||||
'dedupe-injected-deps': true,
|
||||
'disallow-workspace-cycles': false,
|
||||
'enable-modules-dir': true,
|
||||
'node-experimental-package-map': false,
|
||||
'node-package-map-type': 'standard',
|
||||
'enable-pre-post-scripts': true,
|
||||
'exclude-links-from-lockfile': false,
|
||||
'extend-node-path': true,
|
||||
'fail-if-no-match': false,
|
||||
'fetch-retries': 2,
|
||||
'fetch-retry-factor': 10,
|
||||
'fetch-retry-maxtimeout': 60000,
|
||||
'fetch-retry-mintimeout': 10000,
|
||||
'fetch-timeout': 60000,
|
||||
'fetch-warn-timeout-ms': 10_000, // 10 sec
|
||||
'fetch-min-speed-ki-bps': 50, // 50 KiB/s
|
||||
'max-tarball-unpacked-size': 4294967296, // 4 GiB
|
||||
'force-ignores-platform': true,
|
||||
'force-legacy-deploy': false,
|
||||
'git-shallow-hosts': [
|
||||
// Follow https://github.com/npm/git/blob/1e1dbd26bd5b87ca055defecc3679777cb480e2a/lib/clone.js#L13-L19
|
||||
'github.com',
|
||||
'gist.github.com',
|
||||
'gitlab.com',
|
||||
'bitbucket.com',
|
||||
'bitbucket.org',
|
||||
],
|
||||
'git-branch-lockfile': false,
|
||||
hoist: true,
|
||||
'hoist-pattern': ['*'],
|
||||
'hoist-workspace-packages': true,
|
||||
'ignore-workspace-cycles': false,
|
||||
'ignore-workspace-root-check': false,
|
||||
'optimistic-repeat-install': true,
|
||||
optional: true,
|
||||
'init-package-manager': true,
|
||||
'init-type': 'module',
|
||||
'inject-workspace-packages': false,
|
||||
'link-workspace-packages': false,
|
||||
'lockfile-include-tarball-url': false,
|
||||
'minimum-release-age': 24 * 60, // 1 day
|
||||
'minimum-release-age-ignore-missing-time': true,
|
||||
'modules-cache-max-age': 7 * 24 * 60, // 7 days
|
||||
'dlx-cache-max-age': 24 * 60, // 1 day
|
||||
'node-linker': 'isolated',
|
||||
'package-lock': npmDefaults['package-lock'],
|
||||
pending: false,
|
||||
'prefer-workspace-packages': false,
|
||||
'public-hoist-pattern': [],
|
||||
'recursive-install': true,
|
||||
registry: npmDefaults.registry,
|
||||
'block-exotic-subdeps': true,
|
||||
'resolution-mode': 'highest',
|
||||
'resolve-peers-from-workspace-root': true,
|
||||
'save-peer': false,
|
||||
'save-catalog-name': undefined,
|
||||
'save-workspace-protocol': 'rolling',
|
||||
'scripts-prepend-node-path': false,
|
||||
'strict-dep-builds': true,
|
||||
'side-effects-cache': true,
|
||||
symlink: true,
|
||||
'shared-workspace-lockfile': true,
|
||||
'shell-emulator': false,
|
||||
'strict-store-pkg-content-check': true,
|
||||
reverse: false,
|
||||
sort: true,
|
||||
'strict-peer-dependencies': false,
|
||||
'unsafe-perm': npmDefaults['unsafe-perm'],
|
||||
'use-beta-cli': false,
|
||||
userconfig: npmDefaults.userconfig,
|
||||
'verify-deps-before-run': 'install',
|
||||
'verify-store-integrity': true,
|
||||
'frozen-store': false,
|
||||
'workspace-concurrency': 4,
|
||||
'workspace-prefix': undefined,
|
||||
'embed-readme': false,
|
||||
'skip-manifest-obfuscation': false,
|
||||
'registry-supports-time-field': false,
|
||||
'virtual-store-dir-max-length': 120,
|
||||
'virtual-store-only': false,
|
||||
'peers-suffix-max-length': 1000,
|
||||
}
|
||||
|
||||
73
pnpm/crates/config/tests/fixtures/pnpm11-config-reader/npmConfigTypes.ts
generated
vendored
Normal file
73
pnpm/crates/config/tests/fixtures/pnpm11-config-reader/npmConfigTypes.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
import path from 'node:path'
|
||||
import url from 'node:url'
|
||||
|
||||
// Subset of npm config type definitions that pnpm actually uses.
|
||||
export const npmConfigTypes = {
|
||||
access: [null, 'restricted', 'public'],
|
||||
'allow-same-version': Boolean,
|
||||
'bin-links': Boolean,
|
||||
ca: [null, String, Array],
|
||||
cafile: path,
|
||||
cert: [null, String],
|
||||
'commit-hooks': Boolean,
|
||||
depth: Number,
|
||||
description: Boolean,
|
||||
dev: Boolean,
|
||||
'dry-run': Boolean,
|
||||
'engine-strict': Boolean,
|
||||
'fetch-retries': Number,
|
||||
'fetch-retry-factor': Number,
|
||||
'fetch-retry-mintimeout': Number,
|
||||
'fetch-retry-maxtimeout': Number,
|
||||
force: Boolean,
|
||||
git: String,
|
||||
'git-tag-version': Boolean,
|
||||
global: Boolean,
|
||||
'https-proxy': [null, url],
|
||||
'ignore-scripts': Boolean,
|
||||
'init-author-name': String,
|
||||
'init-author-email': String,
|
||||
'init-author-url': ['', url],
|
||||
'init-license': String,
|
||||
'init-version': String,
|
||||
json: Boolean,
|
||||
key: [null, String],
|
||||
'local-address': String,
|
||||
long: Boolean,
|
||||
maxsockets: Number,
|
||||
message: String,
|
||||
'node-options': [null, String],
|
||||
'node-version': [null, String],
|
||||
'no-proxy': [null, String, Array],
|
||||
offline: Boolean,
|
||||
only: [null, 'dev', 'development', 'prod', 'production'],
|
||||
optional: Boolean,
|
||||
otp: [null, String],
|
||||
'package-lock': Boolean,
|
||||
parseable: Boolean,
|
||||
'prefer-offline': Boolean,
|
||||
prefix: path,
|
||||
production: Boolean,
|
||||
progress: Boolean,
|
||||
provenance: Boolean,
|
||||
proxy: [null, false, url],
|
||||
registry: [null, url],
|
||||
save: Boolean,
|
||||
'save-dev': Boolean,
|
||||
'save-exact': Boolean,
|
||||
'save-optional': Boolean,
|
||||
'save-prefix': String,
|
||||
'save-prod': Boolean,
|
||||
scope: String,
|
||||
'script-shell': [null, String],
|
||||
'scripts-prepend-node-path': [false, true, 'auto', 'warn-only'],
|
||||
'sign-git-tag': Boolean,
|
||||
'strict-ssl': Boolean,
|
||||
tag: String,
|
||||
'tag-version-prefix': String,
|
||||
'unsafe-perm': Boolean,
|
||||
'user-agent': String,
|
||||
userconfig: path,
|
||||
umask: Number,
|
||||
version: Boolean,
|
||||
}
|
||||
169
pnpm/crates/config/tests/fixtures/pnpm11-config-reader/types.ts
generated
vendored
Normal file
169
pnpm/crates/config/tests/fixtures/pnpm11-config-reader/types.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
import path from 'node:path'
|
||||
|
||||
import type { TrustPolicy } from '@pnpm/types'
|
||||
|
||||
import { npmConfigTypes } from './npmConfigTypes.js'
|
||||
|
||||
export const pnpmTypes = {
|
||||
'auto-install-peers': Boolean,
|
||||
bail: Boolean,
|
||||
ci: Boolean,
|
||||
'cache-dir': String,
|
||||
'catalog-mode': ['strict', 'prefer', 'manual'],
|
||||
'child-concurrency': Number,
|
||||
'merge-git-branch-lockfiles': Boolean,
|
||||
'merge-git-branch-lockfiles-branch-pattern': Array,
|
||||
color: [Boolean, 'always', 'auto', 'never'],
|
||||
'config-dir': String,
|
||||
'dangerously-allow-all-builds': Boolean,
|
||||
'deploy-all-files': Boolean,
|
||||
'dedupe-peer-dependents': Boolean,
|
||||
'dedupe-peers': Boolean,
|
||||
'dedupe-direct-deps': Boolean,
|
||||
'dedupe-injected-deps': Boolean,
|
||||
dev: [null, true],
|
||||
dir: String,
|
||||
'disallow-workspace-cycles': Boolean,
|
||||
'enable-modules-dir': Boolean,
|
||||
'enable-pre-post-scripts': Boolean,
|
||||
'enable-global-virtual-store': Boolean,
|
||||
'exclude-links-from-lockfile': Boolean,
|
||||
'extend-node-path': Boolean,
|
||||
'fetch-timeout': Number,
|
||||
'fetch-warn-timeout-ms': Number,
|
||||
'fetch-min-speed-ki-bps': Number,
|
||||
'max-tarball-unpacked-size': Number,
|
||||
'fetching-concurrency': Number,
|
||||
filter: [String, Array],
|
||||
'filter-prod': [String, Array],
|
||||
'force-ignores-platform': Boolean,
|
||||
'force-legacy-deploy': Boolean,
|
||||
'frozen-lockfile': Boolean,
|
||||
'git-checks': Boolean,
|
||||
'git-shallow-hosts': Array,
|
||||
'global-bin-dir': String,
|
||||
'global-dir': String,
|
||||
'global-path': String,
|
||||
'global-pnpmfile': String,
|
||||
'git-branch-lockfile': Boolean,
|
||||
hoist: Boolean,
|
||||
'http-proxy': [null, String],
|
||||
'hoist-pattern': Array,
|
||||
'hoist-workspace-packages': Boolean,
|
||||
'hoisting-limits': ['none', 'workspaces', 'dependencies'],
|
||||
'ignore-compatibility-db': Boolean,
|
||||
'ignore-pnpmfile': Boolean,
|
||||
'ignore-workspace': Boolean,
|
||||
'ignore-workspace-cycles': Boolean,
|
||||
'ignore-workspace-root-check': Boolean,
|
||||
'optimistic-repeat-install': Boolean,
|
||||
'include-workspace-root': Boolean,
|
||||
'init-package-manager': Boolean,
|
||||
'init-type': ['commonjs', 'module'],
|
||||
'inject-workspace-packages': Boolean,
|
||||
'legacy-dir-filtering': Boolean,
|
||||
'link-workspace-packages': [Boolean, 'deep'],
|
||||
lockfile: Boolean,
|
||||
'lockfile-dir': String,
|
||||
'lockfile-include-tarball-url': Boolean,
|
||||
'lockfile-only': Boolean,
|
||||
loglevel: ['silent', 'error', 'warn', 'info', 'debug'],
|
||||
maxsockets: Number,
|
||||
'modules-cache-max-age': Number,
|
||||
'dlx-cache-max-age': Number,
|
||||
'minimum-release-age': Number,
|
||||
'minimum-release-age-exclude': [String, Array],
|
||||
'minimum-release-age-ignore-missing-time': Boolean,
|
||||
'minimum-release-age-strict': Boolean,
|
||||
'modules-dir': String,
|
||||
'network-concurrency': Number,
|
||||
'node-download-mirrors': Object,
|
||||
'node-experimental-package-map': Boolean,
|
||||
'node-package-map-type': ['standard', 'loose'],
|
||||
'node-linker': ['pnp', 'isolated', 'hoisted'],
|
||||
noproxy: String,
|
||||
'npm-path': String,
|
||||
'npmrc-auth-file': path,
|
||||
offline: Boolean,
|
||||
'pack-destination': String,
|
||||
'pack-gzip-level': Number,
|
||||
'package-import-method': ['auto', 'hardlink', 'clone', 'copy'],
|
||||
'patches-dir': String,
|
||||
pnpmfile: String,
|
||||
'pm-on-fail': ['download', 'error', 'warn', 'ignore'],
|
||||
'prefer-frozen-lockfile': Boolean,
|
||||
'prefer-offline': Boolean,
|
||||
'prefer-symlinked-executables': Boolean,
|
||||
'prefer-workspace-packages': Boolean,
|
||||
'preserve-absolute-paths': Boolean,
|
||||
production: [null, true],
|
||||
'public-hoist-pattern': Array,
|
||||
'publish-branch': String,
|
||||
'recursive-install': Boolean,
|
||||
'block-exotic-subdeps': Boolean,
|
||||
reporter: String,
|
||||
'resolution-mode': ['highest', 'time-based', 'lowest-direct'],
|
||||
'resolve-peers-from-workspace-root': Boolean,
|
||||
runtime: Boolean,
|
||||
'runtime-on-fail': ['ignore', 'warn', 'error', 'download'],
|
||||
'aggregate-output': Boolean,
|
||||
'reporter-hide-prefix': Boolean,
|
||||
'save-peer': Boolean,
|
||||
'save-catalog-name': String,
|
||||
'save-workspace-protocol': Boolean,
|
||||
'script-shell': String,
|
||||
'shamefully-hoist': Boolean,
|
||||
'shared-workspace-lockfile': Boolean,
|
||||
'shell-emulator': Boolean,
|
||||
'side-effects-cache': Boolean,
|
||||
'side-effects-cache-readonly': Boolean,
|
||||
symlink: Boolean,
|
||||
sort: Boolean,
|
||||
'state-dir': String,
|
||||
'store-dir': String,
|
||||
stream: Boolean,
|
||||
'strict-dep-builds': Boolean,
|
||||
'strict-store-pkg-content-check': Boolean,
|
||||
'strict-peer-dependencies': Boolean,
|
||||
'trust-lockfile': Boolean,
|
||||
'trust-policy': ['off', 'no-downgrade'] satisfies TrustPolicy[],
|
||||
'trust-policy-exclude': [String, Array],
|
||||
'trust-policy-ignore-after': Number,
|
||||
'use-beta-cli': Boolean,
|
||||
'use-stderr': Boolean,
|
||||
'verify-deps-before-run': [Boolean, 'install', 'warn', 'error', 'prompt'],
|
||||
'verify-store-integrity': Boolean,
|
||||
'frozen-store': Boolean,
|
||||
'global-virtual-store-dir': String,
|
||||
'virtual-store-dir': String,
|
||||
'virtual-store-only': Boolean,
|
||||
'virtual-store-type': ['global', 'project'],
|
||||
'virtual-store-dir-max-length': Number,
|
||||
'peers-suffix-max-length': Number,
|
||||
'workspace-concurrency': Number,
|
||||
'workspace-packages': [String, Array],
|
||||
'workspace-root': Boolean,
|
||||
yes: Boolean,
|
||||
'test-pattern': [String, Array],
|
||||
'changed-files-ignore-pattern': [String, Array],
|
||||
'embed-readme': Boolean,
|
||||
'skip-manifest-obfuscation': Boolean,
|
||||
'update-notifier': Boolean,
|
||||
'pnpr-server': [null, String],
|
||||
'registry-supports-time-field': Boolean,
|
||||
'fail-if-no-match': Boolean,
|
||||
'sync-injected-deps-after-scripts': Array,
|
||||
cpu: [String, Array],
|
||||
libc: [String, Array],
|
||||
os: [String, Array],
|
||||
'audit-level': ['low', 'moderate', 'high', 'critical'],
|
||||
}
|
||||
|
||||
// NOTE: pnpmTypes contains some field that overlaps with that of `npmTypes.types`. The definitions of such fields are pointless as they are overwritten by
|
||||
// `npmTypes.types` anyway.
|
||||
// TODO: Fix this overlap later.
|
||||
// TODO: After that, move `...pnpmTypes` down, `...npmTypes.types` up.
|
||||
export const types = {
|
||||
...pnpmTypes,
|
||||
...npmConfigTypes,
|
||||
}
|
||||
198
pnpm/crates/config/tests/fixtures/pnpm11-config-reader/unknownSettings.ts
generated
vendored
Normal file
198
pnpm/crates/config/tests/fixtures/pnpm11-config-reader/unknownSettings.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
import { redactAndSanitize } from '@pnpm/error'
|
||||
import type { WorkspaceManifest } from '@pnpm/workspace.workspace-manifest-reader'
|
||||
import camelcase from 'camelcase'
|
||||
import didYouMean, { ReturnTypeEnums } from 'didyoumean2'
|
||||
|
||||
import type { ConfigWithDeprecatedSettings } from './Config.js'
|
||||
import { types } from './types.js'
|
||||
|
||||
/**
|
||||
* The structured settings of `pnpm-workspace.yaml`, which have no entry in
|
||||
* {@link types} because they never come in through a CLI flag.
|
||||
*/
|
||||
const TYPED_WORKSPACE_MANIFEST_KEYS = [
|
||||
'allowBuilds',
|
||||
'allowUnusedPatches',
|
||||
'allowedDeprecatedVersions',
|
||||
'audit',
|
||||
'auditConfig',
|
||||
'autoInstallPeersFromHighestMatch',
|
||||
'catalog',
|
||||
'catalogs',
|
||||
'configDependencies',
|
||||
'enableGlobalVirtualStore',
|
||||
'externalDependencies',
|
||||
'httpProxy',
|
||||
'httpsProxy',
|
||||
'ignoredOptionalDependencies',
|
||||
'localAddress',
|
||||
'namedRegistries',
|
||||
'nodeDownloadMirrors',
|
||||
'noProxy',
|
||||
'npmrcAuthFile',
|
||||
'overrides',
|
||||
'packageExtensions',
|
||||
'packages',
|
||||
'patchedDependencies',
|
||||
'peerDependencyRules',
|
||||
'pnprServer',
|
||||
'registries',
|
||||
'remoteSideEffectsCache',
|
||||
'requiredScripts',
|
||||
'sideEffectsCache',
|
||||
'strictSsl',
|
||||
'supportedArchitectures',
|
||||
'tasks',
|
||||
'update',
|
||||
'updateConfig',
|
||||
'versioning',
|
||||
'virtualStoreType',
|
||||
] as const satisfies ReadonlyArray<keyof WorkspaceManifest>
|
||||
|
||||
type ProofTypedWorkspaceManifestKeysAreExhaustive =
|
||||
(_: Record<typeof TYPED_WORKSPACE_MANIFEST_KEYS[number], unknown>) => Record<keyof WorkspaceManifest, unknown>
|
||||
|
||||
const _proofTypedWorkspaceManifestKeysAreExhaustive: ProofTypedWorkspaceManifestKeysAreExhaustive = (record) => record
|
||||
|
||||
/**
|
||||
* The {@link ConfigWithDeprecatedSettings} fields that neither {@link types}
|
||||
* nor {@link TYPED_WORKSPACE_MANIFEST_KEYS} carries: settings whose only
|
||||
* spelling is a camelCase config field (e.g. `catalogPrune`), and the reader's
|
||||
* own derived fields. {@link ProofKnownSettingKeysCoverConfig} forces a new
|
||||
* config field to be added here, so a setting introduced later cannot start
|
||||
* out being reported as unrecognized.
|
||||
*/
|
||||
const CONFIG_ONLY_SETTING_KEYS = [
|
||||
'allowNew',
|
||||
'auditIgnorePrune',
|
||||
'authConfig',
|
||||
'autoConfirmAllPrompts',
|
||||
'bin',
|
||||
'catalogPrune',
|
||||
'cleanupUnusedCatalogs',
|
||||
'configByUri',
|
||||
'enablePnp',
|
||||
'extraBinPaths',
|
||||
'extraEnv',
|
||||
'globalPkgDir',
|
||||
'globalPrefix',
|
||||
'ignoreCurrentSpecifiers',
|
||||
'maxSockets',
|
||||
'minimumReleaseAgeExcludePrune',
|
||||
'modulesDirsByProjectName',
|
||||
'packageConfigs',
|
||||
'packageManagerNetworkConfig',
|
||||
'packageManagerRegistries',
|
||||
'pending',
|
||||
'pnpmExecPath',
|
||||
'pnpmHomeDir',
|
||||
'recursive',
|
||||
'registriesByPrefix',
|
||||
'registriesByScope',
|
||||
'registryOptionsByUrl',
|
||||
'reverse',
|
||||
'sideEffectsCacheRead',
|
||||
'sideEffectsCacheWrite',
|
||||
'trustPolicyExcludePrune',
|
||||
'tryLoadDefaultPnpmfile',
|
||||
'useGitBranchLockfile',
|
||||
'useLockfile',
|
||||
'useRunningStoreServer',
|
||||
'useStoreServer',
|
||||
'userConfig',
|
||||
'workspaceDir',
|
||||
'workspacePackagePatterns',
|
||||
'workspacePrefix',
|
||||
] as const satisfies ReadonlyArray<keyof ConfigWithDeprecatedSettings>
|
||||
|
||||
const UNTYPED_WORKSPACE_SETTING_KEYS = [
|
||||
'confirmModulesPurge',
|
||||
'executionEnv',
|
||||
'ignoredBuiltDependencies',
|
||||
'neverBuiltDependencies',
|
||||
'onlyBuiltDependencies',
|
||||
'onlyBuiltDependenciesFile',
|
||||
]
|
||||
|
||||
type KebabToCamelCase<Name extends string> = Name extends `${infer Head}-${infer Rest}`
|
||||
? `${Head}${Capitalize<KebabToCamelCase<Rest>>}`
|
||||
: Name
|
||||
|
||||
type KnownSettingKey =
|
||||
| KebabToCamelCase<keyof typeof types & string>
|
||||
| typeof TYPED_WORKSPACE_MANIFEST_KEYS[number]
|
||||
| typeof CONFIG_ONLY_SETTING_KEYS[number]
|
||||
|
||||
type ProofKnownSettingKeysCoverConfig =
|
||||
(_: Record<KnownSettingKey, unknown>) => Record<keyof ConfigWithDeprecatedSettings, unknown>
|
||||
|
||||
const _proofKnownSettingKeysCoverConfig: ProofKnownSettingKeysCoverConfig = (record) => record
|
||||
|
||||
const KNOWN_SETTING_KEYS: ReadonlySet<string> = new Set([
|
||||
...TYPED_WORKSPACE_MANIFEST_KEYS,
|
||||
...CONFIG_ONLY_SETTING_KEYS,
|
||||
...UNTYPED_WORKSPACE_SETTING_KEYS,
|
||||
...Object.keys(types).map((key) => camelcase(key, { locale: 'en-US' })),
|
||||
])
|
||||
|
||||
/**
|
||||
* Whether {@link key}, given in either camelCase or kebab-case, names a
|
||||
* setting this version of pnpm reads from at least one config source. A key
|
||||
* failing this check is a typo or belongs to a different pnpm version, so it
|
||||
* gets {@link quoteAndAnnotateUnknown}'s warning instead of advice to move it
|
||||
* to another config file.
|
||||
*/
|
||||
export function isKnownSettingKey (key: string): boolean {
|
||||
return KNOWN_SETTING_KEYS.has(camelcase(key, { locale: 'en-US' }))
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings recognized by other supported pnpm release lines but not by this
|
||||
* one, so the warning can name the version that reads the key instead of
|
||||
* guessing at a typo. Maintained by hand: the lines are developed together in
|
||||
* this repository, so a line-exclusive setting is known at build time.
|
||||
*/
|
||||
const SETTINGS_OF_OTHER_PNPM_VERSIONS: Record<string, string> = {
|
||||
addMissingPeerTypes: 'pnpm v12',
|
||||
autoDedupe: 'pnpm v12',
|
||||
bootConfig: 'pnpm v12',
|
||||
cargo: 'pnpm v12',
|
||||
concurrencyGroups: 'pnpm v12',
|
||||
editor: 'pnpm v12',
|
||||
globalPackagesConfig: 'pnpm v12',
|
||||
globalShims: 'pnpm v12',
|
||||
macosBackup: 'pnpm v12',
|
||||
referenceTime: 'pnpm v12',
|
||||
nodePackageMap: 'pnpm v12',
|
||||
permissions: 'pnpm v12',
|
||||
pipelineBase: 'pnpm v12',
|
||||
pipelines: 'pnpm v12',
|
||||
projectScopedOptionalPeers: 'pnpm v12',
|
||||
publishWaitTimeout: 'pnpm v12',
|
||||
python: 'pnpm v12',
|
||||
remoteCache: 'pnpm v12',
|
||||
saveTypes: 'pnpm v12',
|
||||
skills: 'pnpm v12',
|
||||
storeIndexFormat: 'pnpm v12',
|
||||
symlinkedLockfileTargetDirs: 'pnpm v12',
|
||||
tools: 'pnpm v12',
|
||||
warnUnusedOverrides: 'pnpm v12',
|
||||
}
|
||||
|
||||
const KNOWN_SETTING_KEYS_LIST = [...KNOWN_SETTING_KEYS]
|
||||
|
||||
/**
|
||||
* Renders unrecognized keys for a warning. The key comes from a config file a
|
||||
* repository may control, so it is sanitized before it reaches a terminal or a
|
||||
* CI log; the suggestion is one of pnpm's own setting names.
|
||||
*/
|
||||
export function quoteAndAnnotateUnknown (keys: string[]): string {
|
||||
return keys.map((key) => {
|
||||
const sanitized = redactAndSanitize(key)
|
||||
const camelKey = camelcase(sanitized, { locale: 'en-US' })
|
||||
const otherVersion = SETTINGS_OF_OTHER_PNPM_VERSIONS[camelKey]
|
||||
if (otherVersion) return `"${sanitized}" (a ${otherVersion} setting)`
|
||||
const suggestion = didYouMean(camelKey, KNOWN_SETTING_KEYS_LIST, { returnType: ReturnTypeEnums.FIRST_CLOSEST_MATCH })
|
||||
return suggestion ? `"${sanitized}" (did you mean "${suggestion}"?)` : `"${sanitized}"`
|
||||
}).join(', ')
|
||||
}
|
||||
|
|
@ -6,49 +6,10 @@ import readline from 'node:readline'
|
|||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const repoRoot = path.resolve(__dirname, '../../../../..')
|
||||
const packlistPkgDir = path.join(repoRoot, 'pnpm11/fs/packlist')
|
||||
const requireFromPacklist = module.createRequire(path.join(packlistPkgDir, 'package.json'))
|
||||
const npmPacklist = requireFromPacklist('npm-packlist')
|
||||
|
||||
function findWorkspaceTsEntry (specifier, parentURL) {
|
||||
let dir = parentURL?.startsWith('file:')
|
||||
? path.dirname(fileURLToPath(parentURL))
|
||||
: packlistPkgDir
|
||||
while (true) {
|
||||
const candidate = path.join(dir, 'node_modules', specifier, 'src/index.ts')
|
||||
if (fs.existsSync(candidate)) {
|
||||
return fs.realpathSync(candidate)
|
||||
}
|
||||
const parent = path.dirname(dir)
|
||||
if (parent === dir) return null
|
||||
dir = parent
|
||||
}
|
||||
}
|
||||
|
||||
async function loadPnpmPacklist () {
|
||||
module.registerHooks({
|
||||
resolve (specifier, context, nextResolve) {
|
||||
if (specifier.startsWith('.') && specifier.endsWith('.js') && context.parentURL?.startsWith('file:')) {
|
||||
const candidate = path.resolve(path.dirname(fileURLToPath(context.parentURL)), specifier.slice(0, -3) + '.ts')
|
||||
if (fs.existsSync(candidate)) {
|
||||
return { url: pathToFileURL(fs.realpathSync(candidate)).href, shortCircuit: true }
|
||||
}
|
||||
}
|
||||
if (specifier.startsWith('@pnpm/')) {
|
||||
const candidate = findWorkspaceTsEntry(specifier, context.parentURL)
|
||||
if (candidate != null) {
|
||||
return { url: pathToFileURL(candidate).href, shortCircuit: true }
|
||||
}
|
||||
}
|
||||
return nextResolve(specifier, context)
|
||||
},
|
||||
})
|
||||
const mod = await import(pathToFileURL(path.join(packlistPkgDir, 'src/index.ts')).href)
|
||||
return mod.packlist
|
||||
}
|
||||
|
||||
const packlist = await loadPnpmPacklist()
|
||||
const oraclesDir = path.resolve(__dirname, '../../../../test-oracles')
|
||||
const requireFromOracles = module.createRequire(path.join(oraclesDir, 'package.json'))
|
||||
const npmPacklist = requireFromOracles('npm-packlist')
|
||||
const { packlist } = await import(pathToFileURL(requireFromOracles.resolve('@pnpm/fs.packlist')).href)
|
||||
const normalize = (list) => list.map((entry) => entry.replaceAll('\\', '/').replace(/^\.\//, '')).sort()
|
||||
|
||||
function normalizeNpmTreePackage (manifest) {
|
||||
|
|
|
|||
|
|
@ -928,9 +928,9 @@ fn pack_matches_npm_pack_dry_run() {
|
|||
}
|
||||
|
||||
// 2. A slice of real packages (from node_modules and workspace packages)
|
||||
let repo_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../..");
|
||||
let pnpm_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
|
||||
let npm_packlist_dir =
|
||||
fs::canonicalize(repo_root.join("pnpm11/fs/packlist/node_modules/npm-packlist"))
|
||||
fs::canonicalize(pnpm_root.join("test-oracles/node_modules/npm-packlist"))
|
||||
.expect("canonicalize npm-packlist");
|
||||
let npm_packlist_nm = npm_packlist_dir.parent().expect("npm-packlist node_modules");
|
||||
let ignore_walk_dir =
|
||||
|
|
@ -945,9 +945,9 @@ fn pack_matches_npm_pack_dry_run() {
|
|||
ignore_walk_dir,
|
||||
proc_log_dir,
|
||||
minimatch_dir,
|
||||
repo_root.join("pnpm11/fs/packlist"),
|
||||
repo_root.join("pnpm11/crypto/hash"),
|
||||
repo_root.join("pnpm11/text/comments-parser"),
|
||||
pnpm_root.join("npm/get-pnpm"),
|
||||
pnpm_root.join("npm/napi"),
|
||||
pnpm_root.join("esm-loader"),
|
||||
];
|
||||
|
||||
for (idx, candidate) in real_candidates.iter().enumerate() {
|
||||
|
|
|
|||
6
pnpm/npm/pnpm/node-gyp-bin/node-gyp
Executable file
6
pnpm/npm/pnpm/node-gyp-bin/node-gyp
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env sh
|
||||
if [ "x$npm_config_node_gyp" = "x" ]; then
|
||||
node "`dirname "$0"`/../node_modules/node-gyp/bin/node-gyp.js" "$@"
|
||||
else
|
||||
"$npm_config_node_gyp" "$@"
|
||||
fi
|
||||
5
pnpm/npm/pnpm/node-gyp-bin/node-gyp.cmd
Normal file
5
pnpm/npm/pnpm/node-gyp-bin/node-gyp.cmd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
if not defined npm_config_node_gyp (
|
||||
node "%~dp0\..\node_modules\node-gyp\bin\node-gyp.js" %*
|
||||
) else (
|
||||
node "%npm_config_node_gyp%" %*
|
||||
)
|
||||
|
|
@ -23,9 +23,8 @@
|
|||
// depends on it as `workspace:~`, not `workspace:*`: an exact range would make
|
||||
// every get-pnpm release force a pnpm release too.
|
||||
//
|
||||
// The TypeScript CLI builds the same payload for its own package in
|
||||
// pnpm11/pnpm/bundle-deps.ts, and both read the node-gyp version from the
|
||||
// `node-gyp` catalog entry, so the two stacks ship the same node-gyp.
|
||||
// The TypeScript CLI builds the same payload for its own package, and both
|
||||
// read the node-gyp version from the `node-gyp` catalog entry.
|
||||
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import console from 'node:console'
|
||||
|
|
@ -39,9 +38,7 @@ const REPO_ROOT = path.resolve(PNPM_ROOT, '../../..')
|
|||
const DEPLOY_DIR = path.join(PNPM_ROOT, 'temp-deploy')
|
||||
const DIST_DIR = path.join(PNPM_ROOT, 'dist')
|
||||
|
||||
// The wrappers are shared with the TypeScript CLI rather than copied, so the
|
||||
// two stacks cannot drift on how a script's `node-gyp` is dispatched.
|
||||
const NODE_GYP_BIN_SRC = path.join(REPO_ROOT, 'pnpm11', 'pnpm', 'node-gyp-bin')
|
||||
const NODE_GYP_BIN_SRC = path.join(PNPM_ROOT, 'node-gyp-bin')
|
||||
|
||||
function deployNodeGyp () {
|
||||
fs.rmSync(DEPLOY_DIR, { recursive: true, force: true })
|
||||
|
|
|
|||
|
|
@ -30,12 +30,14 @@ const WORKSPACE_WIDE = [
|
|||
* Cargo attributes a file to the manifest above it, so these would otherwise
|
||||
* be attributed to no crate at all and report that nothing changed.
|
||||
*/
|
||||
const ORACLE_CONSUMERS = ['pnpm-cli', 'pnpm-config', 'pnpm-fs-packlist']
|
||||
const EXTERNAL_TEST_INPUTS = [
|
||||
{ prefix: 'fixtures/gvs-link-hash-parity.json', packages: ['pnpm-deps-restorer'] },
|
||||
{ prefix: 'fixtures/pin-decision.json', packages: ['pnpm-cli', 'pnpm-config'] },
|
||||
{ prefix: 'pnpm11/config/reader/src/', packages: ['pnpm-config'] },
|
||||
{ prefix: 'pnpm11/installing/deps-installer/test/fixtures/patch-pkg/', packages: ['pnpm-cli'] },
|
||||
{ prefix: 'pnpm11/deps/compliance/commands/test/sbom/fixtures/', packages: ['pnpm-cli'] },
|
||||
{ prefix: 'pnpm/test-oracles/', packages: ORACLE_CONSUMERS },
|
||||
// The oracles' versions come from the catalog and are locked here.
|
||||
{ prefix: '.config/pnpm/catalog.yaml', packages: ORACLE_CONSUMERS },
|
||||
{ prefix: 'pnpm-lock.yaml', packages: ORACLE_CONSUMERS },
|
||||
]
|
||||
|
||||
export function workspaceWideChanges (files) {
|
||||
|
|
|
|||
|
|
@ -47,10 +47,9 @@ test('prefers the closest crate for a nested manifest', () => {
|
|||
test('selects the crates that read a fixture stored outside them', () => {
|
||||
assert.deepEqual(selectPackages(['fixtures/gvs-link-hash-parity.json'], manifests), ['pnpm-deps-restorer'])
|
||||
assert.deepEqual(selectPackages(['fixtures/pin-decision.json'], manifests), ['pnpm-cli', 'pnpm-config'])
|
||||
assert.deepEqual(selectPackages(['pnpm11/config/reader/src/unknownSettings.ts'], manifests), ['pnpm-config'])
|
||||
assert.deepEqual(
|
||||
selectPackages(['pnpm11/installing/deps-installer/test/fixtures/patch-pkg/is-positive@1.0.0.patch'], manifests),
|
||||
['pnpm-cli'])
|
||||
for (const oracleInput of ['pnpm/test-oracles/package.json', '.config/pnpm/catalog.yaml', 'pnpm-lock.yaml']) {
|
||||
assert.deepEqual(selectPackages([oracleInput], manifests), ['pnpm-cli', 'pnpm-config', 'pnpm-fs-packlist'])
|
||||
}
|
||||
})
|
||||
|
||||
test('refuses to scope a change to the mocked registry packages', () => {
|
||||
|
|
|
|||
12
pnpm/test-oracles/package.json
Normal file
12
pnpm/test-oracles/package.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "@pnpm-private/test-oracles",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"description": "Published packages that Rust tests compare pnpm against",
|
||||
"devDependencies": {
|
||||
"@pnpm/fs.packlist": "1100.0.15",
|
||||
"ci-info": "catalog:",
|
||||
"npm-packlist": "catalog:",
|
||||
"pnpm-v11": "npm:pnpm@11.29.0"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue