Skip to content

feat: per-package build + prepublishOnly hook (closes #80)#81

Merged
mellonis merged 1 commit into
masterfrom
feat/prepublish-build-hook-80
May 19, 2026
Merged

feat: per-package build + prepublishOnly hook (closes #80)#81
mellonis merged 1 commit into
masterfrom
feat/prepublish-build-hook-80

Conversation

@mellonis

Copy link
Copy Markdown
Owner

Summary

Mirrors turing-machine-js#154 shape so post-machine-js releases stop risking stale-`dist/` publishes, and aligns the release workflow uniformly across both repos.

Discovered just before v6.4.0 publish: `packages/machine/package.json` had no `scripts` block. Manual `npm run build` from root before `npm publish` was the only thing keeping dist current. After a session of edits, `dist/` was 105 minutes older than source β€” would have shipped stale code without the manual rebuild.

What changes

  • `scripts/build-node-entries.mjs` β€” paths resolve via `REPO_ROOT` from `import.meta.url`, so the script behaves the same from root or from a sub-package. Optional `--package=` filter for per-package builds (only one package in this repo, but matches engine's shape).
  • `packages/machine/package.json` β€” new `scripts` block:
    ```json
    "scripts": {
    "build": "tsc --build --verbose tsconfig.build.json && node ../../scripts/build-node-entries.mjs --package=@post-machine-js/machine",
    "prepublishOnly": "npm run build"
    }
    ```
    `npm publish` (or `lerna publish from-package`) from `packages/machine/` now auto-builds first.
  • `lerna.json` β€” version synced `6.0.0` β†’ `6.4.0` (was stale; hand-edited bumps don't touch `lerna.json`, so it had drifted across all post-machine-js releases since v6.0.0).

After this lands β€” uniform release workflow across both repos

Step Command
Bump `npx lerna version <X.Y.Z> --no-git-tag-version --no-push --yes`
Publish `npx lerna publish from-package --yes` (from repo root)
GH release `gh release create vX.Y.Z --target master --title vX.Y.Z --notes-file `

Same commands for both repos; per-repo branch-name conventions remain the only difference (`chore/release-X.Y.Z` for turing-machine-js, `vX-Y-Z` for post-machine-js).

Umbrella docs update

The umbrella `mellonis/machines/CLAUDE.md`'s "Release / delivery process" section will be updated to reflect the uniform flow. Direct push to umbrella master (per the established pattern β€” umbrella allows direct).

Compatibility

  • No source / API changes. Infrastructure only.
  • No version bump. Next release picks up the prepublishOnly hook automatically.

Test plan

  • `cd packages/machine && rm -rf dist && npm publish --dry-run` triggers prepublishOnly, rebuilds dist, prepares 50.9 kB tarball (15 files, version 6.4.0).
  • `npx lerna list --json` from root reports `@post-machine-js/machine` at 6.4.0 β€” `lerna publish from-package` will publish it.
  • `npm test` β€” 267/267
  • `npm run typecheck` / `npm run lint` / `npm run build` from root β€” all clean

Mirrors the engine's PR #154 shape so post-machine-js releases stop
risking stale-dist publishes:

- `scripts/build-node-entries.mjs`: cwd-portable (paths resolve via
  REPO_ROOT from import.meta.url) + optional `--package=<scoped-name>`
  filter. Same shape as the engine script.
- `packages/machine/package.json`: new `scripts` block with per-package
  `build` (passes `--package=@post-machine-js/machine` so this single-
  package monorepo's flow matches the engine's multi-package flow) and
  `prepublishOnly: "npm run build"`. `npm publish` (or `lerna publish
  from-package`) from packages/machine/ now auto-builds first.
- `lerna.json` version synced 6.0.0 β†’ 6.4.0 (was stale; hand-edited
  bumps don't touch lerna.json, so it had drifted across releases).

After this lands, post-machine-js's release workflow aligns fully with
the engine:
- Bump: `npx lerna version <X.Y.Z> --no-git-tag-version --no-push --yes`
- Publish: `npx lerna publish from-package --yes` (from repo root)
- GH release: `gh release create vX.Y.Z --target master --title vX.Y.Z --notes-file <path>`

Same commands as turing-machine-js; per-repo branch-name conventions
are the only difference (`chore/release-X.Y.Z` for turing,
`vX-Y-Z` for post).

Umbrella `mellonis/machines/CLAUDE.md`'s Release / delivery process
section will be updated to reflect the uniform flow (separate direct
push to umbrella master β€” umbrella allows direct).

No source/API changes. Infrastructure only. No version bump.

Verified locally:
- `cd packages/machine && rm -rf dist && npm publish --dry-run`
  triggers prepublishOnly, rebuilds dist, prepares correct tarball
  (50.9 kB, 15 files, version 6.4.0).
- `npx lerna list --json` from root reports @post-machine-js/machine
  at 6.4.0 β€” `lerna publish from-package` will publish it.
- npm test 267/267, typecheck/lint/build clean.
@mellonis mellonis merged commit 9576e26 into master May 19, 2026
5 checks passed
@mellonis mellonis deleted the feat/prepublish-build-hook-80 branch May 19, 2026 18:09
@github-project-automation github-project-automation Bot moved this from Todo to Done in @mellonis's machines May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant