Skip to content

Conversation

@bcotrim
Copy link
Contributor

@bcotrim bcotrim commented Dec 22, 2025

Related issues

Proposed Changes

  1. Add bundled Node.js binary - The CLI now uses a bundled Node.js binary instead of relying on the Electron run as Node.

  2. Fix Windows terminal popup - Patched the ps-man package to add windowsHide: true to spawn calls. This prevents a brief console window popup (showing C:\WINDOWS\system32\tasklist) when running CLI commands on Windows.

Testing Instructions

Windows

  1. Build the CLI: npm run cli:build
  2. Run node dist/cli/main.js site create --name=test-site
  3. Verify no popup windows appear during site creation
  4. Verify the site is created successfully
  5. Create a site using Studio and confirm operation times are similar

macOS

  1. Build the CLI: npm run cli:build
  2. Run node dist/cli/main.js site create --name=test-site
  3. Verify the site is created successfully
  4. Create a site using Studio and confirm operation times are similar

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@bcotrim bcotrim self-assigned this Dec 22, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

To make this more portable, let's do it in JS instead.

@bcotrim bcotrim force-pushed the stu-1148-investigate-site-create-performance branch from 75bccac to dd6bce1 Compare December 22, 2025 16:33
@bcotrim bcotrim changed the title add bundled node Studio: Add node binary Dec 24, 2025
@bcotrim bcotrim changed the title Studio: Add node binary Studio CLI: Add bundled Node binary and fix Windows popup Dec 24, 2025
@bcotrim bcotrim marked this pull request as ready for review December 24, 2025 11:55
@bcotrim bcotrim requested a review from a team December 24, 2025 12:06
Copy link
Contributor

@nightnei nightnei left a comment

Choose a reason for hiding this comment

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

The code looks great and works as expected:

  1. I don't see popup on windows anymore.
  2. But, I encounter x2 difference in time between CLI and Studio, is it expected?

macOS:
CLI: 6 sec
Studio: 14 sec

Windows:
CLI: 1:40
Studio: 2:50

const nvmrcPath = path.join( __dirname, '..', '.nvmrc' );
if ( fs.existsSync( nvmrcPath ) ) {
const version = fs.readFileSync( nvmrcPath, 'utf-8' ).trim();
// Ensure version starts with 'v'
Copy link
Contributor

Choose a reason for hiding this comment

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

The code looks self-explanatory

Suggested change
// Ensure version starts with 'v'

export function getBundledNodeBinaryPath(): string {
const nodeBinaryName = process.platform === 'win32' ? 'node.exe' : 'node';

if ( process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test' ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am thinking - should we keep it only for tests? To have it used in development, to work with the same as in prod, to avoid if in prod something will be unexpectedly broken?

Suggested change
if ( process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test' ) {
if ( process.env.NODE_ENV === 'test' ) {

Copy link
Contributor

Choose a reason for hiding this comment

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

The only time we can guarantee that the bundled node binary is available is in the production build. I flipped the logic in this function to return the bundled path only when NODE_ENV === 'production'

Copy link
Contributor

@fredrikekelund fredrikekelund left a comment

Choose a reason for hiding this comment

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

Great initiative! I'm very optimistic about the performance impact of this change.

I made a couple of changes to this PR:

  • Refined scripts/download-node-binary.mjs in 17e2ead
  • Updated ./bin scripts to use the bundled node binary in 4e77d33 (meaning Electron isn't involved when users run studio from the terminal, either)
  • Use the system-level node binary when forking CLI processes during development in f0b9873 (this addresses the performance problems @nightnei noted in #2303 (review))

With those changes in place, this PR should be good to land 👍

@fredrikekelund fredrikekelund merged commit 9e19d25 into dev/studio-cli-i2 Jan 2, 2026
3 of 5 checks passed
@fredrikekelund fredrikekelund deleted the stu-1148-investigate-site-create-performance branch January 2, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants