chore: add prepare script so git installs build dist/#982
Conversation
Consumers that install ueberdb2 via a git ref (e.g. `pnpm add github:ether/ueberDB#main`) need the TypeScript sources compiled into dist/ — the published tarball ships the built artefacts but the git tree does not (dist/ is gitignored). `npm`/`pnpm`'s `prepare` hook runs on git installs and is a no-op for tarball installs from the npm registry, so this fix has zero impact on the published-tarball path. Picked up while unblocking ether/etherpad#7831, whose CI cannot resolve `ueberdb2 ^6.1.0` until the npm publish workflow on this repo (failing E404 since #981 merged) is restored. A git-ref pin is the natural stopgap and requires this script to work end-to-end. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Review Summary by QodoAdd prepare script for git-based installations
WalkthroughsDescription• Add prepare script to auto-build dist/ on git installs • Enables consumers to install via git refs without manual build • No impact on npm tarball installation path • Unblocks etherpad CI pinning to main branch Diagramflowchart LR
A["Git install via ref"] -->|"prepare hook runs"| B["pnpm run build"]
B --> C["dist/ generated"]
C --> D["Consumer gets built artifacts"]
E["npm tarball install"] -->|"prepare skipped"| F["No change to existing flow"]
File Changes1. package.json
|
Code Review by Qodo
1. Prepare requires pnpm
|
| "format": "oxfmt --write .", | ||
| "format:check": "oxfmt --check .", | ||
| "build": "pnpm run build:js && pnpm run build:types", | ||
| "prepare": "pnpm run build", |
There was a problem hiding this comment.
1. Prepare requires pnpm 🐞 Bug ☼ Reliability
The added prepare lifecycle script runs pnpm run build, so any install path that executes prepare without pnpm on PATH (e.g., installing from a git ref via npm/yarn) will fail before the package can be used. This is especially risky because the repo’s README documents installation via npm and the package.json does not declare/enforce a package manager.
Agent Prompt
## Issue description
`prepare` is a package-manager lifecycle hook that can be executed by installers (not just pnpm). Defining it as `pnpm run build` introduces a hard dependency on a global `pnpm` binary, which can break installs when pnpm is unavailable.
## Issue Context
- `prepare` now shells out to pnpm.
- The README shows `npm install ueberdb2`, so npm usage is expected.
- The publish workflow explicitly calls out special handling when a package has a `prepare` script.
## Fix options (pick one)
1) **Remove pnpm dependency from lifecycle scripts (recommended):**
- Update `build`, `build:js`, and `build:types` scripts to call local binaries directly (from `node_modules/.bin`), e.g. `rolldown -c ...` and `tsc ...`.
- Set `prepare` to `npm run build` (or simply `run build`-equivalent) once `build` no longer calls pnpm.
2) **Ensure pnpm is always available when `prepare` runs:**
- Add a `packageManager` field (pin to a chosen pnpm version) and change `prepare` to use Corepack (e.g., `corepack pnpm run build`) so pnpm can be provisioned even if not globally installed.
## Fix Focus Areas
- package.json[135-147]
- package.json[1-6]
- package.json[158-161]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Closing in favour of #983, which fixes the publish workflow root cause (stored NPM_TOKEN → OIDC trusted publishing). Once #983 lands and the one-time npmjs.com trusted-publisher setup is done, ueberdb2 publishes will be reliable end-to-end and the git-ref install path is no longer needed to unblock ether/etherpad#7831. |
Summary
Test plan
🤖 Generated with Claude Code