Skip to content

feat(release): publish ck as @beaconbay/ck-search on npm#117

Merged
runonthespot merged 1 commit into
mainfrom
feat/npm-distribution
May 24, 2026
Merged

feat(release): publish ck as @beaconbay/ck-search on npm#117
runonthespot merged 1 commit into
mainfrom
feat/npm-distribution

Conversation

@runonthespot
Copy link
Copy Markdown
Contributor

Summary

Adds the second distribution channel asked for in the original release plan: `npm install -g @beaconbay/ck-search` for users who don't have Rust installed.

How it works

  • `package.json` declares `@beaconbay/ck-search` with a postinstall script and the `ck` bin entry pointing to a thin JS wrapper.
  • `scripts/install.js` runs on `npm install`: detects platform, builds the matching GitHub release asset URL (`ck-X.Y.Z-.{tar.gz|zip}`), downloads + extracts into `dist/bin/`. Falls back to `cargo build` if invoked from a checkout (the published tarball deliberately doesn't ship Rust source, so the fallback is realistic only for local installs).
  • `cli/ck.js` is a thin `spawn` wrapper that runs `dist/bin/ck` with inherited stdio.
  • `scripts/test.js` is the postinstall smoke test (`npm test`).
  • `.npmignore` restricts the published tarball to just `cli/`, `scripts/`, `package.json`, `README.md`, `LICENSE-*`.

`release.yml` changes

  • New `publish-npm` job after `build-release`. Version is single-source-of-truth: the workspace `Cargo.toml` version + the git tag are the gate. The job runs `npm version --no-git-tag-version` to stamp `package.json` at publish time — maintainers never have to bump `package.json` manually.
  • Idempotent (skips publish if `@beaconbay/ck-search@X.Y.Z` already exists on npm).
  • `finalize-release` now waits on both `publish-crates` and `publish-npm`.

New repo secret required

Validated locally against the live 0.7.7 release

  • `npm pack --dry-run` → clean 15 kB tarball, 7 files (`cli/ck.js`, `scripts/install.js`, `scripts/test.js`, `package.json`, `README.md`, `LICENSE-MIT`, `LICENSE-APACHE`)
  • `node scripts/install.js` → correctly detected `aarch64-apple-darwin`, downloaded + extracted from GH release
  • `node cli/ck.js --version` → prints `ck 0.7.7`
  • `node scripts/test.js` → `✓ ck binary works: ck 0.7.7`

Origin

These files are a re-pickup of the abandoned `feature/npm-distribution` branch from October 2025 (four commits by @runonthespot — 9b20ae0, cff3623, 5a53b72, 40e3d01). The branch was too far behind `main` to rebase cleanly, so I ported the files verbatim onto current `main` with these adjustments:

  • `package.json` version bumped from stale `0.7.0` to current `0.7.7`
  • Removed dead `"main": "index.js"` (no such file exists)
  • Workflow rewritten to auto-stamp package.json version from Cargo.toml at publish time, rather than requiring both to be hand-kept in sync

Test plan

  • `npm pack --dry-run` clean
  • `node -c` syntax check on all 3 JS files
  • Full install flow against live 0.7.7 GH release
  • `cargo fmt --check` clean
  • CI green on this PR
  • After merge: set `NPM_TOKEN` secret, cut 0.7.8, verify first npm publish

Out of scope (follow-ups)

  • The `buildFromSource` cargo fallback path in `install.js` can never fire from a published npm tarball (Rust source is excluded). Could either remove it or improve the error message to point out it's checkout-only. Left as-is to match the original.
  • Linux `aarch64` is not currently built by `release.yml`; npm install on that target falls through to the cargo fallback and fails. Worth adding the target separately.

🤖 Generated with Claude Code

Adds a Node.js wrapper distribution so users can:

    npm install -g @beaconbay/ck-search
    ck --version

How it works:
- Postinstall (scripts/install.js) detects the platform, downloads the
  matching prebuilt binary from the GitHub release for the npm
  package's version (e.g. ck-0.7.7-aarch64-apple-darwin.tar.gz),
  extracts to dist/bin/ck
- cli/ck.js is a thin spawn wrapper that runs dist/bin/ck with
  inherited stdio
- scripts/test.js is a postinstall smoke test (npm test)
- Fallback to \`cargo build\` is kept for source checkouts, but the
  published tarball deliberately excludes Rust source (.npmignore),
  so the fallback is realistically only useful when running this
  out of a git clone

release.yml additions:
- New publish-npm job after build-release
- Version is single-source-of-truth: workspace Cargo.toml + git tag.
  The job runs \`npm version --no-git-tag-version\` to stamp package.json
  at publish time, so maintainers never need to bump it manually.
- Idempotent: skips publish if @beaconbay/ck-search@X.Y.Z already on npm
- Requires NPM_TOKEN repo secret; finalize-release now waits on this

Validated locally against the live 0.7.7 release:
- \`npm pack --dry-run\` produces a clean 15 kB tarball (7 files)
- \`node scripts/install.js\` downloads and extracts the binary
- \`node cli/ck.js --version\` prints "ck 0.7.7"
- \`node scripts/test.js\` smoke test passes

CLAUDE.md updated to clarify maintainers don't need to bump
package.json — Cargo.toml + the tag are the gate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@runonthespot runonthespot merged commit 55681d7 into main May 24, 2026
14 checks passed
@runonthespot runonthespot deleted the feat/npm-distribution branch May 24, 2026 12:57
runonthespot added a commit that referenced this pull request May 24, 2026
Ships everything merged today on top of 0.7.7:

- #117 npm distribution as @beaconbay/ck-search
- #118 dependabot config + safe cargo bumps (incl. openssl CVE fix)
- #119 tar 6 → 7 + engines.node >= 18
- #120 GitHub Actions: checkout v6, codeql v4
- #121 @types/vscode patch
- #122 vue patch (docs-site)
- #125 cargo-safe 20-pack (anyhow, tokio, clap, fastembed 5.13, uuid, etc.)
- #127 shlex 1.3 → 2.0

First release that also publishes to npm. See CHANGELOG.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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