mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
Enables building hapi as standalone Bun-compiled executables for macOS, Linux, and Windows (x64/arm64). Adds build script, bootstrap entry point, runtime asset management, and automatic deployment of bundled tools (ripgrep, difftastic). Includes MCP stdio bridge support and proper environment handling for compiled binaries. Updates documentation with build and installation instructions for single executable distribution.
27 lines
810 B
TypeScript
27 lines
810 B
TypeScript
import { dirname, resolve, join } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import { configuration } from '@/configuration';
|
|
import packageJson from '../package.json';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const bunRuntime = (globalThis as typeof globalThis & { Bun?: { isCompiled?: boolean } }).Bun;
|
|
const argv1 = process.argv[1] ?? '';
|
|
const bunFsMarker = argv1.includes('$bunfs');
|
|
const isCompiled = Boolean(bunRuntime?.isCompiled) || bunFsMarker;
|
|
|
|
export function projectPath(): string {
|
|
return resolve(__dirname, '..');
|
|
}
|
|
|
|
export function runtimePath(): string {
|
|
if (!isCompiled) {
|
|
return projectPath();
|
|
}
|
|
|
|
return join(configuration.happyHomeDir, 'runtime', packageJson.version);
|
|
}
|
|
|
|
export function isBunCompiled(): boolean {
|
|
return isCompiled;
|
|
}
|