|
| 1 | +/** |
| 2 | + * Serve script for Roo Code extension development |
| 3 | + * |
| 4 | + * Usage: |
| 5 | + * pnpm code-server:install # Build and install the extension into code-server |
| 6 | + * |
| 7 | + * After making code changes, run `pnpm code-server:install` again and reload the window |
| 8 | + * (Cmd+Shift+P → "Developer: Reload Window") |
| 9 | + */ |
| 10 | + |
| 11 | +const { execSync } = require("child_process") |
| 12 | +const path = require("path") |
| 13 | +const os = require("os") |
| 14 | + |
| 15 | +const RESET = "\x1b[0m" |
| 16 | +const BOLD = "\x1b[1m" |
| 17 | +const GREEN = "\x1b[32m" |
| 18 | +const YELLOW = "\x1b[33m" |
| 19 | +const CYAN = "\x1b[36m" |
| 20 | +const RED = "\x1b[31m" |
| 21 | + |
| 22 | +// Build vsix to a fixed path in temp directory |
| 23 | +const VSIX_PATH = path.join(os.tmpdir(), "roo-code-serve.vsix") |
| 24 | + |
| 25 | +function log(message) { |
| 26 | + console.log(`${CYAN}[code-server]${RESET} ${message}`) |
| 27 | +} |
| 28 | + |
| 29 | +function logSuccess(message) { |
| 30 | + console.log(`${GREEN}✓${RESET} ${message}`) |
| 31 | +} |
| 32 | + |
| 33 | +function logWarning(message) { |
| 34 | + console.log(`${YELLOW}⚠${RESET} ${message}`) |
| 35 | +} |
| 36 | + |
| 37 | +function logError(message) { |
| 38 | + console.error(`${RED}✗${RESET} ${message}`) |
| 39 | +} |
| 40 | + |
| 41 | +async function main() { |
| 42 | + console.log(`\n${BOLD}🔧 Roo Code - Install Extension${RESET}\n`) |
| 43 | + |
| 44 | + // Build vsix to temp directory |
| 45 | + log(`Building vsix to ${VSIX_PATH}...`) |
| 46 | + try { |
| 47 | + execSync(`pnpm vsix -- --out "${VSIX_PATH}"`, { stdio: "inherit" }) |
| 48 | + logSuccess("Build complete") |
| 49 | + } catch (error) { |
| 50 | + logError("Build failed") |
| 51 | + process.exit(1) |
| 52 | + } |
| 53 | + |
| 54 | + // Install extension into code-server |
| 55 | + log("Installing extension into code-server...") |
| 56 | + try { |
| 57 | + execSync(`code-server --install-extension "${VSIX_PATH}"`, { stdio: "inherit" }) |
| 58 | + logSuccess("Extension installed") |
| 59 | + } catch (error) { |
| 60 | + logWarning("Extension installation had warnings (this is usually fine)") |
| 61 | + } |
| 62 | + |
| 63 | + console.log(`\n${GREEN}✓ Extension built and installed.${RESET}`) |
| 64 | + console.log(` If code-server is running, reload the window to pick up changes.`) |
| 65 | + console.log(` (Cmd+Shift+P → "Developer: Reload Window")\n`) |
| 66 | +} |
| 67 | + |
| 68 | +main().catch((error) => { |
| 69 | + logError(error.message) |
| 70 | + process.exit(1) |
| 71 | +}) |
0 commit comments