2021-10-10 11:02:25 +02:00
|
|
|
const { execSync } = require("child_process");
|
2021-10-07 18:21:01 +02:00
|
|
|
const path = require("path");
|
2021-10-10 11:02:25 +02:00
|
|
|
const fse = require("fs-extra");
|
2021-10-10 17:55:48 +02:00
|
|
|
const { getSystemErrorMap } = require("util");
|
|
|
|
const { argv } = require("process");
|
2021-10-07 18:21:01 +02:00
|
|
|
|
2021-10-10 17:55:48 +02:00
|
|
|
const dirs = ["api", "util", "cdn", "gateway", "bundle"];
|
2021-10-07 18:21:01 +02:00
|
|
|
|
2021-10-10 17:55:48 +02:00
|
|
|
const verbose = argv.includes("verbose") || argv.includes("v");
|
2021-10-07 18:21:01 +02:00
|
|
|
|
2021-10-15 00:44:19 +02:00
|
|
|
if (argv.includes("clean")) {
|
2021-10-20 17:54:54 +02:00
|
|
|
dirs.forEach((a) => {
|
|
|
|
var d = "../" + a + "/dist";
|
|
|
|
if (fse.existsSync(d)) {
|
|
|
|
fse.rmSync(d, { recursive: true });
|
|
|
|
if (verbose) console.log(`Deleted ${d}!`);
|
|
|
|
}
|
|
|
|
});
|
2021-10-07 18:21:01 +02:00
|
|
|
}
|
|
|
|
|
2021-10-20 02:11:12 +02:00
|
|
|
fse.copySync(
|
2021-10-20 17:54:54 +02:00
|
|
|
path.join(__dirname, "..", "..", "api", "assets"),
|
|
|
|
path.join(__dirname, "..", "dist", "api", "assets")
|
2021-10-20 02:11:12 +02:00
|
|
|
);
|
2021-10-10 12:35:46 +02:00
|
|
|
fse.copySync(
|
2021-10-20 17:54:54 +02:00
|
|
|
path.join(__dirname, "..", "..", "api", "client_test"),
|
|
|
|
path.join(__dirname, "..", "dist", "api", "client_test")
|
2021-10-10 12:35:46 +02:00
|
|
|
);
|
2021-10-20 02:11:12 +02:00
|
|
|
fse.copySync(
|
2021-10-20 17:54:54 +02:00
|
|
|
path.join(__dirname, "..", "..", "api", "locales"),
|
|
|
|
path.join(__dirname, "..", "dist", "api", "locales")
|
2021-10-20 02:11:12 +02:00
|
|
|
);
|
2021-10-15 00:44:19 +02:00
|
|
|
dirs.forEach((a) => {
|
2021-10-20 17:54:54 +02:00
|
|
|
fse.copySync("../" + a + "/src", "dist/" + a + "/src");
|
|
|
|
if (verbose)
|
|
|
|
console.log(`Copied ${"../" + a + "/dist"} -> ${"dist/" + a + "/src"}!`);
|
2021-10-07 18:21:01 +02:00
|
|
|
});
|
2021-10-08 10:43:43 +02:00
|
|
|
|
2021-10-20 17:54:54 +02:00
|
|
|
console.log("Copying src files done");
|
|
|
|
if (!argv.includes("copyonly")) {
|
|
|
|
console.log("Compiling src files ...");
|
2021-10-07 18:21:01 +02:00
|
|
|
|
2021-10-20 17:54:54 +02:00
|
|
|
console.log(
|
|
|
|
execSync(
|
|
|
|
'node "' +
|
|
|
|
path.join(
|
|
|
|
__dirname,
|
|
|
|
"..",
|
|
|
|
"node_modules",
|
|
|
|
"typescript",
|
|
|
|
"lib",
|
|
|
|
"tsc.js"
|
|
|
|
) +
|
|
|
|
'" -p "' +
|
|
|
|
path.join(__dirname, "..") +
|
|
|
|
'"',
|
|
|
|
{
|
|
|
|
cwd: path.join(__dirname, ".."),
|
|
|
|
shell: true,
|
|
|
|
env: process.env,
|
|
|
|
encoding: "utf8",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|