skuba 13.0.3 → 14.0.0-esmify-skuba-20251031135439

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 (516) hide show
  1. package/config/eslint.js +1 -1
  2. package/config/prettier.js +10 -2
  3. package/lib/cli/adapter/eslint.js +10 -46
  4. package/lib/cli/adapter/eslint.js.map +2 -2
  5. package/lib/cli/adapter/prettier.js +40 -72
  6. package/lib/cli/adapter/prettier.js.map +2 -2
  7. package/lib/cli/build/args.js +7 -43
  8. package/lib/cli/build/args.js.map +2 -2
  9. package/lib/cli/build/assets.js +27 -62
  10. package/lib/cli/build/assets.js.map +2 -2
  11. package/lib/cli/build/esbuild.js +20 -55
  12. package/lib/cli/build/esbuild.js.map +3 -3
  13. package/lib/cli/build/index.js +20 -56
  14. package/lib/cli/build/index.js.map +2 -2
  15. package/lib/cli/build/tsc.js +24 -66
  16. package/lib/cli/build/tsc.js.map +2 -2
  17. package/lib/cli/buildPackage/index.js +7 -33
  18. package/lib/cli/buildPackage/index.js.map +1 -1
  19. package/lib/cli/configure/analyseConfiguration.js +15 -51
  20. package/lib/cli/configure/analyseConfiguration.js.map +2 -2
  21. package/lib/cli/configure/analyseDependencies.js +24 -60
  22. package/lib/cli/configure/analyseDependencies.js.map +3 -3
  23. package/lib/cli/configure/analysis/diff.js +4 -40
  24. package/lib/cli/configure/analysis/diff.js.map +2 -2
  25. package/lib/cli/configure/analysis/files.js +7 -43
  26. package/lib/cli/configure/analysis/files.js.map +2 -2
  27. package/lib/cli/configure/analysis/git.js +11 -47
  28. package/lib/cli/configure/analysis/git.js.map +2 -2
  29. package/lib/cli/configure/analysis/package.js +10 -48
  30. package/lib/cli/configure/analysis/package.js.map +3 -3
  31. package/lib/cli/configure/analysis/project.js +18 -53
  32. package/lib/cli/configure/analysis/project.js.map +2 -2
  33. package/lib/cli/configure/dependencies/index.js +5 -39
  34. package/lib/cli/configure/dependencies/index.js.map +1 -1
  35. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +3 -29
  36. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
  37. package/lib/cli/configure/dependencies/seekKoala.js +3 -29
  38. package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
  39. package/lib/cli/configure/dependencies/skuba.js +3 -29
  40. package/lib/cli/configure/dependencies/skuba.js.map +1 -1
  41. package/lib/cli/configure/dependencies/skubaDeps.js +1 -27
  42. package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
  43. package/lib/cli/configure/dependencies/skubaDive.js +4 -32
  44. package/lib/cli/configure/dependencies/skubaDive.js.map +1 -1
  45. package/lib/cli/configure/ensureTemplateCompletion.js +31 -61
  46. package/lib/cli/configure/ensureTemplateCompletion.js.map +3 -3
  47. package/lib/cli/configure/getEntryPoint.js +13 -49
  48. package/lib/cli/configure/getEntryPoint.js.map +3 -3
  49. package/lib/cli/configure/getProjectType.js +13 -36
  50. package/lib/cli/configure/getProjectType.js.map +2 -2
  51. package/lib/cli/configure/index.js +49 -85
  52. package/lib/cli/configure/index.js.map +3 -3
  53. package/lib/cli/configure/modules/eslint.js +9 -35
  54. package/lib/cli/configure/modules/eslint.js.map +1 -1
  55. package/lib/cli/configure/modules/ignore.js +7 -33
  56. package/lib/cli/configure/modules/ignore.js.map +1 -1
  57. package/lib/cli/configure/modules/index.js +17 -45
  58. package/lib/cli/configure/modules/index.js.map +2 -2
  59. package/lib/cli/configure/modules/nodemon.js +2 -28
  60. package/lib/cli/configure/modules/nodemon.js.map +1 -1
  61. package/lib/cli/configure/modules/package.js +9 -35
  62. package/lib/cli/configure/modules/package.js.map +1 -1
  63. package/lib/cli/configure/modules/prettier.js +10 -36
  64. package/lib/cli/configure/modules/prettier.js.map +1 -1
  65. package/lib/cli/configure/modules/renovate.js +17 -43
  66. package/lib/cli/configure/modules/renovate.js.map +2 -2
  67. package/lib/cli/configure/modules/serverless.js +1 -27
  68. package/lib/cli/configure/modules/serverless.js.map +1 -1
  69. package/lib/cli/configure/modules/tslint.js +2 -28
  70. package/lib/cli/configure/modules/tslint.js.map +1 -1
  71. package/lib/cli/configure/processing/configFile.js +4 -44
  72. package/lib/cli/configure/processing/configFile.js.map +1 -1
  73. package/lib/cli/configure/processing/deleteFiles.js +1 -27
  74. package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
  75. package/lib/cli/configure/processing/javascript.js +2 -30
  76. package/lib/cli/configure/processing/javascript.js.map +1 -1
  77. package/lib/cli/configure/processing/json.js +6 -34
  78. package/lib/cli/configure/processing/json.js.map +1 -1
  79. package/lib/cli/configure/processing/loadFiles.js +1 -27
  80. package/lib/cli/configure/processing/loadFiles.js.map +1 -1
  81. package/lib/cli/configure/processing/module.js +2 -28
  82. package/lib/cli/configure/processing/module.js.map +1 -1
  83. package/lib/cli/configure/processing/package.js +10 -52
  84. package/lib/cli/configure/processing/package.js.map +3 -3
  85. package/lib/cli/configure/processing/prettier.js +3 -39
  86. package/lib/cli/configure/processing/prettier.js.map +2 -2
  87. package/lib/cli/configure/processing/record.js +4 -44
  88. package/lib/cli/configure/processing/record.js.map +2 -2
  89. package/lib/cli/configure/processing/typescript.js +28 -70
  90. package/lib/cli/configure/processing/typescript.js.map +2 -2
  91. package/lib/cli/configure/types.js +0 -15
  92. package/lib/cli/configure/types.js.map +3 -3
  93. package/lib/cli/format/index.js +19 -55
  94. package/lib/cli/format/index.js.map +2 -2
  95. package/lib/cli/help/index.js +5 -31
  96. package/lib/cli/help/index.js.map +1 -1
  97. package/lib/cli/init/getConfig.js +75 -107
  98. package/lib/cli/init/getConfig.js.map +3 -3
  99. package/lib/cli/init/git.js +16 -54
  100. package/lib/cli/init/git.js.map +3 -3
  101. package/lib/cli/init/index.js +66 -99
  102. package/lib/cli/init/index.js.map +2 -2
  103. package/lib/cli/init/prompts.js +20 -56
  104. package/lib/cli/init/prompts.js.map +3 -3
  105. package/lib/cli/init/types.js +6 -42
  106. package/lib/cli/init/types.js.map +1 -1
  107. package/lib/cli/init/validation.js +5 -39
  108. package/lib/cli/init/validation.js.map +1 -1
  109. package/lib/cli/init/writePackageJson.js +7 -43
  110. package/lib/cli/init/writePackageJson.js.map +2 -2
  111. package/lib/cli/lint/annotate/buildkite/eslint.js +2 -38
  112. package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
  113. package/lib/cli/lint/annotate/buildkite/index.js +10 -46
  114. package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
  115. package/lib/cli/lint/annotate/buildkite/internal.js +2 -38
  116. package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
  117. package/lib/cli/lint/annotate/buildkite/prettier.js +2 -38
  118. package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
  119. package/lib/cli/lint/annotate/buildkite/tsc.js +2 -38
  120. package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
  121. package/lib/cli/lint/annotate/github/eslint.js +1 -27
  122. package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
  123. package/lib/cli/lint/annotate/github/index.js +10 -46
  124. package/lib/cli/lint/annotate/github/index.js.map +1 -1
  125. package/lib/cli/lint/annotate/github/internal.js +1 -27
  126. package/lib/cli/lint/annotate/github/internal.js.map +1 -1
  127. package/lib/cli/lint/annotate/github/prettier.js +1 -27
  128. package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
  129. package/lib/cli/lint/annotate/github/tsc.js +3 -29
  130. package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
  131. package/lib/cli/lint/annotate/index.js +5 -31
  132. package/lib/cli/lint/annotate/index.js.map +1 -1
  133. package/lib/cli/lint/autofix.js +38 -78
  134. package/lib/cli/lint/autofix.js.map +3 -3
  135. package/lib/cli/lint/eslint.js +14 -52
  136. package/lib/cli/lint/eslint.js.map +3 -3
  137. package/lib/cli/lint/external.js +18 -53
  138. package/lib/cli/lint/external.js.map +2 -2
  139. package/lib/cli/lint/index.js +24 -50
  140. package/lib/cli/lint/index.js.map +1 -1
  141. package/lib/cli/lint/internal.js +17 -53
  142. package/lib/cli/lint/internal.js.map +2 -2
  143. package/lib/cli/lint/internalLints/detectBadCodeowners.js +8 -36
  144. package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
  145. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +10 -46
  146. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +3 -3
  147. package/lib/cli/lint/internalLints/patchRenovateConfig.js +20 -56
  148. package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
  149. package/lib/cli/lint/internalLints/refreshConfigFiles.js +33 -68
  150. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
  151. package/lib/cli/lint/internalLints/upgrade/index.js +21 -54
  152. package/lib/cli/lint/internalLints/upgrade/index.js.map +3 -3
  153. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +3 -29
  154. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js.map +1 -1
  155. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js +10 -46
  156. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js.map +2 -2
  157. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +5 -31
  158. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +1 -1
  159. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js +36 -73
  160. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +3 -3
  161. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +11 -49
  162. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +2 -2
  163. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +3 -29
  164. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +1 -1
  165. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +24 -64
  166. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +2 -2
  167. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js +3 -29
  168. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +1 -1
  169. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +11 -49
  170. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +2 -2
  171. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +5 -31
  172. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js.map +1 -1
  173. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js +11 -49
  174. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +2 -2
  175. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +11 -49
  176. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +2 -2
  177. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js +3 -29
  178. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js.map +1 -1
  179. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js +11 -49
  180. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +2 -2
  181. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js +32 -76
  182. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js.map +2 -2
  183. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js +9 -35
  184. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js.map +1 -1
  185. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js +10 -46
  186. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js.map +2 -2
  187. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js +28 -88
  188. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js.map +2 -2
  189. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js +15 -53
  190. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +2 -2
  191. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +16 -52
  192. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js.map +2 -2
  193. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js +9 -35
  194. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js.map +1 -1
  195. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js +9 -45
  196. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js.map +2 -2
  197. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js +11 -47
  198. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js.map +2 -2
  199. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js +3 -29
  200. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js.map +1 -1
  201. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js +14 -50
  202. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js.map +2 -2
  203. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +10 -46
  204. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +2 -2
  205. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +9 -40
  206. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +2 -2
  207. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js +10 -46
  208. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js.map +2 -2
  209. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js +10 -46
  210. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js.map +2 -2
  211. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js +12 -48
  212. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js.map +2 -2
  213. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js +3 -29
  214. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js.map +1 -1
  215. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js +10 -46
  216. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +2 -2
  217. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js +3 -29
  218. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js.map +1 -1
  219. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js +7 -33
  220. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +1 -1
  221. package/lib/cli/lint/prettier.js +13 -51
  222. package/lib/cli/lint/prettier.js.map +3 -3
  223. package/lib/cli/lint/tsc.js +3 -29
  224. package/lib/cli/lint/tsc.js.map +1 -1
  225. package/lib/cli/lint/types.js +0 -15
  226. package/lib/cli/lint/types.js.map +3 -3
  227. package/lib/cli/migrate/index.js +9 -35
  228. package/lib/cli/migrate/index.js.map +1 -1
  229. package/lib/cli/migrate/nodeVersion/checks.js +26 -68
  230. package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
  231. package/lib/cli/migrate/nodeVersion/index.js +24 -56
  232. package/lib/cli/migrate/nodeVersion/index.js.map +2 -2
  233. package/lib/cli/node/index.js +20 -60
  234. package/lib/cli/node/index.js.map +3 -3
  235. package/lib/cli/release/index.js +3 -29
  236. package/lib/cli/release/index.js.map +1 -1
  237. package/lib/cli/start/index.js +15 -51
  238. package/lib/cli/start/index.js.map +3 -3
  239. package/lib/cli/test/index.js +3 -45
  240. package/lib/cli/test/index.js.map +2 -2
  241. package/lib/cli/version/index.js +5 -31
  242. package/lib/cli/version/index.js.map +1 -1
  243. package/lib/config/prettier.d.ts +7 -0
  244. package/lib/index.js +4 -49
  245. package/lib/index.js.map +2 -2
  246. package/lib/skuba.js +26 -44
  247. package/lib/skuba.js.map +3 -3
  248. package/lib/{cli → src/cli}/configure/analyseDependencies.d.ts +1 -1
  249. package/lib/{cli → src/cli}/configure/analysis/package.d.ts +2 -3
  250. package/lib/{cli → src/cli}/configure/ensureTemplateCompletion.d.ts +1 -1
  251. package/lib/{cli → src/cli}/configure/getEntryPoint.d.ts +1 -1
  252. package/lib/{cli → src/cli}/configure/getProjectType.d.ts +1 -1
  253. package/lib/src/cli/configure/processing/package.d.ts +5 -0
  254. package/lib/{cli → src/cli}/configure/types.d.ts +15 -4
  255. package/lib/{cli → src/cli}/init/getConfig.d.ts +1 -1
  256. package/lib/{cli → src/cli}/init/prompts.d.ts +4 -4
  257. package/lib/{cli → src/cli}/lint/internalLints/upgrade/index.d.ts +1 -1
  258. package/lib/{index.d.ts → src/index.d.ts} +0 -1
  259. package/lib/src/utils/fs.d.ts +1 -0
  260. package/lib/{utils → src/utils}/manifest.d.ts +3 -2
  261. package/lib/src/utils/sleep.d.ts +5 -0
  262. package/lib/{utils → src/utils}/wait.d.ts +0 -4
  263. package/lib/{wrapper → src/wrapper}/http.d.ts +0 -6
  264. package/lib/src/wrapper/server.d.ts +7 -0
  265. package/lib/utils/args.js +8 -50
  266. package/lib/utils/args.js.map +2 -2
  267. package/lib/utils/command.js +6 -50
  268. package/lib/utils/command.js.map +3 -3
  269. package/lib/utils/copy.js +22 -64
  270. package/lib/utils/copy.js.map +2 -2
  271. package/lib/utils/dir.js +37 -84
  272. package/lib/utils/dir.js.map +3 -3
  273. package/lib/utils/env.js +1 -27
  274. package/lib/utils/env.js.map +1 -1
  275. package/lib/utils/error.js +11 -53
  276. package/lib/utils/error.js.map +1 -1
  277. package/lib/utils/exec.js +26 -70
  278. package/lib/utils/exec.js.map +3 -3
  279. package/lib/utils/fs.js +15 -0
  280. package/lib/utils/fs.js.map +7 -0
  281. package/lib/utils/help.js +5 -31
  282. package/lib/utils/help.js.map +1 -1
  283. package/lib/utils/logging.js +13 -55
  284. package/lib/utils/logging.js.map +2 -2
  285. package/lib/utils/logo.js +23 -59
  286. package/lib/utils/logo.js.map +2 -2
  287. package/lib/utils/manifest.js +12 -60
  288. package/lib/utils/manifest.js.map +3 -3
  289. package/lib/utils/npmrc.js +1 -27
  290. package/lib/utils/npmrc.js.map +1 -1
  291. package/lib/utils/packageManager.js +14 -56
  292. package/lib/utils/packageManager.js.map +2 -2
  293. package/lib/utils/port.js +4 -42
  294. package/lib/utils/port.js.map +2 -2
  295. package/lib/utils/sleep.js +9 -0
  296. package/lib/utils/sleep.js.map +7 -0
  297. package/lib/utils/template.js +21 -68
  298. package/lib/utils/template.js.map +3 -3
  299. package/lib/utils/validation.js +6 -42
  300. package/lib/utils/validation.js.map +1 -1
  301. package/lib/utils/version.js +11 -53
  302. package/lib/utils/version.js.map +2 -2
  303. package/lib/utils/wait.js +6 -42
  304. package/lib/utils/wait.js.map +2 -2
  305. package/lib/utils/worker.js +9 -37
  306. package/lib/utils/worker.js.map +1 -1
  307. package/lib/wrapper/functionHandler.js +17 -50
  308. package/lib/wrapper/functionHandler.js.map +2 -2
  309. package/lib/wrapper/http.js +7 -53
  310. package/lib/wrapper/http.js.map +3 -3
  311. package/lib/wrapper/index.js +6 -6
  312. package/lib/wrapper/index.js.map +1 -1
  313. package/lib/wrapper/main.js +7 -43
  314. package/lib/wrapper/main.js.map +3 -3
  315. package/lib/wrapper/requestListener.js +12 -47
  316. package/lib/wrapper/requestListener.js.map +3 -3
  317. package/lib/wrapper/server.js +9 -0
  318. package/lib/wrapper/server.js.map +7 -0
  319. package/package.json +19 -24
  320. package/template/base/_.prettierrc.js +1 -1
  321. package/template/base/_eslint.config.js +1 -1
  322. package/template/base/_pnpm-workspace.yaml +3 -2
  323. package/template/base/vitest.config.ts +25 -0
  324. package/template/express-rest-api/.gantry/dev.yml +2 -2
  325. package/template/express-rest-api/.gantry/prod.yml +2 -2
  326. package/template/express-rest-api/package.json +6 -5
  327. package/template/express-rest-api/skuba.template.js +1 -1
  328. package/template/express-rest-api/src/app.test.ts +1 -0
  329. package/template/greeter/package.json +4 -3
  330. package/template/greeter/skuba.template.js +1 -1
  331. package/template/greeter/src/app.test.ts +3 -1
  332. package/template/koa-rest-api/.gantry/dev.yml +2 -2
  333. package/template/koa-rest-api/.gantry/prod.yml +2 -2
  334. package/template/koa-rest-api/package.json +6 -5
  335. package/template/koa-rest-api/skuba.template.js +1 -1
  336. package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +2 -0
  337. package/template/koa-rest-api/src/api/jobs/postJob.test.ts +2 -0
  338. package/template/koa-rest-api/src/app.test.ts +2 -0
  339. package/template/koa-rest-api/src/framework/server.test.ts +2 -2
  340. package/template/koa-rest-api/src/framework/validation.test.ts +2 -0
  341. package/template/koa-rest-api/src/testing/metrics.ts +2 -0
  342. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +15 -3
  343. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +11 -9
  344. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +1 -1
  345. package/template/lambda-sqs-worker-cdk/package.json +6 -5
  346. package/template/lambda-sqs-worker-cdk/skuba.template.js +1 -1
  347. package/template/lambda-sqs-worker-cdk/src/app.test.ts +22 -13
  348. package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +1 -0
  349. package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +33 -31
  350. package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +8 -2
  351. package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +3 -2
  352. package/template/lambda-sqs-worker-cdk/src/testing/services.ts +4 -3
  353. package/template/oss-npm-package/.github/workflows/release.yml +1 -1
  354. package/template/oss-npm-package/.github/workflows/validate.yml +1 -1
  355. package/template/oss-npm-package/_package.json +1 -0
  356. package/template/oss-npm-package/skuba.template.js +1 -1
  357. package/template/oss-npm-package/src/index.test.ts +2 -0
  358. package/template/private-npm-package/_package.json +1 -0
  359. package/template/private-npm-package/skuba.template.js +1 -1
  360. package/template/private-npm-package/src/index.test.ts +2 -0
  361. package/config/jest.js +0 -1
  362. package/config/prettier.d.ts +0 -4
  363. package/jest/moduleNameMapper.js +0 -64
  364. package/jest/transform.js +0 -62
  365. package/jest/tsConfig.js +0 -26
  366. package/jest-preset.js +0 -37
  367. package/lib/api/jest/index.d.ts +0 -15
  368. package/lib/api/jest/index.js +0 -59
  369. package/lib/api/jest/index.js.map +0 -7
  370. package/lib/cli/configure/modules/jest.d.ts +0 -2
  371. package/lib/cli/configure/modules/jest.js +0 -86
  372. package/lib/cli/configure/modules/jest.js.map +0 -7
  373. package/lib/cli/configure/processing/package.d.ts +0 -71
  374. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.d.ts +0 -2
  375. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +0 -144
  376. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +0 -7
  377. package/lib/cli/test/reporters/github/annotations.d.ts +0 -9
  378. package/lib/cli/test/reporters/github/annotations.js +0 -102
  379. package/lib/cli/test/reporters/github/annotations.js.map +0 -7
  380. package/lib/cli/test/reporters/github/index.d.ts +0 -5
  381. package/lib/cli/test/reporters/github/index.js +0 -74
  382. package/lib/cli/test/reporters/github/index.js.map +0 -7
  383. package/template/base/jest.config.ts +0 -19
  384. package/template/base/jest.setup.ts +0 -3
  385. /package/lib/{cli → src/cli}/adapter/eslint.d.ts +0 -0
  386. /package/lib/{cli → src/cli}/adapter/prettier.d.ts +0 -0
  387. /package/lib/{cli → src/cli}/build/args.d.ts +0 -0
  388. /package/lib/{cli → src/cli}/build/assets.d.ts +0 -0
  389. /package/lib/{cli → src/cli}/build/esbuild.d.ts +0 -0
  390. /package/lib/{cli → src/cli}/build/index.d.ts +0 -0
  391. /package/lib/{cli → src/cli}/build/tsc.d.ts +0 -0
  392. /package/lib/{cli → src/cli}/buildPackage/index.d.ts +0 -0
  393. /package/lib/{cli → src/cli}/configure/analyseConfiguration.d.ts +0 -0
  394. /package/lib/{cli → src/cli}/configure/analysis/diff.d.ts +0 -0
  395. /package/lib/{cli → src/cli}/configure/analysis/files.d.ts +0 -0
  396. /package/lib/{cli → src/cli}/configure/analysis/git.d.ts +0 -0
  397. /package/lib/{cli → src/cli}/configure/analysis/project.d.ts +0 -0
  398. /package/lib/{cli → src/cli}/configure/dependencies/index.d.ts +0 -0
  399. /package/lib/{cli → src/cli}/configure/dependencies/seekDatadogCustomMetrics.d.ts +0 -0
  400. /package/lib/{cli → src/cli}/configure/dependencies/seekKoala.d.ts +0 -0
  401. /package/lib/{cli → src/cli}/configure/dependencies/skuba.d.ts +0 -0
  402. /package/lib/{cli → src/cli}/configure/dependencies/skubaDeps.d.ts +0 -0
  403. /package/lib/{cli → src/cli}/configure/dependencies/skubaDive.d.ts +0 -0
  404. /package/lib/{cli → src/cli}/configure/index.d.ts +0 -0
  405. /package/lib/{cli → src/cli}/configure/modules/eslint.d.ts +0 -0
  406. /package/lib/{cli → src/cli}/configure/modules/ignore.d.ts +0 -0
  407. /package/lib/{cli → src/cli}/configure/modules/index.d.ts +0 -0
  408. /package/lib/{cli → src/cli}/configure/modules/nodemon.d.ts +0 -0
  409. /package/lib/{cli → src/cli}/configure/modules/package.d.ts +0 -0
  410. /package/lib/{cli → src/cli}/configure/modules/prettier.d.ts +0 -0
  411. /package/lib/{cli → src/cli}/configure/modules/renovate.d.ts +0 -0
  412. /package/lib/{cli → src/cli}/configure/modules/serverless.d.ts +0 -0
  413. /package/lib/{cli → src/cli}/configure/modules/tslint.d.ts +0 -0
  414. /package/lib/{cli → src/cli}/configure/processing/configFile.d.ts +0 -0
  415. /package/lib/{cli → src/cli}/configure/processing/deleteFiles.d.ts +0 -0
  416. /package/lib/{cli → src/cli}/configure/processing/javascript.d.ts +0 -0
  417. /package/lib/{cli → src/cli}/configure/processing/json.d.ts +0 -0
  418. /package/lib/{cli → src/cli}/configure/processing/loadFiles.d.ts +0 -0
  419. /package/lib/{cli → src/cli}/configure/processing/module.d.ts +0 -0
  420. /package/lib/{cli → src/cli}/configure/processing/prettier.d.ts +0 -0
  421. /package/lib/{cli → src/cli}/configure/processing/record.d.ts +0 -0
  422. /package/lib/{cli → src/cli}/configure/processing/typescript.d.ts +0 -0
  423. /package/lib/{cli → src/cli}/format/index.d.ts +0 -0
  424. /package/lib/{cli → src/cli}/help/index.d.ts +0 -0
  425. /package/lib/{cli → src/cli}/init/git.d.ts +0 -0
  426. /package/lib/{cli → src/cli}/init/index.d.ts +0 -0
  427. /package/lib/{cli → src/cli}/init/types.d.ts +0 -0
  428. /package/lib/{cli → src/cli}/init/validation.d.ts +0 -0
  429. /package/lib/{cli → src/cli}/init/writePackageJson.d.ts +0 -0
  430. /package/lib/{cli → src/cli}/lint/annotate/buildkite/eslint.d.ts +0 -0
  431. /package/lib/{cli → src/cli}/lint/annotate/buildkite/index.d.ts +0 -0
  432. /package/lib/{cli → src/cli}/lint/annotate/buildkite/internal.d.ts +0 -0
  433. /package/lib/{cli → src/cli}/lint/annotate/buildkite/prettier.d.ts +0 -0
  434. /package/lib/{cli → src/cli}/lint/annotate/buildkite/tsc.d.ts +0 -0
  435. /package/lib/{cli → src/cli}/lint/annotate/github/eslint.d.ts +0 -0
  436. /package/lib/{cli → src/cli}/lint/annotate/github/index.d.ts +0 -0
  437. /package/lib/{cli → src/cli}/lint/annotate/github/internal.d.ts +0 -0
  438. /package/lib/{cli → src/cli}/lint/annotate/github/prettier.d.ts +0 -0
  439. /package/lib/{cli → src/cli}/lint/annotate/github/tsc.d.ts +0 -0
  440. /package/lib/{cli → src/cli}/lint/annotate/index.d.ts +0 -0
  441. /package/lib/{cli → src/cli}/lint/autofix.d.ts +0 -0
  442. /package/lib/{cli → src/cli}/lint/eslint.d.ts +0 -0
  443. /package/lib/{cli → src/cli}/lint/external.d.ts +0 -0
  444. /package/lib/{cli → src/cli}/lint/index.d.ts +0 -0
  445. /package/lib/{cli → src/cli}/lint/internal.d.ts +0 -0
  446. /package/lib/{cli → src/cli}/lint/internalLints/detectBadCodeowners.d.ts +0 -0
  447. /package/lib/{cli → src/cli}/lint/internalLints/noSkubaTemplateJs.d.ts +0 -0
  448. /package/lib/{cli → src/cli}/lint/internalLints/patchRenovateConfig.d.ts +0 -0
  449. /package/lib/{cli → src/cli}/lint/internalLints/refreshConfigFiles.d.ts +0 -0
  450. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/10.0.4/index.d.ts +0 -0
  451. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.d.ts +0 -0
  452. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/10.1.0/index.d.ts +0 -0
  453. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.d.ts +0 -0
  454. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.d.ts +0 -0
  455. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.0.2/index.d.ts +0 -0
  456. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.d.ts +0 -0
  457. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.1.1/index.d.ts +0 -0
  458. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.d.ts +0 -0
  459. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.3.0/index.d.ts +0 -0
  460. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.d.ts +0 -0
  461. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.d.ts +0 -0
  462. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.0/index.d.ts +0 -0
  463. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.d.ts +0 -0
  464. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.d.ts +0 -0
  465. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.1/index.d.ts +0 -0
  466. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.d.ts +0 -0
  467. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.d.ts +0 -0
  468. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.d.ts +0 -0
  469. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.d.ts +0 -0
  470. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/7.3.1/index.d.ts +0 -0
  471. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.d.ts +0 -0
  472. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.d.ts +0 -0
  473. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.0.0/index.d.ts +0 -0
  474. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.d.ts +0 -0
  475. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.d.ts +0 -0
  476. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.2.1/index.d.ts +0 -0
  477. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.d.ts +0 -0
  478. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.d.ts +0 -0
  479. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.d.ts +0 -0
  480. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/9.0.1/index.d.ts +0 -0
  481. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.d.ts +0 -0
  482. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/9.1.0/index.d.ts +0 -0
  483. /package/lib/{cli → src/cli}/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.d.ts +0 -0
  484. /package/lib/{cli → src/cli}/lint/prettier.d.ts +0 -0
  485. /package/lib/{cli → src/cli}/lint/tsc.d.ts +0 -0
  486. /package/lib/{cli → src/cli}/lint/types.d.ts +0 -0
  487. /package/lib/{cli → src/cli}/migrate/index.d.ts +0 -0
  488. /package/lib/{cli → src/cli}/migrate/nodeVersion/checks.d.ts +0 -0
  489. /package/lib/{cli → src/cli}/migrate/nodeVersion/index.d.ts +0 -0
  490. /package/lib/{cli → src/cli}/node/index.d.ts +0 -0
  491. /package/lib/{cli → src/cli}/release/index.d.ts +0 -0
  492. /package/lib/{cli → src/cli}/start/index.d.ts +0 -0
  493. /package/lib/{cli → src/cli}/test/index.d.ts +0 -0
  494. /package/lib/{cli → src/cli}/version/index.d.ts +0 -0
  495. /package/lib/{skuba.d.ts → src/skuba.d.ts} +0 -0
  496. /package/lib/{utils → src/utils}/args.d.ts +0 -0
  497. /package/lib/{utils → src/utils}/command.d.ts +0 -0
  498. /package/lib/{utils → src/utils}/copy.d.ts +0 -0
  499. /package/lib/{utils → src/utils}/dir.d.ts +0 -0
  500. /package/lib/{utils → src/utils}/env.d.ts +0 -0
  501. /package/lib/{utils → src/utils}/error.d.ts +0 -0
  502. /package/lib/{utils → src/utils}/exec.d.ts +0 -0
  503. /package/lib/{utils → src/utils}/help.d.ts +0 -0
  504. /package/lib/{utils → src/utils}/logging.d.ts +0 -0
  505. /package/lib/{utils → src/utils}/logo.d.ts +0 -0
  506. /package/lib/{utils → src/utils}/npmrc.d.ts +0 -0
  507. /package/lib/{utils → src/utils}/packageManager.d.ts +0 -0
  508. /package/lib/{utils → src/utils}/port.d.ts +0 -0
  509. /package/lib/{utils → src/utils}/template.d.ts +0 -0
  510. /package/lib/{utils → src/utils}/validation.d.ts +0 -0
  511. /package/lib/{utils → src/utils}/version.d.ts +0 -0
  512. /package/lib/{utils → src/utils}/worker.d.ts +0 -0
  513. /package/lib/{wrapper → src/wrapper}/functionHandler.d.ts +0 -0
  514. /package/lib/{wrapper → src/wrapper}/index.d.ts +0 -0
  515. /package/lib/{wrapper → src/wrapper}/main.d.ts +0 -0
  516. /package/lib/{wrapper → src/wrapper}/requestListener.d.ts +0 -0
