@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/dist/index.mjs CHANGED
@@ -1,174 +1,191 @@
1
- var ir = Object.defineProperty;
2
- var sr = (a, e, r) => e in a ? ir(a, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[e] = r;
3
- var h = (a, e, r) => sr(a, typeof e != "symbol" ? e + "" : e, r);
4
- import { Flags as y, Command as E } from "@oclif/core";
5
- import L from "node:os";
6
- import d, { createWriteStream as cr } from "node:fs";
7
- import o, { resolve as nr } from "node:path";
8
- import { execSync as Ge, spawn as lr, spawnSync as K } from "node:child_process";
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 or } from "node:crypto";
11
- import M from "readline-sync";
12
- import * as T from "node:fs/promises";
13
- import { Writable as dr } from "node:stream";
14
- import { z as O } from "zod";
15
- import gr from "decompress";
16
- import je from "yaml";
17
- import { getDefaultPlVersion as Z } from "@milaboratories/pl-local";
18
- import ur from "node:https";
19
- import * as fr from "tar";
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": y.string({
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
- }, Je = {
28
- image: y.string({
27
+ }, He = {
28
+ image: h.string({
29
29
  description: "use custom docker image to run platforma"
30
30
  })
31
- }, ee = {
32
- version: y.string({
31
+ }, re = {
32
+ version: h.string({
33
33
  description: "use custom platforma release (official docker image or binary package)"
34
34
  })
35
- }, re = {
36
- license: y.string({
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": y.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
- }, te = {
44
- "grpc-port": y.integer({
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": y.string({
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": y.integer({
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": y.string({
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": y.integer({
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": y.string({
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
- }, mr = {
69
- "s3-address-port": y.integer({
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": y.integer({
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
- }, ae = {
80
- storage: y.string({
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
- }, He = {
84
- "pl-log-file": y.file({
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
- }, Ye = {
88
- "pl-workdir": y.file({
104
+ }, qe = {
105
+ "pl-workdir": h.file({
89
106
  description: "specify working directory for Platforma Backend process"
90
107
  })
91
- }, ze = {
92
- "pl-binary": y.file({
108
+ }, Ve = {
109
+ "pl-binary": h.file({
93
110
  description: "start given Platforma Backend binary instead of automatically downloaded version"
94
111
  })
95
- }, Ke = {
96
- "pl-sources": y.file({
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
- }, qe = {
100
- config: y.string({
116
+ }, Xe = {
117
+ config: h.string({
101
118
  description: "use custom Platforma Backend config"
102
119
  })
103
120
  };
104
- y.file({
121
+ h.file({
105
122
  description: "specify path on host to be used as 'primary' storage"
106
123
  });
107
- const he = {
108
- "storage-work": y.file({
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
- y.file({
129
+ h.file({
113
130
  description: "specify path on host to be used as 'library' storage"
114
131
  });
115
- const ye = {
116
- "storage-primary": y.string({
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
- }, Pe = {
124
- "storage-library": y.string({
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
- }, hr = {
132
- "auth-enabled": y.boolean({
148
+ }, vr = {
149
+ "auth-enabled": h.boolean({
133
150
  description: "enable authorization"
134
151
  })
135
- }, yr = {
136
- "auth-htpasswd-file": y.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
- }, Pr = {
140
- "auth-ldap-server": y.string({
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
- }, br = {
144
- "auth-ldap-default-dn": y.string({
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
- ...hr,
149
- ...yr,
150
- ...Pr,
151
- ...br
165
+ ...vr,
166
+ ...wr,
167
+ ...kr,
168
+ ...Sr
152
169
  };
153
- function wr(a) {
154
- return M.question(`${a} [y/N] `).toLowerCase() === "y";
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 F(a = "debug") {
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 c = JSON.stringify(r);
166
- throw Error(`logger message ${c} is not a string`);
182
+ const n = JSON.stringify(r);
183
+ throw Error(`logger message ${n} is not a string`);
167
184
  }
168
- const i = r.split(`
169
- `).map((c, n) => n === 0 ? c : t + c).join(`
185
+ const s = r.split(`
186
+ `).map((n, c) => c === 0 ? n : t + n).join(`
170
187
  `);
171
- return `${((c) => Q.format.colorize().colorize(c, c))(e)}: ${i}`;
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 vr(a) {
182
- return or(Math.ceil(a / 2)).toString("hex").slice(0, a);
198
+ function Ar(a) {
199
+ return ur(Math.ceil(a / 2)).toString("hex").slice(0, a);
183
200
  }
184
- function kr(a) {
185
- return a.startsWith("~") ? o.join(L.homedir(), a.slice(1)) : a;
201
+ function Rr(a) {
202
+ return a.startsWith("~") ? g.join(_.homedir(), a.slice(1)) : a;
186
203
  }
187
204
  function X(a, e) {
188
- d.existsSync(a) || (d.mkdirSync(a, { recursive: !0 }), e != null && e.mode && d.chmodSync(a, e.mode));
205
+ o.existsSync(a) || (o.mkdirSync(a, { recursive: !0 }), e != null && e.mode && o.chmodSync(a, e.mode));
189
206
  }
190
- function Sr(a) {
207
+ function Lr(a) {
191
208
  try {
192
- if (L.platform() !== "win32")
193
- return Ge(`ps -p ${a} -o comm=`, { encoding: "utf8" }).trim();
194
- const e = `wmic process where processid=${a} get Caption`, r = Ge(e, { encoding: "utf8" }).split(`
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"], Ve = ["Tengo", "Python"], Ar = O.union([O.literal("Tengo"), O.literal("Python")]), pr = O.object({
202
- npmOrgName: O.string().min(1),
203
- orgName: O.string().min(1),
204
- blockName: O.string().min(1),
205
- softwarePlatforms: O.array(Ar).refine((a) => new Set(a).size === a.length, {
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 Rr(a) {
210
- const { npmOrgName: e, orgName: r, blockName: t, softwarePlatforms: i } = Lr(), s = o.join(process.cwd(), t);
211
- a.info("Downloading boilerplate code..."), await _r(
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
- s
233
+ i
217
234
  );
218
- const c = Ve.filter((u) => i.indexOf(u) < 0), n = ce.length == c.length;
219
- a.info(`Keep platforms '${i}', remove: '${c}'. Will remove all platforms? ${n}`);
220
- for (const u of c)
221
- await $r(s, u);
222
- n && await Or(s), a.info("Replace everything in the template with provided options..."), Tr(s, [
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 Lr() {
232
- let a = M.question(
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 = M.question('Write an organization name, e.g. "my-org": '), r = M.question('Write a name of the block, e.g. "hello-world": '), t = M.keyInYN("Create package for block's software?");
237
- let i = ["Tengo"];
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 (; i.length < Ve.length; ) {
240
- const s = M.keyInSelect(ce, "Choose software platform:");
241
- if (s < 0) break;
242
- i.push(ce[s]);
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 i = Array.from(new Set(i)).sort(), pr.parse({ npmOrgName: a, orgName: e, blockName: r, softwarePlatforms: i });
261
+ return s = Array.from(new Set(s)).sort(), _r.parse({ npmOrgName: a, orgName: e, blockName: r, softwarePlatforms: s });
245
262
  }
246
- async function _r(a, e, r) {
247
- const i = await (await fetch(a)).blob(), s = await T.mkdtemp(o.join(L.tmpdir(), "create-repo")), c = o.join(s, "packed-repo.zip"), n = dr.toWeb(cr(c));
248
- await i.stream().pipeTo(n);
249
- const u = o.join(s, "unpacked-repo");
250
- await T.mkdir(u), await gr(c, u), await T.cp(o.join(u, e), r, { recursive: !0 });
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 $r(a, e) {
269
+ async function Fr(a, e) {
253
270
  const r = e.toLowerCase();
254
- await C(
255
- o.join(a, "ui", "src", "pages", "MainPage.vue"),
271
+ await B(
272
+ g.join(a, "ui", "src", "pages", "MainPage.vue"),
256
273
  new RegExp(`.*${r}Message.*\\n\\n`, "g")
257
- ), await C(
258
- o.join(a, "model", "src", "index.ts"),
274
+ ), await B(
275
+ g.join(a, "model", "src", "index.ts"),
259
276
  new RegExp(`.*${r}Message.*\\n\\n`, "g")
260
- ), await C(
261
- o.join(a, "workflow", "src", "main.tpl.tengo"),
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 C(
264
- o.join(a, "workflow", "src", "main.tpl.tengo"),
280
+ ), await B(
281
+ g.join(a, "workflow", "src", "main.tpl.tengo"),
265
282
  new RegExp(`.*${r}Message.*\\n`, "g")
266
- ), await C(
267
- o.join(a, "workflow", "src", "wf.test.ts"),
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 T.rm(o.join(a, "software", `src_${r}`), { recursive: !0 }), await be(
270
- o.join(a, "software", "package.json"),
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 i = JSON.parse(t);
273
- return delete i["block-software"].artifacts[`hello-${r}-artifact`], delete i["block-software"].entrypoints[`hello-world-${r}`], JSON.stringify(i, null, 2);
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 Or(a) {
278
- await T.rm(o.join(a, "software"), { recursive: !0 }), await be(
279
- o.join(a, "workflow", "package.json"),
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 C(
285
- o.join(a, "pnpm-workspace.yaml"),
301
+ ), await B(
302
+ g.join(a, "pnpm-workspace.yaml"),
286
303
  /.*- software$\n/gm
287
304
  );
288
305
  }
289
- async function Tr(a, e) {
290
- const r = await Er(a);
291
- for (const { from: t, to: i } of e)
292
- for (const s of r)
293
- await Qe(s, t, i);
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 Er(a) {
296
- return (await T.readdir(a, {
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) => o.join(r.parentPath, r.name));
316
+ })).filter((r) => r.isFile()).map((r) => g.join(r.parentPath, r.name));
300
317
  }
301
- async function be(a, e) {
302
- const r = await T.readFile(a), t = e(r.toString());
303
- await T.writeFile(a, t);
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 Qe(a, e, r) {
306
- return await be(a, (t) => t.replaceAll(e, r));
322
+ async function er(a, e, r) {
323
+ return await ve(a, (t) => t.replaceAll(e, r));
307
324
  }
308
- async function C(a, e) {
309
- return await Qe(a, e, "");
325
+ async function B(a, e) {
326
+ return await er(a, e, "");
310
327
  }
311
- const B = class B extends E {
328
+ const G = class G extends F {
312
329
  async run() {
313
- const { flags: e } = await this.parse(B), r = F(e["log-level"]);
314
- await Rr(r);
330
+ const { flags: e } = await this.parse(G), r = N(e["log-level"]);
331
+ await Or(r);
315
332
  }
316
333
  };
317
- h(B, "description", "Helps to create a new block by downloading a block's template."), h(B, "examples", ["<%= name %>"]), h(B, "flags", {
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 ne = B;
321
- function Xe(...a) {
322
- return nr(__dirname, "..", ...a);
337
+ let le = G;
338
+ function rr(...a) {
339
+ return dr(__dirname, "..", ...a);
323
340
  }
324
- function $(...a) {
325
- return Xe("assets", ...a);
341
+ function O(...a) {
342
+ return rr("assets", ...a);
326
343
  }
327
- function Dr() {
328
- return d.readdirSync($()).filter((e) => e.startsWith("compose-") && e.endsWith(".yaml")).map((e) => $(e));
344
+ function xr() {
345
+ return o.readdirSync(O()).filter((e) => e.startsWith("compose-") && e.endsWith(".yaml")).map((e) => O(e));
329
346
  }
330
- function Fr(...a) {
331
- return d.readFileSync(Xe(...a));
347
+ function Mr(...a) {
348
+ return o.readFileSync(rr(...a));
332
349
  }
333
- function se(a) {
334
- return a || (a = Z()), `quay.io/milaboratories/platforma:${a}`;
350
+ function ne(a) {
351
+ return a || (a = ee()), `quay.io/milaboratories/platforma:${a}`;
335
352
  }
336
- const N = class N {
353
+ const I = class I {
337
354
  constructor(e) {
338
- h(this, "state", {
355
+ P(this, "state", {
339
356
  lastRun: void 0,
340
357
  isActive: !1
341
358
  });
342
- h(this, "filePath");
343
- h(this, "dirPath");
344
- e = e ?? o.resolve(L.homedir(), ".config", "pl-bootstrap");
345
- const r = o.join(e, "state.json");
346
- this.dirPath = e, this.filePath = r, d.existsSync(e) || d.mkdirSync(e, { recursive: !0 }), d.existsSync(r) && (this.state = JSON.parse(Fr(r).toString()));
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 N.instance || (N.instance = new N()), N.instance;
366
+ return I.instance || (I.instance = new I()), I.instance;
350
367
  }
351
368
  path(...e) {
352
- return o.join(this.dirPath, ...e);
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
- d.writeFileSync(this.filePath, JSON.stringify(this.state));
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 = Sr(this.state.lastRun.process.pid);
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
- h(N, "instance");
385
- let le = N;
386
- const l = le.getInstance();
401
+ P(I, "instance");
402
+ let oe = I;
403
+ const d = oe.getInstance();
387
404
  function Ue(a, e, r, t) {
388
- var i;
389
- return l.lastRun = {
390
- ...l.lastRun,
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
- ...(i = l.lastRun) == null ? void 0 : i.docker,
414
+ ...(s = d.lastRun) == null ? void 0 : s.docker,
398
415
  ...t
399
416
  }
400
- }, Ze(a, "docker", e, r);
417
+ }, tr(a, "docker", e, r);
401
418
  }
402
- function Nr(a, e, r, t, i) {
403
- var c;
404
- l.lastRun = {
405
- ...l.lastRun,
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
- ...(c = l.lastRun) == null ? void 0 : c.process,
413
- ...i
429
+ ...(n = d.lastRun) == null ? void 0 : n.process,
430
+ ...s
414
431
  }
415
432
  };
416
- const s = xr(a, e, r, t);
417
- return l.lastRun.process = {
418
- ...l.lastRun.process,
419
- pid: s.pid
420
- }, s;
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 Ir(a, e) {
423
- if (!l.lastRun)
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: l.lastRun.workdir,
443
+ cwd: d.lastRun.workdir,
427
444
  env: {
428
- ...l.lastRun.envs,
445
+ ...d.lastRun.envs,
429
446
  ...e.env
430
447
  },
431
448
  ...e
432
- }, Ze(a, l.lastRun.cmd, l.lastRun.args, e);
449
+ }, tr(a, d.lastRun.cmd, d.lastRun.args, e);
433
450
  }
434
- function xr(a, e, r, t) {
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 i = lr(e, r, t);
442
- var s = !1;
443
- const c = () => {
444
- i.kill("SIGINT"), s = !0;
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", c), i.on("close", (n) => {
447
- process.removeListener("SIGINT", c), s && process.exit(n);
448
- }), i;
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 Ze(a, e, r, t) {
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 Mr(a) {
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 er(a) {
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 x(a, e, r) {
485
- a = kr(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 c = t.hostname, i = t.searchParams.get("region");
541
+ var n = t.hostname, s = t.searchParams.get("region");
490
542
  return {
491
543
  ...r,
492
544
  type: "S3",
493
- bucketName: c,
494
- region: i
545
+ bucketName: n,
546
+ region: s
495
547
  };
496
548
  case "s3e:":
497
- var s = t.pathname.split("/").slice(1), c = s[0], n = s.length > 1 ? s[1] : "";
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: c,
503
- keyPrefix: n,
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 s = t.pathname.split("/").slice(1), c = s[0], n = s.length > 1 ? s[1] : "";
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: c,
515
- keyPrefix: n,
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 Cr(a, e) {
530
- var g, b, v, S, p, k, _, Y, A, we, ve, ke, Se, Ae, pe, Re, Le, _e, $e, Oe, Te, Ee, De, Fe, Ne, Ie, xe, Me, Ce, Be;
531
- const r = (e == null ? void 0 : e.localRoot) ?? l.data("local-custom"), t = {
532
- level: ((g = e == null ? void 0 : e.log) == null ? void 0 : g.level) ?? "info",
533
- path: ((b = e == null ? void 0 : e.log) == null ? void 0 : b.path) ?? `${r}/logs/platforma.log`
534
- }, i = {
535
- listen: ((v = e == null ? void 0 : e.grpc) == null ? void 0 : v.listen) ?? "localhost:6345",
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((p = (S = e == null ? void 0 : e.grpc) == null ? void 0 : S.tls) == null ? void 0 : p.enable, !1),
538
- clientAuthMode: ((_ = (k = e == null ? void 0 : e.grpc) == null ? void 0 : k.tls) == null ? void 0 : _.clientAuthMode) ?? "NoAuth",
539
- certFile: ((A = (Y = e == null ? void 0 : e.grpc) == null ? void 0 : Y.tls) == null ? void 0 : A.certFile) ?? `${r}/certs/tls.cert`,
540
- keyFile: ((ve = (we = e == null ? void 0 : e.grpc) == null ? void 0 : we.tls) == null ? void 0 : ve.keyFile) ?? `${r}/certs/tls.key`,
541
- ...(ke = e == null ? void 0 : e.grpc) == null ? void 0 : ke.tls
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
- }, s = {
595
+ }, i = {
544
596
  auth: {
545
- enabled: ((Ae = (Se = e == null ? void 0 : e.core) == null ? void 0 : Se.auth) == null ? void 0 : Ae.enabled) ?? !1,
546
- drivers: ((Re = (pe = e == null ? void 0 : e.core) == null ? void 0 : pe.auth) == null ? void 0 : Re.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
- }, c = We(
606
+ }, n = Je(
555
607
  "main",
556
608
  `${r}/storages/main`,
557
609
  "main-bucket",
558
- (Le = e == null ? void 0 : e.storages) == null ? void 0 : Le.primary
610
+ ($e = e == null ? void 0 : e.storages) == null ? void 0 : $e.primary
559
611
  );
560
- var n;
561
- switch (($e = (_e = e == null ? void 0 : e.storages) == null ? void 0 : _e.work) == null ? void 0 : $e.type) {
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
- n = er("work"), n.rootPath = ((Te = (Oe = e == null ? void 0 : e.storages) == null ? void 0 : Oe.work) == null ? void 0 : Te.rootPath) ?? `${r}/storages/work`, n.indexCachePeriod = ((De = (Ee = e == null ? void 0 : e.storages) == null ? void 0 : Ee.work) == null ? void 0 : De.indexCachePeriod) ?? "1m";
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 m = We(
621
+ const f = Je(
570
622
  "library",
571
623
  `${r}/storages/library`,
572
624
  "library-bucket",
573
- (Fe = e == null ? void 0 : e.storages) == null ? void 0 : Fe.library
574
- ), f = {
575
- enabled: V((Ne = e == null ? void 0 : e.monitoring) == null ? void 0 : Ne.enabled, !0),
576
- listen: ((Ie = e == null ? void 0 : e.monitoring) == null ? void 0 : Ie.listen) ?? "127.0.0.1:9090"
577
- }, w = {
578
- enabled: V((xe = e == null ? void 0 : e.debug) == null ? void 0 : xe.enabled, !0),
579
- listen: ((Me = e == null ? void 0 : e.debug) == null ? void 0 : Me.listen) ?? "127.0.0.1:9091"
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) ?? ""
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: P,
638
+ license: v,
587
639
  log: t,
588
- grpc: i,
589
- core: s,
590
- monitoring: f,
591
- debug: w,
592
- storages: { primary: c, work: n, library: m },
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 We(a, e, r, t) {
597
- var i;
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
- i = er(a), i.rootPath = (t == null ? void 0 : t.rootPath) ?? e;
653
+ s = ar(a), s.rootPath = (t == null ? void 0 : t.rootPath) ?? e;
602
654
  break;
603
655
  case "S3":
604
- i = Mr(a), i.endpoint = (t == null ? void 0 : t.endpoint) ?? "http://localhost:9000", i.presignEndpoint = (t == null ? void 0 : t.presignEndpoint) ?? "http://localhost:9000", i.bucketName = (t == null ? void 0 : t.bucketName) ?? r, i.createBucket = V(t == null ? void 0 : t.createBucket, !0), i.forcePathStyle = V(t == null ? void 0 : t.forcePathStyle, !0), i.key = (t == null ? void 0 : t.key) ?? "", i.secret = (t == null ? void 0 : t.secret) ?? "", i.keyPrefix = (t == null ? void 0 : t.keyPrefix) ?? "", i.accessPrefixes = (t == null ? void 0 : t.accessPrefixes) ?? [""], i.uploadKeyPrefix = (t == null ? void 0 : t.uploadKeyPrefix) ?? "";
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 i;
661
+ return s;
610
662
  }
611
- function Br(a) {
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 i = a.license.value;
614
- return a.license.file != "" && (i = d.readFileSync(a.license.file).toString().trimEnd()), `
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(i)}
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 Gr = ["linux", "macos", "windows"];
694
- function jr(a) {
695
- const e = L.platform();
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(Gr)
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 Ur = ["amd64", "arm64"];
710
- function rr(a) {
711
- const e = L.arch();
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(Ur)
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 Wr(a, e) {
724
- const r = (e == null ? void 0 : e.version) ?? Z(), t = (e == null ? void 0 : e.showProgress) ?? process.stdout.isTTY, i = `pl-${r}-${rr()}.tgz`, s = (e == null ? void 0 : e.downloadURL) ?? `https://cdn.platforma.bio/software/pl/${jr()}/${i}`, c = (e == null ? void 0 : e.saveTo) ?? l.binaries(i);
725
- if (d.existsSync(c))
726
- return a.info(`Platforma Backend archive download skipped: '${c}' already exists`), Promise.resolve(c);
727
- d.mkdirSync(o.dirname(c), { recursive: !0 }), a.info(`Downloading Platforma Backend archive:
728
- URL: ${s}
729
- Save to: ${c}`);
730
- const n = ur.get(s);
731
- return new Promise((u, m) => {
732
- n.on("response", (f) => {
733
- if (!f.statusCode) {
734
- const b = new Error("failed to download archive: no HTTP status code in response from server");
735
- n.destroy(), m(b);
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 (f.statusCode !== 200) {
739
- const b = new Error(`failed to download archive: ${f.statusCode} ${f.statusMessage}`);
740
- n.destroy(), m(b);
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 w = parseInt(f.headers["content-length"] || "0", 10);
744
- let P = 0;
745
- const g = d.createWriteStream(c);
746
- f.pipe(g), f.on("data", (b) => {
747
- P += b.length;
748
- const v = P / w * 100;
749
- t && process.stdout.write(` downloading: ${v.toFixed(2)}%\r`);
750
- }), f.on("error", (b) => {
751
- d.unlinkSync(c), a.error(`Failed to download Platforma Binary: ${b.message}`), n.destroy(), m(b);
752
- }), g.on("finish", () => {
753
- g.close(), a.info(" ... download done."), n.destroy(), u(c);
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 Jr(a, e) {
810
+ function Kr(a, e) {
759
811
  a.debug("extracting archive...");
760
- const r = (e == null ? void 0 : e.version) ?? Z();
812
+ const r = (e == null ? void 0 : e.version) ?? ee();
761
813
  a.debug(` version: '${r}'`);
762
- const t = `${ar({ version: r })}.tgz`, i = (e == null ? void 0 : e.archivePath) ?? l.binaries(t);
763
- a.debug(` archive path: '${i}'`);
764
- const s = (e == null ? void 0 : e.extractTo) ?? Yr(i);
765
- if (a.debug(` target dir: '${s}'`), d.existsSync(s))
766
- return a.info(`Platforma Backend binaries unpack skipped: '${s}' exists`), s;
767
- if (!d.existsSync(i)) {
768
- const c = `Platforma Backend binary archive not found at '${i}'`;
769
- throw a.error(c), new Error(c);
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 d.existsSync(s) || (a.debug(` creating target dir '${s}'`), d.mkdirSync(s, { recursive: !0 })), a.info(`Unpacking Platforma Backend archive:
772
- Archive: ${i}
773
- Target dir: ${s}`), fr.x({
774
- file: i,
775
- cwd: s,
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."), s;
830
+ }), a.info(" ... unpack done."), i;
779
831
  }
780
- function tr(a, e) {
781
- return Wr(a, e).then((r) => Jr(a, { archivePath: r }));
832
+ function ir(a, e) {
833
+ return zr(a, e).then((r) => Kr(a, { archivePath: r }));
782
834
  }
783
- function ar(a) {
784
- return `pl-${(a == null ? void 0 : a.version) ?? Z()}-${rr()}`;
835
+ function nr(a) {
836
+ return `pl-${(a == null ? void 0 : a.version) ?? ee()}-${sr()}`;
785
837
  }
786
- function Hr(a, ...e) {
787
- return l.binaries(ar({ version: a }), ...e);
838
+ function qr(a, ...e) {
839
+ return d.binaries(nr({ version: a }), ...e);
788
840
  }
789
- function Yr(a) {
841
+ function Vr(a) {
790
842
  const e = a.lastIndexOf(".");
791
843
  return e === -1 ? a : a.slice(0, e);
792
844
  }
793
- class I {
845
+ class x {
794
846
  constructor(e) {
795
847
  this.logger = e;
796
848
  }
797
849
  startLast() {
798
- const e = Ir(this.logger, { stdio: "inherit" });
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 u, m, f, w, P, g, b, v, S, p;
803
- const r = (e == null ? void 0 : e.binaryPath) ?? Hr(e == null ? void 0 : e.version, "binaries", "platforma");
804
- var t = e == null ? void 0 : e.configPath;
805
- const i = (e == null ? void 0 : e.workdir) ?? (t ? process.cwd() : l.path());
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
- ...(u = e.configOptions) == null ? void 0 : u.storages,
810
- primary: x(e.primaryURL, i, (f = (m = e.configOptions) == null ? void 0 : m.storages) == null ? void 0 : f.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
- ...(w = e.configOptions) == null ? void 0 : w.storages,
816
- library: x(e.libraryURL, i, (g = (P = e.configOptions) == null ? void 0 : P.storages) == null ? void 0 : g.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 s = Cr(this.getLastJwt(), e == null ? void 0 : e.configOptions);
820
- this.logger.debug(" checking license..."), this.checkLicense((v = (b = e == null ? void 0 : e.configOptions) == null ? void 0 : b.license) == null ? void 0 : v.value, (p = (S = e == null ? void 0 : e.configOptions) == null ? void 0 : S.license) == null ? void 0 : p.file);
821
- const c = [
822
- `${s.localRoot}/packages`,
823
- `${s.localRoot}/packages-local`,
824
- `${s.localRoot}/blocks-local`
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
- s.storages.primary.type === "FS" && c.push(s.storages.primary.rootPath), s.storages.library.type === "FS" && (c.push(s.storages.library.rootPath), s.hacks.libraryDownloadable = !1), s.storages.work.type === "FS" && c.push(s.storages.work.rootPath), this.logger.debug(" creating pl state directories...");
827
- for (const k of c)
828
- d.existsSync(k) || (this.logger.debug(` '${k}'`), d.mkdirSync(k, { recursive: !0 }));
829
- for (const k of s.core.auth.drivers)
830
- k.driver === "htpasswd" && (d.existsSync(k.path) || (this.logger.debug(` installing default 'users.htpasswd' to ${k.path}...`), d.copyFileSync($("users.htpasswd"), k.path)));
831
- t || (t = o.join(s.localRoot, "config.yaml"), this.logger.debug(` rendering configuration '${t}'...`), d.writeFileSync(t, Br(s)));
832
- const n = this.renderRunInfo({
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: s.core.db.path,
835
- apiAddr: s.grpc.listen,
836
- logPath: s.log.path,
837
- primary: s.storages.primary,
838
- work: s.storages.work,
839
- library: s.storages.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
- ${n}`), Nr(
894
+ ${c}`), Cr(
843
895
  this.logger,
844
896
  r,
845
897
  ["-config", t],
846
898
  {
847
- cwd: i,
899
+ cwd: s,
848
900
  stdio: "inherit"
849
901
  },
850
902
  {
851
- storagePath: s.localRoot
903
+ storagePath: i.localRoot
852
904
  }
853
905
  );
854
906
  }
855
907
  startLocalS3(e) {
856
- var i;
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 = (i = e == null ? void 0 : e.configOptions) == null ? void 0 : i.localRoot;
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 ? o.join(t, "minio") : void 0
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
- var r = $("compose-backend.yaml");
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 i = (e == null ? void 0 : e.image) ?? `quay.io/minio/minio${t}`;
875
- this.logger.debug(` minio image: ${i}`);
876
- const s = (e == null ? void 0 : e.storage) ?? l.data("minio");
877
- X(s, { mode: "0775" });
878
- const c = l.data("stub");
879
- X(c);
880
- const n = (e == null ? void 0 : e.minioPort) ?? 9e3, u = (e == null ? void 0 : e.minioConsolePort) ?? 9001, m = {
881
- MINIO_IMAGE: i,
882
- MINIO_STORAGE: o.resolve(s),
883
- MINIO_PORT: n.toString(),
884
- MINIO_CONSOLE_PORT: u.toString(),
885
- PL_DATA_DB_ROOT: c,
886
- PL_DATA_PRIMARY_ROOT: c,
887
- PL_DATA_LIBRARY_ROOT: c,
888
- PL_DATA_WORKDIR_ROOT: c,
889
- PL_DATA_PACKAGE_ROOT: c,
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 f = K(
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
- ...m
950
+ ...f
900
951
  },
901
952
  stdio: "inherit"
902
953
  }
903
954
  );
904
- z(f, "failed to start MinIO service in docker");
955
+ z(u, "failed to start MinIO service in docker");
905
956
  }
906
957
  buildPlatforma(e) {
907
- const r = o.resolve(e.repoRoot, "cmd", "platforma"), t = e.binPath ?? o.join(L.tmpdir(), "platforma-local-build");
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 i = K("go", ["build", "-o", t, "."], {
960
+ const s = K("go", ["build", "-o", t, "."], {
910
961
  cwd: r,
911
962
  stdio: "inherit"
912
963
  });
913
- return z(i, "failed to build platforma binary from sources using 'go build' command"), t;
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 = $("compose-backend.yaml"), i = (r == null ? void 0 : r.image) ?? se(r == null ? void 0 : r.version);
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 s = (...S) => o.join(e, ...S), c = (S) => {
919
- const p = s(S);
920
- return X(p, { mode: "0775" }), p;
921
- }, n = s("logs", "platforma.log");
922
- d.existsSync(n) || (d.mkdirSync(o.dirname(n), { recursive: !0 }), d.writeFileSync(n, ""));
923
- const u = x("s3e://testuser:testpassword@minio:9000/main-bucket");
924
- if (u.type !== "S3")
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
- u.presignEndpoint = "http://localhost:9000";
927
- const m = x("s3e://testuser:testpassword@minio:9000/library-bucket");
928
- if (m.type !== "S3")
929
- throw new Error(`${m.type} storage type is not supported for library storage`);
930
- m.presignEndpoint = "http://localhost:9000";
931
- const f = c("db"), w = c("work"), P = s("users.htpasswd");
932
- d.existsSync(P) || d.copyFileSync($("users.htpasswd"), P);
933
- const g = {
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: c("minio"),
936
- PL_IMAGE: i,
937
- PL_AUTH_HTPASSWD_PATH: P,
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: o.dirname(n),
1007
+ PL_LOG_DIR: g.dirname(c),
942
1008
  PL_LOG_ROTATION_ENABLED: "true",
943
- PL_DATA_DB_ROOT: f,
944
- PL_DATA_PRIMARY_ROOT: c("primary"),
945
- PL_DATA_LIBRARY_ROOT: c("library"),
946
- PL_DATA_WORKDIR_ROOT: w,
947
- PL_DATA_PACKAGE_ROOT: c("packages"),
948
- ...this.configureDockerStorage("primary", u),
949
- ...this.configureDockerStorage("library", m)
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 && (g.PL_GRPC_ADDR = r.grpcAddr), r != null && r.grpcPort && (g.PL_GRPC_PORT = r.grpcPort.toString()), r != null && r.monitoringAddr && (g.PL_MONITORING_ADDR = r.monitoringAddr), r != null && r.monitoringPort && (g.PL_MONITORING_PORT = r.monitoringPort.toString()), r != null && r.debugAddr && (g.PL_DEBUG_ADDR = r.debugAddr), r != null && r.debugPort && (g.PL_DEBUG_PORT = r.debugPort.toString()), r != null && r.auth && (r.auth.enabled && (g.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
952
- for (const S of r.auth.drivers)
953
- S.driver === "htpasswd" && (g.PL_AUTH_HTPASSWD_PATH = o.resolve(S.path), S.path = "/etc/platforma/users.htpasswd");
954
- g.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
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 b = Ue(
1022
+ const k = Ue(
957
1023
  this.logger,
958
1024
  [
959
1025
  "compose",
960
- `--file=${t}`,
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: g,
1035
+ env: w,
970
1036
  stdio: "inherit"
971
1037
  },
972
1038
  {
973
- plImage: i,
974
- composePath: t
1039
+ plImage: s,
1040
+ composePath: y
975
1041
  }
976
1042
  );
977
- z(b, "failed to start Platforma Backend in Docker"), l.isActive = !0;
978
- const v = this.renderRunInfo({
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: n,
982
- primary: u,
983
- work: { type: "FS", rootPath: w },
984
- library: m,
985
- dbPath: f
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
- ${v}`);
1054
+ ${R}`);
989
1055
  }
990
1056
  startDocker(e, r) {
991
- var t = $("compose-backend.yaml");
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 s = (...k) => o.join(e, ...k), c = (k) => {
995
- const _ = s(k);
996
- return X(_, { mode: "0775" }), _;
997
- }, n = s("logs", "platforma.log");
998
- d.existsSync(n) || (d.mkdirSync(o.dirname(n), { recursive: !0 }), d.writeFileSync(n, ""));
999
- const u = c("db"), m = c("primary"), f = c("library"), w = c("work"), P = s("users.htpasswd");
1000
- d.existsSync(P) || d.copyFileSync($("users.htpasswd"), P);
1001
- const g = x((r == null ? void 0 : r.primaryStorageURL) ?? `file:${m}`, "."), b = x((r == null ? void 0 : r.libraryStorageURL) ?? `file:${f}`, "."), v = {
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: c("minio"),
1004
- PL_IMAGE: i,
1005
- PL_AUTH_HTPASSWD_PATH: P,
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: o.dirname(n),
1088
+ PL_LOG_DIR: g.dirname(c),
1010
1089
  PL_LOG_ROTATION_ENABLED: "true",
1011
- PL_DATA_DB_ROOT: u,
1012
- PL_DATA_PRIMARY_ROOT: m,
1013
- PL_DATA_LIBRARY_ROOT: f,
1014
- PL_DATA_WORKDIR_ROOT: w,
1015
- PL_DATA_PACKAGE_ROOT: c("packages"),
1016
- ...this.configureDockerStorage("primary", g),
1017
- ...this.configureDockerStorage("library", b)
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 && (v.PL_GRPC_ADDR = r.grpcAddr), r != null && r.grpcPort && (v.PL_GRPC_PORT = r.grpcPort.toString()), r != null && r.monitoringAddr && (v.PL_MONITORING_ADDR = r.monitoringAddr), r != null && r.monitoringPort && (v.PL_MONITORING_PORT = r.monitoringPort.toString()), r != null && r.debugAddr && (v.PL_DEBUG_ADDR = r.debugAddr), r != null && r.debugPort && (v.PL_DEBUG_PORT = r.debugPort.toString()), r != null && r.auth && (r.auth.enabled && (v.PL_AUTH_ENABLED = "true"), r.auth.drivers)) {
1020
- for (const k of r.auth.drivers)
1021
- k.driver === "htpasswd" && (v.PL_AUTH_HTPASSWD_PATH = o.resolve(k.path), k.path = "/etc/platforma/users.htpasswd");
1022
- v.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
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 S = Ue(
1103
+ const R = Ue(
1025
1104
  this.logger,
1026
- ["compose", `--file=${t}`, "up", "--detach", "--remove-orphans", "--pull=missing", "backend"],
1105
+ ["compose", `--file=${m}`, "up", "--detach", "--remove-orphans", "--pull=missing"],
1027
1106
  {
1028
- env: v,
1107
+ env: k,
1029
1108
  stdio: "inherit"
1030
1109
  },
1031
1110
  {
1032
- plImage: i,
1033
- composePath: t,
1034
- primaryPath: m,
1035
- workPath: w,
1036
- libraryPath: f
1111
+ plImage: s,
1112
+ composePath: m,
1113
+ primaryPath: f,
1114
+ workPath: b,
1115
+ libraryPath: u
1037
1116
  }
1038
1117
  );
1039
- z(S, "failed to start Platforma Backend in Docker"), l.isActive = !0;
1040
- const p = this.renderRunInfo({
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: n,
1044
- primary: g,
1045
- work: { type: "FS", rootPath: w },
1046
- library: b,
1047
- dbPath: u
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
- ${p}`);
1129
+ ${A}`);
1051
1130
  }
1052
1131
  stop() {
1053
- if (!l.isActive) {
1132
+ if (!d.isActive) {
1054
1133
  console.log("no running service detected");
1055
1134
  return;
1056
1135
  }
1057
- const e = l.lastRun;
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
- l.isActive = !1, r.status !== 0 && process.exit(r.status);
1146
+ d.isActive = !1, r.status !== 0 && process.exit(r.status);
1068
1147
  return;
1069
- case "process":
1070
- l.isValidPID && process.kill(e.process.pid), l.isActive = !1;
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 n, u, m, f, w, P, g, b, v, S, p, k, _, Y;
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 = l.data(), t = [r];
1082
- if ((u = (n = l.lastRun) == null ? void 0 : n.docker) != null && u.primaryPath) {
1083
- const A = (f = (m = l.lastRun) == null ? void 0 : m.docker) == null ? void 0 : f.primaryPath;
1084
- A.startsWith(r) || t.push(A);
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 ((P = (w = l.lastRun) == null ? void 0 : w.docker) != null && P.workPath) {
1087
- const A = (b = (g = l.lastRun) == null ? void 0 : g.docker) == null ? void 0 : b.workPath;
1088
- A.startsWith(r) || t.push(A);
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 ((S = (v = l.lastRun) == null ? void 0 : v.process) != null && S.storagePath) {
1091
- const A = (k = (p = l.lastRun) == null ? void 0 : p.process) == null ? void 0 : k.storagePath;
1092
- A.startsWith(r) || t.push(A);
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 i = t.length > 0 ? ` - storages (you'll loose all projects and calculation results stored in service instances):
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
- ${i}
1182
+ ${s}
1103
1183
  `;
1104
- if (this.logger.warn(s), !wr("Are you sure?")) {
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 c = new Set(Dr());
1109
- (Y = (_ = l.lastRun) == null ? void 0 : _.docker) != null && Y.composePath && c.add(l.lastRun.docker.composePath);
1110
- for (const A of c)
1111
- this.logger.info(`Destroying docker compose '${A}'`), this.destroyDocker(A, se());
1112
- for (const A of t)
1113
- this.logger.info(`Destroying '${A}'`), d.rmSync(A, { recursive: !0, force: !0 });
1114
- this.logger.info(`Destroying state dir '${l.path()}'`), d.rmSync(l.path(), { recursive: !0, force: !0 }), this.logger.info(
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 '${l.binaries()}' dir manually
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 : d.existsSync(o.resolve(L.homedir(), ".pl.license")) && (e["license-file"] = o.resolve(L.homedir(), ".pl.license")));
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
- var t = [];
1204
+ const t = [];
1125
1205
  if (e["auth-htpasswd-file"] && t.push({
1126
1206
  driver: "htpasswd",
1127
- path: o.resolve(r, e["auth-htpasswd-file"])
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 = l.path("auth.jwt"), r = "utf-8";
1219
+ const e = d.path("auth.jwt"), r = "utf-8";
1140
1220
  let t = "";
1141
- try {
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 = l.data("stub"), i = K("docker", ["compose", "--file", e, "down", "--volumes", "--remove-orphans"], {
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
- i.status !== 0 && process.exit(i.status);
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 = {}, i = r.type;
1180
- switch (e = e.toUpperCase(), i) {
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 n, u;
1192
- const t = [], i = (m) => m.padStart(r, " ");
1193
- switch (e.configPath && t.push(`${i("config")}: ${e.configPath}`), e.apiAddr ? t.push(`${i("API")}: ${e.apiAddr}`) : e.apiPort ? t.push(`${i("API")}: 127.0.0.1:${e.apiPort.toString()}`) : t.push(`${i("API")}: 127.0.0.1:6345`), e.logPath && t.push(`${i("log")}: ${e.logPath}`), (n = e.primary) == null ? void 0 : n.type) {
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(`${i("primary")}: ${e.primary.rootPath}`);
1273
+ t.push(`${s("primary")}: ${e.primary.rootPath}`);
1198
1274
  break;
1199
1275
  case "S3":
1200
1276
  t.push(
1201
- `${i("primary")}: S3 at '${e.primary.endpoint ?? "AWS"}', bucket '${e.primary.bucketName}', prefix: '${e.primary.keyPrefix ?? ""}'`
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 ((u = e.library) == null ? void 0 : u.type) {
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(`${i("library")}: ${e.library.rootPath}`);
1287
+ t.push(`${s("library")}: ${e.library.rootPath}`);
1212
1288
  break;
1213
1289
  case "S3":
1214
1290
  t.push(
1215
- `${i("library")}: S3 at '${e.library.endpoint ?? "AWS"}', bucket '${e.library.bucketName}', prefix: '${e.library.keyPrefix ?? ""}'`
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(`${i("workdirs")}: ${e.work.rootPath}`), e.dbPath && t.push(`${i("db")}: ${e.dbPath}`), t.join(`
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 = d.readFileSync(e);
1226
- return je.parse(r.toString());
1302
+ const r = o.readFileSync(e);
1303
+ return Z.parse(r.toString());
1227
1304
  }
1228
1305
  writeComposeFile(e, r) {
1229
- d.writeFileSync(e, je.stringify(r));
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 G = class G extends E {
1316
+ const j = class j extends F {
1240
1317
  async run() {
1241
- const { flags: e } = await this.parse(G), r = F(e["log-level"]);
1242
- new I(r).cleanup();
1318
+ const { flags: e } = await this.parse(j), r = N(e["log-level"]);
1319
+ new x(r).cleanup();
1243
1320
  }
1244
1321
  };
1245
- h(G, "description", "Clear service state (forget last run command, destroy docker services, volumes and so on)"), h(G, "examples", ["<%= config.bin %> <%= command.id %>"]), h(G, "flags", {
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 oe = G;
1249
- const j = class j extends E {
1325
+ let de = j;
1326
+ const U = class U extends F {
1250
1327
  async run() {
1251
- const { flags: e } = await this.parse(j), r = F(e["log-level"]);
1252
- new I(r).startLast();
1328
+ const { flags: e } = await this.parse(U), r = N(e["log-level"]);
1329
+ new x(r).startLast();
1253
1330
  }
1254
1331
  };
1255
- h(j, "description", "Start last run service configuraiton"), h(j, "examples", ["<%= config.bin %> <%= command.id %>"]), h(j, "flags", {
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 de = j;
1259
- const U = class U extends E {
1335
+ let ge = U;
1336
+ const W = class W extends F {
1260
1337
  async run() {
1261
- const { flags: e } = await this.parse(U), r = F(e["log-level"]);
1262
- new I(r).stop();
1338
+ const { flags: e } = await this.parse(W), r = N(e["log-level"]);
1339
+ new x(r).stop();
1263
1340
  }
1264
1341
  };
1265
- h(U, "description", "Stop platforma service"), h(U, "examples", ["<%= config.bin %> <%= command.id %>"]), h(U, "flags", {
1342
+ P(W, "description", "Stop platforma service"), P(W, "examples", ["<%= config.bin %> <%= command.id %>"]), P(W, "flags", {
1266
1343
  ...D
1267
1344
  });
1268
- let ge = U;
1269
- const W = class W extends E {
1345
+ let ue = W;
1346
+ const J = class J extends F {
1270
1347
  async run() {
1271
- const { flags: e } = await this.parse(W), r = F(e["log-level"]), t = new I(r);
1348
+ const { flags: e } = await this.parse(J), r = N(e["log-level"]), t = new x(r);
1272
1349
  t.mergeLicenseEnvs(e);
1273
- const i = e["auth-enabled"], s = i ? {
1274
- enabled: i,
1350
+ const s = e["auth-enabled"], i = s ? {
1351
+ enabled: s,
1275
1352
  drivers: t.initAuthDriversList(e, ".")
1276
- } : void 0, c = e.storage ? o.join(".", e.storage) : l.data("docker");
1277
- t.startDocker(c, {
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: s,
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
- h(W, "description", "Run platforma backend service with 'FS' primary storage type"), h(W, "examples", ["<%= config.bin %> <%= command.id %>"]), h(W, "flags", {
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
- ...he,
1305
- ...Pe
1389
+ ...be
1306
1390
  });
1307
- let ue = W;
1308
- const J = class J extends E {
1391
+ let fe = J;
1392
+ const H = class H extends F {
1309
1393
  async run() {
1310
- const { flags: e } = await this.parse(J), r = F(e["log-level"]), t = new I(r);
1394
+ const { flags: e } = await this.parse(H), r = N(e["log-level"]), t = new x(r);
1311
1395
  t.mergeLicenseEnvs(e);
1312
- const i = e["pl-workdir"] ?? ".", s = e.storage ? o.join(i, e.storage) : l.data("local"), c = e["pl-log-file"] ? o.join(i, e["pl-log-file"]) : void 0, n = t.initAuthDriversList(e, i), u = e["auth-enabled"] ?? n !== void 0;
1313
- var m = e["pl-binary"];
1314
- e["pl-sources"] && (m = t.buildPlatforma({ repoRoot: e["pl-sources"] }));
1315
- var f = "127.0.0.1:6345";
1316
- e["grpc-listen"] ? f = e["grpc-listen"] : e["grpc-port"] && (f = `127.0.0.1:${e["grpc-port"]}`);
1317
- var w = "127.0.0.1:9090";
1318
- e["monitoring-listen"] ? w = e["monitoring-listen"] : e["monitoring-port"] && (w = `127.0.0.1:${e["monitoring-port"]}`);
1319
- var P = "127.0.0.1:9091";
1320
- e["debug-listen"] ? P = e["debug-listen"] : e["debug-port"] && (P = `127.0.0.1:${e["debug-port"]}`);
1321
- const g = {
1322
- binaryPath: m,
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: f },
1330
- monitoring: { listen: w },
1331
- debug: { listen: P },
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: c },
1334
- localRoot: s,
1335
- core: { auth: { enabled: u, drivers: n } },
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
- g.binaryPath ? t.startLocal(g) : tr(r, { version: e.version }).then(() => t.startLocal(g)).catch(function(b) {
1342
- r.error(b.message);
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
- h(J, "description", "Run Platforma Backend service as local process on current host (no docker container)"), h(J, "examples", ["<%= config.bin %> <%= command.id %>"]), h(J, "flags", {
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
- ...ye,
1356
- ...he,
1434
+ ...Ve,
1435
+ ...Qe,
1436
+ ...Xe,
1437
+ ...te,
1438
+ ...se,
1357
1439
  ...Pe,
1358
- ...He,
1359
- ...Ye,
1440
+ ...ye,
1441
+ ...be,
1442
+ ...Ke,
1443
+ ...qe,
1360
1444
  ...ie
1361
1445
  });
1362
- let fe = J;
1363
- var R;
1364
- let zr = (R = class extends E {
1446
+ let me = H;
1447
+ var $;
1448
+ let Qr = ($ = class extends F {
1365
1449
  async run() {
1366
- const { flags: e } = await this.parse(R), r = F(e["log-level"]), t = new I(r);
1450
+ const { flags: e } = await this.parse($), r = N(e["log-level"]), t = new x(r);
1367
1451
  t.mergeLicenseEnvs(e);
1368
- const i = e["auth-enabled"], s = i ? {
1369
- enabled: i,
1452
+ const s = e["auth-enabled"], i = s ? {
1453
+ enabled: s,
1370
1454
  drivers: t.initAuthDriversList(e, ".")
1371
- } : void 0, c = e.storage ? o.join(".", e.storage) : l.data("docker-s3");
1372
- t.startDockerS3(c, {
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
- auth: s,
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
- }, h(R, "description", "Run platforma backend service with 'S3' primary storage type"), h(R, "examples", ["<%= config.bin %> <%= command.id %>"]), h(R, "flags", {
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
- ...ie
1394
- }), R);
1395
- const H = class H extends E {
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(H), r = F(e["log-level"]), t = new I(r);
1490
+ const { flags: e } = await this.parse(Y), r = N(e["log-level"]), t = new x(r);
1398
1491
  t.mergeLicenseEnvs(e);
1399
- const i = e["pl-workdir"] ?? ".", s = e.storage ? o.join(i, e.storage) : l.data("local-s3"), c = e["pl-log-file"] ? o.join(i, e["pl-log-file"]) : void 0, n = t.initAuthDriversList(e, i), u = e["auth-enabled"] ?? n !== void 0;
1400
- var m = e["pl-binary"];
1401
- e["pl-sources"] && (m = t.buildPlatforma({ repoRoot: e["pl-sources"] }));
1402
- var f = "127.0.0.1:6345";
1403
- e["grpc-listen"] ? f = e["grpc-listen"] : e["grpc-port"] && (f = `127.0.0.1:${e["grpc-port"]}`);
1404
- var w = "127.0.0.1:9090";
1405
- e["monitoring-listen"] ? w = e["monitoring-listen"] : e["monitoring-port"] && (w = `127.0.0.1:${e["monitoring-port"]}`);
1406
- var P = "127.0.0.1:9091";
1407
- e["debug-listen"] ? P = e["debug-listen"] : e["debug-port"] && (P = `127.0.0.1:${e["debug-port"]}`);
1408
- const g = {
1409
- binaryPath: m,
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: f },
1419
- monitoring: { listen: w },
1420
- debug: { listen: P },
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: c },
1423
- localRoot: s,
1515
+ log: { path: n },
1516
+ localRoot: i,
1424
1517
  core: {
1425
- auth: { enabled: u, drivers: n }
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
- g.binaryPath ? t.startLocalS3(g) : tr(r, { version: e.version }).then(() => t.startLocalS3(g)).catch(function(b) {
1433
- r.error(b.message);
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
- h(H, "description", "Run Platforma Backend service as local process on current host (no docker container)"), h(H, "examples", ["<%= config.bin %> <%= command.id %>"]), h(H, "flags", {
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
- ...ye,
1448
- ...he,
1534
+ ...Pr,
1535
+ ...Ve,
1536
+ ...Qe,
1537
+ ...Xe,
1538
+ ...te,
1539
+ ...se,
1449
1540
  ...Pe,
1450
- ...He,
1451
- ...Ye,
1541
+ ...ye,
1542
+ ...be,
1543
+ ...Ke,
1544
+ ...qe,
1452
1545
  ...ie
1453
1546
  });
1454
- let me = H;
1455
- const ot = {
1456
- "create-block": ne,
1457
- reset: oe,
1458
- start: de,
1459
- stop: ge,
1460
- "start:docker": ue,
1461
- "start:local": fe,
1462
- "start:docker:s3": zr,
1463
- "start:local:s3": me
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
- ot as COMMANDS
1559
+ ft as COMMANDS
1467
1560
  };
1468
1561
  //# sourceMappingURL=index.mjs.map