Skip to content

Commit 841c0d0

Browse files
committed
refactor: remove pnpm serve command, keep only serve:install
1 parent fd0bf50 commit 841c0d0

File tree

2 files changed

+21
-135
lines changed

2 files changed

+21
-135
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
"clean": "turbo clean --log-order grouped --output-logs new-only && rimraf dist out bin .vite-port .turbo",
2222
"install:vsix": "pnpm install --frozen-lockfile && pnpm clean && pnpm vsix && node scripts/install-vsix.js",
2323
"install:vsix:nightly": "pnpm install --frozen-lockfile && pnpm clean && pnpm vsix:nightly && node scripts/install-vsix.js --nightly",
24-
"serve": "node scripts/serve.js",
25-
"serve:install": "node scripts/serve.js --install-only",
24+
"serve:install": "node scripts/serve.js",
2625
"changeset:version": "cp CHANGELOG.md src/CHANGELOG.md && changeset version && cp -vf src/CHANGELOG.md .",
2726
"knip": "knip --include files",
2827
"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",

scripts/serve.js

Lines changed: 20 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
* Serve script for Roo Code extension development
33
*
44
* Usage:
5-
* pnpm serve:install # Build and install the extension into code-server
6-
* pnpm serve # Start code-server on port 9080
7-
* pnpm serve -- --port 8080 # Use a custom port
8-
* pnpm serve -- --host 0.0.0.0 # Bind to all interfaces (for Docker/remote access)
9-
* pnpm serve -- --auth none # Disable authentication (password|none)
5+
* pnpm serve:install # Build and install the extension into code-server
106
*
117
* After making code changes, run `pnpm serve:install` again and reload the window
128
* (Cmd+Shift+P → "Developer: Reload Window")
139
*/
1410

15-
const { execSync, spawn } = require("child_process")
11+
const { execSync } = require("child_process")
1612
const path = require("path")
1713
const os = require("os")
1814

@@ -26,44 +22,6 @@ const RED = "\x1b[31m"
2622
// Build vsix to a fixed path in temp directory
2723
const VSIX_PATH = path.join(os.tmpdir(), "roo-code-serve.vsix")
2824

29-
// Parse command line flags
30-
const installOnly = process.argv.includes("--install-only")
31-
32-
// Parse --port argument (default: 9080)
33-
const DEFAULT_PORT = 9080
34-
function getPort() {
35-
const portIndex = process.argv.indexOf("--port")
36-
if (portIndex !== -1 && process.argv[portIndex + 1]) {
37-
const port = parseInt(process.argv[portIndex + 1], 10)
38-
if (!isNaN(port) && port > 0 && port < 65536) {
39-
return port
40-
}
41-
}
42-
return DEFAULT_PORT
43-
}
44-
const port = getPort()
45-
46-
// Parse --host argument (default: 127.0.0.1, use 0.0.0.0 for Docker/remote access)
47-
const DEFAULT_HOST = "127.0.0.1"
48-
function getHost() {
49-
const hostIndex = process.argv.indexOf("--host")
50-
if (hostIndex !== -1 && process.argv[hostIndex + 1]) {
51-
return process.argv[hostIndex + 1]
52-
}
53-
return DEFAULT_HOST
54-
}
55-
const host = getHost()
56-
57-
// Parse --auth argument (optional, passed to code-server: "password" or "none")
58-
function getAuth() {
59-
const authIndex = process.argv.indexOf("--auth")
60-
if (authIndex !== -1 && process.argv[authIndex + 1]) {
61-
return process.argv[authIndex + 1]
62-
}
63-
return null
64-
}
65-
const auth = getAuth()
66-
6725
function log(message) {
6826
console.log(`${CYAN}[serve]${RESET} ${message}`)
6927
}
@@ -80,102 +38,31 @@ function logError(message) {
8038
console.error(`${RED}${RESET} ${message}`)
8139
}
8240