@@ -1,64 +1,31 @@
1
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 migrateNpmrcToPnpmWorkspace_exports = {};
30
- __export(migrateNpmrcToPnpmWorkspace_exports, {
31
- tryMigrateNpmrcToPnpmWorkspace: () => tryMigrateNpmrcToPnpmWorkspace
32
- });
33
- module.exports = __toCommonJS(migrateNpmrcToPnpmWorkspace_exports);
34
- var import_util = require("util");
35
- var import_fast_glob = require("fast-glob");
36
- var import_fs_extra = __toESM(require("fs-extra"));
37
- var import_dir = require("../../../../../../utils/dir.js");
38
- var import_logging = require("../../../../../../utils/logging.js");
39
- var import_npmrc = require("../../../../../../utils/npmrc.js");
40
- var import_configFile = require("../../../../../configure/processing/configFile.js");
2
+ import { inspect } from "util";
3
+ import { glob } from "fast-glob";
4
+ import fs from "fs-extra";
5
+ import {
6
+ findCurrentWorkspaceProjectRoot,
7
+ findWorkspaceRoot
8
+ } from "../../../../../../utils/dir.js";
9
+ import { pathExists } from "../../../../../../utils/fs.js";
10
+ import { log } from "../../../../../../utils/logging.js";
11
+ import { hasNpmrcSecret } from "../../../../../../utils/npmrc.js";
12
+ import { replaceManagedSection } from "../../../../../configure/processing/configFile.js";
41
13
  const NPMRC = ".npmrc";
