fix(monorepo/server): path of copy-dist

This commit is contained in:
Elian Doran 2025-04-18 18:31:41 +03:00
parent 4ecb80ce9a
commit 5b298867b3
No known key found for this signature in database

View File

@ -11,38 +11,56 @@ function log(...args: any[]) {
} }
} }
const ROOT_DIR = "../.."; import { fileURLToPath } from "url";
const CLIENT_DIR = "../client"; import { dirname } from "path";
const scriptDir = dirname(fileURLToPath(import.meta.url));
const rootDir = path.resolve(scriptDir, "..", "..", "..");
const clientDir = path.join(rootDir, "apps", "client");
const serverDir = path.join(rootDir, "apps", "server");
function copyAssets(baseDir: string, destDir: string, files: string[]) {
for (const file of files) {
const src = path.join(baseDir, file);
const dest = path.join(destDir, file);
log(`${src} -> ${dest}`);
fs.copySync(src, dest);
}
}
try { try {
const assetsToCopy = new Set([ const clientAssets = [
"./libraries",
`./stylesheets`
];
const serverAssets = [
// copy node_module, to avoid downloading packages a 2nd time during pruning // copy node_module, to avoid downloading packages a 2nd time during pruning
"./node_modules", "./node_modules",
`${CLIENT_DIR}/libraries`,
"./translations", "./translations",
"./db", "./db",
"./config-sample.ini", "./config-sample.ini",
"./package.json", "./package.json",
`${ROOT_DIR}/LICENSE`, "./src/public/icon.png",
`${ROOT_DIR}/README.md`, "./src/public/manifest.webmanifest",
"./src/public/robots.txt",
"./src/public/fonts",
"./src/public/translations",
`./tpl/`, `./tpl/`,
"./scripts/cleanupNodeModules.ts", "./scripts/cleanupNodeModules.ts",
"./src/views/", "./src/views/",
"./src/etapi/etapi.openapi.yaml", "./src/etapi/etapi.openapi.yaml",
"./src/routes/api/openapi.json", "./src/routes/api/openapi.json",
"./src/public/icon.png", ];
"./src/public/manifest.webmanifest",
"./src/public/robots.txt",
"./src/public/fonts",
`${CLIENT_DIR}/stylesheets`,
"./src/public/translations",
`${ROOT_DIR}/packages/turndown-plugin-gfm/src`
]);
for (const asset of assetsToCopy) { const rootAssets = [
log(`Copying ${asset}`); "LICENSE",
fs.copySync(asset, path.normalize(path.join(DEST_DIR, asset))); "README.md"
} ];
copyAssets(clientDir, path.join(DEST_DIR, "src", "public"), clientAssets);
copyAssets(serverDir, path.join(DEST_DIR), serverAssets);
copyAssets(rootDir, path.join(DEST_DIR), rootAssets);
/** /**
* Directories to be copied relative to the project root into <resource_dir>/src/public/app-dist. * Directories to be copied relative to the project root into <resource_dir>/src/public/app-dist.
@ -53,6 +71,8 @@ try {
fs.copySync(dir, path.normalize(path.join(PUBLIC_DIR, path.basename(dir)))); fs.copySync(dir, path.normalize(path.join(PUBLIC_DIR, path.basename(dir))));
} }
fs.copySync(path.join(rootDir, "packages", "turndown-plugin-gfm", "src"), path.join(DEST_DIR, "src", "public", "app-dist", "turndown-plugin-gfm"));
console.log("Copying complete!") console.log("Copying complete!")
} catch(err) { } catch(err) {