From 03274b2c53821e83f409e9b5a3297e80604608ef Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Thu, 15 Oct 2026 11:48:10 +1100 Subject: [PATCH] fix: build dist/ in prepare so installs from git work npm runs a git dependency's prepare script before packing it, but not prepack, so `npm install github:sidorares/node-rfb2#` gave a package without dist/ and `import 'rfb2'` failed. Build in prepare instead of prepack. npm also runs prepare on `npm install` / `npm ci` in a clone and before `npm pack` and `npm publish`, so the workflows no longer need their own build step. --- .github/workflows/ci.yml | 1 - .github/workflows/release-please.yml | 2 +- .github/workflows/release.yml | 2 +- README.md | 6 ++++-- package.json | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4df1a37..249a353 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,6 @@ jobs: - run: npm ci - run: npm run lint - run: npm run typecheck - - run: npm run build - name: Package contents run: npm pack --dry-run diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 1bbaeb9..1978d97 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -70,9 +70,9 @@ jobs: exit 1 fi - run: npm run check - - run: npm run build - name: Publish run: | + # npm publish builds dist/ first (the prepare script). # An empty NPM_TOKEN must not override trusted publishing (OIDC). if [ -z "${NODE_AUTH_TOKEN:-}" ]; then unset NODE_AUTH_TOKEN; fi version="$(node -p 'require("./package.json").version')" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f42767b..0198d48 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,9 +37,9 @@ jobs: exit 1 fi - run: npm run check - - run: npm run build - name: Publish run: | + # npm publish builds dist/ first (the prepare script). # An empty NPM_TOKEN must not override trusted publishing (OIDC). if [ -z "${NODE_AUTH_TOKEN:-}" ]; then unset NODE_AUTH_TOKEN; fi version="$(node -p 'require("./package.json").version')" diff --git a/README.md b/README.md index 8a103c8..f991af7 100644 --- a/README.md +++ b/README.md @@ -218,15 +218,17 @@ The 0.x API still works: `createConnection()`, the `connect`, `rect`, `resize`, ## Development ```bash -npm install +npm install # also builds dist/ (the prepare script) npm run check # lint (Biome), typecheck (tsc), unit tests (node:test) -npm run build # dist/ for publishing +npm run build # rebuild dist/ after changing src/ npm run servers:up # VNC servers in Docker on 127.0.0.1:159xx (see docker/README.md) npm run test:integration # every encoding, pixel format and security type against them npm run servers:down ``` The sources run directly on Node (type stripping): `node examples/screenshot.ts host 5900 > screen.png`. +To try an unreleased branch in another project, `npm install github:sidorares/node-rfb2#`; npm +runs `prepare` there too, so the install has `dist/`. Integration tests skip servers that aren't running; CI starts them all (`.github/workflows/ci.yml`). Commits on `master` use [Conventional Commits](https://www.conventionalcommits.org). release-please diff --git a/package.json b/package.json index 6301378..dcf848e 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "servers:up": "docker compose -f docker/compose.yaml up -d --build --wait", "servers:down": "docker compose -f docker/compose.yaml down", "check": "npm run lint && npm run typecheck && npm test", - "prepack": "npm run build" + "prepare": "npm run build" }, "devDependencies": { "@biomejs/biome": "^2.5.15",