041a19f060
* feat: add service-managed self-update * chore: add temporary self-update test scripts * chore: simplify temporary script markdown fences * chore: run frontend in temporary self-update scripts * fix: show self-update job progress after apply * chore: add real npm self-update test script * fix: isolate npm self-update prefix * fix: detect npm service installs from bin shim * chore: reset service before real npm update test * chore: expand real npm status diagnostics * fix: preserve service home during self-update * fix(cli): tee self-update helper output to a log file * fix(cli): avoid launchd bootstrap race when reloading the macOS service * fix(backend): run macOS self-update helper once via transient launchd plist * fix(web): show self-update progress and lock the apply button until the update lands * fix(cli): reinstall via the kandev wrapper on Homebrew self-update * chore: remove temp self-update test scripts * fix(web): drop unused apply path from useUpdates hook * fix(backend): snapshot install state once in apply preflight * docs: align self-update docs with transient LaunchAgent flow * chore(release): run cli bundle from apps workspace root * fix(backend): guard against concurrent self-update applies * fix(backend): check scheme and helper paths in self-update apply * fix(backend): drop duplicate binary name from npx manual command * fix(cli): allow --help for service self-update without --intent * fix(cli): harden self-update dir perms and darwin uid resolution * fix(web): set required POST fields last in applyUpdate * docs: use JSON body notation for the apply endpoint * fix(backend): expire self-update guard so a stuck helper cannot wedge apply * refactor(cli): collapse redundant writeSync branch in self-update log
54 lines
2.1 KiB
TypeScript
54 lines
2.1 KiB
TypeScript
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
// Default service ports (will auto-fallback if busy).
|
|
// Clustered near the web port (37429) to avoid collisions with commonly used
|
|
// ports (8080, 9090, 9999, etc.) while keeping the numbers memorable.
|
|
export const DEFAULT_BACKEND_PORT = 38429;
|
|
export const DEFAULT_WEB_PORT = 37429;
|
|
export const DEFAULT_AGENTCTL_PORT = 39429;
|
|
|
|
// Random fallback range for port selection.
|
|
export const RANDOM_PORT_MIN = 10000;
|
|
export const RANDOM_PORT_MAX = 60000;
|
|
export const RANDOM_PORT_RETRIES = 10;
|
|
|
|
// Backend healthcheck timeout during startup.
|
|
export const HEALTH_TIMEOUT_MS_RELEASE = 45000;
|
|
export const HEALTH_TIMEOUT_MS_DEV = 600000;
|
|
|
|
// Kandev root directory. Single source of truth for the dotdir name and
|
|
// everything derived from it (data, tasks, bin). Dev mode uses a separate
|
|
// root under the repo (see DEV_KANDEV_DOTDIR).
|
|
export const KANDEV_DOTDIR = ".kandev";
|
|
export const KANDEV_HOME_DIR = path.join(os.homedir(), KANDEV_DOTDIR);
|
|
export const KANDEV_TASKS_DIR = path.join(KANDEV_HOME_DIR, "tasks");
|
|
|
|
// Local user cache/data directories for release bundles and DB.
|
|
export const CACHE_DIR = path.join(KANDEV_HOME_DIR, "bin");
|
|
export const DATA_DIR = path.join(KANDEV_HOME_DIR, "data");
|
|
|
|
export function resolveKandevHomeDir(env: NodeJS.ProcessEnv = process.env): string {
|
|
return env.KANDEV_HOME_DIR?.trim() || KANDEV_HOME_DIR;
|
|
}
|
|
|
|
export function resolveDataDir(env: NodeJS.ProcessEnv = process.env): string {
|
|
return path.join(resolveKandevHomeDir(env), "data");
|
|
}
|
|
|
|
export function resolveCacheDir(env: NodeJS.ProcessEnv = process.env): string {
|
|
return path.join(resolveKandevHomeDir(env), "bin");
|
|
}
|
|
|
|
export function resolveDatabasePath(env: NodeJS.ProcessEnv = process.env): string {
|
|
return env.KANDEV_DATABASE_PATH?.trim() || path.join(resolveDataDir(env), "kandev.db");
|
|
}
|
|
|
|
// Dev-mode root: an isolated kandev home inside the repo so that running
|
|
// `make dev` from inside a kandev-spawned task workspace does not touch the
|
|
// user's production state.
|
|
export const DEV_KANDEV_DOTDIR = ".kandev-dev";
|
|
export function devKandevHome(repoRoot: string): string {
|
|
return path.join(repoRoot, DEV_KANDEV_DOTDIR);
|
|
}
|