-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathucpem.js
More file actions
77 lines (67 loc) · 2.4 KB
/
ucpem.js
File metadata and controls
77 lines (67 loc) · 2.4 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/// <reference path="./.vscode/config.d.ts" />
const { spawnSync } = require("child_process")
const { writeFile } = require("fs/promises")
const { userInfo } = require("os")
const { join } = require("path")
const { project, include, github, log, constants, copy } = require("ucpem")
include("frontend/ucpem.js")
include("cli/ucpem.js")
project.prefix("src").res("common",
github("bt7s7k7/Struct").res("structSync"),
github("bt7s7k7/SimpleServer").res("simpleAuth"),
)
project.prefix("src").res("backend",
project.ref("common"),
github("bt7s7k7/Struct").res("structSyncExpress"),
github("bt7s7k7/LogLib").res("nodeLogger"),
github("bt7s7k7/SimpleServer").res("simpleDB"),
github("bt7s7k7/AdminGUI").res("adminUIBridge")
)
project.script("make-systemd-unit", async () => {
await writeFile("./smwa.service", [
`[Unit]`,
`Description=SMWA`,
``,
`[Service]`,
`Environment=NODE_VERSION=20`,
`ExecStart=${join(process.env.NVM_DIR, "nvm-exec")} ${join(constants.projectPath, "build/index.js")}`,
`WorkingDirectory=${constants.projectPath}`,
`LimitNOFILE=4096`,
`IgnoreSIGPIPE=false`,
`KillMode=control-group`,
`User=${userInfo().username}`,
`Restart=on-success`,
``,
`[Install]`,
`WantedBy=multi-user.target`,
].join("\n"))
log(`Run "sudo cp ./smwa.service /etc/systemd/system/smwa.service" to install`)
})
project.script("esbuild", async () => {
const { build } = require("esbuild")
await build({
bundle: true,
format: "cjs",
entryPoints: ["./src/index.ts"],
outfile: "dist/index.js",
sourcemap: "external",
external: [
"node-pty"
],
logLevel: "info",
platform: "node",
preserveSymlinks: true
})
await copy(join(constants.projectPath, "frontend/dist"), join(constants.projectPath, "dist/frontend/dist"), { quiet: true })
await writeFile(join(constants.projectPath, "dist/package.json"), JSON.stringify({
name: "smwa",
main: "index.js",
private: true,
dependencies: {
"node-pty": "^0.10.1"
}
}, null, 4))
})
project.script("smwa-cli", async (args) => {
spawnSync("node", [join(constants.projectPath, "cli/build/app/app.js"), ...args], { stdio: "inherit", shell: true })
}, { argc: NaN, desc: "Runs the SMWA CLI tool" })