hammerkit 2.1.0-next.5 → 2.1.0-next.6

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.
@@ -37,8 +37,9 @@ function buildEnvironmentVariables(envs, environment, context) {
37
37
  }
38
38
  else if (value.includes('${')) {
39
39
  const interpolated = interpolate(value, envs, environment, context, fromProcess);
40
- if (interpolated.missing) {
41
- replacements.push({ key, name: interpolated.missing, available: false, value: null });
40
+ if (interpolated.missing.length > 0) {
41
+ const [name] = interpolated.missing;
42
+ replacements.push({ key, name, available: false, value: null, missing: interpolated.missing });
42
43
  }
43
44
  else {
44
45
  variables[key] = interpolated.value;
@@ -53,13 +54,15 @@ function buildEnvironmentVariables(envs, environment, context) {
53
54
  exports.buildEnvironmentVariables = buildEnvironmentVariables;
54
55
  // Each `${NAME}` comes from the process environment or a .env file, else from a
55
56
  // literal value of the same build file / task `envs`, else from its
56
- // `:-default`. A reference without any of them is missing.
57
+ // `:-default`. A reference without any of them is missing; each is listed once.
57
58
  function interpolate(value, envs, environment, context, fromProcess) {
58
- let missing = null;
59
+ const missing = [];
59
60
  const result = value.replace(INTERPOLATION, (match, name, fallback) => {
60
61
  const resolved = resolveReference(name, environment, context, fromProcess) ?? getLiteral(envs, name) ?? fallback ?? null;
61
62
  if (resolved === null) {
62
- missing = missing ?? name;
63
+ if (!missing.includes(name)) {
64
+ missing.push(name);
65
+ }
63
66
  return match;
64
67
  }
65
68
  return resolved;
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isRunSourceEnv = exports.RUN_SOURCE_ENVS = void 0;
4
4
  // The variables a server sets for the process of a run, from what the run is from (see
5
5
  // src/server/run-source-environment.ts). Nothing else sets them: the operator's `runs.env`
6
- // can't name them, and a run that isn't from that source has none of them.
6
+ // can't name them, and a run that isn't from that source has none of them. `validate` reads
7
+ // this list too, so an env that reads one of them isn't a variable set nowhere.
7
8
  exports.RUN_SOURCE_ENVS = [
8
9
  'HAMMERKIT_RUN_REPO',
9
10
  'HAMMERKIT_RUN_REF',
@@ -6,6 +6,7 @@ const plan_work_tasks_1 = require("./utils/plan-work-tasks");
6
6
  const unreferenced_build_file_envs_1 = require("./unreferenced-build-file-envs");
7
7
  const normalize_path_1 = require("./utils/normalize-path");
8
8
  const dependency_outputs_1 = require("./utils/dependency-outputs");
9
+ const run_source_envs_1 = require("../environment/run-source-envs");
9
10
  async function* validate(workTree, context) {
10
11
  const cycleItems = [];
11
12
  for (const item of (0, plan_work_tasks_1.iterateWorkServices)(workTree)) {
@@ -111,13 +112,22 @@ async function* validate(workTree, context) {
111
112
  }
112
113
  exports.validate = validate;
113
114
  // An env that reads a variable set nowhere, such as an input of an included file run on its
114
- // own: the task fails when it starts, and until then `$NAME` stays in what it templates
115
+ // own: the task fails when it starts, and until then `$NAME` stays in what it templates. Each
116
+ // variable a value reads counts, `${A}-${B}` both. The variables of what a run is from
117
+ // (`$HAMMERKIT_RUN_REF`) are not of them: a server sets them when it runs the task
118
+ // (RUN_SOURCE_ENVS).
115
119
  function* warnUnsetEnvs(envs, item) {
116
120
  for (const replacement of envs.replacements) {
117
- if (!replacement.available) {
121
+ if (replacement.available) {
122
+ continue;
123
+ }
124
+ for (const name of replacement.missing ?? [replacement.name]) {
125
+ if ((0, run_source_envs_1.isRunSourceEnv)(name)) {
126
+ continue;
127
+ }
118
128
  yield {
119
129
  type: 'warn',
120
- message: `env ${replacement.key} reads $${replacement.name}, which neither the environment nor a .env file sets: ` +
130
+ message: `env ${replacement.key} reads $${name}, which neither the environment nor a .env file sets: ` +
121
131
  `it can't start, and $${replacement.key} stays as it is written in its build file`,
122
132
  item,
123
133
  };
@@ -9,7 +9,7 @@ const COMMIT = /^[0-9a-f]{40}([0-9a-f]{24})?$/i;
9
9
  // repository, and the branch or tag and the commit it was pinned to, or the repository and the
10
10
  // sandbox. None of them is a credential, so a task that reads them still takes arguments and
11
11
  // keeps its network (see PLAIN_SERVER_ENVS). A sandbox has no commit: its files may hold
12
- // changes. A run from an upload has none of them.
12
+ // changes. A run from an upload has none of them. Each is a name of RUN_SOURCE_ENVS.
13
13
  function runSourceEnvironment(source) {
14
14
  if (source.type === 'ref') {
15
15
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hammerkit",
3
3
  "description": "Containerized build tool with incremental caching that runs the same build file locally, in Docker and on Kubernetes.",
4
- "version": "2.1.0-next.5",
4
+ "version": "2.1.0-next.6",
5
5
  "keywords": [
6
6
  "build",
7
7
  "build-tool",