skuba 14.0.0-migrate-to-inquirer-20251031060542 → 14.0.0-replace-global-vars-20251121010036

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 (387) hide show
  1. package/config/eslint.js +1 -1
  2. package/config/prettier.d.ts +8 -4
  3. package/config/prettier.js +10 -2
  4. package/lib/cli/adapter/eslint.js +11 -45
  5. package/lib/cli/adapter/eslint.js.map +3 -3
  6. package/lib/cli/adapter/prettier.js +39 -67
  7. package/lib/cli/adapter/prettier.js.map +2 -2
  8. package/lib/cli/build/args.js +8 -42
  9. package/lib/cli/build/args.js.map +2 -2
  10. package/lib/cli/build/assets.d.ts +3 -2
  11. package/lib/cli/build/assets.js +28 -60
  12. package/lib/cli/build/assets.js.map +3 -3
  13. package/lib/cli/build/esbuild.js +21 -45
  14. package/lib/cli/build/esbuild.js.map +2 -2
  15. package/lib/cli/build/index.js +21 -55
  16. package/lib/cli/build/index.js.map +3 -3
  17. package/lib/cli/build/tsc.js +23 -61
  18. package/lib/cli/build/tsc.js.map +3 -3
  19. package/lib/cli/buildPackage/index.js +8 -32
  20. package/lib/cli/buildPackage/index.js.map +1 -1
  21. package/lib/cli/configure/analyseConfiguration.js +16 -50
  22. package/lib/cli/configure/analyseConfiguration.js.map +2 -2
  23. package/lib/cli/configure/analyseDependencies.d.ts +1 -1
  24. package/lib/cli/configure/analyseDependencies.js +25 -59
  25. package/lib/cli/configure/analyseDependencies.js.map +3 -3
  26. package/lib/cli/configure/analysis/diff.js +5 -39
  27. package/lib/cli/configure/analysis/diff.js.map +3 -3
  28. package/lib/cli/configure/analysis/files.js +8 -42
  29. package/lib/cli/configure/analysis/files.js.map +2 -2
  30. package/lib/cli/configure/analysis/git.js +12 -46
  31. package/lib/cli/configure/analysis/git.js.map +2 -2
  32. package/lib/cli/configure/analysis/package.d.ts +2 -3
  33. package/lib/cli/configure/analysis/package.js +10 -45
  34. package/lib/cli/configure/analysis/package.js.map +3 -3
  35. package/lib/cli/configure/analysis/project.js +18 -50
  36. package/lib/cli/configure/analysis/project.js.map +2 -2
  37. package/lib/cli/configure/dependencies/index.js +7 -35
  38. package/lib/cli/configure/dependencies/index.js.map +1 -1
  39. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +4 -28
  40. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
  41. package/lib/cli/configure/dependencies/seekKoala.js +4 -28
  42. package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
  43. package/lib/cli/configure/dependencies/skuba.js +4 -28
  44. package/lib/cli/configure/dependencies/skuba.js.map +1 -1
  45. package/lib/cli/configure/dependencies/skubaDeps.js +2 -26
  46. package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
  47. package/lib/cli/configure/dependencies/skubaDive.js +4 -29
  48. package/lib/cli/configure/dependencies/skubaDive.js.map +1 -1
  49. package/lib/cli/configure/ensureTemplateCompletion.d.ts +1 -1
  50. package/lib/cli/configure/ensureTemplateCompletion.js +35 -60
  51. package/lib/cli/configure/ensureTemplateCompletion.js.map +3 -3
  52. package/lib/cli/configure/getEntryPoint.d.ts +1 -1
  53. package/lib/cli/configure/getEntryPoint.js +14 -48
  54. package/lib/cli/configure/getEntryPoint.js.map +3 -3
  55. package/lib/cli/configure/getProjectType.d.ts +1 -1
  56. package/lib/cli/configure/getProjectType.js +14 -35
  57. package/lib/cli/configure/getProjectType.js.map +2 -2
  58. package/lib/cli/configure/index.js +50 -84
  59. package/lib/cli/configure/index.js.map +3 -3
  60. package/lib/cli/configure/modules/eslint.js +10 -34
  61. package/lib/cli/configure/modules/eslint.js.map +1 -1
  62. package/lib/cli/configure/modules/ignore.js +8 -32
  63. package/lib/cli/configure/modules/ignore.js.map +1 -1
  64. package/lib/cli/configure/modules/index.js +18 -44
  65. package/lib/cli/configure/modules/index.js.map +2 -2
  66. package/lib/cli/configure/modules/nodemon.js +4 -28
  67. package/lib/cli/configure/modules/nodemon.js.map +1 -1
  68. package/lib/cli/configure/modules/package.js +10 -34
  69. package/lib/cli/configure/modules/package.js.map +1 -1
  70. package/lib/cli/configure/modules/prettier.js +11 -35
  71. package/lib/cli/configure/modules/prettier.js.map +1 -1
  72. package/lib/cli/configure/modules/renovate.js +17 -40
  73. package/lib/cli/configure/modules/renovate.js.map +2 -2
  74. package/lib/cli/configure/modules/serverless.js +2 -26
  75. package/lib/cli/configure/modules/serverless.js.map +1 -1
  76. package/lib/cli/configure/modules/tslint.js +4 -28
  77. package/lib/cli/configure/modules/tslint.js.map +1 -1
  78. package/lib/cli/configure/processing/configFile.js +3 -39
  79. package/lib/cli/configure/processing/configFile.js.map +1 -1
  80. package/lib/cli/configure/processing/deleteFiles.js +2 -26
  81. package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
  82. package/lib/cli/configure/processing/javascript.js +2 -27
  83. package/lib/cli/configure/processing/javascript.js.map +1 -1
  84. package/lib/cli/configure/processing/json.js +6 -31
  85. package/lib/cli/configure/processing/json.js.map +1 -1
  86. package/lib/cli/configure/processing/loadFiles.js +2 -26
  87. package/lib/cli/configure/processing/loadFiles.js.map +1 -1
  88. package/lib/cli/configure/processing/module.js +4 -28
  89. package/lib/cli/configure/processing/module.js.map +1 -1
  90. package/lib/cli/configure/processing/package.d.ts +1 -67
  91. package/lib/cli/configure/processing/package.js +8 -45
  92. package/lib/cli/configure/processing/package.js.map +3 -3
  93. package/lib/cli/configure/processing/prettier.js +4 -38
  94. package/lib/cli/configure/processing/prettier.js.map +2 -2
  95. package/lib/cli/configure/processing/record.js +5 -41
  96. package/lib/cli/configure/processing/record.js.map +2 -2
  97. package/lib/cli/configure/processing/typescript.js +26 -63
  98. package/lib/cli/configure/processing/typescript.js.map +2 -2
  99. package/lib/cli/configure/types.d.ts +15 -4
  100. package/lib/cli/configure/types.js +0 -16
  101. package/lib/cli/configure/types.js.map +3 -3
  102. package/lib/cli/format/index.js +20 -54
  103. package/lib/cli/format/index.js.map +3 -3
  104. package/lib/cli/help/index.js +6 -30
  105. package/lib/cli/help/index.js.map +1 -1
  106. package/lib/cli/init/getConfig.d.ts +1 -1
  107. package/lib/cli/init/getConfig.js +76 -104
  108. package/lib/cli/init/getConfig.js.map +3 -3
  109. package/lib/cli/init/git.js +16 -51
  110. package/lib/cli/init/git.js.map +2 -2
  111. package/lib/cli/init/index.js +67 -98
  112. package/lib/cli/init/index.js.map +2 -2
  113. package/lib/cli/init/prompts.js +21 -42
  114. package/lib/cli/init/prompts.js.map +1 -1
  115. package/lib/cli/init/types.js +7 -41
  116. package/lib/cli/init/types.js.map +1 -1
  117. package/lib/cli/init/validation.js +2 -30
  118. package/lib/cli/init/validation.js.map +1 -1
  119. package/lib/cli/init/writePackageJson.js +8 -42
  120. package/lib/cli/init/writePackageJson.js.map +2 -2
  121. package/lib/cli/lint/annotate/buildkite/eslint.js +3 -37
  122. package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
  123. package/lib/cli/lint/annotate/buildkite/index.js +11 -45
  124. package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
  125. package/lib/cli/lint/annotate/buildkite/internal.js +3 -37
  126. package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
  127. package/lib/cli/lint/annotate/buildkite/prettier.js +3 -37
  128. package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
  129. package/lib/cli/lint/annotate/buildkite/tsc.js +3 -37
  130. package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
  131. package/lib/cli/lint/annotate/github/eslint.js +2 -26
  132. package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
  133. package/lib/cli/lint/annotate/github/index.js +11 -45
  134. package/lib/cli/lint/annotate/github/index.js.map +1 -1
  135. package/lib/cli/lint/annotate/github/internal.js +2 -26
  136. package/lib/cli/lint/annotate/github/internal.js.map +1 -1
  137. package/lib/cli/lint/annotate/github/prettier.js +2 -26
  138. package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
  139. package/lib/cli/lint/annotate/github/tsc.js +4 -28
  140. package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
  141. package/lib/cli/lint/annotate/index.js +6 -30
  142. package/lib/cli/lint/annotate/index.js.map +1 -1
  143. package/lib/cli/lint/autofix.js +37 -73
  144. package/lib/cli/lint/autofix.js.map +1 -1
  145. package/lib/cli/lint/eslint.js +16 -51
  146. package/lib/cli/lint/eslint.js.map +3 -3
  147. package/lib/cli/lint/external.js +19 -51
  148. package/lib/cli/lint/external.js.map +2 -2
  149. package/lib/cli/lint/index.js +26 -52
  150. package/lib/cli/lint/index.js.map +2 -2
  151. package/lib/cli/lint/internal.js +20 -52
  152. package/lib/cli/lint/internal.js.map +3 -3
  153. package/lib/cli/lint/internalLints/detectBadCodeowners.js +8 -33
  154. package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
  155. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +12 -48
  156. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +3 -3
  157. package/lib/cli/lint/internalLints/patchRenovateConfig.js +21 -55
  158. package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
  159. package/lib/cli/lint/internalLints/refreshConfigFiles.js +33 -66
  160. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +3 -3
  161. package/lib/cli/lint/internalLints/upgrade/index.d.ts +1 -1
  162. package/lib/cli/lint/internalLints/upgrade/index.js +23 -56
  163. package/lib/cli/lint/internalLints/upgrade/index.js.map +3 -3
  164. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +4 -28
  165. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js.map +1 -1
  166. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js +11 -45
  167. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js.map +2 -2
  168. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +6 -30
  169. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +1 -1
  170. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js +37 -65
  171. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +3 -3
  172. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +11 -46
  173. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +2 -2
  174. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +4 -28
  175. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +1 -1
  176. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +23 -59
  177. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +2 -2
  178. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js +4 -28
  179. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +1 -1
  180. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +11 -46
  181. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +2 -2
  182. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +6 -30
  183. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js.map +1 -1
  184. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js +11 -46
  185. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +2 -2
  186. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +11 -46
  187. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +2 -2
  188. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js +4 -28
  189. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js.map +1 -1
  190. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js +11 -46
  191. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +2 -2
  192. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js +29 -67
  193. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js.map +2 -2
  194. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js +10 -34
  195. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js.map +1 -1
  196. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js +11 -45
  197. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js.map +2 -2
  198. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.d.ts +4 -0
  199. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js +18 -63
  200. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js.map +3 -3
  201. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js +15 -50
  202. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +2 -2
  203. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/addTypeModuleToPackageJson.d.ts +6 -0
  204. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/addTypeModuleToPackageJson.js +86 -0
  205. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/addTypeModuleToPackageJson.js.map +7 -0
  206. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.d.ts +2 -0
  207. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.js +16 -0
  208. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.js.map +7 -0
  209. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.d.ts +7 -0
  210. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.js +76 -0
  211. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.js.map +7 -0
  212. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +17 -51
  213. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js.map +2 -2
  214. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js +10 -34
  215. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js.map +1 -1
  216. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js +10 -44
  217. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js.map +2 -2
  218. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js +12 -46
  219. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js.map +2 -2
  220. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js +4 -28
  221. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js.map +1 -1
  222. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js +15 -49
  223. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js.map +2 -2
  224. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +11 -45
  225. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +2 -2
  226. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +10 -39
  227. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +2 -2
  228. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js +11 -45
  229. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js.map +2 -2
  230. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js +11 -45
  231. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js.map +2 -2
  232. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js +13 -47
  233. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js.map +2 -2
  234. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js +4 -28
  235. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js.map +1 -1
  236. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js +11 -45
  237. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +2 -2
  238. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js +4 -28
  239. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js.map +1 -1
  240. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js +8 -32
  241. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +1 -1
  242. package/lib/cli/lint/prettier.js +15 -50
  243. package/lib/cli/lint/prettier.js.map +3 -3
  244. package/lib/cli/lint/tsc.js +4 -28
  245. package/lib/cli/lint/tsc.js.map +1 -1
  246. package/lib/cli/lint/types.js +0 -16
  247. package/lib/cli/lint/types.js.map +3 -3
  248. package/lib/cli/migrate/index.js +10 -34
  249. package/lib/cli/migrate/index.js.map +1 -1
  250. package/lib/cli/migrate/nodeVersion/checks.js +24 -61
  251. package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
  252. package/lib/cli/migrate/nodeVersion/index.js +25 -55
  253. package/lib/cli/migrate/nodeVersion/index.js.map +2 -2
  254. package/lib/cli/node/index.js +20 -57
  255. package/lib/cli/node/index.js.map +3 -3
  256. package/lib/cli/release/index.js +4 -28
  257. package/lib/cli/release/index.js.map +1 -1
  258. package/lib/cli/start/index.js +16 -50
  259. package/lib/cli/start/index.js.map +3 -3
  260. package/lib/cli/test/index.js +4 -44
  261. package/lib/cli/test/index.js.map +2 -2
  262. package/lib/cli/version/index.js +6 -30
  263. package/lib/cli/version/index.js.map +1 -1
  264. package/lib/eslint.d.js +0 -1
  265. package/lib/index.d.ts +0 -1
  266. package/lib/index.js +6 -46
  267. package/lib/index.js.map +2 -2
  268. package/lib/skuba.js +26 -45
  269. package/lib/skuba.js.map +3 -3
  270. package/lib/utils/args.js +6 -43
  271. package/lib/utils/args.js.map +2 -2
  272. package/lib/utils/command.js +4 -42
  273. package/lib/utils/command.js.map +3 -3
  274. package/lib/utils/copy.js +20 -57
  275. package/lib/utils/copy.js.map +2 -2
  276. package/lib/utils/dir.js +32 -72
  277. package/lib/utils/dir.js.map +2 -2
  278. package/lib/utils/env.js +2 -26
  279. package/lib/utils/env.js.map +1 -1
  280. package/lib/utils/error.js +10 -47
  281. package/lib/utils/error.js.map +1 -1
  282. package/lib/utils/exec.d.ts +3 -2
  283. package/lib/utils/exec.js +24 -62
  284. package/lib/utils/exec.js.map +3 -3
  285. package/lib/utils/fs.js +6 -40
  286. package/lib/utils/fs.js.map +3 -3
  287. package/lib/utils/help.js +6 -30
  288. package/lib/utils/help.js.map +1 -1
  289. package/lib/utils/logging.d.ts +9 -10
  290. package/lib/utils/logging.js +11 -48
  291. package/lib/utils/logging.js.map +3 -3
  292. package/lib/utils/logo.js +28 -59
  293. package/lib/utils/logo.js.map +3 -3
  294. package/lib/utils/manifest.d.ts +3 -2
  295. package/lib/utils/manifest.js +8 -48
  296. package/lib/utils/manifest.js.map +3 -3
  297. package/lib/utils/npmrc.js +2 -26
  298. package/lib/utils/npmrc.js.map +1 -1
  299. package/lib/utils/packageManager.js +12 -49
  300. package/lib/utils/packageManager.js.map +2 -2
  301. package/lib/utils/port.js +4 -39
  302. package/lib/utils/port.js.map +2 -2
  303. package/lib/utils/sleep.js +2 -26
  304. package/lib/utils/sleep.js.map +1 -1
  305. package/lib/utils/template.js +18 -55
  306. package/lib/utils/template.js.map +3 -3
  307. package/lib/utils/validation.js +2 -31
  308. package/lib/utils/validation.js.map +1 -1
  309. package/lib/utils/version.js +9 -46
  310. package/lib/utils/version.js.map +2 -2
  311. package/lib/utils/wait.js +7 -32
  312. package/lib/utils/wait.js.map +1 -1
  313. package/lib/utils/worker.d.ts +3 -3
  314. package/lib/utils/worker.js +10 -35
  315. package/lib/utils/worker.js.map +1 -1
  316. package/lib/wrapper/function-arguments.d.js +0 -1
  317. package/lib/wrapper/functionHandler.js +18 -49
  318. package/lib/wrapper/functionHandler.js.map +2 -2
  319. package/lib/wrapper/http.d.ts +0 -6
  320. package/lib/wrapper/http.js +8 -51
  321. package/lib/wrapper/http.js.map +3 -3
  322. package/lib/wrapper/index.js +6 -7
  323. package/lib/wrapper/index.js.map +1 -1
  324. package/lib/wrapper/main.js +8 -42
  325. package/lib/wrapper/main.js.map +3 -3
  326. package/lib/wrapper/requestListener.js +13 -46
  327. package/lib/wrapper/requestListener.js.map +3 -3
  328. package/lib/wrapper/server.d.ts +7 -0
  329. package/lib/wrapper/server.js +11 -0
  330. package/lib/wrapper/server.js.map +7 -0
  331. package/package.json +17 -24
  332. package/template/base/_.prettierrc.js +1 -1
  333. package/template/base/_eslint.config.js +1 -1
  334. package/template/base/_pnpm-workspace.yaml +3 -2
  335. package/template/base/vitest.config.ts +25 -0
  336. package/template/express-rest-api/package.json +2 -1
  337. package/template/express-rest-api/skuba.template.js +1 -1
  338. package/template/express-rest-api/src/app.test.ts +1 -0
  339. package/template/greeter/package.json +4 -3
  340. package/template/greeter/skuba.template.js +1 -1
  341. package/template/greeter/src/app.test.ts +3 -1
  342. package/template/koa-rest-api/package.json +2 -1
  343. package/template/koa-rest-api/skuba.template.js +1 -1
  344. package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +2 -0
  345. package/template/koa-rest-api/src/api/jobs/postJob.test.ts +2 -0
  346. package/template/koa-rest-api/src/app.test.ts +2 -0
  347. package/template/koa-rest-api/src/framework/server.test.ts +2 -2
  348. package/template/koa-rest-api/src/framework/validation.test.ts +2 -0
  349. package/template/koa-rest-api/src/testing/metrics.ts +2 -0
  350. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +15 -5
  351. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +11 -9
  352. package/template/lambda-sqs-worker-cdk/package.json +6 -5
  353. package/template/lambda-sqs-worker-cdk/skuba.template.js +1 -1
  354. package/template/lambda-sqs-worker-cdk/src/app.test.ts +22 -13
  355. package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +1 -0
  356. package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +33 -31
  357. package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +8 -2
  358. package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +3 -2
  359. package/template/lambda-sqs-worker-cdk/src/testing/services.ts +4 -3
  360. package/template/oss-npm-package/_package.json +1 -0
  361. package/template/oss-npm-package/skuba.template.js +1 -1
  362. package/template/oss-npm-package/src/index.test.ts +2 -0
  363. package/template/private-npm-package/_package.json +1 -0
  364. package/template/private-npm-package/skuba.template.js +1 -1
  365. package/template/private-npm-package/src/index.test.ts +2 -0
  366. package/config/jest.js +0 -1
  367. package/jest/moduleNameMapper.js +0 -64
  368. package/jest/transform.js +0 -62
  369. package/jest/tsConfig.js +0 -26
  370. package/jest-preset.js +0 -37
  371. package/lib/api/jest/index.d.ts +0 -15
  372. package/lib/api/jest/index.js +0 -59
  373. package/lib/api/jest/index.js.map +0 -7
  374. package/lib/cli/configure/modules/jest.d.ts +0 -2
  375. package/lib/cli/configure/modules/jest.js +0 -86
  376. package/lib/cli/configure/modules/jest.js.map +0 -7
  377. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.d.ts +0 -2
  378. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +0 -144
  379. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +0 -7
  380. package/lib/cli/test/reporters/github/annotations.d.ts +0 -9
  381. package/lib/cli/test/reporters/github/annotations.js +0 -102
  382. package/lib/cli/test/reporters/github/annotations.js.map +0 -7
  383. package/lib/cli/test/reporters/github/index.d.ts +0 -5
  384. package/lib/cli/test/reporters/github/index.js +0 -74
  385. package/lib/cli/test/reporters/github/index.js.map +0 -7
  386. package/template/base/jest.config.ts +0 -19
  387. package/template/base/jest.setup.ts +0 -3
