From 67f8bf39416a2f4726436d0ed829132e6928a498 Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Thu, 25 Jun 2026 14:27:59 +0800 Subject: [PATCH] build(core): SNOWLUMA_BUILD_SKIP_NATIVES=1 escape hatch for darwin dev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two architectural cleanups that complement the bridge darwin support in 7343ae6, both opt-in / default-safe: 1) `vite.config.ts` — gate the missing-native build error behind `SNOWLUMA_BUILD_SKIP_NATIVES=1`. Default behaviour (no env) still throws as before, so the CI invariant "release builds must carry the full native set" is untouched. Darwin developers without prebuilt `websocket-darwin-arm64.node` (source lives in a separate private build repo) can now run `SNOWLUMA_BUILD_SKIP_NATIVES=1 pnpm build` and pair it with the runtime `SNOWLUMA_DEV_NO_NATIVE=1` stub at `node dist/index.mjs` boot. The qq-hook path (separate addon) is independent and unaffected. 2) `packages/core/config/.gitignore` — `runtime.json` is the only tracked deploy-time override file in that dir; every other config file is per-instance runtime state written by the daemon/dev server (admin password hash, EULA consent, per-uin OneBot binding, WebUI layout). Previously they showed up as 5 untracked files after every `pnpm dev:mode`, polluting `git status` and risking accidental commit of local creds via `git add -A`. Pattern: ignore everything except `runtime.json` (and the .gitignore itself). No code paths changed; both are operator-experience fixes for running SnowLuma on darwin against the nnphook DYLD_INSERT hook. --- packages/core/config/.gitignore | 16 ++++++++++++++++ packages/core/vite.config.ts | 21 +++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 packages/core/config/.gitignore diff --git a/packages/core/config/.gitignore b/packages/core/config/.gitignore new file mode 100644 index 00000000..1729ed6d --- /dev/null +++ b/packages/core/config/.gitignore @@ -0,0 +1,16 @@ +# Per-instance runtime state written by the dev server / production daemon. +# `runtime.json` is the only tracked file (the deploy-time overrides for +# webuiPort, hookAutoLoad, etc); everything else here is operator-private: +# * webui.json — admin password hash + rotation state +# * consent.json — EULA/PRIVACY acceptance per agreement version +# * notifications.json — per-account webhook destinations +# * onebot_.json — per-uin OneBot transport binding (HTTP/WS ports etc) +# * ui.json — WebUI panel layout per operator +# +# Without this ignore file, every `pnpm dev:mode` / `node dist/index.mjs` +# leaves a 5-file untracked surface in `packages/core/config/` that pollutes +# `git status` and would accidentally commit local creds if `git add -A` is used. + +* +!.gitignore +!runtime.json diff --git a/packages/core/vite.config.ts b/packages/core/vite.config.ts index 40dbf0d8..d8a936cd 100644 --- a/packages/core/vite.config.ts +++ b/packages/core/vite.config.ts @@ -70,6 +70,14 @@ const ffmpegSrcDir = path.resolve(nativeDir, 'ffmpeg'); // Fail fast if any expected native binary is missing from packages/runtime/native/. // vite-plugin-cp only emits a warning on missing source files; we want a hard // error so CI can't accidentally ship an incomplete archive. +// +// Escape hatch: SNOWLUMA_BUILD_SKIP_NATIVES=1 downgrades the missing-native +// error to a warning. Use ONLY for local dev on platforms where prebuilt +// native binaries aren't available yet (e.g. darwin-arm64 — the websocket +// native source lives in a separate private build repo). The runtime +// websocket loader has its own `SNOWLUMA_DEV_NO_NATIVE=1` stub that lets +// the daemon boot without the addon at the cost of WebSocket I/O; the qq-hook +// path is independent and unaffected. const missingNatives = nativeFiles.filter( (f) => !fs.existsSync(path.join(nativeDir, f)), ); @@ -77,10 +85,15 @@ if (!fs.existsSync(path.join(ffmpegSrcDir, ffmpegAddonFile))) { missingNatives.push(`ffmpeg/${ffmpegAddonFile}`); } if (missingNatives.length > 0) { - throw new Error( - `Missing native binaries for target ${targetTriple}:\n` + - missingNatives.map((f) => ` - ${path.join(nativeDir, f)}`).join('\n'), - ); + const detail = `Missing native binaries for target ${targetTriple}:\n` + + missingNatives.map((f) => ` - ${path.join(nativeDir, f)}`).join('\n'); + if (process.env.SNOWLUMA_BUILD_SKIP_NATIVES === '1') { + console.warn(`[vite.config] ${detail}\n` + + ` (continuing because SNOWLUMA_BUILD_SKIP_NATIVES=1 — runtime needs ` + + `SNOWLUMA_DEV_NO_NATIVE=1 to skip the missing addon at boot)`); + } else { + throw new Error(detail); + } } // Legal docs are served by the WebUI consent gate; a missing one would silently