Skip to content

fix(cli): chmod +x dist/index.js so npx invocation works on Linux#23

Merged
faraa2m merged 1 commit into
mainfrom
fix/cli-bin-executable
May 10, 2026
Merged

fix(cli): chmod +x dist/index.js so npx invocation works on Linux#23
faraa2m merged 1 commit into
mainfrom
fix/cli-bin-executable

Conversation

@faraa2m
Copy link
Copy Markdown
Owner

@faraa2m faraa2m commented May 10, 2026

Summary

The v0.1.0 smoke-test job caught a real bug: published `tokenometer@0.1.0` was missing the execute bit on `dist/index.js`. npx-style invocation on Linux fails with `sh: 1: tokenometer: not found`.

`tsc -b` doesn't preserve / set +x. macOS local install side-loaded it; Linux CI didn't. Existing 0.0.x publishes had the same bug — never caught because no-one ran `npx tokenometer` on Linux until the smoke-test job did.

Fix

`packages/cli/package.json` build script:

```diff

  • "build": "tsc -b",
  • "build": "tsc -b && chmod +x dist/index.js",
    ```

Verified locally:
```
$ ls -la packages/cli/dist/index.js
-rwxr-xr-x ... dist/index.js
```

`patch` changeset included for v0.1.1.

After merge

  1. Workflow runs on `main` → opens Version Packages PR (0.1.1).
  2. Merge that PR → publishes tokenometer@0.1.1 and @tokenometer/core@0.1.1 → smoke-test runs against v0.1.1 and passes.
  3. Phase I steps: vsce → tokenometer-vscode@0.1.1 (idempotent shell wrapper from PR fix(release): idempotent vsce/ovsx publish + bump vscode to 0.1.0 #22 lets a re-publish at 0.1.0 succeed if Marketplace already has it).

Wait — extension version is 0.1.0 in main. We could either ship vscode at 0.1.1 too (consistent) or leave at 0.1.0. The Marketplace publish step uses whatever's in packages/vscode/package.json at workflow runtime. Recommend a follow-up to re-bump vscode to 0.1.1 so all 4 packages stay aligned, OR accept that vscode versions can drift.

🤖 Generated with Claude Code

The published `dist/index.js` was emitted by tsc without an execute bit
(`-rw-r--r--`). On macOS, npm-install side-loads +x for entries listed
in `bin`. On Linux runners, the symlink at `node_modules/.bin/tokenometer`
points at a non-executable target, so:

  $ npx --yes tokenometer@0.1.0 --version
  sh: 1: tokenometer: not found

(Caught by the smoke-test job in the v0.1.0 release workflow.)

Build script now chains `chmod +x dist/index.js` after `tsc -b`. The bit
lands in the published tarball, npx invocation works on every platform.

Includes a `patch` changeset so the next release workflow opens a
Version Packages PR for v0.1.1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tokenometer Ready Ready Preview, Comment May 10, 2026 6:10am

@faraa2m faraa2m merged commit 776191c into main May 10, 2026
7 checks passed
@faraa2m faraa2m deleted the fix/cli-bin-executable branch May 10, 2026 06:12
faraa2m added a commit that referenced this pull request May 10, 2026
PR #23 added `chmod +x dist/index.js` to the CLI's build script. That
works for `npm run build --workspace=packages/cli` and local development,
but CI's release job runs root `npm run build` which is just `tsc -b`
and does NOT recurse into workspace npm scripts. Result: published
0.1.1 tarball still had `dist/index.js` without the execute bit, smoke
test failed again with `sh: 1: tokenometer: not found`.

Add `prepack` script in packages/cli/package.json. `prepack` runs
right before `npm publish` packs the tarball — guaranteed to run
regardless of how the build was invoked. Belt and suspenders alongside
the build-script chmod.

Patch changeset for v0.1.2.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
faraa2m added a commit that referenced this pull request May 11, 2026
The published `dist/index.js` was emitted by tsc without an execute bit
(`-rw-r--r--`). On macOS, npm-install side-loads +x for entries listed
in `bin`. On Linux runners, the symlink at `node_modules/.bin/tokenometer`
points at a non-executable target, so:

  $ npx --yes tokenometer@0.1.0 --version
  sh: 1: tokenometer: not found

(Caught by the smoke-test job in the v0.1.0 release workflow.)

Build script now chains `chmod +x dist/index.js` after `tsc -b`. The bit
lands in the published tarball, npx invocation works on every platform.

Includes a `patch` changeset so the next release workflow opens a
Version Packages PR for v0.1.1.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
faraa2m added a commit that referenced this pull request May 11, 2026
PR #23 added `chmod +x dist/index.js` to the CLI's build script. That
works for `npm run build --workspace=packages/cli` and local development,
but CI's release job runs root `npm run build` which is just `tsc -b`
and does NOT recurse into workspace npm scripts. Result: published
0.1.1 tarball still had `dist/index.js` without the execute bit, smoke
test failed again with `sh: 1: tokenometer: not found`.

Add `prepack` script in packages/cli/package.json. `prepack` runs
right before `npm publish` packs the tarball — guaranteed to run
regardless of how the build was invoked. Belt and suspenders alongside
the build-script chmod.

Patch changeset for v0.1.2.

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