first commit
This commit is contained in:
50
scripts/copy-fullcalendar-css.js
Normal file
50
scripts/copy-fullcalendar-css.js
Normal file
@@ -0,0 +1,50 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const mappings = [
|
||||
{ pkg: "@fullcalendar/core", target: "fullcalendar-core.css" },
|
||||
{ pkg: "@fullcalendar/daygrid", target: "fullcalendar-daygrid.css" },
|
||||
{ pkg: "@fullcalendar/timegrid", target: "fullcalendar-timegrid.css" },
|
||||
{ pkg: "@fullcalendar/list", target: "fullcalendar-list.css" }
|
||||
];
|
||||
|
||||
const candidates = [
|
||||
"main.css",
|
||||
"index.css",
|
||||
"style.css",
|
||||
"styles.css",
|
||||
"main.min.css",
|
||||
"index.min.css",
|
||||
"dist/main.css",
|
||||
"dist/index.css"
|
||||
];
|
||||
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const targetDir = path.join(root, "public", "vendor", "fullcalendar");
|
||||
|
||||
if (!fs.existsSync(targetDir)) {
|
||||
fs.mkdirSync(targetDir, { recursive: true });
|
||||
}
|
||||
|
||||
let missing = 0;
|
||||
|
||||
mappings.forEach(({ pkg, target }) => {
|
||||
const basePath = path.join(root, "node_modules", pkg);
|
||||
const sourcePath =
|
||||
candidates
|
||||
.map((candidate) => path.join(basePath, candidate))
|
||||
.find((candidatePath) => fs.existsSync(candidatePath)) || null;
|
||||
const targetPath = path.join(targetDir, target);
|
||||
|
||||
if (!sourcePath) {
|
||||
console.error(`Missing FullCalendar CSS for ${pkg}`);
|
||||
missing += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
fs.copyFileSync(sourcePath, targetPath);
|
||||
});
|
||||
|
||||
if (missing > 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user