Initial commit: 小羚羚小程序 Axhub Make workspace.
Include xll-miniapp prototype, PRD resources, annotation directory sync, agent skills, and cloud publishing setup. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
48
scripts/build-all.js
Normal file
48
scripts/build-all.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { spawnSync } from 'child_process';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { scanProjectEntries, writeEntriesManifestAtomic } from '../vite-plugins/utils/entriesManifestCore.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const workspaceRoot = path.resolve(__dirname, '..');
|
||||
const entriesPath = path.resolve(workspaceRoot, '.axhub/make/entries.json');
|
||||
|
||||
// Always rescan before build to keep entries manifest fresh and deterministic.
|
||||
const scanned = scanProjectEntries(workspaceRoot, ['prototypes', 'themes']);
|
||||
const entries = writeEntriesManifestAtomic(workspaceRoot, scanned);
|
||||
if (!fs.existsSync(entriesPath)) {
|
||||
console.error('.axhub/make/entries.json 写入失败,无法继续构建。');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const jsEntries = entries.js || {};
|
||||
const entryKeys = Object.keys(jsEntries);
|
||||
|
||||
if (entryKeys.length === 0) {
|
||||
console.log('未发现 JS 入口,跳过构建。');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const distDir = path.resolve(workspaceRoot, 'dist');
|
||||
if (fs.existsSync(distDir)) {
|
||||
fs.rmSync(distDir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
for (const key of entryKeys) {
|
||||
console.log(`\n==== 构建入口: ${key} ====\n`);
|
||||
const result = spawnSync('npx', ['vite', 'build'], {
|
||||
cwd: workspaceRoot,
|
||||
env: { ...process.env, ENTRY_KEY: key },
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
if (result.status !== 0) {
|
||||
console.error(`构建 ${key} 失败,退出码 ${result.status}`);
|
||||
process.exit(result.status ?? 1);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('\n所有入口构建完成 ✅');
|
||||
Reference in New Issue
Block a user