@platforma-sdk/package-builder-lib 1.2.1 → 1.4.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/dist/core/core.cjs +35 -0
- package/dist/core/core.cjs.map +1 -1
- package/dist/core/core.d.ts +32 -6
- package/dist/core/core.d.ts.map +1 -1
- package/dist/core/core.js +35 -0
- package/dist/core/core.js.map +1 -1
- package/dist/core/docker-coverage.cjs +56 -0
- package/dist/core/docker-coverage.cjs.map +1 -0
- package/dist/core/docker-coverage.d.ts +35 -0
- package/dist/core/docker-coverage.d.ts.map +1 -0
- package/dist/core/docker-coverage.js +53 -0
- package/dist/core/docker-coverage.js.map +1 -0
- package/dist/core/envs.d.ts +27 -27
- package/dist/core/envs.d.ts.map +1 -1
- package/dist/core/package-info.cjs +6 -1
- package/dist/core/package-info.cjs.map +1 -1
- package/dist/core/package-info.d.ts +6 -6
- package/dist/core/package-info.d.ts.map +1 -1
- package/dist/core/package-info.js +6 -1
- package/dist/core/package-info.js.map +1 -1
- package/dist/core/push-guard.cjs +17 -0
- package/dist/core/push-guard.cjs.map +1 -0
- package/dist/core/push-guard.d.ts +15 -0
- package/dist/core/push-guard.d.ts.map +1 -0
- package/dist/core/push-guard.js +17 -0
- package/dist/core/push-guard.js.map +1 -0
- package/dist/core/schemas/artifacts.d.ts +236 -71
- package/dist/core/schemas/artifacts.d.ts.map +1 -1
- package/dist/core/schemas/entrypoints.d.ts +357 -10
- package/dist/core/schemas/entrypoints.d.ts.map +1 -1
- package/dist/core/sw-json-render.cjs +18 -0
- package/dist/core/sw-json-render.cjs.map +1 -1
- package/dist/core/sw-json-render.js +18 -0
- package/dist/core/sw-json-render.js.map +1 -1
- package/dist/core/util.d.ts +42 -44
- package/dist/core/util.d.ts.map +1 -1
- package/dist/defaults.d.ts +22 -22
- package/dist/defaults.d.ts.map +1 -1
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/core/__tests__/docker-coverage.test.ts +319 -0
- package/src/core/__tests__/publish-docker-images.test.ts +63 -0
- package/src/core/__tests__/push-guard.test.ts +62 -0
- package/src/core/core.ts +51 -0
- package/src/core/docker-coverage.ts +112 -0
- package/src/core/package-info.ts +11 -0
- package/src/core/push-guard.ts +42 -0
- package/src/core/sw-json-render.ts +25 -0
- package/src/index.ts +9 -0
|
@@ -1,32 +1,379 @@
|
|
|
1
|
-
import { assetType, binaryType, condaType, dockerType, environmentType, javaType, pythonType, rType, withId } from "./artifacts.js";
|
|
1
|
+
import { artifacts_d_exports, assetType, binaryType, condaType, dockerType, environmentType, javaType, pythonType, rType, withId } from "./artifacts.js";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
declare namespace entrypoints_d_exports {
|
|
4
|
+
export { AssetEntrypoint, Entrypoint, EntrypointType, EnvironmentEntrypoint, EnyrypointReferencePattern, PackageEntrypoint, ReferenceEntrypoint, SoftwareEntrypoint, entrypointListSchema, entrypointListType, entrypointSchema, entrypointType, environmentOptionsSchema, referenceSchema, softwareOptionsSchema, softwareOptionsType };
|
|
5
|
+
}
|
|
6
|
+
export declare const EnyrypointReferencePattern: RegExp;
|
|
7
|
+
export declare const referenceSchema: z.ZodString;
|
|
8
|
+
export declare const softwareOptionsSchema: z.ZodObject<{
|
|
9
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
10
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export type softwareOptionsType = z.infer<typeof softwareOptionsSchema>;
|
|
13
|
+
export declare const environmentOptionsSchema: z.ZodObject<{
|
|
14
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
15
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
18
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strict>]>>;
|
|
20
|
+
name: z.ZodOptional<z.ZodString>;
|
|
21
|
+
version: z.ZodOptional<z.ZodString>;
|
|
22
|
+
roots: z.ZodRecord<z.ZodEnum<{
|
|
23
|
+
"linux-aarch64": "linux-aarch64";
|
|
24
|
+
"linux-x64": "linux-x64";
|
|
25
|
+
"macosx-aarch64": "macosx-aarch64";
|
|
26
|
+
"macosx-x64": "macosx-x64";
|
|
27
|
+
"windows-aarch64": "windows-aarch64";
|
|
28
|
+
"windows-x64": "windows-x64";
|
|
29
|
+
}> & z.core.$partial, z.ZodString>;
|
|
30
|
+
runtime: z.ZodEnum<{
|
|
31
|
+
R: "R";
|
|
32
|
+
java: "java";
|
|
33
|
+
python: "python";
|
|
34
|
+
}>;
|
|
35
|
+
"r-version": z.ZodOptional<z.ZodString>;
|
|
36
|
+
"python-version": z.ZodOptional<z.ZodString>;
|
|
37
|
+
"java-version": z.ZodOptional<z.ZodString>;
|
|
38
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
39
|
+
binDir: z.ZodString;
|
|
40
|
+
}, z.core.$strip>]>;
|
|
41
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
export declare const entrypointSchema: z.ZodObject<{
|
|
44
|
+
reference: z.ZodOptional<z.ZodString>;
|
|
45
|
+
asset: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
46
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
47
|
+
name: z.ZodString;
|
|
48
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
49
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.core.$strict>]>>;
|
|
51
|
+
name: z.ZodOptional<z.ZodString>;
|
|
52
|
+
version: z.ZodOptional<z.ZodString>;
|
|
53
|
+
root: z.ZodString;
|
|
54
|
+
}, z.core.$strict>]>>;
|
|
55
|
+
environment: z.ZodOptional<z.ZodObject<{
|
|
56
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
57
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
60
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strict>]>>;
|
|
62
|
+
name: z.ZodOptional<z.ZodString>;
|
|
63
|
+
version: z.ZodOptional<z.ZodString>;
|
|
64
|
+
roots: z.ZodRecord<z.ZodEnum<{
|
|
65
|
+
"linux-aarch64": "linux-aarch64";
|
|
66
|
+
"linux-x64": "linux-x64";
|
|
67
|
+
"macosx-aarch64": "macosx-aarch64";
|
|
68
|
+
"macosx-x64": "macosx-x64";
|
|
69
|
+
"windows-aarch64": "windows-aarch64";
|
|
70
|
+
"windows-x64": "windows-x64";
|
|
71
|
+
}> & z.core.$partial, z.ZodString>;
|
|
72
|
+
runtime: z.ZodEnum<{
|
|
73
|
+
R: "R";
|
|
74
|
+
java: "java";
|
|
75
|
+
python: "python";
|
|
76
|
+
}>;
|
|
77
|
+
"r-version": z.ZodOptional<z.ZodString>;
|
|
78
|
+
"python-version": z.ZodOptional<z.ZodString>;
|
|
79
|
+
"java-version": z.ZodOptional<z.ZodString>;
|
|
80
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
81
|
+
binDir: z.ZodString;
|
|
82
|
+
}, z.core.$strip>]>;
|
|
83
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
84
|
+
}, z.core.$strict>>;
|
|
85
|
+
binary: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
86
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
87
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
88
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
89
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
90
|
+
name: z.ZodString;
|
|
91
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
92
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
93
|
+
}, z.core.$strict>]>>;
|
|
94
|
+
name: z.ZodOptional<z.ZodString>;
|
|
95
|
+
version: z.ZodOptional<z.ZodString>;
|
|
96
|
+
roots: z.ZodRecord<z.ZodEnum<{
|
|
97
|
+
"linux-aarch64": "linux-aarch64";
|
|
98
|
+
"linux-x64": "linux-x64";
|
|
99
|
+
"macosx-aarch64": "macosx-aarch64";
|
|
100
|
+
"macosx-x64": "macosx-x64";
|
|
101
|
+
"windows-aarch64": "windows-aarch64";
|
|
102
|
+
"windows-x64": "windows-x64";
|
|
103
|
+
}> & z.core.$partial, z.ZodString>;
|
|
104
|
+
type: z.ZodLiteral<"binary">;
|
|
105
|
+
}, z.core.$strip>]>;
|
|
106
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
107
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
108
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
109
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
110
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
111
|
+
name: z.ZodString;
|
|
112
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
113
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
114
|
+
}, z.core.$strict>]>>;
|
|
115
|
+
name: z.ZodOptional<z.ZodString>;
|
|
116
|
+
version: z.ZodOptional<z.ZodString>;
|
|
117
|
+
root: z.ZodString;
|
|
118
|
+
type: z.ZodLiteral<"java">;
|
|
119
|
+
environment: z.ZodString;
|
|
120
|
+
}, z.core.$strip>]>;
|
|
121
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
122
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
123
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
124
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
125
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
126
|
+
name: z.ZodString;
|
|
127
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
128
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strict>]>>;
|
|
130
|
+
name: z.ZodOptional<z.ZodString>;
|
|
131
|
+
version: z.ZodOptional<z.ZodString>;
|
|
132
|
+
root: z.ZodString;
|
|
133
|
+
"docker-registry": z.ZodDefault<z.ZodString>;
|
|
134
|
+
pkg: z.ZodDefault<z.ZodString>;
|
|
135
|
+
type: z.ZodLiteral<"python">;
|
|
136
|
+
environment: z.ZodString;
|
|
137
|
+
dependencies: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
138
|
+
toolset: z.ZodLiteral<"pip">;
|
|
139
|
+
requirements: z.ZodString;
|
|
140
|
+
}, z.core.$strict>]>>;
|
|
141
|
+
}, z.core.$strip>]>;
|
|
142
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
143
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
144
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
145
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
146
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
147
|
+
name: z.ZodString;
|
|
148
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
149
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
150
|
+
}, z.core.$strict>]>>;
|
|
151
|
+
name: z.ZodOptional<z.ZodString>;
|
|
152
|
+
version: z.ZodOptional<z.ZodString>;
|
|
153
|
+
root: z.ZodString;
|
|
154
|
+
type: z.ZodLiteral<"R">;
|
|
155
|
+
environment: z.ZodString;
|
|
156
|
+
}, z.core.$strip>]>;
|
|
157
|
+
}, z.core.$strict>]>>;
|
|
158
|
+
conda: z.ZodOptional<z.ZodObject<{
|
|
159
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
160
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
161
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
162
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
163
|
+
name: z.ZodString;
|
|
164
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
165
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
166
|
+
}, z.core.$strict>]>>;
|
|
167
|
+
name: z.ZodOptional<z.ZodString>;
|
|
168
|
+
version: z.ZodOptional<z.ZodString>;
|
|
169
|
+
roots: z.ZodRecord<z.ZodEnum<{
|
|
170
|
+
"linux-aarch64": "linux-aarch64";
|
|
171
|
+
"linux-x64": "linux-x64";
|
|
172
|
+
"macosx-aarch64": "macosx-aarch64";
|
|
173
|
+
"macosx-x64": "macosx-x64";
|
|
174
|
+
"windows-aarch64": "windows-aarch64";
|
|
175
|
+
"windows-x64": "windows-x64";
|
|
176
|
+
}> & z.core.$partial, z.ZodString>;
|
|
177
|
+
"docker-registry": z.ZodDefault<z.ZodString>;
|
|
178
|
+
pkg: z.ZodDefault<z.ZodString>;
|
|
179
|
+
"micromamba-version": z.ZodDefault<z.ZodString>;
|
|
180
|
+
"conda-root-dir": z.ZodDefault<z.ZodString>;
|
|
181
|
+
spec: z.ZodDefault<z.ZodString>;
|
|
182
|
+
}, z.core.$strip>]>;
|
|
183
|
+
}, z.core.$strict>>;
|
|
184
|
+
docker: z.ZodOptional<z.ZodObject<{
|
|
185
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
186
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
187
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
188
|
+
registry: z.ZodDefault<z.ZodString>;
|
|
189
|
+
context: z.ZodString;
|
|
190
|
+
dockerfile: z.ZodDefault<z.ZodString>;
|
|
191
|
+
pkg: z.ZodDefault<z.ZodString>;
|
|
192
|
+
}, z.core.$strip>]>;
|
|
193
|
+
}, z.core.$strict>>;
|
|
194
|
+
}, z.core.$strict>;
|
|
195
|
+
export type entrypointType = z.infer<typeof entrypointSchema>;
|
|
196
|
+
export declare const entrypointListSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
197
|
+
reference: z.ZodOptional<z.ZodString>;
|
|
198
|
+
asset: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
199
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
200
|
+
name: z.ZodString;
|
|
201
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
202
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
203
|
+
}, z.core.$strict>]>>;
|
|
204
|
+
name: z.ZodOptional<z.ZodString>;
|
|
205
|
+
version: z.ZodOptional<z.ZodString>;
|
|
206
|
+
root: z.ZodString;
|
|
207
|
+
}, z.core.$strict>]>>;
|
|
208
|
+
environment: z.ZodOptional<z.ZodObject<{
|
|
209
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
210
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
211
|
+
name: z.ZodString;
|
|
212
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
213
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
214
|
+
}, z.core.$strict>]>>;
|
|
215
|
+
name: z.ZodOptional<z.ZodString>;
|
|
216
|
+
version: z.ZodOptional<z.ZodString>;
|
|
217
|
+
roots: z.ZodRecord<z.ZodEnum<{
|
|
218
|
+
"linux-aarch64": "linux-aarch64";
|
|
219
|
+
"linux-x64": "linux-x64";
|
|
220
|
+
"macosx-aarch64": "macosx-aarch64";
|
|
221
|
+
"macosx-x64": "macosx-x64";
|
|
222
|
+
"windows-aarch64": "windows-aarch64";
|
|
223
|
+
"windows-x64": "windows-x64";
|
|
224
|
+
}> & z.core.$partial, z.ZodString>;
|
|
225
|
+
runtime: z.ZodEnum<{
|
|
226
|
+
R: "R";
|
|
227
|
+
java: "java";
|
|
228
|
+
python: "python";
|
|
229
|
+
}>;
|
|
230
|
+
"r-version": z.ZodOptional<z.ZodString>;
|
|
231
|
+
"python-version": z.ZodOptional<z.ZodString>;
|
|
232
|
+
"java-version": z.ZodOptional<z.ZodString>;
|
|
233
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
234
|
+
binDir: z.ZodString;
|
|
235
|
+
}, z.core.$strip>]>;
|
|
236
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
237
|
+
}, z.core.$strict>>;
|
|
238
|
+
binary: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
239
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
240
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
241
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
242
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
243
|
+
name: z.ZodString;
|
|
244
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
245
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
246
|
+
}, z.core.$strict>]>>;
|
|
247
|
+
name: z.ZodOptional<z.ZodString>;
|
|
248
|
+
version: z.ZodOptional<z.ZodString>;
|
|
249
|
+
roots: z.ZodRecord<z.ZodEnum<{
|
|
250
|
+
"linux-aarch64": "linux-aarch64";
|
|
251
|
+
"linux-x64": "linux-x64";
|
|
252
|
+
"macosx-aarch64": "macosx-aarch64";
|
|
253
|
+
"macosx-x64": "macosx-x64";
|
|
254
|
+
"windows-aarch64": "windows-aarch64";
|
|
255
|
+
"windows-x64": "windows-x64";
|
|
256
|
+
}> & z.core.$partial, z.ZodString>;
|
|
257
|
+
type: z.ZodLiteral<"binary">;
|
|
258
|
+
}, z.core.$strip>]>;
|
|
259
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
260
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
261
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
262
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
263
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
264
|
+
name: z.ZodString;
|
|
265
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
266
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
267
|
+
}, z.core.$strict>]>>;
|
|
268
|
+
name: z.ZodOptional<z.ZodString>;
|
|
269
|
+
version: z.ZodOptional<z.ZodString>;
|
|
270
|
+
root: z.ZodString;
|
|
271
|
+
type: z.ZodLiteral<"java">;
|
|
272
|
+
environment: z.ZodString;
|
|
273
|
+
}, z.core.$strip>]>;
|
|
274
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
275
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
276
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
277
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
278
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
279
|
+
name: z.ZodString;
|
|
280
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
281
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
282
|
+
}, z.core.$strict>]>>;
|
|
283
|
+
name: z.ZodOptional<z.ZodString>;
|
|
284
|
+
version: z.ZodOptional<z.ZodString>;
|
|
285
|
+
root: z.ZodString;
|
|
286
|
+
"docker-registry": z.ZodDefault<z.ZodString>;
|
|
287
|
+
pkg: z.ZodDefault<z.ZodString>;
|
|
288
|
+
type: z.ZodLiteral<"python">;
|
|
289
|
+
environment: z.ZodString;
|
|
290
|
+
dependencies: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
291
|
+
toolset: z.ZodLiteral<"pip">;
|
|
292
|
+
requirements: z.ZodString;
|
|
293
|
+
}, z.core.$strict>]>>;
|
|
294
|
+
}, z.core.$strip>]>;
|
|
295
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
296
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
297
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
298
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
299
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
300
|
+
name: z.ZodString;
|
|
301
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
302
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
303
|
+
}, z.core.$strict>]>>;
|
|
304
|
+
name: z.ZodOptional<z.ZodString>;
|
|
305
|
+
version: z.ZodOptional<z.ZodString>;
|
|
306
|
+
root: z.ZodString;
|
|
307
|
+
type: z.ZodLiteral<"R">;
|
|
308
|
+
environment: z.ZodString;
|
|
309
|
+
}, z.core.$strip>]>;
|
|
310
|
+
}, z.core.$strict>]>>;
|
|
311
|
+
conda: z.ZodOptional<z.ZodObject<{
|
|
312
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
313
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
314
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
315
|
+
registry: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
316
|
+
name: z.ZodString;
|
|
317
|
+
downloadURL: z.ZodOptional<z.ZodString>;
|
|
318
|
+
storageURL: z.ZodOptional<z.ZodString>;
|
|
319
|
+
}, z.core.$strict>]>>;
|
|
320
|
+
name: z.ZodOptional<z.ZodString>;
|
|
321
|
+
version: z.ZodOptional<z.ZodString>;
|
|
322
|
+
roots: z.ZodRecord<z.ZodEnum<{
|
|
323
|
+
"linux-aarch64": "linux-aarch64";
|
|
324
|
+
"linux-x64": "linux-x64";
|
|
325
|
+
"macosx-aarch64": "macosx-aarch64";
|
|
326
|
+
"macosx-x64": "macosx-x64";
|
|
327
|
+
"windows-aarch64": "windows-aarch64";
|
|
328
|
+
"windows-x64": "windows-x64";
|
|
329
|
+
}> & z.core.$partial, z.ZodString>;
|
|
330
|
+
"docker-registry": z.ZodDefault<z.ZodString>;
|
|
331
|
+
pkg: z.ZodDefault<z.ZodString>;
|
|
332
|
+
"micromamba-version": z.ZodDefault<z.ZodString>;
|
|
333
|
+
"conda-root-dir": z.ZodDefault<z.ZodString>;
|
|
334
|
+
spec: z.ZodDefault<z.ZodString>;
|
|
335
|
+
}, z.core.$strip>]>;
|
|
336
|
+
}, z.core.$strict>>;
|
|
337
|
+
docker: z.ZodOptional<z.ZodObject<{
|
|
338
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
339
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
340
|
+
artifact: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
341
|
+
registry: z.ZodDefault<z.ZodString>;
|
|
342
|
+
context: z.ZodString;
|
|
343
|
+
dockerfile: z.ZodDefault<z.ZodString>;
|
|
344
|
+
pkg: z.ZodDefault<z.ZodString>;
|
|
345
|
+
}, z.core.$strip>]>;
|
|
346
|
+
}, z.core.$strict>>;
|
|
347
|
+
}, z.core.$strict>>;
|
|
348
|
+
export type entrypointListType = z.infer<typeof entrypointListSchema>;
|
|
349
|
+
export interface ReferenceEntrypoint {
|
|
6
350
|
type: "reference";
|
|
7
351
|
name: string;
|
|
8
352
|
reference: string;
|
|
9
353
|
}
|
|
10
|
-
interface AssetEntrypoint {
|
|
354
|
+
export interface AssetEntrypoint {
|
|
11
355
|
type: "asset";
|
|
12
356
|
name: string;
|
|
13
357
|
artifact: withId<assetType>;
|
|
14
358
|
}
|
|
15
|
-
interface SoftwareEntrypoint {
|
|
359
|
+
export interface SoftwareEntrypoint {
|
|
16
360
|
type: "software";
|
|
17
361
|
name: string;
|
|
18
362
|
artifact: withId<binaryType | condaType | javaType | pythonType | rType | dockerType>;
|
|
19
363
|
cmd: string[];
|
|
20
364
|
env: string[];
|
|
21
365
|
}
|
|
22
|
-
interface EnvironmentEntrypoint {
|
|
366
|
+
export interface EnvironmentEntrypoint {
|
|
23
367
|
type: "environment";
|
|
24
368
|
name: string;
|
|
25
369
|
artifact: withId<environmentType>;
|
|
26
370
|
env: string[];
|
|
27
371
|
}
|
|
28
|
-
type PackageEntrypoint = AssetEntrypoint | SoftwareEntrypoint | EnvironmentEntrypoint;
|
|
29
|
-
type Entrypoint = ReferenceEntrypoint | PackageEntrypoint;
|
|
372
|
+
export type PackageEntrypoint = AssetEntrypoint | SoftwareEntrypoint | EnvironmentEntrypoint;
|
|
373
|
+
export type Entrypoint = ReferenceEntrypoint | PackageEntrypoint;
|
|
374
|
+
export type EntrypointType = Extract<Entrypoint, {
|
|
375
|
+
type: string;
|
|
376
|
+
}>["type"];
|
|
30
377
|
//#endregion
|
|
31
|
-
export {
|
|
378
|
+
export { entrypoints_d_exports };
|
|
32
379
|
//# sourceMappingURL=entrypoints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoints.d.ts","names":[],"sources":["../../../src/core/schemas/entrypoints.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"entrypoints.d.ts","names":[],"sources":["../../../src/core/schemas/entrypoints.ts"],"mappings":";;;;;qBAaa,4BAA0B;qBAG1B,iBAAe,EAAA;qBAgBf,uBAAqB,EAAA;;;;YAYtB,sBAAsB,EAAE,aAAa;qBAEpC,0BAAwB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAUxB,kBAAgB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA2CjB,iBAAiB,EAAE,aAAa;qBAG/B,sBAAoB,EAAA,UAAA,EAAA,WAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YASrB,qBAAqB,EAAE,aAAa;iBAE/B;EACf;EACA;EACA;;iBAGe;EACf;EACA;EACA,UAAU,OAAiB;;iBAGZ;EACf;EACA;EACA,UAAU,OACN,aACA,YACA,WACA,aACA,QACA;EAEJ;EACA;;iBAGe;EACf;EACA;EACA,UAAU,OAAiB;EAC3B;;YAGU,oBAAoB,kBAAkB,qBAAqB;YAC3D,aAAa,sBAAsB;YACnC,iBAAiB,QAAQ;EAAc"}
|
|
@@ -4,6 +4,7 @@ const require_util = require("./util.cjs");
|
|
|
4
4
|
const require_artifacts = require("./schemas/artifacts.cjs");
|
|
5
5
|
const require_docker = require("./docker.cjs");
|
|
6
6
|
const require_resolver = require("./resolver.cjs");
|
|
7
|
+
const require_docker_coverage = require("./docker-coverage.cjs");
|
|
7
8
|
let node_fs = require("node:fs");
|
|
8
9
|
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
9
10
|
let node_path = require("node:path");
|
|
@@ -128,6 +129,23 @@ var SwJsonRenderer = class {
|
|
|
128
129
|
const dstSwInfoPath = require_resolver.descriptorFilePath(this.pkgInfo.packageRoot, epType, epName);
|
|
129
130
|
require_util.ensureDirsExist(node_path.default.dirname(dstSwInfoPath));
|
|
130
131
|
node_fs.default.copyFileSync(srcFile, dstSwInfoPath);
|
|
132
|
+
if (epType === "software") this.warnIfNoDockerVariant(epName, srcFile);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* A reference re-exports another package's descriptor verbatim, so the docker-coverage
|
|
136
|
+
* check cannot judge it from this package's declaration — and must not fail on it: the
|
|
137
|
+
* owning package may have declared itself binary-only on purpose, and that waiver does
|
|
138
|
+
* not travel inside the descriptor. Warn, naming what to fix and where.
|
|
139
|
+
*/
|
|
140
|
+
warnIfNoDockerVariant(epName, srcFile) {
|
|
141
|
+
let descriptor;
|
|
142
|
+
try {
|
|
143
|
+
descriptor = JSON.parse(node_fs.default.readFileSync(srcFile, "utf-8"));
|
|
144
|
+
} catch {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (!require_docker_coverage.descriptorHasNoDockerVariant(descriptor)) return;
|
|
148
|
+
this.logger.warn(`referenced entrypoint '${epName}' carries no docker image, so no kubernetes installation can run it. Fix it in the package that owns ${srcFile}.`);
|
|
131
149
|
}
|
|
132
150
|
renderLocalPackage(epName, ep, fullDirHash) {
|
|
133
151
|
const artifact = ep.artifact;
|
|
@@ -1 +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 (util.isDevMode(mode)) {\n info.isDev = true;\n }\n\n const pkg = ep.artifact;\n if (!util.producesRegistryDescriptor(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 // One minimal `binary` placeholder per entrypoint, so a block builds, loads, and renders without\n // any software; only executing it fails, against the sentinel registry. References are copied\n // through by the caller, so they are skipped here.\n public renderPlaceholderEntrypoints(\n entrypoints: Map<string, entrypoint.Entrypoint>,\n ): Map<string, swJson.swJsonType> {\n const result = new Map<string, swJson.swJsonType>();\n for (const [epName, ep] of entrypoints.entries()) {\n if (ep.type === \"reference\") continue;\n const originEpName = docker.entrypointNameToOrigin(epName);\n if (result.has(originEpName)) continue;\n result.set(originEpName, {\n id: { package: this.pkgInfo.packageName, name: originEpName },\n isDev: true,\n binary: {\n type: \"binary\",\n registry: defaults.NO_SOFTWARE_PLACEHOLDER,\n package: defaults.NO_SOFTWARE_PLACEHOLDER,\n cmd: [\"true\"],\n },\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 case \"dev-remote\":\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 case \"dev-remote\":\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 case \"dev-remote\":\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;CAEhB;CACS;CAFnB,YACE,QACA,SACA;EAFQ,KAAA,SAAA;EACS,KAAA,UAAA;CAChB;CAEH,0BACE,MACA,aACA,SAIgC;EAChC,MAAM,yBAAS,IAAI,IAA+B;EAClD,IAAI,gBAAgB;EAEpB,MAAM,cAAc,SAAS,eAAe;EAE5C,KAAK,OAAO,KAAK,q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AiBA,SAAS,sBACP,IACA,MACA,QAC8B;CAC9B,IAAI,GAAG,SAAS,MACd,OAAO;CAGT,MAAM,IAAI,MAAM,GAAG,OAAO,eAAe,GAAG,KAAK,IAAI,GAAG,KAAK,YAAY,KAAK,EAAE;AAClF;AA0CA,SAAS,oBACP,KACA,MACA,QAC6C;CAC7C,IAAI,IAAI,SAAS,MACf,OAAO;CAGT,IAAI,QACF,SAAS,GAAG,OAAO;CAGrB,MAAA,aAAA,SAAoB,GAAG,OAAO,YAAY,IAAI,GAAG,MAAM,IAAI,KAAK,aAAa,KAAK,EAAE;AACtF"}
|
|
1
|
+
{"version":3,"file":"sw-json-render.cjs","names":["descriptorFilePath","path","fs","resolveRunEnvironment"],"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 dockerCoverage from \"./docker-coverage\";\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 (util.isDevMode(mode)) {\n info.isDev = true;\n }\n\n const pkg = ep.artifact;\n if (!util.producesRegistryDescriptor(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 // One minimal `binary` placeholder per entrypoint, so a block builds, loads, and renders without\n // any software; only executing it fails, against the sentinel registry. References are copied\n // through by the caller, so they are skipped here.\n public renderPlaceholderEntrypoints(\n entrypoints: Map<string, entrypoint.Entrypoint>,\n ): Map<string, swJson.swJsonType> {\n const result = new Map<string, swJson.swJsonType>();\n for (const [epName, ep] of entrypoints.entries()) {\n if (ep.type === \"reference\") continue;\n const originEpName = docker.entrypointNameToOrigin(epName);\n if (result.has(originEpName)) continue;\n result.set(originEpName, {\n id: { package: this.pkgInfo.packageName, name: originEpName },\n isDev: true,\n binary: {\n type: \"binary\",\n registry: defaults.NO_SOFTWARE_PLACEHOLDER,\n package: defaults.NO_SOFTWARE_PLACEHOLDER,\n cmd: [\"true\"],\n },\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 if (epType === \"software\") this.warnIfNoDockerVariant(epName, srcFile);\n }\n\n /**\n * A reference re-exports another package's descriptor verbatim, so the docker-coverage\n * check cannot judge it from this package's declaration — and must not fail on it: the\n * owning package may have declared itself binary-only on purpose, and that waiver does\n * not travel inside the descriptor. Warn, naming what to fix and where.\n */\n private warnIfNoDockerVariant(epName: string, srcFile: string) {\n let descriptor: unknown;\n try {\n descriptor = JSON.parse(fs.readFileSync(srcFile, \"utf-8\"));\n } catch {\n return; // an unreadable descriptor is the copy's problem to report, not this warning's\n }\n\n if (!dockerCoverage.descriptorHasNoDockerVariant(descriptor)) return;\n\n this.logger.warn(\n `referenced entrypoint '${epName}' carries no docker image, so no kubernetes ` +\n `installation can run it. Fix it in the package that owns ${srcFile}.`,\n );\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 case \"dev-remote\":\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 case \"dev-remote\":\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 case \"dev-remote\":\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":";;;;;;;;;;;;AAcA,IAAa,iBAAb,MAA4B;CAEhB;CACS;CAFnB,YACE,QACA,SACA;EAFQ,KAAA,SAAA;EACS,KAAA,UAAA;CAChB;CAEH,0BACE,MACA,aACA,SAIgC;EAChC,MAAM,yBAAS,IAAI,IAA+B;EAClD,IAAI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A,QAAG,cAAc,UAAU,KAAK,UAAU,OAAO,GAAG,EAAE,UAAU,OAAO,CAAC;AAC1E;AAEA,SAAgB,sBAAsB,UAAqC;CACzE,MAAM,OAAOC,QAAAA,QAAG,aAAa,UAAU,MAAM;CAC7C,OAAO,KAAK,MAAM,IAAI;AACxB;AAEA,SAAS,yBACP,UACA,QACA,iBAC+B;CAC/B,IAAIA,QAAAA,QAAG,WAAW,QAAQ,GACxB,OAAO,sBAAsB,QAAQ;CAGvC,IAAI,iBACF,MAAA,aAAA,SACE,uCAAuC,OAAO,yBAAyB,SAAS,iBAClF;AAIJ;AAiBA,SAAS,sBACP,IACA,MACA,QAC8B;CAC9B,IAAI,GAAG,SAAS,MACd,OAAO;CAGT,MAAM,IAAI,MAAM,GAAG,OAAO,eAAe,GAAG,KAAK,IAAI,GAAG,KAAK,YAAY,KAAK,EAAE;AAClF;AA0CA,SAAS,oBACP,KACA,MACA,QAC6C;CAC7C,IAAI,IAAI,SAAS,MACf,OAAO;CAGT,IAAI,QACF,SAAS,GAAG,OAAO;CAGrB,MAAA,aAAA,SAAoB,GAAG,OAAO,YAAY,IAAI,GAAG,MAAM,IAAI,KAAK,aAAa,KAAK,EAAE;AACtF"}
|
|
@@ -3,6 +3,7 @@ import { CLIError, artifactIDToString, assertNever, currentPlatform, ensureDirsE
|
|
|
3
3
|
import { isCrossPlatform } from "./schemas/artifacts.js";
|
|
4
4
|
import { entrypointNameToOrigin } from "./docker.js";
|
|
5
5
|
import { descriptorFilePath, resolveRunEnvironment } from "./resolver.js";
|
|
6
|
+
import { descriptorHasNoDockerVariant } from "./docker-coverage.js";
|
|
6
7
|
import fs from "node:fs";
|
|
7
8
|
import path from "node:path";
|
|
8
9
|
//#region src/core/sw-json-render.ts
|
|
@@ -125,6 +126,23 @@ var SwJsonRenderer = class {
|
|
|
125
126
|
const dstSwInfoPath = descriptorFilePath(this.pkgInfo.packageRoot, epType, epName);
|
|
126
127
|
ensureDirsExist(path.dirname(dstSwInfoPath));
|
|
127
128
|
fs.copyFileSync(srcFile, dstSwInfoPath);
|
|
129
|
+
if (epType === "software") this.warnIfNoDockerVariant(epName, srcFile);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A reference re-exports another package's descriptor verbatim, so the docker-coverage
|
|
133
|
+
* check cannot judge it from this package's declaration — and must not fail on it: the
|
|
134
|
+
* owning package may have declared itself binary-only on purpose, and that waiver does
|
|
135
|
+
* not travel inside the descriptor. Warn, naming what to fix and where.
|
|
136
|
+
*/
|
|
137
|
+
warnIfNoDockerVariant(epName, srcFile) {
|
|
138
|
+
let descriptor;
|
|
139
|
+
try {
|
|
140
|
+
descriptor = JSON.parse(fs.readFileSync(srcFile, "utf-8"));
|
|
141
|
+
} catch {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (!descriptorHasNoDockerVariant(descriptor)) return;
|
|
145
|
+
this.logger.warn(`referenced entrypoint '${epName}' carries no docker image, so no kubernetes installation can run it. Fix it in the package that owns ${srcFile}.`);
|
|
128
146
|
}
|
|
129
147
|
renderLocalPackage(epName, ep, fullDirHash) {
|
|
130
148
|
const artifact = ep.artifact;
|