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