Notes/bin/copy-dist.ts

66 lines
1.7 KiB
TypeScript
Raw Normal View History

2024-07-14 13:03:06 +03:00
import fs from "fs-extra";
import path from "path";
const DEST_DIR = "./build";
2024-07-27 16:42:47 +03:00
const VERBOSE = process.env.VERBOSE;
function log(...args: any[]) {
2025-01-09 18:07:02 +02:00
if (VERBOSE) {
console.log(...args);
2025-01-09 18:07:02 +02:00
}
2024-07-27 16:42:47 +03:00
}
try {
const assetsToCopy = new Set([
// copy node_module, to avoid downloading packages a 2nd time during pruning
2025-03-23 22:47:59 +02:00
"./node_modules",
"./images",
"./libraries",
"./translations",
"./db",
"./config-sample.ini",
"./package-lock.json",
"./package.json",
"./LICENSE",
"./README.md",
"./forge.config.cjs",
"./bin/tpl/",
"./bin/cleanupNodeModules.ts",
"./bin/electron-forge/desktop.ejs",
2025-03-23 23:22:22 +02:00
"./bin/electron-forge/sign-windows.cjs",
"./src/views/",
2025-02-15 00:25:23 +02:00
"./src/etapi/etapi.openapi.yaml",
"./src/routes/api/openapi.json",
"./src/public/icon.png",
"./src/public/manifest.webmanifest",
"./src/public/robots.txt",
"./src/public/fonts",
"./src/public/stylesheets",
"./src/public/translations",
"./packages/turndown-plugin-gfm/src"
]);
for (const asset of assetsToCopy) {
log(`Copying ${asset}`);
fs.copySync(asset, path.join(DEST_DIR, asset));
2025-01-09 18:07:02 +02:00
}
2025-01-09 18:07:02 +02:00
/**
* Directories to be copied relative to the project root into <resource_dir>/src/public/app-dist.
*/
const publicDirsToCopy = ["./src/public/app/doc_notes"];
const PUBLIC_DIR = path.join(DEST_DIR, "src", "public", "app-dist");
for (const dir of publicDirsToCopy) {
fs.copySync(dir, path.join(PUBLIC_DIR, path.basename(dir)));
2025-01-09 18:07:02 +02:00
}
2024-11-02 16:11:59 +02:00
console.log("Copying complete!")
} catch(err) {
console.error("Error during copy:", err)
process.exit(1)
2025-03-11 23:03:13 +02:00
}