42
- const checkFileExists = async (filePath) => {
43
- try {
44
- await import_fs_extra.default.access(filePath);
45
- return true;
46
- } catch {
47
- return false;
48
- }
49
- };
50
14
  const migrateCustomNpmrcSettings = async () => {
51
- const contents = await import_fs_extra.default.readFile(NPMRC, "utf-8");
52
- const remainderLines = (0, import_configFile.replaceManagedSection)(contents, "").split("\n").map((line) => line.trim()).filter((line) => line.length > 0).filter((line) => !line.startsWith("#")).filter((line) => !(0, import_npmrc.hasNpmrcSecret)(line));
15
+ const contents = await fs.promises.readFile(NPMRC, "utf-8");
16
+ const remainderLines = replaceManagedSection(contents, "").split("\n").map((line) => line.trim()).filter((line) => line.length > 0).filter((line) => !line.startsWith("#")).filter((line) => !hasNpmrcSecret(line));
53
17
  if (remainderLines.length === 0) {
54
18
  return;
55
19
  }
56
20
  const pnpmWorkspaceFile = "pnpm-workspace.yaml";
57
- const pnpmWorkspaceExists = await checkFileExists(pnpmWorkspaceFile);
21
+ const pnpmWorkspaceExists = await pathExists(pnpmWorkspaceFile);
58
22
  if (!pnpmWorkspaceExists) {
59
- await import_fs_extra.default.writeFile(pnpmWorkspaceFile, "");
23
+ await fs.promises.writeFile(pnpmWorkspaceFile, "");
60
24
  }
61
- const pnpmWorkspaceContents = await import_fs_extra.default.readFile(pnpmWorkspaceFile, "utf-8");
25
+ const pnpmWorkspaceContents = await fs.promises.readFile(
26
+ pnpmWorkspaceFile,
27
+ "utf-8"
28
+ );
62
29
  const commentedLines = remainderLines.map((line) => `# ${line}`).join("\n");
63
30
  const newContents = `# TODO: Translate these settings to the required format for pnpm-workspace.yaml.
64
31
  # skuba moved these from .npmrc, but doesn't know what they mean.
@@ -67,43 +34,43 @@ const migrateCustomNpmrcSettings = async () => {
67
34
  ${commentedLines}
68
35
 
69
36
  ${pnpmWorkspaceContents}`;
70
- await import_fs_extra.default.writeFile(pnpmWorkspaceFile, newContents);
37
+ await fs.promises.writeFile(pnpmWorkspaceFile, newContents);
71
38
  };
