@platforma-sdk/bootstrap 2.8.5 → 2.9.0

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