From 9de6c546b01911203cae839c5d50781506dfe8c7 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 14 Aug 2026 21:18:21 +0000 Subject: [PATCH 1/3] Harden the pnpm conversion against Pegma-wide review findings. Keep pack, registry view, and trusted-publisher publish on a real npm CLI even when invoked through pnpm run. Match each public-package lockfile dependency to its own specifier and resolved version. Install pnpm before setup-node cache, drop Corepack from the OIDC publish job, and document corepack enable plus the npm-era bootstrap tag. Co-authored-by: Fly Over Coder --- .github/workflows/ci.yml | 9 +++-- .github/workflows/publish.yml | 5 +-- CONTRIBUTING.md | 1 + README.md | 1 + docs/RELEASING.md | 14 +++++--- scripts/release-packages.d.mts | 8 +++++ scripts/release-packages.mjs | 62 +++++++++++++++++++++++++++------- tests/release-packages.test.ts | 61 +++++++++++++++++++++++++++++++++ 8 files changed, 135 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec8e755..de0483a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,8 +28,10 @@ jobs: - name: Check out repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - - name: Enable Corepack - run: corepack enable + - name: Set up pnpm + uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10 + with: + version: 10.34.5 - name: Set up Node.js uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7 @@ -37,9 +39,6 @@ jobs: node-version: ${{ matrix.node-version }} cache: pnpm - - name: Activate pnpm - run: corepack enable - - name: Install dependencies run: pnpm install --frozen-lockfile diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a7ad2a8..25acea2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -113,9 +113,6 @@ jobs: registry-url: https://registry.npmjs.org package-manager-cache: false - - name: Enable Corepack - run: corepack enable - - name: Use the reviewed npm release run: npm install --global npm@11.18.0 @@ -126,4 +123,4 @@ jobs: path: .release - name: Publish verified prepared tarballs - run: pnpm run release:publish -- --expected-release-commit "${RELEASE_COMMIT}" --manifest .release/package-manifest.json + run: node scripts/release-packages.mjs publish --expected-release-commit "${RELEASE_COMMIT}" --manifest .release/package-manifest.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6e3db45..aa8887d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,6 +3,7 @@ Scheduler requires Node.js 22 or newer. ```sh +corepack enable pnpm install --frozen-lockfile pnpm run format:check pnpm run check diff --git a/README.md b/README.md index 8653e01..2ac34e9 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ The first consumers are: ## Development ```sh +corepack enable pnpm install --frozen-lockfile pnpm run format:check pnpm run check diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 2ff210d..aa3b4c2 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -3,7 +3,8 @@ There are exactly two publication paths: 1. a one-time manual bootstrap of `@pegma/scheduler@0.0.0` and - `@pegma/scheduler-cloudflare@0.0.0` (**done**; dist-tag `bootstrap` only); and + `@pegma/scheduler-cloudflare@0.0.0` (**done**; dist-tag `bootstrap` only; + that immutable pre-pnpm tag remains an npm-era receipt); and 2. every advertised release, beginning with `0.1.0` (**published**), through the environment-protected GitHub OIDC workflow in [`.github/workflows/publish.yml`](../.github/workflows/publish.yml). @@ -34,8 +35,8 @@ before tagging. Never unpublish and reuse a version. ## Normal OIDC releases (`0.1.0` and later) -1. Land a reviewed PR that sets both public packages (and lockfile / fixture - pins) to the same stable version, and updates release notes. +1. Land a reviewed PR that sets both public packages (and `pnpm-lock.yaml` / + fixture pins) to the same stable version, and updates release notes. 2. After merge to `main`, create a **protected signed annotated** tag: ```sh @@ -54,8 +55,11 @@ before tagging. Never unpublish and reuse a version. 4. The workflow: - verifies the signed tag against `RELEASE_ALLOWED_SIGNERS`; - runs the full gate; - - packs both packages with `pnpm run release:pack`; - - publishes exact tarballs with provenance via OIDC (`pnpm run release:publish`). + - packs both packages with `pnpm run release:pack` (npm CLI for `pack` / + registry `view`); + - publishes exact tarballs with provenance via OIDC + (`node scripts/release-packages.mjs publish`). The OIDC job does not + download Corepack pnpm. Local helpers (never substitute for the OIDC lane for advertised releases): diff --git a/scripts/release-packages.d.mts b/scripts/release-packages.d.mts index 27f7d7a..00b3675 100644 --- a/scripts/release-packages.d.mts +++ b/scripts/release-packages.d.mts @@ -45,6 +45,14 @@ export function parsePnpmLockfileImporters( Record> >; +export function lockDependencyMatches( + lockDependency: + | { specifier?: string; version?: string } + | undefined, + specifier: string, + options?: { workspace?: boolean }, +): boolean; + export function isNormalReleaseVersion(version: string): boolean; export function parseArguments( diff --git a/scripts/release-packages.mjs b/scripts/release-packages.mjs index ec1fbe1..2e83083 100644 --- a/scripts/release-packages.mjs +++ b/scripts/release-packages.mjs @@ -87,9 +87,17 @@ function run(command, arguments_, options = {}) { return result; } +/** `pnpm run` sets npm_execpath to pnpm; pack/view/publish must still be npm. */ +function npmEnvironment(env = process.env) { + const isolated = { ...env }; + delete isolated.npm_execpath; + return isolated; +} + function runNpm(arguments_, options = {}) { return run(process.platform === "win32" ? "npm.cmd" : "npm", arguments_, { ...options, + env: npmEnvironment(options.env ?? process.env), shell: process.platform === "win32", }); } @@ -174,6 +182,31 @@ export function parsePnpmLockfileImporters(text) { return importers; } +/** + * Each lockfile importer entry must carry that dependency's own specifier and + * resolved version. Independent substring matches can accept a swapped pin. + */ +export function lockDependencyMatches( + lockDependency, + specifier, + options = {}, +) { + if ( + lockDependency === undefined || + lockDependency.specifier !== specifier || + typeof lockDependency.version !== "string" + ) { + return false; + } + if (options.workspace === true) { + return lockDependency.version.startsWith("link:"); + } + return ( + lockDependency.version === specifier || + lockDependency.version.startsWith(`${specifier}(`) + ); +} + function gitCommand() { return process.platform === "win32" ? "git.exe" : "git"; } @@ -265,22 +298,27 @@ async function validatePackage(root, definition, lockfile) { } for (const section of DEPENDENCY_SECTIONS) { for (const [name, version] of Object.entries(manifest[section] ?? {})) { - if (!RELEASE_NAMES.has(name)) { - continue; + const workspace = RELEASE_NAMES.has(name); + if (workspace) { + const dependency = RELEASE_PACKAGES.find((entry) => entry.name === name); + const dependencyManifest = await readJson( + join(root, "packages", dependency.directory, "package.json"), + ); + if (version !== dependencyManifest.version) { + fail( + `${definition.name} must pin ${name} to its exact workspace version`, + ); + } } - const dependency = RELEASE_PACKAGES.find((entry) => entry.name === name); - const dependencyManifest = await readJson( - join(root, "packages", dependency.directory, "package.json"), - ); - const lockDependency = lockEntry[section]?.[name]; if ( - version !== dependencyManifest.version || - lockDependency?.specifier !== version || - typeof lockDependency?.version !== "string" || - !lockDependency.version.startsWith("link:") + !lockDependencyMatches(lockEntry[section]?.[name], version, { + workspace, + }) ) { fail( - `${definition.name} must pin ${name} to its exact workspace version`, + workspace + ? `${definition.name} must pin ${name} to its exact workspace version` + : `${definition.name} ${name}@${version} is not synchronized with pnpm-lock.yaml`, ); } } diff --git a/tests/release-packages.test.ts b/tests/release-packages.test.ts index 56b3434..7dd72ac 100644 --- a/tests/release-packages.test.ts +++ b/tests/release-packages.test.ts @@ -6,6 +6,7 @@ import { RELEASE_PACKAGES, decidePublication, isNormalReleaseVersion, + lockDependencyMatches, parseArguments, parsePnpmLockfileImporters, } from "../scripts/release-packages.mjs"; @@ -120,6 +121,66 @@ packages: specifier: "0.1.0", version: "link:../scheduler", }); + expect( + lockDependencyMatches( + live["packages/scheduler"]?.dependencies?.["@pegma/spine"], + "0.1.2", + ), + ).toBe(true); + expect( + lockDependencyMatches( + live["packages/scheduler"]?.dependencies?.["@pegma/storage-core"], + "0.4.0", + ), + ).toBe(true); + expect( + lockDependencyMatches( + live["packages/scheduler-cloudflare"]?.dependencies?.[ + "@pegma/scheduler" + ], + "0.1.0", + { workspace: true }, + ), + ).toBe(true); + }); + + it("matches each lockfile dependency to its own specifier and resolved version", () => { + const spine = { specifier: "0.1.2", version: "0.1.2" }; + const storage = { specifier: "0.4.0", version: "0.4.0" }; + expect(lockDependencyMatches(spine, "0.1.2")).toBe(true); + expect(lockDependencyMatches(storage, "0.4.0")).toBe(true); + expect(lockDependencyMatches(spine, "0.4.0")).toBe(false); + expect(lockDependencyMatches(storage, "0.1.2")).toBe(false); + expect( + lockDependencyMatches({ specifier: "0.1.2", version: "999.0.0" }, "0.1.2"), + ).toBe(false); + expect( + lockDependencyMatches( + { specifier: "0.1.0", version: "link:../scheduler" }, + "0.1.0", + { workspace: true }, + ), + ).toBe(true); + expect( + lockDependencyMatches( + { specifier: "0.1.0", version: "0.1.0" }, + "0.1.0", + { workspace: true }, + ), + ).toBe(false); + }); + + it("keeps pack, registry view, and publish on the npm CLI", () => { + const source = readFileSync( + join(process.cwd(), "scripts/release-packages.mjs"), + "utf8", + ); + expect(source).not.toMatch( + /(?:npmExecPath|npm_execpath)\s*(?:\?\?|===|!==)/u, + ); + expect(source).toMatch( + /function runNpm\([\s\S]*?process\.platform === "win32" \? "npm\.cmd" : "npm"/u, + ); }); it("skips a byte-identical existing version", () => { From e7aa5983b41d6bea56288c01ad60e701e22a7e5e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 14 Aug 2026 21:19:16 +0000 Subject: [PATCH 2/3] Apply Prettier to the release helper and tests. Co-authored-by: Fly Over Coder --- scripts/release-packages.d.mts | 4 +--- scripts/release-packages.mjs | 10 ++++------ tests/release-packages.test.ts | 13 +++++++------ 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/scripts/release-packages.d.mts b/scripts/release-packages.d.mts index 00b3675..eb6c180 100644 --- a/scripts/release-packages.d.mts +++ b/scripts/release-packages.d.mts @@ -46,9 +46,7 @@ export function parsePnpmLockfileImporters( >; export function lockDependencyMatches( - lockDependency: - | { specifier?: string; version?: string } - | undefined, + lockDependency: { specifier?: string; version?: string } | undefined, specifier: string, options?: { workspace?: boolean }, ): boolean; diff --git a/scripts/release-packages.mjs b/scripts/release-packages.mjs index 2e83083..af8c377 100644 --- a/scripts/release-packages.mjs +++ b/scripts/release-packages.mjs @@ -186,11 +186,7 @@ export function parsePnpmLockfileImporters(text) { * Each lockfile importer entry must carry that dependency's own specifier and * resolved version. Independent substring matches can accept a swapped pin. */ -export function lockDependencyMatches( - lockDependency, - specifier, - options = {}, -) { +export function lockDependencyMatches(lockDependency, specifier, options = {}) { if ( lockDependency === undefined || lockDependency.specifier !== specifier || @@ -300,7 +296,9 @@ async function validatePackage(root, definition, lockfile) { for (const [name, version] of Object.entries(manifest[section] ?? {})) { const workspace = RELEASE_NAMES.has(name); if (workspace) { - const dependency = RELEASE_PACKAGES.find((entry) => entry.name === name); + const dependency = RELEASE_PACKAGES.find( + (entry) => entry.name === name, + ); const dependencyManifest = await readJson( join(root, "packages", dependency.directory, "package.json"), ); diff --git a/tests/release-packages.test.ts b/tests/release-packages.test.ts index 7dd72ac..670a273 100644 --- a/tests/release-packages.test.ts +++ b/tests/release-packages.test.ts @@ -152,7 +152,10 @@ packages: expect(lockDependencyMatches(spine, "0.4.0")).toBe(false); expect(lockDependencyMatches(storage, "0.1.2")).toBe(false); expect( - lockDependencyMatches({ specifier: "0.1.2", version: "999.0.0" }, "0.1.2"), + lockDependencyMatches( + { specifier: "0.1.2", version: "999.0.0" }, + "0.1.2", + ), ).toBe(false); expect( lockDependencyMatches( @@ -162,11 +165,9 @@ packages: ), ).toBe(true); expect( - lockDependencyMatches( - { specifier: "0.1.0", version: "0.1.0" }, - "0.1.0", - { workspace: true }, - ), + lockDependencyMatches({ specifier: "0.1.0", version: "0.1.0" }, "0.1.0", { + workspace: true, + }), ).toBe(false); }); From a69aada63bfeb6449b8ee95818908df159569650 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 14 Aug 2026 23:00:06 +0000 Subject: [PATCH 3/3] Address Codex follow-up on Corepack, ranges, and lockfile scalars. Document Node 22 and 24 as the local toolchain so corepack enable stays valid. Accept resolved versions that satisfy caret, tilde, and major-only ranges while keeping exact pins exact. Unquote YAML specifier and version scalars, and cover peerDependencies in the lockfile matcher tests. Co-authored-by: Fly Over Coder --- CONTRIBUTING.md | 4 +- README.md | 3 + scripts/release-packages.d.mts | 5 ++ scripts/release-packages.mjs | 119 ++++++++++++++++++++++++++++----- tests/release-packages.test.ts | 91 +++++++++++++++++++++++++ 5 files changed, 206 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa8887d..f2a0d45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,8 @@ # Contributing to Scheduler -Scheduler requires Node.js 22 or newer. +Scheduler is developed on Node.js 22 and 24 (the CI gate). Those releases +bundle Corepack. Official Node 25+ builds do not, so they are not a +documented local toolchain. ```sh corepack enable diff --git a/README.md b/README.md index 2ac34e9..25c6ee7 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,9 @@ The first consumers are: ## Development +Use Node.js 22 or 24. Those releases bundle Corepack; official Node 25+ +builds do not, so they are not a documented local toolchain. + ```sh corepack enable pnpm install --frozen-lockfile diff --git a/scripts/release-packages.d.mts b/scripts/release-packages.d.mts index eb6c180..bc2e344 100644 --- a/scripts/release-packages.d.mts +++ b/scripts/release-packages.d.mts @@ -45,6 +45,11 @@ export function parsePnpmLockfileImporters( Record> >; +export function resolvedVersionSatisfies( + version: string, + specifier: string, +): boolean; + export function lockDependencyMatches( lockDependency: { specifier?: string; version?: string } | undefined, specifier: string, diff --git a/scripts/release-packages.mjs b/scripts/release-packages.mjs index af8c377..d5a77de 100644 --- a/scripts/release-packages.mjs +++ b/scripts/release-packages.mjs @@ -109,14 +109,14 @@ function runPnpm(arguments_, options = {}) { }); } -function unquoteYamlKey(key) { +function unquoteYamlScalar(value) { if ( - (key.startsWith("'") && key.endsWith("'")) || - (key.startsWith('"') && key.endsWith('"')) + (value.startsWith("'") && value.endsWith("'")) || + (value.startsWith('"') && value.endsWith('"')) ) { - return key.slice(1, -1); + return value.slice(1, -1); } - return key; + return value; } /** Reads pnpm-lock.yaml importers without a YAML dependency. */ @@ -143,7 +143,7 @@ export function parsePnpmLockfileImporters(text) { const importerMatch = /^ {2}(\S[^:]*):$/u.exec(line); if (importerMatch !== null) { - currentPath = unquoteYamlKey(importerMatch[1]); + currentPath = unquoteYamlScalar(importerMatch[1]); importers[currentPath] = {}; currentSection = null; currentDep = null; @@ -163,7 +163,7 @@ export function parsePnpmLockfileImporters(text) { const depMatch = /^ {6}([^:]+):$/u.exec(line); if (depMatch !== null && currentPath !== null && currentSection !== null) { - currentDep = unquoteYamlKey(depMatch[1]); + currentDep = unquoteYamlScalar(depMatch[1]); importers[currentPath][currentSection][currentDep] = {}; continue; } @@ -176,31 +176,120 @@ export function parsePnpmLockfileImporters(text) { currentDep !== null ) { importers[currentPath][currentSection][currentDep][fieldMatch[1]] = - fieldMatch[2]; + unquoteYamlScalar(fieldMatch[2]); } } return importers; } +function parseSemverTriple(version) { + const match = STABLE_SEMVER.exec(version); + if (match === null) { + return null; + } + return [Number(match[1]), Number(match[2]), Number(match[3])]; +} + +function leadingResolvedSemver(version) { + const full = /^(\d+)\.(\d+)\.(\d+)/u.exec(version); + if (full !== null) { + return [Number(full[1]), Number(full[2]), Number(full[3])]; + } + const majorMinor = /^(\d+)\.(\d+)(?![.\d])/u.exec(version); + if (majorMinor !== null) { + return [Number(majorMinor[1]), Number(majorMinor[2]), 0]; + } + const major = /^(\d+)(?![.\d])/u.exec(version); + if (major !== null) { + return [Number(major[1]), 0, 0]; + } + return null; +} + +function compareSemver(left, right) { + for (let index = 0; index < 3; index += 1) { + if (left[index] !== right[index]) { + return left[index] < right[index] ? -1 : 1; + } + } + return 0; +} + +function caretUpperBound([major, minor, patch]) { + if (major > 0) { + return [major + 1, 0, 0]; + } + if (minor > 0) { + return [0, minor + 1, 0]; + } + return [0, 0, patch + 1]; +} + +function tildeUpperBound([major, minor]) { + return [major, minor + 1, 0]; +} + +function inHalfOpenRange(resolved, lower, upper) { + return ( + compareSemver(resolved, lower) >= 0 && compareSemver(resolved, upper) < 0 + ); +} + +/** Exact pins must match; ranges accept a resolved version in the specifier. */ +export function resolvedVersionSatisfies(version, specifier) { + if (STABLE_SEMVER.test(specifier)) { + return version === specifier || version.startsWith(`${specifier}(`); + } + if (specifier === "*" || specifier === "x" || specifier === "X") { + return leadingResolvedSemver(version) !== null; + } + const resolved = leadingResolvedSemver(version); + if (resolved === null) { + return false; + } + if (specifier.startsWith("^")) { + const lower = parseSemverTriple(specifier.slice(1)); + return ( + lower !== null && inHalfOpenRange(resolved, lower, caretUpperBound(lower)) + ); + } + if (specifier.startsWith("~")) { + const lower = parseSemverTriple(specifier.slice(1)); + return ( + lower !== null && inHalfOpenRange(resolved, lower, tildeUpperBound(lower)) + ); + } + const majorOnly = /^(\d+)$/u.exec(specifier); + if (majorOnly !== null) { + const lower = [Number(majorOnly[1]), 0, 0]; + return inHalfOpenRange(resolved, lower, [lower[0] + 1, 0, 0]); + } + const majorMinor = /^(\d+)\.(\d+)$/u.exec(specifier); + if (majorMinor !== null) { + const lower = [Number(majorMinor[1]), Number(majorMinor[2]), 0]; + return inHalfOpenRange(resolved, lower, tildeUpperBound(lower)); + } + return false; +} + /** * Each lockfile importer entry must carry that dependency's own specifier and - * resolved version. Independent substring matches can accept a swapped pin. + * a resolved version that satisfies it. Independent substring matches can + * accept a swapped pin; exact-equality on ranges rejects a valid lockfile. */ export function lockDependencyMatches(lockDependency, specifier, options = {}) { if ( lockDependency === undefined || - lockDependency.specifier !== specifier || + unquoteYamlScalar(lockDependency.specifier ?? "") !== specifier || typeof lockDependency.version !== "string" ) { return false; } + const version = unquoteYamlScalar(lockDependency.version); if (options.workspace === true) { - return lockDependency.version.startsWith("link:"); + return version.startsWith("link:"); } - return ( - lockDependency.version === specifier || - lockDependency.version.startsWith(`${specifier}(`) - ); + return resolvedVersionSatisfies(version, specifier); } function gitCommand() { diff --git a/tests/release-packages.test.ts b/tests/release-packages.test.ts index 670a273..448027d 100644 --- a/tests/release-packages.test.ts +++ b/tests/release-packages.test.ts @@ -9,6 +9,7 @@ import { lockDependencyMatches, parseArguments, parsePnpmLockfileImporters, + resolvedVersionSatisfies, } from "../scripts/release-packages.mjs"; describe("release package metadata", () => { @@ -87,6 +88,19 @@ describe("release package metadata", () => { '@pegma/scheduler': specifier: 0.1.0 version: link:../scheduler + peerDependencies: + '@cloudflare/workers-types': + specifier: ^5.20260731.1 + version: 5.20260814.1 + + packages/quoted: + dependencies: + b: + specifier: '1' + version: '1' + wildcard: + specifier: '*' + version: 1.0.0 packages: prettier@3.9.6: @@ -96,6 +110,7 @@ packages: ".", "packages/scheduler", "packages/scheduler-cloudflare", + "packages/quoted", ]); expect(importers["packages/scheduler"]).toEqual({ dependencies: { @@ -111,6 +126,18 @@ packages: specifier: "0.1.0", version: "link:../scheduler", }); + expect( + importers["packages/scheduler-cloudflare"]?.peerDependencies?.[ + "@cloudflare/workers-types" + ], + ).toEqual({ + specifier: "^5.20260731.1", + version: "5.20260814.1", + }); + expect(importers["packages/quoted"]?.dependencies).toEqual({ + b: { specifier: "1", version: "1" }, + wildcard: { specifier: "*", version: "1.0.0" }, + }); const live = parsePnpmLockfileImporters( readFileSync(join(process.cwd(), "pnpm-lock.yaml"), "utf8"), @@ -142,6 +169,23 @@ packages: { workspace: true }, ), ).toBe(true); + expect( + lockDependencyMatches(importers["packages/quoted"]?.dependencies?.b, "1"), + ).toBe(true); + expect( + lockDependencyMatches( + importers["packages/quoted"]?.dependencies?.wildcard, + "*", + ), + ).toBe(true); + expect( + lockDependencyMatches( + importers["packages/scheduler-cloudflare"]?.peerDependencies?.[ + "@cloudflare/workers-types" + ], + "^5.20260731.1", + ), + ).toBe(true); }); it("matches each lockfile dependency to its own specifier and resolved version", () => { @@ -169,6 +213,53 @@ packages: workspace: true, }), ).toBe(false); + expect( + lockDependencyMatches( + { specifier: "^1.2.0", version: "1.2.3" }, + "^1.2.0", + ), + ).toBe(true); + expect( + lockDependencyMatches( + { specifier: "^1.2.0", version: "2.0.0" }, + "^1.2.0", + ), + ).toBe(false); + expect( + lockDependencyMatches( + { specifier: "^0.18.8", version: "0.18.8(@x@1.0.0)" }, + "^0.18.8", + ), + ).toBe(true); + expect( + lockDependencyMatches( + { specifier: "~1.2.0", version: "1.2.5" }, + "~1.2.0", + ), + ).toBe(true); + expect( + lockDependencyMatches( + { specifier: "~1.2.0", version: "1.3.0" }, + "~1.2.0", + ), + ).toBe(false); + expect( + lockDependencyMatches( + { specifier: "^5.20260731.1", version: "5.20260814.1" }, + "^5.20260731.1", + ), + ).toBe(true); + expect(resolvedVersionSatisfies("1.2.3", "^1.2.0")).toBe(true); + expect(resolvedVersionSatisfies("0.0.2", "^0.0.1")).toBe(false); + expect(lockDependencyMatches({ specifier: "1", version: "1" }, "1")).toBe( + true, + ); + expect( + lockDependencyMatches({ specifier: "'1'", version: "'1'" }, "1"), + ).toBe(true); + expect( + lockDependencyMatches({ specifier: "*", version: "1.0.0" }, "*"), + ).toBe(true); }); it("keeps pack, registry view, and publish on the npm CLI", () => {