@platforma-sdk/bootstrap 5.2.50 → 5.2.52

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 (176) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/block.cjs +106 -146
  3. package/dist/block.cjs.map +1 -1
  4. package/dist/block.js +100 -125
  5. package/dist/block.js.map +1 -1
  6. package/dist/cmd-opts.cjs +87 -177
  7. package/dist/cmd-opts.cjs.map +1 -1
  8. package/dist/cmd-opts.js +87 -172
  9. package/dist/cmd-opts.js.map +1 -1
  10. package/dist/commands/create-block.cjs +19 -20
  11. package/dist/commands/create-block.cjs.map +1 -1
  12. package/dist/commands/create-block.d.ts +12 -7
  13. package/dist/commands/create-block.js +17 -17
  14. package/dist/commands/create-block.js.map +1 -1
  15. package/dist/commands/reset.cjs +18 -21
  16. package/dist/commands/reset.cjs.map +1 -1
  17. package/dist/commands/reset.d.ts +12 -7
  18. package/dist/commands/reset.js +16 -18
  19. package/dist/commands/reset.js.map +1 -1
  20. package/dist/commands/start/docker/s3.cjs +64 -67
  21. package/dist/commands/start/docker/s3.cjs.map +1 -1
  22. package/dist/commands/start/docker/s3.d.ts +32 -27
  23. package/dist/commands/start/docker/s3.js +61 -64
  24. package/dist/commands/start/docker/s3.js.map +1 -1
  25. package/dist/commands/start/docker.cjs +64 -67
  26. package/dist/commands/start/docker.cjs.map +1 -1
  27. package/dist/commands/start/docker.d.ts +32 -27
  28. package/dist/commands/start/docker.js +61 -64
  29. package/dist/commands/start/docker.js.map +1 -1
  30. package/dist/commands/start/local/s3.cjs +101 -135
  31. package/dist/commands/start/local/s3.cjs.map +1 -1
  32. package/dist/commands/start/local/s3.d.ts +36 -31
  33. package/dist/commands/start/local/s3.js +97 -113
  34. package/dist/commands/start/local/s3.js.map +1 -1
  35. package/dist/commands/start/local.cjs +95 -122
  36. package/dist/commands/start/local.cjs.map +1 -1
  37. package/dist/commands/start/local.d.ts +34 -29
  38. package/dist/commands/start/local.js +91 -100
  39. package/dist/commands/start/local.js.map +1 -1
  40. package/dist/commands/start.cjs +18 -21
  41. package/dist/commands/start.cjs.map +1 -1
  42. package/dist/commands/start.d.ts +12 -7
  43. package/dist/commands/start.js +16 -18
  44. package/dist/commands/start.js.map +1 -1
  45. package/dist/commands/stop.cjs +22 -27
  46. package/dist/commands/stop.cjs.map +1 -1
  47. package/dist/commands/stop.d.ts +12 -7
  48. package/dist/commands/stop.js +20 -24
  49. package/dist/commands/stop.js.map +1 -1
  50. package/dist/commands/svc/create/arg-parser.cjs +102 -172
  51. package/dist/commands/svc/create/arg-parser.cjs.map +1 -1
  52. package/dist/commands/svc/create/arg-parser.js +102 -171
  53. package/dist/commands/svc/create/arg-parser.js.map +1 -1
  54. package/dist/commands/svc/create/docker/s3.cjs +78 -96
  55. package/dist/commands/svc/create/docker/s3.cjs.map +1 -1
  56. package/dist/commands/svc/create/docker/s3.d.ts +35 -30
  57. package/dist/commands/svc/create/docker/s3.js +75 -93
  58. package/dist/commands/svc/create/docker/s3.js.map +1 -1
  59. package/dist/commands/svc/create/docker.cjs +82 -103
  60. package/dist/commands/svc/create/docker.cjs.map +1 -1
  61. package/dist/commands/svc/create/docker.d.ts +35 -30
  62. package/dist/commands/svc/create/docker.js +79 -100
  63. package/dist/commands/svc/create/docker.js.map +1 -1
  64. package/dist/commands/svc/create/local/s3.cjs +107 -139
  65. package/dist/commands/svc/create/local/s3.cjs.map +1 -1
  66. package/dist/commands/svc/create/local/s3.d.ts +39 -34
  67. package/dist/commands/svc/create/local/s3.js +103 -117
  68. package/dist/commands/svc/create/local/s3.js.map +1 -1
  69. package/dist/commands/svc/create/local.cjs +101 -138
  70. package/dist/commands/svc/create/local.cjs.map +1 -1
  71. package/dist/commands/svc/create/local.d.ts +37 -32
  72. package/dist/commands/svc/create/local.js +97 -116
  73. package/dist/commands/svc/create/local.js.map +1 -1
  74. package/dist/commands/svc/delete.cjs +36 -38
  75. package/dist/commands/svc/delete.cjs.map +1 -1
  76. package/dist/commands/svc/delete.d.ts +16 -11
  77. package/dist/commands/svc/delete.js +34 -35
  78. package/dist/commands/svc/delete.js.map +1 -1
  79. package/dist/commands/svc/down.cjs +27 -30
  80. package/dist/commands/svc/down.cjs.map +1 -1
  81. package/dist/commands/svc/down.d.ts +15 -10
  82. package/dist/commands/svc/down.js +25 -27
  83. package/dist/commands/svc/down.js.map +1 -1
  84. package/dist/commands/svc/list.cjs +25 -29
  85. package/dist/commands/svc/list.cjs.map +1 -1
  86. package/dist/commands/svc/list.d.ts +9 -5
  87. package/dist/commands/svc/list.js +23 -26
  88. package/dist/commands/svc/list.js.map +1 -1
  89. package/dist/commands/svc/up.cjs +33 -49
  90. package/dist/commands/svc/up.cjs.map +1 -1
  91. package/dist/commands/svc/up.d.ts +15 -10
  92. package/dist/commands/svc/up.js +31 -46
  93. package/dist/commands/svc/up.js.map +1 -1
  94. package/dist/core.cjs +712 -881
  95. package/dist/core.cjs.map +1 -1
  96. package/dist/core.js +709 -877
  97. package/dist/core.js.map +1 -1
  98. package/dist/index.cjs +36 -36
  99. package/dist/index.cjs.map +1 -1
  100. package/dist/index.d.ts +37 -33
  101. package/dist/index.js +35 -34
  102. package/dist/index.js.map +1 -1
  103. package/dist/package.cjs +15 -36
  104. package/dist/package.cjs.map +1 -1
  105. package/dist/package.js +14 -14
  106. package/dist/package.js.map +1 -1
  107. package/dist/platforma.cjs +119 -148
  108. package/dist/platforma.cjs.map +1 -1
  109. package/dist/platforma.js +114 -122
  110. package/dist/platforma.js.map +1 -1
  111. package/dist/run.cjs +55 -58
  112. package/dist/run.cjs.map +1 -1
  113. package/dist/run.js +56 -56
  114. package/dist/run.js.map +1 -1
  115. package/dist/state.cjs +114 -141
  116. package/dist/state.cjs.map +1 -1
  117. package/dist/state.js +110 -139
  118. package/dist/state.js.map +1 -1
  119. package/dist/templates/compose.cjs +38 -65
  120. package/dist/templates/compose.cjs.map +1 -1
  121. package/dist/templates/compose.js +35 -63
  122. package/dist/templates/compose.js.map +1 -1
  123. package/dist/templates/pl-config.cjs +163 -165
  124. package/dist/templates/pl-config.cjs.map +1 -1
  125. package/dist/templates/pl-config.js +161 -163
  126. package/dist/templates/pl-config.js.map +1 -1
  127. package/dist/templates/types.cjs +24 -23
  128. package/dist/templates/types.cjs.map +1 -1
  129. package/dist/templates/types.js +24 -22
  130. package/dist/templates/types.js.map +1 -1
  131. package/dist/util.cjs +57 -74
  132. package/dist/util.cjs.map +1 -1
  133. package/dist/util.js +51 -72
  134. package/dist/util.js.map +1 -1
  135. package/package.json +6 -6
  136. package/dist/block.d.ts +0 -25
  137. package/dist/block.d.ts.map +0 -1
  138. package/dist/cmd-opts.d.ts +0 -89
  139. package/dist/cmd-opts.d.ts.map +0 -1
  140. package/dist/commands/create-block.d.ts.map +0 -1
  141. package/dist/commands/reset.d.ts.map +0 -1
  142. package/dist/commands/start/docker/s3.d.ts.map +0 -1
  143. package/dist/commands/start/docker.d.ts.map +0 -1
  144. package/dist/commands/start/local/s3.d.ts.map +0 -1
  145. package/dist/commands/start/local.d.ts.map +0 -1
  146. package/dist/commands/start.d.ts.map +0 -1
  147. package/dist/commands/stop.d.ts.map +0 -1
  148. package/dist/commands/svc/create/arg-parser.d.ts +0 -43
  149. package/dist/commands/svc/create/arg-parser.d.ts.map +0 -1
  150. package/dist/commands/svc/create/docker/s3.d.ts.map +0 -1
  151. package/dist/commands/svc/create/docker.d.ts.map +0 -1
  152. package/dist/commands/svc/create/local/s3.d.ts.map +0 -1
  153. package/dist/commands/svc/create/local.d.ts.map +0 -1
  154. package/dist/commands/svc/delete.d.ts.map +0 -1
  155. package/dist/commands/svc/down.d.ts.map +0 -1
  156. package/dist/commands/svc/list.d.ts.map +0 -1
  157. package/dist/commands/svc/up.d.ts.map +0 -1
  158. package/dist/core.d.ts +0 -105
  159. package/dist/core.d.ts.map +0 -1
  160. package/dist/index.d.ts.map +0 -1
  161. package/dist/package.d.ts +0 -7
  162. package/dist/package.d.ts.map +0 -1
  163. package/dist/platforma.d.ts +0 -24
  164. package/dist/platforma.d.ts.map +0 -1
  165. package/dist/run.d.ts +0 -13
  166. package/dist/run.d.ts.map +0 -1
  167. package/dist/state.d.ts +0 -63
  168. package/dist/state.d.ts.map +0 -1
  169. package/dist/templates/compose.d.ts +0 -14
  170. package/dist/templates/compose.d.ts.map +0 -1
  171. package/dist/templates/pl-config.d.ts +0 -6
  172. package/dist/templates/pl-config.d.ts.map +0 -1
  173. package/dist/templates/types.d.ts +0 -138
  174. package/dist/templates/types.d.ts.map +0 -1
  175. package/dist/util.d.ts +0 -18
  176. package/dist/util.d.ts.map +0 -1
