mirror of
https://github.com/algometrix/second_brain_builder.git
synced 2026-07-22 08:29:32 +00:00
Output release assets to release/ with a personal-modes guard
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
01f8b4c412
commit
4f271b07e3
3 changed files with 30 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,5 +1,6 @@
|
|||
node_modules/
|
||||
main.js
|
||||
release/
|
||||
.claude/
|
||||
data.json
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
"scripts": {
|
||||
"dev": "node scripts/sync-modes.js && node esbuild.config.mjs",
|
||||
"build": "node scripts/sync-modes.js && tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||
"build:release": "node scripts/sync-modes.js --sample && tsc -noEmit -skipLibCheck && node esbuild.config.mjs production"
|
||||
"build:release": "node scripts/sync-modes.js --sample && tsc -noEmit -skipLibCheck && node esbuild.config.mjs production && node scripts/package-release.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
|
|
|
|||
28
scripts/package-release.js
Normal file
28
scripts/package-release.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Copies the release artifacts into release/ after a release build.
|
||||
// Run via `npm run build:release`; upload the contents of release/ as the
|
||||
// GitHub release assets.
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const root = path.join(__dirname, '..');
|
||||
const outDir = path.join(root, 'release');
|
||||
|
||||
const bundle = fs.readFileSync(path.join(root, 'main.js'), 'utf8');
|
||||
const personal = path.join(root, 'modes.personal.json');
|
||||
if (fs.existsSync(personal)) {
|
||||
const ids = JSON.parse(fs.readFileSync(personal, 'utf8')).map((m) => m.id);
|
||||
const sampleIds = JSON.parse(fs.readFileSync(path.join(root, 'modes.sample.json'), 'utf8')).map((m) => m.id);
|
||||
const leaked = ids.filter((id) => !sampleIds.includes(id) && bundle.includes(`"${id}"`));
|
||||
if (leaked.length > 0) {
|
||||
console.error(`Refusing to package: main.js contains personal modes (${leaked.join(', ')}).`);
|
||||
console.error('Run "npm run build:release" so the bundle is built from modes.sample.json.');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
for (const name of ['main.js', 'manifest.json', 'styles.css']) {
|
||||
fs.copyFileSync(path.join(root, name), path.join(outDir, name));
|
||||
}
|
||||
console.log(`Release assets written to release/ (main.js, manifest.json, styles.css)`);
|
||||
Loading…
Reference in a new issue