@platforma-sdk/bootstrap 2.0.0 → 2.0.1

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