From 081f785bd71ccab666725838892790a02619546b Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 6 Aug 2025 22:07:24 -1000 Subject: [PATCH 1/7] Support linking to @roo-code/cloud in `Roo-Code` repo --- package.json | 4 +- scripts/link-cloud.js | 130 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 1 deletion(-) create mode 100755 scripts/link-cloud.js diff --git a/package.json b/package.json index 5e73f0c479e..a481bb862c5 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,9 @@ "changeset:version": "cp CHANGELOG.md src/CHANGELOG.md && changeset version && cp -vf src/CHANGELOG.md .", "knip": "knip --include files", "update-contributors": "node scripts/update-contributors.js", - "evals": "dotenvx run -f packages/evals/.env.development packages/evals/.env.local -- docker compose -f packages/evals/docker-compose.yml --profile server --profile runner up --build --scale runner=0" + "evals": "dotenvx run -f packages/evals/.env.development packages/evals/.env.local -- docker compose -f packages/evals/docker-compose.yml --profile server --profile runner up --build --scale runner=0", + "link:cloud": "node scripts/link-cloud.js", + "unlink:cloud": "rm -f src/node_modules/@roo-code/cloud && cd src && pnpm install && echo 'βœ… @roo-code/cloud SDK unlinked successfully!'" }, "devDependencies": { "@changesets/cli": "^2.27.10", diff --git a/scripts/link-cloud.js b/scripts/link-cloud.js new file mode 100755 index 00000000000..b2b491e6fde --- /dev/null +++ b/scripts/link-cloud.js @@ -0,0 +1,130 @@ +#!/usr/bin/env node + +const { spawn, execSync } = require("child_process") +const path = require("path") +const fs = require("fs") + +const colors = { + yellow: "\x1b[33m", + green: "\x1b[32m", + blue: "\x1b[34m", + red: "\x1b[31m", + reset: "\x1b[0m", +} + +const log = (color, message) => { + console.log(`${colors[color]}${message}${colors.reset}`) +} + +const cloudSdkPath = path.join(__dirname, "../../Roo-Code-Cloud/packages/sdk") +const extensionPath = path.join(__dirname, "../src") +const extensionNodeModules = path.join(extensionPath, "node_modules") +const targetPath = path.join(extensionNodeModules, "@roo-code/cloud") + +if (!fs.existsSync(cloudSdkPath)) { + log("red", "❌ Error: Roo-Code-Cloud repository not found at ../Roo-Code-Cloud") + log("yellow", "Please ensure the Roo-Code-Cloud repository is cloned adjacent to the Roo-Code repository.") + process.exit(1) +} + +log("yellow", "πŸ”— Setting up @roo-code/cloud SDK link...") + +try { + // Step 1: Check if dependencies are already installed + log("yellow", "πŸ“¦ Checking SDK dependencies...") + const nodeModulesPath = path.join(cloudSdkPath, "node_modules") + + if (!fs.existsSync(nodeModulesPath)) { + log("yellow", "πŸ“¦ Installing SDK dependencies...") + + try { + execSync("pnpm install", { + cwd: cloudSdkPath, + stdio: "inherit", + env: { ...process.env, FORCE_COLOR: "1" }, + }) + } catch (installError) { + log("red", "❌ Failed to install dependencies. Trying with --no-frozen-lockfile...") + + execSync("pnpm install --no-frozen-lockfile", { + cwd: cloudSdkPath, + stdio: "inherit", + env: { ...process.env, FORCE_COLOR: "1" }, + }) + } + } else { + log("green", "βœ“ Dependencies already installed") + } + + // Step 2: Build in development mode + log("yellow", "πŸ”¨ Building SDK in development mode...") + + execSync("pnpm build:development", { + cwd: cloudSdkPath, + stdio: "inherit", + env: { ...process.env, FORCE_COLOR: "1" }, + }) + + // Step 3: Build for npm directory + log("yellow", "πŸ“¦ Building for npm directory...") + + execSync("NODE_ENV=development pnpm tsup --outDir npm/dist", { + cwd: cloudSdkPath, + stdio: "inherit", + env: { ...process.env, NODE_ENV: "development", FORCE_COLOR: "1" }, + }) + + // Step 4: Remove existing link if it exists + if (fs.existsSync(targetPath)) { + log("yellow", "πŸ—‘οΈ Removing existing @roo-code/cloud package...") + fs.rmSync(targetPath, { recursive: true, force: true }) + } + + // Step 5: Create @roo-code directory if needed + const rooCodeDir = path.join(extensionNodeModules, "@roo-code") + if (!fs.existsSync(rooCodeDir)) { + fs.mkdirSync(rooCodeDir, { recursive: true }) + } + + // Step 6: Create symlink + const npmPath = path.join(cloudSdkPath, "npm") + fs.symlinkSync(npmPath, targetPath, "dir") + + log("green", "βœ… @roo-code/cloud SDK linked successfully!") + log("green", `πŸ“ Linked: ${targetPath} β†’ ${npmPath}`) +} catch (error) { + log("red", "❌ Error during linking process:") + console.error(error.message) + process.exit(1) +} + +log("blue", "πŸš€ Starting SDK watch mode...\n") + +const sdkProcess = spawn("pnpm", ["build:development:watch"], { + cwd: cloudSdkPath, + stdio: ["inherit", "pipe", "pipe"], + shell: true, +}) + +sdkProcess.stdout.on("data", (data) => { + process.stdout.write(`${colors.blue}[SDK]${colors.reset} ${data}`) +}) + +sdkProcess.stderr.on("data", (data) => { + process.stderr.write(`${colors.red}[SDK]${colors.reset} ${data}`) +}) + +const cleanup = () => { + log("yellow", "\nπŸ›‘ Stopping SDK watch mode...") + sdkProcess.kill() + process.exit(0) +} + +process.on("SIGINT", cleanup) +process.on("SIGTERM", cleanup) + +log("green", "\nβœ… SDK is now linked and watching for changes!") +log("yellow", "\nπŸ“ Next steps:") +log("yellow", "1. Press F5 in VSCode to launch the extension") +log("yellow", "2. The extension will automatically reload when SDK changes are detected") +log("yellow", "3. Press Ctrl+C here to stop the SDK watch mode\n") From 6ce3aab1cc228c9e9d7b5100bd48ada88a1e2b74 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 6 Aug 2025 22:13:01 -1000 Subject: [PATCH 2/7] More progress --- scripts/link-cloud.js | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/scripts/link-cloud.js b/scripts/link-cloud.js index b2b491e6fde..b1b9acae586 100755 --- a/scripts/link-cloud.js +++ b/scripts/link-cloud.js @@ -56,37 +56,19 @@ try { log("green", "βœ“ Dependencies already installed") } - // Step 2: Build in development mode - log("yellow", "πŸ”¨ Building SDK in development mode...") - - execSync("pnpm build:development", { - cwd: cloudSdkPath, - stdio: "inherit", - env: { ...process.env, FORCE_COLOR: "1" }, - }) - - // Step 3: Build for npm directory - log("yellow", "πŸ“¦ Building for npm directory...") - - execSync("NODE_ENV=development pnpm tsup --outDir npm/dist", { - cwd: cloudSdkPath, - stdio: "inherit", - env: { ...process.env, NODE_ENV: "development", FORCE_COLOR: "1" }, - }) - - // Step 4: Remove existing link if it exists + // Step 2: Remove existing link if it exists if (fs.existsSync(targetPath)) { log("yellow", "πŸ—‘οΈ Removing existing @roo-code/cloud package...") fs.rmSync(targetPath, { recursive: true, force: true }) } - // Step 5: Create @roo-code directory if needed + // Step 3: Create @roo-code directory if needed const rooCodeDir = path.join(extensionNodeModules, "@roo-code") if (!fs.existsSync(rooCodeDir)) { fs.mkdirSync(rooCodeDir, { recursive: true }) } - // Step 6: Create symlink + // Step 4: Create symlink const npmPath = path.join(cloudSdkPath, "npm") fs.symlinkSync(npmPath, targetPath, "dir") From 0d2dc2c4266fe3bbe3aa4c8aad2a17d238b79634 Mon Sep 17 00:00:00 2001 From: Chris Estreich Date: Wed, 6 Aug 2025 22:21:49 -1000 Subject: [PATCH 3/7] Update scripts/link-cloud.js Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com> --- scripts/link-cloud.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/link-cloud.js b/scripts/link-cloud.js index b1b9acae586..82fe10269f5 100755 --- a/scripts/link-cloud.js +++ b/scripts/link-cloud.js @@ -88,6 +88,16 @@ const sdkProcess = spawn("pnpm", ["build:development:watch"], { shell: true, }) +sdkProcess.on('error', (error) => { + log("red", "❌ Failed to start SDK watch mode: " + error.message) + log("yellow", "Make sure 'build:development:watch' script exists in the Cloud SDK package.json") + process.exit(1) +}) + cwd: cloudSdkPath, + stdio: ["inherit", "pipe", "pipe"], + shell: true, +}) + sdkProcess.stdout.on("data", (data) => { process.stdout.write(`${colors.blue}[SDK]${colors.reset} ${data}`) }) From d6f0a2fc1a855a65f17cc4f7f8429f07b0d816fe Mon Sep 17 00:00:00 2001 From: cte Date: Thu, 7 Aug 2025 00:01:49 -1000 Subject: [PATCH 4/7] More progress --- src/extension.ts | 48 ++++++++++++++++++++++++++++++++++++----------- src/tsconfig.json | 15 ++++++++++++++- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 1fee81a4823..2d95902295d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -207,28 +207,54 @@ export async function activate(context: vscode.ExtensionContext) { // Watch the core files and automatically reload the extension host. if (process.env.NODE_ENV === "development") { - const pattern = "**/*.ts" - const watchPaths = [ - { path: context.extensionPath, name: "extension" }, - { path: path.join(context.extensionPath, "../packages/types"), name: "types" }, - { path: path.join(context.extensionPath, "../packages/telemetry"), name: "telemetry" }, + { path: context.extensionPath, pattern: "**/*.ts" }, + { path: path.join(context.extensionPath, "../packages/types"), pattern: "**/*.ts" }, + { path: path.join(context.extensionPath, "../packages/telemetry"), pattern: "**/*.ts" }, + { path: path.join(context.extensionPath, "node_modules/@roo-code/cloud"), pattern: "**/*" }, ] console.log( - `♻️♻️♻️ Core auto-reloading is ENABLED. Watching for changes in: ${watchPaths.map(({ name }) => name).join(", ")}`, + `♻️♻️♻️ Core auto-reloading: Watching for changes in ${watchPaths.map(({ path }) => path).join(", ")}`, ) - watchPaths.forEach(({ path: watchPath, name }) => { - const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(watchPath, pattern)) + // Create a debounced reload function to prevent excessive reloads + let reloadTimeout: NodeJS.Timeout | undefined + const DEBOUNCE_DELAY = 1_000 + + const debouncedReload = (uri: vscode.Uri) => { + if (reloadTimeout) { + clearTimeout(reloadTimeout) + } - watcher.onDidChange((uri) => { - console.log(`♻️ ${name} file changed: ${uri.fsPath}. Reloading host…`) + console.log(`♻️ ${uri.fsPath} changed; scheduling reload...`) + + reloadTimeout = setTimeout(() => { + console.log(`♻️ Reloading host after debounce delay...`) vscode.commands.executeCommand("workbench.action.reloadWindow") - }) + }, DEBOUNCE_DELAY) + } + + watchPaths.forEach(({ path: watchPath, pattern }) => { + const relPattern = new vscode.RelativePattern(vscode.Uri.file(watchPath), pattern) + const watcher = vscode.workspace.createFileSystemWatcher(relPattern, false, false, false) + + // Listen to all change types to ensure symlinked file updates trigger reloads. + watcher.onDidChange(debouncedReload) + watcher.onDidCreate(debouncedReload) + watcher.onDidDelete(debouncedReload) context.subscriptions.push(watcher) }) + + // Clean up the timeout on deactivation + context.subscriptions.push({ + dispose: () => { + if (reloadTimeout) { + clearTimeout(reloadTimeout) + } + }, + }) } return new API(outputChannel, provider, socketPath, enableLogging) diff --git a/src/tsconfig.json b/src/tsconfig.json index 6b7158c4ab3..ca719e8b11c 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -21,5 +21,18 @@ "useUnknownInCatchVariables": false }, "include": ["."], - "exclude": ["node_modules"] + "exclude": ["node_modules"], + "watchOptions": { + // Use native file system events for files and directories. + "watchFile": "useFsEvents", + "watchDirectory": "useFsEvents", + // Poll files for updates more frequently when they're updated a lot. + "fallbackPolling": "dynamicPriority", + // Don't coalesce watch notification. + "synchronousWatchDirectory": true, + // Finally, two additional settings for reducing the amount of possible + // files to track work from these directories. + "excludeDirectories": ["**/node_modules", "**/dist", "**/.turbo"] + // "excludeFiles": ["build/fileWhichChangesOften.ts"] + } } From ed049656b7cf72f5852db8474194d7e84ff6dab3 Mon Sep 17 00:00:00 2001 From: cte Date: Thu, 7 Aug 2025 00:33:08 -1000 Subject: [PATCH 5/7] Fix link-cloud.js --- scripts/link-cloud.js | 6 +----- src/tsconfig.json | 6 ------ 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/scripts/link-cloud.js b/scripts/link-cloud.js index 82fe10269f5..13bfa60764f 100755 --- a/scripts/link-cloud.js +++ b/scripts/link-cloud.js @@ -88,15 +88,11 @@ const sdkProcess = spawn("pnpm", ["build:development:watch"], { shell: true, }) -sdkProcess.on('error', (error) => { +sdkProcess.on("error", (error) => { log("red", "❌ Failed to start SDK watch mode: " + error.message) log("yellow", "Make sure 'build:development:watch' script exists in the Cloud SDK package.json") process.exit(1) }) - cwd: cloudSdkPath, - stdio: ["inherit", "pipe", "pipe"], - shell: true, -}) sdkProcess.stdout.on("data", (data) => { process.stdout.write(`${colors.blue}[SDK]${colors.reset} ${data}`) diff --git a/src/tsconfig.json b/src/tsconfig.json index ca719e8b11c..90bdb860cd0 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -23,16 +23,10 @@ "include": ["."], "exclude": ["node_modules"], "watchOptions": { - // Use native file system events for files and directories. "watchFile": "useFsEvents", "watchDirectory": "useFsEvents", - // Poll files for updates more frequently when they're updated a lot. "fallbackPolling": "dynamicPriority", - // Don't coalesce watch notification. "synchronousWatchDirectory": true, - // Finally, two additional settings for reducing the amount of possible - // files to track work from these directories. "excludeDirectories": ["**/node_modules", "**/dist", "**/.turbo"] - // "excludeFiles": ["build/fileWhichChangesOften.ts"] } } From b6984c48776fec616fca1a11ad0a624257c05a3a Mon Sep 17 00:00:00 2001 From: cte Date: Thu, 7 Aug 2025 00:54:10 -1000 Subject: [PATCH 6/7] More progress --- package.json | 4 +- scripts/link-cloud.js | 118 --------------------------------------- scripts/link-packages.js | 91 ++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 120 deletions(-) delete mode 100755 scripts/link-cloud.js create mode 100755 scripts/link-packages.js diff --git a/package.json b/package.json index a481bb862c5..c1ddc682234 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,8 @@ "knip": "knip --include files", "update-contributors": "node scripts/update-contributors.js", "evals": "dotenvx run -f packages/evals/.env.development packages/evals/.env.local -- docker compose -f packages/evals/docker-compose.yml --profile server --profile runner up --build --scale runner=0", - "link:cloud": "node scripts/link-cloud.js", - "unlink:cloud": "rm -f src/node_modules/@roo-code/cloud && cd src && pnpm install && echo 'βœ… @roo-code/cloud SDK unlinked successfully!'" + "link-workspace-packages": "node scripts/link-packages.js", + "unlink-workspace-packages": "node scripts/link-packages.js --unlink" }, "devDependencies": { "@changesets/cli": "^2.27.10", diff --git a/scripts/link-cloud.js b/scripts/link-cloud.js deleted file mode 100755 index 13bfa60764f..00000000000 --- a/scripts/link-cloud.js +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env node - -const { spawn, execSync } = require("child_process") -const path = require("path") -const fs = require("fs") - -const colors = { - yellow: "\x1b[33m", - green: "\x1b[32m", - blue: "\x1b[34m", - red: "\x1b[31m", - reset: "\x1b[0m", -} - -const log = (color, message) => { - console.log(`${colors[color]}${message}${colors.reset}`) -} - -const cloudSdkPath = path.join(__dirname, "../../Roo-Code-Cloud/packages/sdk") -const extensionPath = path.join(__dirname, "../src") -const extensionNodeModules = path.join(extensionPath, "node_modules") -const targetPath = path.join(extensionNodeModules, "@roo-code/cloud") - -if (!fs.existsSync(cloudSdkPath)) { - log("red", "❌ Error: Roo-Code-Cloud repository not found at ../Roo-Code-Cloud") - log("yellow", "Please ensure the Roo-Code-Cloud repository is cloned adjacent to the Roo-Code repository.") - process.exit(1) -} - -log("yellow", "πŸ”— Setting up @roo-code/cloud SDK link...") - -try { - // Step 1: Check if dependencies are already installed - log("yellow", "πŸ“¦ Checking SDK dependencies...") - const nodeModulesPath = path.join(cloudSdkPath, "node_modules") - - if (!fs.existsSync(nodeModulesPath)) { - log("yellow", "πŸ“¦ Installing SDK dependencies...") - - try { - execSync("pnpm install", { - cwd: cloudSdkPath, - stdio: "inherit", - env: { ...process.env, FORCE_COLOR: "1" }, - }) - } catch (installError) { - log("red", "❌ Failed to install dependencies. Trying with --no-frozen-lockfile...") - - execSync("pnpm install --no-frozen-lockfile", { - cwd: cloudSdkPath, - stdio: "inherit", - env: { ...process.env, FORCE_COLOR: "1" }, - }) - } - } else { - log("green", "βœ“ Dependencies already installed") - } - - // Step 2: Remove existing link if it exists - if (fs.existsSync(targetPath)) { - log("yellow", "πŸ—‘οΈ Removing existing @roo-code/cloud package...") - fs.rmSync(targetPath, { recursive: true, force: true }) - } - - // Step 3: Create @roo-code directory if needed - const rooCodeDir = path.join(extensionNodeModules, "@roo-code") - if (!fs.existsSync(rooCodeDir)) { - fs.mkdirSync(rooCodeDir, { recursive: true }) - } - - // Step 4: Create symlink - const npmPath = path.join(cloudSdkPath, "npm") - fs.symlinkSync(npmPath, targetPath, "dir") - - log("green", "βœ… @roo-code/cloud SDK linked successfully!") - log("green", `πŸ“ Linked: ${targetPath} β†’ ${npmPath}`) -} catch (error) { - log("red", "❌ Error during linking process:") - console.error(error.message) - process.exit(1) -} - -log("blue", "πŸš€ Starting SDK watch mode...\n") - -const sdkProcess = spawn("pnpm", ["build:development:watch"], { - cwd: cloudSdkPath, - stdio: ["inherit", "pipe", "pipe"], - shell: true, -}) - -sdkProcess.on("error", (error) => { - log("red", "❌ Failed to start SDK watch mode: " + error.message) - log("yellow", "Make sure 'build:development:watch' script exists in the Cloud SDK package.json") - process.exit(1) -}) - -sdkProcess.stdout.on("data", (data) => { - process.stdout.write(`${colors.blue}[SDK]${colors.reset} ${data}`) -}) - -sdkProcess.stderr.on("data", (data) => { - process.stderr.write(`${colors.red}[SDK]${colors.reset} ${data}`) -}) - -const cleanup = () => { - log("yellow", "\nπŸ›‘ Stopping SDK watch mode...") - sdkProcess.kill() - process.exit(0) -} - -process.on("SIGINT", cleanup) -process.on("SIGTERM", cleanup) - -log("green", "\nβœ… SDK is now linked and watching for changes!") -log("yellow", "\nπŸ“ Next steps:") -log("yellow", "1. Press F5 in VSCode to launch the extension") -log("yellow", "2. The extension will automatically reload when SDK changes are detected") -log("yellow", "3. Press Ctrl+C here to stop the SDK watch mode\n") diff --git a/scripts/link-packages.js b/scripts/link-packages.js new file mode 100755 index 00000000000..6af8c2fc2de --- /dev/null +++ b/scripts/link-packages.js @@ -0,0 +1,91 @@ +#!/usr/bin/env node + +const { spawn, execSync } = require("child_process") +const path = require("path") +const fs = require("fs") + +// Package configuration - Add new packages here as needed. +const config = { + packages: [ + { + name: "@roo-code/cloud", + sourcePath: "../Roo-Code-Cloud/packages/sdk", + targetPath: "src/node_modules/@roo-code/cloud", + npmPath: "npm", + watchCommand: "pnpm build:development:watch", + }, + ], +} + +const args = process.argv.slice(2) +const packageName = args.find((arg) => !arg.startsWith("--")) +const watch = !args.includes("--no-watch") +const unlink = args.includes("--unlink") + +const packages = packageName ? config.packages.filter((p) => p.name === packageName) : config.packages + +if (!packages.length) { + console.error(`Package '${packageName}' not found`) + process.exit(1) +} + +packages.forEach(unlink ? unlinkPackage : linkPackage) + +if (!unlink && watch) { + const watchers = packages.filter((pkg) => pkg.watchCommand).map(startWatch) + + if (watchers.length) { + process.on("SIGINT", () => { + console.log("\nStopping...") + watchers.forEach((w) => w.kill()) + process.exit(0) + }) + console.log("\nWatching for changes. Press Ctrl+C to stop.\n") + } +} + +function linkPackage(pkg) { + const sourcePath = path.resolve(__dirname, "..", pkg.sourcePath) + const targetPath = path.resolve(__dirname, "..", pkg.targetPath) + + if (!fs.existsSync(sourcePath)) { + console.error(`Source not found: ${sourcePath}`) + process.exit(1) + } + + // Install dependencies if needed. + if (!fs.existsSync(path.join(sourcePath, "node_modules"))) { + console.log(`Installing dependencies for ${pkg.name}...`) + + try { + execSync("pnpm install", { cwd: sourcePath, stdio: "inherit" }) + } catch (e) { + execSync("pnpm install --no-frozen-lockfile", { cwd: sourcePath, stdio: "inherit" }) + } + } + + // Create symlink. + fs.rmSync(targetPath, { recursive: true, force: true }) + fs.mkdirSync(path.dirname(targetPath), { recursive: true }) + const linkSource = pkg.npmPath ? path.join(sourcePath, pkg.npmPath) : sourcePath + fs.symlinkSync(linkSource, targetPath, "dir") + console.log(`Linked ${pkg.name}`) +} + +function unlinkPackage(pkg) { + const targetPath = path.resolve(__dirname, "..", pkg.targetPath) + if (fs.existsSync(targetPath)) { + fs.rmSync(targetPath, { recursive: true, force: true }) + console.log(`Unlinked ${pkg.name}`) + } +} + +function startWatch(pkg) { + console.log(`Watching ${pkg.name}...`) + const [cmd, ...args] = pkg.watchCommand.split(" ") + return spawn(cmd, args, { + cwd: path.resolve(__dirname, "..", pkg.sourcePath), + stdio: "inherit", + shell: true, + }) +} From fc66b28f1e30fa8af8a593d3538cac1bc934867c Mon Sep 17 00:00:00 2001 From: cte Date: Thu, 7 Aug 2025 01:08:27 -1000 Subject: [PATCH 7/7] Small fix --- scripts/link-packages.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/link-packages.js b/scripts/link-packages.js index 6af8c2fc2de..60ef3be8653 100755 --- a/scripts/link-packages.js +++ b/scripts/link-packages.js @@ -31,6 +31,20 @@ if (!packages.length) { packages.forEach(unlink ? unlinkPackage : linkPackage) +// After unlinking, restore npm packages with a single pnpm install. +if (unlink && packages.length > 0) { + const srcPath = path.resolve(__dirname, "..", "src") + console.log("\nRestoring npm packages...") + + try { + execSync("pnpm install", { cwd: srcPath, stdio: "inherit" }) + console.log("Successfully restored npm packages") + } catch (error) { + console.error(`Failed to restore packages: ${error.message}`) + console.log("You may need to run 'pnpm install' manually in the src directory") + } +} + if (!unlink && watch) { const watchers = packages.filter((pkg) => pkg.watchCommand).map(startWatch)