@platforma-sdk/bootstrap 5.2.40 → 5.2.42

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 (168) hide show
  1. package/README.md +10 -2
  2. package/assets/compose-backend.yaml +2 -2
  3. package/bin/run.js +3 -3
  4. package/dist/block.cjs +36 -31
  5. package/dist/block.cjs.map +1 -1
  6. package/dist/block.d.ts +2 -2
  7. package/dist/block.d.ts.map +1 -1
  8. package/dist/block.js +36 -31
  9. package/dist/block.js.map +1 -1
  10. package/dist/cmd-opts.cjs +74 -74
  11. package/dist/cmd-opts.cjs.map +1 -1
  12. package/dist/cmd-opts.d.ts +23 -23
  13. package/dist/cmd-opts.d.ts.map +1 -1
  14. package/dist/cmd-opts.js +74 -74
  15. package/dist/cmd-opts.js.map +1 -1
  16. package/dist/commands/create-block.cjs +3 -3
  17. package/dist/commands/create-block.cjs.map +1 -1
  18. package/dist/commands/create-block.d.ts +2 -2
  19. package/dist/commands/create-block.d.ts.map +1 -1
  20. package/dist/commands/create-block.js +3 -3
  21. package/dist/commands/create-block.js.map +1 -1
  22. package/dist/commands/reset.cjs +3 -3
  23. package/dist/commands/reset.cjs.map +1 -1
  24. package/dist/commands/reset.d.ts +2 -2
  25. package/dist/commands/reset.d.ts.map +1 -1
  26. package/dist/commands/reset.js +3 -3
  27. package/dist/commands/reset.js.map +1 -1
  28. package/dist/commands/start/docker/s3.cjs +18 -18
  29. package/dist/commands/start/docker/s3.cjs.map +1 -1
  30. package/dist/commands/start/docker/s3.d.ts +15 -15
  31. package/dist/commands/start/docker/s3.d.ts.map +1 -1
  32. package/dist/commands/start/docker/s3.js +18 -18
  33. package/dist/commands/start/docker/s3.js.map +1 -1
  34. package/dist/commands/start/docker.cjs +18 -18
  35. package/dist/commands/start/docker.cjs.map +1 -1
  36. package/dist/commands/start/docker.d.ts +16 -16
  37. package/dist/commands/start/docker.d.ts.map +1 -1
  38. package/dist/commands/start/docker.js +18 -18
  39. package/dist/commands/start/docker.js.map +1 -1
  40. package/dist/commands/start/local/s3.cjs +36 -34
  41. package/dist/commands/start/local/s3.cjs.map +1 -1
  42. package/dist/commands/start/local/s3.d.ts +18 -18
  43. package/dist/commands/start/local/s3.d.ts.map +1 -1
  44. package/dist/commands/start/local/s3.js +36 -34
  45. package/dist/commands/start/local/s3.js.map +1 -1
  46. package/dist/commands/start/local.cjs +32 -30
  47. package/dist/commands/start/local.cjs.map +1 -1
  48. package/dist/commands/start/local.d.ts +16 -16
  49. package/dist/commands/start/local.d.ts.map +1 -1
  50. package/dist/commands/start/local.js +32 -30
  51. package/dist/commands/start/local.js.map +1 -1
  52. package/dist/commands/start.cjs +3 -3
  53. package/dist/commands/start.cjs.map +1 -1
  54. package/dist/commands/start.d.ts +2 -2
  55. package/dist/commands/start.js +3 -3
  56. package/dist/commands/start.js.map +1 -1
  57. package/dist/commands/stop.cjs +4 -4
  58. package/dist/commands/stop.cjs.map +1 -1
  59. package/dist/commands/stop.d.ts +2 -2
  60. package/dist/commands/stop.js +4 -4
  61. package/dist/commands/stop.js.map +1 -1
  62. package/dist/commands/svc/create/arg-parser.cjs +13 -13
  63. package/dist/commands/svc/create/arg-parser.cjs.map +1 -1
  64. package/dist/commands/svc/create/arg-parser.d.ts +1 -1
  65. package/dist/commands/svc/create/arg-parser.js +13 -13
  66. package/dist/commands/svc/create/arg-parser.js.map +1 -1
  67. package/dist/commands/svc/create/docker/s3.cjs +27 -27
  68. package/dist/commands/svc/create/docker/s3.cjs.map +1 -1
  69. package/dist/commands/svc/create/docker/s3.d.ts +15 -15
  70. package/dist/commands/svc/create/docker/s3.d.ts.map +1 -1
  71. package/dist/commands/svc/create/docker/s3.js +27 -27
  72. package/dist/commands/svc/create/docker/s3.js.map +1 -1
  73. package/dist/commands/svc/create/docker.cjs +35 -35
  74. package/dist/commands/svc/create/docker.cjs.map +1 -1
  75. package/dist/commands/svc/create/docker.d.ts +16 -16
  76. package/dist/commands/svc/create/docker.js +35 -35
  77. package/dist/commands/svc/create/docker.js.map +1 -1
  78. package/dist/commands/svc/create/local/s3.cjs +37 -35
  79. package/dist/commands/svc/create/local/s3.cjs.map +1 -1
  80. package/dist/commands/svc/create/local/s3.d.ts +18 -18
  81. package/dist/commands/svc/create/local/s3.d.ts.map +1 -1
  82. package/dist/commands/svc/create/local/s3.js +37 -35
  83. package/dist/commands/svc/create/local/s3.js.map +1 -1
  84. package/dist/commands/svc/create/local.cjs +35 -35
  85. package/dist/commands/svc/create/local.cjs.map +1 -1
  86. package/dist/commands/svc/create/local.d.ts +16 -16
  87. package/dist/commands/svc/create/local.d.ts.map +1 -1
  88. package/dist/commands/svc/create/local.js +35 -35
  89. package/dist/commands/svc/create/local.js.map +1 -1
  90. package/dist/commands/svc/delete.cjs +4 -4
  91. package/dist/commands/svc/delete.cjs.map +1 -1
  92. package/dist/commands/svc/delete.d.ts +2 -2
  93. package/dist/commands/svc/delete.js +4 -4
  94. package/dist/commands/svc/delete.js.map +1 -1
  95. package/dist/commands/svc/down.cjs +3 -3
  96. package/dist/commands/svc/down.cjs.map +1 -1
  97. package/dist/commands/svc/down.d.ts +2 -2
  98. package/dist/commands/svc/down.js +3 -3
  99. package/dist/commands/svc/down.js.map +1 -1
  100. package/dist/commands/svc/list.cjs +5 -5
  101. package/dist/commands/svc/list.cjs.map +1 -1
  102. package/dist/commands/svc/list.d.ts +1 -1
  103. package/dist/commands/svc/list.d.ts.map +1 -1
  104. package/dist/commands/svc/list.js +5 -5
  105. package/dist/commands/svc/list.js.map +1 -1
  106. package/dist/commands/svc/up.cjs +5 -5
  107. package/dist/commands/svc/up.cjs.map +1 -1
  108. package/dist/commands/svc/up.d.ts +2 -2
  109. package/dist/commands/svc/up.d.ts.map +1 -1
  110. package/dist/commands/svc/up.js +5 -5
  111. package/dist/commands/svc/up.js.map +1 -1
  112. package/dist/core.cjs +261 -231
  113. package/dist/core.cjs.map +1 -1
  114. package/dist/core.d.ts +10 -10
  115. package/dist/core.d.ts.map +1 -1
  116. package/dist/core.js +261 -231
  117. package/dist/core.js.map +1 -1
  118. package/dist/index.cjs +16 -16
  119. package/dist/index.cjs.map +1 -1
  120. package/dist/index.d.ts +29 -29
  121. package/dist/index.js +16 -16
  122. package/dist/index.js.map +1 -1
  123. package/dist/package.cjs +2 -2
  124. package/dist/package.cjs.map +1 -1
  125. package/dist/package.js +2 -2
  126. package/dist/package.js.map +1 -1
  127. package/dist/platforma.cjs +24 -24
  128. package/dist/platforma.cjs.map +1 -1
  129. package/dist/platforma.d.ts +1 -1
  130. package/dist/platforma.d.ts.map +1 -1
  131. package/dist/platforma.js +24 -24
  132. package/dist/platforma.js.map +1 -1
  133. package/dist/run.cjs +6 -6
  134. package/dist/run.cjs.map +1 -1
  135. package/dist/run.d.ts +3 -3
  136. package/dist/run.d.ts.map +1 -1
  137. package/dist/run.js +6 -6
  138. package/dist/run.js.map +1 -1
  139. package/dist/state.cjs +16 -14
  140. package/dist/state.cjs.map +1 -1
  141. package/dist/state.d.ts +5 -5
  142. package/dist/state.d.ts.map +1 -1
  143. package/dist/state.js +16 -14
  144. package/dist/state.js.map +1 -1
  145. package/dist/templates/compose.cjs +2 -2
  146. package/dist/templates/compose.cjs.map +1 -1
  147. package/dist/templates/compose.d.ts.map +1 -1
  148. package/dist/templates/compose.js +2 -2
  149. package/dist/templates/compose.js.map +1 -1
  150. package/dist/templates/pl-config.cjs +49 -49
  151. package/dist/templates/pl-config.cjs.map +1 -1
  152. package/dist/templates/pl-config.d.ts +2 -2
  153. package/dist/templates/pl-config.d.ts.map +1 -1
  154. package/dist/templates/pl-config.js +49 -49
  155. package/dist/templates/pl-config.js.map +1 -1
  156. package/dist/templates/types.cjs +12 -12
  157. package/dist/templates/types.cjs.map +1 -1
  158. package/dist/templates/types.d.ts +6 -6
  159. package/dist/templates/types.d.ts.map +1 -1
  160. package/dist/templates/types.js +12 -12
  161. package/dist/templates/types.js.map +1 -1
  162. package/dist/util.cjs +19 -17
  163. package/dist/util.cjs.map +1 -1
  164. package/dist/util.d.ts +2 -2
  165. package/dist/util.d.ts.map +1 -1
  166. package/dist/util.js +19 -17
  167. package/dist/util.js.map +1 -1
  168. package/package.json +23 -22
