@platforma-sdk/bootstrap 2.6.2 → 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"
@@ -617,6 +617,10 @@ logging:
617
617
  level: '${a.log.level}'
618
618
  destinations:
619
619
  - path: '${a.log.path}'
620
+ rotation:
621
+ maxSize: 1GiB
622
+ maxBackups: 15
623
+ compress: true
620
624
 
621
625
  monitoring${e}:
622
626
  listen: '${a.monitoring.listen}'
@@ -627,7 +631,7 @@ debug${r}:
627
631
  core:
628
632
  logging:
629
633
  extendedInfo: true
630
- dumpResourceData: true
634
+ dumpResourceData: false
631
635
 
632
636
  grpc:
633
637
  listen: '${a.grpc.listen}'
@@ -792,7 +796,7 @@ class I {
792
796
  K(e, "failed to bring back Platforma Backend in the last started configuration");
793
797
  }
794
798
  startLocal(e) {
795
- var u, m, f, w, P, g, b, v, S, p;
799
+ var u, m, f, w, P, g, b, v, S, R;
796
800
  const r = (e == null ? void 0 : e.binaryPath) ?? Hr(e == null ? void 0 : e.version, "binaries", "platforma");
797
801
  var t = e == null ? void 0 : e.configPath;
798
802
  const i = (e == null ? void 0 : e.workdir) ?? (t ? process.cwd() : l.path());
@@ -810,7 +814,7 @@ class I {
810
814
  }
811
815
  });
812
816
  const s = Cr(this.getLastJwt(), e == null ? void 0 : e.configOptions);
813
- 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);
814
818
  const c = [
815
819
  `${s.localRoot}/packages`,
816
820
  `${s.localRoot}/packages-local`,
@@ -908,10 +912,10 @@ ${n}`), Nr(
908
912
  startDockerS3(e, r) {
909
913
  const t = $("compose-backend.yaml"), i = (r == null ? void 0 : r.image) ?? se(r == null ? void 0 : r.version);
910
914
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
911
- const s = (S) => o.join(e, S), c = (S) => {
912
- const p = s(S);
913
- return X(p, { mode: "0775" }), p;
914
- }, 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");
915
919
  d.existsSync(n) || (d.mkdirSync(o.dirname(n), { recursive: !0 }), d.writeFileSync(n, ""));
916
920
  const u = x("s3e://testuser:testpassword@minio:9000/main-bucket");
917
921
  if (u.type !== "S3")
@@ -931,7 +935,8 @@ ${n}`), Nr(
931
935
  PL_LICENSE: r == null ? void 0 : r.license,
932
936
  PL_LICENSE_FILE: r == null ? void 0 : r.licenseFile,
933
937
  PL_LOG_LEVEL: (r == null ? void 0 : r.logLevel) ?? "info",
934
- PL_LOG_FILE: n,
938
+ PL_LOG_DIR: o.dirname(n),
939
+ PL_LOG_ROTATION_ENABLED: "true",
935
940
  PL_DATA_DB_ROOT: f,
936
941
  PL_DATA_PRIMARY_ROOT: c("primary"),
937
942
  PL_DATA_LIBRARY_ROOT: c("library"),
@@ -983,10 +988,10 @@ ${v}`);
983
988
  var t = $("compose-backend.yaml");
984
989
  const i = (r == null ? void 0 : r.image) ?? se(r == null ? void 0 : r.version);
985
990
  this.checkLicense(r == null ? void 0 : r.license, r == null ? void 0 : r.licenseFile);
986
- const s = (k) => o.join(e, k), c = (k) => {
991
+ const s = (...k) => o.join(e, ...k), c = (k) => {
987
992
  const _ = s(k);
988
993
  return X(_, { mode: "0775" }), _;
989
- }, n = s("platforma.log");
994
+ }, n = s("logs", "platforma.log");
990
995
  d.existsSync(n) || (d.mkdirSync(o.dirname(n), { recursive: !0 }), d.writeFileSync(n, ""));
991
996
  const u = c("db"), m = c("primary"), f = c("library"), w = c("work"), P = s("users.htpasswd");
992
997
  d.existsSync(P) || d.copyFileSync($("users.htpasswd"), P);
@@ -998,7 +1003,8 @@ ${v}`);
998
1003
  PL_LICENSE: r == null ? void 0 : r.license,
999
1004
  PL_LICENSE_FILE: r == null ? void 0 : r.licenseFile,
1000
1005
  PL_LOG_LEVEL: "info",
1001
- PL_LOG_FILE: n,
1006
+ PL_LOG_DIR: o.dirname(n),
1007
+ PL_LOG_ROTATION_ENABLED: "true",
1002
1008
  PL_DATA_DB_ROOT: u,
1003
1009
  PL_DATA_PRIMARY_ROOT: m,
1004
1010
  PL_DATA_LIBRARY_ROOT: f,
@@ -1028,7 +1034,7 @@ ${v}`);
1028
1034
  }
1029
1035
  );
1030
1036
  K(S, "failed to start Platforma Backend in Docker"), l.isActive = !0;
1031
- const p = this.renderRunInfo({
1037
+ const R = this.renderRunInfo({
1032
1038
  apiPort: r == null ? void 0 : r.grpcPort,
1033
1039
  apiAddr: r == null ? void 0 : r.grpcAddr,
1034
1040
  logPath: n,
@@ -1038,7 +1044,7 @@ ${v}`);
1038
1044
  dbPath: u
1039
1045
  });
1040
1046
  this.logger.info(`Started platforma:
1041
- ${p}`);
1047
+ ${R}`);
1042
1048
  }
1043
1049
  stop() {
1044
1050
  if (!l.isActive) {
@@ -1065,7 +1071,7 @@ ${p}`);
1065
1071
  }
