forked from tutao/tutanota
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.js
58 lines (53 loc) · 1.73 KB
/
make.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {Argument, program} from "commander"
import {runDevBuild} from "./buildSrc/DevBuild.js"
import {spawn} from "child_process"
import {chalk} from "zx"
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())
.option('-c, --clean', 'Clean build directory')
.option('-d, --desktop', 'Assemble & start desktop client')
.option('-v, --verbose', "activate verbose loggin in desktop client")
.option('-s, --serve', 'Start a local server to serve the website')
.option('--ignore-migrations', "Dont check offline database migrations.")
.action(async (stage, host, options) => {
if (stage === "host" && host == null || stage !== "host" && host != null) {
program.outputHelp()
process.exit(1)
}
const {clean, watch, serve, desktop, ignoreMigrations} = options
if (serve) {
console.error("--serve is currently disabled, point any server to ./build directory instead or build desktop")
}
try {
await runDevBuild({
stage: stage ?? "local",
host,
clean,
watch,
serve,
desktop,
ignoreMigrations
})
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",
env: options.verbose
? Object.assign({}, process.env, {"ELECTRON_ENABLE_LOGGING": 1})
: process.env
})
} else if (!watch) {
// Don't wait for spawned child processes to exit (because they never will)
process.exit(0)
}
} catch (e) {
console.error(chalk.red.underline("Build failed:"), e)
process.exit(1)
}
})
.parseAsync(process.argv)