@milaboratories/pl-deployments 1.1.14 → 1.1.15

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
@@ -2,7 +2,7 @@ var Z = Object.defineProperty;
2
2
  var Y = (s, r, t) => r in s ? Z(s, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[r] = t;
3
3
  var w = (s, r, t) => Y(s, typeof r != "symbol" ? r + "" : r, t);
4
4
  import { spawn as Q } from "node:child_process";
5
- import { sleep as b, fileExists as g, assertNever as j, notEmpty as f, RetryablePromise as X } from "@milaboratories/ts-helpers";
5
+ import { sleep as b, fileExists as y, assertNever as j, notEmpty as f, RetryablePromise as X } from "@milaboratories/ts-helpers";
6
6
  import D from "node:fs";
7
7
  import m, { readFile as tt } from "node:fs/promises";
8
8
  import d from "upath";
@@ -81,7 +81,7 @@ async function pt(s, r, t, e, i, o) {
81
81
  return n;
82
82
  }
83
83
  async function mt(s, r, t, e, i, o) {
84
- const n = G(t, e, r, S(i), O(o)), { archiveUrl: c, alternativeArchiveGAUrl: a, archivePath: l, archiveType: h, targetFolder: u, baseName: y } = n;
84
+ const n = G(t, e, r, S(i), O(o)), { archiveUrl: c, alternativeArchiveGAUrl: a, archivePath: l, archiveType: h, targetFolder: u, baseName: $ } = n;
85
85
  try {
86
86
  await C(s, c, l), n.wasDownloadedFrom = c;
87
87
  } catch {
@@ -104,7 +104,7 @@ async function C(s, r, t) {
104
104
  const e = {};
105
105
  e.dstArchive = t;
106
106
  try {
107
- if (e.fileExisted = await g(t), e.fileExisted)
107
+ if (e.fileExisted = await y(t), e.fileExisted)
108
108
  return s.info(`Platforma Backend archive download skipped: '${t}' already exists`), e;
109
109
  await m.mkdir(d.dirname(t), { recursive: !0 }), e.dirnameCreated = !0, s.info(`Downloading archive:
110
110
  URL: ${r}
@@ -114,7 +114,7 @@ async function C(s, r, t) {
114
114
  const n = await ot(i);
115
115
  throw e.errorMsg = `failed to download archive: ${o}, response: ${n.slice(0, 1e3)}`, s.error(e.errorMsg), new Error(e.errorMsg);
116
116
  }
117
- return e.tmpPath = t + ".tmp", await et.toWeb(i).pipeTo(it.toWeb(D.createWriteStream(e.tmpPath))), e.wroteTmp = !0, e.tmpExisted = await g(e.tmpPath), await m.rename(e.tmpPath, t), e.renamed = !0, e.newExisted = await g(t), e;
117
+ return e.tmpPath = t + ".tmp", await et.toWeb(i).pipeTo(it.toWeb(D.createWriteStream(e.tmpPath))), e.wroteTmp = !0, e.tmpExisted = await y(e.tmpPath), await m.rename(e.tmpPath, t), e.renamed = !0, e.newExisted = await y(t), e;
118
118
  } catch (i) {
119
119
  const o = `downloadArchive: error ${JSON.stringify(i)} occurred, state: ${JSON.stringify(e)}`;
120
120
  throw s.error(o), new Error(o);
@@ -122,16 +122,16 @@ async function C(s, r, t) {
122
122
  }
123
123
  const gt = ".ok";
124
124
  async function yt(s, r, t, e) {
125
- if (s.info("extracting archive..."), s.info(` archive path: '${r}'`), s.info(` target dir: '${e}'`), !await g(r)) {
125
+ if (s.info("extracting archive..."), s.info(` archive path: '${r}'`), s.info(` target dir: '${e}'`), !await y(r)) {
126
126
  const o = `Platforma Backend binary archive not found at '${r}'`;
127
127
  throw s.error(o), new Error(o);
128
128
  }
129
129
  const i = d.join(e, gt);
130
- if (await g(i)) {
130
+ if (await y(i)) {
131
131
  s.info(`Platforma Backend binaries unpack skipped: '${e}' exists`);
132
132
  return;
133
133
  }
134
- switch (await g(e) && (s.info(`Removing previous incompletely unpacked folder: '${e}'`), await m.rm(e, { recursive: !0 })), s.info(` creating target dir '${e}'`), await m.mkdir(e, { recursive: !0 }), s.info(
134
+ switch (await y(e) && (s.info(`Removing previous incompletely unpacked folder: '${e}'`), await m.rm(e, { recursive: !0 })), s.info(` creating target dir '${e}'`), await m.mkdir(e, { recursive: !0 }), s.info(
135
135
  `Unpacking Platforma Backend archive:
136
136
  Archive: ${r}
137
137
  Target dir: ${e}`
@@ -182,7 +182,7 @@ function L(s) {
182
182
  return d.join(s, "pl_pid");
183
183
  }
184
184
  async function Ct(s) {
185
- if (!await g(s))
185
+ if (!await y(s))
186
186
  return;
187
187
  const r = await m.readFile(s);
188
188
  return Number(r.toString());
@@ -426,19 +426,19 @@ class N {
426
426
  let h;
427
427
  try {
428
428
  h = await i.ensure();
429
- } catch (y) {
430
- this.logger.info(`${l}.persistentClient.catch: ${y}`), a.end();
429
+ } catch ($) {
430
+ this.logger.info(`${l}.persistentClient.catch: ${$}`), a.end();
431
431
  return;
432
432
  }
433
433
  let u;
434
434
  try {
435
435
  u = await Rt(this.logger, h, "127.0.0.1", 0, "127.0.0.1", r.remotePort);
436
- } catch (y) {
437
- this.logger.error(`${l}.forwardOut.err: ${y}`), a.end();
436
+ } catch ($) {
437
+ this.logger.error(`${l}.forwardOut.err: ${$}`), a.end();
438
438
  return;
439
439
  }
440
- a.pipe(u), u.pipe(a), a.resume(), u.on("error", (y) => {
441
- this.logger.error(`${l}.stream.error: ${y}`), a.end(), u.end();
440
+ a.pipe(u), u.pipe(a), a.resume(), u.on("error", ($) => {
441
+ this.logger.error(`${l}.stream.error: ${$}`), a.end(), u.end();
442
442
  }), u.on("close", () => {
443
443
  a.end(), u.end();
444
444
  }), a.on("close", () => {
@@ -759,11 +759,11 @@ async function Rt(s, r, t, e, i, o) {
759
759
  });
760
760
  }
761
761
  const Bt = "minio-2024-12-18T13-15-44Z", Nt = "supervisord-0.7.3", Ut = "supervisord_0.7.3_Linux_64-bit";
762
- function $(s) {
762
+ function g(s) {
763
763
  return d.join(s, ".platforma_ssh");
764
764
  }
765
765
  function E(s) {
766
- return d.join($(s), "binaries");
766
+ return d.join(g(s), "binaries");
767
767
  }
768
768
  function Tt(s, r) {
769
769
  return d.join(E(s), `pl-${R()}-${S(r)}`);
@@ -790,10 +790,10 @@ function K(s, r) {
790
790
  return d.join(jt(s, r), "supervisord");
791
791
  }
792
792
  function V(s) {
793
- return d.join($(s), "supervisor.conf");
793
+ return d.join(g(s), "supervisor.conf");
794
794
  }
795
795
  function I(s) {
796
- return d.join($(s), "connection.txt");
796
+ return d.join(g(s), "connection.txt");
797
797
  }
798
798
  async function Ht(s, r, t) {
799
799
  const e = await U(s, r, t, "--daemon");
@@ -958,7 +958,7 @@ class q {
958
958
  /** Stops platforma and deletes its state. */
959
959
  async stopAndClean() {
960
960
  const r = await this.getUserHomeDirectory();
961
- this.logger.info("pl.reset: Stop Platforma on the server"), await this.stop(), this.logger.info(`pl.reset: Deleting Platforma workDir ${r} on the server`), await this.sshClient.deleteFolder($(r));
961
+ this.logger.info("pl.reset: Stop Platforma on the server"), await this.stop(), this.logger.info(`pl.reset: Deleting Platforma workDir ${g(r)} on the server`), await this.sshClient.deleteFolder(g(r));
962
962
  }
963
963
  /** Downloads binaries and untar them on the server,
964
964
  * generates all the configs, creates necessary dirs,
@@ -988,7 +988,7 @@ class q {
988
988
  throw new Error("SshPl.platformaInit: remote ports are not defined");
989
989
  const o = await lt({
990
990
  logger: this.logger,
991
- workingDir: $(t.remoteHome),
991
+ workingDir: g(t.remoteHome),
992
992
  portsMode: {
993
993
  type: "customWithMinio",
994
994
  ports: {
@@ -1019,7 +1019,7 @@ class q {
1019
1019
  t.binPaths.downloadedPl
1020
1020
  );
1021
1021
  if (!await this.sshClient.writeFileOnTheServer(V(t.remoteHome), n))
1022
- throw new Error(`Can not write supervisord config on the server ${$(t.remoteHome)}`);
1022
+ throw new Error(`Can not write supervisord config on the server ${g(t.remoteHome)}`);
1023
1023
  return t.connectionInfo = zt(
1024
1024
  o.plUser,
1025
1025
  o.plPassword,
@@ -1097,13 +1097,13 @@ class q {
1097
1097
  if (await b(300), h == a)
1098
1098
  throw new Error(`downloadAndUntar: ${a} attempts, last error: ${u}`);
1099
1099
  }
1100
- n.downloadResult = f(c), n.localArchivePath = d.resolve(n.downloadResult.archivePath), n.remoteDir = d.join(n.binBasePath, n.downloadResult.baseName), n.remoteArchivePath = n.remoteDir + ".tgz", await this.sshClient.ensureRemoteDirCreated(n.remoteDir), await this.sshClient.uploadFile(n.localArchivePath, n.remoteArchivePath);
1100
+ n.downloadResult = f(c), n.localArchivePath = d.resolve(n.downloadResult.archivePath), n.remoteDir = d.join(n.binBasePath, n.downloadResult.baseName), n.remoteArchivePath = n.remoteDir + ".tgz", await this.sshClient.ensureRemoteDirCreated(n.remoteDir), await this.sshClient.uploadFile(n.localArchivePath, n.remoteArchivePath), n.uploadDone = !0;
1101
1101
  const l = await this.sshClient.exec(
1102
1102
  `tar --warning=no-all -xvf ${n.remoteArchivePath} --directory=${n.remoteDir}`
1103
1103
  );
1104
1104
  if (l.stderr)
1105
1105
  throw Error(`downloadAndUntar: untar: stderr occurred: ${l.stderr}, stdout: ${l.stdout}`);
1106
- return n.plUntarDone = !0, n;
1106
+ return n.untarDone = !0, n;
1107
1107
  }
1108
1108
  async needDownload(r, t) {
1109
1109
  const e = K(r, t.arch), i = z(r, t.arch), o = T(r, t.arch);