Skip to content

Commit 4dcd524

Browse files
chore: enforce frozen pnpm installs
1 parent 570491a commit 4dcd524

10 files changed

Lines changed: 68 additions & 4206 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import assert from "node:assert/strict";
2+
import { execFileSync } from "node:child_process";
3+
import { access, readdir, readFile } from "node:fs/promises";
4+
import { describe, it } from "node:test";
5+
6+
const ROOT_URL = new URL("../../", import.meta.url);
7+
const WORKFLOWS_URL = new URL("workflows/", new URL("../", import.meta.url));
8+
9+
const trackedPackageLocks = async () => {
10+
const tracked = execFileSync("git", ["ls-files", "--", ":(glob)**/package-lock.json"], {
11+
cwd: ROOT_URL,
12+
encoding: "utf8",
13+
})
14+
.trim()
15+
.split("\n")
16+
.filter(Boolean);
17+
18+
const existing = await Promise.all(
19+
tracked.map(async (path) => {
20+
try {
21+
await access(new URL(path, ROOT_URL));
22+
return path;
23+
} catch {
24+
return null;
25+
}
26+
}),
27+
);
28+
29+
return existing.filter((path) => path !== null);
30+
};
31+
32+
const workflowFiles = async () => {
33+
const entries = await readdir(WORKFLOWS_URL, { withFileTypes: true });
34+
return entries.filter((entry) => entry.isFile() && /\.ya?ml$/.test(entry.name));
35+
};
36+
37+
describe("JavaScript dependency policy", () => {
38+
it("keeps pnpm-lock.yaml as the only tracked JavaScript lockfile", async () => {
39+
assert.deepEqual(await trackedPackageLocks(), []);
40+
});
41+
42+
it("uses frozen pnpm installs in every workflow", async () => {
43+
for (const entry of await workflowFiles()) {
44+
const workflow = await readFile(new URL(entry.name, WORKFLOWS_URL), "utf8");
45+
assert.doesNotMatch(workflow, /--no-frozen-lockfile/, entry.name);
46+
47+
const installs = workflow.split("\n").filter((line) => /\bpnpm install\b/.test(line));
48+
49+
for (const install of installs) {
50+
assert.match(install, /--ignore-scripts\b/, `${entry.name}: ${install.trim()}`);
51+
assert.match(install, /--frozen-lockfile\b/, `${entry.name}: ${install.trim()}`);
52+
}
53+
}
54+
});
55+
});

.github/workflows/bench.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393

9494
- name: Install JS dependencies
9595
if: matrix.kind == 'node'
96-
run: corepack pnpm install --ignore-scripts --no-frozen-lockfile
96+
run: corepack pnpm install --ignore-scripts --frozen-lockfile
9797

9898
- name: Install wasm-pack
9999
if: matrix.kind == 'node'

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
- name: Enable Corepack
151151
run: corepack enable
152152
- name: Install JS dependencies
153-
run: corepack pnpm install --ignore-scripts --no-frozen-lockfile
153+
run: corepack pnpm install --ignore-scripts --frozen-lockfile
154154
- name: Run JS lint and format checks
155155
run: corepack pnpm run lint:js
156156
- name: Run JS formatter check
@@ -174,7 +174,7 @@ jobs:
174174
targets: wasm32-unknown-unknown
175175
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
176176
- name: Install JS dependencies
177-
run: corepack pnpm install --ignore-scripts --no-frozen-lockfile
177+
run: corepack pnpm install --ignore-scripts --frozen-lockfile
178178
- name: Install wasm-pack
179179
shell: bash
180180
run: |

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: corepack enable
4040

4141
- name: Install JS dependencies
42-
run: corepack pnpm install --ignore-scripts --no-frozen-lockfile
42+
run: corepack pnpm install --ignore-scripts --frozen-lockfile
4343

4444
- name: Install wasm-pack
4545
shell: bash

CONTRIBUTING.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ Thanks for your interest in contributing to srcmap! Whether it's a bug fix, new
1515
```bash
1616
git clone https://github.com/fallow-rs/srcmap.git
1717
cd srcmap
18+
corepack enable
19+
corepack pnpm install --frozen-lockfile
1820

1921
# Build all Rust crates
2022
cargo build
2123

2224
# Run tests
2325
cargo test
2426

25-
# Run JS tests (requires building WASM packages first)
26-
npm test
27+
# Run JS tests (requires building NAPI and WASM packages first)
28+
corepack pnpm test
2729
```
2830

2931
## Project structure
@@ -72,7 +74,7 @@ cd packages/sourcemap-wasm && wasm-pack build --target web
7274
```bash
7375
cargo test # All Rust tests
7476
cargo test -p srcmap-sourcemap # Single crate
75-
npm run test:js # JS/WASM tests
77+
corepack pnpm run test:js # JS/WASM tests
7678
```
7779

7880
### Benchmarks
@@ -82,14 +84,14 @@ npm run test:js # JS/WASM tests
8284
cargo bench -p srcmap-sourcemap
8385

8486
# JS benchmarks (comparison with other libraries)
85-
cd benchmarks && npm install && node sourcemap-wasm.mjs
87+
corepack pnpm --dir benchmarks exec node sourcemap-wasm.mjs
8688
```
8789

8890
### Coverage
8991

9092
```bash
91-
npm run coverage:rust # Rust coverage (requires cargo-llvm-cov)
92-
npm run coverage:js # JS coverage
93+
corepack pnpm run coverage:rust # Rust coverage (requires cargo-llvm-cov)
94+
corepack pnpm run coverage:js # JS coverage
9395
```
9496

9597
## Code standards

0 commit comments

Comments
 (0)