mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat(cli): add Bun compiled binary runtime asset management
Introduce runtime path abstraction for Bun-compiled binaries that extracts
assets to ~/.happy/runtime/{version} instead of using project paths. This
enables proper distribution of CLI as a self-contained binary with embedded
tools (ripgrep, difftastic) and scripts that are extracted at runtime.
This commit is contained in:
+20
-6
@@ -1,10 +1,24 @@
|
||||
import { dirname, resolve } from 'path';
|
||||
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 isCompiled = Boolean(bunRuntime?.isCompiled);
|
||||
|
||||
export function projectPath() {
|
||||
const path = resolve(__dirname, '..');
|
||||
// console.log('path', path)
|
||||
return path;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user