@platforma-sdk/bootstrap 3.1.5 → 3.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -4,8 +4,8 @@ var l = (a, e, t) => $r(a, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { Flags as v, Command as L, Args as K } from "@oclif/core";
5
5
  import F from "node:os";
6
6
  import f, { createWriteStream as Lr } from "node:fs";
7
- import m, { resolve as Ir } from "node:path";
8
- import { execSync as Ae, spawn as Ar, spawnSync as mr } from "node:child_process";
7
+ import m, { resolve as Ar } from "node:path";
8
+ import { execSync as Ie, spawn as Ir, spawnSync as mr } from "node:child_process";
9
9
  import ge from "winston";
10
10
  import { randomBytes as Or } from "node:crypto";
11
11
  import Z from "readline-sync";
@@ -17,7 +17,7 @@ import { getDefaultPlVersion as fe } from "@milaboratories/pl-deployments";
17
17
  import dr from "yaml";
18
18
  import Tr from "node:https";
19
19
  import * as xr from "tar";
20
- const I = {
20
+ const A = {
21
21
  "log-level": v.string({
22
22
  description: "logging level",
23
23
  default: "info",
@@ -174,7 +174,7 @@ function Cr(a) {
174
174
  function G(a) {
175
175
  throw new Error("this should never happen");
176
176
  }
177
- function A(a = "debug") {
177
+ function I(a = "debug") {
178
178
  return ge.createLogger({
179
179
  level: a,
180
180
  format: ge.format.printf(({ level: e, message: t }) => {
@@ -208,8 +208,8 @@ function Se(a, e) {
208
208
  function Br(a) {
209
209
  try {
210
210
  if (F.platform() !== "win32")
211
- return Ae(`ps -p ${a} -o comm=`, { encoding: "utf8" }).trim();
212
- const e = `wmic process where processid=${a} get Caption`, t = Ae(e, { encoding: "utf8" }).split(`
211
+ return Ie(`ps -p ${a} -o comm=`, { encoding: "utf8" }).trim();
212
+ const e = `wmic process where processid=${a} get Caption`, t = Ie(e, { encoding: "utf8" }).split(`
213
213
  `);
214
214
  return t.length <= 1 ? "" : t[1].trim();
215
215
  } catch {
@@ -217,7 +217,7 @@ function Br(a) {
217
217
  }
218
218
  }
219
219
  function Ur(a) {
220
- const e = Ae(`docker compose ls --filter name=${a} --format json`, { encoding: "utf8" }).trim(), t = JSON.parse(e);
220
+ const e = Ie(`docker compose ls --filter name=${a} --format json`, { encoding: "utf8" }).trim(), t = JSON.parse(e);
221
221
  for (const r of t)
222
222
  if (r.Name === a)
223
223
  return r;
@@ -334,16 +334,16 @@ async function ee(a, e) {
334
334
  }
335
335
  const re = class re extends L {
336
336
  async run() {
337
- const { flags: e } = await this.parse(re), t = A(e["log-level"]);
337
+ const { flags: e } = await this.parse(re), t = I(e["log-level"]);
338
338
  await Hr(t);
339
339
  }
340
340
  };
341
341
  l(re, "description", "Helps to create a new block by downloading a block's template."), l(re, "examples", ["<%= name %>"]), l(re, "flags", {
342
- ...I
342
+ ...A
343
343
  });
344
344
  let Re = re;
345
345
  function wr(...a) {
346
- return Ir(__dirname, "..", ...a);
346
+ return Ar(__dirname, "..", ...a);
347
347
  }
348
348
  function Q(...a) {
349
349
  return wr("assets", ...a);
@@ -481,7 +481,7 @@ function Qr(a, e, t, r) {
481
481
  cmd: ${JSON.stringify([e, ...t])}
482
482
  wd: ${(c = r.cwd) == null ? void 0 : c.toString()}`
483
483
  ), r.env = { ...process.env, ...r.env }, a.debug(" spawning child process");
484
- const n = Ar(e, t, r);
484
+ const n = Ir(e, t, r);
485
485
  let s = !1;
486
486
  const i = () => {
487
487
  n.kill("SIGINT"), s = !0;
@@ -497,7 +497,7 @@ function Xr(a, e, t, r) {
497
497
  opts: ${JSON.stringify(r)}`
498
498
  ), r.env = { ...process.env, ...r.env }, mr(e, t, r);
499
499
  }
500
- function Ie(a, e, t, r, n) {
500
+ function Ae(a, e, t, r, n) {
501
501
  const s = f.readFileSync(a, { encoding: "utf-8" }), i = dr.parse(s.toString());
502
502
  if (!i.services)
503
503
  throw new Error(`file '${a}' seems to be not a docker-compose file or has unsupported version`);
@@ -996,7 +996,7 @@ ${r}`);
996
996
  createMinio(e, t) {
997
997
  this.logger.debug(" creating docker compose for minio service...");
998
998
  const r = Q("compose-backend.yaml"), n = u.instanceDir(e, "compose-minio.yaml");
999
- Ie(
999
+ Ae(
1000
1000
  r,
1001
1001
  n,
1002
1002
  `pl-${e}-minio`,
@@ -1077,7 +1077,7 @@ ${r}`);
1077
1077
  hostPath: p.hostPath,
1078
1078
  containerPath: p.containerPath ?? p.hostPath
1079
1079
  });
1080
- Ie(n, P, `pl-${e}`, /* @__PURE__ */ new Map([
1080
+ Ae(n, P, `pl-${e}`, /* @__PURE__ */ new Map([
1081
1081
  ["minio", {}],
1082
1082
  ["backend", {
1083
1083
  platform: r == null ? void 0 : r.platformOverride,
@@ -1094,6 +1094,7 @@ ${r}`);
1094
1094
  PL_LOG_LEVEL: (r == null ? void 0 : r.logLevel) ?? "info",
1095
1095
  PL_LOG_DIR: m.dirname(o),
1096
1096
  PL_LOG_ROTATION_ENABLED: "true",
1097
+ PL_RUNNER_WD_CACHE_ON_FAILURE: "1h",
1097
1098
  PL_DATA_DB_ROOT: b,
1098
1099
  PL_DATA_PRIMARY_ROOT: c("primary"),
1099
1100
  PL_DATA_LIBRARY_ROOT: c("library"),
@@ -1158,15 +1159,13 @@ ${r}`);
1158
1159
  hostPath: $.hostPath,
1159
1160
  containerPath: $.containerPath ?? $.hostPath
1160
1161
  });
1161
- this.logger.debug(`Rendering docker compose file '${y}' using '${n}' as base template`), Ie(n, y, `pl-${e}`, /* @__PURE__ */ new Map([
1162
+ this.logger.debug(`Rendering docker compose file '${y}' using '${n}' as base template`), Ae(n, y, `pl-${e}`, /* @__PURE__ */ new Map([
1162
1163
  ["backend", {
1163
1164
  platform: r == null ? void 0 : r.platformOverride,
1164
1165
  mounts: P
1165
1166
  }]
1166
1167
  ]));
1167
1168
  const S = X((r == null ? void 0 : r.primaryStorageURL) ?? `file:${g}`, "."), k = X((r == null ? void 0 : r.libraryStorageURL) ?? `file:${h}`, "."), p = {
1168
- MINIO_IMAGE: "quay.io/minio/minio",
1169
- MINIO_STORAGE: c("minio"),
1170
1169
  PL_IMAGE: s,
1171
1170
  PL_AUTH_HTPASSWD_PATH: w,
1172
1171
  PL_LICENSE: r == null ? void 0 : r.license,
@@ -1174,6 +1173,7 @@ ${r}`);
1174
1173
  PL_LOG_LEVEL: "info",
1175
1174
  PL_LOG_DIR: m.dirname(o),
1176
1175
  PL_LOG_ROTATION_ENABLED: "true",
1176
+ PL_RUNNER_WD_CACHE_ON_FAILURE: "1h",
1177
1177
  PL_DATA_DB_ROOT: d,
1178
1178
  PL_DATA_PRIMARY_ROOT: g,
1179
1179
  PL_DATA_LIBRARY_ROOT: h,
@@ -1367,38 +1367,38 @@ function ue(a, e) {
1367
1367
  }
1368
1368
  const te = class te extends L {
1369
1369
  async run() {
1370
- const { flags: e } = await this.parse(te), t = A(e["log-level"]);
1370
+ const { flags: e } = await this.parse(te), t = I(e["log-level"]);
1371
1371
  new O(t).cleanupInstance();
1372
1372
  }
1373
1373
  };
1374
1374
  l(te, "description", "Clear service state (forget last run command, destroy docker services, volumes and so on)"), l(te, "examples", ["<%= config.bin %> <%= command.id %>"]), l(te, "flags", {
1375
- ...I
1375
+ ...A
1376
1376
  });
1377
1377
  let Te = te;
1378
1378
  const ae = class ae extends L {
1379
1379
  async run() {
1380
- const { flags: e } = await this.parse(ae), t = A(e["log-level"]);
1380
+ const { flags: e } = await this.parse(ae), t = I(e["log-level"]);
1381
1381
  new O(t).startLast();
1382
1382
  }
1383
1383
  };
1384
1384
  l(ae, "description", "Start last run service configuraiton"), l(ae, "examples", ["<%= config.bin %> <%= command.id %>"]), l(ae, "flags", {
1385
- ...I
1385
+ ...A
1386
1386
  });
1387
1387
  let xe = ae;
1388
1388
  const ne = class ne extends L {
1389
1389
  async run() {
1390
- const { flags: e } = await this.parse(ne), t = A(e["log-level"]), r = new O(t);
1390
+ const { flags: e } = await this.parse(ne), t = I(e["log-level"]), r = new O(t);
1391
1391
  u.currentInstance ? r.stopInstance(u.currentInstance) : t.warn("up/start command was not called for any instance, nothing to stop");
1392
1392
  }
1393
1393
  };
1394
1394
  l(ne, "description", "Stop platforma service"), l(ne, "examples", ["<%= config.bin %> <%= command.id %>"]), l(ne, "flags", {
1395
- ...I
1395
+ ...A
1396
1396
  });
1397
1397
  let De = ne;
1398
1398
  var E;
1399
1399
  let lt = (E = class extends L {
1400
1400
  async run() {
1401
- const { flags: e } = await this.parse(E), t = A(e["log-level"]), r = new O(t);
1401
+ const { flags: e } = await this.parse(E), t = I(e["log-level"]), r = new O(t);
1402
1402
  r.mergeLicenseEnvs(e);
1403
1403
  const n = "docker", s = e["auth-enabled"], i = s ? {
1404
1404
  enabled: s,
@@ -1427,7 +1427,7 @@ let lt = (E = class extends L {
1427
1427
  r.switchInstance(g);
1428
1428
  }
1429
1429
  }, l(E, "description", "Run platforma backend service with 'FS' primary storage type"), l(E, "examples", ["<%= config.bin %> <%= command.id %>"]), l(E, "flags", {
1430
- ...I,
1430
+ ...A,
1431
1431
  ...j,
1432
1432
  ...me,
1433
1433
  ...C,
@@ -1443,7 +1443,7 @@ let lt = (E = class extends L {
1443
1443
  var T;
1444
1444
  let dt = (T = class extends L {
1445
1445
  async run() {
1446
- const { flags: e } = await this.parse(T), t = A(e["log-level"]), r = new O(t);
1446
+ const { flags: e } = await this.parse(T), t = I(e["log-level"]), r = new O(t);
1447
1447
  r.mergeLicenseEnvs(e);
1448
1448
  const n = "local", s = e["pl-workdir"] ?? ".", i = e.storage ? m.join(s, e.storage) : u.instanceDir(n), c = e["pl-log-file"] ? m.join(s, e["pl-log-file"]) : void 0, o = r.initAuthDriversList(e, s), d = e["auth-enabled"] ?? o !== void 0;
1449
1449
  let g = e["pl-binary"];
@@ -1485,7 +1485,7 @@ let dt = (T = class extends L {
1485
1485
  });
1486
1486
  }
1487
1487
  }, l(T, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(T, "examples", ["<%= config.bin %> <%= command.id %>"]), l(T, "flags", {
1488
- ...I,
1488
+ ...A,
1489
1489
  ...C,
1490
1490
  ...j,
1491
1491
  ...we,
@@ -1502,12 +1502,12 @@ let dt = (T = class extends L {
1502
1502
  }), T);
1503
1503
  const H = class H extends L {
1504
1504
  async run() {
1505
- const { flags: e, args: t } = await this.parse(H), r = A(e["log-level"]), n = new O(r), s = t.name;
1505
+ const { flags: e, args: t } = await this.parse(H), r = I(e["log-level"]), n = new O(r), s = t.name;
1506
1506
  e.all && (n.cleanupInstance(), process.exit(0)), s || (r.error("Please, specify name of instance to be removed or set '--all' flag instead"), process.exit(1)), n.cleanupInstance(s);
1507
1507
  }
1508
1508
  };
1509
1509
  l(H, "description", "List available instances"), l(H, "examples", ["<%= config.bin %> <%= command.id %>"]), l(H, "flags", {
1510
- ...I,
1510
+ ...A,
1511
1511
  all: v.boolean({
1512
1512
  description: "remove all known instances",
1513
1513
  required: !1
@@ -1518,12 +1518,12 @@ l(H, "description", "List available instances"), l(H, "examples", ["<%= config.b
1518
1518
  let Fe = H;
1519
1519
  const W = class W extends L {
1520
1520
  async run() {
1521
- const { flags: e, args: t } = await this.parse(W), r = A(e["log-level"]), n = new O(r), s = t.name ?? u.currentInstanceName;
1521
+ const { flags: e, args: t } = await this.parse(W), r = I(e["log-level"]), n = new O(r), s = t.name ?? u.currentInstanceName;
1522
1522
  s || (r.info("no pl service instance selected. No service was stopped"), process.exit(0)), n.stopInstance(u.getInstanceInfo(s));
1523
1523
  }
1524
1524
  };
1525
1525
  l(W, "description", "List available instances"), l(W, "examples", ["<%= config.bin %> <%= command.id %>"]), l(W, "flags", {
1526
- ...I
1526
+ ...A
1527
1527
  }), l(W, "args", {
1528
1528
  name: K.string({ required: !1 })
1529
1529
  });
@@ -1542,7 +1542,7 @@ l(se, "description", "List available instances"), l(se, "examples", ["<%= config
1542
1542
  let _e = se;
1543
1543
  const q = class q extends L {
1544
1544
  async run() {
1545
- const { flags: e, args: t } = await this.parse(q), r = A(e["log-level"]), n = new O(r), s = t.name ?? u.currentInstanceName;
1545
+ const { flags: e, args: t } = await this.parse(q), r = I(e["log-level"]), n = new O(r), s = t.name ?? u.currentInstanceName;
1546
1546
  s || (r.error("no pl service instance is selected. Select instance with 'select' command or provide name to 'up'"), process.exit(1));
1547
1547
  const i = n.switchInstance(u.getInstanceInfo(s)), c = [];
1548
1548
  for (const o of i)
@@ -1553,7 +1553,7 @@ const q = class q extends L {
1553
1553
  }
1554
1554
  };
1555
1555
  l(q, "description", "List available instances"), l(q, "examples", ["<%= config.bin %> <%= command.id %>"]), l(q, "flags", {
1556
- ...I
1556
+ ...A
1557
1557
  }), l(q, "args", {
1558
1558
  name: K.string({ required: !1 })
1559
1559
  });
@@ -1561,7 +1561,7 @@ let Ce = q;
1561
1561
  var x;
1562
1562
  let gt = (x = class extends L {
1563
1563
  async run() {
1564
- const { flags: e } = await this.parse(x), t = A(e["log-level"]), r = new O(t);
1564
+ const { flags: e } = await this.parse(x), t = I(e["log-level"]), r = new O(t);
1565
1565
  r.mergeLicenseEnvs(e);
1566
1566
  const n = "docker-s3", s = e["auth-enabled"], i = s ? {
1567
1567
  enabled: s,
@@ -1588,7 +1588,7 @@ let gt = (x = class extends L {
1588
1588
  r.switchInstance(h);
1589
1589
  }
1590
1590
  }, l(x, "description", "Run platforma backend service with 'S3' primary storage type"), l(x, "examples", ["<%= config.bin %> <%= command.id %>"]), l(x, "flags", {
1591
- ...I,
1591
+ ...A,
1592
1592
  ...j,
1593
1593
  ...me,
1594
1594
  ...C,
@@ -1602,7 +1602,7 @@ let gt = (x = class extends L {
1602
1602
  var D;
1603
1603
  let ut = (D = class extends L {
1604
1604
  async run() {
1605
- const { flags: e } = await this.parse(D), t = A(e["log-level"]), r = new O(t);
1605
+ const { flags: e } = await this.parse(D), t = I(e["log-level"]), r = new O(t);
1606
1606
  r.mergeLicenseEnvs(e);
1607
1607
  const n = "local-s3", s = e["pl-workdir"] ?? ".", i = e.storage ? m.join(s, e.storage) : u.instanceDir(n), c = e["pl-log-file"] ? m.join(s, e["pl-log-file"]) : void 0, o = r.initAuthDriversList(e, s), d = e["auth-enabled"] ?? o !== void 0;
1608
1608
  let g = e["pl-binary"];
@@ -1648,7 +1648,7 @@ let ut = (D = class extends L {
1648
1648
  });
1649
1649
  }
1650
1650
  }, l(D, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(D, "examples", ["<%= config.bin %> <%= command.id %>"]), l(D, "flags", {
1651
- ...I,
1651
+ ...A,
1652
1652
  ...C,
1653
1653
  ...j,
1654
1654
  ...hr,
@@ -1666,7 +1666,7 @@ let ut = (D = class extends L {
1666
1666
  }), D);
1667
1667
  const z = class z extends L {
1668
1668
  async run() {
1669
- const { flags: e, args: t } = await this.parse(z), r = A(e["log-level"]), n = new O(r);
1669
+ const { flags: e, args: t } = await this.parse(z), r = I(e["log-level"]), n = new O(r);
1670
1670
  n.mergeLicenseEnvs(e);
1671
1671
  const s = t.name, i = e["auth-enabled"], c = i ? {
1672
1672
  enabled: i,
@@ -1696,7 +1696,7 @@ const z = class z extends L {
1696
1696
  }
1697
1697
  };
1698
1698
  l(z, "description", "Run Platforma Backend service as docker container on current host"), l(z, "examples", ["<%= config.bin %> <%= command.id %>"]), l(z, "flags", {
1699
- ...I,
1699
+ ...A,
1700
1700
  ...j,
1701
1701
  ...me,
1702
1702
  ...C,
@@ -1715,7 +1715,7 @@ let Me = z;
1715
1715
  var R;
1716
1716
  let ft = (R = class extends L {
1717
1717
  async run() {
1718
- const { flags: e, args: t } = await this.parse(R), r = A(e["log-level"]), n = new O(r);
1718
+ const { flags: e, args: t } = await this.parse(R), r = I(e["log-level"]), n = new O(r);
1719
1719
  n.mergeLicenseEnvs(e);
1720
1720
  const s = t.name, i = e["pl-workdir"] ?? ".", c = e.storage ? m.join(i, e.storage) : u.instanceDir(s), o = e["pl-log-file"] ? m.join(i, e["pl-log-file"]) : void 0, d = n.initAuthDriversList(e, i), g = e["auth-enabled"] ?? d !== void 0;
1721
1721
  let h = e["pl-binary"];
@@ -1755,7 +1755,7 @@ let ft = (R = class extends L {
1755
1755
  });
1756
1756
  }
1757
1757
  }, l(R, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(R, "examples", ["<%= config.bin %> <%= command.id %>"]), l(R, "flags", {
1758
- ...I,
1758
+ ...A,
1759
1759
  ...C,
1760
1760
  ...j,
1761
1761
  ...we,
@@ -1774,7 +1774,7 @@ let ft = (R = class extends L {
1774
1774
  }), R);
1775
1775
  const Y = class Y extends L {
1776
1776
  async run() {
1777
- const { flags: e, args: t } = await this.parse(Y), r = A(e["log-level"]), n = new O(r);
1777
+ const { flags: e, args: t } = await this.parse(Y), r = I(e["log-level"]), n = new O(r);
1778
1778
  n.mergeLicenseEnvs(e);
1779
1779
  const s = t.name, i = e["auth-enabled"], c = i ? {
1780
1780
  enabled: i,
@@ -1802,7 +1802,7 @@ const Y = class Y extends L {
1802
1802
  }
1803
1803
  };
1804
1804
  l(Y, "description", "Run Platforma Backend service as docker container on current host with MinIO as local S3 storage"), l(Y, "examples", ["<%= config.bin %> <%= command.id %>"]), l(Y, "flags", {
1805
- ...I,
1805
+ ...A,
1806
1806
  ...j,
1807
1807
  ...me,
1808
1808
  ...C,
@@ -1818,7 +1818,7 @@ l(Y, "description", "Run Platforma Backend service as docker container on curren
1818
1818
  let je = Y;
1819
1819
  const V = class V extends L {
1820
1820
  async run() {
1821
- const { flags: e, args: t } = await this.parse(V), r = A(e["log-level"]), n = new O(r);
1821
+ const { flags: e, args: t } = await this.parse(V), r = I(e["log-level"]), n = new O(r);
1822
1822
  n.mergeLicenseEnvs(e);
1823
1823
  const s = t.name, i = e["pl-workdir"] ?? ".", c = e.storage ? m.join(i, e.storage) : u.instanceDir(s), o = e["pl-log-file"] ? m.join(i, e["pl-log-file"]) : void 0, d = n.initAuthDriversList(e, i), g = e["auth-enabled"] ?? d !== void 0;
1824
1824
  let h = e["pl-binary"];
@@ -1861,7 +1861,7 @@ const V = class V extends L {
1861
1861
  }
1862
1862
  };
1863
1863
  l(V, "description", "Run Platforma Backend service as local process on current host (no docker container)"), l(V, "examples", ["<%= config.bin %> <%= command.id %>"]), l(V, "flags", {
1864
- ...I,
1864
+ ...A,
1865
1865
  ...C,
1866
1866
  ...hr,
1867
1867
  ...j,