-
Notifications
You must be signed in to change notification settings - Fork 0
/
riji.rhai
156 lines (128 loc) · 2.59 KB
/
riji.rhai
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
let npmPackages = [
"core-lib/js",
"core-lib/ui",
"core/ui",
"cinema/ui",
"pwvault/ui"
];
let apps = [
"core",
"cinema",
"pwvault"
];
fn help() {
print([
"- npm_install",
"- build <app>",
"- build_core_lib"
]);
}
fn npm_install() {
for pack in npmPackages {
let npm = cmd(["npm", "install"]);
npm.dir("./" + pack);
npm.execute();
}
}
fn npm_ci() {
for pack in npmPackages {
let npm = cmd(["npm", "ci"]);
npm.dir("./" + pack);
npm.execute();
}
}
fn npm_update() {
for pack in npmPackages {
let npm = cmd(["npm", "update"]);
npm.dir("./" + pack);
npm.execute();
}
}
fn cargo_update() {
for app in apps {
let cargo = cmd(["cargo", "update"]);
cargo.dir("./" + app + "/server");
cargo.execute();
}
let cargo = cmd(["cargo", "update"]);
cargo.dir("./core-lib/build");
cargo.execute();
let cargo = cmd(["cargo", "update"]);
cargo.dir("./core-lib/lib");
cargo.execute();
}
// how does the build process work
/// config should be
/// [apps]
/// dir = "./apps"
fn build_all() {
for app in apps {
build(app);
}
fs::delete("./dist");
fs::create_dir("./dist");
fs::copy("./target/release/core-server", "./dist");
fs::create_dir("./dist/apps");
for app in apps {
if app == "core" {
continue
}
let app_dir = "./dist/apps/" + app;
fs::create_dir(app_dir);
fs::copy(
"./target/release/lib" + app + "_server.so",
app_dir + "/" + app + ".so"
);
}
}
fn build(app) {
let npm = cmd(["npm", "run", "build"]);
npm.dir("./" + app + "/ui");
npm.execute();
let cargo = cmd(["cargo", "build", "--release"]);
cargo.dir("./" + app + "/server");
cargo.execute();
}
fn init_core_lib() {
let install_js = cmd(["npm", "ci"]);
install_js.dir("./core-lib/js");
install_js.execute();
let js = cmd(["npm", "run", "build"]);
js.dir("./core-lib/js");
js.execute();
// somehow this does not work on ci
let install_ui = cmd(["npm", "install"]);
install_ui.dir("./core-lib/ui");
install_ui.execute();
let ui = cmd(["npm", "run", "build"]);
ui.dir("./core-lib/ui");
ui.execute();
}
/// build everything to see if it works
fn test_build() {
for app in apps {
test_build(app);
}
}
fn test_build(app) {
let npm = cmd(["npm", "run", "build"]);
npm.dir("./" + app + "/ui");
npm.execute();
if app == "core" {
build_core_lib();
}
let cargo = cmd(["cargo", "build"]);
cargo.dir("./" + app + "/server");
cargo.execute();
}
fn build_docker() {
fs::create_dir("./images");
let build = cmd([
"docker", "build", "-t", "alpenwind", "."
]);
build.execute();
let save = cmd([
"docker", "save", "-o", "./images/alpenwind.tar", "alpenwind"
]);
save.execute();
}