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