@milaboratories/pl-deployments 1.1.6 → 1.1.8

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
@@ -1,9 +1,9 @@
1
- var G = Object.defineProperty;
2
- var Z = (s, t, r) => t in s ? G(s, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[t] = r;
1
+ var q = Object.defineProperty;
2
+ var Z = (s, t, r) => t in s ? q(s, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[t] = r;
3
3
  var w = (s, t, r) => Z(s, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { spawn as V } from "node:child_process";
5
- import { sleep as C, fileExists as m, assertNever as T, notEmpty as p, RetryablePromise as Y } from "@milaboratories/ts-helpers";
6
- import E from "node:fs";
5
+ import { sleep as F, fileExists as m, assertNever as _, notEmpty as p, RetryablePromise as Y } from "@milaboratories/ts-helpers";
6
+ import A from "node:fs";
7
7
  import f, { readFile as Q } from "node:fs/promises";
8
8
  import d from "upath";
9
9
  import { request as X } from "undici";
@@ -11,35 +11,35 @@ import { Readable as rr, Writable as tr } from "node:stream";
11
11
  import { text as er } from "node:stream/consumers";
12
12
  import * as ir from "tar";
13
13
  import or from "decompress";
14
- import k from "node:os";
15
- import sr, { Client as S } from "ssh2";
16
- import B from "node:net";
14
+ import C from "node:os";
15
+ import sr, { Client as E } from "ssh2";
16
+ import I from "node:net";
17
17
  import nr from "node:dns";
18
- import { randomBytes as F } from "node:crypto";
18
+ import { randomBytes as D } from "node:crypto";
19
19
  import { generateSshPlConfigs as ar, getFreePort as y } from "@milaboratories/pl-config";
20
20
  function cr(s, t) {
21
21
  return s.info(`Running:
22
22
  cmd: ${JSON.stringify([t.cmd, ...t.args])}
23
23
  wd: ${t.opts.cwd}`), s.info(" spawning child process"), V(t.cmd, t.args, t.opts);
24
24
  }
25
- async function D(s) {
25
+ async function k(s) {
26
26
  try {
27
27
  return process.kill(s, 0), !0;
28
28
  } catch {
29
29
  return !1;
30
30
  }
31
31
  }
32
- function _(s) {
32
+ function j(s) {
33
33
  return process.kill(s, "SIGINT");
34
34
  }
35
- async function j(s, t) {
35
+ async function H(s, t) {
36
36
  let e = 0;
37
- for (; await D(s); )
38
- if (await C(100), e += 100, e > t)
37
+ for (; await k(s); )
38
+ if (await F(100), e += 100, e > t)
39
39
  throw new Error(`The process did not stopped after ${t} ms.`);
40
40
  }
41
41
  const lr = ["linux", "macos", "windows"];
42
- function I(s) {
42
+ function b(s) {
43
43
  switch (s.toLowerCase()) {
44
44
  case "darwin":
45
45
  return "macos";
@@ -69,36 +69,37 @@ function P(s) {
69
69
  );
70
70
  }
71
71
  }
72
- async function dr(s, t, r, e, i, o) {
73
- const n = wr(r, e, t, P(i), I(o)), { archiveUrl: c, archivePath: a } = n;
74
- return await H(s, c, a), n;
72
+ const dr = "https://cdn.platforma.bio/software", ur = "https://cdn-ga.pl-open.science/software";
73
+ async function wr(s, t, r, e, i, o) {
74
+ const n = M(r, e, t, P(i), b(o)), { archiveUrl: c, alternativeArchiveGAUrl: a, archivePath: l } = n;
75
+ try {
76
+ await v(s, c, l), n.wasDownloadedFrom = c;
77
+ } catch {
78
+ await v(s, a, l), n.wasDownloadedFrom = a;
79
+ }
80
+ return n;
75
81
  }
76
- async function ur(s, t, r, e, i) {
77
- const o = fr(r, t, P(e), I(i)), { archiveUrl: n, archivePath: c, archiveType: a, targetFolder: l, binaryPath: h } = o;
78
- return await H(s, n, c), await mr(s, c, a, l), o;
82
+ async function fr(s, t, r, e, i, o) {
83
+ const n = M(r, e, t, P(i), b(o)), { archiveUrl: c, alternativeArchiveGAUrl: a, archivePath: l, archiveType: h, targetFolder: u, baseName: g } = n;
84
+ try {
85
+ await v(s, c, l), n.wasDownloadedFrom = c;
86
+ } catch {
87
+ await v(s, a, l), n.wasDownloadedFrom = a;
88
+ }
89
+ return await mr(s, l, h, u), n;
79
90
  }
80
- function wr(s, t, r, e, i) {
81
- const o = `${t}-${e}`, n = M[i], c = `${o}.${n}`, a = `https://cdn.platforma.bio/software/${s}/${i}/${c}`, l = d.join(r, c), h = d.join(r, o);
91
+ function M(s, t, r, e, i) {
92
+ const o = `${t}-${e}`, n = gr[i], c = `${o}.${n}`, a = `${dr}/${s}/${i}/${c}`, l = `${ur}/${s}/${i}/${c}`, h = d.join(r, c), u = d.join(r, o);
82
93
  return {
83
94
  archiveUrl: a,
84
- archivePath: l,
95
+ alternativeArchiveGAUrl: l,
96
+ archivePath: h,
85
97
  archiveType: n,
86
- targetFolder: h,
98
+ targetFolder: u,
87
99
  baseName: o
88
100
  };
89
101
  }
90
- function fr(s, t, r, e) {
91
- const i = `pl-${s}-${r}`, o = M[e], n = `${i}.${o}`, c = `https://cdn.platforma.bio/software/pl/${e}/${n}`, a = d.join(t, n), l = d.join(t, i), h = d.join(i, "binaries", gr[e]);
92
- return {
93
- archiveUrl: c,
94
- archivePath: a,
95
- archiveType: o,
96
- targetFolder: l,
97
- binaryPath: h,
98
- baseName: i
99
- };
100
- }
101
- async function H(s, t, r) {
102
+ async function v(s, t, r) {
102
103
  const e = {};
103
104
  e.dstArchive = r;
104
105
  try {
@@ -112,7 +113,7 @@ async function H(s, t, r) {
112
113
  const n = await er(i);
113
114
  throw e.errorMsg = `failed to download archive: ${o}, response: ${n.slice(0, 1e3)}`, s.error(e.errorMsg), new Error(e.errorMsg);
114
115
  }
115
- return e.tmpPath = r + ".tmp", await rr.toWeb(i).pipeTo(tr.toWeb(E.createWriteStream(e.tmpPath))), e.wroteTmp = !0, e.tmpExisted = await m(e.tmpPath), await f.rename(e.tmpPath, r), e.renamed = !0, e.newExisted = await m(r), e;
116
+ return e.tmpPath = r + ".tmp", await rr.toWeb(i).pipeTo(tr.toWeb(A.createWriteStream(e.tmpPath))), e.wroteTmp = !0, e.tmpExisted = await m(e.tmpPath), await f.rename(e.tmpPath, r), e.renamed = !0, e.newExisted = await m(r), e;
116
117
  } catch (i) {
117
118
  const o = `downloadArchive: error ${JSON.stringify(i)} occurred, state: ${JSON.stringify(e)}`;
118
119
  throw s.error(o), new Error(o);
@@ -145,63 +146,65 @@ async function mr(s, t, r, e) {
145
146
  await or(t, e);
146
147
  break;
147
148
  default:
148
- T(r);
149
+ _(r);
149
150
  }
150
151
  await f.writeFile(i, "ok"), s.info(" ... unpack done.");
151
152
  }
152
- const M = {
153
+ const gr = {
153
154
  linux: "tgz",
154
155
  macos: "tgz",
155
156
  windows: "zip"
156
- }, gr = {
157
- linux: "platforma",
158
- macos: "platforma",
159
- windows: "platforma.exe"
160
157
  };
161
- function b() {
158
+ function x() {
162
159
  return "1.18.3";
163
160
  }
164
161
  function yr() {
165
- return { type: "Download", version: b() };
162
+ return { type: "Download", version: x() };
166
163
  }
167
164
  async function $r(s, t, r) {
168
165
  switch (r.type) {
169
166
  case "Download":
170
- return (await ur(s, t, r.version, k.arch(), k.platform())).binaryPath;
167
+ const e = await fr(s, t, "pl", `pl-${r.version}`, C.arch(), C.platform());
168
+ return d.join(e.baseName, "binaries", Pr[b(C.platform())]);
171
169
  case "Local":
172
170
  return r.path;
173
171
  default:
174
- T(r);
172
+ _(r);
175
173
  }
176
174
  }
175
+ const Pr = {
176
+ linux: "platforma",
177
+ macos: "platforma",
178
+ windows: "platforma.exe"
179
+ };
177
180
  function J(s) {
178
181
  return d.join(s, "pl_pid");
179
182
  }
180
- async function Pr(s) {
183
+ async function vr(s) {
181
184
  if (!await m(s))
182
185
  return;
183
186
  const t = await f.readFile(s);
184
187
  return Number(t.toString());
185
188
  }
186
- async function vr(s, t) {
189
+ async function Sr(s, t) {
187
190
  await f.writeFile(s, JSON.stringify(t));
188
191
  }
189
- function Sr() {
192
+ function Cr() {
190
193
  return {};
191
194
  }
192
- function Cr(s, t, r) {
195
+ function Er(s, t, r) {
193
196
  return s[t] = r, r;
194
197
  }
195
- async function A(s, t) {
196
- const r = Sr();
198
+ async function O(s, t) {
199
+ const r = Cr();
197
200
  try {
198
- return await t((i, o) => Cr(r, i, o), r);
201
+ return await t((i, o) => Er(r, i, o), r);
199
202
  } catch (e) {
200
203
  throw s.error(`error ${e} while doing traced operation, state: ${JSON.stringify(r)}`), e;
201
204
  }
202
205
  }
203
- const Er = "config-local.yaml";
204
- class Fr {
206
+ const Fr = "config-local.yaml";
207
+ class Ar {
205
208
  constructor(t, r, e, i, o, n, c, a) {
206
209
  w(this, "instance");
207
210
  w(this, "pid");
@@ -211,7 +214,7 @@ class Fr {
211
214
  this.logger = t, this.workingDir = r, this.startOptions = e, this.initialStartHistory = i, this.onClose = o, this.onError = n, this.onCloseAndError = c, this.onCloseAndErrorNoStop = a;
212
215
  }
213
216
  async start() {
214
- await A(this.logger, async (t, r) => {
217
+ await O(this.logger, async (t, r) => {
215
218
  this.wasStopped = !1;
216
219
  const e = cr(this.logger, this.startOptions);
217
220
  e.on("error", (o) => {
@@ -222,20 +225,20 @@ class Fr {
222
225
  this.logger.warn(`platforma was closed, started opts: ${JSON.stringify(this.debugInfo())}`), this.onClose !== void 0 && this.onClose(this), this.onCloseAndError !== void 0 && this.onCloseAndError(this), this.onCloseAndErrorNoStop !== void 0 && !this.wasStopped && this.onCloseAndErrorNoStop(this);
223
226
  }), t("started", !0);
224
227
  const i = t("pidFile", J(this.workingDir));
225
- t("pid", p(e.pid)), t("pidWritten", await vr(i, p(e.pid))), this.nRuns++, this.instance = e, this.pid = e.pid, this.lastRunHistory = r;
228
+ t("pid", p(e.pid)), t("pidWritten", await Sr(i, p(e.pid))), this.nRuns++, this.instance = e, this.pid = e.pid, this.lastRunHistory = r;
226
229
  });
227
230
  }
228
231
  stop() {
229
- this.wasStopped = !0, _(p(this.pid));
232
+ this.wasStopped = !0, j(p(this.pid));
230
233
  }
231
234
  async waitStopped() {
232
- await j(p(this.pid), 15e3);
235
+ await H(p(this.pid), 15e3);
233
236
  }
234
237
  stopped() {
235
238
  return this.wasStopped;
236
239
  }
237
240
  async isAlive() {
238
- return await D(p(this.pid));
241
+ return await k(p(this.pid));
239
242
  }
240
243
  debugInfo() {
241
244
  return {
@@ -248,21 +251,21 @@ class Fr {
248
251
  };
249
252
  }
250
253
  }
251
- async function it(s, t) {
254
+ async function st(s, t) {
252
255
  const r = {
253
256
  plBinary: yr(),
254
257
  spawnOptions: {},
255
258
  closeOld: !0,
256
259
  ...t
257
260
  };
258
- return await A(s, async (e, i) => {
261
+ return await O(s, async (e, i) => {
259
262
  e("startOptions", { ...r, config: "too wordy" });
260
263
  const o = d.resolve(r.workingDir);
261
264
  r.closeOld && e("closeOld", await Dr(s, o));
262
- const n = d.join(o, Er);
265
+ const n = d.join(o, Fr);
263
266
  s.info(`writing configuration '${n}'...`), await f.writeFile(n, r.config);
264
- const c = await $r(s, d.join(o, "binaries"), r.plBinary), l = {
265
- cmd: e("binaryPath", d.join("binaries", c)),
267
+ const c = d.join(o, "binaries"), a = await $r(s, c, r.plBinary), h = {
268
+ cmd: e("binaryPath", d.join("binaries", a)),
266
269
  args: ["-config", n],
267
270
  opts: {
268
271
  env: { ...process.env },
@@ -274,34 +277,34 @@ async function it(s, t) {
274
277
  }
275
278
  };
276
279
  e("processOpts", {
277
- cmd: l.cmd,
278
- args: l.args,
279
- cwd: l.opts.cwd
280
+ cmd: h.cmd,
281
+ args: h.args,
282
+ cwd: h.opts.cwd
280
283
  });
281
- const h = new Fr(
284
+ const u = new Ar(
282
285
  s,
283
286
  r.workingDir,
284
- l,
287
+ h,
285
288
  i,
286
289
  r.onClose,
287
290
  r.onError,
288
291
  r.onCloseAndError,
289
292
  r.onCloseAndErrorNoStop
290
293
  );
291
- return await h.start(), h;
294
+ return await u.start(), u;
292
295
  });
293
296
  }
294
297
  async function Dr(s, t) {
295
- return await A(s, async (r, e) => {
296
- const i = r("pidFilePath", J(t)), o = r("pid", await Pr(i)), n = r("wasAlive", await D(o));
297
- return o !== void 0 && n && (r("stopped", _(o)), r("waitStopped", await j(o, 1e4))), e;
298
+ return await O(s, async (r, e) => {
299
+ const i = r("pidFilePath", J(t)), o = r("pid", await vr(i)), n = r("wasAlive", await k(o));
300
+ return o !== void 0 && n && (r("stopped", j(o)), r("waitStopped", await H(o, 1e4))), e;
298
301
  });
299
302
  }
300
- const br = {
303
+ const kr = {
301
304
  keepaliveInterval: 6e4,
302
305
  keepaliveCountMax: 10
303
306
  };
304
- class x {
307
+ class R {
305
308
  constructor(t, r) {
306
309
  w(this, "config");
307
310
  w(this, "homeDir");
@@ -315,9 +318,9 @@ class x {
315
318
  */
316
319
  static async init(t, r) {
317
320
  const e = {
318
- ...br,
321
+ ...kr,
319
322
  ...r
320
- }, i = new x(t, new S());
323
+ }, i = new R(t, new E());
321
324
  return await i.connect(e), i;
322
325
  }
323
326
  getForwardedServers() {
@@ -337,7 +340,7 @@ class x {
337
340
  * @returns A promise that resolves when the connection is established or rejects on error.
338
341
  */
339
342
  async connect(t) {
340
- return this.config = t, await Ar(this.client, t);
343
+ return this.config = t, await br(this.client, t);
341
344
  }
342
345
  /**
343
346
  * Executes a command on the SSH server.
@@ -369,7 +372,7 @@ class x {
369
372
  static async getAuthTypes(t, r) {
370
373
  return new Promise((e) => {
371
374
  let i = "";
372
- const o = new S();
375
+ const o = new E();
373
376
  o.on("ready", () => {
374
377
  o.end();
375
378
  const n = this.extractAuthMethods(i);
@@ -404,10 +407,10 @@ class x {
404
407
  * @returns { server: net.Server } A promise resolving with the created server instance.
405
408
  */
406
409
  async forwardPort(t, r) {
407
- const e = `ssh.forward:${t.localPort}:${t.remotePort}.id_${F(1).toString("hex")}`;
410
+ const e = `ssh.forward:${t.localPort}:${t.remotePort}.id_${D(1).toString("hex")}`;
408
411
  r = r ?? this.config;
409
412
  const i = new Y((o) => new Promise((n, c) => {
410
- const a = new S();
413
+ const a = new E();
411
414
  a.on("ready", () => {
412
415
  this.logger.info(`${e}.client.ready`), n(a);
413
416
  }), a.on("error", (l) => {
@@ -417,8 +420,8 @@ class x {
417
420
  }), a.connect(r);
418
421
  }));
419
422
  return await i.ensure(), new Promise((o, n) => {
420
- const c = B.createServer({ pauseOnConnect: !0 }, async (a) => {
421
- const l = `${e}.sock_${F(1).toString("hex")}`;
423
+ const c = I.createServer({ pauseOnConnect: !0 }, async (a) => {
424
+ const l = `${e}.sock_${D(1).toString("hex")}`;
422
425
  let h;
423
426
  try {
424
427
  h = await i.ensure();
@@ -635,14 +638,14 @@ class x {
635
638
  }
636
639
  async __uploadDirectory(t, r, e, i = 432) {
637
640
  return new Promise((o, n) => {
638
- E.readdir(r, async (c, a) => {
641
+ A.readdir(r, async (c, a) => {
639
642
  if (c)
640
643
  return n(new Error(`ssh.__uploadDir: err ${c}, localDir: ${r}, remoteDir: ${e}`));
641
644
  try {
642
645
  await this.__createRemoteDirectory(t, e);
643
646
  for (const l of a) {
644
647
  const h = d.join(r, l), u = `${e}/${l}`;
645
- E.lstatSync(h).isDirectory() ? await this.__uploadDirectory(t, h, u, i) : await this.uploadFileUsingExistingSftp(t, h, u, i);
648
+ A.lstatSync(h).isDirectory() ? await this.__uploadDirectory(t, h, u, i) : await this.uploadFileUsingExistingSftp(t, h, u, i);
646
649
  }
647
650
  o();
648
651
  } catch (l) {
@@ -740,7 +743,7 @@ class x {
740
743
  this.closeForwardedPorts(), this.client.end();
741
744
  }
742
745
  }
743
- async function Ar(s, t, r, e) {
746
+ async function br(s, t, r, e) {
744
747
  return new Promise((i, o) => {
745
748
  s.on("ready", () => {
746
749
  i(s);
@@ -755,65 +758,65 @@ async function xr(s, t, r, e, i, o) {
755
758
  t.forwardOut(r, e, i, o, (a, l) => a ? (s.error(`forwardOut.error: ${a}`), c(a)) : n(l));
756
759
  });
757
760
  }
758
- const Or = "minio-2024-12-18T13-15-44Z", kr = "supervisord-0.7.3", Rr = "supervisord_0.7.3_Linux_64-bit";
761
+ const Or = "minio-2024-12-18T13-15-44Z", Rr = "supervisord-0.7.3", Ur = "supervisord_0.7.3_Linux_64-bit";
759
762
  function $(s) {
760
763
  return d.join(s, "platforma_ssh");
761
764
  }
762
- function v(s) {
765
+ function S(s) {
763
766
  return d.join(s, "platforma_ssh", "binaries");
764
767
  }
765
768
  function Nr(s, t) {
766
- return d.join(v(s), `pl-${b()}-${P(t)}`);
769
+ return d.join(S(s), `pl-${x()}-${P(t)}`);
767
770
  }
768
771
  function L(s, t) {
769
772
  return d.join(Nr(s, t), "binaries");
770
773
  }
771
- function R(s, t) {
774
+ function N(s, t) {
772
775
  return d.join(L(s, t), "platforma");
773
776
  }
774
- function Ur(s, t) {
777
+ function Br(s, t) {
775
778
  return d.join(L(s, t), "free-port");
776
779
  }
777
- function z(s, t) {
778
- return d.join(v(s), `minio-2024-12-18T13-15-44Z-${P(t)}`);
780
+ function W(s, t) {
781
+ return d.join(S(s), `minio-2024-12-18T13-15-44Z-${P(t)}`);
779
782
  }
780
783
  function Tr(s, t) {
781
- return d.join(z(s, t), "minio");
784
+ return d.join(W(s, t), "minio");
782
785
  }
783
- function Br(s, t) {
784
- return d.join(v(s), `supervisord-0.7.3-${P(t)}`, Rr);
786
+ function _r(s, t) {
787
+ return d.join(S(s), `supervisord-0.7.3-${P(t)}`, Ur);
785
788
  }
786
- function W(s, t) {
787
- return d.join(Br(s, t), "supervisord");
789
+ function z(s, t) {
790
+ return d.join(_r(s, t), "supervisord");
788
791
  }
789
- function K(s) {
792
+ function G(s) {
790
793
  return d.join($(s), "supervisor.conf");
791
794
  }
792
- function N(s) {
795
+ function B(s) {
793
796
  return d.join($(s), "connection.txt");
794
797
  }
795
- async function _r(s, t, r) {
796
- const e = await O(s, t, r, "--daemon");
798
+ async function Ir(s, t, r) {
799
+ const e = await U(s, t, r, "--daemon");
797
800
  if (e.stderr)
798
801
  throw new Error(`Can not run ssh Platforma ${e.stderr}`);
799
802
  }
800
803
  async function jr(s, t, r) {
801
- const e = await O(s, t, r, "ctl shutdown");
804
+ const e = await U(s, t, r, "ctl shutdown");
802
805
  if (e.stderr)
803
806
  throw new Error(`Can not stop ssh Platforma ${e.stderr}`);
804
807
  }
805
- async function Ir(s, t, r, e) {
806
- const i = await O(t, r, e, "ctl status");
808
+ async function Hr(s, t, r, e) {
809
+ const i = await U(t, r, e, "ctl status");
807
810
  if (i.stderr)
808
811
  return s.info(`supervisord ctl status: stderr occurred: ${i.stderr}, stdout: ${i.stdout}`), !1;
809
812
  const o = {
810
- platforma: U(i.stdout, "platforma"),
811
- minio: U(i.stdout, "minio")
813
+ platforma: T(i.stdout, "platforma"),
814
+ minio: T(i.stdout, "minio")
812
815
  };
813
816
  return o.platforma && o.minio ? !0 : (o.minio || s.warn("Minio is not running on the server"), o.platforma || s.warn("Platforma is not running on the server"), !1);
814
817
  }
815
- function Hr(s, t, r, e, i, o, n) {
816
- const c = Object.entries(t).map(([h, u]) => `${h}="${u}"`).join(","), a = F(16).toString("hex"), l = r;
818
+ function Mr(s, t, r, e, i, o, n) {
819
+ const c = Object.entries(t).map(([h, u]) => `${h}="${u}"`).join(","), a = D(16).toString("hex"), l = r;
817
820
  return `
818
821
  [supervisord]
819
822
  logfile=${e}/supervisord.log
@@ -845,18 +848,18 @@ directory=${e}
845
848
  autorestart=true
846
849
  `;
847
850
  }
848
- async function O(s, t, r, e) {
849
- const i = W(t, r), o = K(t), n = `${i} --configuration ${o} ${e}`;
851
+ async function U(s, t, r, e) {
852
+ const i = z(t, r), o = G(t), n = `${i} --configuration ${o} ${e}`;
850
853
  return await s.exec(n);
851
854
  }
852
- function U(s, t) {
855
+ function T(s, t) {
853
856
  return ((i) => i.replace(/\x1B\[[0-9;]*m/g, ""))(s).split(`
854
857
  `).some((i) => {
855
858
  const [o, n] = i.trim().split(/\s{2,}/);
856
859
  return o === t && n === "Running";
857
860
  });
858
861
  }
859
- class q {
862
+ class K {
860
863
  constructor(t, r, e) {
861
864
  w(this, "initState", {});
862
865
  this.logger = t, this.sshClient = r, this.username = e;
@@ -869,8 +872,8 @@ class q {
869
872
  }
870
873
  static async init(t, r) {
871
874
  try {
872
- const e = await x.init(t, r);
873
- return new q(t, e, p(r.username));
875
+ const e = await R.init(t, r);
876
+ return new K(t, e, p(r.username));
874
877
  } catch (e) {
875
878
  throw t.error(`Connection error in SshClient.init: ${e}`), e;
876
879
  }
@@ -881,7 +884,7 @@ class q {
881
884
  async isAlive() {
882
885
  const t = await this.getArch(), r = await this.getUserHomeDirectory();
883
886
  try {
884
- return await Ir(this.logger, this.sshClient, r, t.arch);
887
+ return await Hr(this.logger, this.sshClient, r, t.arch);
885
888
  } catch {
886
889
  return !1;
887
890
  }
@@ -889,7 +892,7 @@ class q {
889
892
  async start() {
890
893
  const t = await this.getArch(), r = await this.getUserHomeDirectory();
891
894
  try {
892
- return await _r(this.sshClient, r, t.arch), await this.checkIsAliveWithInterval();
895
+ return await Ir(this.sshClient, r, t.arch), await this.checkIsAliveWithInterval();
893
896
  } catch (e) {
894
897
  const i = `ssh.start: error occurred ${e}`;
895
898
  throw this.logger.error(i), new Error(i);
@@ -909,7 +912,7 @@ class q {
909
912
  return this.logger.info("pl.reset: Stop Platforma on the server"), await this.stop(), this.logger.info(`pl.reset: Deleting Platforma workDir ${t} on the server`), await this.sshClient.deleteFolder($(t)), this.cleanUp(), !0;
910
913
  }
911
914
  async platformaInit(t) {
912
- const r = { localWorkdir: t };
915
+ const r = { localWorkdir: t.localWorkdir };
913
916
  try {
914
917
  if (r.arch = await this.getArch(), r.remoteHome = await this.getUserHomeDirectory(), r.isAlive = await this.isAlive(), r.isAlive) {
915
918
  if (r.userCredentials = await this.getUserCredentials(r.remoteHome), !r.userCredentials)
@@ -917,7 +920,7 @@ class q {
917
920
  return r.userCredentials;
918
921
  }
919
922
  const e = await this.downloadBinariesAndUploadToTheServer(
920
- t,
923
+ t.localWorkdir,
921
924
  r.remoteHome,
922
925
  r.arch
923
926
  );
@@ -947,7 +950,7 @@ class q {
947
950
  await this.sshClient.writeFileOnTheServer(c, a), this.logger.info(`Created file ${c}`);
948
951
  for (const c of i.dirsToCreate)
949
952
  await this.sshClient.createRemoteDirectory(c), this.logger.info(`Created directory ${c}`);
950
- const o = Hr(
953
+ const o = Mr(
951
954
  i.minioConfig.storageDir,
952
955
  i.minioConfig.envs,
953
956
  await this.getFreePortForPlatformaOnServer(r.remoteHome, r.arch),
@@ -956,14 +959,14 @@ class q {
956
959
  r.binPaths.minioRelPath,
957
960
  r.binPaths.downloadedPl
958
961
  );
959
- if (!await this.sshClient.writeFileOnTheServer(K(r.remoteHome), o))
962
+ if (!await this.sshClient.writeFileOnTheServer(G(r.remoteHome), o))
960
963
  throw new Error(`Can not write supervisord config on the server ${$(r.remoteHome)}`);
961
964
  return r.connectionInfo = {
962
965
  plUser: i.plUser,
963
966
  plPassword: i.plPassword,
964
967
  ports: r.ports
965
968
  }, await this.sshClient.writeFileOnTheServer(
966
- N(r.remoteHome),
969
+ B(r.remoteHome),
967
970
  JSON.stringify(r.connectionInfo, void 0, 2)
968
971
  ), await this.start(), r.started = !0, this.initState = r, {
969
972
  plUser: i.plUser,
@@ -983,7 +986,7 @@ class q {
983
986
  r,
984
987
  e,
985
988
  "pl",
986
- `pl-${b()}`
989
+ `pl-${x()}`
987
990
  );
988
991
  i.push(o);
989
992
  const n = await this.downloadAndUntar(
@@ -991,7 +994,7 @@ class q {
991
994
  r,
992
995
  e,
993
996
  "supervisord",
994
- kr
997
+ Rr
995
998
  );
996
999
  i.push(n);
997
1000
  const c = Tr(r, e.arch), a = await this.downloadAndUntar(
@@ -1004,7 +1007,7 @@ class q {
1004
1007
  return i.push(a), await this.sshClient.chmod(c, 488), {
1005
1008
  history: i,
1006
1009
  minioRelPath: c,
1007
- downloadedPl: R(r, e.arch)
1010
+ downloadedPl: N(r, e.arch)
1008
1011
  };
1009
1012
  } catch (o) {
1010
1013
  const n = `SshPl.downloadBinariesAndUploadToServer: error ${o} occurred, state: ${JSON.stringify(i)}`;
@@ -1017,12 +1020,12 @@ class q {
1017
1020
  * For this reason, we extract all to the remote server. */
1018
1021
  async downloadAndUntar(t, r, e, i, o) {
1019
1022
  const n = {};
1020
- n.binBasePath = v(r), await this.sshClient.createRemoteDirectory(n.binBasePath), n.binBasePathCreated = !0;
1023
+ n.binBasePath = S(r), await this.sshClient.createRemoteDirectory(n.binBasePath), n.binBasePathCreated = !0;
1021
1024
  let c = null;
1022
1025
  const a = 5;
1023
1026
  for (let h = 1; h <= a; h++)
1024
1027
  try {
1025
- c = await dr(
1028
+ c = await wr(
1026
1029
  this.logger,
1027
1030
  t,
1028
1031
  i,
@@ -1032,7 +1035,7 @@ class q {
1032
1035
  );
1033
1036
  break;
1034
1037
  } catch (u) {
1035
- if (await C(300), h == a)
1038
+ if (await F(300), h == a)
1036
1039
  throw new Error(`downloadAndUntar: ${a} attempts, last error: ${u}`);
1037
1040
  }
1038
1041
  n.downloadResult = p(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.createRemoteDirectory(n.remoteDir), await this.sshClient.uploadFile(n.localArchivePath, n.remoteArchivePath);
@@ -1044,20 +1047,20 @@ class q {
1044
1047
  return n.plUntarDone = !0, n;
1045
1048
  }
1046
1049
  async needDownload(t, r) {
1047
- const e = W(t, r.arch), i = z(t, r.arch), o = R(t, r.arch);
1050
+ const e = z(t, r.arch), i = W(t, r.arch), o = N(t, r.arch);
1048
1051
  return !await this.sshClient.checkFileExists(o) || !await this.sshClient.checkFileExists(i) || !await this.sshClient.checkFileExists(e);
1049
1052
  }
1050
1053
  async checkIsAliveWithInterval(t = 1e3, r = 15, e = !0) {
1051
1054
  const i = r * t;
1052
1055
  let o = 0, n = await this.isAlive();
1053
1056
  for (; e ? !n : n; ) {
1054
- if (await C(t), o += t, o > i)
1057
+ if (await F(t), o += t, o > i)
1055
1058
  throw new Error(`isAliveWithInterval: The process did not ${e ? "started" : "stopped"} after ${i} ms.`);
1056
1059
  n = await this.isAlive();
1057
1060
  }
1058
1061
  }
1059
1062
  async getUserCredentials(t) {
1060
- const r = await this.sshClient.readFile(N(t));
1063
+ const r = await this.sshClient.readFile(B(t));
1061
1064
  return JSON.parse(r);
1062
1065
  }
1063
1066
  async fetchPorts(t, r) {
@@ -1086,7 +1089,7 @@ class q {
1086
1089
  }
1087
1090
  async getLocalFreePort() {
1088
1091
  return new Promise((t) => {
1089
- const r = B.createServer();
1092
+ const r = I.createServer();
1090
1093
  r.listen(0, () => {
1091
1094
  const e = r.address().port;
1092
1095
  r.close((i) => t(e));
@@ -1094,7 +1097,7 @@ class q {
1094
1097
  });
1095
1098
  }
1096
1099
  async getFreePortForPlatformaOnServer(t, r) {
1097
- const e = Ur(t, r.arch), { stdout: i, stderr: o } = await this.sshClient.exec(`${e}`);
1100
+ const e = Br(t, r.arch), { stdout: i, stderr: o } = await this.sshClient.exec(`${e}`);
1098
1101
  if (o)
1099
1102
  throw new Error(`getFreePortForPlatformaOnServer: stderr is not empty: ${o}, stdout: ${i}`);
1100
1103
  return +i;
@@ -1120,11 +1123,11 @@ class q {
1120
1123
  }
1121
1124
  }
1122
1125
  export {
1123
- Er as LocalConfigYaml,
1124
- Fr as LocalPl,
1125
- x as SshClient,
1126
- q as SshPl,
1127
- b as getDefaultPlVersion,
1128
- it as localPlatformaInit
1126
+ Fr as LocalConfigYaml,
1127
+ Ar as LocalPl,
1128
+ R as SshClient,
1129
+ K as SshPl,
1130
+ x as getDefaultPlVersion,
1131
+ st as localPlatformaInit
1129
1132
  };
1130
1133
  //# sourceMappingURL=index.mjs.map