@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,327 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_defaults = require("../defaults.cjs");
|
|
3
|
+
const require_util = require("./util.cjs");
|
|
4
|
+
const require_artifacts = require("./schemas/artifacts.cjs");
|
|
5
|
+
const require_docker = require("./docker.cjs");
|
|
6
|
+
const require_resolver = require("./resolver.cjs");
|
|
7
|
+
let node_fs = require("node:fs");
|
|
8
|
+
node_fs = require_runtime.__toESM(node_fs);
|
|
9
|
+
let node_path = require("node:path");
|
|
10
|
+
node_path = require_runtime.__toESM(node_path);
|
|
11
|
+
//#region src/core/sw-json-render.ts
|
|
12
|
+
var SwJsonRenderer = class {
|
|
13
|
+
constructor(logger, pkgInfo) {
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
this.pkgInfo = pkgInfo;
|
|
16
|
+
}
|
|
17
|
+
renderSoftwareEntrypoints(mode, entrypoints, options) {
|
|
18
|
+
const result = /* @__PURE__ */ new Map();
|
|
19
|
+
let hasReferences = false;
|
|
20
|
+
const fullDirHash = options?.fullDirHash ?? false;
|
|
21
|
+
this.logger.info(`Rendering entrypoint descriptors...`);
|
|
22
|
+
this.logger.debug(" entrypoints: " + JSON.stringify(entrypoints));
|
|
23
|
+
for (const [epName, ep] of entrypoints.entries()) {
|
|
24
|
+
if (ep.type === "reference") {
|
|
25
|
+
hasReferences = true;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
this.logger.debug(`Rendering entrypoint descriptor '${epName}'...`);
|
|
29
|
+
const originEpName = require_docker.entrypointNameToOrigin(epName);
|
|
30
|
+
const info = result.has(originEpName) ? result.get(originEpName) : { id: {
|
|
31
|
+
package: this.pkgInfo.packageName,
|
|
32
|
+
name: originEpName
|
|
33
|
+
} };
|
|
34
|
+
if (!info) throw require_util.CLIError(`Entrypoint ${epName} not found in result`);
|
|
35
|
+
if (mode !== "release") info.isDev = true;
|
|
36
|
+
const pkg = ep.artifact;
|
|
37
|
+
if (require_util.isDevLocalMode(mode)) {
|
|
38
|
+
switch (pkg.type) {
|
|
39
|
+
case "docker":
|
|
40
|
+
info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
this.logger.debug(" rendering 'local' source...");
|
|
44
|
+
info.local = this.renderLocalPackage(epName, ep, fullDirHash);
|
|
45
|
+
}
|
|
46
|
+
result.set(originEpName, info);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const type = pkg.type;
|
|
50
|
+
switch (type) {
|
|
51
|
+
case "R":
|
|
52
|
+
info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);
|
|
53
|
+
break;
|
|
54
|
+
case "environment":
|
|
55
|
+
info.runEnv = this.renderRunEnvInfo(mode, epName, ep, options?.requireAllArtifacts);
|
|
56
|
+
break;
|
|
57
|
+
case "asset":
|
|
58
|
+
info.asset = this.renderAssetInfo(mode, epName, ep, options?.requireAllArtifacts);
|
|
59
|
+
break;
|
|
60
|
+
case "binary":
|
|
61
|
+
info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);
|
|
62
|
+
break;
|
|
63
|
+
case "docker":
|
|
64
|
+
info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);
|
|
65
|
+
break;
|
|
66
|
+
case "java":
|
|
67
|
+
info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);
|
|
68
|
+
break;
|
|
69
|
+
case "python":
|
|
70
|
+
info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);
|
|
71
|
+
break;
|
|
72
|
+
case "conda":
|
|
73
|
+
info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
require_util.assertNever(type);
|
|
77
|
+
throw new Error(`renderer logic error: renderSoftwareEntrypoints does not cover all package types`);
|
|
78
|
+
}
|
|
79
|
+
result.set(originEpName, info);
|
|
80
|
+
}
|
|
81
|
+
if (result.size === 0 && !hasReferences) {
|
|
82
|
+
this.logger.error("no entrypoint descriptors were rendered");
|
|
83
|
+
throw require_util.CLIError("no entrypoint descriptors were rendered");
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
writeSwJson(info, dstFile) {
|
|
88
|
+
const epType = info.asset ? "asset" : "software";
|
|
89
|
+
const dstSwInfoPath = dstFile ?? require_resolver.descriptorFilePath(this.pkgInfo.packageRoot, epType, info.id.name);
|
|
90
|
+
this.logger.info(`Writing entrypoint descriptor to '${dstSwInfoPath}'`);
|
|
91
|
+
const { id, ...toEncode } = info;
|
|
92
|
+
const encoded = JSON.stringify({
|
|
93
|
+
name: require_util.artifactIDToString(id),
|
|
94
|
+
...toEncode
|
|
95
|
+
});
|
|
96
|
+
require_util.ensureDirsExist(node_path.default.dirname(dstSwInfoPath));
|
|
97
|
+
node_fs.default.writeFileSync(dstSwInfoPath, encoded + "\n");
|
|
98
|
+
}
|
|
99
|
+
copySwJson(epName, srcFile) {
|
|
100
|
+
let epType;
|
|
101
|
+
if (srcFile.endsWith(".sw.json")) epType = "software";
|
|
102
|
+
else if (srcFile.endsWith(".as.json")) epType = "asset";
|
|
103
|
+
else throw require_util.CLIError(`unknown entrypoint '${epName}' type: cannot get type from extension of source file ${srcFile}`);
|
|
104
|
+
const dstSwInfoPath = require_resolver.descriptorFilePath(this.pkgInfo.packageRoot, epType, epName);
|
|
105
|
+
require_util.ensureDirsExist(node_path.default.dirname(dstSwInfoPath));
|
|
106
|
+
node_fs.default.copyFileSync(srcFile, dstSwInfoPath);
|
|
107
|
+
}
|
|
108
|
+
renderLocalPackage(epName, ep, fullDirHash) {
|
|
109
|
+
const artifact = ep.artifact;
|
|
110
|
+
const rootDir = this.pkgInfo.artifactContentRoot(artifact, require_util.currentPlatform());
|
|
111
|
+
const hash = fullDirHash ? require_util.hashDirSync(rootDir) : require_util.hashDirMetaSync(rootDir);
|
|
112
|
+
const localPath = rootDir;
|
|
113
|
+
const epType = ep.type;
|
|
114
|
+
switch (epType) {
|
|
115
|
+
case "environment": throw require_util.CLIError(`entrypoint ${epName} points to 'environment' artifact, which does not support local build yet`);
|
|
116
|
+
case "asset": throw require_util.CLIError(`entrypoint ${epName} points to 'asset' artifact, which does not support local build yet`);
|
|
117
|
+
case "software": {
|
|
118
|
+
const pkgType = artifact.type;
|
|
119
|
+
switch (pkgType) {
|
|
120
|
+
case "environment": throw require_util.CLIError(`entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`);
|
|
121
|
+
case "asset": throw require_util.CLIError(`entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`);
|
|
122
|
+
case "binary": return {
|
|
123
|
+
type: "binary",
|
|
124
|
+
hash: hash.digest().toString("hex"),
|
|
125
|
+
path: localPath,
|
|
126
|
+
cmd: ep.cmd,
|
|
127
|
+
envVars: ep.env
|
|
128
|
+
};
|
|
129
|
+
case "java": return {
|
|
130
|
+
type: "java",
|
|
131
|
+
hash: hash.digest().toString("hex"),
|
|
132
|
+
path: localPath,
|
|
133
|
+
cmd: ep.cmd,
|
|
134
|
+
envVars: ep.env,
|
|
135
|
+
runEnv: require_resolver.resolveRunEnvironment(this.logger, this.pkgInfo.packageRoot, this.pkgInfo.packageName, artifact.environment, artifact.type)
|
|
136
|
+
};
|
|
137
|
+
case "python": {
|
|
138
|
+
const { toolset, ...deps } = artifact.dependencies ?? {};
|
|
139
|
+
return {
|
|
140
|
+
type: "python",
|
|
141
|
+
hash: hash.digest().toString("hex"),
|
|
142
|
+
path: localPath,
|
|
143
|
+
cmd: ep.cmd,
|
|
144
|
+
envVars: ep.env,
|
|
145
|
+
runEnv: require_resolver.resolveRunEnvironment(this.logger, this.pkgInfo.packageRoot, this.pkgInfo.packageName, artifact.environment, artifact.type),
|
|
146
|
+
toolset: toolset ?? "pip",
|
|
147
|
+
dependencies: deps
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
case "R": return {
|
|
151
|
+
type: "R",
|
|
152
|
+
hash: hash.digest().toString("hex"),
|
|
153
|
+
path: localPath,
|
|
154
|
+
cmd: ep.cmd,
|
|
155
|
+
envVars: ep.env,
|
|
156
|
+
toolset: "renv",
|
|
157
|
+
dependencies: {},
|
|
158
|
+
runEnv: require_resolver.resolveRunEnvironment(this.logger, this.pkgInfo.packageRoot, this.pkgInfo.packageName, artifact.environment, artifact.type)
|
|
159
|
+
};
|
|
160
|
+
case "docker": throw new Error(`internal build script logic error: attempt to build docker entrypoint as local binary package`);
|
|
161
|
+
case "conda": return {
|
|
162
|
+
type: "conda",
|
|
163
|
+
hash: hash.digest().toString("hex"),
|
|
164
|
+
path: localPath,
|
|
165
|
+
cmd: ep.cmd,
|
|
166
|
+
envVars: ep.env,
|
|
167
|
+
["micromamba-version"]: artifact["micromamba-version"],
|
|
168
|
+
["conda-root-dir"]: artifact["conda-root-dir"],
|
|
169
|
+
spec: artifact.spec
|
|
170
|
+
};
|
|
171
|
+
default:
|
|
172
|
+
require_util.assertNever(pkgType);
|
|
173
|
+
throw new Error("renderer logic error: renderLocalInfo does not cover all artifact types");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
default:
|
|
177
|
+
require_util.assertNever(epType);
|
|
178
|
+
throw new Error("renderer logic error: renderLocalInfo does not cover all environment types");
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
renderBinaryInfo(mode, epName, ep, requireArtifactInfo) {
|
|
182
|
+
switch (mode) {
|
|
183
|
+
case "release": break;
|
|
184
|
+
case "dev-local": throw new Error(`'*.sw.json' generator logic error`);
|
|
185
|
+
default: require_util.assertNever(mode);
|
|
186
|
+
}
|
|
187
|
+
ep = requireEntrypointType(ep, "software", `internal build script logic error`);
|
|
188
|
+
const binPkg = ep.artifact;
|
|
189
|
+
const artInfoPath = this.pkgInfo.artifactInfoLocation(binPkg.id, "archive", require_artifacts.isCrossPlatform(binPkg.type) ? void 0 : require_util.currentPlatform());
|
|
190
|
+
const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);
|
|
191
|
+
if (!artInfo) return;
|
|
192
|
+
if (!artInfo.registryName) throw require_util.CLIError(`could not render binary entrypoint '${epName}': registry name is not set in artifact info file ${artInfoPath}`);
|
|
193
|
+
const pkgType = binPkg.type;
|
|
194
|
+
switch (pkgType) {
|
|
195
|
+
case "docker": throw new Error(`internal build script logic error: entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`);
|
|
196
|
+
case "conda": return {
|
|
197
|
+
type: "conda",
|
|
198
|
+
registry: artInfo.registryName,
|
|
199
|
+
package: artInfo.remoteArtifactLocation,
|
|
200
|
+
cmd: ep.cmd,
|
|
201
|
+
envVars: ep.env,
|
|
202
|
+
["micromamba-version"]: binPkg["micromamba-version"],
|
|
203
|
+
["conda-root-dir"]: binPkg["conda-root-dir"],
|
|
204
|
+
spec: require_defaults.CONDA_FROZEN_ENV_SPEC_FILE
|
|
205
|
+
};
|
|
206
|
+
case "binary": return {
|
|
207
|
+
type: "binary",
|
|
208
|
+
registry: artInfo.registryName,
|
|
209
|
+
package: artInfo.remoteArtifactLocation,
|
|
210
|
+
cmd: ep.cmd,
|
|
211
|
+
envVars: ep.env
|
|
212
|
+
};
|
|
213
|
+
case "java": return {
|
|
214
|
+
type: "java",
|
|
215
|
+
registry: artInfo.registryName,
|
|
216
|
+
package: artInfo.remoteArtifactLocation,
|
|
217
|
+
cmd: ep.cmd,
|
|
218
|
+
envVars: ep.env,
|
|
219
|
+
runEnv: require_resolver.resolveRunEnvironment(this.logger, this.pkgInfo.packageRoot, this.pkgInfo.packageName, binPkg.environment, binPkg.type)
|
|
220
|
+
};
|
|
221
|
+
case "python": {
|
|
222
|
+
const { toolset, ...deps } = binPkg.dependencies ?? {};
|
|
223
|
+
return {
|
|
224
|
+
type: "python",
|
|
225
|
+
registry: artInfo.registryName,
|
|
226
|
+
package: artInfo.remoteArtifactLocation,
|
|
227
|
+
cmd: ep.cmd,
|
|
228
|
+
envVars: ep.env,
|
|
229
|
+
runEnv: require_resolver.resolveRunEnvironment(this.logger, this.pkgInfo.packageRoot, this.pkgInfo.packageName, binPkg.environment, binPkg.type),
|
|
230
|
+
toolset: toolset ?? "pip",
|
|
231
|
+
dependencies: deps
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
case "R": return {
|
|
235
|
+
type: "R",
|
|
236
|
+
registry: artInfo.registryName,
|
|
237
|
+
package: artInfo.remoteArtifactLocation,
|
|
238
|
+
cmd: ep.cmd,
|
|
239
|
+
envVars: ep.env,
|
|
240
|
+
runEnv: require_resolver.resolveRunEnvironment(this.logger, this.pkgInfo.packageRoot, this.pkgInfo.packageName, binPkg.environment, binPkg.type),
|
|
241
|
+
toolset: "renv",
|
|
242
|
+
dependencies: {}
|
|
243
|
+
};
|
|
244
|
+
default:
|
|
245
|
+
require_util.assertNever(pkgType);
|
|
246
|
+
throw new Error("internal build script logic error: renderBinaryInfo does not cover all package types");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
renderRunEnvInfo(mode, epName, ep, requireArtifactInfo) {
|
|
250
|
+
switch (mode) {
|
|
251
|
+
case "release": break;
|
|
252
|
+
case "dev-local": throw require_util.CLIError(`run environments do not support 'local' dev build mode yet`);
|
|
253
|
+
default: require_util.assertNever(mode);
|
|
254
|
+
}
|
|
255
|
+
ep = requireEntrypointType(ep, "environment", `internal build script logic error`);
|
|
256
|
+
const envArtifact = requireArtifactType(ep.artifact, "environment", `could not render 'environment' entrypoint`);
|
|
257
|
+
const artInfo = readArtifactInfoIfExists(this.pkgInfo.artifactInfoLocation(envArtifact.id, "archive", require_util.currentPlatform()), epName, requireArtifactInfo);
|
|
258
|
+
if (!artInfo) return;
|
|
259
|
+
return {
|
|
260
|
+
type: envArtifact.runtime,
|
|
261
|
+
["r-version"]: envArtifact["r-version"],
|
|
262
|
+
["python-version"]: envArtifact["python-version"],
|
|
263
|
+
["java-version"]: envArtifact["java-version"],
|
|
264
|
+
envVars: envArtifact.envVars ?? [],
|
|
265
|
+
registry: artInfo.registryName,
|
|
266
|
+
package: artInfo.remoteArtifactLocation,
|
|
267
|
+
binDir: envArtifact.binDir
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
renderAssetInfo(mode, epName, ep, requireArtifactInfo) {
|
|
271
|
+
switch (mode) {
|
|
272
|
+
case "release": break;
|
|
273
|
+
case "dev-local": throw require_util.CLIError(`assets do not support 'local' dev build mode yet`);
|
|
274
|
+
default: require_util.assertNever(mode);
|
|
275
|
+
}
|
|
276
|
+
ep = requireEntrypointType(ep, "asset", `internal build script logic error`);
|
|
277
|
+
const assetPkg = requireArtifactType(ep.artifact, "asset", `could not render 'asset' entrypoint`);
|
|
278
|
+
if (assetPkg.type !== "asset") throw require_util.CLIError(`could not render asset entrypoint '${epName}': not 'asset' artifact`);
|
|
279
|
+
const artInfo = readArtifactInfoIfExists(this.pkgInfo.artifactInfoLocation(assetPkg.id, "archive", void 0), epName, requireArtifactInfo);
|
|
280
|
+
if (!artInfo) return;
|
|
281
|
+
if (!artInfo.registryURL) throw require_util.CLIError(`could not render asset entrypoint '${epName}': base download URL is not configured for asset's registry`);
|
|
282
|
+
return {
|
|
283
|
+
registry: artInfo.registryName,
|
|
284
|
+
package: artInfo.remoteArtifactLocation,
|
|
285
|
+
url: require_util.urlJoin(artInfo.registryURL, artInfo.remoteArtifactLocation)
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
renderDockerInfo(epName, ep, requireArtifactInfo) {
|
|
289
|
+
ep = requireEntrypointType(ep, "software", `internal build script logic error`);
|
|
290
|
+
const dockerArtifact = requireArtifactType(ep.artifact, "docker", `could not render 'docker' entrypoint`);
|
|
291
|
+
const artInfo = readArtifactInfoIfExists(this.pkgInfo.artifactInfoLocation(dockerArtifact.id, "docker", "x64"), epName, requireArtifactInfo);
|
|
292
|
+
if (!artInfo) return;
|
|
293
|
+
return {
|
|
294
|
+
tag: artInfo.remoteArtifactLocation,
|
|
295
|
+
entrypoint: artInfo.entrypoint ?? [],
|
|
296
|
+
cmd: ep.cmd,
|
|
297
|
+
pkg: dockerArtifact.pkg || "/"
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
function writeBuiltArtifactInfo(location, locInfo) {
|
|
302
|
+
node_fs.default.mkdirSync(node_path.default.dirname(location), { recursive: true });
|
|
303
|
+
node_fs.default.writeFileSync(location, JSON.stringify(locInfo), { encoding: "utf8" });
|
|
304
|
+
}
|
|
305
|
+
function readBuiltArtifactInfo(location) {
|
|
306
|
+
const data = node_fs.default.readFileSync(location, "utf8");
|
|
307
|
+
return JSON.parse(data);
|
|
308
|
+
}
|
|
309
|
+
function readArtifactInfoIfExists(location, epName, requireExisting) {
|
|
310
|
+
if (node_fs.default.existsSync(location)) return readBuiltArtifactInfo(location);
|
|
311
|
+
if (requireExisting) throw require_util.CLIError(`could not render docker entrypoint '${epName}': artifact info file '${location}' does not exist`);
|
|
312
|
+
}
|
|
313
|
+
function requireEntrypointType(ep, type, errMsg) {
|
|
314
|
+
if (ep.type === type) return ep;
|
|
315
|
+
throw new Error(`${errMsg}: entrypoint ${ep.name} (${ep.type}) is not '${type}'`);
|
|
316
|
+
}
|
|
317
|
+
function requireArtifactType(pkg, type, errMsg) {
|
|
318
|
+
if (pkg.type === type) return pkg;
|
|
319
|
+
if (errMsg) errMsg = `${errMsg}: `;
|
|
320
|
+
throw require_util.CLIError(`${errMsg}artifact '${pkg.id}' ('${pkg.type}') is not '${type}'`);
|
|
321
|
+
}
|
|
322
|
+
//#endregion
|
|
323
|
+
exports.SwJsonRenderer = SwJsonRenderer;
|
|
324
|
+
exports.readBuiltArtifactInfo = readBuiltArtifactInfo;
|
|
325
|
+
exports.writeBuiltArtifactInfo = writeBuiltArtifactInfo;
|
|
326
|
+
|
|
327
|
+
//# sourceMappingURL=sw-json-render.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sw-json-render.cjs","names":["descriptorFilePath","path","resolveRunEnvironment","fs"],"sources":["../../src/core/sw-json-render.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type winston from \"winston\";\nimport type { PackageInfo } from \"./package-info\";\nimport * as artifacts from \"./schemas/artifacts\";\nimport type * as swJson from \"./schemas/sw-json\";\nimport type * as entrypoint from \"./schemas/entrypoints\";\nimport * as util from \"./util\";\nimport * as docker from \"./docker\";\nimport * as defaults from \"../defaults\";\nimport { descriptorFilePath } from \"./resolver\";\nimport { resolveRunEnvironment } from \"./resolver\";\n\nexport class SwJsonRenderer {\n constructor(\n private logger: winston.Logger,\n private readonly pkgInfo: PackageInfo,\n ) {}\n\n public renderSoftwareEntrypoints(\n mode: util.BuildMode,\n entrypoints: Map<string, entrypoint.Entrypoint>,\n options?: {\n requireAllArtifacts?: boolean;\n fullDirHash?: boolean;\n },\n ): Map<string, swJson.swJsonType> {\n const result = new Map<string, swJson.swJsonType>();\n let hasReferences = false;\n\n const fullDirHash = options?.fullDirHash ?? false;\n\n this.logger.info(`Rendering entrypoint descriptors...`);\n this.logger.debug(\" entrypoints: \" + JSON.stringify(entrypoints));\n\n for (const [epName, ep] of entrypoints.entries()) {\n if (ep.type === \"reference\") {\n // Entrypoint references do not need any rendering\n hasReferences = true;\n continue;\n }\n\n this.logger.debug(`Rendering entrypoint descriptor '${epName}'...`);\n\n //\n // In docker case we should merge docker info and other info\n //\n const originEpName = docker.entrypointNameToOrigin(epName);\n const info = result.has(originEpName)\n ? result.get(originEpName)\n : {\n id: {\n package: this.pkgInfo.packageName,\n name: originEpName,\n },\n };\n if (!info) {\n throw util.CLIError(`Entrypoint ${epName} not found in result`);\n }\n\n if (mode !== \"release\") {\n info.isDev = true;\n }\n\n const pkg = ep.artifact;\n if (util.isDevLocalMode(mode)) {\n switch (pkg.type) {\n case \"docker\": {\n info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);\n break;\n }\n default:\n this.logger.debug(\" rendering 'local' source...\");\n info.local = this.renderLocalPackage(epName, ep, fullDirHash);\n }\n\n result.set(originEpName, info);\n continue;\n }\n\n const type = pkg.type;\n switch (type) {\n case \"R\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"environment\":\n info.runEnv = this.renderRunEnvInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"asset\":\n info.asset = this.renderAssetInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"binary\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"docker\":\n info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);\n break;\n case \"java\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"python\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"conda\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n default:\n util.assertNever(type);\n throw new Error(\n `renderer logic error: renderSoftwareEntrypoints does not cover all package types`,\n );\n }\n\n result.set(originEpName, info);\n }\n\n if (result.size === 0 && !hasReferences) {\n this.logger.error(\"no entrypoint descriptors were rendered\");\n throw util.CLIError(\"no entrypoint descriptors were rendered\");\n }\n\n return result;\n }\n\n public writeSwJson(info: swJson.swJsonType, dstFile?: string) {\n const epType = info.asset ? \"asset\" : \"software\";\n const dstSwInfoPath =\n dstFile ?? descriptorFilePath(this.pkgInfo.packageRoot, epType, info.id.name);\n\n this.logger.info(`Writing entrypoint descriptor to '${dstSwInfoPath}'`);\n\n const { id, ...toEncode } = info; // cut entrypoint ID from the final .sw.json\n const encoded = JSON.stringify({\n name: util.artifactIDToString(id),\n ...toEncode,\n });\n\n util.ensureDirsExist(path.dirname(dstSwInfoPath));\n fs.writeFileSync(dstSwInfoPath, encoded + \"\\n\");\n }\n\n public copySwJson(epName: string, srcFile: string) {\n let epType: Extract<entrypoint.EntrypointType, \"software\" | \"asset\">;\n if (srcFile.endsWith(compiledSoftwareSuffix)) {\n epType = \"software\";\n } else if (srcFile.endsWith(compiledAssetSuffix)) {\n epType = \"asset\";\n } else {\n throw util.CLIError(\n `unknown entrypoint '${epName}' type: cannot get type from extension of source file ${srcFile}`,\n );\n }\n\n const dstSwInfoPath = descriptorFilePath(this.pkgInfo.packageRoot, epType, epName);\n util.ensureDirsExist(path.dirname(dstSwInfoPath));\n fs.copyFileSync(srcFile, dstSwInfoPath);\n }\n\n private renderLocalPackage(\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n fullDirHash: boolean,\n ): swJson.localSoftwareType {\n const artifact = ep.artifact;\n const rootDir = this.pkgInfo.artifactContentRoot(artifact, util.currentPlatform());\n const hash = fullDirHash ? util.hashDirSync(rootDir) : util.hashDirMetaSync(rootDir);\n const localPath = rootDir;\n\n const epType = ep.type;\n switch (epType) {\n case \"environment\":\n throw util.CLIError(\n `entrypoint ${epName} points to 'environment' artifact, which does not support local build yet`,\n );\n\n case \"asset\":\n throw util.CLIError(\n `entrypoint ${epName} points to 'asset' artifact, which does not support local build yet`,\n );\n\n case \"software\": {\n const pkgType = artifact.type;\n switch (pkgType) {\n case \"environment\": {\n throw util.CLIError(\n `entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"asset\": {\n throw util.CLIError(\n `entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"binary\": {\n // Regular binary with no run environment dependency\n return {\n type: \"binary\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n };\n }\n case \"java\": {\n return {\n type: \"java\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n };\n }\n case \"python\": {\n const { toolset, ...deps } = artifact.dependencies ?? {};\n\n return {\n type: \"python\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n toolset: toolset ?? defaults.PYTHON_TOOLSET,\n dependencies: deps,\n };\n }\n case \"R\": {\n return {\n type: \"R\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n toolset: \"renv\",\n dependencies: {},\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n };\n }\n case \"docker\": {\n throw new Error(\n `internal build script logic error: attempt to build docker entrypoint as local binary package`,\n );\n }\n case \"conda\": {\n return {\n type: \"conda\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n\n [\"micromamba-version\"]: artifact[\"micromamba-version\"],\n [\"conda-root-dir\"]: artifact[\"conda-root-dir\"],\n spec: artifact.spec,\n };\n }\n default:\n util.assertNever(pkgType);\n throw new Error(\n \"renderer logic error: renderLocalInfo does not cover all artifact types\",\n );\n }\n }\n\n default:\n util.assertNever(epType);\n throw new Error(\n \"renderer logic error: renderLocalInfo does not cover all environment types\",\n );\n }\n }\n\n private renderBinaryInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.remoteSoftwareType | undefined {\n switch (mode) {\n case \"release\":\n break;\n\n case \"dev-local\":\n throw new Error(`'*.sw.json' generator logic error`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"software\", `internal build script logic error`);\n\n const binPkg = ep.artifact;\n\n // TODO: we need to collect artifact info for all platforms\n const artInfoPath = this.pkgInfo.artifactInfoLocation(\n binPkg.id,\n \"archive\",\n artifacts.isCrossPlatform(binPkg.type) ? undefined : util.currentPlatform(),\n );\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n if (!artInfo.registryName) {\n throw util.CLIError(\n `could not render binary entrypoint '${epName}': registry name is not set in artifact info file ${artInfoPath}`,\n );\n }\n\n const pkgType = binPkg.type;\n switch (pkgType) {\n case \"docker\": {\n throw new Error(\n `internal build script logic error: entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"conda\": {\n return {\n type: \"conda\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n\n [\"micromamba-version\"]: binPkg[\"micromamba-version\"],\n [\"conda-root-dir\"]: binPkg[\"conda-root-dir\"],\n\n spec: defaults.CONDA_FROZEN_ENV_SPEC_FILE,\n };\n }\n case \"binary\": {\n return {\n type: \"binary\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n };\n }\n case \"java\": {\n return {\n type: \"java\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n };\n }\n case \"python\": {\n const { toolset, ...deps } = binPkg.dependencies ?? {};\n\n return {\n type: \"python\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n toolset: toolset ?? \"pip\",\n dependencies: deps,\n };\n }\n case \"R\": {\n return {\n type: \"R\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n toolset: \"renv\",\n dependencies: {},\n };\n }\n default: {\n util.assertNever(pkgType);\n throw new Error(\n \"internal build script logic error: renderBinaryInfo does not cover all package types\",\n );\n }\n }\n }\n\n private renderRunEnvInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.runEnvInfo | undefined {\n switch (mode) {\n case \"release\":\n break;\n\n case \"dev-local\":\n throw util.CLIError(`run environments do not support 'local' dev build mode yet`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"environment\", `internal build script logic error`);\n const envArtifact = requireArtifactType(\n ep.artifact,\n \"environment\",\n `could not render 'environment' entrypoint`,\n );\n\n // TODO: we need to collect artifact info for all platforms\n const artInfoPath = this.pkgInfo.artifactInfoLocation(\n envArtifact.id,\n \"archive\",\n util.currentPlatform(),\n );\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n return {\n type: envArtifact.runtime,\n\n [\"r-version\"]: envArtifact[\"r-version\"],\n [\"python-version\"]: envArtifact[\"python-version\"],\n [\"java-version\"]: envArtifact[\"java-version\"],\n\n envVars: envArtifact.envVars ?? [],\n registry: artInfo.registryName!,\n package: artInfo.remoteArtifactLocation,\n binDir: envArtifact.binDir,\n };\n }\n\n private renderAssetInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.assetInfo | undefined {\n switch (mode) {\n case \"release\":\n break;\n\n case \"dev-local\":\n throw util.CLIError(`assets do not support 'local' dev build mode yet`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"asset\", `internal build script logic error`);\n const assetPkg = requireArtifactType(\n ep.artifact,\n \"asset\",\n `could not render 'asset' entrypoint`,\n );\n\n if (assetPkg.type !== \"asset\") {\n throw util.CLIError(`could not render asset entrypoint '${epName}': not 'asset' artifact`);\n }\n\n const artInfoPath = this.pkgInfo.artifactInfoLocation(assetPkg.id, \"archive\", undefined);\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n if (!artInfo.registryURL) {\n throw util.CLIError(\n `could not render asset entrypoint '${epName}': base download URL is not configured for asset's registry`,\n );\n }\n\n return {\n registry: artInfo.registryName!,\n package: artInfo.remoteArtifactLocation,\n url: util.urlJoin(artInfo.registryURL, artInfo.remoteArtifactLocation),\n };\n }\n\n private renderDockerInfo(\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.dockerInfo | undefined {\n ep = requireEntrypointType(ep, \"software\", `internal build script logic error`);\n const dockerArtifact = requireArtifactType(\n ep.artifact,\n \"docker\",\n `could not render 'docker' entrypoint`,\n );\n\n // Matches the \"x64\" write in core.buildDockerImage — docker artifacts are\n // always cross-compiled to linux/amd64 so we look up the x64 descriptor\n // regardless of host.\n const artInfoPath = this.pkgInfo.artifactInfoLocation(dockerArtifact.id, \"docker\", \"x64\");\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n return {\n tag: artInfo.remoteArtifactLocation,\n entrypoint: artInfo.entrypoint ?? [],\n cmd: ep.cmd,\n pkg: dockerArtifact.pkg || \"/\",\n };\n }\n}\n\nexport const compiledSoftwareSuffix = \".sw.json\";\nexport const compiledAssetSuffix = \".as.json\";\n\nexport type builtArtifactInfo = {\n type: artifacts.artifactType;\n platform: util.PlatformType;\n registryURL?: string; // registry public URL (for assets)\n registryName?: string; // name of registry (for binary and asset archives)\n remoteArtifactLocation: string; // path to put into sw.json or as.json file\n uploadPath?: string; // custom upload path if it does not match pathForSwJson\n\n // docker-specific fields\n entrypoint?: string[]; // entrypoint of resulting docker image. Can be overriden by setting in package.json\n\n // conda-specific fields\n spec?: string; // path to spec.yaml file within conda package\n [\"micromamba-version\"]?: string; // version of micromamba used in this conda package\n};\n\nexport function writeBuiltArtifactInfo(location: string, locInfo: builtArtifactInfo) {\n fs.mkdirSync(path.dirname(location), { recursive: true });\n fs.writeFileSync(location, JSON.stringify(locInfo), { encoding: \"utf8\" });\n}\n\nexport function readBuiltArtifactInfo(location: string): builtArtifactInfo {\n const data = fs.readFileSync(location, \"utf8\");\n return JSON.parse(data) as builtArtifactInfo;\n}\n\nfunction readArtifactInfoIfExists(\n location: string,\n epName: string,\n requireExisting?: boolean,\n): builtArtifactInfo | undefined {\n if (fs.existsSync(location)) {\n return readBuiltArtifactInfo(location);\n }\n\n if (requireExisting) {\n throw util.CLIError(\n `could not render docker entrypoint '${epName}': artifact info file '${location}' does not exist`,\n );\n }\n\n return undefined;\n}\n\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"asset\",\n errMsg: string,\n): entrypoint.AssetEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"software\",\n errMsg: string,\n): entrypoint.SoftwareEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"environment\",\n errMsg: string,\n): entrypoint.EnvironmentEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: entrypoint.EntrypointType,\n errMsg: string,\n): entrypoint.PackageEntrypoint {\n if (ep.type === type) {\n return ep;\n }\n\n throw new Error(`${errMsg}: entrypoint ${ep.name} (${ep.type}) is not '${type}'`);\n}\n\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"asset\",\n errMsg: string,\n): artifacts.withId<artifacts.assetType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"environment\",\n errMsg: string,\n): artifacts.withId<artifacts.environmentType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"java\",\n errMsg: string,\n): artifacts.withId<artifacts.javaType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"python\",\n errMsg: string,\n): artifacts.withId<artifacts.pythonType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"R\",\n errMsg: string,\n): artifacts.withId<artifacts.rType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"binary\",\n errMsg: string,\n): artifacts.withId<artifacts.binaryType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"docker\",\n errMsg: string,\n): artifacts.withId<artifacts.dockerType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"conda\",\n errMsg: string,\n): artifacts.withId<artifacts.condaType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: artifacts.artifactType,\n errMsg: string,\n): artifacts.withId<artifacts.anyArtifactType> {\n if (pkg.type === type) {\n return pkg;\n }\n\n if (errMsg) {\n errMsg = `${errMsg}: `;\n }\n\n throw util.CLIError(`${errMsg}artifact '${pkg.id}' ('${pkg.type}') is not '${type}'`);\n}\n"],"mappings":";;;;;;;;;;;AAaA,IAAa,iBAAb,MAA4B;CAC1B,YACE,QACA,SACA;AAFQ,OAAA,SAAA;AACS,OAAA,UAAA;;CAGnB,0BACE,MACA,aACA,SAIgC;EAChC,MAAM,yBAAS,IAAI,KAAgC;EACnD,IAAI,gBAAgB;EAEpB,MAAM,cAAc,SAAS,eAAe;AAE5C,OAAK,OAAO,KAAK,sCAAsC;AACvD,OAAK,OAAO,MAAM,oBAAoB,KAAK,UAAU,YAAY,CAAC;AAElE,OAAK,MAAM,CAAC,QAAQ,OAAO,YAAY,SAAS,EAAE;AAChD,OAAI,GAAG,SAAS,aAAa;AAE3B,oBAAgB;AAChB;;AAGF,QAAK,OAAO,MAAM,o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