72
39
  const fixDockerfiles = async () => {
73
- const fileNames = await (0, import_fast_glob.glob)(["**/Dockerfile*"]);
40
+ const fileNames = await glob(["**/Dockerfile*"]);
74
41
  await Promise.all(
75
42
  fileNames.map(async (fileName) => {
76
- const contents = await import_fs_extra.default.readFile(fileName, "utf8");
43
+ const contents = await fs.promises.readFile(fileName, "utf8");
77
44
  const patched = contents.replaceAll(
78
45
  "--mount=type=bind,source=.npmrc,target=.npmrc",
79
46
  "--mount=type=bind,source=pnpm-workspace.yaml,target=pnpm-workspace.yaml"
80
47
  );
81
48
  if (patched !== contents) {
82
- await import_fs_extra.default.writeFile(fileName, patched);
49
+ await fs.promises.writeFile(fileName, patched);
83
50
  }
84
51
  })
85
52
  );
86
53
  };
87
54
  const fixBuildkitePipelines = async () => {
88
- const fileNames = await (0, import_fast_glob.glob)(["**/.buildkite/**.{yml,yaml}"]);
55
+ const fileNames = await glob(["**/.buildkite/**.{yml,yaml}"]);
89
56
  await Promise.all(
90
57
  fileNames.map(async (fileName) => {
91
- const contents = await import_fs_extra.default.readFile(fileName, "utf8");
58
+ const contents = await fs.promises.readFile(fileName, "utf8");
92
59
  const patched = contents.replace(
93
60
  /(cache-on:[\s\S]*?)([ \t]+-[ \t]+\.npmrc)([\s\S]*?)(?=\n[ \t]*\S|$)/g,
94
61
  (_, before, npmrcLine, after) => before + npmrcLine.replace(".npmrc", "pnpm-workspace.yaml") + after
95
62
  );
96
63
  if (patched !== contents) {
97
- await import_fs_extra.default.writeFile(fileName, patched);
64
+ await fs.promises.writeFile(fileName, patched);
98
65
  }
99
66
  })
100
67
  );
101
68
  };
