code-server.js 1.9 KB

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