From 8cbe68c47acbdbc9d17765391d105ea3ec5d0ced Mon Sep 17 00:00:00 2001 From: weishu Date: Sun, 21 Dec 2025 22:03:59 +0800 Subject: [PATCH] fix(cli): add stub embedded assets generation to build process --- cli/package.json | 2 +- cli/scripts/write-embedded-assets-stub.ts | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 cli/scripts/write-embedded-assets-stub.ts diff --git a/cli/package.json b/cli/package.json index 0feaddb2..821bbcf2 100644 --- a/cli/package.json +++ b/cli/package.json @@ -67,7 +67,7 @@ "scripts": { "why do we need to build before running tests / dev?": "We need the binary to be built so we run daemon commands which directly run the binary - we don't want them to go out of sync or have custom spawn logic depending how we started HAPI", "typecheck": "tsc --noEmit", - "build": "shx rm -rf dist && tsc --noEmit && pkgroll", + "build": "bun run scripts/write-embedded-assets-stub.ts && shx rm -rf dist && tsc --noEmit && pkgroll", "build:exe": "bun run scripts/build-executable.ts", "build:exe:all": "bun run scripts/build-executable.ts --all", "build:exe:allinone": "bun run scripts/build-executable.ts --with-web-assets", diff --git a/cli/scripts/write-embedded-assets-stub.ts b/cli/scripts/write-embedded-assets-stub.ts new file mode 100644 index 00000000..44800d99 --- /dev/null +++ b/cli/scripts/write-embedded-assets-stub.ts @@ -0,0 +1,23 @@ +import { dirname, join } from 'node:path'; +import { writeFileSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; + +const scriptDir = dirname(fileURLToPath(import.meta.url)); +const cliRoot = join(scriptDir, '..'); +const workspaceRoot = join(cliRoot, '..'); +const outputPath = join(workspaceRoot, 'server', 'src', 'web', 'embeddedAssets.generated.ts'); +const contents = [ + '// This file is generated by cli/scripts/build-executable.ts when --with-web-assets is not used.', + '// It intentionally contains no embedded assets.', + '', + 'export interface EmbeddedWebAsset {', + ' path: string;', + ' sourcePath: string;', + ' mimeType: string;', + '}', + '', + 'export const embeddedAssets: EmbeddedWebAsset[] = [];', + '' +].join('\n'); + +writeFileSync(outputPath, contents, 'utf-8');