102
69
  const forceUpgradeToPnpm10 = async () => {
103
- const fileNames = await (0, import_fast_glob.glob)(["**/package.json"]);
70
+ const fileNames = await glob(["**/package.json"]);
104
71
  await Promise.all(
105
72
  fileNames.map(async (fileName) => {
106
- const contents = await import_fs_extra.default.readFile(fileName, "utf8");
73
+ const contents = await fs.promises.readFile(fileName, "utf8");
107
74
  const packageManagerMatch = /"packageManager"\s*:\s*"pnpm@([^"]+)"/.exec(
108
75
  contents
109
76
  );
@@ -117,7 +84,7 @@ const forceUpgradeToPnpm10 = async () => {
117
84
  /"packageManager"(\s*):(\s*)"pnpm@[^"]+"/,
118
85
  '"packageManager"$1:$2"pnpm@10.8.1"'
119
86
  );
120
- await import_fs_extra.default.writeFile(fileName, patched);
87
+ await fs.promises.writeFile(fileName, patched);
121
88
  }
122
89
  })
123
90
  );
@@ -133,8 +100,8 @@ const migrateNpmrcToPnpmWorkspace = async ({
133
100
  };
134
101
  }
135
102
  const [workspaceRoot, currentWorkspaceProjectRoot] = await Promise.all([
136
- (0, import_dir.findWorkspaceRoot)(),
137
- (0, import_dir.findCurrentWorkspaceProjectRoot)()
103
+ findWorkspaceRoot(),
104
+ findCurrentWorkspaceProjectRoot()
138
105
  ]);