package/dist/block.js CHANGED
@@ -1,156 +1,131 @@
1
- import { createWriteStream } from 'node:fs';
2
- import * as fs from 'node:fs/promises';
3
- import path from 'node:path';
4
- import { Writable } from 'node:stream';
5
- import os__default from 'node:os';
6
- import readlineSync from 'readline-sync';
7
- import { z } from 'zod';
8
- import decompress from 'decompress';
1
+ import os from "node:os";
2
+ import { createWriteStream } from "node:fs";
3
+ import path from "node:path";
4
+ import readlineSync from "readline-sync";
5
+ import * as fs$1 from "node:fs/promises";
6
+ import { Writable } from "node:stream";
7
+ import { z } from "zod";
8
+ import decompress from "decompress";
9
9
 
10
+ //#region src/block.ts
10
11
  const blockPlatformsToChoose = ["Python"];
11
12
  const allPlatforms = ["Tengo", "Python"];
12
13
  const CreateBlockPlatforms = z.union([z.literal("Tengo"), z.literal("Python")]);
13
14
  const CreateBlockOptions = z.object({
14
- npmOrgName: z.string().min(1),
15
- orgName: z.string().min(1, { message: `Organization name must be provided` }),
16
- blockName: z.string().min(1, { message: `Block name must be provided` }),
17
- softwarePlatforms: z.array(CreateBlockPlatforms).refine((p) => new Set(p).size === p.length, {
18
- message: "Must be an array of unique software platforms",
19
- }),
15
+ npmOrgName: z.string().min(1),
16
+ orgName: z.string().min(1, { message: `Organization name must be provided` }),
17
+ blockName: z.string().min(1, { message: `Block name must be provided` }),
18
+ softwarePlatforms: z.array(CreateBlockPlatforms).refine((p) => new Set(p).size === p.length, { message: "Must be an array of unique software platforms" })
20
19
  });
21
20
  /** Creates a block by cloning block-boilerplate repository. */
22
21
  async function createBlock(logger) {
23
- const { npmOrgName, orgName, blockName, softwarePlatforms } = askForOptions();
24
- const targetPath = path.join(process.cwd(), blockName);
25
- logger.info(`Downloading boilerplate code...`);
26
- await downloadAndUnzip(
27
- // 'https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/software_platforms.zip',
28
- // 'platforma-block-boilerplate-software_platforms',
29
- "https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip", "platforma-block-boilerplate-main", targetPath);
30
- const platformsToRemove = allPlatforms.filter((p) => softwarePlatforms.indexOf(p) < 0);
31
- const noPlatforms = blockPlatformsToChoose.length == platformsToRemove.length;
32
- logger.info(`Keep platforms '${softwarePlatforms}', remove: '${platformsToRemove}'. Will remove all platforms? ${noPlatforms}`);
33
- for (const p of platformsToRemove) {
34
- await removePlatform(targetPath, p);
35
- }
36
- if (noPlatforms) {
37
- await removePlatformsCompletely(targetPath);
38
- }
39
- logger.info(`Replace everything in the template with provided options...`);
40
- replaceRegexInAllFiles(targetPath, [
41
- // '@' literal ensures only npm org name will be renamed,
42
- // as public registry for software also is called platforma-open, but without '@'.
43
- // Also, don't rename an organization for runenv-python-3 package.
44
- { from: /@platforma-open(?!.*runenv-python-3)/g, to: `@${npmOrgName}` },
45
- { from: /my-org/g, to: orgName },
46
- { from: /block-boilerplate/g, to: blockName },
47
- ]);
22
+ const { npmOrgName, orgName, blockName, softwarePlatforms } = askForOptions();
23
+ const targetPath = path.join(process.cwd(), blockName);
24
+ logger.info(`Downloading boilerplate code...`);
25
+ await downloadAndUnzip("https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip", "platforma-block-boilerplate-main", targetPath);
26
+ const platformsToRemove = allPlatforms.filter((p) => softwarePlatforms.indexOf(p) < 0);
27
+ const noPlatforms = blockPlatformsToChoose.length == platformsToRemove.length;
28
+ logger.info(`Keep platforms '${softwarePlatforms}', remove: '${platformsToRemove}'. Will remove all platforms? ${noPlatforms}`);
29
+ for (const p of platformsToRemove) await removePlatform(targetPath, p);
30
+ if (noPlatforms) await removePlatformsCompletely(targetPath);
31
+ logger.info(`Replace everything in the template with provided options...`);
32
+ replaceRegexInAllFiles(targetPath, [
33
+ {
34
+ from: /@platforma-open(?!.*runenv-python-3)/g,
35
+ to: `@${npmOrgName}`
36
+ },
37
+ {
38
+ from: /my-org/g,
39
+ to: orgName
40
+ },
41
+ {
42
+ from: /block-boilerplate/g,
43
+ to: blockName
44
+ }
45
+ ]);
48
46
  }
