skuba 0.0.0-beta-20231002015947
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/LICENSE +21 -0
- package/README.md +67 -0
- package/config/eslint.js +3 -0
- package/config/jest.js +1 -0
- package/config/prettier.d.ts +4 -0
- package/config/prettier.js +6 -0
- package/config/tsconfig.json +11 -0
- package/jest/moduleNameMapper.js +58 -0
- package/jest/moduleNameMapper.test.ts +64 -0
- package/jest/transform.js +50 -0
- package/jest/transform.test.ts +11 -0
- package/jest/tsConfig.js +26 -0
- package/jest-preset.js +40 -0
- package/lib/api/buildkite/annotate.d.ts +26 -0
- package/lib/api/buildkite/annotate.js +49 -0
- package/lib/api/buildkite/annotate.js.map +7 -0
- package/lib/api/buildkite/index.d.ts +3 -0
- package/lib/api/buildkite/index.js +32 -0
- package/lib/api/buildkite/index.js.map +7 -0
- package/lib/api/buildkite/md.d.ts +6 -0
- package/lib/api/buildkite/md.js +33 -0
- package/lib/api/buildkite/md.js.map +7 -0
- package/lib/api/git/commit.d.ts +15 -0
- package/lib/api/git/commit.js +52 -0
- package/lib/api/git/commit.js.map +7 -0
- package/lib/api/git/commitAllChanges.d.ts +19 -0
- package/lib/api/git/commitAllChanges.js +79 -0
- package/lib/api/git/commitAllChanges.js.map +7 -0
- package/lib/api/git/currentBranch.d.ts +10 -0
- package/lib/api/git/currentBranch.js +59 -0
- package/lib/api/git/currentBranch.js.map +7 -0
- package/lib/api/git/findRoot.d.ts +9 -0
- package/lib/api/git/findRoot.js +52 -0
- package/lib/api/git/findRoot.js.map +7 -0
- package/lib/api/git/getChangedFiles.d.ts +20 -0
- package/lib/api/git/getChangedFiles.js +63 -0
- package/lib/api/git/getChangedFiles.js.map +7 -0
- package/lib/api/git/index.d.ts +11 -0
- package/lib/api/git/index.js +58 -0
- package/lib/api/git/index.js.map +7 -0
- package/lib/api/git/log.d.ts +19 -0
- package/lib/api/git/log.js +71 -0
- package/lib/api/git/log.js.map +7 -0
- package/lib/api/git/pull.d.ts +35 -0
- package/lib/api/git/pull.js +69 -0
- package/lib/api/git/pull.js.map +7 -0
- package/lib/api/git/push.d.ts +43 -0
- package/lib/api/git/push.js +70 -0
- package/lib/api/git/push.js.map +7 -0
- package/lib/api/git/remote.d.ts +20 -0
- package/lib/api/git/remote.js +73 -0
- package/lib/api/git/remote.js.map +7 -0
- package/lib/api/git/reset.d.ts +12 -0
- package/lib/api/git/reset.js +62 -0
- package/lib/api/git/reset.js.map +7 -0
- package/lib/api/git/statusMatrix.d.ts +7 -0
- package/lib/api/git/statusMatrix.js +47 -0
- package/lib/api/git/statusMatrix.js.map +7 -0
- package/lib/api/github/checkRun.d.ts +44 -0
- package/lib/api/github/checkRun.js +81 -0
- package/lib/api/github/checkRun.js.map +7 -0
- package/lib/api/github/environment.d.ts +18 -0
- package/lib/api/github/environment.js +48 -0
- package/lib/api/github/environment.js.map +7 -0
- package/lib/api/github/index.d.ts +7 -0
- package/lib/api/github/index.js +48 -0
- package/lib/api/github/index.js.map +7 -0
- package/lib/api/github/issueComment.d.ts +59 -0
- package/lib/api/github/issueComment.js +83 -0
- package/lib/api/github/issueComment.js.map +7 -0
- package/lib/api/github/pullRequest.d.ts +21 -0
- package/lib/api/github/pullRequest.js +69 -0
- package/lib/api/github/pullRequest.js.map +7 -0
- package/lib/api/github/push.d.ts +79 -0
- package/lib/api/github/push.js +167 -0
- package/lib/api/github/push.js.map +7 -0
- package/lib/api/jest/index.d.ts +147 -0
- package/lib/api/jest/index.js +41 -0
- package/lib/api/jest/index.js.map +7 -0
- package/lib/api/net/compose.d.ts +4 -0
- package/lib/api/net/compose.js +50 -0
- package/lib/api/net/compose.js.map +7 -0
- package/lib/api/net/index.d.ts +1 -0
- package/lib/api/net/index.js +29 -0
- package/lib/api/net/index.js.map +7 -0
- package/lib/api/net/socket.d.ts +5 -0
- package/lib/api/net/socket.js +68 -0
- package/lib/api/net/socket.js.map +7 -0
- package/lib/api/net/waitFor.d.ts +22 -0
- package/lib/api/net/waitFor.js +40 -0
- package/lib/api/net/waitFor.js.map +7 -0
- package/lib/cli/adapter/eslint.d.ts +14 -0
- package/lib/cli/adapter/eslint.js +99 -0
- package/lib/cli/adapter/eslint.js.map +7 -0
- package/lib/cli/adapter/prettier.d.ts +52 -0
- package/lib/cli/adapter/prettier.js +176 -0
- package/lib/cli/adapter/prettier.js.map +7 -0
- package/lib/cli/build/args.d.ts +7 -0
- package/lib/cli/build/args.js +73 -0
- package/lib/cli/build/args.js.map +7 -0
- package/lib/cli/build/assets.d.ts +10 -0
- package/lib/cli/build/assets.js +107 -0
- package/lib/cli/build/assets.js.map +7 -0
- package/lib/cli/build/esbuild.d.ts +5 -0
- package/lib/cli/build/esbuild.js +98 -0
- package/lib/cli/build/esbuild.js.map +7 -0
- package/lib/cli/build/index.d.ts +1 -0
- package/lib/cli/build/index.js +83 -0
- package/lib/cli/build/index.js.map +7 -0
- package/lib/cli/build/tsc.d.ts +4 -0
- package/lib/cli/build/tsc.js +102 -0
- package/lib/cli/build/tsc.js.map +7 -0
- package/lib/cli/buildPackage.d.ts +1 -0
- package/lib/cli/buildPackage.js +69 -0
- package/lib/cli/buildPackage.js.map +7 -0
- package/lib/cli/configure/addEmptyExports.d.ts +6 -0
- package/lib/cli/configure/addEmptyExports.js +76 -0
- package/lib/cli/configure/addEmptyExports.js.map +7 -0
- package/lib/cli/configure/analyseConfiguration.d.ts +9 -0
- package/lib/cli/configure/analyseConfiguration.js +69 -0
- package/lib/cli/configure/analyseConfiguration.js.map +7 -0
- package/lib/cli/configure/analyseDependencies.d.ts +10 -0
- package/lib/cli/configure/analyseDependencies.js +136 -0
- package/lib/cli/configure/analyseDependencies.js.map +7 -0
- package/lib/cli/configure/analysis/diff.d.ts +1 -0
- package/lib/cli/configure/analysis/diff.js +45 -0
- package/lib/cli/configure/analysis/diff.js.map +7 -0
- package/lib/cli/configure/analysis/files.d.ts +1 -0
- package/lib/cli/configure/analysis/files.js +58 -0
- package/lib/cli/configure/analysis/files.js.map +7 -0
- package/lib/cli/configure/analysis/git.d.ts +1 -0
- package/lib/cli/configure/analysis/git.js +54 -0
- package/lib/cli/configure/analysis/git.js.map +7 -0
- package/lib/cli/configure/analysis/package.d.ts +13 -0
- package/lib/cli/configure/analysis/package.js +110 -0
- package/lib/cli/configure/analysis/package.js.map +7 -0
- package/lib/cli/configure/analysis/project.d.ts +3 -0
- package/lib/cli/configure/analysis/project.js +109 -0
- package/lib/cli/configure/analysis/project.js.map +7 -0
- package/lib/cli/configure/dependencies/index.d.ts +5 -0
- package/lib/cli/configure/dependencies/index.js +41 -0
- package/lib/cli/configure/dependencies/index.js.map +7 -0
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.d.ts +2 -0
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +59 -0
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +7 -0
- package/lib/cli/configure/dependencies/seekKoala.d.ts +2 -0
- package/lib/cli/configure/dependencies/seekKoala.js +56 -0
- package/lib/cli/configure/dependencies/seekKoala.js.map +7 -0
- package/lib/cli/configure/dependencies/skuba.d.ts +2 -0
- package/lib/cli/configure/dependencies/skuba.js +52 -0
- package/lib/cli/configure/dependencies/skuba.js.map +7 -0
- package/lib/cli/configure/dependencies/skubaDeps.d.ts +2 -0
- package/lib/cli/configure/dependencies/skubaDeps.js +56 -0
- package/lib/cli/configure/dependencies/skubaDeps.js.map +7 -0
- package/lib/cli/configure/dependencies/skubaDive.d.ts +3 -0
- package/lib/cli/configure/dependencies/skubaDive.js +70 -0
- package/lib/cli/configure/dependencies/skubaDive.js.map +7 -0
- package/lib/cli/configure/ensureTemplateCompletion.d.ts +9 -0
- package/lib/cli/configure/ensureTemplateCompletion.js +77 -0
- package/lib/cli/configure/ensureTemplateCompletion.js.map +7 -0
- package/lib/cli/configure/getEntryPoint.d.ts +11 -0
- package/lib/cli/configure/getEntryPoint.js +73 -0
- package/lib/cli/configure/getEntryPoint.js.map +7 -0
- package/lib/cli/configure/getProjectType.d.ts +9 -0
- package/lib/cli/configure/getProjectType.js +52 -0
- package/lib/cli/configure/getProjectType.js.map +7 -0
- package/lib/cli/configure/index.d.ts +1 -0
- package/lib/cli/configure/index.js +148 -0
- package/lib/cli/configure/index.js.map +7 -0
- package/lib/cli/configure/modules/eslint.d.ts +2 -0
- package/lib/cli/configure/modules/eslint.js +61 -0
- package/lib/cli/configure/modules/eslint.js.map +7 -0
- package/lib/cli/configure/modules/ignore.d.ts +2 -0
- package/lib/cli/configure/modules/ignore.js +40 -0
- package/lib/cli/configure/modules/ignore.js.map +7 -0
- package/lib/cli/configure/modules/index.d.ts +2 -0
- package/lib/cli/configure/modules/index.js +54 -0
- package/lib/cli/configure/modules/index.js.map +7 -0
- package/lib/cli/configure/modules/jest.d.ts +2 -0
- package/lib/cli/configure/modules/jest.js +86 -0
- package/lib/cli/configure/modules/jest.js.map +7 -0
- package/lib/cli/configure/modules/nodemon.d.ts +2 -0
- package/lib/cli/configure/modules/nodemon.js +30 -0
- package/lib/cli/configure/modules/nodemon.js.map +7 -0
- package/lib/cli/configure/modules/package.d.ts +2 -0
- package/lib/cli/configure/modules/package.js +117 -0
- package/lib/cli/configure/modules/package.js.map +7 -0
- package/lib/cli/configure/modules/prettier.d.ts +2 -0
- package/lib/cli/configure/modules/prettier.js +52 -0
- package/lib/cli/configure/modules/prettier.js.map +7 -0
- package/lib/cli/configure/modules/renovate.d.ts +3 -0
- package/lib/cli/configure/modules/renovate.js +69 -0
- package/lib/cli/configure/modules/renovate.js.map +7 -0
- package/lib/cli/configure/modules/serverless.d.ts +2 -0
- package/lib/cli/configure/modules/serverless.js +36 -0
- package/lib/cli/configure/modules/serverless.js.map +7 -0
- package/lib/cli/configure/modules/skubaDive.d.ts +2 -0
- package/lib/cli/configure/modules/skubaDive.js +72 -0
- package/lib/cli/configure/modules/skubaDive.js.map +7 -0
- package/lib/cli/configure/modules/tsconfig.d.ts +2 -0
- package/lib/cli/configure/modules/tsconfig.js +87 -0
- package/lib/cli/configure/modules/tsconfig.js.map +7 -0
- package/lib/cli/configure/modules/tslint.d.ts +2 -0
- package/lib/cli/configure/modules/tslint.js +30 -0
- package/lib/cli/configure/modules/tslint.js.map +7 -0
- package/lib/cli/configure/patchDockerfile.d.ts +1 -0
- package/lib/cli/configure/patchDockerfile.js +65 -0
- package/lib/cli/configure/patchDockerfile.js.map +7 -0
- package/lib/cli/configure/patchRenovateConfig.d.ts +1 -0
- package/lib/cli/configure/patchRenovateConfig.js +138 -0
- package/lib/cli/configure/patchRenovateConfig.js.map +7 -0
- package/lib/cli/configure/patchServerListener.d.ts +3 -0
- package/lib/cli/configure/patchServerListener.js +87 -0
- package/lib/cli/configure/patchServerListener.js.map +7 -0
- package/lib/cli/configure/processing/deleteFiles.d.ts +5 -0
- package/lib/cli/configure/processing/deleteFiles.js +31 -0
- package/lib/cli/configure/processing/deleteFiles.js.map +7 -0
- package/lib/cli/configure/processing/ignoreFile.d.ts +8 -0
- package/lib/cli/configure/processing/ignoreFile.js +74 -0
- package/lib/cli/configure/processing/ignoreFile.js.map +7 -0
- package/lib/cli/configure/processing/javascript.d.ts +2 -0
- package/lib/cli/configure/processing/javascript.js +38 -0
- package/lib/cli/configure/processing/javascript.js.map +7 -0
- package/lib/cli/configure/processing/json.d.ts +2 -0
- package/lib/cli/configure/processing/json.js +57 -0
- package/lib/cli/configure/processing/json.js.map +7 -0
- package/lib/cli/configure/processing/loadFiles.d.ts +5 -0
- package/lib/cli/configure/processing/loadFiles.js +31 -0
- package/lib/cli/configure/processing/loadFiles.js.map +7 -0
- package/lib/cli/configure/processing/module.d.ts +10 -0
- package/lib/cli/configure/processing/module.js +39 -0
- package/lib/cli/configure/processing/module.js.map +7 -0
- package/lib/cli/configure/processing/package.d.ts +73 -0
- package/lib/cli/configure/processing/package.js +85 -0
- package/lib/cli/configure/processing/package.js.map +7 -0
- package/lib/cli/configure/processing/prettier.d.ts +4 -0
- package/lib/cli/configure/processing/prettier.js +44 -0
- package/lib/cli/configure/processing/prettier.js.map +7 -0
- package/lib/cli/configure/processing/record.d.ts +11 -0
- package/lib/cli/configure/processing/record.js +65 -0
- package/lib/cli/configure/processing/record.js.map +7 -0
- package/lib/cli/configure/processing/typescript.d.ts +23 -0
- package/lib/cli/configure/processing/typescript.js +205 -0
- package/lib/cli/configure/processing/typescript.js.map +7 -0
- package/lib/cli/configure/refreshIgnoreFiles.d.ts +3 -0
- package/lib/cli/configure/refreshIgnoreFiles.js +78 -0
- package/lib/cli/configure/refreshIgnoreFiles.js.map +7 -0
- package/lib/cli/configure/types.d.ts +26 -0
- package/lib/cli/configure/types.js +17 -0
- package/lib/cli/configure/types.js.map +7 -0
- package/lib/cli/format.d.ts +1 -0
- package/lib/cli/format.js +74 -0
- package/lib/cli/format.js.map +7 -0
- package/lib/cli/help.d.ts +1 -0
- package/lib/cli/help.js +34 -0
- package/lib/cli/help.js.map +7 -0
- package/lib/cli/init/getConfig.d.ts +26 -0
- package/lib/cli/init/getConfig.js +286 -0
- package/lib/cli/init/getConfig.js.map +7 -0
- package/lib/cli/init/git.d.ts +7 -0
- package/lib/cli/init/git.js +82 -0
- package/lib/cli/init/git.js.map +7 -0
- package/lib/cli/init/index.d.ts +1 -0
- package/lib/cli/init/index.js +146 -0
- package/lib/cli/init/index.js.map +7 -0
- package/lib/cli/init/prompts.d.ts +45 -0
- package/lib/cli/init/prompts.js +97 -0
- package/lib/cli/init/prompts.js.map +7 -0
- package/lib/cli/init/types.d.ts +28 -0
- package/lib/cli/init/types.js +65 -0
- package/lib/cli/init/types.js.map +7 -0
- package/lib/cli/init/validation.d.ts +8 -0
- package/lib/cli/init/validation.js +43 -0
- package/lib/cli/init/validation.js.map +7 -0
- package/lib/cli/init/writePackageJson.d.ts +13 -0
- package/lib/cli/init/writePackageJson.js +58 -0
- package/lib/cli/init/writePackageJson.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/eslint.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/eslint.js +40 -0
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/index.d.ts +4 -0
- package/lib/cli/lint/annotate/buildkite/index.js +58 -0
- package/lib/cli/lint/annotate/buildkite/index.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/prettier.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/prettier.js +47 -0
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/tsc.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/tsc.js +45 -0
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +7 -0
- package/lib/cli/lint/annotate/github/eslint.d.ts +3 -0
- package/lib/cli/lint/annotate/github/eslint.js +45 -0
- package/lib/cli/lint/annotate/github/eslint.js.map +7 -0
- package/lib/cli/lint/annotate/github/index.d.ts +4 -0
- package/lib/cli/lint/annotate/github/index.js +63 -0
- package/lib/cli/lint/annotate/github/index.js.map +7 -0
- package/lib/cli/lint/annotate/github/prettier.d.ts +3 -0
- package/lib/cli/lint/annotate/github/prettier.js +39 -0
- package/lib/cli/lint/annotate/github/prettier.js.map +7 -0
- package/lib/cli/lint/annotate/github/tsc.d.ts +3 -0
- package/lib/cli/lint/annotate/github/tsc.js +63 -0
- package/lib/cli/lint/annotate/github/tsc.js.map +7 -0
- package/lib/cli/lint/annotate/index.d.ts +4 -0
- package/lib/cli/lint/annotate/index.js +36 -0
- package/lib/cli/lint/annotate/index.js.map +7 -0
- package/lib/cli/lint/autofix.d.ts +10 -0
- package/lib/cli/lint/autofix.js +214 -0
- package/lib/cli/lint/autofix.js.map +7 -0
- package/lib/cli/lint/eslint.d.ts +4 -0
- package/lib/cli/lint/eslint.js +55 -0
- package/lib/cli/lint/eslint.js.map +7 -0
- package/lib/cli/lint/external.d.ts +10 -0
- package/lib/cli/lint/external.js +117 -0
- package/lib/cli/lint/external.js.map +7 -0
- package/lib/cli/lint/index.d.ts +2 -0
- package/lib/cli/lint/index.js +51 -0
- package/lib/cli/lint/index.js.map +7 -0
- package/lib/cli/lint/internal.d.ts +1 -0
- package/lib/cli/lint/internal.js +64 -0
- package/lib/cli/lint/internal.js.map +7 -0
- package/lib/cli/lint/prettier.d.ts +4 -0
- package/lib/cli/lint/prettier.js +55 -0
- package/lib/cli/lint/prettier.js.map +7 -0
- package/lib/cli/lint/tsc.d.ts +2 -0
- package/lib/cli/lint/tsc.js +58 -0
- package/lib/cli/lint/tsc.js.map +7 -0
- package/lib/cli/lint/types.d.ts +34 -0
- package/lib/cli/lint/types.js +17 -0
- package/lib/cli/lint/types.js.map +7 -0
- package/lib/cli/node.d.ts +1 -0
- package/lib/cli/node.js +77 -0
- package/lib/cli/node.js.map +7 -0
- package/lib/cli/release.d.ts +1 -0
- package/lib/cli/release.js +32 -0
- package/lib/cli/release.js.map +7 -0
- package/lib/cli/start.d.ts +1 -0
- package/lib/cli/start.js +69 -0
- package/lib/cli/start.js.map +7 -0
- package/lib/cli/test/index.d.ts +1 -0
- package/lib/cli/test/index.js +36 -0
- package/lib/cli/test/index.js.map +7 -0
- package/lib/cli/test/reporters/github/annotations.d.ts +9 -0
- package/lib/cli/test/reporters/github/annotations.js +102 -0
- package/lib/cli/test/reporters/github/annotations.js.map +7 -0
- package/lib/cli/test/reporters/github/index.d.ts +5 -0
- package/lib/cli/test/reporters/github/index.js +75 -0
- package/lib/cli/test/reporters/github/index.js.map +7 -0
- package/lib/cli/test/reporters/prettier/index.d.ts +4 -0
- package/lib/cli/test/reporters/prettier/index.js +67 -0
- package/lib/cli/test/reporters/prettier/index.js.map +7 -0
- package/lib/cli/version.d.ts +1 -0
- package/lib/cli/version.js +34 -0
- package/lib/cli/version.js.map +7 -0
- package/lib/enquirer.d.js +2 -0
- package/lib/enquirer.d.js.map +7 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.js +51 -0
- package/lib/index.js.map +7 -0
- package/lib/skuba.d.ts +11 -0
- package/lib/skuba.js +53 -0
- package/lib/skuba.js.map +7 -0
- package/lib/utils/args.d.ts +43 -0
- package/lib/utils/args.js +114 -0
- package/lib/utils/args.js.map +7 -0
- package/lib/utils/command.d.ts +6 -0
- package/lib/utils/command.js +72 -0
- package/lib/utils/command.js.map +7 -0
- package/lib/utils/copy.d.ts +17 -0
- package/lib/utils/copy.js +105 -0
- package/lib/utils/copy.js.map +7 -0
- package/lib/utils/dir.d.ts +22 -0
- package/lib/utils/dir.js +91 -0
- package/lib/utils/dir.js.map +7 -0
- package/lib/utils/env.d.ts +5 -0
- package/lib/utils/env.js +29 -0
- package/lib/utils/env.js.map +7 -0
- package/lib/utils/error.d.ts +28 -0
- package/lib/utils/error.js +72 -0
- package/lib/utils/error.js.map +7 -0
- package/lib/utils/exec.d.ts +39 -0
- package/lib/utils/exec.js +163 -0
- package/lib/utils/exec.js.map +7 -0
- package/lib/utils/help.d.ts +1 -0
- package/lib/utils/help.js +34 -0
- package/lib/utils/help.js.map +7 -0
- package/lib/utils/logging.d.ts +27 -0
- package/lib/utils/logging.js +60 -0
- package/lib/utils/logging.js.map +7 -0
- package/lib/utils/logo.d.ts +9 -0
- package/lib/utils/logo.js +74 -0
- package/lib/utils/logo.js.map +7 -0
- package/lib/utils/manifest.d.ts +10 -0
- package/lib/utils/manifest.js +83 -0
- package/lib/utils/manifest.js.map +7 -0
- package/lib/utils/port.d.ts +2 -0
- package/lib/utils/port.js +48 -0
- package/lib/utils/port.js.map +7 -0
- package/lib/utils/template.d.ts +37 -0
- package/lib/utils/template.js +116 -0
- package/lib/utils/template.js.map +7 -0
- package/lib/utils/validation.d.ts +6 -0
- package/lib/utils/validation.js +44 -0
- package/lib/utils/validation.js.map +7 -0
- package/lib/utils/version.d.ts +13 -0
- package/lib/utils/version.js +89 -0
- package/lib/utils/version.js.map +7 -0
- package/lib/utils/wait.d.ts +17 -0
- package/lib/utils/wait.js +59 -0
- package/lib/utils/wait.js.map +7 -0
- package/lib/utils/worker.d.ts +20 -0
- package/lib/utils/worker.js +63 -0
- package/lib/utils/worker.js.map +7 -0
- package/lib/wrapper/function-arguments.d.js +2 -0
- package/lib/wrapper/function-arguments.d.js.map +7 -0
- package/lib/wrapper/functionHandler.d.ts +10 -0
- package/lib/wrapper/functionHandler.js +63 -0
- package/lib/wrapper/functionHandler.js.map +7 -0
- package/lib/wrapper/http.d.ts +20 -0
- package/lib/wrapper/http.js +79 -0
- package/lib/wrapper/http.js.map +7 -0
- package/lib/wrapper/index.d.ts +12 -0
- package/lib/wrapper/index.js +16 -0
- package/lib/wrapper/index.js.map +7 -0
- package/lib/wrapper/main.d.ts +1 -0
- package/lib/wrapper/main.js +47 -0
- package/lib/wrapper/main.js.map +7 -0
- package/lib/wrapper/requestListener.d.ts +11 -0
- package/lib/wrapper/requestListener.js +69 -0
- package/lib/wrapper/requestListener.js.map +7 -0
- package/package.json +170 -0
- package/template/base/.github/CODEOWNERS +1 -0
- package/template/base/.github/renovate.json5 +3 -0
- package/template/base/_.dockerignore +18 -0
- package/template/base/_.eslintignore +14 -0
- package/template/base/_.eslintrc.js +3 -0
- package/template/base/_.gitignore +23 -0
- package/template/base/_.prettierignore +8 -0
- package/template/base/_.prettierrc.js +1 -0
- package/template/base/jest.config.ts +15 -0
- package/template/base/jest.setup.ts +3 -0
- package/template/base/tsconfig.build.json +5 -0
- package/template/base/tsconfig.json +13 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +105 -0
- package/template/express-rest-api/.env +1 -0
- package/template/express-rest-api/.gantry/common.yml +20 -0
- package/template/express-rest-api/.gantry/dev.yml +8 -0
- package/template/express-rest-api/.gantry/prod.yml +8 -0
- package/template/express-rest-api/.nvmrc +1 -0
- package/template/express-rest-api/Dockerfile +37 -0
- package/template/express-rest-api/Dockerfile.dev-deps +11 -0
- package/template/express-rest-api/README.md +106 -0
- package/template/express-rest-api/docker-compose.yml +22 -0
- package/template/express-rest-api/gantry.apply.yml +120 -0
- package/template/express-rest-api/gantry.build.yml +15 -0
- package/template/express-rest-api/package.json +30 -0
- package/template/express-rest-api/skuba.template.js +49 -0
- package/template/express-rest-api/src/api/healthCheck.ts +11 -0
- package/template/express-rest-api/src/api/smokeTest.ts +8 -0
- package/template/express-rest-api/src/app.test.ts +9 -0
- package/template/express-rest-api/src/app.ts +14 -0
- package/template/express-rest-api/src/config.ts +57 -0
- package/template/express-rest-api/src/framework/logging.ts +17 -0
- package/template/express-rest-api/src/listen.ts +23 -0
- package/template/express-rest-api/src/register.ts +1 -0
- package/template/greeter/.buildkite/pipeline.yml +37 -0
- package/template/greeter/.nvmrc +1 -0
- package/template/greeter/Dockerfile +11 -0
- package/template/greeter/README.md +96 -0
- package/template/greeter/docker-compose.yml +22 -0
- package/template/greeter/package.json +24 -0
- package/template/greeter/skuba.template.js +16 -0
- package/template/greeter/src/app.test.ts +5 -0
- package/template/greeter/src/app.ts +4 -0
- package/template/koa-rest-api/.buildkite/pipeline.yml +105 -0
- package/template/koa-rest-api/.env +1 -0
- package/template/koa-rest-api/.gantry/common.yml +20 -0
- package/template/koa-rest-api/.gantry/dev.yml +11 -0
- package/template/koa-rest-api/.gantry/prod.yml +11 -0
- package/template/koa-rest-api/.nvmrc +1 -0
- package/template/koa-rest-api/Dockerfile +37 -0
- package/template/koa-rest-api/Dockerfile.dev-deps +11 -0
- package/template/koa-rest-api/README.md +111 -0
- package/template/koa-rest-api/docker-compose.yml +22 -0
- package/template/koa-rest-api/gantry.apply.yml +127 -0
- package/template/koa-rest-api/gantry.build.yml +15 -0
- package/template/koa-rest-api/package.json +47 -0
- package/template/koa-rest-api/skuba.template.js +49 -0
- package/template/koa-rest-api/src/api/healthCheck.ts +13 -0
- package/template/koa-rest-api/src/api/index.ts +10 -0
- package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +9 -0
- package/template/koa-rest-api/src/api/jobs/getJobs.ts +15 -0
- package/template/koa-rest-api/src/api/jobs/index.ts +10 -0
- package/template/koa-rest-api/src/api/jobs/postJob.test.ts +34 -0
- package/template/koa-rest-api/src/api/jobs/postJob.ts +19 -0
- package/template/koa-rest-api/src/api/smokeTest.ts +11 -0
- package/template/koa-rest-api/src/app.test.ts +21 -0
- package/template/koa-rest-api/src/app.ts +8 -0
- package/template/koa-rest-api/src/config.ts +57 -0
- package/template/koa-rest-api/src/framework/logging.ts +25 -0
- package/template/koa-rest-api/src/framework/metrics.ts +11 -0
- package/template/koa-rest-api/src/framework/middleware.ts +3 -0
- package/template/koa-rest-api/src/framework/server.test.ts +260 -0
- package/template/koa-rest-api/src/framework/server.ts +51 -0
- package/template/koa-rest-api/src/framework/validation.test.ts +72 -0
- package/template/koa-rest-api/src/framework/validation.ts +77 -0
- package/template/koa-rest-api/src/listen.ts +24 -0
- package/template/koa-rest-api/src/register.ts +1 -0
- package/template/koa-rest-api/src/storage/jobs.ts +28 -0
- package/template/koa-rest-api/src/testing/logging.ts +16 -0
- package/template/koa-rest-api/src/testing/metrics.ts +29 -0
- package/template/koa-rest-api/src/testing/server.ts +31 -0
- package/template/koa-rest-api/src/testing/types.ts +24 -0
- package/template/koa-rest-api/src/tracing.ts +56 -0
- package/template/koa-rest-api/src/types/jobs.ts +17 -0
- package/template/koa-rest-api/src/types/koa.ts +8 -0
- package/template/koa-rest-api/tsconfig.json +18 -0
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +98 -0
- package/template/lambda-sqs-worker/.env +1 -0
- package/template/lambda-sqs-worker/.nvmrc +1 -0
- package/template/lambda-sqs-worker/Dockerfile +12 -0
- package/template/lambda-sqs-worker/README.md +132 -0
- package/template/lambda-sqs-worker/docker-compose.yml +27 -0
- package/template/lambda-sqs-worker/package.json +44 -0
- package/template/lambda-sqs-worker/serverless.yml +202 -0
- package/template/lambda-sqs-worker/skuba.template.js +32 -0
- package/template/lambda-sqs-worker/src/app.test.ts +116 -0
- package/template/lambda-sqs-worker/src/app.ts +57 -0
- package/template/lambda-sqs-worker/src/config.ts +57 -0
- package/template/lambda-sqs-worker/src/framework/handler.test.ts +61 -0
- package/template/lambda-sqs-worker/src/framework/handler.ts +43 -0
- package/template/lambda-sqs-worker/src/framework/logging.ts +27 -0
- package/template/lambda-sqs-worker/src/framework/metrics.ts +14 -0
- package/template/lambda-sqs-worker/src/framework/validation.test.ts +84 -0
- package/template/lambda-sqs-worker/src/framework/validation.ts +10 -0
- package/template/lambda-sqs-worker/src/hooks.ts +96 -0
- package/template/lambda-sqs-worker/src/mapping/jobScorer.ts +22 -0
- package/template/lambda-sqs-worker/src/services/aws.ts +5 -0
- package/template/lambda-sqs-worker/src/services/jobScorer.test.ts +44 -0
- package/template/lambda-sqs-worker/src/services/jobScorer.ts +59 -0
- package/template/lambda-sqs-worker/src/services/pipelineEventSender.test.ts +40 -0
- package/template/lambda-sqs-worker/src/services/pipelineEventSender.ts +33 -0
- package/template/lambda-sqs-worker/src/testing/handler.ts +13 -0
- package/template/lambda-sqs-worker/src/testing/logging.ts +19 -0
- package/template/lambda-sqs-worker/src/testing/services.ts +28 -0
- package/template/lambda-sqs-worker/src/testing/types.ts +33 -0
- package/template/lambda-sqs-worker/src/types/jobScorer.ts +15 -0
- package/template/lambda-sqs-worker/src/types/pipelineEvents.ts +21 -0
- package/template/lambda-sqs-worker/tsconfig.json +13 -0
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +95 -0
- package/template/lambda-sqs-worker-cdk/.nvmrc +1 -0
- package/template/lambda-sqs-worker-cdk/Dockerfile +13 -0
- package/template/lambda-sqs-worker-cdk/cdk.json +25 -0
- package/template/lambda-sqs-worker-cdk/docker-compose.yml +28 -0
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +723 -0
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +34 -0
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +74 -0
- package/template/lambda-sqs-worker-cdk/infra/index.ts +14 -0
- package/template/lambda-sqs-worker-cdk/package.json +30 -0
- package/template/lambda-sqs-worker-cdk/shared/context-types.ts +21 -0
- package/template/lambda-sqs-worker-cdk/skuba.template.js +27 -0
- package/template/lambda-sqs-worker-cdk/src/app.ts +10 -0
- package/template/lambda-sqs-worker-cdk/tsconfig.json +13 -0
- package/template/oss-npm-package/.github/workflows/release.yml +36 -0
- package/template/oss-npm-package/.github/workflows/validate.yml +31 -0
- package/template/oss-npm-package/.nvmrc +1 -0
- package/template/oss-npm-package/LICENSE +21 -0
- package/template/oss-npm-package/README.md +128 -0
- package/template/oss-npm-package/_package.json +47 -0
- package/template/oss-npm-package/skuba.template.js +22 -0
- package/template/oss-npm-package/src/index.test.ts +5 -0
- package/template/oss-npm-package/src/index.ts +7 -0
- package/template/oss-npm-package/tsconfig.json +10 -0
- package/template/private-npm-package/.buildkite/pipeline.yml +5 -0
- package/template/private-npm-package/.nvmrc +1 -0
- package/template/private-npm-package/README.md +109 -0
- package/template/private-npm-package/_package.json +44 -0
- package/template/private-npm-package/skuba.template.js +24 -0
- package/template/private-npm-package/src/index.test.ts +5 -0
- package/template/private-npm-package/src/index.ts +7 -0
- package/template/private-npm-package/tsconfig.json +10 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
|
|
4
|
+
// Use minimal dependencies to reduce the chance of crashes on module load.
|
|
5
|
+
import {
|
|
6
|
+
CodeDeployClient,
|
|
7
|
+
PutLifecycleEventHookExecutionStatusCommand,
|
|
8
|
+
} from '@aws-sdk/client-codedeploy';
|
|
9
|
+
import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda';
|
|
10
|
+
import { toUtf8 } from '@aws-sdk/util-utf8-node';
|
|
11
|
+
|
|
12
|
+
const codeDeploy = new CodeDeployClient({
|
|
13
|
+
apiVersion: '2014-10-06',
|
|
14
|
+
maxAttempts: 5,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const lambda = new LambdaClient({
|
|
18
|
+
apiVersion: '2015-03-31',
|
|
19
|
+
maxAttempts: 5,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
type Status = 'Succeeded' | 'Failed';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Synchronously invokes a Lambda function with a smoke test event.
|
|
26
|
+
*
|
|
27
|
+
* Any non-error response is treated as a success.
|
|
28
|
+
*/
|
|
29
|
+
const smokeTestLambdaFunction = async (): Promise<Status> => {
|
|
30
|
+
const functionName = process.env.FUNCTION_NAME_TO_INVOKE;
|
|
31
|
+
|
|
32
|
+
if (!functionName) {
|
|
33
|
+
console.error('Missing process.env.FUNCTION_NAME_TO_INVOKE');
|
|
34
|
+
return 'Failed';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.info('Function:', functionName);
|
|
38
|
+
|
|
39
|
+
const response = await lambda.send(
|
|
40
|
+
new InvokeCommand({
|
|
41
|
+
FunctionName: functionName,
|
|
42
|
+
InvocationType: 'RequestResponse',
|
|
43
|
+
// Treat an empty object as our smoke test event.
|
|
44
|
+
Payload: Buffer.from('{}'),
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
console.info('Version:', response.ExecutedVersion ?? '?');
|
|
49
|
+
console.info('Status', response.StatusCode ?? '?');
|
|
50
|
+
|
|
51
|
+
if (response.FunctionError) {
|
|
52
|
+
console.error('Error:', response.FunctionError);
|
|
53
|
+
if (response.Payload) {
|
|
54
|
+
console.error(toUtf8(response.Payload));
|
|
55
|
+
}
|
|
56
|
+
return 'Failed';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return response.StatusCode === 200 ? 'Succeeded' : 'Failed';
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The event supplied to a CodeDeploy lifecycle hook Lambda function.
|
|
64
|
+
*
|
|
65
|
+
* {@link https://docs.aws.amazon.com/codedeploy/latest/userguide/tutorial-ecs-with-hooks-create-hooks.html}
|
|
66
|
+
*/
|
|
67
|
+
interface CodeDeployLifecycleHookEvent {
|
|
68
|
+
DeploymentId: string;
|
|
69
|
+
LifecycleEventHookExecutionId: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A handler to smoke test a new Lambda function version before it goes live.
|
|
74
|
+
*
|
|
75
|
+
* This tries to be exception safe so that a status reaches CodeDeploy. If we
|
|
76
|
+
* crash or otherwise fail to report back, the deployment will hang for an hour.
|
|
77
|
+
*/
|
|
78
|
+
export const pre = async (
|
|
79
|
+
event: CodeDeployLifecycleHookEvent,
|
|
80
|
+
): Promise<void> => {
|
|
81
|
+
let status: Status;
|
|
82
|
+
try {
|
|
83
|
+
status = await smokeTestLambdaFunction();
|
|
84
|
+
} catch (err) {
|
|
85
|
+
console.error('Exception:', err);
|
|
86
|
+
status = 'Failed';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
await codeDeploy.send(
|
|
90
|
+
new PutLifecycleEventHookExecutionStatusCommand({
|
|
91
|
+
deploymentId: event.DeploymentId,
|
|
92
|
+
lifecycleEventHookExecutionId: event.LifecycleEventHookExecutionId,
|
|
93
|
+
status,
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
96
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { JobScorerInput, JobScorerOutput } from 'src/types/jobScorer';
|
|
2
|
+
import type {
|
|
3
|
+
JobPublishedEvent,
|
|
4
|
+
JobScoredEvent,
|
|
5
|
+
} from 'src/types/pipelineEvents';
|
|
6
|
+
|
|
7
|
+
export const jobPublishedEventToScorerInput = (
|
|
8
|
+
record: JobPublishedEvent,
|
|
9
|
+
): JobScorerInput => ({
|
|
10
|
+
details: record.data.details,
|
|
11
|
+
id: record.entityId,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const jobScorerOutputToScoredEvent = (
|
|
15
|
+
output: JobScorerOutput,
|
|
16
|
+
): JobScoredEvent => ({
|
|
17
|
+
data: {
|
|
18
|
+
score: output.score,
|
|
19
|
+
},
|
|
20
|
+
entityId: output.id,
|
|
21
|
+
eventType: 'JobScored',
|
|
22
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { scoringService } from 'src/testing/services';
|
|
2
|
+
import { chance, mockJobPublishedEvent } from 'src/testing/types';
|
|
3
|
+
|
|
4
|
+
import * as jobScorer from './jobScorer';
|
|
5
|
+
|
|
6
|
+
describe('scoreJobPublishedEvent', () => {
|
|
7
|
+
beforeAll(scoringService.spy);
|
|
8
|
+
|
|
9
|
+
afterEach(scoringService.clear);
|
|
10
|
+
|
|
11
|
+
it('scores an event', async () => {
|
|
12
|
+
const score = chance.floating({ max: 1, min: 0 });
|
|
13
|
+
|
|
14
|
+
scoringService.request.mockResolvedValue(score);
|
|
15
|
+
|
|
16
|
+
await expect(
|
|
17
|
+
jobScorer.scoreJobPublishedEvent(
|
|
18
|
+
mockJobPublishedEvent({ entityId: '1' }),
|
|
19
|
+
),
|
|
20
|
+
).resolves.toStrictEqual({
|
|
21
|
+
data: {
|
|
22
|
+
score,
|
|
23
|
+
},
|
|
24
|
+
entityId: '1',
|
|
25
|
+
eventType: 'JobScored',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
expect(scoringService.request).toHaveBeenCalledTimes(1);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('bubbles up scoring service error', async () => {
|
|
32
|
+
const err = Error(chance.sentence());
|
|
33
|
+
|
|
34
|
+
scoringService.request.mockRejectedValue(err);
|
|
35
|
+
|
|
36
|
+
await expect(
|
|
37
|
+
jobScorer.scoreJobPublishedEvent(
|
|
38
|
+
mockJobPublishedEvent({ entityId: '1' }),
|
|
39
|
+
),
|
|
40
|
+
).rejects.toThrow(err);
|
|
41
|
+
|
|
42
|
+
expect(scoringService.request).toHaveBeenCalledTimes(1);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
jobPublishedEventToScorerInput,
|
|
3
|
+
jobScorerOutputToScoredEvent,
|
|
4
|
+
} from 'src/mapping/jobScorer';
|
|
5
|
+
import {
|
|
6
|
+
type JobScorerInput,
|
|
7
|
+
type JobScorerOutput,
|
|
8
|
+
JobScorerOutputSchema,
|
|
9
|
+
} from 'src/types/jobScorer';
|
|
10
|
+
import type {
|
|
11
|
+
JobPublishedEvent,
|
|
12
|
+
JobScoredEvent,
|
|
13
|
+
} from 'src/types/pipelineEvents';
|
|
14
|
+
|
|
15
|
+
/* istanbul ignore next: simulation of an external service */
|
|
16
|
+
export const scoringService = {
|
|
17
|
+
request: (details: string): Promise<unknown> => {
|
|
18
|
+
// Networking woes
|
|
19
|
+
if (Math.random() < 0.05) {
|
|
20
|
+
const err = Error('could not reach scoring service');
|
|
21
|
+
|
|
22
|
+
return Promise.reject(err);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Unexpected behaviour on certain inputs
|
|
26
|
+
if (details.length % 100 === 0) {
|
|
27
|
+
return Promise.resolve(null);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return Promise.resolve(Math.random());
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
smokeTest: async (): Promise<void> => {
|
|
34
|
+
// A connectivity test
|
|
35
|
+
await Promise.resolve();
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const scoreJob = async ({
|
|
40
|
+
details,
|
|
41
|
+
id,
|
|
42
|
+
}: JobScorerInput): Promise<JobScorerOutput> => {
|
|
43
|
+
const score = await scoringService.request(details);
|
|
44
|
+
|
|
45
|
+
return JobScorerOutputSchema.parse({
|
|
46
|
+
id,
|
|
47
|
+
score,
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const scoreJobPublishedEvent = async (
|
|
52
|
+
publishedJob: JobPublishedEvent,
|
|
53
|
+
): Promise<JobScoredEvent> => {
|
|
54
|
+
const scorerInput = jobPublishedEventToScorerInput(publishedJob);
|
|
55
|
+
|
|
56
|
+
const scorerOutput = await scoreJob(scorerInput);
|
|
57
|
+
|
|
58
|
+
return jobScorerOutputToScoredEvent(scorerOutput);
|
|
59
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PublishCommand } from '@aws-sdk/client-sns';
|
|
2
|
+
|
|
3
|
+
import { sns } from 'src/testing/services';
|
|
4
|
+
import { chance } from 'src/testing/types';
|
|
5
|
+
|
|
6
|
+
import { sendPipelineEvent } from './pipelineEventSender';
|
|
7
|
+
|
|
8
|
+
describe('sendPipelineEvent', () => {
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
jest.clearAllMocks();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('handles happy path', async () => {
|
|
14
|
+
const messageId = chance.guid({ version: 4 });
|
|
15
|
+
|
|
16
|
+
sns.publish.resolves({ MessageId: messageId });
|
|
17
|
+
|
|
18
|
+
await expect(sendPipelineEvent({})).resolves.toBe(messageId);
|
|
19
|
+
|
|
20
|
+
expect(sns.client).toReceiveCommandTimes(PublishCommand, 1);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('bubbles up SNS error', () => {
|
|
24
|
+
const err = Error(chance.sentence());
|
|
25
|
+
|
|
26
|
+
sns.publish.rejects(err);
|
|
27
|
+
|
|
28
|
+
return expect(sendPipelineEvent({})).rejects.toThrow(err);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('throws on missing message ID', () => {
|
|
32
|
+
sns.publish.resolves({});
|
|
33
|
+
|
|
34
|
+
return expect(
|
|
35
|
+
sendPipelineEvent({}),
|
|
36
|
+
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
37
|
+
`"SNS did not return a message ID"`,
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PublishCommand } from '@aws-sdk/client-sns';
|
|
2
|
+
|
|
3
|
+
import { config } from 'src/config';
|
|
4
|
+
|
|
5
|
+
import { sns } from './aws';
|
|
6
|
+
|
|
7
|
+
export const sendPipelineEvent = async (
|
|
8
|
+
event: unknown,
|
|
9
|
+
smokeTest: boolean = false,
|
|
10
|
+
): Promise<string> => {
|
|
11
|
+
const snsResponse = await sns.send(
|
|
12
|
+
new PublishCommand({
|
|
13
|
+
Message: JSON.stringify(event),
|
|
14
|
+
...(smokeTest && {
|
|
15
|
+
MessageAttributes: {
|
|
16
|
+
// Used for connectivity tests.
|
|
17
|
+
// Subscribers should filter out messages containing this attribute.
|
|
18
|
+
SmokeTest: {
|
|
19
|
+
DataType: 'String',
|
|
20
|
+
StringValue: 'true',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
TopicArn: config.destinationSnsTopicArn,
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (snsResponse.MessageId === undefined) {
|
|
29
|
+
throw Error('SNS did not return a message ID');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return snsResponse.MessageId;
|
|
33
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Context, SQSEvent } from 'aws-lambda';
|
|
2
|
+
|
|
3
|
+
import { chance } from './types';
|
|
4
|
+
|
|
5
|
+
export const createCtx = () =>
|
|
6
|
+
({
|
|
7
|
+
awsRequestId: chance.guid({ version: 4 }),
|
|
8
|
+
}) as Context;
|
|
9
|
+
|
|
10
|
+
export const createSqsEvent = (bodies: string[]) =>
|
|
11
|
+
({
|
|
12
|
+
Records: bodies.map((body) => ({ body })),
|
|
13
|
+
}) as SQSEvent;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as logging from 'src/framework/logging';
|
|
2
|
+
|
|
3
|
+
export const logger = {
|
|
4
|
+
error: jest.fn(),
|
|
5
|
+
info: jest.fn(),
|
|
6
|
+
debug: jest.fn(),
|
|
7
|
+
|
|
8
|
+
clear: () => {
|
|
9
|
+
logger.error.mockClear();
|
|
10
|
+
logger.info.mockClear();
|
|
11
|
+
logger.debug.mockClear();
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
spy: () => {
|
|
15
|
+
jest.spyOn(logging.logger, 'error').mockImplementation(logger.error);
|
|
16
|
+
jest.spyOn(logging.logger, 'info').mockImplementation(logger.info);
|
|
17
|
+
jest.spyOn(logging.logger, 'debug').mockImplementation(logger.debug);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import 'aws-sdk-client-mock-jest';
|
|
2
|
+
|
|
3
|
+
import { PublishCommand } from '@aws-sdk/client-sns';
|
|
4
|
+
import { mockClient } from 'aws-sdk-client-mock';
|
|
5
|
+
|
|
6
|
+
import { sns as snsClient } from 'src/services/aws';
|
|
7
|
+
import * as jobScorer from 'src/services/jobScorer';
|
|
8
|
+
|
|
9
|
+
export const scoringService = {
|
|
10
|
+
request: jest.fn(),
|
|
11
|
+
|
|
12
|
+
clear: () => scoringService.request.mockClear(),
|
|
13
|
+
|
|
14
|
+
spy: () =>
|
|
15
|
+
jest
|
|
16
|
+
.spyOn(jobScorer.scoringService, 'request')
|
|
17
|
+
.mockImplementation(scoringService.request),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const snsMock = mockClient(snsClient);
|
|
21
|
+
|
|
22
|
+
export const sns = {
|
|
23
|
+
publish: snsMock.on(PublishCommand),
|
|
24
|
+
|
|
25
|
+
clear: () => snsMock.resetHistory(),
|
|
26
|
+
|
|
27
|
+
client: snsMock,
|
|
28
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Chance } from 'chance';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import type { JobPublishedEvent } from 'src/types/pipelineEvents';
|
|
5
|
+
|
|
6
|
+
export type IdDescription = z.infer<typeof IdDescriptionSchema>;
|
|
7
|
+
|
|
8
|
+
export const IdDescriptionSchema = z.object({
|
|
9
|
+
id: z.string(),
|
|
10
|
+
description: z.string(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const chance = new Chance();
|
|
14
|
+
|
|
15
|
+
export const mockIdDescription = (): IdDescription => ({
|
|
16
|
+
id: chance.guid({ version: 4 }),
|
|
17
|
+
description: chance.sentence(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const mockIdDescriptionJson = (): string =>
|
|
21
|
+
JSON.stringify(mockIdDescription());
|
|
22
|
+
|
|
23
|
+
export const mockJobPublishedEvent = ({
|
|
24
|
+
entityId,
|
|
25
|
+
}: {
|
|
26
|
+
entityId: string;
|
|
27
|
+
}): JobPublishedEvent => ({
|
|
28
|
+
data: {
|
|
29
|
+
details: chance.paragraph(),
|
|
30
|
+
},
|
|
31
|
+
entityId,
|
|
32
|
+
eventType: 'JobPublished',
|
|
33
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export type JobScorerInput = z.infer<typeof JobScorerInputSchema>;
|
|
4
|
+
|
|
5
|
+
const JobScorerInputSchema = z.object({
|
|
6
|
+
id: z.string(),
|
|
7
|
+
details: z.string(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type JobScorerOutput = z.infer<typeof JobScorerOutputSchema>;
|
|
11
|
+
|
|
12
|
+
export const JobScorerOutputSchema = z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
score: z.number(),
|
|
15
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export type JobPublishedEvent = z.infer<typeof JobPublishedEventSchema>;
|
|
4
|
+
|
|
5
|
+
export const JobPublishedEventSchema = z.object({
|
|
6
|
+
data: z.object({
|
|
7
|
+
details: z.string(),
|
|
8
|
+
}),
|
|
9
|
+
entityId: z.string(),
|
|
10
|
+
eventType: z.literal('JobPublished'),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export type JobScoredEvent = z.infer<typeof JobScoredEventSchema>;
|
|
14
|
+
|
|
15
|
+
export const JobScoredEventSchema = z.object({
|
|
16
|
+
data: z.object({
|
|
17
|
+
score: z.number(),
|
|
18
|
+
}),
|
|
19
|
+
entityId: z.string(),
|
|
20
|
+
eventType: z.literal('JobScored'),
|
|
21
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
agents:
|
|
2
|
+
queue: <%- prodBuildkiteQueueName %>
|
|
3
|
+
|
|
4
|
+
configs:
|
|
5
|
+
plugins:
|
|
6
|
+
- &aws-sm
|
|
7
|
+
seek-oss/aws-sm#v2.3.1:
|
|
8
|
+
env:
|
|
9
|
+
NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token
|
|
10
|
+
|
|
11
|
+
- &docker-ecr-cache
|
|
12
|
+
seek-oss/docker-ecr-cache#v2.1.0: &docker-ecr-cache-defaults
|
|
13
|
+
cache-on:
|
|
14
|
+
- package.json
|
|
15
|
+
- yarn.lock
|
|
16
|
+
secrets: id=npm,src=.npmrc
|
|
17
|
+
|
|
18
|
+
- &private-npm
|
|
19
|
+
seek-oss/private-npm#v1.2.0:
|
|
20
|
+
env: NPM_READ_TOKEN
|
|
21
|
+
|
|
22
|
+
base-steps:
|
|
23
|
+
- &deploy
|
|
24
|
+
commands:
|
|
25
|
+
- echo '+++ yarn deploy'
|
|
26
|
+
- yarn deploy
|
|
27
|
+
concurrency: 1
|
|
28
|
+
plugins:
|
|
29
|
+
- artifacts#v1.9.2:
|
|
30
|
+
build: ${BUILDKITE_BUILD_ID}
|
|
31
|
+
download: lib/*
|
|
32
|
+
- *aws-sm
|
|
33
|
+
- *private-npm
|
|
34
|
+
- *docker-ecr-cache
|
|
35
|
+
- docker-compose#v4.14.0:
|
|
36
|
+
dependencies: false
|
|
37
|
+
run: app
|
|
38
|
+
retry:
|
|
39
|
+
manual:
|
|
40
|
+
# Only use this if you need to roll back a deployment ASAP.
|
|
41
|
+
# Always follow up with a proper revert or fix in Git history.
|
|
42
|
+
permit_on_passed: true
|
|
43
|
+
|
|
44
|
+
steps:
|
|
45
|
+
- label: ๐งช Test, Lint & Build
|
|
46
|
+
artifact_paths: lib/**/*
|
|
47
|
+
commands:
|
|
48
|
+
- echo '+++ yarn test:ci'
|
|
49
|
+
- yarn test
|
|
50
|
+
- echo '--- yarn lint'
|
|
51
|
+
- yarn lint
|
|
52
|
+
- echo '--- yarn build'
|
|
53
|
+
- yarn build
|
|
54
|
+
env:
|
|
55
|
+
GET_GITHUB_TOKEN: please
|
|
56
|
+
plugins:
|
|
57
|
+
- *aws-sm
|
|
58
|
+
- *private-npm
|
|
59
|
+
- *docker-ecr-cache
|
|
60
|
+
- docker-compose#v4.14.0:
|
|
61
|
+
run: app
|
|
62
|
+
timeout_in_minutes: 10
|
|
63
|
+
|
|
64
|
+
- agents:
|
|
65
|
+
queue: <%- devBuildkiteQueueName %>
|
|
66
|
+
branches: '!renovate-*'
|
|
67
|
+
label: ๐งโโ๏ธ Warm Dev
|
|
68
|
+
command: ':'
|
|
69
|
+
plugins:
|
|
70
|
+
- *aws-sm
|
|
71
|
+
- *private-npm
|
|
72
|
+
- seek-oss/docker-ecr-cache#v2.1.0:
|
|
73
|
+
<<: *docker-ecr-cache-defaults
|
|
74
|
+
skip-pull-from-cache: true
|
|
75
|
+
|
|
76
|
+
- wait
|
|
77
|
+
- block: ๐๐ปโโ๏ธ Deploy Dev
|
|
78
|
+
branches: '!${BUILDKITE_PIPELINE_DEFAULT_BRANCH}'
|
|
79
|
+
|
|
80
|
+
- <<: *deploy
|
|
81
|
+
agents:
|
|
82
|
+
queue: <%- devBuildkiteQueueName %>
|
|
83
|
+
env:
|
|
84
|
+
ENVIRONMENT: dev
|
|
85
|
+
label: ๐ค Deploy Dev
|
|
86
|
+
concurrency_group: '<%- repoName %>/deploy/dev'
|
|
87
|
+
key: deploy-dev
|
|
88
|
+
|
|
89
|
+
- <<: *deploy
|
|
90
|
+
env:
|
|
91
|
+
ENVIRONMENT: prod
|
|
92
|
+
label: ๐ Deploy Prod
|
|
93
|
+
branches: ${BUILDKITE_PIPELINE_DEFAULT_BRANCH}
|
|
94
|
+
concurrency_group: '<%- repoName %>/deploy/prod'
|
|
95
|
+
depends_on: deploy-dev
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
18
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1.2
|
|
2
|
+
|
|
3
|
+
FROM --platform=${BUILDPLATFORM:-<%- platformName %>} node:18-alpine AS dev-deps
|
|
4
|
+
|
|
5
|
+
WORKDIR /workdir
|
|
6
|
+
|
|
7
|
+
COPY package.json yarn.lock ./
|
|
8
|
+
|
|
9
|
+
RUN \
|
|
10
|
+
--mount=type=secret,id=npm,dst=/workdir/.npmrc \
|
|
11
|
+
yarn install --frozen-lockfile --ignore-optional --non-interactive && \
|
|
12
|
+
yarn package && \
|
|
13
|
+
yarn cache clean
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": "npx ts-node infra/index.ts",
|
|
3
|
+
"context": {
|
|
4
|
+
"global": {
|
|
5
|
+
"appName": "<%- serviceName %>"
|
|
6
|
+
},
|
|
7
|
+
"dev": {
|
|
8
|
+
"workerLambda": {
|
|
9
|
+
"reservedConcurrency": 1,
|
|
10
|
+
"environment": {
|
|
11
|
+
"SOMETHING": "dev"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"prod": {
|
|
16
|
+
"workerLambda": {
|
|
17
|
+
"reservedConcurrency": 2,
|
|
18
|
+
"environment": {
|
|
19
|
+
"SOMETHING": "prod"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"progress": "events"
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
version: '3.7'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
app:
|
|
5
|
+
environment:
|
|
6
|
+
# Enable Buildkite + GitHub integrations.
|
|
7
|
+
- BUILDKITE
|
|
8
|
+
- BUILDKITE_AGENT_ACCESS_TOKEN
|
|
9
|
+
- BUILDKITE_BRANCH
|
|
10
|
+
- BUILDKITE_BUILD_NUMBER
|
|
11
|
+
- BUILDKITE_JOB_ID
|
|
12
|
+
- BUILDKITE_PIPELINE_DEFAULT_BRANCH
|
|
13
|
+
- BUILDKITE_STEP_ID
|
|
14
|
+
- GITHUB_API_TOKEN
|
|
15
|
+
# Tag AWS resources with the commit hash.
|
|
16
|
+
- BUILDKITE_COMMIT
|
|
17
|
+
# Pass through application configuration.
|
|
18
|
+
- ENVIRONMENT
|
|
19
|
+
- VERSION
|
|
20
|
+
image: ${BUILDKITE_PLUGIN_DOCKER_IMAGE:-''}
|
|
21
|
+
init: true
|
|
22
|
+
volumes:
|
|
23
|
+
- ./:/workdir
|
|
24
|
+
# Mount agent for Buildkite annotations.
|
|
25
|
+
- /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
|
|
26
|
+
# Mount cached dependencies.
|
|
27
|
+
- /workdir/node_modules
|
|
28
|
+
- /workdir/lib/node_modules
|