139
106
  if (workspaceRoot !== currentWorkspaceProjectRoot) {
140
107
  return {
@@ -142,7 +109,7 @@ const migrateNpmrcToPnpmWorkspace = async ({
142
109
  reason: "not running in the workspace root"
143
110
  };
144
111
  }
145
- const npmrcExists = await checkFileExists(NPMRC);
112
+ const npmrcExists = await pathExists(NPMRC);
146
113
  if (!npmrcExists) {
147
114
  return {
148
115
  result: "skip",
@@ -160,20 +127,16 @@ const migrateNpmrcToPnpmWorkspace = async ({
160
127
  fixBuildkitePipelines(),
161
128
  forceUpgradeToPnpm10()
162
129
  ]);
163
- await import_fs_extra.default.rm(NPMRC);
130
+ await fs.promises.rm(NPMRC);
164
131
  return { result: "apply" };
165
132
  };
166
- const tryMigrateNpmrcToPnpmWorkspace = async (config) => {
133
+ export const tryMigrateNpmrcToPnpmWorkspace = async (config) => {
167
134
  try {
168
135
  return await migrateNpmrcToPnpmWorkspace(config);
169
136
  } catch (err) {
170
- import_logging.log.warn("Failed to migrate .npmrc to pnpm-workspace.yaml");
171
- import_logging.log.subtle((0, import_util.inspect)(err));
137
+ log.warn("Failed to migrate .npmrc to pnpm-workspace.yaml");
138
+ log.subtle(inspect(err));
172
139
  return { result: "skip", reason: "due to an error" };
173
140
  }
174
141
  };
175
- // Annotate the CommonJS export names for ESM import in node:
176
- 0 && (module.exports = {
177
- tryMigrateNpmrcToPnpmWorkspace
178
- });
179
142
  //# sourceMappingURL=migrateNpmrcToPnpmWorkspace.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.ts"],
4
- "sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport {\n findCurrentWorkspaceProjectRoot,\n findWorkspaceRoot,\n} from '../../../../../../utils/dir.js';\nimport { log } from '../../../../../../utils/logging.js';\nimport { hasNpmrcSecret } from '../../../../../../utils/npmrc.js';\nimport { replaceManagedSection } from '../../../../../configure/processing/configFile.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst NPMRC = '.npmrc';\n\nconst checkFileExists = async (filePath: string) => {\n try {\n await fs.access(filePath);\n return true;\n } catch {\n return false;\n }\n};\n\nconst migrateCustomNpmrcSettings = async () => {\n const contents = await fs.readFile(NPMRC, 'utf-8');\n\n const remainderLines = replaceManagedSection(contents, '')\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0)\n .filter((line) => !line.startsWith('#'))\n .filter((line) => !hasNpmrcSecret(line));\n\n if (remainderLines.length === 0) {\n return;\n }\n\n const pnpmWorkspaceFile = 'pnpm-workspace.yaml';\n const pnpmWorkspaceExists = await checkFileExists(pnpmWorkspaceFile);\n if (!pnpmWorkspaceExists) {\n await fs.writeFile(pnpmWorkspaceFile, '');\n }\n\n // prepend the lines to the pnpm-workspace.yaml file, but commented out\n const pnpmWorkspaceContents = await fs.readFile(pnpmWorkspaceFile, 'utf-8');\n const commentedLines = remainderLines.map((line) => `# ${line}`).join('\\n');\n const newContents = `# TODO: Translate these settings to the required format for pnpm-workspace.yaml.\n# skuba moved these from .npmrc, but doesn't know what they mean.\n# See: https://pnpm.io/settings\n#\n${commentedLines}\n\n${pnpmWorkspaceContents}`;\n\n await fs.writeFile(pnpmWorkspaceFile, newContents);\n};\n\nconst fixDockerfiles = async () => {\n const fileNames = await glob(['**/Dockerfile*']);\n\n await Promise.all(\n fileNames.map(async (fileName) => {\n const contents = await fs.readFile(fileName, 'utf8');\n const patched = contents.replaceAll(\n '--mount=type=bind,source=.npmrc,target=.npmrc',\n '--mount=type=bind,source=pnpm-workspace.yaml,target=pnpm-workspace.yaml',\n );\n\n if (patched !== contents) {\n await fs.writeFile(fileName, patched);\n }\n }),\n );\n};\n\nconst fixBuildkitePipelines = async () => {\n const fileNames = await glob(['**/.buildkite/**.{yml,yaml}']);\n\n await Promise.all(\n fileNames.map(async (fileName) => {\n const contents = await fs.readFile(fileName, 'utf8');\n const patched = contents.replace(\n /(cache-on:[\\s\\S]*?)([ \\t]+-[ \\t]+\\.npmrc)([\\s\\S]*?)(?=\\n[ \\t]*\\S|$)/g,\n (_, before: string, npmrcLine: string, after: string) =>\n before + npmrcLine.replace('.npmrc', 'pnpm-workspace.yaml') + after,\n );\n\n if (patched !== contents) {\n await fs.writeFile(fileName, patched);\n }\n }),\n );\n};\n\nconst forceUpgradeToPnpm10 = async () => {\n const fileNames = await glob(['**/package.json']);\n\n await Promise.all(\n fileNames.map(async (fileName) => {\n const contents = await fs.readFile(fileName, 'utf8');\n\n const packageManagerMatch = /\"packageManager\"\\s*:\\s*\"pnpm@([^\"]+)\"/.exec(\n contents,\n );\n\n if (!packageManagerMatch) {\n return;\n }\n\n const currentVersion = packageManagerMatch[1] ?? '';\n const majorVersion = parseInt(currentVersion.split('.')?.[0] ?? '0', 10);\n\n if (!isNaN(majorVersion) && majorVersion < 10) {\n const patched = contents.replace(\n /\"packageManager\"(\\s*):(\\s*)\"pnpm@[^\"]+\"/,\n '\"packageManager\"$1:$2\"pnpm@10.8.1\"',\n );\n\n await fs.writeFile(fileName, patched);\n }\n }),\n );\n};\n\nconst migrateNpmrcToPnpmWorkspace: PatchFunction = async ({\n mode,\n packageManager,\n}): Promise<PatchReturnType> => {\n if (packageManager.command !== 'pnpm') {\n return {\n result: 'skip',\n reason: 'not using pnpm',\n };\n }\n\n const [workspaceRoot, currentWorkspaceProjectRoot] = await Promise.all([\n findWorkspaceRoot(),\n findCurrentWorkspaceProjectRoot(),\n ]);\n\n if (workspaceRoot !== currentWorkspaceProjectRoot) {\n return {\n result: 'skip',\n reason: 'not running in the workspace root',\n };\n }\n\n const npmrcExists = await checkFileExists(NPMRC);\n if (!npmrcExists) {\n return {\n result: 'skip',\n reason: 'no .npmrc found',\n };\n }\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all([\n migrateCustomNpmrcSettings(),\n fixDockerfiles(),\n fixBuildkitePipelines(),\n forceUpgradeToPnpm10(),\n ]);\n\n await fs.rm(NPMRC);\n\n return { result: 'apply' };\n};\n\nexport const tryMigrateNpmrcToPnpmWorkspace: PatchFunction = async (config) => {\n try {\n return await migrateNpmrcToPnpmWorkspace(config);\n } catch (err) {\n log.warn('Failed to migrate .npmrc to pnpm-workspace.yaml');\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,uBAAqB;AACrB,sBAAe;AAEf,iBAGO;AACP,qBAAoB;AACpB,mBAA+B;AAC/B,wBAAsC;AAGtC,MAAM,QAAQ;AAEd,MAAM,kBAAkB,OAAO,aAAqB;AAClD,MAAI;AACF,UAAM,gBAAAA,QAAG,OAAO,QAAQ;AACxB,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,MAAM,6BAA6B,YAAY;AAC7C,QAAM,WAAW,MAAM,gBAAAA,QAAG,SAAS,OAAO,OAAO;AAEjD,QAAM,qBAAiB,yCAAsB,UAAU,EAAE,EACtD,MAAM,IAAI,EACV,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,EAChC,OAAO,CAAC,SAAS,CAAC,KAAK,WAAW,GAAG,CAAC,EACtC,OAAO,CAAC,SAAS,KAAC,6BAAe,IAAI,CAAC;AAEzC,MAAI,eAAe,WAAW,GAAG;AAC/B;AAAA,EACF;AAEA,QAAM,oBAAoB;AAC1B,QAAM,sBAAsB,MAAM,gBAAgB,iBAAiB;AACnE,MAAI,CAAC,qBAAqB;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,QAAG,GAAG,KAAK;AAEjB,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,iCAAgD,OAAO,WAAW;AAC7E,MAAI;AACF,WAAO,MAAM,4BAA4B,MAAM;AAAA,EACjD,SAAS,KAAK;AACZ,uBAAI,KAAK,iDAAiD;AAC1D,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
- "names": ["fs"]
4
+ "sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport {\n findCurrentWorkspaceProjectRoot,\n findWorkspaceRoot,\n} from '../../../../../../utils/dir.js';\nimport { pathExists } from '../../../../../../utils/fs.js';\nimport { log } from '../../../../../../utils/logging.js';\nimport { hasNpmrcSecret } from '../../../../../../utils/npmrc.js';\nimport { replaceManagedSection } from '../../../../../configure/processing/configFile.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst NPMRC = '.npmrc';\n\nconst migrateCustomNpmrcSettings = async () => {\n const contents = await fs.promises.readFile(NPMRC, 'utf-8');\n\n const remainderLines = replaceManagedSection(contents, '')\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0)\n .filter((line) => !line.startsWith('#'))\n .filter((line) => !hasNpmrcSecret(line));\n\n if (remainderLines.length === 0) {\n return;\n }\n\n const pnpmWorkspaceFile = 'pnpm-workspace.yaml';\n const pnpmWorkspaceExists = await pathExists(pnpmWorkspaceFile);\n if (!pnpmWorkspaceExists) {\n await fs.promises.writeFile(pnpmWorkspaceFile, '');\n }\n\n // prepend the lines to the pnpm-workspace.yaml file, but commented out\n const pnpmWorkspaceContents = await fs.promises.readFile(\n pnpmWorkspaceFile,\n 'utf-8',\n );\n const commentedLines = remainderLines.map((line) => `# ${line}`).join('\\n');\n const newContents = `# TODO: Translate these settings to the required format for pnpm-workspace.yaml.\n# skuba moved these from .npmrc, but doesn't know what they mean.\n# See: https://pnpm.io/settings\n#\n${commentedLines}\n\n${pnpmWorkspaceContents}`;\n\n await fs.promises.writeFile(pnpmWorkspaceFile, newContents);\n};\n\nconst fixDockerfiles = async () => {\n const fileNames = await glob(['**/Dockerfile*']);\n\n await Promise.all(\n fileNames.map(async (fileName) => {\n const contents = await fs.promises.readFile(fileName, 'utf8');\n const patched = contents.replaceAll(\n '--mount=type=bind,source=.npmrc,target=.npmrc',\n '--mount=type=bind,source=pnpm-workspace.yaml,target=pnpm-workspace.yaml',\n );\n\n if (patched !== contents) {\n await fs.promises.writeFile(fileName, patched);\n }\n }),\n );\n};\n\nconst fixBuildkitePipelines = async () => {\n const fileNames = await glob(['**/.buildkite/**.{yml,yaml}']);\n\n await Promise.all(\n fileNames.map(async (fileName) => {\n const contents = await fs.promises.readFile(fileName, 'utf8');\n const patched = contents.replace(\n /(cache-on:[\\s\\S]*?)([ \\t]+-[ \\t]+\\.npmrc)([\\s\\S]*?)(?=\\n[ \\t]*\\S|$)/g,\n (_, before: string, npmrcLine: string, after: string) =>\n before + npmrcLine.replace('.npmrc', 'pnpm-workspace.yaml') + after,\n );\n\n if (patched !== contents) {\n await fs.promises.writeFile(fileName, patched);\n }\n }),\n );\n};\n\nconst forceUpgradeToPnpm10 = async () => {\n const fileNames = await glob(['**/package.json']);\n\n await Promise.all(\n fileNames.map(async (fileName) => {\n const contents = await fs.promises.readFile(fileName, 'utf8');\n\n const packageManagerMatch = /\"packageManager\"\\s*:\\s*\"pnpm@([^\"]+)\"/.exec(\n contents,\n );\n\n if (!packageManagerMatch) {\n return;\n }\n\n const currentVersion = packageManagerMatch[1] ?? '';\n const majorVersion = parseInt(currentVersion.split('.')?.[0] ?? '0', 10);\n\n if (!isNaN(majorVersion) && majorVersion < 10) {\n const patched = contents.replace(\n /\"packageManager\"(\\s*):(\\s*)\"pnpm@[^\"]+\"/,\n '\"packageManager\"$1:$2\"pnpm@10.8.1\"',\n );\n\n await fs.promises.writeFile(fileName, patched);\n }\n }),\n );\n};\n\nconst migrateNpmrcToPnpmWorkspace: PatchFunction = async ({\n mode,\n packageManager,\n}): Promise<PatchReturnType> => {\n if (packageManager.command !== 'pnpm') {\n return {\n result: 'skip',\n reason: 'not using pnpm',\n };\n }\n\n const [workspaceRoot, currentWorkspaceProjectRoot] = await Promise.all([\n findWorkspaceRoot(),\n findCurrentWorkspaceProjectRoot(),\n ]);\n\n if (workspaceRoot !== currentWorkspaceProjectRoot) {\n return {\n result: 'skip',\n reason: 'not running in the workspace root',\n };\n }\n\n const npmrcExists = await pathExists(NPMRC);\n if (!npmrcExists) {\n return {\n result: 'skip',\n reason: 'no .npmrc found',\n };\n }\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all([\n migrateCustomNpmrcSettings(),\n fixDockerfiles(),\n fixBuildkitePipelines(),\n forceUpgradeToPnpm10(),\n ]);\n\n await fs.promises.rm(NPMRC);\n\n return { result: 'apply' };\n};\n\nexport const tryMigrateNpmrcToPnpmWorkspace: PatchFunction = async (config) => {\n try {\n return await migrateNpmrcToPnpmWorkspace(config);\n } catch (err) {\n log.warn('Failed to migrate .npmrc to pnpm-workspace.yaml');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
5
+ "mappings": ";AAAA,SAAS,eAAe;AAExB,SAAS,YAAY;AACrB,OAAO,QAAQ;AAEf;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,WAAW;AACpB,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AAGtC,MAAM,QAAQ;AAEd,MAAM,6BAA6B,YAAY;AAC7C,QAAM,WAAW,MAAM,GAAG,SAAS,SAAS,OAAO,OAAO;AAE1D,QAAM,iBAAiB,sBAAsB,UAAU,EAAE,EACtD,MAAM,IAAI,EACV,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,EAChC,OAAO,C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;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO;AAAA,MACL,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,QAAQ,IAAI;AAAA,IAChB,2BAA2B;AAAA,IAC3B,eAAe;AAAA,IACf,sBAAsB;AAAA,IACtB,qBAAqB;AAAA,EACvB,CAAC;AAED,QAAM,GAAG,SAAS,GAAG,KAAK;AAE1B,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,aAAM,iCAAgD,OAAO,WAAW;AAC7E,MAAI;AACF,WAAO,MAAM,4BAA4B,MAAM;AAAA,EACjD,SAAS,KAAK;AACZ,QAAI,KAAK,iDAAiD;AAC1D,QAAI,OAAO,QAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": []
7
7
  }
@@ -1,51 +1,18 @@
1
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 stopBundlingInCDKTests_exports = {};
30
- __export(stopBundlingInCDKTests_exports, {
31
- hasAppImportRegex: () => hasAppImportRegex,
32
- tryStopBundlingInCDKTests: () => tryStopBundlingInCDKTests
33
- });
34
- module.exports = __toCommonJS(stopBundlingInCDKTests_exports);
35
- var import_util = require("util");
36
- var import_fast_glob = require("fast-glob");
37
- var import_fs_extra = __toESM(require("fs-extra"));
38
- var import_logging = require("../../../../../../utils/logging.js");
2
+ import { inspect } from "util";
3
+ import { glob } from "fast-glob";
4
+ import fs from "fs-extra";
5
+ import { log } from "../../../../../../utils/logging.js";
39
6
  const fetchFiles = async (files) => Promise.all(
40
7
  files.map(async (file) => {
41
- const contents = await import_fs_extra.default.promises.readFile(file, "utf8");
8
+ const contents = await fs.promises.readFile(file, "utf8");
42
9
  return {
43
10
  file,
44
11
  contents
45
12
  };
46
13
  })
47
14
  );
48
- const hasAppImportRegex = /import\s*\{\s*(?:[^}]*,\s*)?App\s*(?:,\s*[^}]*)?\s*\}\s*from\s*['"]aws-cdk-lib['"]/gm;
15
+ export const hasAppImportRegex = /import\s*\{\s*(?:[^}]*,\s*)?App\s*(?:,\s*[^}]*)?\s*\}\s*from\s*['"]aws-cdk-lib['"]/gm;
49
16
  const addBundlingContext = (contents) => {
50
17
  if (contents.includes("new App()") && hasAppImportRegex.test(contents)) {
51
18
  return contents.replaceAll(
@@ -58,7 +25,7 @@ const addBundlingContext = (contents) => {
58
25
  const stopBundlingInCDKTests = async ({
59
26
  mode
60
27
  }) => {
61
- const infraTestFileNames = await (0, import_fast_glob.glob)(["**/infra/**/*.test.ts"]);
28
+ const infraTestFileNames = await glob(["**/infra/**/*.test.ts"]);
62
29
  if (!infraTestFileNames.length) {
63
30
  return {
64
31
  result: "skip",
@@ -84,23 +51,18 @@ const stopBundlingInCDKTests = async ({
84
51
  }
85
52
  await Promise.all(
86
53
  mapped.map(async ({ file, after }) => {
87
- await import_fs_extra.default.promises.writeFile(file, after);
54
+ await fs.promises.writeFile(file, after);
88
55
  })
89
56
  );
90
57
  return { result: "apply" };
91
58
  };
92
- const tryStopBundlingInCDKTests = async (config) => {
59
+ export const tryStopBundlingInCDKTests = async (config) => {
93
60
  try {
94
61
  return await stopBundlingInCDKTests(config);
95
62
  } catch (err) {
96
- import_logging.log.warn("Failed to remove bundling in CDK tests");
97
- import_logging.log.subtle((0, import_util.inspect)(err));
63
+ log.warn("Failed to remove bundling in CDK tests");
64
+ log.subtle(inspect(err));
98
65
  return { result: "skip", reason: "due to an error" };
99
66
  }
100
67
  };
101
- // Annotate the CommonJS export names for ESM import in node:
102
- 0 && (module.exports = {
103
- hasAppImportRegex,
104
- tryStopBundlingInCDKTests
105
- });
106
68
  //# sourceMappingURL=stopBundlingInCDKTests.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.ts"],
4
4
  "sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst fetchFiles = async (files: string[]) =>\n Promise.all(\n files.map(async (file) => {\n const contents = await fs.promises.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\nexport const hasAppImportRegex =\n /import\\s*\\{\\s*(?:[^}]*,\\s*)?App\\s*(?:,\\s*[^}]*)?\\s*\\}\\s*from\\s*['\"]aws-cdk-lib['\"]/gm;\n\nconst addBundlingContext = (contents: string) => {\n if (contents.includes('new App()') && hasAppImportRegex.test(contents)) {\n return contents.replaceAll(\n 'new App()',\n \"new App({ context: { 'aws:cdk:bundling-stacks': [] } })\",\n );\n }\n\n return contents;\n};\n\nconst stopBundlingInCDKTests: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n const infraTestFileNames = await glob(['**/infra/**/*.test.ts']);\n\n if (!infraTestFileNames.length) {\n return {\n result: 'skip',\n reason: 'no CDK test files found',\n };\n }\n\n const infraTestFiles = await fetchFiles(infraTestFileNames);\n\n const mapped = infraTestFiles.map(({ file, contents }) => ({\n file,\n before: contents,\n after: addBundlingContext(contents),\n }));\n\n if (!mapped.some(({ before, after }) => before !== after)) {\n return {\n result: 'skip',\n reason: 'no CDK test files need patching',\n };\n }\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all(\n mapped.map(async ({ file, after }) => {\n await fs.promises.writeFile(file, after);\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const tryStopBundlingInCDKTests: PatchFunction = async (config) => {\n try {\n return await stopBundlingInCDKTests(config);\n } catch (err) {\n log.warn('Failed to remove bundling in CDK tests');\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;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,qBAAoB;AAGpB,MAAM,aAAa,OAAO,UACxB,QAAQ;AAAA,EACN,MAAM,IAAI,OAAO,SAAS;AACxB,UAAM,WAAW,MAAM,gBAAAA,QAAG,SAAS,SAAS,MAAM,MAAM;AAExD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEK,MAAM,oBACX;AAEF,MAAM,qBAAqB,CAAC,aAAqB;AAC/C,MAAI,SAAS,SAAS,WAAW,KAAK,kBAAkB,KAAK,QAAQ,GAAG;AACtE,WAAO,SAAS;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEA,MAAM,yBAAwC,OAAO;AAAA,EACnD;AACF,MAAgC;AAC9B,QAAM,qBAAqB,U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Q,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": []
7
7
  }
@@ -1,35 +1,9 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var __exports = {};
20
- __export(__exports, {
21
- patches: () => patches
22
- });
23
- module.exports = __toCommonJS(__exports);
24
- var import_unhandledRejections = require("./unhandledRejections.js");
25
- const patches = [
2
+ import { tryPatchUnhandledRejections } from "./unhandledRejections.js";
3
+ export const patches = [
26
4
  {
27
- apply: import_unhandledRejections.tryPatchUnhandledRejections,
5
+ apply: tryPatchUnhandledRejections,
28
6
  description: "Add event handler to log unhandled promise rejections instead of crashing the process"
29
7
  }
30
8
  ];
31
- // Annotate the CommonJS export names for ESM import in node:
32
- 0 && (module.exports = {
33
- patches
34
- });
35
9
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.0.2/index.ts"],
4
4
  "sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { tryPatchUnhandledRejections } from './unhandledRejections.js';\n\nexport const patches: Patches = [\n {\n apply: tryPatchUnhandledRejections,\n description:\n 'Add event handler to log unhandled promise rejections instead of crashing the process',\n },\n];\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iCAA4C;AAErC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AACF;",
5
+ "mappings": ";AAEA,SAAS,mCAAmC;AAErC,aAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,45 +1,11 @@
1
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 unhandledRejections_exports = {};
30
- __export(unhandledRejections_exports, {
31
- IMPORT_REGEX: () => IMPORT_REGEX,
32
- NAMED_EXPORT_REGEX: () => NAMED_EXPORT_REGEX,
33
- tryPatchUnhandledRejections: () => tryPatchUnhandledRejections
34
- });
35
- module.exports = __toCommonJS(unhandledRejections_exports);
36
- var import_path = __toESM(require("path"));
37
- var import_util = require("util");
38
- var import_fast_glob = require("fast-glob");
39
- var import_fs_extra = __toESM(require("fs-extra"));
40
- var import_error = require("../../../../../../utils/error.js");
41
- var import_logging = require("../../../../../../utils/logging.js");
42
- var import_prettier = require("../../../../../configure/processing/prettier.js");
2
+ import path from "path";
3
+ import { inspect } from "util";
4
+ import { glob } from "fast-glob";
5
+ import fs from "fs-extra";
6
+ import { isErrorWithCode } from "../../../../../../utils/error.js";
7
+ import { log } from "../../../../../../utils/logging.js";
8
+ import { formatPrettier } from "../../../../../configure/processing/prettier.js";
43
9
  const addListener = (identifier) => `
44
10
  // Report unhandled rejections instead of crashing the process
45
11
  // Make sure to monitor these reports and alert as appropriate
@@ -50,10 +16,10 @@ process.on('unhandledRejection', (err) =>
50
16
  const tryReadFilesSequentially = async (filepaths) => {
51
17
  for (const filepath of filepaths) {
52
18
  try {
53
- const contents = await import_fs_extra.default.promises.readFile(filepath, "utf8");
19
+ const contents = await fs.promises.readFile(filepath, "utf8");
54
20
  return { contents, filepath };
55
21
  } catch (err) {
56
- if ((0, import_error.isErrorWithCode)(err, "ENOENT")) {
22
+ if (isErrorWithCode(err, "ENOENT")) {
57
23
  continue;
58
24
  }
59
25
  throw err;
@@ -61,8 +27,8 @@ const tryReadFilesSequentially = async (filepaths) => {
61
27
  }
62
28
  return;
63
29
  };
64
- const IMPORT_REGEX = /import\s+(?:\{\s*(\w*[Ll]ogger)(?:\s+as\s+(\w*[Ll]ogger))?\s*\}|(\w*[Ll]ogger))\s+from\s+['"][^'"]+\/(?:logger|logging)(?:\/index)?(?:\.[jt]s)?['"]/u;
65
- const NAMED_EXPORT_REGEX = /export\s+(?:const\s+|\{[^{}]*)\b(\w*[Ll]ogger)\b/u;
30
+ export const IMPORT_REGEX = /import\s+(?:\{\s*(\w*[Ll]ogger)(?:\s+as\s+(\w*[Ll]ogger))?\s*\}|(\w*[Ll]ogger))\s+from\s+['"][^'"]+\/(?:logger|logging)(?:\/index)?(?:\.[jt]s)?['"]/u;
31
+ export const NAMED_EXPORT_REGEX = /export\s+(?:const\s+|\{[^{}]*)\b(\w*[Ll]ogger)\b/u;
66
32
  const findLogger = async ({
67
33
  contents,
68
34
  root
@@ -74,7 +40,7 @@ const findLogger = async ({
74
40
  return { identifier };
75
41
  }
76
42
  }
77
- const loggerPaths = await (0, import_fast_glob.glob)("**/{logger,logging}.ts", {
43
+ const loggerPaths = await glob("**/{logger,logging}.ts", {
78
44
  cwd: root,
79
45
  ignore: ["**/.git", "**/node_modules"]
80
46
  });
@@ -82,8 +48,8 @@ const findLogger = async ({
82
48
  if (!loggingModule) {
83
49
  return { identifier: "console" };
84
50
  }
85
- const parsedPath = import_path.default.parse(import_path.default.relative(root, loggingModule.filepath));
86
- const importPath = import_path.default.join(parsedPath.dir, parsedPath.name);
51
+ const parsedPath = path.parse(path.relative(root, loggingModule.filepath));
52
+ const importPath = path.join(parsedPath.dir, parsedPath.name);
87
53
  const namedExportResult = NAMED_EXPORT_REGEX.exec(loggingModule.contents);
88
54
  if (namedExportResult?.[1]) {
89
55
  const identifier = namedExportResult[1];
@@ -101,22 +67,22 @@ const findLogger = async ({
101
67
  return { identifier: "console" };
102
68
  };
103
69
  const patchUnhandledRejections = async (mode) => {
104
- const filepaths = await (0, import_fast_glob.glob)("**/src/listen.ts", {
70
+ const filepaths = await glob("**/src/listen.ts", {
105
71
  ignore: ["**/.git", "**/node_modules"]
106
72
  });
107
73
  let hasPatched = false;
108
74
  for (const filepath of filepaths) {
109
- const contents = await import_fs_extra.default.promises.readFile(filepath, "utf8");
75
+ const contents = await fs.promises.readFile(filepath, "utf8");
110
76
  if (contents.includes("unhandledRejection")) {
111
- import_logging.log.subtle(
77
+ log.subtle(
112
78
  "Skipping entry point that appears to have an unhandled rejection listener:",
113
79
  filepath
114
80
  );
115
81
  continue;
116
82
  }
117
- const root = import_path.default.dirname(import_path.default.dirname(filepath));
83
+ const root = path.dirname(path.dirname(filepath));
118
84
  const logger = await findLogger({ contents, root });
119
- import_logging.log.subtle(
85
+ log.subtle(
120
86
  "Logging unhandled rejections to",
121
87
  logger.identifier,
122
88
  "in file:",
@@ -127,11 +93,11 @@ const patchUnhandledRejections = async (mode) => {
127
93
  ...[logger.import ? [logger.import] : []],
128
94
  addListener(logger.identifier)
129
95
  ].join("\n\n");
130
- const newContents = await (0, import_prettier.formatPrettier)(patched, { parser: "typescript" });
96
+ const newContents = await formatPrettier(patched, { parser: "typescript" });
131
97
  if (mode === "lint") {
132
98
  return { result: "apply" };
133
99
  }
134
- await import_fs_extra.default.promises.writeFile(filepath, newContents);
100
+ await fs.promises.writeFile(filepath, newContents);
135
101
  hasPatched = true;
136
102
  }
137
103
  if (hasPatched) {
@@ -142,21 +108,15 @@ const patchUnhandledRejections = async (mode) => {
142
108
  reason: "no applicable src/listen.ts entry points found"
143
109
  };
144
110
  };
145
- const tryPatchUnhandledRejections = async ({
111
+ export const tryPatchUnhandledRejections = async ({
146
112
  mode
147
113
  }) => {
148
114
  try {
149
115
  return await patchUnhandledRejections(mode);
150
116
  } catch (err) {
151
- import_logging.log.warn("Failed to patch listeners for unhandled promise rejections");
152
- import_logging.log.subtle((0, import_util.inspect)(err));
117
+ log.warn("Failed to patch listeners for unhandled promise rejections");
118
+ log.subtle(inspect(err));
153
119
  return { result: "skip", reason: "due to an error" };
154
120
  }
155
121
  };
156
- // Annotate the CommonJS export names for ESM import in node:
157
- 0 && (module.exports = {
158
- IMPORT_REGEX,
159
- NAMED_EXPORT_REGEX,
160
- tryPatchUnhandledRejections
161
- });
162
122
  //# sourceMappingURL=unhandledRejections.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.ts"],
4
4
  "sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { isErrorWithCode } from '../../../../../../utils/error.js';\nimport { log } from '../../../../../../utils/logging.js';\nimport { formatPrettier } from '../../../../../configure/processing/prettier.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst addListener = (identifier: string) =>\n `\n// Report unhandled rejections instead of crashing the process\n// Make sure to monitor these reports and alert as appropriate\nprocess.on('unhandledRejection', (err) =>\n ${identifier}.error(err, 'Unhandled promise rejection'),\n);\n`.trim();\n\nconst tryReadFilesSequentially = async (\n filepaths: string[],\n): Promise<{ contents: string; filepath: string } | undefined> => {\n for (const filepath of filepaths) {\n try {\n const contents = await fs.promises.readFile(filepath, 'utf8');\n\n return { contents, filepath };\n } catch (err) {\n if (isErrorWithCode(err, 'ENOENT')) {\n continue;\n }\n\n throw err;\n }\n }\n\n return;\n};\n\nexport const IMPORT_REGEX =\n /import\\s+(?:\\{\\s*(\\w*[Ll]ogger)(?:\\s+as\\s+(\\w*[Ll]ogger))?\\s*\\}|(\\w*[Ll]ogger))\\s+from\\s+['\"][^'\"]+\\/(?:logger|logging)(?:\\/index)?(?:\\.[jt]s)?['\"]/u;\n\nexport const NAMED_EXPORT_REGEX =\n /export\\s+(?:const\\s+|\\{[^{}]*)\\b(\\w*[Ll]ogger)\\b/u;\n\nconst findLogger = async ({\n contents,\n root,\n}: {\n contents: string;\n root: string;\n}): Promise<{ identifier: string; import?: string }> => {\n const importResult = IMPORT_REGEX.exec(contents);\n\n {\n const identifier =\n importResult?.[3] ?? importResult?.[2] ?? importResult?.[1];\n\n if (identifier) {\n return { identifier };\n }\n }\n\n const loggerPaths = await glob('**/{logger,logging}.ts', {\n cwd: root,\n ignore: ['**/.git', '**/node_modules'],\n });\n\n const loggingModule = await tryReadFilesSequentially(loggerPaths);\n\n if (!loggingModule) {\n return { identifier: 'console' };\n }\n\n const parsedPath = path.parse(path.relative(root, loggingModule.filepath));\n\n const importPath = path.join(parsedPath.dir, parsedPath.name);\n\n const namedExportResult = NAMED_EXPORT_REGEX.exec(loggingModule.contents);\n\n if (namedExportResult?.[1]) {\n const identifier = namedExportResult[1];\n\n return {\n identifier: namedExportResult[1],\n import: `import { ${identifier} } from '${importPath}';`,\n };\n }\n\n if (loggingModule.contents.includes('export default')) {\n return {\n identifier: 'logger',\n import: `import logger from '${importPath}';`,\n };\n }\n\n return { identifier: 'console' };\n};\n\nconst patchUnhandledRejections = async (\n mode: 'format' | 'lint',\n): Promise<PatchReturnType> => {\n const filepaths = await glob('**/src/listen.ts', {\n ignore: ['**/.git', '**/node_modules'],\n });\n\n let hasPatched = false;\n\n for (const filepath of filepaths) {\n const contents = await fs.promises.readFile(filepath, 'utf8');\n\n if (contents.includes('unhandledRejection')) {\n log.subtle(\n 'Skipping entry point that appears to have an unhandled rejection listener:',\n filepath,\n );\n continue;\n }\n\n const root = path.dirname(path.dirname(filepath));\n\n const logger = await findLogger({ contents, root });\n\n log.subtle(\n 'Logging unhandled rejections to',\n logger.identifier,\n 'in file:',\n filepath,\n );\n\n const patched = [\n contents,\n\n ...[logger.import ? [logger.import] : []],\n\n addListener(logger.identifier),\n ].join('\\n\\n');\n\n const newContents = await formatPrettier(patched, { parser: 'typescript' });\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n await fs.promises.writeFile(filepath, newContents);\n\n hasPatched = true;\n }\n\n if (hasPatched) {\n return { result: 'apply' };\n }\n\n return {\n result: 'skip',\n reason: 'no applicable src/listen.ts entry points found',\n };\n};\n\nexport const tryPatchUnhandledRejections: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n try {\n return await patchUnhandledRejections(mode);\n } catch (err) {\n log.warn('Failed to patch listeners for unhandled promise rejections');\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;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,uBAAqB;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