@milaboratories/pl-deployments 1.1.4 → 1.1.5

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,45 +1,45 @@
1
- var K = Object.defineProperty;
2
- var q = (s, r, t) => r in s ? K(s, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[r] = t;
3
- var d = (s, r, t) => q(s, typeof r != "symbol" ? r + "" : r, t);
4
- import { spawn as G } from "node:child_process";
5
- import { sleep as S, fileExists as f, assertNever as N, notEmpty as p } from "@milaboratories/ts-helpers";
1
+ var G = Object.defineProperty;
2
+ var Z = (s, r, t) => r in s ? G(s, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[r] = t;
3
+ var w = (s, r, t) => Z(s, typeof r != "symbol" ? r + "" : r, t);
4
+ import { spawn as V } from "node:child_process";
5
+ import { sleep as C, fileExists as m, assertNever as T, notEmpty as f, RetryablePromise as Y } from "@milaboratories/ts-helpers";
6
6
  import E from "node:fs";
7
- import w, { readFile as Z } from "node:fs/promises";
7
+ import p, { readFile as Q } from "node:fs/promises";
8
8
  import u from "upath";
9
- import { request as V } from "undici";
10
- import { Readable as Y, Writable as Q } from "node:stream";
11
- import { text as X } from "node:stream/consumers";
12
- import * as tt from "tar";
13
- import rt from "decompress";
9
+ import { request as X } from "undici";
10
+ import { Readable as tt, Writable as rt } from "node:stream";
11
+ import { text as et } from "node:stream/consumers";
12
+ import * as it from "tar";
13
+ import ot from "decompress";
14
14
  import k from "node:os";
15
- import et, { Client as v } from "ssh2";
16
- import U from "node:net";
17
- import it from "node:dns";
18
- import { generateSshPlConfigs as ot, getFreePort as g } from "@milaboratories/pl-config";
19
- import { randomBytes as nt } from "node:crypto";
20
- function st(s, r) {
15
+ import st, { Client as S } from "ssh2";
16
+ import B from "node:net";
17
+ import nt from "node:dns";
18
+ import { randomBytes as F } from "node:crypto";
19
+ import { generateSshPlConfigs as at, getFreePort as y } from "@milaboratories/pl-config";
20
+ function ct(s, r) {
21
21
  return s.info(`Running:
22
22
  cmd: ${JSON.stringify([r.cmd, ...r.args])}
23
- wd: ${r.opts.cwd}`), s.info(" spawning child process"), G(r.cmd, r.args, r.opts);
23
+ wd: ${r.opts.cwd}`), s.info(" spawning child process"), V(r.cmd, r.args, r.opts);
24
24
  }
25
- async function C(s) {
25
+ async function D(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 T(s) {
32
+ function _(s) {
33
33
  return process.kill(s, "SIGINT");
34
34
  }
35
- async function B(s, r) {
35
+ async function j(s, r) {
36
36
  let e = 0;
37
- for (; await C(s); )
38
- if (await S(100), e += 100, e > r)
37
+ for (; await D(s); )
38
+ if (await C(100), e += 100, e > r)
39
39
  throw new Error(`The process did not stopped after ${r} ms.`);
40
40
  }
41
- const at = ["linux", "macos", "windows"];
42
- function H(s) {
41
+ const lt = ["linux", "macos", "windows"];
42
+ function I(s) {
43
43
  switch (s.toLowerCase()) {
44
44
  case "darwin":
45
45
  return "macos";
@@ -49,12 +49,12 @@ function H(s) {
49
49
  return "windows";
50
50
  default:
51
51
  throw new Error(
52
- `operating system '${s}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` + JSON.stringify(at)
52
+ `operating system '${s}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` + JSON.stringify(lt)
53
53
  );
54
54
  }
55
55
  }
56
- const ct = ["amd64", "arm64"];
57
- function $(s) {
56
+ const ht = ["amd64", "arm64"];
57
+ function P(s) {
58
58
  switch (s) {
59
59
  case "aarch64":
60
60
  case "aarch64_be":
@@ -65,155 +65,155 @@ function $(s) {
65
65
  return "amd64";
66
66
  default:
67
67
  throw new Error(
68
- `processor architecture '${s}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(ct)
68
+ `processor architecture '${s}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(ht)
69
69
  );
70
70
  }
71
71
  }
72
- async function lt(s, r, t, e, i, o) {
73
- const n = ut(t, e, r, $(i), H(o)), { archiveUrl: a, archivePath: c } = n;
74
- return await _(s, a, c), n;
72
+ async function ut(s, r, t, e, i, o) {
73
+ const n = wt(t, e, r, P(i), I(o)), { archiveUrl: c, archivePath: a } = n;
74
+ return await H(s, c, a), n;
75
75
  }
76
- async function ht(s, r, t, e, i) {
77
- const o = dt(t, r, $(e), H(i)), { archiveUrl: n, archivePath: a, archiveType: c, targetFolder: l, binaryPath: h } = o;
78
- return await _(s, n, a), await pt(s, a, c, l), o;
76
+ async function dt(s, r, t, e, i) {
77
+ const o = pt(t, r, P(e), I(i)), { archiveUrl: n, archivePath: c, archiveType: a, targetFolder: l, binaryPath: h } = o;
78
+ return await H(s, n, c), await mt(s, c, a, l), o;
79
79
  }
80
- function ut(s, r, t, e, i) {
81
- const o = `${r}-${e}`, n = I[i], a = `${o}.${n}`, c = `https://cdn.platforma.bio/software/${s}/${i}/${a}`, l = u.join(t, a), h = u.join(t, o);
80
+ function wt(s, r, t, e, i) {
81
+ const o = `${r}-${e}`, n = M[i], c = `${o}.${n}`, a = `https://cdn.platforma.bio/software/${s}/${i}/${c}`, l = u.join(t, c), h = u.join(t, o);
82
82
  return {
83
- archiveUrl: c,
83
+ archiveUrl: a,
84
84
  archivePath: l,
85
85
  archiveType: n,
86
86
  targetFolder: h,
87
87
  baseName: o
88
88
  };
89
89
  }
90
- function dt(s, r, t, e) {
91
- const i = `pl-${s}-${t}`, o = I[e], n = `${i}.${o}`, a = `https://cdn.platforma.bio/software/pl/${e}/${n}`, c = u.join(r, n), l = u.join(r, i), h = u.join(i, "binaries", ft[e]);
90
+ function pt(s, r, t, e) {
91
+ const i = `pl-${s}-${t}`, o = M[e], n = `${i}.${o}`, c = `https://cdn.platforma.bio/software/pl/${e}/${n}`, a = u.join(r, n), l = u.join(r, i), h = u.join(i, "binaries", gt[e]);
92
92
  return {
93
- archiveUrl: a,
94
- archivePath: c,
93
+ archiveUrl: c,
94
+ archivePath: a,
95
95
  archiveType: o,
96
96
  targetFolder: l,
97
97
  binaryPath: h,
98
98
  baseName: i
99
99
  };
100
100
  }
101
- async function _(s, r, t) {
101
+ async function H(s, r, t) {
102
102
  const e = {};
103
103
  e.dstArchive = t;
104
104
  try {
105
- if (e.fileExisted = await f(t), e.fileExisted)
105
+ if (e.fileExisted = await m(t), e.fileExisted)
106
106
  return s.info(`Platforma Backend archive download skipped: '${t}' already exists`), e;
107
- await w.mkdir(u.dirname(t), { recursive: !0 }), e.dirnameCreated = !0, s.info(`Downloading archive:
107
+ await p.mkdir(u.dirname(t), { recursive: !0 }), e.dirnameCreated = !0, s.info(`Downloading archive:
108
108
  URL: ${r}
109
109
  Save to: ${t}`);
110
- const { body: i, statusCode: o } = await V(r);
110
+ const { body: i, statusCode: o } = await X(r);
111
111
  if (e.statusCode = o, o != 200) {
112
- const n = await X(i);
112
+ const n = await et(i);
113
113
  throw e.errorMsg = `failed to download archive: ${o}, response: ${n.slice(0, 1e3)}`, s.error(e.errorMsg), new Error(e.errorMsg);
114
114
  }
115
- return e.tmpPath = t + ".tmp", await Y.toWeb(i).pipeTo(Q.toWeb(E.createWriteStream(e.tmpPath))), e.wroteTmp = !0, e.tmpExisted = await f(e.tmpPath), await w.rename(e.tmpPath, t), e.renamed = !0, e.newExisted = await f(t), e;
115
+ return e.tmpPath = t + ".tmp", await tt.toWeb(i).pipeTo(rt.toWeb(E.createWriteStream(e.tmpPath))), e.wroteTmp = !0, e.tmpExisted = await m(e.tmpPath), await p.rename(e.tmpPath, t), e.renamed = !0, e.newExisted = await m(t), e;
116
116
  } catch (i) {
117
117
  const o = `downloadArchive: error ${JSON.stringify(i)} occurred, state: ${JSON.stringify(e)}`;
118
118
  throw s.error(o), new Error(o);
119
119
  }
120
120
  }
121
- const wt = ".ok";
122
- async function pt(s, r, t, e) {
123
- if (s.info("extracting archive..."), s.info(` archive path: '${r}'`), s.info(` target dir: '${e}'`), !await f(r)) {
121
+ const ft = ".ok";
122
+ async function mt(s, r, t, e) {
123
+ if (s.info("extracting archive..."), s.info(` archive path: '${r}'`), s.info(` target dir: '${e}'`), !await m(r)) {
124
124
  const o = `Platforma Backend binary archive not found at '${r}'`;
125
125
  throw s.error(o), new Error(o);
126
126
  }
127
- const i = u.join(e, wt);
128
- if (await f(i)) {
127
+ const i = u.join(e, ft);
128
+ if (await m(i)) {
129
129
  s.info(`Platforma Backend binaries unpack skipped: '${e}' exists`);
130
130
  return;
131
131
  }
132
- switch (await f(e) && (s.info(`Removing previous incompletely unpacked folder: '${e}'`), await w.rm(e, { recursive: !0 })), s.info(` creating target dir '${e}'`), await w.mkdir(e, { recursive: !0 }), s.info(
132
+ switch (await m(e) && (s.info(`Removing previous incompletely unpacked folder: '${e}'`), await p.rm(e, { recursive: !0 })), s.info(` creating target dir '${e}'`), await p.mkdir(e, { recursive: !0 }), s.info(
133
133
  `Unpacking Platforma Backend archive:
134
134
  Archive: ${r}
135
135
  Target dir: ${e}`
136
136
  ), t) {
137
137
  case "tgz":
138
- await tt.x({
138
+ await it.x({
139
139
  file: r,
140
140
  cwd: e,
141
141
  gzip: !0
142
142
  });
143
143
  break;
144
144
  case "zip":
145
- await rt(r, e);
145
+ await ot(r, e);
146
146
  break;
147
147
  default:
148
- N(t);
148
+ T(t);
149
149
  }
150
- await w.writeFile(i, "ok"), s.info(" ... unpack done.");
150
+ await p.writeFile(i, "ok"), s.info(" ... unpack done.");
151
151
  }
152
- const I = {
152
+ const M = {
153
153
  linux: "tgz",
154
154
  macos: "tgz",
155
155
  windows: "zip"
156
- }, ft = {
156
+ }, gt = {
157
157
  linux: "platforma",
158
158
  macos: "platforma",
159
159
  windows: "platforma.exe"
160
160
  };
161
- function F() {
161
+ function b() {
162
162
  return "1.18.3";
163
163
  }
164
- function mt() {
165
- return { type: "Download", version: F() };
164
+ function yt() {
165
+ return { type: "Download", version: b() };
166
166
  }
167
- async function gt(s, r, t) {
167
+ async function $t(s, r, t) {
168
168
  switch (t.type) {
169
169
  case "Download":
170
- return (await ht(s, r, t.version, k.arch(), k.platform())).binaryPath;
170
+ return (await dt(s, r, t.version, k.arch(), k.platform())).binaryPath;
171
171
  case "Local":
172
172
  return t.path;
173
173
  default:
174
- N(t);
174
+ T(t);
175
175
  }
176
176
  }
177
- function j(s) {
177
+ function J(s) {
178
178
  return u.join(s, "pl_pid");
179
179
  }
180
- async function yt(s) {
181
- if (!await f(s))
180
+ async function Pt(s) {
181
+ if (!await m(s))
182
182
  return;
183
- const r = await w.readFile(s);
183
+ const r = await p.readFile(s);
184
184
  return Number(r.toString());
185
185
  }
186
- async function $t(s, r) {
187
- await w.writeFile(s, JSON.stringify(r));
186
+ async function vt(s, r) {
187
+ await p.writeFile(s, JSON.stringify(r));
188
188
  }
189
- function Pt() {
189
+ function St() {
190
190
  return {};
191
191
  }
192
- function vt(s, r, t) {
192
+ function Ct(s, r, t) {
193
193
  return s[r] = t, t;
194
194
  }
195
- async function b(s, r) {
196
- const t = Pt();
195
+ async function A(s, r) {
196
+ const t = St();
197
197
  try {
198
- return await r((i, o) => vt(t, i, o), t);
198
+ return await r((i, o) => Ct(t, i, o), t);
199
199
  } catch (e) {
200
200
  throw s.error(`error ${e} while doing traced operation, state: ${JSON.stringify(t)}`), e;
201
201
  }
202
202
  }
203
- const St = "config-local.yaml";
204
- class Et {
205
- constructor(r, t, e, i, o, n, a, c) {
206
- d(this, "instance");
207
- d(this, "pid");
208
- d(this, "nRuns", 0);
209
- d(this, "lastRunHistory", {});
210
- d(this, "wasStopped", !1);
211
- this.logger = r, this.workingDir = t, this.startOptions = e, this.initialStartHistory = i, this.onClose = o, this.onError = n, this.onCloseAndError = a, this.onCloseAndErrorNoStop = c;
203
+ const Et = "config-local.yaml";
204
+ class Ft {
205
+ constructor(r, t, e, i, o, n, c, a) {
206
+ w(this, "instance");
207
+ w(this, "pid");
208
+ w(this, "nRuns", 0);
209
+ w(this, "lastRunHistory", {});
210
+ w(this, "wasStopped", !1);
211
+ this.logger = r, this.workingDir = t, this.startOptions = e, this.initialStartHistory = i, this.onClose = o, this.onError = n, this.onCloseAndError = c, this.onCloseAndErrorNoStop = a;
212
212
  }
213
213
  async start() {
214
- await b(this.logger, async (r, t) => {
214
+ await A(this.logger, async (r, t) => {
215
215
  this.wasStopped = !1;
216
- const e = st(this.logger, this.startOptions);
216
+ const e = ct(this.logger, this.startOptions);
217
217
  e.on("error", (o) => {
218
218
  this.logger.error(
219
219
  `error '${o}', while running platforma, started opts: ${JSON.stringify(this.debugInfo())}`
@@ -221,21 +221,21 @@ class Et {
221
221
  }), e.on("close", () => {
222
222
  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
223
  }), r("started", !0);
224
- const i = r("pidFile", j(this.workingDir));
225
- r("pid", p(e.pid)), r("pidWritten", await $t(i, p(e.pid))), this.nRuns++, this.instance = e, this.pid = e.pid, this.lastRunHistory = t;
224
+ const i = r("pidFile", J(this.workingDir));
225
+ r("pid", f(e.pid)), r("pidWritten", await vt(i, f(e.pid))), this.nRuns++, this.instance = e, this.pid = e.pid, this.lastRunHistory = t;
226
226
  });
227
227
  }
228
228
  stop() {
229
- this.wasStopped = !0, T(p(this.pid));
229
+ this.wasStopped = !0, _(f(this.pid));
230
230
  }
231
231
  async waitStopped() {
232
- await B(p(this.pid), 15e3);
232
+ await j(f(this.pid), 15e3);
233
233
  }
234
234
  stopped() {
235
235
  return this.wasStopped;
236
236
  }
237
237
  async isAlive() {
238
- return await C(p(this.pid));
238
+ return await D(f(this.pid));
239
239
  }
240
240
  debugInfo() {
241
241
  return {
@@ -248,21 +248,21 @@ class Et {
248
248
  };
249
249
  }
250
250
  }
251
- async function Xt(s, r) {
251
+ async function ir(s, r) {
252
252
  const t = {
253
- plBinary: mt(),
253
+ plBinary: yt(),
254
254
  spawnOptions: {},
255
255
  closeOld: !0,
256
256
  ...r
257
257
  };
258
- return await b(s, async (e, i) => {
258
+ return await A(s, async (e, i) => {
259
259
  e("startOptions", { ...t, config: "too wordy" });
260
260
  const o = u.resolve(t.workingDir);
261
- t.closeOld && e("closeOld", await Ct(s, o));
262
- const n = u.join(o, St);
263
- s.info(`writing configuration '${n}'...`), await w.writeFile(n, t.config);
264
- const a = await gt(s, u.join(o, "binaries"), t.plBinary), l = {
265
- cmd: e("binaryPath", u.join("binaries", a)),
261
+ t.closeOld && e("closeOld", await Dt(s, o));
262
+ const n = u.join(o, Et);
263
+ s.info(`writing configuration '${n}'...`), await p.writeFile(n, t.config);
264
+ const c = await $t(s, u.join(o, "binaries"), t.plBinary), l = {
265
+ cmd: e("binaryPath", u.join("binaries", c)),
266
266
  args: ["-config", n],
267
267
  opts: {
268
268
  env: { ...process.env },
@@ -278,7 +278,7 @@ async function Xt(s, r) {
278
278
  args: l.args,
279
279
  cwd: l.opts.cwd
280
280
  });
281
- const h = new Et(
281
+ const h = new Ft(
282
282
  s,
283
283
  t.workingDir,
284
284
  l,
@@ -291,20 +291,20 @@ async function Xt(s, r) {
291
291
  return await h.start(), h;
292
292
  });
293
293
  }
294
- async function Ct(s, r) {
295
- return await b(s, async (t, e) => {
296
- const i = t("pidFilePath", j(r)), o = t("pid", await yt(i)), n = t("wasAlive", await C(o));
297
- return o !== void 0 && n && (t("stopped", T(o)), t("waitStopped", await B(o, 1e4))), e;
294
+ async function Dt(s, r) {
295
+ return await A(s, async (t, e) => {
296
+ const i = t("pidFilePath", J(r)), o = t("pid", await Pt(i)), n = t("wasAlive", await D(o));
297
+ return o !== void 0 && n && (t("stopped", _(o)), t("waitStopped", await j(o, 1e4))), e;
298
298
  });
299
299
  }
300
- const Ft = {
300
+ const bt = {
301
301
  keepaliveInterval: 6e4,
302
302
  keepaliveCountMax: 10
303
303
  };
304
- class D {
304
+ class x {
305
305
  constructor(r, t) {
306
- d(this, "config");
307
- d(this, "homeDir");
306
+ w(this, "config");
307
+ w(this, "homeDir");
308
308
  this.logger = r, this.client = t;
309
309
  }
310
310
  /**
@@ -314,9 +314,9 @@ class D {
314
314
  */
315
315
  static async init(r, t) {
316
316
  const e = {
317
- ...Ft,
317
+ ...bt,
318
318
  ...t
319
- }, i = new D(r, new v());
319
+ }, i = new x(r, new S());
320
320
  return await i.connect(e), i;
321
321
  }
322
322
  getFullHostName() {
@@ -333,15 +333,7 @@ class D {
333
333
  * @returns A promise that resolves when the connection is established or rejects on error.
334
334
  */
335
335
  async connect(r) {
336
- return this.config = r, new Promise((t, e) => {
337
- this.client.on("ready", () => {
338
- t(void 0);
339
- }).on("error", (i) => {
340
- e(new Error(`ssh.connect: error occurred: ${i}`));
341
- }).on("timeout", () => {
342
- e(new Error("timeout was occurred while waiting for SSH connection."));
343
- }).connect(r);
344
- });
336
+ return this.config = r, await At(this.client, r);
345
337
  }
346
338
  /**
347
339
  * Executes a command on the SSH server.
@@ -353,13 +345,13 @@ class D {
353
345
  this.client.exec(r, (i, o) => {
354
346
  if (i)
355
347
  return e(`ssh.exec: ${r}, error occurred: ${i}`);
356
- let n = "", a = "";
357
- o.on("close", (c) => {
358
- c === 0 ? t({ stdout: n, stderr: a }) : e(new Error(`Command ${r} exited with code ${c}`));
359
- }).on("data", (c) => {
360
- n += c.toString();
361
- }).stderr.on("data", (c) => {
362
- a += c.toString();
348
+ let n = "", c = "";
349
+ o.on("close", (a) => {
350
+ a === 0 ? t({ stdout: n, stderr: c }) : e(new Error(`Command ${r} exited with code ${a}`));
351
+ }).on("data", (a) => {
352
+ n += a.toString();
353
+ }).stderr.on("data", (a) => {
354
+ c += a.toString();
363
355
  });
364
356
  });
365
357
  });
@@ -373,7 +365,7 @@ class D {
373
365
  static async getAuthTypes(r, t) {
374
366
  return new Promise((e) => {
375
367
  let i = "";
376
- const o = new v();
368
+ const o = new S();
377
369
  o.on("ready", () => {
378
370
  o.end();
379
371
  const n = this.extractAuthMethods(i);
@@ -408,40 +400,50 @@ class D {
408
400
  * @returns { server: net.Server } A promise resolving with the created server instance.
409
401
  */
410
402
  async forwardPort(r, t) {
411
- return t = t ?? this.config, new Promise((e, i) => {
412
- if (!t) {
413
- i("No config defined");
414
- return;
415
- }
416
- const o = new v();
417
- let n;
418
- o.on("ready", () => {
419
- this.logger.info(`[SSH] Connection to ${t.host}. Remote port ${r.remotePort} will be available locally on the ${r.localPort}`), n = U.createServer({ pauseOnConnect: !0 }, (a) => {
420
- o.forwardOut(
421
- "127.0.0.1",
422
- 0,
423
- "127.0.0.1",
424
- r.remotePort,
425
- (c, l) => {
426
- if (c) {
427
- console.error("Error opening SSH channel:", c.message), a.end();
428
- return;
429
- }
430
- a.pipe(l), l.pipe(a), a.resume();
431
- }
432
- );
433
- }), n.listen(r.localPort, "127.0.0.1", () => {
434
- this.logger.info(`[+] Port local ${r.localPort} available locally for remote port → :${r.remotePort}`), e({ server: n });
435
- }), n.on("error", (a) => {
436
- o.end(), n.close(), i(new Error(`ssh.forwardPort: server error: ${a}`));
437
- }), n.on("close", () => {
438
- this.logger.info(`Server closed ${JSON.stringify(r)}`), o && (this.logger.info("End SSH connection"), o.end());
403
+ const e = `ssh.forward:${r.localPort}:${r.remotePort}.id_${F(1).toString("hex")}`;
404
+ t = t ?? this.config;
405
+ const i = new Y((o) => new Promise((n, c) => {
406
+ const a = new S();
407
+ a.on("ready", () => {
408
+ this.logger.info(`${e}.client.ready`), n(a);
409
+ }), a.on("error", (l) => {
410
+ this.logger.info(`${e}.client.error: ${l}`), o.reset(), c(l);
411
+ }), a.on("close", () => {
412
+ this.logger.info(`${e}.client.closed`), o.reset();
413
+ }), a.connect(t);
414
+ }));
415
+ return await i.ensure(), new Promise((o, n) => {
416
+ const c = B.createServer({ pauseOnConnect: !0 }, async (a) => {
417
+ const l = `${e}.sock_${F(1).toString("hex")}`;
418
+ let h;
419
+ try {
420
+ h = await i.ensure();
421
+ } catch (g) {
422
+ this.logger.info(`${l}.persistentClient.catch: ${g}`), a.end();
423
+ return;
424
+ }
425
+ let d;
426
+ try {
427
+ d = await xt(this.logger, h, "127.0.0.1", 0, "127.0.0.1", r.remotePort);
428
+ } catch (g) {
429
+ this.logger.error(`${l}.forwardOut.err: ${g}`), a.end();
430
+ return;
431
+ }
432
+ a.pipe(d), d.pipe(a), a.resume(), d.on("error", (g) => {
433
+ this.logger.error(`${l}.stream.error: ${g}`), a.end(), d.end();
434
+ }), d.on("close", () => {
435
+ a.end(), d.end();
436
+ }), a.on("close", () => {
437
+ this.logger.info(`${l}.localSocket: closed`), a.end(), d.end();
439
438
  });
440
- }), o.on("error", (a) => {
441
- this.logger.error(`[SSH] SSH connection error, ports: ${JSON.stringify(r)}, err: ${a.message}`), n == null || n.close(), i(`ssh.forwardPort: conn.err: ${a}`);
442
- }), o.on("close", () => {
443
- this.logger.info(`[SSH] Connection closed, ports: ${JSON.stringify(r)}`);
444
- }), o.connect(t);
439
+ });
440
+ c.listen(r.localPort, "127.0.0.1", () => {
441
+ this.logger.info(`${e}.server: started listening`), o({ server: c });
442
+ }), c.on("error", (a) => {
443
+ c.close(), n(new Error(`${e}.server: error: ${JSON.stringify(a)}`));
444
+ }), c.on("close", () => {
445
+ this.logger.info(`${e}.server: closed ${JSON.stringify(r)}`);
446
+ });
445
447
  });
446
448
  }
447
449
  /**
@@ -451,7 +453,7 @@ class D {
451
453
  */
452
454
  static async checkHostAvailability(r) {
453
455
  return new Promise((t) => {
454
- it.lookup(r, (e) => {
456
+ nt.lookup(r, (e) => {
455
457
  t(!e);
456
458
  });
457
459
  });
@@ -464,7 +466,7 @@ class D {
464
466
  static async isPassphraseRequiredForKey(r) {
465
467
  return new Promise((t, e) => {
466
468
  try {
467
- return et.utils.parseKey(r) instanceof Error && t(!0), t(!1);
469
+ return st.utils.parseKey(r) instanceof Error && t(!0), t(!1);
468
470
  } catch (i) {
469
471
  console.log("Error parsing privateKey"), e(new Error(`ssh.isPassphraseRequiredForKey: err ${i}`));
470
472
  }
@@ -481,10 +483,10 @@ class D {
481
483
  return await this.withSftp(async (e) => new Promise((i, o) => {
482
484
  e.fastPut(r, t, (n) => {
483
485
  if (n) {
484
- const a = new Error(
486
+ const c = new Error(
485
487
  `ssh.uploadFile: err: ${n}, localPath: ${r}, remotePath: ${t}`
486
488
  );
487
- return o(a);
489
+ return o(c);
488
490
  }
489
491
  i(!0);
490
492
  });
@@ -513,12 +515,12 @@ class D {
513
515
  }
514
516
  async getForderStructure(r, t, e = { files: [], directories: [] }) {
515
517
  return new Promise((i, o) => {
516
- r.readdir(t, async (n, a) => {
518
+ r.readdir(t, async (n, c) => {
517
519
  if (n)
518
520
  return o(n);
519
- for (const c of a) {
520
- const l = `${t}/${c.filename}`;
521
- if (c.attrs.isDirectory()) {
521
+ for (const a of c) {
522
+ const l = `${t}/${a.filename}`;
523
+ if (a.attrs.isDirectory()) {
522
524
  e.directories.push(l);
523
525
  try {
524
526
  await this.getForderStructure(r, l, e);
@@ -598,20 +600,20 @@ class D {
598
600
  }
599
601
  async writeFile(r, t, e, i = 432) {
600
602
  return new Promise((o, n) => {
601
- r.writeFile(t, e, { mode: i }, (a) => {
602
- if (a)
603
- return n(new Error(`ssh.writeFile: err ${a}, remotePath: ${t}`));
603
+ r.writeFile(t, e, { mode: i }, (c) => {
604
+ if (c)
605
+ return n(new Error(`ssh.writeFile: err ${c}, remotePath: ${t}`));
604
606
  o(!0);
605
607
  });
606
608
  });
607
609
  }
608
610
  uploadFileUsingExistingSftp(r, t, e, i = 432) {
609
611
  return new Promise((o, n) => {
610
- Z(t).then(async (a) => {
611
- this.writeFile(r, e, a, i).then(() => {
612
+ Q(t).then(async (c) => {
613
+ this.writeFile(r, e, c, i).then(() => {
612
614
  o(void 0);
613
- }).catch((c) => {
614
- const l = `uploadFileUsingExistingSftp: error ${c} occurred`;
615
+ }).catch((a) => {
616
+ const l = `uploadFileUsingExistingSftp: error ${a} occurred`;
615
617
  this.logger.error(l), n(new Error(l));
616
618
  });
617
619
  });
@@ -619,14 +621,14 @@ class D {
619
621
  }
620
622
  async __uploadDirectory(r, t, e, i = 432) {
621
623
  return new Promise((o, n) => {
622
- E.readdir(t, async (a, c) => {
623
- if (a)
624
- return n(new Error(`ssh.__uploadDir: err ${a}, localDir: ${t}, remoteDir: ${e}`));
624
+ E.readdir(t, async (c, a) => {
625
+ if (c)
626
+ return n(new Error(`ssh.__uploadDir: err ${c}, localDir: ${t}, remoteDir: ${e}`));
625
627
  try {
626
628
  await this.__createRemoteDirectory(r, e);
627
- for (const l of c) {
628
- const h = u.join(t, l), m = `${e}/${l}`;
629
- E.lstatSync(h).isDirectory() ? await this.__uploadDirectory(r, h, m, i) : await this.uploadFileUsingExistingSftp(r, h, m, i);
629
+ for (const l of a) {
630
+ const h = u.join(t, l), d = `${e}/${l}`;
631
+ E.lstatSync(h).isDirectory() ? await this.__uploadDirectory(r, h, d, i) : await this.uploadFileUsingExistingSftp(r, h, d, i);
630
632
  }
631
633
  o();
632
634
  } catch (l) {
@@ -659,18 +661,18 @@ class D {
659
661
  return new Promise((e, i) => {
660
662
  const o = t.split("/");
661
663
  let n = "";
662
- const a = (c) => {
663
- if (c >= o.length)
664
+ const c = (a) => {
665
+ if (a >= o.length)
664
666
  return e();
665
- n += `${o[c]}/`, r.stat(n, (l) => {
667
+ n += `${o[a]}/`, r.stat(n, (l) => {
666
668
  l ? r.mkdir(n, (h) => {
667
669
  if (h)
668
670
  return i(new Error(`ssh.__createRemDir: err ${h}, remotePath: ${t}`));
669
- a(c + 1);
670
- }) : a(c + 1);
671
+ c(a + 1);
672
+ }) : c(a + 1);
671
673
  });
672
674
  };
673
- a(0);
675
+ c(0);
674
676
  });
675
677
  }
676
678
  /**
@@ -686,18 +688,18 @@ class D {
686
688
  for (const n of i) {
687
689
  o += `${n}/`;
688
690
  try {
689
- await new Promise((a, c) => {
691
+ await new Promise((c, a) => {
690
692
  e.stat(o, (l) => {
691
- if (!l) return a();
693
+ if (!l) return c();
692
694
  e.mkdir(o, { mode: t }, (h) => {
693
695
  if (h)
694
- return c(new Error(`ssh.createRemoteDir: err ${h}, remotePath: ${r}`));
695
- a();
696
+ return a(new Error(`ssh.createRemoteDir: err ${h}, remotePath: ${r}`));
697
+ c();
696
698
  });
697
699
  });
698
700
  });
699
- } catch (a) {
700
- throw console.error(`Failed to create directory: ${o}`, a), a;
701
+ } catch (c) {
702
+ throw console.error(`Failed to create directory: ${o}`, c), c;
701
703
  }
702
704
  }
703
705
  });
@@ -724,65 +726,80 @@ class D {
724
726
  this.client.end();
725
727
  }
726
728
  }
727
- const bt = "minio-2024-12-18T13-15-44Z", Dt = "supervisord-0.7.3", At = "supervisord_0.7.3_Linux_64-bit";
728
- function y(s) {
729
+ async function At(s, r, t, e) {
730
+ return new Promise((i, o) => {
731
+ s.on("ready", () => {
732
+ i(s);
733
+ }), s.on("error", (n) => {
734
+ o(new Error(`ssh.connect: error occurred: ${n}`));
735
+ }), s.on("close", () => {
736
+ }), s.connect(r);
737
+ });
738
+ }
739
+ async function xt(s, r, t, e, i, o) {
740
+ return new Promise((n, c) => {
741
+ r.forwardOut(t, e, i, o, (a, l) => a ? (s.error(`forwardOut.error: ${a}`), c(a)) : n(l));
742
+ });
743
+ }
744
+ const Ot = "minio-2024-12-18T13-15-44Z", kt = "supervisord-0.7.3", Rt = "supervisord_0.7.3_Linux_64-bit";
745
+ function $(s) {
729
746
  return u.join(s, "platforma_ssh");
730
747
  }
731
- function P(s) {
748
+ function v(s) {
732
749
  return u.join(s, "platforma_ssh", "binaries");
733
750
  }
734
- function kt(s, r) {
735
- return u.join(P(s), `pl-${F()}-${$(r)}`);
751
+ function Nt(s, r) {
752
+ return u.join(v(s), `pl-${b()}-${P(r)}`);
736
753
  }
737
- function J(s, r) {
738
- return u.join(kt(s, r), "binaries");
754
+ function L(s, r) {
755
+ return u.join(Nt(s, r), "binaries");
739
756
  }
740
- function x(s, r) {
741
- return u.join(J(s, r), "platforma");
757
+ function R(s, r) {
758
+ return u.join(L(s, r), "platforma");
742
759
  }
743
- function xt(s, r) {
744
- return u.join(J(s, r), "free-port");
760
+ function Ut(s, r) {
761
+ return u.join(L(s, r), "free-port");
745
762
  }
746
- function M(s, r) {
747
- return u.join(P(s), `minio-2024-12-18T13-15-44Z-${$(r)}`);
763
+ function z(s, r) {
764
+ return u.join(v(s), `minio-2024-12-18T13-15-44Z-${P(r)}`);
748
765
  }
749
- function Ot(s, r) {
750
- return u.join(M(s, r), "minio");
766
+ function Tt(s, r) {
767
+ return u.join(z(s, r), "minio");
751
768
  }
752
- function Rt(s, r) {
753
- return u.join(P(s), `supervisord-0.7.3-${$(r)}`, At);
769
+ function Bt(s, r) {
770
+ return u.join(v(s), `supervisord-0.7.3-${P(r)}`, Rt);
754
771
  }
755
- function L(s, r) {
756
- return u.join(Rt(s, r), "supervisord");
772
+ function W(s, r) {
773
+ return u.join(Bt(s, r), "supervisord");
757
774
  }
758
- function z(s) {
759
- return u.join(y(s), "supervisor.conf");
775
+ function K(s) {
776
+ return u.join($(s), "supervisor.conf");
760
777
  }
761
- function O(s) {
762
- return u.join(y(s), "connection.txt");
778
+ function N(s) {
779
+ return u.join($(s), "connection.txt");
763
780
  }
764
- async function Nt(s, r, t) {
765
- const e = await A(s, r, t, "--daemon");
781
+ async function _t(s, r, t) {
782
+ const e = await O(s, r, t, "--daemon");
766
783
  if (e.stderr)
767
784
  throw new Error(`Can not run ssh Platforma ${e.stderr}`);
768
785
  }
769
- async function Ut(s, r, t) {
770
- const e = await A(s, r, t, "ctl shutdown");
786
+ async function jt(s, r, t) {
787
+ const e = await O(s, r, t, "ctl shutdown");
771
788
  if (e.stderr)
772
789
  throw new Error(`Can not stop ssh Platforma ${e.stderr}`);
773
790
  }
774
- async function Tt(s, r, t, e) {
775
- const i = await A(r, t, e, "ctl status");
791
+ async function It(s, r, t, e) {
792
+ const i = await O(r, t, e, "ctl status");
776
793
  if (i.stderr)
777
794
  return s.info(`supervisord ctl status: stderr occurred: ${i.stderr}, stdout: ${i.stdout}`), !1;
778
795
  const o = {
779
- platforma: R(i.stdout, "platforma"),
780
- minio: R(i.stdout, "minio")
796
+ platforma: U(i.stdout, "platforma"),
797
+ minio: U(i.stdout, "minio")
781
798
  };
782
799
  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);
783
800
  }
784
- function Bt(s, r, t, e, i, o, n) {
785
- const a = Object.entries(r).map(([h, m]) => `${h}="${m}"`).join(","), c = nt(16).toString("hex"), l = t;
801
+ function Ht(s, r, t, e, i, o, n) {
802
+ const c = Object.entries(r).map(([h, d]) => `${h}="${d}"`).join(","), a = F(16).toString("hex"), l = t;
786
803
  return `
787
804
  [supervisord]
788
805
  logfile=${e}/supervisord.log
@@ -792,12 +809,12 @@ pidfile=${e}/supervisord.pid
792
809
  [inet_http_server]
793
810
  port=127.0.0.1:${l}
794
811
  username=default-user
795
- password=${c}
812
+ password=${a}
796
813
 
797
814
  [supervisorctl]
798
815
  serverurl=http://127.0.0.1:${l}
799
816
  username=default-user
800
- password=${c}
817
+ password=${a}
801
818
 
802
819
  [program:platforma]
803
820
  autostart=true
@@ -808,26 +825,26 @@ autorestart=true
808
825
 
809
826
  [program:minio]
810
827
  autostart=true
811
- environment=${a}
828
+ environment=${c}
812
829
  command=${o} server ${s}
813
830
  directory=${e}
814
831
  autorestart=true
815
832
  `;
816
833
  }
817
- async function A(s, r, t, e) {
818
- const i = L(r, t), o = z(r), n = `${i} --configuration ${o} ${e}`;
834
+ async function O(s, r, t, e) {
835
+ const i = W(r, t), o = K(r), n = `${i} --configuration ${o} ${e}`;
819
836
  return await s.exec(n);
820
837
  }
821
- function R(s, r) {
838
+ function U(s, r) {
822
839
  return ((i) => i.replace(/\x1B\[[0-9;]*m/g, ""))(s).split(`
823
840
  `).some((i) => {
824
841
  const [o, n] = i.trim().split(/\s{2,}/);
825
842
  return o === r && n === "Running";
826
843
  });
827
844
  }
828
- class W {
845
+ class q {
829
846
  constructor(r, t, e) {
830
- d(this, "initState", {});
847
+ w(this, "initState", {});
831
848
  this.logger = r, this.sshClient = t, this.username = e;
832
849
  }
833
850
  info() {
@@ -838,8 +855,8 @@ class W {
838
855
  }
839
856
  static async init(r, t) {
840
857
  try {
841
- const e = await D.init(r, t);
842
- return new W(r, e, p(t.username));
858
+ const e = await x.init(r, t);
859
+ return new q(r, e, f(t.username));
843
860
  } catch (e) {
844
861
  throw r.error(`Connection error in SshClient.init: ${e}`), e;
845
862
  }
@@ -847,7 +864,7 @@ class W {
847
864
  async isAlive() {
848
865
  const r = await this.getArch(), t = await this.getUserHomeDirectory();
849
866
  try {
850
- return await Tt(this.logger, this.sshClient, t, r.arch);
867
+ return await It(this.logger, this.sshClient, t, r.arch);
851
868
  } catch {
852
869
  return !1;
853
870
  }
@@ -855,7 +872,7 @@ class W {
855
872
  async start() {
856
873
  const r = await this.getArch(), t = await this.getUserHomeDirectory();
857
874
  try {
858
- return await Nt(this.sshClient, t, r.arch), await this.checkIsAliveWithInterval();
875
+ return await _t(this.sshClient, t, r.arch), await this.checkIsAliveWithInterval();
859
876
  } catch (e) {
860
877
  const i = `ssh.start: error occurred ${e}`;
861
878
  throw this.logger.error(i), new Error(i);
@@ -864,7 +881,7 @@ class W {
864
881
  async stop() {
865
882
  const r = await this.getArch(), t = await this.getUserHomeDirectory();
866
883
  try {
867
- return await Ut(this.sshClient, t, r.arch), await this.checkIsAliveWithInterval(void 0, void 0, !1);
884
+ return await jt(this.sshClient, t, r.arch), await this.checkIsAliveWithInterval(void 0, void 0, !1);
868
885
  } catch (e) {
869
886
  const i = `ssh.stop: error occurred ${e}`;
870
887
  throw this.logger.error(i), new Error(i);
@@ -872,7 +889,7 @@ class W {
872
889
  }
873
890
  async reset() {
874
891
  const r = await this.getUserHomeDirectory();
875
- return 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(y(r)), !0;
892
+ return 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)), !0;
876
893
  }
877
894
  async platformaInit(r) {
878
895
  const t = { localWorkdir: r };
@@ -889,9 +906,9 @@ class W {
889
906
  );
890
907
  if (t.binPaths = { ...e, history: void 0 }, t.downloadedBinaries = e.history, t.ports = await this.fetchPorts(t.remoteHome, t.arch), !t.ports.debug.remote || !t.ports.grpc.remote || !t.ports.minioPort.remote || !t.ports.minioConsolePort.remote || !t.ports.monitoring.remote)
891
908
  throw new Error("SshPl.platformaInit: remote ports are not defined");
892
- const i = await ot({
909
+ const i = await at({
893
910
  logger: this.logger,
894
- workingDir: y(t.remoteHome),
911
+ workingDir: $(t.remoteHome),
895
912
  portsMode: {
896
913
  type: "customWithMinio",
897
914
  ports: {
@@ -909,11 +926,11 @@ class W {
909
926
  }
910
927
  });
911
928
  t.generatedConfig = { ...i, filesToCreate: { skipped: "it is too wordy" } };
912
- for (const [a, c] of Object.entries(i.filesToCreate))
913
- await this.sshClient.writeFileOnTheServer(a, c), this.logger.info(`Created file ${a}`);
914
- for (const a of i.dirsToCreate)
915
- await this.sshClient.createRemoteDirectory(a), this.logger.info(`Created directory ${a}`);
916
- const o = Bt(
929
+ for (const [c, a] of Object.entries(i.filesToCreate))
930
+ await this.sshClient.writeFileOnTheServer(c, a), this.logger.info(`Created file ${c}`);
931
+ for (const c of i.dirsToCreate)
932
+ await this.sshClient.createRemoteDirectory(c), this.logger.info(`Created directory ${c}`);
933
+ const o = Ht(
917
934
  i.minioConfig.storageDir,
918
935
  i.minioConfig.envs,
919
936
  await this.getFreePortForPlatformaOnServer(t.remoteHome, t.arch),
@@ -922,14 +939,14 @@ class W {
922
939
  t.binPaths.minioRelPath,
923
940
  t.binPaths.downloadedPl
924
941
  );
925
- if (!await this.sshClient.writeFileOnTheServer(z(t.remoteHome), o))
926
- throw new Error(`Can not write supervisord config on the server ${y(t.remoteHome)}`);
942
+ if (!await this.sshClient.writeFileOnTheServer(K(t.remoteHome), o))
943
+ throw new Error(`Can not write supervisord config on the server ${$(t.remoteHome)}`);
927
944
  return t.connectionInfo = {
928
945
  plUser: i.plUser,
929
946
  plPassword: i.plPassword,
930
947
  ports: t.ports
931
948
  }, await this.sshClient.writeFileOnTheServer(
932
- O(t.remoteHome),
949
+ N(t.remoteHome),
933
950
  JSON.stringify(t.connectionInfo, void 0, 2)
934
951
  ), await this.start(), t.started = !0, this.initState = t, {
935
952
  plUser: i.plUser,
@@ -949,7 +966,7 @@ class W {
949
966
  t,
950
967
  e,
951
968
  "pl",
952
- `pl-${F()}`
969
+ `pl-${b()}`
953
970
  );
954
971
  i.push(o);
955
972
  const n = await this.downloadAndUntar(
@@ -957,20 +974,20 @@ class W {
957
974
  t,
958
975
  e,
959
976
  "supervisord",
960
- Dt
977
+ kt
961
978
  );
962
979
  i.push(n);
963
- const a = Ot(t, e.arch), c = await this.downloadAndUntar(
980
+ const c = Tt(t, e.arch), a = await this.downloadAndUntar(
964
981
  r,
965
982
  t,
966
983
  e,
967
984
  "minio",
968
- bt
985
+ Ot
969
986
  );
970
- return i.push(c), await this.sshClient.chmod(a, 488), {
987
+ return i.push(a), await this.sshClient.chmod(c, 488), {
971
988
  history: i,
972
- minioRelPath: a,
973
- downloadedPl: x(t, e.arch)
989
+ minioRelPath: c,
990
+ downloadedPl: R(t, e.arch)
974
991
  };
975
992
  } catch (o) {
976
993
  const n = `SshPl.downloadBinariesAndUploadToServer: error ${o} occurred, state: ${JSON.stringify(i)}`;
@@ -983,12 +1000,12 @@ class W {
983
1000
  * For this reason, we extract all to the remote server. */
984
1001
  async downloadAndUntar(r, t, e, i, o) {
985
1002
  const n = {};
986
- n.binBasePath = P(t), await this.sshClient.createRemoteDirectory(n.binBasePath), n.binBasePathCreated = !0;
987
- let a = null;
988
- const c = 5;
989
- for (let h = 1; h <= c; h++)
1003
+ n.binBasePath = v(t), await this.sshClient.createRemoteDirectory(n.binBasePath), n.binBasePathCreated = !0;
1004
+ let c = null;
1005
+ const a = 5;
1006
+ for (let h = 1; h <= a; h++)
990
1007
  try {
991
- a = await lt(
1008
+ c = await ut(
992
1009
  this.logger,
993
1010
  r,
994
1011
  i,
@@ -997,11 +1014,11 @@ class W {
997
1014
  e.platform
998
1015
  );
999
1016
  break;
1000
- } catch (m) {
1001
- if (await S(300), h == c)
1002
- throw new Error(`downloadAndUntar: ${c} attempts, last error: ${m}`);
1017
+ } catch (d) {
1018
+ if (await C(300), h == a)
1019
+ throw new Error(`downloadAndUntar: ${a} attempts, last error: ${d}`);
1003
1020
  }
1004
- n.downloadResult = p(a), n.localArchivePath = u.resolve(n.downloadResult.archivePath), n.remoteDir = u.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);
1021
+ n.downloadResult = f(c), n.localArchivePath = u.resolve(n.downloadResult.archivePath), n.remoteDir = u.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);
1005
1022
  const l = await this.sshClient.exec(
1006
1023
  `tar xvf ${n.remoteArchivePath} --directory=${n.remoteDir}`
1007
1024
  );
@@ -1010,49 +1027,49 @@ class W {
1010
1027
  return n.plUntarDone = !0, n;
1011
1028
  }
1012
1029
  async needDownload(r, t) {
1013
- const e = L(r, t.arch), i = M(r, t.arch), o = x(r, t.arch);
1030
+ const e = W(r, t.arch), i = z(r, t.arch), o = R(r, t.arch);
1014
1031
  return !await this.sshClient.checkFileExists(o) || !await this.sshClient.checkFileExists(i) || !await this.sshClient.checkFileExists(e);
1015
1032
  }
1016
1033
  async checkIsAliveWithInterval(r = 1e3, t = 15, e = !0) {
1017
1034
  const i = t * r;
1018
1035
  let o = 0, n = await this.isAlive();
1019
1036
  for (; e ? !n : n; ) {
1020
- if (await S(r), o += r, o > i)
1037
+ if (await C(r), o += r, o > i)
1021
1038
  throw new Error(`isAliveWithInterval: The process did not ${e ? "started" : "stopped"} after ${i} ms.`);
1022
1039
  n = await this.isAlive();
1023
1040
  }
1024
1041
  }
1025
1042
  async getUserCredentials(r) {
1026
- const t = await this.sshClient.readFile(O(r));
1043
+ const t = await this.sshClient.readFile(N(r));
1027
1044
  return JSON.parse(t);
1028
1045
  }
1029
1046
  async fetchPorts(r, t) {
1030
1047
  return {
1031
1048
  grpc: {
1032
- local: await g(),
1049
+ local: await y(),
1033
1050
  remote: await this.getFreePortForPlatformaOnServer(r, t)
1034
1051
  },
1035
1052
  monitoring: {
1036
- local: await g(),
1053
+ local: await y(),
1037
1054
  remote: await this.getFreePortForPlatformaOnServer(r, t)
1038
1055
  },
1039
1056
  debug: {
1040
- local: await g(),
1057
+ local: await y(),
1041
1058
  remote: await this.getFreePortForPlatformaOnServer(r, t)
1042
1059
  },
1043
1060
  minioPort: {
1044
- local: await g(),
1061
+ local: await y(),
1045
1062
  remote: await this.getFreePortForPlatformaOnServer(r, t)
1046
1063
  },
1047
1064
  minioConsolePort: {
1048
- local: await g(),
1065
+ local: await y(),
1049
1066
  remote: await this.getFreePortForPlatformaOnServer(r, t)
1050
1067
  }
1051
1068
  };
1052
1069
  }
1053
1070
  async getLocalFreePort() {
1054
1071
  return new Promise((r) => {
1055
- const t = U.createServer();
1072
+ const t = B.createServer();
1056
1073
  t.listen(0, () => {
1057
1074
  const e = t.address().port;
1058
1075
  t.close((i) => r(e));
@@ -1060,7 +1077,7 @@ class W {
1060
1077
  });
1061
1078
  }
1062
1079
  async getFreePortForPlatformaOnServer(r, t) {
1063
- const e = xt(r, t.arch), { stdout: i, stderr: o } = await this.sshClient.exec(`${e}`);
1080
+ const e = Ut(r, t.arch), { stdout: i, stderr: o } = await this.sshClient.exec(`${e}`);
1064
1081
  if (o)
1065
1082
  throw new Error(`getFreePortForPlatformaOnServer: stderr is not empty: ${o}, stdout: ${i}`);
1066
1083
  return +i;
@@ -1086,11 +1103,11 @@ class W {
1086
1103
  }
1087
1104
  }
1088
1105
  export {
1089
- St as LocalConfigYaml,
1090
- Et as LocalPl,
1091
- D as SshClient,
1092
- W as SshPl,
1093
- F as getDefaultPlVersion,
1094
- Xt as localPlatformaInit
1106
+ Et as LocalConfigYaml,
1107
+ Ft as LocalPl,
1108
+ x as SshClient,
1109
+ q as SshPl,
1110
+ b as getDefaultPlVersion,
1111
+ ir as localPlatformaInit
1095
1112
  };
1096
1113
  //# sourceMappingURL=index.mjs.map