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