GitHubivarvong
ply
main
1// What a consumer gets from the packed tarball with lifecycle scripts off, and what README.md says about it.
2// The judges are npm and Node, not ply: `npm install --ignore-scripts <tarball>` into an empty project must leave
3// exactly one package, Node must import the root and all 19 subpaths (20, counted by hand from package.json
4// "exports"), and `require('ply')` must do what README Install states for the running Node. The expected require()
5// outcomes were measured with Node binaries on the development machine (the REQUIRE_MEASURED table below). The
6// boundary on the 20 line is 20.19.0 (Node's CHANGELOG_V20.md, 20.19.0: "require(esm) is now enabled by default";
7// measured: 20.18.3 throws, 20.19.0 works); the 22.12 boundary is Node's own (require of ES modules is unflagged from
8// 22.12.0) and is not measured here. CI job `pack` runs scripts/pack-check.mjs under the newest Node 20, 22 and 24.
9import { test, beforeAll as before, afterAll as after } from 'vitest';
10import assert from 'node:assert/strict';
11import { mkdtempSync, rmSync, readFileSync } from 'node:fs';
12import { tmpdir } from 'node:os';
13import { join } from 'node:path';
14import { pack, installTarball, importAll, requireRoot, requireExpected, nodeVersion, examplesSetupCommand } from '../scripts/pack-check.mjs';
16const README = readFileSync(new URL('../README.md', import.meta.url), 'utf8');
17const INSTALL = README.slice(README.indexOf('## Install'), README.indexOf('## Beta'));
18let out;
19let consumer;
20before(() => {
21 out = mkdtempSync(join(tmpdir(), 'ply-pack-test-'));
22 consumer = installTarball(pack(out));
23}, 300_000);
24after(() => {
25 if (consumer) consumer.cleanup();
26 if (out) rmSync(out, { recursive: true, force: true });
27});
29test('the tarball installs with --ignore-scripts as one package and every subpath imports', () => {
30 assert.deepEqual(consumer.packages, ['ply']);
31 const imported = importAll(consumer.dir);
32 assert.equal(Object.keys(imported).length, 20);
33 for (const [name, count] of Object.entries(imported)) assert.ok(count > 0, `${name} exports nothing`);
34});
36test('README Install states ESM-only and the require() behaviour this Node shows', () => {
37 const { major, minor } = nodeVersion();
38 const expected = major > 22 || (major === 22 && minor >= 12) || (major === 20 && minor >= 19) ? 'ok' : 'ERR_REQUIRE_ESM';
39 assert.equal(requireRoot(consumer.dir), expected);
40 assert.match(INSTALL, /ESM[- ]only/);
41 assert.match(INSTALL, /ERR_REQUIRE_ESM/);
42 assert.match(INSTALL, /20\.19\.0/);
43 assert.match(INSTALL, /22\.12/);
44 assert.match(INSTALL, /await import\('ply'\)/);
45 assert.equal(JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).engines.node, '>=20');
46});
48// `require('ply')` from a CommonJS file in an empty project with the tarball installed, run under each Node binary on
49// the development machine (2026-11-11; 20.18.3, 20.19.0 and 20.20.2 are the official nodejs.org darwin-arm64 builds,
50// checksums verified). The two 22.x rows are Node's documented boundary (22.12.0), not measured.
51const REQUIRE_MEASURED = [
52 ['20.17.0', 'ERR_REQUIRE_ESM'], ['20.18.0', 'ERR_REQUIRE_ESM'], ['20.18.3', 'ERR_REQUIRE_ESM'],
53 ['20.19.0', 'ok'], ['20.20.2', 'ok'],
54 ['22.11.0', 'ERR_REQUIRE_ESM'], ['22.12.0', 'ok'],
55 ['22.15.0', 'ok'], ['24.2.0', 'ok'], ['24.16.0', 'ok'], ['24.18.0', 'ok'], ['25.2.1', 'ok'],
56];
58test('the require() outcome pack-check expects is the measured one on every Node version in the table', () => {
59 for (const [version, outcome] of REQUIRE_MEASURED) {
60 const [major, minor] = version.split('.').map(Number);
61 assert.equal(requireExpected({ major, minor }), outcome, `node ${version}`);
62 }
63});
65test('examples/README.md documents one setup command before the example commands', () => {
66 // the examples import `ply` by name, which resolves to dist/; `npm install` runs `prepare`, which builds it.
67 // scripts/pack-check.mjs (CI job `pack`) runs this command in a fresh export and then starts each example.
68 assert.equal(examplesSetupCommand(readFileSync(new URL('../examples/README.md', import.meta.url), 'utf8')), 'npm install');
69});
71test('README Install states what npm, pnpm, yarn and bun each do with the git dependency, by measured version', () => {
72 // The judges are the package managers, not ply: `<pm> add github:ivarvong/ply#77048fb` into an empty project, with
73 // and without --ignore-scripts, then `import('ply')` (npm against a local clone of the same commit). Measured once:
74 // npm 11.16.0 and pnpm 8.15.9 run `prepare` and leave dist/ (158 files); yarn 1.22.22 and bun 1.2.18 exit 0 without
75 // running it and leave no dist/. That run needs the network and four package managers, so it is not repeated here;
76 // this test holds README to naming each one with the version it was measured on and the outcome that version showed.
77 const rows = Object.fromEntries(INSTALL.split('\n').filter(line => line.startsWith('| ')).map(line => [String(line.split('|')[1]).trim(), line]));
78 assert.match(rows['npm 11.16.0'] ?? '', /^\| npm 11\.16\.0 \| builds `dist\/`/);
79 assert.match(rows['pnpm 8.15.9'] ?? '', /^\| pnpm 8\.15\.9 \| builds `dist\/`/);
80 assert.match(rows['yarn 1.22.22'] ?? '', /^\| yarn 1\.22\.22 \| exits 0[^|]*no `dist\/`/);
81 assert.match(rows['bun 1.2.18'] ?? '', /^\| bun 1\.2\.18 \| exits 0[^|]*no `dist\/`/);
82});
Diagnostics6 git calls · 97 ms
CallStatusSizeTime097 ms
discover200191 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=191 git.server.agent=git/github-9922ec520325-Linux git.server.object_format=sha1 git.server.caps=agent ls-refs fetch server-option object-format git.server.fetch=shallow wait-for-done filter git.protocol.version=2 git.pkt.frames=9 git.pkt.data=7 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=191 git.pkt.payload.max=36
ls-refs20012 KiB · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=11990 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=152 git.pkt.data=151 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=11990 git.pkt.payload.max=122 git.ls_refs.count=151 git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 102004.2 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=4347 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=19912563f540228593df0c489082e5e2508e21e4 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=4347 git.pkt.payload.max=4247 git.sideband.band1.bytes=4247 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=10 git.pack.bytes=4247 git.pack.ofs_delta=0 git.pack.ref_delta=0 git.pack.chain.max=0 git.pack.trailer=a6caf8e129bea82c9bae4cbc7c130c9205add400 git.pack.full=10Open pack map
fetchtree:0200919 B · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=919 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=800d30ba8923860bfc460ca884b7f9ba22083588 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=919 git.pkt.payload.max=892 git.sideband.band1.bytes=892 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=892 git.pack.trailer=5323b9266eea5ded637285d1c5320699f12be76eOpen pack map
fetchtree:02005.6 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=87 git.response.bytes=5724 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=58fabb6768b3f737ee9cd8bac647bdc27405fb4d git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=5724 git.pkt.payload.max=5697 git.sideband.band1.bytes=5697 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=5697 git.pack.trailer=be7e0453974a5fe832f9065a33bb7e3434c10e9bOpen pack map
fetch2002.2 KiB87 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=2270 git.response.cache=MISS git.response.duration_ms=87 git.fetch.wants=6f957310e31ee0368e7f2b67694d84984f625d2e git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=2270 git.pkt.payload.max=2243 git.sideband.band1.bytes=2243 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://github.com/ivarvong/ply
- Ref
- refs/heads/main
- Commit
- 19912563f540228593df0c489082e5e2508e21e4
- cf-ray
- a5e0fdf12a28332c
- Request
- 237ffab8…
- Protocol
- v2 · sha1
- Agent
- git/github-9922ec520325-Linux
- Filter
- advertised
- Fetch
- shallow wait-for-done filter
- Capabilities
- agent ls-refs fetch server-option object-format