mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat(cli): refactor embedded assets with Bun-specific and stub implementations
Split embedded assets loading into runtime-specific variants using package.json imports field. Bun-compiled binaries use the full implementation with file assets, while stub fallback provides clear error for non-Bun runtimes.
This commit is contained in:
+7
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hapi",
|
||||
"version": "0.12.0-0",
|
||||
"version": "0.12.0-1",
|
||||
"description": "Mobile and Web client for Claude Code and Codex",
|
||||
"author": "Kirill Dubovitskiy",
|
||||
"license": "MIT",
|
||||
@@ -51,6 +51,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"imports": {
|
||||
"#embedded-assets": {
|
||||
"bun": "./src/runtime/embeddedAssets.bun.ts",
|
||||
"default": "./src/runtime/embeddedAssets.stub.ts"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"bin",
|
||||
|
||||
@@ -2,3 +2,5 @@
|
||||
process.env.DEV = 'false';
|
||||
|
||||
await import('./index');
|
||||
|
||||
export {};
|
||||
|
||||
@@ -3,7 +3,7 @@ import { dirname, join } from 'node:path';
|
||||
import { arch, platform } from 'node:os';
|
||||
import * as tar from 'tar';
|
||||
import packageJson from '../../package.json';
|
||||
import type { EmbeddedAsset } from './embeddedAssets';
|
||||
import type { EmbeddedAsset } from '#embedded-assets';
|
||||
import { isBunCompiled, runtimePath } from '@/projectPath';
|
||||
|
||||
const RUNTIME_MARKER = '.runtime-version';
|
||||
@@ -131,7 +131,7 @@ export async function ensureRuntimeAssets(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
const { loadEmbeddedAssets } = await import('./embeddedAssets');
|
||||
const { loadEmbeddedAssets } = await import('#embedded-assets');
|
||||
const runtimeRoot = runtimePath();
|
||||
const markerPath = join(runtimeRoot, RUNTIME_MARKER);
|
||||
if (existsSync(markerPath)) {
|
||||
|
||||
@@ -10,7 +10,6 @@ import ripgrepArchiveLicense from '../../tools/archives/ripgrep-LICENSE' assert
|
||||
import difftasticLicense from '../../tools/licenses/difftastic-LICENSE' assert { type: 'file' };
|
||||
import ripgrepLicense from '../../tools/licenses/ripgrep-LICENSE' assert { type: 'file' };
|
||||
|
||||
|
||||
export interface EmbeddedAsset {
|
||||
relativePath: string;
|
||||
sourcePath: string;
|
||||
@@ -0,0 +1,8 @@
|
||||
export interface EmbeddedAsset {
|
||||
relativePath: string;
|
||||
sourcePath: string;
|
||||
}
|
||||
|
||||
export async function loadEmbeddedAssets(): Promise<EmbeddedAsset[]> {
|
||||
throw new Error('Embedded assets are only available in Bun-compiled binaries.');
|
||||
}
|
||||
Vendored
+2
@@ -8,4 +8,6 @@ declare module 'bun:bundle' {
|
||||
| 'HAPI_TARGET_WIN32_X64'
|
||||
| 'HAPI_TARGET_WIN32_ARM64';
|
||||
}
|
||||
|
||||
export function feature(name: Registry['features']): boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user