@platforma-sdk/bootstrap 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/compose-backend.yaml +6 -6
- package/dist/cmd-opts.d.ts +6 -3
- package/dist/cmd-opts.d.ts.map +1 -1
- package/dist/commands/start/docker/s3.d.ts +6 -3
- package/dist/commands/start/docker/s3.d.ts.map +1 -1
- package/dist/commands/start/docker.d.ts +6 -3
- package/dist/commands/start/docker.d.ts.map +1 -1
- package/dist/commands/start/local/s3.d.ts +6 -3
- package/dist/commands/start/local/s3.d.ts.map +1 -1
- package/dist/commands/start/local.d.ts +6 -3
- package/dist/commands/start/local.d.ts.map +1 -1
- package/dist/core.d.ts +15 -6
- package/dist/core.d.ts.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +928 -469
- package/dist/index.mjs.map +1 -1
- package/dist/package.d.ts +0 -1
- package/dist/package.d.ts.map +1 -1
- package/dist/platforma.d.ts.map +1 -1
- package/dist/state.d.ts +3 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/templates/pl-config.d.ts.map +1 -1
- package/dist/templates/types.d.ts +6 -0
- package/dist/templates/types.d.ts.map +1 -1
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -1
- package/package.json +10 -7
- package/src/block.ts +0 -82
- package/src/cmd-opts.ts +0 -175
- package/src/commands/create-block.ts +0 -21
- package/src/commands/reset.ts +0 -23
- package/src/commands/start/docker/s3.ts +0 -59
- package/src/commands/start/docker.ts +0 -65
- package/src/commands/start/local/s3.ts +0 -96
- package/src/commands/start/local.ts +0 -89
- package/src/commands/start.ts +0 -23
- package/src/commands/stop.ts +0 -23
- package/src/core.ts +0 -696
- package/src/index.ts +0 -10
- package/src/package.ts +0 -54
- package/src/platforma.ts +0 -194
- package/src/run.ts +0 -120
- package/src/state.ts +0 -105
- package/src/templates/pl-config.ts +0 -280
- package/src/templates/types.ts +0 -172
- package/src/util.ts +0 -55
package/dist/index.mjs
CHANGED
|
@@ -1,39 +1,85 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var m = (
|
|
4
|
-
import { Flags as
|
|
5
|
-
import { spawn as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { randomBytes as
|
|
12
|
-
import
|
|
13
|
-
import "
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
1
|
+
var er = Object.defineProperty;
|
|
2
|
+
var rr = (a, e, r) => e in a ? er(a, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[e] = r;
|
|
3
|
+
var m = (a, e, r) => rr(a, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { Flags as y, Command as O } from "@oclif/core";
|
|
5
|
+
import { execSync as Me, spawn as tr, spawnSync as H } from "node:child_process";
|
|
6
|
+
import Ce from "yaml";
|
|
7
|
+
import o, { createWriteStream as ar } from "node:fs";
|
|
8
|
+
import p from "node:os";
|
|
9
|
+
import f, { resolve as ir } from "node:path";
|
|
10
|
+
import j from "winston";
|
|
11
|
+
import { randomBytes as sr } from "node:crypto";
|
|
12
|
+
import V from "readline-sync";
|
|
13
|
+
import cr from "node:https";
|
|
14
|
+
import * as nr from "tar";
|
|
15
|
+
import { Writable as lr } from "node:stream";
|
|
16
|
+
import { z as K } from "zod";
|
|
17
|
+
import or from "decompress";
|
|
18
|
+
function Ue(...a) {
|
|
19
|
+
return ir(__dirname, "..", ...a);
|
|
20
|
+
}
|
|
21
|
+
function $(...a) {
|
|
22
|
+
return Ue("assets", ...a);
|
|
23
|
+
}
|
|
24
|
+
function dr() {
|
|
25
|
+
return o.readdirSync($()).filter((e) => e.startsWith("compose-") && e.endsWith(".yaml")).map((e) => $(e));
|
|
26
|
+
}
|
|
27
|
+
function We(...a) {
|
|
28
|
+
return o.readFileSync(Ue(...a));
|
|
29
|
+
}
|
|
30
|
+
var ae;
|
|
31
|
+
function Q() {
|
|
32
|
+
return ae || (ae = JSON.parse(We("package.json").toString())), ae;
|
|
33
|
+
}
|
|
34
|
+
function ie(a) {
|
|
35
|
+
return a || (a = Q()["pl-version"]), `quay.io/milaboratories/platforma:${a}`;
|
|
36
|
+
}
|
|
37
|
+
function gr(a) {
|
|
38
|
+
return V.question(`${a} [y/N] `).toLowerCase() === "y";
|
|
39
|
+
}
|
|
40
|
+
function Y(a) {
|
|
41
|
+
throw new Error("this should never happen");
|
|
42
|
+
}
|
|
43
|
+
function T(a = "debug") {
|
|
44
|
+
return j.createLogger({
|
|
45
|
+
level: a,
|
|
46
|
+
format: j.format.combine(
|
|
47
|
+
j.format.printf(({ level: e, message: r }) => {
|
|
48
|
+
const t = " ".repeat(e.length + 2), i = r.split(`
|
|
49
|
+
`).map((c, n) => n === 0 ? c : t + c).join(`
|
|
50
|
+
`);
|
|
51
|
+
return `${((c) => j.format.colorize().colorize(c, c))(e)}: ${i}`;
|
|
52
|
+
})
|
|
53
|
+
),
|
|
54
|
+
transports: [
|
|
55
|
+
new j.transports.Console({
|
|
56
|
+
stderrLevels: ["error", "warn", "info", "debug"],
|
|
57
|
+
handleExceptions: !0
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function ur(a) {
|
|
63
|
+
return sr(Math.ceil(a / 2)).toString("hex").slice(0, a);
|
|
64
|
+
}
|
|
65
|
+
function fr(a) {
|
|
66
|
+
return a.startsWith("~") ? f.join(p.homedir(), a.slice(1)) : a;
|
|
67
|
+
}
|
|
68
|
+
function q(a) {
|
|
69
|
+
o.existsSync(a) || o.mkdirSync(a, { recursive: !0 });
|
|
70
|
+
}
|
|
71
|
+
function hr(a) {
|
|
72
|
+
try {
|
|
73
|
+
if (p.platform() !== "win32")
|
|
74
|
+
return Me(`ps -p ${a} -o comm=`, { encoding: "utf8" }).trim();
|
|
75
|
+
const e = `wmic process where processid=${a} get Caption`, r = Me(e, { encoding: "utf8" }).split(`
|
|
76
|
+
`);
|
|
77
|
+
return r.length <= 1 ? "" : r[1].trim();
|
|
78
|
+
} catch {
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const F = class F {
|
|
37
83
|
constructor(e) {
|
|
38
84
|
m(this, "state", {
|
|
39
85
|
lastRun: void 0,
|
|
@@ -41,21 +87,35 @@ const w = class w {
|
|
|
41
87
|
});
|
|
42
88
|
m(this, "filePath");
|
|
43
89
|
m(this, "dirPath");
|
|
44
|
-
e = e ??
|
|
45
|
-
const r =
|
|
46
|
-
this.dirPath = e, this.filePath = r,
|
|
90
|
+
e = e ?? f.resolve(p.homedir(), ".config", "pl-bootstrap");
|
|
91
|
+
const r = f.join(e, "state.json");
|
|
92
|
+
this.dirPath = e, this.filePath = r, o.existsSync(e) || o.mkdirSync(e, { recursive: !0 }), o.existsSync(r) && (this.state = JSON.parse(We(r).toString()));
|
|
47
93
|
}
|
|
48
94
|
static getInstance() {
|
|
49
|
-
return
|
|
95
|
+
return F.instance || (F.instance = new F()), F.instance;
|
|
50
96
|
}
|
|
51
97
|
path(...e) {
|
|
52
|
-
return
|
|
98
|
+
return f.join(this.dirPath, ...e);
|
|
99
|
+
}
|
|
100
|
+
data(...e) {
|
|
101
|
+
return this.path("data", ...e);
|
|
102
|
+
}
|
|
103
|
+
binaries(...e) {
|
|
104
|
+
return this.path("binaries", ...e);
|
|
53
105
|
}
|
|
54
106
|
writeState() {
|
|
55
|
-
|
|
107
|
+
o.writeFileSync(this.filePath, JSON.stringify(this.state));
|
|
56
108
|
}
|
|
57
109
|
get isActive() {
|
|
58
|
-
|
|
110
|
+
var e, r;
|
|
111
|
+
return this.state.isActive ? this.state.isActive : (r = (e = this.state.lastRun) == null ? void 0 : e.process) != null && r.pid ? this.isValidPID : !1;
|
|
112
|
+
}
|
|
113
|
+
get isValidPID() {
|
|
114
|
+
var r, t;
|
|
115
|
+
if (!((t = (r = this.state.lastRun) == null ? void 0 : r.process) != null && t.pid))
|
|
116
|
+
return !1;
|
|
117
|
+
const e = hr(this.state.lastRun.process.pid);
|
|
118
|
+
return e === "platforma" || e.endsWith("/platforma") || e.endsWith("\\platforma");
|
|
59
119
|
}
|
|
60
120
|
set isActive(e) {
|
|
61
121
|
this.state.isActive = e, this.writeState();
|
|
@@ -67,10 +127,10 @@ const w = class w {
|
|
|
67
127
|
this.state.lastRun = e, this.writeState();
|
|
68
128
|
}
|
|
69
129
|
};
|
|
70
|
-
m(
|
|
71
|
-
let
|
|
72
|
-
const l =
|
|
73
|
-
function
|
|
130
|
+
m(F, "instance");
|
|
131
|
+
let se = F;
|
|
132
|
+
const l = se.getInstance();
|
|
133
|
+
function Be(a, e, r, t) {
|
|
74
134
|
var i;
|
|
75
135
|
return l.lastRun = {
|
|
76
136
|
...l.lastRun,
|
|
@@ -81,31 +141,31 @@ function ve(t, e, r, a) {
|
|
|
81
141
|
envs: r.env,
|
|
82
142
|
docker: {
|
|
83
143
|
...(i = l.lastRun) == null ? void 0 : i.docker,
|
|
84
|
-
...
|
|
144
|
+
...t
|
|
85
145
|
}
|
|
86
|
-
},
|
|
146
|
+
}, je(a, "docker", e, r);
|
|
87
147
|
}
|
|
88
|
-
function
|
|
89
|
-
var
|
|
148
|
+
function mr(a, e, r, t, i) {
|
|
149
|
+
var c;
|
|
90
150
|
l.lastRun = {
|
|
91
151
|
...l.lastRun,
|
|
92
152
|
mode: "process",
|
|
93
153
|
cmd: e,
|
|
94
154
|
args: r,
|
|
95
|
-
workdir:
|
|
96
|
-
envs:
|
|
155
|
+
workdir: t.cwd,
|
|
156
|
+
envs: t.env,
|
|
97
157
|
process: {
|
|
98
|
-
...(
|
|
158
|
+
...(c = l.lastRun) == null ? void 0 : c.process,
|
|
99
159
|
...i
|
|
100
160
|
}
|
|
101
161
|
};
|
|
102
|
-
const
|
|
162
|
+
const s = Pr(a, e, r, t);
|
|
103
163
|
return l.lastRun.process = {
|
|
104
164
|
...l.lastRun.process,
|
|
105
|
-
pid:
|
|
106
|
-
},
|
|
165
|
+
pid: s.pid
|
|
166
|
+
}, s;
|
|
107
167
|
}
|
|
108
|
-
function
|
|
168
|
+
function yr(a, e) {
|
|
109
169
|
if (!l.lastRun)
|
|
110
170
|
throw new Error("no previous run info found: this is the first run after package installation");
|
|
111
171
|
return e = {
|
|
@@ -115,35 +175,35 @@ function De(t, e) {
|
|
|
115
175
|
...e.env
|
|
116
176
|
},
|
|
117
177
|
...e
|
|
118
|
-
},
|
|
178
|
+
}, je(a, l.lastRun.cmd, l.lastRun.args, e);
|
|
119
179
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
180
|
+
function Pr(a, e, r, t) {
|
|
181
|
+
a.debug(
|
|
122
182
|
`Running:
|
|
123
|
-
env: ${JSON.stringify(
|
|
183
|
+
env: ${JSON.stringify(t.env)}
|
|
124
184
|
cmd: ${JSON.stringify([e, ...r])}
|
|
125
|
-
wd: ${
|
|
126
|
-
),
|
|
127
|
-
const i =
|
|
128
|
-
var
|
|
129
|
-
const
|
|
130
|
-
i.kill("SIGINT"),
|
|
185
|
+
wd: ${t.cwd}`
|
|
186
|
+
), t.env = { ...process.env, ...t.env }, a.debug(" spawning child process");
|
|
187
|
+
const i = tr(e, r, t);
|
|
188
|
+
var s = !1;
|
|
189
|
+
const c = () => {
|
|
190
|
+
i.kill("SIGINT"), s = !0;
|
|
131
191
|
};
|
|
132
|
-
return
|
|
133
|
-
process.removeListener("SIGINT",
|
|
192
|
+
return a.debug(" setting up signal handler"), process.on("SIGINT", c), i.on("close", (n) => {
|
|
193
|
+
process.removeListener("SIGINT", c), s && process.exit(n);
|
|
134
194
|
}), i;
|
|
135
195
|
}
|
|
136
|
-
function
|
|
137
|
-
return
|
|
196
|
+
function je(a, e, r, t) {
|
|
197
|
+
return a.debug(
|
|
138
198
|
`Running:
|
|
139
|
-
env: ${JSON.stringify(
|
|
199
|
+
env: ${JSON.stringify(t.env)}
|
|
140
200
|
cmd: ${JSON.stringify([e, ...r])}
|
|
141
|
-
wd: ${
|
|
142
|
-
),
|
|
201
|
+
wd: ${t.cwd}`
|
|
202
|
+
), t.env = { ...process.env, ...t.env }, H(e, r, t);
|
|
143
203
|
}
|
|
144
|
-
function
|
|
204
|
+
function br(a) {
|
|
145
205
|
return {
|
|
146
|
-
id:
|
|
206
|
+
id: a,
|
|
147
207
|
type: "S3",
|
|
148
208
|
indexCachePeriod: "0s",
|
|
149
209
|
endpoint: "",
|
|
@@ -159,187 +219,159 @@ function pe(t) {
|
|
|
159
219
|
uploadKeyPrefix: ""
|
|
160
220
|
};
|
|
161
221
|
}
|
|
162
|
-
function
|
|
222
|
+
function Je(a) {
|
|
163
223
|
return {
|
|
164
|
-
id:
|
|
224
|
+
id: a,
|
|
165
225
|
type: "FS",
|
|
166
226
|
indexCachePeriod: "0s",
|
|
167
227
|
rootPath: ""
|
|
168
228
|
};
|
|
169
229
|
}
|
|
170
|
-
function
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
throw new Error("this should never happen");
|
|
175
|
-
}
|
|
176
|
-
function K(t = "debug") {
|
|
177
|
-
return F.createLogger({
|
|
178
|
-
level: t,
|
|
179
|
-
format: F.format.combine(
|
|
180
|
-
F.format.printf(({ level: e, message: r }) => {
|
|
181
|
-
const a = " ".repeat(e.length + 2), i = r.split(`
|
|
182
|
-
`).map((s, n) => n === 0 ? s : a + s).join(`
|
|
183
|
-
`);
|
|
184
|
-
return `${((s) => F.format.colorize().colorize(s, s))(e)}: ${i}`;
|
|
185
|
-
})
|
|
186
|
-
),
|
|
187
|
-
transports: [
|
|
188
|
-
new F.transports.Console({
|
|
189
|
-
stderrLevels: ["error", "warn", "info", "debug"],
|
|
190
|
-
handleExceptions: !0
|
|
191
|
-
})
|
|
192
|
-
]
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
function Ce(t) {
|
|
196
|
-
return Ee(Math.ceil(t / 2)).toString("hex").slice(0, t);
|
|
197
|
-
}
|
|
198
|
-
function xe(t) {
|
|
199
|
-
return t.startsWith("~") ? o.join(R.homedir(), t.slice(1)) : t;
|
|
200
|
-
}
|
|
201
|
-
function S(t, e, r) {
|
|
202
|
-
t = xe(t);
|
|
203
|
-
const a = new URL(t, `file:${e}`);
|
|
204
|
-
switch (a.protocol) {
|
|
230
|
+
function N(a, e, r) {
|
|
231
|
+
a = fr(a);
|
|
232
|
+
const t = new URL(a, `file:${e}`);
|
|
233
|
+
switch (t.protocol) {
|
|
205
234
|
case "s3:":
|
|
206
|
-
var
|
|
235
|
+
var c = t.hostname, i = t.searchParams.get("region");
|
|
207
236
|
return {
|
|
208
237
|
...r,
|
|
209
238
|
type: "S3",
|
|
210
|
-
bucketName:
|
|
239
|
+
bucketName: c,
|
|
211
240
|
region: i
|
|
212
241
|
};
|
|
213
242
|
case "s3e:":
|
|
214
|
-
var
|
|
243
|
+
var s = t.pathname.split("/").slice(1), c = s[0], n = s.length > 1 ? s[1] : "";
|
|
215
244
|
return {
|
|
216
245
|
...r,
|
|
217
246
|
type: "S3",
|
|
218
|
-
endpoint: `http://${
|
|
219
|
-
bucketName:
|
|
247
|
+
endpoint: `http://${t.host}/`,
|
|
248
|
+
bucketName: c,
|
|
220
249
|
keyPrefix: n,
|
|
221
|
-
region:
|
|
222
|
-
key:
|
|
223
|
-
secret:
|
|
250
|
+
region: t.searchParams.get("region"),
|
|
251
|
+
key: t.username ? `static:${t.username}` : "",
|
|
252
|
+
secret: t.password ? `static:${t.password}` : ""
|
|
224
253
|
};
|
|
225
254
|
case "s3es:":
|
|
226
|
-
var
|
|
255
|
+
var s = t.pathname.split("/").slice(1), c = s[0], n = s.length > 1 ? s[1] : "";
|
|
227
256
|
return {
|
|
228
257
|
...r,
|
|
229
258
|
type: "S3",
|
|
230
|
-
endpoint: `https://${
|
|
231
|
-
bucketName:
|
|
259
|
+
endpoint: `https://${t.host}/`,
|
|
260
|
+
bucketName: c,
|
|
232
261
|
keyPrefix: n,
|
|
233
|
-
region:
|
|
234
|
-
key:
|
|
235
|
-
secret:
|
|
262
|
+
region: t.searchParams.get("region"),
|
|
263
|
+
key: t.username ? `static:${t.username}` : "",
|
|
264
|
+
secret: t.password ? `static:${t.password}` : ""
|
|
236
265
|
};
|
|
237
266
|
case "file:":
|
|
238
267
|
return {
|
|
239
268
|
type: "FS",
|
|
240
|
-
rootPath:
|
|
269
|
+
rootPath: t.pathname
|
|
241
270
|
};
|
|
242
271
|
default:
|
|
243
|
-
throw new Error(`storage protocol '${
|
|
272
|
+
throw new Error(`storage protocol '${t.protocol}' is not supported`);
|
|
244
273
|
}
|
|
245
274
|
}
|
|
246
|
-
function
|
|
247
|
-
var
|
|
248
|
-
const r = (e == null ? void 0 : e.localRoot) ?? l.
|
|
249
|
-
level: ((
|
|
250
|
-
path: ((
|
|
275
|
+
function vr(a, e) {
|
|
276
|
+
var d, b, w, S, L, k, _, W, A, ye, Pe, be, ve, we, ke, Se, Ae, Le, Re, pe, _e, $e, Oe, Te, Ee, Fe, De, Ne, Ie, xe;
|
|
277
|
+
const r = (e == null ? void 0 : e.localRoot) ?? l.data("local-custom"), t = {
|
|
278
|
+
level: ((d = e == null ? void 0 : e.log) == null ? void 0 : d.level) ?? "info",
|
|
279
|
+
path: ((b = e == null ? void 0 : e.log) == null ? void 0 : b.path) ?? `${r}/platforma.log`
|
|
251
280
|
}, i = {
|
|
252
|
-
listen: ((
|
|
281
|
+
listen: ((w = e == null ? void 0 : e.grpc) == null ? void 0 : w.listen) ?? "localhost:6345",
|
|
253
282
|
tls: {
|
|
254
|
-
enable:
|
|
255
|
-
clientAuthMode: ((
|
|
256
|
-
certFile: ((
|
|
257
|
-
keyFile: ((
|
|
258
|
-
...(
|
|
283
|
+
enable: z((L = (S = e == null ? void 0 : e.grpc) == null ? void 0 : S.tls) == null ? void 0 : L.enable, !1),
|
|
284
|
+
clientAuthMode: ((_ = (k = e == null ? void 0 : e.grpc) == null ? void 0 : k.tls) == null ? void 0 : _.clientAuthMode) ?? "NoAuth",
|
|
285
|
+
certFile: ((A = (W = e == null ? void 0 : e.grpc) == null ? void 0 : W.tls) == null ? void 0 : A.certFile) ?? `${r}/certs/tls.cert`,
|
|
286
|
+
keyFile: ((Pe = (ye = e == null ? void 0 : e.grpc) == null ? void 0 : ye.tls) == null ? void 0 : Pe.keyFile) ?? `${r}/certs/tls.key`,
|
|
287
|
+
...(be = e == null ? void 0 : e.grpc) == null ? void 0 : be.tls
|
|
259
288
|
}
|
|
260
|
-
},
|
|
289
|
+
}, s = {
|
|
261
290
|
auth: {
|
|
262
|
-
enabled: ((
|
|
263
|
-
drivers: ((
|
|
264
|
-
{ driver: "jwt", key:
|
|
291
|
+
enabled: ((we = (ve = e == null ? void 0 : e.core) == null ? void 0 : ve.auth) == null ? void 0 : we.enabled) ?? !1,
|
|
292
|
+
drivers: ((Se = (ke = e == null ? void 0 : e.core) == null ? void 0 : ke.auth) == null ? void 0 : Se.drivers) ?? [
|
|
293
|
+
{ driver: "jwt", key: a },
|
|
265
294
|
{ driver: "htpasswd", path: `${r}/users.htpasswd` }
|
|
266
295
|
]
|
|
296
|
+
},
|
|
297
|
+
db: {
|
|
298
|
+
path: `${r}/db`
|
|
267
299
|
}
|
|
268
|
-
},
|
|
300
|
+
}, c = Ge(
|
|
269
301
|
"main",
|
|
270
302
|
`${r}/storages/main`,
|
|
271
303
|
"main-bucket",
|
|
272
|
-
(
|
|
304
|
+
(Ae = e == null ? void 0 : e.storages) == null ? void 0 : Ae.primary
|
|
273
305
|
);
|
|
274
306
|
var n;
|
|
275
|
-
switch ((
|
|
307
|
+
switch ((Re = (Le = e == null ? void 0 : e.storages) == null ? void 0 : Le.work) == null ? void 0 : Re.type) {
|
|
276
308
|
case void 0:
|
|
277
309
|
case "FS":
|
|
278
|
-
n =
|
|
310
|
+
n = Je("work"), n.rootPath = ((_e = (pe = e == null ? void 0 : e.storages) == null ? void 0 : pe.work) == null ? void 0 : _e.rootPath) ?? `${r}/storages/work`, n.indexCachePeriod = ((Oe = ($e = e == null ? void 0 : e.storages) == null ? void 0 : $e.work) == null ? void 0 : Oe.indexCachePeriod) ?? "1m";
|
|
279
311
|
break;
|
|
280
312
|
default:
|
|
281
313
|
throw new Error("work storage MUST have 'FS' type as it is used for working directories management");
|
|
282
314
|
}
|
|
283
|
-
const
|
|
315
|
+
const u = Ge(
|
|
284
316
|
"library",
|
|
285
317
|
`${r}/storages/library`,
|
|
286
318
|
"library-bucket",
|
|
287
|
-
(
|
|
288
|
-
),
|
|
289
|
-
enabled:
|
|
290
|
-
listen: ((
|
|
291
|
-
},
|
|
292
|
-
enabled:
|
|
293
|
-
listen: ((
|
|
294
|
-
},
|
|
295
|
-
value: ((
|
|
296
|
-
file: ((
|
|
319
|
+
(Te = e == null ? void 0 : e.storages) == null ? void 0 : Te.library
|
|
320
|
+
), g = {
|
|
321
|
+
enabled: z((Ee = e == null ? void 0 : e.monitoring) == null ? void 0 : Ee.enabled, !0),
|
|
322
|
+
listen: ((Fe = e == null ? void 0 : e.monitoring) == null ? void 0 : Fe.listen) ?? "127.0.0.1:9090"
|
|
323
|
+
}, v = {
|
|
324
|
+
enabled: z((De = e == null ? void 0 : e.debug) == null ? void 0 : De.enabled, !0),
|
|
325
|
+
listen: ((Ne = e == null ? void 0 : e.debug) == null ? void 0 : Ne.listen) ?? "127.0.0.1:9091"
|
|
326
|
+
}, P = {
|
|
327
|
+
value: ((Ie = e == null ? void 0 : e.license) == null ? void 0 : Ie.value) ?? "",
|
|
328
|
+
file: ((xe = e == null ? void 0 : e.license) == null ? void 0 : xe.file) ?? ""
|
|
297
329
|
};
|
|
298
330
|
return {
|
|
299
331
|
localRoot: r,
|
|
300
|
-
license:
|
|
301
|
-
log:
|
|
332
|
+
license: P,
|
|
333
|
+
log: t,
|
|
302
334
|
grpc: i,
|
|
303
|
-
core:
|
|
304
|
-
monitoring:
|
|
305
|
-
debug:
|
|
306
|
-
storages: { primary:
|
|
335
|
+
core: s,
|
|
336
|
+
monitoring: g,
|
|
337
|
+
debug: v,
|
|
338
|
+
storages: { primary: c, work: n, library: u },
|
|
307
339
|
hacks: { libraryDownloadable: !0 }
|
|
308
340
|
};
|
|
309
341
|
}
|
|
310
|
-
function
|
|
342
|
+
function Ge(a, e, r, t) {
|
|
311
343
|
var i;
|
|
312
|
-
switch (
|
|
344
|
+
switch (t == null ? void 0 : t.type) {
|
|
313
345
|
case void 0:
|
|
314
346
|
case "FS":
|
|
315
|
-
i =
|
|
347
|
+
i = Je(a), i.rootPath = (t == null ? void 0 : t.rootPath) ?? e;
|
|
316
348
|
break;
|
|
317
349
|
case "S3":
|
|
318
|
-
i =
|
|
350
|
+
i = br(a), i.endpoint = (t == null ? void 0 : t.endpoint) ?? "http://localhost:9000", i.presignEndpoint = (t == null ? void 0 : t.presignEndpoint) ?? "http://localhost:9000", i.bucketName = (t == null ? void 0 : t.bucketName) ?? r, i.createBucket = z(t == null ? void 0 : t.createBucket, !0), i.forcePathStyle = z(t == null ? void 0 : t.forcePathStyle, !0), i.key = (t == null ? void 0 : t.key) ?? "", i.secret = (t == null ? void 0 : t.secret) ?? "", i.keyPrefix = (t == null ? void 0 : t.keyPrefix) ?? "", i.accessPrefixes = (t == null ? void 0 : t.accessPrefixes) ?? [""], i.uploadKeyPrefix = (t == null ? void 0 : t.uploadKeyPrefix) ?? "";
|
|
319
351
|
break;
|
|
320
352
|
default:
|
|
321
|
-
throw
|
|
353
|
+
throw Y(), new Error("unknown storage type");
|
|
322
354
|
}
|
|
323
355
|
return i;
|
|
324
356
|
}
|
|
325
|
-
function
|
|
326
|
-
const e =
|
|
327
|
-
var i =
|
|
328
|
-
return
|
|
357
|
+
function wr(a) {
|
|
358
|
+
const e = a.monitoring.enabled ? "" : " disabled", r = a.debug.enabled ? "" : " disabled", t = a.hacks.libraryDownloadable ? "true" : "false";
|
|
359
|
+
var i = a.license.value;
|
|
360
|
+
return a.license.file != "" && (i = o.readFileSync(a.license.file).toString().trimEnd()), `
|
|
329
361
|
license:
|
|
330
|
-
value: '${
|
|
331
|
-
file: '${
|
|
362
|
+
value: '${a.license.value}'
|
|
363
|
+
file: '${a.license.file}'
|
|
332
364
|
|
|
333
365
|
logging:
|
|
334
|
-
level: '${
|
|
366
|
+
level: '${a.log.level}'
|
|
335
367
|
destinations:
|
|
336
|
-
- path: '${
|
|
368
|
+
- path: '${a.log.path}'
|
|
337
369
|
|
|
338
370
|
monitoring${e}:
|
|
339
|
-
listen: '${
|
|
371
|
+
listen: '${a.monitoring.listen}'
|
|
340
372
|
|
|
341
373
|
debug${r}:
|
|
342
|
-
listen: '${
|
|
374
|
+
listen: '${a.debug.listen}'
|
|
343
375
|
|
|
344
376
|
core:
|
|
345
377
|
logging:
|
|
@@ -347,20 +379,20 @@ core:
|
|
|
347
379
|
dumpResourceData: true
|
|
348
380
|
|
|
349
381
|
grpc:
|
|
350
|
-
listen: '${
|
|
382
|
+
listen: '${a.grpc.listen}'
|
|
351
383
|
|
|
352
|
-
tlsEnabled: ${JSON.stringify(
|
|
384
|
+
tlsEnabled: ${JSON.stringify(a.grpc.tls.enable)}
|
|
353
385
|
tls:
|
|
354
|
-
clientAuthMode: '${
|
|
386
|
+
clientAuthMode: '${a.grpc.tls.clientAuthMode}'
|
|
355
387
|
certificates:
|
|
356
|
-
- certFile: '${
|
|
357
|
-
keyFile: '${
|
|
388
|
+
- certFile: '${a.grpc.tls.certFile}'
|
|
389
|
+
keyFile: '${a.grpc.tls.keyFile}'
|
|
358
390
|
|
|
359
391
|
|
|
360
|
-
authEnabled: ${JSON.stringify(
|
|
361
|
-
auth: ${JSON.stringify(
|
|
392
|
+
authEnabled: ${JSON.stringify(a.core.auth.enabled)}
|
|
393
|
+
auth: ${JSON.stringify(a.core.auth.drivers)}
|
|
362
394
|
db:
|
|
363
|
-
path: '${
|
|
395
|
+
path: '${a.core.db.path}'
|
|
364
396
|
|
|
365
397
|
controllers:
|
|
366
398
|
data:
|
|
@@ -372,36 +404,52 @@ controllers:
|
|
|
372
404
|
|
|
373
405
|
library:
|
|
374
406
|
mode: passive
|
|
375
|
-
downloadable: ${
|
|
407
|
+
downloadable: ${t}
|
|
376
408
|
|
|
377
409
|
work:
|
|
378
410
|
mode: active
|
|
379
411
|
downloadable: false
|
|
380
412
|
|
|
381
413
|
storages:
|
|
382
|
-
- ${JSON.stringify(
|
|
383
|
-
- ${JSON.stringify(
|
|
384
|
-
- ${JSON.stringify(
|
|
414
|
+
- ${JSON.stringify(a.storages.primary)}
|
|
415
|
+
- ${JSON.stringify(a.storages.library)}
|
|
416
|
+
- ${JSON.stringify(a.storages.work)}
|
|
385
417
|
|
|
386
418
|
runner:
|
|
387
419
|
type: local
|
|
388
|
-
storageRoot: '${
|
|
420
|
+
storageRoot: '${a.storages.work.rootPath}'
|
|
389
421
|
secrets:
|
|
390
422
|
- map:
|
|
391
423
|
MI_LICENSE: ${JSON.stringify(i)}
|
|
392
424
|
|
|
393
425
|
packageLoader:
|
|
394
|
-
packagesRoot: '${
|
|
426
|
+
packagesRoot: '${a.localRoot}/packages'
|
|
395
427
|
|
|
396
428
|
workflows: {}
|
|
397
429
|
`;
|
|
398
430
|
}
|
|
399
|
-
function
|
|
400
|
-
return
|
|
431
|
+
function z(a, e) {
|
|
432
|
+
return a === void 0 ? e : a;
|
|
401
433
|
}
|
|
402
|
-
const
|
|
403
|
-
function
|
|
404
|
-
const e =
|
|
434
|
+
const kr = ["linux", "macos", "windows"];
|
|
435
|
+
function Sr(a) {
|
|
436
|
+
const e = p.platform();
|
|
437
|
+
switch (e) {
|
|
438
|
+
case "darwin":
|
|
439
|
+
return "macos";
|
|
440
|
+
case "linux":
|
|
441
|
+
return "linux";
|
|
442
|
+
case "win32":
|
|
443
|
+
return "windows";
|
|
444
|
+
default:
|
|
445
|
+
throw new Error(
|
|
446
|
+
`operating system '${e}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` + JSON.stringify(kr)
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const Ar = ["amd64", "arm64"];
|
|
451
|
+
function He(a) {
|
|
452
|
+
const e = p.arch();
|
|
405
453
|
switch (e) {
|
|
406
454
|
case "arm64":
|
|
407
455
|
return "arm64";
|
|
@@ -409,104 +457,150 @@ function Je(t) {
|
|
|
409
457
|
return "amd64";
|
|
410
458
|
default:
|
|
411
459
|
throw new Error(
|
|
412
|
-
`processor architecture '${e}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(
|
|
460
|
+
`processor architecture '${e}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(Ar)
|
|
413
461
|
);
|
|
414
462
|
}
|
|
415
463
|
}
|
|
416
|
-
function
|
|
417
|
-
|
|
464
|
+
function Lr(a, e) {
|
|
465
|
+
const r = (e == null ? void 0 : e.version) ?? Q()["pl-version"], t = (e == null ? void 0 : e.showProgress) ?? process.stdout.isTTY, i = `pl-${r}-${He()}.tgz`, s = (e == null ? void 0 : e.downloadURL) ?? `https://cdn.platforma.bio/software/pl/${Sr()}/${i}`, c = (e == null ? void 0 : e.saveTo) ?? l.binaries(i);
|
|
466
|
+
if (o.existsSync(c))
|
|
467
|
+
return a.info(`Platforma Backend archive download skipped: '${c}' already exists`), Promise.resolve(c);
|
|
468
|
+
o.mkdirSync(f.dirname(c), { recursive: !0 }), a.info(`Downloading Platforma Backend archive:
|
|
469
|
+
URL: ${s}
|
|
470
|
+
Save to: ${c}`);
|
|
471
|
+
const n = cr.get(s);
|
|
472
|
+
return new Promise((h, u) => {
|
|
473
|
+
n.on("response", (g) => {
|
|
474
|
+
if (!g.statusCode) {
|
|
475
|
+
const b = new Error("failed to download archive: no HTTP status code in response from server");
|
|
476
|
+
n.destroy(), u(b);
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (g.statusCode !== 200) {
|
|
480
|
+
const b = new Error(`failed to download archive: ${g.statusCode} ${g.statusMessage}`);
|
|
481
|
+
n.destroy(), u(b);
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const v = parseInt(g.headers["content-length"] || "0", 10);
|
|
485
|
+
let P = 0;
|
|
486
|
+
const d = o.createWriteStream(c);
|
|
487
|
+
g.pipe(d), g.on("data", (b) => {
|
|
488
|
+
P += b.length;
|
|
489
|
+
const w = P / v * 100;
|
|
490
|
+
t && process.stdout.write(` downloading: ${w.toFixed(2)}%\r`);
|
|
491
|
+
}), g.on("error", (b) => {
|
|
492
|
+
o.unlinkSync(c), a.error(`Failed to download Platforma Binary: ${b.message}`), n.destroy(), u(b);
|
|
493
|
+
}), d.on("finish", () => {
|
|
494
|
+
d.close(), a.info(" ... download done."), n.destroy(), h(c);
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
function Rr(a, e) {
|
|
500
|
+
a.debug("extracting archive...");
|
|
501
|
+
const r = (e == null ? void 0 : e.version) ?? Q()["pl-version"];
|
|
502
|
+
a.debug(` version: '${r}'`);
|
|
503
|
+
const t = `${ze({ version: r })}.tgz`, i = (e == null ? void 0 : e.archivePath) ?? l.binaries(t);
|
|
504
|
+
a.debug(` archive path: '${i}'`);
|
|
505
|
+
const s = (e == null ? void 0 : e.extractTo) ?? _r(i);
|
|
506
|
+
if (a.debug(` target dir: '${s}'`), o.existsSync(s))
|
|
507
|
+
return a.info(`Platforma Backend binaries unpack skipped: '${s}' exists`), s;
|
|
508
|
+
if (!o.existsSync(i)) {
|
|
509
|
+
const c = `Platforma Backend binary archive not found at '${i}'`;
|
|
510
|
+
throw a.error(c), new Error(c);
|
|
511
|
+
}
|
|
512
|
+
return o.existsSync(s) || (a.debug(` creating target dir '${s}'`), o.mkdirSync(s, { recursive: !0 })), a.info(`Unpacking Platforma Backend archive:
|
|
513
|
+
Archive: ${i}
|
|
514
|
+
Target dir: ${s}`), nr.x({
|
|
515
|
+
file: i,
|
|
516
|
+
cwd: s,
|
|
517
|
+
gzip: !0,
|
|
518
|
+
sync: !0
|
|
519
|
+
}), a.info(" ... unpack done."), s;
|
|
418
520
|
}
|
|
419
|
-
function
|
|
420
|
-
return
|
|
521
|
+
function Ye(a, e) {
|
|
522
|
+
return Lr(a, e).then((r) => Rr(a, { archivePath: r }));
|
|
421
523
|
}
|
|
422
|
-
|
|
524
|
+
function ze(a) {
|
|
525
|
+
return `pl-${(a == null ? void 0 : a.version) ?? Q()["pl-version"]}-${He()}`;
|
|
526
|
+
}
|
|
527
|
+
function pr(a, ...e) {
|
|
528
|
+
return l.binaries(ze({ version: a }), ...e);
|
|
529
|
+
}
|
|
530
|
+
function _r(a) {
|
|
531
|
+
const e = a.lastIndexOf(".");
|
|
532
|
+
return e === -1 ? a : a.slice(0, e);
|
|
533
|
+
}
|
|
534
|
+
class D {
|
|
423
535
|
constructor(e) {
|
|
424
536
|
this.logger = e;
|
|
425
537
|
}
|
|
426
538
|
startLast() {
|
|
427
|
-
const e =
|
|
428
|
-
|
|
539
|
+
const e = yr(this.logger, { stdio: "inherit" });
|
|
540
|
+
J(e, "failed to bring back Platforma Backend in the last started configuration");
|
|
429
541
|
}
|
|
430
542
|
startLocal(e) {
|
|
431
|
-
var h,
|
|
432
|
-
const r = (e == null ? void 0 : e.binaryPath) ??
|
|
433
|
-
var
|
|
434
|
-
const i = (e == null ? void 0 : e.workdir) ?? (
|
|
543
|
+
var h, u, g, v, P, d, b, w, S, L;
|
|
544
|
+
const r = (e == null ? void 0 : e.binaryPath) ?? pr(e == null ? void 0 : e.version, "binaries", "platforma");
|
|
545
|
+
var t = e == null ? void 0 : e.configPath;
|
|
546
|
+
const i = (e == null ? void 0 : e.workdir) ?? (t ? process.cwd() : l.path());
|
|
435
547
|
e != null && e.primaryURL && (e.configOptions = {
|
|
436
548
|
...e.configOptions,
|
|
437
549
|
storages: {
|
|
438
550
|
...(h = e.configOptions) == null ? void 0 : h.storages,
|
|
439
|
-
primary:
|
|
551
|
+
primary: N(e.primaryURL, i, (g = (u = e.configOptions) == null ? void 0 : u.storages) == null ? void 0 : g.primary)
|
|
440
552
|
}
|
|
441
553
|
}), e != null && e.libraryURL && (e.configOptions = {
|
|
442
554
|
...e.configOptions,
|
|
443
555
|
storages: {
|
|
444
|
-
...(
|
|
445
|
-
library:
|
|
556
|
+
...(v = e.configOptions) == null ? void 0 : v.storages,
|
|
557
|
+
library: N(e.libraryURL, i, (d = (P = e.configOptions) == null ? void 0 : P.storages) == null ? void 0 : d.library)
|
|
446
558
|
}
|
|
447
559
|
});
|
|
448
|
-
const
|
|
449
|
-
this.logger.debug(" checking license..."), this.checkLicense((
|
|
450
|
-
const
|
|
451
|
-
`${
|
|
452
|
-
`${
|
|
453
|
-
`${
|
|
560
|
+
const s = vr(this.getLastJwt(), e == null ? void 0 : e.configOptions);
|
|
561
|
+
this.logger.debug(" checking license..."), this.checkLicense((w = (b = e == null ? void 0 : e.configOptions) == null ? void 0 : b.license) == null ? void 0 : w.value, (L = (S = e == null ? void 0 : e.configOptions) == null ? void 0 : S.license) == null ? void 0 : L.file);
|
|
562
|
+
const c = [
|
|
563
|
+
`${s.localRoot}/packages`,
|
|
564
|
+
`${s.localRoot}/packages-local`,
|
|
565
|
+
`${s.localRoot}/blocks-local`
|
|
454
566
|
];
|
|
455
|
-
|
|
456
|
-
for (const
|
|
457
|
-
|
|
458
|
-
for (const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
default:
|
|
473
|
-
C();
|
|
474
|
-
}
|
|
475
|
-
switch (c.storages.library.type) {
|
|
476
|
-
case "FS":
|
|
477
|
-
n.push(`${u("library")}: ${c.storages.library.rootPath}`);
|
|
478
|
-
break;
|
|
479
|
-
case "S3":
|
|
480
|
-
n.push(
|
|
481
|
-
`${u("library")}: S3 at '${c.storages.library.endpoint ?? "AWS"}', bucket '${c.storages.library.bucketName}', prefix: '${c.storages.library.keyPrefix}'`
|
|
482
|
-
);
|
|
483
|
-
break;
|
|
484
|
-
default:
|
|
485
|
-
C();
|
|
486
|
-
}
|
|
487
|
-
return n.push(`${u("workdirs")}: ${c.storages.work.rootPath}`), this.logger.info(`Starting platforma:
|
|
488
|
-
${n.join(`
|
|
489
|
-
`)}`), Ne(
|
|
567
|
+
s.storages.primary.type === "FS" && c.push(s.storages.primary.rootPath), s.storages.library.type === "FS" && (c.push(s.storages.library.rootPath), s.hacks.libraryDownloadable = !1), s.storages.work.type === "FS" && c.push(s.storages.work.rootPath), this.logger.debug(" creating pl state directories...");
|
|
568
|
+
for (const k of c)
|
|
569
|
+
o.existsSync(k) || (this.logger.debug(` '${k}'`), o.mkdirSync(k, { recursive: !0 }));
|
|
570
|
+
for (const k of s.core.auth.drivers)
|
|
571
|
+
k.driver === "htpasswd" && (o.existsSync(k.path) || (this.logger.debug(` installing default 'users.htpasswd' to ${k.path}...`), o.copyFileSync($("users.htpasswd"), k.path)));
|
|
572
|
+
t || (t = f.join(s.localRoot, "config.yaml"), this.logger.debug(` rendering configuration '${t}'...`), o.writeFileSync(t, wr(s)));
|
|
573
|
+
const n = this.renderRunInfo({
|
|
574
|
+
configPath: t,
|
|
575
|
+
dbPath: s.core.db.path,
|
|
576
|
+
apiAddr: s.grpc.listen,
|
|
577
|
+
logPath: s.log.path,
|
|
578
|
+
primary: s.storages.primary,
|
|
579
|
+
work: s.storages.work,
|
|
580
|
+
library: s.storages.library
|
|
581
|
+
});
|
|
582
|
+
return this.logger.info(`Starting platforma:
|
|
583
|
+
${n}`), mr(
|
|
490
584
|
this.logger,
|
|
491
585
|
r,
|
|
492
|
-
["-config",
|
|
586
|
+
["-config", t],
|
|
493
587
|
{
|
|
494
588
|
cwd: i,
|
|
495
589
|
stdio: "inherit"
|
|
496
590
|
},
|
|
497
591
|
{
|
|
498
|
-
storagePath:
|
|
592
|
+
storagePath: s.localRoot
|
|
499
593
|
}
|
|
500
594
|
);
|
|
501
595
|
}
|
|
502
596
|
startLocalS3(e) {
|
|
503
597
|
var i;
|
|
504
598
|
this.logger.debug("starting platforma in 'local s3' mode...");
|
|
505
|
-
const r = (e == null ? void 0 : e.minioPort) ?? 9e3,
|
|
599
|
+
const r = (e == null ? void 0 : e.minioPort) ?? 9e3, t = (i = e == null ? void 0 : e.configOptions) == null ? void 0 : i.localRoot;
|
|
506
600
|
return this.startMinio({
|
|
507
601
|
minioPort: r,
|
|
508
602
|
minioConsolePort: e == null ? void 0 : e.minioConsolePort,
|
|
509
|
-
storage:
|
|
603
|
+
storage: t ? f.join(t, "minio") : void 0
|
|
510
604
|
}), this.startLocal({
|
|
511
605
|
...e,
|
|
512
606
|
primaryURL: (e == null ? void 0 : e.primaryURL) ?? `s3e://testuser:testpassword@localhost:${r}/main-bucket/?region=no-region`,
|
|
@@ -515,86 +609,95 @@ ${n.join(`
|
|
|
515
609
|
}
|
|
516
610
|
startMinio(e) {
|
|
517
611
|
this.logger.debug(" starting minio...");
|
|
518
|
-
var r =
|
|
519
|
-
const
|
|
520
|
-
this.logger.debug(` minio version: ${
|
|
521
|
-
const i = (e == null ? void 0 : e.image) ?? `quay.io/minio/minio${
|
|
612
|
+
var r = $("compose-backend.yaml");
|
|
613
|
+
const t = e != null && e.version ? `:${e.version}` : "";
|
|
614
|
+
this.logger.debug(` minio version: ${t}`);
|
|
615
|
+
const i = (e == null ? void 0 : e.image) ?? `quay.io/minio/minio${t}`;
|
|
522
616
|
this.logger.debug(` minio image: ${i}`);
|
|
523
|
-
const
|
|
617
|
+
const s = (e == null ? void 0 : e.storage) ?? l.data("minio");
|
|
618
|
+
q(s);
|
|
619
|
+
const c = l.data("stub");
|
|
620
|
+
q(c);
|
|
621
|
+
const n = (e == null ? void 0 : e.minioPort) ?? 9e3, h = (e == null ? void 0 : e.minioConsolePort) ?? 9001, u = {
|
|
524
622
|
MINIO_IMAGE: i,
|
|
525
|
-
MINIO_STORAGE:
|
|
623
|
+
MINIO_STORAGE: f.resolve(s),
|
|
526
624
|
MINIO_PORT: n.toString(),
|
|
527
|
-
MINIO_CONSOLE_PORT:
|
|
528
|
-
PL_DATA_DB_ROOT:
|
|
529
|
-
PL_DATA_PRIMARY_ROOT:
|
|
530
|
-
PL_DATA_LIBRARY_ROOT:
|
|
531
|
-
PL_DATA_WORKDIR_ROOT:
|
|
532
|
-
PL_DATA_PACKAGE_ROOT:
|
|
625
|
+
MINIO_CONSOLE_PORT: h.toString(),
|
|
626
|
+
PL_DATA_DB_ROOT: c,
|
|
627
|
+
PL_DATA_PRIMARY_ROOT: c,
|
|
628
|
+
PL_DATA_LIBRARY_ROOT: c,
|
|
629
|
+
PL_DATA_WORKDIR_ROOT: c,
|
|
630
|
+
PL_DATA_PACKAGE_ROOT: c,
|
|
533
631
|
PL_IMAGE: "scratch"
|
|
534
632
|
};
|
|
535
|
-
this.
|
|
536
|
-
const
|
|
633
|
+
this.logger.debug(" spawning child 'docker' process...");
|
|
634
|
+
const g = H(
|
|
537
635
|
"docker",
|
|
538
636
|
["compose", `--file=${r}`, "up", "--detach", "--remove-orphans", "--pull=missing", "minio"],
|
|
539
637
|
{
|
|
540
638
|
env: {
|
|
541
639
|
...process.env,
|
|
542
|
-
...
|
|
640
|
+
...u
|
|
543
641
|
},
|
|
544
642
|
stdio: "inherit"
|
|
545
643
|
}
|
|
546
644
|
);
|
|
547
|
-
|
|
645
|
+
J(g, "failed to start MinIO service in docker");
|
|
548
646
|
}
|
|
549
647
|
buildPlatforma(e) {
|
|
550
|
-
const r =
|
|
551
|
-
this.logger.info("Building Platforma Backend binary from sources"), this.logger.info(` sources path: ${e.repoRoot}`), this.logger.info(` binary path: ${
|
|
552
|
-
const i =
|
|
648
|
+
const r = f.resolve(e.repoRoot, "cmd", "platforma"), t = e.binPath ?? f.join(p.tmpdir(), "platforma-local-build");
|
|
649
|
+
this.logger.info("Building Platforma Backend binary from sources"), this.logger.info(` sources path: ${e.repoRoot}`), this.logger.info(` binary path: ${t}`);
|
|
650
|
+
const i = H("go", ["build", "-o", t, "."], {
|
|
553
651
|
cwd: r,
|
|
554
652
|
stdio: "inherit"
|
|
555
653
|
});
|
|
556
|
-
return
|
|
654
|
+
return J(i, "failed to build platforma binary from sources using 'go build' command"), t;
|
|
557
655
|
}
|
|
558
656
|
startDockerS3(e, r) {
|
|
559
|
-
const
|
|
657
|
+
const t = $("compose-backend.yaml"), i = (r == null ? void 0 : r.image) ?? ie(r == null ? void 0 : r.version);
|
|
560
658
|
this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
659
|
+
const s = (S) => f.join(e, S), c = (S) => {
|
|
660
|
+
const L = s(S);
|
|
661
|
+
return q(L), L;
|
|
662
|
+
}, n = s("platforma.log");
|
|
663
|
+
o.existsSync(n) || (o.mkdirSync(f.dirname(n), { recursive: !0 }), o.writeFileSync(n, ""));
|
|
664
|
+
const h = N("s3e://testuser:testpassword@minio:9000/main-bucket");
|
|
665
|
+
if (h.type !== "S3")
|
|
565
666
|
throw new Error("primary storage must have 'S3' type in 'docker s3' configuration");
|
|
566
|
-
|
|
567
|
-
const u =
|
|
667
|
+
h.presignEndpoint = "http://localhost:9000";
|
|
668
|
+
const u = N("s3e://testuser:testpassword@minio:9000/library-bucket");
|
|
568
669
|
if (u.type !== "S3")
|
|
569
670
|
throw new Error(`${u.type} storage type is not supported for library storage`);
|
|
570
671
|
u.presignEndpoint = "http://localhost:9000";
|
|
571
|
-
const
|
|
672
|
+
const g = c("db"), v = c("work"), P = s("users.htpasswd");
|
|
673
|
+
o.existsSync(P) || o.copyFileSync($("users.htpasswd"), P);
|
|
674
|
+
const d = {
|
|
572
675
|
MINIO_IMAGE: "quay.io/minio/minio",
|
|
573
676
|
MINIO_STORAGE: c("minio"),
|
|
574
677
|
PL_IMAGE: i,
|
|
575
|
-
PL_AUTH_HTPASSWD_PATH:
|
|
678
|
+
PL_AUTH_HTPASSWD_PATH: P,
|
|
576
679
|
PL_LICENSE: r == null ? void 0 : r.license,
|
|
577
680
|
PL_LICENSE_FILE: r == null ? void 0 : r.licenseFile,
|
|
578
|
-
PL_LOG_LEVEL: "info",
|
|
579
|
-
PL_LOG_FILE:
|
|
580
|
-
PL_DATA_DB_ROOT:
|
|
681
|
+
PL_LOG_LEVEL: (r == null ? void 0 : r.logLevel) ?? "info",
|
|
682
|
+
PL_LOG_FILE: n,
|
|
683
|
+
PL_DATA_DB_ROOT: g,
|
|
581
684
|
PL_DATA_PRIMARY_ROOT: c("primary"),
|
|
582
685
|
PL_DATA_LIBRARY_ROOT: c("library"),
|
|
583
|
-
PL_DATA_WORKDIR_ROOT:
|
|
686
|
+
PL_DATA_WORKDIR_ROOT: v,
|
|
584
687
|
PL_DATA_PACKAGE_ROOT: c("packages"),
|
|
585
|
-
...this.configureDockerStorage("primary",
|
|
688
|
+
...this.configureDockerStorage("primary", h),
|
|
586
689
|
...this.configureDockerStorage("library", u)
|
|
587
690
|
};
|
|
588
|
-
if (
|
|
589
|
-
for (const
|
|
590
|
-
|
|
591
|
-
|
|
691
|
+
if (r != null && r.grpcAddr && (d.PL_GRPC_ADDR = r.grpcAddr), r != null && r.grpcPort && (d.PL_GRPC_PORT = r.grpcPort.toString()), r != null && r.monitoringAddr && (d.PL_MONITORING_ADDR = r.monitoringAddr), r != null && r.monitoringPort && (d.PL_MONITORING_PORT = r.monitoringPort.toString()), r != null && r.debugAddr && (d.PL_DEBUG_ADDR = r.debugAddr), r != null && r.debugPort && (d.PL_DEBUG_PORT = r.debugPort.toString()), r != null && r.auth && (r.auth.enabled && (d.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
|
|
692
|
+
for (const S of r.auth.drivers)
|
|
693
|
+
S.driver === "htpasswd" && (d.PL_AUTH_HTPASSWD_PATH = f.resolve(S.path), S.path = "/etc/platforma/users.htpasswd");
|
|
694
|
+
d.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
|
|
592
695
|
}
|
|
593
|
-
const
|
|
696
|
+
const b = Be(
|
|
594
697
|
this.logger,
|
|
595
698
|
[
|
|
596
699
|
"compose",
|
|
597
|
-
`--file=${
|
|
700
|
+
`--file=${t}`,
|
|
598
701
|
"up",
|
|
599
702
|
"--detach",
|
|
600
703
|
"--remove-orphans",
|
|
@@ -603,56 +706,87 @@ ${n.join(`
|
|
|
603
706
|
"backend"
|
|
604
707
|
],
|
|
605
708
|
{
|
|
606
|
-
env:
|
|
709
|
+
env: d,
|
|
607
710
|
stdio: "inherit"
|
|
608
711
|
},
|
|
609
712
|
{
|
|
610
713
|
plImage: i,
|
|
611
|
-
composePath:
|
|
714
|
+
composePath: t
|
|
612
715
|
}
|
|
613
716
|
);
|
|
614
|
-
|
|
717
|
+
J(b, "failed to start Platforma Backend in Docker"), l.isActive = !0;
|
|
718
|
+
const w = this.renderRunInfo({
|
|
719
|
+
apiPort: r == null ? void 0 : r.grpcPort,
|
|
720
|
+
apiAddr: r == null ? void 0 : r.grpcAddr,
|
|
721
|
+
logPath: n,
|
|
722
|
+
primary: h,
|
|
723
|
+
work: { type: "FS", rootPath: v },
|
|
724
|
+
library: u,
|
|
725
|
+
dbPath: g
|
|
726
|
+
});
|
|
727
|
+
this.logger.info(`Started platforma:
|
|
728
|
+
${w}`);
|
|
615
729
|
}
|
|
616
730
|
startDocker(e, r) {
|
|
617
|
-
var
|
|
618
|
-
const i = (r == null ? void 0 : r.image) ??
|
|
731
|
+
var t = $("compose-backend.yaml");
|
|
732
|
+
const i = (r == null ? void 0 : r.image) ?? ie(r == null ? void 0 : r.version);
|
|
619
733
|
this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
|
|
620
|
-
const
|
|
734
|
+
const s = (k) => f.join(e, k), c = (k) => {
|
|
735
|
+
const _ = s(k);
|
|
736
|
+
return q(_), _;
|
|
737
|
+
}, n = s("platforma.log");
|
|
738
|
+
o.existsSync(n) || (o.mkdirSync(f.dirname(n), { recursive: !0 }), o.writeFileSync(n, ""));
|
|
739
|
+
const h = c("db"), u = c("primary"), g = c("library"), v = c("work"), P = s("users.htpasswd");
|
|
740
|
+
o.existsSync(P) || o.copyFileSync($("users.htpasswd"), P);
|
|
741
|
+
const d = N((r == null ? void 0 : r.primaryStorageURL) ?? `file:${u}`, "."), b = N((r == null ? void 0 : r.libraryStorageURL) ?? `file:${g}`, "."), w = {
|
|
621
742
|
MINIO_IMAGE: "quay.io/minio/minio",
|
|
622
743
|
MINIO_STORAGE: c("minio"),
|
|
623
744
|
PL_IMAGE: i,
|
|
624
|
-
PL_AUTH_HTPASSWD_PATH:
|
|
745
|
+
PL_AUTH_HTPASSWD_PATH: P,
|
|
625
746
|
PL_LICENSE: r == null ? void 0 : r.license,
|
|
626
747
|
PL_LICENSE_FILE: r == null ? void 0 : r.licenseFile,
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
748
|
+
PL_LOG_LEVEL: "info",
|
|
749
|
+
PL_LOG_FILE: n,
|
|
750
|
+
PL_DATA_DB_ROOT: h,
|
|
751
|
+
PL_DATA_PRIMARY_ROOT: u,
|
|
752
|
+
PL_DATA_LIBRARY_ROOT: g,
|
|
753
|
+
PL_DATA_WORKDIR_ROOT: v,
|
|
631
754
|
PL_DATA_PACKAGE_ROOT: c("packages"),
|
|
632
|
-
...this.configureDockerStorage("primary",
|
|
633
|
-
...this.configureDockerStorage("library",
|
|
755
|
+
...this.configureDockerStorage("primary", d),
|
|
756
|
+
...this.configureDockerStorage("library", b)
|
|
634
757
|
};
|
|
635
|
-
if (
|
|
636
|
-
for (const
|
|
637
|
-
|
|
638
|
-
|
|
758
|
+
if (r != null && r.grpcAddr && (w.PL_GRPC_ADDR = r.grpcAddr), r != null && r.grpcPort && (w.PL_GRPC_PORT = r.grpcPort.toString()), r != null && r.monitoringAddr && (w.PL_MONITORING_ADDR = r.monitoringAddr), r != null && r.monitoringPort && (w.PL_MONITORING_PORT = r.monitoringPort.toString()), r != null && r.debugAddr && (w.PL_DEBUG_ADDR = r.debugAddr), r != null && r.debugPort && (w.PL_DEBUG_PORT = r.debugPort.toString()), r != null && r.auth && (r.auth.enabled && (w.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
|
|
759
|
+
for (const k of r.auth.drivers)
|
|
760
|
+
k.driver === "htpasswd" && (w.PL_AUTH_HTPASSWD_PATH = f.resolve(k.path), k.path = "/etc/platforma/users.htpasswd");
|
|
761
|
+
w.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
|
|
639
762
|
}
|
|
640
|
-
const
|
|
763
|
+
const S = Be(
|
|
641
764
|
this.logger,
|
|
642
|
-
["compose", `--file=${
|
|
765
|
+
["compose", `--file=${t}`, "up", "--detach", "--remove-orphans", "--pull=missing", "backend"],
|
|
643
766
|
{
|
|
644
|
-
env:
|
|
767
|
+
env: w,
|
|
645
768
|
stdio: "inherit"
|
|
646
769
|
},
|
|
647
770
|
{
|
|
648
771
|
plImage: i,
|
|
649
|
-
composePath:
|
|
650
|
-
primaryPath:
|
|
651
|
-
workPath:
|
|
652
|
-
libraryPath:
|
|
772
|
+
composePath: t,
|
|
773
|
+
primaryPath: u,
|
|
774
|
+
workPath: v,
|
|
775
|
+
libraryPath: g
|
|
653
776
|
}
|
|
654
777
|
);
|
|
655
|
-
|
|
778
|
+
J(S, "failed to start Platforma Backend in Docker"), l.isActive = !0;
|
|
779
|
+
const L = this.renderRunInfo({
|
|
780
|
+
apiPort: r == null ? void 0 : r.grpcPort,
|
|
781
|
+
apiAddr: r == null ? void 0 : r.grpcAddr,
|
|
782
|
+
logPath: n,
|
|
783
|
+
primary: d,
|
|
784
|
+
work: { type: "FS", rootPath: v },
|
|
785
|
+
library: b,
|
|
786
|
+
dbPath: h
|
|
787
|
+
});
|
|
788
|
+
this.logger.info(`Started platforma:
|
|
789
|
+
${L}`);
|
|
656
790
|
}
|
|
657
791
|
stop() {
|
|
658
792
|
if (!l.isActive) {
|
|
@@ -662,7 +796,7 @@ ${n.join(`
|
|
|
662
796
|
const e = l.lastRun;
|
|
663
797
|
switch (e.mode) {
|
|
664
798
|
case "docker":
|
|
665
|
-
const r =
|
|
799
|
+
const r = H("docker", ["compose", "--file", e.docker.composePath, "down"], {
|
|
666
800
|
env: {
|
|
667
801
|
...process.env,
|
|
668
802
|
...e.envs
|
|
@@ -672,84 +806,95 @@ ${n.join(`
|
|
|
672
806
|
l.isActive = !1, r.status !== 0 && process.exit(r.status);
|
|
673
807
|
return;
|
|
674
808
|
case "process":
|
|
675
|
-
l.
|
|
809
|
+
l.isValidPID && process.kill(e.process.pid), l.isActive = !1;
|
|
676
810
|
return;
|
|
677
811
|
default:
|
|
678
|
-
|
|
812
|
+
Y(e.mode);
|
|
679
813
|
}
|
|
680
814
|
}
|
|
681
815
|
cleanup() {
|
|
682
|
-
var
|
|
816
|
+
var n, h, u, g, v, P, d, b, w, S, L, k, _, W;
|
|
683
817
|
const e = [
|
|
684
818
|
"last command run cache ('pl-service start' shorthand will stop working until next full start command call)",
|
|
685
819
|
"'platforma' docker compose service containers and volumes"
|
|
686
|
-
], r =
|
|
687
|
-
(
|
|
688
|
-
|
|
689
|
-
|
|
820
|
+
], r = l.data(), t = [r];
|
|
821
|
+
if ((h = (n = l.lastRun) == null ? void 0 : n.docker) != null && h.primaryPath) {
|
|
822
|
+
const A = (g = (u = l.lastRun) == null ? void 0 : u.docker) == null ? void 0 : g.primaryPath;
|
|
823
|
+
A.startsWith(r) || t.push(A);
|
|
824
|
+
}
|
|
825
|
+
if ((P = (v = l.lastRun) == null ? void 0 : v.docker) != null && P.workPath) {
|
|
826
|
+
const A = (b = (d = l.lastRun) == null ? void 0 : d.docker) == null ? void 0 : b.workPath;
|
|
827
|
+
A.startsWith(r) || t.push(A);
|
|
828
|
+
}
|
|
829
|
+
if ((S = (w = l.lastRun) == null ? void 0 : w.process) != null && S.storagePath) {
|
|
830
|
+
const A = (k = (L = l.lastRun) == null ? void 0 : L.process) == null ? void 0 : k.storagePath;
|
|
831
|
+
A.startsWith(r) || t.push(A);
|
|
832
|
+
}
|
|
833
|
+
const i = t.length > 0 ? ` - storages (you'll loose all projects and calculation results stored in service instances):
|
|
834
|
+
- ${t.join(`
|
|
690
835
|
- `)}` : "";
|
|
691
|
-
var
|
|
836
|
+
var s = `
|
|
692
837
|
You are going to reset the state of platforma service
|
|
693
838
|
Things to be removed:
|
|
694
839
|
- ${e.join(`
|
|
695
840
|
- `)}
|
|
696
|
-
${
|
|
841
|
+
${i}
|
|
697
842
|
`;
|
|
698
|
-
if (this.logger.warn(
|
|
843
|
+
if (this.logger.warn(s), !gr("Are you sure?")) {
|
|
699
844
|
this.logger.info("Reset action was canceled");
|
|
700
845
|
return;
|
|
701
846
|
}
|
|
702
|
-
const c = new Set(
|
|
703
|
-
(
|
|
704
|
-
for (const
|
|
705
|
-
this.logger.info(`Destroying docker compose '${
|
|
706
|
-
for (const
|
|
707
|
-
this.logger.info(`Destroying '${
|
|
708
|
-
this.logger.info(`Destroying state dir '${l.path()}'`),
|
|
847
|
+
const c = new Set(dr());
|
|
848
|
+
(W = (_ = l.lastRun) == null ? void 0 : _.docker) != null && W.composePath && c.add(l.lastRun.docker.composePath);
|
|
849
|
+
for (const A of c)
|
|
850
|
+
this.logger.info(`Destroying docker compose '${A}'`), this.destroyDocker(A, ie());
|
|
851
|
+
for (const A of t)
|
|
852
|
+
this.logger.info(`Destroying '${A}'`), o.rmSync(A, { recursive: !0, force: !0 });
|
|
853
|
+
this.logger.info(`Destroying state dir '${l.path()}'`), o.rmSync(l.path(), { recursive: !0, force: !0 }), this.logger.info(
|
|
709
854
|
`
|
|
710
|
-
If you want to remove all downloaded platforma binaries, delete '${
|
|
855
|
+
If you want to remove all downloaded platforma binaries, delete '${l.binaries()}' dir manually
|
|
711
856
|
`
|
|
712
857
|
);
|
|
713
858
|
}
|
|
714
859
|
mergeLicenseEnvs(e) {
|
|
715
|
-
e.license === void 0 && ((process.env.MI_LICENSE ?? "") != "" ? e.license = process.env.MI_LICENSE : (process.env.PL_LICENSE ?? "") != "" && (e.license = process.env.PL_LICENSE)), e["license-file"] === void 0 && e.license === void 0 && ((process.env.MI_LICENSE_FILE ?? "") != "" ? e["license-file"] = process.env.MI_LICENSE_FILE : (process.env.PL_LICENSE_FILE ?? "") != "" ? e["license-file"] = process.env.PL_LICENSE_FILE :
|
|
860
|
+
e.license === void 0 && ((process.env.MI_LICENSE ?? "") != "" ? e.license = process.env.MI_LICENSE : (process.env.PL_LICENSE ?? "") != "" && (e.license = process.env.PL_LICENSE)), e["license-file"] === void 0 && e.license === void 0 && ((process.env.MI_LICENSE_FILE ?? "") != "" ? e["license-file"] = process.env.MI_LICENSE_FILE : (process.env.PL_LICENSE_FILE ?? "") != "" ? e["license-file"] = process.env.PL_LICENSE_FILE : o.existsSync(f.resolve(p.homedir(), ".pl.license")) && (e["license-file"] = f.resolve(p.homedir(), ".pl.license")));
|
|
716
861
|
}
|
|
717
862
|
initAuthDriversList(e, r) {
|
|
718
|
-
var
|
|
719
|
-
if (e["auth-htpasswd-file"] &&
|
|
863
|
+
var t = [];
|
|
864
|
+
if (e["auth-htpasswd-file"] && t.push({
|
|
720
865
|
driver: "htpasswd",
|
|
721
|
-
path:
|
|
866
|
+
path: f.resolve(r, e["auth-htpasswd-file"])
|
|
722
867
|
}), !!e["auth-ldap-server"] != !!e["auth-ldap-default-dn"])
|
|
723
868
|
throw new Error("LDAP auth settings require both 'server' and 'default DN' options to be set");
|
|
724
|
-
if (e["auth-ldap-server"] &&
|
|
869
|
+
if (e["auth-ldap-server"] && t.push({
|
|
725
870
|
driver: "ldap",
|
|
726
871
|
serverUrl: e["auth-ldap-server"],
|
|
727
872
|
defaultDN: e["auth-ldap-default-dn"]
|
|
728
|
-
}),
|
|
729
|
-
return [{ driver: "jwt", key: this.getLastJwt() }, ...
|
|
873
|
+
}), t.length !== 0)
|
|
874
|
+
return [{ driver: "jwt", key: this.getLastJwt() }, ...t];
|
|
730
875
|
}
|
|
731
876
|
/** Gets the last stored JWT secret key or generates it and stores in a file. */
|
|
732
877
|
getLastJwt() {
|
|
733
878
|
const e = l.path("auth.jwt"), r = "utf-8";
|
|
734
|
-
let
|
|
879
|
+
let t = "";
|
|
735
880
|
try {
|
|
736
|
-
|
|
881
|
+
t = o.readFileSync(e, { encoding: r });
|
|
737
882
|
} catch {
|
|
738
883
|
}
|
|
739
|
-
return
|
|
884
|
+
return t == "" && (t = ur(64), o.writeFileSync(e, t, { encoding: r })), t;
|
|
740
885
|
}
|
|
741
886
|
destroyDocker(e, r) {
|
|
742
|
-
const
|
|
887
|
+
const t = l.data("stub"), i = H("docker", ["compose", "--file", e, "down", "--volumes", "--remove-orphans"], {
|
|
743
888
|
env: {
|
|
744
889
|
...process.env,
|
|
745
890
|
PL_IMAGE: "scratch",
|
|
746
|
-
PL_DATA_DB_ROOT:
|
|
747
|
-
PL_DATA_PRIMARY_ROOT:
|
|
748
|
-
PL_DATA_LIBRARY_ROOT:
|
|
749
|
-
PL_DATA_WORKDIR_ROOT:
|
|
750
|
-
PL_DATA_PACKAGE_ROOT:
|
|
891
|
+
PL_DATA_DB_ROOT: t,
|
|
892
|
+
PL_DATA_PRIMARY_ROOT: t,
|
|
893
|
+
PL_DATA_LIBRARY_ROOT: t,
|
|
894
|
+
PL_DATA_WORKDIR_ROOT: t,
|
|
895
|
+
PL_DATA_PACKAGE_ROOT: t,
|
|
751
896
|
MINIO_IMAGE: "scratch",
|
|
752
|
-
MINIO_STORAGE:
|
|
897
|
+
MINIO_STORAGE: t
|
|
753
898
|
},
|
|
754
899
|
stdio: "inherit"
|
|
755
900
|
});
|
|
@@ -770,163 +915,477 @@ or stored in '$HOME/.pl.license'.
|
|
|
770
915
|
You can obtain the license from "https://licensing.milaboratories.com".`), new Error("The license was not provided.");
|
|
771
916
|
}
|
|
772
917
|
configureDockerStorage(e, r) {
|
|
773
|
-
const
|
|
918
|
+
const t = {}, i = r.type;
|
|
774
919
|
switch (e = e.toUpperCase(), i) {
|
|
775
920
|
case "S3":
|
|
776
|
-
return
|
|
921
|
+
return t[`PL_DATA_${e}_TYPE`] = "S3", t[`PL_DATA_${e}_S3_BUCKET`] = r.bucketName, r.endpoint && (t[`PL_DATA_${e}_S3_ENDPOINT`] = r.endpoint), r.presignEndpoint && (t[`PL_DATA_${e}_S3_PRESIGN_ENDPOINT`] = r.presignEndpoint), r.region && (t[`PL_DATA_${e}_S3_REGION`] = r.region), r.key && (t[`PL_DATA_${e}_S3_KEY`] = r.key), r.secret && (t[`PL_DATA_${e}_S3_SECRET`] = r.secret), t;
|
|
777
922
|
case "FS":
|
|
778
|
-
return
|
|
923
|
+
return t[`PL_DATA_${e}_TYPE`] = "FS", t;
|
|
779
924
|
default:
|
|
780
|
-
|
|
925
|
+
Y();
|
|
781
926
|
}
|
|
782
927
|
return {};
|
|
783
928
|
}
|
|
929
|
+
renderRunInfo(e, r = 10) {
|
|
930
|
+
var n, h;
|
|
931
|
+
const t = [], i = (u) => u.padStart(r, " ");
|
|
932
|
+
switch (e.configPath && t.push(`${i("config")}: ${e.configPath}`), e.apiAddr ? t.push(`${i("API")}: ${e.apiAddr}`) : e.apiPort ? t.push(`${i("API")}: 127.0.0.1:${e.apiPort.toString()}`) : t.push(`${i("API")}: 127.0.0.1:6345`), e.logPath && t.push(`${i("log")}: ${e.logPath}`), (n = e.primary) == null ? void 0 : n.type) {
|
|
933
|
+
case void 0:
|
|
934
|
+
break;
|
|
935
|
+
case "FS":
|
|
936
|
+
t.push(`${i("primary")}: ${e.primary.rootPath}`);
|
|
937
|
+
break;
|
|
938
|
+
case "S3":
|
|
939
|
+
t.push(
|
|
940
|
+
`${i("primary")}: S3 at '${e.primary.endpoint ?? "AWS"}', bucket '${e.primary.bucketName}', prefix: '${e.primary.keyPrefix ?? ""}'`
|
|
941
|
+
);
|
|
942
|
+
break;
|
|
943
|
+
default:
|
|
944
|
+
Y();
|
|
945
|
+
}
|
|
946
|
+
switch ((h = e.library) == null ? void 0 : h.type) {
|
|
947
|
+
case void 0:
|
|
948
|
+
break;
|
|
949
|
+
case "FS":
|
|
950
|
+
t.push(`${i("library")}: ${e.library.rootPath}`);
|
|
951
|
+
break;
|
|
952
|
+
case "S3":
|
|
953
|
+
t.push(
|
|
954
|
+
`${i("library")}: S3 at '${e.library.endpoint ?? "AWS"}', bucket '${e.library.bucketName}', prefix: '${e.library.keyPrefix ?? ""}'`
|
|
955
|
+
);
|
|
956
|
+
break;
|
|
957
|
+
default:
|
|
958
|
+
Y();
|
|
959
|
+
}
|
|
960
|
+
return e.work && t.push(`${i("workdirs")}: ${e.work.rootPath}`), e.dbPath && t.push(`${i("db")}: ${e.dbPath}`), t.join(`
|
|
961
|
+
`);
|
|
962
|
+
}
|
|
784
963
|
readComposeFile(e) {
|
|
785
|
-
const r =
|
|
786
|
-
return
|
|
964
|
+
const r = o.readFileSync(e);
|
|
965
|
+
return Ce.parse(r.toString());
|
|
787
966
|
}
|
|
788
967
|
writeComposeFile(e, r) {
|
|
789
|
-
|
|
968
|
+
o.writeFileSync(e, Ce.stringify(r));
|
|
790
969
|
}
|
|
791
970
|
}
|
|
792
|
-
function
|
|
793
|
-
if (
|
|
794
|
-
throw
|
|
971
|
+
function J(a, e) {
|
|
972
|
+
if (a.error)
|
|
973
|
+
throw a.error;
|
|
795
974
|
const r = e ?? "failed to run command";
|
|
796
|
-
if (
|
|
797
|
-
throw new Error(`${r}, process exited with code '${
|
|
975
|
+
if (a.status !== 0)
|
|
976
|
+
throw new Error(`${r}, process exited with code '${a.status}'`);
|
|
798
977
|
}
|
|
799
|
-
const
|
|
800
|
-
"log-level":
|
|
978
|
+
const E = {
|
|
979
|
+
"log-level": y.string({
|
|
801
980
|
description: "logging level",
|
|
802
981
|
default: "info",
|
|
803
982
|
options: ["error", "warn", "info", "debug"],
|
|
804
983
|
required: !1
|
|
805
984
|
})
|
|
985
|
+
}, Ke = {
|
|
986
|
+
image: y.string({
|
|
987
|
+
description: "use custom docker image to run platforma"
|
|
988
|
+
})
|
|
989
|
+
}, X = {
|
|
990
|
+
version: y.string({
|
|
991
|
+
description: "use custom platforma release (official docker image or binary package)"
|
|
992
|
+
})
|
|
993
|
+
}, Z = {
|
|
994
|
+
license: y.string({
|
|
995
|
+
description: 'pass a license code. The license can be got from "https://licensing.milaboratories.com".'
|
|
996
|
+
}),
|
|
997
|
+
"license-file": y.file({
|
|
998
|
+
exists: !0,
|
|
999
|
+
description: "specify a path to the file with a license. The license can be got from 'https://licensing.milaboratories.com'."
|
|
1000
|
+
})
|
|
1001
|
+
}, ee = {
|
|
1002
|
+
"grpc-port": y.integer({
|
|
1003
|
+
description: "port for Platforma Backend gRPC API. Default is 6345",
|
|
1004
|
+
env: "PLATFORMA_GRPC_PORT"
|
|
1005
|
+
}),
|
|
1006
|
+
"grpc-listen": y.string({
|
|
1007
|
+
description: "full listen addr for Platforma Backend gRPC API. Default is 127.0.0.1:6345",
|
|
1008
|
+
env: "PLATFORMA_GRPC_LISTEN"
|
|
1009
|
+
}),
|
|
1010
|
+
"monitoring-port": y.integer({
|
|
1011
|
+
description: "port for Platforma Backend monitoring API. Default is 9090",
|
|
1012
|
+
env: "PLATFORMA_MONITORING_PORT"
|
|
1013
|
+
}),
|
|
1014
|
+
"monitoring-listen": y.string({
|
|
1015
|
+
description: "full listen addr for Platforma Backend monitoring API. Default is 127.0.0.1:9090",
|
|
1016
|
+
env: "PLATFORMA_MONITORING_LISTEN"
|
|
1017
|
+
}),
|
|
1018
|
+
"debug-port": y.integer({
|
|
1019
|
+
description: "port for Platforma Backend debug API. Default is 9091",
|
|
1020
|
+
env: "PLATFORMA_DEBUG_PORT"
|
|
1021
|
+
}),
|
|
1022
|
+
"debug-listen": y.string({
|
|
1023
|
+
description: "full listen addr for Platforma Backend debug API. Default is 127.0.0.1:9091",
|
|
1024
|
+
env: "PLATFORMA_DEBUG_LISTEN"
|
|
1025
|
+
})
|
|
1026
|
+
}, $r = {
|
|
1027
|
+
"s3-address-port": y.integer({
|
|
1028
|
+
description: "port that S3 will listen, default is 9000",
|
|
1029
|
+
default: 9e3,
|
|
1030
|
+
env: "PLATFORMA_S3_PORT"
|
|
1031
|
+
}),
|
|
1032
|
+
"s3-console-address-port": y.integer({
|
|
1033
|
+
description: "port that a console of S3 will listen, default is 9001",
|
|
1034
|
+
default: 9001,
|
|
1035
|
+
env: "PLATFORMA_S3_CONSOLE_PORT"
|
|
1036
|
+
})
|
|
1037
|
+
}, re = {
|
|
1038
|
+
storage: y.string({
|
|
1039
|
+
description: "specify path on host to be used as storage for all Platforma Backend data"
|
|
1040
|
+
})
|
|
1041
|
+
}, qe = {
|
|
1042
|
+
"pl-log-file": y.file({
|
|
1043
|
+
description: "specify path for Platforma Backend log file"
|
|
1044
|
+
})
|
|
1045
|
+
}, Ve = {
|
|
1046
|
+
"pl-workdir": y.file({
|
|
1047
|
+
description: "specify working directory for Platforma Backend process"
|
|
1048
|
+
})
|
|
1049
|
+
}, Qe = {
|
|
1050
|
+
"pl-binary": y.file({
|
|
1051
|
+
description: "start given Platforma Backend binary instead of automatically downloaded version"
|
|
1052
|
+
})
|
|
1053
|
+
}, Xe = {
|
|
1054
|
+
"pl-sources": y.file({
|
|
1055
|
+
description: "path to pl repository root: build Platforma Backend from sources and start the resulting binary"
|
|
1056
|
+
})
|
|
1057
|
+
}, Ze = {
|
|
1058
|
+
config: y.string({
|
|
1059
|
+
description: "use custom Platforma Backend config"
|
|
1060
|
+
})
|
|
806
1061
|
};
|
|
807
|
-
|
|
808
|
-
description: "use custom docker image to run platforma"
|
|
809
|
-
});
|
|
810
|
-
d.string({
|
|
811
|
-
description: "use custom platforma release (official docker image or binary package)"
|
|
812
|
-
});
|
|
813
|
-
d.string({
|
|
814
|
-
description: 'pass a license code. The license can be got from "https://licensing.milaboratories.com".'
|
|
815
|
-
}), d.file({
|
|
816
|
-
exists: !0,
|
|
817
|
-
description: "specify a path to the file with a license. The license can be got from 'https://licensing.milaboratories.com'."
|
|
818
|
-
});
|
|
819
|
-
d.integer({
|
|
820
|
-
description: "port that the platform's grpc server will listen, by default it's 6345",
|
|
821
|
-
default: 6345,
|
|
822
|
-
env: "PLATFORMA_GRPC_PORT"
|
|
823
|
-
}), d.integer({
|
|
824
|
-
description: "port that the platform's monitoring server will listen, by default it's 9090",
|
|
825
|
-
default: 9090,
|
|
826
|
-
env: "PLATFORMA_MONITORING_PORT"
|
|
827
|
-
}), d.integer({
|
|
828
|
-
description: "port that the platform's debug server will listen, by default it's 9091",
|
|
829
|
-
default: 9091,
|
|
830
|
-
env: "PLATFORMA_DEBUG_PORT"
|
|
831
|
-
});
|
|
832
|
-
d.integer({
|
|
833
|
-
description: "port that S3 will listen, default is 9000",
|
|
834
|
-
default: 9e3,
|
|
835
|
-
env: "PLATFORMA_S3_PORT"
|
|
836
|
-
}), d.integer({
|
|
837
|
-
description: "port that a console of S3 will listen, default is 9001",
|
|
838
|
-
default: 9001,
|
|
839
|
-
env: "PLATFORMA_S3_CONSOLE_PORT"
|
|
840
|
-
});
|
|
841
|
-
d.string({
|
|
842
|
-
description: "specify path on host to be used as storage for all Platforma Backend data"
|
|
843
|
-
});
|
|
844
|
-
d.file({
|
|
845
|
-
description: "specify path for Platforma Backend log file"
|
|
846
|
-
});
|
|
847
|
-
d.file({
|
|
848
|
-
description: "specify working directory for Platforma Backend process"
|
|
849
|
-
});
|
|
850
|
-
d.file({
|
|
851
|
-
description: "start given Platforma Backend binary instead of automatically downloaded version"
|
|
852
|
-
});
|
|
853
|
-
d.file({
|
|
854
|
-
description: "path to pl repository root: build Platforma Backend from sources and start the resulting binary"
|
|
855
|
-
});
|
|
856
|
-
d.string({
|
|
857
|
-
description: "use custom Platforma Backend config"
|
|
858
|
-
});
|
|
859
|
-
d.file({
|
|
1062
|
+
y.file({
|
|
860
1063
|
description: "specify path on host to be used as 'primary' storage"
|
|
861
1064
|
});
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
1065
|
+
const fe = {
|
|
1066
|
+
"storage-work": y.file({
|
|
1067
|
+
description: "specify path on host to be used as 'work' storage"
|
|
1068
|
+
})
|
|
1069
|
+
};
|
|
1070
|
+
y.file({
|
|
866
1071
|
description: "specify path on host to be used as 'library' storage"
|
|
867
1072
|
});
|
|
868
|
-
|
|
869
|
-
|
|
1073
|
+
const he = {
|
|
1074
|
+
"storage-primary": y.string({
|
|
1075
|
+
description: `specify 'primary' storage destination URL.
|
|
870
1076
|
file:/path/to/dir for directory on local FS
|
|
871
1077
|
s3://<bucket>/?region=<name> for real AWS bucket
|
|
872
1078
|
s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
|
|
873
1079
|
s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`
|
|
874
|
-
})
|
|
875
|
-
|
|
876
|
-
|
|
1080
|
+
})
|
|
1081
|
+
}, me = {
|
|
1082
|
+
"storage-library": y.string({
|
|
1083
|
+
description: `specify 'library' storage destination URL.
|
|
877
1084
|
file:/path/to/dir for directory on local FS
|
|
878
1085
|
s3://<bucket>/?region=<name> for real AWS bucket
|
|
879
1086
|
s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
|
|
880
1087
|
s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`
|
|
1088
|
+
})
|
|
1089
|
+
}, Or = {
|
|
1090
|
+
"auth-enabled": y.boolean({
|
|
1091
|
+
description: "enable authorization"
|
|
1092
|
+
})
|
|
1093
|
+
}, Tr = {
|
|
1094
|
+
"auth-htpasswd-file": y.file({
|
|
1095
|
+
description: "path to .htpasswd file with Platforma users (static user DB auth source)"
|
|
1096
|
+
})
|
|
1097
|
+
}, Er = {
|
|
1098
|
+
"auth-ldap-server": y.string({
|
|
1099
|
+
description: "address of LDAP server to use for auth in Platforma (auth source)"
|
|
1100
|
+
})
|
|
1101
|
+
}, Fr = {
|
|
1102
|
+
"auth-ldap-default-dn": y.string({
|
|
1103
|
+
description: "DN to use when checking user with LDAP bind operation: e.g. cn=%u,ou=users,dc=example,dc=com"
|
|
1104
|
+
})
|
|
1105
|
+
}, te = {
|
|
1106
|
+
...Or,
|
|
1107
|
+
...Tr,
|
|
1108
|
+
...Er,
|
|
1109
|
+
...Fr
|
|
1110
|
+
}, I = class I extends O {
|
|
1111
|
+
async run() {
|
|
1112
|
+
const { flags: e } = await this.parse(I), r = T(e["log-level"]);
|
|
1113
|
+
new D(r).stop();
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
m(I, "description", "Stop platforma service"), m(I, "examples", ["<%= config.bin %> <%= command.id %>"]), m(I, "flags", {
|
|
1117
|
+
...E
|
|
881
1118
|
});
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
1119
|
+
let ce = I;
|
|
1120
|
+
const x = class x extends O {
|
|
1121
|
+
async run() {
|
|
1122
|
+
const { flags: e } = await this.parse(x), r = T(e["log-level"]);
|
|
1123
|
+
new D(r).cleanup();
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
1126
|
+
m(x, "description", "Clear service state (forget last run command, destroy docker services, volumes and so on)"), m(x, "examples", ["<%= config.bin %> <%= command.id %>"]), m(x, "flags", {
|
|
1127
|
+
...E
|
|
887
1128
|
});
|
|
888
|
-
|
|
889
|
-
|
|
1129
|
+
let ne = x;
|
|
1130
|
+
const M = class M extends O {
|
|
1131
|
+
async run() {
|
|
1132
|
+
const { flags: e } = await this.parse(M), r = T(e["log-level"]);
|
|
1133
|
+
new D(r).startLast();
|
|
1134
|
+
}
|
|
1135
|
+
};
|
|
1136
|
+
m(M, "description", "Start last run service configuraiton"), m(M, "examples", ["<%= config.bin %> <%= command.id %>"]), m(M, "flags", {
|
|
1137
|
+
...E
|
|
890
1138
|
});
|
|
891
|
-
|
|
892
|
-
|
|
1139
|
+
let le = M;
|
|
1140
|
+
const C = class C extends O {
|
|
1141
|
+
async run() {
|
|
1142
|
+
const { flags: e } = await this.parse(C), r = T(e["log-level"]), t = new D(r);
|
|
1143
|
+
t.mergeLicenseEnvs(e);
|
|
1144
|
+
const i = e["auth-enabled"], s = i ? {
|
|
1145
|
+
enabled: i,
|
|
1146
|
+
drivers: t.initAuthDriversList(e, ".")
|
|
1147
|
+
} : void 0, c = e.storage ? f.join(".", e.storage) : l.data("docker");
|
|
1148
|
+
t.startDocker(c, {
|
|
1149
|
+
primaryStorageURL: e["storage-primary"],
|
|
1150
|
+
workStoragePath: e["storage-work"],
|
|
1151
|
+
libraryStorageURL: e["storage-library"],
|
|
1152
|
+
image: e.image,
|
|
1153
|
+
version: e.version,
|
|
1154
|
+
license: e.license,
|
|
1155
|
+
licenseFile: e["license-file"],
|
|
1156
|
+
auth: s,
|
|
1157
|
+
grpcAddr: e["grpc-listen"],
|
|
1158
|
+
grpcPort: e["grpc-port"],
|
|
1159
|
+
monitoringAddr: e["monitoring-listen"],
|
|
1160
|
+
monitoringPort: e["monitoring-port"],
|
|
1161
|
+
debugAddr: e["debug-listen"],
|
|
1162
|
+
debugPort: e["debug-port"]
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
m(C, "description", "Run platforma backend service with 'FS' primary storage type"), m(C, "examples", ["<%= config.bin %> <%= command.id %>"]), m(C, "flags", {
|
|
1167
|
+
...E,
|
|
1168
|
+
...ee,
|
|
1169
|
+
...Ke,
|
|
1170
|
+
...X,
|
|
1171
|
+
...te,
|
|
1172
|
+
...Z,
|
|
1173
|
+
...re,
|
|
1174
|
+
...he,
|
|
1175
|
+
...fe,
|
|
1176
|
+
...me
|
|
893
1177
|
});
|
|
894
|
-
|
|
1178
|
+
let oe = C;
|
|
1179
|
+
var R;
|
|
1180
|
+
let Dr = (R = class extends O {
|
|
1181
|
+
async run() {
|
|
1182
|
+
const { flags: e } = await this.parse(R), r = T(e["log-level"]), t = new D(r);
|
|
1183
|
+
t.mergeLicenseEnvs(e);
|
|
1184
|
+
const i = e["auth-enabled"], s = i ? {
|
|
1185
|
+
enabled: i,
|
|
1186
|
+
drivers: t.initAuthDriversList(e, ".")
|
|
1187
|
+
} : void 0, c = e.storage ? f.join(".", e.storage) : l.data("docker-s3");
|
|
1188
|
+
t.startDockerS3(c, {
|
|
1189
|
+
image: e.image,
|
|
1190
|
+
version: e.version,
|
|
1191
|
+
license: e.license,
|
|
1192
|
+
licenseFile: e["license-file"],
|
|
1193
|
+
auth: s,
|
|
1194
|
+
grpcAddr: e["grpc-listen"],
|
|
1195
|
+
grpcPort: e["grpc-port"],
|
|
1196
|
+
monitoringAddr: e["monitoring-listen"],
|
|
1197
|
+
monitoringPort: e["monitoring-port"],
|
|
1198
|
+
debugAddr: e["debug-listen"],
|
|
1199
|
+
debugPort: e["debug-port"]
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
}, m(R, "description", "Run platforma backend service with 'S3' primary storage type"), m(R, "examples", ["<%= config.bin %> <%= command.id %>"]), m(R, "flags", {
|
|
1203
|
+
...E,
|
|
1204
|
+
...ee,
|
|
1205
|
+
...Ke,
|
|
1206
|
+
...X,
|
|
1207
|
+
...re,
|
|
1208
|
+
...Z,
|
|
1209
|
+
...te
|
|
1210
|
+
}), R);
|
|
1211
|
+
const B = class B extends O {
|
|
895
1212
|
async run() {
|
|
896
|
-
const { flags: e } = await this.parse(
|
|
897
|
-
|
|
1213
|
+
const { flags: e } = await this.parse(B), r = T(e["log-level"]), t = new D(r);
|
|
1214
|
+
t.mergeLicenseEnvs(e);
|
|
1215
|
+
const i = e["pl-workdir"] ?? ".", s = e.storage ? f.join(i, e.storage) : l.data("local"), c = e["pl-log-file"] ? f.join(i, e["pl-log-file"]) : void 0, n = t.initAuthDriversList(e, i), h = e["auth-enabled"] ?? n !== void 0;
|
|
1216
|
+
var u = e["pl-binary"];
|
|
1217
|
+
e["pl-sources"] && (u = t.buildPlatforma({ repoRoot: e["pl-sources"] }));
|
|
1218
|
+
var g = "127.0.0.1:6345";
|
|
1219
|
+
e["grpc-listen"] ? g = e["grpc-listen"] : e["grpc-port"] && (g = `127.0.0.1:${e["grpc-port"]}`);
|
|
1220
|
+
var v = "127.0.0.1:9090";
|
|
1221
|
+
e["monitoring-listen"] ? v = e["monitoring-listen"] : e["monitoring-port"] && (v = `127.0.0.1:${e["monitoring-port"]}`);
|
|
1222
|
+
var P = "127.0.0.1:9091";
|
|
1223
|
+
e["debug-listen"] ? P = e["debug-listen"] : e["debug-port"] && (P = `127.0.0.1:${e["debug-port"]}`);
|
|
1224
|
+
const d = {
|
|
1225
|
+
binaryPath: u,
|
|
1226
|
+
version: e.version,
|
|
1227
|
+
configPath: e.config,
|
|
1228
|
+
workdir: e["pl-workdir"],
|
|
1229
|
+
primaryURL: e["storage-primary"],
|
|
1230
|
+
libraryURL: e["storage-library"],
|
|
1231
|
+
configOptions: {
|
|
1232
|
+
grpc: { listen: g },
|
|
1233
|
+
monitoring: { listen: v },
|
|
1234
|
+
debug: { listen: P },
|
|
1235
|
+
license: { value: e.license, file: e["license-file"] },
|
|
1236
|
+
log: { path: c },
|
|
1237
|
+
localRoot: s,
|
|
1238
|
+
core: { auth: { enabled: h, drivers: n } },
|
|
1239
|
+
storages: {
|
|
1240
|
+
work: { type: "FS", rootPath: e["storage-work"] }
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
d.binaryPath ? t.startLocal(d) : Ye(r, { version: e.version }).then(() => t.startLocal(d)).catch(function(b) {
|
|
1245
|
+
r.error(b.message);
|
|
1246
|
+
});
|
|
898
1247
|
}
|
|
899
1248
|
};
|
|
900
|
-
m(
|
|
901
|
-
...
|
|
1249
|
+
m(B, "description", "Run Platforma Backend service as local process on current host (no docker container)"), m(B, "examples", ["<%= config.bin %> <%= command.id %>"]), m(B, "flags", {
|
|
1250
|
+
...E,
|
|
1251
|
+
...X,
|
|
1252
|
+
...ee,
|
|
1253
|
+
...Qe,
|
|
1254
|
+
...Xe,
|
|
1255
|
+
...Ze,
|
|
1256
|
+
...Z,
|
|
1257
|
+
...re,
|
|
1258
|
+
...he,
|
|
1259
|
+
...fe,
|
|
1260
|
+
...me,
|
|
1261
|
+
...qe,
|
|
1262
|
+
...Ve,
|
|
1263
|
+
...te
|
|
902
1264
|
});
|
|
903
|
-
let
|
|
904
|
-
const
|
|
1265
|
+
let de = B;
|
|
1266
|
+
const G = class G extends O {
|
|
905
1267
|
async run() {
|
|
906
|
-
const { flags: e } = await this.parse(
|
|
907
|
-
|
|
1268
|
+
const { flags: e } = await this.parse(G), r = T(e["log-level"]), t = new D(r);
|
|
1269
|
+
t.mergeLicenseEnvs(e);
|
|
1270
|
+
const i = e["pl-workdir"] ?? ".", s = e.storage ? f.join(i, e.storage) : l.data("local-s3"), c = e["pl-log-file"] ? f.join(i, e["pl-log-file"]) : void 0, n = t.initAuthDriversList(e, i), h = e["auth-enabled"] ?? n !== void 0;
|
|
1271
|
+
var u = e["pl-binary"];
|
|
1272
|
+
e["pl-sources"] && (u = t.buildPlatforma({ repoRoot: e["pl-sources"] }));
|
|
1273
|
+
var g = "127.0.0.1:6345";
|
|
1274
|
+
e["grpc-listen"] ? g = e["grpc-listen"] : e["grpc-port"] && (g = `127.0.0.1:${e["grpc-port"]}`);
|
|
1275
|
+
var v = "127.0.0.1:9090";
|
|
1276
|
+
e["monitoring-listen"] ? v = e["monitoring-listen"] : e["monitoring-port"] && (v = `127.0.0.1:${e["monitoring-port"]}`);
|
|
1277
|
+
var P = "127.0.0.1:9091";
|
|
1278
|
+
e["debug-listen"] ? P = e["debug-listen"] : e["debug-port"] && (P = `127.0.0.1:${e["debug-port"]}`);
|
|
1279
|
+
const d = {
|
|
1280
|
+
binaryPath: u,
|
|
1281
|
+
version: e.version,
|
|
1282
|
+
configPath: e.config,
|
|
1283
|
+
workdir: e["pl-workdir"],
|
|
1284
|
+
primaryURL: e["storage-primary"],
|
|
1285
|
+
libraryURL: e["storage-library"],
|
|
1286
|
+
minioPort: e["s3-address-port"],
|
|
1287
|
+
minioConsolePort: e["s3-console-address-port"],
|
|
1288
|
+
configOptions: {
|
|
1289
|
+
grpc: { listen: g },
|
|
1290
|
+
monitoring: { listen: v },
|
|
1291
|
+
debug: { listen: P },
|
|
1292
|
+
license: { value: e.license, file: e["license-file"] },
|
|
1293
|
+
log: { path: c },
|
|
1294
|
+
localRoot: s,
|
|
1295
|
+
core: {
|
|
1296
|
+
auth: { enabled: h, drivers: n }
|
|
1297
|
+
},
|
|
1298
|
+
storages: {
|
|
1299
|
+
work: { type: "FS", rootPath: e["storage-work"] }
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
d.binaryPath ? t.startLocalS3(d) : Ye(r, { version: e.version }).then(() => t.startLocalS3(d)).catch(function(b) {
|
|
1304
|
+
r.error(b.message);
|
|
1305
|
+
});
|
|
908
1306
|
}
|
|
909
1307
|
};
|
|
910
|
-
m(
|
|
911
|
-
...
|
|
1308
|
+
m(G, "description", "Run Platforma Backend service as local process on current host (no docker container)"), m(G, "examples", ["<%= config.bin %> <%= command.id %>"]), m(G, "flags", {
|
|
1309
|
+
...E,
|
|
1310
|
+
...X,
|
|
1311
|
+
...ee,
|
|
1312
|
+
...$r,
|
|
1313
|
+
...Qe,
|
|
1314
|
+
...Xe,
|
|
1315
|
+
...Ze,
|
|
1316
|
+
...Z,
|
|
1317
|
+
...re,
|
|
1318
|
+
...he,
|
|
1319
|
+
...fe,
|
|
1320
|
+
...me,
|
|
1321
|
+
...qe,
|
|
1322
|
+
...Ve,
|
|
1323
|
+
...te
|
|
1324
|
+
});
|
|
1325
|
+
let ge = G;
|
|
1326
|
+
const Nr = K.object({
|
|
1327
|
+
npmOrgName: K.string().min(1),
|
|
1328
|
+
orgName: K.string().min(1),
|
|
1329
|
+
blockName: K.string().min(1)
|
|
912
1330
|
});
|
|
913
|
-
|
|
914
|
-
const
|
|
1331
|
+
async function Ir(a) {
|
|
1332
|
+
const e = xr(), r = f.join(process.cwd(), e.blockName);
|
|
1333
|
+
a.info("Downloading boilerplate code..."), await Mr(
|
|
1334
|
+
"https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip",
|
|
1335
|
+
"platforma-block-boilerplate-main",
|
|
1336
|
+
r
|
|
1337
|
+
), a.info("Replace everything in the template with provided options..."), Cr(
|
|
1338
|
+
r,
|
|
1339
|
+
/pl-open\/my-org.block-boilerplate/g,
|
|
1340
|
+
`${e.npmOrgName}/${e.orgName}.${e.blockName}`
|
|
1341
|
+
);
|
|
1342
|
+
}
|
|
1343
|
+
function xr() {
|
|
1344
|
+
let a = V.question('Write an organization name for npm. Default is "pl-open": ');
|
|
1345
|
+
a === "" && (a = "pl-open");
|
|
1346
|
+
const e = V.question('Write an organization name, e.g. "my-org": '), r = V.question('Write a name of the block, e.g. "hello-world": ');
|
|
1347
|
+
return Nr.parse({ npmOrgName: a, orgName: e, blockName: r });
|
|
1348
|
+
}
|
|
1349
|
+
async function Mr(a, e, r) {
|
|
1350
|
+
const i = await (await fetch(a)).blob(), s = o.mkdtempSync(f.join(p.tmpdir(), "create-repo")), c = f.join(s, "packed-repo.zip"), n = lr.toWeb(ar(c));
|
|
1351
|
+
await i.stream().pipeTo(n);
|
|
1352
|
+
const h = f.join(s, "unpacked-repo");
|
|
1353
|
+
o.mkdirSync(h), await or(c, h), o.cpSync(f.join(h, e), r, { recursive: !0 });
|
|
1354
|
+
}
|
|
1355
|
+
function Cr(a, e, r) {
|
|
1356
|
+
Br(a).forEach((t) => Gr(t, e, r));
|
|
1357
|
+
}
|
|
1358
|
+
function Br(a) {
|
|
1359
|
+
return o.readdirSync(a, {
|
|
1360
|
+
withFileTypes: !0,
|
|
1361
|
+
recursive: !0
|
|
1362
|
+
}).filter((r) => r.isFile()).map((r) => f.join(r.parentPath, r.name));
|
|
1363
|
+
}
|
|
1364
|
+
function Gr(a, e, r) {
|
|
1365
|
+
const i = o.readFileSync(a).toString().replaceAll(e, r);
|
|
1366
|
+
o.writeFileSync(a, i);
|
|
1367
|
+
}
|
|
1368
|
+
const U = class U extends O {
|
|
915
1369
|
async run() {
|
|
916
|
-
const { flags: e } = await this.parse(
|
|
917
|
-
|
|
1370
|
+
const { flags: e } = await this.parse(U), r = T(e["log-level"]);
|
|
1371
|
+
await Ir(r);
|
|
918
1372
|
}
|
|
919
1373
|
};
|
|
920
|
-
m(
|
|
921
|
-
...
|
|
1374
|
+
m(U, "description", "Helps to create a new block by downloading a block's template."), m(U, "examples", ["<%= name %>"]), m(U, "flags", {
|
|
1375
|
+
...E
|
|
922
1376
|
});
|
|
923
|
-
let
|
|
924
|
-
const
|
|
925
|
-
stop:
|
|
926
|
-
start:
|
|
927
|
-
reset:
|
|
1377
|
+
let ue = U;
|
|
1378
|
+
const rt = {
|
|
1379
|
+
stop: ce,
|
|
1380
|
+
start: le,
|
|
1381
|
+
reset: ne,
|
|
1382
|
+
"create-block": ue,
|
|
1383
|
+
"start docker": oe,
|
|
1384
|
+
"start local": de,
|
|
1385
|
+
"start docker s3": Dr,
|
|
1386
|
+
"start local s3": ge
|
|
928
1387
|
};
|
|
929
1388
|
export {
|
|
930
|
-
|
|
1389
|
+
rt as COMMANDS
|
|
931
1390
|
};
|
|
932
1391
|
//# sourceMappingURL=index.mjs.map
|