@platforma-sdk/bootstrap 2.9.0 → 3.0.0

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