49
47
  function askForOptions() {
50
- let npmOrgName = readlineSync.question('Write an organization name for npm. Default is "platforma-open": ');
51
- if (npmOrgName === "") {
52
- npmOrgName = "platforma-open";
53
- }
54
- let orgName = "";
55
- while (orgName.length < 1)
56
- orgName = readlineSync.question('Write an organization name, e.g. "my-org": ');
57
- let blockName = "";
58
- while (blockName.length < 1)
59
- blockName = readlineSync.question('Write a name of the block, e.g. "hello-world": ');
60
- const needSoftware = readlineSync.keyInYN("Create package for block's software?");
61
- let softwarePlatforms = ["Tengo"];
62
- if (needSoftware) {
63
- while (softwarePlatforms.length < allPlatforms.length) {
64
- const index = readlineSync.keyInSelect(blockPlatformsToChoose, "Choose software platform:");
65
- if (index < 0)
66
- break;
67
- softwarePlatforms.push(blockPlatformsToChoose[index]);
68
- }
69
- }
70
- softwarePlatforms = Array.from(new Set(softwarePlatforms)).sort();
71
- const result = CreateBlockOptions.safeParse({
72
- npmOrgName,
73
- orgName,
74
- blockName,
75
- softwarePlatforms,
76
- });
77
- if (!result.success && result.error.issues.length) {
78
- throw new Error(result.error.issues.map((i) => i.message).join("; "));
79
- }
80
- return result.data;
48
+ let npmOrgName = readlineSync.question("Write an organization name for npm. Default is \"platforma-open\": ");
49
+ if (npmOrgName === "") npmOrgName = "platforma-open";
50
+ let orgName = "";
51
+ while (orgName.length < 1) orgName = readlineSync.question("Write an organization name, e.g. \"my-org\": ");
52
+ let blockName = "";
53
+ while (blockName.length < 1) blockName = readlineSync.question("Write a name of the block, e.g. \"hello-world\": ");
54
+ const needSoftware = readlineSync.keyInYN("Create package for block's software?");
55
+ let softwarePlatforms = ["Tengo"];
56
+ if (needSoftware) while (softwarePlatforms.length < allPlatforms.length) {
57
+ const index = readlineSync.keyInSelect(blockPlatformsToChoose, "Choose software platform:");
58
+ if (index < 0) break;
59
+ softwarePlatforms.push(blockPlatformsToChoose[index]);
60
+ }
61
+ softwarePlatforms = Array.from(new Set(softwarePlatforms)).sort();
62
+ const result = CreateBlockOptions.safeParse({
63
+ npmOrgName,
64
+ orgName,
65
+ blockName,
66
+ softwarePlatforms
67
+ });
68
+ if (!result.success && result.error.issues.length) throw new Error(result.error.issues.map((i) => i.message).join("; "));
69
+ return result.data;
81
70
  }
82
71
  async function downloadAndUnzip(url, pathInArchive, outputPath) {
83
- const response = await fetch(url);
84
- const content = await response.blob();
85
- const tmpDir = await fs.mkdtemp(path.join(os__default.tmpdir(), "create-repo"));
86
- const tmpFile = path.join(tmpDir, "packed-repo.zip");
87
- const f = Writable.toWeb(createWriteStream(tmpFile));
88
- await content.stream().pipeTo(f);
89
- const tmpRepo = path.join(tmpDir, "unpacked-repo");
90
- await fs.mkdir(tmpRepo);
91
- await decompress(tmpFile, tmpRepo);
92
- await fs.cp(path.join(tmpRepo, pathInArchive), outputPath, { recursive: true });
72
+ const content = await (await fetch(url)).blob();
73
+ const tmpDir = await fs$1.mkdtemp(path.join(os.tmpdir(), "create-repo"));
74
+ const tmpFile = path.join(tmpDir, "packed-repo.zip");
75
+ const f = Writable.toWeb(createWriteStream(tmpFile));
76
+ await content.stream().pipeTo(f);
77
+ const tmpRepo = path.join(tmpDir, "unpacked-repo");
78
+ await fs$1.mkdir(tmpRepo);
79
+ await decompress(tmpFile, tmpRepo);
80
+ await fs$1.cp(path.join(tmpRepo, pathInArchive), outputPath, { recursive: true });
93
81
  }
94
82
  /** Removes a bunch of dependencies to the platform. */
95
83
  async function removePlatform(dir, platform) {
96
- const p = platform.toLowerCase();
97
- // Remove <PlAlert> line from MainPage.vue
98
- // https://regex101.com/r/oCTyHk/1
99
- await deleteRegexInFile(path.join(dir, "ui", "src", "pages", "MainPage.vue"), new RegExp(`.*${p}Message.*\\n`, "g"));
100
- // Remove an output from the model.
101
- await deleteRegexInFile(path.join(dir, "model", "src", "index.ts"), new RegExp(`.*${p}Message.*\\n\\n`, "g"));
102
- // This regexp represents a block of code until the empty line.
103
- // https://regex101.com/r/Os8kX1/1
104
- await deleteRegexInFile(path.join(dir, "workflow", "src", "main.tpl.tengo"), new RegExp(`.*${p}.*exec.builder.*[\\s\\S]*?\\n\\n`, "g"));
105
- // Remove a line from the workflow output.
106
- // https://regex101.com/r/PkHwQ8/1
107
- await deleteRegexInFile(path.join(dir, "workflow", "src", "main.tpl.tengo"), new RegExp(`.*${p}Message.*\\n`, "g"));
108
- // Remove 2 lines: the one with the language message and the one with expect
109
- await deleteRegexInFile(path.join(dir, "workflow", "src", "wf.test.ts"), new RegExp(`.*${p}Message.*\\n.*expect.*\\n\\n`, "g"));
110
- await fs.rm(path.join(dir, "software", `src_${p}`), { recursive: true });
111
- await replaceInFile(path.join(dir, "software", "package.json"), (content) => {
112
- const json = JSON.parse(content);
113
- delete json["block-software"]["artifacts"][`hello-${p}-artifact`];
114
- delete json["block-software"]["entrypoints"][`hello-world-${p}`];
115
- return JSON.stringify(json, null, 2);
116
- });
84
+ const p = platform.toLowerCase();
85
+ await deleteRegexInFile(path.join(dir, "ui", "src", "pages", "MainPage.vue"), new RegExp(`.*${p}Message.*\\n`, "g"));
86
+ await deleteRegexInFile(path.join(dir, "model", "src", "index.ts"), new RegExp(`.*${p}Message.*\\n\\n`, "g"));
87
+ await deleteRegexInFile(path.join(dir, "workflow", "src", "main.tpl.tengo"), new RegExp(`.*${p}.*exec.builder.*[\\s\\S]*?\\n\\n`, "g"));
88
+ await deleteRegexInFile(path.join(dir, "workflow", "src", "main.tpl.tengo"), new RegExp(`.*${p}Message.*\\n`, "g"));
89
+ await deleteRegexInFile(path.join(dir, "workflow", "src", "wf.test.ts"), new RegExp(`.*${p}Message.*\\n.*expect.*\\n\\n`, "g"));
90
+ await fs$1.rm(path.join(dir, "software", `src_${p}`), { recursive: true });
91
+ await replaceInFile(path.join(dir, "software", "package.json"), (content) => {
92
+ const json = JSON.parse(content);
93
+ delete json["block-software"]["artifacts"][`hello-${p}-artifact`];
94
+ delete json["block-software"]["entrypoints"][`hello-world-${p}`];
95
+ return JSON.stringify(json, null, 2);
96
+ });
117
97
  }
118
98
  /** Removes software directory completely and all references to it from the workspace. */
119
99
  async function removePlatformsCompletely(dir) {
120
- await fs.rm(path.join(dir, "software"), { recursive: true });
121
- await replaceInFile(path.join(dir, "workflow", "package.json"), (content) => {
122
- const json = JSON.parse(content);
123
- delete json["dependencies"]["@platforma-open/my-org.block-boilerplate.software"];
124
- return JSON.stringify(json, null, 2);
125
- });
126
- await deleteRegexInFile(path.join(dir, "pnpm-workspace.yaml"), /.*- software$\n/gm);
100
+ await fs$1.rm(path.join(dir, "software"), { recursive: true });
101
+ await replaceInFile(path.join(dir, "workflow", "package.json"), (content) => {
102
+ const json = JSON.parse(content);
103
+ delete json["dependencies"]["@platforma-open/my-org.block-boilerplate.software"];
104
+ return JSON.stringify(json, null, 2);
105
+ });
106
+ await deleteRegexInFile(path.join(dir, "pnpm-workspace.yaml"), /.*- software$\n/gm);
127
107
  }