83-
function isCodeServerInstalled() {
84-
try {
85-
execSync("which code-server", { stdio: "pipe" })
86-
return true
87-
} catch {
88-
return false
89-
}
90-
}
91-
9241
async function main() {
93-
// If install-only mode, just build and install the extension
94-
if (installOnly) {
95-
console.log(`\n${BOLD}🔧 Roo Code - Install Extension${RESET}\n`)
96-
97-
// Build vsix to temp directory
98-
log(`Building vsix to ${VSIX_PATH}...`)
99-
try {
100-
execSync(`pnpm vsix -- --out "${VSIX_PATH}"`, { stdio: "inherit" })
101-
logSuccess("Build complete")
102-
} catch (error) {
103-
logError("Build failed")
104-
process.exit(1)
105-
}
42+
console.log(`\n${BOLD}🔧 Roo Code - Install Extension${RESET}\n`)
10643

107-
// Install extension into code-server
108-
log("Installing extension into code-server...")
109-
try {
110-
execSync(`code-server --install-extension "${VSIX_PATH}"`, { stdio: "inherit" })
111-
logSuccess("Extension installed")
112-
} catch (error) {
113-
logWarning("Extension installation had warnings (this is usually fine)")
114-
}
115-
116-
console.log(`\n${GREEN}✓ Extension built and installed.${RESET}`)
117-
console.log(` If code-server is running, reload the window to pick up changes.`)
118-
console.log(` (Cmd+Shift+P → "Developer: Reload Window")\n`)
119-
return
120-
}
121-
122-
// Default: Start code-server
123-
log("Checking for code-server...")
124-
if (!isCodeServerInstalled()) {
125-
logError("code-server is not installed")
126-
console.log("\nTo install code-server on macOS:")
127-
console.log(` ${CYAN}brew install code-server${RESET}`)
128-
console.log("\nFor other platforms, see: https://coder.com/docs/code-server/install")
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")
12951
process.exit(1)
13052
}
131-
logSuccess("code-server found")
13253

133-
console.log(`\n${BOLD}🚀 Roo Code - code-server Development Server${RESET}\n`)
134-
const cwd = process.cwd()
135-
console.log(`\n${BOLD}Starting code-server...${RESET}`)
136-
console.log(` Working directory: ${cwd}`)
137-
console.log(` URL: ${CYAN}http://${host}:${port}${RESET}`)
138-
if (auth === "none") {
139-
console.log(` Auth: ${YELLOW}disabled${RESET}`)
140-
} else {
141-
console.log(` Password: ${YELLOW}~/.config/code-server/config.yaml${RESET}`)
142-
}
143-
console.log(`\n Press ${BOLD}Ctrl+C${RESET} to stop\n`)
144-
145-
// Spawn code-server with:
146-
// --bind-addr: Address to bind to
147-
// --auth: Authentication type (password or none)
148-
// --disable-workspace-trust: Skip workspace trust prompts
149-
// --disable-getting-started-override: Disable welcome/getting started page
150-
// -e: Ignore last opened directory (start fresh)
151-
const args = ["--bind-addr", `${host}:${port}`]
152-
if (auth) {
153-
args.push("--auth", auth)
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)")
15461
}
155-
args.push("--disable-workspace-trust", "--disable-getting-started-override", "-e", cwd)
156-
157-
const codeServer = spawn("code-server", args, {
158-
stdio: "inherit",
159-
cwd: cwd,
160-
})
161-
162-
codeServer.on("error", (err) => {
163-
logError(`Failed to start code-server: ${err.message}`)
164-
process.exit(1)
165-
})
166-
167-
codeServer.on("close", (code) => {
168-
if (code !== 0 && code !== null) {
169-
logError(`code-server exited with code ${code}`)
170-
}
171-
})
17262

173-
// Handle Ctrl+C gracefully
174-
process.on("SIGINT", () => {
175-
console.log("\n")
176-
log("Shutting down code-server...")
177-
codeServer.kill("SIGTERM")
178-
})
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`)
17966
}
18067

18168
main().catch((error) => {

0 commit comments

Comments
 (0)