@@ -1,59 +1,34 @@
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 getConfig_exports = {};
30
- __export(getConfig_exports, {
31
- configureFromPrompt: () => configureFromPrompt,
32
- getConfig: () => getConfig,
33
- getTemplateConfig: () => getTemplateConfig,
34
- readJSONFromStdIn: () => readJSONFromStdIn,
35
- runForm: () => runForm
36
- });
37
- module.exports = __toCommonJS(getConfig_exports);
38
- var import_path = __toESM(require("path"));
39
- var import_prompts = require("@inquirer/prompts");
40
- var import_chalk = __toESM(require("chalk"));
41
- var import_fs_extra = __toESM(require("fs-extra"));
42
- var import_copy = require("../../utils/copy.js");
43
- var import_error = require("../../utils/error.js");
44
- var import_logging = require("../../utils/logging.js");
45
- var import_packageManager = require("../../utils/packageManager.js");
46
- var import_port = require("../../utils/port.js");
47
- var import_template = require("../../utils/template.js");
48
- var import_git = require("./git.js");
49
- var import_prompts2 = require("./prompts.js");
50
- var import_types = require("./types.js");
1
+ import { styleText } from "node:util";
2
+ import path from "path";
3
+ import { input } from "@inquirer/prompts";
4
+ import fs from "fs-extra";
5
+ import { copyFiles } from "../../utils/copy.js";
6
+ import { isErrorWithCode } from "../../utils/error.js";
7
+ import { log } from "../../utils/logging.js";
8
+ import {
9
+ DEFAULT_PACKAGE_MANAGER,
10
+ configForPackageManager
11
+ } from "../../utils/packageManager.js";
12
+ import { getRandomPort } from "../../utils/port.js";
13
+ import {
14
+ TEMPLATE_CONFIG_FILENAME,
15
+ TEMPLATE_DIR,
16
+ templateConfigSchema
17
+ } from "../../utils/template.js";
18
+ import { downloadGitHubTemplate } from "./git.js";
19
+ import {
20
+ BASE_PROMPT_PROPS,
21
+ getGitPath,
22
+ getTemplateName,
23
+ shouldContinue
24
+ } from "./prompts.js";
25
+ import { initConfigInputSchema } from "./types.js";
51
26
  const runForm = async (props) => {
52
27
  const { message } = props;
53
- import_logging.log.plain(message);
28
+ log.plain(message);
54
29
  const result = {};
55
30
  for (const choice of props.choices) {
56
- const inputValue = await (0, import_prompts.input)({
31
+ const inputValue = await input({
57
32
  message: choice.message,
58
33
  default: choice.initial,
59
34
  validate: async (inputText) => {
@@ -69,20 +44,20 @@ const runForm = async (props) => {
69
44
  };
70
45
  const confirmShouldContinue = async (choices) => {
71
46
  const fieldsList = choices.map((choice) => choice.message);
72
- import_logging.log.newline();
73
- import_logging.log.plain("This template uses the following information:");
74
- import_logging.log.newline();
75
- fieldsList.forEach((message) => import_logging.log.subtle(`- ${message}`));
76
- import_logging.log.newline();
77
- const result = await (0, import_prompts2.shouldContinue)();
47
+ log.newline();
48
+ log.plain("This template uses the following information:");
49
+ log.newline();
50
+ fieldsList.forEach((message) => log.subtle(`- ${message}`));
51
+ log.newline();
52
+ const result = await shouldContinue();
78
53
  return result === "yes";
79
54
  };
80
55
  const createDirectory = async (dir) => {
81
56
  try {
82
- await import_fs_extra.default.promises.mkdir(dir);
57
+ await fs.promises.mkdir(dir);
83
58
  } catch (err) {
84
- if ((0, import_error.isErrorWithCode)(err, "EEXIST")) {
85
- import_logging.log.err(`The directory '${dir}' already exists.`);
59
+ if (isErrorWithCode(err, "EEXIST")) {
60
+ log.err(`The directory '${dir}' already exists.`);
86
61
  process.exit(1);
87
62
  }
88
63
  throw err;
@@ -92,10 +67,10 @@ const cloneTemplate = async (templateName, destinationDir) => {
92
67
  const isCustomTemplate = templateName.startsWith("github:");
93
68
  if (isCustomTemplate) {
94
69
  const gitHubPath = templateName.slice("github:".length);
95
- await (0, import_git.downloadGitHubTemplate)(gitHubPath, destinationDir);
70
+ await downloadGitHubTemplate(gitHubPath, destinationDir);
96
71
  } else {
97
- const templateDir = import_path.default.join(import_template.TEMPLATE_DIR, templateName);
98
- await (0, import_copy.copyFiles)({
72
+ const templateDir = path.join(TEMPLATE_DIR, templateName);
73
+ await copyFiles({
99
74
  // assume built-in templates have no extraneous files
100
75
  include: () => true,
101
76
  sourceRoot: templateDir,
@@ -105,17 +80,15 @@ const cloneTemplate = async (templateName, destinationDir) => {
105
80
  stripUnderscorePrefix: true
106
81
  });
107
82
  }
108
- const templateConfig = getTemplateConfig(
109
- import_path.default.join(process.cwd(), destinationDir)
83
+ const templateConfig = await getTemplateConfig(
84
+ path.join(process.cwd(), destinationDir)
110
85
  );
111
86
  if (isCustomTemplate) {
112
- import_logging.log.newline();
113
- import_logging.log.warn(
87
+ log.newline();
88
+ log.warn(
114
89
  "You may need to run",
115
- import_logging.log.bold(
116
- (0, import_packageManager.configForPackageManager)(templateConfig.packageManager).print.exec,
117
- "skuba",
118
- "configure"
90
+ log.bold(
91
+ `${configForPackageManager(templateConfig.packageManager).print.exec} skuba configure`
119
92
  ),
120
93
  "once this is done."
121
94
  );
@@ -123,9 +96,9 @@ const cloneTemplate = async (templateName, destinationDir) => {
123
96
  return templateConfig;
124
97
  };
125
98
  const selectTemplateName = async () => {
126
- const templateSelection = await (0, import_prompts2.getTemplateName)();
99
+ const templateSelection = await getTemplateName();
127
100
  if (templateSelection === "github \u2192") {
128
- const gitHubPath = await (0, import_prompts2.getGitPath)();
101
+ const gitHubPath = await getGitPath();
129
102
  return `github:${gitHubPath}`;
130
103
  }
131
104
  return templateSelection;
@@ -133,17 +106,17 @@ const selectTemplateName = async () => {
133
106
  const generatePlaceholders = (choices) => Object.fromEntries(
134
107
  choices.map(({ name }) => [name, `<%- ${name} %>`])
135
108
  );
136
- const getTemplateConfig = (dir) => {
137
- const templateConfigPath = import_path.default.join(dir, import_template.TEMPLATE_CONFIG_FILENAME);
109
+ const getTemplateConfig = async (dir) => {
110
+ const templateConfigPath = path.join(dir, TEMPLATE_CONFIG_FILENAME);
138
111
  try {
139
- const templateConfig = require(templateConfigPath);
140
- return import_template.templateConfigSchema.parse(templateConfig);
112
+ const templateModule = await import(templateConfigPath);
113
+ return templateConfigSchema.parse(templateModule.default);
141
114
  } catch (err) {
142
- if ((0, import_error.isErrorWithCode)(err, "MODULE_NOT_FOUND")) {
115
+ if (isErrorWithCode(err, "MODULE_NOT_FOUND")) {
143
116
  return {
144
117
  entryPoint: void 0,
145
118
  fields: [],
146
- packageManager: import_packageManager.DEFAULT_PACKAGE_MANAGER,
119
+ packageManager: DEFAULT_PACKAGE_MANAGER,
147
120
  type: void 0
148
121
  };
149
122
  }
@@ -157,7 +130,7 @@ const baseToTemplateData = async ({
157
130
  defaultBranch
158
131
  }) => {
159
132
  const [orgName, teamName] = ownerName.split("/");
160
- const port = String(await (0, import_port.getRandomPort)());
133
+ const port = String(await getRandomPort());
161
134
  if (!orgName) {
162
135
  throw new Error(`Invalid format for owner name: ${ownerName}`);
163
136
  }
@@ -175,8 +148,8 @@ const baseToTemplateData = async ({
175
148
  };
176
149
  };
177
150
  const configureFromPrompt = async () => {
178
- const { ownerName, platformName, repoName, defaultBranch } = await runForm(import_prompts2.BASE_PROMPT_PROPS);
179
- import_logging.log.plain(import_chalk.default.cyan(repoName), "by", import_chalk.default.cyan(ownerName));
151
+ const { ownerName, platformName, repoName, defaultBranch } = await runForm(BASE_PROMPT_PROPS);
152
+ log.plain(styleText("cyan", repoName), "by", styleText("cyan", ownerName));
180
153
  const templateData = await baseToTemplateData({
181
154
  ownerName,
182
155
  platformName,
@@ -185,7 +158,7 @@ const configureFromPrompt = async () => {
185
158
  });
186
159
  const destinationDir = repoName;
187
160
  await createDirectory(destinationDir);
188
- import_logging.log.newline();
161
+ log.newline();
189
162
  const templateName = await selectTemplateName();
190
163
  const { entryPoint, fields, noSkip, packageManager, type } = await cloneTemplate(templateName, destinationDir);
191
164
  if (fields.length === 0) {
@@ -201,10 +174,13 @@ const configureFromPrompt = async () => {
201
174
  }
202
175
  const shouldContinueWithTemplate = noSkip ? true : await confirmShouldContinue(fields);
203
176
  if (shouldContinueWithTemplate) {
204
- import_logging.log.newline();
177
+ log.newline();
205
178
  const customAnswers2 = await runForm({
206
179
  choices: fields,
207
- message: import_chalk.default.bold(`Complete ${import_chalk.default.cyan(templateName)}:`),
180
+ message: styleText(
181
+ "bold",
182
+ `Complete ${styleText("cyan", templateName)}:`
183
+ ),
208
184
  name: "customAnswers"
209
185
  });
210
186
  return {
@@ -217,12 +193,9 @@ const configureFromPrompt = async () => {
217
193
  type
218
194
  };
219
195
  }
220
- import_logging.log.newline();
221
- import_logging.log.warn(
222
- `Resume this later with ${import_chalk.default.bold(
223
- (0, import_packageManager.configForPackageManager)(packageManager).print.exec,
224
- "skuba configure"
225
- )}.`
196
+ log.newline();
197
+ log.warn(
198
+ `Resume this later with ${styleText("bold", `${configForPackageManager(packageManager).print.exec} skuba configure`)}.`
226
199
  );
227
200
  const customAnswers = generatePlaceholders(fields);
228
201
  return {
@@ -242,24 +215,24 @@ const readJSONFromStdIn = async () => {
242
215
  );
243
216
  text = text.trim();
244
217
  if (text === "") {
245
- import_logging.log.err("No data from stdin.");
218
+ log.err("No data from stdin.");
246
219
  process.exit(1);
247
220
  }
248
221
  let value;
249
222
  try {
250
223
  value = JSON.parse(text);
251
224
  } catch {
252
- import_logging.log.err("Invalid JSON from stdin.");
225
+ log.err("Invalid JSON from stdin.");
253
226
  process.exit(1);
254
227
  }
255
228
  return value;
256
229
  };
257
230
  const configureFromPipe = async () => {
258
231
  const value = await readJSONFromStdIn();
259
- const result = import_types.initConfigInputSchema.safeParse(value);
232
+ const result = initConfigInputSchema.safeParse(value);
260
233
  if (!result.success) {
261
- import_logging.log.err("Invalid data from stdin:");
262
- import_logging.log.err(result.error);
234
+ log.err("Invalid data from stdin:");
235
+ log.err(result.error);
263
236
  process.exit(1);
264
237
  }
265
238
  const { destinationDir, templateComplete, templateName } = result.data;
@@ -271,7 +244,7 @@ const configureFromPipe = async () => {
271
244
  const { entryPoint, fields, noSkip, packageManager, type } = await cloneTemplate(templateName, destinationDir);
272
245
  if (!templateComplete) {
273
246
  if (noSkip) {
274
- import_logging.log.err("Templating for", import_logging.log.bold(templateName), "cannot be skipped.");
247
+ log.err("Templating for", log.bold(templateName), "cannot be skipped.");
275
248
  process.exit(1);
276
249
  }
277
250
  return {
@@ -289,9 +262,9 @@ const configureFromPipe = async () => {
289
262
  const provided = new Set(Object.keys(templateData));
290
263
  const missing = required.filter((name) => !provided.has(name));
291
264
  if (missing.length > 0) {
292
- import_logging.log.err("This template uses the following information:");
293
- import_logging.log.newline();
294
- missing.forEach((name) => import_logging.log.err(`- ${name}`));
265
+ log.err("This template uses the following information:");
266
+ log.newline();
267
+ missing.forEach((name) => log.err(`- ${name}`));
295
268
  process.exit(1);
296
269
  }
297
270
  return {
@@ -303,12 +276,11 @@ const configureFromPipe = async () => {
303
276
  };
304
277
  };
305
278
  const getConfig = () => process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();
306
- // Annotate the CommonJS export names for ESM import in node:
307
- 0 && (module.exports = {
279
+ export {
308
280
  configureFromPrompt,
309
281
  getConfig,
310
282
  getTemplateConfig,
311
283
  readJSONFromStdIn,
312
284
  runForm
313
- });
285
+ };
314
286
  //# sourceMappingURL=getConfig.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/init/getConfig.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport { input } from '@inquirer/prompts';\nimport chalk from 'chalk';\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 getGitPath,\n getTemplateName,\n shouldContinue,\n} from './prompts.js';\nimport { type InitConfig, initConfigInputSchema } from './types.js';\n\nexport const runForm = async <T = Record<string, string>>(props: {\n choices: readonly Choice[];\n message: string;\n name: string;\n}): Promise<T> => {\n const { message } = props;\n log.plain(message);\n\n const result: Record<string, string> = {};\n\n for (const choice of props.choices) {\n const inputValue = await input({\n message: choice.message,\n default: choice.initial,\n validate: async (inputText: string) => {\n if (\n !inputText ||\n inputText === '' ||\n (inputText === choice.initial && !choice.allowInitial)\n ) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(inputText) ?? true;\n },\n });\n\n result[choice.name] = inputValue;\n }\n\n return result as T;\n};\n\nconst confirmShouldContinue = async (choices: readonly Choice[]) => {\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 shouldContinue();\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 = 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 selectTemplateName = async () => {\n const templateSelection = await getTemplateName();\n\n if (templateSelection === 'github \u2192') {\n const gitHubPath = await getGitPath();\n return `github:${gitHubPath}`;\n }\n\n return templateSelection;\n};\n\nconst generatePlaceholders = (choices: Choice[]) =>\n Object.fromEntries(\n choices.map(({ name }) => [name, `<%- ${name} %>`] as const),\n );\n\nexport const getTemplateConfig = (dir: string): TemplateConfig => {\n const templateConfigPath = path.join(dir, TEMPLATE_CONFIG_FILENAME);\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const templateConfig = require(templateConfigPath) as unknown;\n\n return templateConfigSchema.parse(templateConfig);\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 selectTemplateName();\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 shouldContinueWithTemplate = noSkip\n ? true\n : await confirmShouldContinue(fields);\n\n if (shouldContinueWithTemplate) {\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};\n\nexport const getConfig = () =>\n process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;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Q,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
- "names": ["import_prompts", "fs", "path", "chalk", "customAnswers"]
4
+ "sourcesContent": ["import { styleText } from 'node:util';\nimport path from 'path';\n\nimport { input } from '@inquirer/prompts';\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 getGitPath,\n getTemplateName,\n shouldContinue,\n} from './prompts.js';\nimport { type InitConfig, initConfigInputSchema } from './types.js';\n\nexport const runForm = async <T = Record<string, string>>(props: {\n choices: readonly Choice[];\n message: string;\n name: string;\n}): Promise<T> => {\n const { message } = props;\n log.plain(message);\n\n const result: Record<string, string> = {};\n\n for (const choice of props.choices) {\n const inputValue = await input({\n message: choice.message,\n default: choice.initial,\n validate: async (inputText: string) => {\n if (\n !inputText ||\n inputText === '' ||\n (inputText === choice.initial && !choice.allowInitial)\n ) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(inputText) ?? true;\n },\n });\n\n result[choice.name] = inputValue;\n }\n\n return result as T;\n};\n\nconst confirmShouldContinue = async (choices: readonly Choice[]) => {\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 shouldContinue();\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} skuba configure`,\n ),\n 'once this is done.',\n );\n }\n\n return templateConfig;\n};\n\nconst selectTemplateName = async () => {\n const templateSelection = await getTemplateName();\n\n if (templateSelection === 'github \u2192') {\n const gitHubPath = await getGitPath();\n return `github:${gitHubPath}`;\n }\n\n return templateSelection;\n};\n\nconst generatePlaceholders = (choices: Choice[]) =>\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(styleText('cyan', repoName), 'by', styleText('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 selectTemplateName();\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 shouldContinueWithTemplate = noSkip\n ? true\n : await confirmShouldContinue(fields);\n\n if (shouldContinueWithTemplate) {\n log.newline();\n const customAnswers = await runForm({\n choices: fields,\n message: styleText(\n 'bold',\n `Complete ${styleText('cyan', templateName)}:`,\n ),\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 ${styleText('bold', `${configForPackageManager(packageManager).print.exec} skuba configure`)}.`,\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};\n\nexport const getConfig = () =>\n process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAC1B,OAAO,UAAU;AAEjB,SAAS,aAAa;AACtB,OAAO,QAAQ;AAEf,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AA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EO,MAAM,YAAY,MACvB,QAAQ,MAAM,QAAQ,oBAAoB,IAAI,kBAAkB;",
6
+ "names": ["customAnswers"]
7
7
  }
@@ -1,75 +1,40 @@
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 git_exports = {};
30
- __export(git_exports, {
31
- downloadGitHubTemplate: () => downloadGitHubTemplate,
32
- initialiseRepo: () => initialiseRepo
33
- });
34
- module.exports = __toCommonJS(git_exports);
35
- var import_path = __toESM(require("path"));
36
- var import_fs_extra = __toESM(require("fs-extra"));
37
- var import_isomorphic_git = __toESM(require("isomorphic-git"));
38
- var import_simple_git = require("simple-git");
39
- var import_logging = require("../../utils/logging.js");
40
- var Git = __toESM(require("@skuba-lib/api/git"));
1
+ import path from "path";
2
+ import fs from "fs-extra";
3
+ import git from "isomorphic-git";
4
+ import { simpleGit } from "simple-git";
5
+ import { log } from "../../utils/logging.js";
6
+ import * as Git from "@skuba-lib/api/git";
41
7
  const initialiseRepo = async (dir, { orgName, repoName, defaultBranch }) => {
42
- await import_isomorphic_git.default.init({
8
+ await git.init({
43
9
  defaultBranch,
44
10
  dir,
45
- fs: import_fs_extra.default
11
+ fs
46
12
  });
47
13
  await Git.commit({
48
14
  dir,
49
15
  message: "Initial commit"
50
16
  });
51
- await import_isomorphic_git.default.addRemote({
17
+ await git.addRemote({
52
18
  dir,
53
- fs: import_fs_extra.default,
19
+ fs,
54
20
  remote: "origin",
55
21
  url: `git@github.com:${orgName}/${repoName}.git`
56
22
  });
57
23
  };
58
24
  const downloadGitHubTemplate = async (gitHubPath, destinationDir) => {
59
- import_logging.log.newline();
60
- import_logging.log.plain("Downloading", import_logging.log.bold(gitHubPath), "from GitHub...");
61
- await (0, import_simple_git.simpleGit)().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [
25
+ log.newline();
26
+ log.plain("Downloading", log.bold(gitHubPath), "from GitHub...");
27
+ await simpleGit().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [
62
28
  "--depth=1",
63
29
  "--quiet"
64
30
  ]);
65
- await import_fs_extra.default.promises.rm(import_path.default.join(destinationDir, ".git"), {
31
+ await fs.promises.rm(path.join(destinationDir, ".git"), {
66
32
  force: true,
67
33
  recursive: true
68
34
  });
69
35
  };
70
- // Annotate the CommonJS export names for ESM import in node:
71
- 0 && (module.exports = {
36
+ export {
72
37
  downloadGitHubTemplate,
73
38
  initialiseRepo
74
- });
39
+ };
75
40
  //# sourceMappingURL=git.js.map
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,4BAAgB;AAChB,wBAA0B;AAE1B,qBAAoB;AAEpB,UAAqB;AAQd,MAAM,iBAAiB,OAC5B,KACA,EAAE,SAAS,UAAU,cAAc,MAChC;AACH,QAAM,sBAAAA,QAAI,KAAK;AAAA,IACb;AAAA,IACA;AAAA,IACA,oBAAAC;AAAA,EACF,CAAC;AAED,QAAM,IAAI,OAAO;AAAA,IACf;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAED,QAAM,sBAAAD,QAAI,UAAU;AAAA,IAClB;AAAA,IACA,oBAAAC;AAAA,IACA,QAAQ;AAAA,IACR,KAAK,kBAAkB,OAAO,IAAI,QAAQ;AAAA,EAC5C,CAAC;AACH;AAEO,MAAM,yBAAyB,OACpC,YACA,mBACG;AACH,qBAAI,QAAQ;AACZ,qBAAI,MAAM,eAAe,mBAAI,KAAK,UAAU,GAAG,gBAAgB;AAE/D,YAAM,6BAAU,EAAE,MAAM,kBAAkB,UAAU,Q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