128
108
  async function replaceRegexInAllFiles(dir, patterns) {
129
- const files = await getAllFiles(dir);
130
- for (const { from, to } of patterns) {
131
- for (const fPath of files) {
132
- await replaceRegexInFile(fPath, from, to);
133
- }
134
- }
109
+ const files = await getAllFiles(dir);
110
+ for (const { from, to } of patterns) for (const fPath of files) await replaceRegexInFile(fPath, from, to);
135
111
  }
136
112
  async function getAllFiles(dir) {
137
- const allDirents = await fs.readdir(dir, {
138
- withFileTypes: true,
139
- recursive: true,
140
- });
141
- return allDirents.filter((f) => f.isFile()).map((f) => path.join(f.parentPath, f.name));
113
+ return (await fs$1.readdir(dir, {
114
+ withFileTypes: true,
115
+ recursive: true
116
+ })).filter((f) => f.isFile()).map((f) => path.join(f.parentPath, f.name));
142
117
  }
143
118
  async function replaceInFile(fPath, replacer) {
144
- const content = await fs.readFile(fPath);
145
- const newContent = replacer(content.toString());
146
- await fs.writeFile(fPath, newContent);
119
+ const newContent = replacer((await fs$1.readFile(fPath)).toString());
120
+ await fs$1.writeFile(fPath, newContent);
147
121
  }
148
122
  async function replaceRegexInFile(fPath, from, to) {
149
- return await replaceInFile(fPath, (content) => content.replaceAll(from, to));
123
+ return await replaceInFile(fPath, (content) => content.replaceAll(from, to));
150
124
  }
151
125
  async function deleteRegexInFile(fPath, what) {
152
- return await replaceRegexInFile(fPath, what, "");
126
+ return await replaceRegexInFile(fPath, what, "");
153
127
  }
154
128
 
129
+ //#endregion
155
130
  export { createBlock };
