hammerkit 1.5.0 → 1.6.0-alpha.1
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/.agents/FEEDBACK.md +74 -0
- package/.agents/skills/before-commit/SKILL.md +101 -0
- package/.agents/skills/do-the-work/SKILL.md +64 -0
- package/.agents/skills/fix-ci/SKILL.md +98 -0
- package/.agents/skills/speckit-git-commit/SKILL.md +53 -0
- package/.agents/skills/speckit-git-feature/SKILL.md +72 -0
- package/.agents/skills/speckit-git-initialize/SKILL.md +54 -0
- package/.agents/skills/speckit-git-remote/SKILL.md +50 -0
- package/.agents/skills/speckit-git-validate/SKILL.md +54 -0
- package/.gitbook.yaml +5 -0
- package/.specify/extensions/.registry +37 -0
- package/.specify/extensions/git/README.md +100 -0
- package/.specify/extensions/git/commands/speckit.git.commit.md +48 -0
- package/.specify/extensions/git/commands/speckit.git.feature.md +67 -0
- package/.specify/extensions/git/commands/speckit.git.initialize.md +49 -0
- package/.specify/extensions/git/commands/speckit.git.remote.md +45 -0
- package/.specify/extensions/git/commands/speckit.git.validate.md +49 -0
- package/.specify/extensions/git/config-template.yml +62 -0
- package/.specify/extensions/git/extension.yml +140 -0
- package/.specify/extensions/git/git-config.yml +62 -0
- package/.specify/extensions.yml +149 -0
- package/.specify/feature.json +3 -0
- package/.specify/init-options.json +10 -0
- package/.specify/integration.json +15 -0
- package/.specify/integrations/claude.manifest.json +16 -0
- package/.specify/integrations/speckit.manifest.json +17 -0
- package/.specify/memory/constitution.md +162 -0
- package/.specify/templates/checklist-template.md +40 -0
- package/.specify/templates/constitution-template.md +50 -0
- package/.specify/templates/plan-template.md +113 -0
- package/.specify/templates/spec-template.md +131 -0
- package/.specify/templates/tasks-template.md +252 -0
- package/.specify/workflows/speckit/workflow.yml +77 -0
- package/.specify/workflows/workflow-registry.json +13 -0
- package/AGENTS.md +94 -0
- package/Dockerfile +3 -3
- package/FOLLOWUPS.md +34 -0
- package/README.md +9 -7
- package/SUMMARY.md +30 -5
- package/VALUES.md +53 -0
- package/build.schema.json +542 -408
- package/dist/cache/auto-pull.spec.js +123 -0
- package/dist/cache/backends/local-cache-backend.js +56 -0
- package/dist/cache/backends/local-cache-backend.spec.js +72 -0
- package/dist/cache/backends/s3-cache-backend.js +124 -0
- package/dist/cache/backends/s3-cache-backend.spec.js +118 -0
- package/dist/cache/cache-backend-registry.js +21 -0
- package/dist/cache/cache-backend-registry.spec.js +22 -0
- package/dist/cache/cache-backend.js +3 -0
- package/dist/cache/resolve-cache.js +60 -0
- package/dist/cache/resolve-cache.spec.js +52 -0
- package/dist/cli.js +112 -82
- package/dist/cli.spec.js +20 -2
- package/dist/console/get-logger.spec.js +23 -0
- package/dist/docker/get-default-platform.spec.js +29 -0
- package/dist/docker/longest-common-prefix.spec.js +26 -0
- package/dist/docker/package.js +283 -0
- package/dist/docker/package.spec.js +145 -0
- package/dist/docker/pull.js +4 -4
- package/dist/docker/remove-container.spec.js +32 -0
- package/dist/docker/stream.js +3 -3
- package/dist/docker/using-container.js +29 -11
- package/dist/docker/using-container.spec.js +90 -0
- package/dist/environment/merge-environment-variables.js +21 -0
- package/dist/environment/merge-environment-variables.spec.js +24 -0
- package/dist/environment/replace-env-variables.js +43 -10
- package/dist/environment/replace-env-variables.spec.js +47 -0
- package/dist/executer/abort.spec.js +18 -0
- package/dist/executer/await-completed-dependencies.js +56 -0
- package/dist/executer/cache-metadata.js +11 -0
- package/dist/executer/check-readiness.js +1 -1
- package/dist/{planner/work-node-port.js → executer/container-bind.js} +1 -1
- package/dist/executer/docker-service.js +110 -86
- package/dist/executer/docker-task.js +132 -0
- package/dist/executer/environment-mock.js +3 -4
- package/dist/executer/environment-mock.spec.js +22 -0
- package/dist/executer/event-cache.js +60 -127
- package/dist/executer/execute-command.js +4 -3
- package/dist/executer/execute-docker.js +32 -14
- package/dist/executer/execute-work-service.js +61 -0
- package/dist/executer/execute-work-task.js +107 -0
- package/dist/executer/execute-work-tree.js +27 -0
- package/dist/executer/execute.spec.js +14 -10
- package/dist/executer/execution-steps.js +47 -31
- package/dist/executer/get-container-binds.js +19 -0
- package/dist/executer/get-docker-executor.js +12 -12
- package/dist/executer/get-scheduler-down-result.js +12 -0
- package/dist/executer/get-scheduler-execute-result.js +28 -0
- package/dist/executer/get-scheduler-up-result.js +12 -0
- package/dist/executer/get-service-containers.js +14 -0
- package/dist/executer/get-service-containers.spec.js +59 -0
- package/dist/executer/get-service-env-hints.js +35 -0
- package/dist/executer/get-service-env-hints.spec.js +65 -0
- package/dist/executer/kubernetes-service.js +116 -48
- package/dist/executer/label-values.js +29 -46
- package/dist/executer/label-values.spec.js +61 -0
- package/dist/executer/lazy-resolver.js +16 -0
- package/dist/executer/lazy-resolver.spec.js +20 -0
- package/dist/executer/local-task.js +44 -0
- package/dist/executer/process-manager.js +16 -70
- package/dist/executer/process-manager.spec.js +39 -76
- package/dist/executer/reset-work-tree.js +30 -0
- package/dist/executer/scheduler/check-for-loop.js +17 -7
- package/dist/executer/scheduler/{scheduler-state.js → dependency-state.js} +1 -1
- package/dist/executer/scheduler/enqueue-next.js +83 -19
- package/dist/executer/scheduler/enqueue-next.spec.js +136 -0
- package/dist/executer/scheduler/{node-state.js → need-state.js} +1 -1
- package/dist/{parser/build-file.js → executer/scheduler/task-state.js} +1 -1
- package/dist/executer/set-user-permission.js +1 -1
- package/dist/executer/state-resolver.js +61 -0
- package/dist/executer/state-resolver.spec.js +37 -0
- package/dist/executer/state.js +37 -31
- package/dist/executer/state.spec.js +66 -0
- package/dist/executer/states.spec.js +14 -0
- package/dist/executer/watch-loop.js +68 -0
- package/dist/executer/watch-state-key.js +44 -0
- package/dist/executer/work-scope.js +1 -5
- package/dist/file/get-file-context.js +24 -3
- package/dist/file/get-file-context.spec.js +178 -0
- package/dist/file/move-files.js +2 -2
- package/dist/file/move-files.spec.js +48 -0
- package/dist/index.js +7 -8
- package/dist/json-schema.js +12 -0
- package/dist/kubernetes/apply.js +34 -0
- package/dist/kubernetes/await-running-state.js +71 -0
- package/dist/kubernetes/ensure-http-route.js +53 -0
- package/dist/kubernetes/ensure-http-route.spec.js +70 -0
- package/dist/kubernetes/ensure-ingress.js +54 -0
- package/dist/kubernetes/ensure-kubernetes-deployment-exists.js +105 -0
- package/dist/kubernetes/ensure-kubernetes-persistent-volume-claim-exists.js +40 -0
- package/dist/kubernetes/ensure-kubernetes-service-exists.js +36 -0
- package/dist/kubernetes/ensure-namespace.js +43 -0
- package/dist/kubernetes/ensure-namespace.spec.js +39 -0
- package/dist/kubernetes/ensure-persistent-data.js +158 -0
- package/dist/kubernetes/get-service-ip.js +11 -0
- package/dist/kubernetes/kubernetes-instance.js +48 -0
- package/dist/kubernetes/remove-persistent-data.js +19 -0
- package/dist/kubernetes/resolve-pod-name.js +42 -0
- package/dist/kubernetes/resolve-pod-name.spec.js +81 -0
- package/dist/kubernetes/resources.js +12 -0
- package/dist/kubernetes/restore-kubernetes-data.js +42 -0
- package/dist/kubernetes/store-kubernetes-data.js +39 -0
- package/dist/kubernetes/volumes.js +64 -0
- package/dist/log.js +69 -69
- package/dist/log.spec.js +131 -0
- package/dist/logging/grouped-logger.js +17 -15
- package/dist/logging/grouped-logger.spec.js +84 -0
- package/dist/logging/interactive-logger.js +1 -1
- package/dist/logging/interactive-logger.spec.js +57 -0
- package/dist/logging/live-logger.js +2 -2
- package/dist/logging/live-logger.spec.js +37 -0
- package/dist/logging/loggers.spec.js +154 -0
- package/dist/optimizer/calculate-checksum.spec.js +34 -0
- package/dist/optimizer/get-cache-directory.js +6 -6
- package/dist/optimizer/get-cache-directory.spec.js +59 -0
- package/dist/optimizer/get-work-cache-stats.js +53 -0
- package/dist/optimizer/get-work-cache-stats.spec.js +79 -0
- package/dist/{parser/build-file-task.js → optimizer/work-cache-stats.js} +1 -1
- package/dist/optimizer/work-task-cache-description.js +25 -0
- package/dist/optimizer/work-task-cache-description.spec.js +45 -0
- package/dist/parser/default-build-file.js +14 -7
- package/dist/parser/default-build-file.spec.js +48 -0
- package/dist/parser/parse-label-arguments.spec.js +27 -0
- package/dist/parser/read-build-file.js +2 -13
- package/dist/parser/read-build-file.spec.js +89 -0
- package/dist/parser/read-env-file.js +4 -5
- package/dist/parser/read-env-file.spec.js +42 -0
- package/dist/planner/utils/append-work-dependencies.js +55 -0
- package/dist/planner/utils/append-work-environment.js +22 -0
- package/dist/planner/utils/append-work-needs.js +18 -0
- package/dist/planner/utils/append-work-service.js +107 -0
- package/dist/planner/utils/append-work-service.spec.js +71 -0
- package/dist/planner/utils/append-work-task.js +81 -0
- package/dist/planner/utils/get-container-user.js +14 -0
- package/dist/planner/utils/get-container-user.spec.js +30 -0
- package/dist/planner/utils/get-default-kube-config.js +10 -0
- package/dist/planner/utils/get-default-kube-config.spec.js +11 -0
- package/dist/planner/utils/get-work-runtime.js +44 -0
- package/dist/planner/utils/normalize-path.js +1 -1
- package/dist/planner/utils/normalize-path.spec.js +24 -0
- package/dist/planner/utils/parse-work-command.js +80 -0
- package/dist/planner/utils/parse-work-command.spec.js +21 -0
- package/dist/planner/utils/parse-work-generate.js +38 -0
- package/dist/planner/utils/parse-work-generate.spec.js +45 -0
- package/dist/planner/utils/{parse-work-node-mount.js → parse-work-mount.js} +10 -7
- package/dist/planner/utils/{parse-work-node-mount.spec.js → parse-work-mount.spec.js} +14 -11
- package/dist/planner/utils/parse-work-mounts.js +13 -0
- package/dist/planner/utils/parse-work-mounts.spec.js +19 -0
- package/dist/planner/utils/{parse-work-node-port.js → parse-work-port.js} +11 -8
- package/dist/planner/utils/parse-work-port.spec.js +24 -0
- package/dist/planner/utils/parse-work-ports.js +10 -0
- package/dist/planner/utils/parse-work-ports.spec.js +24 -0
- package/dist/planner/utils/parse-work-source.js +72 -0
- package/dist/planner/utils/parse-work-source.spec.js +58 -0
- package/dist/planner/utils/parse-work-volume.js +45 -0
- package/dist/planner/utils/parse-work-volume.spec.js +18 -0
- package/dist/planner/utils/plan-work-tasks.js +41 -0
- package/dist/planner/utils/plan-work-tasks.spec.js +30 -0
- package/dist/planner/utils/plan-work-volume.js +1 -0
- package/dist/planner/utils/plan-work-volume.spec.js +33 -0
- package/dist/planner/utils/split-name.js +2 -2
- package/dist/planner/utils/split-name.spec.js +16 -0
- package/dist/planner/utils/template-value.js +1 -2
- package/dist/planner/utils/template-value.spec.js +14 -0
- package/dist/planner/validate.js +71 -38
- package/dist/planner/validate.spec.js +251 -0
- package/dist/planner/work-cache-id.js +12 -0
- package/dist/planner/work-cache-id.spec.js +173 -0
- package/dist/planner/work-command.js +3 -0
- package/dist/planner/work-environment.js +3 -0
- package/dist/planner/work-healthcheck.js +3 -0
- package/dist/planner/{work-node-status.js → work-item-status.js} +16 -62
- package/dist/{parser/build-file-service.js → planner/work-item-validation.js} +1 -1
- package/dist/planner/work-item.js +16 -0
- package/dist/{optimizer/work-node-cache-stats.js → planner/work-kubernetes-selector.js} +1 -1
- package/dist/planner/{work-nodes.js → work-port.js} +1 -1
- package/dist/planner/work-runtime-docker.js +224 -0
- package/dist/planner/work-runtime-kubernetes.js +264 -0
- package/dist/planner/work-runtime-local.js +109 -0
- package/dist/planner/work-runtime-local.spec.js +193 -0
- package/dist/planner/work-service-id.js +15 -5
- package/dist/planner/work-source.js +3 -0
- package/dist/planner/work-task.js +8 -0
- package/dist/program-commands.spec.js +84 -0
- package/dist/program.js +219 -73
- package/dist/program.spec.js +34 -11
- package/dist/run-program.js +28 -0
- package/dist/{executer/process.js → runtime/runtime.js} +1 -1
- package/dist/schema/build-file-base-task-schema.js +27 -0
- package/dist/schema/build-file-container-service-schema.js +28 -0
- package/dist/schema/build-file-container-task-schema.js +13 -0
- package/dist/schema/build-file-environment-schema-ingress.js +14 -0
- package/dist/schema/build-file-environment-schema.js +23 -0
- package/dist/schema/build-file-kubernetes-service-schema.js +17 -0
- package/dist/schema/build-file-kubernetes-service-selector-schema.js +9 -0
- package/dist/schema/build-file-local-platform-schema.js +9 -0
- package/dist/schema/build-file-local-task-schema.js +12 -0
- package/dist/schema/build-file-need-schema.js +12 -0
- package/dist/schema/build-file-schema.js +23 -0
- package/dist/schema/build-file-schema.spec.js +61 -0
- package/dist/schema/build-file-service-container-healthcheck.js +8 -0
- package/dist/schema/build-file-service-schema.js +15 -0
- package/dist/schema/build-file-task-command-schema.js +12 -0
- package/dist/schema/build-file-task-schema.js +12 -0
- package/dist/schema/build-file-volume-schema.js +14 -0
- package/dist/schema/cache-schema.js +31 -0
- package/dist/schema/doc-build-files.spec.js +223 -0
- package/dist/schema/envs-schema.js +6 -0
- package/dist/schema/labels-schema.js +6 -0
- package/dist/schema/parse-context.js +3 -0
- package/dist/schema/parse-error.js +12 -0
- package/dist/schema/parse-error.spec.js +18 -0
- package/dist/schema/reference-parser.js +209 -0
- package/dist/schema/reference-parser.spec.js +83 -0
- package/dist/schema/schema-parser.js +66 -0
- package/dist/schema/schema-parser.spec.js +80 -0
- package/dist/schema/type-guards.spec.js +23 -0
- package/dist/schema/work-scope-parser.js +77 -0
- package/dist/schema/work-scope-parser.spec.js +66 -0
- package/dist/service/update-service-status.js +11 -0
- package/dist/service/update-service-status.spec.js +27 -0
- package/dist/testing/ensure-local-registry.js +134 -0
- package/dist/testing/example-test-suite.js +16 -18
- package/dist/testing/expect.js +46 -22
- package/dist/testing/http-get.js +21 -0
- package/dist/testing/integration/cache.spec.js +13 -14
- package/dist/testing/integration/cancellation.spec.js +14 -9
- package/dist/testing/integration/clean.spec.js +14 -11
- package/dist/testing/integration/cmd.spec.js +1 -1
- package/dist/testing/integration/concurrency.spec.js +3 -3
- package/dist/testing/integration/docker-package-registry.spec.js +44 -0
- package/dist/testing/integration/docker-service-crash.spec.js +36 -0
- package/dist/testing/integration/docker.spec.js +4 -3
- package/dist/testing/integration/env.spec.js +9 -8
- package/dist/testing/integration/environment.spec.js +97 -0
- package/dist/testing/integration/error.spec.js +5 -4
- package/dist/testing/integration/export.spec.js +22 -0
- package/dist/testing/integration/extend.spec.js +9 -12
- package/dist/testing/integration/glob.spec.js +12 -20
- package/dist/testing/integration/include.spec.js +3 -3
- package/dist/testing/integration/invalid.spec.js +2 -3
- package/dist/testing/integration/invalid_loop.spec.js +49 -6
- package/dist/testing/integration/k8s-state-cache.spec.js +41 -0
- package/dist/testing/integration/kubernetes-service.spec.js +148 -0
- package/dist/testing/integration/kubernetes.spec.js +93 -9
- package/dist/testing/integration/labels.spec.js +6 -11
- package/dist/testing/integration/local.spec.js +1 -1
- package/dist/testing/integration/monorepo.spec.js +4 -4
- package/dist/testing/integration/multi-line.spec.js +3 -3
- package/dist/testing/integration/reference.spec.js +4 -5
- package/dist/testing/integration/services.spec.js +22 -4
- package/dist/testing/integration/store.spec.js +15 -16
- package/dist/testing/integration/unknown.spec.js +20 -18
- package/dist/testing/integration/validate.spec.js +143 -26
- package/dist/testing/integration/watch-dependency.spec.js +11 -8
- package/dist/testing/integration/watch.spec.js +15 -16
- package/dist/testing/requires-kubernetes.js +18 -0
- package/dist/testing/requires-linux-containers.js +18 -0
- package/dist/testing/requires-windows-containers.js +18 -0
- package/dist/testing/test-case.js +75 -0
- package/dist/testing/test-streams.js +28 -0
- package/dist/testing/testing-timeout.js +32 -0
- package/dist/utils/abort-event.js +10 -4
- package/dist/utils/abort-event.spec.js +46 -0
- package/dist/utils/buffer-context.js +44 -0
- package/dist/utils/buffer-context.spec.js +38 -0
- package/dist/utils/ci.spec.js +53 -0
- package/dist/utils/emitter.spec.js +34 -0
- package/dist/utils/empty-writable.spec.js +18 -0
- package/dist/utils/environment-config.js +4 -1
- package/dist/utils/environment-config.spec.js +26 -0
- package/dist/utils/fail-never.spec.js +9 -0
- package/dist/version.js +9 -0
- package/dist/version.spec.js +12 -0
- package/package.json +41 -23
- package/specs/build-file/caches/spec.md +114 -0
- package/specs/build-file/environment-variables/spec.md +82 -0
- package/specs/build-file/includes/spec.md +60 -0
- package/specs/build-file/references/spec.md +56 -0
- package/specs/build-file/spec.md +62 -0
- package/specs/cli/clean/spec.md +85 -0
- package/specs/cli/down/spec.md +85 -0
- package/specs/cli/execute/spec.md +101 -0
- package/specs/cli/init/spec.md +64 -0
- package/specs/cli/ls/spec.md +66 -0
- package/specs/cli/package/spec.md +110 -0
- package/specs/cli/spec.md +73 -0
- package/specs/cli/store-restore/spec.md +74 -0
- package/specs/cli/up/spec.md +80 -0
- package/specs/cli/validate/spec.md +70 -0
- package/specs/labels/spec.md +91 -0
- package/specs/service/container/spec.md +120 -0
- package/specs/service/kubernetes/spec.md +97 -0
- package/specs/service/spec.md +105 -0
- package/specs/task/caching/spec.md +107 -0
- package/specs/task/container/spec.md +118 -0
- package/specs/task/dependencies/spec.md +70 -0
- package/specs/task/extending/spec.md +74 -0
- package/specs/task/kubernetes/spec.md +125 -0
- package/specs/task/needs/spec.md +59 -0
- package/specs/task/spec.md +87 -0
- package/specs/task/watching/spec.md +69 -0
- package/dist/console/console-context-mock.js +0 -14
- package/dist/environment/get-process-env.js +0 -15
- package/dist/executer/create-scheduler-state.js +0 -32
- package/dist/executer/docker-node.js +0 -123
- package/dist/executer/hierarchy-scheduler.js +0 -94
- package/dist/executer/local-node.js +0 -57
- package/dist/executer/schedule.js +0 -137
- package/dist/executer/start-node.js +0 -67
- package/dist/executer/watch-node.js +0 -56
- package/dist/executer/watch-service.js +0 -54
- package/dist/file/get-file-context-mock.js +0 -187
- package/dist/file/get-file-context-mock.spec.js +0 -56
- package/dist/get-work-context.js +0 -29
- package/dist/optimizer/get-work-node-cache-stats.js +0 -104
- package/dist/optimizer/read-work-node-cache.js +0 -19
- package/dist/optimizer/work-node-cache-description.js +0 -32
- package/dist/optimizer/write-work-node-cache.js +0 -21
- package/dist/parser/build-file-task-command.js +0 -3
- package/dist/parser/build-file-task-platform.js +0 -3
- package/dist/parser/build-file-task-source.js +0 -3
- package/dist/parser/get-build-file.js +0 -9
- package/dist/parser/parse-boolean.js +0 -29
- package/dist/parser/parse-boolean.spec.js +0 -48
- package/dist/parser/parse-build-file-references.js +0 -35
- package/dist/parser/parse-build-file-services.js +0 -58
- package/dist/parser/parse-build-file-task-command.js +0 -36
- package/dist/parser/parse-build-file-task-source.js +0 -63
- package/dist/parser/parse-build-file.js +0 -125
- package/dist/parser/parse-context.js +0 -13
- package/dist/parser/parse-envs.js +0 -29
- package/dist/parser/parse-healthcheck.js +0 -28
- package/dist/parser/parse-service-selector.js +0 -39
- package/dist/parser/parse-string-array.js +0 -20
- package/dist/parser/parse-string-map.js +0 -30
- package/dist/parser/parse-string.js +0 -20
- package/dist/planner/utils/get-container-mounts.js +0 -24
- package/dist/planner/utils/parse-work-service-volume.js +0 -23
- package/dist/planner/utils/plan-work-command.js +0 -21
- package/dist/planner/utils/plan-work-dependency.js +0 -36
- package/dist/planner/utils/plan-work-node.js +0 -293
- package/dist/planner/utils/plan-work-nodes.js +0 -78
- package/dist/planner/utils/plan-work-tree.js +0 -15
- package/dist/planner/work-context.js +0 -23
- package/dist/planner/work-node-command.js +0 -3
- package/dist/planner/work-node-id.js +0 -12
- package/dist/planner/work-node-id.spec.js +0 -106
- package/dist/planner/work-node-path.js +0 -2
- package/dist/planner/work-node-source.js +0 -3
- package/dist/planner/work-node-validation.js +0 -3
- package/dist/planner/work-node.js +0 -8
- package/dist/planner/work-service-volume.js +0 -3
- package/dist/planner/work-services.js +0 -3
- package/dist/start-watch-processes.js +0 -28
- package/dist/testing/cli.js +0 -73
- package/dist/testing/create-build-file.js +0 -9
- package/dist/testing/get-logger.js +0 -23
- package/dist/testing/get-node.js +0 -12
- package/dist/testing/get-test-context.js +0 -19
- package/dist/testing/integration/program.spec.js +0 -25
- package/dist/testing/lazy.js +0 -17
- package/dist/testing/start-watch-processes.js +0 -29
- package/dist/testing/test-suite-options.js +0 -3
- package/dist/utils/abortable-function.js +0 -71
- package/logs/cache-console.log +0 -0
- package/logs/cache-status.log +0 -6
- package/logs/cache-stout.log +0 -0
- package/logs/cancellation-console.log +0 -0
- package/logs/cancellation-status.log +0 -3
- package/logs/cancellation-stout.log +0 -3
- package/logs/clean-console.log +0 -0
- package/logs/clean-status.log +0 -37
- package/logs/clean-stout.log +0 -95
- package/logs/cmd-console.log +0 -0
- package/logs/cmd-status.log +0 -8
- package/logs/cmd-stout.log +0 -9
- package/logs/concurrency-console.log +0 -0
- package/logs/concurrency-status.log +0 -14
- package/logs/concurrency-stout.log +0 -88
- package/logs/docker-console.log +0 -0
- package/logs/docker-status.log +0 -14
- package/logs/docker-stout.log +0 -39
- package/logs/env-console.log +0 -1
- package/logs/env-status.log +0 -1
- package/logs/env-stout.log +0 -0
- package/logs/error-console.log +0 -0
- package/logs/error-status.log +0 -10
- package/logs/error-stout.log +0 -36
- package/logs/extend-console.log +0 -0
- package/logs/extend-status.log +0 -1
- package/logs/extend-stout.log +0 -0
- package/logs/glob-console.log +0 -28
- package/logs/glob-status.log +0 -23
- package/logs/glob-stout.log +0 -52
- package/logs/hello-world-node-console.log +0 -0
- package/logs/hello-world-node-status.log +0 -37
- package/logs/hello-world-node-stout.log +0 -41
- package/logs/include-console.log +0 -0
- package/logs/include-status.log +0 -3
- package/logs/include-stout.log +0 -0
- package/logs/invalid-console.log +0 -0
- package/logs/invalid-status.log +0 -1
- package/logs/invalid-stout.log +0 -0
- package/logs/invalid_loop-console.log +0 -0
- package/logs/invalid_loop-status.log +0 -1
- package/logs/invalid_loop-stout.log +0 -11
- package/logs/labels-console.log +0 -0
- package/logs/labels-status.log +0 -1
- package/logs/labels-stout.log +0 -0
- package/logs/local-console.log +0 -0
- package/logs/local-status.log +0 -7
- package/logs/local-stout.log +0 -8
- package/logs/monorepo-console.log +0 -0
- package/logs/monorepo-status.log +0 -152
- package/logs/monorepo-stout.log +0 -2354
- package/logs/multi-line-console.log +0 -0
- package/logs/multi-line-status.log +0 -1
- package/logs/multi-line-stout.log +0 -0
- package/logs/reference-console.log +0 -0
- package/logs/reference-status.log +0 -5
- package/logs/reference-stout.log +0 -0
- package/logs/services-console.log +0 -0
- package/logs/services-status.log +0 -129
- package/logs/services-stout.log +0 -639
- package/logs/store-restore-console.log +0 -0
- package/logs/store-restore-status.log +0 -40
- package/logs/store-restore-stout.log +0 -97
- package/logs/unknown-console.log +0 -3
- package/logs/unknown-status.log +0 -1
- package/logs/unknown-stout.log +0 -0
- package/logs/validate-console.log +0 -0
- package/logs/validate-status.log +0 -2
- package/logs/validate-stout.log +0 -0
- package/logs/watch-console.log +0 -0
- package/logs/watch-dependency-console.log +0 -0
- package/logs/watch-dependency-status.log +0 -176
- package/logs/watch-dependency-stout.log +0 -779
- package/logs/watch-status.log +0 -100
- package/logs/watch-stout.log +0 -349
package/dist/planner/validate.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkIfContextExists = exports.
|
|
3
|
+
exports.checkIfContextExists = exports.hasDependencyCycle = exports.hasNeedCycle = exports.hasMixedCycle = exports.validate = void 0;
|
|
4
4
|
const read_build_file_1 = require("../parser/read-build-file");
|
|
5
|
+
const plan_work_tasks_1 = require("./utils/plan-work-tasks");
|
|
5
6
|
async function* validate(workTree, context) {
|
|
6
|
-
const
|
|
7
|
-
for (const
|
|
7
|
+
const cycleItems = [];
|
|
8
|
+
for (const item of (0, plan_work_tasks_1.iterateWorkServices)(workTree)) {
|
|
9
|
+
const service = item.data;
|
|
8
10
|
if (!service.description) {
|
|
9
|
-
yield { type: 'warn', message: `missing description`,
|
|
11
|
+
yield { type: 'warn', message: `missing description`, item: service };
|
|
10
12
|
}
|
|
11
13
|
if (service.type === 'container-service') {
|
|
12
14
|
if (!service.healthcheck) {
|
|
13
|
-
yield { type: 'warn', message: 'missing healthcheck',
|
|
15
|
+
yield { type: 'warn', message: 'missing healthcheck', item: service };
|
|
14
16
|
}
|
|
15
17
|
for (const mount of service.mounts) {
|
|
16
18
|
if (!(await context.file.exists(mount.localPath))) {
|
|
17
19
|
yield {
|
|
18
20
|
type: 'warn',
|
|
19
21
|
message: `mount ${mount.localPath} does not exist`,
|
|
20
|
-
|
|
22
|
+
item: service,
|
|
21
23
|
};
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -27,71 +29,102 @@ async function* validate(workTree, context) {
|
|
|
27
29
|
yield {
|
|
28
30
|
type: 'warn',
|
|
29
31
|
message: `kubeconfig ${service.kubeconfig} does not exist`,
|
|
30
|
-
|
|
32
|
+
item: service,
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
35
|
else if (!(await checkIfContextExists(service, context))) {
|
|
34
36
|
yield {
|
|
35
37
|
type: 'warn',
|
|
36
38
|
message: `context ${service.context} does not exist in kubeconfig ${service.kubeconfig}`,
|
|
37
|
-
|
|
39
|
+
item: service,
|
|
38
40
|
};
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
|
-
for (const key of Object.keys(service.buildService.unknownProps)) {
|
|
42
|
-
yield {
|
|
43
|
-
type: 'warn',
|
|
44
|
-
message: `${key} is an unknown configuration`,
|
|
45
|
-
node: service,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
43
|
}
|
|
49
|
-
for (const
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
for (const item of (0, plan_work_tasks_1.iterateWorkTasks)(workTree)) {
|
|
45
|
+
const task = item.data;
|
|
46
|
+
if (!task.description) {
|
|
47
|
+
yield { type: 'warn', message: `missing description`, item: task };
|
|
52
48
|
}
|
|
53
|
-
if ((!
|
|
54
|
-
yield { type: 'warn', message: `task is empty`,
|
|
49
|
+
if ((!task.cmds || task.cmds.length === 0) && (!item.deps || item.deps.length === 0)) {
|
|
50
|
+
yield { type: 'warn', message: `task is empty`, item: task };
|
|
55
51
|
}
|
|
56
|
-
for (const src of
|
|
52
|
+
for (const src of task.src) {
|
|
57
53
|
if (!(await context.file.exists(src.absolutePath))) {
|
|
58
54
|
yield {
|
|
59
55
|
type: 'warn',
|
|
60
56
|
message: `src ${src.absolutePath} does not exist`,
|
|
61
|
-
|
|
57
|
+
item: task,
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
60
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
61
|
+
if (cycleItems.indexOf(item) === -1) {
|
|
62
|
+
const cyclePath = hasDependencyCycle(item, []);
|
|
63
|
+
if (cyclePath) {
|
|
64
|
+
cycleItems.push(...cyclePath);
|
|
65
|
+
yield { type: 'error', message: `task cycle detected ${cyclePath.map((n) => n.name).join(' -> ')}`, item: task };
|
|
66
|
+
}
|
|
71
67
|
}
|
|
72
|
-
if (
|
|
73
|
-
const cyclePath =
|
|
68
|
+
if (cycleItems.indexOf(item) === -1) {
|
|
69
|
+
const cyclePath = hasMixedCycle(item, []);
|
|
74
70
|
if (cyclePath) {
|
|
75
|
-
|
|
76
|
-
yield {
|
|
71
|
+
cycleItems.push(...cyclePath);
|
|
72
|
+
yield {
|
|
73
|
+
type: 'error',
|
|
74
|
+
message: `cycle detected across deps/needs ${cyclePath.map((n) => n.name).join(' -> ')}`,
|
|
75
|
+
item: task,
|
|
76
|
+
};
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
exports.validate = validate;
|
|
82
|
-
function
|
|
83
|
-
if (currentPath.indexOf(
|
|
84
|
-
return [...currentPath,
|
|
82
|
+
function hasMixedCycle(item, currentPath) {
|
|
83
|
+
if (currentPath.indexOf(item) >= 0) {
|
|
84
|
+
return [...currentPath, item];
|
|
85
|
+
}
|
|
86
|
+
const nextPath = [...currentPath, item];
|
|
87
|
+
for (const dep of item.deps) {
|
|
88
|
+
const cycle = hasMixedCycle(dep, nextPath);
|
|
89
|
+
if (cycle) {
|
|
90
|
+
return cycle;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for (const need of item.needs) {
|
|
94
|
+
const cycle = hasMixedCycle(need.service, nextPath);
|
|
95
|
+
if (cycle) {
|
|
96
|
+
return cycle;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
exports.hasMixedCycle = hasMixedCycle;
|
|
102
|
+
function hasNeedCycle(item, currentPath) {
|
|
103
|
+
if (currentPath.indexOf(item) >= 0) {
|
|
104
|
+
return [...currentPath, item];
|
|
105
|
+
}
|
|
106
|
+
for (const dep of item.needs) {
|
|
107
|
+
const depHasCycle = hasNeedCycle(dep.service, [...currentPath, item]);
|
|
108
|
+
if (depHasCycle) {
|
|
109
|
+
return depHasCycle;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
exports.hasNeedCycle = hasNeedCycle;
|
|
115
|
+
function hasDependencyCycle(item, currentPath) {
|
|
116
|
+
if (currentPath.indexOf(item) >= 0) {
|
|
117
|
+
return [...currentPath, item];
|
|
85
118
|
}
|
|
86
|
-
for (const dep of
|
|
87
|
-
const depHasCycle =
|
|
119
|
+
for (const dep of item.deps) {
|
|
120
|
+
const depHasCycle = hasDependencyCycle(dep, [...currentPath, item]);
|
|
88
121
|
if (depHasCycle) {
|
|
89
122
|
return depHasCycle;
|
|
90
123
|
}
|
|
91
124
|
}
|
|
92
125
|
return null;
|
|
93
126
|
}
|
|
94
|
-
exports.
|
|
127
|
+
exports.hasDependencyCycle = hasDependencyCycle;
|
|
95
128
|
async function checkIfContextExists(service, context) {
|
|
96
129
|
const kubeconfig = await (0, read_build_file_1.read)(service.kubeconfig, context);
|
|
97
130
|
if (kubeconfig.contexts && kubeconfig.contexts instanceof Array) {
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const validate_1 = require("./validate");
|
|
4
|
+
function makeTask(name) {
|
|
5
|
+
const item = {
|
|
6
|
+
id: () => name,
|
|
7
|
+
name,
|
|
8
|
+
status: {},
|
|
9
|
+
data: { type: 'local-task', name },
|
|
10
|
+
needs: [],
|
|
11
|
+
deps: [],
|
|
12
|
+
requiredBy: [],
|
|
13
|
+
state: {},
|
|
14
|
+
runtime: {},
|
|
15
|
+
};
|
|
16
|
+
return item;
|
|
17
|
+
}
|
|
18
|
+
function makeService(name) {
|
|
19
|
+
const item = {
|
|
20
|
+
id: () => name,
|
|
21
|
+
name,
|
|
22
|
+
status: {},
|
|
23
|
+
data: { type: 'container-service', name },
|
|
24
|
+
needs: [],
|
|
25
|
+
deps: [],
|
|
26
|
+
requiredBy: [],
|
|
27
|
+
state: {},
|
|
28
|
+
runtime: {},
|
|
29
|
+
};
|
|
30
|
+
return item;
|
|
31
|
+
}
|
|
32
|
+
describe('validate', () => {
|
|
33
|
+
describe('hasDependencyCycle', () => {
|
|
34
|
+
it('returns null for an item with no deps', () => {
|
|
35
|
+
const t = makeTask('a');
|
|
36
|
+
expect((0, validate_1.hasDependencyCycle)(t, [])).toBeNull();
|
|
37
|
+
});
|
|
38
|
+
it('returns null for a linear chain', () => {
|
|
39
|
+
const a = makeTask('a');
|
|
40
|
+
const b = makeTask('b');
|
|
41
|
+
const c = makeTask('c');
|
|
42
|
+
a.deps.push(b);
|
|
43
|
+
b.deps.push(c);
|
|
44
|
+
expect((0, validate_1.hasDependencyCycle)(a, [])).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
it('detects a direct self-cycle', () => {
|
|
47
|
+
const a = makeTask('a');
|
|
48
|
+
a.deps.push(a);
|
|
49
|
+
const cycle = (0, validate_1.hasDependencyCycle)(a, []);
|
|
50
|
+
expect(cycle).not.toBeNull();
|
|
51
|
+
expect(cycle.map((i) => i.name)).toEqual(['a', 'a']);
|
|
52
|
+
});
|
|
53
|
+
it('detects an indirect cycle', () => {
|
|
54
|
+
const a = makeTask('a');
|
|
55
|
+
const b = makeTask('b');
|
|
56
|
+
const c = makeTask('c');
|
|
57
|
+
a.deps.push(b);
|
|
58
|
+
b.deps.push(c);
|
|
59
|
+
c.deps.push(a);
|
|
60
|
+
const cycle = (0, validate_1.hasDependencyCycle)(a, []);
|
|
61
|
+
expect(cycle).not.toBeNull();
|
|
62
|
+
expect(cycle.map((i) => i.name)).toEqual(['a', 'b', 'c', 'a']);
|
|
63
|
+
});
|
|
64
|
+
it('does not flag a diamond as a cycle', () => {
|
|
65
|
+
const root = makeTask('root');
|
|
66
|
+
const left = makeTask('left');
|
|
67
|
+
const right = makeTask('right');
|
|
68
|
+
const leaf = makeTask('leaf');
|
|
69
|
+
root.deps.push(left, right);
|
|
70
|
+
left.deps.push(leaf);
|
|
71
|
+
right.deps.push(leaf);
|
|
72
|
+
expect((0, validate_1.hasDependencyCycle)(root, [])).toBeNull();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
describe('hasNeedCycle', () => {
|
|
76
|
+
it('returns null when no needs', () => {
|
|
77
|
+
const s = makeService('db');
|
|
78
|
+
expect((0, validate_1.hasNeedCycle)(s, [])).toBeNull();
|
|
79
|
+
});
|
|
80
|
+
it('detects a need cycle across services', () => {
|
|
81
|
+
const a = makeService('a');
|
|
82
|
+
const b = makeService('b');
|
|
83
|
+
a.needs.push({ name: 'b', service: b });
|
|
84
|
+
b.needs.push({ name: 'a', service: a });
|
|
85
|
+
const cycle = (0, validate_1.hasNeedCycle)(a, []);
|
|
86
|
+
expect(cycle).not.toBeNull();
|
|
87
|
+
expect(cycle.map((i) => i.name)).toEqual(['a', 'b', 'a']);
|
|
88
|
+
});
|
|
89
|
+
it('detects a self-need cycle', () => {
|
|
90
|
+
const a = makeService('a');
|
|
91
|
+
a.needs.push({ name: 'a', service: a });
|
|
92
|
+
const cycle = (0, validate_1.hasNeedCycle)(a, []);
|
|
93
|
+
expect(cycle).not.toBeNull();
|
|
94
|
+
expect(cycle.map((i) => i.name)).toEqual(['a', 'a']);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe('hasMixedCycle', () => {
|
|
98
|
+
it('returns null for an acyclic task → service → task chain', () => {
|
|
99
|
+
const t1 = makeTask('build');
|
|
100
|
+
const s = makeService('db');
|
|
101
|
+
const t2 = makeTask('migrate');
|
|
102
|
+
t1.needs.push({ name: 'db', service: s });
|
|
103
|
+
s.deps.push(t2);
|
|
104
|
+
expect((0, validate_1.hasMixedCycle)(t1, [])).toBeNull();
|
|
105
|
+
});
|
|
106
|
+
it('detects a cycle that alternates deps and needs', () => {
|
|
107
|
+
const t = makeTask('api-build');
|
|
108
|
+
const s = makeService('api');
|
|
109
|
+
t.needs.push({ name: 'api', service: s });
|
|
110
|
+
s.deps.push(t);
|
|
111
|
+
const cycle = (0, validate_1.hasMixedCycle)(t, []);
|
|
112
|
+
expect(cycle).not.toBeNull();
|
|
113
|
+
expect(cycle.map((i) => i.name)).toEqual(['api-build', 'api', 'api-build']);
|
|
114
|
+
});
|
|
115
|
+
it('detects a long mixed cycle', () => {
|
|
116
|
+
const a = makeTask('a');
|
|
117
|
+
const b = makeService('b');
|
|
118
|
+
const c = makeTask('c');
|
|
119
|
+
const d = makeService('d');
|
|
120
|
+
a.needs.push({ name: 'b', service: b });
|
|
121
|
+
b.deps.push(c);
|
|
122
|
+
c.needs.push({ name: 'd', service: d });
|
|
123
|
+
d.deps.push(a);
|
|
124
|
+
const cycle = (0, validate_1.hasMixedCycle)(a, []);
|
|
125
|
+
expect(cycle).not.toBeNull();
|
|
126
|
+
expect(cycle.map((i) => i.name)).toEqual(['a', 'b', 'c', 'd', 'a']);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
function taskItem(name, data) {
|
|
131
|
+
const item = {
|
|
132
|
+
id: () => name,
|
|
133
|
+
name,
|
|
134
|
+
status: {},
|
|
135
|
+
data: { type: 'local-task', name, description: 'a task', cmds: [{}], src: [], ...data },
|
|
136
|
+
needs: [],
|
|
137
|
+
deps: [],
|
|
138
|
+
requiredBy: [],
|
|
139
|
+
state: {},
|
|
140
|
+
runtime: {},
|
|
141
|
+
};
|
|
142
|
+
return item;
|
|
143
|
+
}
|
|
144
|
+
function serviceItem(name, data) {
|
|
145
|
+
const item = {
|
|
146
|
+
id: () => name,
|
|
147
|
+
name,
|
|
148
|
+
status: {},
|
|
149
|
+
data: { type: 'container-service', name, description: 'a service', healthcheck: {}, mounts: [], ...data },
|
|
150
|
+
needs: [],
|
|
151
|
+
deps: [],
|
|
152
|
+
requiredBy: [],
|
|
153
|
+
state: {},
|
|
154
|
+
runtime: {},
|
|
155
|
+
};
|
|
156
|
+
return item;
|
|
157
|
+
}
|
|
158
|
+
function workTree(items) {
|
|
159
|
+
return {
|
|
160
|
+
tasks: Object.fromEntries((items.tasks ?? []).map((t) => [t.name, t])),
|
|
161
|
+
services: Object.fromEntries((items.services ?? []).map((s) => [s.name, s])),
|
|
162
|
+
environment: {},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
// Environment whose file.exists only returns true for the listed paths.
|
|
166
|
+
function fakeEnv(existing = []) {
|
|
167
|
+
return { file: { exists: vi.fn(async (p) => existing.includes(p)) } };
|
|
168
|
+
}
|
|
169
|
+
async function collect(gen) {
|
|
170
|
+
const out = [];
|
|
171
|
+
for await (const v of gen) {
|
|
172
|
+
out.push(v);
|
|
173
|
+
}
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
describe('validate (generator)', () => {
|
|
177
|
+
it('warns about a task without a description', async () => {
|
|
178
|
+
const tree = workTree({ tasks: [taskItem('build', { description: null })] });
|
|
179
|
+
const result = await collect((0, validate_1.validate)(tree, fakeEnv()));
|
|
180
|
+
expect(result).toContainEqual(expect.objectContaining({ type: 'warn', message: 'missing description' }));
|
|
181
|
+
});
|
|
182
|
+
it('warns about an empty task (no cmds and no deps)', async () => {
|
|
183
|
+
const tree = workTree({ tasks: [taskItem('noop', { cmds: [] })] });
|
|
184
|
+
const result = await collect((0, validate_1.validate)(tree, fakeEnv()));
|
|
185
|
+
expect(result).toContainEqual(expect.objectContaining({ type: 'warn', message: 'task is empty' }));
|
|
186
|
+
});
|
|
187
|
+
it('warns about a missing src path', async () => {
|
|
188
|
+
const tree = workTree({ tasks: [taskItem('build', { src: [{ absolutePath: '/nope' }] })] });
|
|
189
|
+
const result = await collect((0, validate_1.validate)(tree, fakeEnv([])));
|
|
190
|
+
expect(result).toContainEqual(expect.objectContaining({ type: 'warn', message: 'src /nope does not exist' }));
|
|
191
|
+
});
|
|
192
|
+
it('does not warn when the src path exists', async () => {
|
|
193
|
+
const tree = workTree({ tasks: [taskItem('build', { src: [{ absolutePath: '/yes' }] })] });
|
|
194
|
+
const result = await collect((0, validate_1.validate)(tree, fakeEnv(['/yes'])));
|
|
195
|
+
expect(result.map((r) => r.message)).not.toContain('src /yes does not exist');
|
|
196
|
+
});
|
|
197
|
+
it('emits a cycle error through the generator', async () => {
|
|
198
|
+
const a = taskItem('a', {});
|
|
199
|
+
a.deps.push(a);
|
|
200
|
+
const tree = workTree({ tasks: [a] });
|
|
201
|
+
const result = await collect((0, validate_1.validate)(tree, fakeEnv()));
|
|
202
|
+
expect(result).toContainEqual(expect.objectContaining({ type: 'error', message: 'task cycle detected a -> a' }));
|
|
203
|
+
});
|
|
204
|
+
it('warns about a container service missing a healthcheck', async () => {
|
|
205
|
+
const tree = workTree({ services: [serviceItem('db', { healthcheck: null })] });
|
|
206
|
+
const result = await collect((0, validate_1.validate)(tree, fakeEnv()));
|
|
207
|
+
expect(result).toContainEqual(expect.objectContaining({ type: 'warn', message: 'missing healthcheck' }));
|
|
208
|
+
});
|
|
209
|
+
it('warns about a container service mount that does not exist', async () => {
|
|
210
|
+
const tree = workTree({
|
|
211
|
+
services: [serviceItem('db', { mounts: [{ localPath: '/data' }] })],
|
|
212
|
+
});
|
|
213
|
+
const result = await collect((0, validate_1.validate)(tree, fakeEnv([])));
|
|
214
|
+
expect(result).toContainEqual(expect.objectContaining({ type: 'warn', message: 'mount /data does not exist' }));
|
|
215
|
+
});
|
|
216
|
+
it('warns when a kubernetes service kubeconfig is missing', async () => {
|
|
217
|
+
const tree = workTree({
|
|
218
|
+
services: [
|
|
219
|
+
serviceItem('cluster', {
|
|
220
|
+
type: 'kubernetes-service',
|
|
221
|
+
kubeconfig: '/missing/kubeconfig',
|
|
222
|
+
context: 'prod',
|
|
223
|
+
}),
|
|
224
|
+
],
|
|
225
|
+
});
|
|
226
|
+
const result = await collect((0, validate_1.validate)(tree, fakeEnv([])));
|
|
227
|
+
expect(result).toContainEqual(expect.objectContaining({ type: 'warn', message: 'kubeconfig /missing/kubeconfig does not exist' }));
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
describe('checkIfContextExists', () => {
|
|
231
|
+
function kubeconfigEnv(yaml) {
|
|
232
|
+
return {
|
|
233
|
+
file: { read: vi.fn(async () => yaml) },
|
|
234
|
+
status: { context: () => ({ write: vi.fn() }) },
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const service = { kubeconfig: '/kube/config', context: 'prod' };
|
|
238
|
+
it('is true when the context is present', async () => {
|
|
239
|
+
const env = kubeconfigEnv('contexts:\n - name: prod\n - name: dev\n');
|
|
240
|
+
expect(await (0, validate_1.checkIfContextExists)(service, env)).toBe(true);
|
|
241
|
+
});
|
|
242
|
+
it('is false when the context is absent', async () => {
|
|
243
|
+
const env = kubeconfigEnv('contexts:\n - name: dev\n');
|
|
244
|
+
expect(await (0, validate_1.checkIfContextExists)(service, env)).toBe(false);
|
|
245
|
+
});
|
|
246
|
+
it('is false when there are no contexts', async () => {
|
|
247
|
+
const env = kubeconfigEnv('clusters:\n - name: c1\n');
|
|
248
|
+
expect(await (0, validate_1.checkIfContextExists)(service, env)).toBe(false);
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
//# sourceMappingURL=validate.spec.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWorkTaskId = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const work_task_cache_description_1 = require("../optimizer/work-task-cache-description");
|
|
6
|
+
function getWorkTaskId(task) {
|
|
7
|
+
const description = (0, work_task_cache_description_1.getWorkTaskCacheDescription)(task);
|
|
8
|
+
const jsonData = JSON.stringify(description);
|
|
9
|
+
return (0, crypto_1.createHash)('sha1').update(jsonData).digest('hex');
|
|
10
|
+
}
|
|
11
|
+
exports.getWorkTaskId = getWorkTaskId;
|
|
12
|
+
//# sourceMappingURL=work-cache-id.js.map
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const test_case_1 = require("../testing/test-case");
|
|
4
|
+
const program_1 = require("../program");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
async function compareTasks(first, second, taskName, expectEqual) {
|
|
7
|
+
const testCase = (0, test_case_1.createTestCase)('work-task-id', {
|
|
8
|
+
'first.yaml': first,
|
|
9
|
+
'second.yaml': second,
|
|
10
|
+
});
|
|
11
|
+
await testCase.setup(async (cwd, environment) => {
|
|
12
|
+
const firstCli = await (0, program_1.createCli)((0, path_1.join)(cwd, 'first.yaml'), environment, { taskName });
|
|
13
|
+
const secondCli = await (0, program_1.createCli)((0, path_1.join)(cwd, 'second.yaml'), environment, { taskName });
|
|
14
|
+
const firstTask = firstCli.task(taskName);
|
|
15
|
+
const secondTask = secondCli.task(taskName);
|
|
16
|
+
if (expectEqual) {
|
|
17
|
+
expect(firstTask.id()).toEqual(secondTask.id());
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
expect(firstTask.id()).not.toEqual(secondTask.id());
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
describe('work-cache-id', () => {
|
|
25
|
+
it('should be the same for different mount order', async () => {
|
|
26
|
+
await compareTasks({
|
|
27
|
+
tasks: {
|
|
28
|
+
example: {
|
|
29
|
+
image: 'node',
|
|
30
|
+
mounts: ['$PWD/.npm:/.npm', '$PWD/.config:/.config'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}, {
|
|
34
|
+
tasks: {
|
|
35
|
+
example: {
|
|
36
|
+
image: 'node',
|
|
37
|
+
mounts: ['$PWD/.config:/.config', '$PWD/.npm:/.npm'],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}, 'example', true);
|
|
41
|
+
});
|
|
42
|
+
it('should be the same for different object key order', async () => {
|
|
43
|
+
await compareTasks({
|
|
44
|
+
tasks: {
|
|
45
|
+
example: {
|
|
46
|
+
image: 'node:alpine',
|
|
47
|
+
cmds: ['npm ci'],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
}, {
|
|
51
|
+
tasks: {
|
|
52
|
+
example: {
|
|
53
|
+
cmds: ['npm ci'],
|
|
54
|
+
image: 'node:alpine',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
}, 'example', true);
|
|
58
|
+
});
|
|
59
|
+
it('should be the same with additional description', async () => {
|
|
60
|
+
await compareTasks({
|
|
61
|
+
tasks: {
|
|
62
|
+
example: {
|
|
63
|
+
image: 'node:alpine',
|
|
64
|
+
cmds: ['npm ci'],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
}, {
|
|
68
|
+
tasks: {
|
|
69
|
+
example: {
|
|
70
|
+
image: 'node:alpine',
|
|
71
|
+
cmds: ['npm ci'],
|
|
72
|
+
description: 'should not matter',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
}, 'example', true);
|
|
76
|
+
});
|
|
77
|
+
it('should be not be the same for different images', async () => {
|
|
78
|
+
await compareTasks({
|
|
79
|
+
tasks: {
|
|
80
|
+
example: {
|
|
81
|
+
image: 'node:alpine',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}, {
|
|
85
|
+
tasks: {
|
|
86
|
+
example: {
|
|
87
|
+
image: 'node',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
}, 'example', false);
|
|
91
|
+
});
|
|
92
|
+
it('should be not be the same for different cmd order', async () => {
|
|
93
|
+
await compareTasks({
|
|
94
|
+
tasks: {
|
|
95
|
+
example: {
|
|
96
|
+
cmds: ['npm ci', 'npm run build'],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
}, {
|
|
100
|
+
tasks: {
|
|
101
|
+
example: {
|
|
102
|
+
cmds: ['npm run build', 'npm ci'],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
}, 'example', false);
|
|
106
|
+
});
|
|
107
|
+
it('should be be the same for different env key order', async () => {
|
|
108
|
+
await compareTasks({
|
|
109
|
+
tasks: {
|
|
110
|
+
example: {
|
|
111
|
+
envs: {
|
|
112
|
+
NODE_VERSION: '16.6.0',
|
|
113
|
+
NPM_VERSION: '6.0.0',
|
|
114
|
+
},
|
|
115
|
+
cmds: ['npm ci', 'npm run build'],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
}, {
|
|
119
|
+
tasks: {
|
|
120
|
+
example: {
|
|
121
|
+
envs: {
|
|
122
|
+
NPM_VERSION: '6.0.0',
|
|
123
|
+
NODE_VERSION: '16.6.0',
|
|
124
|
+
},
|
|
125
|
+
cmds: ['npm ci', 'npm run build'],
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}, 'example', true);
|
|
129
|
+
});
|
|
130
|
+
it('should be be the same for deps in different order', async () => {
|
|
131
|
+
await compareTasks({
|
|
132
|
+
tasks: {
|
|
133
|
+
install: {
|
|
134
|
+
cmds: ['npm install'],
|
|
135
|
+
},
|
|
136
|
+
build: {
|
|
137
|
+
cmds: ['tsc'],
|
|
138
|
+
},
|
|
139
|
+
example: {
|
|
140
|
+
deps: ['install', 'build'],
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
}, {
|
|
144
|
+
tasks: {
|
|
145
|
+
install: {
|
|
146
|
+
cmds: ['npm install'],
|
|
147
|
+
},
|
|
148
|
+
build: {
|
|
149
|
+
cmds: ['tsc'],
|
|
150
|
+
},
|
|
151
|
+
example: {
|
|
152
|
+
deps: ['build', 'install'],
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
}, 'example', true);
|
|
156
|
+
});
|
|
157
|
+
it('should be be the same for sources in different order', async () => {
|
|
158
|
+
await compareTasks({
|
|
159
|
+
tasks: {
|
|
160
|
+
example: {
|
|
161
|
+
src: ['package.json', 'package-lock.json'],
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
}, {
|
|
165
|
+
tasks: {
|
|
166
|
+
example: {
|
|
167
|
+
src: ['package-lock.json', 'package.json'],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
}, 'example', true);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
//# sourceMappingURL=work-cache-id.spec.js.map
|