hammerkit 1.4.0-beta.6 → 1.5.0-alpha.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.
Files changed (182) hide show
  1. package/.devcontainer/Dockerfile +5 -0
  2. package/.devcontainer/devcontainer.json +40 -0
  3. package/Dockerfile +1 -1
  4. package/README.md +13 -86
  5. package/SUMMARY.md +43 -0
  6. package/build.schema.json +56 -2
  7. package/dist/cli.js +97 -0
  8. package/dist/cli.spec.js +5 -0
  9. package/dist/console/console-context-mock.js +11 -0
  10. package/dist/console/get-logger.js +23 -0
  11. package/dist/docker/pull.js +5 -5
  12. package/dist/docker/remove-container.js +21 -0
  13. package/dist/docker/stream.js +19 -21
  14. package/dist/docker/using-container.js +28 -0
  15. package/dist/environment/get-process-env.js +4 -4
  16. package/dist/environment/replace-env-variables.js +2 -3
  17. package/dist/executer/abort.js +13 -0
  18. package/dist/executer/check-readiness.js +25 -0
  19. package/dist/executer/create-scheduler-state.js +32 -0
  20. package/dist/executer/docker-node.js +123 -0
  21. package/dist/executer/docker-service.js +113 -0
  22. package/dist/executer/environment-mock.js +17 -0
  23. package/dist/executer/event-cache.js +165 -0
  24. package/dist/executer/execute-command.js +42 -0
  25. package/dist/executer/execute-docker.js +73 -223
  26. package/dist/executer/execute.spec.js +37 -37
  27. package/dist/executer/execution-steps.js +57 -0
  28. package/dist/executer/get-docker-executor.js +21 -20
  29. package/dist/executer/hierarchy-scheduler.js +94 -0
  30. package/dist/executer/kubernetes-service.js +64 -0
  31. package/dist/executer/label-values.js +65 -0
  32. package/dist/executer/local-node.js +57 -0
  33. package/dist/executer/print-container-options.js +17 -0
  34. package/dist/{logging/log-strategy.js → executer/process-item.js} +1 -1
  35. package/dist/executer/process-listener.js +3 -0
  36. package/dist/executer/process-manager.js +111 -0
  37. package/dist/executer/process-manager.spec.js +91 -0
  38. package/dist/executer/{executor.js → process.js} +1 -1
  39. package/dist/executer/{execute-result.js → readonly-state.js} +1 -1
  40. package/dist/executer/schedule.js +139 -0
  41. package/dist/executer/scheduler/check-for-loop.js +21 -0
  42. package/dist/executer/scheduler/enqueue-next.js +27 -0
  43. package/dist/{testing/test-context.js → executer/scheduler/node-state.js} +1 -1
  44. package/dist/executer/scheduler/scheduler-result.js +3 -0
  45. package/dist/executer/scheduler/scheduler-state.js +3 -0
  46. package/dist/executer/scheduler/service-state.js +3 -0
  47. package/dist/executer/service-dns.js +6 -0
  48. package/dist/executer/set-user-permission.js +16 -0
  49. package/dist/executer/start-node.js +59 -0
  50. package/dist/executer/state-listener.js +3 -0
  51. package/dist/executer/state.js +49 -0
  52. package/dist/executer/states.js +4 -129
  53. package/dist/executer/watch-node.js +57 -0
  54. package/dist/executer/watch-service.js +54 -0
  55. package/dist/executer/work-scope.js +10 -0
  56. package/dist/file/get-file-context-mock.js +1 -0
  57. package/dist/file/get-file-context-mock.spec.js +28 -27
  58. package/dist/file/get-file-context.js +73 -63
  59. package/dist/file/move-files.js +1 -1
  60. package/dist/get-work-context.js +29 -0
  61. package/dist/index.js +11 -10
  62. package/dist/log.js +209 -52
  63. package/dist/logging/grouped-logger.js +31 -19
  64. package/dist/logging/interactive-logger.js +20 -23
  65. package/dist/logging/live-logger.js +7 -17
  66. package/dist/optimizer/calculate-checksum.js +1 -1
  67. package/dist/optimizer/get-cache-directory.js +8 -13
  68. package/dist/optimizer/get-work-node-cache-stats.js +68 -21
  69. package/dist/optimizer/read-work-node-cache.js +2 -2
  70. package/dist/optimizer/work-node-cache-description.js +12 -11
  71. package/dist/optimizer/write-work-node-cache.js +9 -8
  72. package/dist/{executer/execution-context.js → parser/build-file-service.js} +1 -1
  73. package/dist/{optimizer → parser}/cache-method.js +0 -0
  74. package/dist/parser/get-build-file.js +1 -1
  75. package/dist/parser/parse-boolean.js +29 -0
  76. package/dist/parser/parse-boolean.spec.js +48 -0
  77. package/dist/parser/parse-build-file-references.js +2 -2
  78. package/dist/parser/parse-build-file-services.js +58 -0
  79. package/dist/parser/parse-build-file-task-command.js +6 -5
  80. package/dist/parser/parse-build-file-task-source.js +5 -5
  81. package/dist/parser/parse-build-file.js +29 -17
  82. package/dist/parser/parse-context.js +13 -0
  83. package/dist/parser/parse-envs.js +4 -3
  84. package/dist/parser/parse-healthcheck.js +28 -0
  85. package/dist/parser/parse-label-arguments.js +23 -0
  86. package/dist/parser/parse-service-selector.js +39 -0
  87. package/dist/parser/parse-string-array.js +6 -5
  88. package/dist/parser/parse-string-map.js +30 -0
  89. package/dist/parser/parse-string.js +20 -0
  90. package/dist/parser/read-build-file.js +16 -5
  91. package/dist/parser/read-env-file.js +7 -7
  92. package/dist/planner/utils/get-container-mounts.js +24 -0
  93. package/dist/planner/utils/normalize-path.js +17 -0
  94. package/dist/planner/utils/parse-work-node-mount.js +3 -14
  95. package/dist/planner/utils/parse-work-node-mount.spec.js +10 -10
  96. package/dist/planner/utils/parse-work-service-volume.js +21 -0
  97. package/dist/planner/utils/plan-work-command.js +1 -1
  98. package/dist/planner/utils/plan-work-dependency.js +29 -24
  99. package/dist/planner/utils/plan-work-node.js +203 -120
  100. package/dist/planner/utils/plan-work-nodes.js +60 -12
  101. package/dist/planner/utils/plan-work-tree.js +8 -4
  102. package/dist/planner/utils/plan-work-volume.js +25 -0
  103. package/dist/planner/validate.js +56 -8
  104. package/dist/planner/work-context.js +20 -0
  105. package/dist/planner/work-mount.js +3 -0
  106. package/dist/planner/work-node-id.js +4 -4
  107. package/dist/planner/work-node-id.spec.js +11 -8
  108. package/dist/planner/work-node-path.js +0 -1
  109. package/dist/planner/work-node-status.js +121 -18
  110. package/dist/planner/work-node.js +3 -3
  111. package/dist/planner/work-service-id.js +13 -0
  112. package/dist/planner/work-service-volume.js +3 -0
  113. package/dist/planner/work-service.js +6 -0
  114. package/dist/planner/work-services.js +3 -0
  115. package/dist/planner/work-volume.js +3 -0
  116. package/dist/program.js +155 -91
  117. package/dist/program.spec.js +20 -0
  118. package/dist/start-watch-processes.js +28 -0
  119. package/dist/testing/cli.js +73 -0
  120. package/dist/testing/create-build-file.js +1 -1
  121. package/dist/testing/example-test-suite.js +54 -0
  122. package/dist/testing/expect.js +30 -18
  123. package/dist/testing/get-logger.js +23 -0
  124. package/dist/testing/get-node.js +2 -2
  125. package/dist/testing/get-test-context.js +6 -5
  126. package/dist/testing/get-test-suite.js +2 -51
  127. package/dist/testing/integration/cache.spec.js +25 -28
  128. package/dist/testing/integration/cancellation.spec.js +19 -21
  129. package/dist/testing/integration/clean.spec.js +29 -13
  130. package/dist/testing/integration/cmd.spec.js +5 -8
  131. package/dist/testing/integration/concurrency.spec.js +8 -17
  132. package/dist/testing/integration/docker.spec.js +6 -9
  133. package/dist/testing/integration/env.spec.js +27 -34
  134. package/dist/testing/integration/error.spec.js +5 -9
  135. package/dist/testing/integration/extend.spec.js +32 -0
  136. package/dist/testing/integration/glob.spec.js +35 -28
  137. package/dist/testing/integration/include.spec.js +17 -16
  138. package/dist/testing/integration/invalid.spec.js +3 -2
  139. package/dist/testing/integration/invalid_loop.spec.js +13 -0
  140. package/dist/testing/integration/kubernetes.spec.js +15 -0
  141. package/dist/testing/integration/labels.spec.js +47 -0
  142. package/dist/testing/integration/local.spec.js +4 -7
  143. package/dist/testing/integration/monorepo.spec.js +6 -30
  144. package/dist/testing/integration/multi-line.spec.js +4 -4
  145. package/dist/testing/integration/program.spec.js +3 -10
  146. package/dist/testing/integration/reference.spec.js +10 -13
  147. package/dist/testing/integration/services.spec.js +14 -0
  148. package/dist/testing/integration/store.spec.js +42 -35
  149. package/dist/testing/integration/unknown.spec.js +4 -4
  150. package/dist/testing/integration/validate.spec.js +4 -4
  151. package/dist/testing/integration/watch.spec.js +25 -23
  152. package/dist/testing/lazy.js +17 -0
  153. package/dist/testing/start-watch-processes.js +29 -0
  154. package/dist/testing/test-suite-setup.js +3 -0
  155. package/dist/utils/abort-event.js +24 -0
  156. package/dist/utils/abortable-function.js +71 -0
  157. package/dist/utils/debouncer.spec.js +8 -8
  158. package/dist/utils/environment-config.js +13 -0
  159. package/dist/utils/fail-never.js +1 -1
  160. package/dist/utils/sleep.spec.js +3 -3
  161. package/package.json +24 -21
  162. package/dist/console/get-console-context-mock.js +0 -33
  163. package/dist/executer/clean.js +0 -22
  164. package/dist/executer/execute-local.js +0 -58
  165. package/dist/executer/execute.js +0 -95
  166. package/dist/executer/execution-context-event.js +0 -3
  167. package/dist/executer/execution-context-mock.js +0 -3
  168. package/dist/executer/executor-mock.js +0 -39
  169. package/dist/executer/get-environment-mock.js +0 -17
  170. package/dist/executer/get-execution-context-mock.js +0 -19
  171. package/dist/executer/get-local-executor.js +0 -22
  172. package/dist/executer/get-ready-work-nodes.js +0 -15
  173. package/dist/executer/restore.js +0 -22
  174. package/dist/executer/store.js +0 -23
  175. package/dist/logging/get-logger.js +0 -23
  176. package/dist/logging/message-to-console.js +0 -16
  177. package/dist/optimizer/optimize.js +0 -32
  178. package/dist/optimizer/work-node-description.js +0 -12
  179. package/dist/planner/utils/find-build-task.js +0 -18
  180. package/dist/testing/create-work-tree.js +0 -11
  181. package/dist/utils/defer.js +0 -57
  182. package/dist/utils/defer.spec.js +0 -76
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseLabelArguments = void 0;
4
+ function parseLabelArguments(args) {
5
+ const labels = {};
6
+ for (const arg of args) {
7
+ const labelParts = arg.split('=');
8
+ if (labelParts.length !== 2) {
9
+ throw new Error(`invalid label ${arg}`);
10
+ }
11
+ const key = labelParts[0];
12
+ const value = labelParts[1];
13
+ if (!labels[key]) {
14
+ labels[key] = [value];
15
+ }
16
+ else if (labels[key].indexOf(value) === -1) {
17
+ labels[key].push(value);
18
+ }
19
+ }
20
+ return labels;
21
+ }
22
+ exports.parseLabelArguments = parseLabelArguments;
23
+ //# sourceMappingURL=parse-label-arguments.js.map
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseServiceSelector = void 0;
4
+ const parse_context_1 = require("./parse-context");
5
+ const parse_string_1 = require("./parse-string");
6
+ function parseServiceSelector(ctx, value, optional) {
7
+ if (value === null || value === undefined) {
8
+ if (optional) {
9
+ return null;
10
+ }
11
+ else {
12
+ throw new Error(`${(0, parse_context_1.parseContextDescription)(ctx)} missing selector`);
13
+ }
14
+ }
15
+ if (typeof value !== 'object') {
16
+ throw new Error(`${(0, parse_context_1.parseContextDescription)(ctx)} invalid selector, expecting map`);
17
+ }
18
+ const result = { type: '', name: '' };
19
+ for (const [key, prop] of Object.entries(value || {})) {
20
+ if (key === 'type') {
21
+ result.type = (0, parse_string_1.parseString)(ctx, 'selector type', prop, false);
22
+ }
23
+ else if (key === 'name') {
24
+ result.name = (0, parse_string_1.parseString)(ctx, 'selector name', prop, false);
25
+ }
26
+ else {
27
+ throw new Error(`${(0, parse_context_1.parseContextDescription)(ctx)} unknown property ${key} in healthcheck`);
28
+ }
29
+ }
30
+ if (!result.type) {
31
+ throw new Error(`${(0, parse_context_1.parseContextDescription)(ctx)} invalid selector, missing type property`);
32
+ }
33
+ if (!result.name) {
34
+ throw new Error(`${(0, parse_context_1.parseContextDescription)(ctx)} invalid selector, missing name property`);
35
+ }
36
+ return result;
37
+ }
38
+ exports.parseServiceSelector = parseServiceSelector;
39
+ //# sourceMappingURL=parse-service-selector.js.map
@@ -1,18 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseStringArray = void 0;
4
- function parseStringArray(fileName, taskName, valueName, value) {
4
+ const parse_context_1 = require("./parse-context");
5
+ function parseStringArray(ctx, valueName, value) {
5
6
  if (!value) {
6
7
  return null;
7
8
  }
8
9
  if (value instanceof Array) {
9
- if (!value.every((v) => typeof v === 'string')) {
10
- throw new Error(`${fileName} task ${taskName} ${valueName} needs to be a string array`);
10
+ if (!value.every((v) => typeof v === 'string' || typeof v === 'number')) {
11
+ throw new Error(`${(0, parse_context_1.parseContextDescription)(ctx)} ${valueName} needs to be a string array`);
11
12
  }
12
- return value;
13
+ return value.map((v) => `${v}`);
13
14
  }
14
15
  else {
15
- throw new Error(`${fileName} task ${taskName} ${valueName} needs to be a string array`);
16
+ throw new Error(`${(0, parse_context_1.parseContextDescription)(ctx)} ${valueName} needs to be a string array`);
16
17
  }
17
18
  }
18
19
  exports.parseStringArray = parseStringArray;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseStringMap = void 0;
4
+ const parse_context_1 = require("./parse-context");
5
+ function parseStringMap(ctx, valueName, value) {
6
+ if (value === null || value === undefined) {
7
+ return {};
8
+ }
9
+ if (typeof value !== 'object') {
10
+ throw new Error(`${(0, parse_context_1.parseContextDescription)(ctx)} ${valueName} needs to be a string map`);
11
+ }
12
+ if (!value) {
13
+ return {};
14
+ }
15
+ const map = {};
16
+ for (const [key, item] of Object.entries(value)) {
17
+ if (typeof item === 'string') {
18
+ map[key] = item;
19
+ }
20
+ else if (typeof item === 'number') {
21
+ map[key] = item.toString();
22
+ }
23
+ else {
24
+ throw new Error(`${(0, parse_context_1.parseContextDescription)(ctx)} ${valueName} ${key} should be a string value`);
25
+ }
26
+ }
27
+ return map;
28
+ }
29
+ exports.parseStringMap = parseStringMap;
30
+ //# sourceMappingURL=parse-string-map.js.map
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseString = void 0;
4
+ const parse_context_1 = require("./parse-context");
5
+ function parseString(ctx, keyName, value, optional) {
6
+ if (value === null || value === undefined) {
7
+ if (optional) {
8
+ return null;
9
+ }
10
+ else {
11
+ throw new Error(`${(0, parse_context_1.parseContextDescription)(ctx)} -> ${keyName} is missing`);
12
+ }
13
+ }
14
+ if (typeof value === 'string' || typeof value === 'number') {
15
+ return `${value}`;
16
+ }
17
+ throw new Error(`${(0, parse_context_1.parseContextDescription)(ctx)} -> ${keyName} is not a valid string`);
18
+ }
19
+ exports.parseString = parseString;
20
+ //# sourceMappingURL=parse-string.js.map
@@ -1,10 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readBuildFile = exports.read = void 0;
3
+ exports.readBuildFile = exports.read = exports.write = void 0;
4
4
  const yaml_1 = require("yaml");
5
5
  const parse_build_file_1 = require("./parse-build-file");
6
+ async function write(filename, content, context) {
7
+ await context.file.writeFile(filename, (0, yaml_1.stringify)(content));
8
+ }
9
+ exports.write = write;
6
10
  async function read(fileName, context) {
7
- // context.console.debug(`read ${fileName} build file`)
11
+ context.status
12
+ .context({ type: 'cli', id: 'general', name: 'hammerkit' })
13
+ .write('debug', `read ${fileName} build file`);
8
14
  let content;
9
15
  try {
10
16
  content = await context.file.read(fileName);
@@ -13,10 +19,15 @@ async function read(fileName, context) {
13
19
  throw new Error(`unable to read ${fileName}`);
14
20
  }
15
21
  try {
16
- return yaml_1.parse(content);
22
+ return (0, yaml_1.parse)(content);
17
23
  }
18
24
  catch (e) {
19
- throw new Error(`unable to parse ${fileName}: ${e.message}`);
25
+ if (e instanceof Error) {
26
+ throw new Error(`unable to parse ${fileName}: ${e.message}`);
27
+ }
28
+ else {
29
+ throw e;
30
+ }
20
31
  }
21
32
  }
22
33
  exports.read = read;
@@ -25,7 +36,7 @@ async function readBuildFile(fileName, files, context) {
25
36
  return files[fileName];
26
37
  }
27
38
  const input = await read(fileName, context);
28
- return parse_build_file_1.parseBuildFile(fileName, files, input, context);
39
+ return (0, parse_build_file_1.parseBuildFile)(fileName, files, input, context);
29
40
  }
30
41
  exports.readBuildFile = readBuildFile;
31
42
  //# sourceMappingURL=read-build-file.js.map
@@ -2,24 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readEnvFile = void 0;
4
4
  const path_1 = require("path");
5
- async function readEnvFile(path, baseEnv, context) {
6
- const directory = path_1.join(path, '.env');
5
+ async function readEnvFile(path, baseEnv, environment) {
6
+ const directory = (0, path_1.join)(path, '.env');
7
7
  let envs = { ...baseEnv };
8
- if (path_1.basename(path) !== path) {
9
- envs = { ...(await readEnvFile(path_1.basename(path), envs, context)) };
8
+ if ((0, path_1.basename)(path) !== path) {
9
+ envs = { ...(await readEnvFile((0, path_1.basename)(path), envs, environment)) };
10
10
  }
11
- const exists = await context.file.exists(directory);
11
+ const exists = await environment.file.exists(directory);
12
12
  if (!exists) {
13
13
  return envs;
14
14
  }
15
- const envFile = (await context.file.read(directory)).split(/\r?\n/);
15
+ const envFile = (await environment.file.read(directory)).split(/\r?\n/);
16
16
  for (const envVar of envFile) {
17
17
  const index = envVar.indexOf('=');
18
18
  if (index > 0) {
19
19
  const key = envVar.substr(0, index);
20
20
  const value = envVar.substr(index + 1);
21
21
  if (!envs[key]) {
22
- context.console.debug(`load env variable ${key} from ${directory} file`);
22
+ environment.console.debug(`load env variable ${key} from ${directory} file`);
23
23
  envs[key] = value;
24
24
  }
25
25
  }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getContainerMounts = void 0;
4
+ function getContainerMounts(task, workMount) {
5
+ const result = [
6
+ ...task.src.map((source) => ({
7
+ localPath: source.absolutePath,
8
+ containerPath: source.absolutePath,
9
+ })),
10
+ ...workMount,
11
+ ];
12
+ for (const volume of result) {
13
+ const otherVolumes = result.filter((v) => v.containerPath === volume.containerPath && v.localPath !== volume.localPath);
14
+ if (otherVolumes.length > 0) {
15
+ throw new Error(`duplicate container mount with different sources ${[
16
+ volume.localPath,
17
+ ...otherVolumes.map((ov) => ov.localPath),
18
+ ].join(', ')}`);
19
+ }
20
+ }
21
+ return result.filter((v, i) => result.findIndex((iv) => iv.containerPath == v.containerPath) === i);
22
+ }
23
+ exports.getContainerMounts = getContainerMounts;
24
+ //# sourceMappingURL=get-container-mounts.js.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizePath = void 0;
4
+ const path_1 = require("path");
5
+ function normalizePath(cwd, pwd, path) {
6
+ if (path.startsWith('/')) {
7
+ return path;
8
+ }
9
+ else if (path.startsWith('$PWD')) {
10
+ return (0, path_1.join)(pwd, path.substr('$PWD'.length));
11
+ }
12
+ else {
13
+ return (0, path_1.join)(cwd, path);
14
+ }
15
+ }
16
+ exports.normalizePath = normalizePath;
17
+ //# sourceMappingURL=normalize-path.js.map
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseWorkNodeMount = void 0;
4
- const path_1 = require("path");
5
4
  const os_1 = require("os");
5
+ const normalize_path_1 = require("./normalize-path");
6
6
  function parseWorkNodeMount(cwd, dir) {
7
7
  const parts = dir.split(':');
8
8
  if (parts.length === 1) {
@@ -16,21 +16,10 @@ function parseWorkNodeMount(cwd, dir) {
16
16
  }
17
17
  }
18
18
  exports.parseWorkNodeMount = parseWorkNodeMount;
19
- function normalizePath(cwd, pwd, path) {
20
- if (path.startsWith('/')) {
21
- return path;
22
- }
23
- else if (path.startsWith('$PWD')) {
24
- return path_1.join(pwd, path.substr('$PWD'.length));
25
- }
26
- else {
27
- return path_1.join(cwd, path);
28
- }
29
- }
30
19
  function parseLocalMount(cwd, localPath, containerPath) {
31
20
  return {
32
- localPath: normalizePath(cwd, os_1.homedir(), localPath),
33
- containerPath: normalizePath(cwd, cwd, containerPath),
21
+ localPath: (0, normalize_path_1.normalizePath)(cwd, (0, os_1.homedir)(), localPath),
22
+ containerPath: (0, normalize_path_1.normalizePath)(cwd, cwd, containerPath),
34
23
  };
35
24
  }
36
25
  //# sourceMappingURL=parse-work-node-mount.js.map
@@ -8,49 +8,49 @@ function normalizePath(val) {
8
8
  }
9
9
  describe('parse-work-node-mount', () => {
10
10
  it('should parse "subdir"', () => {
11
- expect(parse_work_node_mount_1.parseWorkNodeMount('/home/test', 'subdir')).toEqual({
11
+ expect((0, parse_work_node_mount_1.parseWorkNodeMount)('/home/test', 'subdir')).toEqual({
12
12
  localPath: normalizePath('/home/test/subdir'),
13
13
  containerPath: normalizePath('/home/test/subdir'),
14
14
  });
15
15
  });
16
16
  it('should parse "./subdir"', () => {
17
- expect(parse_work_node_mount_1.parseWorkNodeMount('/home/test', './subdir')).toEqual({
17
+ expect((0, parse_work_node_mount_1.parseWorkNodeMount)('/home/test', './subdir')).toEqual({
18
18
  localPath: normalizePath('/home/test/subdir'),
19
19
  containerPath: normalizePath('/home/test/subdir'),
20
20
  });
21
21
  });
22
22
  it('should parse "./subdir:./otherdir"', () => {
23
- expect(parse_work_node_mount_1.parseWorkNodeMount('/home/test', './subdir:./otherdir')).toEqual({
23
+ expect((0, parse_work_node_mount_1.parseWorkNodeMount)('/home/test', './subdir:./otherdir')).toEqual({
24
24
  localPath: normalizePath('/home/test/subdir'),
25
25
  containerPath: normalizePath('/home/test/otherdir'),
26
26
  });
27
27
  });
28
28
  it('should parse "$PWD/subdir:/subdir"', () => {
29
- expect(parse_work_node_mount_1.parseWorkNodeMount('/home/test', '$PWD/subdir:/subdir')).toEqual({
30
- localPath: path_1.join(os_1.homedir(), 'subdir'),
29
+ expect((0, parse_work_node_mount_1.parseWorkNodeMount)('/home/test', '$PWD/subdir:/subdir')).toEqual({
30
+ localPath: (0, path_1.join)((0, os_1.homedir)(), 'subdir'),
31
31
  containerPath: '/subdir',
32
32
  });
33
33
  });
34
34
  it('should parse "$PWD/subdir:$PWD/subdir"', () => {
35
- expect(parse_work_node_mount_1.parseWorkNodeMount('/home/test', '$PWD/subdir:$PWD/subdir')).toEqual({
36
- localPath: path_1.join(os_1.homedir(), 'subdir'),
35
+ expect((0, parse_work_node_mount_1.parseWorkNodeMount)('/home/test', '$PWD/subdir:$PWD/subdir')).toEqual({
36
+ localPath: (0, path_1.join)((0, os_1.homedir)(), 'subdir'),
37
37
  containerPath: normalizePath('/home/test/subdir'),
38
38
  });
39
39
  });
40
40
  it('should parse "/subdir:/otherdir"', () => {
41
- expect(parse_work_node_mount_1.parseWorkNodeMount('/home/test', '/subdir:/otherdir')).toEqual({
41
+ expect((0, parse_work_node_mount_1.parseWorkNodeMount)('/home/test', '/subdir:/otherdir')).toEqual({
42
42
  localPath: '/subdir',
43
43
  containerPath: '/otherdir',
44
44
  });
45
45
  });
46
46
  it('should parse "/subdir:otherdir"', () => {
47
- expect(parse_work_node_mount_1.parseWorkNodeMount('/home/test', '/subdir:otherdir')).toEqual({
47
+ expect((0, parse_work_node_mount_1.parseWorkNodeMount)('/home/test', '/subdir:otherdir')).toEqual({
48
48
  localPath: '/subdir',
49
49
  containerPath: normalizePath('/home/test/otherdir'),
50
50
  });
51
51
  });
52
52
  it('should parse "subdir:/otherdir"', () => {
53
- expect(parse_work_node_mount_1.parseWorkNodeMount('/home/test', 'subdir:/otherdir')).toEqual({
53
+ expect((0, parse_work_node_mount_1.parseWorkNodeMount)('/home/test', 'subdir:/otherdir')).toEqual({
54
54
  localPath: normalizePath('/home/test/subdir'),
55
55
  containerPath: '/otherdir',
56
56
  });
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseWorkServiceVolume = void 0;
4
+ const normalize_path_1 = require("./normalize-path");
5
+ function parseWorkServiceVolume(cwd, dir) {
6
+ const parts = dir.split(':');
7
+ if (parts.length === 2) {
8
+ return parseVolume(cwd, parts[0], parts[1]);
9
+ }
10
+ else {
11
+ throw new Error(`invalid volume ${dir}`);
12
+ }
13
+ }
14
+ exports.parseWorkServiceVolume = parseWorkServiceVolume;
15
+ function parseVolume(cwd, name, containerPath) {
16
+ return {
17
+ name,
18
+ containerPath: (0, normalize_path_1.normalizePath)(cwd, cwd, containerPath),
19
+ };
20
+ }
21
+ //# sourceMappingURL=parse-work-service-volume.js.map
@@ -11,7 +11,7 @@ function planWorkCommand(cmds, workingDir) {
11
11
  else {
12
12
  result.push({
13
13
  cmd: cmd.cmd,
14
- path: path_1.join(workingDir, cmd.path || ''),
14
+ path: (0, path_1.join)(workingDir, cmd.path || ''),
15
15
  });
16
16
  }
17
17
  }
@@ -1,33 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.planWorkDependency = void 0;
4
- const plan_work_node_1 = require("./plan-work-node");
5
- function planWorkDependency(build, node, taskName, dep, nodes, context) {
6
- const depNode = plan_work_node_1.planWorkNode(build, dep, nodes, {
7
- ...context,
8
- idPrefix: null,
9
- });
10
- if (!depNode) {
11
- throw new Error(`unable to find dependency ${dep} for task ${taskName} in ${build.path}`);
12
- }
13
- node.deps.push(depNode);
14
- for (const src of depNode.src) {
15
- if (node.src.indexOf(src) === -1) {
16
- node.src.push(src);
4
+ const work_node_1 = require("../work-node");
5
+ const plan_work_volume_1 = require("./plan-work-volume");
6
+ function planWorkDependency(deps, node) {
7
+ for (const depNode of deps) {
8
+ if (node.deps.some((d) => d.id === depNode.id)) {
9
+ continue;
17
10
  }
18
- }
19
- for (const generate of depNode.generates) {
20
- if (node.generates.indexOf(generate) === -1) {
21
- node.generates.push(generate);
11
+ node.deps.push(depNode);
12
+ for (const src of depNode.src) {
13
+ if (node.src.indexOf(src) === -1) {
14
+ node.src.push(src);
15
+ if ((0, work_node_1.isContainerWorkNode)(node)) {
16
+ node.mounts.push({
17
+ localPath: src.absolutePath,
18
+ containerPath: src.absolutePath,
19
+ });
20
+ }
21
+ }
22
22
  }
23
- }
24
- if (!node.status.pendingDependencies[depNode.id]) {
25
- node.status.pendingDependencies[depNode.id] = depNode;
26
- }
27
- for (const dep of depNode.deps) {
28
- if (!node.status.pendingDependencies[dep.id]) {
29
- node.status.pendingDependencies[dep.id] = dep;
23
+ for (const generate of depNode.generates) {
24
+ if (!node.generates.some((g) => g.path === generate.path)) {
25
+ node.generates.push({ path: generate.path, inherited: true });
26
+ if ((0, work_node_1.isContainerWorkNode)(node)) {
27
+ const name = (0, plan_work_volume_1.getVolumeName)(generate.path);
28
+ node.volumes.push({
29
+ name,
30
+ containerPath: generate.path,
31
+ });
32
+ }
33
+ }
30
34
  }
35
+ planWorkDependency(depNode.deps, node);
31
36
  }
32
37
  }
33
38
  exports.planWorkDependency = planWorkDependency;