156
- //# sourceMappingURL=block.js.map
131
+ //# sourceMappingURL=block.js.map
package/dist/block.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"block.js","sources":["../src/block.ts"],"sourcesContent":["import { createWriteStream } from \"node:fs\";\nimport * as fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type winston from \"winston\";\nimport { Writable } from \"node:stream\";\nimport os from \"node:os\";\nimport readlineSync from \"readline-sync\";\nimport { z } from \"zod\";\nimport decompress from \"decompress\";\n\nconst blockPlatformsToChoose = [\"Python\"];\nconst allPlatforms = [\"Tengo\", \"Python\"] as const;\nconst CreateBlockPlatforms = z.union([z.literal(\"Tengo\"), z.literal(\"Python\")]);\nexport type CreateBlockPlatform = z.infer<typeof CreateBlockPlatforms>;\n\nconst CreateBlockOptions = z.object({\n npmOrgName: z.string().min(1),\n orgName: z.string().min(1, { message: `Organization name must be provided` }),\n blockName: z.string().min(1, { message: `Block name must be provided` }),\n softwarePlatforms: z.array(CreateBlockPlatforms).refine((p) => new Set(p).size === p.length, {\n message: \"Must be an array of unique software platforms\",\n }),\n});\nexport type CreateBlockOptions = z.infer<typeof CreateBlockOptions>;\n\n/** Creates a block by cloning block-boilerplate repository. */\nexport async function createBlock(logger: winston.Logger) {\n const { npmOrgName, orgName, blockName, softwarePlatforms } = askForOptions();\n const targetPath = path.join(process.cwd(), blockName);\n\n logger.info(`Downloading boilerplate code...`);\n await downloadAndUnzip(\n // 'https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/software_platforms.zip',\n // 'platforma-block-boilerplate-software_platforms',\n \"https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip\",\n \"platforma-block-boilerplate-main\",\n targetPath,\n );\n\n const platformsToRemove = allPlatforms.filter((p) => softwarePlatforms.indexOf(p) < 0);\n const noPlatforms = blockPlatformsToChoose.length == platformsToRemove.length;\n logger.info(\n `Keep platforms '${softwarePlatforms}', remove: '${platformsToRemove}'. Will remove all platforms? ${noPlatforms}`,\n );\n for (const p of platformsToRemove) {\n await removePlatform(targetPath, p);\n }\n if (noPlatforms) {\n await removePlatformsCompletely(targetPath);\n }\n\n logger.info(`Replace everything in the template with provided options...`);\n replaceRegexInAllFiles(targetPath, [\n // '@' literal ensures only npm org name will be renamed,\n // as public registry for software also is called platforma-open, but without '@'.\n // Also, don't rename an organization for runenv-python-3 package.\n { from: /@platforma-open(?!.*runenv-python-3)/g, to: `@${npmOrgName}` },\n\n { from: /my-org/g, to: orgName },\n\n { from: /block-boilerplate/g, to: blockName },\n ]);\n}\n\nfunction askForOptions(): CreateBlockOptions {\n let npmOrgName = readlineSync.question(\n 'Write an organization name for npm. Default is \"platforma-open\": ',\n );\n if (npmOrgName === \"\") {\n npmOrgName = \"platforma-open\";\n }\n\n let orgName = \"\";\n while (orgName.length < 1)\n orgName = readlineSync.question('Write an organization name, e.g. \"my-org\": ');\n\n let blockName = \"\";\n while (blockName.length < 1)\n blockName = readlineSync.question('Write a name of the block, e.g. \"hello-world\": ');\n\n const needSoftware = readlineSync.keyInYN(\"Create package for block's software?\");\n let softwarePlatforms = [\"Tengo\"];\n if (needSoftware) {\n while (softwarePlatforms.length < allPlatforms.length) {\n const index = readlineSync.keyInSelect(blockPlatformsToChoose, \"Choose software platform:\");\n if (index < 0) break;\n softwarePlatforms.push(blockPlatformsToChoose[index]);\n }\n }\n softwarePlatforms = Array.from(new Set(softwarePlatforms)).sort();\n\n const result = CreateBlockOptions.safeParse({\n npmOrgName,\n orgName,\n blockName,\n softwarePlatforms,\n });\n if (!result.success && result.error.issues.length) {\n throw new Error(result.error.issues.map((i) => i.message).join(\"; \"));\n }\n\n return result.data!;\n}\n\nasync function downloadAndUnzip(url: string, pathInArchive: string, outputPath: string) {\n const response = await fetch(url);\n const content = await response.blob();\n\n const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), \"create-repo\"));\n\n const tmpFile = path.join(tmpDir, \"packed-repo.zip\");\n const f = Writable.toWeb(createWriteStream(tmpFile));\n await content.stream().pipeTo(f);\n\n const tmpRepo = path.join(tmpDir, \"unpacked-repo\");\n await fs.mkdir(tmpRepo);\n await decompress(tmpFile, tmpRepo);\n\n await fs.cp(path.join(tmpRepo, pathInArchive), outputPath, { recursive: true });\n}\n\n/** Removes a bunch of dependencies to the platform. */\nasync function removePlatform(dir: string, platform: CreateBlockPlatform) {\n const p = platform.toLowerCase();\n\n // Remove <PlAlert> line from MainPage.vue\n // https://regex101.com/r/oCTyHk/1\n await deleteRegexInFile(\n path.join(dir, \"ui\", \"src\", \"pages\", \"MainPage.vue\"),\n new RegExp(`.*${p}Message.*\\\\n`, \"g\"),\n );\n\n // Remove an output from the model.\n await deleteRegexInFile(\n path.join(dir, \"model\", \"src\", \"index.ts\"),\n new RegExp(`.*${p}Message.*\\\\n\\\\n`, \"g\"),\n );\n\n // This regexp represents a block of code until the empty line.\n // https://regex101.com/r/Os8kX1/1\n await deleteRegexInFile(\n path.join(dir, \"workflow\", \"src\", \"main.tpl.tengo\"),\n new RegExp(`.*${p}.*exec.builder.*[\\\\s\\\\S]*?\\\\n\\\\n`, \"g\"),\n );\n\n // Remove a line from the workflow output.\n // https://regex101.com/r/PkHwQ8/1\n await deleteRegexInFile(\n path.join(dir, \"workflow\", \"src\", \"main.tpl.tengo\"),\n new RegExp(`.*${p}Message.*\\\\n`, \"g\"),\n );\n\n // Remove 2 lines: the one with the language message and the one with expect\n await deleteRegexInFile(\n path.join(dir, \"workflow\", \"src\", \"wf.test.ts\"),\n new RegExp(`.*${p}Message.*\\\\n.*expect.*\\\\n\\\\n`, \"g\"),\n );\n\n await fs.rm(path.join(dir, \"software\", `src_${p}`), { recursive: true });\n\n await replaceInFile(path.join(dir, \"software\", \"package.json\"), (content) => {\n const json = JSON.parse(content);\n delete json[\"block-software\"][\"artifacts\"][`hello-${p}-artifact`];\n delete json[\"block-software\"][\"entrypoints\"][`hello-world-${p}`];\n return JSON.stringify(json, null, 2);\n });\n}\n\n/** Removes software directory completely and all references to it from the workspace. */\nasync function removePlatformsCompletely(dir: string) {\n await fs.rm(path.join(dir, \"software\"), { recursive: true });\n\n await replaceInFile(path.join(dir, \"workflow\", \"package.json\"), (content) => {\n const json = JSON.parse(content);\n delete json[\"dependencies\"][\"@platforma-open/my-org.block-boilerplate.software\"];\n return JSON.stringify(json, null, 2);\n });\n\n await deleteRegexInFile(path.join(dir, \"pnpm-workspace.yaml\"), /.*- software$\\n/gm);\n}\n\nasync function replaceRegexInAllFiles(dir: string, patterns: { from: RegExp; to: string }[]) {\n const files = await getAllFiles(dir);\n for (const { from, to } of patterns) {\n for (const fPath of files) {\n await replaceRegexInFile(fPath, from, to);\n }\n }\n}\n\nasync function getAllFiles(dir: string): Promise<string[]> {\n const allDirents = await fs.readdir(dir, {\n withFileTypes: true,\n recursive: true,\n });\n\n return allDirents.filter((f: any) => f.isFile()).map((f: any) => path.join(f.parentPath, f.name));\n}\n\nasync function replaceInFile(fPath: string, replacer: (content: string) => any) {\n const content = await fs.readFile(fPath);\n const newContent = replacer(content.toString());\n await fs.writeFile(fPath, newContent);\n}\n\nasync function replaceRegexInFile(fPath: string, from: RegExp, to: string) {\n return await replaceInFile(fPath, (content) => content.replaceAll(from, to));\n}\n\nasync function deleteRegexInFile(fPath: string, what: RegExp) {\n return await replaceRegexInFile(fPath, what, \"\");\n}\n"],"names":["os"],"mappings":";;;;;;;;;AAUA,MAAM,sBAAsB,GAAG,CAAC,QAAQ,CAAC;AACzC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAU;AACjD,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAG/E,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7B,IAAA,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAA,kCAAA,CAAoC,EAAE,CAAC;AAC7E,IAAA,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAA,2BAAA,CAA6B,EAAE,CAAC;IACxE,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE;AAC3F,QAAA,OAAO,EAAE,+CAA+C;KACzD,CAAC;AACH,CAAA,CAAC;AAGF;AACO,eAAe,WAAW,CAAC,MAAsB,EAAA;AACtD,IAAA,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,aAAa,EAAE;AAC7E,IAAA,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GA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AU,CAAC,MAAM,CAAC,CAAC,CAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAM,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AACnG;AAEA,eAAe,aAAa,CAAC,KAAa,EAAE,QAAkC,EAAA;IAC5E,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;IACxC,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC/C,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC;AACvC;AAEA,eAAe,kBAAkB,CAAC,KAAa,EAAE,IAAY,EAAE,EAAU,EAAA;AACvE,IAAA,OAAO,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,OAAO,KAAK,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC9E;AAEA,eAAe,iBAAiB,CAAC,KAAa,EAAE,IAAY,EAAA;IAC1D,OAAO,MAAM,kBAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;AAClD;;;;"}
1
+ {"version":3,"file":"block.js","names":["fs"],"sources":["../src/block.ts"],"sourcesContent":["import { createWriteStream } from \"node:fs\";\nimport * as fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type winston from \"winston\";\nimport { Writable } from \"node:stream\";\nimport os from \"node:os\";\nimport readlineSync from \"readline-sync\";\nimport { z } from \"zod\";\nimport decompress from \"decompress\";\n\nconst blockPlatformsToChoose = [\"Python\"];\nconst allPlatforms = [\"Tengo\", \"Python\"] as const;\nconst CreateBlockPlatforms = z.union([z.literal(\"Tengo\"), z.literal(\"Python\")]);\nexport type CreateBlockPlatform = z.infer<typeof CreateBlockPlatforms>;\n\nconst CreateBlockOptions = z.object({\n npmOrgName: z.string().min(1),\n orgName: z.string().min(1, { message: `Organization name must be provided` }),\n blockName: z.string().min(1, { message: `Block name must be provided` }),\n softwarePlatforms: z.array(CreateBlockPlatforms).refine((p) => new Set(p).size === p.length, {\n message: \"Must be an array of unique software platforms\",\n }),\n});\nexport type CreateBlockOptions = z.infer<typeof CreateBlockOptions>;\n\n/** Creates a block by cloning block-boilerplate repository. */\nexport async function createBlock(logger: winston.Logger) {\n const { npmOrgName, orgName, blockName, softwarePlatforms } = askForOptions();\n const targetPath = path.join(process.cwd(), blockName);\n\n logger.info(`Downloading boilerplate code...`);\n await downloadAndUnzip(\n // 'https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/software_platforms.zip',\n // 'platforma-block-boilerplate-software_platforms',\n \"https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip\",\n \"platforma-block-boilerplate-main\",\n targetPath,\n );\n\n const platformsToRemove = allPlatforms.filter((p) => softwarePlatforms.indexOf(p) < 0);\n const noPlatforms = blockPlatformsToChoose.length == platformsToRemove.length;\n logger.info(\n `Keep platforms '${softwarePlatforms}', remove: '${platformsToRemove}'. Will remove all platforms? ${noPlatforms}`,\n );\n for (const p of platformsToRemove) {\n await removePlatform(targetPath, p);\n }\n if (noPlatforms) {\n await removePlatformsCompletely(targetPath);\n }\n\n logger.info(`Replace everything in the template with provided options...`);\n replaceRegexInAllFiles(targetPath, [\n // '@' literal ensures only npm org name will be renamed,\n // as public registry for software also is called platforma-open, but without '@'.\n // Also, don't rename an organization for runenv-python-3 package.\n { from: /@platforma-open(?!.*runenv-python-3)/g, to: `@${npmOrgName}` },\n\n { from: /my-org/g, to: orgName },\n\n { from: /block-boilerplate/g, to: blockName },\n ]);\n}\n\nfunction askForOptions(): CreateBlockOptions {\n let npmOrgName = readlineSync.question(\n 'Write an organization name for npm. Default is \"platforma-open\": ',\n );\n if (npmOrgName === \"\") {\n npmOrgName = \"platforma-open\";\n }\n\n let orgName = \"\";\n while (orgName.length < 1)\n orgName = readlineSync.question('Write an organization name, e.g. \"my-org\": ');\n\n let blockName = \"\";\n while (blockName.length < 1)\n blockName = readlineSync.question('Write a name of the block, e.g. \"hello-world\": ');\n\n const needSoftware = readlineSync.keyInYN(\"Create package for block's software?\");\n let softwarePlatforms = [\"Tengo\"];\n if (needSoftware) {\n while (softwarePlatforms.length < allPlatforms.length) {\n const index = readlineSync.keyInSelect(blockPlatformsToChoose, \"Choose software platform:\");\n if (index < 0) break;\n softwarePlatforms.push(blockPlatformsToChoose[index]);\n }\n }\n softwarePlatforms = Array.from(new Set(softwarePlatforms)).sort();\n\n const result = CreateBlockOptions.safeParse({\n npmOrgName,\n orgName,\n blockName,\n softwarePlatforms,\n });\n if (!result.success && result.error.issues.length) {\n throw new Error(result.error.issues.map((i) => i.message).join(\"; \"));\n }\n\n return result.data!;\n}\n\nasync function downloadAndUnzip(url: string, pathInArchive: string, outputPath: string) {\n const response = await fetch(url);\n const content = await response.blob();\n\n const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), \"create-repo\"));\n\n const tmpFile = path.join(tmpDir, \"packed-repo.zip\");\n const f = Writable.toWeb(createWriteStream(tmpFile));\n await content.stream().pipeTo(f);\n\n const tmpRepo = path.join(tmpDir, \"unpacked-repo\");\n await fs.mkdir(tmpRepo);\n await decompress(tmpFile, tmpRepo);\n\n await fs.cp(path.join(tmpRepo, pathInArchive), outputPath, { recursive: true });\n}\n\n/** Removes a bunch of dependencies to the platform. */\nasync function removePlatform(dir: string, platform: CreateBlockPlatform) {\n const p = platform.toLowerCase();\n\n // Remove <PlAlert> line from MainPage.vue\n // https://regex101.com/r/oCTyHk/1\n await deleteRegexInFile(\n path.join(dir, \"ui\", \"src\", \"pages\", \"MainPage.vue\"),\n new RegExp(`.*${p}Message.*\\\\n`, \"g\"),\n );\n\n // Remove an output from the model.\n await deleteRegexInFile(\n path.join(dir, \"model\", \"src\", \"index.ts\"),\n new RegExp(`.*${p}Message.*\\\\n\\\\n`, \"g\"),\n );\n\n // This regexp represents a block of code until the empty line.\n // https://regex101.com/r/Os8kX1/1\n await deleteRegexInFile(\n path.join(dir, \"workflow\", \"src\", \"main.tpl.tengo\"),\n new RegExp(`.*${p}.*exec.builder.*[\\\\s\\\\S]*?\\\\n\\\\n`, \"g\"),\n );\n\n // Remove a line from the workflow output.\n // https://regex101.com/r/PkHwQ8/1\n await deleteRegexInFile(\n path.join(dir, \"workflow\", \"src\", \"main.tpl.tengo\"),\n new RegExp(`.*${p}Message.*\\\\n`, \"g\"),\n );\n\n // Remove 2 lines: the one with the language message and the one with expect\n await deleteRegexInFile(\n path.join(dir, \"workflow\", \"src\", \"wf.test.ts\"),\n new RegExp(`.*${p}Message.*\\\\n.*expect.*\\\\n\\\\n`, \"g\"),\n );\n\n await fs.rm(path.join(dir, \"software\", `src_${p}`), { recursive: true });\n\n await replaceInFile(path.join(dir, \"software\", \"package.json\"), (content) => {\n const json = JSON.parse(content);\n delete json[\"block-software\"][\"artifacts\"][`hello-${p}-artifact`];\n delete json[\"block-software\"][\"entrypoints\"][`hello-world-${p}`];\n return JSON.stringify(json, null, 2);\n });\n}\n\n/** Removes software directory completely and all references to it from the workspace. */\nasync function removePlatformsCompletely(dir: string) {\n await fs.rm(path.join(dir, \"software\"), { recursive: true });\n\n await replaceInFile(path.join(dir, \"workflow\", \"package.json\"), (content) => {\n const json = JSON.parse(content);\n delete json[\"dependencies\"][\"@platforma-open/my-org.block-boilerplate.software\"];\n return JSON.stringify(json, null, 2);\n });\n\n await deleteRegexInFile(path.join(dir, \"pnpm-workspace.yaml\"), /.*- software$\\n/gm);\n}\n\nasync function replaceRegexInAllFiles(dir: string, patterns: { from: RegExp; to: string }[]) {\n const files = await getAllFiles(dir);\n for (const { from, to } of patterns) {\n for (const fPath of files) {\n await replaceRegexInFile(fPath, from, to);\n }\n }\n}\n\nasync function getAllFiles(dir: string): Promise<string[]> {\n const allDirents = await fs.readdir(dir, {\n withFileTypes: true,\n recursive: true,\n });\n\n return allDirents.filter((f: any) => f.isFile()).map((f: any) => path.join(f.parentPath, f.name));\n}\n\nasync function replaceInFile(fPath: string, replacer: (content: string) => any) {\n const content = await fs.readFile(fPath);\n const newContent = replacer(content.toString());\n await fs.writeFile(fPath, newContent);\n}\n\nasync function replaceRegexInFile(fPath: string, from: RegExp, to: string) {\n return await replaceInFile(fPath, (content) => content.replaceAll(from, to));\n}\n\nasync function deleteRegexInFile(fPath: string, what: RegExp) {\n return await replaceRegexInFile(fPath, what, \"\");\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAM,yBAAyB,CAAC,SAAS;AACzC,MAAM,eAAe,CAAC,SAAS,SAAS;AACxC,MAAM,uBAAuB,EAAE,MAAM,CAAC,EAAE,QAAQ,QAAQ,EAAE,EAAE,QAAQ,SAAS,CAAC,CAAC;AAG/E,MAAM,qBAAqB,EAAE,OAAO;CAClC,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC7B,SAAS,EAAE,QAAQ,CAAC,IAAI,GAAG,EAAE,SAAS,sCAAsC,CAAC;CAC7E,WAAW,EAAE,QAAQ,CAAC,IAAI,GAAG,EAAE,SAAS,+BAA+B,CAAC;CACxE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC,QAAQ,MAAM,IAAI,IAAI,EAAE,CAAC,SAAS,EAAE,QAAQ,EAC3F,SAAS,iDACV,CAAC;CACH,CAAC;;AAIF,eAAsB,YAAY,QAAwB;CACxD,MAAM,EAAE,YAAY,SAAS,WAAW,sBAAsB,eAAe;CAC7E,MAAM,aAAa,KAAK,KAAK,QAAQ,KAAK,EAAE,UAAU;AAEtD,QAAO,KAAK,kCAAkC;AAC9C,OAAM,iBAGJ,2FACA,oCACA,WACD;CAED,MAAM,oBAAoB,aAAa,QAAQ,MAAM,kBAAkB,QAAQ,EAAE,GAAG,EAAE;CACtF,MAAM,cAAc,uBAAuB,UAAU,kBAAkB;AACvE,QAAO,KACL,mBAAmB,kBAAkB,cAAc,kBAAkB,gCAAgC,cACtG;AACD,MAAK,MAAM,KAAK,kBACd,OAAM,eAAe,YAAY,EAAE;A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AMA,KAAG,GAAG,KAAK,KAAK,KAAK,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AAE5D,OAAM,cAAc,KAAK,KAAK,KAAK,YAAY,eAAe,GAAG,YAAY;EAC3E,MAAM,OAAO,KAAK,MAAM,QAAQ;AAChC,SAAO,KAAK,gBAAgB;AAC5B,SAAO,KAAK,UAAU,MAAM,MAAM,EAAE;GACpC;AAEF,OAAM,kBAAkB,KAAK,KAAK,KAAK,sBAAsB,EAAE,oBAAoB;;AAGrF,eAAe,uBAAuB,KAAa,UAA0C;CAC3F,MAAM,QAAQ,MAAM,YAAY,IAAI;AACpC,MAAK,MAAM,EAAE,MAAM,QAAQ,SACzB,MAAK,MAAM,SAAS,MAClB,OAAM,mBAAmB,OAAO,MAAM,GAAG;;AAK/C,eAAe,YAAY,KAAgC;AAMzD,SALmB,MAAMA,KAAG,QAAQ,KAAK;EACvC,eAAe;EACf,WAAW;EACZ,CAAC,EAEgB,QAAQ,MAAW,EAAE,QAAQ,CAAC,CAAC,KAAK,MAAW,KAAK,KAAK,EAAE,YAAY,EAAE,KAAK,CAAC;;AAGnG,eAAe,cAAc,OAAe,UAAoC;CAE9E,MAAM,aAAa,UADH,MAAMA,KAAG,SAAS,MAAM,EACJ,UAAU,CAAC;AAC/C,OAAMA,KAAG,UAAU,OAAO,WAAW;;AAGvC,eAAe,mBAAmB,OAAe,MAAc,IAAY;AACzE,QAAO,MAAM,cAAc,QAAQ,YAAY,QAAQ,WAAW,MAAM,GAAG,CAAC;;AAG9E,eAAe,kBAAkB,OAAe,MAAc;AAC5D,QAAO,MAAM,mBAAmB,OAAO,MAAM,GAAG"}
package/dist/cmd-opts.cjs CHANGED
@@ -1,194 +1,104 @@
1
- 'use strict';
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ let _oclif_core = require("@oclif/core");
2
3
 
3
- var core = require('@oclif/core');
4
-
5
- const GlobalFlags = {
6
- "log-level": core.Flags.string({
7
- description: "logging level",
8
- default: "info",
9
- options: ["error", "warn", "info", "debug"],
10
- required: false,
11
- }),
12
- };
13
- ({
14
- name: core.Flags.string({
15
- description: "name of instance",
16
- required: false,
17
- }),
18
- });
19
- const ImageFlag = {
20
- image: core.Flags.string({
21
- description: "use custom docker image to run platforma",
22
- }),
23
- };
24
- const VersionFlag = {
25
- version: core.Flags.string({
26
- description: "use custom platforma release (official docker image or binary package)",
27
- }),
28
- };
29
- const ArchFlag = {
30
- arch: core.Flags.string({
31
- description: "override architecture. You can start amd64 linux image on arm-based host (say, Apple M family processor). I.e. arm64, amd64, amd64/v2",
32
- }),
33
- };
4
+ //#region src/cmd-opts.ts
5
+ const GlobalFlags = { "log-level": _oclif_core.Flags.string({
6
+ description: "logging level",
7
+ default: "info",
8
+ options: [
9
+ "error",
10
+ "warn",
11
+ "info",
12
+ "debug"
13
+ ],
14
+ required: false
15
+ }) };
16
+ const InstanceName = { name: _oclif_core.Flags.string({
17
+ description: "name of instance",
18
+ required: false
19
+ }) };
20
+ const ImageFlag = { image: _oclif_core.Flags.string({ description: "use custom docker image to run platforma" }) };
21
+ const VersionFlag = { version: _oclif_core.Flags.string({ description: "use custom platforma release (official docker image or binary package)" }) };
22
+ const ArchFlag = { arch: _oclif_core.Flags.string({ description: "override architecture. You can start amd64 linux image on arm-based host (say, Apple M family processor). I.e. arm64, amd64, amd64/v2" }) };
34
23
  const LicenseFlags = {
35
- license: core.Flags.string({
36
- description: 'pass a license code. The license can be got from "https://platforma.bio/getlicense".',
37
- }),
38
- "license-file": core.Flags.file({
39
- exists: true,
40
- description: "specify a path to the file with a license. The license can be got from 'https://platforma.bio/getlicense'.",
41
- }),
24
+ license: _oclif_core.Flags.string({ description: "pass a license code. The license can be got from \"https://platforma.bio/getlicense\"." }),
25
+ "license-file": _oclif_core.Flags.file({
26
+ exists: true,
27
+ description: "specify a path to the file with a license. The license can be got from 'https://platforma.bio/getlicense'."
28
+ })
42
29
  };
43
30
  const AddressesFlags = {
44
- "grpc-port": core.Flags.integer({
45
- description: "port for Platforma Backend gRPC API. Default is 6345",
46
- env: "PLATFORMA_GRPC_PORT",
47
- }),
48
- "grpc-listen": core.Flags.string({
49
- description: "full listen addr for Platforma Backend gRPC API. Default is 127.0.0.1:6345",
50
- env: "PLATFORMA_GRPC_LISTEN",
51
- }),
52
- "monitoring-port": core.Flags.integer({
53
- description: "port for Platforma Backend monitoring API. Default is 9090",
54
- env: "PLATFORMA_MONITORING_PORT",
55
- }),
56
- "monitoring-listen": core.Flags.string({
57
- description: "full listen addr for Platforma Backend monitoring API. Default is 127.0.0.1:9090",
58
- env: "PLATFORMA_MONITORING_LISTEN",
59
- }),
60
- "debug-port": core.Flags.integer({
61
- description: "port for Platforma Backend debug API. Default is 9091",
62
- env: "PLATFORMA_DEBUG_PORT",
63
- }),
64
- "debug-listen": core.Flags.string({
65
- description: "full listen addr for Platforma Backend debug API. Default is 127.0.0.1:9091",
66
- env: "PLATFORMA_DEBUG_LISTEN",
67
- }),
31
+ "grpc-port": _oclif_core.Flags.integer({
32
+ description: "port for Platforma Backend gRPC API. Default is 6345",
33
+ env: "PLATFORMA_GRPC_PORT"
34
+ }),
35
+ "grpc-listen": _oclif_core.Flags.string({
36
+ description: "full listen addr for Platforma Backend gRPC API. Default is 127.0.0.1:6345",
37
+ env: "PLATFORMA_GRPC_LISTEN"
38
+ }),
39
+ "monitoring-port": _oclif_core.Flags.integer({
40
+ description: "port for Platforma Backend monitoring API. Default is 9090",
41
+ env: "PLATFORMA_MONITORING_PORT"
42
+ }),
43
+ "monitoring-listen": _oclif_core.Flags.string({
44
+ description: "full listen addr for Platforma Backend monitoring API. Default is 127.0.0.1:9090",
45
+ env: "PLATFORMA_MONITORING_LISTEN"
46
+ }),
47
+ "debug-port": _oclif_core.Flags.integer({
48
+ description: "port for Platforma Backend debug API. Default is 9091",
49
+ env: "PLATFORMA_DEBUG_PORT"
50
+ }),
51
+ "debug-listen": _oclif_core.Flags.string({
52
+ description: "full listen addr for Platforma Backend debug API. Default is 127.0.0.1:9091",
53
+ env: "PLATFORMA_DEBUG_LISTEN"
54
+ })
68
55
  };
69
56
  const S3AddressesFlags = {
70
- "s3-port": core.Flags.integer({
71
- description: "port that S3 will listen, default is 9000",
72
- default: 9000,
73
- env: "PLATFORMA_S3_PORT",
74
- }),
75
- "s3-console-port": core.Flags.integer({
76
- description: "port that a console of S3 will listen, default is 9001",
77
- default: 9001,
78
- env: "PLATFORMA_S3_CONSOLE_PORT",
79
- }),
80
- };
81
- const StorageFlag = {
82
- storage: core.Flags.string({
83
- description: "specify path on host to be used as storage for all Platforma Backend data",
84
- }),
85
- };
86
- const MinioPresignHostFlag = {
87
- ["minio-presign-host"]: core.Flags.boolean({
88
- description: "use 'minio' host instead of 'localhost' in presign URLs",
89
- }),
90
- };
91
- const MountFlag = {
92
- mount: core.Flags.string({
93
- multiple: true,
94
- description: "things to be mounted into platforma docker container. Targets will appear inside the container under the same absolute paths",
95
- }),
96
- };
97
- const PlLogFileFlag = {
98
- ["pl-log-file"]: core.Flags.file({
99
- description: "specify path for Platforma Backend log file",
100
- }),
101
- };
102
- const PlWorkdirFlag = {
103
- ["pl-workdir"]: core.Flags.file({
104
- description: "specify working directory for Platforma Backend process",
105
- }),
106
- };
107
- const PlBinaryFlag = {
108
- ["pl-binary"]: core.Flags.file({
109
- description: "start given Platforma Backend binary instead of automatically downloaded version",
110
- }),
111
- };
112
- const PlSourcesFlag = {
113
- ["pl-sources"]: core.Flags.file({
114
- description: "path to pl repository root: build Platforma Backend from sources and start the resulting binary",
115
- }),
116
- };
117
- const ConfigFlag = {
118
- config: core.Flags.string({
119
- description: "use custom Platforma Backend config",
120
- }),
121
- };
122
- ({
123
- "storage-primary": core.Flags.file({
124
- description: "specify path on host to be used as 'primary' storage",
125
- }),
126
- });
127
- const StorageWorkPathFlag = {
128
- "storage-work": core.Flags.file({
129
- description: "specify path on host to be used as 'work' storage",
130
- }),
131
- };
132
- ({
133
- "storage-primary": core.Flags.file({
134
- description: "specify path on host to be used as 'library' storage",
135
- }),
136
- });
137
- const StoragePrimaryURLFlag = {
138
- "storage-primary": core.Flags.string({
139
- description: "specify 'primary' storage destination URL.\n" +
140
- "\tfile:/path/to/dir for directory on local FS\n" +
141
- "\ts3://<bucket>/?region=<name> for real AWS bucket\n" +
142
- "\ts3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http\n" +
143
- "\ts3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https",
144
- }),
145
- };
146
- const StorageLibraryURLFlag = {
147
- "storage-library": core.Flags.string({
148
- description: "specify 'library' storage destination URL.\n" +
149
- "\tfile:/path/to/dir for directory on local FS\n" +
150
- "\ts3://<bucket>/?region=<name> for real AWS bucket\n" +
151
- "\ts3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http\n" +
152
- "\ts3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https",
153
- }),
154
- };
155
- const AuthEnabledFlag = {
156
- "auth-enabled": core.Flags.boolean({
157
- description: "enable authorization",
158
- }),
159
- };
160
- const HTPasswdFileFlag = {
161
- "auth-htpasswd-file": core.Flags.file({
162
- description: "path to .htpasswd file with Platforma users (static user DB auth source)",
163
- }),
164
- };
165
- const LDAPAddressFlag = {
166
- "auth-ldap-server": core.Flags.string({
167
- description: "address of LDAP server to use for auth in Platforma (auth source)",
168
- }),
169
- };
170
- const LDAPDefaultDNFlag = {
171
- "auth-ldap-default-dn": core.Flags.string({
172
- description: "DN to use when checking user with LDAP bind operation: e.g. cn=%u,ou=users,dc=example,dc=com",
173
- }),
174
- };
57
+ "s3-port": _oclif_core.Flags.integer({
58
+ description: "port that S3 will listen, default is 9000",
59
+ default: 9e3,
60
+ env: "PLATFORMA_S3_PORT"
61
+ }),
62
+ "s3-console-port": _oclif_core.Flags.integer({
63
+ description: "port that a console of S3 will listen, default is 9001",
64
+ default: 9001,
65
+ env: "PLATFORMA_S3_CONSOLE_PORT"
66
+ })
67
+ };
68
+ const StorageFlag = { storage: _oclif_core.Flags.string({ description: "specify path on host to be used as storage for all Platforma Backend data" }) };
69
+ const MinioPresignHostFlag = { ["minio-presign-host"]: _oclif_core.Flags.boolean({ description: "use 'minio' host instead of 'localhost' in presign URLs" }) };
70
+ const MountFlag = { mount: _oclif_core.Flags.string({
71
+ multiple: true,
72
+ description: "things to be mounted into platforma docker container. Targets will appear inside the container under the same absolute paths"
73
+ }) };
74
+ const PlLogFileFlag = { ["pl-log-file"]: _oclif_core.Flags.file({ description: "specify path for Platforma Backend log file" }) };
75
+ const PlWorkdirFlag = { ["pl-workdir"]: _oclif_core.Flags.file({ description: "specify working directory for Platforma Backend process" }) };
76
+ const PlBinaryFlag = { ["pl-binary"]: _oclif_core.Flags.file({ description: "start given Platforma Backend binary instead of automatically downloaded version" }) };
77
+ const PlSourcesFlag = { ["pl-sources"]: _oclif_core.Flags.file({ description: "path to pl repository root: build Platforma Backend from sources and start the resulting binary" }) };
78
+ const ConfigFlag = { config: _oclif_core.Flags.string({ description: "use custom Platforma Backend config" }) };
79
+ const StoragePrimaryPathFlag = { "storage-primary": _oclif_core.Flags.file({ description: "specify path on host to be used as 'primary' storage" }) };
80
+ const StorageWorkPathFlag = { "storage-work": _oclif_core.Flags.file({ description: "specify path on host to be used as 'work' storage" }) };
81
+ const StorageLibraryPathFlag = { "storage-primary": _oclif_core.Flags.file({ description: "specify path on host to be used as 'library' storage" }) };
82
+ const StoragePrimaryURLFlag = { "storage-primary": _oclif_core.Flags.string({ description: "specify 'primary' storage destination URL.\n file:/path/to/dir for directory on local FS\n s3://<bucket>/?region=<name> for real AWS bucket\n s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http\n s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https" }) };
83
+ const StorageLibraryURLFlag = { "storage-library": _oclif_core.Flags.string({ description: "specify 'library' storage destination URL.\n file:/path/to/dir for directory on local FS\n s3://<bucket>/?region=<name> for real AWS bucket\n s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http\n s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https" }) };
84
+ const AuthEnabledFlag = { "auth-enabled": _oclif_core.Flags.boolean({ description: "enable authorization" }) };
85
+ const HTPasswdFileFlag = { "auth-htpasswd-file": _oclif_core.Flags.file({ description: "path to .htpasswd file with Platforma users (static user DB auth source)" }) };
86
+ const LDAPAddressFlag = { "auth-ldap-server": _oclif_core.Flags.string({ description: "address of LDAP server to use for auth in Platforma (auth source)" }) };
87
+ const LDAPDefaultDNFlag = { "auth-ldap-default-dn": _oclif_core.Flags.string({ description: "DN to use when checking user with LDAP bind operation: e.g. cn=%u,ou=users,dc=example,dc=com" }) };
175
88
  const AuthFlags = {
176
- ...AuthEnabledFlag,
177
- ...HTPasswdFileFlag,
178
- ...LDAPAddressFlag,
179
- ...LDAPDefaultDNFlag,
89
+ ...AuthEnabledFlag,
90
+ ...HTPasswdFileFlag,
91
+ ...LDAPAddressFlag,
92
+ ...LDAPDefaultDNFlag
180
93
  };
