2022-05-02 17:17:33 +02:00
|
|
|
import {Argument, program} from "commander"
|
2021-11-05 17:11:35 +01:00
|
|
|
import {runDevBuild} from "./buildSrc/DevBuild.js"
|
2019-09-13 13:49:11 +02:00
|
|
|
import {spawn} from "child_process"
|
2017-08-15 13:54:22 +02:00
|
|
|
|
2022-04-28 14:36:24 +02:00
|
|
|
await program
|
|
|
|
.usage('[options] [test|prod|local|host <url>]')
|
|
|
|
.addArgument(new Argument("stage")
|
|
|
|
.choices(["test", "prod", "local", "host"])
|
|
|
|
.default("local")
|
|
|
|
.argOptional())
|
|
|
|
.addArgument(new Argument("host").argOptional())
|
2018-10-02 16:02:55 +02:00
|
|
|
.option('-c, --clean', 'Clean build directory')
|
2021-09-07 15:45:28 +02:00
|
|
|
.option('-d, --desktop', 'Assemble & start desktop client')
|
|
|
|
.option('-s, --serve', 'Start a local server to serve the website')
|
2021-11-05 17:11:35 +01:00
|
|
|
.action(async (stage, host, options) => {
|
2022-04-28 14:36:24 +02:00
|
|
|
if (stage === "host" && host == null || stage !== "host" && host != null) {
|
|
|
|
program.outputHelp()
|
2018-12-21 13:29:35 +01:00
|
|
|
process.exit(1)
|
|
|
|
}
|
2021-07-28 12:20:36 +02:00
|
|
|
|
2021-11-05 17:11:35 +01:00
|
|
|
const {clean, watch, serve, desktop} = options
|
|
|
|
|
2022-05-02 17:17:33 +02:00
|
|
|
if (serve) {
|
|
|
|
console.error("--serve is currently disabled, point any server to ./build directory instead or build desktop")
|
|
|
|
}
|
|
|
|
|
2021-11-05 17:11:35 +01:00
|
|
|
try {
|
|
|
|
await runDevBuild({
|
|
|
|
stage: stage ?? "local",
|
|
|
|
host,
|
|
|
|
clean,
|
|
|
|
watch,
|
|
|
|
serve,
|
|
|
|
desktop
|
|
|
|
})
|
|
|
|
|
|
|
|
if (desktop) {
|
|
|
|
// we don't want to quit here because we want to keep piping output to our stdout.
|
|
|
|
spawn("./start-desktop.sh", {stdio: "inherit"})
|
|
|
|
} else if (!watch) {
|
|
|
|
// Don't wait for spawned child processes to exit (because they never will)
|
|
|
|
process.exit(0)
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error("Build failed:", e)
|
|
|
|
process.exit(1)
|
2021-07-28 12:20:36 +02:00
|
|
|
}
|
2021-11-05 17:11:35 +01:00
|
|
|
})
|
2022-04-28 14:36:24 +02:00
|
|
|
.parseAsync(process.argv)
|