From ae8e12a7ea63505e20a1e6898e8580f51e1dd7a6 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Wed, 26 Nov 2025 07:35:30 -0800 Subject: [PATCH 1/6] [jj-spr] initial version Created using jj-spr 0.1.0 --- .gitignore | 4 ++ .../test/backward-compatibility.test.ts | 46 +++++++++++++------ flake.nix | 9 +++- 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index a465194539..7e3dafb63d 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,10 @@ Session.vim # just in case we use npm by mistake apps/framework-internal-app/package-lock.json +# Local npm directories (for backward compatibility tests) +.npm-cache/ +.npm-global/ + packages/ts-moose-proto/generated/ # ignore all scratch files and folders diff --git a/apps/framework-cli-e2e/test/backward-compatibility.test.ts b/apps/framework-cli-e2e/test/backward-compatibility.test.ts index 8e85887b5f..915aee44c2 100644 --- a/apps/framework-cli-e2e/test/backward-compatibility.test.ts +++ b/apps/framework-cli-e2e/test/backward-compatibility.test.ts @@ -54,22 +54,38 @@ const MOOSE_PY_LIB_PATH = path.resolve( "../../../packages/py-moose-lib", ); +// Path to npm-installed CLI (will be set by checkLatestPublishedCLI) +let LATEST_CLI_PATH: string; + /** - * Check the latest published version of moose-cli + * Install and check the latest published version of moose-cli + * Uses npm install instead of npx to ensure consistent registry behavior */ async function checkLatestPublishedCLI(): Promise { - console.log("Checking latest published moose-cli from npm..."); + console.log("Installing latest published moose-cli from npm..."); - // Check if npx moose-cli is available (this downloads the latest version) try { - const { stdout } = await execAsync( - "npx -y @514labs/moose-cli@latest --version", + // Install CLI using npm (not npx) to ensure consistent registry usage + const installResult = await execAsync( + "npm install --no-save @514labs/moose-cli@latest", + ); + console.log("npm install output:", installResult.stdout); + + // Find the installed CLI binary + const { stdout: cliPath } = await execAsync( + "npm bin --no-save", ); - console.log("Latest published CLI version:", stdout.trim()); + LATEST_CLI_PATH = path.join(cliPath.trim(), "moose-cli"); + + // Verify it works + const { stdout: version } = await execAsync(`"${LATEST_CLI_PATH}" --version`); + console.log("Latest published CLI version:", version.trim()); } catch (error: any) { - console.error("Failed to get latest CLI from npm:", error.message); + console.error("Failed to install latest CLI from npm:", error.message); + if (error.stdout) console.error("stdout:", error.stdout); + if (error.stderr) console.error("stderr:", error.stderr); throw new Error( - "Cannot check latest published CLI for backward compatibility test", + "Cannot install latest published CLI for backward compatibility test", ); } } @@ -85,9 +101,9 @@ async function setupTypeScriptProjectWithLatestNpm( console.log(`Initializing TypeScript project with latest npm moose-cli...`); try { - // using npx for both languages as they are the same binary + // Use npm-installed CLI instead of npx for consistent registry behavior const result = await execAsync( - `npx -y @514labs/moose-cli@latest init ${appName} ${templateName} --location "${projectDir}"`, + `"${LATEST_CLI_PATH}" init ${appName} ${templateName} --location "${projectDir}"`, ); console.log("CLI init stdout:", result.stdout); if (result.stderr) { @@ -130,10 +146,10 @@ async function setupPythonProjectWithLatestPypi( ): Promise { console.log(`Initializing Python project with latest pypi moose-cli...`); - // Initialize project with latest CLI via npx + // Initialize project with latest CLI (npm-installed, not npx) try { const result = await execAsync( - `npx -y @514labs/moose-cli@latest init ${appName} ${templateName} --location "${projectDir}"`, + `"${LATEST_CLI_PATH}" init ${appName} ${templateName} --location "${projectDir}"`, ); console.log("CLI init stdout:", result.stdout); if (result.stderr) { @@ -284,9 +300,9 @@ describe("Backward Compatibility Tests", function () { } fs.writeFileSync(mooseConfigPath, mooseConfig); - // Start dev server with LATEST published CLI via npx + // Start dev server with LATEST published CLI (npm-installed) console.log( - "Starting dev server with LATEST published CLI (via npx)...", + "Starting dev server with LATEST published CLI (npm-installed)...", ); const devEnv = config.language === "python" ? @@ -305,7 +321,7 @@ describe("Backward Compatibility Tests", function () { TEST_AWS_SECRET_ACCESS_KEY: "test-secret-access-key", }; - devProcess = spawn("npx", ["-y", "@514labs/moose-cli@latest", "dev"], { + devProcess = spawn(LATEST_CLI_PATH, ["dev"], { stdio: "pipe", cwd: TEST_PROJECT_DIR, env: devEnv, diff --git a/flake.nix b/flake.nix index f2617ad586..1b8953b6b1 100644 --- a/flake.nix +++ b/flake.nix @@ -57,7 +57,7 @@ pnpm = pkgs.pnpm; # Python with required packages (wrapped with safe-chain for malware protection) - python = pkgs.python312; + python = pkgs.python313; pythonEnv = (python.withPackages ( ps: with ps; [ pip @@ -171,6 +171,13 @@ # Set Python path for development export PYTHONPATH="$PWD/packages/py-moose-lib:$PYTHONPATH" + + # Configure npm to use local directories (for backward compatibility tests) + # This avoids needing global npm install access + mkdir -p "$PWD/.npm-cache" "$PWD/.npm-global"/{lib,bin,share} + export NPM_CONFIG_CACHE="$PWD/.npm-cache" + export NPM_CONFIG_PREFIX="$PWD/.npm-global" + export PATH="$PWD/.npm-global/bin:$PATH" ''; }; From 06c106fb9dceacc82b0f67c948f64b03be6efd6d Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Wed, 26 Nov 2025 07:38:22 -0800 Subject: [PATCH 2/6] format Created using jj-spr 0.1.0 --- .../framework-cli-e2e/test/backward-compatibility.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/framework-cli-e2e/test/backward-compatibility.test.ts b/apps/framework-cli-e2e/test/backward-compatibility.test.ts index 915aee44c2..062ac1928d 100644 --- a/apps/framework-cli-e2e/test/backward-compatibility.test.ts +++ b/apps/framework-cli-e2e/test/backward-compatibility.test.ts @@ -72,13 +72,13 @@ async function checkLatestPublishedCLI(): Promise { console.log("npm install output:", installResult.stdout); // Find the installed CLI binary - const { stdout: cliPath } = await execAsync( - "npm bin --no-save", - ); + const { stdout: cliPath } = await execAsync("npm bin --no-save"); LATEST_CLI_PATH = path.join(cliPath.trim(), "moose-cli"); // Verify it works - const { stdout: version } = await execAsync(`"${LATEST_CLI_PATH}" --version`); + const { stdout: version } = await execAsync( + `"${LATEST_CLI_PATH}" --version`, + ); console.log("Latest published CLI version:", version.trim()); } catch (error: any) { console.error("Failed to install latest CLI from npm:", error.message); From 73ccd44d7863f785f41f855ab7c3120b77eecb82 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Wed, 26 Nov 2025 08:02:10 -0800 Subject: [PATCH 3/6] use pnpm for everything Created using jj-spr 0.1.0 --- .../test/backward-compatibility.test.ts | 43 +++++++++++++------ pnpm-lock.yaml | 4 +- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/apps/framework-cli-e2e/test/backward-compatibility.test.ts b/apps/framework-cli-e2e/test/backward-compatibility.test.ts index 062ac1928d..efd885b853 100644 --- a/apps/framework-cli-e2e/test/backward-compatibility.test.ts +++ b/apps/framework-cli-e2e/test/backward-compatibility.test.ts @@ -56,32 +56,47 @@ const MOOSE_PY_LIB_PATH = path.resolve( // Path to npm-installed CLI (will be set by checkLatestPublishedCLI) let LATEST_CLI_PATH: string; +let CLI_INSTALL_DIR: string; /** * Install and check the latest published version of moose-cli - * Uses npm install instead of npx to ensure consistent registry behavior + * Uses pnpm for consistency with the monorepo */ async function checkLatestPublishedCLI(): Promise { console.log("Installing latest published moose-cli from npm..."); try { - // Install CLI using npm (not npx) to ensure consistent registry usage + // Create a temp directory for CLI install + const os = require("os"); + CLI_INSTALL_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "moose-cli-")); + console.log(`Installing CLI to temp directory: ${CLI_INSTALL_DIR}`); + + // Install CLI using pnpm (consistent with monorepo) const installResult = await execAsync( - "npm install --no-save @514labs/moose-cli@latest", + "pnpm add @514labs/moose-cli@latest", + { cwd: CLI_INSTALL_DIR }, + ); + console.log("pnpm install output:", installResult.stdout); + + // Find the installed CLI binary in pnpm's structure + LATEST_CLI_PATH = path.join( + CLI_INSTALL_DIR, + "node_modules", + ".bin", + "moose-cli", ); - console.log("npm install output:", installResult.stdout); - // Find the installed CLI binary - const { stdout: cliPath } = await execAsync("npm bin --no-save"); - LATEST_CLI_PATH = path.join(cliPath.trim(), "moose-cli"); + // Verify it exists and works + if (!fs.existsSync(LATEST_CLI_PATH)) { + throw new Error(`CLI binary not found at ${LATEST_CLI_PATH}`); + } - // Verify it works const { stdout: version } = await execAsync( `"${LATEST_CLI_PATH}" --version`, ); console.log("Latest published CLI version:", version.trim()); } catch (error: any) { - console.error("Failed to install latest CLI from npm:", error.message); + console.error("Failed to install latest CLI:", error.message); if (error.stdout) console.error("stdout:", error.stdout); if (error.stderr) console.error("stderr:", error.stderr); throw new Error( @@ -116,21 +131,21 @@ async function setupTypeScriptProjectWithLatestNpm( throw error; } - // Install dependencies with latest moose-lib from npm + // Install dependencies with latest moose-lib using pnpm console.log( - "Installing dependencies with npm (using latest @514labs/moose-lib)...", + "Installing dependencies with pnpm (using latest @514labs/moose-lib)...", ); await new Promise((resolve, reject) => { - const installCmd = spawn("npm", ["install"], { + const installCmd = spawn("pnpm", ["install"], { stdio: "inherit", cwd: projectDir, }); installCmd.on("close", (code) => { - console.log(`npm install exited with code ${code}`); + console.log(`pnpm install exited with code ${code}`); if (code === 0) { resolve(); } else { - reject(new Error(`npm install failed with code ${code}`)); + reject(new Error(`pnpm install failed with code ${code}`)); } }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 20d90858fb..fde755e678 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15357,7 +15357,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.1(@typescript-eslint/parser@8.46.3(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)): + eslint-module-utils@2.12.1(@typescript-eslint/parser@8.46.3(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1)))(eslint@9.39.1(jiti@2.6.1)): dependencies: debug: 3.2.7 optionalDependencies: @@ -15408,7 +15408,7 @@ snapshots: doctrine: 2.1.0 eslint: 9.39.1(jiti@2.6.1) eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.46.3(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)) + eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.46.3(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1)))(eslint@9.39.1(jiti@2.6.1)) hasown: 2.0.2 is-core-module: 2.16.1 is-glob: 4.0.3 From 7d4dd0b47eef769f5aadf62fe857db4b9a80c726 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Wed, 26 Nov 2025 08:07:27 -0800 Subject: [PATCH 4/6] remove unneeded itens Created using jj-spr 0.1.0 --- .gitignore | 4 ---- flake.nix | 7 ------- 2 files changed, 11 deletions(-) diff --git a/.gitignore b/.gitignore index 7e3dafb63d..a465194539 100644 --- a/.gitignore +++ b/.gitignore @@ -63,10 +63,6 @@ Session.vim # just in case we use npm by mistake apps/framework-internal-app/package-lock.json -# Local npm directories (for backward compatibility tests) -.npm-cache/ -.npm-global/ - packages/ts-moose-proto/generated/ # ignore all scratch files and folders diff --git a/flake.nix b/flake.nix index 1b8953b6b1..a7073db62e 100644 --- a/flake.nix +++ b/flake.nix @@ -171,13 +171,6 @@ # Set Python path for development export PYTHONPATH="$PWD/packages/py-moose-lib:$PYTHONPATH" - - # Configure npm to use local directories (for backward compatibility tests) - # This avoids needing global npm install access - mkdir -p "$PWD/.npm-cache" "$PWD/.npm-global"/{lib,bin,share} - export NPM_CONFIG_CACHE="$PWD/.npm-cache" - export NPM_CONFIG_PREFIX="$PWD/.npm-global" - export PATH="$PWD/.npm-global/bin:$PATH" ''; }; From 48b1ebe9f5398a6959e0904653f641b7c5bfbae9 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Wed, 26 Nov 2025 08:10:35 -0800 Subject: [PATCH 5/6] fix clean up bug Created using jj-spr 0.1.0 --- .npm-cache/_update-notifier-last-checked | 0 .../test/backward-compatibility.test.ts | 12 ++++++++++++ 2 files changed, 12 insertions(+) create mode 100644 .npm-cache/_update-notifier-last-checked diff --git a/.npm-cache/_update-notifier-last-checked b/.npm-cache/_update-notifier-last-checked new file mode 100644 index 0000000000..e69de29bb2 diff --git a/apps/framework-cli-e2e/test/backward-compatibility.test.ts b/apps/framework-cli-e2e/test/backward-compatibility.test.ts index efd885b853..b3d293156a 100644 --- a/apps/framework-cli-e2e/test/backward-compatibility.test.ts +++ b/apps/framework-cli-e2e/test/backward-compatibility.test.ts @@ -262,6 +262,18 @@ describe("Backward Compatibility Tests", function () { } }); + after(function () { + // Clean up temporary CLI install directory + if (CLI_INSTALL_DIR) { + try { + console.log(`Cleaning up temporary CLI install directory: ${CLI_INSTALL_DIR}`); + fs.rmSync(CLI_INSTALL_DIR, { recursive: true, force: true }); + } catch (error) { + console.error(`Failed to clean up CLI install directory: ${error}`); + } + } + }); + for (const config of BACKWARD_COMPAT_CONFIGS) { describe(`${config.displayName} - Upgrade from n-1 to n`, function () { let devProcess: ChildProcess | null = null; From 13d59e6e76c8e8484988c806c64ab3e3a57de1b6 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Wed, 26 Nov 2025 08:12:00 -0800 Subject: [PATCH 6/6] format Created using jj-spr 0.1.0 --- apps/framework-cli-e2e/test/backward-compatibility.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/framework-cli-e2e/test/backward-compatibility.test.ts b/apps/framework-cli-e2e/test/backward-compatibility.test.ts index b3d293156a..dc1218bee8 100644 --- a/apps/framework-cli-e2e/test/backward-compatibility.test.ts +++ b/apps/framework-cli-e2e/test/backward-compatibility.test.ts @@ -266,7 +266,9 @@ describe("Backward Compatibility Tests", function () { // Clean up temporary CLI install directory if (CLI_INSTALL_DIR) { try { - console.log(`Cleaning up temporary CLI install directory: ${CLI_INSTALL_DIR}`); + console.log( + `Cleaning up temporary CLI install directory: ${CLI_INSTALL_DIR}`, + ); fs.rmSync(CLI_INSTALL_DIR, { recursive: true, force: true }); } catch (error) { console.error(`Failed to clean up CLI install directory: ${error}`);