mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
refactor: migrate from tsx to bun as TypeScript runtime
Remove tsx dependency and update all dev scripts and documentation to use bun as the primary TypeScript runtime for development. Consolidate process detection logic in daemon.ts to check for dev mode via src/index.ts regardless of runtime.
This commit is contained in:
@@ -264,7 +264,7 @@ All data is plain JSON over TLS; authentication is `CLI_API_TOKEN` (no end-to-en
|
||||
|
||||
`hapi doctor` uses `ps aux | grep` to find all HAPI processes:
|
||||
- Production: matches `hapi` binary, `happy-coder`
|
||||
- Development: matches `tsx.*src/index.ts`
|
||||
- Development: matches `src/index.ts` (run via `bun`)
|
||||
- Categorizes by command args: daemon, daemon-spawned, user-session, doctor
|
||||
|
||||
### Clean Runaway Processes
|
||||
|
||||
@@ -256,7 +256,7 @@ describe.skipIf(!await isServerHealthy())('Daemon Integration Tests', { timeout:
|
||||
it('should not allow starting a second daemon', async () => {
|
||||
// Daemon is already running from beforeEach
|
||||
// Try to start another daemon
|
||||
const secondChild = spawn('yarn', ['tsx', 'src/index.ts', 'daemon', 'start-sync'], {
|
||||
const secondChild = spawn('bun', ['src/index.ts', 'daemon', 'start-sync'], {
|
||||
cwd: process.cwd(),
|
||||
env: process.env,
|
||||
stdio: ['ignore', 'pipe', 'pipe']
|
||||
|
||||
@@ -22,12 +22,13 @@ export async function findAllHappyProcesses(): Promise<Array<{ pid: number, comm
|
||||
|
||||
// Check if it's a HAPI process
|
||||
const isHappyBinary = name === 'hapi' || name === 'hapi.exe' || /\bhapi(\.exe)?\b/.test(cmd);
|
||||
// Dev mode: running via bun/node with src/index.ts (production uses compiled binary)
|
||||
const isDevMode = cmd.includes('src/index.ts');
|
||||
const isHappy = name.includes('happy') ||
|
||||
name === 'node' && cmd.includes('happy-cli') ||
|
||||
cmd.includes('happy-coder') ||
|
||||
isHappyBinary ||
|
||||
(cmd.includes('tsx') && cmd.includes('src/index.ts') && cmd.includes('happy-cli')) ||
|
||||
(cmd.includes('bun') && cmd.includes('src/index.ts') && cmd.includes('happy-cli'));
|
||||
isDevMode;
|
||||
|
||||
if (!isHappy) continue;
|
||||
|
||||
@@ -36,17 +37,17 @@ export async function findAllHappyProcesses(): Promise<Array<{ pid: number, comm
|
||||
if (proc.pid === process.pid) {
|
||||
type = 'current';
|
||||
} else if (cmd.includes('--version')) {
|
||||
type = cmd.includes('tsx') ? 'dev-daemon-version-check' : 'daemon-version-check';
|
||||
type = isDevMode ? 'dev-daemon-version-check' : 'daemon-version-check';
|
||||
} else if (cmd.includes('daemon start-sync') || cmd.includes('daemon start')) {
|
||||
type = cmd.includes('tsx') ? 'dev-daemon' : 'daemon';
|
||||
type = isDevMode ? 'dev-daemon' : 'daemon';
|
||||
} else if (cmd.includes('--started-by daemon')) {
|
||||
type = cmd.includes('tsx') ? 'dev-daemon-spawned' : 'daemon-spawned-session';
|
||||
type = isDevMode ? 'dev-daemon-spawned' : 'daemon-spawned-session';
|
||||
} else if (cmd.includes('doctor')) {
|
||||
type = cmd.includes('tsx') ? 'dev-doctor' : 'doctor';
|
||||
type = isDevMode ? 'dev-doctor' : 'doctor';
|
||||
} else if (cmd.includes('--yolo')) {
|
||||
type = 'dev-session';
|
||||
} else {
|
||||
type = cmd.includes('tsx') ? 'dev-related' : 'user-session';
|
||||
type = isDevMode ? 'dev-related' : 'user-session';
|
||||
}
|
||||
|
||||
allProcesses.push({ pid: proc.pid, command: cmd || name, type });
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* HAPI CLI runs in two modes:
|
||||
* 1. **Compiled binary**: A single executable built with `bun build --compile`
|
||||
* 2. **Development mode**: Running TypeScript directly via `tsx` or `bun`
|
||||
* 2. **Development mode**: Running TypeScript directly via `bun`
|
||||
*
|
||||
* ## Execution Modes
|
||||
*
|
||||
@@ -15,7 +15,7 @@
|
||||
* - No additional entrypoint needed - just pass args to `process.execPath`
|
||||
*
|
||||
* **Development Mode:**
|
||||
* - Running via `tsx src/index.ts` or `bun src/index.ts`
|
||||
* - Running via `bun src/index.ts`
|
||||
* - Spawn child processes using the same runtime with `src/index.ts` entrypoint
|
||||
*
|
||||
* ## Cross-Platform Support
|
||||
@@ -70,7 +70,7 @@ export function getHappyCliCommand(args: string[]): HappyCliCommand {
|
||||
};
|
||||
}
|
||||
|
||||
// Node.js with tsx: preserve execArgv (which includes tsx loader)
|
||||
// Node.js fallback: preserve execArgv (for compatibility)
|
||||
return {
|
||||
command: process.execPath,
|
||||
args: [...process.execArgv, entrypoint, ...args]
|
||||
|
||||
Reference in New Issue
Block a user