@milaboratories/pl-deployments 2.15.7 → 2.15.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.
Files changed (106) hide show
  1. package/README.md +18 -5
  2. package/dist/common/os_and_arch.cjs +19 -19
  3. package/dist/common/os_and_arch.cjs.map +1 -1
  4. package/dist/common/os_and_arch.js +19 -19
  5. package/dist/common/os_and_arch.js.map +1 -1
  6. package/dist/common/pl_binary.cjs +9 -9
  7. package/dist/common/pl_binary.cjs.map +1 -1
  8. package/dist/common/pl_binary.d.ts +6 -6
  9. package/dist/common/pl_binary.d.ts.map +1 -1
  10. package/dist/common/pl_binary.js +9 -9
  11. package/dist/common/pl_binary.js.map +1 -1
  12. package/dist/common/pl_binary_download.cjs +16 -16
  13. package/dist/common/pl_binary_download.cjs.map +1 -1
  14. package/dist/common/pl_binary_download.d.ts +6 -6
  15. package/dist/common/pl_binary_download.d.ts.map +1 -1
  16. package/dist/common/pl_binary_download.js +16 -16
  17. package/dist/common/pl_binary_download.js.map +1 -1
  18. package/dist/common/pl_version.cjs +1 -1
  19. package/dist/common/pl_version.cjs.map +1 -1
  20. package/dist/common/pl_version.js +1 -1
  21. package/dist/common/pl_version.js.map +1 -1
  22. package/dist/index.d.ts +5 -5
  23. package/dist/local/options.d.ts +4 -4
  24. package/dist/local/pid.cjs +1 -1
  25. package/dist/local/pid.cjs.map +1 -1
  26. package/dist/local/pid.js +1 -1
  27. package/dist/local/pid.js.map +1 -1
  28. package/dist/local/pl.cjs +26 -26
  29. package/dist/local/pl.cjs.map +1 -1
  30. package/dist/local/pl.d.ts +8 -8
  31. package/dist/local/pl.d.ts.map +1 -1
  32. package/dist/local/pl.js +26 -26
  33. package/dist/local/pl.js.map +1 -1
  34. package/dist/local/process.cjs +16 -16
  35. package/dist/local/process.cjs.map +1 -1
  36. package/dist/local/process.d.ts +2 -2
  37. package/dist/local/process.js +16 -16
  38. package/dist/local/process.js.map +1 -1
  39. package/dist/local/trace.cjs.map +1 -1
  40. package/dist/local/trace.d.ts +1 -1
  41. package/dist/local/trace.js.map +1 -1
  42. package/dist/package.json.cjs +2 -1
  43. package/dist/package.json.cjs.map +1 -1
  44. package/dist/package.json.js +2 -1
  45. package/dist/package.json.js.map +1 -1
  46. package/dist/ssh/__tests__/common-utils.d.ts +2 -2
  47. package/dist/ssh/__tests__/common-utils.d.ts.map +1 -1
  48. package/dist/ssh/connection_info.cjs +13 -7
  49. package/dist/ssh/connection_info.cjs.map +1 -1
  50. package/dist/ssh/connection_info.d.ts +1 -1
  51. package/dist/ssh/connection_info.d.ts.map +1 -1
  52. package/dist/ssh/connection_info.js +13 -7
  53. package/dist/ssh/connection_info.js.map +1 -1
  54. package/dist/ssh/pl.cjs +79 -76
  55. package/dist/ssh/pl.cjs.map +1 -1
  56. package/dist/ssh/pl.d.ts +18 -18
  57. package/dist/ssh/pl.d.ts.map +1 -1
  58. package/dist/ssh/pl.js +79 -76
  59. package/dist/ssh/pl.js.map +1 -1
  60. package/dist/ssh/pl_paths.cjs +13 -13
  61. package/dist/ssh/pl_paths.cjs.map +1 -1
  62. package/dist/ssh/pl_paths.d.ts.map +1 -1
  63. package/dist/ssh/pl_paths.js +13 -13
  64. package/dist/ssh/pl_paths.js.map +1 -1
  65. package/dist/ssh/ssh.cjs +43 -40
  66. package/dist/ssh/ssh.cjs.map +1 -1
  67. package/dist/ssh/ssh.d.ts +9 -9
  68. package/dist/ssh/ssh.d.ts.map +1 -1
  69. package/dist/ssh/ssh.js +43 -40
  70. package/dist/ssh/ssh.js.map +1 -1
  71. package/dist/ssh/ssh_errors.cjs +7 -5
  72. package/dist/ssh/ssh_errors.cjs.map +1 -1
  73. package/dist/ssh/ssh_errors.d.ts.map +1 -1
  74. package/dist/ssh/ssh_errors.js +7 -5
  75. package/dist/ssh/ssh_errors.js.map +1 -1
  76. package/dist/ssh/supervisord.cjs +15 -13
  77. package/dist/ssh/supervisord.cjs.map +1 -1
  78. package/dist/ssh/supervisord.d.ts +2 -2
  79. package/dist/ssh/supervisord.d.ts.map +1 -1
  80. package/dist/ssh/supervisord.js +15 -13
  81. package/dist/ssh/supervisord.js.map +1 -1
  82. package/package.json +37 -36
  83. package/src/common/os_and_arch.ts +19 -19
  84. package/src/common/pl_binary.ts +30 -27
  85. package/src/common/pl_binary_download.ts +80 -59
  86. package/src/common/pl_version.ts +2 -2
  87. package/src/index.ts +5 -5
  88. package/src/local/config.test.yaml +19 -19
  89. package/src/local/options.ts +4 -4
  90. package/src/local/pid.ts +4 -4
  91. package/src/local/pl.test.ts +245 -253
  92. package/src/local/pl.ts +45 -50
  93. package/src/local/process.ts +21 -21
  94. package/src/local/trace.ts +1 -1
  95. package/src/ssh/__tests__/common-utils.ts +21 -19
  96. package/src/ssh/__tests__/pl-docker.test.ts +68 -59
  97. package/src/ssh/__tests__/ssh-docker.test.ts +152 -90
  98. package/src/ssh/__tests__/ssh-upload.test.ts +42 -31
  99. package/src/ssh/connection_info.ts +33 -27
  100. package/src/ssh/pl.test.ts +15 -13
  101. package/src/ssh/pl.ts +228 -143
  102. package/src/ssh/pl_paths.ts +22 -18
  103. package/src/ssh/ssh.ts +151 -74
  104. package/src/ssh/ssh_errors.test.ts +39 -39
  105. package/src/ssh/ssh_errors.ts +8 -6
  106. package/src/ssh/supervisord.ts +28 -28
package/dist/local/pl.js CHANGED
@@ -9,7 +9,7 @@ import * as os from 'node:os';
9
9
  import { defaultHttpDispatcher } from '@milaboratories/pl-http';
10
10
  import { parseHttpAuth } from '@milaboratories/pl-model-common';
11
11
 
12
- const LocalConfigYaml = 'config-local.yaml';
12
+ const LocalConfigYaml = "config-local.yaml";
13
13
  /**
14
14
  * Represents a local running pl-core,
15
15
  * and has methods to start, check if it's running, stop and wait for stopping it.
@@ -43,7 +43,7 @@ class LocalPl {
43
43
  await withTrace(this.logger, async (trace, t) => {
44
44
  this.wasStopped = false;
45
45
  const instance = processRun(this.logger, this.startOptions);
46
- instance.on('error', (e) => {
46
+ instance.on("error", (e) => {
47
47
  this.logger.error(`error '${e}', while running platforma, started opts: ${JSON.stringify(this.debugInfo())}`);
48
48
  // keep in mind there are no awaits here, it will be asynchronous
49
49
  if (this.onError !== undefined)
@@ -53,7 +53,7 @@ class LocalPl {
53
53
  if (this.onCloseAndErrorNoStop !== undefined && !this.wasStopped)
54
54
  void this.onCloseAndErrorNoStop(this);
55
55
  });
56
- instance.on('close', () => {
56
+ instance.on("close", () => {
57
57
  this.logger.warn(`platforma was closed, started opts: ${JSON.stringify(this.debugInfo())}`);
58
58
  // keep in mind there are no awaits here, it will be asynchronous
59
59
  if (this.onClose !== undefined)
@@ -63,10 +63,10 @@ class LocalPl {
63
63
  if (this.onCloseAndErrorNoStop !== undefined && !this.wasStopped)
64
64
  void this.onCloseAndErrorNoStop(this);
65
65
  });
66
- trace('started', true);
67
- const pidFile = trace('pidFile', filePid(this.workingDir));
68
- trace('pid', notEmpty(instance.pid));
69
- trace('pidWritten', await writePid(pidFile, notEmpty(instance.pid)));
66
+ trace("started", true);
67
+ const pidFile = trace("pidFile", filePid(this.workingDir));
68
+ trace("pid", notEmpty(instance.pid));
69
+ trace("pidWritten", await writePid(pidFile, notEmpty(instance.pid)));
70
70
  this.nRuns++;
71
71
  this.instance = instance;
72
72
  this.pid = instance.pid;
@@ -108,28 +108,28 @@ async function localPlatformaInit(logger, _ops) {
108
108
  const numCpu = Math.max(os.cpus().length - 2, 1);
109
109
  const ops = mergeDefaultOps(_ops, numCpu);
110
110
  return await withTrace(logger, async (trace, t) => {
111
- trace('startOptions', { ...ops, config: 'too wordy' });
111
+ trace("startOptions", { ...ops, config: "too wordy" });
112
112
  const workDir = upath.resolve(ops.workingDir);
113
113
  if (ops.closeOld) {
114
- trace('closeOld', await localPlatformaReadPidAndStop(logger, workDir));
114
+ trace("closeOld", await localPlatformaReadPidAndStop(logger, workDir));
115
115
  }
116
116
  const configPath = upath.join(workDir, LocalConfigYaml);
117
117
  logger.info(`writing configuration '${configPath}'...`);
118
118
  await fsp.writeFile(configPath, ops.config);
119
- const plBinPath = upath.join(workDir, 'binaries');
119
+ const plBinPath = upath.join(workDir, "binaries");
120
120
  const baseBinaryPath = await resolveLocalPlBinaryPath({
121
121
  logger,
122
122
  downloadDir: plBinPath,
123
123
  src: ops.plBinary,
124
124
  dispatcher: defaultHttpDispatcher(ops.proxy),
125
125
  });
126
- const binaryPath = trace('binaryPath', upath.join('binaries', baseBinaryPath));
126
+ const binaryPath = trace("binaryPath", upath.join("binaries", baseBinaryPath));
127
127
  const env = { ...process.env };
128
128
  if (ops.proxy?.url) {
129
129
  const url = new URL(ops.proxy.url);
130
130
  if (ops.proxy.auth) {
131
131
  const parsed = parseHttpAuth(ops.proxy.auth);
132
- if (parsed.scheme !== 'Basic') {
132
+ if (parsed.scheme !== "Basic") {
133
133
  throw new Error(`\
134
134
  Unsupported auth scheme: ${parsed.scheme}. \
135
135
  Only Basic auth is supported by the backend.`);
@@ -141,7 +141,7 @@ Only Basic auth is supported by the backend.`);
141
141
  env.https_proxy = url.toString();
142
142
  }
143
143
  const processOpts = plProcessOps(binaryPath, configPath, ops, workDir, env);
144
- trace('processOpts', {
144
+ trace("processOpts", {
145
145
  cmd: processOpts.cmd,
146
146
  args: processOpts.args,
147
147
  cwd: processOpts.opts.cwd,
@@ -155,17 +155,17 @@ Only Basic auth is supported by the backend.`);
155
155
  * and closes it. */
