@@ -56,32 +56,47 @@ const MOOSE_PY_LIB_PATH = path.resolve(
5656
5757// Path to npm-installed CLI (will be set by checkLatestPublishedCLI)
5858let LATEST_CLI_PATH : string ;
59+ let CLI_INSTALL_DIR : string ;
5960
6061/**
6162 * Install and check the latest published version of moose-cli
62- * Uses npm install instead of npx to ensure consistent registry behavior
63+ * Uses pnpm for consistency with the monorepo
6364 */
6465async function checkLatestPublishedCLI ( ) : Promise < void > {
6566 console . log ( "Installing latest published moose-cli from npm..." ) ;
6667
6768 try {
68- // Install CLI using npm (not npx) to ensure consistent registry usage
69+ // Create a temp directory for CLI install
70+ const os = require ( "os" ) ;
71+ CLI_INSTALL_DIR = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "moose-cli-" ) ) ;
72+ console . log ( `Installing CLI to temp directory: ${ CLI_INSTALL_DIR } ` ) ;
73+
74+ // Install CLI using pnpm (consistent with monorepo)
6975 const installResult = await execAsync (
70- "npm install --no-save @514labs/moose-cli@latest" ,
76+ "pnpm add @514labs/moose-cli@latest" ,
77+ { cwd : CLI_INSTALL_DIR } ,
78+ ) ;
79+ console . log ( "pnpm install output:" , installResult . stdout ) ;
80+
81+ // Find the installed CLI binary in pnpm's structure
82+ LATEST_CLI_PATH = path . join (
83+ CLI_INSTALL_DIR ,
84+ "node_modules" ,
85+ ".bin" ,
86+ "moose-cli" ,
7187 ) ;
72- console . log ( "npm install output:" , installResult . stdout ) ;
7388
74- // Find the installed CLI binary
75- const { stdout : cliPath } = await execAsync ( "npm bin --no-save" ) ;
76- LATEST_CLI_PATH = path . join ( cliPath . trim ( ) , "moose-cli" ) ;
89+ // Verify it exists and works
90+ if ( ! fs . existsSync ( LATEST_CLI_PATH ) ) {
91+ throw new Error ( `CLI binary not found at ${ LATEST_CLI_PATH } ` ) ;
92+ }
7793
78- // Verify it works
7994 const { stdout : version } = await execAsync (
8095 `"${ LATEST_CLI_PATH } " --version` ,
8196 ) ;
8297 console . log ( "Latest published CLI version:" , version . trim ( ) ) ;
8398 } catch ( error : any ) {
84- console . error ( "Failed to install latest CLI from npm :" , error . message ) ;
99+ console . error ( "Failed to install latest CLI:" , error . message ) ;
85100 if ( error . stdout ) console . error ( "stdout:" , error . stdout ) ;
86101 if ( error . stderr ) console . error ( "stderr:" , error . stderr ) ;
87102 throw new Error (
@@ -116,21 +131,21 @@ async function setupTypeScriptProjectWithLatestNpm(
116131 throw error ;
117132 }
118133
119- // Install dependencies with latest moose-lib from npm
134+ // Install dependencies with latest moose-lib using pnpm
120135 console . log (
121- "Installing dependencies with npm (using latest @514labs/moose-lib)..." ,
136+ "Installing dependencies with pnpm (using latest @514labs/moose-lib)..." ,
122137 ) ;
123138 await new Promise < void > ( ( resolve , reject ) => {
124- const installCmd = spawn ( "npm " , [ "install" ] , {
139+ const installCmd = spawn ( "pnpm " , [ "install" ] , {
125140 stdio : "inherit" ,
126141 cwd : projectDir ,
127142 } ) ;
128143 installCmd . on ( "close" , ( code ) => {
129- console . log ( `npm install exited with code ${ code } ` ) ;
144+ console . log ( `pnpm install exited with code ${ code } ` ) ;
130145 if ( code === 0 ) {
131146 resolve ( ) ;
132147 } else {
133- reject ( new Error ( `npm install failed with code ${ code } ` ) ) ;
148+ reject ( new Error ( `pnpm install failed with code ${ code } ` ) ) ;
134149 }
135150 } ) ;
136151 } ) ;
0 commit comments