|
11 | 11 | * pnpm serve # Build, install, and start code-server on port 9080 |
12 | 12 | * pnpm serve -- --port 8080 # Use a custom port |
13 | 13 | * pnpm serve -- --host 0.0.0.0 # Bind to all interfaces (for Docker/remote access) |
| 14 | + * pnpm serve -- --auth none # Disable authentication (password|none) |
14 | 15 | * pnpm serve:rebuild # Only rebuild and reinstall the extension |
15 | 16 | * |
16 | 17 | * The script will: |
@@ -66,6 +67,16 @@ function getHost() { |
66 | 67 | } |
67 | 68 | const host = getHost() |
68 | 69 |
|
| 70 | +// Parse --auth argument (optional, passed to code-server: "password" or "none") |
| 71 | +function getAuth() { |
| 72 | + const authIndex = process.argv.indexOf("--auth") |
| 73 | + if (authIndex !== -1 && process.argv[authIndex + 1]) { |
| 74 | + return process.argv[authIndex + 1] |
| 75 | + } |
| 76 | + return null |
| 77 | +} |
| 78 | +const auth = getAuth() |
| 79 | + |
69 | 80 | function log(message) { |
70 | 81 | console.log(`${CYAN}[serve]${RESET} ${message}`) |
71 | 82 | } |
@@ -175,28 +186,29 @@ async function main() { |
175 | 186 | console.log(`\n${BOLD}Starting code-server...${RESET}`) |
176 | 187 | console.log(` Working directory: ${cwd}`) |
177 | 188 | console.log(` URL: ${CYAN}http://${host}:${port}${RESET}`) |
178 | | - console.log(` Password: ${YELLOW}~/.config/code-server/config.yaml${RESET}`) |
| 189 | + if (auth === "none") { |
| 190 | + console.log(` Auth: ${YELLOW}disabled${RESET}`) |
| 191 | + } else { |
| 192 | + console.log(` Password: ${YELLOW}~/.config/code-server/config.yaml${RESET}`) |
| 193 | + } |
179 | 194 | console.log(`\n Press ${BOLD}Ctrl+C${RESET} to stop\n`) |
180 | 195 |
|
181 | 196 | // Spawn code-server with: |
| 197 | + // --bind-addr: Address to bind to |
| 198 | + // --auth: Authentication type (password or none) |
182 | 199 | // --disable-workspace-trust: Skip workspace trust prompts |
183 | 200 | // --disable-getting-started-override: Disable welcome/getting started page |
184 | 201 | // -e: Ignore last opened directory (start fresh) |
185 | | - const codeServer = spawn( |
186 | | - "code-server", |
187 | | - [ |
188 | | - "--bind-addr", |
189 | | - `${host}:${port}`, |
190 | | - "--disable-workspace-trust", |
191 | | - "--disable-getting-started-override", |
192 | | - "-e", |
193 | | - cwd, |
194 | | - ], |
195 | | - { |
196 | | - stdio: "inherit", |
197 | | - cwd: cwd, |
198 | | - }, |
199 | | - ) |
| 202 | + const args = ["--bind-addr", `${host}:${port}`] |
| 203 | + if (auth) { |
| 204 | + args.push("--auth", auth) |
| 205 | + } |
| 206 | + args.push("--disable-workspace-trust", "--disable-getting-started-override", "-e", cwd) |
| 207 | + |
| 208 | + const codeServer = spawn("code-server", args, { |
| 209 | + stdio: "inherit", |
| 210 | + cwd: cwd, |
| 211 | + }) |
200 | 212 |
|
201 | 213 | codeServer.on("error", (err) => { |
202 | 214 | logError(`Failed to start code-server: ${err.message}`) |
|
0 commit comments