Configure CLI build pipeline for npm publishing#2697
Open
ivan-ottinger wants to merge 2 commits intotrunkfrom
Open
Configure CLI build pipeline for npm publishing#2697ivan-ottinger wants to merge 2 commits intotrunkfrom
ivan-ottinger wants to merge 2 commits intotrunkfrom
Conversation
Add a separate Vite config (vite.config.npm.ts) that externalizes all runtime dependencies and adds a Node.js shebang, producing a standalone CLI package publishable to npm as @automattic/studio-cli. The existing Electron-bundled build (vite.config.ts) is unchanged.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prepares the Studio CLI workspace package for publishing to npm under the new scoped name @automattic/studio-cli, including a dedicated npm-oriented build (externalized deps + shebang) and an npm-consumer postinstall pruning step.
Changes:
- Renames the CLI workspace/package to
@automattic/studio-cliand updates workspace script references. - Adds a dedicated
vite.config.npm.tsbuild that externalizes runtime dependencies and prepends a Node shebang tomain.js. - Adds an npm postinstall script to apply patches and prune large/unneeded binaries after install.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updates root scripts to reference the new scoped CLI workspace and adds cli:build:npm. |
| package-lock.json | Reflects the CLI rename/versioning and dependency reshaping needed for npm publishing. |
| apps/studio/package.json | Updates Studio app scripts to call the renamed CLI workspace. |
| apps/cli/vite.config.npm.ts | Introduces npm-specific Vite build config (externalization + shebang injection + locales copy). |
| apps/cli/scripts/postinstall-npm.mjs | Adds npm-consumer postinstall actions (patches + binary pruning). |
| apps/cli/package.json | Updates CLI package metadata for npm publishing (name/version/bin/files/engines/scripts). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove unused `main` field (CLI-only package) - Include source maps in `files` whitelist - Use `npx --no-install` for deterministic postinstall
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
In this PR I am proposing to add a new CLI build - for now with manual package creation. As the next step I am planning to look into our organization npm access so we could manually publish it (privately-first) to npm under
@automattic/studio-cli- if we agree on that name.Then we can continue with making the publishing automated.
How AI was used in this PR
Claude Code implemented the plan from STU-1362 and iterated on build issues (externalized dependency resolution, shebang injection, ...) based on my feedback and manual testing. I have reviewed the whole generated code myself and with Copilot as well.
Proposed Changes
@automattic/studio-cliwith version, bin, files, engines, and publishConfig fields for npm publishingvite.config.npm.ts— a separate Vite config that externalizes all runtime dependencies (npm handles them) and adds a#!/usr/bin/env nodeshebang to the main entry pointscripts/postinstall-npm.mjs— prunes PHP WASM asyncify/web binaries and cross-platform fs-ext binaries after npm install (no-op in workspace context)package.jsonfiles to use the new scoped package namecli:build:npmroot script for the npm buildTesting Instructions
node_modules/in npm build output and shebang is present:Pre-merge Checklist