77 lines
2.1 KiB
JavaScript
77 lines
2.1 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* electron-builder 산출물 → chatbotApp public-ai/downloads/ 복사
|
|
*/
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import {
|
|
DOWNLOAD_ARTIFACTS,
|
|
DOWNLOAD_ARTIFACT_LIST,
|
|
OBSOLETE_DOWNLOAD_ARTIFACTS,
|
|
} from "./download-artifacts.mjs";
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const distDir = path.join(root, "dist");
|
|
const downloadsDir = path.resolve(
|
|
root,
|
|
"../chatbotApp-chatbot2.0-agent/public-ai/downloads",
|
|
);
|
|
const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
|
|
if (!fs.existsSync(distDir)) {
|
|
console.error(`[publish-downloads] dist 없음: ${distDir}`);
|
|
console.error("먼저 npm run dist:mac 또는 dist:win 을 실행하세요.");
|
|
process.exit(1);
|
|
}
|
|
|
|
fs.mkdirSync(downloadsDir, { recursive: true });
|
|
|
|
for (const name of OBSOLETE_DOWNLOAD_ARTIFACTS) {
|
|
const p = path.join(downloadsDir, name);
|
|
if (fs.existsSync(p)) {
|
|
fs.unlinkSync(p);
|
|
console.log(`[publish-downloads] removed obsolete ${name}`);
|
|
}
|
|
}
|
|
|
|
const copied = [];
|
|
for (const name of DOWNLOAD_ARTIFACT_LIST) {
|
|
const src = path.join(distDir, name);
|
|
if (!fs.existsSync(src)) {
|
|
console.warn(`[publish-downloads] skip (없음): ${name}`);
|
|
continue;
|
|
}
|
|
const dest = path.join(downloadsDir, name);
|
|
fs.copyFileSync(src, dest);
|
|
const stat = fs.statSync(dest);
|
|
copied.push({
|
|
file: name,
|
|
size: stat.size,
|
|
mtime: stat.mtime.toISOString(),
|
|
});
|
|
console.log(`[publish-downloads] ${name} → ${dest}`);
|
|
}
|
|
|
|
const manifest = {
|
|
version: pkg.version,
|
|
updatedAt: new Date().toISOString(),
|
|
files: { ...DOWNLOAD_ARTIFACTS },
|
|
artifacts: copied,
|
|
note:
|
|
"미서명 빌드 — Mac: dmg(설치) / zip(포터블·실행하기.command). Windows: Setup.exe(설치) / portable.exe(포터블).",
|
|
};
|
|
|
|
fs.writeFileSync(
|
|
path.join(downloadsDir, "manifest.json"),
|
|
`${JSON.stringify(manifest, null, 2)}\n`,
|
|
"utf8",
|
|
);
|
|
|
|
if (copied.length === 0) {
|
|
console.error("[publish-downloads] 복사된 파일이 없습니다.");
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`[publish-downloads] ✅ ${copied.length}개 → ${downloadsDir}`);
|