@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.
- package/assets/conda-dockerfile.template +45 -0
- package/assets/python-dockerfile.template +22 -0
- package/dist/_virtual/_rolldown/runtime.cjs +33 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/core/archive.cjs +52 -0
- package/dist/core/archive.cjs.map +1 -0
- package/dist/core/archive.js +47 -0
- package/dist/core/archive.js.map +1 -0
- package/dist/core/conda/builder.cjs +226 -0
- package/dist/core/conda/builder.cjs.map +1 -0
- package/dist/core/conda/builder.js +220 -0
- package/dist/core/conda/builder.js.map +1 -0
- package/dist/core/conda/validate-spec.cjs +76 -0
- package/dist/core/conda/validate-spec.cjs.map +1 -0
- package/dist/core/conda/validate-spec.js +73 -0
- package/dist/core/conda/validate-spec.js.map +1 -0
- package/dist/core/core.cjs +403 -0
- package/dist/core/core.cjs.map +1 -0
- package/dist/core/core.d.ts +82 -0
- package/dist/core/core.d.ts.map +1 -0
- package/dist/core/core.js +397 -0
- package/dist/core/core.js.map +1 -0
- package/dist/core/docker-conda.cjs +75 -0
- package/dist/core/docker-conda.cjs.map +1 -0
- package/dist/core/docker-conda.js +71 -0
- package/dist/core/docker-conda.js.map +1 -0
- package/dist/core/docker-python.cjs +147 -0
- package/dist/core/docker-python.cjs.map +1 -0
- package/dist/core/docker-python.js +144 -0
- package/dist/core/docker-python.js.map +1 -0
- package/dist/core/docker.cjs +223 -0
- package/dist/core/docker.cjs.map +1 -0
- package/dist/core/docker.js +207 -0
- package/dist/core/docker.js.map +1 -0
- package/dist/core/envs.cjs +58 -0
- package/dist/core/envs.cjs.map +1 -0
- package/dist/core/envs.d.ts +26 -0
- package/dist/core/envs.d.ts.map +1 -0
- package/dist/core/envs.js +51 -0
- package/dist/core/envs.js.map +1 -0
- package/dist/core/package-info.cjs +450 -0
- package/dist/core/package-info.cjs.map +1 -0
- package/dist/core/package-info.d.ts +57 -0
- package/dist/core/package-info.d.ts.map +1 -0
- package/dist/core/package-info.js +447 -0
- package/dist/core/package-info.js.map +1 -0
- package/dist/core/paths.cjs +15 -0
- package/dist/core/paths.cjs.map +1 -0
- package/dist/core/paths.js +14 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/resolver.cjs +99 -0
- package/dist/core/resolver.cjs.map +1 -0
- package/dist/core/resolver.js +95 -0
- package/dist/core/resolver.js.map +1 -0
- package/dist/core/schemas/artifacts.cjs +136 -0
- package/dist/core/schemas/artifacts.cjs.map +1 -0
- package/dist/core/schemas/artifacts.d.ts +280 -0
- package/dist/core/schemas/artifacts.d.ts.map +1 -0
- package/dist/core/schemas/artifacts.js +122 -0
- package/dist/core/schemas/artifacts.js.map +1 -0
- package/dist/core/schemas/entrypoints.cjs +43 -0
- package/dist/core/schemas/entrypoints.cjs.map +1 -0
- package/dist/core/schemas/entrypoints.d.ts +32 -0
- package/dist/core/schemas/entrypoints.d.ts.map +1 -0
- package/dist/core/schemas/entrypoints.js +41 -0
- package/dist/core/schemas/entrypoints.js.map +1 -0
- package/dist/core/schemas/sw-json.cjs +111 -0
- package/dist/core/schemas/sw-json.cjs.map +1 -0
- package/dist/core/schemas/sw-json.js +110 -0
- package/dist/core/schemas/sw-json.js.map +1 -0
- package/dist/core/storage.cjs +86 -0
- package/dist/core/storage.cjs.map +1 -0
- package/dist/core/storage.js +83 -0
- package/dist/core/storage.js.map +1 -0
- package/dist/core/sw-json-render.cjs +327 -0
- package/dist/core/sw-json-render.cjs.map +1 -0
- package/dist/core/sw-json-render.js +322 -0
- package/dist/core/sw-json-render.js.map +1 -0
- package/dist/core/util.cjs +313 -0
- package/dist/core/util.cjs.map +1 -0
- package/dist/core/util.d.ts +66 -0
- package/dist/core/util.d.ts.map +1 -0
- package/dist/core/util.js +281 -0
- package/dist/core/util.js.map +1 -0
- package/dist/defaults.cjs +54 -0
- package/dist/defaults.cjs.map +1 -0
- package/dist/defaults.d.ts +21 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +37 -0
- package/dist/defaults.js.map +1 -0
- package/dist/index.cjs +31 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
- package/src/__test__/Dockerfile +1 -0
- package/src/__test__/docker.test.ts +67 -0
- package/src/__test__/package.json +39 -0
- package/src/__test__/python-example/main.py +1 -0
- package/src/__test__/python-example/requirements.txt +0 -0
- package/src/__test__/vite.config.mts +7 -0
- package/src/core/__tests__/docker-conda.test.ts +145 -0
- package/src/core/__tests__/docker-entrypoint-generation.test.ts +119 -0
- package/src/core/__tests__/docker-python.test.ts +374 -0
- package/src/core/__tests__/publish-docker-images.test.ts +309 -0
- package/src/core/archive.ts +102 -0
- package/src/core/conda/builder.test.ts +71 -0
- package/src/core/conda/builder.ts +384 -0
- package/src/core/conda/validate-spec.test.ts +213 -0
- package/src/core/conda/validate-spec.ts +107 -0
- package/src/core/core.ts +835 -0
- package/src/core/docker-conda.ts +149 -0
- package/src/core/docker-python.ts +283 -0
- package/src/core/docker.ts +300 -0
- package/src/core/envs.ts +31 -0
- package/src/core/package-info.test.ts +82 -0
- package/src/core/package-info.ts +843 -0
- package/src/core/paths.ts +16 -0
- package/src/core/resolver.ts +195 -0
- package/src/core/schemas/artifacts.test.ts +72 -0
- package/src/core/schemas/artifacts.ts +279 -0
- package/src/core/schemas/entrypoints.test.ts +171 -0
- package/src/core/schemas/entrypoints.ts +150 -0
- package/src/core/schemas/sw-json.ts +216 -0
- package/src/core/schemas/test-artifacts.ts +362 -0
- package/src/core/storage.ts +125 -0
- package/src/core/sw-json-render.test.ts +215 -0
- package/src/core/sw-json-render.ts +682 -0
- package/src/core/util.ts +390 -0
- package/src/defaults.ts +38 -0
- package/src/index.ts +31 -0
- package/src/requirements.txt +1 -0
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { BIN_REGISTRY_DOWNLOAD_URL, BIN_REGISTRY_NAME } from "../defaults.js";
|
|
2
|
+
import { PL_PKG_VERSION } from "./envs.js";
|
|
3
|
+
import { CLIError, assertNever, currentArch, currentPlatform, findPackageRoot, formatZodIssues, packageJsonName, softwareConfigName, splitPlatform, trimPrefix } from "./util.js";
|
|
4
|
+
import { artifactIndexSchema, dockerAutogenTypes, isBuildable, isCrossPlatform } from "./schemas/artifacts.js";
|
|
5
|
+
import { EnyrypointReferencePattern, entrypointListSchema } from "./schemas/entrypoints.js";
|
|
6
|
+
import { entrypointName } from "./docker.js";
|
|
7
|
+
import { prepareDockerOptions } from "./docker-python.js";
|
|
8
|
+
import { prepareDockerOptions as prepareDockerOptions$1 } from "./docker-conda.js";
|
|
9
|
+
import * as fs$1 from "node:fs";
|
|
10
|
+
import * as path$1 from "node:path";
|
|
11
|
+
import { z } from "zod/v4";
|
|
12
|
+
import { tryResolve } from "@milaboratories/resolve-helper";
|
|
13
|
+
//#region src/core/package-info.ts
|
|
14
|
+
const storagePresetSchema = z.object({
|
|
15
|
+
downloadURL: z.string().optional(),
|
|
16
|
+
storageURL: z.string().optional()
|
|
17
|
+
});
|
|
18
|
+
const binaryRegistryPresetsSchema = z.record(z.string(), storagePresetSchema);
|
|
19
|
+
const packageJsonSchema = z.object({
|
|
20
|
+
name: z.string(),
|
|
21
|
+
version: z.string(),
|
|
22
|
+
private: z.boolean().optional(),
|
|
23
|
+
"block-software": z.object({
|
|
24
|
+
registries: z.object({ binary: binaryRegistryPresetsSchema.optional() }).optional(),
|
|
25
|
+
artifacts: artifactIndexSchema.optional(),
|
|
26
|
+
entrypoints: entrypointListSchema
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
const wellKnownRegistries = { [BIN_REGISTRY_NAME]: { downloadURL: BIN_REGISTRY_DOWNLOAD_URL } };
|
|
30
|
+
var PackageInfo = class {
|
|
31
|
+
packageRoot;
|
|
32
|
+
packageName;
|
|
33
|
+
pkgJson;
|
|
34
|
+
_versionOverride;
|
|
35
|
+
constructor(logger, options) {
|
|
36
|
+
this.logger = logger;
|
|
37
|
+
this.logger.debug("Reading package information...");
|
|
38
|
+
this.packageRoot = options?.packageRoot ?? findPackageRoot(logger);
|
|
39
|
+
let pkgJsonData;
|
|
40
|
+
if (options?.pkgJsonData) pkgJsonData = options.pkgJsonData;
|
|
41
|
+
else {
|
|
42
|
+
const pkgJsonPath = path$1.resolve(this.packageRoot, packageJsonName);
|
|
43
|
+
this.logger.debug(` - loading '${pkgJsonPath}'`);
|
|
44
|
+
if (!fs$1.existsSync(pkgJsonPath)) {
|
|
45
|
+
this.logger.error(`no '${packageJsonName}' file found at '${this.packageRoot}'`);
|
|
46
|
+
throw CLIError("not a platform software package directory");
|
|
47
|
+
}
|
|
48
|
+
pkgJsonData = fs$1.readFileSync(pkgJsonPath, "utf8");
|
|
49
|
+
}
|
|
50
|
+
const result = parsePackageJson(pkgJsonData);
|
|
51
|
+
if (!result.success) throw CLIError(`\n` + formatZodIssues(result.error.issues));
|
|
52
|
+
this.pkgJson = result.data;
|
|
53
|
+
this.logger.debug(" " + JSON.stringify(this.pkgJson));
|
|
54
|
+
this.validateConfig();
|
|
55
|
+
this.packageName = this.pkgJson.name;
|
|
56
|
+
logger.debug(" package information loaded successfully.");
|
|
57
|
+
}
|
|
58
|
+
get isPrivate() {
|
|
59
|
+
return this.pkgJson.private ?? false;
|
|
60
|
+
}
|
|
61
|
+
get binaryRegistries() {
|
|
62
|
+
return this.pkgJson["block-software"].registries?.binary ?? {};
|
|
63
|
+
}
|
|
64
|
+
get entrypoints() {
|
|
65
|
+
const list = /* @__PURE__ */ new Map();
|
|
66
|
+
for (const [epName, ep] of Object.entries(this.pkgJson["block-software"].entrypoints)) {
|
|
67
|
+
if (ep.docker) {
|
|
68
|
+
const artifactID = typeof ep.docker.artifact === "string" ? ep.docker.artifact : epName;
|
|
69
|
+
const artifact = this.getArtifact(artifactID, "docker");
|
|
70
|
+
list.set(entrypointName(epName), {
|
|
71
|
+
type: "software",
|
|
72
|
+
name: epName,
|
|
73
|
+
artifact,
|
|
74
|
+
cmd: ep.docker.cmd ?? [],
|
|
75
|
+
env: ep.docker.envVars ?? []
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (ep.reference) {
|
|
79
|
+
list.set(epName, {
|
|
80
|
+
type: "reference",
|
|
81
|
+
name: epName,
|
|
82
|
+
reference: ep.reference
|
|
83
|
+
});
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (ep.binary || ep.conda) {
|
|
87
|
+
const swOptions = ep.binary ? ep.binary : ep.conda;
|
|
88
|
+
const artifactOrRef = ep.binary ? ep.binary.artifact : ep.conda.artifact;
|
|
89
|
+
const artifactID = typeof artifactOrRef === "string" ? artifactOrRef : epName;
|
|
90
|
+
const artifact = this.getArtifact(artifactID, "any");
|
|
91
|
+
if (artifact.type === "asset") throw CLIError(`binary entrypoint cannot point to asset artifact: ${epName}`);
|
|
92
|
+
if (artifact.type === "environment") throw CLIError(`binary entrypoint cannot point to environment artifact: ${epName}`);
|
|
93
|
+
list.set(epName, {
|
|
94
|
+
type: "software",
|
|
95
|
+
name: epName,
|
|
96
|
+
artifact,
|
|
97
|
+
cmd: swOptions.cmd,
|
|
98
|
+
env: swOptions.envVars ?? []
|
|
99
|
+
});
|
|
100
|
+
if (!ep.docker) {
|
|
101
|
+
if (dockerAutogenTypes.includes(artifact.type)) switch (artifact.type) {
|
|
102
|
+
case "conda":
|
|
103
|
+
case "python":
|
|
104
|
+
list.set(entrypointName(epName), {
|
|
105
|
+
type: "software",
|
|
106
|
+
name: epName,
|
|
107
|
+
artifact: this.generateDockerPackage(artifact),
|
|
108
|
+
cmd: swOptions.cmd,
|
|
109
|
+
env: swOptions.envVars ?? []
|
|
110
|
+
});
|
|
111
|
+
continue;
|
|
112
|
+
default: throw new Error(`docker autogeneration is not defined for type: ${artifact.type}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (ep.environment) {
|
|
117
|
+
const packageID = typeof ep.environment.artifact === "string" ? ep.environment.artifact : epName;
|
|
118
|
+
list.set(epName, {
|
|
119
|
+
type: "environment",
|
|
120
|
+
name: epName,
|
|
121
|
+
artifact: this.getArtifact(packageID, "environment"),
|
|
122
|
+
env: ep.environment.envVars ?? []
|
|
123
|
+
});
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (ep.asset) {
|
|
127
|
+
const packageID = typeof ep.asset === "string" ? ep.asset : epName;
|
|
128
|
+
list.set(epName, {
|
|
129
|
+
type: "asset",
|
|
130
|
+
name: epName,
|
|
131
|
+
artifact: this.getArtifact(packageID, "asset")
|
|
132
|
+
});
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (list.size === 0) throw CLIError(`entrypoint '${epName}' type is not supported by current platforma package builder`);
|
|
136
|
+
}
|
|
137
|
+
return list;
|
|
138
|
+
}
|
|
139
|
+
getMainEntrypoint(name) {
|
|
140
|
+
const ep = this.entrypoints.get(name);
|
|
141
|
+
if (ep) return ep;
|
|
142
|
+
return this.entrypoints.get(entrypointName(name));
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Resolves entrypoint reference to full entrypoint file path and type
|
|
146
|
+
*/
|
|
147
|
+
resolveReference(epName, ep) {
|
|
148
|
+
this.logger.debug(`resolving entrypoint '${epName}' reference '${ep.reference}'. packageRoot='${this.packageRoot}'`);
|
|
149
|
+
if (!ep.reference.match(EnyrypointReferencePattern)?.groups) {
|
|
150
|
+
this.logger.error(`entrypoint reference '${epName}' has incorrect reference format. <full package name>/<path to entrypoint> is expected`);
|
|
151
|
+
throw CLIError(`invalid entrypoint '${epName}' reference format`);
|
|
152
|
+
}
|
|
153
|
+
const refPath = tryResolve(this.packageRoot, ep.reference);
|
|
154
|
+
if (!refPath) {
|
|
155
|
+
this.logger.error(`entrypoint reference '${epName}' cannot be resolved into file path`);
|
|
156
|
+
throw CLIError(`invalid entrypoint '${epName}' reference`);
|
|
157
|
+
}
|
|
158
|
+
return refPath;
|
|
159
|
+
}
|
|
160
|
+
get packages() {
|
|
161
|
+
const result = /* @__PURE__ */ new Map();
|
|
162
|
+
for (const ep of this.entrypoints.values()) {
|
|
163
|
+
if (ep.type === "reference") continue;
|
|
164
|
+
if (!result.has(ep.artifact.id)) result.set(ep.artifact.id, ep.artifact);
|
|
165
|
+
}
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
artifactInfoLocation(pkgID, artifactType, platform) {
|
|
169
|
+
const platformPart = platform ? `_${platform}` : "";
|
|
170
|
+
return path$1.resolve(this.packageRoot, "dist", "artifacts", pkgID, `${artifactType}${platformPart}.json`);
|
|
171
|
+
}
|
|
172
|
+
generateDockerPackage(artifact) {
|
|
173
|
+
switch (artifact.type) {
|
|
174
|
+
case "python": {
|
|
175
|
+
const options = prepareDockerOptions(this.logger, this.packageRoot, this.packageName, artifact.id, artifact);
|
|
176
|
+
return {
|
|
177
|
+
id: artifact.id,
|
|
178
|
+
type: "docker",
|
|
179
|
+
registry: artifact["docker-registry"],
|
|
180
|
+
...options
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
case "conda": {
|
|
184
|
+
const options = prepareDockerOptions$1(this.logger, this.packageRoot, artifact.id, artifact, currentArch());
|
|
185
|
+
return {
|
|
186
|
+
id: artifact.id,
|
|
187
|
+
type: "docker",
|
|
188
|
+
registry: artifact["docker-registry"],
|
|
189
|
+
...options
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
default:
|
|
193
|
+
assertNever(artifact);
|
|
194
|
+
throw new Error("calm down the linter");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
getArtifact(id, type) {
|
|
198
|
+
const artifacts = this.pkgJson["block-software"].artifacts ?? {};
|
|
199
|
+
const entrypoints = this.pkgJson["block-software"].entrypoints;
|
|
200
|
+
let artifact;
|
|
201
|
+
let errMsg = "";
|
|
202
|
+
if (artifacts[id]) artifact = artifacts[id];
|
|
203
|
+
else {
|
|
204
|
+
const ep = entrypoints[id];
|
|
205
|
+
if (!ep) throw CLIError(`artifact with id '${id}' not found neither in 'entrypoints', nor in 'artifacts'`);
|
|
206
|
+
errMsg = `incorrect artifact reference in entrypoint '${id}'`;
|
|
207
|
+
if (ep.asset) artifact = typeof ep.asset === "string" ? artifacts[ep.asset] : {
|
|
208
|
+
type: "asset",
|
|
209
|
+
...ep.asset
|
|
210
|
+
};
|
|
211
|
+
else if (ep.binary && type !== "docker") {
|
|
212
|
+
const a = ep.binary.artifact;
|
|
213
|
+
artifact = typeof a === "string" ? artifacts[a] : a;
|
|
214
|
+
} else if (ep.conda && type !== "docker") {
|
|
215
|
+
const a = ep.conda.artifact;
|
|
216
|
+
artifact = typeof a === "string" ? artifacts[a] : {
|
|
217
|
+
type: "conda",
|
|
218
|
+
...a
|
|
219
|
+
};
|
|
220
|
+
} else if (ep.environment) {
|
|
221
|
+
const a = ep.environment.artifact;
|
|
222
|
+
artifact = typeof a === "string" ? artifacts[a] : {
|
|
223
|
+
type: "environment",
|
|
224
|
+
...a
|
|
225
|
+
};
|
|
226
|
+
} else if (ep.docker) {
|
|
227
|
+
const a = ep.docker.artifact;
|
|
228
|
+
artifact = typeof a === "string" ? artifacts[a] : {
|
|
229
|
+
type: "docker",
|
|
230
|
+
...a
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (!artifact) throw CLIError(`artifact '${id}' not found neither in 'entrypoints', nor in 'artifacts'`);
|
|
235
|
+
switch (type) {
|
|
236
|
+
case "docker": return {
|
|
237
|
+
id,
|
|
238
|
+
...requireArtifactType(artifact, "docker", errMsg)
|
|
239
|
+
};
|
|
240
|
+
case "asset": return {
|
|
241
|
+
id,
|
|
242
|
+
...requireArtifactType(artifact, "asset", errMsg)
|
|
243
|
+
};
|
|
244
|
+
case "environment": return {
|
|
245
|
+
id,
|
|
246
|
+
...requireArtifactType(artifact, "environment", errMsg)
|
|
247
|
+
};
|
|
248
|
+
case "binary": return {
|
|
249
|
+
id,
|
|
250
|
+
...requireArtifactType(artifact, "binary", errMsg)
|
|
251
|
+
};
|
|
252
|
+
case "java": return {
|
|
253
|
+
id,
|
|
254
|
+
...requireArtifactType(artifact, "java", errMsg)
|
|
255
|
+
};
|
|
256
|
+
case "python": return {
|
|
257
|
+
id,
|
|
258
|
+
...requireArtifactType(artifact, "python", errMsg)
|
|
259
|
+
};
|
|
260
|
+
case "R": return {
|
|
261
|
+
id,
|
|
262
|
+
...requireArtifactType(artifact, "R", errMsg)
|
|
263
|
+
};
|
|
264
|
+
case "conda": return {
|
|
265
|
+
id,
|
|
266
|
+
...requireArtifactType(artifact, "conda", errMsg)
|
|
267
|
+
};
|
|
268
|
+
case "any": return {
|
|
269
|
+
id,
|
|
270
|
+
...artifact
|
|
271
|
+
};
|
|
272
|
+
default:
|
|
273
|
+
assertNever(type);
|
|
274
|
+
throw CLIError(`invalid artifact type`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
set version(v) {
|
|
278
|
+
this._versionOverride = v;
|
|
279
|
+
}
|
|
280
|
+
artifactName(artifact) {
|
|
281
|
+
if (artifact.type !== "docker") {
|
|
282
|
+
if (artifact.name) return artifact.name;
|
|
283
|
+
}
|
|
284
|
+
return trimPrefix(this.pkgJson.name, "@") + "/" + artifact.id;
|
|
285
|
+
}
|
|
286
|
+
artifactVersion(artifact) {
|
|
287
|
+
if (this._versionOverride) return this._versionOverride;
|
|
288
|
+
if (process.env["PL_PKG_VERSION"]) return process.env[PL_PKG_VERSION];
|
|
289
|
+
if (artifact.type !== "docker" && artifact.version) return artifact.version;
|
|
290
|
+
return this.pkgJson.version;
|
|
291
|
+
}
|
|
292
|
+
artifactRegistrySettings(artifact) {
|
|
293
|
+
if (artifact.type === "docker") return { name: artifact.registry };
|
|
294
|
+
const registry = artifact.registry;
|
|
295
|
+
const registries = this.binaryRegistries;
|
|
296
|
+
const result = {
|
|
297
|
+
name: "default",
|
|
298
|
+
downloadURL: registries.default?.downloadURL,
|
|
299
|
+
storageURL: registries.default?.storageURL
|
|
300
|
+
};
|
|
301
|
+
if (registry) if (typeof registry === "string") {
|
|
302
|
+
result.name = registry;
|
|
303
|
+
const regDefault = wellKnownRegistries[result.name];
|
|
304
|
+
result.downloadURL = registries[result.name]?.downloadURL ?? regDefault?.downloadURL;
|
|
305
|
+
result.storageURL = registries[result.name]?.storageURL ?? regDefault?.storageURL;
|
|
306
|
+
} else {
|
|
307
|
+
result.name = registry.name;
|
|
308
|
+
const regDefault = wellKnownRegistries[result.name];
|
|
309
|
+
result.downloadURL = registry.downloadURL ?? registries[result.name]?.downloadURL ?? regDefault?.downloadURL;
|
|
310
|
+
result.storageURL = registry.storageURL ?? registries[result.name]?.storageURL ?? regDefault?.storageURL;
|
|
311
|
+
}
|
|
312
|
+
const regNameUpper = result.name.toUpperCase().replaceAll(/[^A-Z0-9_]/g, "_");
|
|
313
|
+
const uploadTo = process.env[`PL_REGISTRY_${regNameUpper}_UPLOAD_URL`];
|
|
314
|
+
if (uploadTo) result.storageURL = uploadTo;
|
|
315
|
+
const downloadFrom = process.env[`PL_REGISTRY_${regNameUpper}_DOWNLOAD_URL`];
|
|
316
|
+
if (downloadFrom) result.downloadURL = downloadFrom;
|
|
317
|
+
if (result.downloadURL) {
|
|
318
|
+
const u = new URL(result.downloadURL, "file:/nonexistent");
|
|
319
|
+
if (!["https:", "http:"].includes(u.protocol)) throw CLIError(`registry ${result.name} download URL is not valid. Only 'https://' and 'http://' schemes are supported for now`);
|
|
320
|
+
}
|
|
321
|
+
return result;
|
|
322
|
+
}
|
|
323
|
+
artifactContentRoot(artifact, platform) {
|
|
324
|
+
if ("root" in artifact && artifact.root) return path$1.resolve(this.packageRoot, artifact.root);
|
|
325
|
+
if ("roots" in artifact && artifact.roots[platform]) return path$1.resolve(this.packageRoot, artifact.roots[platform]);
|
|
326
|
+
throw CLIError(`root path of software archive on ${platform} is undefined for binary package`);
|
|
327
|
+
}
|
|
328
|
+
artifactPlatforms(artifact) {
|
|
329
|
+
if (artifact.type === "docker") return [currentPlatform()];
|
|
330
|
+
if ("root" in artifact && artifact.root) return [currentPlatform()];
|
|
331
|
+
if ("roots" in artifact) return Object.keys(artifact.roots);
|
|
332
|
+
throw CLIError(`no platforms are defined as supported for artifact '${artifact.id}' in binary mode (no 'roots' are defined)`);
|
|
333
|
+
}
|
|
334
|
+
artifactArchiveFullName(artifact, platform) {
|
|
335
|
+
const group = artifact.type === "asset" ? "assets" : "software";
|
|
336
|
+
const extension = artifact.type === "asset" ? "zip" : "tgz";
|
|
337
|
+
const name = this.artifactName(artifact);
|
|
338
|
+
const version = this.artifactVersion(artifact);
|
|
339
|
+
if (isCrossPlatform(artifact.type)) return `${group}/${name}/${version}.${extension}`;
|
|
340
|
+
const { os, arch } = splitPlatform(platform);
|
|
341
|
+
return `${group}/${name}/${version}-${os}-${arch}.${extension}`;
|
|
342
|
+
}
|
|
343
|
+
artifactArchiveAddressPattern(artifact) {
|
|
344
|
+
const group = artifact.type === "asset" ? "assets" : "software";
|
|
345
|
+
const extension = artifact.type === "asset" ? "zip" : "tgz";
|
|
346
|
+
const name = this.artifactName(artifact);
|
|
347
|
+
const version = this.artifactVersion(artifact);
|
|
348
|
+
if (isCrossPlatform(artifact.type)) return `${group}/${name}/${version}.${extension}`;
|
|
349
|
+
return `${group}/${name}/${version}-{os}-{arch}.${extension}`;
|
|
350
|
+
}
|
|
351
|
+
validateConfig() {
|
|
352
|
+
let hasErrors = false;
|
|
353
|
+
const blockSoftware = this.pkgJson["block-software"];
|
|
354
|
+
const as = blockSoftware.artifacts ?? {};
|
|
355
|
+
const entrypoints = blockSoftware.entrypoints ?? {};
|
|
356
|
+
for (const [epName, ep] of Object.entries(entrypoints)) {
|
|
357
|
+
if (ep.binary) {
|
|
358
|
+
const artifactID = typeof ep.binary.artifact === "string" ? ep.binary.artifact : epName;
|
|
359
|
+
const artifact = this.getArtifact(artifactID, "any");
|
|
360
|
+
if (!artifact) {
|
|
361
|
+
this.logger.error(`entrypoint '${epName}' refers to artifact '${artifactID}' which is not defined in '${softwareConfigName}'`);
|
|
362
|
+
hasErrors = true;
|
|
363
|
+
}
|
|
364
|
+
if (!this.validateArtifact(artifactID, artifact)) hasErrors = true;
|
|
365
|
+
if (!isBuildable(artifact.type)) {
|
|
366
|
+
this.logger.error(`entrypoint '${epName}' artifact type '${artifact.type}' is not buildable to binary package`);
|
|
367
|
+
hasErrors = true;
|
|
368
|
+
}
|
|
369
|
+
if (artifact.type === "environment") {
|
|
370
|
+
this.logger.error(`entrypoint '${epName}' artifact type '${artifact.type}' cannot be build into software pacakge. Use 'environment' entrypoint`);
|
|
371
|
+
hasErrors = true;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (ep.environment) {
|
|
375
|
+
const artifactID = typeof ep.environment.artifact === "string" ? ep.environment.artifact : epName;
|
|
376
|
+
const artifact = this.getArtifact(artifactID, "any");
|
|
377
|
+
if (!artifact) {
|
|
378
|
+
this.logger.error(`entrypoint '${epName}' refers to artifact '${artifactID}' which is not defined in '${softwareConfigName}'`);
|
|
379
|
+
hasErrors = true;
|
|
380
|
+
}
|
|
381
|
+
if (!this.validateArtifact(artifactID, artifact)) hasErrors = true;
|
|
382
|
+
if (artifact.type !== "environment") {
|
|
383
|
+
this.logger.error(`entrypoint '${epName}' with 'environment' settings should refer to 'environment' artifact type`);
|
|
384
|
+
hasErrors = true;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
const uniquePackageNames = /* @__PURE__ */ new Set();
|
|
389
|
+
for (const [artifactID, artifact] of Object.entries(as)) {
|
|
390
|
+
if (!isBuildable(artifact.type)) continue;
|
|
391
|
+
if (!this.validateArtifact(artifactID, artifact)) hasErrors = true;
|
|
392
|
+
const name = this.artifactName({
|
|
393
|
+
id: artifactID,
|
|
394
|
+
...artifact
|
|
395
|
+
});
|
|
396
|
+
const version = this.artifactVersion(artifact);
|
|
397
|
+
const uniqueName = `${name}-${version}`;
|
|
398
|
+
if (uniquePackageNames.has(uniqueName)) {
|
|
399
|
+
this.logger.error(`found two packages with the same name '${name}' and version '${version}'`);
|
|
400
|
+
hasErrors = true;
|
|
401
|
+
}
|
|
402
|
+
uniquePackageNames.add(uniqueName);
|
|
403
|
+
}
|
|
404
|
+
if (hasErrors) throw CLIError(`${softwareConfigName} has xconfiguration errors in 'block-software' section. See error log messages above for details`);
|
|
405
|
+
}
|
|
406
|
+
validateArtifact(artifactName, artifact) {
|
|
407
|
+
if (isBuildable(artifact.type)) {
|
|
408
|
+
const resolvedRoots = [];
|
|
409
|
+
const aType = artifact.type;
|
|
410
|
+
switch (aType) {
|
|
411
|
+
case "asset":
|
|
412
|
+
case "java":
|
|
413
|
+
case "R":
|
|
414
|
+
case "python":
|
|
415
|
+
resolvedRoots.push(path$1.resolve(this.packageRoot, artifact.root));
|
|
416
|
+
break;
|
|
417
|
+
case "docker":
|
|
418
|
+
resolvedRoots.push(path$1.resolve(this.packageRoot, artifact.context));
|
|
419
|
+
break;
|
|
420
|
+
case "environment":
|
|
421
|
+
case "conda":
|
|
422
|
+
case "binary":
|
|
423
|
+
resolvedRoots.push(...Object.values(artifact.roots).map((root) => path$1.resolve(this.packageRoot, root)));
|
|
424
|
+
break;
|
|
425
|
+
default: assertNever(aType);
|
|
426
|
+
}
|
|
427
|
+
for (const root of resolvedRoots) if (root === this.packageRoot) {
|
|
428
|
+
this.logger.error(`Invalid configuration: '${artifact.type}' artifact '${artifactName}' has 'root' set to the package root, which is not allowed`);
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
function parsePackageJson(data) {
|
|
436
|
+
const parsedData = JSON.parse(data);
|
|
437
|
+
return packageJsonSchema.safeParse(parsedData);
|
|
438
|
+
}
|
|
439
|
+
function requireArtifactType(artifact, type, errMsg) {
|
|
440
|
+
if (artifact.type === type) return artifact;
|
|
441
|
+
if (errMsg) errMsg = `${errMsg}: `;
|
|
442
|
+
throw CLIError(`${errMsg}wrong artifact type: expected '${type}', got '${artifact.type}'`);
|
|
443
|
+
}
|
|
444
|
+
//#endregion
|
|
445
|
+
export { PackageInfo };
|
|
446
|
+
|
|
447
|
+
//# sourceMappingURL=package-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-info.js","names":["entrypoints.entrypointListSchema","defaults.BIN_REGISTRY_NAME","defaults.BIN_REGISTRY_DOWNLOAD_URL","util.findPackageRoot","path","util.packageJsonName","fs","util.CLIError","util.formatZodIssues","docker.entrypointName","entrypoints.EnyrypointReferencePattern","pythonDockerOptions","condaDockerOptions","util.currentArch","util.trimPrefix","envs.PL_PKG_VERSION","util.currentPlatform","artifacts.isCrossPlatform","util.splitPlatform","util.softwareConfigName","artifacts.isBuildable"],"sources":["../../src/core/package-info.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs\";\nimport type winston from \"winston\";\nimport { z } from \"zod/v4\";\n\nimport * as defaults from \"../defaults\";\nimport * as util from \"./util\";\nimport * as envs from \"./envs\";\nimport * as artifacts from \"./schemas/artifacts\";\nimport * as entrypoints from \"./schemas/entrypoints\";\nimport { tryResolve } from \"@milaboratories/resolve-helper\";\nimport * as docker from \"./docker\";\nimport { prepareDockerOptions as pythonDockerOptions } from \"./docker-python\";\nimport { prepareDockerOptions as condaDockerOptions } from \"./docker-conda\";\n\nconst storagePresetSchema = z.object({\n downloadURL: z.string().optional(),\n storageURL: z.string().optional(),\n});\ntype storagePreset = z.infer<typeof storagePresetSchema>;\n\nconst binaryRegistryPresetsSchema = z.record(z.string(), storagePresetSchema);\ntype binaryRegistryPresets = z.infer<typeof binaryRegistryPresetsSchema>;\n\nconst packageJsonSchema = z.object({\n name: z.string(),\n version: z.string(),\n private: z.boolean().optional(),\n\n \"block-software\": z.object({\n registries: z\n .object({\n binary: binaryRegistryPresetsSchema.optional(),\n })\n .optional(),\n\n artifacts: artifacts.artifactIndexSchema.optional(),\n entrypoints: entrypoints.entrypointListSchema,\n }),\n});\ntype packageJson = z.infer<typeof packageJsonSchema>;\n\nconst wellKnownRegistries: Record<string, storagePreset> = {\n [defaults.BIN_REGISTRY_NAME]: {\n downloadURL: defaults.BIN_REGISTRY_DOWNLOAD_URL,\n },\n};\n\n/*\n * package.json -> block-software structure example:\n * {\n * \"block-software\": {\n * \"registries\": {\n * \"binary\": {\n * \"default\": { \"uploadURL\": \"s3://<bucket>/<some-prefix>?region=<region-name>\" }\n * }\n * },\n *\n * \"artifacts\": {\n * \"pkg-1\": {\n * \"type\": \"binary\",\n * \"roots\": {\n * \"linux-x64\": \"./linux-x64/src\",\n * \"linux-aarch64\": \"./linux-aarch/src\",\n * \"...and so on...\": \"platform-dependant roots\",\n * }\n * }\n * }\n *\n * \"entrypoints\": {\n * \"script1\": {\n * \"software\": {\n * \"artifact\": \"pkg-1\",\n * \"cmd\": [ \"{pkg}/script1\" ]\n * }\n * }\n * }\n * }\n * }\n */\nexport class PackageInfo {\n public readonly packageRoot: string;\n public readonly packageName: string;\n\n private readonly pkgJson: packageJson;\n private _versionOverride: string | undefined;\n\n constructor(\n private logger: winston.Logger,\n options?: {\n packageRoot?: string;\n pkgJsonData?: string;\n },\n ) {\n this.logger.debug(\"Reading package information...\");\n\n this.packageRoot = options?.packageRoot ?? util.findPackageRoot(logger);\n\n let pkgJsonData: string;\n if (options?.pkgJsonData) {\n pkgJsonData = options.pkgJsonData;\n } else {\n const pkgJsonPath = path.resolve(this.packageRoot, util.packageJsonName);\n\n this.logger.debug(` - loading '${pkgJsonPath}'`);\n if (!fs.existsSync(pkgJsonPath)) {\n this.logger.error(`no '${util.packageJsonName}' file found at '${this.packageRoot}'`);\n throw util.CLIError(\"not a platform software package directory\");\n }\n\n pkgJsonData = fs.readFileSync(pkgJsonPath, \"utf8\");\n }\n\n const result = parsePackageJson(pkgJsonData);\n if (!result.success) {\n throw util.CLIError(`\\n` + util.formatZodIssues(result.error.issues));\n }\n this.pkgJson = result.data;\n this.logger.debug(\" \" + JSON.stringify(this.pkgJson));\n\n this.validateConfig();\n\n this.packageName = this.pkgJson.name;\n\n logger.debug(\" package information loaded successfully.\");\n }\n\n get isPrivate(): boolean {\n return this.pkgJson.private ?? false;\n }\n\n get binaryRegistries(): binaryRegistryPresets {\n return this.pkgJson[\"block-software\"].registries?.binary ?? {};\n }\n\n get entrypoints(): Map<string, entrypoints.Entrypoint> {\n const list = new Map<string, entrypoints.Entrypoint>();\n\n for (const [epName, ep] of Object.entries(this.pkgJson[\"block-software\"].entrypoints)) {\n if (ep.docker) {\n const artifactID = typeof ep.docker.artifact === \"string\" ? ep.docker.artifact : epName;\n const artifact = this.getArtifact(artifactID, \"docker\");\n\n // will mix docker to separate entrypoint\n // render function have to merge\n list.set(docker.entrypointName(epName), {\n type: \"software\",\n name: epName,\n artifact: artifact,\n cmd: ep.docker.cmd ?? [],\n env: ep.docker.envVars ?? [],\n });\n }\n\n if (ep.reference) {\n list.set(epName, {\n type: \"reference\",\n name: epName,\n reference: ep.reference,\n });\n continue;\n }\n\n if (ep.binary || ep.conda) {\n const swOptions: entrypoints.softwareOptionsType = ep.binary ? ep.binary : ep.conda!;\n const artifactOrRef = ep.binary ? ep.binary.artifact : ep.conda!.artifact;\n const artifactID = typeof artifactOrRef === \"string\" ? artifactOrRef : epName;\n const artifact = this.getArtifact(artifactID, \"any\");\n if (artifact.type === \"asset\") {\n throw util.CLIError(`binary entrypoint cannot point to asset artifact: ${epName}`);\n }\n if (artifact.type === \"environment\") {\n throw util.CLIError(`binary entrypoint cannot point to environment artifact: ${epName}`);\n }\n\n list.set(epName, {\n type: \"software\",\n name: epName,\n artifact: artifact,\n cmd: swOptions.cmd,\n env: swOptions.envVars ?? [],\n });\n\n if (!ep.docker) {\n if (artifacts.dockerAutogenTypes.includes(artifact.type)) {\n switch (artifact.type) {\n case \"conda\":\n case \"python\":\n list.set(docker.entrypointName(epName), {\n type: \"software\",\n name: epName,\n artifact: this.generateDockerPackage(artifact),\n cmd: swOptions.cmd,\n env: swOptions.envVars ?? [],\n });\n continue;\n default: {\n throw new Error(`docker autogeneration is not defined for type: ${artifact.type}`);\n }\n }\n }\n }\n }\n\n if (ep.environment) {\n const packageID =\n typeof ep.environment.artifact === \"string\" ? ep.environment.artifact : epName;\n list.set(epName, {\n type: \"environment\",\n name: epName,\n artifact: this.getArtifact(packageID, \"environment\"),\n env: ep.environment.envVars ?? [],\n });\n continue;\n }\n\n if (ep.asset) {\n const packageID = typeof ep.asset === \"string\" ? ep.asset : epName;\n list.set(epName, {\n type: \"asset\",\n name: epName,\n artifact: this.getArtifact(packageID, \"asset\"),\n });\n continue;\n }\n\n if (list.size === 0) {\n throw util.CLIError(\n `entrypoint '${epName}' type is not supported by current platforma package builder`,\n );\n }\n }\n\n return list;\n }\n\n // Get not docker entrypoint if exists.\n // If only docker entrypoint exists, return it.\n public getMainEntrypoint(name: string): entrypoints.Entrypoint {\n const ep = this.entrypoints.get(name);\n if (ep) {\n return ep;\n }\n\n return this.entrypoints.get(docker.entrypointName(name))!;\n }\n\n /**\n * Resolves entrypoint reference to full entrypoint file path and type\n */\n public resolveReference(epName: string, ep: entrypoints.ReferenceEntrypoint): string {\n this.logger.debug(\n `resolving entrypoint '${epName}' reference '${ep.reference}'. packageRoot='${this.packageRoot}'`,\n );\n\n const refInfo = ep.reference.match(entrypoints.EnyrypointReferencePattern)?.groups;\n\n if (!refInfo) {\n this.logger.error(\n `entrypoint reference '${epName}' has incorrect reference format. <full package name>/<path to entrypoint> is expected`,\n );\n throw util.CLIError(`invalid entrypoint '${epName}' reference format`);\n }\n\n const refPath = tryResolve(this.packageRoot, ep.reference);\n if (!refPath) {\n this.logger.error(`entrypoint reference '${epName}' cannot be resolved into file path`);\n throw util.CLIError(`invalid entrypoint '${epName}' reference`);\n }\n\n return refPath;\n }\n\n // Packages are buildable artifacts with entrypoints\n get packages(): Map<string, artifacts.withId<artifacts.anyArtifactType>> {\n const result = new Map<string, artifacts.withId<artifacts.anyArtifactType>>();\n\n for (const ep of this.entrypoints.values()) {\n if (ep.type === \"reference\") {\n // Entrypoint references are not buildable\n continue;\n }\n\n if (!result.has(ep.artifact.id)) {\n result.set(ep.artifact.id, ep.artifact);\n }\n }\n\n return result;\n }\n\n public artifactInfoLocation(\n pkgID: string,\n artifactType: \"docker\",\n platform: util.ArchType,\n ): string;\n public artifactInfoLocation(\n pkgID: string,\n artifactType: \"archive\",\n platform?: util.PlatformType,\n ): string;\n public artifactInfoLocation(\n pkgID: string,\n artifactType: \"archive\" | \"docker\",\n platform?: util.PlatformType | util.ArchType,\n ): string {\n const platformPart = platform ? `_${platform}` : \"\";\n return path.resolve(\n this.packageRoot,\n \"dist\",\n \"artifacts\",\n pkgID,\n `${artifactType}${platformPart}.json`,\n );\n }\n\n private generateDockerPackage(\n artifact: artifacts.withId<artifacts.pythonType | artifacts.condaType>,\n ): artifacts.withId<artifacts.dockerType> {\n switch (artifact.type) {\n case \"python\": {\n const options = pythonDockerOptions(\n this.logger,\n this.packageRoot,\n this.packageName,\n artifact.id,\n artifact,\n );\n\n return {\n id: artifact.id,\n type: \"docker\",\n registry: artifact[\"docker-registry\"],\n ...options,\n };\n }\n case \"conda\": {\n const options = condaDockerOptions(\n this.logger,\n this.packageRoot,\n artifact.id,\n artifact,\n util.currentArch(),\n );\n\n return {\n id: artifact.id,\n type: \"docker\",\n registry: artifact[\"docker-registry\"],\n ...options,\n };\n }\n default: {\n util.assertNever(artifact);\n throw new Error(\"calm down the linter\");\n }\n }\n }\n\n public getArtifact(\n id: string,\n type: \"asset\",\n ): artifacts.withId<artifacts.withType<\"asset\", artifacts.assetType>>;\n public getArtifact(id: string, type: \"environment\"): artifacts.withId<artifacts.environmentType>;\n public getArtifact(id: string, type: \"binary\"): artifacts.withId<artifacts.binaryType>;\n public getArtifact(id: string, type: \"java\"): artifacts.withId<artifacts.javaType>;\n public getArtifact(id: string, type: \"python\"): artifacts.withId<artifacts.pythonType>;\n public getArtifact(id: string, type: \"R\"): artifacts.withId<artifacts.rType>;\n public getArtifact(id: string, type: \"docker\"): artifacts.withId<artifacts.dockerType>;\n public getArtifact(id: string, type: \"conda\"): artifacts.withId<artifacts.condaType>;\n public getArtifact(id: string, type: \"any\"): artifacts.withId<artifacts.anyArtifactType>;\n public getArtifact(\n id: string,\n type: artifacts.artifactType | \"any\",\n ): artifacts.withId<artifacts.anyArtifactType> {\n const artifacts = this.pkgJson[\"block-software\"].artifacts ?? {};\n const entrypoints = this.pkgJson[\"block-software\"].entrypoints;\n\n let artifact: artifacts.anyArtifactType | undefined;\n let errMsg = \"\";\n if (artifacts[id]) {\n artifact = artifacts[id];\n } else {\n const ep = entrypoints[id];\n if (!ep) {\n throw util.CLIError(\n `artifact with id '${id}' not found neither in 'entrypoints', nor in 'artifacts'`,\n );\n }\n\n errMsg = `incorrect artifact reference in entrypoint '${id}'`;\n\n if (ep.asset) {\n artifact =\n typeof ep.asset === \"string\"\n ? artifacts[ep.asset]\n : ({ type: \"asset\", ...ep.asset } as artifacts.assetType);\n } else if (ep.binary && type !== \"docker\") {\n // single entrypoint can keep both binary and docker\n const a = ep.binary.artifact;\n artifact = typeof a === \"string\" ? artifacts[a] : a;\n } else if (ep.conda && type !== \"docker\") {\n // single entrypoint can keep both conda and docker\n const a = ep.conda.artifact;\n artifact =\n typeof a === \"string\" ? artifacts[a] : ({ type: \"conda\", ...a } as artifacts.condaType);\n } else if (ep.environment) {\n const a = ep.environment.artifact;\n artifact =\n typeof a === \"string\"\n ? artifacts[a]\n : ({ type: \"environment\", ...a } as artifacts.environmentType);\n } else if (ep.docker) {\n const a = ep.docker.artifact;\n artifact =\n typeof a === \"string\" ? artifacts[a] : ({ type: \"docker\", ...a } as artifacts.dockerType);\n }\n }\n\n if (!artifact) {\n throw util.CLIError(\n `artifact '${id}' not found neither in 'entrypoints', nor in 'artifacts'`,\n );\n }\n\n switch (type) {\n case \"docker\": {\n return {\n id: id,\n ...requireArtifactType(artifact, \"docker\", errMsg),\n };\n }\n case \"asset\": {\n return {\n id: id,\n ...requireArtifactType(artifact, \"asset\", errMsg),\n };\n }\n case \"environment\": {\n return {\n id: id,\n ...requireArtifactType(artifact, \"environment\", errMsg),\n };\n }\n case \"binary\": {\n return {\n id: id,\n ...requireArtifactType(artifact, \"binary\", errMsg),\n };\n }\n case \"java\": {\n return {\n id: id,\n ...requireArtifactType(artifact, \"java\", errMsg),\n };\n }\n case \"python\": {\n return {\n id: id,\n ...requireArtifactType(artifact, \"python\", errMsg),\n };\n }\n case \"R\": {\n return {\n id: id,\n ...requireArtifactType(artifact, \"R\", errMsg),\n };\n }\n case \"conda\": {\n return {\n id: id,\n ...requireArtifactType(artifact, \"conda\", errMsg),\n };\n }\n case \"any\": {\n return {\n id: id,\n ...artifact,\n };\n }\n default: {\n util.assertNever(type);\n throw util.CLIError(`invalid artifact type`); // calm down the linter\n }\n }\n }\n\n public set version(v: string | undefined) {\n this._versionOverride = v;\n }\n\n public artifactName(artifact: artifacts.withId<artifacts.anyArtifactType>): string {\n if (artifact.type !== \"docker\") {\n if (artifact.name) {\n return artifact.name;\n }\n }\n\n return util.trimPrefix(this.pkgJson.name, \"@\") + \"/\" + artifact.id;\n }\n\n public artifactVersion(artifact: artifacts.anyArtifactType): string {\n if (this._versionOverride) {\n return this._versionOverride;\n }\n\n if (process.env[envs.PL_PKG_VERSION]) {\n return process.env[envs.PL_PKG_VERSION];\n }\n\n if (artifact.type !== \"docker\" && artifact.version) {\n return artifact.version;\n }\n\n return this.pkgJson.version;\n }\n\n public artifactRegistrySettings(artifact: artifacts.anyArtifactType): artifacts.registry {\n if (artifact.type === \"docker\") {\n return {\n name: artifact.registry,\n };\n }\n\n const registry = artifact.registry;\n const registries = this.binaryRegistries;\n\n const result: artifacts.registry = {\n name: \"default\",\n downloadURL: registries.default?.downloadURL,\n storageURL: registries.default?.storageURL,\n };\n\n if (registry) {\n if (typeof registry === \"string\") {\n result.name = registry;\n const regDefault = wellKnownRegistries[result.name];\n result.downloadURL = registries[result.name]?.downloadURL ?? regDefault?.downloadURL;\n result.storageURL = registries[result.name]?.storageURL ?? regDefault?.storageURL;\n } else {\n result.name = registry.name;\n const regDefault = wellKnownRegistries[result.name];\n result.downloadURL =\n registry.downloadURL ?? registries[result.name]?.downloadURL ?? regDefault?.downloadURL;\n result.storageURL =\n registry.storageURL ?? registries[result.name]?.storageURL ?? regDefault?.storageURL;\n }\n }\n\n const regNameUpper = result.name.toUpperCase().replaceAll(/[^A-Z0-9_]/g, \"_\");\n\n const uploadTo = process.env[`PL_REGISTRY_${regNameUpper}_UPLOAD_URL`];\n if (uploadTo) {\n result.storageURL = uploadTo;\n }\n\n const downloadFrom = process.env[`PL_REGISTRY_${regNameUpper}_DOWNLOAD_URL`];\n if (downloadFrom) {\n result.downloadURL = downloadFrom;\n }\n\n if (result.downloadURL) {\n const u = new URL(result.downloadURL, \"file:/nonexistent\"); // check download URL is valid URL\n if (![\"https:\", \"http:\"].includes(u.protocol)) {\n throw util.CLIError(\n `registry ${result.name} download URL is not valid. Only 'https://' and 'http://' schemes are supported for now`,\n );\n }\n }\n\n return result;\n }\n\n public artifactContentRoot(\n artifact: artifacts.withId<artifacts.anyArtifactType>,\n platform: util.PlatformType,\n ): string {\n if (\"root\" in artifact && artifact.root) {\n return path.resolve(this.packageRoot, artifact.root);\n }\n if (\"roots\" in artifact && artifact.roots[platform]) {\n return path.resolve(this.packageRoot, artifact.roots[platform]);\n }\n\n throw util.CLIError(\n `root path of software archive on ${platform} is undefined for binary package`,\n );\n }\n\n public artifactPlatforms(\n artifact: artifacts.withId<artifacts.anyArtifactType>,\n ): util.PlatformType[] {\n if (artifact.type === \"docker\") {\n return [util.currentPlatform()];\n }\n\n if (\"root\" in artifact && artifact.root) {\n return [util.currentPlatform()];\n }\n\n if (\"roots\" in artifact) {\n return Object.keys(artifact.roots) as util.PlatformType[];\n }\n\n throw util.CLIError(\n `no platforms are defined as supported for artifact '${artifact.id}' in binary mode ` +\n `(no 'roots' are defined)`,\n );\n }\n\n public artifactArchiveFullName(\n artifact: artifacts.withId<artifacts.anyArtifactType>,\n platform: util.PlatformType,\n ): string {\n const group = artifact.type === \"asset\" ? \"assets\" : \"software\";\n const extension = artifact.type === \"asset\" ? \"zip\" : \"tgz\";\n const name = this.artifactName(artifact);\n const version = this.artifactVersion(artifact);\n\n if (artifacts.isCrossPlatform(artifact.type)) {\n return `${group}/${name}/${version}.${extension}`;\n }\n\n const { os, arch } = util.splitPlatform(platform);\n return `${group}/${name}/${version}-${os}-${arch}.${extension}`;\n }\n\n public artifactArchiveAddressPattern(\n artifact: artifacts.withId<artifacts.anyArtifactType>,\n ): string {\n const group = artifact.type === \"asset\" ? \"assets\" : \"software\";\n const extension = artifact.type === \"asset\" ? \"zip\" : \"tgz\";\n const name = this.artifactName(artifact);\n const version = this.artifactVersion(artifact);\n\n if (artifacts.isCrossPlatform(artifact.type)) {\n return `${group}/${name}/${version}.${extension}`;\n }\n\n return `${group}/${name}/${version}-{os}-{arch}.${extension}`;\n }\n\n private validateConfig() {\n let hasErrors: boolean = false;\n\n const blockSoftware = this.pkgJson[\"block-software\"];\n\n const as = blockSoftware.artifacts ?? {};\n const entrypoints = blockSoftware.entrypoints ?? {};\n\n for (const [epName, ep] of Object.entries(entrypoints)) {\n if (ep.binary) {\n const artifactID = typeof ep.binary.artifact === \"string\" ? ep.binary.artifact : epName;\n const artifact = this.getArtifact(artifactID, \"any\");\n\n if (!artifact) {\n this.logger.error(\n `entrypoint '${epName}' refers to artifact '${artifactID}' which is not defined in '${util.softwareConfigName}'`,\n );\n hasErrors = true;\n }\n\n if (!this.validateArtifact(artifactID, artifact)) {\n hasErrors = true;\n }\n\n if (!artifacts.isBuildable(artifact.type)) {\n this.logger.error(\n `entrypoint '${epName}' artifact type '${artifact.type}' is not buildable to binary package`,\n );\n hasErrors = true;\n }\n\n if (artifact.type === \"environment\") {\n this.logger.error(\n `entrypoint '${epName}' artifact type '${artifact.type}' cannot be build into software pacakge. Use 'environment' entrypoint`,\n );\n hasErrors = true;\n }\n }\n\n if (ep.environment) {\n const artifactID =\n typeof ep.environment.artifact === \"string\" ? ep.environment.artifact : epName;\n const artifact = this.getArtifact(artifactID, \"any\");\n\n if (!artifact) {\n this.logger.error(\n `entrypoint '${epName}' refers to artifact '${artifactID}' which is not defined in '${util.softwareConfigName}'`,\n );\n hasErrors = true;\n }\n\n if (!this.validateArtifact(artifactID, artifact)) {\n hasErrors = true;\n }\n\n if (artifact.type !== \"environment\") {\n this.logger.error(\n `entrypoint '${epName}' with 'environment' settings should refer to 'environment' artifact type`,\n );\n hasErrors = true;\n }\n }\n\n // TODO: add docker validation here\n // TODO(rfiskov)[MILAB-3163]: Carefully handle docker artifacts, as some (e.g., for Python) may be autogenerated dynamically rather than explicitly defined.\n }\n\n const uniquePackageNames = new Set<string>();\n\n for (const [artifactID, artifact] of Object.entries(as)) {\n if (!artifacts.isBuildable(artifact.type)) {\n continue;\n }\n\n if (!this.validateArtifact(artifactID, artifact)) {\n hasErrors = true;\n }\n\n const name = this.artifactName({ id: artifactID, ...artifact });\n const version = this.artifactVersion(artifact);\n const uniqueName = `${name}-${version}`;\n if (uniquePackageNames.has(uniqueName)) {\n this.logger.error(\n `found two packages with the same name '${name}' and version '${version}'`,\n );\n hasErrors = true;\n }\n\n uniquePackageNames.add(uniqueName);\n }\n\n if (hasErrors) {\n throw util.CLIError(\n `${util.softwareConfigName} has xconfiguration errors in 'block-software' section. See error log messages above for details`,\n );\n }\n }\n\n private validateArtifact(artifactName: string, artifact: artifacts.anyArtifactType): boolean {\n if (artifacts.isBuildable(artifact.type)) {\n // Validate that root is not equal to package root\n const resolvedRoots: string[] = [];\n const aType = artifact.type;\n switch (aType) {\n case \"asset\":\n case \"java\":\n case \"R\":\n case \"python\": {\n resolvedRoots.push(path.resolve(this.packageRoot, artifact.root));\n break;\n }\n case \"docker\": {\n resolvedRoots.push(path.resolve(this.packageRoot, artifact.context));\n break;\n }\n case \"environment\":\n case \"conda\":\n case \"binary\": {\n resolvedRoots.push(\n ...Object.values(artifact.roots).map((root) => path.resolve(this.packageRoot, root)),\n );\n break;\n }\n default:\n util.assertNever(aType);\n }\n\n for (const root of resolvedRoots) {\n if (root === this.packageRoot) {\n this.logger.error(\n `Invalid configuration: '${artifact.type}' artifact '${artifactName}' has 'root' set to the package root, which is not allowed`,\n );\n return false;\n }\n }\n }\n\n return true;\n }\n}\n\nfunction parsePackageJson(data: string): z.ZodSafeParseResult<packageJson> {\n const parsedData: unknown = JSON.parse(data);\n return packageJsonSchema.safeParse(parsedData);\n}\n\nfunction requireArtifactType(\n artifact: artifacts.anyArtifactType,\n type: \"asset\",\n errMsg: string,\n): artifacts.withType<\"asset\", artifacts.assetType>;\nfunction requireArtifactType(\n artifact: artifacts.anyArtifactType,\n type: \"environment\",\n errMsg: string,\n): artifacts.environmentType;\nfunction requireArtifactType(\n artifact: artifacts.anyArtifactType,\n type: \"java\",\n errMsg: string,\n): artifacts.javaType;\nfunction requireArtifactType(\n artifact: artifacts.anyArtifactType,\n type: \"python\",\n errMsg: string,\n): artifacts.pythonType;\nfunction requireArtifactType(\n artifact: artifacts.anyArtifactType,\n type: \"R\",\n errMsg: string,\n): artifacts.rType;\nfunction requireArtifactType(\n artifact: artifacts.anyArtifactType,\n type: \"binary\",\n errMsg: string,\n): artifacts.binaryType;\nfunction requireArtifactType(\n artifact: artifacts.anyArtifactType,\n type: \"docker\",\n errMsg: string,\n): artifacts.dockerType;\nfunction requireArtifactType(\n artifact: artifacts.anyArtifactType,\n type: \"conda\",\n errMsg: string,\n): artifacts.condaType;\nfunction requireArtifactType(\n artifact: artifacts.anyArtifactType,\n type: artifacts.artifactType,\n errMsg: string,\n): artifacts.anyArtifactType {\n if (artifact.type === type) {\n return artifact;\n }\n\n if (errMsg) {\n errMsg = `${errMsg}: `;\n }\n\n throw util.CLIError(`${errMsg}wrong artifact type: expected '${type}', got '${artifact.type}'`);\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,sBAAsB,EAAE,OA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AAK,cAAc,aAAa,4DACrE;AACD,WAAO;;;AAKb,SAAO;;;AAIX,SAAS,iBAAiB,MAAiD;CACzE,MAAM,aAAsB,KAAK,MAAM,KAAK;AAC5C,QAAO,kBAAkB,UAAU,WAAW;;AA2ChD,SAAS,oBACP,UACA,MACA,QAC2B;AAC3B,KAAI,SAAS,SAAS,KACpB,QAAO;AAGT,KAAI,OACF,UAAS,GAAG,OAAO;AAGrB,OAAMG,SAAc,GAAG,OAAO,iCAAiC,KAAK,UAAU,SAAS,KAAK,GAAG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
let node_url = require("node:url");
|
|
4
|
+
//#region src/core/paths.ts
|
|
5
|
+
const __dirname$1 = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
6
|
+
function path(...p) {
|
|
7
|
+
return (0, node_path.resolve)(__dirname$1, "..", "..", ...p);
|
|
8
|
+
}
|
|
9
|
+
function assets(...p) {
|
|
10
|
+
return path("assets", ...p);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.assets = assets;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=paths.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.cjs","names":["__dirname"],"sources":["../../src/core/paths.ts"],"sourcesContent":["import { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport function path(...p: string[]): string {\n return resolve(__dirname, \"..\", \"..\", ...p);\n}\n\nexport function assets(...p: string[]): string {\n return path(\"assets\", ...p);\n}\n\nexport function dist(...p: string[]): string {\n return path(\"dist\", ...p);\n}\n"],"mappings":";;;;AAGA,MAAMA,eAAAA,GAAAA,UAAAA,UAAAA,GAAAA,SAAAA,eAAAA,QAAAA,MAAAA,CAAAA,cAAAA,WAAAA,CAAAA,KAAkD,CAAC;AAEzD,SAAgB,KAAK,GAAG,GAAqB;AAC3C,SAAA,GAAA,UAAA,SAAeA,aAAW,MAAM,MAAM,GAAG,EAAE;;AAG7C,SAAgB,OAAO,GAAG,GAAqB;AAC7C,QAAO,KAAK,UAAU,GAAG,EAAE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
//#region src/core/paths.ts
|
|
4
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
function path$1(...p) {
|
|
6
|
+
return resolve(__dirname, "..", "..", ...p);
|
|
7
|
+
}
|
|
8
|
+
function assets(...p) {
|
|
9
|
+
return path$1("assets", ...p);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { assets };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","names":["path"],"sources":["../../src/core/paths.ts"],"sourcesContent":["import { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport function path(...p: string[]): string {\n return resolve(__dirname, \"..\", \"..\", ...p);\n}\n\nexport function assets(...p: string[]): string {\n return path(\"assets\", ...p);\n}\n\nexport function dist(...p: string[]): string {\n return path(\"dist\", ...p);\n}\n"],"mappings":";;;AAGA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,SAAgBA,OAAK,GAAG,GAAqB;AAC3C,QAAO,QAAQ,WAAW,MAAM,MAAM,GAAG,EAAE;;AAG7C,SAAgB,OAAO,GAAG,GAAqB;AAC7C,QAAOA,OAAK,UAAU,GAAG,EAAE"}
|