@platforma-sdk/bootstrap 2.6.3 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ import je from "yaml";
17
17
  import { getDefaultPlVersion as Z } from "@milaboratories/pl-local";
18
18
  import ur from "node:https";
19
19
  import * as fr from "tar";
20
- const F = {
20
+ const D = {
21
21
  "log-level": y.string({
22
22
  description: "logging level",
23
23
  default: "info",
@@ -156,7 +156,7 @@ function wr(a) {
156
156
  function V(a) {
157
157
  throw new Error("this should never happen");
158
158
  }
159
- function D(a = "debug") {
159
+ function F(a = "debug") {
160
160
  return z.createLogger({
161
161
  level: a,
162
162
  format: z.format.combine(
@@ -195,7 +195,7 @@ function Sr(a) {
195
195
  return "";
196
196
  }
197
197
  }
198
- const ce = ["Python"], Ve = ["Tengo", "Python"], Ar = O.union([O.literal("Tengo"), O.literal("Python")]), pr = O.object({
198
+ const ce = ["Python"], Ve = ["Tengo", "Python"], Ar = O.union([O.literal("Tengo"), O.literal("Python")]), Rr = O.object({
199
199
  npmOrgName: O.string().min(1),
200
200
  orgName: O.string().min(1),
201
201
  blockName: O.string().min(1),
@@ -203,7 +203,7 @@ const ce = ["Python"], Ve = ["Tengo", "Python"], Ar = O.union([O.literal("Tengo"
203
203
  message: "Must be an array of unique software platforms"
204
204
  })
205
205
  });
206
- async function Rr(a) {
206
+ async function pr(a) {
207
207
  const { npmOrgName: e, orgName: r, blockName: t, softwarePlatforms: i } = Lr(), s = o.join(process.cwd(), t);
208
208
  a.info("Downloading boilerplate code..."), await _r(
209
209
  // 'https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/software_platforms.zip',
@@ -238,7 +238,7 @@ function Lr() {
238
238
  if (s < 0) break;
239
239
  i.push(ce[s]);
240
240
  }
241
- return i = Array.from(new Set(i)).sort(), pr.parse({ npmOrgName: a, orgName: e, blockName: r, softwarePlatforms: i });
241
+ return i = Array.from(new Set(i)).sort(), Rr.parse({ npmOrgName: a, orgName: e, blockName: r, softwarePlatforms: i });
242
242
  }
243
243
  async function _r(a, e, r) {
244
244
  const i = await (await fetch(a)).blob(), s = await T.mkdtemp(o.join(L.tmpdir(), "create-repo")), c = o.join(s, "packed-repo.zip"), n = dr.toWeb(cr(c));
@@ -307,12 +307,12 @@ async function C(a, e) {
307
307
  }
308
308
  const B = class B extends E {
309
309
  async run() {
310
- const { flags: e } = await this.parse(B), r = D(e["log-level"]);
311
- await Rr(r);
310
+ const { flags: e } = await this.parse(B), r = F(e["log-level"]);
311
+ await pr(r);
312
312
  }
313
313
  };
314
314
  h(B, "description", "Helps to create a new block by downloading a block's template."), h(B, "examples", ["<%= name %>"]), h(B, "flags", {
315
- ...F
315
+ ...D
316
316
  });
317
317
  let ne = B;
318
318
  function Xe(...a) {
@@ -321,10 +321,10 @@ function Xe(...a) {
321
321
  function $(...a) {
322
322
  return Xe("assets", ...a);
323
323
  }
324
- function Fr() {
324
+ function Dr() {
325
325
  return d.readdirSync($()).filter((e) => e.startsWith("compose-") && e.endsWith(".yaml")).map((e) => $(e));
326
326
  }
327
- function Dr(...a) {
327
+ function Fr(...a) {
328
328
  return d.readFileSync(Xe(...a));
329
329
  }
330
330
  function se(a) {
@@ -340,7 +340,7 @@ const N = class N {
340
340
  h(this, "dirPath");
341
341
  e = e ?? o.resolve(L.homedir(), ".config", "pl-bootstrap");
342
342
  const r = o.join(e, "state.json");
343
- this.dirPath = e, this.filePath = r, d.existsSync(e) || d.mkdirSync(e, { recursive: !0 }), d.existsSync(r) && (this.state = JSON.parse(Dr(r).toString()));
343
+ this.dirPath = e, this.filePath = r, d.existsSync(e) || d.mkdirSync(e, { recursive: !0 }), d.existsSync(r) && (this.state = JSON.parse(Fr(r).toString()));
344
344
  }
345
345
  static getInstance() {
346
346
  return N.instance || (N.instance = new N()), N.instance;
@@ -524,14 +524,14 @@ function x(a, e, r) {
524
524
  }
525
525
  }
526
526
  function Cr(a, e) {
527
- var g, b, v, S, p, k, _, Y, A, we, ve, ke, Se, Ae, pe, Re, Le, _e, $e, Oe, Te, Ee, Fe, De, Ne, Ie, xe, Me, Ce, Be;
527
+ var g, b, v, S, R, k, _, Y, A, we, ve, ke, Se, Ae, Re, pe, Le, _e, $e, Oe, Te, Ee, De, Fe, Ne, Ie, xe, Me, Ce, Be;
528
528
  const r = (e == null ? void 0 : e.localRoot) ?? l.data("local-custom"), t = {
529
529
  level: ((g = e == null ? void 0 : e.log) == null ? void 0 : g.level) ?? "info",
530
- path: ((b = e == null ? void 0 : e.log) == null ? void 0 : b.path) ?? `${r}/platforma.log`
530
+ path: ((b = e == null ? void 0 : e.log) == null ? void 0 : b.path) ?? `${r}/logs/platforma.log`
531
531
  }, i = {
532
532
  listen: ((v = e == null ? void 0 : e.grpc) == null ? void 0 : v.listen) ?? "localhost:6345",
533
533
  tls: {
534
- enable: Q((p = (S = e == null ? void 0 : e.grpc) == null ? void 0 : S.tls) == null ? void 0 : p.enable, !1),
534
+ enable: Q((R = (S = e == null ? void 0 : e.grpc) == null ? void 0 : S.tls) == null ? void 0 : R.enable, !1),
535
535
  clientAuthMode: ((_ = (k = e == null ? void 0 : e.grpc) == null ? void 0 : k.tls) == null ? void 0 : _.clientAuthMode) ?? "NoAuth",
536
536
  certFile: ((A = (Y = e == null ? void 0 : e.grpc) == null ? void 0 : Y.tls) == null ? void 0 : A.certFile) ?? `${r}/certs/tls.cert`,
537
537
  keyFile: ((ve = (we = e == null ? void 0 : e.grpc) == null ? void 0 : we.tls) == null ? void 0 : ve.keyFile) ?? `${r}/certs/tls.key`,
@@ -540,7 +540,7 @@ function Cr(a, e) {
540
540
  }, s = {
541
541
  auth: {
542
542
  enabled: ((Ae = (Se = e == null ? void 0 : e.core) == null ? void 0 : Se.auth) == null ? void 0 : Ae.enabled) ?? !1,
543
- drivers: ((Re = (pe = e == null ? void 0 : e.core) == null ? void 0 : pe.auth) == null ? void 0 : Re.drivers) ?? [
543
+ drivers: ((pe = (Re = e == null ? void 0 : e.core) == null ? void 0 : Re.auth) == null ? void 0 : pe.drivers) ?? [
544
544
  { driver: "jwt", key: a },
545
545
  { driver: "htpasswd", path: `${r}/users.htpasswd` }
546
546
  ]
@@ -558,7 +558,7 @@ function Cr(a, e) {
558
558
  switch (($e = (_e = e == null ? void 0 : e.storages) == null ? void 0 : _e.work) == null ? void 0 : $e.type) {
559
559
  case void 0:
560
560
  case "FS":
561
- n = er("work"), n.rootPath = ((Te = (Oe = e == null ? void 0 : e.storages) == null ? void 0 : Oe.work) == null ? void 0 : Te.rootPath) ?? `${r}/storages/work`, n.indexCachePeriod = ((Fe = (Ee = e == null ? void 0 : e.storages) == null ? void 0 : Ee.work) == null ? void 0 : Fe.indexCachePeriod) ?? "1m";
561
+ n = er("work"), n.rootPath = ((Te = (Oe = e == null ? void 0 : e.storages) == null ? void 0 : Oe.work) == null ? void 0 : Te.rootPath) ?? `${r}/storages/work`, n.indexCachePeriod = ((De = (Ee = e == null ? void 0 : e.storages) == null ? void 0 : Ee.work) == null ? void 0 : De.indexCachePeriod) ?? "1m";
562
562
  break;
563
563
  default:
564
564
  throw new Error("work storage MUST have 'FS' type as it is used for working directories management");
@@ -567,7 +567,7 @@ function Cr(a, e) {
567
567
  "library",
568
568
  `${r}/storages/library`,
569
569
  "library-bucket",
570
- (De = e == null ? void 0 : e.storages) == null ? void 0 : De.library
570
+ (Fe = e == null ? void 0 : e.storages) == null ? void 0 : Fe.library
571
571
  ), f = {
572
572
  enabled: Q((Ne = e == null ? void 0 : e.monitoring) == null ? void 0 : Ne.enabled, !0),
573
573
  listen: ((Ie = e == null ? void 0 : e.monitoring) == null ? void 0 : Ie.listen) ?? "127.0.0.1:9090"
@@ -796,7 +796,7 @@ class I {
796
796
  K(e, "failed to bring back Platforma Backend in the last started configuration");
797
797
  }
798
798
  startLocal(e) {
799
- var u, m, f, w, P, g, b, v, S, p;
799
+ var u, m, f, w, P, g, b, v, S, R;
800
800
  const r = (e == null ? void 0 : e.binaryPath) ?? Hr(e == null ? void 0 : e.version, "binaries", "platforma");
801
801
  var t = e == null ? void 0 : e.configPath;
802
802
  const i = (e == null ? void 0 : e.workdir) ?? (t ? process.cwd() : l.path());
@@ -814,7 +814,7 @@ class I {
814
814
  }
815
815
  });
816
816
  const s = Cr(this.getLastJwt(), e == null ? void 0 : e.configOptions);
817
- this.logger.debug(" checking license..."), this.checkLicense((v = (b = e == null ? void 0 : e.configOptions) == null ? void 0 : b.license) == null ? void 0 : v.value, (p = (S = e == null ? void 0 : e.configOptions) == null ? void 0 : S.license) == null ? void 0 : p.file);
817
+ this.logger.debug(" checking license..."), this.checkLicense((v = (b = e == null ? void 0 : e.configOptions) == null ? void 0 : b.license) == null ? void 0 : v.value, (R = (S = e == null ? void 0 : e.configOptions) == null ? void 0 : S.license) == null ? void 0 : R.file);
818
818
  const c = [
819
819
  `${s.localRoot}/packages`,
820
820
  `${s.localRoot}/packages-local`,
@@ -912,10 +912,10 @@ ${n}`), Nr(
912
912
  startDockerS3(e, r) {
913
913
  const t = $("compose-backend.yaml"), i = (r == null ? void 0 : r.image) ?? se(r == null ? void 0 : r.version);
914
914
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
915
- const s = (S) => o.join(e, S), c = (S) => {
916
- const p = s(S);
917
- return X(p, { mode: "0775" }), p;
918
- }, n = s("platforma.log");
915
+ const s = (...S) => o.join(e, ...S), c = (S) => {
916
+ const R = s(S);
917
+ return X(R, { mode: "0775" }), R;
918
+ }, n = s("logs", "platforma.log");
919
919
  d.existsSync(n) || (d.mkdirSync(o.dirname(n), { recursive: !0 }), d.writeFileSync(n, ""));
920
920
  const u = x("s3e://testuser:testpassword@minio:9000/main-bucket");
921
921
  if (u.type !== "S3")
@@ -935,7 +935,8 @@ ${n}`), Nr(
935
935
  PL_LICENSE: r == null ? void 0 : r.license,
936
936
  PL_LICENSE_FILE: r == null ? void 0 : r.licenseFile,
937
937
  PL_LOG_LEVEL: (r == null ? void 0 : r.logLevel) ?? "info",
938
- PL_LOG_FILE: n,
938
+ PL_LOG_DIR: o.dirname(n),
939
+ PL_LOG_ROTATION_ENABLED: "true",
939
940
  PL_DATA_DB_ROOT: f,
940
941
  PL_DATA_PRIMARY_ROOT: c("primary"),
941
942
  PL_DATA_LIBRARY_ROOT: c("library"),
@@ -987,10 +988,10 @@ ${v}`);
987
988
  var t = $("compose-backend.yaml");
988
989
  const i = (r == null ? void 0 : r.image) ?? se(r == null ? void 0 : r.version);
989
990
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
990
- const s = (k) => o.join(e, k), c = (k) => {
991
+ const s = (...k) => o.join(e, ...k), c = (k) => {
991
992
  const _ = s(k);
992
993
  return X(_, { mode: "0775" }), _;
993
- }, n = s("platforma.log");
994
+ }, n = s("logs", "platforma.log");
994
995
  d.existsSync(n) || (d.mkdirSync(o.dirname(n), { recursive: !0 }), d.writeFileSync(n, ""));
995
996
  const u = c("db"), m = c("primary"), f = c("library"), w = c("work"), P = s("users.htpasswd");
996
997
  d.existsSync(P) || d.copyFileSync($("users.htpasswd"), P);
@@ -1002,7 +1003,8 @@ ${v}`);
1002
1003
  PL_LICENSE: r == null ? void 0 : r.license,
1003
1004
  PL_LICENSE_FILE: r == null ? void 0 : r.licenseFile,
1004
1005
  PL_LOG_LEVEL: "info",
1005
- PL_LOG_FILE: n,
1006
+ PL_LOG_DIR: o.dirname(n),
1007
+ PL_LOG_ROTATION_ENABLED: "true",
1006
1008
  PL_DATA_DB_ROOT: u,
1007
1009
  PL_DATA_PRIMARY_ROOT: m,
1008
1010
  PL_DATA_LIBRARY_ROOT: f,
@@ -1032,7 +1034,7 @@ ${v}`);
1032
1034
  }
1033
1035
  );
1034
1036
  K(S, "failed to start Platforma Backend in Docker"), l.isActive = !0;
1035
- const p = this.renderRunInfo({
1037
+ const R = this.renderRunInfo({
1036
1038
  apiPort: r == null ? void 0 : r.grpcPort,
1037
1039
  apiAddr: r == null ? void 0 : r.grpcAddr,
1038
1040
  logPath: n,
@@ -1042,7 +1044,7 @@ ${v}`);
1042
1044
  dbPath: u
1043
1045
  });
1044
1046
  this.logger.info(`Started platforma:
1045
- ${p}`);
1047
+ ${R}`);
1046
1048
  }
1047
1049
  stop() {
1048
1050
  if (!l.isActive) {
@@ -1069,7 +1071,7 @@ ${p}`);
1069
1071
  }
1070
1072
  }
1071
1073
  cleanup() {
1072
- var n, u, m, f, w, P, g, b, v, S, p, k, _, Y;
1074
+ var n, u, m, f, w, P, g, b, v, S, R, k, _, Y;
1073
1075
  const e = [
1074
1076
  "last command run cache ('pl-service start' shorthand will stop working until next full start command call)",
1075
1077
  "'platforma' docker compose service containers and volumes"
@@ -1083,7 +1085,7 @@ ${p}`);
1083
1085
  A.startsWith(r) || t.push(A);
1084
1086
  }
1085
1087
  if ((S = (v = l.lastRun) == null ? void 0 : v.process) != null && S.storagePath) {
1086
- const A = (k = (p = l.lastRun) == null ? void 0 : p.process) == null ? void 0 : k.storagePath;
1088
+ const A = (k = (R = l.lastRun) == null ? void 0 : R.process) == null ? void 0 : k.storagePath;
1087
1089
  A.startsWith(r) || t.push(A);
1088
1090
  }
1089
1091
  const i = t.length > 0 ? ` - storages (you'll loose all projects and calculation results stored in service instances):
@@ -1100,7 +1102,7 @@ ${i}
1100
1102
  this.logger.info("Reset action was canceled");
1101
1103
  return;
1102
1104
  }
1103
- const c = new Set(Fr());
1105
+ const c = new Set(Dr());
1104
1106
  (Y = (_ = l.lastRun) == null ? void 0 : _.docker) != null && Y.composePath && c.add(l.lastRun.docker.composePath);
1105
1107
  for (const A of c)
1106
1108
  this.logger.info(`Destroying docker compose '${A}'`), this.destroyDocker(A, se());
@@ -1233,37 +1235,37 @@ function K(a, e) {
1233
1235
  }
1234
1236
  const G = class G extends E {
1235
1237
  async run() {
1236
- const { flags: e } = await this.parse(G), r = D(e["log-level"]);
1238
+ const { flags: e } = await this.parse(G), r = F(e["log-level"]);
1237
1239
  new I(r).cleanup();
1238
1240
  }
1239
1241
  };
1240
1242
  h(G, "description", "Clear service state (forget last run command, destroy docker services, volumes and so on)"), h(G, "examples", ["<%= config.bin %> <%= command.id %>"]), h(G, "flags", {
1241
- ...F
1243
+ ...D
1242
1244
  });
1243
1245
  let oe = G;
1244
1246
  const j = class j extends E {
1245
1247
  async run() {
1246
- const { flags: e } = await this.parse(j), r = D(e["log-level"]);
1248
+ const { flags: e } = await this.parse(j), r = F(e["log-level"]);
1247
1249
  new I(r).startLast();
1248
1250
  }
1249
1251
  };
1250
1252
  h(j, "description", "Start last run service configuraiton"), h(j, "examples", ["<%= config.bin %> <%= command.id %>"]), h(j, "flags", {
1251
- ...F
1253
+ ...D
1252
1254
  });
1253
1255
  let de = j;
1254
1256
  const U = class U extends E {
1255
1257
  async run() {
1256
- const { flags: e } = await this.parse(U), r = D(e["log-level"]);
1258
+ const { flags: e } = await this.parse(U), r = F(e["log-level"]);
1257
1259
  new I(r).stop();
1258
1260
  }
1259
1261
  };
1260
1262
  h(U, "description", "Stop platforma service"), h(U, "examples", ["<%= config.bin %> <%= command.id %>"]), h(U, "flags", {
1261
- ...F
1263
+ ...D
1262
1264
  });
1263
1265
  let ge = U;
1264
1266
  const W = class W extends E {
1265
1267
  async run() {
1266
- const { flags: e } = await this.parse(W), r = D(e["log-level"]), t = new I(r);
1268
+ const { flags: e } = await this.parse(W), r = F(e["log-level"]), t = new I(r);
1267
1269
  t.mergeLicenseEnvs(e);
1268
1270
  const i = e["auth-enabled"], s = i ? {
1269
1271
  enabled: i,
@@ -1288,7 +1290,7 @@ const W = class W extends E {
1288
1290
  }
1289
1291
  };
1290
1292
  h(W, "description", "Run platforma backend service with 'FS' primary storage type"), h(W, "examples", ["<%= config.bin %> <%= command.id %>"]), h(W, "flags", {
1291
- ...F,
1293
+ ...D,
1292
1294
  ...te,
1293
1295
  ...Je,
1294
1296
  ...ee,
@@ -1302,7 +1304,7 @@ h(W, "description", "Run platforma backend service with 'FS' primary storage typ
1302
1304
  let ue = W;
1303
1305
  const J = class J extends E {
1304
1306
  async run() {
1305
- const { flags: e } = await this.parse(J), r = D(e["log-level"]), t = new I(r);
1307
+ const { flags: e } = await this.parse(J), r = F(e["log-level"]), t = new I(r);
1306
1308
  t.mergeLicenseEnvs(e);
1307
1309
  const i = e["pl-workdir"] ?? ".", s = e.storage ? o.join(i, e.storage) : l.data("local"), c = e["pl-log-file"] ? o.join(i, e["pl-log-file"]) : void 0, n = t.initAuthDriversList(e, i), u = e["auth-enabled"] ?? n !== void 0;
1308
1310
  var m = e["pl-binary"];
@@ -1339,7 +1341,7 @@ const J = class J extends E {
1339
1341
  }
1340
1342
  };
1341
1343
  h(J, "description", "Run Platforma Backend service as local process on current host (no docker container)"), h(J, "examples", ["<%= config.bin %> <%= command.id %>"]), h(J, "flags", {
1342
- ...F,
1344
+ ...D,
1343
1345
  ...ee,
1344
1346
  ...te,
1345
1347
  ...ze,
@@ -1355,10 +1357,10 @@ h(J, "description", "Run Platforma Backend service as local process on current h
1355
1357
  ...ie
1356
1358
  });
1357
1359
  let fe = J;
1358
- var R;
1359
- let zr = (R = class extends E {
1360
+ var p;
1361
+ let zr = (p = class extends E {
1360
1362
  async run() {
1361
- const { flags: e } = await this.parse(R), r = D(e["log-level"]), t = new I(r);
1363
+ const { flags: e } = await this.parse(p), r = F(e["log-level"]), t = new I(r);
1362
1364
  t.mergeLicenseEnvs(e);
1363
1365
  const i = e["auth-enabled"], s = i ? {
1364
1366
  enabled: i,
@@ -1378,18 +1380,18 @@ let zr = (R = class extends E {
1378
1380
  debugPort: e["debug-port"]
1379
1381
  });
1380
1382
  }
1381
- }, h(R, "description", "Run platforma backend service with 'S3' primary storage type"), h(R, "examples", ["<%= config.bin %> <%= command.id %>"]), h(R, "flags", {
1382
- ...F,
1383
+ }, h(p, "description", "Run platforma backend service with 'S3' primary storage type"), h(p, "examples", ["<%= config.bin %> <%= command.id %>"]), h(p, "flags", {
1384
+ ...D,
1383
1385
  ...te,
1384
1386
  ...Je,
1385
1387
  ...ee,
1386
1388
  ...ae,
1387
1389
  ...re,
1388
1390
  ...ie
1389
- }), R);
1391
+ }), p);
1390
1392
  const H = class H extends E {
1391
1393
  async run() {
1392
- const { flags: e } = await this.parse(H), r = D(e["log-level"]), t = new I(r);
1394
+ const { flags: e } = await this.parse(H), r = F(e["log-level"]), t = new I(r);
1393
1395
  t.mergeLicenseEnvs(e);
1394
1396
  const i = e["pl-workdir"] ?? ".", s = e.storage ? o.join(i, e.storage) : l.data("local-s3"), c = e["pl-log-file"] ? o.join(i, e["pl-log-file"]) : void 0, n = t.initAuthDriversList(e, i), u = e["auth-enabled"] ?? n !== void 0;
1395
1397
  var m = e["pl-binary"];
@@ -1430,7 +1432,7 @@ const H = class H extends E {
1430
1432
  }
1431
1433
  };
1432
1434
  h(H, "description", "Run Platforma Backend service as local process on current host (no docker container)"), h(H, "examples", ["<%= config.bin %> <%= command.id %>"]), h(H, "flags", {
1433
- ...F,
1435
+ ...D,
1434
1436
  ...ee,
1435
1437
  ...te,
1436
1438
  ...mr,