@platforma-sdk/bootstrap 3.1.3 → 3.1.5

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,183 +1,183 @@
1
- var kr = Object.defineProperty;
2
- var Sr = (a, e, t) => e in a ? kr(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var l = (a, e, t) => Sr(a, typeof e != "symbol" ? e + "" : e, t);
4
- import { Flags as b, Command as L, Args as H } from "@oclif/core";
5
- import x from "node:os";
6
- import u, { createWriteStream as $r } from "node:fs";
7
- import m, { resolve as Lr } from "node:path";
8
- import { execSync as Pe, spawn as Ar, spawnSync as fr } from "node:child_process";
9
- import de from "winston";
10
- import { randomBytes as Ir } from "node:crypto";
11
- import X from "readline-sync";
12
- import * as N from "node:fs/promises";
13
- import { Writable as Or } from "node:stream";
14
- import { z as D } from "zod";
1
+ var Sr = Object.defineProperty;
2
+ var $r = (a, e, t) => e in a ? Sr(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
+ var l = (a, e, t) => $r(a, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Flags as v, Command as L, Args as K } from "@oclif/core";
5
+ import F from "node:os";
6
+ import f, { createWriteStream as Lr } from "node:fs";
7
+ import m, { resolve as Ir } from "node:path";
8
+ import { execSync as Ae, spawn as Ar, spawnSync as mr } from "node:child_process";
9
+ import ge from "winston";
10
+ import { randomBytes as Or } from "node:crypto";
11
+ import Z from "readline-sync";
12
+ import * as _ from "node:fs/promises";
13
+ import { Writable as Rr } from "node:stream";
14
+ import { z as N } from "zod";
15
15
  import Er from "decompress";
16
- import ue from "yaml";
17
16
  import { getDefaultPlVersion as fe } from "@milaboratories/pl-deployments";
18
- import Rr from "node:https";
19
- import * as Tr from "tar";
20
- const A = {
21
- "log-level": b.string({
17
+ import dr from "yaml";
18
+ import Tr from "node:https";
19
+ import * as xr from "tar";
20
+ const I = {
21
+ "log-level": v.string({
22
22
  description: "logging level",
23
23
  default: "info",
24
24
  options: ["error", "warn", "info", "debug"],
25
25
  required: !1
26
26
  })
27
27
  };
28
- b.string({
28
+ v.string({
29
29
  description: "name of instance",
30
30
  required: !1
31
31
  });
32
32
  const me = {
33
- image: b.string({
33
+ image: v.string({
34
34
  description: "use custom docker image to run platforma"
35
35
  })
36
- }, W = {
37
- version: b.string({
36
+ }, C = {
37
+ version: v.string({
38
38
  description: "use custom platforma release (official docker image or binary package)"
39
39
  })
40
40
  }, he = {
41
- arch: b.string({
41
+ arch: v.string({
42
42
  description: "override architecture. You can start amd64 linux image on arm-based host (say, Apple M family processor). I.e. arm64, amd64, amd64/v2"
43
43
  })
44
- }, q = {
45
- license: b.string({
44
+ }, M = {
45
+ license: v.string({
46
46
  description: 'pass a license code. The license can be got from "https://licensing.milaboratories.com".'
47
47
  }),
48
- "license-file": b.file({
48
+ "license-file": v.file({
49
49
  exists: !0,
50
50
  description: "specify a path to the file with a license. The license can be got from 'https://licensing.milaboratories.com'."
51
51
  })
52
- }, z = {
53
- "grpc-port": b.integer({
52
+ }, j = {
53
+ "grpc-port": v.integer({
54
54
  description: "port for Platforma Backend gRPC API. Default is 6345",
55
55
  env: "PLATFORMA_GRPC_PORT"
56
56
  }),
57
- "grpc-listen": b.string({
57
+ "grpc-listen": v.string({
58
58
  description: "full listen addr for Platforma Backend gRPC API. Default is 127.0.0.1:6345",
59
59
  env: "PLATFORMA_GRPC_LISTEN"
60
60
  }),
61
- "monitoring-port": b.integer({
61
+ "monitoring-port": v.integer({
62
62
  description: "port for Platforma Backend monitoring API. Default is 9090",
63
63
  env: "PLATFORMA_MONITORING_PORT"
64
64
  }),
65
- "monitoring-listen": b.string({
65
+ "monitoring-listen": v.string({
66
66
  description: "full listen addr for Platforma Backend monitoring API. Default is 127.0.0.1:9090",
67
67
  env: "PLATFORMA_MONITORING_LISTEN"
68
68
  }),
69
- "debug-port": b.integer({
69
+ "debug-port": v.integer({
70
70
  description: "port for Platforma Backend debug API. Default is 9091",
71
71
  env: "PLATFORMA_DEBUG_PORT"
72
72
  }),
73
- "debug-listen": b.string({
73
+ "debug-listen": v.string({
74
74
  description: "full listen addr for Platforma Backend debug API. Default is 127.0.0.1:9091",
75
75
  env: "PLATFORMA_DEBUG_LISTEN"
76
76
  })
77
- }, mr = {
78
- "s3-port": b.integer({
77
+ }, hr = {
78
+ "s3-port": v.integer({
79
79
  description: "port that S3 will listen, default is 9000",
80
80
  default: 9e3,
81
81
  env: "PLATFORMA_S3_PORT"
82
82
  }),
83
- "s3-console-port": b.integer({
83
+ "s3-console-port": v.integer({
84
84
  description: "port that a console of S3 will listen, default is 9001",
85
85
  default: 9001,
86
86
  env: "PLATFORMA_S3_CONSOLE_PORT"
87
87
  })
88
- }, Y = {
89
- storage: b.string({
88
+ }, B = {
89
+ storage: v.string({
90
90
  description: "specify path on host to be used as storage for all Platforma Backend data"
91
91
  })
92
- }, hr = {
93
- "minio-presign-host": b.boolean({
92
+ }, yr = {
93
+ "minio-presign-host": v.boolean({
94
94
  description: "use 'minio' host instead of 'localhost' in presign URLs"
95
95
  })
96
96
  }, ye = {
97
- mount: b.string({
97
+ mount: v.string({
98
98
  multiple: !0,
99
99
  description: "things to be mounted into platforma docker container. Targets will appear inside the container under the same absolute paths"
100
100
  })
101
- }, Ne = {
102
- "pl-log-file": b.file({
101
+ }, pe = {
102
+ "pl-log-file": v.file({
103
103
  description: "specify path for Platforma Backend log file"
104
104
  })
105
- }, _e = {
106
- "pl-workdir": b.file({
105
+ }, be = {
106
+ "pl-workdir": v.file({
107
107
  description: "specify working directory for Platforma Backend process"
108
108
  })
109
- }, Ce = {
110
- "pl-binary": b.file({
109
+ }, we = {
110
+ "pl-binary": v.file({
111
111
  description: "start given Platforma Backend binary instead of automatically downloaded version"
112
112
  })
113
- }, Me = {
114
- "pl-sources": b.file({
113
+ }, ve = {
114
+ "pl-sources": v.file({
115
115
  description: "path to pl repository root: build Platforma Backend from sources and start the resulting binary"
116
116
  })
117
- }, je = {
118
- config: b.string({
117
+ }, Pe = {
118
+ config: v.string({
119
119
  description: "use custom Platforma Backend config"
120
120
  })
121
121
  };
122
- b.file({
122
+ v.file({
123
123
  description: "specify path on host to be used as 'primary' storage"
124
124
  });
125
- const ce = {
126
- "storage-work": b.file({
125
+ const ie = {
126
+ "storage-work": v.file({
127
127
  description: "specify path on host to be used as 'work' storage"
128
128
  })
129
129
  };
130
- b.file({
130
+ v.file({
131
131
  description: "specify path on host to be used as 'library' storage"
132
132
  });
133
- const oe = {
134
- "storage-primary": b.string({
133
+ const ce = {
134
+ "storage-primary": v.string({
135
135
  description: `specify 'primary' storage destination URL.
136
136
  file:/path/to/dir for directory on local FS
137
137
  s3://<bucket>/?region=<name> for real AWS bucket
138
138
  s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
139
139
  s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`
140
140
  })
141
- }, le = {
142
- "storage-library": b.string({
141
+ }, oe = {
142
+ "storage-library": v.string({
143
143
  description: `specify 'library' storage destination URL.
144
144
  file:/path/to/dir for directory on local FS
145
145
  s3://<bucket>/?region=<name> for real AWS bucket
146
146
  s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
147
147
  s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`
148
148
  })
149
- }, Fr = {
150
- "auth-enabled": b.boolean({
149
+ }, Dr = {
150
+ "auth-enabled": v.boolean({
151
151
  description: "enable authorization"
152
152
  })
153
- }, xr = {
154
- "auth-htpasswd-file": b.file({
153
+ }, Fr = {
154
+ "auth-htpasswd-file": v.file({
155
155
  description: "path to .htpasswd file with Platforma users (static user DB auth source)"
156
156
  })
157
- }, Dr = {
158
- "auth-ldap-server": b.string({
157
+ }, Nr = {
158
+ "auth-ldap-server": v.string({
159
159
  description: "address of LDAP server to use for auth in Platforma (auth source)"
160
160
  })
161
- }, Nr = {
162
- "auth-ldap-default-dn": b.string({
161
+ }, _r = {
162
+ "auth-ldap-default-dn": v.string({
163
163
  description: "DN to use when checking user with LDAP bind operation: e.g. cn=%u,ou=users,dc=example,dc=com"
164
164
  })
165
- }, V = {
166
- ...Fr,
167
- ...xr,
165
+ }, U = {
168
166
  ...Dr,
169
- ...Nr
167
+ ...Fr,
168
+ ...Nr,
169
+ ..._r
170
170
  };
171
- function _r(a) {
172
- return X.question(`${a} [y/N] `).toLowerCase() === "y";
171
+ function Cr(a) {
172
+ return Z.question(`${a} [y/N] `).toLowerCase() === "y";
173
173
  }
174
- function _(a) {
174
+ function G(a) {
175
175
  throw new Error("this should never happen");
176
176
  }
177
- function I(a = "debug") {
178
- return de.createLogger({
177
+ function A(a = "debug") {
178
+ return ge.createLogger({
179
179
  level: a,
180
- format: de.format.printf(({ level: e, message: t }) => {
180
+ format: ge.format.printf(({ level: e, message: t }) => {
181
181
  const r = " ".repeat(e.length + 2);
182
182
  if (typeof t != "string") {
183
183
  const i = JSON.stringify(t);
@@ -186,64 +186,64 @@ function I(a = "debug") {
186
186
  const n = t.split(`
187
187
  `).map((i, c) => c === 0 ? i : r + i).join(`
188
188
  `);
189
- return `${((i) => de.format.colorize().colorize(i, i))(e)}: ${n}`;
189
+ return `${((i) => ge.format.colorize().colorize(i, i))(e)}: ${n}`;
190
190
  }),
191
191
  transports: [
192
- new de.transports.Console({
192
+ new ge.transports.Console({
193
193
  stderrLevels: ["error", "warn", "info", "debug"],
194
194
  handleExceptions: !0
195
195
  })
196
196
  ]
197
197
  });
198
198
  }
199
- function Cr(a) {
200
- return Ir(Math.ceil(a / 2)).toString("hex").slice(0, a);
201
- }
202
199
  function Mr(a) {
203
- return a.startsWith("~") ? m.join(x.homedir(), a.slice(1)) : a;
204
- }
205
- function pe(a, e) {
206
- u.existsSync(a) || (u.mkdirSync(a, { recursive: !0 }), e != null && e.mode && u.chmodSync(a, e.mode));
200
+ return Or(Math.ceil(a / 2)).toString("hex").slice(0, a);
207
201
  }
208
202
  function jr(a) {
203
+ return a.startsWith("~") ? m.join(F.homedir(), a.slice(1)) : a;
204
+ }
205
+ function Se(a, e) {
206
+ f.existsSync(a) || (f.mkdirSync(a, { recursive: !0 }), e != null && e.mode && f.chmodSync(a, e.mode));
207
+ }
208
+ function Br(a) {
209
209
  try {
210
- if (x.platform() !== "win32")
211
- return Pe(`ps -p ${a} -o comm=`, { encoding: "utf8" }).trim();
212
- const e = `wmic process where processid=${a} get Caption`, t = Pe(e, { encoding: "utf8" }).split(`
210
+ if (F.platform() !== "win32")
211
+ return Ae(`ps -p ${a} -o comm=`, { encoding: "utf8" }).trim();
212
+ const e = `wmic process where processid=${a} get Caption`, t = Ae(e, { encoding: "utf8" }).split(`
213
213
  `);
214
214
  return t.length <= 1 ? "" : t[1].trim();
215
215
  } catch {
216
216
  return "";
217
217
  }
218
218
  }
219
- function Br(a) {
220
- const e = Pe(`docker compose ls --filter name=${a} --format json`, { encoding: "utf8" }).trim(), t = JSON.parse(e);
219
+ function Ur(a) {
220
+ const e = Ae(`docker compose ls --filter name=${a} --format json`, { encoding: "utf8" }).trim(), t = JSON.parse(e);
221
221
  for (const r of t)
222
222
  if (r.Name === a)
223
223
  return r;
224
224
  }
225
- const ke = ["Python"], yr = ["Tengo", "Python"], Gr = D.union([D.literal("Tengo"), D.literal("Python")]), Ur = D.object({
226
- npmOrgName: D.string().min(1),
227
- orgName: D.string().min(1),
228
- blockName: D.string().min(1),
229
- softwarePlatforms: D.array(Gr).refine((a) => new Set(a).size === a.length, {
225
+ const Oe = ["Python"], pr = ["Tengo", "Python"], Gr = N.union([N.literal("Tengo"), N.literal("Python")]), Jr = N.object({
226
+ npmOrgName: N.string().min(1),
227
+ orgName: N.string().min(1),
228
+ blockName: N.string().min(1),
229
+ softwarePlatforms: N.array(Gr).refine((a) => new Set(a).size === a.length, {
230
230
  message: "Must be an array of unique software platforms"
231
231
  })
232
232
  });
233
- async function Jr(a) {
234
- const { npmOrgName: e, orgName: t, blockName: r, softwarePlatforms: n } = Hr(), s = m.join(process.cwd(), r);
235
- a.info("Downloading boilerplate code..."), await Wr(
233
+ async function Hr(a) {
234
+ const { npmOrgName: e, orgName: t, blockName: r, softwarePlatforms: n } = Wr(), s = m.join(process.cwd(), r);
235
+ a.info("Downloading boilerplate code..."), await qr(
236
236
  // 'https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/software_platforms.zip',
237
237
  // 'platforma-block-boilerplate-software_platforms',
238
238
  "https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip",
239
239
  "platforma-block-boilerplate-main",
240
240
  s
241
241
  );
242
- const i = yr.filter((o) => n.indexOf(o) < 0), c = ke.length == i.length;
242
+ const i = pr.filter((o) => n.indexOf(o) < 0), c = Oe.length == i.length;
243
243
  a.info(`Keep platforms '${n}', remove: '${i}'. Will remove all platforms? ${c}`);
244
244
  for (const o of i)
245
- await qr(s, o);
246
- c && await zr(s), a.info("Replace everything in the template with provided options..."), Yr(s, [
245
+ await zr(s, o);
246
+ c && await Yr(s), a.info("Replace everything in the template with provided options..."), Vr(s, [
247
247
  // '@' literal ensures only npm org name will be renamed,
248
248
  // as public registry for software also is called platforma-open, but without '@'.
249
249
  // Also, don't rename an organization for runenv-python-3 package.
@@ -252,45 +252,45 @@ async function Jr(a) {
252
252
  { from: /block-boilerplate/g, to: r }
253
253
  ]);
254
254
  }
255
- function Hr() {
256
- let a = X.question(
255
+ function Wr() {
256
+ let a = Z.question(
257
257
  'Write an organization name for npm. Default is "platforma-open": '
258
258
  );
259
259
  a === "" && (a = "platforma-open");
260
- const e = X.question('Write an organization name, e.g. "my-org": '), t = X.question('Write a name of the block, e.g. "hello-world": '), r = X.keyInYN("Create package for block's software?");
260
+ const e = Z.question('Write an organization name, e.g. "my-org": '), t = Z.question('Write a name of the block, e.g. "hello-world": '), r = Z.keyInYN("Create package for block's software?");
261
261
  let n = ["Tengo"];
262
262
  if (r)
263
- for (; n.length < yr.length; ) {
264
- const s = X.keyInSelect(ke, "Choose software platform:");
263
+ for (; n.length < pr.length; ) {
264
+ const s = Z.keyInSelect(Oe, "Choose software platform:");
265
265
  if (s < 0) break;
266
- n.push(ke[s]);
266
+ n.push(Oe[s]);
267
267
  }
268
- return n = Array.from(new Set(n)).sort(), Ur.parse({ npmOrgName: a, orgName: e, blockName: t, softwarePlatforms: n });
268
+ return n = Array.from(new Set(n)).sort(), Jr.parse({ npmOrgName: a, orgName: e, blockName: t, softwarePlatforms: n });
269
269
  }
270
- async function Wr(a, e, t) {
271
- const n = await (await fetch(a)).blob(), s = await N.mkdtemp(m.join(x.tmpdir(), "create-repo")), i = m.join(s, "packed-repo.zip"), c = Or.toWeb($r(i));
270
+ async function qr(a, e, t) {
271
+ const n = await (await fetch(a)).blob(), s = await _.mkdtemp(m.join(F.tmpdir(), "create-repo")), i = m.join(s, "packed-repo.zip"), c = Rr.toWeb(Lr(i));
272
272
  await n.stream().pipeTo(c);
273
273
  const o = m.join(s, "unpacked-repo");
274
- await N.mkdir(o), await Er(i, o), await N.cp(m.join(o, e), t, { recursive: !0 });
274
+ await _.mkdir(o), await Er(i, o), await _.cp(m.join(o, e), t, { recursive: !0 });
275
275
  }
276
- async function qr(a, e) {
276
+ async function zr(a, e) {
277
277
  const t = e.toLowerCase();
278
- await Z(
278
+ await ee(
279
279
  m.join(a, "ui", "src", "pages", "MainPage.vue"),
280
280
  new RegExp(`.*${t}Message.*\\n\\n`, "g")
281
- ), await Z(
281
+ ), await ee(
282
282
  m.join(a, "model", "src", "index.ts"),
283
283
  new RegExp(`.*${t}Message.*\\n\\n`, "g")
284
- ), await Z(
284
+ ), await ee(
285
285
  m.join(a, "workflow", "src", "main.tpl.tengo"),
286
286
  new RegExp(`.*${t}.*exec.builder.*[\\s\\S]*?\\n\\n`, "g")
287
- ), await Z(
287
+ ), await ee(
288
288
  m.join(a, "workflow", "src", "main.tpl.tengo"),
289
289
  new RegExp(`.*${t}Message.*\\n`, "g")
290
- ), await Z(
290
+ ), await ee(
291
291
  m.join(a, "workflow", "src", "wf.test.ts"),
292
292
  new RegExp(`.*${t}Message.*\\n.*expect.*\\n\\n`, "g")
293
- ), await N.rm(m.join(a, "software", `src_${t}`), { recursive: !0 }), await Be(
293
+ ), await _.rm(m.join(a, "software", `src_${t}`), { recursive: !0 }), await Ue(
294
294
  m.join(a, "software", "package.json"),
295
295
  (r) => {
296
296
  const n = JSON.parse(r);
@@ -298,75 +298,75 @@ async function qr(a, e) {
298
298
  }
299
299
  );
300
300
  }
301
- async function zr(a) {
302
- await N.rm(m.join(a, "software"), { recursive: !0 }), await Be(
301
+ async function Yr(a) {
302
+ await _.rm(m.join(a, "software"), { recursive: !0 }), await Ue(
303
303
  m.join(a, "workflow", "package.json"),
304
304
  (e) => {
305
305
  const t = JSON.parse(e);
306
306
  return delete t.dependencies["@platforma-open/my-org.block-boilerplate.software"], JSON.stringify(t, null, 2);
307
307
  }
308
- ), await Z(
308
+ ), await ee(
309
309
  m.join(a, "pnpm-workspace.yaml"),
310
310
  /.*- software$\n/gm
311
311
  );
312
312
  }
313
- async function Yr(a, e) {
314
- const t = await Vr(a);
313
+ async function Vr(a, e) {
314
+ const t = await Kr(a);
315
315
  for (const { from: r, to: n } of e)
316
316
  for (const s of t)
317
- await pr(s, r, n);
317
+ await br(s, r, n);
318
318
  }
319
- async function Vr(a) {
320
- return (await N.readdir(a, {
319
+ async function Kr(a) {
320
+ return (await _.readdir(a, {
321
321
  withFileTypes: !0,
322
322
  recursive: !0
323
323
  })).filter((t) => t.isFile()).map((t) => m.join(t.parentPath, t.name));
324
324
  }
325
- async function Be(a, e) {
326
- const t = await N.readFile(a), r = e(t.toString());
327
- await N.writeFile(a, r);
325
+ async function Ue(a, e) {
326
+ const t = await _.readFile(a), r = e(t.toString());
327
+ await _.writeFile(a, r);
328
328
  }
329
- async function pr(a, e, t) {
330
- return await Be(a, (r) => r.replaceAll(e, t));
329
+ async function br(a, e, t) {
330
+ return await Ue(a, (r) => r.replaceAll(e, t));
331
331
  }
332
- async function Z(a, e) {
333
- return await pr(a, e, "");
332
+ async function ee(a, e) {
333
+ return await br(a, e, "");
334
334
  }
335
- const ee = class ee extends L {
335
+ const re = class re extends L {
336
336
  async run() {
337
- const { flags: e } = await this.parse(ee), t = I(e["log-level"]);
338
- await Jr(t);
337
+ const { flags: e } = await this.parse(re), t = A(e["log-level"]);
338
+ await Hr(t);
339
339
  }
340
340
  };
341
- l(ee, "description", "Helps to create a new block by downloading a block's template."), l(ee, "examples", ["<%= name %>"]), l(ee, "flags", {
342
- ...A
341
+ l(re, "description", "Helps to create a new block by downloading a block's template."), l(re, "examples", ["<%= name %>"]), l(re, "flags", {
342
+ ...I
343
343
  });
344
- let Se = ee;
345
- function br(...a) {
346
- return Lr(__dirname, "..", ...a);
344
+ let Re = re;
345
+ function wr(...a) {
346
+ return Ir(__dirname, "..", ...a);
347
347
  }
348
- function K(...a) {
349
- return br("assets", ...a);
348
+ function Q(...a) {
349
+ return wr("assets", ...a);
350
350
  }
351
- function be(...a) {
352
- return u.readFileSync(br(...a));
351
+ function $e(...a) {
352
+ return f.readFileSync(wr(...a));
353
353
  }
354
- function dr(a) {
354
+ function gr(a) {
355
355
  return a || (a = fe()), `quay.io/milaboratories/platforma:${a}`;
356
356
  }
357
- const C = class C {
357
+ const J = class J {
358
358
  constructor(e) {
359
359
  l(this, "state", {
360
360
  currentInstance: ""
361
361
  });
362
362
  l(this, "filePath");
363
363
  l(this, "dirPath");
364
- e = e ?? m.resolve(x.homedir(), ".config", "pl-bootstrap");
364
+ e = e ?? m.resolve(F.homedir(), ".config", "pl-bootstrap");
365
365
  const t = m.join(e, "state.json");
366
- this.dirPath = e, this.filePath = t, u.existsSync(e) || u.mkdirSync(e, { recursive: !0 }), u.existsSync(t) && (this.state = JSON.parse(be(t).toString()));
366
+ this.dirPath = e, this.filePath = t, f.existsSync(e) || f.mkdirSync(e, { recursive: !0 }), f.existsSync(t) && (this.state = JSON.parse($e(t).toString()));
367
367
  }
368
368
  static getStateInstance() {
369
- return C.instance || (C.instance = new C()), C.instance;
369
+ return J.instance || (J.instance = new J()), J.instance;
370
370
  }
371
371
  path(...e) {
372
372
  return m.join(this.dirPath, ...e);
@@ -378,40 +378,40 @@ const C = class C {
378
378
  return this.path("binaries", ...e);
379
379
  }
380
380
  writeState() {
381
- u.writeFileSync(this.filePath, JSON.stringify(this.state));
381
+ f.writeFileSync(this.filePath, JSON.stringify(this.state));
382
382
  }
383
383
  get instanceList() {
384
- return u.existsSync(this.instanceDir()) ? u.readdirSync(this.instanceDir()).filter((t) => this.instanceExists(t)) : [];
384
+ return f.existsSync(this.instanceDir()) ? f.readdirSync(this.instanceDir()).filter((t) => this.instanceExists(t)) : [];
385
385
  }
386
386
  instanceExists(e) {
387
- return u.existsSync(this.instanceDir(e, "instance.json"));
387
+ return f.existsSync(this.instanceDir(e, "instance.json"));
388
388
  }
389
389
  getInstanceInfo(e) {
390
390
  const t = this.instanceDir(e, "instance.json");
391
- if (!u.existsSync(t))
391
+ if (!f.existsSync(t))
392
392
  throw new Error(`platforma backend instance '${e}' does not exist or is corrupted`);
393
- const r = JSON.parse(be(t).toString());
393
+ const r = JSON.parse($e(t).toString());
394
394
  return {
395
395
  name: e,
396
396
  ...r
397
397
  };
398
398
  }
399
399
  setInstanceInfo(e, t) {
400
- u.existsSync(this.instanceDir(e)) || u.mkdirSync(this.instanceDir(e), { recursive: !0 });
400
+ f.existsSync(this.instanceDir(e)) || f.mkdirSync(this.instanceDir(e), { recursive: !0 });
401
401
  const r = this.instanceDir(e, "instance.json");
402
402
  let n = {};
403
- u.existsSync(r) && (n = JSON.parse(be(r).toString())), u.writeFileSync(r, JSON.stringify({ ...n, ...t }));
403
+ f.existsSync(r) && (n = JSON.parse($e(r).toString())), f.writeFileSync(r, JSON.stringify({ ...n, ...t }));
404
404
  }
405
405
  isInstanceActive(e) {
406
406
  switch (e.type) {
407
407
  case "docker": {
408
- const r = Br(`pl-${e.name}`);
408
+ const r = Ur(`pl-${e.name}`);
409
409
  return r ? r.Status.trim().startsWith("running") : !1;
410
410
  }
411
411
  case "process":
412
- return e.pid ? gr(e.pid) : !1;
412
+ return e.pid ? ur(e.pid) : !1;
413
413
  default:
414
- throw _(), new Error("cli logic error: unknown service type, cannot check its state");
414
+ throw G(), new Error("cli logic error: unknown service type, cannot check its state");
415
415
  }
416
416
  }
417
417
  get isActive() {
@@ -423,7 +423,7 @@ const C = class C {
423
423
  return !1;
424
424
  }
425
425
  isValidPID(e) {
426
- return gr(e);
426
+ return ur(e);
427
427
  }
428
428
  get currentInstance() {
429
429
  const e = this.state.currentInstance;
@@ -442,14 +442,14 @@ const C = class C {
442
442
  this.state.currentInstance = e, this.writeState();
443
443
  }
444
444
  };
445
- l(C, "instance");
446
- let $e = C;
447
- function gr(a) {
448
- const e = jr(a);
445
+ l(J, "instance");
446
+ let Ee = J;
447
+ function ur(a) {
448
+ const e = Br(a);
449
449
  return e === "platforma" || e.endsWith("/platforma") || e.endsWith("\\platforma");
450
450
  }
451
- const d = $e.getStateInstance();
452
- function we(a, e, t) {
451
+ const u = Ee.getStateInstance();
452
+ function Le(a, e, t) {
453
453
  const r = [], n = [];
454
454
  for (const s of e)
455
455
  if (t = {
@@ -461,10 +461,10 @@ function we(a, e, t) {
461
461
  ...s.runOpts,
462
462
  ...t
463
463
  }, s.async) {
464
- const i = Kr(a, s.cmd, s.args, t);
464
+ const i = Qr(a, s.cmd, s.args, t);
465
465
  n.push(i);
466
466
  } else {
467
- const i = Qr(a, s.cmd, s.args, t);
467
+ const i = Xr(a, s.cmd, s.args, t);
468
468
  if (r.push(i), i.error || i.status !== 0)
469
469
  break;
470
470
  }
@@ -473,7 +473,7 @@ function we(a, e, t) {
473
473
  spawned: n
474
474
  };
475
475
  }
476
- function Kr(a, e, t, r) {
476
+ function Qr(a, e, t, r) {
477
477
  var c;
478
478
  a.debug(
479
479
  `Running:
@@ -490,15 +490,15 @@ function Kr(a, e, t, r) {
490
490
  process.removeListener("SIGINT", i), s && process.exit(o);
491
491
  }), n;
492
492
  }
493
- function Qr(a, e, t, r) {
493
+ function Xr(a, e, t, r) {
494
494
  return a.debug(
495
495
  `Running:
496
496
  cmd: ${JSON.stringify([e, ...t])}
497
497
  opts: ${JSON.stringify(r)}`
498
- ), r.env = { ...process.env, ...r.env }, fr(e, t, r);
498
+ ), r.env = { ...process.env, ...r.env }, mr(e, t, r);
499
499
  }
500
- function ve(a, e, t, r, n) {
501
- const s = u.readFileSync(a, { encoding: "utf-8" }), i = ue.parse(s.toString());
500
+ function Ie(a, e, t, r, n) {
501
+ const s = f.readFileSync(a, { encoding: "utf-8" }), i = dr.parse(s.toString());
502
502
  if (!i.services)
503
503
  throw new Error(`file '${a}' seems to be not a docker-compose file or has unsupported version`);
504
504
  if (r)
@@ -506,38 +506,37 @@ function ve(a, e, t, r, n) {
506
506
  r.has(c) || delete i.services[c];
507
507
  i.name = t;
508
508
  for (const [c, o] of (r == null ? void 0 : r.entries()) ?? []) {
509
- const f = i.services[c];
510
- if (!f)
509
+ const d = i.services[c];
510
+ if (!d)
511
511
  throw new Error(`docker compose '${a}' has no declaration of service '${c}'`);
512
- if (o.platform && (f.platform = o.platform), o.envs) {
513
- f.environment || (f.environment = []);
514
- for (let g = 0; g < ((f == null ? void 0 : f.environment.length) ?? 0); ) {
515
- const w = f.environment[g].split("=")[0];
516
- if (o.envs[w]) {
517
- const v = f.environment.pop();
518
- v && f.environment.length !== g && (f.environment[g] = v);
512
+ if (o.platform && (d.platform = o.platform), o.envs) {
513
+ d.environment || (d.environment = []);
514
+ for (let g = 0; g < ((d == null ? void 0 : d.environment.length) ?? 0); ) {
515
+ const b = d.environment[g].split("=")[0];
516
+ if (o.envs[b]) {
517
+ const w = d.environment.pop();
518
+ w && d.environment.length !== g && (d.environment[g] = w);
519
519
  } else
520
520
  g++;
521
521
  }
522
522
  for (const [g, h] of Object.entries(o.envs))
523
- f.environment.push(`${g}=${h}`);
523
+ d.environment.push(`${g}=${h}`);
524
524
  }
525
525
  if (o.mounts) {
526
- f.volumes || (f.volumes = []);
526
+ d.volumes || (d.volumes = []);
527
527
  for (const g of o.mounts)
528
- f.volumes.push(`${g.hostPath}:${g.containerPath}`);
528
+ d.volumes.push(`${g.hostPath}:${g.containerPath}`);
529
529
  }
530
530
  }
531
- n != null && n.dropVolumes && delete i.volumes, u.writeFileSync(e, ue.stringify(i));
531
+ n != null && n.dropVolumes && delete i.volumes, f.writeFileSync(e, dr.stringify(i));
532
532
  }
533
- function Xr(a) {
533
+ function Zr(a) {
534
534
  return {
535
535
  id: a,
536
536
  type: "S3",
537
537
  indexCachePeriod: "0s",
538
538
  endpoint: "",
539
539
  region: "",
540
- presignEndpoint: "",
541
540
  bucketName: "",
542
541
  createBucket: !1,
543
542
  forcePathStyle: !1,
@@ -548,7 +547,7 @@ function Xr(a) {
548
547
  uploadKeyPrefix: ""
549
548
  };
550
549
  }
551
- function wr(a) {
550
+ function vr(a) {
552
551
  return {
553
552
  id: a,
554
553
  type: "FS",
@@ -556,42 +555,46 @@ function wr(a) {
556
555
  rootPath: ""
557
556
  };
558
557
  }
559
- function Q(a, e, t) {
560
- a = Mr(a);
558
+ function X(a, e, t) {
559
+ a = jr(a);
561
560
  const r = new URL(a, `file:${e}`);
562
561
  switch (r.protocol) {
563
- case "s3:":
564
- var i = r.hostname, n = r.searchParams.get("region");
562
+ case "s3:": {
563
+ const n = r.hostname, s = r.searchParams.get("region"), i = r.pathname.slice(1);
565
564
  return {
566
565
  ...t,
567
566
  type: "S3",
568
- bucketName: i,
569
- region: n
567
+ bucketName: n,
568
+ region: s,
569
+ keyPrefix: i
570
570
  };
571
- case "s3e:":
572
- var s = r.pathname.split("/").slice(1), i = s[0], c = s.length > 1 ? s[1] : "";
571
+ }
572
+ case "s3e:": {
573
+ const n = r.pathname.split("/").slice(1), s = n[0], i = n.length > 1 ? n.slice(1).join("/") : "";
573
574
  return {
574
575
  ...t,
575
576
  type: "S3",
576
577
  endpoint: `http://${r.host}/`,
577
- bucketName: i,
578
- keyPrefix: c,
578
+ bucketName: s,
579
+ keyPrefix: i,
579
580
  region: r.searchParams.get("region"),
580
581
  key: r.username ? `static:${r.username}` : "",
581
582
  secret: r.password ? `static:${r.password}` : ""
582
583
  };
583
- case "s3es:":
584
- var s = r.pathname.split("/").slice(1), i = s[0], c = s.length > 1 ? s[1] : "";
584
+ }
585
+ case "s3es:": {
586
+ const n = r.pathname.split("/").slice(1), s = n[0], i = n.length > 1 ? n.slice(1).join("/") : "";
585
587
  return {
586
588
  ...t,
587
589
  type: "S3",
588
590
  endpoint: `https://${r.host}/`,
589
- bucketName: i,
590
- keyPrefix: c,
591
+ bucketName: s,
592
+ keyPrefix: i,
591
593
  region: r.searchParams.get("region"),
592
594
  key: r.username ? `static:${r.username}` : "",
593
595
  secret: r.password ? `static:${r.password}` : ""
594
596
  };
597
+ }
595
598
  case "file:":
596
599
  return {
597
600
  type: "FS",
@@ -601,17 +604,17 @@ function Q(a, e, t) {
601
604
  throw new Error(`storage protocol '${r.protocol}' is not supported`);
602
605
  }
603
606
  }
604
- function Zr(a, e) {
605
- var v, y, P, S, k, p, $, se, Ue, Je, He, We, qe, ze, Ye, Ve, Ke, Qe, Xe, Ze, er, rr, tr, ar, nr, sr, ir, cr, or, lr;
606
- const t = (e == null ? void 0 : e.localRoot) ?? d.instanceDir("default"), r = {
607
- level: ((v = e == null ? void 0 : e.log) == null ? void 0 : v.level) ?? "info",
607
+ function et(a, e) {
608
+ var w, y, P, S, k, p, $, le, Ge, Je, He, We, qe, ze, Ye, Ve, Ke, Qe, Xe, Ze, er, rr, tr, ar, nr, sr, ir, cr, or, lr;
609
+ const t = (e == null ? void 0 : e.localRoot) ?? u.instanceDir("default"), r = {
610
+ level: ((w = e == null ? void 0 : e.log) == null ? void 0 : w.level) ?? "info",
608
611
  path: ((y = e == null ? void 0 : e.log) == null ? void 0 : y.path) ?? `${t}/logs/platforma.log`
609
612
  }, n = {
610
613
  listen: ((P = e == null ? void 0 : e.grpc) == null ? void 0 : P.listen) ?? "localhost:6345",
611
614
  tls: {
612
- enable: ie((k = (S = e == null ? void 0 : e.grpc) == null ? void 0 : S.tls) == null ? void 0 : k.enable, !1),
615
+ enable: de((k = (S = e == null ? void 0 : e.grpc) == null ? void 0 : S.tls) == null ? void 0 : k.enable, !1),
613
616
  clientAuthMode: (($ = (p = e == null ? void 0 : e.grpc) == null ? void 0 : p.tls) == null ? void 0 : $.clientAuthMode) ?? "NoAuth",
614
- certFile: ((Ue = (se = e == null ? void 0 : e.grpc) == null ? void 0 : se.tls) == null ? void 0 : Ue.certFile) ?? `${t}/certs/tls.cert`,
617
+ certFile: ((Ge = (le = e == null ? void 0 : e.grpc) == null ? void 0 : le.tls) == null ? void 0 : Ge.certFile) ?? `${t}/certs/tls.cert`,
615
618
  keyFile: ((He = (Je = e == null ? void 0 : e.grpc) == null ? void 0 : Je.tls) == null ? void 0 : He.keyFile) ?? `${t}/certs/tls.key`,
616
619
  ...(We = e == null ? void 0 : e.grpc) == null ? void 0 : We.tls
617
620
  }
@@ -626,7 +629,7 @@ function Zr(a, e) {
626
629
  db: {
627
630
  path: `${t}/db`
628
631
  }
629
- }, i = ur(
632
+ }, i = fr(
630
633
  "main",
631
634
  `${t}/storages/main`,
632
635
  "main-bucket",
@@ -636,57 +639,57 @@ function Zr(a, e) {
636
639
  switch ((Xe = (Qe = e == null ? void 0 : e.storages) == null ? void 0 : Qe.work) == null ? void 0 : Xe.type) {
637
640
  case void 0:
638
641
  case "FS":
639
- c = wr("work"), c.rootPath = ((er = (Ze = e == null ? void 0 : e.storages) == null ? void 0 : Ze.work) == null ? void 0 : er.rootPath) ?? `${t}/storages/work`, c.indexCachePeriod = ((tr = (rr = e == null ? void 0 : e.storages) == null ? void 0 : rr.work) == null ? void 0 : tr.indexCachePeriod) ?? "1m";
642
+ c = vr("work"), c.rootPath = ((er = (Ze = e == null ? void 0 : e.storages) == null ? void 0 : Ze.work) == null ? void 0 : er.rootPath) ?? `${t}/storages/work`, c.indexCachePeriod = ((tr = (rr = e == null ? void 0 : e.storages) == null ? void 0 : rr.work) == null ? void 0 : tr.indexCachePeriod) ?? "1m";
640
643
  break;
641
644
  default:
642
645
  throw new Error("work storage MUST have 'FS' type as it is used for working directories management");
643
646
  }
644
- const f = ur(
647
+ const d = fr(
645
648
  "library",
646
649
  `${t}/storages/library`,
647
650
  "library-bucket",
648
651
  (ar = e == null ? void 0 : e.storages) == null ? void 0 : ar.library
649
652
  ), g = {
650
- enabled: ie((nr = e == null ? void 0 : e.monitoring) == null ? void 0 : nr.enabled, !0),
653
+ enabled: de((nr = e == null ? void 0 : e.monitoring) == null ? void 0 : nr.enabled, !0),
651
654
  listen: ((sr = e == null ? void 0 : e.monitoring) == null ? void 0 : sr.listen) ?? "127.0.0.1:9090"
652
655
  }, h = {
653
- enabled: ie((ir = e == null ? void 0 : e.debug) == null ? void 0 : ir.enabled, !0),
656
+ enabled: de((ir = e == null ? void 0 : e.debug) == null ? void 0 : ir.enabled, !0),
654
657
  listen: ((cr = e == null ? void 0 : e.debug) == null ? void 0 : cr.listen) ?? "127.0.0.1:9091"
655
- }, w = {
658
+ }, b = {
656
659
  value: ((or = e == null ? void 0 : e.license) == null ? void 0 : or.value) ?? "",
657
660
  file: ((lr = e == null ? void 0 : e.license) == null ? void 0 : lr.file) ?? ""
658
661
  };
659
662
  return {
660
663
  localRoot: t,
661
- license: w,
664
+ license: b,
662
665
  log: r,
663
666
  grpc: n,
664
667
  core: s,
665
668
  monitoring: g,
666
669
  debug: h,
667
- storages: { primary: i, work: c, library: f },
670
+ storages: { primary: i, work: c, library: d },
668
671
  hacks: { libraryDownloadable: !0 }
669
672
  };
670
673
  }
671
- function ur(a, e, t, r) {
674
+ function fr(a, e, t, r) {
672
675
  let n;
673
676
  switch (r == null ? void 0 : r.type) {
674
677
  case void 0:
675
678
  case "FS":
676
- n = wr(a), n.rootPath = (r == null ? void 0 : r.rootPath) ?? e;
679
+ n = vr(a), n.rootPath = (r == null ? void 0 : r.rootPath) ?? e;
677
680
  break;
678
681
  case "S3":
679
- n = Xr(a), n.endpoint = (r == null ? void 0 : r.endpoint) ?? "http://localhost:9000", n.presignEndpoint = (r == null ? void 0 : r.presignEndpoint) ?? "http://localhost:9000", n.bucketName = (r == null ? void 0 : r.bucketName) ?? t, n.createBucket = ie(r == null ? void 0 : r.createBucket, !0), n.forcePathStyle = ie(r == null ? void 0 : r.forcePathStyle, !0), n.key = (r == null ? void 0 : r.key) ?? "", n.secret = (r == null ? void 0 : r.secret) ?? "", n.keyPrefix = (r == null ? void 0 : r.keyPrefix) ?? "", n.accessPrefixes = (r == null ? void 0 : r.accessPrefixes) ?? [""], n.uploadKeyPrefix = (r == null ? void 0 : r.uploadKeyPrefix) ?? "";
682
+ n = Zr(a), n.endpoint = r == null ? void 0 : r.endpoint, n.region = r == null ? void 0 : r.region, n.presignEndpoint = (r == null ? void 0 : r.presignEndpoint) ?? (r == null ? void 0 : r.endpoint), n.bucketName = (r == null ? void 0 : r.bucketName) ?? t, n.createBucket = de(r == null ? void 0 : r.createBucket, !0), n.forcePathStyle = de(r == null ? void 0 : r.forcePathStyle, !0), n.key = (r == null ? void 0 : r.key) ?? "", n.secret = (r == null ? void 0 : r.secret) ?? "", n.keyPrefix = (r == null ? void 0 : r.keyPrefix) ?? "", n.accessPrefixes = (r == null ? void 0 : r.accessPrefixes) ?? [""], n.uploadKeyPrefix = (r == null ? void 0 : r.uploadKeyPrefix) ?? "";
680
683
  break;
681
684
  default:
682
- throw _(), new Error("unknown storage type");
685
+ throw G(), new Error("unknown storage type");
683
686
  }
684
687
  return n;
685
688
  }
686
- function et(a) {
689
+ function rt(a) {
687
690
  const e = a.monitoring.enabled ? "" : " disabled", t = a.debug.enabled ? "" : " disabled", r = a.hacks.libraryDownloadable ? "true" : "false";
688
691
  let n = a.license.value;
689
- return a.license.file != "" && (n = u.readFileSync(a.license.file).toString().trimEnd()), `
692
+ return a.license.file != "" && (n = f.readFileSync(a.license.file).toString().trimEnd()), `
690
693
  license:
691
694
  value: '${a.license.value}'
692
695
  file: '${a.license.file}'
@@ -762,12 +765,12 @@ controllers:
762
765
  workflows: {}
763
766
  `;
764
767
  }
765
- function ie(a, e) {
768
+ function de(a, e) {
766
769
  return a === void 0 ? e : a;
767
770
  }
768
- const rt = ["linux", "macos", "windows"];
769
- function tt(a) {
770
- const e = x.platform();
771
+ const tt = ["linux", "macos", "windows"];
772
+ function at(a) {
773
+ const e = F.platform();
771
774
  switch (e) {
772
775
  case "darwin":
773
776
  return "macos";
@@ -777,13 +780,13 @@ function tt(a) {
777
780
  return "windows";
778
781
  default:
779
782
  throw new Error(
780
- `operating system '${e}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` + JSON.stringify(rt)
783
+ `operating system '${e}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` + JSON.stringify(tt)
781
784
  );
782
785
  }
783
786
  }
784
- const at = ["amd64", "arm64"];
785
- function vr(a) {
786
- const e = x.arch();
787
+ const nt = ["amd64", "arm64"];
788
+ function Pr(a) {
789
+ const e = F.arch();
787
790
  switch (e) {
788
791
  case "arm64":
789
792
  return "arm64";
@@ -791,77 +794,77 @@ function vr(a) {
791
794
  return "amd64";
792
795
  default:
793
796
  throw new Error(
794
- `processor architecture '${e}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(at)
797
+ `processor architecture '${e}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(nt)
795
798
  );
796
799
  }
797
800
  }
798
- function nt(a, e) {
799
- const t = (e == null ? void 0 : e.version) ?? fe(), r = (e == null ? void 0 : e.showProgress) ?? process.stdout.isTTY, n = `pl-${t}-${vr()}.tgz`, s = (e == null ? void 0 : e.downloadURL) ?? `https://cdn.platforma.bio/software/pl/${tt()}/${n}`, i = (e == null ? void 0 : e.saveTo) ?? d.binaries(n);
800
- if (u.existsSync(i))
801
+ function st(a, e) {
802
+ const t = (e == null ? void 0 : e.version) ?? fe(), r = (e == null ? void 0 : e.showProgress) ?? process.stdout.isTTY, n = `pl-${t}-${Pr()}.tgz`, s = (e == null ? void 0 : e.downloadURL) ?? `https://cdn.platforma.bio/software/pl/${at()}/${n}`, i = (e == null ? void 0 : e.saveTo) ?? u.binaries(n);
803
+ if (f.existsSync(i))
801
804
  return a.info(`Platforma Backend archive download skipped: '${i}' already exists`), Promise.resolve(i);
802
- u.mkdirSync(m.dirname(i), { recursive: !0 }), a.info(`Downloading Platforma Backend archive:
805
+ f.mkdirSync(m.dirname(i), { recursive: !0 }), a.info(`Downloading Platforma Backend archive:
803
806
  URL: ${s}
804
807
  Save to: ${i}`);
805
- const c = Rr.get(s);
806
- return new Promise((o, f) => {
808
+ const c = Tr.get(s);
809
+ return new Promise((o, d) => {
807
810
  c.on("response", (g) => {
808
811
  if (!g.statusCode) {
809
812
  const y = new Error("failed to download archive: no HTTP status code in response from server");
810
- c.destroy(), f(y);
813
+ c.destroy(), d(y);
811
814
  return;
812
815
  }
813
816
  if (g.statusCode !== 200) {
814
817
  const y = new Error(`failed to download archive: ${g.statusCode} ${g.statusMessage}`);
815
- c.destroy(), f(y);
818
+ c.destroy(), d(y);
816
819
  return;
817
820
  }
818
821
  const h = parseInt(g.headers["content-length"] || "0", 10);
819
- let w = 0;
820
- const v = u.createWriteStream(i);
821
- g.pipe(v), g.on("data", (y) => {
822
- w += y.length;
823
- const P = w / h * 100;
822
+ let b = 0;
823
+ const w = f.createWriteStream(i);
824
+ g.pipe(w), g.on("data", (y) => {
825
+ b += y.length;
826
+ const P = b / h * 100;
824
827
  r && process.stdout.write(` downloading: ${P.toFixed(2)}%\r`);
825
828
  }), g.on("error", (y) => {
826
- u.unlinkSync(i), a.error(`Failed to download Platforma Binary: ${y.message}`), c.destroy(), f(y);
827
- }), v.on("finish", () => {
828
- v.close(), a.info(" ... download done."), c.destroy(), o(i);
829
+ f.unlinkSync(i), a.error(`Failed to download Platforma Binary: ${y.message}`), c.destroy(), d(y);
830
+ }), w.on("finish", () => {
831
+ w.close(), a.info(" ... download done."), c.destroy(), o(i);
829
832
  });
830
833
  });
831
834
  });
832
835
  }
833
- function st(a, e) {
836
+ function it(a, e) {
834
837
  a.debug("extracting archive...");
835
838
  const t = (e == null ? void 0 : e.version) ?? fe();
836
839
  a.debug(` version: '${t}'`);
837
- const r = `${Pr({ version: t })}.tgz`, n = (e == null ? void 0 : e.archivePath) ?? d.binaries(r);
840
+ const r = `${kr({ version: t })}.tgz`, n = (e == null ? void 0 : e.archivePath) ?? u.binaries(r);
838
841
  a.debug(` archive path: '${n}'`);
839
- const s = (e == null ? void 0 : e.extractTo) ?? ct(n);
840
- if (a.debug(` target dir: '${s}'`), u.existsSync(s))
842
+ const s = (e == null ? void 0 : e.extractTo) ?? ot(n);
843
+ if (a.debug(` target dir: '${s}'`), f.existsSync(s))
841
844
  return a.info(`Platforma Backend binaries unpack skipped: '${s}' exists`), s;
842
- if (!u.existsSync(n)) {
845
+ if (!f.existsSync(n)) {
843
846
  const i = `Platforma Backend binary archive not found at '${n}'`;
844
847
  throw a.error(i), new Error(i);
845
848
  }
846
- return u.existsSync(s) || (a.debug(` creating target dir '${s}'`), u.mkdirSync(s, { recursive: !0 })), a.info(`Unpacking Platforma Backend archive:
849
+ return f.existsSync(s) || (a.debug(` creating target dir '${s}'`), f.mkdirSync(s, { recursive: !0 })), a.info(`Unpacking Platforma Backend archive:
847
850
  Archive: ${n}
848
- Target dir: ${s}`), Tr.x({
851
+ Target dir: ${s}`), xr.x({
849
852
  file: n,
850
853
  cwd: s,
851
854
  gzip: !0,
852
855
  sync: !0
853
856
  }), a.info(" ... unpack done."), s;
854
857
  }
855
- function Ge(a, e) {
856
- return nt(a, e).then((t) => st(a, { archivePath: t }));
858
+ function ke(a, e) {
859
+ return st(a, e).then((t) => it(a, { archivePath: t }));
857
860
  }
858
- function Pr(a) {
859
- return `pl-${(a == null ? void 0 : a.version) ?? fe()}-${vr()}`;
861
+ function kr(a) {
862
+ return `pl-${(a == null ? void 0 : a.version) ?? fe()}-${Pr()}`;
860
863
  }
861
- function it(a, ...e) {
862
- return d.binaries(Pr({ version: a }), ...e);
864
+ function ct(a, ...e) {
865
+ return u.binaries(kr({ version: a }), ...e);
863
866
  }
864
- function ct(a) {
867
+ function ot(a) {
865
868
  const e = a.lastIndexOf(".");
866
869
  return e === -1 ? a : a.slice(0, e);
867
870
  }
@@ -870,7 +873,7 @@ class O {
870
873
  this.logger = e;
871
874
  }
872
875
  startLast() {
873
- const e = d.currentInstance;
876
+ const e = u.currentInstance;
874
877
  if (!e)
875
878
  throw this.logger.error("failed to bring back Platforma Backend in the last started configuration: no last configuration found"), new Error("no previous run info found");
876
879
  return this.startInstance(e);
@@ -881,57 +884,57 @@ class O {
881
884
  this.logger.info(`Starting platforma backend instance '${e.name}':
882
885
  ${r}`);
883
886
  }
884
- const t = we(
887
+ const t = Le(
885
888
  this.logger,
886
889
  e.upCommands
887
890
  );
888
- return ge(t.executed), t.spawned.length > 0 && e.type === "process" && (e.pid = t.spawned[t.spawned.length - 1].pid, d.setInstanceInfo(e.name, e), this.logger.info(`instance '${e.name}' started`)), d.currentInstanceName = e.name, t.spawned;
891
+ return ue(t.executed), t.spawned.length > 0 && e.type === "process" && (e.pid = t.spawned[t.spawned.length - 1].pid, u.setInstanceInfo(e.name, e), this.logger.info(`instance '${e.name}' started`)), u.currentInstanceName = e.name, t.spawned;
889
892
  }
890
893
  stopInstance(e) {
891
- if (!d.isInstanceActive(e)) {
894
+ if (!u.isInstanceActive(e)) {
892
895
  this.logger.info(`instance '${e.name}' is not running`);
893
896
  return;
894
897
  }
895
898
  this.logger.info(`stopping platforma backend instance '${e.name}'...`);
896
- const t = we(this.logger, e.downCommands);
897
- switch (ge(t.executed), e.type) {
899
+ const t = Le(this.logger, e.downCommands);
900
+ switch (ue(t.executed), e.type) {
898
901
  case "docker":
899
902
  return;
900
903
  case "process": {
901
- e.pid && d.isValidPID(e.pid) && process.kill(e.pid);
904
+ e.pid && u.isValidPID(e.pid) && process.kill(e.pid);
902
905
  return;
903
906
  }
904
907
  default:
905
- _();
908
+ G();
906
909
  }
907
910
  }
908
911
  switchInstance(e) {
909
- for (const t of d.instanceList)
912
+ for (const t of u.instanceList)
910
913
  if (t !== e.name) {
911
- const r = d.getInstanceInfo(t);
912
- d.isInstanceActive(r) && this.stopInstance(r);
914
+ const r = u.getInstanceInfo(t);
915
+ u.isInstanceActive(r) && this.stopInstance(r);
913
916
  }
914
917
  return this.startInstance(e);
915
918
  }
916
919
  createLocal(e, t) {
917
- var o, f, g, h, w, v, y, P, S, k;
918
- const r = (t == null ? void 0 : t.binaryPath) ?? it(t == null ? void 0 : t.version, "binaries", "platforma");
920
+ var o, d, g, h, b, w, y, P, S, k;
921
+ const r = (t == null ? void 0 : t.binaryPath) ?? ct(t == null ? void 0 : t.version, "binaries", "platforma");
919
922
  let n = t == null ? void 0 : t.configPath;
920
- const s = (t == null ? void 0 : t.workdir) ?? (n ? process.cwd() : d.instanceDir(e));
923
+ const s = (t == null ? void 0 : t.workdir) ?? (n ? process.cwd() : u.instanceDir(e));
921
924
  t != null && t.primaryURL && (t.configOptions = {
922
925
  ...t.configOptions,
923
926
  storages: {
924
927
  ...(o = t.configOptions) == null ? void 0 : o.storages,
925
- primary: Q(t.primaryURL, s, (g = (f = t.configOptions) == null ? void 0 : f.storages) == null ? void 0 : g.primary)
928
+ primary: X(t.primaryURL, s, (g = (d = t.configOptions) == null ? void 0 : d.storages) == null ? void 0 : g.primary)
926
929
  }
927
930
  }), t != null && t.libraryURL && (t.configOptions = {
928
931
  ...t.configOptions,
929
932
  storages: {
930
933
  ...(h = t.configOptions) == null ? void 0 : h.storages,
931
- library: Q(t.libraryURL, s, (v = (w = t.configOptions) == null ? void 0 : w.storages) == null ? void 0 : v.library)
934
+ library: X(t.libraryURL, s, (w = (b = t.configOptions) == null ? void 0 : b.storages) == null ? void 0 : w.library)
932
935
  }
933
936
  });
934
- const i = Zr(this.getLastJwt(), t == null ? void 0 : t.configOptions);
937
+ const i = et(this.getLastJwt(), t == null ? void 0 : t.configOptions);
935
938
  this.logger.debug(" checking license..."), this.checkLicense((P = (y = t == null ? void 0 : t.configOptions) == null ? void 0 : y.license) == null ? void 0 : P.value, (k = (S = t == null ? void 0 : t.configOptions) == null ? void 0 : S.license) == null ? void 0 : k.file);
936
939
  const c = [
937
940
  `${i.localRoot}/packages`,
@@ -940,10 +943,10 @@ ${r}`);
940
943
  ];
941
944
  i.storages.primary.type === "FS" && c.push(i.storages.primary.rootPath), i.storages.library.type === "FS" && (c.push(i.storages.library.rootPath), i.hacks.libraryDownloadable = !1), i.storages.work.type === "FS" && c.push(i.storages.work.rootPath), this.logger.debug(" creating pl state directories...");
942
945
  for (const p of c)
943
- u.existsSync(p) || (this.logger.debug(` '${p}'`), u.mkdirSync(p, { recursive: !0 }));
946
+ f.existsSync(p) || (this.logger.debug(` '${p}'`), f.mkdirSync(p, { recursive: !0 }));
944
947
  for (const p of i.core.auth.drivers)
945
- p.driver === "htpasswd" && (u.existsSync(p.path) || (this.logger.debug(` installing default 'users.htpasswd' to ${p.path}...`), u.copyFileSync(K("users.htpasswd"), p.path)));
946
- return n || (n = m.join(i.localRoot, "config.yaml"), this.logger.debug(` rendering configuration '${n}'...`), u.writeFileSync(n, et(i))), d.setInstanceInfo(e, {
948
+ p.driver === "htpasswd" && (f.existsSync(p.path) || (this.logger.debug(` installing default 'users.htpasswd' to ${p.path}...`), f.copyFileSync(Q("users.htpasswd"), p.path)));
949
+ return n || (n = m.join(i.localRoot, "config.yaml"), this.logger.debug(` rendering configuration '${n}'...`), f.writeFileSync(n, rt(i))), u.setInstanceInfo(e, {
947
950
  type: "process",
948
951
  upCommands: [
949
952
  {
@@ -965,7 +968,7 @@ ${r}`);
965
968
  work: i.storages.work,
966
969
  library: i.storages.library
967
970
  }
968
- }), d.getInstanceInfo(e);
971
+ }), u.getInstanceInfo(e);
969
972
  }
970
973
  createLocalS3(e, t) {
971
974
  var c;
@@ -988,12 +991,12 @@ ${r}`);
988
991
  ], n.cleanupCommands = [
989
992
  i.cleanup,
990
993
  ...n.cleanupCommands
991
- ], d.setInstanceInfo(e, n), n;
994
+ ], u.setInstanceInfo(e, n), n;
992
995
  }
993
996
  createMinio(e, t) {
994
997
  this.logger.debug(" creating docker compose for minio service...");
995
- const r = K("compose-backend.yaml"), n = d.instanceDir(e, "compose-minio.yaml");
996
- ve(
998
+ const r = Q("compose-backend.yaml"), n = u.instanceDir(e, "compose-minio.yaml");
999
+ Ie(
997
1000
  r,
998
1001
  n,
999
1002
  `pl-${e}-minio`,
@@ -1006,75 +1009,75 @@ ${r}`);
1006
1009
  this.logger.debug(` minio version: ${s}`);
1007
1010
  const i = (t == null ? void 0 : t.image) ?? `quay.io/minio/minio${s}`;
1008
1011
  this.logger.debug(` minio image: ${i}`);
1009
- const c = (t == null ? void 0 : t.storage) ?? d.instanceDir(e, "minio");
1010
- pe(c, { mode: "0775" });
1011
- const o = (t == null ? void 0 : t.minioPort) ?? 9e3, f = (t == null ? void 0 : t.minioConsolePort) ?? 9001, g = {
1012
+ const c = (t == null ? void 0 : t.storage) ?? u.instanceDir(e, "minio");
1013
+ Se(c, { mode: "0775" });
1014
+ const o = (t == null ? void 0 : t.minioPort) ?? 9e3, d = (t == null ? void 0 : t.minioConsolePort) ?? 9001, g = {
1012
1015
  MINIO_IMAGE: i,
1013
1016
  MINIO_STORAGE: m.resolve(c),
1014
1017
  MINIO_PORT: o.toString(),
1015
- MINIO_CONSOLE_PORT: f.toString()
1018
+ MINIO_CONSOLE_PORT: d.toString()
1016
1019
  };
1017
1020
  return {
1018
1021
  start: {
1019
1022
  cmd: "docker",
1020
1023
  args: ["compose", `--file=${n}`, "up", "--detach", "--remove-orphans", "--pull=missing"],
1021
1024
  envs: g,
1022
- workdir: d.instanceDir(e),
1025
+ workdir: u.instanceDir(e),
1023
1026
  runOpts: { stdio: "inherit" }
1024
1027
  },
1025
1028
  stop: {
1026
1029
  cmd: "docker",
1027
1030
  args: ["compose", `--file=${n}`, "down"],
1028
1031
  envs: g,
1029
- workdir: d.instanceDir(e),
1032
+ workdir: u.instanceDir(e),
1030
1033
  runOpts: { stdio: "inherit" }
1031
1034
  },
1032
1035
  cleanup: {
1033
1036
  cmd: "docker",
1034
1037
  args: ["compose", `--file=${n}`, "down", "--volumes", "--remove-orphans"],
1035
1038
  envs: g,
1036
- workdir: d.instanceDir(e),
1039
+ workdir: u.instanceDir(e),
1037
1040
  runOpts: { stdio: "inherit" }
1038
1041
  }
1039
1042
  };
1040
1043
  }
1041
1044
  buildPlatforma(e) {
1042
- const t = m.resolve(e.repoRoot, "cmd", "platforma"), r = e.binPath ?? m.join(x.tmpdir(), "platforma-local-build");
1045
+ const t = m.resolve(e.repoRoot, "cmd", "platforma"), r = e.binPath ?? m.join(F.tmpdir(), "platforma-local-build");
1043
1046
  this.logger.info("Building Platforma Backend binary from sources"), this.logger.info(` sources path: ${e.repoRoot}`), this.logger.info(` binary path: ${r}`);
1044
- const n = fr("go", ["build", "-o", r, "."], {
1047
+ const n = mr("go", ["build", "-o", r, "."], {
1045
1048
  cwd: t,
1046
1049
  stdio: "inherit"
1047
1050
  });
1048
- return ge([n], "failed to build platforma binary from sources using 'go build' command"), r;
1051
+ return ue([n], "failed to build platforma binary from sources using 'go build' command"), r;
1049
1052
  }
1050
1053
  createDockerS3(e, t, r) {
1051
1054
  this.logger.debug("creating platforma instance in 'docker s3' mode...");
1052
- const n = K("compose-backend.yaml"), s = (r == null ? void 0 : r.image) ?? dr(r == null ? void 0 : r.version);
1055
+ const n = Q("compose-backend.yaml"), s = (r == null ? void 0 : r.image) ?? gr(r == null ? void 0 : r.version);
1053
1056
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
1054
1057
  const i = (...p) => m.join(t, ...p), c = (p) => {
1055
1058
  const $ = i(p);
1056
- return pe($, { mode: "0775" }), $;
1059
+ return Se($, { mode: "0775" }), $;
1057
1060
  }, o = i("logs", "platforma.log");
1058
- u.existsSync(o) || (u.mkdirSync(m.dirname(o), { recursive: !0 }), u.writeFileSync(o, ""));
1059
- const f = (r == null ? void 0 : r.presignHost) ?? "localhost", g = Q("s3e://testuser:testpassword@minio:9000/main-bucket");
1061
+ f.existsSync(o) || (f.mkdirSync(m.dirname(o), { recursive: !0 }), f.writeFileSync(o, ""));
1062
+ const d = (r == null ? void 0 : r.presignHost) ?? "localhost", g = X("s3e://testuser:testpassword@minio:9000/main-bucket");
1060
1063
  if (g.type !== "S3")
1061
1064
  throw new Error("primary storage must have 'S3' type in 'docker s3' configuration");
1062
- g.presignEndpoint = `http://${f}:9000`;
1063
- const h = Q("s3e://testuser:testpassword@minio:9000/library-bucket");
1065
+ g.presignEndpoint = `http://${d}:9000`;
1066
+ const h = X("s3e://testuser:testpassword@minio:9000/library-bucket");
1064
1067
  if (h.type !== "S3")
1065
1068
  throw new Error(`${h.type} storage type is not supported for library storage`);
1066
- h.presignEndpoint = `http://${f}:9000`;
1067
- const w = c("db"), v = c("work"), y = i("users.htpasswd");
1068
- u.existsSync(y) || u.copyFileSync(K("users.htpasswd"), y);
1069
+ h.presignEndpoint = `http://${d}:9000`;
1070
+ const b = c("db"), w = c("work"), y = i("users.htpasswd");
1071
+ f.existsSync(y) || f.copyFileSync(Q("users.htpasswd"), y);
1069
1072
  const P = i("compose.yaml");
1070
- u.existsSync(P) && this.logger.info(`replacing docker compose file ${P}`);
1073
+ f.existsSync(P) && this.logger.info(`replacing docker compose file ${P}`);
1071
1074
  const S = [];
1072
1075
  for (const p of (r == null ? void 0 : r.customMounts) ?? [])
1073
1076
  S.push({
1074
1077
  hostPath: p.hostPath,
1075
1078
  containerPath: p.containerPath ?? p.hostPath
1076
1079
  });
1077
- ve(n, P, `pl-${e}`, /* @__PURE__ */ new Map([
1080
+ Ie(n, P, `pl-${e}`, /* @__PURE__ */ new Map([
1078
1081
  ["minio", {}],
1079
1082
  ["backend", {
1080
1083
  platform: r == null ? void 0 : r.platformOverride,
@@ -1091,10 +1094,10 @@ ${r}`);
1091
1094
  PL_LOG_LEVEL: (r == null ? void 0 : r.logLevel) ?? "info",
1092
1095
  PL_LOG_DIR: m.dirname(o),
1093
1096
  PL_LOG_ROTATION_ENABLED: "true",
1094
- PL_DATA_DB_ROOT: w,
1097
+ PL_DATA_DB_ROOT: b,
1095
1098
  PL_DATA_PRIMARY_ROOT: c("primary"),
1096
1099
  PL_DATA_LIBRARY_ROOT: c("library"),
1097
- PL_DATA_WORKDIR_ROOT: v,
1100
+ PL_DATA_WORKDIR_ROOT: w,
1098
1101
  // Mount packages storage as volume, because APFS is case-insensitive on Mac OS X and this breaks some pl software installation.
1099
1102
  // PL_DATA_PACKAGE_ROOT: storageDir('packages'),
1100
1103
  ...this.configureDockerStorage("primary", g),
@@ -1105,7 +1108,7 @@ ${r}`);
1105
1108
  p.driver === "htpasswd" && (k.PL_AUTH_HTPASSWD_PATH = m.resolve(p.path), p.path = "/etc/platforma/users.htpasswd");
1106
1109
  k.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
1107
1110
  }
1108
- return d.setInstanceInfo(e, {
1111
+ return u.setInstanceInfo(e, {
1109
1112
  type: "docker",
1110
1113
  upCommands: [{
1111
1114
  cmd: "docker",
@@ -1130,51 +1133,51 @@ ${r}`);
1130
1133
  apiAddr: r == null ? void 0 : r.grpcAddr,
1131
1134
  logPath: o,
1132
1135
  primary: g,
1133
- work: { type: "FS", rootPath: v },
1136
+ work: { type: "FS", rootPath: w },
1134
1137
  library: h,
1135
- dbPath: w
1138
+ dbPath: b
1136
1139
  }
1137
- }), d.getInstanceInfo(e);
1140
+ }), u.getInstanceInfo(e);
1138
1141
  }
1139
1142
  createDocker(e, t, r) {
1140
1143
  this.logger.debug("creating platforma instance in 'docker' mode...");
1141
- const n = K("compose-backend.yaml"), s = (r == null ? void 0 : r.image) ?? dr(r == null ? void 0 : r.version);
1144
+ const n = Q("compose-backend.yaml"), s = (r == null ? void 0 : r.image) ?? gr(r == null ? void 0 : r.version);
1142
1145
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
1143
1146
  const i = (...$) => m.join(t, ...$), c = ($) => {
1144
- const se = i($);
1145
- return pe(se, { mode: "0775" }), se;
1147
+ const le = i($);
1148
+ return Se(le, { mode: "0775" }), le;
1146
1149
  }, o = i("logs", "platforma.log");
1147
- u.existsSync(o) || (u.mkdirSync(m.dirname(o), { recursive: !0 }), u.writeFileSync(o, ""));
1148
- const f = c("db"), g = c("primary"), h = c("library"), w = c("work"), v = i("users.htpasswd");
1149
- u.existsSync(v) || u.copyFileSync(K("users.htpasswd"), v);
1150
+ f.existsSync(o) || (f.mkdirSync(m.dirname(o), { recursive: !0 }), f.writeFileSync(o, ""));
1151
+ const d = c("db"), g = c("primary"), h = c("library"), b = c("work"), w = i("users.htpasswd");
1152
+ f.existsSync(w) || f.copyFileSync(Q("users.htpasswd"), w);
1150
1153
  const y = i("compose.yaml");
1151
- u.existsSync(y) && this.logger.info(`replacing docker compose file ${y}`);
1154
+ f.existsSync(y) && this.logger.info(`replacing docker compose file ${y}`);
1152
1155
  const P = [];
1153
1156
  for (const $ of (r == null ? void 0 : r.customMounts) ?? [])
1154
1157
  P.push({
1155
1158
  hostPath: $.hostPath,
1156
1159
  containerPath: $.containerPath ?? $.hostPath
1157
1160
  });
1158
- this.logger.debug(`Rendering docker compose file '${y}' using '${n}' as base template`), ve(n, y, `pl-${e}`, /* @__PURE__ */ new Map([
1161
+ this.logger.debug(`Rendering docker compose file '${y}' using '${n}' as base template`), Ie(n, y, `pl-${e}`, /* @__PURE__ */ new Map([
1159
1162
  ["backend", {
1160
1163
  platform: r == null ? void 0 : r.platformOverride,
1161
1164
  mounts: P
1162
1165
  }]
1163
1166
  ]));
1164
- const S = Q((r == null ? void 0 : r.primaryStorageURL) ?? `file:${g}`, "."), k = Q((r == null ? void 0 : r.libraryStorageURL) ?? `file:${h}`, "."), p = {
1167
+ const S = X((r == null ? void 0 : r.primaryStorageURL) ?? `file:${g}`, "."), k = X((r == null ? void 0 : r.libraryStorageURL) ?? `file:${h}`, "."), p = {
1165
1168
  MINIO_IMAGE: "quay.io/minio/minio",
1166
1169
  MINIO_STORAGE: c("minio"),
1167
1170
  PL_IMAGE: s,
1168
- PL_AUTH_HTPASSWD_PATH: v,
1171
+ PL_AUTH_HTPASSWD_PATH: w,
1169
1172
  PL_LICENSE: r == null ? void 0 : r.license,
1170
1173
  PL_LICENSE_FILE: r == null ? void 0 : r.licenseFile,
1171
1174
  PL_LOG_LEVEL: "info",
1172
1175
  PL_LOG_DIR: m.dirname(o),
1173
1176
  PL_LOG_ROTATION_ENABLED: "true",
1174
- PL_DATA_DB_ROOT: f,
1177
+ PL_DATA_DB_ROOT: d,
1175
1178
  PL_DATA_PRIMARY_ROOT: g,
1176
1179
  PL_DATA_LIBRARY_ROOT: h,
1177
- PL_DATA_WORKDIR_ROOT: w,
1180
+ PL_DATA_WORKDIR_ROOT: b,
1178
1181
  PL_DATA_PACKAGE_ROOT: c("packages"),
1179
1182
  ...this.configureDockerStorage("primary", S),
1180
1183
  ...this.configureDockerStorage("library", k)
@@ -1184,7 +1187,7 @@ ${r}`);
1184
1187
  $.driver === "htpasswd" && (p.PL_AUTH_HTPASSWD_PATH = m.resolve($.path), $.path = "/etc/platforma/users.htpasswd");
1185
1188
  p.PL_AUTH_DRIVERS = JSON.stringify(r.auth.drivers);
1186
1189
  }
1187
- return d.setInstanceInfo(e, {
1190
+ return u.setInstanceInfo(e, {
1188
1191
  type: "docker",
1189
1192
  upCommands: [{
1190
1193
  cmd: "docker",
@@ -1209,30 +1212,30 @@ ${r}`);
1209
1212
  apiAddr: r == null ? void 0 : r.grpcAddr,
1210
1213
  logPath: o,
1211
1214
  primary: S,
1212
- work: { type: "FS", rootPath: w },
1215
+ work: { type: "FS", rootPath: b },
1213
1216
  library: k,
1214
- dbPath: f
1217
+ dbPath: d
1215
1218
  }
1216
- }), d.getInstanceInfo(e);
1219
+ }), u.getInstanceInfo(e);
1217
1220
  }
1218
1221
  cleanupInstance(e) {
1219
1222
  const t = [], r = /* @__PURE__ */ new Map();
1220
1223
  let n = "";
1221
1224
  if (e) {
1222
- const s = d.getInstanceInfo(e);
1225
+ const s = u.getInstanceInfo(e);
1223
1226
  switch (r.set(e, s), s.type) {
1224
1227
  case "docker": {
1225
- t.push(`docker service 'pl-${e}', including all its volumes and data in '${d.instanceDir(e)}' will be destroyed`);
1228
+ t.push(`docker service 'pl-${e}', including all its volumes and data in '${u.instanceDir(e)}' will be destroyed`);
1226
1229
  break;
1227
1230
  }
1228
1231
  case "process": {
1229
- t.push(`directory '${d.instanceDir(e)}' would be deleted`), s.downCommands && t.push("associated docker service, including all volumes and data will be destroyed");
1232
+ t.push(`directory '${u.instanceDir(e)}' would be deleted`), s.downCommands && t.push("associated docker service, including all volumes and data will be destroyed");
1230
1233
  break;
1231
1234
  }
1232
1235
  default:
1233
- _();
1236
+ G();
1234
1237
  }
1235
- e === d.currentInstanceName && t.push(
1238
+ e === u.currentInstanceName && t.push(
1236
1239
  "last command run cache ('pl-dev start' shorthand will stop working until next full start command call)"
1237
1240
  ), n = `
1238
1241
  You are going to reset the state of platforma service '${e}':
@@ -1240,37 +1243,37 @@ You are going to reset the state of platforma service '${e}':
1240
1243
  - `)}
1241
1244
  `;
1242
1245
  } else {
1243
- for (const s of d.instanceList)
1244
- r.set(s, d.getInstanceInfo(s));
1246
+ for (const s of u.instanceList)
1247
+ r.set(s, u.getInstanceInfo(s));
1245
1248
  t.push(
1246
1249
  "last command run cache ('pl-dev start' shorthand will stop working until next full start command call)",
1247
- `all service configurations stored in: ${d.instanceDir()} (including all associated docker containers and volumes)`
1250
+ `all service configurations stored in: ${u.instanceDir()} (including all associated docker containers and volumes)`
1248
1251
  ), n = `
1249
1252
  You are going to reset the state of all platforma services configured with pl-bootstrap package.
1250
1253
  - ${t.join(`
1251
1254
  - `)}
1252
1255
  `;
1253
1256
  }
1254
- if (this.logger.warn(n), !_r("Are you sure?")) {
1257
+ if (this.logger.warn(n), !Cr("Are you sure?")) {
1255
1258
  this.logger.info("Reset action was canceled");
1256
1259
  return;
1257
1260
  }
1258
1261
  for (const [s, i] of r.entries()) {
1259
1262
  if (i.cleanupCommands.length) {
1260
1263
  this.logger.info(`Wiping instance ${s} services`);
1261
- const c = we(this.logger, i.cleanupCommands);
1262
- ge(c.executed, `failed to wipe instance ${s} services`);
1264
+ const c = Le(this.logger, i.cleanupCommands);
1265
+ ue(c.executed, `failed to wipe instance ${s} services`);
1263
1266
  }
1264
- this.logger.info(`Destroying instance '${s}' data directory`), u.rmSync(d.instanceDir(s), { recursive: !0, force: !0 });
1267
+ this.logger.info(`Destroying instance '${s}' data directory`), f.rmSync(u.instanceDir(s), { recursive: !0, force: !0 });
1265
1268
  }
1266
- e || (this.logger.info(`Destroying state dir '${d.path()}'`), u.rmSync(d.path(), { recursive: !0, force: !0 })), this.logger.info(
1269
+ e || (this.logger.info(`Destroying state dir '${u.path()}'`), f.rmSync(u.path(), { recursive: !0, force: !0 })), this.logger.info(
1267
1270
  `
1268
- If you want to remove all downloaded platforma binaries, delete '${d.binaries()}' dir manually
1271
+ If you want to remove all downloaded platforma binaries, delete '${u.binaries()}' dir manually
1269
1272
  `
1270
1273
  );
1271
1274
  }
1272
1275
  mergeLicenseEnvs(e) {
1273
- 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 : u.existsSync(m.resolve(x.homedir(), ".pl.license")) && (e["license-file"] = m.resolve(x.homedir(), ".pl.license")));
1276
+ 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 : f.existsSync(m.resolve(F.homedir(), ".pl.license")) && (e["license-file"] = m.resolve(F.homedir(), ".pl.license")));
1274
1277
  }
1275
1278
  initAuthDriversList(e, t) {
1276
1279
  const r = [];
@@ -1288,9 +1291,9 @@ If you want to remove all downloaded platforma binaries, delete '${d.binaries()}
1288
1291
  }
1289
1292
  /** Gets the last stored JWT secret key or generates it and stores in a file. */
1290
1293
  getLastJwt() {
1291
- const e = d.path("auth.jwt"), t = "utf-8";
1294
+ const e = u.path("auth.jwt"), t = "utf-8";
1292
1295
  let r = "";
1293
- return u.existsSync(e) && (r = u.readFileSync(e, { encoding: t })), r == "" && (r = Cr(64), u.writeFileSync(e, r, { encoding: t })), r;
1296
+ return f.existsSync(e) && (r = f.readFileSync(e, { encoding: t })), r == "" && (r = Mr(64), f.writeFileSync(e, r, { encoding: t })), r;
1294
1297
  }
1295
1298
  checkLicense(e, t) {
1296
1299
  if (!(e !== void 0 && e != "") && !(t !== void 0 && t != ""))
@@ -1314,13 +1317,13 @@ You can obtain the license from "https://licensing.milaboratories.com".`), new E
1314
1317
  case "FS":
1315
1318
  return r[`PL_DATA_${e}_TYPE`] = "FS", r;
1316
1319
  default:
1317
- _();
1320
+ G();
1318
1321
  }
1319
1322
  return {};
1320
1323
  }
1321
1324
  renderRunInfo(e, t = 10) {
1322
1325
  var c, o;
1323
- const r = [], n = (f) => f.padStart(t, " ");
1326
+ const r = [], n = (d) => d.padStart(t, " ");
1324
1327
  switch (e.configPath && r.push(`${n("config")}: ${e.configPath}`), e.apiAddr ? r.push(`${n("API")}: ${e.apiAddr}`) : e.apiPort ? r.push(`${n("API")}: 127.0.0.1:${e.apiPort.toString()}`) : r.push(`${n("API")}: 127.0.0.1:6345`), e.logPath && r.push(`${n("log")}: ${e.logPath}`), (c = e.primary) == null ? void 0 : c.type) {
1325
1328
  case void 0:
1326
1329
  break;
@@ -1333,7 +1336,7 @@ You can obtain the license from "https://licensing.milaboratories.com".`), new E
1333
1336
  );
1334
1337
  break;
1335
1338
  default:
1336
- _();
1339
+ G();
1337
1340
  }
1338
1341
  switch ((o = e.library) == null ? void 0 : o.type) {
1339
1342
  case void 0:
@@ -1347,21 +1350,13 @@ You can obtain the license from "https://licensing.milaboratories.com".`), new E
1347
1350
  );
1348
1351
  break;
1349
1352
  default:
1350
- _();
1353
+ G();
1351
1354
  }
1352
1355
  return e.work && r.push(`${n("workdirs")}: ${e.work.rootPath}`), e.dbPath && r.push(`${n("db")}: ${e.dbPath}`), r.join(`
1353
1356
  `);
1354
1357
  }
1355
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1356
- readComposeFile(e) {
1357
- const t = u.readFileSync(e);
1358
- return ue.parse(t.toString());
1359
- }
1360
- writeComposeFile(e, t) {
1361
- u.writeFileSync(e, ue.stringify(t));
1362
- }
1363
1358
  }
1364
- function ge(a, e) {
1359
+ function ue(a, e) {
1365
1360
  for (const t of a) {
1366
1361
  if (t.error)
1367
1362
  throw t.error;
@@ -1370,54 +1365,54 @@ function ge(a, e) {
1370
1365
  throw new Error(`${r}, process exited with code '${t.status}'`);
1371
1366
  }
1372
1367
  }
1373
- const re = class re extends L {
1368
+ const te = class te extends L {
1374
1369
  async run() {
1375
- const { flags: e } = await this.parse(re), t = I(e["log-level"]);
1370
+ const { flags: e } = await this.parse(te), t = A(e["log-level"]);
1376
1371
  new O(t).cleanupInstance();
1377
1372
  }
1378
1373
  };
1379
- l(re, "description", "Clear service state (forget last run command, destroy docker services, volumes and so on)"), l(re, "examples", ["<%= config.bin %> <%= command.id %>"]), l(re, "flags", {
1380
- ...A
1374
+ l(te, "description", "Clear service state (forget last run command, destroy docker services, volumes and so on)"), l(te, "examples", ["<%= config.bin %> <%= command.id %>"]), l(te, "flags", {
1375
+ ...I
1381
1376
  });
1382
- let Le = re;
1383
- const te = class te extends L {
1377
+ let Te = te;
1378
+ const ae = class ae extends L {
1384
1379
  async run() {
1385
- const { flags: e } = await this.parse(te), t = I(e["log-level"]);
1380
+ const { flags: e } = await this.parse(ae), t = A(e["log-level"]);
1386
1381
  new O(t).startLast();
1387
1382
  }
1388
1383
  };
1389
- l(te, "description", "Start last run service configuraiton"), l(te, "examples", ["<%= config.bin %> <%= command.id %>"]), l(te, "flags", {
1390
- ...A
1384
+ l(ae, "description", "Start last run service configuraiton"), l(ae, "examples", ["<%= config.bin %> <%= command.id %>"]), l(ae, "flags", {
1385
+ ...I
1391
1386
  });
1392
- let Ae = te;
1393
- const ae = class ae extends L {
1387
+ let xe = ae;
1388
+ const ne = class ne extends L {
1394
1389
  async run() {
1395
- const { flags: e } = await this.parse(ae), t = I(e["log-level"]), r = new O(t);
1396
- d.currentInstance ? r.stopInstance(d.currentInstance) : t.warn("up/start command was not called for any instance, nothing to stop");
1390
+ const { flags: e } = await this.parse(ne), t = A(e["log-level"]), r = new O(t);
1391
+ u.currentInstance ? r.stopInstance(u.currentInstance) : t.warn("up/start command was not called for any instance, nothing to stop");
1397
1392
  }
1398
1393
  };
1399
- l(ae, "description", "Stop platforma service"), l(ae, "examples", ["<%= config.bin %> <%= command.id %>"]), l(ae, "flags", {
1400
- ...A
1394
+ l(ne, "description", "Stop platforma service"), l(ne, "examples", ["<%= config.bin %> <%= command.id %>"]), l(ne, "flags", {
1395
+ ...I
1401
1396
  });
1402
- let Ie = ae;
1397
+ let De = ne;
1403
1398
  var E;
1404
- let ot = (E = class extends L {
1399
+ let lt = (E = class extends L {
1405
1400
  async run() {
1406
- const { flags: e } = await this.parse(E), t = I(e["log-level"]), r = new O(t);
1401
+ const { flags: e } = await this.parse(E), t = A(e["log-level"]), r = new O(t);
1407
1402
  r.mergeLicenseEnvs(e);
1408
1403
  const n = "docker", s = e["auth-enabled"], i = s ? {
1409
1404
  enabled: s,
1410
1405
  drivers: r.initAuthDriversList(e, ".")
1411
- } : void 0, c = e.storage ? m.join(".", e.storage) : d.instanceDir(n), o = [];
1406
+ } : void 0, c = e.storage ? m.join(".", e.storage) : u.instanceDir(n), o = [];
1412
1407
  for (const h of e.mount ?? [])
1413
1408
  o.push({ hostPath: h });
1414
- const f = e.arch ? `linux/${e.arch}` : void 0, g = r.createDocker(n, c, {
1409
+ const d = e.arch ? `linux/${e.arch}` : void 0, g = r.createDocker(n, c, {
1415
1410
  primaryStorageURL: e["storage-primary"],
1416
1411
  workStoragePath: e["storage-work"],
1417
1412
  libraryStorageURL: e["storage-library"],
1418
1413
  image: e.image,
1419
1414
  version: e.version,
1420
- platformOverride: f,
1415
+ platformOverride: d,
1421
1416
  customMounts: o,
1422
1417
  license: e.license,
1423
1418
  licenseFile: e["license-file"],
@@ -1432,33 +1427,33 @@ let ot = (E = class extends L {
1432
1427
  r.switchInstance(g);
1433
1428
  }
1434
1429
  }, l(E, "description", "Run platforma backend service with 'FS' primary storage type"), l(E, "examples", ["<%= config.bin %> <%= command.id %>"]), l(E, "flags", {
1435
- ...A,
1436
- ...z,
1430
+ ...I,
1431
+ ...j,
1437
1432
  ...me,
1438
- ...W,
1433
+ ...C,
1439
1434
  ...he,
1440
- ...V,
1441
- ...q,
1435
+ ...U,
1436
+ ...M,
1442
1437
  ...ye,
1443
- ...Y,
1444
- ...oe,
1438
+ ...B,
1445
1439
  ...ce,
1446
- ...le
1440
+ ...ie,
1441
+ ...oe
1447
1442
  }), E);
1448
- var R;
1449
- let lt = (R = class extends L {
1443
+ var T;
1444
+ let dt = (T = class extends L {
1450
1445
  async run() {
1451
- const { flags: e } = await this.parse(R), t = I(e["log-level"]), r = new O(t);
1446
+ const { flags: e } = await this.parse(T), t = A(e["log-level"]), r = new O(t);
1452
1447
  r.mergeLicenseEnvs(e);
1453
- const n = "local", s = e["pl-workdir"] ?? ".", i = e.storage ? m.join(s, e.storage) : d.instanceDir(n), c = e["pl-log-file"] ? m.join(s, e["pl-log-file"]) : void 0, o = r.initAuthDriversList(e, s), f = e["auth-enabled"] ?? o !== void 0;
1448
+ const n = "local", s = e["pl-workdir"] ?? ".", i = e.storage ? m.join(s, e.storage) : u.instanceDir(n), c = e["pl-log-file"] ? m.join(s, e["pl-log-file"]) : void 0, o = r.initAuthDriversList(e, s), d = e["auth-enabled"] ?? o !== void 0;
1454
1449
  let g = e["pl-binary"];
1455
1450
  e["pl-sources"] && (g = r.buildPlatforma({ repoRoot: e["pl-sources"] }));
1456
1451
  let h = "127.0.0.1:6345";
1457
1452
  e["grpc-listen"] ? h = e["grpc-listen"] : e["grpc-port"] && (h = `127.0.0.1:${e["grpc-port"]}`);
1458
- let w = "127.0.0.1:9090";
1459
- e["monitoring-listen"] ? w = e["monitoring-listen"] : e["monitoring-port"] && (w = `127.0.0.1:${e["monitoring-port"]}`);
1460
- let v = "127.0.0.1:9091";
1461
- e["debug-listen"] ? v = e["debug-listen"] : e["debug-port"] && (v = `127.0.0.1:${e["debug-port"]}`);
1453
+ let b = "127.0.0.1:9090";
1454
+ e["monitoring-listen"] ? b = e["monitoring-listen"] : e["monitoring-port"] && (b = `127.0.0.1:${e["monitoring-port"]}`);
1455
+ let w = "127.0.0.1:9091";
1456
+ e["debug-listen"] ? w = e["debug-listen"] : e["debug-port"] && (w = `127.0.0.1:${e["debug-port"]}`);
1462
1457
  const y = {
1463
1458
  binaryPath: g,
1464
1459
  version: e.version,
@@ -1468,18 +1463,18 @@ let lt = (R = class extends L {
1468
1463
  libraryURL: e["storage-library"],
1469
1464
  configOptions: {
1470
1465
  grpc: { listen: h },
1471
- monitoring: { listen: w },
1472
- debug: { listen: v },
1466
+ monitoring: { listen: b },
1467
+ debug: { listen: w },
1473
1468
  license: { value: e.license, file: e["license-file"] },
1474
1469
  log: { path: c },
1475
1470
  localRoot: i,
1476
- core: { auth: { enabled: f, drivers: o } },
1471
+ core: { auth: { enabled: d, drivers: o } },
1477
1472
  storages: {
1478
1473
  work: { type: "FS", rootPath: e["storage-work"] }
1479
1474
  }
1480
1475
  }
1481
1476
  }, P = r.createLocal(n, y);
1482
- y.binaryPath ? r.switchInstance(P) : Ge(t, { version: e.version }).then(() => {
1477
+ y.binaryPath ? r.switchInstance(P) : ke(t, { version: e.version }).then(() => {
1483
1478
  const S = r.switchInstance(P);
1484
1479
  setTimeout(() => {
1485
1480
  for (const k of S)
@@ -1489,96 +1484,97 @@ let lt = (R = class extends L {
1489
1484
  t.error(S.message);
1490
1485
  });
1491
1486
  }
1492
- }, l(R, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(R, "examples", ["<%= config.bin %> <%= command.id %>"]), l(R, "flags", {
1493
- ...A,
1494
- ...W,
1495
- ...z,
1496
- ...Ce,
1497
- ...Me,
1498
- ...je,
1499
- ...q,
1500
- ...Y,
1501
- ...oe,
1487
+ }, l(T, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(T, "examples", ["<%= config.bin %> <%= command.id %>"]), l(T, "flags", {
1488
+ ...I,
1489
+ ...C,
1490
+ ...j,
1491
+ ...we,
1492
+ ...ve,
1493
+ ...Pe,
1494
+ ...M,
1495
+ ...B,
1502
1496
  ...ce,
1503
- ...le,
1504
- ...Ne,
1505
- ..._e,
1506
- ...V
1507
- }), R);
1508
- const M = class M extends L {
1497
+ ...ie,
1498
+ ...oe,
1499
+ ...pe,
1500
+ ...be,
1501
+ ...U
1502
+ }), T);
1503
+ const H = class H extends L {
1509
1504
  async run() {
1510
- const { flags: e, args: t } = await this.parse(M), r = I(e["log-level"]), n = new O(r), s = t.name;
1505
+ const { flags: e, args: t } = await this.parse(H), r = A(e["log-level"]), n = new O(r), s = t.name;
1511
1506
  e.all && (n.cleanupInstance(), process.exit(0)), s || (r.error("Please, specify name of instance to be removed or set '--all' flag instead"), process.exit(1)), n.cleanupInstance(s);
1512
1507
  }
1513
1508
  };
1514
- l(M, "description", "List available instances"), l(M, "examples", ["<%= config.bin %> <%= command.id %>"]), l(M, "flags", {
1515
- ...A,
1516
- all: b.boolean({
1509
+ l(H, "description", "List available instances"), l(H, "examples", ["<%= config.bin %> <%= command.id %>"]), l(H, "flags", {
1510
+ ...I,
1511
+ all: v.boolean({
1517
1512
  description: "remove all known instances",
1518
1513
  required: !1
1519
1514
  })
1520
- }), l(M, "args", {
1521
- name: H.string({ required: !1 })
1515
+ }), l(H, "args", {
1516
+ name: K.string({ required: !1 })
1522
1517
  });
1523
- let Oe = M;
1524
- const j = class j extends L {
1518
+ let Fe = H;
1519
+ const W = class W extends L {
1525
1520
  async run() {
1526
- const { flags: e, args: t } = await this.parse(j), r = I(e["log-level"]), n = new O(r), s = t.name ?? d.currentInstanceName;
1527
- s || (r.info("no pl service instance selected. No service was stopped"), process.exit(0)), n.stopInstance(d.getInstanceInfo(s));
1521
+ const { flags: e, args: t } = await this.parse(W), r = A(e["log-level"]), n = new O(r), s = t.name ?? u.currentInstanceName;
1522
+ s || (r.info("no pl service instance selected. No service was stopped"), process.exit(0)), n.stopInstance(u.getInstanceInfo(s));
1528
1523
  }
1529
1524
  };
1530
- l(j, "description", "List available instances"), l(j, "examples", ["<%= config.bin %> <%= command.id %>"]), l(j, "flags", {
1531
- ...A
1532
- }), l(j, "args", {
1533
- name: H.string({ required: !1 })
1525
+ l(W, "description", "List available instances"), l(W, "examples", ["<%= config.bin %> <%= command.id %>"]), l(W, "flags", {
1526
+ ...I
1527
+ }), l(W, "args", {
1528
+ name: K.string({ required: !1 })
1534
1529
  });
1535
- let Ee = j;
1536
- const ne = class ne extends L {
1530
+ let Ne = W;
1531
+ const se = class se extends L {
1537
1532
  async run() {
1538
- await this.parse(ne);
1539
- const e = d.instanceList, t = d.currentInstanceName;
1533
+ await this.parse(se);
1534
+ const e = u.instanceList, t = u.currentInstanceName;
1540
1535
  for (const r of e) {
1541
- const n = [], s = d.getInstanceInfo(r);
1542
- d.isInstanceActive(s) && n.push("status:up"), n.push(`type:${s.type}`), console.log(r === t ? ` * ${r} (${n.join(", ")})` : ` ${r} (${n.join(", ")})`);
1536
+ const n = [], s = u.getInstanceInfo(r);
1537
+ u.isInstanceActive(s) && n.push("status:up"), n.push(`type:${s.type}`), console.log(r === t ? ` * ${r} (${n.join(", ")})` : ` ${r} (${n.join(", ")})`);
1543
1538
  }
1544
1539
  }
1545
1540
  };
1546
- l(ne, "description", "List available instances"), l(ne, "examples", ["<%= config.bin %> <%= command.id %>"]), l(ne, "flags", {});
1547
- let Re = ne;
1548
- const B = class B extends L {
1541
+ l(se, "description", "List available instances"), l(se, "examples", ["<%= config.bin %> <%= command.id %>"]), l(se, "flags", {});
1542
+ let _e = se;
1543
+ const q = class q extends L {
1549
1544
  async run() {
1550
- const { flags: e, args: t } = await this.parse(B), r = I(e["log-level"]), n = new O(r), s = t.name ?? d.currentInstanceName;
1545
+ const { flags: e, args: t } = await this.parse(q), r = A(e["log-level"]), n = new O(r), s = t.name ?? u.currentInstanceName;
1551
1546
  s || (r.error("no pl service instance is selected. Select instance with 'select' command or provide name to 'up'"), process.exit(1));
1552
- const i = n.switchInstance(d.getInstanceInfo(s));
1553
- setTimeout(() => {
1554
- for (const c of i)
1555
- c.unref();
1556
- }, 1e3);
1547
+ const i = n.switchInstance(u.getInstanceInfo(s)), c = [];
1548
+ for (const o of i)
1549
+ c.push(new Promise((d, g) => {
1550
+ o.on("close", d), o.on("error", g);
1551
+ }));
1552
+ await Promise.all(c);
1557
1553
  }
1558
1554
  };
1559
- l(B, "description", "List available instances"), l(B, "examples", ["<%= config.bin %> <%= command.id %>"]), l(B, "flags", {
1560
- ...A
1561
- }), l(B, "args", {
1562
- name: H.string({ required: !1 })
1555
+ l(q, "description", "List available instances"), l(q, "examples", ["<%= config.bin %> <%= command.id %>"]), l(q, "flags", {
1556
+ ...I
1557
+ }), l(q, "args", {
1558
+ name: K.string({ required: !1 })
1563
1559
  });
1564
- let Te = B;
1565
- var T;
1566
- let dt = (T = class extends L {
1560
+ let Ce = q;
1561
+ var x;
1562
+ let gt = (x = class extends L {
1567
1563
  async run() {
1568
- const { flags: e } = await this.parse(T), t = I(e["log-level"]), r = new O(t);
1564
+ const { flags: e } = await this.parse(x), t = A(e["log-level"]), r = new O(t);
1569
1565
  r.mergeLicenseEnvs(e);
1570
1566
  const n = "docker-s3", s = e["auth-enabled"], i = s ? {
1571
1567
  enabled: s,
1572
1568
  drivers: r.initAuthDriversList(e, ".")
1573
- } : void 0, c = e.storage ? m.join(".", e.storage) : d.instanceDir(n), o = [];
1574
- for (const w of e.mount ?? [])
1575
- o.push({ hostPath: w });
1576
- const f = e.arch ? `linux/${e.arch}` : void 0, g = e["minio-presign-host"] ? "minio" : "localhost", h = r.createDockerS3(n, c, {
1569
+ } : void 0, c = e.storage ? m.join(".", e.storage) : u.instanceDir(n), o = [];
1570
+ for (const b of e.mount ?? [])
1571
+ o.push({ hostPath: b });
1572
+ const d = e.arch ? `linux/${e.arch}` : void 0, g = e["minio-presign-host"] ? "minio" : "localhost", h = r.createDockerS3(n, c, {
1577
1573
  image: e.image,
1578
1574
  version: e.version,
1579
1575
  license: e.license,
1580
1576
  licenseFile: e["license-file"],
1581
- platformOverride: f,
1577
+ platformOverride: d,
1582
1578
  customMounts: o,
1583
1579
  auth: i,
1584
1580
  grpcAddr: e["grpc-listen"],
@@ -1591,32 +1587,32 @@ let dt = (T = class extends L {
1591
1587
  });
1592
1588
  r.switchInstance(h);
1593
1589
  }
1594
- }, l(T, "description", "Run platforma backend service with 'S3' primary storage type"), l(T, "examples", ["<%= config.bin %> <%= command.id %>"]), l(T, "flags", {
1595
- ...A,
1596
- ...z,
1590
+ }, l(x, "description", "Run platforma backend service with 'S3' primary storage type"), l(x, "examples", ["<%= config.bin %> <%= command.id %>"]), l(x, "flags", {
1591
+ ...I,
1592
+ ...j,
1597
1593
  ...me,
1598
- ...W,
1594
+ ...C,
1599
1595
  ...he,
1600
- ...V,
1601
- ...q,
1596
+ ...U,
1597
+ ...M,
1602
1598
  ...ye,
1603
- ...Y,
1604
- ...hr
1605
- }), T);
1606
- var F;
1607
- let gt = (F = class extends L {
1599
+ ...B,
1600
+ ...yr
1601
+ }), x);
1602
+ var D;
1603
+ let ut = (D = class extends L {
1608
1604
  async run() {
1609
- const { flags: e } = await this.parse(F), t = I(e["log-level"]), r = new O(t);
1605
+ const { flags: e } = await this.parse(D), t = A(e["log-level"]), r = new O(t);
1610
1606
  r.mergeLicenseEnvs(e);
1611
- const n = "local-s3", s = e["pl-workdir"] ?? ".", i = e.storage ? m.join(s, e.storage) : d.instanceDir(n), c = e["pl-log-file"] ? m.join(s, e["pl-log-file"]) : void 0, o = r.initAuthDriversList(e, s), f = e["auth-enabled"] ?? o !== void 0;
1607
+ const n = "local-s3", s = e["pl-workdir"] ?? ".", i = e.storage ? m.join(s, e.storage) : u.instanceDir(n), c = e["pl-log-file"] ? m.join(s, e["pl-log-file"]) : void 0, o = r.initAuthDriversList(e, s), d = e["auth-enabled"] ?? o !== void 0;
1612
1608
  let g = e["pl-binary"];
1613
1609
  e["pl-sources"] && (g = r.buildPlatforma({ repoRoot: e["pl-sources"] }));
1614
1610
  let h = "127.0.0.1:6345";
1615
1611
  e["grpc-listen"] ? h = e["grpc-listen"] : e["grpc-port"] && (h = `127.0.0.1:${e["grpc-port"]}`);
1616
- let w = "127.0.0.1:9090";
1617
- e["monitoring-listen"] ? w = e["monitoring-listen"] : e["monitoring-port"] && (w = `127.0.0.1:${e["monitoring-port"]}`);
1618
- let v = "127.0.0.1:9091";
1619
- e["debug-listen"] ? v = e["debug-listen"] : e["debug-port"] && (v = `127.0.0.1:${e["debug-port"]}`);
1612
+ let b = "127.0.0.1:9090";
1613
+ e["monitoring-listen"] ? b = e["monitoring-listen"] : e["monitoring-port"] && (b = `127.0.0.1:${e["monitoring-port"]}`);
1614
+ let w = "127.0.0.1:9091";
1615
+ e["debug-listen"] ? w = e["debug-listen"] : e["debug-port"] && (w = `127.0.0.1:${e["debug-port"]}`);
1620
1616
  const y = {
1621
1617
  binaryPath: g,
1622
1618
  version: e.version,
@@ -1628,20 +1624,20 @@ let gt = (F = class extends L {
1628
1624
  minioConsolePort: e["s3-console-port"],
1629
1625
  configOptions: {
1630
1626
  grpc: { listen: h },
1631
- monitoring: { listen: w },
1632
- debug: { listen: v },
1627
+ monitoring: { listen: b },
1628
+ debug: { listen: w },
1633
1629
  license: { value: e.license, file: e["license-file"] },
1634
1630
  log: { path: c },
1635
1631
  localRoot: i,
1636
1632
  core: {
1637
- auth: { enabled: f, drivers: o }
1633
+ auth: { enabled: d, drivers: o }
1638
1634
  },
1639
1635
  storages: {
1640
1636
  work: { type: "FS", rootPath: e["storage-work"] }
1641
1637
  }
1642
1638
  }
1643
1639
  }, P = r.createLocalS3(n, y);
1644
- y.binaryPath ? r.switchInstance(P) : Ge(t, { version: e.version }).then(() => {
1640
+ y.binaryPath ? r.switchInstance(P) : ke(t, { version: e.version }).then(() => {
1645
1641
  const S = r.switchInstance(P);
1646
1642
  setTimeout(() => {
1647
1643
  for (const k of S)
@@ -1651,33 +1647,33 @@ let gt = (F = class extends L {
1651
1647
  t.error(S.message);
1652
1648
  });
1653
1649
  }
1654
- }, l(F, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(F, "examples", ["<%= config.bin %> <%= command.id %>"]), l(F, "flags", {
1655
- ...A,
1656
- ...W,
1657
- ...z,
1658
- ...mr,
1659
- ...Ce,
1660
- ...Me,
1661
- ...je,
1662
- ...q,
1663
- ...Y,
1664
- ...oe,
1650
+ }, l(D, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(D, "examples", ["<%= config.bin %> <%= command.id %>"]), l(D, "flags", {
1651
+ ...I,
1652
+ ...C,
1653
+ ...j,
1654
+ ...hr,
1655
+ ...we,
1656
+ ...ve,
1657
+ ...Pe,
1658
+ ...M,
1659
+ ...B,
1665
1660
  ...ce,
1666
- ...le,
1667
- ...Ne,
1668
- ..._e,
1669
- ...V
1670
- }), F);
1671
- const G = class G extends L {
1661
+ ...ie,
1662
+ ...oe,
1663
+ ...pe,
1664
+ ...be,
1665
+ ...U
1666
+ }), D);
1667
+ const z = class z extends L {
1672
1668
  async run() {
1673
- const { flags: e, args: t } = await this.parse(G), r = I(e["log-level"]), n = new O(r);
1669
+ const { flags: e, args: t } = await this.parse(z), r = A(e["log-level"]), n = new O(r);
1674
1670
  n.mergeLicenseEnvs(e);
1675
1671
  const s = t.name, i = e["auth-enabled"], c = i ? {
1676
1672
  enabled: i,
1677
1673
  drivers: n.initAuthDriversList(e, ".")
1678
- } : void 0, o = e.storage ? m.join(".", e.storage) : d.instanceDir(s), f = [];
1674
+ } : void 0, o = e.storage ? m.join(".", e.storage) : u.instanceDir(s), d = [];
1679
1675
  for (const h of e.mount ?? [])
1680
- f.push({ hostPath: h });
1676
+ d.push({ hostPath: h });
1681
1677
  const g = e.arch ? `linux/${e.arch}` : void 0;
1682
1678
  n.createDocker(s, o, {
1683
1679
  primaryStorageURL: e["storage-primary"],
@@ -1686,7 +1682,7 @@ const G = class G extends L {
1686
1682
  image: e.image,
1687
1683
  version: e.version,
1688
1684
  platformOverride: g,
1689
- customMounts: f,
1685
+ customMounts: d,
1690
1686
  license: e.license,
1691
1687
  licenseFile: e["license-file"],
1692
1688
  auth: c,
@@ -1699,34 +1695,35 @@ const G = class G extends L {
1699
1695
  }), r.info(`Instance '${s}' was created. To start it run 'up' command`);
1700
1696
  }
1701
1697
  };
1702
- l(G, "description", "Run Platforma Backend service as docker container on current host"), l(G, "examples", ["<%= config.bin %> <%= command.id %>"]), l(G, "flags", {
1703
- ...A,
1704
- ...z,
1698
+ l(z, "description", "Run Platforma Backend service as docker container on current host"), l(z, "examples", ["<%= config.bin %> <%= command.id %>"]), l(z, "flags", {
1699
+ ...I,
1700
+ ...j,
1705
1701
  ...me,
1706
- ...W,
1702
+ ...C,
1707
1703
  ...he,
1708
- ...V,
1709
- ...q,
1704
+ ...U,
1705
+ ...M,
1710
1706
  ...ye,
1711
- ...Y,
1712
- ...oe,
1707
+ ...B,
1713
1708
  ...ce,
1714
- ...le
1715
- }), l(G, "args", {
1716
- name: H.string({ required: !0 })
1709
+ ...ie,
1710
+ ...oe
1711
+ }), l(z, "args", {
1712
+ name: K.string({ required: !0 })
1717
1713
  });
1718
- let Fe = G;
1719
- const U = class U extends L {
1714
+ let Me = z;
1715
+ var R;
1716
+ let ft = (R = class extends L {
1720
1717
  async run() {
1721
- const { flags: e, args: t } = await this.parse(U), r = I(e["log-level"]), n = new O(r);
1718
+ const { flags: e, args: t } = await this.parse(R), r = A(e["log-level"]), n = new O(r);
1722
1719
  n.mergeLicenseEnvs(e);
1723
- const s = t.name, i = e["pl-workdir"] ?? ".", c = e.storage ? m.join(i, e.storage) : d.instanceDir(s), o = e["pl-log-file"] ? m.join(i, e["pl-log-file"]) : void 0, f = n.initAuthDriversList(e, i), g = e["auth-enabled"] ?? f !== void 0;
1720
+ const s = t.name, i = e["pl-workdir"] ?? ".", c = e.storage ? m.join(i, e.storage) : u.instanceDir(s), o = e["pl-log-file"] ? m.join(i, e["pl-log-file"]) : void 0, d = n.initAuthDriversList(e, i), g = e["auth-enabled"] ?? d !== void 0;
1724
1721
  let h = e["pl-binary"];
1725
1722
  e["pl-sources"] && (h = n.buildPlatforma({ repoRoot: e["pl-sources"] }));
1726
- let w = "127.0.0.1:6345";
1727
- e["grpc-listen"] ? w = e["grpc-listen"] : e["grpc-port"] && (w = `127.0.0.1:${e["grpc-port"]}`);
1728
- let v = "127.0.0.1:9090";
1729
- e["monitoring-listen"] ? v = e["monitoring-listen"] : e["monitoring-port"] && (v = `127.0.0.1:${e["monitoring-port"]}`);
1723
+ let b = "127.0.0.1:6345";
1724
+ e["grpc-listen"] ? b = e["grpc-listen"] : e["grpc-port"] && (b = `127.0.0.1:${e["grpc-port"]}`);
1725
+ let w = "127.0.0.1:9090";
1726
+ e["monitoring-listen"] ? w = e["monitoring-listen"] : e["monitoring-port"] && (w = `127.0.0.1:${e["monitoring-port"]}`);
1730
1727
  let y = "127.0.0.1:9091";
1731
1728
  e["debug-listen"] ? y = e["debug-listen"] : e["debug-port"] && (y = `127.0.0.1:${e["debug-port"]}`);
1732
1729
  const P = {
@@ -1737,72 +1734,54 @@ const U = class U extends L {
1737
1734
  primaryURL: e["storage-primary"],
1738
1735
  libraryURL: e["storage-library"],
1739
1736
  configOptions: {
1740
- grpc: { listen: w },
1741
- monitoring: { listen: v },
1737
+ grpc: { listen: b },
1738
+ monitoring: { listen: w },
1742
1739
  debug: { listen: y },
1743
1740
  license: { value: e.license, file: e["license-file"] },
1744
1741
  log: { path: o },
1745
1742
  localRoot: c,
1746
- core: { auth: { enabled: g, drivers: f } },
1743
+ core: { auth: { enabled: g, drivers: d } },
1747
1744
  storages: {
1748
1745
  work: { type: "FS", rootPath: e["storage-work"] }
1749
1746
  }
1750
1747
  }
1751
1748
  };
1752
- switch (t.mode) {
1753
- case "s3": {
1754
- r.info("Creating instance configuration, data directory and other stuff..."), n.createLocalS3(s, {
1755
- ...P,
1756
- minioPort: e["s3-port"],
1757
- minioConsolePort: e["s3-console-port"]
1758
- });
1759
- break;
1760
- }
1761
- case void 0: {
1762
- e["s3-port"] && r.warn("flag 's3-port' is only for 's3' mode"), e["s3-console-port"] && r.warn("flag 's3-console-port' is only for 's3' mode"), n.createLocal(s, P);
1763
- break;
1764
- }
1765
- }
1766
- if (P.binaryPath) {
1749
+ if (n.createLocal(s, P), P.binaryPath) {
1767
1750
  r.info(`Instance '${s}' was created. To start it run 'up' command`);
1768
1751
  return;
1769
1752
  }
1770
- Ge(r, { version: e.version }).then(() => r.info(`Instance '${s}' was created. To start it run 'pl up' command`)).catch(function(k) {
1771
- r.error(k.message);
1753
+ ke(r, { version: e.version }).then(() => r.info(`Instance '${s}' was created. To start it run 'pl up' command`)).catch(function(S) {
1754
+ r.error(S.message);
1772
1755
  });
1773
1756
  }
1774
- };
1775
- l(U, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(U, "examples", ["<%= config.bin %> <%= command.id %>"]), l(U, "flags", {
1776
- ...A,
1777
- ...W,
1778
- ...mr,
1779
- ...z,
1780
- ...Ce,
1781
- ...Me,
1782
- ...je,
1783
- ...q,
1784
- ...Y,
1785
- ...oe,
1757
+ }, l(R, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(R, "examples", ["<%= config.bin %> <%= command.id %>"]), l(R, "flags", {
1758
+ ...I,
1759
+ ...C,
1760
+ ...j,
1761
+ ...we,
1762
+ ...ve,
1763
+ ...Pe,
1764
+ ...M,
1765
+ ...B,
1786
1766
  ...ce,
1787
- ...le,
1788
- ...Ne,
1789
- ..._e,
1790
- ...V
1791
- }), l(U, "args", {
1792
- name: H.string({ required: !0 }),
1793
- mode: H.string({ options: ["s3"], required: !1 })
1794
- });
1795
- let xe = U;
1796
- const J = class J extends L {
1767
+ ...ie,
1768
+ ...oe,
1769
+ ...pe,
1770
+ ...be,
1771
+ ...U
1772
+ }), l(R, "args", {
1773
+ name: K.string({ required: !0 })
1774
+ }), R);
1775
+ const Y = class Y extends L {
1797
1776
  async run() {
1798
- const { flags: e, args: t } = await this.parse(J), r = I(e["log-level"]), n = new O(r);
1777
+ const { flags: e, args: t } = await this.parse(Y), r = A(e["log-level"]), n = new O(r);
1799
1778
  n.mergeLicenseEnvs(e);
1800
1779
  const s = t.name, i = e["auth-enabled"], c = i ? {
1801
1780
  enabled: i,
1802
1781
  drivers: n.initAuthDriversList(e, ".")
1803
- } : void 0, o = e.storage ? m.join(".", e.storage) : d.instanceDir(s), f = [];
1804
- for (const w of e.mount ?? [])
1805
- f.push({ hostPath: w });
1782
+ } : void 0, o = e.storage ? m.join(".", e.storage) : u.instanceDir(s), d = [];
1783
+ for (const b of e.mount ?? [])
1784
+ d.push({ hostPath: b });
1806
1785
  const g = e.arch ? `linux/${e.arch}` : void 0, h = e["minio-presign-host"] ? "minio" : "localhost";
1807
1786
  n.createDockerS3(s, o, {
1808
1787
  image: e.image,
@@ -1810,7 +1789,7 @@ const J = class J extends L {
1810
1789
  license: e.license,
1811
1790
  licenseFile: e["license-file"],
1812
1791
  platformOverride: g,
1813
- customMounts: f,
1792
+ customMounts: d,
1814
1793
  auth: c,
1815
1794
  grpcAddr: e["grpc-listen"],
1816
1795
  grpcPort: e["grpc-port"],
@@ -1822,39 +1801,104 @@ const J = class J extends L {
1822
1801
  }), r.info(`Instance '${s}' was created. To start it run 'up' command`), e["minio-presign-host"] && r.info(" NOTE: make sure you have 'minio' host in your hosts file as 127.0.0.1 address");
1823
1802
  }
1824
1803
  };
1825
- l(J, "description", "Run Platforma Backend service as docker container on current host with MinIO as local S3 storage"), l(J, "examples", ["<%= config.bin %> <%= command.id %>"]), l(J, "flags", {
1826
- ...A,
1827
- ...z,
1804
+ l(Y, "description", "Run Platforma Backend service as docker container on current host with MinIO as local S3 storage"), l(Y, "examples", ["<%= config.bin %> <%= command.id %>"]), l(Y, "flags", {
1805
+ ...I,
1806
+ ...j,
1828
1807
  ...me,
1829
- ...W,
1808
+ ...C,
1830
1809
  ...he,
1831
- ...V,
1832
- ...q,
1810
+ ...U,
1811
+ ...M,
1833
1812
  ...ye,
1834
- ...Y,
1835
- ...hr
1836
- }), l(J, "args", {
1837
- name: H.string({ required: !0 })
1813
+ ...B,
1814
+ ...yr
1815
+ }), l(Y, "args", {
1816
+ name: K.string({ required: !0 })
1817
+ });
1818
+ let je = Y;
1819
+ const V = class V extends L {
1820
+ async run() {
1821
+ const { flags: e, args: t } = await this.parse(V), r = A(e["log-level"]), n = new O(r);
1822
+ n.mergeLicenseEnvs(e);
1823
+ const s = t.name, i = e["pl-workdir"] ?? ".", c = e.storage ? m.join(i, e.storage) : u.instanceDir(s), o = e["pl-log-file"] ? m.join(i, e["pl-log-file"]) : void 0, d = n.initAuthDriversList(e, i), g = e["auth-enabled"] ?? d !== void 0;
1824
+ let h = e["pl-binary"];
1825
+ e["pl-sources"] && (h = n.buildPlatforma({ repoRoot: e["pl-sources"] }));
1826
+ let b = "127.0.0.1:6345";
1827
+ e["grpc-listen"] ? b = e["grpc-listen"] : e["grpc-port"] && (b = `127.0.0.1:${e["grpc-port"]}`);
1828
+ let w = "127.0.0.1:9090";
1829
+ e["monitoring-listen"] ? w = e["monitoring-listen"] : e["monitoring-port"] && (w = `127.0.0.1:${e["monitoring-port"]}`);
1830
+ let y = "127.0.0.1:9091";
1831
+ e["debug-listen"] ? y = e["debug-listen"] : e["debug-port"] && (y = `127.0.0.1:${e["debug-port"]}`);
1832
+ const P = {
1833
+ binaryPath: h,
1834
+ version: e.version,
1835
+ configPath: e.config,
1836
+ workdir: e["pl-workdir"],
1837
+ primaryURL: e["storage-primary"],
1838
+ libraryURL: e["storage-library"],
1839
+ minioPort: e["s3-port"],
1840
+ minioConsolePort: e["s3-console-port"],
1841
+ configOptions: {
1842
+ grpc: { listen: b },
1843
+ monitoring: { listen: w },
1844
+ debug: { listen: y },
1845
+ license: { value: e.license, file: e["license-file"] },
1846
+ log: { path: o },
1847
+ localRoot: c,
1848
+ core: { auth: { enabled: g, drivers: d } },
1849
+ storages: {
1850
+ work: { type: "FS", rootPath: e["storage-work"] }
1851
+ }
1852
+ }
1853
+ };
1854
+ if (r.info("Creating instance configuration, data directory and other stuff..."), n.createLocalS3(s, P), P.binaryPath) {
1855
+ r.info(`Instance '${s}' was created. To start it run 'up' command`);
1856
+ return;
1857
+ }
1858
+ ke(r, { version: e.version }).then(() => r.info(`Instance '${s}' was created. To start it run 'pl up' command`)).catch(function(S) {
1859
+ r.error(S.message);
1860
+ });
1861
+ }
1862
+ };
1863
+ l(V, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(V, "examples", ["<%= config.bin %> <%= command.id %>"]), l(V, "flags", {
1864
+ ...I,
1865
+ ...C,
1866
+ ...hr,
1867
+ ...j,
1868
+ ...we,
1869
+ ...ve,
1870
+ ...Pe,
1871
+ ...M,
1872
+ ...B,
1873
+ ...ce,
1874
+ ...ie,
1875
+ ...oe,
1876
+ ...pe,
1877
+ ...be,
1878
+ ...U
1879
+ }), l(V, "args", {
1880
+ name: K.string({ required: !0 })
1838
1881
  });
1839
- let De = J;
1840
- const It = {
1841
- "create-block": Se,
1842
- reset: Le,
1843
- start: Ae,
1844
- stop: Ie,
1845
- "start:docker": ot,
1846
- "start:local": lt,
1847
- "svc:delete": Oe,
1848
- "svc:down": Ee,
1849
- "svc:list": Re,
1850
- "svc:up": Te,
1851
- "start:docker:s3": dt,
1852
- "start:local:s3": gt,
1853
- "svc:create:docker": Fe,
1854
- "svc:create:local": xe,
1855
- "svc:create:docker:s3": De
1882
+ let Be = V;
1883
+ const Rt = {
1884
+ "create-block": Re,
1885
+ reset: Te,
1886
+ start: xe,
1887
+ stop: De,
1888
+ "start:docker": lt,
1889
+ "start:local": dt,
1890
+ "svc:delete": Fe,
1891
+ "svc:down": Ne,
1892
+ "svc:list": _e,
1893
+ "svc:up": Ce,
1894
+ "start:docker:s3": gt,
1895
+ "start:local:s3": ut,
1896
+ "svc:create:docker": Me,
1897
+ "svc:create:local": ft,
1898
+ "svc:create:docker:s3": je,
1899
+ "svc:create:local:s3": Be
1856
1900
  };
1857
1901
  export {
1858
- It as COMMANDS
1902
+ Rt as COMMANDS
1859
1903
  };
1860
1904
  //# sourceMappingURL=index.mjs.map