@platforma-sdk/package-builder-lib 1.1.0

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 (134) hide show
  1. package/assets/conda-dockerfile.template +45 -0
  2. package/assets/python-dockerfile.template +22 -0
  3. package/dist/_virtual/_rolldown/runtime.cjs +33 -0
  4. package/dist/_virtual/_rolldown/runtime.js +13 -0
  5. package/dist/core/archive.cjs +52 -0
  6. package/dist/core/archive.cjs.map +1 -0
  7. package/dist/core/archive.js +47 -0
  8. package/dist/core/archive.js.map +1 -0
  9. package/dist/core/conda/builder.cjs +226 -0
  10. package/dist/core/conda/builder.cjs.map +1 -0
  11. package/dist/core/conda/builder.js +220 -0
  12. package/dist/core/conda/builder.js.map +1 -0
  13. package/dist/core/conda/validate-spec.cjs +76 -0
  14. package/dist/core/conda/validate-spec.cjs.map +1 -0
  15. package/dist/core/conda/validate-spec.js +73 -0
  16. package/dist/core/conda/validate-spec.js.map +1 -0
  17. package/dist/core/core.cjs +403 -0
  18. package/dist/core/core.cjs.map +1 -0
  19. package/dist/core/core.d.ts +82 -0
  20. package/dist/core/core.d.ts.map +1 -0
  21. package/dist/core/core.js +397 -0
  22. package/dist/core/core.js.map +1 -0
  23. package/dist/core/docker-conda.cjs +75 -0
  24. package/dist/core/docker-conda.cjs.map +1 -0
  25. package/dist/core/docker-conda.js +71 -0
  26. package/dist/core/docker-conda.js.map +1 -0
  27. package/dist/core/docker-python.cjs +147 -0
  28. package/dist/core/docker-python.cjs.map +1 -0
  29. package/dist/core/docker-python.js +144 -0
  30. package/dist/core/docker-python.js.map +1 -0
  31. package/dist/core/docker.cjs +223 -0
  32. package/dist/core/docker.cjs.map +1 -0
  33. package/dist/core/docker.js +207 -0
  34. package/dist/core/docker.js.map +1 -0
  35. package/dist/core/envs.cjs +58 -0
  36. package/dist/core/envs.cjs.map +1 -0
  37. package/dist/core/envs.d.ts +26 -0
  38. package/dist/core/envs.d.ts.map +1 -0
  39. package/dist/core/envs.js +51 -0
  40. package/dist/core/envs.js.map +1 -0
  41. package/dist/core/package-info.cjs +450 -0
  42. package/dist/core/package-info.cjs.map +1 -0
  43. package/dist/core/package-info.d.ts +57 -0
  44. package/dist/core/package-info.d.ts.map +1 -0
  45. package/dist/core/package-info.js +447 -0
  46. package/dist/core/package-info.js.map +1 -0
  47. package/dist/core/paths.cjs +15 -0
  48. package/dist/core/paths.cjs.map +1 -0
  49. package/dist/core/paths.js +14 -0
  50. package/dist/core/paths.js.map +1 -0
  51. package/dist/core/resolver.cjs +99 -0
  52. package/dist/core/resolver.cjs.map +1 -0
  53. package/dist/core/resolver.js +95 -0
  54. package/dist/core/resolver.js.map +1 -0
  55. package/dist/core/schemas/artifacts.cjs +136 -0
  56. package/dist/core/schemas/artifacts.cjs.map +1 -0
  57. package/dist/core/schemas/artifacts.d.ts +280 -0
  58. package/dist/core/schemas/artifacts.d.ts.map +1 -0
  59. package/dist/core/schemas/artifacts.js +122 -0
  60. package/dist/core/schemas/artifacts.js.map +1 -0
  61. package/dist/core/schemas/entrypoints.cjs +43 -0
  62. package/dist/core/schemas/entrypoints.cjs.map +1 -0
  63. package/dist/core/schemas/entrypoints.d.ts +32 -0
  64. package/dist/core/schemas/entrypoints.d.ts.map +1 -0
  65. package/dist/core/schemas/entrypoints.js +41 -0
  66. package/dist/core/schemas/entrypoints.js.map +1 -0
  67. package/dist/core/schemas/sw-json.cjs +111 -0
  68. package/dist/core/schemas/sw-json.cjs.map +1 -0
  69. package/dist/core/schemas/sw-json.js +110 -0
  70. package/dist/core/schemas/sw-json.js.map +1 -0
  71. package/dist/core/storage.cjs +86 -0
  72. package/dist/core/storage.cjs.map +1 -0
  73. package/dist/core/storage.js +83 -0
  74. package/dist/core/storage.js.map +1 -0
  75. package/dist/core/sw-json-render.cjs +327 -0
  76. package/dist/core/sw-json-render.cjs.map +1 -0
  77. package/dist/core/sw-json-render.js +322 -0
  78. package/dist/core/sw-json-render.js.map +1 -0
  79. package/dist/core/util.cjs +313 -0
  80. package/dist/core/util.cjs.map +1 -0
  81. package/dist/core/util.d.ts +66 -0
  82. package/dist/core/util.d.ts.map +1 -0
  83. package/dist/core/util.js +281 -0
  84. package/dist/core/util.js.map +1 -0
  85. package/dist/defaults.cjs +54 -0
  86. package/dist/defaults.cjs.map +1 -0
  87. package/dist/defaults.d.ts +21 -0
  88. package/dist/defaults.d.ts.map +1 -0
  89. package/dist/defaults.js +37 -0
  90. package/dist/defaults.js.map +1 -0
  91. package/dist/index.cjs +31 -0
  92. package/dist/index.cjs.map +1 -0
  93. package/dist/index.d.ts +20 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +12 -0
  96. package/dist/index.js.map +1 -0
  97. package/package.json +56 -0
  98. package/src/__test__/Dockerfile +1 -0
  99. package/src/__test__/docker.test.ts +67 -0
  100. package/src/__test__/package.json +39 -0
  101. package/src/__test__/python-example/main.py +1 -0
  102. package/src/__test__/python-example/requirements.txt +0 -0
  103. package/src/__test__/vite.config.mts +7 -0
  104. package/src/core/__tests__/docker-conda.test.ts +145 -0
  105. package/src/core/__tests__/docker-entrypoint-generation.test.ts +119 -0
  106. package/src/core/__tests__/docker-python.test.ts +374 -0
  107. package/src/core/__tests__/publish-docker-images.test.ts +309 -0
  108. package/src/core/archive.ts +102 -0
  109. package/src/core/conda/builder.test.ts +71 -0
  110. package/src/core/conda/builder.ts +384 -0
  111. package/src/core/conda/validate-spec.test.ts +213 -0
  112. package/src/core/conda/validate-spec.ts +107 -0
  113. package/src/core/core.ts +835 -0
  114. package/src/core/docker-conda.ts +149 -0
  115. package/src/core/docker-python.ts +283 -0
  116. package/src/core/docker.ts +300 -0
  117. package/src/core/envs.ts +31 -0
  118. package/src/core/package-info.test.ts +82 -0
  119. package/src/core/package-info.ts +843 -0
  120. package/src/core/paths.ts +16 -0
  121. package/src/core/resolver.ts +195 -0
  122. package/src/core/schemas/artifacts.test.ts +72 -0
  123. package/src/core/schemas/artifacts.ts +279 -0
  124. package/src/core/schemas/entrypoints.test.ts +171 -0
  125. package/src/core/schemas/entrypoints.ts +150 -0
  126. package/src/core/schemas/sw-json.ts +216 -0
  127. package/src/core/schemas/test-artifacts.ts +362 -0
  128. package/src/core/storage.ts +125 -0
  129. package/src/core/sw-json-render.test.ts +215 -0
  130. package/src/core/sw-json-render.ts +682 -0
  131. package/src/core/util.ts +390 -0
  132. package/src/defaults.ts +38 -0
  133. package/src/index.ts +31 -0
  134. package/src/requirements.txt +1 -0
