skuba 0.0.0-master-20231002013336 → 0.0.0-master-20240206001217

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/README.md +3 -3
  2. package/jest/transform.test.ts +3 -1
  3. package/lib/api/jest/index.d.ts +3 -3
  4. package/lib/api/jest/index.js +19 -1
  5. package/lib/api/jest/index.js.map +2 -2
  6. package/lib/api/net/compose.js +2 -1
  7. package/lib/api/net/compose.js.map +2 -2
  8. package/lib/cli/adapter/prettier.d.ts +1 -1
  9. package/lib/cli/adapter/prettier.js +11 -10
  10. package/lib/cli/adapter/prettier.js.map +2 -2
  11. package/lib/cli/build/index.js +0 -2
  12. package/lib/cli/build/index.js.map +2 -2
  13. package/lib/cli/buildPackage.js +0 -2
  14. package/lib/cli/buildPackage.js.map +2 -2
  15. package/lib/cli/configure/analyseConfiguration.d.ts +2 -0
  16. package/lib/cli/configure/analyseConfiguration.js.map +2 -2
  17. package/lib/cli/configure/getEntryPoint.js +1 -1
  18. package/lib/cli/configure/getEntryPoint.js.map +2 -2
  19. package/lib/cli/configure/getProjectType.d.ts +1 -1
  20. package/lib/cli/configure/getProjectType.js +6 -3
  21. package/lib/cli/configure/getProjectType.js.map +2 -2
  22. package/lib/cli/configure/index.js +11 -12
  23. package/lib/cli/configure/index.js.map +2 -2
  24. package/lib/cli/configure/modules/index.js +0 -2
  25. package/lib/cli/configure/modules/index.js.map +2 -2
  26. package/lib/cli/configure/modules/package.d.ts +1 -1
  27. package/lib/cli/configure/modules/package.js +2 -1
  28. package/lib/cli/configure/modules/package.js.map +2 -2
  29. package/lib/cli/configure/patchRenovateConfig.d.ts +2 -1
  30. package/lib/cli/configure/patchRenovateConfig.js +36 -21
  31. package/lib/cli/configure/patchRenovateConfig.js.map +2 -2
  32. package/lib/cli/configure/types.d.ts +2 -0
  33. package/lib/cli/configure/types.js.map +1 -1
  34. package/lib/cli/configure/upgrade/index.d.ts +15 -0
  35. package/lib/cli/configure/upgrade/index.js +130 -0
  36. package/lib/cli/configure/upgrade/index.js.map +7 -0
  37. package/lib/cli/configure/{addEmptyExports.d.ts → upgrade/patches/7.3.1/addEmptyExports.d.ts} +2 -2
  38. package/lib/cli/configure/{addEmptyExports.js → upgrade/patches/7.3.1/addEmptyExports.js} +15 -11
  39. package/lib/cli/configure/upgrade/patches/7.3.1/addEmptyExports.js.map +7 -0
  40. package/lib/cli/configure/upgrade/patches/7.3.1/index.d.ts +2 -0
  41. package/lib/cli/configure/upgrade/patches/7.3.1/index.js +55 -0
  42. package/lib/cli/configure/upgrade/patches/7.3.1/index.js.map +7 -0
  43. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.d.ts +2 -0
  44. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js +94 -0
  45. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js.map +7 -0
  46. package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.d.ts +2 -0
  47. package/lib/cli/configure/{patchDockerfile.js → upgrade/patches/7.3.1/patchDockerfile.js} +18 -12
  48. package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.js.map +7 -0
  49. package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.d.ts +2 -0
  50. package/lib/cli/configure/{patchServerListener.js → upgrade/patches/7.3.1/patchServerListener.js} +18 -14
  51. package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.js.map +7 -0
  52. package/lib/cli/format.js +7 -14
  53. package/lib/cli/format.js.map +2 -2
  54. package/lib/cli/init/getConfig.d.ts +7 -5
  55. package/lib/cli/init/getConfig.js +61 -34
  56. package/lib/cli/init/getConfig.js.map +2 -2
  57. package/lib/cli/init/git.d.ts +2 -1
  58. package/lib/cli/init/git.js +2 -9
  59. package/lib/cli/init/git.js.map +2 -2
  60. package/lib/cli/init/index.d.ts +1 -1
  61. package/lib/cli/init/index.js +19 -10
  62. package/lib/cli/init/index.js.map +2 -2
  63. package/lib/cli/init/prompts.d.ts +26 -3
  64. package/lib/cli/init/prompts.js +10 -2
  65. package/lib/cli/init/prompts.js.map +2 -2
  66. package/lib/cli/init/types.d.ts +120 -27
  67. package/lib/cli/init/types.js +30 -35
  68. package/lib/cli/init/types.js.map +2 -2
  69. package/lib/cli/init/writePackageJson.d.ts +6 -0
  70. package/lib/cli/init/writePackageJson.js.map +2 -2
  71. package/lib/cli/lint/annotate/buildkite/index.d.ts +2 -1
  72. package/lib/cli/lint/annotate/buildkite/index.js +5 -3
  73. package/lib/cli/lint/annotate/buildkite/index.js.map +2 -2
  74. package/lib/cli/lint/annotate/buildkite/internal.d.ts +2 -0
  75. package/lib/cli/lint/annotate/buildkite/internal.js +45 -0
  76. package/lib/cli/lint/annotate/buildkite/internal.js.map +7 -0
  77. package/lib/cli/lint/annotate/github/index.d.ts +2 -1
  78. package/lib/cli/lint/annotate/github/index.js +4 -2
  79. package/lib/cli/lint/annotate/github/index.js.map +2 -2
  80. package/lib/cli/lint/annotate/github/internal.d.ts +3 -0
  81. package/lib/cli/lint/annotate/github/internal.js +36 -0
  82. package/lib/cli/lint/annotate/github/internal.js.map +7 -0
  83. package/lib/cli/lint/annotate/index.d.ts +4 -3
  84. package/lib/cli/lint/annotate/index.js +9 -3
  85. package/lib/cli/lint/annotate/index.js.map +2 -2
  86. package/lib/cli/lint/autofix.d.ts +3 -1
  87. package/lib/cli/lint/autofix.js +36 -59
  88. package/lib/cli/lint/autofix.js.map +3 -3
  89. package/lib/cli/lint/external.d.ts +6 -1
  90. package/lib/cli/lint/external.js +6 -29
  91. package/lib/cli/lint/external.js.map +2 -2
  92. package/lib/cli/lint/index.d.ts +2 -1
  93. package/lib/cli/lint/index.js +46 -14
  94. package/lib/cli/lint/index.js.map +2 -2
  95. package/lib/cli/lint/internal.d.ts +12 -1
  96. package/lib/cli/lint/internal.js +55 -19
  97. package/lib/cli/lint/internal.js.map +3 -3
  98. package/lib/cli/lint/internalLints/deleteFiles.d.ts +3 -0
  99. package/lib/cli/lint/internalLints/deleteFiles.js +102 -0
  100. package/lib/cli/lint/internalLints/deleteFiles.js.map +7 -0
  101. package/lib/cli/lint/internalLints/noSkubaTemplateJs.d.ts +3 -0
  102. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +75 -0
  103. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +7 -0
  104. package/lib/cli/lint/internalLints/refreshConfigFiles.d.ts +11 -0
  105. package/lib/cli/lint/internalLints/refreshConfigFiles.js +147 -0
  106. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +7 -0
  107. package/lib/cli/test/index.js +0 -2
  108. package/lib/cli/test/index.js.map +2 -2
  109. package/lib/skuba.d.ts +1 -1
  110. package/lib/skuba.js.map +1 -1
  111. package/lib/utils/error.d.ts +30 -10
  112. package/lib/utils/error.js +10 -20
  113. package/lib/utils/error.js.map +2 -2
  114. package/lib/utils/exec.d.ts +2 -1
  115. package/lib/utils/exec.js +3 -2
  116. package/lib/utils/exec.js.map +2 -2
  117. package/lib/utils/logging.d.ts +2 -0
  118. package/lib/utils/logging.js +1 -0
  119. package/lib/utils/logging.js.map +2 -2
  120. package/lib/utils/logo.js +6 -10
  121. package/lib/utils/logo.js.map +3 -3
  122. package/lib/utils/manifest.d.ts +4 -4
  123. package/lib/utils/manifest.js +10 -10
  124. package/lib/utils/manifest.js.map +2 -2
  125. package/lib/utils/npmrc.d.ts +1 -0
  126. package/lib/utils/npmrc.js +29 -0
  127. package/lib/utils/npmrc.js.map +7 -0
  128. package/lib/utils/packageManager.d.ts +24 -0
  129. package/lib/utils/packageManager.js +97 -0
  130. package/lib/utils/packageManager.js.map +7 -0
  131. package/lib/utils/template.d.ts +46 -13
  132. package/lib/utils/template.js +17 -15
  133. package/lib/utils/template.js.map +2 -2
  134. package/lib/utils/worker.d.ts +1 -0
  135. package/lib/wrapper/http.d.ts +1 -0
  136. package/package.json +50 -47
  137. package/template/base/_.dockerignore +0 -1
  138. package/template/base/_.eslintignore +1 -0
  139. package/template/base/_.gitignore +1 -1
  140. package/template/base/_.npmrc +8 -0
  141. package/template/express-rest-api/.buildkite/pipeline.yml +16 -12
  142. package/template/express-rest-api/.gantry/dev.yml +3 -0
  143. package/template/express-rest-api/.nvmrc +1 -1
  144. package/template/express-rest-api/Dockerfile +6 -12
  145. package/template/express-rest-api/Dockerfile.dev-deps +8 -7
  146. package/template/express-rest-api/README.md +12 -12
  147. package/template/express-rest-api/docker-compose.yml +0 -10
  148. package/template/express-rest-api/gantry.apply.yml +5 -0
  149. package/template/express-rest-api/gantry.build.yml +1 -2
  150. package/template/express-rest-api/package.json +4 -4
  151. package/template/express-rest-api/skuba.template.js +1 -0
  152. package/template/greeter/.buildkite/pipeline.yml +15 -11
  153. package/template/greeter/.nvmrc +1 -1
  154. package/template/greeter/Dockerfile +8 -7
  155. package/template/greeter/README.md +9 -9
  156. package/template/greeter/docker-compose.yml +0 -10
  157. package/template/greeter/package.json +3 -3
  158. package/template/greeter/skuba.template.js +1 -0
  159. package/template/koa-rest-api/.buildkite/pipeline.yml +16 -12
  160. package/template/koa-rest-api/.gantry/dev.yml +3 -0
  161. package/template/koa-rest-api/.nvmrc +1 -1
  162. package/template/koa-rest-api/Dockerfile +6 -12
  163. package/template/koa-rest-api/Dockerfile.dev-deps +8 -7
  164. package/template/koa-rest-api/README.md +12 -12
  165. package/template/koa-rest-api/docker-compose.yml +0 -10
  166. package/template/koa-rest-api/gantry.apply.yml +5 -0
  167. package/template/koa-rest-api/gantry.build.yml +1 -2
  168. package/template/koa-rest-api/package.json +10 -8
  169. package/template/koa-rest-api/skuba.template.js +1 -0
  170. package/template/koa-rest-api/src/app.test.ts +8 -4
  171. package/template/koa-rest-api/src/framework/validation.test.ts +48 -15
  172. package/template/koa-rest-api/src/framework/validation.ts +31 -8
  173. package/template/koa-rest-api/src/testing/types.ts +16 -4
  174. package/template/lambda-sqs-worker/.buildkite/pipeline.yml +25 -18
  175. package/template/lambda-sqs-worker/.nvmrc +1 -1
  176. package/template/lambda-sqs-worker/Dockerfile +8 -8
  177. package/template/lambda-sqs-worker/README.md +14 -14
  178. package/template/lambda-sqs-worker/_.npmrc +12 -0
  179. package/template/lambda-sqs-worker/docker-compose.yml +0 -15
  180. package/template/lambda-sqs-worker/package.json +6 -7
  181. package/template/lambda-sqs-worker/serverless.yml +5 -2
  182. package/template/lambda-sqs-worker/skuba.template.js +1 -0
  183. package/template/lambda-sqs-worker/src/framework/validation.test.ts +1 -1
  184. package/template/lambda-sqs-worker/src/hooks.ts +1 -2
  185. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +46 -21
  186. package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
  187. package/template/lambda-sqs-worker-cdk/Dockerfile +11 -9
  188. package/template/lambda-sqs-worker-cdk/cdk.json +12 -6
  189. package/template/lambda-sqs-worker-cdk/docker-compose.yml +0 -15
  190. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +1590 -228
  191. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +23 -3
  192. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +128 -15
  193. package/template/lambda-sqs-worker-cdk/package.json +9 -7
  194. package/template/lambda-sqs-worker-cdk/shared/context-types.ts +1 -0
  195. package/template/lambda-sqs-worker-cdk/skuba.template.js +1 -0
  196. package/template/lambda-sqs-worker-cdk/src/app.ts +14 -1
  197. package/template/lambda-sqs-worker-cdk/src/postHook.ts +154 -0
  198. package/template/lambda-sqs-worker-cdk/src/preHook.ts +95 -0
  199. package/template/oss-npm-package/.github/workflows/release.yml +10 -7
  200. package/template/oss-npm-package/.github/workflows/validate.yml +10 -7
  201. package/template/oss-npm-package/.nvmrc +1 -1
  202. package/template/oss-npm-package/.releaserc +16 -0
  203. package/template/oss-npm-package/README.md +18 -18
  204. package/template/oss-npm-package/_package.json +3 -2
  205. package/template/oss-npm-package/skuba.template.js +1 -0
  206. package/template/private-npm-package/.nvmrc +1 -1
  207. package/template/private-npm-package/.releaserc +16 -0
  208. package/template/private-npm-package/README.md +18 -18
  209. package/template/private-npm-package/_package.json +3 -3
  210. package/template/private-npm-package/skuba.template.js +1 -0
  211. package/lib/cli/configure/addEmptyExports.js.map +0 -7
  212. package/lib/cli/configure/modules/tsconfig.d.ts +0 -2
  213. package/lib/cli/configure/modules/tsconfig.js +0 -87
  214. package/lib/cli/configure/modules/tsconfig.js.map +0 -7
  215. package/lib/cli/configure/patchDockerfile.d.ts +0 -1
  216. package/lib/cli/configure/patchDockerfile.js.map +0 -7
  217. package/lib/cli/configure/patchServerListener.d.ts +0 -3
  218. package/lib/cli/configure/patchServerListener.js.map +0 -7
  219. package/lib/cli/configure/refreshIgnoreFiles.d.ts +0 -3
  220. package/lib/cli/configure/refreshIgnoreFiles.js +0 -78
  221. package/lib/cli/configure/refreshIgnoreFiles.js.map +0 -7
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var moveNpmrcOutOfGitignoreManagedSection_exports = {};
30
+ __export(moveNpmrcOutOfGitignoreManagedSection_exports, {
31
+ tryMoveNpmrcOutOfGitignoreManagedSection: () => tryMoveNpmrcOutOfGitignoreManagedSection
32
+ });
33
+ module.exports = __toCommonJS(moveNpmrcOutOfGitignoreManagedSection_exports);
34
+ var import_path = __toESM(require("path"));
35
+ var import_util = require("util");
36
+ var import_fs_extra = __toESM(require("fs-extra"));
37
+ var import_logging = require("../../../../../utils/logging");
38
+ var import_project = require("../../../analysis/project");
39
+ const NPMRC_IGNORE_SECTION = `
40
+
41
+ # Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.
42
+ # IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.
43
+ # You can use \`skuba format\` to generate the file or otherwise commit an empty file.
44
+ # Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.
45
+ .npmrc
46
+ `;
47
+ const moveNpmrcOutOfGitignoreManagedSection = async (mode, dir) => {
48
+ const readFile = (0, import_project.createDestinationFileReader)(dir);
49
+ const gitignore = await readFile(".gitignore");
50
+ if (!gitignore) {
51
+ return { result: "skip", reason: "no .gitignore file found" };
52
+ }
53
+ let isIgnored;
54
+ let currentlyInManagedSection = false;
55
+ for (const line of gitignore.split("\n")) {
56
+ if (line.trim() === "# managed by skuba") {
57
+ currentlyInManagedSection = true;
58
+ } else if (line.trim() === "# end managed by skuba") {
59
+ currentlyInManagedSection = false;
60
+ }
61
+ if (line.trim() === ".npmrc" || line.trim() === "/.npmrc") {
62
+ isIgnored = { inManaged: currentlyInManagedSection };
63
+ }
64
+ if (line.trim() === "!.npmrc" || line.trim() === "!/.npmrc") {
65
+ isIgnored = void 0;
66
+ }
67
+ }
68
+ if (isIgnored && !isIgnored.inManaged) {
69
+ return { result: "skip", reason: "already ignored in unmanaged section" };
70
+ }
71
+ if (!isIgnored) {
72
+ return { result: "skip", reason: "not ignored" };
73
+ }
74
+ if (mode === "lint") {
75
+ return { result: "apply" };
76
+ }
77
+ const newGitignore = gitignore.split("\n").filter((line) => line.trim().replace(/^[!/]+/g, "") !== ".npmrc").join("\n").trim() + NPMRC_IGNORE_SECTION;
78
+ await import_fs_extra.default.promises.writeFile(import_path.default.join(dir, ".gitignore"), newGitignore);
79
+ return { result: "apply" };
80
+ };
81
+ const tryMoveNpmrcOutOfGitignoreManagedSection = async (mode, dir = process.cwd()) => {
82
+ try {
83
+ return await moveNpmrcOutOfGitignoreManagedSection(mode, dir);
84
+ } catch (err) {
85
+ import_logging.log.warn("Failed to move .npmrc out of .gitignore managed section.");
86
+ import_logging.log.subtle((0, import_util.inspect)(err));
87
+ return { result: "skip", reason: "due to an error" };
88
+ }
89
+ };
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ tryMoveNpmrcOutOfGitignoreManagedSection
93
+ });
94
+ //# sourceMappingURL=moveNpmrcOutOfGitignoreManagedSection.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.ts"],
4
+ "sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../utils/logging';\nimport { createDestinationFileReader } from '../../../analysis/project';\n\nconst NPMRC_IGNORE_SECTION = `\n\n# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.\n# IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.\n# You can use \\`skuba format\\` to generate the file or otherwise commit an empty file.\n# Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.\n.npmrc\n`;\n\nconst moveNpmrcOutOfGitignoreManagedSection = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n const gitignore = await readFile('.gitignore');\n\n if (!gitignore) {\n return { result: 'skip', reason: 'no .gitignore file found' };\n }\n\n let isIgnored: { inManaged: boolean } | undefined;\n let currentlyInManagedSection = false;\n\n for (const line of gitignore.split('\\n')) {\n if (line.trim() === '# managed by skuba') {\n currentlyInManagedSection = true;\n } else if (line.trim() === '# end managed by skuba') {\n currentlyInManagedSection = false;\n }\n\n if (line.trim() === '.npmrc' || line.trim() === '/.npmrc') {\n isIgnored = { inManaged: currentlyInManagedSection };\n }\n\n if (line.trim() === '!.npmrc' || line.trim() === '!/.npmrc') {\n isIgnored = undefined;\n }\n }\n\n if (isIgnored && !isIgnored.inManaged) {\n return { result: 'skip', reason: 'already ignored in unmanaged section' };\n }\n\n if (!isIgnored) {\n return { result: 'skip', reason: 'not ignored' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n const newGitignore =\n gitignore\n .split('\\n')\n .filter((line) => line.trim().replace(/^[!/]+/g, '') !== '.npmrc')\n .join('\\n')\n .trim() + NPMRC_IGNORE_SECTION;\n\n await fs.promises.writeFile(path.join(dir, '.gitignore'), newGitignore);\n\n return { result: 'apply' };\n};\n\nexport const tryMoveNpmrcOutOfGitignoreManagedSection = (async (\n mode: 'format' | 'lint',\n dir = process.cwd(),\n) => {\n try {\n return await moveNpmrcOutOfGitignoreManagedSection(mode, dir);\n } catch (err) {\n log.warn('Failed to move .npmrc out of .gitignore managed section.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n}) satisfies PatchFunction;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,qBAA4C;AAE5C,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS7B,MAAM,wCAAwC,OAC5C,MACA,QAC6B;AAC7B,QAAM,eAAW,4CAA4B,GAAG;AAEhD,QAAM,YAAY,MAAM,SAAS,YAAY;AAE7C,MAAI,CAAC,WAAW;AACd,WAAO,EAAE,QAAQ,QAAQ,QAAQ,2BAA2B;AAAA,EAC9D;AAEA,MAAI;AACJ,MAAI,4BAA4B;AAEhC,aAAW,QAAQ,UAAU,MAAM,IAAI,GAAG;AACxC,QAAI,KAAK,KAAK,MAAM,sBAAsB;AACxC,kCAA4B;AAAA,IAC9B,WAAW,KAAK,KAAK,MAAM,0BAA0B;AACnD,kCAA4B;AAAA,IAC9B;AAEA,QAAI,KAAK,KAAK,MAAM,YAAY,KAAK,KAAK,MAAM,WAAW;AACzD,kBAAY,EAAE,WAAW,0BAA0B;AAAA,IACrD;AAEA,QAAI,KAAK,KAAK,MAAM,aAAa,KAAK,KAAK,MAAM,YAAY;AAC3D,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,MAAI,aAAa,CAAC,UAAU,WAAW;AACrC,WAAO,EAAE,QAAQ,QAAQ,QAAQ,uCAAuC;AAAA,EAC1E;AAEA,MAAI,CAAC,WAAW;AACd,WAAO,EAAE,QAAQ,QAAQ,QAAQ,cAAc;AAAA,EACjD;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,eACJ,UACG,MAAM,IAAI,EACV,OAAO,CAAC,SAAS,KAAK,KAAK,EAAE,QAAQ,WAAW,EAAE,MAAM,QAAQ,EAChE,KAAK,IAAI,EACT,KAAK,IAAI;AAEd,QAAM,gBAAAA,QAAG,SAAS,UAAU,YAAAC,QAAK,KAAK,KAAK,YAAY,GAAG,YAAY;AAEtE,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,2CAA4C,OACvD,MACA,MAAM,QAAQ,IAAI,MACf;AACH,MAAI;AACF,WAAO,MAAM,sCAAsC,MAAM,GAAG;AAAA,EAC9D,SAAS,KAAK;AACZ,uBAAI,KAAK,0DAA0D;AACnE,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs", "path"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { PatchFunction } from '../..';
2
+ export declare const tryPatchDockerfile: PatchFunction;
@@ -33,29 +33,35 @@ __export(patchDockerfile_exports, {
33
33
  module.exports = __toCommonJS(patchDockerfile_exports);
34
34
  var import_util = require("util");
35
35
  var import_fs_extra = __toESM(require("fs-extra"));
36
- var import_logging = require("../../utils/logging");
37
- var import_project = require("./analysis/project");
36
+ var import_logging = require("../../../../../utils/logging");
37
+ var import_project = require("../../../analysis/project");
38
38
  const DOCKERFILE_FILENAME = "Dockerfile";
39
- const VERSION_REGEX = /gcr.io\/distroless\/nodejs:(16|18|20)/g;
40
- const VERSION_DEBIAN_REPLACE = "gcr.io/distroless/nodejs$1-debian11";
41
- const patchDockerfile = async (dir) => {
39
+ const NON_DEBIAN_REGEX = /gcr.io\/distroless\/nodejs:(18|20)/g;
40
+ const DEBIAN_REGEX = /gcr.io\/distroless\/nodejs(18|20)-debian11/g;
41
+ const VERSION_DEBIAN_REPLACE = "gcr.io/distroless/nodejs$1-debian12";
42
+ const patchDockerfile = async (mode, dir) => {
42
43
  const readFile = (0, import_project.createDestinationFileReader)(dir);
43
44
  const maybeDockerfile = await readFile(DOCKERFILE_FILENAME);
44
45
  if (!maybeDockerfile) {
45
- return;
46
+ return { result: "skip", reason: "no Dockerfile found" };
47
+ }
48
+ const patched = maybeDockerfile.replaceAll(NON_DEBIAN_REGEX, VERSION_DEBIAN_REPLACE).replaceAll(DEBIAN_REGEX, VERSION_DEBIAN_REPLACE);
49
+ if (patched === maybeDockerfile) {
50
+ return { result: "skip" };
51
+ }
52
+ if (mode === "lint") {
53
+ return { result: "apply" };
46
54
  }
47
- const patched = maybeDockerfile.replaceAll(
48
- VERSION_REGEX,
49
- VERSION_DEBIAN_REPLACE
50
- );
51
55
  await import_fs_extra.default.promises.writeFile(DOCKERFILE_FILENAME, patched);
56
+ return { result: "apply" };
52
57
  };
53
- const tryPatchDockerfile = async (dir = process.cwd()) => {
58
+ const tryPatchDockerfile = async (mode, dir = process.cwd()) => {
54
59
  try {
55
- await patchDockerfile(dir);
60
+ return await patchDockerfile(mode, dir);
56
61
  } catch (err) {
57
62
  import_logging.log.warn("Failed to patch Dockerfile.");
58
63
  import_logging.log.subtle((0, import_util.inspect)(err));
64
+ return { result: "skip", reason: "due to an error" };
59
65
  }
60
66
  };
61
67
  // Annotate the CommonJS export names for ESM import in node:
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/cli/configure/upgrade/patches/7.3.1/patchDockerfile.ts"],
4
+ "sourcesContent": ["import { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../utils/logging';\nimport { createDestinationFileReader } from '../../../analysis/project';\n\nconst DOCKERFILE_FILENAME = 'Dockerfile';\n\nconst NON_DEBIAN_REGEX = /gcr.io\\/distroless\\/nodejs:(18|20)/g;\nconst DEBIAN_REGEX = /gcr.io\\/distroless\\/nodejs(18|20)-debian11/g;\nconst VERSION_DEBIAN_REPLACE = 'gcr.io/distroless/nodejs$1-debian12';\n\nconst patchDockerfile = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n const maybeDockerfile = await readFile(DOCKERFILE_FILENAME);\n\n if (!maybeDockerfile) {\n return { result: 'skip', reason: 'no Dockerfile found' };\n }\n\n const patched = maybeDockerfile\n .replaceAll(NON_DEBIAN_REGEX, VERSION_DEBIAN_REPLACE)\n .replaceAll(DEBIAN_REGEX, VERSION_DEBIAN_REPLACE);\n\n if (patched === maybeDockerfile) {\n return { result: 'skip' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n await fs.promises.writeFile(DOCKERFILE_FILENAME, patched);\n\n return { result: 'apply' };\n};\n\nexport const tryPatchDockerfile: PatchFunction = async (\n mode: 'format' | 'lint',\n dir = process.cwd(),\n) => {\n try {\n return await patchDockerfile(mode, dir);\n } catch (err) {\n log.warn('Failed to patch Dockerfile.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,qBAA4C;AAE5C,MAAM,sBAAsB;AAE5B,MAAM,mBAAmB;AACzB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAE/B,MAAM,kBAAkB,OACtB,MACA,QAC6B;AAC7B,QAAM,eAAW,4CAA4B,GAAG;AAEhD,QAAM,kBAAkB,MAAM,SAAS,mBAAmB;AAE1D,MAAI,CAAC,iBAAiB;AACpB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,sBAAsB;AAAA,EACzD;AAEA,QAAM,UAAU,gBACb,WAAW,kBAAkB,sBAAsB,EACnD,WAAW,cAAc,sBAAsB;AAElD,MAAI,YAAY,iBAAiB;AAC/B,WAAO,EAAE,QAAQ,OAAO;AAAA,EAC1B;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,gBAAAA,QAAG,SAAS,UAAU,qBAAqB,OAAO;AAExD,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,qBAAoC,OAC/C,MACA,MAAM,QAAQ,IAAI,MACf;AACH,MAAI;AACF,WAAO,MAAM,gBAAgB,MAAM,GAAG;AAAA,EACxC,SAAS,KAAK;AACZ,uBAAI,KAAK,6BAA6B;AACtC,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { PatchFunction } from '../..';
2
+ export declare const tryPatchServerListener: PatchFunction;
@@ -28,16 +28,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var patchServerListener_exports = {};
30
30
  __export(patchServerListener_exports, {
31
- KEEP_ALIVE_CODE: () => KEEP_ALIVE_CODE,
32
- SERVER_LISTENER_FILENAME: () => SERVER_LISTENER_FILENAME,
33
31
  tryPatchServerListener: () => tryPatchServerListener
34
32
  });
35
33
  module.exports = __toCommonJS(patchServerListener_exports);
36
34
  var import_util = require("util");
37
35
  var import_fs_extra = __toESM(require("fs-extra"));
38
- var import_logging = require("../../utils/logging");
39
- var import_project = require("./analysis/project");
40
- var import_prettier = require("./processing/prettier");
36
+ var import_logging = require("../../../../../utils/logging");
37
+ var import_project = require("../../../analysis/project");
38
+ var import_prettier = require("../../../processing/prettier");
39
+ const SERVER_LISTENER_FILENAME = "src/listen.ts";
41
40
  const KEEP_ALIVE_CODE = `
42
41
  // Gantry ALB default idle timeout is 30 seconds
43
42
  // https://nodejs.org/docs/latest-v18.x/api/http.html#serverkeepalivetimeout
@@ -46,12 +45,14 @@ const KEEP_ALIVE_CODE = `
46
45
  // AWS recommends setting an application timeout larger than the load balancer
47
46
  listener.keepAliveTimeout = 31000;
48
47
  `;
49
- const SERVER_LISTENER_FILENAME = "src/listen.ts";
50
- const patchServerListener = async (dir) => {
48
+ const patchServerListener = async (mode, dir) => {
51
49
  const readFile = (0, import_project.createDestinationFileReader)(dir);
52
50
  let listener = await readFile(SERVER_LISTENER_FILENAME);
53
- if (!listener || listener.includes("keepAliveTimeout")) {
54
- return;
51
+ if (!listener) {
52
+ return { result: "skip", reason: "no listener file found" };
53
+ }
54
+ if (listener.includes("keepAliveTimeout")) {
55
+ return { result: "skip", reason: "keepAliveTimeout already configured" };
55
56
  }
56
57
  if (listener.includes("\napp.listen(")) {
57
58
  listener = listener.replace(
@@ -60,7 +61,10 @@ const patchServerListener = async (dir) => {
60
61
  );
61
62
  }
62
63
  if (!listener.includes("\nconst listener = app.listen(")) {
63
- return;
64
+ return { result: "skip", reason: "no server listener found" };
65
+ }
66
+ if (mode === "lint") {
67
+ return { result: "apply" };
64
68
  }
65
69
  listener = `${listener}${KEEP_ALIVE_CODE}`;
66
70
  await import_fs_extra.default.promises.writeFile(
@@ -69,19 +73,19 @@ const patchServerListener = async (dir) => {
69
73
  parser: "typescript"
70
74
  })
71
75
  );
76
+ return { result: "apply" };
72
77
  };
73
- const tryPatchServerListener = async (dir = process.cwd()) => {
78
+ const tryPatchServerListener = async (mode, dir = process.cwd()) => {
74
79
  try {
75
- await patchServerListener(dir);
80
+ return await patchServerListener(mode, dir);
76
81
  } catch (err) {
77
82
  import_logging.log.warn("Failed to patch server listener.");
78
83
  import_logging.log.subtle((0, import_util.inspect)(err));
84
+ return { result: "skip", reason: "due to an error" };
79
85
  }
80
86
  };
81
87
  // Annotate the CommonJS export names for ESM import in node:
82
88
  0 && (module.exports = {
83
- KEEP_ALIVE_CODE,
84
- SERVER_LISTENER_FILENAME,
85
89
  tryPatchServerListener
86
90
  });
87
91
  //# sourceMappingURL=patchServerListener.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/cli/configure/upgrade/patches/7.3.1/patchServerListener.ts"],
4
+ "sourcesContent": ["import { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../utils/logging';\nimport { createDestinationFileReader } from '../../../analysis/project';\nimport { formatPrettier } from '../../../processing/prettier';\n\nconst SERVER_LISTENER_FILENAME = 'src/listen.ts';\n\nconst KEEP_ALIVE_CODE = `\n// Gantry ALB default idle timeout is 30 seconds\n// https://nodejs.org/docs/latest-v18.x/api/http.html#serverkeepalivetimeout\n// Node default is 5 seconds\n// https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout\n// AWS recommends setting an application timeout larger than the load balancer\nlistener.keepAliveTimeout = 31000;\n`;\n\nconst patchServerListener = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n let listener = await readFile(SERVER_LISTENER_FILENAME);\n if (!listener) {\n return { result: 'skip', reason: 'no listener file found' };\n }\n\n if (listener.includes('keepAliveTimeout')) {\n return { result: 'skip', reason: 'keepAliveTimeout already configured' };\n }\n\n if (listener.includes('\\napp.listen(')) {\n listener = listener.replace(\n '\\napp.listen(',\n '\\nconst listener = app.listen(',\n );\n }\n\n if (!listener.includes('\\nconst listener = app.listen(')) {\n return { result: 'skip', reason: 'no server listener found' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n listener = `${listener}${KEEP_ALIVE_CODE}`;\n\n await fs.promises.writeFile(\n SERVER_LISTENER_FILENAME,\n await formatPrettier(listener, {\n parser: 'typescript',\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const tryPatchServerListener: PatchFunction = async (\n mode: 'format' | 'lint',\n dir = process.cwd(),\n) => {\n try {\n return await patchServerListener(mode, dir);\n } catch (err) {\n log.warn('Failed to patch server listener.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,qBAA4C;AAC5C,sBAA+B;AAE/B,MAAM,2BAA2B;AAEjC,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASxB,MAAM,sBAAsB,OAC1B,MACA,QAC6B;AAC7B,QAAM,eAAW,4CAA4B,GAAG;AAEhD,MAAI,WAAW,MAAM,SAAS,wBAAwB;AACtD,MAAI,CAAC,UAAU;AACb,WAAO,EAAE,QAAQ,QAAQ,QAAQ,yBAAyB;AAAA,EAC5D;AAEA,MAAI,SAAS,SAAS,kBAAkB,GAAG;AACzC,WAAO,EAAE,QAAQ,QAAQ,QAAQ,sCAAsC;AAAA,EACzE;AAEA,MAAI,SAAS,SAAS,eAAe,GAAG;AACtC,eAAW,SAAS;AAAA,MAClB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,SAAS,SAAS,gCAAgC,GAAG;AACxD,WAAO,EAAE,QAAQ,QAAQ,QAAQ,2BAA2B;AAAA,EAC9D;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,aAAW,GAAG,QAAQ,GAAG,eAAe;AAExC,QAAM,gBAAAA,QAAG,SAAS;AAAA,IAChB;AAAA,IACA,UAAM,gCAAe,UAAU;AAAA,MAC7B,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,yBAAwC,OACnD,MACA,MAAM,QAAQ,IAAI,MACf;AACH,MAAI;AACF,WAAO,MAAM,oBAAoB,MAAM,GAAG;AAAA,EAC5C,SAAS,KAAK;AACZ,uBAAI,KAAK,kCAAkC;AAC3C,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs"]
7
+ }
package/lib/cli/format.js CHANGED
@@ -36,32 +36,25 @@ var import_args = require("../utils/args");
36
36
  var import_logging = require("../utils/logging");
37
37
  var import_eslint = require("./adapter/eslint");
38
38
  var import_prettier = require("./adapter/prettier");
39
- var import_addEmptyExports = require("./configure/addEmptyExports");
40
- var import_patchDockerfile = require("./configure/patchDockerfile");
41
- var import_patchRenovateConfig = require("./configure/patchRenovateConfig");
42
- var import_patchServerListener = require("./configure/patchServerListener");
43
- var import_refreshIgnoreFiles = require("./configure/refreshIgnoreFiles");
39
+ var import_internal = require("./lint/internal");
44
40
  const format = async (args = process.argv.slice(2)) => {
45
- await Promise.all([
46
- (0, import_addEmptyExports.tryAddEmptyExports)(),
47
- (0, import_patchRenovateConfig.tryPatchRenovateConfig)(),
48
- (0, import_patchDockerfile.tryPatchDockerfile)(),
49
- (0, import_patchServerListener.tryPatchServerListener)(),
50
- (0, import_refreshIgnoreFiles.tryRefreshIgnoreFiles)()
51
- ]);
52
41
  const debug = (0, import_args.hasDebugFlag)(args);
42
+ import_logging.log.plain(import_chalk.default.blueBright("skuba lints"));
43
+ const internal = await (0, import_internal.internalLint)("format", { debug, serial: true });
53
44
  const logger = (0, import_logging.createLogger)(debug);
45
+ import_logging.log.newline();
54
46
  import_logging.log.plain(import_chalk.default.magenta("ESLint"));
55
47
  const eslint = await (0, import_eslint.runESLint)("format", logger);
56
48
  import_logging.log.newline();
57
49
  import_logging.log.plain(import_chalk.default.cyan("Prettier"));
58
50
  const prettier = await (0, import_prettier.runPrettier)("format", logger);
59
- if (eslint.ok && prettier.ok) {
51
+ if (eslint.ok && prettier.ok && internal.ok) {
60
52
  return;
61
53
  }
62
54
  const tools = [
63
55
  ...eslint.ok ? [] : ["ESLint"],
64
- ...prettier.ok ? [] : ["Prettier"]
56
+ ...prettier.ok ? [] : ["Prettier"],
57
+ ...internal.ok ? [] : ["skuba"]
65
58
  ];
66
59
  import_logging.log.newline();
67
60
  import_logging.log.err(tools.join(", "), "found issues that require triage.");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/cli/format.ts"],
4
- "sourcesContent": ["import chalk from 'chalk';\n\nimport { hasDebugFlag } from '../utils/args';\nimport { createLogger, log } from '../utils/logging';\n\nimport { runESLint } from './adapter/eslint';\nimport { runPrettier } from './adapter/prettier';\nimport { tryAddEmptyExports } from './configure/addEmptyExports';\nimport { tryPatchDockerfile } from './configure/patchDockerfile';\nimport { tryPatchRenovateConfig } from './configure/patchRenovateConfig';\nimport { tryPatchServerListener } from './configure/patchServerListener';\nimport { tryRefreshIgnoreFiles } from './configure/refreshIgnoreFiles';\n\nexport const format = async (args = process.argv.slice(2)): Promise<void> => {\n await Promise.all([\n tryAddEmptyExports(),\n tryPatchRenovateConfig(),\n tryPatchDockerfile(),\n tryPatchServerListener(),\n tryRefreshIgnoreFiles(),\n ]);\n\n const debug = hasDebugFlag(args);\n const logger = createLogger(debug);\n\n log.plain(chalk.magenta('ESLint'));\n\n const eslint = await runESLint('format', logger);\n\n log.newline();\n log.plain(chalk.cyan('Prettier'));\n\n const prettier = await runPrettier('format', logger);\n\n if (eslint.ok && prettier.ok) {\n return;\n }\n\n const tools = [\n ...(eslint.ok ? [] : ['ESLint']),\n ...(prettier.ok ? [] : ['Prettier']),\n ];\n\n log.newline();\n log.err(tools.join(', '), 'found issues that require triage.');\n\n process.exitCode = 1;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,kBAA6B;AAC7B,qBAAkC;AAElC,oBAA0B;AAC1B,sBAA4B;AAC5B,6BAAmC;AACnC,6BAAmC;AACnC,iCAAuC;AACvC,iCAAuC;AACvC,gCAAsC;AAE/B,MAAM,SAAS,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAqB;AAC3E,QAAM,QAAQ,IAAI;AAAA,QAChB,2CAAmB;AAAA,QACnB,mDAAuB;AAAA,QACvB,2CAAmB;AAAA,QACnB,mDAAuB;AAAA,QACvB,iDAAsB;AAAA,EACxB,CAAC;AAED,QAAM,YAAQ,0BAAa,IAAI;AAC/B,QAAM,aAAS,6BAAa,KAAK;AAEjC,qBAAI,MAAM,aAAAA,QAAM,QAAQ,QAAQ,CAAC;AAEjC,QAAM,SAAS,UAAM,yBAAU,UAAU,MAAM;AAE/C,qBAAI,QAAQ;AACZ,qBAAI,MAAM,aAAAA,QAAM,KAAK,UAAU,CAAC;AAEhC,QAAM,WAAW,UAAM,6BAAY,UAAU,MAAM;AAEnD,MAAI,OAAO,MAAM,SAAS,IAAI;AAC5B;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,GAAI,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ;AAAA,IAC9B,GAAI,SAAS,KAAK,CAAC,IAAI,CAAC,UAAU;AAAA,EACpC;AAEA,qBAAI,QAAQ;AACZ,qBAAI,IAAI,MAAM,KAAK,IAAI,GAAG,mCAAmC;AAE7D,UAAQ,WAAW;AACrB;",
4
+ "sourcesContent": ["import chalk from 'chalk';\n\nimport { hasDebugFlag } from '../utils/args';\nimport { createLogger, log } from '../utils/logging';\n\nimport { runESLint } from './adapter/eslint';\nimport { runPrettier } from './adapter/prettier';\nimport { internalLint } from './lint/internal';\n\nexport const format = async (args = process.argv.slice(2)): Promise<void> => {\n const debug = hasDebugFlag(args);\n\n log.plain(chalk.blueBright('skuba lints'));\n const internal = await internalLint('format', { debug, serial: true });\n\n const logger = createLogger(debug);\n\n log.newline();\n log.plain(chalk.magenta('ESLint'));\n\n const eslint = await runESLint('format', logger);\n\n log.newline();\n log.plain(chalk.cyan('Prettier'));\n\n const prettier = await runPrettier('format', logger);\n\n if (eslint.ok && prettier.ok && internal.ok) {\n return;\n }\n\n const tools = [\n ...(eslint.ok ? [] : ['ESLint']),\n ...(prettier.ok ? [] : ['Prettier']),\n ...(internal.ok ? [] : ['skuba']),\n ];\n\n log.newline();\n log.err(tools.join(', '), 'found issues that require triage.');\n\n process.exitCode = 1;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,kBAA6B;AAC7B,qBAAkC;AAElC,oBAA0B;AAC1B,sBAA4B;AAC5B,sBAA6B;AAEtB,MAAM,SAAS,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAqB;AAC3E,QAAM,YAAQ,0BAAa,IAAI;AAE/B,qBAAI,MAAM,aAAAA,QAAM,WAAW,aAAa,CAAC;AACzC,QAAM,WAAW,UAAM,8BAAa,UAAU,EAAE,OAAO,QAAQ,KAAK,CAAC;AAErE,QAAM,aAAS,6BAAa,KAAK;AAEjC,qBAAI,QAAQ;AACZ,qBAAI,MAAM,aAAAA,QAAM,QAAQ,QAAQ,CAAC;AAEjC,QAAM,SAAS,UAAM,yBAAU,UAAU,MAAM;AAE/C,qBAAI,QAAQ;AACZ,qBAAI,MAAM,aAAAA,QAAM,KAAK,UAAU,CAAC;AAEhC,QAAM,WAAW,UAAM,6BAAY,UAAU,MAAM;AAEnD,MAAI,OAAO,MAAM,SAAS,MAAM,SAAS,IAAI;AAC3C;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,GAAI,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ;AAAA,IAC9B,GAAI,SAAS,KAAK,CAAC,IAAI,CAAC,UAAU;AAAA,IAClC,GAAI,SAAS,KAAK,CAAC,IAAI,CAAC,OAAO;AAAA,EACjC;AAEA,qBAAI,QAAQ;AACZ,qBAAI,IAAI,MAAM,KAAK,IAAI,GAAG,mCAAmC;AAE7D,UAAQ,WAAW;AACrB;",
6
6
  "names": ["chalk"]
7
7
  }
@@ -1,26 +1,28 @@
1
- import { TemplateConfig } from '../../utils/template';
1
+ import { type TemplateConfig } from '../../utils/template';
2
+ import { type Choice } from './prompts';
2
3
  import { type InitConfig } from './types';
3
- import { type FormChoice } from 'enquirer';
4
4
  export declare const runForm: <T = Record<string, string>>(props: {
5
- choices: Readonly<FormChoice[]>;
5
+ choices: Readonly<Choice[]>;
6
6
  message: string;
7
7
  name: string;
8
8
  }) => Promise<T>;
9
9
  export declare const getTemplateConfig: (dir: string) => TemplateConfig;
10
10
  export declare const configureFromPrompt: () => Promise<InitConfig>;
11
11
  export declare const getConfig: () => Promise<{
12
+ packageManager: "yarn" | "pnpm";
12
13
  templateName: string;
13
14
  destinationDir: string;
14
15
  templateComplete: boolean;
15
16
  templateData: {
16
17
  port: string;
18
+ defaultBranch: string;
17
19
  orgName: string;
18
20
  repoName: string;
19
21
  ownerName: string;
20
22
  teamName: string;
21
23
  } & {
22
- [x: string]: string;
24
+ [k: string]: string;
23
25
  };
24
- type?: "package" | "application" | undefined;
25
26
  entryPoint?: string | undefined;
27
+ type?: "package" | "application" | undefined;
26
28
  }>;
@@ -36,22 +36,23 @@ __export(getConfig_exports, {
36
36
  module.exports = __toCommonJS(getConfig_exports);
37
37
  var import_path = __toESM(require("path"));
38
38
  var import_chalk = __toESM(require("chalk"));
39
+ var import_enquirer = require("enquirer");
39
40
  var import_fs_extra = __toESM(require("fs-extra"));
40
41
  var import_copy = require("../../utils/copy");
41
42
  var import_error = require("../../utils/error");
42
43
  var import_logging = require("../../utils/logging");
44
+ var import_packageManager = require("../../utils/packageManager");
43
45
  var import_port = require("../../utils/port");
44
46
  var import_template = require("../../utils/template");
45
47
  var import_git = require("./git");
46
48
  var import_prompts = require("./prompts");
47
49
  var import_types = require("./types");
48
- var import_enquirer = require("enquirer");
49
50
  const runForm = (props) => {
50
51
  const { message, name } = props;
51
52
  const choices = props.choices.map((choice) => ({
52
53
  ...choice,
53
54
  validate: (value) => {
54
- if (!value || value === "" || value === choice.initial) {
55
+ if (!value || value === "" || value === choice.initial && !choice.allowInitial) {
55
56
  return "Form is not complete";
56
57
  }
57
58
  return choice.validate?.(value) ?? true;
@@ -92,20 +93,38 @@ const createDirectory = async (dir) => {
92
93
  }
93
94
  };
94
95
  const cloneTemplate = async (templateName, destinationDir) => {
95
- if (templateName.startsWith("github:")) {
96
+ const isCustomTemplate = templateName.startsWith("github:");
97
+ if (isCustomTemplate) {
96
98
  const gitHubPath = templateName.slice("github:".length);
97
- return (0, import_git.downloadGitHubTemplate)(gitHubPath, destinationDir);
99
+ await (0, import_git.downloadGitHubTemplate)(gitHubPath, destinationDir);
100
+ } else {
101
+ const templateDir = import_path.default.join(import_template.TEMPLATE_DIR, templateName);
102
+ await (0, import_copy.copyFiles)({
103
+ // assume built-in templates have no extraneous files
104
+ include: () => true,
105
+ sourceRoot: templateDir,
106
+ destinationRoot: destinationDir,
107
+ processors: [],
108
+ // built-in templates have files like _package.json
109
+ stripUnderscorePrefix: true
110
+ });
98
111
  }
99
- const templateDir = import_path.default.join(import_template.TEMPLATE_DIR, templateName);
100
- await (0, import_copy.copyFiles)({
101
- // assume built-in templates have no extraneous files
102
- include: () => true,
103
- sourceRoot: templateDir,
104
- destinationRoot: destinationDir,
105
- processors: [],
106
- // built-in templates have files like _package.json
107
- stripUnderscorePrefix: true
108
- });
112
+ const templateConfig = getTemplateConfig(
113
+ import_path.default.join(process.cwd(), destinationDir)
114
+ );
115
+ if (isCustomTemplate) {
116
+ import_logging.log.newline();
117
+ import_logging.log.warn(
118
+ "You may need to run",
119
+ import_logging.log.bold(
120
+ (0, import_packageManager.configForPackageManager)(templateConfig.packageManager).exec,
121
+ "skuba",
122
+ "configure"
123
+ ),
124
+ "once this is done."
125
+ );
126
+ }
127
+ return templateConfig;
109
128
  };
110
129
  const getTemplateName = async () => {
111
130
  const templateSelection = await import_prompts.TEMPLATE_PROMPT.run();
@@ -122,12 +141,13 @@ const getTemplateConfig = (dir) => {
122
141
  const templateConfigPath = import_path.default.join(dir, import_template.TEMPLATE_CONFIG_FILENAME);
123
142
  try {
124
143
  const templateConfig = require(templateConfigPath);
125
- return import_template.TemplateConfig.check(templateConfig);
144
+ return import_template.templateConfigSchema.parse(templateConfig);
126
145
  } catch (err) {
127
146
  if ((0, import_error.isErrorWithCode)(err, "MODULE_NOT_FOUND")) {
128
147
  return {
129
148
  entryPoint: void 0,
130
149
  fields: [],
150
+ packageManager: import_packageManager.DEFAULT_PACKAGE_MANAGER,
131
151
  type: void 0
132
152
  };
133
153
  }
@@ -137,7 +157,8 @@ const getTemplateConfig = (dir) => {
137
157
  const baseToTemplateData = async ({
138
158
  ownerName,
139
159
  platformName,
140
- repoName
160
+ repoName,
161
+ defaultBranch
141
162
  }) => {
142
163
  const [orgName, teamName] = ownerName.split("/");
143
164
  const port = String(await (0, import_port.getRandomPort)());
@@ -148,6 +169,7 @@ const baseToTemplateData = async ({
148
169
  orgName,
149
170
  ownerName,
150
171
  repoName,
172
+ defaultBranch,
151
173
  // Use standalone username in `teamName` contexts
152
174
  teamName: teamName ?? orgName,
153
175
  port,
@@ -157,25 +179,24 @@ const baseToTemplateData = async ({
157
179
  };
158
180
  };
159
181
  const configureFromPrompt = async () => {
160
- const { ownerName, platformName, repoName } = await runForm(import_prompts.BASE_PROMPT_PROPS);
182
+ const { ownerName, platformName, repoName, defaultBranch } = await runForm(import_prompts.BASE_PROMPT_PROPS);
161
183
  import_logging.log.plain(import_chalk.default.cyan(repoName), "by", import_chalk.default.cyan(ownerName));
162
184
  const templateData = await baseToTemplateData({
163
185
  ownerName,
164
186
  platformName,
165
- repoName
187
+ repoName,
188
+ defaultBranch
166
189
  });
167
190
  const destinationDir = repoName;
168
191
  await createDirectory(destinationDir);
169
192
  import_logging.log.newline();
170
193
  const templateName = await getTemplateName();
171
- await cloneTemplate(templateName, destinationDir);
172
- const { entryPoint, fields, noSkip, type } = getTemplateConfig(
173
- import_path.default.join(process.cwd(), destinationDir)
174
- );
194
+ const { entryPoint, fields, noSkip, packageManager, type } = await cloneTemplate(templateName, destinationDir);
175
195
  if (fields.length === 0) {
176
196
  return {
177
197
  destinationDir,
178
198
  entryPoint,
199
+ packageManager,
179
200
  templateComplete: true,
180
201
  templateData,
181
202
  templateName,
@@ -193,6 +214,7 @@ const configureFromPrompt = async () => {
193
214
  return {
194
215
  destinationDir,
195
216
  entryPoint,
217
+ packageManager,
196
218
  templateComplete: true,
197
219
  templateData: { ...templateData, ...customAnswers2 },
198
220
  templateName,
@@ -200,11 +222,17 @@ const configureFromPrompt = async () => {
200
222
  };
201
223
  }
202
224
  import_logging.log.newline();
203
- import_logging.log.warn(`Resume this later with ${import_chalk.default.bold("yarn skuba configure")}.`);
225
+ import_logging.log.warn(
226
+ `Resume this later with ${import_chalk.default.bold(
227
+ (0, import_packageManager.configForPackageManager)(packageManager).exec,
228
+ "skuba configure"
229
+ )}.`
230
+ );
204
231
  const customAnswers = generatePlaceholders(fields);
205
232
  return {
206
233
  destinationDir,
207
234
  entryPoint,
235
+ packageManager,
208
236
  templateComplete: false,
209
237
  templateData: { ...templateData, ...customAnswers },
210
238
  templateName,
@@ -228,30 +256,28 @@ const configureFromPipe = async () => {
228
256
  import_logging.log.err("Invalid JSON from stdin.");
229
257
  process.exit(1);
230
258
  }
231
- const result = import_types.InitConfigInput.validate(value);
259
+ const result = import_types.initConfigInputSchema.safeParse(value);
232
260
  if (!result.success) {
233
261
  import_logging.log.err("Invalid data from stdin:");
234
- import_logging.log.err(result.message);
262
+ import_logging.log.err(result.error);
235
263
  process.exit(1);
236
264
  }
237
- const { destinationDir, templateComplete, templateName } = result.value;
265
+ const { destinationDir, templateComplete, templateName } = result.data;
238
266
  const templateData = {
239
- ...await baseToTemplateData(result.value.templateData),
240
- ...result.value.templateData
267
+ ...await baseToTemplateData(result.data.templateData),
268
+ ...result.data.templateData
241
269
  };
242
270
  await createDirectory(destinationDir);
243
- await cloneTemplate(templateName, destinationDir);
244
- const { entryPoint, fields, noSkip, type } = getTemplateConfig(
245
- import_path.default.join(process.cwd(), destinationDir)
246
- );
271
+ const { entryPoint, fields, noSkip, packageManager, type } = await cloneTemplate(templateName, destinationDir);
247
272
  if (!templateComplete) {
248
273
  if (noSkip) {
249
274
  import_logging.log.err("Templating for", import_logging.log.bold(templateName), "cannot be skipped.");
250
275
  process.exit(1);
251
276
  }
252
277
  return {
253
- ...result.value,
278
+ ...result.data,
254
279
  entryPoint,
280
+ packageManager,
255
281
  templateData: {
256
282
  ...templateData,
257
283
  ...generatePlaceholders(fields)
@@ -269,8 +295,9 @@ const configureFromPipe = async () => {
269
295
  process.exit(1);
270
296
  }
271
297
  return {
272
- ...result.value,
298
+ ...result.data,
273
299
  entryPoint,
300
+ packageManager,
274
301
  templateData,
275
302
  type
276
303
  };