156
156
  async function localPlatformaReadPidAndStop(logger, workingDir) {
157
157
  return await withTrace(logger, async (trace, t) => {
158
- const file = trace('pidFilePath', filePid(workingDir));
159
- const oldPid = trace('pid', await readPid(file));
160
- const alive = trace('wasAlive', await isProcessAlive(oldPid));
158
+ const file = trace("pidFilePath", filePid(workingDir));
159
+ const oldPid = trace("pid", await readPid(file));
160
+ const alive = trace("wasAlive", await isProcessAlive(oldPid));
161
161
  if (oldPid !== undefined && alive) {
162
- trace('stopped', processStop(oldPid));
162
+ trace("stopped", processStop(oldPid));
163
163
  try {
164
- trace('waitStopped', await processWaitStopped(oldPid, 15_000)); // larger, that 10s we provide to backend in config.
164
+ trace("waitStopped", await processWaitStopped(oldPid, 15_000)); // larger, that 10s we provide to backend in config.
165
165
  }
166
- catch (_e) {
167
- trace('forceStopped', processStop(oldPid, true));
168
- trace('waitForceStopped', await processWaitStopped(oldPid, 5_000));
166
+ catch {
167
+ trace("forceStopped", processStop(oldPid, true));
168
+ trace("waitForceStopped", await processWaitStopped(oldPid, 5_000));
169
169
  }
170
170
  }
171
171
  return t;
@@ -188,11 +188,11 @@ function mergeDefaultOps(ops, numCpu) {
188
188
  }
189
189
  if (ops.spawnOptions) {
190
190
  const withoutEnv = { ...ops.spawnOptions };
191
- delete withoutEnv['env'];
191
+ delete withoutEnv["env"];
192
192
  result.spawnOptions = { ...result.spawnOptions, ...withoutEnv };
193
193
  }
194
194
  const withoutSpawnOps = { ...ops };
195
- delete withoutSpawnOps['spawnOptions'];
195
+ delete withoutSpawnOps["spawnOptions"];
196
196
  return { ...result, ...withoutSpawnOps };
197
197
  }
198
198
  /** Gets default options for a platforma local binary
@@ -200,11 +200,11 @@ function mergeDefaultOps(ops, numCpu) {
200
200
  function plProcessOps(binaryPath, configPath, ops, workDir, defaultEnv) {
201
201
  const result = {
202
202
  cmd: binaryPath,
203
- args: ['--config', configPath],
203
+ args: ["--config", configPath],
204
204
  opts: {
205
205
  env: { ...defaultEnv },
206
206
  cwd: workDir,
207
- stdio: ['pipe', 'ignore', 'inherit'],
207
+ stdio: ["pipe", "ignore", "inherit"],
208
208
  windowsHide: true, // hide a terminal on Windows
209
209
  },
210
210
  };
@@ -212,7 +212,7 @@ function plProcessOps(binaryPath, configPath, ops, workDir, defaultEnv) {
212
212
  result.opts.env = { ...result.opts.env, ...ops.spawnOptions.env };
213
213
  }
214
214
  const withoutEnv = { ...ops.spawnOptions };
215
- delete withoutEnv['env'];
215
+ delete withoutEnv["env"];
216
216
  result.opts = { ...result.opts, ...withoutEnv };
217
217
  return result;
218
218
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pl.js","sources":["../../src/local/pl.ts"],"sourcesContent":["import type { ProcessOptions } from './process';\nimport {\n isProcessAlive,\n processStop,\n processWaitStopped,\n processRun,\n} from './process';\nimport type { PlBinarySource } from '../common/pl_binary';\nimport { newDefaultPlBinarySource, resolveLocalPlBinaryPath } from '../common/pl_binary';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { notEmpty } from '@milaboratories/ts-helpers';\nimport type { ChildProcess, SpawnOptions } from 'node:child_process';\nimport { filePid, readPid, writePid } from './pid';\nimport type { Trace } from './trace';\nimport { withTrace } from './trace';\nimport upath from 'upath';\nimport fsp from 'node:fs/promises';\nimport type { Required } from 'utility-types';\nimport * as os from 'node:os';\nimport type { ProxySettings } from '@milaboratories/pl-http';\nimport { defaultHttpDispatcher } from '@milaboratories/pl-http';\nimport { parseHttpAuth } from '@milaboratories/pl-model-common';\n\nexport const LocalConfigYaml = 'config-local.yaml';\n\n/**\n * Represents a local running pl-core,\n * and has methods to start, check if it's running, stop and wait for stopping it.\n * Also, a hook on pl-core closed can be provided.\n */\nexport class LocalPl {\n private instance?: ChildProcess;\n public pid?: number;\n private nRuns: number = 0;\n private lastRunHistory: Trace = {};\n private wasStopped = false;\n\n constructor(\n private readonly logger: MiLogger,\n private readonly workingDir: string,\n private readonly startOptions: ProcessOptions,\n private readonly initialStartHistory: Trace,\n private readonly onClose?: (pl: LocalPl) => Promise<void>,\n private readonly onError?: (pl: LocalPl) => Promise<void>,\n private readonly onCloseAndError?: (pl: LocalPl) => Promise<void>,\n private readonly onCloseAndErrorNoStop?: (pl: LocalPl) => Promise<void>,\n ) {}\n\n async start() {\n await withTrace(this.logger, async (trace, t) => {\n this.wasStopped = false;\n const instance = processRun(this.logger, this.startOptions);\n instance.on('error', (e: any) => {\n this.logger.error(\n `error '${e}', while running platforma, started opts: ${JSON.stringify(this.debugInfo())}`,\n );\n\n // keep in mind there are no awaits here, it will be asynchronous\n if (this.onError !== undefined) void this.onError(this);\n if (this.onCloseAndError !== undefined) void this.onCloseAndError(this);\n if (this.onCloseAndErrorNoStop !== undefined && !this.wasStopped)\n void this.onCloseAndErrorNoStop(this);\n });\n instance.on('close', () => {\n this.logger.warn(`platforma was closed, started opts: ${JSON.stringify(this.debugInfo())}`);\n\n // keep in mind there are no awaits here, it will be asynchronous\n if (this.onClose !== undefined) void this.onClose(this);\n if (this.onCloseAndError !== undefined) void this.onCloseAndError(this);\n if (this.onCloseAndErrorNoStop !== undefined && !this.wasStopped)\n void this.onCloseAndErrorNoStop(this);\n });\n\n trace('started', true);\n\n const pidFile = trace('pidFile', filePid(this.workingDir));\n trace('pid', notEmpty(instance.pid));\n trace('pidWritten', await writePid(pidFile, notEmpty(instance.pid)));\n\n this.nRuns++;\n this.instance = instance;\n this.pid = instance.pid;\n this.lastRunHistory = t;\n });\n }\n\n stop() {\n // TODO use this.instance to stop the process\n this.wasStopped = true;\n processStop(notEmpty(this.pid));\n }\n\n async waitStopped() {\n await processWaitStopped(notEmpty(this.pid), 15000);\n }\n\n stopped() {\n return this.wasStopped;\n }\n\n async isAlive(): Promise<boolean> {\n return await isProcessAlive(notEmpty(this.pid));\n }\n\n debugInfo() {\n return {\n lastRunHistory: this.lastRunHistory,\n nRuns: this.nRuns,\n pid: this.pid,\n workingDir: this.workingDir,\n initialStartHistory: this.initialStartHistory,\n wasStopped: this.wasStopped,\n };\n }\n}\n\n/** Options to start a local pl-core. */\nexport type LocalPlOptions = {\n /** From what directory start a process. */\n readonly workingDir: string;\n /** A string representation of yaml config. */\n readonly config: string;\n /** How to get a binary, download it or get an existing one (default: download latest version) */\n readonly plBinary?: PlBinarySource;\n /** Additional options for a process, environments, stdout, stderr etc. */\n readonly spawnOptions?: SpawnOptions;\n /**\n * If the previous pl-core was started from the same directory,\n * we can check if it's still running and then stop it before starting a new one.\n * (default: true)\n */\n readonly closeOld?: boolean;\n /**\n * Proxy settings to use to fetch the binary and pass it down\n * as a HTTPS_PROXY/HTTP_PROXY environment variable;\n * Backend only supports Basic auth.\n */\n readonly proxy?: ProxySettings;\n\n readonly onClose?: (pl: LocalPl) => Promise<void>;\n readonly onError?: (pl: LocalPl) => Promise<void>;\n readonly onCloseAndError?: (pl: LocalPl) => Promise<void>;\n readonly onCloseAndErrorNoStop?: (pl: LocalPl) => Promise<void>;\n};\n\nexport type LocalPlOptionsFull = Required<LocalPlOptions, 'plBinary' | 'spawnOptions' | 'closeOld'>;\n\n/**\n * Starts pl-core, if the option was provided downloads a binary, reads license environments etc.\n */\nexport async function localPlatformaInit(logger: MiLogger, _ops: LocalPlOptions): Promise<LocalPl> {\n // filling-in default values\n\n // Backend could consume a lot of CPU power,\n // we want to keep at least a couple for UI and other apps to work.\n const numCpu = Math.max(os.cpus().length - 2, 1);\n const ops = mergeDefaultOps(_ops, numCpu);\n\n return await withTrace(logger, async (trace, t) => {\n trace('startOptions', { ...ops, config: 'too wordy' });\n\n const workDir = upath.resolve(ops.workingDir);\n\n if (ops.closeOld) {\n trace('closeOld', await localPlatformaReadPidAndStop(logger, workDir));\n }\n\n const configPath = upath.join(workDir, LocalConfigYaml);\n\n logger.info(`writing configuration '${configPath}'...`);\n await fsp.writeFile(configPath, ops.config);\n\n const plBinPath = upath.join(workDir, 'binaries');\n const baseBinaryPath = await resolveLocalPlBinaryPath({\n logger,\n downloadDir: plBinPath,\n src: ops.plBinary,\n dispatcher: defaultHttpDispatcher(ops.proxy),\n });\n const binaryPath = trace('binaryPath', upath.join('binaries', baseBinaryPath));\n\n const env = { ...process.env };\n\n if (ops.proxy?.url) {\n const url = new URL(ops.proxy.url);\n if (ops.proxy.auth) {\n const parsed = parseHttpAuth(ops.proxy.auth);\n if (parsed.scheme !== 'Basic') {\n throw new Error(`\\\nUnsupported auth scheme: ${parsed.scheme}. \\\nOnly Basic auth is supported by the backend.`);\n }\n url.username = parsed.username;\n url.password = parsed.password;\n }\n env.http_proxy = url.toString();\n env.https_proxy = url.toString();\n }\n\n const processOpts = plProcessOps(binaryPath, configPath, ops, workDir, env);\n trace('processOpts', {\n cmd: processOpts.cmd,\n args: processOpts.args,\n cwd: processOpts.opts.cwd,\n });\n\n const pl = new LocalPl(\n logger,\n ops.workingDir,\n processOpts,\n t,\n ops.onClose,\n ops.onError,\n ops.onCloseAndError,\n ops.onCloseAndErrorNoStop,\n );\n await pl.start();\n\n return pl;\n });\n}\n\n/** Reads a pid of the old pl-core if it was started in the same working directory,\n * and closes it. */\nasync function localPlatformaReadPidAndStop(\n logger: MiLogger,\n workingDir: string,\n): Promise<Record<string, any>> {\n return await withTrace(logger, async (trace, t) => {\n const file = trace('pidFilePath', filePid(workingDir));\n\n const oldPid = trace('pid', await readPid(file));\n const alive = trace('wasAlive', await isProcessAlive(oldPid));\n\n if (oldPid !== undefined && alive) {\n trace('stopped', processStop(oldPid));\n try {\n trace('waitStopped', await processWaitStopped(oldPid, 15_000)); // larger, that 10s we provide to backend in config.\n } catch (_e) {\n trace('forceStopped', processStop(oldPid, true));\n trace('waitForceStopped', await processWaitStopped(oldPid, 5_000));\n }\n }\n\n return t;\n });\n}\n\n/** Gets default options for the whole init process\n * and overrides them with the provided options. */\nexport function mergeDefaultOps(ops: LocalPlOptions, numCpu: number): LocalPlOptionsFull {\n const result: {\n plBinary: PlBinarySource;\n spawnOptions: SpawnOptions;\n closeOld: boolean;\n } = {\n plBinary: newDefaultPlBinarySource(),\n spawnOptions: {\n env: {\n GOMAXPROCS: String(numCpu),\n },\n },\n closeOld: true,\n };\n\n if (ops.spawnOptions?.env) {\n result.spawnOptions.env = { ...result.spawnOptions.env, ...ops.spawnOptions.env };\n }\n\n if (ops.spawnOptions) {\n const withoutEnv = { ...ops.spawnOptions };\n delete withoutEnv['env'];\n result.spawnOptions = { ...result.spawnOptions, ...withoutEnv };\n }\n\n const withoutSpawnOps = { ...ops };\n delete withoutSpawnOps['spawnOptions'];\n\n return { ...result, ...withoutSpawnOps };\n}\n\n/** Gets default options for a platforma local binary\n * and overrides them with the provided options. */\nexport function plProcessOps(\n binaryPath: any,\n configPath: string,\n ops: LocalPlOptionsFull,\n workDir: string,\n defaultEnv: Record<string, string | undefined>,\n): ProcessOptions {\n const result: ProcessOptions = {\n cmd: binaryPath,\n args: ['--config', configPath],\n opts: {\n env: { ...defaultEnv },\n cwd: workDir,\n stdio: ['pipe', 'ignore', 'inherit'],\n windowsHide: true, // hide a terminal on Windows\n },\n };\n\n if (ops.spawnOptions?.env) {\n result.opts.env = { ...result.opts.env, ...ops.spawnOptions.env };\n }\n\n const withoutEnv = { ...ops.spawnOptions };\n delete withoutEnv['env'];\n result.opts = { ...result.opts, ...withoutEnv };\n\n return result;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAuBO,MAAM,eAAe,GAAG;AAE/B;;;;AAIG;MACU,OAAO,CAAA;AAQC,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,YAAA;AACA,IAAA,mBAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA,eAAA;AACA,IAAA,qBAAA;AAdX,IAAA,QAAQ;AACT,IAAA,GAAG;IACF,KAAK,GAAW,CAAC;IACjB,cAAc,GAAU,EAAE;IAC1B,UAAU,GAAG,KAAK;AAE1B,IAAA,WAAA,CACmB,MAAgB,EAChB,UAAkB,EAClB,YAA4B,EAC5B,mBAA0B,EAC1B,OAAwC,EACxC,OAAwC,EACxC,eAAgD,EAChD,qBAAsD,EAAA;QAPtD,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,YAAY,GAAZ,YAAY;QACZ,IAAA,CAAA,mBAAmB,GAAnB,mBAAmB;QACnB,IAAA,CAAA,OAAO,GAAP,OAAO;QACP,IAAA,CAAA,OAAO,GAAP,OAAO;QACP,IAAA,CAAA,eAAe,GAAf,eAAe;QACf,IAAA,CAAA,qBAAqB,GAArB,qBAAqB;IACrC;AAEH,IAAA,MAAM,KAAK,GAAA;AACT,QAAA,MAAM,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,EAAE,CAAC,KAA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AC,YAAY,CAAC,GAAG,EAAE;IACnE;IAEA,MAAM,UAAU,GAAG,EAAE,GAAG,GAAG,CAAC,YAAY,EAAE;AAC1C,IAAA,OAAO,UAAU,CAAC,KAAK,CAAC;AACxB,IAAA,MAAM,CAAC,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,UAAU,EAAE;AAE/C,IAAA,OAAO,MAAM;AACf;;;;"}
1
+ {"version":3,"file":"pl.js","sources":["../../src/local/pl.ts"],"sourcesContent":["import type { ProcessOptions } from \"./process\";\nimport { isProcessAlive, processStop, processWaitStopped, processRun } from \"./process\";\nimport type { PlBinarySource } from \"../common/pl_binary\";\nimport { newDefaultPlBinarySource, resolveLocalPlBinaryPath } from \"../common/pl_binary\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { ChildProcess, SpawnOptions } from \"node:child_process\";\nimport { filePid, readPid, writePid } from \"./pid\";\nimport type { Trace } from \"./trace\";\nimport { withTrace } from \"./trace\";\nimport upath from \"upath\";\nimport fsp from \"node:fs/promises\";\nimport type { Required } from \"utility-types\";\nimport * as os from \"node:os\";\nimport type { ProxySettings } from \"@milaboratories/pl-http\";\nimport { defaultHttpDispatcher } from \"@milaboratories/pl-http\";\nimport { parseHttpAuth } from \"@milaboratories/pl-model-common\";\n\nexport const LocalConfigYaml = \"config-local.yaml\";\n\n/**\n * Represents a local running pl-core,\n * and has methods to start, check if it's running, stop and wait for stopping it.\n * Also, a hook on pl-core closed can be provided.\n */\nexport class LocalPl {\n private instance?: ChildProcess;\n public pid?: number;\n private nRuns: number = 0;\n private lastRunHistory: Trace = {};\n private wasStopped = false;\n\n constructor(\n private readonly logger: MiLogger,\n private readonly workingDir: string,\n private readonly startOptions: ProcessOptions,\n private readonly initialStartHistory: Trace,\n private readonly onClose?: (pl: LocalPl) => Promise<void>,\n private readonly onError?: (pl: LocalPl) => Promise<void>,\n private readonly onCloseAndError?: (pl: LocalPl) => Promise<void>,\n private readonly onCloseAndErrorNoStop?: (pl: LocalPl) => Promise<void>,\n ) {}\n\n async start() {\n await withTrace(this.logger, async (trace, t) => {\n this.wasStopped = false;\n const instance = processRun(this.logger, this.startOptions);\n instance.on(\"error\", (e: any) => {\n this.logger.error(\n `error '${e}', while running platforma, started opts: ${JSON.stringify(this.debugInfo())}`,\n );\n\n // keep in mind there are no awaits here, it will be asynchronous\n if (this.onError !== undefined) void this.onError(this);\n if (this.onCloseAndError !== undefined) void this.onCloseAndError(this);\n if (this.onCloseAndErrorNoStop !== undefined && !this.wasStopped)\n void this.onCloseAndErrorNoStop(this);\n });\n instance.on(\"close\", () => {\n this.logger.warn(`platforma was closed, started opts: ${JSON.stringify(this.debugInfo())}`);\n\n // keep in mind there are no awaits here, it will be asynchronous\n if (this.onClose !== undefined) void this.onClose(this);\n if (this.onCloseAndError !== undefined) void this.onCloseAndError(this);\n if (this.onCloseAndErrorNoStop !== undefined && !this.wasStopped)\n void this.onCloseAndErrorNoStop(this);\n });\n\n trace(\"started\", true);\n\n const pidFile = trace(\"pidFile\", filePid(this.workingDir));\n trace(\"pid\", notEmpty(instance.pid));\n trace(\"pidWritten\", await writePid(pidFile, notEmpty(instance.pid)));\n\n this.nRuns++;\n this.instance = instance;\n this.pid = instance.pid;\n this.lastRunHistory = t;\n });\n }\n\n stop() {\n // TODO use this.instance to stop the process\n this.wasStopped = true;\n processStop(notEmpty(this.pid));\n }\n\n async waitStopped() {\n await processWaitStopped(notEmpty(this.pid), 15000);\n }\n\n stopped() {\n return this.wasStopped;\n }\n\n async isAlive(): Promise<boolean> {\n return await isProcessAlive(notEmpty(this.pid));\n }\n\n debugInfo() {\n return {\n lastRunHistory: this.lastRunHistory,\n nRuns: this.nRuns,\n pid: this.pid,\n workingDir: this.workingDir,\n initialStartHistory: this.initialStartHistory,\n wasStopped: this.wasStopped,\n };\n }\n}\n\n/** Options to start a local pl-core. */\nexport type LocalPlOptions = {\n /** From what directory start a process. */\n readonly workingDir: string;\n /** A string representation of yaml config. */\n readonly config: string;\n /** How to get a binary, download it or get an existing one (default: download latest version) */\n readonly plBinary?: PlBinarySource;\n /** Additional options for a process, environments, stdout, stderr etc. */\n readonly spawnOptions?: SpawnOptions;\n /**\n * If the previous pl-core was started from the same directory,\n * we can check if it's still running and then stop it before starting a new one.\n * (default: true)\n */\n readonly closeOld?: boolean;\n /**\n * Proxy settings to use to fetch the binary and pass it down\n * as a HTTPS_PROXY/HTTP_PROXY environment variable;\n * Backend only supports Basic auth.\n */\n readonly proxy?: ProxySettings;\n\n readonly onClose?: (pl: LocalPl) => Promise<void>;\n readonly onError?: (pl: LocalPl) => Promise<void>;\n readonly onCloseAndError?: (pl: LocalPl) => Promise<void>;\n readonly onCloseAndErrorNoStop?: (pl: LocalPl) => Promise<void>;\n};\n\nexport type LocalPlOptionsFull = Required<LocalPlOptions, \"plBinary\" | \"spawnOptions\" | \"closeOld\">;\n\n/**\n * Starts pl-core, if the option was provided downloads a binary, reads license environments etc.\n */\nexport async function localPlatformaInit(logger: MiLogger, _ops: LocalPlOptions): Promise<LocalPl> {\n // filling-in default values\n\n // Backend could consume a lot of CPU power,\n // we want to keep at least a couple for UI and other apps to work.\n const numCpu = Math.max(os.cpus().length - 2, 1);\n const ops = mergeDefaultOps(_ops, numCpu);\n\n return await withTrace(logger, async (trace, t) => {\n trace(\"startOptions\", { ...ops, config: \"too wordy\" });\n\n const workDir = upath.resolve(ops.workingDir);\n\n if (ops.closeOld) {\n trace(\"closeOld\", await localPlatformaReadPidAndStop(logger, workDir));\n }\n\n const configPath = upath.join(workDir, LocalConfigYaml);\n\n logger.info(`writing configuration '${configPath}'...`);\n await fsp.writeFile(configPath, ops.config);\n\n const plBinPath = upath.join(workDir, \"binaries\");\n const baseBinaryPath = await resolveLocalPlBinaryPath({\n logger,\n downloadDir: plBinPath,\n src: ops.plBinary,\n dispatcher: defaultHttpDispatcher(ops.proxy),\n });\n const binaryPath = trace(\"binaryPath\", upath.join(\"binaries\", baseBinaryPath));\n\n const env = { ...process.env };\n\n if (ops.proxy?.url) {\n const url = new URL(ops.proxy.url);\n if (ops.proxy.auth) {\n const parsed = parseHttpAuth(ops.proxy.auth);\n if (parsed.scheme !== \"Basic\") {\n throw new Error(`\\\nUnsupported auth scheme: ${parsed.scheme}. \\\nOnly Basic auth is supported by the backend.`);\n }\n url.username = parsed.username;\n url.password = parsed.password;\n }\n env.http_proxy = url.toString();\n env.https_proxy = url.toString();\n }\n\n const processOpts = plProcessOps(binaryPath, configPath, ops, workDir, env);\n trace(\"processOpts\", {\n cmd: processOpts.cmd,\n args: processOpts.args,\n cwd: processOpts.opts.cwd,\n });\n\n const pl = new LocalPl(\n logger,\n ops.workingDir,\n processOpts,\n t,\n ops.onClose,\n ops.onError,\n ops.onCloseAndError,\n ops.onCloseAndErrorNoStop,\n );\n await pl.start();\n\n return pl;\n });\n}\n\n/** Reads a pid of the old pl-core if it was started in the same working directory,\n * and closes it. */\nasync function localPlatformaReadPidAndStop(\n logger: MiLogger,\n workingDir: string,\n): Promise<Record<string, any>> {\n return await withTrace(logger, async (trace, t) => {\n const file = trace(\"pidFilePath\", filePid(workingDir));\n\n const oldPid = trace(\"pid\", await readPid(file));\n const alive = trace(\"wasAlive\", await isProcessAlive(oldPid));\n\n if (oldPid !== undefined && alive) {\n trace(\"stopped\", processStop(oldPid));\n try {\n trace(\"waitStopped\", await processWaitStopped(oldPid, 15_000)); // larger, that 10s we provide to backend in config.\n } catch {\n trace(\"forceStopped\", processStop(oldPid, true));\n trace(\"waitForceStopped\", await processWaitStopped(oldPid, 5_000));\n }\n }\n\n return t;\n });\n}\n\n/** Gets default options for the whole init process\n * and overrides them with the provided options. */\nexport function mergeDefaultOps(ops: LocalPlOptions, numCpu: number): LocalPlOptionsFull {\n const result: {\n plBinary: PlBinarySource;\n spawnOptions: SpawnOptions;\n closeOld: boolean;\n } = {\n plBinary: newDefaultPlBinarySource(),\n spawnOptions: {\n env: {\n GOMAXPROCS: String(numCpu),\n },\n },\n closeOld: true,\n };\n\n if (ops.spawnOptions?.env) {\n result.spawnOptions.env = { ...result.spawnOptions.env, ...ops.spawnOptions.env };\n }\n\n if (ops.spawnOptions) {\n const withoutEnv = { ...ops.spawnOptions };\n delete withoutEnv[\"env\"];\n result.spawnOptions = { ...result.spawnOptions, ...withoutEnv };\n }\n\n const withoutSpawnOps = { ...ops };\n delete withoutSpawnOps[\"spawnOptions\"];\n\n return { ...result, ...withoutSpawnOps };\n}\n\n/** Gets default options for a platforma local binary\n * and overrides them with the provided options. */\nexport function plProcessOps(\n binaryPath: any,\n configPath: string,\n ops: LocalPlOptionsFull,\n workDir: string,\n defaultEnv: Record<string, string | undefined>,\n): ProcessOptions {\n const result: ProcessOptions = {\n cmd: binaryPath,\n args: [\"--config\", configPath],\n opts: {\n env: { ...defaultEnv },\n cwd: workDir,\n stdio: [\"pipe\", \"ignore\", \"inherit\"],\n windowsHide: true, // hide a terminal on Windows\n },\n };\n\n if (ops.spawnOptions?.env) {\n result.opts.env = { ...result.opts.env, ...ops.spawnOptions.env };\n }\n\n const withoutEnv = { ...ops.spawnOptions };\n delete withoutEnv[\"env\"];\n result.opts = { ...result.opts, ...withoutEnv };\n\n return result;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAkBO,MAAM,eAAe,GAAG;AAE/B;;;;AAIG;MACU,OAAO,CAAA;AAQC,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,YAAA;AACA,IAAA,mBAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA,eAAA;AACA,IAAA,qBAAA;AAdX,IAAA,QAAQ;AACT,IAAA,GAAG;IACF,KAAK,GAAW,CAAC;IACjB,cAAc,GAAU,EAAE;IAC1B,UAAU,GAAG,KAAK;AAE1B,IAAA,WAAA,CACmB,MAAgB,EAChB,UAAkB,EAClB,YAA4B,EAC5B,mBAA0B,EAC1B,OAAwC,EACxC,OAAwC,EACxC,eAAgD,EAChD,qBAAsD,EAAA;QAPtD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,CAAC,UAAU,EAAE,UAAU,CAAC;AAC9B,QAAA,IAAI,EAAE;AACJ,YAAA,GAAG,EAAE,EAAE,GAAG,UAAU,EAAE;AACtB,YAAA,GAAG,EAAE,OAAO;AACZ,YAAA,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC;YACpC,WAAW,EAAE,IAAI;AAClB,SAAA;KACF;AAED,IAAA,IAAI,GAAG,CAAC,YAAY,EAAE,GAAG,EAAE;QACzB,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE;IACnE;IAEA,MAAM,UAAU,GAAG,EAAE,GAAG,GAAG,CAAC,YAAY,EAAE;AAC1C,IAAA,OAAO,UAAU,CAAC,KAAK,CAAC;AACxB,IAAA,MAAM,CAAC,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,UAAU,EAAE;AAE/C,IAAA,OAAO,MAAM;AACf;;;;"}
@@ -7,7 +7,7 @@ function processRun(logger, opts) {
7
7
  logger.info(`Running:
8
8
  cmd: ${JSON.stringify([opts.cmd, ...opts.args])}
9
9
  wd: ${opts.opts.cwd}`);
10
- logger.info(' spawning child process');
10
+ logger.info(" spawning child process");
11
11
  return node_child_process.spawn(opts.cmd, opts.args, opts.opts);
12
12
  }
13
13
  // eslint-disable-next-line @typescript-eslint/require-await
@@ -16,47 +16,47 @@ async function isProcessAlive(pid) {
16
16
  process.kill(pid, 0);
17
17
  // Check we look at 'platforma' to not kill wrong process.
18
18
  const processName = getProcessName(pid);
19
- if (process.platform === 'win32') {
20
- return processName === 'platforma.exe'; // process name does not contain path to the file.
19
+ if (process.platform === "win32") {
20
+ return processName === "platforma.exe"; // process name does not contain path to the file.
21
21
  }
22
22
  // Linux and Mac OS X behave differently (so can different Linux distributions).
23
23
  // Process name can contain original path to the binary file or just its name.
24
- return processName.endsWith('/platforma') || processName === 'platforma';
24
+ return processName.endsWith("/platforma") || processName === "platforma";
25
25
  }
26
- catch (_e) {
26
+ catch {
27
27
  return false;
28
28
  }
29
29
  }
30
30
  function getProcessName(pid) {
31
31
  try {
32
- if (process.platform === 'win32') {
32
+ if (process.platform === "win32") {
33
33
  // Windows: use tasklist command
34
- const output = node_child_process.execSync(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`, { encoding: 'utf8' });
35
- const lines = output.trim().split('\n');
36
- if (lines.length > 0 && lines[0].includes(',')) {
37
- const parts = lines[0].split(',');
34
+ const output = node_child_process.execSync(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`, { encoding: "utf8" });
35
+ const lines = output.trim().split("\n");
36
+ if (lines.length > 0 && lines[0].includes(",")) {
37
+ const parts = lines[0].split(",");
38
38
  if (parts.length >= 1) {
39
39
  // Remove quotes and get the executable name
40
- const exeName = parts[0].replace(/^"|"$/g, '').trim();
40
+ const exeName = parts[0].replace(/^"|"$/g, "").trim();
41
41
  return exeName;
42
42
  }
43
43
  }
44
44
  }
45
45
  else {
46
46
  // Unix-like systems: use ps command
47
- const output = node_child_process.execSync(`ps -p ${pid} -o comm=`, { encoding: 'utf8' });
47
+ const output = node_child_process.execSync(`ps -p ${pid} -o comm=`, { encoding: "utf8" });
48
48
  const processName = output.trim();
49
49
  return processName;
50
50
  }
51
51
  }
52
- catch (_error) {
52
+ catch {
53
53
  // If we can't get the process name, return empty string
54
- return '';
54
+ return "";
55
55
  }
56
- return '';
56
+ return "";
57
57
  }
58
58
  function processStop(pid, force = false) {
59
- return process.kill(pid, force ? 'SIGKILL' : 'SIGINT');
59
+ return process.kill(pid, force ? "SIGKILL" : "SIGINT");
60
60
  }
61
61
  async function processWaitStopped(pid, maxMs) {
62
62
  const sleepMs = 100;
@@ -1 +1 @@
1
- {"version":3,"file":"process.cjs","sources":["../../src/local/process.ts"],"sourcesContent":["import type { SpawnOptions, ChildProcess } from 'node:child_process';\nimport { spawn } from 'node:child_process';\nimport { execSync } from 'node:child_process';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { sleep } from '@milaboratories/ts-helpers';\n\nexport type ProcessOptions = {\n cmd: string;\n args: string[];\n opts: SpawnOptions;\n};\n\nexport function processRun(logger: MiLogger, opts: ProcessOptions): ChildProcess {\n logger.info(`Running:\ncmd: ${JSON.stringify([opts.cmd, ...opts.args])}\nwd: ${opts.opts.cwd}`);\n\n logger.info(' spawning child process');\n return spawn(opts.cmd, opts.args, opts.opts);\n}\n\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function isProcessAlive(pid: number) {\n try {\n process.kill(pid, 0);\n\n // Check we look at 'platforma' to not kill wrong process.\n const processName = getProcessName(pid);\n if (process.platform === 'win32') {\n return processName === 'platforma.exe'; // process name does not contain path to the file.\n }\n\n // Linux and Mac OS X behave differently (so can different Linux distributions).\n // Process name can contain original path to the binary file or just its name.\n return processName.endsWith('/platforma') || processName === 'platforma';\n } catch (_e) {\n return false;\n }\n}\n\nfunction getProcessName(pid: number): string {\n try {\n if (process.platform === 'win32') {\n // Windows: use tasklist command\n const output = execSync(`tasklist /FI \"PID eq ${pid}\" /FO CSV /NH`, { encoding: 'utf8' });\n const lines = output.trim().split('\\n');\n if (lines.length > 0 && lines[0].includes(',')) {\n const parts = lines[0].split(',');\n if (parts.length >= 1) {\n // Remove quotes and get the executable name\n const exeName = parts[0].replace(/^\"|\"$/g, '').trim();\n return exeName;\n }\n }\n } else {\n // Unix-like systems: use ps command\n const output = execSync(`ps -p ${pid} -o comm=`, { encoding: 'utf8' });\n const processName = output.trim();\n return processName;\n }\n } catch (_error) {\n // If we can't get the process name, return empty string\n return '';\n }\n return '';\n}\n\nexport function processStop(pid: number, force: boolean = false) {\n return process.kill(pid, force ? 'SIGKILL' : 'SIGINT');\n}\n\nexport async function processWaitStopped(pid: number, maxMs: number) {\n const sleepMs = 100;\n let total = 0;\n while (await isProcessAlive(pid)) {\n await sleep(sleepMs);\n total += sleepMs;\n if (total > maxMs) {\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"}
1
+ {"version":3,"file":"process.cjs","sources":["../../src/local/process.ts"],"sourcesContent":["import type { SpawnOptions, ChildProcess } from \"node:child_process\";\nimport { spawn } from \"node:child_process\";\nimport { execSync } from \"node:child_process\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { sleep } from \"@milaboratories/ts-helpers\";\n\nexport type ProcessOptions = {\n cmd: string;\n args: string[];\n opts: SpawnOptions;\n};\n\nexport function processRun(logger: MiLogger, opts: ProcessOptions): ChildProcess {\n logger.info(`Running:\ncmd: ${JSON.stringify([opts.cmd, ...opts.args])}\nwd: ${opts.opts.cwd}`);\n\n logger.info(\" spawning child process\");\n return spawn(opts.cmd, opts.args, opts.opts);\n}\n\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function isProcessAlive(pid: number) {\n try {\n process.kill(pid, 0);\n\n // Check we look at 'platforma' to not kill wrong process.\n const processName = getProcessName(pid);\n if (process.platform === \"win32\") {\n return processName === \"platforma.exe\"; // process name does not contain path to the file.\n }\n\n // Linux and Mac OS X behave differently (so can different Linux distributions).\n // Process name can contain original path to the binary file or just its name.\n return processName.endsWith(\"/platforma\") || processName === \"platforma\";\n } catch {\n return false;\n }\n}\n\nfunction getProcessName(pid: number): string {\n try {\n if (process.platform === \"win32\") {\n // Windows: use tasklist command\n const output = execSync(`tasklist /FI \"PID eq ${pid}\" /FO CSV /NH`, { encoding: \"utf8\" });\n const lines = output.trim().split(\"\\n\");\n if (lines.length > 0 && lines[0].includes(\",\")) {\n const parts = lines[0].split(\",\");\n if (parts.length >= 1) {\n // Remove quotes and get the executable name\n const exeName = parts[0].replace(/^\"|\"$/g, \"\").trim();\n return exeName;\n }\n }\n } else {\n // Unix-like systems: use ps command\n const output = execSync(`ps -p ${pid} -o comm=`, { encoding: \"utf8\" });\n const processName = output.trim();\n return processName;\n }\n } catch {\n // If we can't get the process name, return empty string\n return \"\";\n }\n return \"\";\n}\n\nexport function processStop(pid: number, force: boolean = false) {\n return process.kill(pid, force ? \"SIGKILL\" : \"SIGINT\");\n}\n\nexport async function processWaitStopped(pid: number, maxMs: number) {\n const sleepMs = 100;\n let total = 0;\n while (await isProcessAlive(pid)) {\n await sleep(sleepMs);\n total += sleepMs;\n if (total > maxMs) {\n throw new Error(`The process did not stopped after ${maxMs} ms.`);\n }\n }\n}\n"],"names":["spawn","execSync","sleep"],"mappings":";;;;;AAYM,SAAU,UAAU,CAAC,MAAgB,EAAE,IAAoB,EAAA;IAC/D,MAAM,CAAC,IAAI,CAAC,CAAA;AACP,KAAA,EAAA,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;AACzC,IAAA,EAAA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA,CAAE,CAAC;AAEpB,IAAA,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC;AACvC,IAAA,OAAOA,wBAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;AAC9C;AAEA;AACO,eAAe,cAAc,CAAC,GAAW,EAAA;AAC9C,IAAA,IAAI;AACF,QAAA,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;;AAGpB,QAAA,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC;AACvC,QAAA,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;AAChC,YAAA,OAAO,WAAW,KAAK,eAAe,CAAC;QACzC;;;QAIA,OAAO,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,WAAW,KAAK,WAAW;IAC1E;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF;AAEA,SAAS,cAAc,CAAC,GAAW,EAAA;AACjC,IAAA,IAAI;AACF,QAAA,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;;AAEhC,YAAA,MAAM,MAAM,GAAGC,2BAAQ,CAAC,wBAAwB,GA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QAAA,IAAI,KAAK,GAAG,KAAK,EAAE;AACjB,YAAA,MAAM,IAAI,KAAK,CAAC,qCAAqC,KAAK,CAAA,IAAA,CAAM,CAAC;QACnE;IACF;AACF;;;;;;;"}
@@ -1,5 +1,5 @@
1
- import type { SpawnOptions, ChildProcess } from 'node:child_process';
2
- import type { MiLogger } from '@milaboratories/ts-helpers';
1
+ import type { SpawnOptions, ChildProcess } from "node:child_process";
2
+ import type { MiLogger } from "@milaboratories/ts-helpers";
3
3
  export type ProcessOptions = {
4
4
  cmd: string;
5
5
  args: string[];
@@ -5,7 +5,7 @@ function processRun(logger, opts) {
5
5
  logger.info(`Running:
6
6
  cmd: ${JSON.stringify([opts.cmd, ...opts.args])}
7
7
  wd: ${opts.opts.cwd}`);
8
- logger.info(' spawning child process');
8
+ logger.info(" spawning child process");
9
9
  return spawn(opts.cmd, opts.args, opts.opts);
10
10
  }
11
11
  // eslint-disable-next-line @typescript-eslint/require-await
@@ -14,47 +14,47 @@ async function isProcessAlive(pid) {
14
14
  process.kill(pid, 0);
15
15
  // Check we look at 'platforma' to not kill wrong process.
16
16
  const processName = getProcessName(pid);
17
- if (process.platform === 'win32') {
18
- return processName === 'platforma.exe'; // process name does not contain path to the file.
17
+ if (process.platform === "win32") {
18
+ return processName === "platforma.exe"; // process name does not contain path to the file.
19
19
  }
20
20
  // Linux and Mac OS X behave differently (so can different Linux distributions).
21
21
  // Process name can contain original path to the binary file or just its name.
22
- return processName.endsWith('/platforma') || processName === 'platforma';
22
+ return processName.endsWith("/platforma") || processName === "platforma";
23
23
  }
24
- catch (_e) {
24
+ catch {
25
25
  return false;
26
26
  }
27
27
  }
28
28
  function getProcessName(pid) {
29
29
  try {
30
- if (process.platform === 'win32') {
30
+ if (process.platform === "win32") {
31
31
  // Windows: use tasklist command
32
- const output = execSync(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`, { encoding: 'utf8' });
33
- const lines = output.trim().split('\n');
34
- if (lines.length > 0 && lines[0].includes(',')) {
35
- const parts = lines[0].split(',');
32
+ const output = execSync(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`, { encoding: "utf8" });
33
+ const lines = output.trim().split("\n");
34
+ if (lines.length > 0 && lines[0].includes(",")) {
35
+ const parts = lines[0].split(",");
36
36
  if (parts.length >= 1) {
37
37
  // Remove quotes and get the executable name
38
- const exeName = parts[0].replace(/^"|"$/g, '').trim();
38
+ const exeName = parts[0].replace(/^"|"$/g, "").trim();
39
39
  return exeName;
40
40
  }
41
41
  }
42
42
  }
43
43
  else {
44
44
  // Unix-like systems: use ps command
45
- const output = execSync(`ps -p ${pid} -o comm=`, { encoding: 'utf8' });
45
+ const output = execSync(`ps -p ${pid} -o comm=`, { encoding: "utf8" });
46
46
  const processName = output.trim();
47
47
  return processName;
48
48
  }
49
49
  }
50
- catch (_error) {
50
+ catch {
51
51
  // If we can't get the process name, return empty string
52
- return '';
52
+ return "";
53
53
  }
54
- return '';
54
+ return "";
55
55
  }
56
56
  function processStop(pid, force = false) {
57
- return process.kill(pid, force ? 'SIGKILL' : 'SIGINT');
57
+ return process.kill(pid, force ? "SIGKILL" : "SIGINT");
58
58
  }
59
59
  async function processWaitStopped(pid, maxMs) {
60
60
  const sleepMs = 100;
@@ -1 +1 @@
1
- {"version":3,"file":"process.js","sources":["../../src/local/process.ts"],"sourcesContent":["import type { SpawnOptions, ChildProcess } from 'node:child_process';\nimport { spawn } from 'node:child_process';\nimport { execSync } from 'node:child_process';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { sleep } from '@milaboratories/ts-helpers';\n\nexport type ProcessOptions = {\n cmd: string;\n args: string[];\n opts: SpawnOptions;\n};\n\nexport function processRun(logger: MiLogger, opts: ProcessOptions): ChildProcess {\n logger.info(`Running:\ncmd: ${JSON.stringify([opts.cmd, ...opts.args])}\nwd: ${opts.opts.cwd}`);\n\n logger.info(' spawning child process');\n return spawn(opts.cmd, opts.args, opts.opts);\n}\n\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function isProcessAlive(pid: number) {\n try {\n process.kill(pid, 0);\n\n // Check we look at 'platforma' to not kill wrong process.\n const processName = getProcessName(pid);\n if (process.platform === 'win32') {\n return processName === 'platforma.exe'; // process name does not contain path to the file.\n }\n\n // Linux and Mac OS X behave differently (so can different Linux distributions).\n // Process name can contain original path to the binary file or just its name.\n return processName.endsWith('/platforma') || processName === 'platforma';\n } catch (_e) {\n return false;\n }\n}\n\nfunction getProcessName(pid: number): string {\n try {\n if (process.platform === 'win32') {\n // Windows: use tasklist command\n const output = execSync(`tasklist /FI \"PID eq ${pid}\" /FO CSV /NH`, { encoding: 'utf8' });\n const lines = output.trim().split('\\n');\n if (lines.length > 0 && lines[0].includes(',')) {\n const parts = lines[0].split(',');\n if (parts.length >= 1) {\n // Remove quotes and get the executable name\n const exeName = parts[0].replace(/^\"|\"$/g, '').trim();\n return exeName;\n }\n }\n } else {\n // Unix-like systems: use ps command\n const output = execSync(`ps -p ${pid} -o comm=`, { encoding: 'utf8' });\n const processName = output.trim();\n return processName;\n }\n } catch (_error) {\n // If we can't get the process name, return empty string\n return '';\n }\n return '';\n}\n\nexport function processStop(pid: number, force: boolean = false) {\n return process.kill(pid, force ? 'SIGKILL' : 'SIGINT');\n}\n\nexport async function processWaitStopped(pid: number, maxMs: number) {\n const sleepMs = 100;\n let total = 0;\n while (await isProcessAlive(pid)) {\n await sleep(sleepMs);\n total += sleepMs;\n if (total > maxMs) {\n throw new Error(`The process did not stopped after ${maxMs} ms.`);\n }\n }\n}\n"],"names":[],"mappings":";;;AAYM,SAAU,UAAU,CAAC,MAAgB,EAAE,IAAoB,EAAA;IAC/D,MAAM,CAAC,IAAI,CAAC,CAAA;AACP,KAAA,EAAA,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;AACzC,IAAA,EAAA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA,CAAE,CAAC;AAEpB,IAAA,MAAM,CAAC,IA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rD,oBAAA,OAAO,OAAO;gBAChB;YACF;QACF;aAAO;;AAEL,YAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,GAAG,CAAA,SAAA,CAAW,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACtE,YAAA,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,EAAE;AACjC,YAAA,OAAO,WAAW;QACpB;IACF;IAAE,OAAO,MAAM,EAAE;;AAEf,QAAA,OAAO,EAAE;IACX;AACA,IAAA,OAAO,EAAE;AACX;SAEgB,WAAW,CAAC,GAAW,EAAE,QAAiB,KAAK,EAAA;AAC7D,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;AACxD;AAEO,eAAe,kBAAkB,CAAC,GAAW,EAAE,KAAa,EAAA;IACjE,MAAM,OAAO,GAAG,GAAG;IACnB,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,OAAO,MAAM,cAAc,CAAC,GAAG,CAAC,EAAE;AAChC,QAAA,MAAM,KAAK,CAAC,OAAO,CAAC;QACpB,KAAK,IAAI,OAAO;AAChB,QAAA,IAAI,KAAK,GAAG,KAAK,EAAE;AACjB,YAAA,MAAM,IAAI,KAAK,CAAC,qCAAqC,KAAK,CAAA,IAAA,CAAM,CAAC;QACnE;IACF;AACF;;;;"}
1
+ {"version":3,"file":"process.js","sources":["../../src/local/process.ts"],"sourcesContent":["import type { SpawnOptions, ChildProcess } from \"node:child_process\";\nimport { spawn } from \"node:child_process\";\nimport { execSync } from \"node:child_process\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { sleep } from \"@milaboratories/ts-helpers\";\n\nexport type ProcessOptions = {\n cmd: string;\n args: string[];\n opts: SpawnOptions;\n};\n\nexport function processRun(logger: MiLogger, opts: ProcessOptions): ChildProcess {\n logger.info(`Running:\ncmd: ${JSON.stringify([opts.cmd, ...opts.args])}\nwd: ${opts.opts.cwd}`);\n\n logger.info(\" spawning child process\");\n return spawn(opts.cmd, opts.args, opts.opts);\n}\n\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function isProcessAlive(pid: number) {\n try {\n process.kill(pid, 0);\n\n // Check we look at 'platforma' to not kill wrong process.\n const processName = getProcessName(pid);\n if (process.platform === \"win32\") {\n return processName === \"platforma.exe\"; // process name does not contain path to the file.\n }\n\n // Linux and Mac OS X behave differently (so can different Linux distributions).\n // Process name can contain original path to the binary file or just its name.\n return processName.endsWith(\"/platforma\") || processName === \"platforma\";\n } catch {\n return false;\n }\n}\n\nfunction getProcessName(pid: number): string {\n try {\n if (process.platform === \"win32\") {\n // Windows: use tasklist command\n const output = execSync(`tasklist /FI \"PID eq ${pid}\" /FO CSV /NH`, { encoding: \"utf8\" });\n const lines = output.trim().split(\"\\n\");\n if (lines.length > 0 && lines[0].includes(\",\")) {\n const parts = lines[0].split(\",\");\n if (parts.length >= 1) {\n // Remove quotes and get the executable name\n const exeName = parts[0].replace(/^\"|\"$/g, \"\").trim();\n return exeName;\n }\n }\n } else {\n // Unix-like systems: use ps command\n const output = execSync(`ps -p ${pid} -o comm=`, { encoding: \"utf8\" });\n const processName = output.trim();\n return processName;\n }\n } catch {\n // If we can't get the process name, return empty string\n return \"\";\n }\n return \"\";\n}\n\nexport function processStop(pid: number, force: boolean = false) {\n return process.kill(pid, force ? \"SIGKILL\" : \"SIGINT\");\n}\n\nexport async function processWaitStopped(pid: number, maxMs: number) {\n const sleepMs = 100;\n let total = 0;\n while (await isProcessAlive(pid)) {\n await sleep(sleepMs);\n total += sleepMs;\n if (total > maxMs) {\n throw new Error(`The process did not stopped after ${maxMs} ms.`);\n }\n }\n}\n"],"names":[],"mappings":";;;AAYM,SAAU,UAAU,CAAC,MAAgB,EAAE,IAAoB,EAAA;IAC/D,MAAM,CAAC,IAAI,CAAC,CAAA;AACP,KAAA,EAAA,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAA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A,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE;AACrD,oBAAA,OAAO,OAAO;gBAChB;YACF;QACF;aAAO;;AAEL,YAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,GAAG,CAAA,SAAA,CAAW,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACtE,YAAA,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,EAAE;AACjC,YAAA,OAAO,WAAW;QACpB;IACF;AAAE,IAAA,MAAM;;AAEN,QAAA,OAAO,EAAE;IACX;AACA,IAAA,OAAO,EAAE;AACX;SAEgB,WAAW,CAAC,GAAW,EAAE,QAAiB,KAAK,EAAA;AAC7D,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;AACxD;AAEO,eAAe,kBAAkB,CAAC,GAAW,EAAE,KAAa,EAAA;IACjE,MAAM,OAAO,GAAG,GAAG;IACnB,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,OAAO,MAAM,cAAc,CAAC,GAAG,CAAC,EAAE;AAChC,QAAA,MAAM,KAAK,CAAC,OAAO,CAAC;QACpB,KAAK,IAAI,OAAO;AAChB,QAAA,IAAI,KAAK,GAAG,KAAK,EAAE;AACjB,YAAA,MAAM,IAAI,KAAK,CAAC,qCAAqC,KAAK,CAAA,IAAA,CAAM,CAAC;QACnE;IACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"trace.cjs","sources":["../../src/local/trace.ts"],"sourcesContent":["import type { MiLogger } from '@milaboratories/ts-helpers';\n\n/** Records all inputs and outputs of one's choice, so if the error happened\n * one can check how it was by just printing this structure. */\nexport type Trace = Record<string, any>;\n\nexport function newTrace(): Trace {\n return {};\n}\n\nexport function trace(t: Trace, k: string, v: any) {\n t[k] = v;\n return v;\n}\n\n/** Creates a trace and runs a function with it. The function can record all its\n * logs or traces using `trace` fn. */\nexport async function withTrace<T>(\n logger: MiLogger,\n fn: (trace: (k: string, v: any) => typeof v, t: Trace) => Promise<T>,\n): Promise<T> {\n const t = newTrace();\n try {\n const result = await fn((k: string, v: any) => trace(t, k, v), t);\n return result;\n } catch (e: any) {\n logger.error(`error ${e} while doing traced operation, state: ${JSON.stringify(t)}`);\n throw e;\n }\n}\n"],"names":[],"mappings":";;SAMgB,QAAQ,GAAA;AACtB,IAAA,OAAO,EAAE;AACX;SAEgB,KAAK,CAAC,CAAQ,EAAE,CAAS,EAAE,CAAM,EAAA;AAC/C,IAAA,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACR,IAAA,OAAO,CAAC;AACV;AAEA;AACsC;AAC/B,eAAe,SAAS,CAC7B,MAAgB,EAChB,EAAoE,EAAA;AAEpE,IAAA,MAAM,CAAC,GAAG,QAAQ,EAAE;AACpB,IAAA,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAS,EAAE,CAAM,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACjE,QAAA,OAAO,MAAM;IACf;IAAE,OAAO,CAAM,EAAE;AACf,QAAA,MAAM,CAAC,KAAK,CAAC,CAAA,MAAA,EAAS,CAAC,CAAA,sCAAA,EAAyC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC;AACpF,QAAA,MAAM,CAAC;IACT;AACF;;;;;;"}
1
+ {"version":3,"file":"trace.cjs","sources":["../../src/local/trace.ts"],"sourcesContent":["import type { MiLogger } from \"@milaboratories/ts-helpers\";\n\n/** Records all inputs and outputs of one's choice, so if the error happened\n * one can check how it was by just printing this structure. */\nexport type Trace = Record<string, any>;\n\nexport function newTrace(): Trace {\n return {};\n}\n\nexport function trace(t: Trace, k: string, v: any) {\n t[k] = v;\n return v;\n}\n\n/** Creates a trace and runs a function with it. The function can record all its\n * logs or traces using `trace` fn. */\nexport async function withTrace<T>(\n logger: MiLogger,\n fn: (trace: (k: string, v: any) => typeof v, t: Trace) => Promise<T>,\n): Promise<T> {\n const t = newTrace();\n try {\n const result = await fn((k: string, v: any) => trace(t, k, v), t);\n return result;\n } catch (e: any) {\n logger.error(`error ${e} while doing traced operation, state: ${JSON.stringify(t)}`);\n throw e;\n }\n}\n"],"names":[],"mappings":";;SAMgB,QAAQ,GAAA;AACtB,IAAA,OAAO,EAAE;AACX;SAEgB,KAAK,CAAC,CAAQ,EAAE,CAAS,EAAE,CAAM,EAAA;AAC/C,IAAA,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACR,IAAA,OAAO,CAAC;AACV;AAEA;AACsC;AAC/B,eAAe,SAAS,CAC7B,MAAgB,EAChB,EAAoE,EAAA;AAEpE,IAAA,MAAM,CAAC,GAAG,QAAQ,EAAE;AACpB,IAAA,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAS,EAAE,CAAM,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACjE,QAAA,OAAO,MAAM;IACf;IAAE,OAAO,CAAM,EAAE;AACf,QAAA,MAAM,CAAC,KAAK,CAAC,CAAA,MAAA,EAAS,CAAC,CAAA,sCAAA,EAAyC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC;AACpF,QAAA,MAAM,CAAC;IACT;AACF;;;;;;"}
@@ -1,4 +1,4 @@
1
- import type { MiLogger } from '@milaboratories/ts-helpers';
1
+ import type { MiLogger } from "@milaboratories/ts-helpers";
2
2
  /** Records all inputs and outputs of one's choice, so if the error happened
3
3
  * one can check how it was by just printing this structure. */
4
4
  export type Trace = Record<string, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"trace.js","sources":["../../src/local/trace.ts"],"sourcesContent":["import type { MiLogger } from '@milaboratories/ts-helpers';\n\n/** Records all inputs and outputs of one's choice, so if the error happened\n * one can check how it was by just printing this structure. */\nexport type Trace = Record<string, any>;\n\nexport function newTrace(): Trace {\n return {};\n}\n\nexport function trace(t: Trace, k: string, v: any) {\n t[k] = v;\n return v;\n}\n\n/** Creates a trace and runs a function with it. The function can record all its\n * logs or traces using `trace` fn. */\nexport async function withTrace<T>(\n logger: MiLogger,\n fn: (trace: (k: string, v: any) => typeof v, t: Trace) => Promise<T>,\n): Promise<T> {\n const t = newTrace();\n try {\n const result = await fn((k: string, v: any) => trace(t, k, v), t);\n return result;\n } catch (e: any) {\n logger.error(`error ${e} while doing traced operation, state: ${JSON.stringify(t)}`);\n throw e;\n }\n}\n"],"names":[],"mappings":"SAMgB,QAAQ,GAAA;AACtB,IAAA,OAAO,EAAE;AACX;SAEgB,KAAK,CAAC,CAAQ,EAAE,CAAS,EAAE,CAAM,EAAA;AAC/C,IAAA,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACR,IAAA,OAAO,CAAC;AACV;AAEA;AACsC;AAC/B,eAAe,SAAS,CAC7B,MAAgB,EAChB,EAAoE,EAAA;AAEpE,IAAA,MAAM,CAAC,GAAG,QAAQ,EAAE;AACpB,IAAA,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAS,EAAE,CAAM,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACjE,QAAA,OAAO,MAAM;IACf;IAAE,OAAO,CAAM,EAAE;AACf,QAAA,MAAM,CAAC,KAAK,CAAC,CAAA,MAAA,EAAS,CAAC,CAAA,sCAAA,EAAyC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC;AACpF,QAAA,MAAM,CAAC;IACT;AACF;;;;"}
1
+ {"version":3,"file":"trace.js","sources":["../../src/local/trace.ts"],"sourcesContent":["import type { MiLogger } from \"@milaboratories/ts-helpers\";\n\n/** Records all inputs and outputs of one's choice, so if the error happened\n * one can check how it was by just printing this structure. */\nexport type Trace = Record<string, any>;\n\nexport function newTrace(): Trace {\n return {};\n}\n\nexport function trace(t: Trace, k: string, v: any) {\n t[k] = v;\n return v;\n}\n\n/** Creates a trace and runs a function with it. The function can record all its\n * logs or traces using `trace` fn. */\nexport async function withTrace<T>(\n logger: MiLogger,\n fn: (trace: (k: string, v: any) => typeof v, t: Trace) => Promise<T>,\n): Promise<T> {\n const t = newTrace();\n try {\n const result = await fn((k: string, v: any) => trace(t, k, v), t);\n return result;\n } catch (e: any) {\n logger.error(`error ${e} while doing traced operation, state: ${JSON.stringify(t)}`);\n throw e;\n }\n}\n"],"names":[],"mappings":"SAMgB,QAAQ,GAAA;AACtB,IAAA,OAAO,EAAE;AACX;SAEgB,KAAK,CAAC,CAAQ,EAAE,CAAS,EAAE,CAAM,EAAA;AAC/C,IAAA,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACR,IAAA,OAAO,CAAC;AACV;AAEA;AACsC;AAC/B,eAAe,SAAS,CAC7B,MAAgB,EAChB,EAAoE,EAAA;AAEpE,IAAA,MAAM,CAAC,GAAG,QAAQ,EAAE;AACpB,IAAA,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAS,EAAE,CAAM,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACjE,QAAA,OAAO,MAAM;IACf;IAAE,OAAO,CAAM,EAAE;AACf,QAAA,MAAM,CAAC,KAAK,CAAC,CAAA,MAAA,EAAS,CAAC,CAAA,sCAAA,EAAyC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC;AACpF,QAAA,MAAM,CAAC;IACT;AACF;;;;"}
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var packageJson = {
4
- "pl-version": "1.44.1"};
4
+ "pl-version": "1.44.1"
5
+ };
5
6
 
6
7
  module.exports = packageJson;
7
8
  //# sourceMappingURL=package.json.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
1
+ {"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -1,5 +1,6 @@
1
1
  var packageJson = {
2
- "pl-version": "1.44.1"};
2
+ "pl-version": "1.44.1"
3
+ };
3
4
 
4
5
  export { packageJson as default };
5
6
  //# sourceMappingURL=package.json.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -1,5 +1,5 @@
1
- import type { StartedTestContainer } from 'testcontainers';
2
- import type { ConnectConfig } from 'ssh2';
1
+ import type { StartedTestContainer } from "testcontainers";
2
+ import type { ConnectConfig } from "ssh2";
3
3
  export declare const testAssetsPath: string;
4
4
  export declare function readPrivateKey(): string;
5
5
  export declare function initContainer(name: string): Promise<StartedTestContainer>;
@@ -1 +1 @@
1
- {"version":3,"file":"common-utils.d.ts","sourceRoot":"","sources":["../../../src/ssh/__tests__/common-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAI3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAK1C,eAAO,MAAM,cAAc,QAA2D,CAAC;AASvF,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAgB/E;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,oBAAoB;;;EAKtE;AAgBD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,oBAAoB,EAAE,KAAK,GAAE,OAAe,GAAG,aAAa,CAa1G;AAED,wBAAsB,OAAO,CAAC,SAAS,EAAE,oBAAoB,iBAE5D"}
1
+ {"version":3,"file":"common-utils.d.ts","sourceRoot":"","sources":["../../../src/ssh/__tests__/common-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAI3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAK1C,eAAO,MAAM,cAAc,QAA2D,CAAC;AASvF,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAe/E;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,oBAAoB;;;EAKtE;AAgBD,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,oBAAoB,EAC/B,KAAK,GAAE,OAAe,GACrB,aAAa,CAaf;AAED,wBAAsB,OAAO,CAAC,SAAS,EAAE,oBAAoB,iBAE5D"}
@@ -7,11 +7,14 @@ var zod = require('zod');
7
7
  //
8
8
  // Types
9
9
  //
10
- const PortPair = zod.z.object({
10
+ const PortPair = zod.z
11
+ .object({
11
12
  local: zod.z.number(),
12
13
  remote: zod.z.number(),
13
- }).passthrough();
14
- const SshPlPorts = zod.z.object({
14
+ })
15
+ .passthrough();
16
+ const SshPlPorts = zod.z
17
+ .object({
15
18
  grpc: PortPair,
16
19
  http: PortPair.optional(),
17
20
  monitoring: PortPair,
@@ -20,8 +23,10 @@ const SshPlPorts = zod.z.object({
20
23
  minioPort: PortPair,
21
24
  /** @deprecated */
22
25
  minioConsolePort: PortPair,
23
- }).passthrough();
24
- const ConnectionInfo = zod.z.object({
26
+ })
27
+ .passthrough();
28
+ const ConnectionInfo = zod.z
29
+ .object({
25
30
  plUser: zod.z.string(),
26
31
  plPassword: zod.z.string(),
27
32
  ports: SshPlPorts,
@@ -29,10 +34,11 @@ const ConnectionInfo = zod.z.object({
29
34
  // and in some deployments there won't be useGlobalAccess flag in the file.
30
35
  useGlobalAccess: zod.z.boolean().default(false),
31
36
  // We added the field afterwards, the pl backend was this version.
32
- plVersion: zod.z.string().default('1.18.3'),
37
+ plVersion: zod.z.string().default("1.18.3"),
33
38
  // It's true by default because it was added later and previous installation use minio.
34
39
  minioIsUsed: zod.z.boolean().default(true),
35
- }).passthrough();
40
+ })
41
+ .passthrough();
36
42
  //
37
43
  // Funcs
38
44
  //
@@ -1 +1 @@
1
- {"version":3,"file":"connection_info.cjs","sources":["../../src/ssh/connection_info.ts"],"sourcesContent":["/** We store all info about the connection on the server,\n * so that another client could read the file and connect from another machine. */\nimport { z } from 'zod';\n\n//\n// Types\n//\n\nexport const PortPair = z.object({\n local: z.number(),\n remote: z.number(),\n}).passthrough();\n/** The pair of ports for forwarding. */\nexport type PortPair = z.infer<typeof PortPair>;\n\nexport const SshPlPorts = z.object({\n grpc: PortPair,\n http: PortPair.optional(),\n monitoring: PortPair,\n debug: PortPair,\n /** @deprecated */\n minioPort: PortPair,\n /** @deprecated */\n minioConsolePort: PortPair,\n}).passthrough();\n/** All info about ports that are forwarded. */\nexport type SshPlPorts = z.infer<typeof SshPlPorts>;\n\nexport const ConnectionInfo = z.object({\n plUser: z.string(),\n plPassword: z.string(),\n ports: SshPlPorts,\n\n // It's false by default because it was added later,\n // and in some deployments there won't be useGlobalAccess flag in the file.\n useGlobalAccess: z.boolean().default(false),\n\n // We added the field afterwards, the pl backend was this version.\n plVersion: z.string().default('1.18.3'),\n\n // It's true by default because it was added later and previous installation use minio.\n minioIsUsed: z.boolean().default(true),\n}).passthrough();\n/** The content of the file that holds all the info about the connection on the remote server. */\nexport type ConnectionInfo = z.infer<typeof ConnectionInfo>;\n\n//\n// Funcs\n//\n\nexport function newConnectionInfo(\n plUser: string,\n plPassword: string,\n ports: SshPlPorts,\n useGlobalAccess: boolean,\n plVersion: string,\n minioIsUsed: boolean,\n): ConnectionInfo {\n return {\n plUser,\n plPassword,\n ports,\n useGlobalAccess,\n plVersion,\n minioIsUsed: minioIsUsed,\n };\n}\n\nexport function parseConnectionInfo(content: string): ConnectionInfo {\n return ConnectionInfo.parse(JSON.parse(content));\n}\n\nexport function stringifyConnectionInfo(conn: ConnectionInfo): string {\n return JSON.stringify(conn, undefined, 2);\n}\n"],"names":["z"],"mappings":";;;;AAAA;AACkF;AAGlF;AACA;AACA;AAEO,MAAM,QAAQ,GAAGA,KAAC,CAAC,MAAM,CAAC;AAC/B,IAAA,KAAK,EAAEA,KAAC,CAAC,MAAM,EAAE;AACjB,IAAA,MAAM,EAAEA,KAAC,CAAC,MAAM,EAAE;CACnB,CAAC,CAAC,WAAW;AAIP,MAAM,UAAU,GAAGA,KAAC,CAAC,MAAM,CAAC;AACjC,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE;AACzB,IAAA,UAAU,EAAE,QAAQ;AACpB,IAAA,KAAK,EAAE,QAAQ;;AAEf,IAAA,SAAS,EAAE,QAAQ;;AAEnB,IAAA,gBAAgB,EAAE,QAAQ;CAC3B,CAAC,CAAC,WAAW;AAIP,MAAM,cAAc,GAAGA,KAAC,CAAC,MAAM,CAAC;AACrC,IAAA,MAAM,EAAEA,KAAC,CAAC,MAAM,EAAE;AAClB,IAAA,UAAU,EAAEA,KAAC,CAAC,MAAM,EAAE;AACtB,IAAA,KAAK,EAAE,UAAU;;;IAIjB,eAAe,EAAEA,KAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;;IAG3C,SAAS,EAAEA,KAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;;IAGvC,WAAW,EAAEA,KAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CACvC,CAAC,CAAC,WAAW;AAId;AACA;AACA;AAEM,SAAU,iBAAiB,CAC/B,MAAc,EACd,UAAkB,EAClB,KAAiB,EACjB,eAAwB,EACxB,SAAiB,EACjB,WAAoB,EAAA;IAEpB,OAAO;QACL,MAAM;QACN,UAAU;QACV,KAAK;QACL,eAAe;QACf,SAAS;AACT,QAAA,WAAW,EAAE,WAAW;KACzB;AACH;AAEM,SAAU,mBAAmB,CAAC,OAAe,EAAA;IACjD,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAClD;AAEM,SAAU,uBAAuB,CAAC,IAAoB,EAAA;IAC1D,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AAC3C;;;;;;;;;"}
1
+ {"version":3,"file":"connection_info.cjs","sources":["../../src/ssh/connection_info.ts"],"sourcesContent":["/** We store all info about the connection on the server,\n * so that another client could read the file and connect from another machine. */\nimport { z } from \"zod\";\n\n//\n// Types\n//\n\nexport const PortPair = z\n .object({\n local: z.number(),\n remote: z.number(),\n })\n .passthrough();\n/** The pair of ports for forwarding. */\nexport type PortPair = z.infer<typeof PortPair>;\n\nexport const SshPlPorts = z\n .object({\n grpc: PortPair,\n http: PortPair.optional(),\n monitoring: PortPair,\n debug: PortPair,\n /** @deprecated */\n minioPort: PortPair,\n /** @deprecated */\n minioConsolePort: PortPair,\n })\n .passthrough();\n/** All info about ports that are forwarded. */\nexport type SshPlPorts = z.infer<typeof SshPlPorts>;\n\nexport const ConnectionInfo = z\n .object({\n plUser: z.string(),\n plPassword: z.string(),\n ports: SshPlPorts,\n\n // It's false by default because it was added later,\n // and in some deployments there won't be useGlobalAccess flag in the file.\n useGlobalAccess: z.boolean().default(false),\n\n // We added the field afterwards, the pl backend was this version.\n plVersion: z.string().default(\"1.18.3\"),\n\n // It's true by default because it was added later and previous installation use minio.\n minioIsUsed: z.boolean().default(true),\n })\n .passthrough();\n/** The content of the file that holds all the info about the connection on the remote server. */\nexport type ConnectionInfo = z.infer<typeof ConnectionInfo>;\n\n//\n// Funcs\n//\n\nexport function newConnectionInfo(\n plUser: string,\n plPassword: string,\n ports: SshPlPorts,\n useGlobalAccess: boolean,\n plVersion: string,\n minioIsUsed: boolean,\n): ConnectionInfo {\n return {\n plUser,\n plPassword,\n ports,\n useGlobalAccess,\n plVersion,\n minioIsUsed: minioIsUsed,\n };\n}\n\nexport function parseConnectionInfo(content: string): ConnectionInfo {\n return ConnectionInfo.parse(JSON.parse(content));\n}\n\nexport function stringifyConnectionInfo(conn: ConnectionInfo): string {\n return JSON.stringify(conn, undefined, 2);\n}\n"],"names":["z"],"mappings":";;;;AAAA;AACkF;AAGlF;AACA;AACA;AAEO,MAAM,QAAQ,GAAGA;AACrB,KAAA,MAAM,CAAC;AACN,IAAA,KAAK,EAAEA,KAAC,CAAC,MAAM,EAAE;AACjB,IAAA,MAAM,EAAEA,KAAC,CAAC,MAAM,EAAE;CACnB;AACA,KAAA,WAAW;AAIP,MAAM,UAAU,GAAGA;AACvB,KAAA,MAAM,CAAC;AACN,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE;AACzB,IAAA,UAAU,EAAE,QAAQ;AACpB,IAAA,KAAK,EAAE,QAAQ;;AAEf,IAAA,SAAS,EAAE,QAAQ;;AAEnB,IAAA,gBAAgB,EAAE,QAAQ;CAC3B;AACA,KAAA,WAAW;AAIP,MAAM,cAAc,GAAGA;AAC3B,KAAA,MAAM,CAAC;AACN,IAAA,MAAM,EAAEA,KAAC,CAAC,MAAM,EAAE;AAClB,IAAA,UAAU,EAAEA,KAAC,CAAC,MAAM,EAAE;AACtB,IAAA,KAAK,EAAE,UAAU;;;IAIjB,eAAe,EAAEA,KAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;;IAG3C,SAAS,EAAEA,KAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;;IAGvC,WAAW,EAAEA,KAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CACvC;AACA,KAAA,WAAW;AAId;AACA;AACA;AAEM,SAAU,iBAAiB,CAC/B,MAAc,EACd,UAAkB,EAClB,KAAiB,EACjB,eAAwB,EACxB,SAAiB,EACjB,WAAoB,EAAA;IAEpB,OAAO;QACL,MAAM;QACN,UAAU;QACV,KAAK;QACL,eAAe;QACf,SAAS;AACT,QAAA,WAAW,EAAE,WAAW;KACzB;AACH;AAEM,SAAU,mBAAmB,CAAC,OAAe,EAAA;IACjD,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAClD;AAEM,SAAU,uBAAuB,CAAC,IAAoB,EAAA;IAC1D,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AAC3C;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  /** We store all info about the connection on the server,
2
2
  * so that another client could read the file and connect from another machine. */
3
- import { z } from 'zod';
3
+ import { z } from "zod";
4
4
  export declare const PortPair: z.ZodObject<{
5
5
  local: z.ZodNumber;
6
6
  remote: z.ZodNumber;
@@ -1 +1 @@
1
- {"version":3,"file":"connection_info.d.ts","sourceRoot":"","sources":["../../src/ssh/connection_info.ts"],"names":[],"mappings":"AAAA;kFACkF;AAClF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,QAAQ;;;;;;;;;gCAGL,CAAC;AACjB,wCAAwC;AACxC,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKrB,kBAAkB;;;;;;;;;;;IAElB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAFlB,kBAAkB;;;;;;;;;;;IAElB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAFlB,kBAAkB;;;;;;;;;;;IAElB,kBAAkB;;;;;;;;;;;gCAEJ,CAAC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