hammerkit 1.14.1 → 1.15.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/build.schema.json
CHANGED
|
@@ -59,6 +59,22 @@
|
|
|
59
59
|
"extend": {
|
|
60
60
|
"type": "string"
|
|
61
61
|
},
|
|
62
|
+
"reset": {
|
|
63
|
+
"type": "array",
|
|
64
|
+
"items": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"enum": [
|
|
67
|
+
"deps",
|
|
68
|
+
"needs",
|
|
69
|
+
"src",
|
|
70
|
+
"generates",
|
|
71
|
+
"cmds",
|
|
72
|
+
"mounts",
|
|
73
|
+
"envs",
|
|
74
|
+
"labels"
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
},
|
|
62
78
|
"envs": {
|
|
63
79
|
"$ref": "#/definitions/hammerkit/properties/envs",
|
|
64
80
|
"description": "Environment values for the current build task\nhttps://hammerkit.dev/docs/build-file/environment-variables"
|
|
@@ -270,6 +286,9 @@
|
|
|
270
286
|
"extend": {
|
|
271
287
|
"$ref": "#/definitions/hammerkit/properties/tasks/additionalProperties/anyOf/0/properties/extend"
|
|
272
288
|
},
|
|
289
|
+
"reset": {
|
|
290
|
+
"$ref": "#/definitions/hammerkit/properties/tasks/additionalProperties/anyOf/0/properties/reset"
|
|
291
|
+
},
|
|
273
292
|
"envs": {
|
|
274
293
|
"$ref": "#/definitions/hammerkit/properties/tasks/additionalProperties/anyOf/0/properties/envs"
|
|
275
294
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildFileBaseTaskSchema = void 0;
|
|
3
|
+
exports.buildFileBaseTaskSchema = exports.RESET_PROPERTIES = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const build_file_need_schema_1 = require("./build-file-need-schema");
|
|
6
6
|
const envs_schema_1 = require("./envs-schema");
|
|
@@ -11,11 +11,15 @@ const build_file_volume_schema_1 = require("./build-file-volume-schema");
|
|
|
11
11
|
const duration_schema_1 = require("./duration-schema");
|
|
12
12
|
const build_file_secret_schema_1 = require("./build-file-secret-schema");
|
|
13
13
|
const resources_schema_1 = require("./resources-schema");
|
|
14
|
+
// what `extend` adds to (the rest, e.g. `image` or `shell`, the task just overrides)
|
|
15
|
+
exports.RESET_PROPERTIES = ['deps', 'needs', 'src', 'generates', 'cmds', 'mounts', 'envs', 'labels'];
|
|
14
16
|
exports.buildFileBaseTaskSchema = (0, zod_1.object)({
|
|
15
17
|
deps: (0, zod_1.array)((0, zod_1.string)()).optional(),
|
|
16
18
|
needs: (0, zod_1.array)(build_file_need_schema_1.buildFileNeedSchema).optional(),
|
|
17
19
|
description: (0, zod_1.string)().optional(),
|
|
18
20
|
extend: (0, zod_1.string)().optional(),
|
|
21
|
+
// properties of the `extend` base this task does not inherit
|
|
22
|
+
reset: (0, zod_1.array)((0, zod_1.enum)(exports.RESET_PROPERTIES)).optional(),
|
|
19
23
|
envs: envs_schema_1.envsSchema.optional(),
|
|
20
24
|
labels: labels_schema_1.labelsSchema.optional(),
|
|
21
25
|
cache: cache_schema_1.cacheSchema.optional(),
|
|
@@ -103,8 +103,13 @@ function applySchemaExtension(reference, task) {
|
|
|
103
103
|
throw new Error(`task ${task.relativeName} extends itself`);
|
|
104
104
|
}
|
|
105
105
|
task.extension = 'applying';
|
|
106
|
-
task.
|
|
106
|
+
task.depBases = [];
|
|
107
|
+
task.needBases = [];
|
|
108
|
+
const reset = new Set(task.schema.reset ?? []);
|
|
107
109
|
if (!task.schema.extend) {
|
|
110
|
+
if (reset.size > 0) {
|
|
111
|
+
throw new Error(`task ${task.relativeName} sets reset without extend`);
|
|
112
|
+
}
|
|
108
113
|
task.extension = 'applied';
|
|
109
114
|
return;
|
|
110
115
|
}
|
|
@@ -113,22 +118,35 @@ function applySchemaExtension(reference, task) {
|
|
|
113
118
|
task.schema.shell = task.schema.shell ?? extend.schema.shell;
|
|
114
119
|
task.schema.cache = task.schema.cache ?? extend.schema.cache;
|
|
115
120
|
task.schema.timeout = task.schema.timeout ?? extend.schema.timeout;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
if (!reset.has('cmds'))
|
|
122
|
+
task.schema.cmds = extendArray(task.schema.cmds, extend.schema.cmds);
|
|
123
|
+
if (!reset.has('src'))
|
|
124
|
+
task.schema.src = extendArray(task.schema.src, extend.schema.src);
|
|
125
|
+
if (!reset.has('generates'))
|
|
126
|
+
task.schema.generates = extendArray(task.schema.generates, extend.schema.generates);
|
|
127
|
+
if (!reset.has('labels'))
|
|
128
|
+
task.schema.labels = extendObject(task.schema.labels, extend.schema.labels);
|
|
129
|
+
// the base's resolved envs: its own plus the top-level envs of its build file
|
|
130
|
+
// (and the inputs an include passed), which carry the defaults it relies on
|
|
131
|
+
if (!reset.has('envs'))
|
|
132
|
+
task.envs = (0, merge_environment_variables_1.mergeEnvironmentVariables)(task.envs, extend.envs);
|
|
121
133
|
if ((0, build_file_task_schema_1.isBuildFileContainerTaskSchema)(extend.schema)) {
|
|
122
134
|
const taskSchema = task.schema;
|
|
123
135
|
taskSchema.image = taskSchema.image ?? extend.schema.image;
|
|
124
|
-
|
|
136
|
+
if (!reset.has('mounts'))
|
|
137
|
+
taskSchema.mounts = extendArray(taskSchema.mounts, extend.schema.mounts);
|
|
125
138
|
}
|
|
126
139
|
// deps and needs resolve in the file that declares them, so every base up the
|
|
127
|
-
// chain contributes its own, not only the nearest
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
140
|
+
// chain contributes its own, not only the nearest; what a task resets is not
|
|
141
|
+
// passed on to the tasks extending it either
|
|
142
|
+
const base = { scope: extend.scope, schema: extend.schema };
|
|
143
|
+
task.needBases = reset.has('needs') ? [] : [...(extend.needBases ?? []), base];
|
|
144
|
+
task.depBases = reset.has('deps') ? [] : [...(extend.depBases ?? []), base];
|
|
145
|
+
for (const needBase of task.needBases) {
|
|
146
|
+
resolveNeeds(reference, task, needBase.scope, needBase.schema);
|
|
147
|
+
}
|
|
148
|
+
for (const depBase of task.depBases) {
|
|
149
|
+
resolveDeps(reference, task, depBase.scope, depBase.schema);
|
|
132
150
|
}
|
|
133
151
|
task.extension = 'applied';
|
|
134
152
|
}
|
package/package.json
CHANGED