From 53d4b6ee9fc7fb84e050755a3e45d4835a99dac4 Mon Sep 17 00:00:00 2001 From: hongfushi Date: Sat, 25 Apr 2026 23:21:39 +0800 Subject: [PATCH 1/2] feat(auth): add auto-start login flow and fix start script --- bun.lock | 1 + package.json | 3 ++- src/auth.ts | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bun.lock b/bun.lock index 20e895e7f..9ece87578 100644 --- a/bun.lock +++ b/bun.lock @@ -1,5 +1,6 @@ { "lockfileVersion": 1, + "configVersion": 0, "workspaces": { "": { "name": "copilot-api", diff --git a/package.json b/package.json index a5adbb8e7..d23fa1f94 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,11 @@ "knip": "knip-bun", "lint": "eslint --cache", "lint:all": "eslint --cache .", + "login": "NODE_ENV=production bun run ./src/main.ts auth --auto-start", "prepack": "bun run build", "prepare": "simple-git-hooks", "release": "bumpp && bun publish --access public", - "start": "NODE_ENV=production bun run ./src/main.ts", + "start": "NODE_ENV=production bun run ./src/main.ts start", "typecheck": "tsc" }, "simple-git-hooks": { diff --git a/src/auth.ts b/src/auth.ts index cb31ff6f8..838825774 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -2,6 +2,7 @@ import { defineCommand } from "citty" import consola from "consola" +import { spawn } from "node:child_process" import { PATHS, ensurePaths } from "./lib/paths" import { state } from "./lib/state" @@ -10,6 +11,7 @@ import { setupGitHubToken } from "./lib/token" interface RunAuthOptions { verbose: boolean showToken: boolean + autoStart: boolean } export async function runAuth(options: RunAuthOptions): Promise { @@ -23,6 +25,16 @@ export async function runAuth(options: RunAuthOptions): Promise { await ensurePaths() await setupGitHubToken({ force: true }) consola.success("GitHub token written to", PATHS.GITHUB_TOKEN_PATH) + + if (options.autoStart) { + const child = spawn(process.execPath, [process.argv[1], "start"], { + detached: true, + stdio: "ignore", + env: { ...process.env, NODE_ENV: "production" }, + }) + child.unref() + consola.success("Server started in background (port 4141)") + } } export const auth = defineCommand({ @@ -42,11 +54,17 @@ export const auth = defineCommand({ default: false, description: "Show GitHub token on auth", }, + "auto-start": { + type: "boolean", + default: false, + description: "Automatically start the server in background after login", + }, }, run({ args }) { return runAuth({ verbose: args.verbose, showToken: args["show-token"], + autoStart: args["auto-start"], }) }, }) From 89f41583d770c43b60af028331ea58ead2c8a3c7 Mon Sep 17 00:00:00 2001 From: h4ai Date: Sat, 25 Apr 2026 23:24:23 +0800 Subject: [PATCH 2/2] Revert "feat(auth): add auto-start login flow and fix start script" This reverts commit 53d4b6ee9fc7fb84e050755a3e45d4835a99dac4. --- bun.lock | 1 - package.json | 3 +-- src/auth.ts | 18 ------------------ 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/bun.lock b/bun.lock index 9ece87578..20e895e7f 100644 --- a/bun.lock +++ b/bun.lock @@ -1,6 +1,5 @@ { "lockfileVersion": 1, - "configVersion": 0, "workspaces": { "": { "name": "copilot-api", diff --git a/package.json b/package.json index d23fa1f94..a5adbb8e7 100644 --- a/package.json +++ b/package.json @@ -27,11 +27,10 @@ "knip": "knip-bun", "lint": "eslint --cache", "lint:all": "eslint --cache .", - "login": "NODE_ENV=production bun run ./src/main.ts auth --auto-start", "prepack": "bun run build", "prepare": "simple-git-hooks", "release": "bumpp && bun publish --access public", - "start": "NODE_ENV=production bun run ./src/main.ts start", + "start": "NODE_ENV=production bun run ./src/main.ts", "typecheck": "tsc" }, "simple-git-hooks": { diff --git a/src/auth.ts b/src/auth.ts index 838825774..cb31ff6f8 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -2,7 +2,6 @@ import { defineCommand } from "citty" import consola from "consola" -import { spawn } from "node:child_process" import { PATHS, ensurePaths } from "./lib/paths" import { state } from "./lib/state" @@ -11,7 +10,6 @@ import { setupGitHubToken } from "./lib/token" interface RunAuthOptions { verbose: boolean showToken: boolean - autoStart: boolean } export async function runAuth(options: RunAuthOptions): Promise { @@ -25,16 +23,6 @@ export async function runAuth(options: RunAuthOptions): Promise { await ensurePaths() await setupGitHubToken({ force: true }) consola.success("GitHub token written to", PATHS.GITHUB_TOKEN_PATH) - - if (options.autoStart) { - const child = spawn(process.execPath, [process.argv[1], "start"], { - detached: true, - stdio: "ignore", - env: { ...process.env, NODE_ENV: "production" }, - }) - child.unref() - consola.success("Server started in background (port 4141)") - } } export const auth = defineCommand({ @@ -54,17 +42,11 @@ export const auth = defineCommand({ default: false, description: "Show GitHub token on auth", }, - "auto-start": { - type: "boolean", - default: false, - description: "Automatically start the server in background after login", - }, }, run({ args }) { return runAuth({ verbose: args.verbose, showToken: args["show-token"], - autoStart: args["auto-start"], }) }, })