1
Fork 0
ingeli-design-system/5-build/deploy-one.js
2026-02-04 16:40:43 +01:00

88 lines
2.2 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import fs from "fs";
import path from "path";
import { stripBOM } from "./utils/fs-utils.js";
const [,, clientName, appName, variantName, ...flags] = process.argv;
const touchVersion = flags.includes("--touch");
if (!clientName || !appName || !variantName) {
console.error("❌ Usage: node deploy-one.js <client> <application> <variant> [--touch]");
process.exit(1);
}
const ROOT = process.cwd();
const CONFIG_FILE = path.join(
ROOT,
"4-clients",
clientName,
"client.config.json"
);
if (!fs.existsSync(CONFIG_FILE)) {
console.error(`❌ Config not found: ${CONFIG_FILE}`);
process.exit(1);
}
const rawConfig = fs.readFileSync(CONFIG_FILE, "utf8");
const config = JSON.parse(stripBOM(rawConfig));
const app = config.applications.find(a => a.name === appName);
if (!app) {
console.error(`❌ Application "${appName}" not found for client "${clientName}"`);
process.exit(1);
}
if (!app.variants.includes(variantName)) {
console.error(
`❌ Variant "${variantName}" not defined for application "${appName}"`
);
process.exit(1);
}
const DIST_DIR = path.join(
ROOT,
"dist",
clientName,
variantName
);
if (!fs.existsSync(DIST_DIR)) {
console.error(`❌ Build output not found: ${DIST_DIR}`);
process.exit(1);
}
const TARGET_DIR = path.join(
ROOT,
config.csharpRoot,
app.deployPath,
"wwwroot",
"themes",
variantName
);
console.log("📤 Deploy");
console.log(` Client : ${clientName}`);
console.log(` Application : ${appName}`);
console.log(` Variant : ${variantName}`);
console.log(` From : ${DIST_DIR}`);
console.log(` To : ${TARGET_DIR}`);
/* 1⃣ Clean target directory */
if (fs.existsSync(TARGET_DIR)) {
fs.rmSync(TARGET_DIR, { recursive: true, force: true });
console.log(" 🧹 Target directory cleaned");
}
fs.mkdirSync(TARGET_DIR, { recursive: true });
for (const file of fs.readdirSync(DIST_DIR)) {
const src = path.join(DIST_DIR, file);
const dest = path.join(TARGET_DIR, file);
fs.copyFileSync(src, dest);
console.log(`${file}`);
}
console.log("✅ Deploy finished");