1066
1072
  }
1067
1073
  cleanup() {
1068
- 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;
1069
1075
  const e = [
1070
1076
  "last command run cache ('pl-service start' shorthand will stop working until next full start command call)",
1071
1077
  "'platforma' docker compose service containers and volumes"
@@ -1079,7 +1085,7 @@ ${p}`);
1079
1085
  A.startsWith(r) || t.push(A);
1080
1086
  }
1081
1087
  if ((S = (v = l.lastRun) == null ? void 0 : v.process) != null && S.storagePath) {
1082
- 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;
1083
1089
  A.startsWith(r) || t.push(A);
1084
1090
  }
1085
1091
  const i = t.length > 0 ? ` - storages (you'll loose all projects and calculation results stored in service instances):
@@ -1096,7 +1102,7 @@ ${i}
1096
1102
  this.logger.info("Reset action was canceled");
1097
1103
  return;
1098
1104
  }
1099
- const c = new Set(Fr());
1105
+ const c = new Set(Dr());
1100
1106
  (Y = (_ = l.lastRun) == null ? void 0 : _.docker) != null && Y.composePath && c.add(l.lastRun.docker.composePath);
1101
1107
  for (const A of c)
1102
1108
  this.logger.info(`Destroying docker compose '${A}'`), this.destroyDocker(A, se());
@@ -1229,37 +1235,37 @@ function K(a, e) {
1229
1235
  }
1230
1236
  const G = class G extends E {
1231
1237
  async run() {
1232
- 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"]);
1233
1239
  new I(r).cleanup();
1234
1240
  }
1235
1241
  };
1236
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", {
1237
- ...F
1243
+ ...D
1238
1244
  });
1239
1245
  let oe = G;
1240
1246
  const j = class j extends E {
1241
1247
  async run() {
1242
- 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"]);
1243
1249
  new I(r).startLast();
1244
1250
  }
1245
1251
  };
1246
1252
  h(j, "description", "Start last run service configuraiton"), h(j, "examples", ["<%= config.bin %> <%= command.id %>"]), h(j, "flags", {
1247
- ...F
1253
+ ...D
1248
1254
  });
1249
1255
  let de = j;
1250
1256
  const U = class U extends E {
1251
1257
  async run() {
1252
- 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"]);
1253
1259
  new I(r).stop();
1254
1260
  }
1255
1261
  };
1256
1262
  h(U, "description", "Stop platforma service"), h(U, "examples", ["<%= config.bin %> <%= command.id %>"]), h(U, "flags", {
1257
- ...F
1263
+ ...D
1258
1264
  });
1259
1265
  let ge = U;
1260
1266
  const W = class W extends E {
1261
1267
  async run() {
1262
- 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);
1263
1269
  t.mergeLicenseEnvs(e);
1264
1270
  const i = e["auth-enabled"], s = i ? {
1265
1271
  enabled: i,
@@ -1284,7 +1290,7 @@ const W = class W extends E {
1284
1290
  }
1285
1291
  };
1286
1292
  h(W, "description", "Run platforma backend service with 'FS' primary storage type"), h(W, "examples", ["<%= config.bin %> <%= command.id %>"]), h(W, "flags", {
1287
- ...F,
1293
+ ...D,
1288
1294
  ...te,
1289
1295
  ...Je,
1290
1296
  ...ee,
@@ -1298,7 +1304,7 @@ h(W, "description", "Run platforma backend service with 'FS' primary storage typ
1298
1304
  let ue = W;
1299
1305
  const J = class J extends E {
1300
1306
  async run() {
1301
- 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);
1302
1308
  t.mergeLicenseEnvs(e);
1303
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;
1304
1310
  var m = e["pl-binary"];
@@ -1335,7 +1341,7 @@ const J = class J extends E {
1335
1341
  }
1336
1342
  };
1337
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", {
1338
- ...F,
1344
+ ...D,
1339
1345
  ...ee,
1340
1346
  ...te,
1341
1347
  ...ze,
@@ -1351,10 +1357,10 @@ h(J, "description", "Run Platforma Backend service as local process on current h
1351
1357
  ...ie
1352
1358
  });
1353
1359
  let fe = J;
1354
- var R;
1355
- let zr = (R = class extends E {
1360
+ var p;
1361
+ let zr = (p = class extends E {
1356
1362
  async run() {
1357
- 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);
1358
1364
  t.mergeLicenseEnvs(e);
1359
1365
  const i = e["auth-enabled"], s = i ? {
1360
1366
  enabled: i,
@@ -1374,18 +1380,18 @@ let zr = (R = class extends E {
1374
1380
  debugPort: e["debug-port"]
1375
1381
  });
1376
1382
  }
1377
- }, h(R, "description", "Run platforma backend service with 'S3' primary storage type"), h(R, "examples", ["<%= config.bin %> <%= command.id %>"]), h(R, "flags", {
1378
- ...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,
1379
1385
  ...te,
1380
1386
  ...Je,
1381
1387
  ...ee,
1382
1388
  ...ae,
1383
1389
  ...re,
1384
1390
  ...ie
1385
- }), R);
1391
+ }), p);
1386
1392
  const H = class H extends E {
1387
1393
  async run() {
1388
- 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);
1389
1395
  t.mergeLicenseEnvs(e);
1390
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;
1391
1397
  var m = e["pl-binary"];
@@ -1426,7 +1432,7 @@ const H = class H extends E {
1426
1432
  }
1427
1433
  };
1428
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", {
1429
- ...F,
1435
+ ...D,
1430
1436
  ...ee,
1431
1437
  ...te,
1432
1438
  ...mr,