Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 49b7a0a

Browse files
committed
refactor: separate serve (start) and serve:install (build+install)
1 parent 466defc commit 49b7a0a

2 files changed

Lines changed: 40 additions & 42 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
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",
2424
"serve": "node scripts/serve.js",
25-
"serve:rebuild": "node scripts/serve.js --rebuild-only",
25+
"serve:install": "node scripts/serve.js --install-only",
2626
"changeset:version": "cp CHANGELOG.md src/CHANGELOG.md && changeset version && cp -vf src/CHANGELOG.md .",
2727
"knip": "knip --include files",
2828
"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: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
/**
22
* Serve script for Roo Code extension development
33
*
4-
* This script builds the extension as a vsix, installs it into code-server,
5-
* and launches code-server for web-based VS Code testing.
4+
* This script manages code-server for web-based VS Code testing.
65
*
76
* Prerequisites:
87
* brew install code-server
98
*
109
* Usage:
11-
* pnpm serve # Build, install, and start code-server on port 9080
10+
* pnpm serve # Start code-server on port 9080
1211
* pnpm serve -- --port 8080 # Use a custom port
1312
* pnpm serve -- --host 0.0.0.0 # Bind to all interfaces (for Docker/remote access)
1413
* pnpm serve -- --auth none # Disable authentication (password|none)
15-
* pnpm serve:rebuild # Only rebuild and reinstall the extension
14+
* pnpm serve:install # Build and install the extension into code-server
1615
*
17-
* The script will:
18-
* 1. Check if code-server is installed
19-
* 2. Build the vsix (pnpm vsix)
20-
* 3. Install the vsix into code-server
21-
* 4. Configure user settings (disable welcome tab)
22-
* 5. Start code-server on http://127.0.0.1:9080 (unless --rebuild-only)
16+
* Workflow:
17+
* 1. Run `pnpm serve:install` to build and install the extension
18+
* 2. Run `pnpm serve` to start code-server
19+
* 3. After code changes, run `pnpm serve:install` again and reload the window
20+
* (Cmd+Shift+P → "Developer: Reload Window")
2321
*
2422
* Your password is stored in ~/.config/code-server/config.yaml
2523
*/
@@ -40,7 +38,7 @@ const RED = "\x1b[31m"
4038
const VSIX_PATH = path.join(os.tmpdir(), "roo-code-serve.vsix")
4139

4240
// Parse command line flags
43-
const rebuildOnly = process.argv.includes("--rebuild-only")
41+
const installOnly = process.argv.includes("--install-only")
4442

4543
// Parse --port argument (default: 9080)
4644
const DEFAULT_PORT = 9080
@@ -135,10 +133,7 @@ function ensureUserSettings() {
135133
}
136134

137135
async function main() {
138-
const title = rebuildOnly ? "Roo Code - Rebuild Extension" : "Roo Code - code-server Development Server"
139-
console.log(`\n${BOLD}🚀 ${title}${RESET}\n`)
140-
141-
// Step 1: Check if code-server is installed
136+
// Check if code-server is installed
142137
log("Checking for code-server...")
143138
if (!isCodeServerInstalled()) {
144139
logError("code-server is not installed")
@@ -149,39 +144,42 @@ async function main() {
149144
}
150145
logSuccess("code-server found")
151146

152-
// Step 2: Build vsix to temp directory
153-
log(`Building vsix to ${VSIX_PATH}...`)
154-
try {
155-
execSync(`pnpm vsix -- --out "${VSIX_PATH}"`, { stdio: "inherit" })
156-
logSuccess("Build complete")
157-
} catch (error) {
158-
logError("Build failed")
159-
process.exit(1)
160-
}
147+
// If install-only mode, build and install the extension
148+
if (installOnly) {
149+
console.log(`\n${BOLD}🔧 Roo Code - Install Extension${RESET}\n`)
161150

162-
// Step 3: Install extension into code-server
163-
log("Installing extension into code-server...")
164-
try {
165-
execSync(`code-server --install-extension "${VSIX_PATH}"`, { stdio: "inherit" })
166-
logSuccess("Extension installed")
167-
} catch (error) {
168-
logWarning("Extension installation had warnings (this is usually fine)")
169-
}
151+
// Build vsix to temp directory
152+
log(`Building vsix to ${VSIX_PATH}...`)
153+
try {
154+
execSync(`pnpm vsix -- --out "${VSIX_PATH}"`, { stdio: "inherit" })
155+
logSuccess("Build complete")
156+
} catch (error) {
157+
logError("Build failed")
158+
process.exit(1)
159+
}
160+
161+
// Install extension into code-server
162+
log("Installing extension into code-server...")
163+
try {
164+
execSync(`code-server --install-extension "${VSIX_PATH}"`, { stdio: "inherit" })
165+
logSuccess("Extension installed")
166+
} catch (error) {
167+
logWarning("Extension installation had warnings (this is usually fine)")
168+
}
170169

171-
// Step 4: Configure user settings to disable welcome tab
172-
log("Configuring user settings...")
173-
ensureUserSettings()
174-
logSuccess("User settings configured (welcome tab disabled)")
170+
// Configure user settings to disable welcome tab
171+
log("Configuring user settings...")
172+
ensureUserSettings()
173+
logSuccess("User settings configured (welcome tab disabled)")
175174

176-
// If rebuild-only mode, exit here
177-
if (rebuildOnly) {
178-
console.log(`\n${GREEN}✓ Extension rebuilt and installed.${RESET}`)
179-
console.log(` Reload the code-server window to pick up changes.`)
175+
console.log(`\n${GREEN}✓ Extension built and installed.${RESET}`)
176+
console.log(` If code-server is running, reload the window to pick up changes.`)
180177
console.log(` (Cmd+Shift+P → "Developer: Reload Window")\n`)
181178
return
182179
}
183180

184-
// Step 5: Start code-server
181+
// Default: Start code-server
182+
console.log(`\n${BOLD}🚀 Roo Code - code-server Development Server${RESET}\n`)
185183
const cwd = process.cwd()
186184
console.log(`\n${BOLD}Starting code-server...${RESET}`)
187185
console.log(` Working directory: ${cwd}`)

0 commit comments

Comments
 (0)