Skip to content

feat(npm): bootstrap from real tarballs instead of placeholders - #3

Merged
ajay-bhargava merged 2 commits into
mainfrom
docs/npm-bootstrap
Jul 27, 2026
Merged

feat(npm): bootstrap from real tarballs instead of placeholders#3
ajay-bhargava merged 2 commits into
mainfrom
docs/npm-bootstrap

Conversation

@ajay-bhargava

@ajay-bhargava ajay-bhargava commented Jul 27, 2026

Copy link
Copy Markdown
Member

Follow-up to #2. The bootstrap step in docs/npm-publishing.md said "publish placeholders", which was underspecified and, on inspection, the wrong approach.

The constraint

npm Trusted Publishing can only be configured on a package that already exists, and our CI publishes through Trusted Publishing. So the first publish of each of the 7 names must come from a maintainer's machine.

Why placeholders were wrong

A placeholder is a 373-byte package containing only package.json and an empty bin/.gitkeep (verified with npm pack --dry-run). Two defects:

  1. It claims the latest dist-tag — npm i @planmonster/olkcli would install a launcher with no binary.
  2. Registry versions are immutable, so the junk version stays visible forever.

What replaces it

Bootstrap from the tarballs a dry_run already builds:

1. Actions -> Publish (npm) -> version: X, dry_run: true
2. Download + unzip the npm-tarballs artifact
3. npm login
4. bash scripts/bootstrap-npm.sh <dir>     (--dry-run first)
5. Add Trusted Publisher to each of the 7 packages
6. Revoke the token

No Mac needed locally, no junk versions, and the first published version is real and installable.

scripts/bootstrap-npm.sh enforces the ordering (6 binary packages, launcher last) and refuses to run unless all 7 tarballs are present. build-npm.mjs gains --tag, so the placeholder path — kept only for reserving names ahead of a first release — stays off latest.

Testing

  • bash scripts/bootstrap-npm.sh /tmp/bs --dry-run against 7 real packed tarballs: correct split (6 binary + 1 launcher), correct order, no publish
  • Verified a placeholder's contents with npm pack --dry-run: bin/.gitkeep + package.json, 373 B
  • bash scripts/test-npm-package.sh → PASS (unscoped + scoped)
  • bash -n clean on the new script

View with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is enabled.

npm Trusted Publishing can only be configured on a package that already
exists, so the first publish of each of the seven names cannot come from CI.
The previous instruction was to publish 373-byte placeholder packages, which
has two defects: the placeholder claims the "latest" dist-tag, so
`npm i @planmonster/olkcli` would install a launcher with no binary, and the
junk version stays on the registry forever because versions are immutable.

Bootstrap from the tarballs that a dry run already produces instead. A
maintainer starts publish-npm.yml with dry_run: true, downloads the
npm-tarballs artifact, and publishes it with scripts/bootstrap-npm.sh. No Mac
is needed locally, the first published version is real and installable, and
the token is used once and then revoked.

scripts/bootstrap-npm.sh enforces the publish order (six binary packages
first, launcher last) and refuses to run unless all seven tarballs are
present. It supports --dry-run and --tag.

build-npm.mjs gains --tag so the placeholder path, kept only for reserving
names ahead of a first release, can stay off the "latest" tag.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb4d117e-fd29-48ba-be5e-a89d74ecff60

📥 Commits

Reviewing files that changed from the base of the PR and between 0cb1c57 and 89ac14f.

📒 Files selected for processing (2)
  • scripts/bootstrap-npm.sh
  • scripts/build-npm.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/build-npm.mjs

📝 Walkthrough

Walkthrough

Changes

npm publishing bootstrap

Layer / File(s) Summary
Publish dist-tag support
scripts/build-npm.mjs
Adds --tag and NPM_TAG handling and forwards a configured dist-tag to npm publish.
Ordered tarball bootstrap publishing
scripts/bootstrap-npm.sh
Adds strict argument parsing, package metadata validation, duplicate/version checks, dry-run support, and binary-before-launcher publication ordering.
Trusted Publishing bootstrap instructions
docs/npm-publishing.md
Documents maintainer first publishes, Trusted Publishing follow-up releases, tarball preparation, and placeholder reservation with the bootstrap tag.

Sequence Diagram(s)

sequenceDiagram
  participant Maintainer
  participant bootstrap_npm_sh
  participant npm_registry
  Maintainer->>bootstrap_npm_sh: Provide tarball directory and options
  bootstrap_npm_sh->>bootstrap_npm_sh: Validate and classify seven tarballs
  bootstrap_npm_sh->>npm_registry: Check package versions
  bootstrap_npm_sh->>npm_registry: Publish six platform packages
  bootstrap_npm_sh->>npm_registry: Publish launcher package
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ffd61203-c13e-45b3-b148-2683a954ebbb

📥 Commits

Reviewing files that changed from the base of the PR and between ce801a0 and 0cb1c57.

📒 Files selected for processing (3)
  • docs/npm-publishing.md
  • scripts/bootstrap-npm.sh
  • scripts/build-npm.mjs

Comment thread scripts/bootstrap-npm.sh
Comment thread scripts/bootstrap-npm.sh Outdated
Comment thread scripts/bootstrap-npm.sh Outdated
…trap resumable

Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
@ajay-bhargava
ajay-bhargava merged commit 764c720 into main Jul 27, 2026
4 checks passed
@ajay-bhargava
ajay-bhargava deleted the docs/npm-bootstrap branch July 27, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant