mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 19:36:12 +01:00
chore(dx/server): trigger build of client & copy artifacts
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import * as esbuild from "esbuild";
|
import * as esbuild from "esbuild";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import * as fs from "fs-extra";
|
import * as fs from "fs-extra";
|
||||||
|
import * as child_process from "child_process";
|
||||||
|
|
||||||
const projectDir = __dirname + "/..";
|
const projectDir = __dirname + "/..";
|
||||||
const outDir = join(projectDir, "dist");
|
const outDir = join(projectDir, "dist");
|
||||||
@@ -51,6 +52,17 @@ function copyAssets() {
|
|||||||
copy("../../packages/share-theme/src/templates", "share-theme/templates/");
|
copy("../../packages/share-theme/src/templates", "share-theme/templates/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildAndCopyClient() {
|
||||||
|
// Trigger the build.
|
||||||
|
child_process.execSync("pnpm build", { cwd: clientDir, stdio: "inherit" });
|
||||||
|
|
||||||
|
// Copy the artifacts.
|
||||||
|
copy("../client/dist", "public/");
|
||||||
|
|
||||||
|
// Remove unnecessary files.
|
||||||
|
deleteFromOutput("public/webpack-stats.json");
|
||||||
|
}
|
||||||
|
|
||||||
function copy(projectDirPath: string, outDirPath: string) {
|
function copy(projectDirPath: string, outDirPath: string) {
|
||||||
if (outDirPath.endsWith("/")) {
|
if (outDirPath.endsWith("/")) {
|
||||||
fs.mkdirpSync(join(outDirPath));
|
fs.mkdirpSync(join(outDirPath));
|
||||||
@@ -58,10 +70,15 @@ function copy(projectDirPath: string, outDirPath: string) {
|
|||||||
fs.copySync(join(projectDir, projectDirPath), join(outDir, outDirPath), { dereference: true });
|
fs.copySync(join(projectDir, projectDirPath), join(outDir, outDirPath), { dereference: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteFromOutput(path: string) {
|
||||||
|
fs.rmSync(join(outDir, path), { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
fs.emptyDirSync(outDir);
|
fs.emptyDirSync(outDir);
|
||||||
await build();
|
await build();
|
||||||
copyAssets();
|
copyAssets();
|
||||||
|
buildAndCopyClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|||||||
Reference in New Issue
Block a user