@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
@@ -5,13 +5,13 @@ var node_crypto = require('node:crypto');
5
5
 
6
6
  /** Provides helper functions to work with supervisord */
7
7
  async function supervisorCtlStart(sshClient, remoteHome, arch) {
8
- const result = await supervisorExec(sshClient, remoteHome, arch, '--daemon');
8
+ const result = await supervisorExec(sshClient, remoteHome, arch, "--daemon");
9
9
  if (result.stderr) {
10
10
  throw new Error(`Can not run ssh Platforma ${result.stderr}`);
11
11
  }
12
12
  }
13
13
  async function supervisorStop(sshClient, remoteHome, arch) {
14
- const result = await supervisorExec(sshClient, remoteHome, arch, 'ctl shutdown');
14
+ const result = await supervisorExec(sshClient, remoteHome, arch, "ctl shutdown");
15
15
  if (result.stderr) {
16
16
  throw new Error(`Can not stop ssh Platforma ${result.stderr}`);
17
17
  }
@@ -28,7 +28,7 @@ function isSupervisordRunning(status) {
28
28
  async function supervisorStatus(logger, sshClient, remoteHome, arch) {
29
29
  let result;
30
30
  try {
31
- result = await supervisorExec(sshClient, remoteHome, arch, 'ctl status');
31
+ result = await supervisorExec(sshClient, remoteHome, arch, "ctl status");
32
32
  }
33
33
  catch (e) {
34
34
  return { execError: String(e) };
@@ -37,18 +37,18 @@ async function supervisorStatus(logger, sshClient, remoteHome, arch) {
37
37
  logger.info(`supervisord ctl status: stderr occurred: ${result.stderr}, stdout: ${result.stdout}`);
38
38
  return { rawResult: result };
39
39
  }
40
- const platforma = isProgramRunning(result.stdout, 'platforma');
41
- const minio = isProgramRunning(result.stdout, 'minio');
40
+ const platforma = isProgramRunning(result.stdout, "platforma");
41
+ const minio = isProgramRunning(result.stdout, "minio");
42
42
  const status = {
43
43
  rawResult: result,
44
44
  platforma,
45
45
  minio,
46
46
  };
47
47
  if (!status.minio) {
48
- logger.warn('Minio is not running on the server');
48
+ logger.warn("Minio is not running on the server");
49
49
  }
50
50
  if (!status.platforma) {
51
- logger.warn('Platforma is not running on the server');
51
+ logger.warn("Platforma is not running on the server");
52
52
  }
53
53
  return status;
54
54
  }
@@ -56,7 +56,7 @@ async function supervisorStatus(logger, sshClient, remoteHome, arch) {
56
56
  * docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings
57
57
  */
58
58
  function generateSupervisordConfig(supervisorRemotePort, remoteWorkDir, platformaConfigPath, plPath) {
59
- const password = node_crypto.randomBytes(16).toString('hex');
59
+ const password = node_crypto.randomBytes(16).toString("hex");
60
60
  const freePort = supervisorRemotePort;
61
61
  return `
62
62
  [supervisord]
@@ -88,8 +88,10 @@ redirect_stderr=true
88
88
  /** @deprecated, we use minio only on old deployments that existed before we remove minio,
89
89
  * for new servers use generation of the config above. */
90
90
  function generateSupervisordConfigWithMinio(minioStorageDir, minioEnvs, supervisorRemotePort, remoteWorkDir, platformaConfigPath, minioPath, plPath) {
91
- const minioEnvStr = Object.entries(minioEnvs).map(([key, value]) => `${key}="${value}"`).join(',');
92
- const password = node_crypto.randomBytes(16).toString('hex');
91
+ const minioEnvStr = Object.entries(minioEnvs)
92
+ .map(([key, value]) => `${key}="${value}"`)
93
+ .join(",");
94
+ const password = node_crypto.randomBytes(16).toString("hex");
93
95
  const freePort = supervisorRemotePort;
94
96
  return `
95
97
  [supervisord]
@@ -130,11 +132,11 @@ async function supervisorExec(sshClient, remoteHome, arch, command) {
130
132
  }
131
133
  function isProgramRunning(output, programName) {
132
134
  // eslint-disable-next-line no-control-regex
133
- const stripAnsi = (str) => str.replace(/\x1B\[[0-9;]*m/g, '');
135
+ const stripAnsi = (str) => str.replace(/\x1B\[[0-9;]*m/g, "");
134
136
  const cleanedOutput = stripAnsi(output);
135
- return cleanedOutput.split('\n').some((line) => {
137
+ return cleanedOutput.split("\n").some((line) => {
136
138
  const [name, status] = line.trim().split(/\s{2,}/); // Split string by 2 spaces.
137
- return name === programName && status === 'Running';
139
+ return name === programName && status === "Running";
138
140
  });
139
141
  }
140
142
 
@@ -1 +1 @@
1
- {"version":3,"file":"supervisord.cjs","sources":["../../src/ssh/supervisord.ts"],"sourcesContent":["/** Provides helper functions to work with supervisord */\n\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport * as plpath from './pl_paths';\nimport type { SshClient, SshExecResult } from './ssh';\nimport { randomBytes } from 'node:crypto';\n\nexport async function supervisorCtlStart(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n) {\n const result = await supervisorExec(sshClient, remoteHome, arch, '--daemon');\n\n if (result.stderr) {\n throw new Error(`Can not run ssh Platforma ${result.stderr}`);\n }\n}\n\nexport async function supervisorStop(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n) {\n const result = await supervisorExec(sshClient, remoteHome, arch, 'ctl shutdown');\n\n if (result.stderr) {\n throw new Error(`Can not stop ssh Platforma ${result.stderr}`);\n }\n}\n\n/** Provides a simple true/false response got from supervisord status\n * along with a debug info that could be showed in error logs (raw response from the command, parsed response etc). */\nexport type SupervisorStatus = {\n platforma?: boolean;\n minio?: boolean;\n rawResult?: SshExecResult;\n execError?: string;\n};\n\nexport function isAllAlive(status: SupervisorStatus, shouldUseMinio: boolean) {\n if (shouldUseMinio) {\n return status.platforma && status.minio;\n }\n\n return status.platforma;\n}\n\nexport function isSupervisordRunning(status: SupervisorStatus) {\n return status.execError === undefined;\n}\n\nexport async function supervisorStatus(\n logger: MiLogger,\n sshClient: SshClient,\n remoteHome: string, arch: string,\n): Promise<SupervisorStatus> {\n let result: SshExecResult;\n try {\n result = await supervisorExec(sshClient, remoteHome, arch, 'ctl status');\n } catch (e: unknown) {\n return { execError: String(e) };\n }\n\n if (result.stderr) {\n logger.info(`supervisord ctl status: stderr occurred: ${result.stderr}, stdout: ${result.stdout}`);\n\n return { rawResult: result };\n }\n\n const platforma = isProgramRunning(result.stdout, 'platforma');\n const minio = isProgramRunning(result.stdout, 'minio');\n const status: SupervisorStatus = {\n rawResult: result,\n platforma,\n minio,\n };\n\n if (!status.minio) {\n logger.warn('Minio is not running on the server');\n }\n\n if (!status.platforma) {\n logger.warn('Platforma is not running on the server');\n }\n\n return status;\n}\n\n/** Generates the config for supervisord.\n * docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings\n */\nexport function generateSupervisordConfig(\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n plPath: string,\n) {\n const password = randomBytes(16).toString('hex');\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\nstdout_logfile=${remoteWorkDir}/platforma_cli_logs.log\nstdout_logfile_maxbytes=10000\nstdout_logfile_backups=10\nredirect_stderr=true\n`;\n}\n\n/** @deprecated, we use minio only on old deployments that existed before we remove minio,\n * for new servers use generation of the config above. */\nexport function generateSupervisordConfigWithMinio(\n minioStorageDir: string,\n minioEnvs: Record<string, string>,\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n\n minioPath: string,\n plPath: string,\n) {\n const minioEnvStr = Object.entries(minioEnvs).map(([key, value]) => `${key}=\"${value}\"`).join(',');\n const password = randomBytes(16).toString('hex');\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ndepends_on=minio\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\n\n[program:minio]\nautostart=true\nenvironment=${minioEnvStr}\ncommand=${minioPath} server ${minioStorageDir}\ndirectory=${remoteWorkDir}\nautorestart=true\n`;\n}\n\nexport async function supervisorExec(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n command: string,\n) {\n const supervisorCmd = plpath.supervisorBin(remoteHome, arch);\n const supervisorConf = plpath.supervisorConf(remoteHome);\n\n const cmd = `${supervisorCmd} --configuration ${supervisorConf} ${command}`;\n return await sshClient.exec(cmd);\n}\n\nfunction isProgramRunning(output: string, programName: string) {\n // eslint-disable-next-line no-control-regex\n const stripAnsi = (str: string) => str.replace(/\\x1B\\[[0-9;]*m/g, '');\n\n const cleanedOutput = stripAnsi(output);\n\n return cleanedOutput.split('\\n').some((line) => {\n const [name, status] = line.trim().split(/\\s{2,}/); // Split string by 2 spaces.\n\n return name ===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,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAI;AAC7C,QAAA,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAEnD,QAAA,OAAO,IAAI,KAAK,WAAW,IAAI,MAAM,KAAK,SAAS;AACrD,IAAA,CAAC,CAAC;AACJ;;;;;;;;;;;"}
1
+ {"version":3,"file":"supervisord.cjs","sources":["../../src/ssh/supervisord.ts"],"sourcesContent":["/** Provides helper functions to work with supervisord */\n\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport * as plpath from \"./pl_paths\";\nimport type { SshClient, SshExecResult } from \"./ssh\";\nimport { randomBytes } from \"node:crypto\";\n\nexport async function supervisorCtlStart(sshClient: SshClient, remoteHome: string, arch: string) {\n const result = await supervisorExec(sshClient, remoteHome, arch, \"--daemon\");\n\n if (result.stderr) {\n throw new Error(`Can not run ssh Platforma ${result.stderr}`);\n }\n}\n\nexport async function supervisorStop(sshClient: SshClient, remoteHome: string, arch: string) {\n const result = await supervisorExec(sshClient, remoteHome, arch, \"ctl shutdown\");\n\n if (result.stderr) {\n throw new Error(`Can not stop ssh Platforma ${result.stderr}`);\n }\n}\n\n/** Provides a simple true/false response got from supervisord status\n * along with a debug info that could be showed in error logs (raw response from the command, parsed response etc). */\nexport type SupervisorStatus = {\n platforma?: boolean;\n minio?: boolean;\n rawResult?: SshExecResult;\n execError?: string;\n};\n\nexport function isAllAlive(status: SupervisorStatus, shouldUseMinio: boolean) {\n if (shouldUseMinio) {\n return status.platforma && status.minio;\n }\n\n return status.platforma;\n}\n\nexport function isSupervisordRunning(status: SupervisorStatus) {\n return status.execError === undefined;\n}\n\nexport async function supervisorStatus(\n logger: MiLogger,\n sshClient: SshClient,\n remoteHome: string,\n arch: string,\n): Promise<SupervisorStatus> {\n let result: SshExecResult;\n try {\n result = await supervisorExec(sshClient, remoteHome, arch, \"ctl status\");\n } catch (e: unknown) {\n return { execError: String(e) };\n }\n\n if (result.stderr) {\n logger.info(\n `supervisord ctl status: stderr occurred: ${result.stderr}, stdout: ${result.stdout}`,\n );\n\n return { rawResult: result };\n }\n\n const platforma = isProgramRunning(result.stdout, \"platforma\");\n const minio = isProgramRunning(result.stdout, \"minio\");\n const status: SupervisorStatus = {\n rawResult: result,\n platforma,\n minio,\n };\n\n if (!status.minio) {\n logger.warn(\"Minio is not running on the server\");\n }\n\n if (!status.platforma) {\n logger.warn(\"Platforma is not running on the server\");\n }\n\n return status;\n}\n\n/** Generates the config for supervisord.\n * docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings\n */\nexport function generateSupervisordConfig(\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n plPath: string,\n) {\n const password = randomBytes(16).toString(\"hex\");\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\nstdout_logfile=${remoteWorkDir}/platforma_cli_logs.log\nstdout_logfile_maxbytes=10000\nstdout_logfile_backups=10\nredirect_stderr=true\n`;\n}\n\n/** @deprecated, we use minio only on old deployments that existed before we remove minio,\n * for new servers use generation of the config above. */\nexport function generateSupervisordConfigWithMinio(\n minioStorageDir: string,\n minioEnvs: Record<string, string>,\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n\n minioPath: string,\n plPath: string,\n) {\n const minioEnvStr = Object.entries(minioEnvs)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(\",\");\n const password = randomBytes(16).toString(\"hex\");\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ndepends_on=minio\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\n\n[program:minio]\nautostart=true\nenvironment=${minioEnvStr}\ncommand=${minioPath} server ${minioStorageDir}\ndirectory=${remoteWorkDir}\nautorestart=true\n`;\n}\n\nexport async function supervisorExec(\n sshClient: SshClient,\n remoteHome: string,\n arch: string,\n command: string,\n) {\n const supervisorCmd = plpath.supervisorBin(remoteHome, arch);\n const supervisorConf = plpath.supervisorConf(remoteHome);\n\n const cmd = `${supervisorCmd} --configuration ${supervisorConf} ${command}`;\n return await sshClient.exec(cmd);\n}\n\nfunction isProgramRunning(output: string, programName: string) {\n // eslint-disable-next-line no-control-regex\n const stripAnsi = (str: string) => str.replace(/\\x1B\\[[0-9;]*m/g, \"\");\n\n const cleanedOutput = stripAnsi(output);\n\n return cleanedOutput.split(\"\\n\").some((line) => {\n const [name, status] = line.trim().split(/\\s{2,}/); // Split string by 2 spaces.\n\n return name === programName && status === \"Running\";\n });\n}\n"],"names":["randomBytes","plpath.supervisorBin","plpath.supervisorConf"],"mappings":";;;;;AAAA;AAOO,eAAe,kBAAkB,CAAC,SAAoB,EAAE,UAAkB,EAAE,IAAY,EAAA;AAC7F,IAAA,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC;AAE5E,IAAA,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,CAAA,0BAAA,EAA6B,MAAM,CAAC,MAAM,CAAA,CAAE,CAAC;IAC/D;AACF;AAEO,e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C,aAAa,CAAA;;UAEb,aAAa,CAAA;;;iBAGN,QAAQ;;WAEd,QAAQ;;;6BAGU,QAAQ;;WAE1B,QAAQ;;;;;AAKT,QAAA,EAAA,MAAM,aAAa,mBAAmB;YACpC,aAAa;;;;;cAKX,WAAW;AACf,QAAA,EAAA,SAAS,WAAW,eAAe;YACjC,aAAa;;CAExB;AACD;AAEO,eAAe,cAAc,CAClC,SAAoB,EACpB,UAAkB,EAClB,IAAY,EACZ,OAAe,EAAA;IAEf,MAAM,aAAa,GAAGC,sBAAoB,CAAC,UAAU,EAAE,IAAI,CAAC;IAC5D,MAAM,cAAc,GAAGC,uBAAqB,CAAC,UAAU,CAAC;IAExD,MAAM,GAAG,GAAG,CAAA,EAAG,aAAa,oBAAoB,cAAc,CAAA,CAAA,EAAI,OAAO,CAAA,CAAE;AAC3E,IAAA,OAAO,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;AAClC;AAEA,SAAS,gBAAgB,CAAC,MAAc,EAAE,WAAmB,EAAA;;AAE3D,IAAA,MAAM,SAAS,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;AAErE,IAAA,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC;AAEvC,IAAA,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAI;AAC7C,QAAA,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAEnD,QAAA,OAAO,IAAI,KAAK,WAAW,IAAI,MAAM,KAAK,SAAS;AACrD,IAAA,CAAC,CAAC;AACJ;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  /** Provides helper functions to work with supervisord */
2
- import type { MiLogger } from '@milaboratories/ts-helpers';
3
- import type { SshClient, SshExecResult } from './ssh';
2
+ import type { MiLogger } from "@milaboratories/ts-helpers";
3
+ import type { SshClient, SshExecResult } from "./ssh";
4
4
  export declare function supervisorCtlStart(sshClient: SshClient, remoteHome: string, arch: string): Promise<void>;
5
5
  export declare function supervisorStop(sshClient: SshClient, remoteHome: string, arch: string): Promise<void>;
6
6
  /** Provides a simple true/false response got from supervisord status
@@ -1 +1 @@
1
- {"version":3,"file":"supervisord.d.ts","sourceRoot":"","sources":["../../src/ssh/supervisord.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtD,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAOjC;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAOjC;AAED;sHACsH;AACtH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,OAAO,uBAM3E;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,WAE5D;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,QAAQ,EAChB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CA+B3B;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,oBAAoB,EAAE,MAAM,EAC5B,aAAa,EAAE,MAAM,EACrB,mBAAmB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ChB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,gBAAgB,CAAC,CAiC3B;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,oBAAoB,EAAE,MAAM,EAC5B,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,MAAM,EAC3B,MAAM,EAAE,MAAM,UA+Bf;AAED;yDACyD;AACzD,wBAAgB,kCAAkC,CAChD,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,oBAAoB,EAAE,MAAM,EAC5B,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,MAAM,EAE3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,UAsCf;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,0BAOhB"}
@@ -3,13 +3,13 @@ import { randomBytes } from 'node:crypto';
3
3
 
4
4
  /** Provides helper functions to work with supervisord */
5
5
  async function supervisorCtlStart(sshClient, remoteHome, arch) {
6
- const result = await supervisorExec(sshClient, remoteHome, arch, '--daemon');
6
+ const result = await supervisorExec(sshClient, remoteHome, arch, "--daemon");
7
7
  if (result.stderr) {
8
8
  throw new Error(`Can not run ssh Platforma ${result.stderr}`);
9
9
  }
10
10
  }
11
11
  async function supervisorStop(sshClient, remoteHome, arch) {
12
- const result = await supervisorExec(sshClient, remoteHome, arch, 'ctl shutdown');
12
+ const result = await supervisorExec(sshClient, remoteHome, arch, "ctl shutdown");
13
13
  if (result.stderr) {
14
14
  throw new Error(`Can not stop ssh Platforma ${result.stderr}`);
15
15
  }
@@ -26,7 +26,7 @@ function isSupervisordRunning(status) {
26
26
  async function supervisorStatus(logger, sshClient, remoteHome, arch) {
27
27
  let result;
28
28
  try {
29
- result = await supervisorExec(sshClient, remoteHome, arch, 'ctl status');
29
+ result = await supervisorExec(sshClient, remoteHome, arch, "ctl status");
30
30
  }
31
31
  catch (e) {
32
32
  return { execError: String(e) };
@@ -35,18 +35,18 @@ async function supervisorStatus(logger, sshClient, remoteHome, arch) {
35
35
  logger.info(`supervisord ctl status: stderr occurred: ${result.stderr}, stdout: ${result.stdout}`);
36
36
  return { rawResult: result };
37
37
  }
38
- const platforma = isProgramRunning(result.stdout, 'platforma');
39
- const minio = isProgramRunning(result.stdout, 'minio');
38
+ const platforma = isProgramRunning(result.stdout, "platforma");
39
+ const minio = isProgramRunning(result.stdout, "minio");
40
40
  const status = {
41
41
  rawResult: result,
42
42
  platforma,
43
43
  minio,
44
44
  };
45
45
  if (!status.minio) {
46
- logger.warn('Minio is not running on the server');
46
+ logger.warn("Minio is not running on the server");
47
47
  }
48
48
  if (!status.platforma) {
49
- logger.warn('Platforma is not running on the server');
49
+ logger.warn("Platforma is not running on the server");
50
50
  }
51
51
  return status;
52
52
  }
@@ -54,7 +54,7 @@ async function supervisorStatus(logger, sshClient, remoteHome, arch) {
54
54
  * docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings
55
55
  */
56
56
  function generateSupervisordConfig(supervisorRemotePort, remoteWorkDir, platformaConfigPath, plPath) {
57
- const password = randomBytes(16).toString('hex');
57
+ const password = randomBytes(16).toString("hex");
58
58
  const freePort = supervisorRemotePort;
59
59
  return `
60
60
  [supervisord]
@@ -86,8 +86,10 @@ redirect_stderr=true
86
86
  /** @deprecated, we use minio only on old deployments that existed before we remove minio,
87
87
  * for new servers use generation of the config above. */
88
88
  function generateSupervisordConfigWithMinio(minioStorageDir, minioEnvs, supervisorRemotePort, remoteWorkDir, platformaConfigPath, minioPath, plPath) {
89
- const minioEnvStr = Object.entries(minioEnvs).map(([key, value]) => `${key}="${value}"`).join(',');
90
- const password = randomBytes(16).toString('hex');
89
+ const minioEnvStr = Object.entries(minioEnvs)
90
+ .map(([key, value]) => `${key}="${value}"`)
91
+ .join(",");
92
+ const password = randomBytes(16).toString("hex");
91
93
  const freePort = supervisorRemotePort;
92
94
  return `
93
95
  [supervisord]
@@ -128,11 +130,11 @@ async function supervisorExec(sshClient, remoteHome, arch, command) {
128
130
  }
129
131
  function isProgramRunning(output, programName) {
130
132
  // eslint-disable-next-line no-control-regex
131
- const stripAnsi = (str) => str.replace(/\x1B\[[0-9;]*m/g, '');
133
+ const stripAnsi = (str) => str.replace(/\x1B\[[0-9;]*m/g, "");
132
134
  const cleanedOutput = stripAnsi(output);
133
- return cleanedOutput.split('\n').some((line) => {
135
+ return cleanedOutput.split("\n").some((line) => {
134
136
  const [name, status] = line.trim().split(/\s{2,}/); // Split string by 2 spaces.
135
- return name === programName && status === 'Running';
137
+ return name === programName && status === "Running";
136
138
  });
137
139
  }
138
140
 
@@ -1 +1 @@
1
- {"version":3,"file":"supervisord.js","sources":["../../src/ssh/supervisord.ts"],"sourcesContent":["/** Provides helper functions to work with supervisord */\n\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport * as plpath from './pl_paths';\nimport type { SshClient, SshExecResult } from './ssh';\nimport { randomBytes } from 'node:crypto';\n\nexport async function supervisorCtlStart(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n) {\n const result = await supervisorExec(sshClient, remoteHome, arch, '--daemon');\n\n if (result.stderr) {\n throw new Error(`Can not run ssh Platforma ${result.stderr}`);\n }\n}\n\nexport async function supervisorStop(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n) {\n const result = await supervisorExec(sshClient, remoteHome, arch, 'ctl shutdown');\n\n if (result.stderr) {\n throw new Error(`Can not stop ssh Platforma ${result.stderr}`);\n }\n}\n\n/** Provides a simple true/false response got from supervisord status\n * along with a debug info that could be showed in error logs (raw response from the command, parsed response etc). */\nexport type SupervisorStatus = {\n platforma?: boolean;\n minio?: boolean;\n rawResult?: SshExecResult;\n execError?: string;\n};\n\nexport function isAllAlive(status: SupervisorStatus, shouldUseMinio: boolean) {\n if (shouldUseMinio) {\n return status.platforma && status.minio;\n }\n\n return status.platforma;\n}\n\nexport function isSupervisordRunning(status: SupervisorStatus) {\n return status.execError === undefined;\n}\n\nexport async function supervisorStatus(\n logger: MiLogger,\n sshClient: SshClient,\n remoteHome: string, arch: string,\n): Promise<SupervisorStatus> {\n let result: SshExecResult;\n try {\n result = await supervisorExec(sshClient, remoteHome, arch, 'ctl status');\n } catch (e: unknown) {\n return { execError: String(e) };\n }\n\n if (result.stderr) {\n logger.info(`supervisord ctl status: stderr occurred: ${result.stderr}, stdout: ${result.stdout}`);\n\n return { rawResult: result };\n }\n\n const platforma = isProgramRunning(result.stdout, 'platforma');\n const minio = isProgramRunning(result.stdout, 'minio');\n const status: SupervisorStatus = {\n rawResult: result,\n platforma,\n minio,\n };\n\n if (!status.minio) {\n logger.warn('Minio is not running on the server');\n }\n\n if (!status.platforma) {\n logger.warn('Platforma is not running on the server');\n }\n\n return status;\n}\n\n/** Generates the config for supervisord.\n * docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings\n */\nexport function generateSupervisordConfig(\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n plPath: string,\n) {\n const password = randomBytes(16).toString('hex');\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\nstdout_logfile=${remoteWorkDir}/platforma_cli_logs.log\nstdout_logfile_maxbytes=10000\nstdout_logfile_backups=10\nredirect_stderr=true\n`;\n}\n\n/** @deprecated, we use minio only on old deployments that existed before we remove minio,\n * for new servers use generation of the config above. */\nexport function generateSupervisordConfigWithMinio(\n minioStorageDir: string,\n minioEnvs: Record<string, string>,\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n\n minioPath: string,\n plPath: string,\n) {\n const minioEnvStr = Object.entries(minioEnvs).map(([key, value]) => `${key}=\"${value}\"`).join(',');\n const password = randomBytes(16).toString('hex');\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ndepends_on=minio\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\n\n[program:minio]\nautostart=true\nenvironment=${minioEnvStr}\ncommand=${minioPath} server ${minioStorageDir}\ndirectory=${remoteWorkDir}\nautorestart=true\n`;\n}\n\nexport async function supervisorExec(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n command: string,\n) {\n const supervisorCmd = plpath.supervisorBin(remoteHome, arch);\n const supervisorConf = plpath.supervisorConf(remoteHome);\n\n const cmd = `${supervisorCmd} --configuration ${supervisorConf} ${command}`;\n return await sshClient.exec(cmd);\n}\n\nfunction isProgramRunning(output: string, programName: string) {\n // eslint-disable-next-line no-control-regex\n const stripAnsi = (str: string) => str.replace(/\\x1B\\[[0-9;]*m/g, '');\n\n const cleanedOutput = stripAnsi(output);\n\n return cleanedOutput.split('\\n').some((line) => {\n const [name, status] = line.trim().split(/\\s{2,}/); // Split string by 2 spaces.\n\n return name === programName && status === 'Running';\n });\n}\n"],"names":["plpath.supervisorBin","supervisorConf","plpath.supervisorConf"],"mappings":";;;AAAA;AAOO,eAAe,kBAAkB,CACtC,SAAoB,EACpB,UAAkB,EAAE,IAAY,EAAA;AAEhC,IAAA,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,UAAU,EA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I,MAAM,KAAK,SAAS;AACrD,IAAA,CAAC,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"supervisord.js","sources":["../../src/ssh/supervisord.ts"],"sourcesContent":["/** Provides helper functions to work with supervisord */\n\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport * as plpath from \"./pl_paths\";\nimport type { SshClient, SshExecResult } from \"./ssh\";\nimport { randomBytes } from \"node:crypto\";\n\nexport async function supervisorCtlStart(sshClient: SshClient, remoteHome: string, arch: string) {\n const result = await supervisorExec(sshClient, remoteHome, arch, \"--daemon\");\n\n if (result.stderr) {\n throw new Error(`Can not run ssh Platforma ${result.stderr}`);\n }\n}\n\nexport async function supervisorStop(sshClient: SshClient, remoteHome: string, arch: string) {\n const result = await supervisorExec(sshClient, remoteHome, arch, \"ctl shutdown\");\n\n if (result.stderr) {\n throw new Error(`Can not stop ssh Platforma ${result.stderr}`);\n }\n}\n\n/** Provides a simple true/false response got from supervisord status\n * along with a debug info that could be showed in error logs (raw response from the command, parsed response etc). */\nexport type SupervisorStatus = {\n platforma?: boolean;\n minio?: boolean;\n rawResult?: SshExecResult;\n execError?: string;\n};\n\nexport function isAllAlive(status: SupervisorStatus, shouldUseMinio: boolean) {\n if (shouldUseMinio) {\n return status.platforma && status.minio;\n }\n\n return status.platforma;\n}\n\nexport function isSupervisordRunning(status: SupervisorStatus) {\n return status.execError === undefined;\n}\n\nexport async function supervisorStatus(\n logger: MiLogger,\n sshClient: SshClient,\n remoteHome: string,\n arch: string,\n): Promise<SupervisorStatus> {\n let result: SshExecResult;\n try {\n result = await supervisorExec(sshClient, remoteHome, arch, \"ctl status\");\n } catch (e: unknown) {\n return { execError: String(e) };\n }\n\n if (result.stderr) {\n logger.info(\n `supervisord ctl status: stderr occurred: ${result.stderr}, stdout: ${result.stdout}`,\n );\n\n return { rawResult: result };\n }\n\n const platforma = isProgramRunning(result.stdout, \"platforma\");\n const minio = isProgramRunning(result.stdout, \"minio\");\n const status: SupervisorStatus = {\n rawResult: result,\n platforma,\n minio,\n };\n\n if (!status.minio) {\n logger.warn(\"Minio is not running on the server\");\n }\n\n if (!status.platforma) {\n logger.warn(\"Platforma is not running on the server\");\n }\n\n return status;\n}\n\n/** Generates the config for supervisord.\n * docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings\n */\nexport function generateSupervisordConfig(\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n plPath: string,\n) {\n const password = randomBytes(16).toString(\"hex\");\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\nstdout_logfile=${remoteWorkDir}/platforma_cli_logs.log\nstdout_logfile_maxbytes=10000\nstdout_logfile_backups=10\nredirect_stderr=true\n`;\n}\n\n/** @deprecated, we use minio only on old deployments that existed before we remove minio,\n * for new servers use generation of the config above. */\nexport function generateSupervisordConfigWithMinio(\n minioStorageDir: string,\n minioEnvs: Record<string, string>,\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n\n minioPath: string,\n plPath: string,\n) {\n const minioEnvStr = Object.entries(minioEnvs)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(\",\");\n const password = randomBytes(16).toString(\"hex\");\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ndepends_on=minio\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\n\n[program:minio]\nautostart=true\nenvironment=${minioEnvStr}\ncommand=${minioPath} server ${minioStorageDir}\ndirectory=${remoteWorkDir}\nautorestart=true\n`;\n}\n\nexport async function supervisorExec(\n sshClient: SshClient,\n remoteHome: string,\n arch: string,\n command: string,\n) {\n const supervisorCmd = plpath.supervisorBin(remoteHome, arch);\n const supervisorConf = plpath.supervisorConf(remoteHome);\n\n const cmd = `${supervisorCmd} --configuration ${supervisorConf} ${command}`;\n return await sshClient.exec(cmd);\n}\n\nfunction isProgramRunning(output: string, programName: string) {\n // eslint-disable-next-line no-control-regex\n const stripAnsi = (str: string) => str.replace(/\\x1B\\[[0-9;]*m/g, \"\");\n\n const cleanedOutput = stripAnsi(output);\n\n return cleanedOutput.split(\"\\n\").some((line) => {\n const [name, status] = line.trim().split(/\\s{2,}/); // Split string by 2 spaces.\n\n return name === programName && status === \"Running\";\n });\n}\n"],"names":["plpath.supervisorBin","supervisorConf","plpath.supervisorConf"],"mappings":";;;AAAA;AAOO,eAAe,kBAAkB,CAAC,SAAoB,EAAE,UAAkB,EAAE,IAAY,EAAA;AAC7F,IAAA,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC;AAE5E,IAAA,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,CAAA,0BAAA,EAA6B,MAAM,CAAC,MAAM,CAAA,CAAE,CAAC;IAC/D;AACF;AAEO,eAAe,cAAc,CAAC,SAAoB,EAAE,UAAkB,EAAE,IAAY,EAAA;AACzF,IAAA,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,CAAC;AAEhF,IAAA,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,CAAA,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AAe,cAAc,CAClC,SAAoB,EACpB,UAAkB,EAClB,IAAY,EACZ,OAAe,EAAA;IAEf,MAAM,aAAa,GAAGA,aAAoB,CAAC,UAAU,EAAE,IAAI,CAAC;IAC5D,MAAMC,gBAAc,GAAGC,cAAqB,CAAC,UAAU,CAAC;IAExD,MAAM,GAAG,GAAG,CAAA,EAAG,aAAa,oBAAoBD,gBAAc,CAAA,CAAA,EAAI,OAAO,CAAA,CAAE;AAC3E,IAAA,OAAO,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;AAClC;AAEA,SAAS,gBAAgB,CAAC,MAAc,EAAE,WAAmB,EAAA;;AAE3D,IAAA,MAAM,SAAS,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;AAErE,IAAA,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC;AAEvC,IAAA,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAI;AAC7C,QAAA,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAEnD,QAAA,OAAO,IAAI,KAAK,WAAW,IAAI,MAAM,KAAK,SAAS;AACrD,IAAA,CAAC,CAAC;AACJ;;;;"}
package/package.json CHANGED
@@ -1,21 +1,9 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-deployments",
3
- "version": "2.15.7",
4
- "pl-version": "1.44.1",
3
+ "version": "2.15.8",
5
4
  "description": "MiLaboratories Platforma Backend code service run wrapper",
6
- "engines": {
7
- "node": ">=22.19.0"
8
- },
9
- "types": "./dist/index.d.ts",
10
- "main": "./dist/index.cjs",
11
- "module": "./dist/index.js",
12
- "exports": {
13
- ".": {
14
- "types": "./dist/index.d.ts",
15
- "require": "./dist/index.cjs",
16
- "import": "./dist/index.js"
17
- }
18
- },
5
+ "keywords": [],
6
+ "license": "UNLICENSED",
19
7
  "files": [
20
8
  "./dist/**/*",
21
9
  "./src/**/*",
@@ -25,46 +13,59 @@
25
13
  "assets",
26
14
  "postinstall.js"
27
15
  ],
28
- "keywords": [],
29
- "license": "UNLICENSED",
16
+ "main": "./dist/index.cjs",
17
+ "module": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "require": "./dist/index.cjs",
23
+ "import": "./dist/index.js"
24
+ }
25
+ },
26
+ "dependencies": {
27
+ "decompress": "^4.2.1",
28
+ "ssh2": "^1.16.0",
29
+ "tar": "^7.4.3",
30
+ "undici": "~7.16.0",
31
+ "upath": "^2.0.1",
32
+ "yaml": "^2.8.0",
33
+ "zod": "~3.23.8",
34
+ "@milaboratories/pl-config": "1.7.12",
35
+ "@milaboratories/pl-http": "1.2.1",
36
+ "@milaboratories/pl-model-common": "1.24.4",
37
+ "@milaboratories/ts-helpers": "1.7.1"
38
+ },
30
39
  "devDependencies": {
31
40
  "@types/decompress": "^4.2.7",
32
41
  "@types/node": "~24.5.2",
33
42
  "@types/ssh2": "^1.15.5",
34
43
  "@vitest/coverage-istanbul": "^4.0.16",
35
- "eslint": "^9.25.1",
36
44
  "testcontainers": "^10.18.0",
37
45
  "tsconfig-paths": "^4.2.0",
38
46
  "typescript": "~5.6.3",
39
47
  "utility-types": "^3.11.0",
40
48
  "vitest": "^4.0.16",
49
+ "@milaboratories/build-configs": "1.4.1",
41
50
  "@milaboratories/ts-configs": "1.2.0",
42
- "@milaboratories/eslint-config": "1.0.5",
43
- "@milaboratories/build-configs": "1.4.0",
44
- "@milaboratories/ts-builder": "1.2.4"
51
+ "@milaboratories/ts-builder": "1.2.5"
45
52
  },
46
- "dependencies": {
47
- "decompress": "^4.2.1",
48
- "ssh2": "^1.16.0",
49
- "tar": "^7.4.3",
50
- "undici": "~7.16.0",
51
- "upath": "^2.0.1",
52
- "yaml": "^2.8.0",
53
- "zod": "~3.23.8",
54
- "@milaboratories/ts-helpers": "1.7.0",
55
- "@milaboratories/pl-http": "1.2.0",
56
- "@milaboratories/pl-model-common": "1.24.3",
57
- "@milaboratories/pl-config": "1.7.11"
53
+ "engines": {
54
+ "node": ">=22.19.0"
58
55
  },
56
+ "pl-version": "1.44.1",
59
57
  "scripts": {
60
- "type-check": "ts-builder types --target node",
61
58
  "build": "ts-builder build --target node",
62
59
  "watch": "ts-builder build --target node --watch",
63
- "lint": "eslint .",
60
+ "check": "ts-builder check --target node",
61
+ "formatter:check": "ts-builder formatter --check",
62
+ "linter:check": "ts-builder linter --check",
63
+ "types:check": "ts-builder type-check --target node",
64
64
  "test": "vitest run --coverage",
65
65
  "do-pack": "rm -rf src/.test && rm -f *.tgz && pnpm pack && mv *.tgz package.tgz",
66
66
  "cleanup-docker": "docker container stop pl-ssh-test-pl || true && docker container stop pl-ssh-test-ssh || true && docker container rm -f pl-ssh-test-pl || true && docker container rm -f pl-ssh-test-ssh || true && docker image rm -f pl-ssh-test-container-ssh:1.0.0 || true && docker image rm -f pl-ssh-test-container-pl:1.0.0 || true",
67
67
  "dev-docker": "docker build --tag pl-ssh-dev:local . && docker run -p 4343:22 pl-ssh-dev:local",
68
- "exec-dev-docker": "docker exec -ti $(docker ps --format=json | jq -r 'select(.Image == \"pl-ssh-dev:local\").ID') bash"
68
+ "exec-dev-docker": "docker exec -ti $(docker ps --format=json | jq -r 'select(.Image == \"pl-ssh-dev:local\").ID') bash",
69
+ "fmt": "ts-builder format"
69
70
  }
70
71
  }
@@ -1,42 +1,42 @@
1
- export const OSes = ['linux', 'macos', 'windows'] as const;
1
+ export const OSes = ["linux", "macos", "windows"] as const;
2
2
  export type OSType = (typeof OSes)[number];
3
3
 
4
4
  /** @param osName - should be the thing returned from either {@link os.platform())} or `uname -s` */
5
5
  export function newOs(osName: string): OSType {
6
6
  switch (osName.toLowerCase()) {
7
- case 'darwin':
8
- return 'macos';
9
- case 'linux':
10
- return 'linux';
11
- case 'win32':
12
- return 'windows';
7
+ case "darwin":
8
+ return "macos";
9
+ case "linux":
10
+ return "linux";
11
+ case "win32":
12
+ return "windows";
13
13
  default:
14
14
  throw new Error(
15
- `operating system '${osName}' is not currently supported by Platforma ecosystem. The list of OSes supported: `
16
- + JSON.stringify(OSes),
15
+ `operating system '${osName}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` +
16
+ JSON.stringify(OSes),
17
17
  );
18
18
  }
19
19
  }
20
20
 
21
- export const Arches = ['amd64', 'arm64'] as const;
21
+ export const Arches = ["amd64", "arm64"] as const;
22
22
  export type ArchType = (typeof Arches)[number];
23
23
 
24
24
  /** @param arch - should be the thing returned from either {@link os.arch())} or `uname -m` */
25
25
  export function newArch(arch: string): ArchType {
26
26
  switch (arch) {
27
- case 'aarch64':
28
- case 'aarch64_be':
29
- case 'arm64':
30
- return 'arm64';
27
+ case "aarch64":
28
+ case "aarch64_be":
29
+ case "arm64":
30
+ return "arm64";
31
31
 
32
- case 'x86_64':
33
- case 'x64':
34
- return 'amd64';
32
+ case "x86_64":
33
+ case "x64":
34
+ return "amd64";
35
35
 
36
36
  default:
37
37
  throw new Error(
38
- `processor architecture '${arch}' is not currently supported by Platforma ecosystem. The list of architectures supported: `
39
- + JSON.stringify(Arches),
38
+ `processor architecture '${arch}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` +
39
+ JSON.stringify(Arches),
40
40
  );
41
41
  }
42
42
  }
@@ -1,53 +1,56 @@
1
- import type { MiLogger } from '@milaboratories/ts-helpers';
2
- import { assertNever } from '@milaboratories/ts-helpers';
3
- import { downloadBinary } from './pl_binary_download';
4
- import { getDefaultPlVersion } from './pl_version';
5
- import os from 'node:os';
6
- import upath from 'upath';
7
- import type { OSType } from './os_and_arch';
8
- import { newOs } from './os_and_arch';
9
- import type { Dispatcher } from 'undici';
1
+ import type { MiLogger } from "@milaboratories/ts-helpers";
2
+ import { assertNever } from "@milaboratories/ts-helpers";
3
+ import { downloadBinary } from "./pl_binary_download";
4
+ import { getDefaultPlVersion } from "./pl_version";
5
+ import os from "node:os";
6
+ import upath from "upath";
7
+ import type { OSType } from "./os_and_arch";
8
+ import { newOs } from "./os_and_arch";
9
+ import type { Dispatcher } from "undici";
10
10
 
11
11
  /** Shows how the binary should be got. */
12
12
  export type PlBinarySource = PlBinarySourceDownload | PlBinarySourceLocal;
13
13
 
14
14
  export type PlBinarySourceDownload = {
15
- readonly type: 'Download';
15
+ readonly type: "Download";
16
16
  readonly version: string;
17
17
  };
18
18
 
19
19
  export type PlBinarySourceLocal = {
20
- readonly type: 'Local';
20
+ readonly type: "Local";
21
21
  readonly path: string;
22
22
  };
23
23
 
24
24
  export function newDefaultPlBinarySource(): PlBinarySourceDownload {
25
- return { type: 'Download', version: getDefaultPlVersion() };
25
+ return { type: "Download", version: getDefaultPlVersion() };
26
26
  }
27
27
 
28
- export async function resolveLocalPlBinaryPath(
29
- { logger, downloadDir, src, dispatcher }: {
30
- logger: MiLogger;
31
- downloadDir: string;
32
- src: PlBinarySource;
33
- dispatcher?: Dispatcher;
34
- },
35
- ): Promise<string> {
28
+ export async function resolveLocalPlBinaryPath({
29
+ logger,
30
+ downloadDir,
31
+ src,
32
+ dispatcher,
33
+ }: {
34
+ logger: MiLogger;
35
+ downloadDir: string;
36
+ src: PlBinarySource;
37
+ dispatcher?: Dispatcher;
38
+ }): Promise<string> {
36
39
  switch (src.type) {
37
- case 'Download':
40
+ case "Download":
38
41
  // eslint-disable-next-line no-case-declarations
39
42
  const ops = await downloadBinary({
40
43
  logger,
41
44
  baseDir: downloadDir,
42
- softwareName: 'pl',
45
+ softwareName: "pl",
43
46
  archiveName: `pl-${src.version}`,
44
47
  arch: os.arch(),
45
48
  platform: os.platform(),
46
49
  dispatcher,
47
50
  });
48
- return upath.join(ops.baseName, 'binaries', osToBinaryName[newOs(os.platform())]);
51
+ return upath.join(ops.baseName, "binaries", osToBinaryName[newOs(os.platform())]);
49
52
 
50
- case 'Local':
53
+ case "Local":
51
54
  return src.path;
52
55
 
53
56
  default:
@@ -56,7 +59,7 @@ export async function resolveLocalPlBinaryPath(
56
59
  }
57
60
 
58
61
  export const osToBinaryName: Record<OSType, string> = {
59
- linux: 'platforma',
60
- macos: 'platforma',
61
- windows: 'platforma.exe',
62
+ linux: "platforma",
63
+ macos: "platforma",
64
+ windows: "platforma.exe",
62
65
  };