Files
cinny-desktop/scripts/sync-web-config.mjs
T
Lotus CIandClaude Opus 5.5 1e71940789
Build Lotus Chat Desktop / prepare (push) Successful in 8s
Build Lotus Chat Desktop / build-linux (push) Successful in 30m37s
Build Lotus Chat Desktop / build-arch (push) Successful in 11s
Build Lotus Chat Desktop / build-windows (push) Successful in 32m6s
Build Lotus Chat Desktop / update-manifest (push) Successful in 8s
fix(build): bundle the web app's Giphy key so the desktop GIF picker works
The web deploy serves a config.json kept on the server (not in git), which
is where the Giphy key lives. The desktop app bundles the repo's
config.json, whose gifApiKey is empty, so on desktop the GIF button never
appeared even with Settings → GIF Picker switched on.

scripts/sync-web-config.mjs copies an allow-list of deployment-only keys
(just gifApiKey) from https://chat.lotusguild.org/config.json into
cinny/config.json before the Windows and Linux builds. The key is public
already (served to every web visitor; Giphy keys are client keys). A fetch
failure is a warning, not a build failure.

Tested locally: sets the key, is a no-op on a second run, and skips cleanly
on a 404.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
2026-09-25 15:50:35 -04:00

31 lines
1.4 KiB
JavaScript

// Copy deployment-only client config from the live web app into the bundled
// cinny/config.json before a desktop build.
//
// The web deploy serves a config.json kept on the server (not in git), so
// values such as the Giphy key exist only there; the desktop app bundles the
// repo's config.json, where they are empty. Without this the GIF picker can be
// switched on in Settings and still never show a button on desktop.
//
// Only an allow-list of keys is copied, and a failure to fetch is a warning:
// the build still succeeds, just without those values.
import { readFileSync, writeFileSync } from 'node:fs';
const SOURCE = process.env.WEB_CONFIG_URL || 'https://chat.lotusguild.org/config.json';
const TARGET = 'cinny/config.json';
const KEYS = ['gifApiKey'];
try {
const res = await fetch(SOURCE, { signal: AbortSignal.timeout(15000) });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const web = await res.json();
const local = JSON.parse(readFileSync(TARGET, 'utf8'));
const copied = KEYS.filter((k) => typeof web[k] === 'string' && web[k] && local[k] !== web[k]);
copied.forEach((k) => {
local[k] = web[k];
});
writeFileSync(TARGET, `${JSON.stringify(local, null, 2)}\n`);
console.log(`sync-web-config: ${copied.length ? `set ${copied.join(', ')}` : 'nothing to change'}`);
} catch (e) {
console.warn(`sync-web-config: skipped (${e.message}); building with the repo config`);
}