Files
game_voice_recorder/app/build.mjs
EJClaw 35d2cab792 앱 v1.1.0: 겜녹이 봇 기본 연결 + '다른 봇으로 진행하기'
- 설정 discord.botMode (builtin 기본 / custom). 겜녹이 봇은 토큰 입력 없이 연결
- 겜녹이 봇 토큰은 저장소에 두지 않고 빌드 때 GVR_BUILTIN_BOT_TOKEN 에서 읽어 감춘 값으로 박는다
- 마법사·디스코드 탭에 봇 선택 카드, 다른 봇일 때만 토큰 입력. 오가도 넣은 토큰 유지
- v1.0.0 에서 토큰을 넣어 쓰던 설치는 custom 으로 이어짐
- win-ci full 빌드가 서버 비밀 저장소에서 토큰을 넣고, smoke 에 기본 봇 로그인 결과 기록
- 테스트 6개 추가 (기본·다른 봇·전환·이전 설치·기본 봇 없는 빌드·개발 env)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 04:54:48 +09:00

41 lines
2.5 KiB
JavaScript

// 앱 빌드: 메인·preload (CJS, node_modules 는 그대로 두고 asar 로 묶음) + 렌더러(React 번들) + 스키마 사본
import { build } from 'esbuild';
import fs from 'node:fs';
import path from 'node:path';
const root = import.meta.dirname; // Windows 에서 URL.pathname 은 /C:/... 라 쓰면 안 된다
const shared = path.join(root, '..', 'packages', 'shared', 'src', 'index.ts');
fs.writeFileSync(
path.join(root, 'src/core/db/schema.ts'),
'// 자동 생성: schema.sql 사본 (npm run build 가 다시 만든다)\nexport const SCHEMA_SQL = ' + JSON.stringify(fs.readFileSync(path.join(root, 'src/core/db/schema.sql'), 'utf8')) + ';\n',
);
fs.rmSync(path.join(root, 'dist'), { recursive: true, force: true });
// 겜녹이 기본 봇 토큰: 환경변수에서만 받아 감춘 값으로 박는다 (저장소·로그에 남기지 않는다)
let builtinBot = '';
if (process.env.GVR_BUILTIN_BOT_TOKEN) {
const mod = await build({ entryPoints: [path.join(root, 'src/core/builtin-bot.ts')], bundle: true, platform: 'node', format: 'esm', write: false, logLevel: 'silent' });
const { encodeBuiltinToken } = await import('data:text/javascript;base64,' + Buffer.from(mod.outputFiles[0].text).toString('base64'));
builtinBot = encodeBuiltinToken(process.env.GVR_BUILTIN_BOT_TOKEN.trim());
}
console.log(`겜녹이 기본 봇 토큰: ${builtinBot ? '포함' : '없음 (GVR_BUILTIN_BOT_TOKEN 미설정)'}`);
const common = { bundle: true, platform: 'node', target: 'node22', format: 'cjs', sourcemap: true, alias: { '@gvr/shared': shared }, define: { __GVR_BUILTIN_BOT__: JSON.stringify(builtinBot) }, logLevel: 'info' };
await build({ ...common, entryPoints: ['src/main/main.ts'], outfile: 'dist/main.cjs', packages: 'external', external: ['electron'] });
await build({ ...common, entryPoints: ['src/main/preload.ts'], outfile: 'dist/preload.cjs', external: ['electron'] });
await build({ ...common, entryPoints: ['src/core/cli.ts'], outfile: 'dist/cli.cjs', packages: 'external' });
if (fs.existsSync(path.join(root, 'src/renderer/main.tsx'))) {
await build({
entryPoints: ['src/renderer/main.tsx'],
bundle: true,
outfile: 'dist/renderer/renderer.js',
platform: 'browser',
target: 'chrome130',
jsx: 'automatic',
loader: { '.png': 'file', '.svg': 'file' },
alias: { '@gvr/shared': shared },
define: { 'process.env.NODE_ENV': '"production"' },
minify: true,
logLevel: 'info',
});
fs.copyFileSync('src/renderer/index.html', 'dist/renderer/index.html');
}