package/dist/core.cjs CHANGED
@@ -21,8 +21,8 @@ class Core {
21
21
  startLast() {
22
22
  const instance = state.currentInstance;
23
23
  if (!instance) {
24
- this.logger.error('failed to bring back Platforma Backend in the last started configuration: no last configuration found');
25
- throw new Error('no previous run info found');
24
+ this.logger.error("failed to bring back Platforma Backend in the last started configuration: no last configuration found");
25
+ throw new Error("no previous run info found");
26
26
  }
27
27
  return this.startInstance(instance);
28
28
  }
@@ -33,7 +33,7 @@ class Core {
33
33
  }
34
34
  const result = run.runCommands(this.logger, instance.upCommands);
35
35
  checkRunError(result.executed);
36
- if (result.spawned.length > 0 && instance.type === 'process') {
36
+ if (result.spawned.length > 0 && instance.type === "process") {
37
37
  instance.pid = result.spawned[result.spawned.length - 1].pid;
38
38
  state.setInstanceInfo(instance.name, instance);
39
39
  this.logger.info(`instance '${instance.name}' started`);
@@ -47,10 +47,10 @@ class Core {
47
47
  checkRunError(result.executed);
48
48
  const iType = instance.type;
49
49
  switch (iType) {
50
- case 'docker': {
50
+ case "docker": {
51
51
  return;
52
52
  }
53
- case 'process': {
53
+ case "process": {
54
54
  if (instance.pid && state.isInstanceActive(instance)) {
55
55
  process.kill(instance.pid);
56
56
  }
@@ -73,9 +73,9 @@ class Core {
73
73
  return this.startInstance(instance);
74
74
  }
75
75
  createLocal(instanceName, options) {
76
- let plBinaryPath = platforma.binaryPath(options?.version, 'binaries', 'platforma');
76
+ let plBinaryPath = platforma.binaryPath(options?.version, "binaries", "platforma");
77
77
  if (options?.sourcesPath) {
78
- plBinaryPath = path.join(os.tmpdir(), 'platforma-custom-build');
78
+ plBinaryPath = path.join(os.tmpdir(), "platforma-custom-build");
79
79
  }
80
80
  if (options?.binaryPath) {
81
81
  plBinaryPath = options.binaryPath;
@@ -108,17 +108,17 @@ class Core {
108
108
  `${configOptions.localRoot}/packages-local`,
109
109
  `${configOptions.localRoot}/blocks-local`,
110
110
  ];
111
- if (configOptions.storages.primary.type === 'FS') {
111
+ if (configOptions.storages.primary.type === "FS") {
112
112
  storageDirs.push(configOptions.storages.primary.rootPath);
113
113
  }
114
- if (configOptions.storages.library.type === 'FS') {
114
+ if (configOptions.storages.library.type === "FS") {
115
115
  storageDirs.push(configOptions.storages.library.rootPath);
116
116
  configOptions.hacks.libraryDownloadable = false;
117
117
  }
118
- if (configOptions.storages.work.type === 'FS') {
118
+ if (configOptions.storages.work.type === "FS") {
119
119
  storageDirs.push(configOptions.storages.work.rootPath);
120
120
  }
121
- this.logger.debug(' creating pl state directories...');
121
+ this.logger.debug(" creating pl state directories...");
122
122
  for (const dir of storageDirs) {
123
123
  if (!fs.existsSync(dir)) {
124
124
  this.logger.debug(` '${dir}'`);
@@ -126,36 +126,36 @@ class Core {
126
126
  }
127
127
  }
128
128
  for (const drv of configOptions.core.auth.drivers) {
129
- if (drv.driver === 'htpasswd') {
129
+ if (drv.driver === "htpasswd") {
130
130
  if (!fs.existsSync(drv.path)) {
131
131
  this.logger.debug(` installing default 'users.htpasswd' to ${drv.path}...`);
132
- fs.copyFileSync(_package.assets('users.htpasswd'), drv.path);
132
+ fs.copyFileSync(_package.assets("users.htpasswd"), drv.path);
133
133
  }
134
134
  }
135
135
  }
136
136
  if (!configPath) {
137
- configPath = path.join(configOptions.localRoot, 'config.yaml');
137
+ configPath = path.join(configOptions.localRoot, "config.yaml");
138
138
  this.logger.debug(` rendering configuration '${configPath}'...`);
139
139
  fs.writeFileSync(configPath, plConfig.render(configOptions));
140
140
  }
141
141
  const upCommands = [];
142
142
  if (options?.sourcesPath) {
143
143
  upCommands.push({
144
- cmd: 'go',
145
- args: ['build', '-o', plBinaryPath, '.'],
146
- workdir: path.resolve(options.sourcesPath, 'cmd', 'platforma'),
144
+ cmd: "go",
145
+ args: ["build", "-o", plBinaryPath, "."],
146
+ workdir: path.resolve(options.sourcesPath, "cmd", "platforma"),
147
147
  runOpts: {
148
- stdio: 'inherit',
148
+ stdio: "inherit",
149
149
  },
150
150
  });
151
151
  }
152
152
  const runBinary = {
153
153
  async: true,
154
154
  cmd: plBinaryPath,
155
- args: ['--quiet', '--config', configPath],
155
+ args: ["--quiet", "--config", configPath],
156
156
  workdir: workdir,
157
157
  runOpts: {
158
- stdio: 'inherit',
158
+ stdio: "inherit",
159
159
  },
160
160
  };
161
161
  if (options?.configOptions?.numCpu) {
@@ -169,7 +169,7 @@ class Core {
169
169
  runBinary.runOpts.env = {};
170
170
  }
171
171
  for (const cmd of options.backendCommands) {
172
- const equalIndex = cmd.indexOf('=');
172
+ const equalIndex = cmd.indexOf("=");
173
173
  if (equalIndex > 0) {
174
174
  const key = cmd.substring(0, equalIndex);
175
175
  const value = cmd.substring(equalIndex + 1);
@@ -182,13 +182,13 @@ class Core {
182
182
  }
183
183
  // Process additional backend commands
184
184
  if (options?.backendCommands && options.backendCommands.length > 0) {
185
- this.logger.debug(`Adding backend commands: ${options.backendCommands.join(' ')}`);
185
+ this.logger.debug(`Adding backend commands: ${options.backendCommands.join(" ")}`);
186
186
  // Add commands as arguments to the binary
187
187
  runBinary.args = [...runBinary.args, ...options.backendCommands];
188
188
  }
189
189
  upCommands.push(runBinary);
190
190
  state.setInstanceInfo(instanceName, {
191
- type: 'process',
191
+ type: "process",
192
192
  upCommands: upCommands,
193
193
  downCommands: [],
194
194
  cleanupCommands: [],
@@ -205,47 +205,38 @@ class Core {
205
205
  return state.getInstanceInfo(instanceName);
206
206
  }
207
207
  createLocalS3(instanceName, options) {
208
- this.logger.debug('creating platforma instance in \'local s3\' mode...');
208
+ this.logger.debug("creating platforma instance in 'local s3' mode...");
209
209
  const minioPort = options?.minioPort ?? 9000;
210
210
  const instance = this.createLocal(instanceName, {
211
211
  ...options,
212
- primaryURL: options?.primaryURL ?? `s3e://testuser:testpassword@localhost:${minioPort}/platforma-primary-bucket/?region=no-region`,
213
- libraryURL: options?.libraryURL ?? `s3e://testuser:testpassword@localhost:${minioPort}/platforma-library-bucket/?region=no-region`,
212
+ primaryURL: options?.primaryURL ??
213
+ `s3e://testuser:testpassword@localhost:${minioPort}/platforma-primary-bucket/?region=no-region`,
214
+ libraryURL: options?.libraryURL ??
215
+ `s3e://testuser:testpassword@localhost:${minioPort}/platforma-library-bucket/?region=no-region`,
214
216
  });
215
217
  const localRoot = options?.configOptions?.localRoot;
216
218
  const minioRunCmd = this.createMinio(instanceName, {
217
219
  minioPort: minioPort,
218
220
  minioConsolePort: options?.minioConsolePort,
219
- storage: localRoot ? path.join(localRoot, 'minio') : undefined,
221
+ storage: localRoot ? path.join(localRoot, "minio") : undefined,
220
222
  });
221
- instance.upCommands = [
222
- minioRunCmd.start,
223
- ...instance.upCommands,
224
- ];
225
- instance.downCommands = [
226
- minioRunCmd.stop,
227
- ...instance.downCommands,
228
- ];
229
- instance.cleanupCommands = [
230
- minioRunCmd.cleanup,
231
- ...instance.cleanupCommands,
232
- ];
223
+ instance.upCommands = [minioRunCmd.start, ...instance.upCommands];
224
+ instance.downCommands = [minioRunCmd.stop, ...instance.downCommands];
225
+ instance.cleanupCommands = [minioRunCmd.cleanup, ...instance.cleanupCommands];
233
226
  state.setInstanceInfo(instanceName, instance);
234
227
  return instance;
235
228
  }
236
229
  createMinio(instanceName, options) {
237
- this.logger.debug(' creating docker compose for minio service...');
238
- const composeSrc = _package.assets('compose-backend.yaml');
239
- const composeMinio = state.instanceDir(instanceName, 'compose-minio.yaml');
240
- compose.render(composeSrc, composeMinio, `pl-${instanceName}-minio`, new Map([
241
- ['minio', {}],
242
- ]), { dropVolumes: true });
243
- const version = options?.version ? `:${options.version}` : '';
230
+ this.logger.debug(" creating docker compose for minio service...");
231
+ const composeSrc = _package.assets("compose-backend.yaml");
232
+ const composeMinio = state.instanceDir(instanceName, "compose-minio.yaml");
233
+ compose.render(composeSrc, composeMinio, `pl-${instanceName}-minio`, new Map([["minio", {}]]), { dropVolumes: true });
234
+ const version = options?.version ? `:${options.version}` : "";
244
235
  this.logger.debug(` minio version: ${version}`);
245
236
  const image = options?.image ?? `quay.io/minio/minio${version}`;
246
237
  this.logger.debug(` minio image: ${image}`);
247
- const storage = options?.storage ?? state.instanceDir(instanceName, 'minio');
248
- util.ensureDir(storage, { mode: '0775' });
238
+ const storage = options?.storage ?? state.instanceDir(instanceName, "minio");
239
+ util.ensureDir(storage, { mode: "0775" });
249
240
  const minioPort = options?.minioPort ?? 9000;
250
241
  const minioConsolePort = options?.minioConsolePort ?? 9001;
251
242
  const envs = {
@@ -256,67 +247,74 @@ class Core {
256
247
  };
257
248
  return {
258
249
  start: {
259
- cmd: 'docker',
260
- args: ['compose', `--file=${composeMinio}`, 'up', '--detach', '--remove-orphans', '--pull=missing'],
250
+ cmd: "docker",
251
+ args: [
252
+ "compose",
253
+ `--file=${composeMinio}`,
254
+ "up",
255
+ "--detach",
256
+ "--remove-orphans",
257
+ "--pull=missing",
258
+ ],
261
259
  envs: envs,
262
260
  workdir: state.instanceDir(instanceName),
263
- runOpts: { stdio: 'inherit' },
261
+ runOpts: { stdio: "inherit" },
264
262
  },
265
263
  stop: {
266
- cmd: 'docker',
267
- args: ['compose', `--file=${composeMinio}`, 'down'],
264
+ cmd: "docker",
265
+ args: ["compose", `--file=${composeMinio}`, "down"],
268
266
  envs: envs,
269
267
  workdir: state.instanceDir(instanceName),
270
- runOpts: { stdio: 'inherit' },
268
+ runOpts: { stdio: "inherit" },
271
269
  },
272
270
  cleanup: {
273
- cmd: 'docker',
274
- args: ['compose', `--file=${composeMinio}`, 'down', '--volumes', '--remove-orphans'],
271
+ cmd: "docker",
272
+ args: ["compose", `--file=${composeMinio}`, "down", "--volumes", "--remove-orphans"],
275
273
  envs: envs,
276
274
  workdir: state.instanceDir(instanceName),
277
- runOpts: { stdio: 'inherit' },
275
+ runOpts: { stdio: "inherit" },
278
276
  },
279
277
  };
280
278
  }
281
279
  createDockerS3(instanceName, localRoot, options) {
282
- this.logger.debug('creating platforma instance in \'docker s3\' mode...');
283
- const composeS3Path = _package.assets('compose-backend.yaml');
280
+ this.logger.debug("creating platforma instance in 'docker s3' mode...");
281
+ const composeS3Path = _package.assets("compose-backend.yaml");
284
282
  const image = options?.image ?? _package.plImageTag(options?.version);
285
283
  this.checkLicense(options?.license, options?.licenseFile);
286
284
  const storagePath = (...s) => path.join(localRoot, ...s);
287
285
  const storageDir = (s) => {
288
286
  const p = storagePath(s);
289
- util.ensureDir(p, { mode: '0775' });
287
+ util.ensureDir(p, { mode: "0775" });
290
288
  return p;
291
289
  };
292
- const logFilePath = storagePath('logs', 'platforma.log');
290
+ const logFilePath = storagePath("logs", "platforma.log");
293
291
  if (!fs.existsSync(logFilePath)) {
294
292
  fs.mkdirSync(path.dirname(logFilePath), { recursive: true });
295
- fs.writeFileSync(logFilePath, '');
293
+ fs.writeFileSync(logFilePath, "");
296
294
  }
297
- const presignHost = options?.presignHost ?? 'localhost';
295
+ const presignHost = options?.presignHost ?? "localhost";
298
296
  const presignPort = options?.s3Port ?? 9000;
299
297
  const primary = plConfig.storageSettingsFromURL(`s3e://testuser:testpassword@minio:${presignPort}/platforma-primary-bucket`);
300
- if (primary.type !== 'S3') {
301
- throw new Error('primary storage must have \'S3\' type in \'docker s3\' configuration');
298
+ if (primary.type !== "S3") {
299
+ throw new Error("primary storage must have 'S3' type in 'docker s3' configuration");
302
300
  }
303
301
  else {
304
302
  primary.presignEndpoint = `http://${presignHost}:${presignPort}`;
305
303
  }
306
304
  const library = plConfig.storageSettingsFromURL(`s3e://testuser:testpassword@minio:${presignPort}/platforma-library-bucket`);
307
- if (library.type !== 'S3') {
305
+ if (library.type !== "S3") {
308
306
  throw new Error(`${library.type} storage type is not supported for library storage`);
309
307
  }
310
308
  else {
311
309
  library.presignEndpoint = `http://${presignHost}:${presignPort}`;
312
310
  }
313
- const dbFSPath = storageDir('db');
314
- const workFSPath = storageDir('work');
315
- const usersFSPath = storagePath('users.htpasswd');
311
+ const dbFSPath = storageDir("db");
312
+ const workFSPath = storageDir("work");
313
+ const usersFSPath = storagePath("users.htpasswd");
316
314
  if (!fs.existsSync(usersFSPath)) {
317
- fs.copyFileSync(_package.assets('users.htpasswd'), usersFSPath);
315
+ fs.copyFileSync(_package.assets("users.htpasswd"), usersFSPath);
318
316
  }
319
- const composeDstPath = storagePath('compose.yaml');
317
+ const composeDstPath = storagePath("compose.yaml");
320
318
  if (fs.existsSync(composeDstPath)) {
321
319
  this.logger.info(`replacing docker compose file ${composeDstPath}`);
322
320
  }
@@ -328,35 +326,38 @@ class Core {
328
326
  });
329
327
  }
330
328
  compose.render(composeS3Path, composeDstPath, `pl-${instanceName}`, new Map([
331
- ['minio', {}],
332
- ['backend', {
329
+ ["minio", {}],
330
+ [
331
+ "backend",
332
+ {
333
333
  platform: options?.platformOverride,
334
334
  mounts: backendMounts,
335
335
  commands: options?.backendCommands,
336
- }],
336
+ },
337
+ ],
337
338
  ]));
338
339
  const envs = {
339
- MINIO_IMAGE: 'quay.io/minio/minio',
340
- MINIO_STORAGE: storageDir('minio'),
340
+ MINIO_IMAGE: "quay.io/minio/minio",
341
+ MINIO_STORAGE: storageDir("minio"),
341
342
  PL_IMAGE: image,
342
343
  PL_AUTH_HTPASSWD: usersFSPath,
343
344
  PL_LICENSE: options?.license,
344
345
  PL_LICENSE_FILE: options?.licenseFile,
345
- PL_LOG_LEVEL: options?.logLevel ?? 'info',
346
+ PL_LOG_LEVEL: options?.logLevel ?? "info",
346
347
  PL_LOG_DIR: path.dirname(logFilePath),
347
- PL_LOG_ROTATION_ENABLED: 'true',
348
- PL_RUNNER_WD_CACHE_ON_FAILURE: '1h',
348
+ PL_LOG_ROTATION_ENABLED: "true",
349
+ PL_RUNNER_WD_CACHE_ON_FAILURE: "1h",
349
350
  PL_DATA_DB_ROOT: dbFSPath,
350
- PL_DATA_PRIMARY_ROOT: storageDir('primary'),
351
- PL_DATA_LIBRARY_ROOT: storageDir('library'),
351
+ PL_DATA_PRIMARY_ROOT: storageDir("primary"),
352
+ PL_DATA_LIBRARY_ROOT: storageDir("library"),
352
353
  PL_DATA_WORKDIR_ROOT: workFSPath,
353
354
  // Mount packages storage as volume, because APFS is case-insensitive on Mac OS X and this breaks some pl software installation.
354
355
  // PL_DATA_PACKAGE_ROOT: storageDir('packages'),
355
- ...this.configureDockerStorage('primary', primary),
356
- ...this.configureDockerStorage('library', library),
356
+ ...this.configureDockerStorage("primary", primary),
357
+ ...this.configureDockerStorage("library", library),
357
358
  };
358
359
  if (options?.grpcAddr) {
359
- const addrParts = options.grpcAddr.split(':');
360
+ const addrParts = options.grpcAddr.split(":");
360
361
  if (addrParts.length === 2) {
361
362
  envs.PL_LISTEN_ADDRESS = addrParts[0];
362
363
  envs.PL_LISTEN_PORT = addrParts[1];
@@ -369,7 +370,7 @@ class Core {
369
370
  envs.PL_LISTEN_PORT = options.grpcPort.toString();
370
371
  }
371
372
  if (options?.monitoringAddr) {
372
- const addrParts = options.monitoringAddr.split(':');
373
+ const addrParts = options.monitoringAddr.split(":");
373
374
  if (addrParts.length === 2) {
374
375
  envs.PL_MONITORING_IP = addrParts[0];
375
376
  envs.PL_MONITORING_PORT = addrParts[1];
@@ -382,7 +383,7 @@ class Core {
382
383
  envs.PL_MONITORING_PORT = options.monitoringPort.toString();
383
384
  }
384
385
  if (options?.debugAddr) {
385
- const addrParts = options.debugAddr.split(':');
386
+ const addrParts = options.debugAddr.split(":");
386
387
  if (addrParts.length === 2) {
387
388
  envs.PL_DEBUG_IP = addrParts[0];
388
389
  envs.PL_DEBUG_PORT = addrParts[1];
@@ -400,51 +401,64 @@ class Core {
400
401
  envs.MINIO_CONSOLE_PORT = options.s3ConsolePort.toString();
401
402
  if (options?.auth) {
402
403
  if (options.auth.enabled) {
403
- envs['PL_NO_AUTH'] = 'false';
404
+ envs["PL_NO_AUTH"] = "false";
404
405
  }
405
406
  else {
406
- envs['PL_NO_AUTH'] = 'true';
407
+ envs["PL_NO_AUTH"] = "true";
407
408
  }
408
409
  if (options.auth.drivers) {
409
410
  for (const drv of options.auth.drivers) {
410
- if (drv.driver === 'htpasswd') {
411
- envs['PL_AUTH_HTPASSWD'] = path.resolve(drv.path);
412
- drv.path = '/etc/platforma/users.htpasswd';
411
+ if (drv.driver === "htpasswd") {
412
+ envs["PL_AUTH_HTPASSWD"] = path.resolve(drv.path);
413
+ drv.path = "/etc/platforma/users.htpasswd";
413
414
  }
414
415
  }
415
- envs['PL_AUTH_DRIVERS'] = JSON.stringify(options.auth.drivers);
416
+ envs["PL_AUTH_DRIVERS"] = JSON.stringify(options.auth.drivers);
416
417
  }
417
418
  }
418
419
  // Process additional backend commands
419
420
  if (options?.backendCommands && options.backendCommands.length > 0) {
420
- this.logger.debug(`Adding backend commands: ${options.backendCommands.join(' ')}`);
421
+ this.logger.debug(`Adding backend commands: ${options.backendCommands.join(" ")}`);
421
422
  }
422
423
  state.setInstanceInfo(instanceName, {
423
- type: 'docker',
424
- upCommands: [{
425
- cmd: 'docker',
426
- args: ['compose', `--file=${composeDstPath}`, 'up', '--detach', '--remove-orphans', '--pull=missing'],
424
+ type: "docker",
425
+ upCommands: [
426
+ {
427
+ cmd: "docker",
428
+ args: [
429
+ "compose",
430
+ `--file=${composeDstPath}`,
431
+ "up",
432
+ "--detach",
433
+ "--remove-orphans",
434
+ "--pull=missing",
435
+ ],
427
436
  envs: envs,
428
- runOpts: { stdio: 'inherit' },
429
- }],
430
- downCommands: [{
431
- cmd: 'docker',
432
- args: ['compose', `--file=${composeDstPath}`, 'down'],
437
+ runOpts: { stdio: "inherit" },
438
+ },
439
+ ],
440
+ downCommands: [
441
+ {
442
+ cmd: "docker",
443
+ args: ["compose", `--file=${composeDstPath}`, "down"],
433
444
  envs: envs,
434
- runOpts: { stdio: 'inherit' },
435
- }],
436
- cleanupCommands: [{
437
- cmd: 'docker',
438
- args: ['compose', `--file=${composeDstPath}`, 'down', '--volumes', '--remove-orphans'],
445
+ runOpts: { stdio: "inherit" },
446
+ },
447
+ ],
448
+ cleanupCommands: [
449
+ {
450
+ cmd: "docker",
451
+ args: ["compose", `--file=${composeDstPath}`, "down", "--volumes", "--remove-orphans"],
439
452
  envs: envs,
440
- runOpts: { stdio: 'inherit' },
441
- }],
453
+ runOpts: { stdio: "inherit" },
454
+ },
455
+ ],
442
456
  runInfo: {
443
457
  apiPort: options?.grpcPort,
444
458
  apiAddr: options?.grpcAddr,
445
459
  logPath: logFilePath,
446
460
  primary: primary,
447
- work: { type: 'FS', rootPath: workFSPath },
461
+ work: { type: "FS", rootPath: workFSPath },
448
462
  library: library,
449
463
  dbPath: dbFSPath,
450
464
  },
@@ -452,30 +466,30 @@ class Core {
452
466
  return state.getInstanceInfo(instanceName);
453
467
  }
454
468
  createDocker(instanceName, localRoot, options) {
455
- this.logger.debug('creating platforma instance in \'docker\' mode...');
456
- const composeFSPath = _package.assets('compose-backend.yaml');
469
+ this.logger.debug("creating platforma instance in 'docker' mode...");
470
+ const composeFSPath = _package.assets("compose-backend.yaml");
457
471
  const image = options?.image ?? _package.plImageTag(options?.version);
458
472
  this.checkLicense(options?.license, options?.licenseFile);
459
473
  const storagePath = (...s) => path.join(localRoot, ...s);
460
474
  const storageDir = (s) => {
461
475
  const p = storagePath(s);
462
- util.ensureDir(p, { mode: '0775' });
476
+ util.ensureDir(p, { mode: "0775" });
463
477
  return p;
464
478
  };
465
- const logFilePath = storagePath('logs', 'platforma.log');
479
+ const logFilePath = storagePath("logs", "platforma.log");
466
480
  if (!fs.existsSync(logFilePath)) {
467
481
  fs.mkdirSync(path.dirname(logFilePath), { recursive: true });
468
- fs.writeFileSync(logFilePath, '');
482
+ fs.writeFileSync(logFilePath, "");
469
483
  }
470
- const dbFSPath = storageDir('db');
471
- const primaryFSPath = storageDir('primary');
472
- const libraryFSPath = storageDir('library');
473
- const workFSPath = storageDir('work');
474
- const usersFSPath = storagePath('users.htpasswd');
484
+ const dbFSPath = storageDir("db");
485
+ const primaryFSPath = storageDir("primary");
486
+ const libraryFSPath = storageDir("library");
487
+ const workFSPath = storageDir("work");
488
+ const usersFSPath = storagePath("users.htpasswd");
475
489
  if (!fs.existsSync(usersFSPath)) {
476
- fs.copyFileSync(_package.assets('users.htpasswd'), usersFSPath);
490
+ fs.copyFileSync(_package.assets("users.htpasswd"), usersFSPath);
477
491
  }
478
- const composeDstPath = storagePath('compose.yaml');
492
+ const composeDstPath = storagePath("compose.yaml");
479
493
  if (fs.existsSync(composeDstPath)) {
480
494
  this.logger.info(`replacing docker compose file ${composeDstPath}`);
481
495
  }
@@ -488,33 +502,36 @@ class Core {
488
502
  }
489
503
  this.logger.debug(`Rendering docker compose file '${composeDstPath}' using '${composeFSPath}' as base template`);
490
504
  compose.render(composeFSPath, composeDstPath, `pl-${instanceName}`, new Map([
491
- ['backend', {
505
+ [
506
+ "backend",
507
+ {
492
508
  platform: options?.platformOverride,
493
509
  mounts: backendMounts,
494
510
  commands: options?.backendCommands,
495
- }],
511
+ },
512
+ ],
496
513
  ]));
497
- const primary = plConfig.storageSettingsFromURL(options?.primaryStorageURL ?? `file:${primaryFSPath}`, '.');
498
- const library = plConfig.storageSettingsFromURL(options?.libraryStorageURL ?? `file:${libraryFSPath}`, '.');
514
+ const primary = plConfig.storageSettingsFromURL(options?.primaryStorageURL ?? `file:${primaryFSPath}`, ".");
515
+ const library = plConfig.storageSettingsFromURL(options?.libraryStorageURL ?? `file:${libraryFSPath}`, ".");
499
516
  const envs = {
500
517
  PL_IMAGE: image,
501
518
  PL_AUTH_HTPASSWD: usersFSPath,
502
519
  PL_LICENSE: options?.license,
503
520
  PL_LICENSE_FILE: options?.licenseFile,
504
- PL_LOG_LEVEL: options?.logLevel ?? 'info',
521
+ PL_LOG_LEVEL: options?.logLevel ?? "info",
505
522
  PL_LOG_DIR: path.dirname(logFilePath),
506
- PL_LOG_ROTATION_ENABLED: 'true',
507
- PL_RUNNER_WD_CACHE_ON_FAILURE: '1h',
523
+ PL_LOG_ROTATION_ENABLED: "true",
524
+ PL_RUNNER_WD_CACHE_ON_FAILURE: "1h",
508
525
  PL_DATA_DB_ROOT: dbFSPath,
509
526
  PL_DATA_PRIMARY_ROOT: primaryFSPath,
510
527
  PL_DATA_LIBRARY_ROOT: libraryFSPath,
511
528
  PL_DATA_WORKDIR_ROOT: workFSPath,
512
- PL_DATA_PACKAGE_ROOT: storageDir('packages'),
513
- ...this.configureDockerStorage('primary', primary),
514
- ...this.configureDockerStorage('library', library),
529
+ PL_DATA_PACKAGE_ROOT: storageDir("packages"),
530
+ ...this.configureDockerStorage("primary", primary),
531
+ ...this.configureDockerStorage("library", library),
515
532
  };
516
533
  if (options?.grpcAddr) {
517
- const addrParts = options.grpcAddr.split(':');
534
+ const addrParts = options.grpcAddr.split(":");
518
535
  if (addrParts.length === 2) {
519
536
  envs.PL_LISTEN_ADDRESS = addrParts[0];
520
537
  envs.PL_LISTEN_PORT = addrParts[1];
@@ -527,7 +544,7 @@ class Core {
527
544
  envs.PL_LISTEN_PORT = options.grpcPort.toString();
528
545
  }
529
546
  if (options?.monitoringAddr) {
530
- const addrParts = options.monitoringAddr.split(':');
547
+ const addrParts = options.monitoringAddr.split(":");
531
548
  if (addrParts.length === 2) {
532
549
  envs.PL_MONITORING_IP = addrParts[0];
533
550
  envs.PL_MONITORING_PORT = addrParts[1];
@@ -540,7 +557,7 @@ class Core {
540
557
  envs.PL_MONITORING_PORT = options.monitoringPort.toString();
541
558
  }
542
559
  if (options?.debugAddr) {
543
- const addrParts = options.debugAddr.split(':');
560
+ const addrParts = options.debugAddr.split(":");
544
561
  if (addrParts.length === 2) {
545
562
  envs.PL_DEBUG_IP = addrParts[0];
546
563
  envs.PL_DEBUG_PORT = addrParts[1];
@@ -554,51 +571,64 @@ class Core {
554
571
  }
555
572
  if (options?.auth) {
556
573
  if (options.auth.enabled) {
557
- envs['PL_NO_AUTH'] = 'false';
574
+ envs["PL_NO_AUTH"] = "false";
558
575
  }
559
576
  else {
560
- envs['PL_NO_AUTH'] = 'true';
577
+ envs["PL_NO_AUTH"] = "true";
561
578
  }
562
579
  if (options.auth.drivers) {
563
580
  for (const drv of options.auth.drivers) {
564
- if (drv.driver === 'htpasswd') {
565
- envs['PL_AUTH_HTPASSWD'] = path.resolve(drv.path);
566
- drv.path = '/etc/platforma/users.htpasswd';
581
+ if (drv.driver === "htpasswd") {
582
+ envs["PL_AUTH_HTPASSWD"] = path.resolve(drv.path);
583
+ drv.path = "/etc/platforma/users.htpasswd";
567
584
  }
568
585
  }
569
- envs['PL_AUTH_DRIVERS'] = JSON.stringify(options.auth.drivers);
586
+ envs["PL_AUTH_DRIVERS"] = JSON.stringify(options.auth.drivers);
570
587
  }
571
588
  }
572
589
  // Process additional backend commands
573
590
  if (options?.backendCommands && options.backendCommands.length > 0) {
574
- this.logger.debug(`Adding backend commands: ${options.backendCommands.join(' ')}`);
591
+ this.logger.debug(`Adding backend commands: ${options.backendCommands.join(" ")}`);
575
592
  }
576
593
  state.setInstanceInfo(instanceName, {
577
- type: 'docker',
578
- upCommands: [{
579
- cmd: 'docker',
580
- args: ['compose', `--file=${composeDstPath}`, 'up', '--detach', '--remove-orphans', '--pull=missing'],
594
+ type: "docker",
595
+ upCommands: [
596
+ {
597
+ cmd: "docker",
598
+ args: [
599
+ "compose",
600
+ `--file=${composeDstPath}`,
601
+ "up",
602
+ "--detach",
603
+ "--remove-orphans",
604
+ "--pull=missing",
605
+ ],
581
606
  envs: envs,
582
- runOpts: { stdio: 'inherit' },
583
- }],
584
- downCommands: [{
585
- cmd: 'docker',
586
- args: ['compose', `--file=${composeDstPath}`, 'down'],
607
+ runOpts: { stdio: "inherit" },
608
+ },
609
+ ],
610
+ downCommands: [
611
+ {
612
+ cmd: "docker",
613
+ args: ["compose", `--file=${composeDstPath}`, "down"],
587
614
  envs: envs,
588
- runOpts: { stdio: 'inherit' },
589
- }],
590
- cleanupCommands: [{
591
- cmd: 'docker',
592
- args: ['compose', `--file=${composeDstPath}`, 'down', '--volumes', '--remove-orphans'],
615
+ runOpts: { stdio: "inherit" },
616
+ },
617
+ ],
618
+ cleanupCommands: [
619
+ {
620
+ cmd: "docker",
621
+ args: ["compose", `--file=${composeDstPath}`, "down", "--volumes", "--remove-orphans"],
593
622
  envs: envs,
594
- runOpts: { stdio: 'inherit' },
595
- }],
623
+ runOpts: { stdio: "inherit" },
624
+ },
625
+ ],
596
626
  runInfo: {
597
627
  apiPort: options?.grpcPort,
598
628
  apiAddr: options?.grpcAddr,
599
629
  logPath: logFilePath,
600
630
  primary: primary,
601
- work: { type: 'FS', rootPath: workFSPath },
631
+ work: { type: "FS", rootPath: workFSPath },
602
632
  library: library,
603
633
  dbPath: dbFSPath,
604
634
  },
@@ -608,17 +638,17 @@ class Core {
608
638
  cleanupInstance(instanceName) {
609
639
  const removeWarns = [];
610
640
  const instancesToDrop = new Map();
611
- let warnMessage = '';
641
+ let warnMessage = "";
612
642
  if (instanceName) {
613
643
  const instance = state.getInstanceInfo(instanceName);
614
644
  instancesToDrop.set(instanceName, instance);
615
645
  const iType = instance.type;
616
646
  switch (iType) {
617
- case 'docker': {
647
+ case "docker": {
618
648
  removeWarns.push(`docker service 'pl-${instanceName}', including all its volumes and data in '${state.instanceDir(instanceName)}' will be destroyed`);
619
649
  break;
620
650
  }
621
- case 'process': {
651
+ case "process": {
622
652
  removeWarns.push(`directory '${state.instanceDir(instanceName)}' would be deleted`);
623
653
  if (instance.downCommands) {
624
654
  removeWarns.push(`associated docker service, including all volumes and data will be destroyed`);
@@ -629,26 +659,26 @@ class Core {
629
659
  util.assertNever();
630
660
  }
631
661
  if (instanceName === state.currentInstanceName) {
632
- removeWarns.push('last command run cache (\'pl-dev start\' shorthand will stop working until next full start command call)');
662
+ removeWarns.push("last command run cache ('pl-dev start' shorthand will stop working until next full start command call)");
633
663
  }
634
664
  warnMessage = `
635
665
  You are going to reset the state of platforma service '${instanceName}':
636
- - ${removeWarns.join('\n - ')}
666
+ - ${removeWarns.join("\n - ")}
637
667
  `;
638
668
  }
639
669
  else {
640
670
  for (const iName of state.instanceList) {
641
671
  instancesToDrop.set(iName, state.getInstanceInfo(iName));
642
672
  }
643
- removeWarns.push('last command run cache (\'pl-dev start\' shorthand will stop working until next full start command call)', `all service configurations stored in: ${state.instanceDir()} (including all associated docker containers and volumes)`);
673
+ removeWarns.push("last command run cache ('pl-dev start' shorthand will stop working until next full start command call)", `all service configurations stored in: ${state.instanceDir()} (including all associated docker containers and volumes)`);
644
674
  warnMessage = `
645
675
  You are going to reset the state of all platforma services configured with pl-bootstrap package.
646
- - ${removeWarns.join('\n - ')}
676
+ - ${removeWarns.join("\n - ")}
647
677
  `;
648
678
  }
649
679
  this.logger.warn(warnMessage);
650
- if (!util.askYN('Are you sure?')) {
651
- this.logger.info('Reset action was canceled');
680
+ if (!util.askYN("Are you sure?")) {
681
+ this.logger.info("Reset action was canceled");
652
682
  return;
653
683
  }
654
684
  for (const [name, instance] of instancesToDrop.entries()) {
@@ -668,62 +698,62 @@ You are going to reset the state of all platforma services configured with pl-bo
668
698
  }
669
699
  mergeLicenseEnvs(flags) {
670
700
  if (flags.license === undefined) {
671
- if ((process.env.MI_LICENSE ?? '') != '')
701
+ if ((process.env.MI_LICENSE ?? "") != "")
672
702
  flags.license = process.env.MI_LICENSE;
673
- else if ((process.env.PL_LICENSE ?? '') != '')
703
+ else if ((process.env.PL_LICENSE ?? "") != "")
674
704
  flags.license = process.env.PL_LICENSE;
675
705
  }
676
706
  // set 'license-file' only if license is still undefined
677
- if (flags['license-file'] === undefined && flags.license === undefined) {
678
- if ((process.env.MI_LICENSE_FILE ?? '') != '')
679
- flags['license-file'] = process.env.MI_LICENSE_FILE;
680
- else if ((process.env.PL_LICENSE_FILE ?? '') != '')
681
- flags['license-file'] = process.env.PL_LICENSE_FILE;
682
- else if (fs.existsSync(path.resolve(os.homedir(), '.pl.license')))
683
- flags['license-file'] = path.resolve(os.homedir(), '.pl.license');
707
+ if (flags["license-file"] === undefined && flags.license === undefined) {
708
+ if ((process.env.MI_LICENSE_FILE ?? "") != "")
709
+ flags["license-file"] = process.env.MI_LICENSE_FILE;
710
+ else if ((process.env.PL_LICENSE_FILE ?? "") != "")
711
+ flags["license-file"] = process.env.PL_LICENSE_FILE;
712
+ else if (fs.existsSync(path.resolve(os.homedir(), ".pl.license")))
713
+ flags["license-file"] = path.resolve(os.homedir(), ".pl.license");
684
714
  }
685
715
  }
686
716
  initAuthDriversList(flags, workdir) {
687
717
  const authDrivers = [];
688
- if (flags['auth-htpasswd-file']) {
718
+ if (flags["auth-htpasswd-file"]) {
689
719
  authDrivers.push({
690
- driver: 'htpasswd',
691
- path: path.resolve(workdir, flags['auth-htpasswd-file']),
720
+ driver: "htpasswd",
721
+ path: path.resolve(workdir, flags["auth-htpasswd-file"]),
692
722
  });
693
723
  }
694
- if (Boolean(flags['auth-ldap-server']) !== Boolean(flags['auth-ldap-default-dn'])) {
695
- throw new Error('LDAP auth settings require both \'server\' and \'default DN\' options to be set');
724
+ if (Boolean(flags["auth-ldap-server"]) !== Boolean(flags["auth-ldap-default-dn"])) {
725
+ throw new Error("LDAP auth settings require both 'server' and 'default DN' options to be set");
696
726
  }
697
- if (flags['auth-ldap-server']) {
727
+ if (flags["auth-ldap-server"]) {
698
728
  authDrivers.push({
699
- driver: 'ldap',
700
- serverUrl: flags['auth-ldap-server'],
701
- defaultDN: flags['auth-ldap-default-dn'],
729
+ driver: "ldap",
730
+ serverUrl: flags["auth-ldap-server"],
731
+ defaultDN: flags["auth-ldap-default-dn"],
702
732
  });
703
733
  }
704
734
  if (authDrivers.length === 0) {
705
735
  return undefined;
706
736
  }
707
- return [{ driver: 'jwt', key: this.getLastJwt() }, ...authDrivers];
737
+ return [{ driver: "jwt", key: this.getLastJwt() }, ...authDrivers];
708
738
  }
709
739
  /** Gets the last stored JWT secret key or generates it and stores in a file. */
710
740
  getLastJwt() {
711
- const jwtFile = state.path('auth.jwt');
712
- const encoding = 'utf-8';
713
- let lastJwt = '';
741
+ const jwtFile = state.path("auth.jwt");
742
+ const encoding = "utf-8";
743
+ let lastJwt = "";
714
744
  if (fs.existsSync(jwtFile)) {
715
745
  lastJwt = fs.readFileSync(jwtFile, { encoding });
716
746
  }
717
- if (lastJwt == '') {
747
+ if (lastJwt == "") {
718
748
  lastJwt = util.randomStr(64);
719
749
  fs.writeFileSync(jwtFile, lastJwt, { encoding });
720
750
  }
721
751
  return lastJwt;
722
752
  }
723
753
  checkLicense(value, file) {
724
- if (value !== undefined && value != '')
754
+ if (value !== undefined && value != "")
725
755
  return;
726
- if (file !== undefined && file != '')
756
+ if (file !== undefined && file != "")
727
757
  return;
728
758
  this.logger.error(`A license for Platforma Backend must be set.
729
759
 
@@ -743,55 +773,55 @@ You can obtain the license from "https://platforma.bio/getlicense".`);
743
773
  const sType = storage.type;
744
774
  storageID = storageID.toUpperCase();
745
775
  switch (sType) {
746
- case 'S3':
776
+ case "S3":
747
777
  switch (storageID) {
748
- case 'PRIMARY': {
778
+ case "PRIMARY": {
749
779
  // Construct the S3 URL for primary storage
750
780
  if (storage.endpoint && storage.bucketName) {
751
- envs['PL_PRIMARY_STORAGE_S3'] = `${storage.endpoint}${storage.bucketName}`;
781
+ envs["PL_PRIMARY_STORAGE_S3"] = `${storage.endpoint}${storage.bucketName}`;
752
782
  }
753
783
  if (storage.endpoint)
754
- envs['PL_PRIMARY_STORAGE_S3_ENDPOINT'] = storage.endpoint;
784
+ envs["PL_PRIMARY_STORAGE_S3_ENDPOINT"] = storage.endpoint;
755
785
  if (storage.presignEndpoint)
756
- envs['PL_PRIMARY_STORAGE_S3_EXTERNAL_ENDPOINT'] = storage.presignEndpoint;
786
+ envs["PL_PRIMARY_STORAGE_S3_EXTERNAL_ENDPOINT"] = storage.presignEndpoint;
757
787
  if (storage.region)
758
- envs['PL_PRIMARY_STORAGE_S3_REGION'] = storage.region;
788
+ envs["PL_PRIMARY_STORAGE_S3_REGION"] = storage.region;
759
789
  if (storage.key)
760
- envs['PL_PRIMARY_STORAGE_S3_KEY'] = storage.key;
790
+ envs["PL_PRIMARY_STORAGE_S3_KEY"] = storage.key;
761
791
  if (storage.secret)
762
- envs['PL_PRIMARY_STORAGE_S3_SECRET'] = storage.secret;
792
+ envs["PL_PRIMARY_STORAGE_S3_SECRET"] = storage.secret;
763
793
  break;
764
794
  }
765
- case 'LIBRARY': {
795
+ case "LIBRARY": {
766
796
  // Construct the S3 URL for library storage
767
797
  if (storage.endpoint && storage.bucketName) {
768
- envs['PL_DATA_LIBRARY_S3_URL'] = `library=${storage.endpoint}${storage.bucketName}`;
798
+ envs["PL_DATA_LIBRARY_S3_URL"] = `library=${storage.endpoint}${storage.bucketName}`;
769
799
  }
770
800
  if (storage.endpoint)
771
- envs['PL_DATA_LIBRARY_S3_ENDPOINT'] = `library=${storage.endpoint}`;
801
+ envs["PL_DATA_LIBRARY_S3_ENDPOINT"] = `library=${storage.endpoint}`;
772
802
  if (storage.presignEndpoint)
773
- envs['PL_DATA_LIBRARY_S3_EXTERNAL_ENDPOINT'] = `library=${storage.presignEndpoint}`;
803
+ envs["PL_DATA_LIBRARY_S3_EXTERNAL_ENDPOINT"] = `library=${storage.presignEndpoint}`;
774
804
  if (storage.region)
775
- envs['PL_DATA_LIBRARY_S3_REGION'] = `library=${storage.region}`;
805
+ envs["PL_DATA_LIBRARY_S3_REGION"] = `library=${storage.region}`;
776
806
  if (storage.key)
777
- envs['PL_DATA_LIBRARY_S3_KEY'] = `library=${storage.key}`;
807
+ envs["PL_DATA_LIBRARY_S3_KEY"] = `library=${storage.key}`;
778
808
  if (storage.secret)
779
- envs['PL_DATA_LIBRARY_S3_SECRET'] = `library=${storage.secret}`;
809
+ envs["PL_DATA_LIBRARY_S3_SECRET"] = `library=${storage.secret}`;
780
810
  break;
781
811
  }
782
812
  default:
783
813
  throw new Error(`Unknown storage ID: ${storageID}`);
784
814
  }
785
815
  return envs;
786
- case 'FS':
816
+ case "FS":
787
817
  switch (storageID) {
788
- case 'PRIMARY':
818
+ case "PRIMARY":
789
819
  if (storage.rootPath)
790
- envs['PL_PRIMARY_STORAGE_FS'] = storage.rootPath;
820
+ envs["PL_PRIMARY_STORAGE_FS"] = storage.rootPath;
791
821
  break;
792
- case 'LIBRARY':
822
+ case "LIBRARY":
793
823
  if (storage.rootPath)
794
- envs['PL_DATA_LIBRARY_FS_PATH'] = storage.rootPath;
824
+ envs["PL_DATA_LIBRARY_FS_PATH"] = storage.rootPath;
795
825
  break;
796
826
  default:
797
827
  throw new Error(`Unknown storage ID: ${storageID}`);
@@ -804,31 +834,31 @@ You can obtain the license from "https://platforma.bio/getlicense".`);
804
834
  }
805
835
  renderRunInfo(runInfo, indent = 10) {
806
836
  const report = [];
807
- const column = (t) => t.padStart(indent, ' ');
837
+ const column = (t) => t.padStart(indent, " ");
808
838
  if (runInfo.configPath) {
809
- report.push(`${column('config')}: ${runInfo.configPath}`);
839
+ report.push(`${column("config")}: ${runInfo.configPath}`);
810
840
  }
811
841
  if (runInfo.apiAddr) {
812
- report.push(`${column('API')}: ${runInfo.apiAddr}`);
842
+ report.push(`${column("API")}: ${runInfo.apiAddr}`);
813
843
  }
814
844
  else if (runInfo.apiPort) {
815
- report.push(`${column('API')}: 127.0.0.1:${runInfo.apiPort.toString()}`);
845
+ report.push(`${column("API")}: 127.0.0.1:${runInfo.apiPort.toString()}`);
816
846
  }
817
847
  else {
818
- report.push(`${column('API')}: 127.0.0.1:6345`);
848
+ report.push(`${column("API")}: 127.0.0.1:6345`);
819
849
  }
820
850
  if (runInfo.logPath) {
821
- report.push(`${column('log')}: ${runInfo.logPath}`);
851
+ report.push(`${column("log")}: ${runInfo.logPath}`);
822
852
  }
823
853
  const primaryType = runInfo.primary?.type;
824
854
  switch (primaryType) {
825
855
  case undefined:
826
856
  break;
827
- case 'FS':
828
- report.push(`${column('primary')}: ${runInfo.primary.rootPath}`);
857
+ case "FS":
858
+ report.push(`${column("primary")}: ${runInfo.primary.rootPath}`);
829
859
  break;
830
- case 'S3':
831
- report.push(`${column('primary')}: S3 at '${runInfo.primary.endpoint ?? 'AWS'}', bucket '${runInfo.primary.bucketName}', prefix: '${runInfo.primary.keyPrefix ?? ''}'`);
860
+ case "S3":
861
+ report.push(`${column("primary")}: S3 at '${runInfo.primary.endpoint ?? "AWS"}', bucket '${runInfo.primary.bucketName}', prefix: '${runInfo.primary.keyPrefix ?? ""}'`);
832
862
  break;
833
863
  default:
834
864
  util.assertNever();
@@ -837,22 +867,22 @@ You can obtain the license from "https://platforma.bio/getlicense".`);
837
867
  switch (libraryType) {
838
868
  case undefined:
839
869
  break;
840
- case 'FS':
841
- report.push(`${column('library')}: ${runInfo.library.rootPath}`);
870
+ case "FS":
871
+ report.push(`${column("library")}: ${runInfo.library.rootPath}`);
842
872
  break;
843
- case 'S3':
844
- report.push(`${column('library')}: S3 at '${runInfo.library.endpoint ?? 'AWS'}', bucket '${runInfo.library.bucketName}', prefix: '${runInfo.library.keyPrefix ?? ''}'`);
873
+ case "S3":
874
+ report.push(`${column("library")}: S3 at '${runInfo.library.endpoint ?? "AWS"}', bucket '${runInfo.library.bucketName}', prefix: '${runInfo.library.keyPrefix ?? ""}'`);
845
875
  break;
846
876
  default:
847
877
  util.assertNever();
848
878
  }
849
879
  if (runInfo.work) {
850
- report.push(`${column('workdirs')}: ${runInfo.work.rootPath}`);
880
+ report.push(`${column("workdirs")}: ${runInfo.work.rootPath}`);
851
881
  }
852
882
  if (runInfo.dbPath) {
853
- report.push(`${column('db')}: ${runInfo.dbPath}`);
883
+ report.push(`${column("db")}: ${runInfo.dbPath}`);
854
884
  }
855
- return report.join('\n');
885
+ return report.join("\n");
856
886
  }
857
887
  }
858
888
  function checkRunError(result, message) {
@@ -860,7 +890,7 @@ function checkRunError(result, message) {
860
890
  if (buffer.error) {
861
891
  throw buffer.error;
862
892
  }
863
- const msg = message ?? 'failed to run command';
893
+ const msg = message ?? "failed to run command";
864
894
  if (buffer.status !== 0) {
865
895
  throw new Error(`${msg}, process exited with code '${buffer.status}'`);
866
896
  }