@@ -0,0 +1,313 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_envs = require("./envs.cjs");
3
+ let node_fs = require("node:fs");
4
+ node_fs = require_runtime.__toESM(node_fs);
5
+ let node_path = require("node:path");
6
+ node_path = require_runtime.__toESM(node_path);
7
+ let node_os = require("node:os");
8
+ node_os = require_runtime.__toESM(node_os);
9
+ let node_crypto = require("node:crypto");
10
+ let winston = require("winston");
11
+ winston = require_runtime.__toESM(winston);
12
+ //#region src/core/util.ts
13
+ var util_exports = /* @__PURE__ */ require_runtime.__exportAll({
14
+ AllPlatforms: () => AllPlatforms,
15
+ AllSoftwareSources: () => AllSoftwareSources,
16
+ Arches: () => Arches,
17
+ CLIError: () => CLIError,
18
+ CLIErrorClass: () => CLIErrorClass,
19
+ OSes: () => OSes,
20
+ artifactIDFromString: () => artifactIDFromString,
21
+ artifactIDToString: () => artifactIDToString,
22
+ assertNever: () => assertNever,
23
+ createLogger: () => createLogger,
24
+ currentArch: () => currentArch,
25
+ currentOS: () => currentOS,
26
+ currentPlatform: () => currentPlatform,
27
+ ensureDirsExist: () => ensureDirsExist,
28
+ findInstalledModule: () => findInstalledModule,
29
+ findNodeModules: () => findNodeModules,
30
+ findPackageRoot: () => findPackageRoot,
31
+ formatZodIssues: () => formatZodIssues,
32
+ hashDirMetaSync: () => hashDirMetaSync,
33
+ hashDirSync: () => hashDirSync,
34
+ indentText: () => indentText,
35
+ isDevLocalMode: () => isDevLocalMode,
36
+ isPlatformSupported: () => isPlatformSupported,
37
+ joinPlatform: () => joinPlatform,
38
+ packageJsonName: () => packageJsonName,
39
+ rSplit: () => rSplit,
40
+ softwareConfigName: () => softwareConfigName,
41
+ splitPlatform: () => splitPlatform,
42
+ toInt: () => toInt,
43
+ trimPrefix: () => trimPrefix,
44
+ trimSuffix: () => trimSuffix,
45
+ urlJoin: () => urlJoin,
46
+ wrapErr: () => wrapErr
47
+ });
48
+ const packageJsonName = "package.json";
49
+ const softwareConfigName = "package.json";
50
+ function assertNever(_a) {
51
+ throw new Error(`code logic error: assertNever() call for ${JSON.stringify(_a)}`);
52
+ }
53
+ function trimPrefix(str, prefix) {
54
+ if (str.startsWith(prefix)) return str.slice(prefix.length);
55
+ return str;
56
+ }
57
+ function trimSuffix(str, suffix) {
58
+ if (str.endsWith(suffix)) return str.slice(0, -suffix.length);
59
+ return str;
60
+ }
61
+ function hashDirMetaSync(folder, hasher) {
62
+ const hash = hasher ? hasher : (0, node_crypto.createHash)("sha256");
63
+ const info = node_fs.default.readdirSync(folder, { withFileTypes: true });
64
+ for (const item of info) {
65
+ const fullPath = node_path.join(folder, item.name);
66
+ if (item.isFile()) {
67
+ const statInfo = node_fs.default.statSync(fullPath);
68
+ const fileInfo = `${fullPath}:${statInfo.size}:${statInfo.mtimeMs}`;
69
+ hash.update(fileInfo);
70
+ } else if (item.isDirectory()) hashDirMetaSync(fullPath, hash);
71
+ }
72
+ return hash;
73
+ }
74
+ function hashDirSync(rootDir, hasher, subdir) {
75
+ const hash = hasher ? hasher : (0, node_crypto.createHash)("sha256");
76
+ const folder = node_path.join(rootDir, subdir ?? ".");
77
+ const info = node_fs.default.readdirSync(folder, { withFileTypes: true });
78
+ for (const item of info) {
79
+ const relPath = node_path.join(subdir ?? ".", item.name);
80
+ const fullPath = node_path.join(folder, item.name);
81
+ hash.update(relPath);
82
+ if (item.isFile()) {
83
+ const fileDescriptor = node_fs.default.openSync(fullPath, "r");
84
+ const buffer = Buffer.alloc(65536);
85
+ let bytesRead;
86
+ while ((bytesRead = node_fs.default.readSync(fileDescriptor, buffer, 0, buffer.length, null)) !== 0) hash.update(buffer.subarray(0, bytesRead));
87
+ node_fs.default.closeSync(fileDescriptor);
88
+ } else if (item.isDirectory()) hashDirSync(fullPath, hash);
89
+ }
90
+ return hash;
91
+ }
92
+ function ensureDirsExist(dirPath) {
93
+ if (node_fs.default.existsSync(dirPath)) return;
94
+ ensureDirsExist(node_path.dirname(dirPath));
95
+ node_fs.default.mkdirSync(dirPath);
96
+ }
97
+ function findPackageRoot(logger, startPath) {
98
+ if (!startPath) startPath = process.cwd();
99
+ logger.debug(`Detecting package root...`);
100
+ const pkgRoot = searchPathUp(startPath, startPath, packageJsonName);
101
+ logger.debug(` package root found at '${pkgRoot}'`);
102
+ return pkgRoot;
103
+ }
104
+ function findNodeModules(logger, startPath) {
105
+ if (!startPath) startPath = process.cwd();
106
+ logger.debug(`Detecting 'node_modules' directory...`);
107
+ const nodeModules = searchPathUp(startPath, startPath, "node_modules");
108
+ logger.debug(` 'node_modules' found at '${nodeModules}'`);
109
+ return node_path.join(nodeModules, "node_modules");
110
+ }
111
+ function findInstalledModule(logger, packageName, startPath) {
112
+ const nodeModules = findNodeModules(logger, startPath);
113
+ const packagePath = node_path.resolve(nodeModules, packageName);
114
+ if (!node_fs.default.existsSync(packagePath)) throw CLIError(`package '${packageName}' not found in '${nodeModules}'. Did you forget to add it as a dependency?`);
115
+ return packagePath;
116
+ }
117
+ function searchPathUp(startPath, pathToCheck, itemToCheck) {
118
+ const itemPath = node_path.resolve(pathToCheck, itemToCheck);
119
+ if (node_fs.default.existsSync(itemPath)) return pathToCheck;
120
+ const parentDir = node_path.dirname(pathToCheck);
121
+ if (parentDir === pathToCheck || pathToCheck === "") throw CLIError(`failed to find '${itemToCheck}' file in any of parent directories starting from '${startPath}'`);
122
+ return searchPathUp(startPath, parentDir, itemToCheck);
123
+ }
124
+ function createLogger(level = "debug") {
125
+ if (require_envs.isCI() && require_envs.isRunnerDebug()) level = "debug";
126
+ return winston.default.createLogger({
127
+ level,
128
+ format: winston.default.format.printf(({ level, message }) => {
129
+ const indent = " ".repeat(level.length + 2);
130
+ if (typeof message !== "string") {
131
+ const messageJson = JSON.stringify(message);
132
+ throw new Error(`logger message ${messageJson} is not a string`);
133
+ }
134
+ const indentedMessage = message.split("\n").map((line, index) => index === 0 ? line : indent + line).join("\n");
135
+ const colorize = (l) => winston.default.format.colorize().colorize(l, l);
136
+ return `${colorize(level)}: ${indentedMessage}`;
137
+ }),
138
+ transports: [new winston.default.transports.Console({
139
+ stderrLevels: [
140
+ "error",
141
+ "warn",
142
+ "info",
143
+ "debug"
144
+ ],
145
+ handleExceptions: true
146
+ })]
147
+ });
148
+ }
149
+ function rSplit(input, delimiter, limit) {
150
+ const parts = input.split(delimiter);
151
+ if (!limit || parts.length <= limit) return parts;
152
+ return [parts.slice(0, -limit + 1).join(delimiter), ...parts.slice(-limit + 1)];
153
+ }
154
+ const replaceDuplicateSlashes = /* @__PURE__ */ new RegExp("//+", "g");
155
+ function urlJoin(url, appendPath) {
156
+ const u = new URL(url, "file:/nonexistent-9672674c/");
157
+ if (u.protocol === "file:" && u.pathname.startsWith("/nonexistent-9672674c/")) throw new Error(`string '${url}' is not valid URL`);
158
+ u.pathname = u.pathname + "/" + appendPath;
159
+ u.pathname = u.pathname.replaceAll(replaceDuplicateSlashes, "/");
160
+ return u.toString();
161
+ }
162
+ function wrapErr(e, msg) {
163
+ if (!(e instanceof Error)) return e;
164
+ const wrappedError = /* @__PURE__ */ new Error(`${msg}: ${e.message}`);
165
+ wrappedError.name = e.name;
166
+ wrappedError.stack = e.stack;
167
+ Object.assign(wrappedError, e);
168
+ return wrappedError;
169
+ }
170
+ /**
171
+ * Converts any value to integer number 1 if value is truthful and 0 otherwice.
172
+ * Provides simple way to count values that are defined in an object:
173
+ * toInt(options.a) + toInt(options.b) + toInt(options.c) === 1
174
+ * @param input: any
175
+ * @returns number - '1' or '0'
176
+ */
177
+ function toInt(input) {
178
+ return input ? 1 : 0;
179
+ }
180
+ const OSes = [
181
+ "linux",
182
+ "macosx",
183
+ "windows"
184
+ ];
185
+ function currentOS() {
186
+ const platform = node_os.platform();
187
+ switch (platform) {
188
+ case "darwin": return "macosx";
189
+ case "linux": return "linux";
190
+ case "win32": return "windows";
191
+ default: throw CLIError(`operating system '${platform}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` + JSON.stringify(OSes));
192
+ }
193
+ }
194
+ const Arches = ["x64", "aarch64"];
195
+ function currentArch() {
196
+ const arch = node_os.arch();
197
+ switch (arch) {
198
+ case "arm64": return "aarch64";
199
+ case "x64": return "x64";
200
+ default: throw CLIError(`processor architecture '${arch}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(Arches));
201
+ }
202
+ }
203
+ const AllPlatforms = [
204
+ "linux-x64",
205
+ "linux-aarch64",
206
+ "macosx-x64",
207
+ "macosx-aarch64",
208
+ "windows-x64"
209
+ ];
210
+ function splitPlatform(platform) {
211
+ const parts = platform.split("-");
212
+ return {
213
+ os: parts[0],
214
+ arch: parts[1]
215
+ };
216
+ }
217
+ function joinPlatform(os, arch) {
218
+ return `${os}-${arch}`;
219
+ }
220
+ function isPlatformSupported(os, arch) {
221
+ return AllPlatforms.includes(`${os}-${arch}`);
222
+ }
223
+ function currentPlatform() {
224
+ return `${currentOS()}-${currentArch()}`;
225
+ }
226
+ const AllSoftwareSources = ["archive", "docker"];
227
+ /** True for dev-local build mode. */
228
+ function isDevLocalMode(mode) {
229
+ return mode === "dev-local";
230
+ }
231
+ function artifactIDFromString(s) {
232
+ const parts = s.split(":", 2);
233
+ if (parts.length < 2) throw CLIError(`string '${s}' is not an artifact ID (artifact ID format is <packageName>:<artifactName>)`);
234
+ return {
235
+ package: parts[0],
236
+ name: parts[1]
237
+ };
238
+ }
239
+ function artifactIDToString(a) {
240
+ return `${a.package}:${a.name}`;
241
+ }
242
+ function indentText(txt, indent, skipFirstLine = false) {
243
+ indent = typeof indent === "number" ? " ".repeat(indent) : indent;
244
+ return txt.split("\n").map((line, index) => index === 0 && skipFirstLine ? line : `${indent}${line}`).join("\n");
245
+ }
246
+ const formatZodIssues = (issues, i = "", p = []) => {
247
+ const _errors = [];
248
+ const formatSubpath = (path, prefix = "") => {
249
+ let pp = path.join(".");
250
+ if (pp != "" && p.length > 0) pp = `.${pp}`;
251
+ if (pp != "") pp = `${prefix}${pp}`;
252
+ return pp;
253
+ };
254
+ const addItem = (item) => _errors.push(indentText(item, i));
255
+ for (const issue of issues) if (issue.code === "invalid_union") {
256
+ addItem(`✖ Expected one of several possible values`);
257
+ addItem(` → at '${formatSubpath(issue.path, "")}':`);
258
+ for (const errGrp of issue.errors) _errors.push(formatZodIssues(errGrp, `${i} `, [...p, ...issue.path]));
259
+ } else if (issue.code === "invalid_element" || issue.code === "invalid_key") {
260
+ addItem(`✖ ${issue.code.replaceAll("_", " ")}:`);
261
+ _errors.push(formatZodIssues(issue.issues, `${i} `, [...p, ...issue.path]));
262
+ } else if (issue.code === "invalid_type") {
263
+ const path = formatSubpath(issue.path, " ");
264
+ const prefix = `✖ (${issue.expected})${path}: `;
265
+ addItem(`${prefix}${indentText(issue.message, Math.min(prefix.length, 20), true)}`);
266
+ } else {
267
+ const path = formatSubpath(issue.path, " ");
268
+ const prefix = `✖ (${issue.code.replaceAll("_", " ")})${path}: `;
269
+ addItem(`${prefix}${indentText(issue.message, Math.min(prefix.length, 20), true)}`);
270
+ }
271
+ return _errors.join("\n");
272
+ };
273
+ var CLIErrorClass = class extends Error {
274
+ constructor(msg) {
275
+ super(typeof msg === "string" ? msg : msg.message);
276
+ this.name = "CLIError";
277
+ }
278
+ };
279
+ function CLIError(msg) {
280
+ return new CLIErrorClass(msg);
281
+ }
282
+ //#endregion
283
+ exports.AllPlatforms = AllPlatforms;
284
+ exports.CLIError = CLIError;
285
+ exports.artifactIDToString = artifactIDToString;
286
+ exports.assertNever = assertNever;
287
+ exports.currentArch = currentArch;
288
+ exports.currentOS = currentOS;
289
+ exports.currentPlatform = currentPlatform;
290
+ exports.ensureDirsExist = ensureDirsExist;
291
+ exports.findInstalledModule = findInstalledModule;
292
+ exports.findPackageRoot = findPackageRoot;
293
+ exports.formatZodIssues = formatZodIssues;
294
+ exports.hashDirMetaSync = hashDirMetaSync;
295
+ exports.hashDirSync = hashDirSync;
296
+ exports.isDevLocalMode = isDevLocalMode;
297
+ exports.joinPlatform = joinPlatform;
298
+ exports.packageJsonName = packageJsonName;
299
+ exports.rSplit = rSplit;
300
+ exports.softwareConfigName = softwareConfigName;
301
+ exports.splitPlatform = splitPlatform;
302
+ exports.toInt = toInt;
303
+ exports.trimPrefix = trimPrefix;
304
+ exports.urlJoin = urlJoin;
305
+ Object.defineProperty(exports, "util_exports", {
306
+ enumerable: true,
307
+ get: function() {
308
+ return util_exports;
309
+ }
310
+ });
311
+ exports.wrapErr = wrapErr;
312
+
313
+ //# sourceMappingURL=util.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.cjs","names":["fs","path","os"],"sources":["../../src/core/util.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as os from \"node:os\";\nimport fs from \"node:fs\";\nimport type { Hash } from \"node:crypto\";\nimport { createHash } from \"node:crypto\";\nimport winston from \"winston\";\nimport type { z } from \"zod/v4\";\nimport * as envs from \"./envs\";\n\nexport const packageJsonName = \"package.json\";\nexport const softwareConfigName = \"package.json\";\n\nexport function assertNever(_a: never) {\n throw new Error(`code logic error: assertNever() call for ${JSON.stringify(_a)}`);\n}\n\nexport function trimPrefix(str: string, prefix: string): string {\n if (str.startsWith(prefix)) {\n return str.slice(prefix.length);\n }\n return str;\n}\n\nexport function trimSuffix(str: string, suffix: string): string {\n if (str.endsWith(suffix)) {\n return str.slice(0, -suffix.length);\n }\n return str;\n}\n\nexport function hashDirMetaSync(folder: string, hasher?: Hash): Hash {\n const hash = hasher ? hasher : createHash(\"sha256\");\n const info = fs.readdirSync(folder, { withFileTypes: true });\n\n for (const item of info) {\n const fullPath = path.join(folder, item.name);\n\n if (item.isFile()) {\n const statInfo = fs.statSync(fullPath);\n const fileInfo = `${fullPath}:${statInfo.size}:${statInfo.mtimeMs}`;\n hash.update(fileInfo);\n } else if (item.isDirectory()) {\n hashDirMetaSync(fullPath, hash);\n }\n }\n\n return hash;\n}\n\nexport function hashDirSync(rootDir: string, hasher?: Hash, subdir?: string): Hash {\n const hash = hasher ? hasher : createHash(\"sha256\");\n const folder = path.join(rootDir, subdir ?? \".\");\n\n const info = fs.readdirSync(folder, { withFileTypes: true });\n\n for (const item of info) {\n const relPath = path.join(subdir ?? \".\", item.name);\n const fullPath = path.join(folder, item.name);\n\n hash.update(relPath);\n\n if (item.isFile()) {\n const fileDescriptor = fs.openSync(fullPath, \"r\");\n const buffer = Buffer.alloc(65536);\n let bytesRead: number;\n\n while ((bytesRead = fs.readSync(fileDescriptor, buffer, 0, buffer.length, null)) !== 0) {\n hash.update(buffer.subarray(0, bytesRead));\n }\n\n fs.closeSync(fileDescriptor);\n } else if (item.isDirectory()) {\n hashDirSync(fullPath, hash);\n }\n }\n\n return hash;\n}\n\n//\n// Creates all intermediate directories down to given <dirPath>.\n//\nexport function ensureDirsExist(dirPath: string) {\n if (fs.existsSync(dirPath)) {\n return;\n }\n const parentDir = path.dirname(dirPath);\n ensureDirsExist(parentDir);\n fs.mkdirSync(dirPath);\n}\n\nexport function findPackageRoot(logger: winston.Logger, startPath?: string): string {\n if (!startPath) {\n startPath = process.cwd();\n }\n logger.debug(`Detecting package root...`);\n const pkgRoot = searchPathUp(startPath, startPath, packageJsonName);\n logger.debug(` package root found at '${pkgRoot}'`);\n\n return pkgRoot;\n}\n\nexport function findNodeModules(logger: winston.Logger, startPath?: string): string {\n if (!startPath) {\n startPath = process.cwd();\n }\n logger.debug(`Detecting 'node_modules' directory...`);\n const nodeModules = searchPathUp(startPath, startPath, \"node_modules\");\n logger.debug(` 'node_modules' found at '${nodeModules}'`);\n\n return path.join(nodeModules, \"node_modules\");\n}\n\nexport function findInstalledModule(\n logger: winston.Logger,\n packageName: string,\n startPath?: string,\n): string {\n const nodeModules = findNodeModules(logger, startPath);\n const packagePath = path.resolve(nodeModules, packageName);\n\n if (!fs.existsSync(packagePath)) {\n throw CLIError(\n `package '${packageName}' not found in '${nodeModules}'. Did you forget to add it as a dependency?`,\n );\n }\n\n return packagePath;\n}\n\nfunction searchPathUp(startPath: string, pathToCheck: string, itemToCheck: string): string {\n const itemPath = path.resolve(pathToCheck, itemToCheck);\n\n if (fs.existsSync(itemPath)) {\n return pathToCheck;\n }\n\n const parentDir = path.dirname(pathToCheck);\n if (parentDir === pathToCheck || pathToCheck === \"\") {\n throw CLIError(\n `failed to find '${itemToCheck}' file in any of parent directories starting from '${startPath}'`,\n );\n }\n\n return searchPathUp(startPath, parentDir, itemToCheck);\n}\n\nexport function createLogger(level: string = \"debug\"): winston.Logger {\n if (envs.isCI() && envs.isRunnerDebug()) {\n level = \"debug\";\n }\n\n return winston.createLogger({\n level: level,\n\n format: winston.format.printf(({ level, message }) => {\n const indent = \" \".repeat(level.length + 2); // For ': ' after the level\n if (typeof message !== \"string\") {\n const messageJson = JSON.stringify(message);\n throw new Error(`logger message ${messageJson} is not a string`);\n }\n const indentedMessage = message\n .split(\"\\n\")\n .map((line: string, index: number) => (index === 0 ? line : indent + line))\n .join(\"\\n\");\n\n const colorize = (l: string) => winston.format.colorize().colorize(l, l);\n\n return `${colorize(level)}: ${indentedMessage}`;\n }),\n\n transports: [\n new winston.transports.Console({\n stderrLevels: [\"error\", \"warn\", \"info\", \"debug\"],\n handleExceptions: true,\n }),\n ],\n });\n}\n\nexport function rSplit(input: string, delimiter: string, limit?: number): string[] {\n const parts = input.split(delimiter);\n if (!limit || parts.length <= limit) {\n return parts;\n }\n\n return [parts.slice(0, -limit + 1).join(delimiter), ...parts.slice(-limit + 1)];\n}\n\nconst replaceDuplicateSlashes = new RegExp(\"//+\", \"g\");\nexport function urlJoin(url: string, appendPath: string): string {\n const u = new URL(url, \"file:/nonexistent-9672674c/\");\n if (u.protocol === \"file:\" && u.pathname.startsWith(\"/nonexistent-9672674c/\")) {\n throw new Error(`string '${url}' is not valid URL`);\n }\n\n u.pathname = u.pathname + \"/\" + appendPath;\n u.pathname = u.pathname.replaceAll(replaceDuplicateSlashes, \"/\");\n return u.toString();\n}\n\nexport function wrapErr(e: any, msg: string): any {\n if (!(e instanceof Error)) {\n return e;\n }\n\n const wrappedError = new Error(`${msg}: ${e.message}`);\n wrappedError.name = e.name;\n wrappedError.stack = e.stack;\n // Copy any additional custom properties\n Object.assign(wrappedError, e);\n return wrappedError;\n}\n\n/**\n * Converts any value to integer number 1 if value is truthful and 0 otherwice.\n * Provides simple way to count values that are defined in an object:\n * toInt(options.a) + toInt(options.b) + toInt(options.c) === 1\n * @param input: any\n * @returns number - '1' or '0'\n */\nexport function toInt(input: any): number {\n return input ? 1 : 0;\n}\n\nexport const OSes = [\"linux\", \"macosx\", \"windows\"] as const;\nexport type OSType = (typeof OSes)[number];\n\nexport function currentOS(): OSType {\n const platform = os.platform();\n switch (platform) {\n case \"darwin\":\n return \"macosx\";\n case \"linux\":\n return \"linux\";\n case \"win32\":\n return \"windows\";\n default:\n throw CLIError(\n `operating system '${platform}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` +\n JSON.stringify(OSes),\n );\n }\n}\n\nexport const Arches = [\"x64\", \"aarch64\"] as const;\nexport type ArchType = (typeof Arches)[number];\n\nexport function currentArch(): ArchType {\n const arch = os.arch();\n switch (arch) {\n case \"arm64\":\n return \"aarch64\";\n case \"x64\":\n return \"x64\";\n default:\n throw CLIError(\n `processor architecture '${arch}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` +\n JSON.stringify(Arches),\n );\n }\n}\n\n// Combinartions of OS and architecture, Platforma supports.\nexport const AllPlatforms: `${OSType}-${ArchType}`[] = [\n \"linux-x64\",\n \"linux-aarch64\",\n \"macosx-x64\",\n \"macosx-aarch64\",\n \"windows-x64\",\n] as const;\nexport type PlatformType = (typeof AllPlatforms)[number];\n\nexport function splitPlatform(platform: PlatformType): { os: OSType; arch: ArchType } {\n const parts = platform.split(\"-\");\n\n return {\n os: parts[0] as OSType,\n arch: parts[1] as ArchType,\n };\n}\n\nexport function joinPlatform(os: OSType, arch: ArchType): PlatformType {\n return `${os}-${arch}`;\n}\n\nexport function isPlatformSupported(os: OSType, arch: ArchType): boolean {\n return AllPlatforms.includes(`${os}-${arch}`);\n}\n\nexport function currentPlatform(): PlatformType {\n return `${currentOS()}-${currentArch()}`;\n}\n\nexport const AllSoftwareSources = [\"archive\", \"docker\"] as const; // add 'image', '<whatever>' here when supported\nexport type SoftwareSource = (typeof AllSoftwareSources)[number];\n\nexport type BuildMode = \"dev-local\" | \"release\";\n\n/** True for dev-local build mode. */\nexport function isDevLocalMode(mode: BuildMode): mode is \"dev-local\" {\n return mode === \"dev-local\";\n}\n\nexport type artifactID = {\n package: string;\n name: string;\n};\n\nexport function artifactIDFromString(s: string): artifactID {\n const parts = s.split(\":\", 2);\n if (parts.length < 2) {\n throw CLIError(\n `string '${s}' is not an artifact ID (artifact ID format is <packageName>:<artifactName>)`,\n );\n }\n return {\n package: parts[0],\n name: parts[1],\n };\n}\n\nexport function artifactIDToString(a: artifactID): string {\n return `${a.package}:${a.name}`;\n}\n\nexport function indentText(txt: string, indent: string | number, skipFirstLine: boolean = false) {\n indent = typeof indent === \"number\" ? \" \".repeat(indent) : indent;\n\n return txt\n .split(\"\\n\")\n .map((line, index) => (index === 0 && skipFirstLine ? line : `${indent}${line}`))\n .join(\"\\n\");\n}\n\nexport const formatZodIssues = (\n issues: z.core.$ZodIssue[],\n i: string = \"\",\n p: PropertyKey[] = [],\n): string => {\n const _errors: string[] = [];\n\n const formatSubpath = (path: PropertyKey[], prefix: string = \"\") => {\n let pp = path.join(\".\");\n if (pp != \"\" && p.length > 0) pp = `.${pp}`;\n if (pp != \"\") pp = `${prefix}${pp}`;\n return pp;\n };\n\n const addItem = (item: string) => _errors.push(indentText(item, i));\n\n for (const issue of issues) {\n if (issue.code === \"invalid_union\") {\n addItem(`✖ Expected one of several possible values`);\n const path = formatSubpath(issue.path, \"\");\n addItem(` → at '${path}':`);\n for (const errGrp of issue.errors) {\n _errors.push(formatZodIssues(errGrp, `${i} `, [...p, ...issue.path]));\n }\n } else if (issue.code === \"invalid_element\" || issue.code === \"invalid_key\") {\n addItem(`✖ ${issue.code.replaceAll(\"_\", \" \")}:`);\n _errors.push(formatZodIssues(issue.issues, `${i} `, [...p, ...issue.path]));\n } else if (issue.code === \"invalid_type\") {\n const path = formatSubpath(issue.path, \" \");\n const prefix = `✖ (${issue.expected})${path}: `;\n const msg = indentText(issue.message, Math.min(prefix.length, 20), true);\n addItem(`${prefix}${msg}`);\n } else {\n const path = formatSubpath(issue.path, \" \");\n const prefix = `✖ (${issue.code.replaceAll(\"_\", \" \")})${path}: `;\n const msg = indentText(issue.message, Math.min(prefix.length, 20), true);\n addItem(`${prefix}${msg}`);\n }\n }\n\n return _errors.join(\"\\n\");\n};\n\n// User-facing CLI error. The top-level handler (bin/run.mjs) prints its\n// message without a stack trace and exits non-zero.\nexport class CLIErrorClass extends Error {\n constructor(msg: string | Error) {\n super(typeof msg === \"string\" ? msg : msg.message);\n this.name = \"CLIError\";\n }\n}\n\nexport function CLIError(msg: string | Error): CLIErrorClass {\n return new CLIErrorClass(msg);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,kBAAkB;AAC/B,MAAa,qBAAqB;AAElC,SAAgB,YAAY,IAAW;AACrC,OAAM,IAAI,MAAM,4CAA4C,KAAK,UAAU,GAAG,GAAG;;AAGnF,SAAgB,WAAW,KAAa,QAAwB;AAC9D,KAAI,IAAI,WAAW,OAAO,CACxB,QAAO,IAAI,MAAM,OAAO,OAAO;AAEjC,QAAO;;AAGT,SAAgB,WAAW,KAAa,QAAwB;AAC9D,KAAI,IAAI,SAAS,OAAO,CACtB,QAAO,IAAI,MAAM,GAAG,CAAC,OAAO,OAAO;AAErC,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,CAAC,CAAC;YACnE,MAAM,SAAS,gBAAgB;EACxC,MAAM,OAAO,cAAc,MAAM,MAAM,IAAI;EAC3C,MAAM,SAAS,MAAM,MAAM,SAAS,GAAG,KAAK;AAE5C,UAAQ,GAAG,SADC,WAAW,MAAM,SAAS,KAAK,IAAI,OAAO,QAAQ,GAAG,EAAE,KAAK,GAC9C;QACrB;EACL,MAAM,OAAO,cAAc,MAAM,MAAM,IAAI;EAC3C,MAAM,SAAS,MAAM,MAAM,KAAK,WAAW,KAAK,IAAI,CAAC,GAAG,KAAK;AAE7D,UAAQ,GAAG,SADC,WAAW,MAAM,SAAS,KAAK,IAAI,OAAO,QAAQ,GAAG,EAAE,KAAK,GAC9C;;AAI9B,QAAO,QAAQ,KAAK,KAAK;;AAK3B,IAAa,gBAAb,cAAmC,MAAM;CACvC,YAAY,KAAqB;AAC/B,QAAM,OAAO,QAAQ,WAAW,MAAM,IAAI,QAAQ;AAClD,OAAK,OAAO;;;AAIhB,SAAgB,SAAS,KAAoC;AAC3D,QAAO,IAAI,cAAc,IAAI"}
@@ -0,0 +1,66 @@
1
+ import { z } from "zod/v4";
2
+ import { Hash } from "node:crypto";
3
+ import winston from "winston";
4
+
5
+ //#region src/core/util.d.ts
6
+ declare namespace util_d_exports {
7
+ export { AllPlatforms, AllSoftwareSources, ArchType, Arches, BuildMode, CLIError, CLIErrorClass, OSType, OSes, PlatformType, SoftwareSource, artifactID, artifactIDFromString, artifactIDToString, assertNever, createLogger, currentArch, currentOS, currentPlatform, ensureDirsExist, findInstalledModule, findNodeModules, findPackageRoot, formatZodIssues, hashDirMetaSync, hashDirSync, indentText, isDevLocalMode, isPlatformSupported, joinPlatform, packageJsonName, rSplit, softwareConfigName, splitPlatform, toInt, trimPrefix, trimSuffix, urlJoin, wrapErr };
8
+ }
9
+ declare const packageJsonName = "package.json";
10
+ declare const softwareConfigName = "package.json";
11
+ declare function assertNever(_a: never): void;
12
+ declare function trimPrefix(str: string, prefix: string): string;
13
+ declare function trimSuffix(str: string, suffix: string): string;
14
+ declare function hashDirMetaSync(folder: string, hasher?: Hash): Hash;
15
+ declare function hashDirSync(rootDir: string, hasher?: Hash, subdir?: string): Hash;
16
+ declare function ensureDirsExist(dirPath: string): void;
17
+ declare function findPackageRoot(logger: winston.Logger, startPath?: string): string;
18
+ declare function findNodeModules(logger: winston.Logger, startPath?: string): string;
19
+ declare function findInstalledModule(logger: winston.Logger, packageName: string, startPath?: string): string;
20
+ declare function createLogger(level?: string): winston.Logger;
21
+ declare function rSplit(input: string, delimiter: string, limit?: number): string[];
22
+ declare function urlJoin(url: string, appendPath: string): string;
23
+ declare function wrapErr(e: any, msg: string): any;
24
+ /**
25
+ * Converts any value to integer number 1 if value is truthful and 0 otherwice.
26
+ * Provides simple way to count values that are defined in an object:
27
+ * toInt(options.a) + toInt(options.b) + toInt(options.c) === 1
28
+ * @param input: any
29
+ * @returns number - '1' or '0'
30
+ */
31
+ declare function toInt(input: any): number;
32
+ declare const OSes: readonly ["linux", "macosx", "windows"];
33
+ type OSType = (typeof OSes)[number];
34
+ declare function currentOS(): OSType;
35
+ declare const Arches: readonly ["x64", "aarch64"];
36
+ type ArchType = (typeof Arches)[number];
37
+ declare function currentArch(): ArchType;
38
+ declare const AllPlatforms: `${OSType}-${ArchType}`[];
39
+ type PlatformType = (typeof AllPlatforms)[number];
40
+ declare function splitPlatform(platform: PlatformType): {
41
+ os: OSType;
42
+ arch: ArchType;
43
+ };
44
+ declare function joinPlatform(os: OSType, arch: ArchType): PlatformType;
45
+ declare function isPlatformSupported(os: OSType, arch: ArchType): boolean;
46
+ declare function currentPlatform(): PlatformType;
47
+ declare const AllSoftwareSources: readonly ["archive", "docker"];
48
+ type SoftwareSource = (typeof AllSoftwareSources)[number];
49
+ type BuildMode = "dev-local" | "release";
50
+ /** True for dev-local build mode. */
51
+ declare function isDevLocalMode(mode: BuildMode): mode is "dev-local";
52
+ type artifactID = {
53
+ package: string;
54
+ name: string;
55
+ };
56
+ declare function artifactIDFromString(s: string): artifactID;
57
+ declare function artifactIDToString(a: artifactID): string;
58
+ declare function indentText(txt: string, indent: string | number, skipFirstLine?: boolean): string;
59
+ declare const formatZodIssues: (issues: z.core.$ZodIssue[], i?: string, p?: PropertyKey[]) => string;
60
+ declare class CLIErrorClass extends Error {
61
+ constructor(msg: string | Error);
62
+ }
63
+ declare function CLIError(msg: string | Error): CLIErrorClass;
64
+ //#endregion
65
+ export { ArchType, BuildMode, OSType, PlatformType, SoftwareSource, util_d_exports };
66
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","names":[],"sources":["../../src/core/util.ts"],"mappings":";;;;;;;;cASa,eAAA;AAAA,cACA,kBAAA;AAAA,iBAEG,WAAA,CAAY,EAAA;AAAA,iBAIZ,UAAA,CAAW,GAAA,UAAa,MAAA;AAAA,iBAOxB,UAAA,CAAW,GAAA,UAAa,MAAA;AAAA,iBAOxB,eAAA,CAAgB,MAAA,UAAgB,MAAA,GAAS,IAAA,GAAO,IAAA;AAAA,iBAmBhD,WAAA,CAAY,OAAA,UAAiB,MAAA,GAAS,IAAA,EAAM,MAAA,YAAkB,IAAA;AAAA,iBAiC9D,eAAA,CAAgB,OAAA;AAAA,iBAShB,eAAA,CAAgB,MAAA,EAAQ,OAAA,CAAQ,MAAA,EAAQ,SAAA;AAAA,iBAWxC,eAAA,CAAgB,MAAA,EAAQ,OAAA,CAAQ,MAAA,EAAQ,SAAA;AAAA,iBAWxC,mBAAA,CACd,MAAA,EAAQ,OAAA,CAAQ,MAAA,EAChB,WAAA,UACA,SAAA;AAAA,iBA+Bc,YAAA,CAAa,KAAA,YAA0B,OAAA,CAAQ,MAAA;AAAA,iBAiC/C,MAAA,CAAO,KAAA,UAAe,SAAA,UAAmB,KAAA;AAAA,iBAUzC,OAAA,CAAQ,GAAA,UAAa,UAAA;AAAA,iBAWrB,OAAA,CAAQ,CAAA,OAAQ,GAAA;;;;;;;;iBAoBhB,KAAA,CAAM,KAAA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