181
94
 
95
+ //#endregion
182
96
  exports.AddressesFlags = AddressesFlags;
183
97
  exports.ArchFlag = ArchFlag;
184
- exports.AuthEnabledFlag = AuthEnabledFlag;
185
98
  exports.AuthFlags = AuthFlags;
186
99
  exports.ConfigFlag = ConfigFlag;
187
100
  exports.GlobalFlags = GlobalFlags;
188
- exports.HTPasswdFileFlag = HTPasswdFileFlag;
189
101
  exports.ImageFlag = ImageFlag;
190
- exports.LDAPAddressFlag = LDAPAddressFlag;
191
- exports.LDAPDefaultDNFlag = LDAPDefaultDNFlag;
192
102
  exports.LicenseFlags = LicenseFlags;
193
103
  exports.MinioPresignHostFlag = MinioPresignHostFlag;
194
104
  exports.MountFlag = MountFlag;
@@ -202,4 +112,4 @@ exports.StorageLibraryURLFlag = StorageLibraryURLFlag;
202
112
  exports.StoragePrimaryURLFlag = StoragePrimaryURLFlag;
203
113
  exports.StorageWorkPathFlag = StorageWorkPathFlag;
204
114
  exports.VersionFlag = VersionFlag;
205
- //# sourceMappingURL=cmd-opts.cjs.map
115
+ //# sourceMappingURL=cmd-opts.cjs.map