skuba 14.0.0-esmify-skuba-20251031141102 → 14.0.0-esmify-skuba-20251105032119
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/lib/cli/adapter/eslint.js +4 -2
- package/lib/cli/adapter/eslint.js.map +1 -1
- package/lib/cli/adapter/prettier.js +8 -4
- package/lib/cli/adapter/prettier.js.map +1 -1
- package/lib/cli/build/args.js +4 -2
- package/lib/cli/build/args.js.map +1 -1
- package/lib/cli/build/assets.js +6 -3
- package/lib/cli/build/assets.js.map +1 -1
- package/lib/cli/build/esbuild.js +5 -3
- package/lib/cli/build/esbuild.js.map +2 -2
- package/lib/cli/build/index.js +4 -2
- package/lib/cli/build/index.js.map +1 -1
- package/lib/cli/build/tsc.js +10 -5
- package/lib/cli/build/tsc.js.map +1 -1
- package/lib/cli/buildPackage/index.js +4 -2
- package/lib/cli/buildPackage/index.js.map +1 -1
- package/lib/cli/configure/analyseConfiguration.js +4 -2
- package/lib/cli/configure/analyseConfiguration.js.map +1 -1
- package/lib/cli/configure/analyseDependencies.js +4 -2
- package/lib/cli/configure/analyseDependencies.js.map +1 -1
- package/lib/cli/configure/analysis/diff.js +4 -2
- package/lib/cli/configure/analysis/diff.js.map +1 -1
- package/lib/cli/configure/analysis/files.js +4 -2
- package/lib/cli/configure/analysis/files.js.map +1 -1
- package/lib/cli/configure/analysis/git.js +4 -2
- package/lib/cli/configure/analysis/git.js.map +1 -1
- package/lib/cli/configure/analysis/package.js +6 -3
- package/lib/cli/configure/analysis/package.js.map +1 -1
- package/lib/cli/configure/analysis/project.js +6 -3
- package/lib/cli/configure/analysis/project.js.map +1 -1
- package/lib/cli/configure/dependencies/index.js +12 -6
- package/lib/cli/configure/dependencies/index.js.map +1 -1
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +4 -2
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
- package/lib/cli/configure/dependencies/seekKoala.js +4 -2
- package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
- package/lib/cli/configure/dependencies/skuba.js +4 -2
- package/lib/cli/configure/dependencies/skuba.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDeps.js +4 -2
- package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDive.js +6 -3
- package/lib/cli/configure/dependencies/skubaDive.js.map +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.js +4 -2
- package/lib/cli/configure/ensureTemplateCompletion.js.map +1 -1
- package/lib/cli/configure/getEntryPoint.js +4 -2
- package/lib/cli/configure/getEntryPoint.js.map +1 -1
- package/lib/cli/configure/getProjectType.js +4 -2
- package/lib/cli/configure/getProjectType.js.map +1 -1
- package/lib/cli/configure/index.js +4 -2
- package/lib/cli/configure/index.js.map +1 -1
- package/lib/cli/configure/modules/eslint.js +4 -2
- package/lib/cli/configure/modules/eslint.js.map +1 -1
- package/lib/cli/configure/modules/ignore.js +4 -2
- package/lib/cli/configure/modules/ignore.js.map +1 -1
- package/lib/cli/configure/modules/index.js +4 -2
- package/lib/cli/configure/modules/index.js.map +1 -1
- package/lib/cli/configure/modules/nodemon.js +4 -2
- package/lib/cli/configure/modules/nodemon.js.map +1 -1
- package/lib/cli/configure/modules/package.js +4 -2
- package/lib/cli/configure/modules/package.js.map +1 -1
- package/lib/cli/configure/modules/prettier.js +4 -2
- package/lib/cli/configure/modules/prettier.js.map +1 -1
- package/lib/cli/configure/modules/renovate.js +6 -3
- package/lib/cli/configure/modules/renovate.js.map +1 -1
- package/lib/cli/configure/modules/serverless.js +4 -2
- package/lib/cli/configure/modules/serverless.js.map +1 -1
- package/lib/cli/configure/modules/tslint.js +4 -2
- package/lib/cli/configure/modules/tslint.js.map +1 -1
- package/lib/cli/configure/processing/configFile.js +8 -4
- package/lib/cli/configure/processing/configFile.js.map +1 -1
- package/lib/cli/configure/processing/deleteFiles.js +4 -2
- package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
- package/lib/cli/configure/processing/javascript.js +6 -3
- package/lib/cli/configure/processing/javascript.js.map +1 -1
- package/lib/cli/configure/processing/json.js +6 -3
- package/lib/cli/configure/processing/json.js.map +1 -1
- package/lib/cli/configure/processing/loadFiles.js +4 -2
- package/lib/cli/configure/processing/loadFiles.js.map +1 -1
- package/lib/cli/configure/processing/module.js +4 -2
- package/lib/cli/configure/processing/module.js.map +1 -1
- package/lib/cli/configure/processing/package.js +10 -5
- package/lib/cli/configure/processing/package.js.map +1 -1
- package/lib/cli/configure/processing/prettier.js +4 -2
- package/lib/cli/configure/processing/prettier.js.map +1 -1
- package/lib/cli/configure/processing/record.js +8 -4
- package/lib/cli/configure/processing/record.js.map +1 -1
- package/lib/cli/configure/processing/typescript.js +10 -5
- package/lib/cli/configure/processing/typescript.js.map +1 -1
- package/lib/cli/configure/types.js +0 -1
- package/lib/cli/format/index.js +4 -2
- package/lib/cli/format/index.js.map +1 -1
- package/lib/cli/help/index.js +4 -2
- package/lib/cli/help/index.js.map +1 -1
- package/lib/cli/init/getConfig.js +12 -6
- package/lib/cli/init/getConfig.js.map +1 -1
- package/lib/cli/init/git.js +6 -3
- package/lib/cli/init/git.js.map +1 -1
- package/lib/cli/init/index.js +4 -2
- package/lib/cli/init/index.js.map +1 -1
- package/lib/cli/init/prompts.js +10 -5
- package/lib/cli/init/prompts.js.map +1 -1
- package/lib/cli/init/types.js +4 -2
- package/lib/cli/init/types.js.map +1 -1
- package/lib/cli/init/validation.js +12 -6
- package/lib/cli/init/validation.js.map +1 -1
- package/lib/cli/init/writePackageJson.js +4 -2
- package/lib/cli/init/writePackageJson.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/eslint.js +4 -2
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/index.js +4 -2
- package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/internal.js +4 -2
- package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/prettier.js +4 -2
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/tsc.js +4 -2
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
- package/lib/cli/lint/annotate/github/eslint.js +4 -2
- package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/github/index.js +4 -2
- package/lib/cli/lint/annotate/github/index.js.map +1 -1
- package/lib/cli/lint/annotate/github/internal.js +4 -2
- package/lib/cli/lint/annotate/github/internal.js.map +1 -1
- package/lib/cli/lint/annotate/github/prettier.js +4 -2
- package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/github/tsc.js +4 -2
- package/lib/cli/lint/annotate/github/tsc.js.map +1 -1
- package/lib/cli/lint/annotate/index.js +4 -2
- package/lib/cli/lint/annotate/index.js.map +1 -1
- package/lib/cli/lint/autofix.js +8 -4
- package/lib/cli/lint/autofix.js.map +1 -1
- package/lib/cli/lint/eslint.js +6 -3
- package/lib/cli/lint/eslint.js.map +1 -1
- package/lib/cli/lint/external.js +6 -3
- package/lib/cli/lint/external.js.map +1 -1
- package/lib/cli/lint/index.js +4 -2
- package/lib/cli/lint/index.js.map +1 -1
- package/lib/cli/lint/internal.js +4 -2
- package/lib/cli/lint/internal.js.map +1 -1
- package/lib/cli/lint/internalLints/detectBadCodeowners.js +6 -3
- package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +4 -2
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +1 -1
- package/lib/cli/lint/internalLints/patchRenovateConfig.js +4 -2
- package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +1 -1
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +8 -4
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +8 -4
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js +12 -6
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js +28 -14
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js +6 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js +4 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +1 -1
- package/lib/cli/lint/prettier.js +6 -3
- package/lib/cli/lint/prettier.js.map +1 -1
- package/lib/cli/lint/tsc.js +4 -2
- package/lib/cli/lint/tsc.js.map +1 -1
- package/lib/cli/lint/types.js +0 -1
- package/lib/cli/migrate/index.js +4 -2
- package/lib/cli/migrate/index.js.map +1 -1
- package/lib/cli/migrate/nodeVersion/checks.js +10 -5
- package/lib/cli/migrate/nodeVersion/checks.js.map +1 -1
- package/lib/cli/migrate/nodeVersion/index.js +4 -2
- package/lib/cli/migrate/nodeVersion/index.js.map +1 -1
- package/lib/cli/node/index.js +6 -3
- package/lib/cli/node/index.js.map +1 -1
- package/lib/cli/release/index.js +4 -2
- package/lib/cli/release/index.js.map +1 -1
- package/lib/cli/start/index.js +4 -2
- package/lib/cli/start/index.js.map +1 -1
- package/lib/cli/test/index.js +4 -2
- package/lib/cli/test/index.js.map +1 -1
- package/lib/cli/version/index.js +4 -2
- package/lib/cli/version/index.js.map +1 -1
- package/lib/enquirer.d.js +0 -1
- package/lib/eslint.d.js +0 -1
- package/lib/index.js +10 -5
- package/lib/index.js.map +1 -1
- package/lib/skuba.js +0 -1
- package/lib/skuba.js.map +1 -1
- package/lib/utils/args.js +10 -5
- package/lib/utils/args.js.map +1 -1
- package/lib/utils/command.js +12 -6
- package/lib/utils/command.js.map +1 -1
- package/lib/utils/copy.js +10 -5
- package/lib/utils/copy.js.map +1 -1
- package/lib/utils/dir.js +16 -8
- package/lib/utils/dir.js.map +1 -1
- package/lib/utils/env.js +4 -2
- package/lib/utils/env.js.map +1 -1
- package/lib/utils/error.js +10 -5
- package/lib/utils/error.js.map +1 -1
- package/lib/utils/exec.js +12 -6
- package/lib/utils/exec.js.map +1 -1
- package/lib/utils/fs.js +4 -2
- package/lib/utils/fs.js.map +1 -1
- package/lib/utils/help.js +4 -2
- package/lib/utils/help.js.map +1 -1
- package/lib/utils/logging.js +10 -5
- package/lib/utils/logging.js.map +1 -1
- package/lib/utils/logo.js +4 -2
- package/lib/utils/logo.js.map +1 -1
- package/lib/utils/manifest.js +16 -8
- package/lib/utils/manifest.js.map +1 -1
- package/lib/utils/npmrc.js +4 -2
- package/lib/utils/npmrc.js.map +1 -1
- package/lib/utils/packageManager.js +10 -5
- package/lib/utils/packageManager.js.map +1 -1
- package/lib/utils/port.js +6 -3
- package/lib/utils/port.js.map +1 -1
- package/lib/utils/sleep.js +4 -2
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/template.js +20 -10
- package/lib/utils/template.js.map +1 -1
- package/lib/utils/validation.js +14 -7
- package/lib/utils/validation.js.map +1 -1
- package/lib/utils/version.js +10 -5
- package/lib/utils/version.js.map +1 -1
- package/lib/utils/wait.js +6 -3
- package/lib/utils/wait.js.map +1 -1
- package/lib/utils/worker.js +6 -3
- package/lib/utils/worker.js.map +1 -1
- package/lib/wrapper/function-arguments.d.js +0 -1
- package/lib/wrapper/functionHandler.js +4 -2
- package/lib/wrapper/functionHandler.js.map +1 -1
- package/lib/wrapper/http.js +6 -3
- package/lib/wrapper/http.js.map +1 -1
- package/lib/wrapper/index.js +0 -1
- package/lib/wrapper/index.js.map +1 -1
- package/lib/wrapper/main.js +4 -2
- package/lib/wrapper/main.js.map +1 -1
- package/lib/wrapper/requestListener.js +4 -2
- package/lib/wrapper/requestListener.js.map +1 -1
- package/lib/wrapper/server.js +4 -2
- package/lib/wrapper/server.js.map +1 -1
- package/package.json +4 -4
- package/template/greeter/package.json +2 -2
- package/template/lambda-sqs-worker-cdk/package.json +2 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import chalk from "chalk";
|
|
4
3
|
import enquirer from "enquirer";
|
|
@@ -24,7 +23,7 @@ import {
|
|
|
24
23
|
TEMPLATE_PROMPT
|
|
25
24
|
} from "./prompts.js";
|
|
26
25
|
import { initConfigInputSchema } from "./types.js";
|
|
27
|
-
|
|
26
|
+
const runForm = (props) => {
|
|
28
27
|
const { message, name } = props;
|
|
29
28
|
const choices = props.choices.map((choice) => ({
|
|
30
29
|
...choice,
|
|
@@ -114,7 +113,7 @@ const getTemplateName = async () => {
|
|
|
114
113
|
const generatePlaceholders = (choices) => Object.fromEntries(
|
|
115
114
|
choices.map(({ name }) => [name, `<%- ${name} %>`])
|
|
116
115
|
);
|
|
117
|
-
|
|
116
|
+
const getTemplateConfig = async (dir) => {
|
|
118
117
|
const templateConfigPath = path.join(dir, TEMPLATE_CONFIG_FILENAME);
|
|
119
118
|
try {
|
|
120
119
|
const templateModule = await import(templateConfigPath);
|
|
@@ -155,7 +154,7 @@ const baseToTemplateData = async ({
|
|
|
155
154
|
lambdaServerlessArchitecture: platformName === "amd64" ? "x86_64" : platformName
|
|
156
155
|
};
|
|
157
156
|
};
|
|
158
|
-
|
|
157
|
+
const configureFromPrompt = async () => {
|
|
159
158
|
const { ownerName, platformName, repoName, defaultBranch } = await runForm(BASE_PROMPT_PROPS);
|
|
160
159
|
log.plain(chalk.cyan(repoName), "by", chalk.cyan(ownerName));
|
|
161
160
|
const templateData = await baseToTemplateData({
|
|
@@ -216,7 +215,7 @@ export const configureFromPrompt = async () => {
|
|
|
216
215
|
type
|
|
217
216
|
};
|
|
218
217
|
};
|
|
219
|
-
|
|
218
|
+
const readJSONFromStdIn = async () => {
|
|
220
219
|
let text = "";
|
|
221
220
|
await new Promise(
|
|
222
221
|
(resolve) => process.stdin.on("data", (chunk) => text += chunk.toString()).once("end", resolve)
|
|
@@ -283,5 +282,12 @@ const configureFromPipe = async () => {
|
|
|
283
282
|
type
|
|
284
283
|
};
|
|
285
284
|
};
|
|
286
|
-
|
|
285
|
+
const getConfig = () => process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();
|
|
286
|
+
export {
|
|
287
|
+
configureFromPrompt,
|
|
288
|
+
getConfig,
|
|
289
|
+
getTemplateConfig,
|
|
290
|
+
readJSONFromStdIn,
|
|
291
|
+
runForm
|
|
292
|
+
};
|
|
287
293
|
//# sourceMappingURL=getConfig.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/getConfig.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\n\nimport chalk from 'chalk';\nimport enquirer, { type FormChoice } from 'enquirer';\nimport fs from 'fs-extra';\n\nimport { copyFiles } from '../../utils/copy.js';\nimport { isErrorWithCode } from '../../utils/error.js';\nimport { log } from '../../utils/logging.js';\nimport {\n DEFAULT_PACKAGE_MANAGER,\n configForPackageManager,\n} from '../../utils/packageManager.js';\nimport { getRandomPort } from '../../utils/port.js';\nimport {\n TEMPLATE_CONFIG_FILENAME,\n TEMPLATE_DIR,\n type TemplateConfig,\n templateConfigSchema,\n} from '../../utils/template.js';\n\nimport { downloadGitHubTemplate } from './git.js';\nimport {\n BASE_PROMPT_PROPS,\n type BaseFields,\n type Choice,\n GIT_PATH_PROMPT,\n SHOULD_CONTINUE_PROMPT,\n TEMPLATE_PROMPT,\n} from './prompts.js';\nimport { type InitConfig, initConfigInputSchema } from './types.js';\n\nexport const runForm = <T = Record<string, string>>(props: {\n choices: readonly Choice[];\n message: string;\n name: string;\n}) => {\n const { message, name } = props;\n\n const choices = props.choices.map((choice) => ({\n ...choice,\n validate: (value: string | undefined) => {\n if (\n !value ||\n value === '' ||\n (value === choice.initial && !choice.allowInitial)\n ) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(value) ?? true;\n },\n }));\n\n const form = new enquirer.Form<T>({\n choices,\n message,\n name,\n validate: async (values) => {\n const results = await Promise.all(\n choices.map(async (choice) => choice.validate(values[choice.name])),\n );\n\n return (\n results.find((result) => typeof result === 'string') ??\n results.every((result) => result === true)\n );\n },\n });\n\n return form.run();\n};\n\nconst confirmShouldContinue = async (choices: readonly FormChoice[]) => {\n const fieldsList = choices.map((choice) => choice.message);\n\n log.newline();\n log.plain('This template uses the following information:');\n log.newline();\n fieldsList.forEach((message) => log.subtle(`- ${message}`));\n\n log.newline();\n const result = await SHOULD_CONTINUE_PROMPT.run();\n\n return result === 'yes';\n};\n\nconst createDirectory = async (dir: string) => {\n try {\n await fs.promises.mkdir(dir);\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n log.err(`The directory '${dir}' already exists.`);\n process.exit(1);\n }\n\n throw err;\n }\n};\n\nconst cloneTemplate = async (\n templateName: string,\n destinationDir: string,\n): Promise<TemplateConfig> => {\n const isCustomTemplate = templateName.startsWith('github:');\n\n if (isCustomTemplate) {\n const gitHubPath = templateName.slice('github:'.length);\n\n await downloadGitHubTemplate(gitHubPath, destinationDir);\n } else {\n const templateDir = path.join(TEMPLATE_DIR, templateName);\n\n await copyFiles({\n // assume built-in templates have no extraneous files\n include: () => true,\n sourceRoot: templateDir,\n destinationRoot: destinationDir,\n processors: [],\n // built-in templates have files like _package.json\n stripUnderscorePrefix: true,\n });\n }\n\n const templateConfig = await getTemplateConfig(\n path.join(process.cwd(), destinationDir),\n );\n\n if (isCustomTemplate) {\n log.newline();\n log.warn(\n 'You may need to run',\n log.bold(\n configForPackageManager(templateConfig.packageManager).print.exec,\n 'skuba',\n 'configure',\n ),\n 'once this is done.',\n );\n }\n\n return templateConfig;\n};\n\nconst getTemplateName = async () => {\n const templateSelection = await TEMPLATE_PROMPT.run();\n\n if (templateSelection === 'github \u2192') {\n const gitHubPath = await GIT_PATH_PROMPT.run();\n return `github:${gitHubPath}`;\n }\n\n return templateSelection;\n};\n\nconst generatePlaceholders = (choices: FormChoice[]) =>\n Object.fromEntries(\n choices.map(({ name }) => [name, `<%- ${name} %>`] as const),\n );\n\nexport const getTemplateConfig = async (\n dir: string,\n): Promise<TemplateConfig> => {\n const templateConfigPath = path.join(dir, TEMPLATE_CONFIG_FILENAME);\n\n try {\n const templateModule = (await import(templateConfigPath)) as {\n default: unknown;\n };\n\n return templateConfigSchema.parse(templateModule.default);\n } catch (err) {\n if (isErrorWithCode(err, 'MODULE_NOT_FOUND')) {\n return {\n entryPoint: undefined,\n fields: [],\n packageManager: DEFAULT_PACKAGE_MANAGER,\n type: undefined,\n };\n }\n\n throw err;\n }\n};\n\nconst baseToTemplateData = async ({\n ownerName,\n platformName,\n repoName,\n defaultBranch,\n}: BaseFields) => {\n const [orgName, teamName] = ownerName.split('/');\n\n const port = String(await getRandomPort());\n\n if (!orgName) {\n throw new Error(`Invalid format for owner name: ${ownerName}`);\n }\n\n return {\n orgName,\n ownerName,\n repoName,\n defaultBranch,\n // Use standalone username in `teamName` contexts\n teamName: teamName ?? orgName,\n\n port,\n\n platformName,\n lambdaCdkArchitecture: platformName === 'amd64' ? 'X86_64' : 'ARM_64',\n lambdaServerlessArchitecture:\n platformName === 'amd64' ? 'x86_64' : platformName,\n };\n};\n\nexport const configureFromPrompt = async (): Promise<InitConfig> => {\n const { ownerName, platformName, repoName, defaultBranch } =\n await runForm<BaseFields>(BASE_PROMPT_PROPS);\n log.plain(chalk.cyan(repoName), 'by', chalk.cyan(ownerName));\n\n const templateData = await baseToTemplateData({\n ownerName,\n platformName,\n repoName,\n defaultBranch,\n });\n\n const destinationDir = repoName;\n\n await createDirectory(destinationDir);\n\n log.newline();\n const templateName = await getTemplateName();\n\n const { entryPoint, fields, noSkip, packageManager, type } =\n await cloneTemplate(templateName, destinationDir);\n\n if (fields.length === 0) {\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: true,\n templateData,\n templateName,\n type,\n };\n }\n\n const shouldContinue = noSkip ? true : await confirmShouldContinue(fields);\n\n if (shouldContinue) {\n log.newline();\n const customAnswers = await runForm({\n choices: fields,\n message: chalk.bold(`Complete ${chalk.cyan(templateName)}:`),\n name: 'customAnswers',\n });\n\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: true,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n }\n\n log.newline();\n log.warn(\n `Resume this later with ${chalk.bold(\n configForPackageManager(packageManager).print.exec,\n 'skuba configure',\n )}.`,\n );\n\n const customAnswers = generatePlaceholders(fields);\n\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: false,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n};\n\nexport const readJSONFromStdIn = async () => {\n let text = '';\n\n await new Promise((resolve) =>\n process.stdin\n .on('data', (chunk) => (text += chunk.toString()))\n .once('end', resolve),\n );\n\n text = text.trim();\n\n if (text === '') {\n log.err('No data from stdin.');\n process.exit(1);\n }\n\n let value: unknown;\n\n try {\n value = JSON.parse(text) as unknown;\n } catch {\n log.err('Invalid JSON from stdin.');\n process.exit(1);\n }\n\n return value;\n};\n\nconst configureFromPipe = async (): Promise<InitConfig> => {\n const value = await readJSONFromStdIn();\n\n const result = initConfigInputSchema.safeParse(value);\n\n if (!result.success) {\n log.err('Invalid data from stdin:');\n log.err(result.error);\n process.exit(1);\n }\n\n const { destinationDir, templateComplete, templateName } = result.data;\n\n const templateData = {\n ...(await baseToTemplateData(result.data.templateData)),\n ...result.data.templateData,\n };\n\n await createDirectory(destinationDir);\n\n const { entryPoint, fields, noSkip, packageManager, type } =\n await cloneTemplate(templateName, destinationDir);\n\n if (!templateComplete) {\n if (noSkip) {\n log.err('Templating for', log.bold(templateName), 'cannot be skipped.');\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n packageManager,\n templateData: {\n ...templateData,\n ...generatePlaceholders(fields),\n },\n type,\n };\n }\n\n const required = fields.map(({ name }) => name);\n\n const provided = new Set(Object.keys(templateData));\n\n const missing = required.filter((name) => !provided.has(name));\n\n if (missing.length > 0) {\n log.err('This template uses the following information:');\n log.newline();\n missing.forEach((name) => log.err(`- ${name}`));\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n packageManager,\n templateData,\n type,\n };\n};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IACF;AAAA,EACF;AAEA,QAAM,WAAW,OAAO,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI;AAE9C,QAAM,WAAW,IAAI,IAAI,OAAO,KAAK,YAAY,CAAC;AAElD,QAAM,UAAU,SAAS,OAAO,CAAC,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC;AAE7D,MAAI,QAAQ,SAAS,GAAG;AACtB,QAAI,IAAI,+CAA+C;AACvD,QAAI,QAAQ;AACZ,YAAQ,QAAQ,CAAC,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;AAC9C,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,SAAO;AAAA,IACL,GAAG,OAAO;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,YAAY,MACvB,QAAQ,MAAM,QAAQ,oBAAoB,IAAI,kBAAkB;",
|
|
6
6
|
"names": ["customAnswers"]
|
|
7
7
|
}
|
package/lib/cli/init/git.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import fs from "fs-extra";
|
|
4
3
|
import git from "isomorphic-git";
|
|
5
4
|
import { simpleGit } from "simple-git";
|
|
6
5
|
import { log } from "../../utils/logging.js";
|
|
7
6
|
import * as Git from "@skuba-lib/api/git";
|
|
8
|
-
|
|
7
|
+
const initialiseRepo = async (dir, { orgName, repoName, defaultBranch }) => {
|
|
9
8
|
await git.init({
|
|
10
9
|
defaultBranch,
|
|
11
10
|
dir,
|
|
@@ -22,7 +21,7 @@ export const initialiseRepo = async (dir, { orgName, repoName, defaultBranch })
|
|
|
22
21
|
url: `git@github.com:${orgName}/${repoName}.git`
|
|
23
22
|
});
|
|
24
23
|
};
|
|
25
|
-
|
|
24
|
+
const downloadGitHubTemplate = async (gitHubPath, destinationDir) => {
|
|
26
25
|
log.newline();
|
|
27
26
|
log.plain("Downloading", log.bold(gitHubPath), "from GitHub...");
|
|
28
27
|
await simpleGit().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [
|
|
@@ -34,4 +33,8 @@ export const downloadGitHubTemplate = async (gitHubPath, destinationDir) => {
|
|
|
34
33
|
recursive: true
|
|
35
34
|
});
|
|
36
35
|
};
|
|
36
|
+
export {
|
|
37
|
+
downloadGitHubTemplate,
|
|
38
|
+
initialiseRepo
|
|
39
|
+
};
|
|
37
40
|
//# sourceMappingURL=git.js.map
|
package/lib/cli/init/git.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/git.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport git from 'isomorphic-git';\nimport { simpleGit } from 'simple-git';\n\nimport { log } from '../../utils/logging.js';\n\nimport * as Git from '@skuba-lib/api/git';\n\ninterface GitHubProject {\n orgName: string;\n repoName: string;\n defaultBranch: string;\n}\n\nexport const initialiseRepo = async (\n dir: string,\n { orgName, repoName, defaultBranch }: GitHubProject,\n) => {\n await git.init({\n defaultBranch,\n dir,\n fs,\n });\n\n await Git.commit({\n dir,\n message: 'Initial commit',\n });\n\n await git.addRemote({\n dir,\n fs,\n remote: 'origin',\n url: `git@github.com:${orgName}/${repoName}.git`,\n });\n};\n\nexport const downloadGitHubTemplate = async (\n gitHubPath: string,\n destinationDir: string,\n) => {\n log.newline();\n log.plain('Downloading', log.bold(gitHubPath), 'from GitHub...');\n\n await simpleGit().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [\n '--depth=1',\n '--quiet',\n ]);\n\n await fs.promises.rm(path.join(destinationDir, '.git'), {\n force: true,\n recursive: true,\n });\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAEjB,OAAO,QAAQ;AACf,OAAO,SAAS;AAChB,SAAS,iBAAiB;AAE1B,SAAS,WAAW;AAEpB,YAAY,SAAS;AAQd,MAAM,iBAAiB,OAC5B,KACA,EAAE,SAAS,UAAU,cAAc,MAChC;AACH,QAAM,IAAI,KAAK;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,IAAI,OAAO;AAAA,IACf;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAED,QAAM,IAAI,UAAU;AAAA,IAClB;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,KAAK,kBAAkB,OAAO,IAAI,QAAQ;AAAA,EAC5C,CAAC;AACH;AAEO,MAAM,yBAAyB,OACpC,YACA,mBACG;AACH,MAAI,QAAQ;AACZ,MAAI,MAAM,eAAe,IAAI,KAAK,UAAU,GAAG,gBAAgB;AAE/D,QAAM,UAAU,EAAE,MAAM,kBAAkB,UAAU,QAAQ,gBAAgB;AAAA,IAC1E;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,GAAG,SAAS,GAAG,KAAK,KAAK,gBAAgB,MAAM,GAAG;AAAA,IACtD,OAAO;AAAA,IACP,WAAW;AAAA,EACb,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/cli/init/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import { inspect } from "util";
|
|
4
3
|
import { hasDebugFlag } from "../../utils/args.js";
|
|
@@ -19,7 +18,7 @@ import { getConfig } from "./getConfig.js";
|
|
|
19
18
|
import { initialiseRepo } from "./git.js";
|
|
20
19
|
import { writePackageJson } from "./writePackageJson.js";
|
|
21
20
|
import * as Git from "@skuba-lib/api/git";
|
|
22
|
-
|
|
21
|
+
const init = async (args = process.argv.slice(2)) => {
|
|
23
22
|
const opts = {
|
|
24
23
|
debug: hasDebugFlag(args)
|
|
25
24
|
};
|
|
@@ -137,4 +136,7 @@ export const init = async (args = process.argv.slice(2)) => {
|
|
|
137
136
|
log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);
|
|
138
137
|
log.newline();
|
|
139
138
|
};
|
|
139
|
+
export {
|
|
140
|
+
init
|
|
141
|
+
};
|
|
140
142
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/index.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { hasDebugFlag } from '../../utils/args.js';\nimport { copyFiles, createEjsRenderer } from '../../utils/copy.js';\nimport { createInclusionFilter } from '../../utils/dir.js';\nimport { createExec, ensureCommands } from '../../utils/exec.js';\nimport { createLogger, log } from '../../utils/logging.js';\nimport { showLogoAndVersionInfo } from '../../utils/logo.js';\nimport { getConsumerManifest } from '../../utils/manifest.js';\nimport { detectPackageManager } from '../../utils/packageManager.js';\nimport {\n BASE_TEMPLATE_DIR,\n ensureTemplateConfigDeletion,\n} from '../../utils/template.js';\nimport { runPrettier } from '../adapter/prettier.js';\nimport { tryPatchRenovateConfig } from '../lint/internalLints/patchRenovateConfig.js';\n\nimport { getConfig } from './getConfig.js';\nimport { initialiseRepo } from './git.js';\nimport type { Input } from './types.js';\nimport { writePackageJson } from './writePackageJson.js';\n\nimport * as Git from '@skuba-lib/api/git';\n\nexport const init = async (args = process.argv.slice(2)) => {\n const opts: Input = {\n debug: hasDebugFlag(args),\n };\n\n const skubaVersionInfo = await showLogoAndVersionInfo();\n\n const {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete,\n templateData,\n templateName,\n type,\n } = await getConfig();\n\n await ensureCommands(packageManager);\n\n const include = await createInclusionFilter([\n path.join(destinationDir, '.gitignore'),\n path.join(BASE_TEMPLATE_DIR, '_.gitignore'),\n ]);\n\n const processors = [createEjsRenderer(templateData)];\n\n await copyFiles({\n sourceRoot: BASE_TEMPLATE_DIR,\n destinationRoot: destinationDir,\n include,\n // prefer template-specific files\n overwrite: false,\n processors,\n // base template has files like _eslint.config.js\n stripUnderscorePrefix: true,\n });\n\n await copyFiles({\n sourceRoot: destinationDir,\n destinationRoot: destinationDir,\n include,\n processors,\n });\n\n await Promise.all([\n templateComplete\n ? ensureTemplateConfigDeletion(destinationDir)\n : Promise.resolve(),\n\n writePackageJson({\n cwd: destinationDir,\n entryPoint,\n template: templateName,\n type,\n version: skubaVersionInfo.local,\n }),\n ]);\n\n const exec = createExec({\n cwd: destinationDir,\n stdio: 'pipe',\n streamStdio: packageManager,\n });\n\n log.newline();\n await initialiseRepo(destinationDir, templateData);\n\n const [manifest, packageManagerConfig] = await Promise.all([\n getConsumerManifest(destinationDir),\n detectPackageManager(destinationDir),\n ]);\n\n if (!manifest) {\n throw new Error(\"Repository doesn't contain a package.json file.\");\n }\n\n // Patch in a baseline Renovate preset based on the configured Git owner.\n await tryPatchRenovateConfig({\n mode: 'format',\n dir: destinationDir,\n manifest,\n packageManager: packageManagerConfig,\n });\n\n const skubaSlug = `skuba@${skubaVersionInfo.local}`;\n\n let depsInstalled = false;\n try {\n // The `-D` shorthand is portable across our package managers.\n await exec(packageManager, 'add', '-D', skubaSlug);\n\n // Templating can initially leave certain files in an unformatted state;\n // consider a Markdown table with columns sized based on content length.\n await runPrettier(\n 'format',\n createLogger({ debug: opts.debug }),\n destinationDir,\n );\n\n depsInstalled = true;\n } catch (err) {\n log.warn(inspect(err));\n }\n\n await Git.commitAllChanges({\n dir: destinationDir,\n message: `Clone ${templateName}`,\n });\n\n const logGitHubRepoCreation = () => {\n log.plain(\n 'Next, create an empty',\n log.bold(`${templateData.orgName}/${templateData.repoName}`),\n 'repository:',\n );\n log.ok('https://github.com/new');\n };\n\n if (!depsInstalled) {\n log.newline();\n log.warn(log.bold('\u2717 Failed to install dependencies.'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, resume initialisation:');\n log.ok('cd', destinationDir);\n // The `-D` shorthand is portable across our package managers.\n log.ok(packageManager, 'add', '-D', skubaSlug);\n log.ok(packageManager, 'run', 'format');\n log.ok('git add --all');\n log.ok('git commit --message', `'Pin ${skubaSlug}'`);\n log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);\n\n log.newline();\n process.exitCode = 1;\n return;\n }\n\n log.newline();\n log.ok(log.bold('\u2714 Project initialised!'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, push your local changes:');\n log.ok('cd', destinationDir);\n log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);\n\n log.newline();\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,SAAS,eAAe;AAExB,SAAS,oBAAoB;AAC7B,SAAS,WAAW,yBAAyB;AAC7C,SAAS,6BAA6B;AACtC,SAAS,YAAY,sBAAsB;AAC3C,SAAS,cAAc,WAAW;AAClC,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AAEvC,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAE/B,SAAS,wBAAwB;AAEjC,YAAY,SAAS;AAEd,MAAM,OAAO,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAM;AAC1D,QAAM,OAAc;AAAA,IAClB,OAAO,aAAa,IAAI;AAAA,EAC1B;AAEA,QAAM,mBAAmB,MAAM,uBAAuB;AAEtD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,MAAM,UAAU;AAEpB,QAAM,eAAe,cAAc;AAEnC,QAAM,UAAU,MAAM,sBAAsB;AAAA,IAC1C,KAAK,KAAK,gBAAgB,YAAY;AAAA,IACtC,KAAK,KAAK,mBAAmB,aAAa;AAAA,EAC5C,CAAC;AAED,QAAM,aAAa,CAAC,kBAAkB,YAAY,CAAC;AAEnD,QAAM,UAAU;AAAA,IACd,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB;AAAA;AAAA,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AM;AAClC,QAAI;AAAA,MACF;AAAA,MACA,IAAI,KAAK,GAAG,aAAa,OAAO,IAAI,aAAa,QAAQ,EAAE;AAAA,MAC3D;AAAA,IACF;AACA,QAAI,GAAG,wBAAwB;AAAA,EACjC;AAEA,MAAI,CAAC,eAAe;AAClB,QAAI,QAAQ;AACZ,QAAI,KAAK,IAAI,KAAK,wCAAmC,CAAC;AAEtD,QAAI,QAAQ;AACZ,0BAAsB;AAEtB,QAAI,QAAQ;AACZ,QAAI,MAAM,8BAA8B;AACxC,QAAI,GAAG,MAAM,cAAc;AAE3B,QAAI,GAAG,gBAAgB,OAAO,MAAM,SAAS;AAC7C,QAAI,GAAG,gBAAgB,OAAO,QAAQ;AACtC,QAAI,GAAG,eAAe;AACtB,QAAI,GAAG,wBAAwB,QAAQ,SAAS,GAAG;AACnD,QAAI,GAAG,kCAAkC,aAAa,aAAa,EAAE;AAErE,QAAI,QAAQ;AACZ,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,MAAI,QAAQ;AACZ,MAAI,GAAG,IAAI,KAAK,6BAAwB,CAAC;AAEzC,MAAI,QAAQ;AACZ,wBAAsB;AAEtB,MAAI,QAAQ;AACZ,MAAI,MAAM,gCAAgC;AAC1C,MAAI,GAAG,MAAM,cAAc;AAC3B,MAAI,GAAG,kCAAkC,aAAa,aAAa,EAAE;AAErE,MAAI,QAAQ;AACd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/cli/init/prompts.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import enquirer from "enquirer";
|
|
3
2
|
import { pathExists } from "../../utils/fs.js";
|
|
4
3
|
import { TEMPLATE_NAMES_WITH_BYO } from "../../utils/template.js";
|
|
@@ -55,25 +54,31 @@ const BASE_CHOICES = [
|
|
|
55
54
|
validate: (value) => typeof value === "string" && value.length > 0 ? true : "required"
|
|
56
55
|
}
|
|
57
56
|
];
|
|
58
|
-
|
|
57
|
+
const BASE_PROMPT_PROPS = {
|
|
59
58
|
choices: BASE_CHOICES,
|
|
60
59
|
message: "For starters, some project details:",
|
|
61
60
|
name: "baseAnswers"
|
|
62
61
|
};
|
|
63
|
-
|
|
62
|
+
const SHOULD_CONTINUE_PROMPT = new enquirer.Select({
|
|
64
63
|
choices: ["yes", "no"],
|
|
65
64
|
message: "Fill this in now?",
|
|
66
65
|
name: "shouldContinue"
|
|
67
66
|
});
|
|
68
|
-
|
|
67
|
+
const GIT_PATH_PROMPT = new enquirer.Input({
|
|
69
68
|
message: "Git path",
|
|
70
69
|
name: "gitPath",
|
|
71
70
|
initial: "seek-oss/skuba",
|
|
72
71
|
validate: (value) => /[^/]+\/[^/]+/.test(value) || "Path is not valid"
|
|
73
72
|
});
|
|
74
|
-
|
|
73
|
+
const TEMPLATE_PROMPT = new enquirer.Select({
|
|
75
74
|
choices: TEMPLATE_NAMES_WITH_BYO,
|
|
76
75
|
message: "Select a template:",
|
|
77
76
|
name: "templateName"
|
|
78
77
|
});
|
|
78
|
+
export {
|
|
79
|
+
BASE_PROMPT_PROPS,
|
|
80
|
+
GIT_PATH_PROMPT,
|
|
81
|
+
SHOULD_CONTINUE_PROMPT,
|
|
82
|
+
TEMPLATE_PROMPT
|
|
83
|
+
};
|
|
79
84
|
//# sourceMappingURL=prompts.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/prompts.ts"],
|
|
4
4
|
"sourcesContent": ["import enquirer, { type FormChoice } from 'enquirer';\n\nimport { pathExists } from '../../utils/fs.js';\nimport { TEMPLATE_NAMES_WITH_BYO } from '../../utils/template.js';\n\nimport {\n PLATFORM_OPTIONS,\n type Platform,\n isGitHubOrg,\n isGitHubRepo,\n isGitHubTeam,\n isPlatform,\n} from './validation.js';\n\nexport type Choice = FormChoice & {\n /**\n * Whether the user is allowed to skip field entry and use the initial value.\n *\n * Defaults to `false`.\n */\n allowInitial?: boolean;\n};\n\nexport type BaseFields = Record<\n (typeof BASE_CHOICES)[number]['name'],\n string\n> & {\n platformName: Platform;\n};\n\nconst BASE_CHOICES = [\n {\n name: 'ownerName',\n message: 'Owner',\n initial: 'SEEK-Jobs/my-team',\n validate: (value: unknown) => {\n if (typeof value !== 'string') {\n return 'required';\n }\n\n const [org, team] = value.split('/');\n\n if (!org || !isGitHubOrg(org)) {\n return 'fails GitHub validation';\n }\n\n return (\n team === undefined || isGitHubTeam(team) || 'fails GitHub validation'\n );\n },\n },\n {\n name: 'repoName',\n message: 'Repo',\n initial: 'my-repo',\n validate: async (value: unknown) => {\n if (typeof value !== 'string') {\n return 'required';\n }\n\n if (!isGitHubRepo(value)) {\n return 'fails GitHub validation';\n }\n\n const exists = await pathExists(value);\n\n return !exists || `'${value}' is an existing directory`;\n },\n },\n {\n name: 'platformName',\n message: 'Platform',\n initial: 'arm64',\n allowInitial: true,\n validate: (value: unknown) =>\n isPlatform(value) || `must be ${PLATFORM_OPTIONS}`,\n },\n {\n name: 'defaultBranch',\n message: 'Default Branch',\n initial: 'main',\n allowInitial: true,\n validate: (value: unknown) =>\n typeof value === 'string' && value.length > 0 ? true : 'required',\n },\n] as const;\n\nexport const BASE_PROMPT_PROPS = {\n choices: BASE_CHOICES,\n message: 'For starters, some project details:',\n name: 'baseAnswers',\n};\n\nexport const SHOULD_CONTINUE_PROMPT = new enquirer.Select({\n choices: ['yes', 'no'] as const,\n message: 'Fill this in now?',\n name: 'shouldContinue',\n});\n\nexport const GIT_PATH_PROMPT = new enquirer.Input({\n message: 'Git path',\n name: 'gitPath',\n initial: 'seek-oss/skuba',\n validate: (value) => /[^/]+\\/[^/]+/.test(value) || 'Path is not valid',\n});\n\nexport const TEMPLATE_PROMPT = new enquirer.Select({\n choices: TEMPLATE_NAMES_WITH_BYO,\n message: 'Select a template:',\n name: 'templateName',\n});\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,cAAmC;AAE1C,SAAS,kBAAkB;AAC3B,SA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AAAA,EACT,MAAM;AACR,CAAC;AAEM,MAAM,kBAAkB,IAAI,SAAS,MAAM;AAAA,EAChD,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,UAAU,eAAe,KAAK,KAAK,KAAK;AACrD,CAAC;AAEM,MAAM,kBAAkB,IAAI,SAAS,OAAO;AAAA,EACjD,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AACR,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/cli/init/types.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import * as z from "zod/v4";
|
|
3
2
|
import { projectTypeSchema } from "../../utils/manifest.js";
|
|
4
3
|
import { packageManagerSchema } from "../../utils/packageManager.js";
|
|
5
|
-
|
|
4
|
+
const initConfigInputSchema = z.object({
|
|
6
5
|
destinationDir: z.string(),
|
|
7
6
|
templateComplete: z.boolean(),
|
|
8
7
|
templateData: z.object({
|
|
@@ -31,4 +30,7 @@ const initConfigSchema = initConfigInputSchema.omit({
|
|
|
31
30
|
packageManager: packageManagerSchema,
|
|
32
31
|
type: projectTypeSchema.optional()
|
|
33
32
|
});
|
|
33
|
+
export {
|
|
34
|
+
initConfigInputSchema
|
|
35
|
+
};
|
|
34
36
|
//# sourceMappingURL=types.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/types.ts"],
|
|
4
4
|
"sourcesContent": ["import * as z from 'zod/v4';\n\nimport { projectTypeSchema } from '../../utils/manifest.js';\nimport { packageManagerSchema } from '../../utils/packageManager.js';\n\nexport interface Input {\n /**\n * Whether to enable verbose debug logging.\n *\n * Defaults to `false`.\n */\n debug: boolean;\n}\n\nexport type InitConfigInput = z.infer<typeof initConfigInputSchema>;\n\nexport const initConfigInputSchema = z.object({\n destinationDir: z.string(),\n templateComplete: z.boolean(),\n templateData: z\n .object({\n ownerName: z.string(),\n repoName: z.string(),\n platformName: z.union([z.literal('amd64'), z.literal('arm64')]),\n defaultBranch: z.string(),\n })\n .catchall(z.string()),\n templateName: z.string(),\n});\n\nexport type InitConfig = z.infer<typeof initConfigSchema>;\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst initConfigSchema = initConfigInputSchema\n .omit({\n templateData: true,\n })\n .extend({\n templateData: z\n .object({\n ownerName: z.string(),\n repoName: z.string(),\n defaultBranch: z.string(),\n\n // Derived from ownerName\n // TODO: use zod to transform `InitConfigInput` -> `InitConfig`?\n orgName: z.string(),\n teamName: z.string(),\n\n // Generated by init command\n port: z.string(),\n })\n .catchall(z.string()),\n\n entryPoint: z.string().optional(),\n packageManager: packageManagerSchema,\n type: projectTypeSchema.optional(),\n });\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,YAAY,OAAO;AAEnB,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AAa9B,MAAM,wBAAwB,EAAE,OAAO;AAAA,EAC5C,gBAAgB,EAAE,OAAO;AAAA,EACzB,kBAAkB,EAAE,QAAQ;AAAA,EAC5B,cAAc,EACX,OAAO;AAAA,IACN,WAAW,EAAE,OAAO;AAAA,IACpB,UAAU,EAAE,OAAO;AAAA,IACnB,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,CAAC,CAAC;AAAA,IAC9D,eAAe,EAAE,OAAO;AAAA,EAC1B,CAAC,EACA,SAAS,EAAE,OAAO,CAAC;AAAA,EACtB,cAAc,EAAE,OAAO;AACzB,CAAC;AAKD,MAAM,mBAAmB,sBACtB,KAAK;AAAA,EACJ,cAAc;AAChB,CAAC,EACA,OAAO;AAAA,EACN,cAAc,EACX,OAAO;AAAA,IACN,WAAW,EAAE,OAAO;AAAA,IACpB,UAAU,EAAE,OAAO;AAAA,IACnB,eAAe,EAAE,OAAO;AAAA;AAAA;AAAA,IAIxB,SAAS,EAAE,OAAO;AAAA,IAClB,UAAU,EAAE,OAAO;AAAA;AAAA,IAGnB,MAAM,EAAE,OAAO;AAAA,EACjB,CAAC,EACA,SAAS,EAAE,OAAO,CAAC;AAAA,EAEtB,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,gBAAgB;AAAA,EAChB,MAAM,kBAAkB,SAAS;AACnC,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const isGitHubTeam = (value) => /^[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?$/.test(value) && !value.endsWith("-") && !value.includes("--");
|
|
1
|
+
const isGitHubOrg = (value) => /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/.test(value) && !value.includes("--");
|
|
2
|
+
const isGitHubRepo = (value) => /^[A-Za-z0-9_.-]+$/.test(value) && value !== "." && value !== "..";
|
|
3
|
+
const isGitHubTeam = (value) => /^[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?$/.test(value) && !value.endsWith("-") && !value.includes("--");
|
|
5
4
|
const PLATFORMS = ["amd64", "arm64"];
|
|
6
|
-
|
|
5
|
+
const PLATFORM_OPTIONS = PLATFORMS.join(" | ");
|
|
7
6
|
const platformSet = new Set(PLATFORMS);
|
|
8
|
-
|
|
7
|
+
const isPlatform = (value) => platformSet.has(value);
|
|
8
|
+
export {
|
|
9
|
+
PLATFORM_OPTIONS,
|
|
10
|
+
isGitHubOrg,
|
|
11
|
+
isGitHubRepo,
|
|
12
|
+
isGitHubTeam,
|
|
13
|
+
isPlatform
|
|
14
|
+
};
|
|
9
15
|
//# sourceMappingURL=validation.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/validation.ts"],
|
|
4
4
|
"sourcesContent": ["export const isGitHubOrg = (value: string) =>\n /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/.test(value) &&\n !value.includes('--');\n\nexport const isGitHubRepo = (value: string) =>\n /^[A-Za-z0-9_.-]+$/.test(value) && value !== '.' && value !== '..';\n\nexport const isGitHubTeam = (value: string) =>\n /^[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?$/.test(value) &&\n !value.endsWith('-') &&\n !value.includes('--');\n\nconst PLATFORMS = ['amd64', 'arm64'] as const;\n\nexport type Platform = (typeof PLATFORMS)[number];\n\nexport const PLATFORM_OPTIONS = PLATFORMS.join(' | ');\n\nconst platformSet = new Set<unknown>(PLATFORMS);\n\nexport const isPlatform = (value: unknown) => platformSet.has(value);\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAO,MAAM,cAAc,CAAC,UAC1B,6CAA6C,KAAK,KAAK,KACvD,CAAC,MAAM,SAAS,IAAI;AAEf,MAAM,eAAe,CAAC,UAC3B,oBAAoB,KAAK,KAAK,KAAK,UAAU,OAAO,UAAU;AAEzD,MAAM,eAAe,CAAC,UAC3B,gDAAgD,KAAK,KAAK,KAC1D,CAAC,MAAM,SAAS,GAAG,KACnB,CAAC,MAAM,SAAS,IAAI;AAEtB,MAAM,YAAY,CAAC,SAAS,OAAO;AAI5B,MAAM,mBAAmB,UAAU,KAAK,KAAK;AAEpD,MAAM,cAAc,IAAI,IAAa,SAAS;AAEvC,MAAM,aAAa,CAAC,UAAmB,YAAY,IAAI,KAAK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import fs from "fs-extra";
|
|
3
2
|
import { getDestinationManifest } from "../configure/analysis/package.js";
|
|
4
3
|
import { formatPackage } from "../configure/processing/package.js";
|
|
5
|
-
|
|
4
|
+
const writePackageJson = async ({
|
|
6
5
|
cwd,
|
|
7
6
|
entryPoint,
|
|
8
7
|
template,
|
|
@@ -19,4 +18,7 @@ export const writePackageJson = async ({
|
|
|
19
18
|
const updatedPackageJson = await formatPackage(manifest.packageJson);
|
|
20
19
|
await fs.promises.writeFile(manifest.path, updatedPackageJson);
|
|
21
20
|
};
|
|
21
|
+
export {
|
|
22
|
+
writePackageJson
|
|
23
|
+
};
|
|
22
24
|
//# sourceMappingURL=writePackageJson.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/writePackageJson.ts"],
|
|
4
4
|
"sourcesContent": ["import fs from 'fs-extra';\n\nimport type { ProjectType } from '../../utils/manifest.js';\nimport { getDestinationManifest } from '../configure/analysis/package.js';\nimport { formatPackage } from '../configure/processing/package.js';\n\ninterface WritePackageJsonProps {\n cwd: string;\n entryPoint?: string;\n template: string;\n type?: ProjectType;\n version: string;\n}\n\nexport interface SkubaPackageJson {\n entryPoint: string | null;\n template: string;\n type?: string;\n version: string;\n}\n\n/**\n * Write a `skuba` section into the destination `package.json`.\n */\nexport const writePackageJson = async ({\n cwd,\n entryPoint,\n template,\n type,\n version,\n}: WritePackageJsonProps) => {\n const manifest = await getDestinationManifest({ cwd });\n\n manifest.packageJson.skuba = {\n entryPoint: entryPoint ?? null,\n template,\n type,\n version,\n } satisfies SkubaPackageJson;\n\n const updatedPackageJson = await formatPackage(manifest.packageJson);\n\n await fs.promises.writeFile(manifest.path, updatedPackageJson);\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AAGf,SAAS,8BAA8B;AACvC,SAAS,qBAAqB;AAoBvB,MAAM,mBAAmB,OAAO;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA6B;AAC3B,QAAM,WAAW,MAAM,uBAAuB,EAAE,IAAI,CAAC;AAErD,WAAS,YAAY,QAAQ;AAAA,IAC3B,YAAY,cAAc;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,qBAAqB,MAAM,cAAc,SAAS,WAAW;AAEnE,QAAM,GAAG,SAAS,UAAU,SAAS,MAAM,kBAAkB;AAC/D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import * as Buildkite from "@skuba-lib/api/buildkite";
|
|
3
|
-
|
|
2
|
+
const createEslintAnnotations = (eslint) => !eslint.ok ? ["**ESLint**", Buildkite.md.terminal(eslint.output.trim())] : [];
|
|
3
|
+
export {
|
|
4
|
+
createEslintAnnotations
|
|
5
|
+
};
|
|
4
6
|
//# sourceMappingURL=eslint.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/annotate/buildkite/eslint.ts"],
|
|
4
4
|
"sourcesContent": ["import type { ESLintOutput } from '../../../adapter/eslint.js';\n\nimport * as Buildkite from '@skuba-lib/api/buildkite';\n\nexport const createEslintAnnotations = (eslint: ESLintOutput): string[] =>\n !eslint.ok ? ['**ESLint**', Buildkite.md.terminal(eslint.output.trim())] : [];\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAEA,YAAY,eAAe;AAEpB,MAAM,0BAA0B,CAAC,WACtC,CAAC,OAAO,KAAK,CAAC,cAAc,UAAU,GAAG,SAAS,OAAO,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { createEslintAnnotations } from "./eslint.js";
|
|
3
2
|
import { createInternalAnnotations } from "./internal.js";
|
|
4
3
|
import { createPrettierAnnotations } from "./prettier.js";
|
|
5
4
|
import { createTscAnnotations } from "./tsc.js";
|
|
6
5
|
import * as Buildkite from "@skuba-lib/api/buildkite";
|
|
7
|
-
|
|
6
|
+
const createBuildkiteAnnotations = async (internal, eslint, prettier, tscOk, tscOutputStream) => {
|
|
8
7
|
if (internal.ok && eslint.ok && prettier.ok && tscOk) {
|
|
9
8
|
return;
|
|
10
9
|
}
|
|
@@ -21,4 +20,7 @@ export const createBuildkiteAnnotations = async (internal, eslint, prettier, tsc
|
|
|
21
20
|
style: "error"
|
|
22
21
|
});
|
|
23
22
|
};
|
|
23
|
+
export {
|
|
24
|
+
createBuildkiteAnnotations
|
|
25
|
+
};
|
|
24
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/annotate/buildkite/index.ts"],
|
|
4
4
|
"sourcesContent": ["import type { ESLintOutput } from '../../../adapter/eslint.js';\nimport type { PrettierOutput } from '../../../adapter/prettier.js';\nimport type { StreamInterceptor } from '../../../lint/external.js';\nimport type { InternalLintResult } from '../../internal.js';\n\nimport { createEslintAnnotations } from './eslint.js';\nimport { createInternalAnnotations } from './internal.js';\nimport { createPrettierAnnotations } from './prettier.js';\nimport { createTscAnnotations } from './tsc.js';\n\nimport * as Buildkite from '@skuba-lib/api/buildkite';\nexport const createBuildkiteAnnotations = async (\n internal: InternalLintResult,\n eslint: ESLintOutput,\n prettier: PrettierOutput,\n tscOk: boolean,\n tscOutputStream: StreamInterceptor,\n): Promise<void> => {\n if (internal.ok && eslint.ok && prettier.ok && tscOk) {\n return;\n }\n\n const buildkiteOutput = [\n '`skuba lint` found issues that require triage:',\n ...createInternalAnnotations(internal),\n ...createEslintAnnotations(eslint),\n ...createPrettierAnnotations(prettier),\n ...createTscAnnotations(tscOk, tscOutputStream),\n ].join('\\n\\n');\n\n await Buildkite.annotate(buildkiteOutput, {\n context: 'skuba-lint',\n scopeContextToStep: true,\n style: 'error',\n });\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAKA,SAAS,+BAA+B;AACxC,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,4BAA4B;AAErC,YAAY,eAAe;AACpB,MAAM,6BAA6B,OACxC,UACA,QACA,UACA,OACA,oBACkB;AAClB,MAAI,SAAS,MAAM,OAAO,MAAM,SAAS,MAAM,OAAO;AACpD;AAAA,EACF;AAEA,QAAM,kBAAkB;AAAA,IACtB;AAAA,IACA,GAAG,0BAA0B,QAAQ;AAAA,IACrC,GAAG,wBAAwB,MAAM;AAAA,IACjC,GAAG,0BAA0B,QAAQ;AAAA,IACrC,GAAG,qBAAqB,OAAO,eAAe;AAAA,EAChD,EAAE,KAAK,MAAM;AAEb,QAAM,UAAU,SAAS,iBAAiB;AAAA,IACxC,SAAS;AAAA,IACT,oBAAoB;AAAA,IACpB,OAAO;AAAA,EACT,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import * as Buildkite from "@skuba-lib/api/buildkite";
|
|
3
|
-
|
|
2
|
+
const createInternalAnnotations = (internal) => !internal.ok && internal.annotations?.length ? [
|
|
4
3
|
"**skuba**",
|
|
5
4
|
Buildkite.md.terminal(
|
|
6
5
|
internal.annotations.map(({ message, path }) => `${path} ${message}`).join("\n")
|
|
7
6
|
)
|
|
8
7
|
] : [];
|
|
8
|
+
export {
|
|
9
|
+
createInternalAnnotations
|
|
10
|
+
};
|
|
9
11
|
//# sourceMappingURL=internal.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/annotate/buildkite/internal.ts"],
|
|
4
4
|
"sourcesContent": ["import type { InternalLintResult } from '../../internal.js';\n\nimport * as Buildkite from '@skuba-lib/api/buildkite';\nexport const createInternalAnnotations = (\n internal: InternalLintResult,\n): string[] =>\n !internal.ok && internal.annotations?.length\n ? [\n '**skuba**',\n Buildkite.md.terminal(\n internal.annotations\n .map(({ message, path }) => `${path} ${message}`)\n .join('\\n'),\n ),\n ]\n : [];\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAEA,YAAY,eAAe;AACpB,MAAM,4BAA4B,CACvC,aAEA,CAAC,SAAS,MAAM,SAAS,aAAa,SAClC;AAAA,EACE;AAAA,EACA,UAAU,GAAG;AAAA,IACX,SAAS,YACN,IAAI,CAAC,EAAE,SAAS,KAAK,MAAM,GAAG,IAAI,IAAI,OAAO,EAAE,EAC/C,KAAK,IAAI;AAAA,EACd;AACF,IACA,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import * as Buildkite from "@skuba-lib/api/buildkite";
|
|
3
|
-
|
|
2
|
+
const createPrettierAnnotations = (prettier) => !prettier.ok ? [
|
|
4
3
|
"**Prettier**",
|
|
5
4
|
Buildkite.md.terminal(
|
|
6
5
|
prettier.result.errored.map(
|
|
@@ -11,4 +10,7 @@ export const createPrettierAnnotations = (prettier) => !prettier.ok ? [
|
|
|
11
10
|
).join("\n")
|
|
12
11
|
)
|
|
13
12
|
] : [];
|
|
13
|
+
export {
|
|
14
|
+
createPrettierAnnotations
|
|
15
|
+
};
|
|
14
16
|
//# sourceMappingURL=prettier.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/annotate/buildkite/prettier.ts"],
|
|
4
4
|
"sourcesContent": ["import type { PrettierOutput } from '../../../adapter/prettier.js';\n\nimport * as Buildkite from '@skuba-lib/api/buildkite';\n\nexport const createPrettierAnnotations = (\n prettier: PrettierOutput,\n): string[] =>\n !prettier.ok\n ? [\n '**Prettier**',\n Buildkite.md.terminal(\n prettier.result.errored\n .map(({ err, filepath }) =>\n [\n filepath,\n ...(typeof err === 'string' || err instanceof Error\n ? [String(err)]\n : []),\n ].join(' '),\n )\n .join('\\n'),\n ),\n ]\n : [];\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAEA,YAAY,eAAe;AAEpB,MAAM,4BAA4B,CACvC,aAEA,CAAC,SAAS,KACN;AAAA,EACE;AAAA,EACA,UAAU,GAAG;AAAA,IACX,SAAS,OAAO,QACb;AAAA,MAAI,CAAC,EAAE,KAAK,SAAS,MACpB;AAAA,QACE;AAAA,QACA,GAAI,OAAO,QAAQ,YAAY,eAAe,QAC1C,CAAC,OAAO,GAAG,CAAC,IACZ,CAAC;AAAA,MACP,EAAE,KAAK,GAAG;AAAA,IACZ,EACC,KAAK,IAAI;AAAA,EACd;AACF,IACA,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import * as Buildkite from "@skuba-lib/api/buildkite";
|
|
3
|
-
|
|
2
|
+
const createTscAnnotations = (tscOk, tscOutputStream) => !tscOk ? [
|
|
4
3
|
"**tsc**",
|
|
5
4
|
Buildkite.md.terminal(
|
|
6
5
|
tscOutputStream.output().split("\n").filter(Boolean).filter((line) => !line.startsWith("TSFILE: ")).join("\n").trim()
|
|
7
6
|
)
|
|
8
7
|
] : [];
|
|
8
|
+
export {
|
|
9
|
+
createTscAnnotations
|
|
10
|
+
};
|
|
9
11
|
//# sourceMappingURL=tsc.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/annotate/buildkite/tsc.ts"],
|
|
4
4
|
"sourcesContent": ["import type { StreamInterceptor } from '../../../lint/external.js';\n\nimport * as Buildkite from '@skuba-lib/api/buildkite';\n\nexport const createTscAnnotations = (\n tscOk: boolean,\n tscOutputStream: StreamInterceptor,\n): string[] =>\n !tscOk\n ? [\n '**tsc**',\n Buildkite.md.terminal(\n tscOutputStream\n .output()\n .split('\\n')\n .filter(Boolean)\n .filter((line) => !line.startsWith('TSFILE: '))\n .join('\\n')\n .trim(),\n ),\n ]\n : [];\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAEA,YAAY,eAAe;AAEpB,MAAM,uBAAuB,CAClC,OACA,oBAEA,CAAC,QACG;AAAA,EACE;AAAA,EACA,UAAU,GAAG;AAAA,IACX,gBACG,OAAO,EACP,MAAM,IAAI,EACV,OAAO,OAAO,EACd,OAAO,CAAC,SAAS,CAAC,KAAK,WAAW,UAAU,CAAC,EAC7C,KAAK,IAAI,EACT,KAAK;AAAA,EACV;AACF,IACA,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export const createEslintAnnotations = (eslint) => [...eslint.errors, ...eslint.warnings].flatMap(
|
|
1
|
+
const createEslintAnnotations = (eslint) => [...eslint.errors, ...eslint.warnings].flatMap(
|
|
3
2
|
(result) => result.messages.map((message) => {
|
|
4
3
|
const isSameLine = message.line === message.endLine;
|
|
5
4
|
const startColumn = isSameLine && message.column;
|
|
@@ -16,4 +15,7 @@ export const createEslintAnnotations = (eslint) => [...eslint.errors, ...eslint.
|
|
|
16
15
|
};
|
|
17
16
|
})
|
|
18
17
|
);
|
|
18
|
+
export {
|
|
19
|
+
createEslintAnnotations
|
|
20
|
+
};
|
|
19
21
|
//# sourceMappingURL=eslint.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/annotate/github/eslint.ts"],
|
|
4
4
|
"sourcesContent": ["import type { ESLintOutput } from '../../../adapter/eslint.js';\n\nimport type * as GitHub from '@skuba-lib/api/github';\n\nexport const createEslintAnnotations = (\n eslint: ESLintOutput,\n): GitHub.Annotation[] =>\n [...eslint.errors, ...eslint.warnings].flatMap<GitHub.Annotation>((result) =>\n result.messages.map((message): GitHub.Annotation => {\n // Annotations only support start_column and end_column on the same line.\n const isSameLine = message.line === message.endLine;\n const startColumn = isSameLine && message.column;\n const endColumn = (isSameLine && message.endColumn) || startColumn;\n\n return {\n annotation_level: message.severity === 2 ? 'failure' : 'warning',\n start_line: message.line ?? 1,\n end_line: message.endLine ?? message.line ?? 1,\n ...(startColumn && { start_column: startColumn }),\n ...(endColumn && { end_column: endColumn }),\n message: message.message,\n path: result.filePath,\n title: `ESLint${message.ruleId ? ` (${message.ruleId})` : ''}`,\n };\n }),\n );\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAIO,MAAM,0BAA0B,CACrC,WAEA,CAAC,GAAG,OAAO,QAAQ,GAAG,OAAO,QAAQ,EAAE;AAAA,EAA2B,CAAC,WACjE,OAAO,SAAS,IAAI,CAAC,YAA+B;AAElD,UAAM,aAAa,QAAQ,SAAS,QAAQ;AAC5C,UAAM,cAAc,cAAc,QAAQ;AAC1C,UAAM,YAAa,cAAc,QAAQ,aAAc;AAEvD,WAAO;AAAA,MACL,kBAAkB,QAAQ,aAAa,IAAI,YAAY;AAAA,MACvD,YAAY,QAAQ,QAAQ;AAAA,MAC5B,UAAU,QAAQ,WAAW,QAAQ,QAAQ;AAAA,MAC7C,GAAI,eAAe,EAAE,cAAc,YAAY;AAAA,MAC/C,GAAI,aAAa,EAAE,YAAY,UAAU;AAAA,MACzC,SAAS,QAAQ;AAAA,MACjB,MAAM,OAAO;AAAA,MACb,OAAO,SAAS,QAAQ,SAAS,KAAK,QAAQ,MAAM,MAAM,EAAE;AAAA,IAC9D;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import { createEslintAnnotations } from "./eslint.js";
|
|
3
2
|
import { createInternalAnnotations } from "./internal.js";
|
|
4
3
|
import { createPrettierAnnotations } from "./prettier.js";
|
|
5
4
|
import { createTscAnnotations } from "./tsc.js";
|
|
6
5
|
import * as GitHub from "@skuba-lib/api/github";
|
|
7
|
-
|
|
6
|
+
const createGitHubAnnotations = async (internal, eslint, prettier, tscOk, tscOutputStream) => {
|
|
8
7
|
if (!GitHub.enabledFromEnvironment()) {
|
|
9
8
|
return;
|
|
10
9
|
}
|
|
@@ -25,4 +24,7 @@ export const createGitHubAnnotations = async (internal, eslint, prettier, tscOk,
|
|
|
25
24
|
title: `${build} ${isOk ? "passed" : "failed"}`
|
|
26
25
|
});
|
|
27
26
|
};
|
|
27
|
+
export {
|
|
28
|
+
createGitHubAnnotations
|
|
29
|
+
};
|
|
28
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/annotate/github/index.ts"],
|
|
4
4
|
"sourcesContent": ["import type { ESLintOutput } from '../../../adapter/eslint.js';\nimport type { PrettierOutput } from '../../../adapter/prettier.js';\nimport type { StreamInterceptor } from '../../../lint/external.js';\nimport type { InternalLintResult } from '../../internal.js';\n\nimport { createEslintAnnotations } from './eslint.js';\nimport { createInternalAnnotations } from './internal.js';\nimport { createPrettierAnnotations } from './prettier.js';\nimport { createTscAnnotations } from './tsc.js';\n\nimport * as GitHub from '@skuba-lib/api/github';\n\nexport const createGitHubAnnotations = async (\n internal: InternalLintResult,\n eslint: ESLintOutput,\n prettier: PrettierOutput,\n tscOk: boolean,\n tscOutputStream: StreamInterceptor,\n) => {\n if (!GitHub.enabledFromEnvironment()) {\n return;\n }\n\n const annotations: GitHub.Annotation[] = [\n ...createInternalAnnotations(internal),\n ...createEslintAnnotations(eslint),\n ...createPrettierAnnotations(prettier),\n ...createTscAnnotations(tscOk, tscOutputStream),\n ];\n\n const isOk = eslint.ok && prettier.ok && internal.ok && tscOk;\n\n const summary = isOk\n ? '`skuba lint` passed.'\n : '`skuba lint` found issues that require triage.';\n\n const build = GitHub.buildNameFromEnvironment();\n\n await GitHub.createCheckRun({\n name: 'skuba/lint',\n summary,\n annotations,\n conclusion: isOk ? 'success' : 'failure',\n title: `${build} ${isOk ? 'passed' : 'failed'}`,\n });\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAKA,SAAS,+BAA+B;AACxC,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,4BAA4B;AAErC,YAAY,YAAY;AAEjB,MAAM,0BAA0B,OACrC,UACA,QACA,UACA,OACA,oBACG;AACH,MAAI,CAAC,OAAO,uBAAuB,GAAG;AACpC;AAAA,EACF;AAEA,QAAM,cAAmC;AAAA,IACvC,GAAG,0BAA0B,QAAQ;AAAA,IACrC,GAAG,wBAAwB,MAAM;AAAA,IACjC,GAAG,0BAA0B,QAAQ;AAAA,IACrC,GAAG,qBAAqB,OAAO,eAAe;AAAA,EAChD;AAEA,QAAM,OAAO,OAAO,MAAM,SAAS,MAAM,SAAS,MAAM;AAExD,QAAM,UAAU,OACZ,yBACA;AAEJ,QAAM,QAAQ,OAAO,yBAAyB;AAE9C,QAAM,OAAO,eAAe;AAAA,IAC1B,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,YAAY,OAAO,YAAY;AAAA,IAC/B,OAAO,GAAG,KAAK,IAAI,OAAO,WAAW,QAAQ;AAAA,EAC/C,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export const createInternalAnnotations = (internal) => (internal.annotations ?? []).map((annotation) => ({
|
|
1
|
+
const createInternalAnnotations = (internal) => (internal.annotations ?? []).map((annotation) => ({
|
|
3
2
|
annotation_level: "failure",
|
|
4
3
|
start_line: annotation.start_line ?? 1,
|
|
5
4
|
end_line: annotation.end_line ?? annotation.start_line ?? 1,
|
|
@@ -7,4 +6,7 @@ export const createInternalAnnotations = (internal) => (internal.annotations ??
|
|
|
7
6
|
message: annotation.message,
|
|
8
7
|
title: "skuba lint"
|
|
9
8
|
}));
|
|
9
|
+
export {
|
|
10
|
+
createInternalAnnotations
|
|
11
|
+
};
|
|
10
12
|
//# sourceMappingURL=internal.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/annotate/github/internal.ts"],
|
|
4
4
|
"sourcesContent": ["import type { InternalLintResult } from '../../internal.js';\n\nimport type * as GitHub from '@skuba-lib/api/github';\n\nexport const createInternalAnnotations = (\n internal: InternalLintResult,\n): GitHub.Annotation[] =>\n (internal.annotations ?? []).map((annotation) => ({\n annotation_level: 'failure',\n start_line: annotation.start_line ?? 1,\n end_line: annotation.end_line ?? annotation.start_line ?? 1,\n path: annotation.path,\n message: annotation.message,\n title: 'skuba lint',\n }));\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAIO,MAAM,4BAA4B,CACvC,cAEC,SAAS,eAAe,CAAC,GAAG,IAAI,CAAC,gBAAgB;AAAA,EAChD,kBAAkB;AAAA,EAClB,YAAY,WAAW,cAAc;AAAA,EACrC,UAAU,WAAW,YAAY,WAAW,cAAc;AAAA,EAC1D,MAAM,WAAW;AAAA,EACjB,SAAS,WAAW;AAAA,EACpB,OAAO;AACT,EAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export const createPrettierAnnotations = (prettier) => prettier.result.errored.map((result) => {
|
|
1
|
+
const createPrettierAnnotations = (prettier) => prettier.result.errored.map((result) => {
|
|
3
2
|
const message = result.err instanceof Error ? result.err.message : result.err;
|
|
4
3
|
return {
|
|
5
4
|
annotation_level: "failure",
|
|
@@ -10,4 +9,7 @@ export const createPrettierAnnotations = (prettier) => prettier.result.errored.m
|
|
|
10
9
|
title: "Prettier"
|
|
11
10
|
};
|
|
12
11
|
});
|
|
12
|
+
export {
|
|
13
|
+
createPrettierAnnotations
|
|
14
|
+
};
|
|
13
15
|
//# sourceMappingURL=prettier.js.map
|