skuba 14.0.0-esmify-skuba-20251105034821 → 14.0.0-hacky-hack-lang-json-20260108235938

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 (408) hide show
  1. package/config/eslint.js +1 -1
  2. package/config/jest.js +1 -0
  3. package/config/prettier.d.ts +4 -8
  4. package/config/prettier.js +2 -10
  5. package/jest/moduleNameMapper.js +64 -0
  6. package/jest/transform.js +62 -0
  7. package/jest/tsConfig.js +26 -0
  8. package/jest-preset.js +37 -0
  9. package/lib/api/jest/index.d.ts +15 -0
  10. package/lib/api/jest/index.js +59 -0
  11. package/lib/api/jest/index.js.map +7 -0
  12. package/lib/cli/adapter/eslint.js +45 -11
  13. package/lib/cli/adapter/eslint.js.map +3 -3
  14. package/lib/cli/adapter/prettier.js +67 -39
  15. package/lib/cli/adapter/prettier.js.map +2 -2
  16. package/lib/cli/build/args.js +42 -8
  17. package/lib/cli/build/args.js.map +2 -2
  18. package/lib/cli/build/assets.d.ts +3 -2
  19. package/lib/cli/build/assets.js +60 -28
  20. package/lib/cli/build/assets.js.map +3 -3
  21. package/lib/cli/build/esbuild.d.ts +4 -2
  22. package/lib/cli/build/esbuild.js +64 -23
  23. package/lib/cli/build/esbuild.js.map +2 -2
  24. package/lib/cli/build/index.js +53 -21
  25. package/lib/cli/build/index.js.map +2 -2
  26. package/lib/cli/build/tsc.js +60 -24
  27. package/lib/cli/build/tsc.js.map +3 -3
  28. package/lib/cli/buildPackage/index.js +32 -8
  29. package/lib/cli/buildPackage/index.js.map +1 -1
  30. package/lib/cli/configure/analyseConfiguration.js +50 -16
  31. package/lib/cli/configure/analyseConfiguration.js.map +2 -2
  32. package/lib/cli/configure/analyseDependencies.d.ts +1 -1
  33. package/lib/cli/configure/analyseDependencies.js +59 -25
  34. package/lib/cli/configure/analyseDependencies.js.map +3 -3
  35. package/lib/cli/configure/analysis/diff.js +29 -5
  36. package/lib/cli/configure/analysis/diff.js.map +2 -2
  37. package/lib/cli/configure/analysis/files.js +42 -8
  38. package/lib/cli/configure/analysis/files.js.map +2 -2
  39. package/lib/cli/configure/analysis/git.js +46 -12
  40. package/lib/cli/configure/analysis/git.js.map +2 -2
  41. package/lib/cli/configure/analysis/package.d.ts +3 -2
  42. package/lib/cli/configure/analysis/package.js +45 -10
  43. package/lib/cli/configure/analysis/package.js.map +3 -3
  44. package/lib/cli/configure/analysis/project.js +50 -18
  45. package/lib/cli/configure/analysis/project.js.map +2 -2
  46. package/lib/cli/configure/dependencies/index.js +35 -7
  47. package/lib/cli/configure/dependencies/index.js.map +1 -1
  48. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +28 -4
  49. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
  50. package/lib/cli/configure/dependencies/seekKoala.js +28 -4
  51. package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
  52. package/lib/cli/configure/dependencies/skuba.js +28 -4
  53. package/lib/cli/configure/dependencies/skuba.js.map +1 -1
  54. package/lib/cli/configure/dependencies/skubaDeps.js +26 -2
  55. package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
  56. package/lib/cli/configure/dependencies/skubaDive.js +29 -4
  57. package/lib/cli/configure/dependencies/skubaDive.js.map +1 -1
  58. package/lib/cli/configure/ensureTemplateCompletion.d.ts +1 -1
  59. package/lib/cli/configure/ensureTemplateCompletion.js +63 -32
  60. package/lib/cli/configure/ensureTemplateCompletion.js.map +3 -3
  61. package/lib/cli/configure/getEntryPoint.d.ts +2 -2
  62. package/lib/cli/configure/getEntryPoint.js +51 -19
  63. package/lib/cli/configure/getEntryPoint.js.map +3 -3
  64. package/lib/cli/configure/getProjectType.d.ts +1 -1
  65. package/lib/cli/configure/getProjectType.js +36 -17
  66. package/lib/cli/configure/getProjectType.js.map +2 -2
  67. package/lib/cli/configure/index.js +91 -56
  68. package/lib/cli/configure/index.js.map +3 -3
  69. package/lib/cli/configure/modules/eslint.js +34 -10
  70. package/lib/cli/configure/modules/eslint.js.map +1 -1
  71. package/lib/cli/configure/modules/ignore.js +32 -8
  72. package/lib/cli/configure/modules/ignore.js.map +1 -1
  73. package/lib/cli/configure/modules/index.js +44 -18
  74. package/lib/cli/configure/modules/index.js.map +2 -2
  75. package/lib/cli/configure/modules/jest.d.ts +2 -0
  76. package/lib/cli/configure/modules/jest.js +86 -0
  77. package/lib/cli/configure/modules/jest.js.map +7 -0
  78. package/lib/cli/configure/modules/nodemon.js +28 -4
  79. package/lib/cli/configure/modules/nodemon.js.map +1 -1
  80. package/lib/cli/configure/modules/package.js +34 -10
  81. package/lib/cli/configure/modules/package.js.map +1 -1
  82. package/lib/cli/configure/modules/prettier.js +35 -11
  83. package/lib/cli/configure/modules/prettier.js.map +1 -1
  84. package/lib/cli/configure/modules/renovate.js +40 -17
  85. package/lib/cli/configure/modules/renovate.js.map +2 -2
  86. package/lib/cli/configure/modules/serverless.js +26 -2
  87. package/lib/cli/configure/modules/serverless.js.map +1 -1
  88. package/lib/cli/configure/modules/tslint.js +28 -4
  89. package/lib/cli/configure/modules/tslint.js.map +1 -1
  90. package/lib/cli/configure/processing/configFile.js +39 -3
  91. package/lib/cli/configure/processing/configFile.js.map +1 -1
  92. package/lib/cli/configure/processing/deleteFiles.js +26 -2
  93. package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
  94. package/lib/cli/configure/processing/javascript.js +27 -2
  95. package/lib/cli/configure/processing/javascript.js.map +1 -1
  96. package/lib/cli/configure/processing/json.js +31 -6
  97. package/lib/cli/configure/processing/json.js.map +1 -1
  98. package/lib/cli/configure/processing/loadFiles.js +26 -2
  99. package/lib/cli/configure/processing/loadFiles.js.map +1 -1
  100. package/lib/cli/configure/processing/module.js +28 -4
  101. package/lib/cli/configure/processing/module.js.map +1 -1
  102. package/lib/cli/configure/processing/package.d.ts +67 -1
  103. package/lib/cli/configure/processing/package.js +45 -8
  104. package/lib/cli/configure/processing/package.js.map +3 -3
  105. package/lib/cli/configure/processing/prettier.js +38 -4
  106. package/lib/cli/configure/processing/prettier.js.map +2 -2
  107. package/lib/cli/configure/processing/record.js +41 -5
  108. package/lib/cli/configure/processing/record.js.map +2 -2
  109. package/lib/cli/configure/processing/typescript.js +63 -26
  110. package/lib/cli/configure/processing/typescript.js.map +2 -2
  111. package/lib/cli/configure/types.d.ts +4 -15
  112. package/lib/cli/configure/types.js +16 -0
  113. package/lib/cli/configure/types.js.map +3 -3
  114. package/lib/cli/format/index.js +44 -20
  115. package/lib/cli/format/index.js.map +2 -2
  116. package/lib/cli/help/index.js +30 -6
  117. package/lib/cli/help/index.js.map +1 -1
  118. package/lib/cli/init/getConfig.d.ts +2 -2
  119. package/lib/cli/init/getConfig.js +121 -102
  120. package/lib/cli/init/getConfig.js.map +3 -3
  121. package/lib/cli/init/git.js +51 -16
  122. package/lib/cli/init/git.js.map +2 -2
  123. package/lib/cli/init/index.js +98 -67
  124. package/lib/cli/init/index.js.map +2 -2
  125. package/lib/cli/init/prompts.d.ts +13 -10
  126. package/lib/cli/init/prompts.js +56 -35
  127. package/lib/cli/init/prompts.js.map +2 -2
  128. package/lib/cli/init/types.d.ts +1 -1
  129. package/lib/cli/init/types.js +41 -7
  130. package/lib/cli/init/types.js.map +1 -1
  131. package/lib/cli/init/validation.js +30 -2
  132. package/lib/cli/init/validation.js.map +1 -1
  133. package/lib/cli/init/writePackageJson.js +42 -8
  134. package/lib/cli/init/writePackageJson.js.map +2 -2
  135. package/lib/cli/lint/annotate/buildkite/eslint.js +37 -3
  136. package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
  137. package/lib/cli/lint/annotate/buildkite/index.js +45 -11
  138. package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
  139. package/lib/cli/lint/annotate/buildkite/internal.js +37 -3
  140. package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
  141. package/lib/cli/lint/annotate/buildkite/prettier.js +37 -3
  142. package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
  143. package/lib/cli/lint/annotate/buildkite/tsc.js +37 -3
  144. package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
  145. package/lib/cli/lint/annotate/github/eslint.js +26 -2
  146. package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
  147. package/lib/cli/lint/annotate/github/index.js +45 -11
  148. package/lib/cli/lint/annotate/github/index.js.map +1 -1
  149. package/lib/cli/lint/annotate/github/internal.js +26 -2
  150. package/lib/cli/lint/annotate/github/internal.js.map +1 -1
  151. package/lib/cli/lint/annotate/github/prettier.js +26 -2
  152. package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
  153. package/lib/cli/lint/annotate/github/tsc.js +28 -4
  154. package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
  155. package/lib/cli/lint/annotate/index.js +30 -6
  156. package/lib/cli/lint/annotate/index.js.map +1 -1
  157. package/lib/cli/lint/autofix.d.ts +5 -0
  158. package/lib/cli/lint/autofix.js +80 -40
  159. package/lib/cli/lint/autofix.js.map +2 -2
  160. package/lib/cli/lint/eslint.js +51 -16
  161. package/lib/cli/lint/eslint.js.map +3 -3
  162. package/lib/cli/lint/external.js +51 -19
  163. package/lib/cli/lint/external.js.map +2 -2
  164. package/lib/cli/lint/index.js +50 -28
  165. package/lib/cli/lint/index.js.map +2 -2
  166. package/lib/cli/lint/internal.js +44 -18
  167. package/lib/cli/lint/internal.js.map +2 -2
  168. package/lib/cli/lint/internalLints/detectBadCodeowners.js +33 -8
  169. package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
  170. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +46 -14
  171. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +3 -3
  172. package/lib/cli/lint/internalLints/patchRenovateConfig.js +55 -21
  173. package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
  174. package/lib/cli/lint/internalLints/refreshConfigFiles.js +64 -35
  175. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +3 -3
  176. package/lib/cli/lint/internalLints/upgrade/index.d.ts +2 -2
  177. package/lib/cli/lint/internalLints/upgrade/index.js +105 -41
  178. package/lib/cli/lint/internalLints/upgrade/index.js.map +3 -3
  179. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +28 -4
  180. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js.map +1 -1
  181. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js +45 -11
  182. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js.map +2 -2
  183. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +30 -6
  184. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +1 -1
  185. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js +65 -34
  186. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +2 -2
  187. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +46 -11
  188. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +2 -2
  189. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +28 -4
  190. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +1 -1
  191. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +59 -23
  192. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +2 -2
  193. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js +28 -4
  194. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +1 -1
  195. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +46 -11
  196. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +2 -2
  197. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +30 -6
  198. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js.map +1 -1
  199. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js +46 -11
  200. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +2 -2
  201. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +46 -11
  202. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +2 -2
  203. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js +28 -4
  204. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js.map +1 -1
  205. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js +46 -11
  206. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +2 -2
  207. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js +67 -29
  208. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js.map +2 -2
  209. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js +34 -10
  210. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js.map +1 -1
  211. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js +45 -11
  212. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js.map +2 -2
  213. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js +63 -17
  214. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js.map +2 -2
  215. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js +50 -15
  216. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +2 -2
  217. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/index.js +40 -0
  218. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/index.js.map +7 -0
  219. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.d.ts +3 -0
  220. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.js +149 -0
  221. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.js.map +7 -0
  222. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/upgradeNode.js +55 -0
  223. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/upgradeNode.js.map +7 -0
  224. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +51 -17
  225. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js.map +2 -2
  226. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js +34 -10
  227. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js.map +1 -1
  228. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js +44 -10
  229. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js.map +2 -2
  230. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js +46 -12
  231. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js.map +2 -2
  232. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js +28 -4
  233. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js.map +1 -1
  234. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js +49 -15
  235. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js.map +2 -2
  236. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +45 -11
  237. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +2 -2
  238. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +34 -10
  239. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +1 -1
  240. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js +45 -11
  241. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js.map +2 -2
  242. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js +45 -11
  243. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js.map +2 -2
  244. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js +47 -13
  245. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js.map +2 -2
  246. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js +28 -4
  247. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js.map +1 -1
  248. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js +45 -11
  249. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +2 -2
  250. package/lib/cli/lint/prettier.js +50 -15
  251. package/lib/cli/lint/prettier.js.map +3 -3
  252. package/lib/cli/lint/tsc.js +28 -4
  253. package/lib/cli/lint/tsc.js.map +1 -1
  254. package/lib/cli/lint/types.js +16 -0
  255. package/lib/cli/lint/types.js.map +3 -3
  256. package/lib/cli/migrate/index.d.ts +5 -0
  257. package/lib/cli/migrate/index.js +79 -15
  258. package/lib/cli/migrate/index.js.map +2 -2
  259. package/lib/cli/migrate/nodeVersion/checks.d.ts +1 -14
  260. package/lib/cli/migrate/nodeVersion/checks.js +51 -120
  261. package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
  262. package/lib/cli/migrate/nodeVersion/index.d.ts +8 -2
  263. package/lib/cli/migrate/nodeVersion/index.js +239 -65
  264. package/lib/cli/migrate/nodeVersion/index.js.map +3 -3
  265. package/lib/cli/migrate/nodeVersion/upgrade.d.ts +8 -0
  266. package/lib/cli/migrate/nodeVersion/upgrade.js +179 -0
  267. package/lib/cli/migrate/nodeVersion/upgrade.js.map +7 -0
  268. package/lib/cli/node/index.js +57 -20
  269. package/lib/cli/node/index.js.map +3 -3
  270. package/lib/cli/release/index.js +28 -4
  271. package/lib/cli/release/index.js.map +1 -1
  272. package/lib/cli/start/index.js +50 -16
  273. package/lib/cli/start/index.js.map +3 -3
  274. package/lib/cli/test/index.js +44 -4
  275. package/lib/cli/test/index.js.map +2 -2
  276. package/lib/cli/test/reporters/github/annotations.d.ts +9 -0
  277. package/lib/cli/test/reporters/github/annotations.js +102 -0
  278. package/lib/cli/test/reporters/github/annotations.js.map +7 -0
  279. package/lib/cli/test/reporters/github/index.d.ts +5 -0
  280. package/lib/cli/test/reporters/github/index.js +74 -0
  281. package/lib/cli/test/reporters/github/index.js.map +7 -0
  282. package/lib/cli/version/index.js +30 -6
  283. package/lib/cli/version/index.js.map +1 -1
  284. package/lib/index.d.ts +1 -0
  285. package/lib/index.js +46 -6
  286. package/lib/index.js.map +2 -2
  287. package/lib/skuba.js +45 -26
  288. package/lib/skuba.js.map +3 -3
  289. package/lib/utils/args.js +43 -6
  290. package/lib/utils/args.js.map +2 -2
  291. package/lib/utils/command.js +42 -4
  292. package/lib/utils/command.js.map +3 -3
  293. package/lib/utils/copy.js +57 -20
  294. package/lib/utils/copy.js.map +2 -2
  295. package/lib/utils/dir.js +72 -32
  296. package/lib/utils/dir.js.map +2 -2
  297. package/lib/utils/env.js +26 -2
  298. package/lib/utils/env.js.map +1 -1
  299. package/lib/utils/error.js +47 -10
  300. package/lib/utils/error.js.map +1 -1
  301. package/lib/utils/exec.d.ts +3 -2
  302. package/lib/utils/exec.js +62 -24
  303. package/lib/utils/exec.js.map +3 -3
  304. package/lib/utils/fs.js +40 -6
  305. package/lib/utils/fs.js.map +2 -2
  306. package/lib/utils/help.js +30 -6
  307. package/lib/utils/help.js.map +1 -1
  308. package/lib/utils/logging.d.ts +9 -10
  309. package/lib/utils/logging.js +38 -11
  310. package/lib/utils/logging.js.map +2 -2
  311. package/lib/utils/logo.js +52 -25
  312. package/lib/utils/logo.js.map +2 -2
  313. package/lib/utils/manifest.d.ts +2 -3
  314. package/lib/utils/manifest.js +48 -8
  315. package/lib/utils/manifest.js.map +3 -3
  316. package/lib/utils/npmrc.js +26 -2
  317. package/lib/utils/npmrc.js.map +1 -1
  318. package/lib/utils/packageManager.js +49 -12
  319. package/lib/utils/packageManager.js.map +2 -2
  320. package/lib/utils/port.js +39 -4
  321. package/lib/utils/port.js.map +2 -2
  322. package/lib/utils/sleep.js +26 -2
  323. package/lib/utils/sleep.js.map +1 -1
  324. package/lib/utils/template.js +55 -18
  325. package/lib/utils/template.js.map +3 -3
  326. package/lib/utils/validation.js +31 -2
  327. package/lib/utils/validation.js.map +1 -1
  328. package/lib/utils/version.js +46 -9
  329. package/lib/utils/version.js.map +2 -2
  330. package/lib/utils/wait.js +32 -7
  331. package/lib/utils/wait.js.map +1 -1
  332. package/lib/utils/worker.d.ts +3 -3
  333. package/lib/utils/worker.js +35 -10
  334. package/lib/utils/worker.js.map +1 -1
  335. package/lib/wrapper/function-arguments.d.js +1 -0
  336. package/lib/wrapper/functionHandler.js +49 -18
  337. package/lib/wrapper/functionHandler.js.map +2 -2
  338. package/lib/wrapper/http.js +43 -8
  339. package/lib/wrapper/http.js.map +2 -2
  340. package/lib/wrapper/index.js +7 -6
  341. package/lib/wrapper/index.js.map +1 -1
  342. package/lib/wrapper/main.js +42 -8
  343. package/lib/wrapper/main.js.map +3 -3
  344. package/lib/wrapper/requestListener.js +47 -13
  345. package/lib/wrapper/requestListener.js.map +2 -2
  346. package/lib/wrapper/server.js +28 -4
  347. package/lib/wrapper/server.js.map +2 -2
  348. package/package.json +43 -45
  349. package/template/base/_.prettierrc.js +1 -1
  350. package/template/base/_eslint.config.js +1 -1
  351. package/template/base/_pnpm-workspace.yaml +4 -3
  352. package/template/base/jest.config.ts +19 -0
  353. package/template/base/jest.setup.ts +3 -0
  354. package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
  355. package/template/express-rest-api/.nvmrc +1 -1
  356. package/template/express-rest-api/package.json +8 -9
  357. package/template/express-rest-api/skuba.template.js +1 -1
  358. package/template/express-rest-api/src/app.test.ts +0 -1
  359. package/template/greeter/.buildkite/pipeline.yml +1 -1
  360. package/template/greeter/.nvmrc +1 -1
  361. package/template/greeter/package.json +4 -5
  362. package/template/greeter/skuba.template.js +1 -1
  363. package/template/greeter/src/app.test.ts +1 -3
  364. package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
  365. package/template/koa-rest-api/.nvmrc +1 -1
  366. package/template/koa-rest-api/package.json +9 -11
  367. package/template/koa-rest-api/skuba.template.js +1 -1
  368. package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +0 -2
  369. package/template/koa-rest-api/src/api/jobs/postJob.test.ts +0 -2
  370. package/template/koa-rest-api/src/app.test.ts +0 -2
  371. package/template/koa-rest-api/src/framework/server.test.ts +2 -2
  372. package/template/koa-rest-api/src/framework/validation.test.ts +0 -2
  373. package/template/koa-rest-api/src/testing/metrics.ts +0 -2
  374. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -2
  375. package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
  376. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +7 -21
  377. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +9 -11
  378. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +3 -3
  379. package/template/lambda-sqs-worker-cdk/infra/config.ts +2 -4
  380. package/template/lambda-sqs-worker-cdk/package.json +9 -9
  381. package/template/lambda-sqs-worker-cdk/skuba.template.js +13 -1
  382. package/template/lambda-sqs-worker-cdk/src/app.test.ts +13 -22
  383. package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +0 -1
  384. package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +31 -33
  385. package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +2 -8
  386. package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +2 -3
  387. package/template/lambda-sqs-worker-cdk/src/testing/services.ts +3 -4
  388. package/template/oss-npm-package/.github/workflows/release.yml +1 -1
  389. package/template/oss-npm-package/.github/workflows/validate.yml +1 -1
  390. package/template/oss-npm-package/.nvmrc +1 -1
  391. package/template/oss-npm-package/_package.json +0 -1
  392. package/template/oss-npm-package/skuba.template.js +1 -1
  393. package/template/oss-npm-package/src/index.test.ts +0 -2
  394. package/template/private-npm-package/.nvmrc +1 -1
  395. package/template/private-npm-package/_package.json +1 -2
  396. package/template/private-npm-package/skuba.template.js +2 -2
  397. package/template/private-npm-package/src/index.test.ts +0 -2
  398. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js +0 -11
  399. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js.map +0 -7
  400. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js +0 -34
  401. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +0 -7
  402. package/lib/enquirer.d.js +0 -1
  403. package/lib/enquirer.d.js.map +0 -7
  404. package/lib/eslint.d.js +0 -1
  405. package/lib/eslint.d.js.map +0 -7
  406. package/template/base/vitest.config.ts +0 -25
  407. /package/lib/cli/lint/internalLints/upgrade/patches/{9.1.0 → 13.1.1}/index.d.ts +0 -0
  408. /package/lib/cli/lint/internalLints/upgrade/patches/{9.1.0 → 13.1.1}/upgradeNode.d.ts +0 -0
@@ -1,88 +1,235 @@
1
- import { inspect } from "util";
2
- import { glob } from "fast-glob";
3
- import fs from "fs-extra";
4
- import { log } from "../../../utils/logging.js";
5
- import { createDestinationFileReader } from "../../configure/analysis/project.js";
6
- import {
7
- isPatchableNodeVersion,
8
- isPatchableServerlessVersion,
9
- isPatchableSkubaType
10
- } from "./checks.js";
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 nodeVersion_exports = {};
30
+ __export(nodeVersion_exports, {
31
+ nodeVersionMigration: () => nodeVersionMigration
32
+ });
33
+ module.exports = __toCommonJS(nodeVersion_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_semver = require("semver");
38
+ var import_logging = require("../../../utils/logging.js");
39
+ var import_project = require("../../configure/analysis/project.js");
40
+ var import_checks = require("./checks.js");
41
+ var import_upgrade = require("./upgrade.js");
11
42
  const subPatches = ({
12
43
  nodeVersion,
13
- ECMAScriptVersion
44
+ ECMAScriptVersion,
45
+ packageECMAScriptVersion,
46
+ packageNodeVersion
14
47
  }) => [
15
- { file: ".nvmrc", replace: `${nodeVersion}
16
- ` },
17
48
  {
49
+ type: "nodejs",
50
+ file: ".nvmrc",
51
+ regex: () => /.*([0-9.]+).*/gm,
52
+ replace: {
53
+ default: {
54
+ captureGroup: 1,
55
+ string: nodeVersion,
56
+ version: nodeVersion
57
+ }
58
+ }
59
+ },
60
+ {
61
+ type: "nodejs",
18
62
  files: "**/Dockerfile*",
19
63
  regex: () => /^FROM(.*) (public.ecr.aws\/docker\/library\/)?node:([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?)(-[a-z0-9]+)?(@sha256:[a-f0-9]{64})?( .*)?$/gm,
20
- replace: `FROM$1 $2node:${nodeVersion}$4$6`
64
+ replace: {
65
+ default: {
66
+ captureGroup: 3,
67
+ string: `FROM$1 $2node:${nodeVersion}$4$6`,
68
+ version: nodeVersion
69
+ }
70
+ }
21
71
  },
22
72
  {
73
+ type: "nodejs",
23
74
  files: "**/Dockerfile*",
24
- regex: () => /^FROM(.*) gcr.io\/distroless\/nodejs\d+-debian(\d+)(@sha256:[a-f0-9]{64})?(\.[^- \n]+)?(-[^ \n]+)?( .+|)$/gm,
25
- replace: `FROM$1 gcr.io/distroless/nodejs${nodeVersion}-debian$2$4$5$6`
75
+ regex: () => /^FROM(.*) gcr.io\/distroless\/nodejs(\d+)-debian(\d+)(@sha256:[a-f0-9]{64})?(\.[^- \n]+)?(-[^ \n]+)?( .+|)$/gm,
76
+ replace: {
77
+ default: {
78
+ captureGroup: 2,
79
+ string: `FROM$1 gcr.io/distroless/nodejs${nodeVersion}-debian$3$6$7`,
80
+ version: nodeVersion
81
+ }
82
+ }
26
83
  },
27
84
  {
85
+ type: "nodejs",
28
86
  files: "**/serverless*.y*ml",
29
- regex: () => /\bnodejs\d+.x\b/gm,
30
- tests: [isPatchableServerlessVersion],
31
- replace: `nodejs${nodeVersion}.x`
87
+ regex: () => /\bnodejs(\d+).x\b/gm,
88
+ replace: {
89
+ default: {
90
+ captureGroup: 1,
91
+ string: `nodejs${nodeVersion}.x`,
92
+ version: nodeVersion
93
+ }
94
+ }
32
95
  },
33
96
  {
97
+ type: "nodejs",
34
98
  files: "**/serverless*.y*ml",
35
- regex: () => /\bnode\d+\b/gm,
36
- tests: [isPatchableServerlessVersion],
37
- replace: `node${nodeVersion}`
99
+ regex: () => /\bnode(\d+)\b/gm,
100
+ replace: {
101
+ default: {
102
+ captureGroup: 1,
103
+ string: `node${nodeVersion}`,
104
+ version: nodeVersion
105
+ }
106
+ }
38
107
  },
39
108
  {
109
+ type: "nodejs",
40
110
  files: "**/infra/**/*.ts",
41
- regex: () => /NODEJS_\d+_X/g,
42
- replace: `NODEJS_${nodeVersion}_X`
111
+ regex: () => /NODEJS_(\d+)_X/g,
112
+ replace: {
113
+ default: {
114
+ captureGroup: 1,
115
+ string: `NODEJS_${nodeVersion}_X`,
116
+ version: nodeVersion
117
+ }
118
+ }
43
119
  },
44
120
  {
121
+ type: "nodejs",
45
122
  files: "**/infra/**/*.ts",
46
123
  regex: () => /(target:\s*'node)(\d+)(.+)$/gm,
47
- replace: `$1${nodeVersion}$3`
124
+ replace: {
125
+ default: {
126
+ captureGroup: 2,
127
+ string: `$1${nodeVersion}$3`,
128
+ version: nodeVersion
129
+ }
130
+ }
48
131
  },
49
132
  {
133
+ type: "nodejs",
50
134
  files: "**/.buildkite/*",
51
- regex: () => /(image: )(public.ecr.aws\/docker\/library\/)?(node:)[0-9.]+(\.[^- \n]+)?(-[^ \n]+)?$/gm,
52
- replace: `$1$2$3${nodeVersion}$5`
135
+ regex: () => /(image: )(public.ecr.aws\/docker\/library\/)?(node:)([0-9.]+)(\.[^- \n]+)?(-[^ \n]+)?$/gm,
136
+ replace: {
137
+ default: {
138
+ captureGroup: 4,
139
+ string: `$1$2$3${nodeVersion}$5$6`,
140
+ version: nodeVersion
141
+ }
142
+ }
53
143
  },
54
144
  {
145
+ type: "nodejs",
55
146
  files: ".node-version*",
56
147
  regex: () => /(\d+(?:\.\d+)*)/g,
57
- replace: `${nodeVersion}`
148
+ replace: {
149
+ default: {
150
+ captureGroup: 1,
151
+ string: `${nodeVersion}`,
152
+ version: nodeVersion
153
+ }
154
+ }
58
155
  },
59
156
  {
157
+ type: "nodejs",
60
158
  files: "**/package.json",
61
159
  regex: () => /(["']engines["']:\s*{[\s\S]*?["']node["']:\s*["']>=)(\d+(?:\.\d+)*)(['"]\s*})/gm,
62
- tests: [isPatchableServerlessVersion, isPatchableSkubaType],
63
- replace: `$1${nodeVersion}$3`
160
+ replace: {
161
+ package: {
162
+ string: `$1${packageNodeVersion}$3`,
163
+ version: packageNodeVersion,
164
+ captureGroup: 2
165
+ },
166
+ default: {
167
+ string: `$1${nodeVersion}$3`,
168
+ version: nodeVersion,
169
+ captureGroup: 2
170
+ }
171
+ }
64
172
  },
65
173
  {
174
+ type: "nodejs",
175
+ files: "**/docker-compose*.y*ml",
176
+ regex: () => /(image: )(public.ecr.aws\/docker\/library\/)?(node:)([0-9.]+)(\.[^- \n]+)?(-[^ \n]+)?$/gm,
177
+ replace: {
178
+ default: {
179
+ captureGroup: 4,
180
+ string: `$1$2$3${nodeVersion}$5$6`,
181
+ version: nodeVersion
182
+ }
183
+ }
184
+ },
185
+ {
186
+ type: "ecmascript",
66
187
  files: "**/tsconfig*.json",
67
188
  regex: () => /("target":\s*")(ES\d+)"/gim,
68
- tests: [isPatchableServerlessVersion, isPatchableSkubaType],
69
- replace: `$1${ECMAScriptVersion}"`
189
+ replace: {
190
+ package: {
191
+ string: `$1${packageECMAScriptVersion}"`,
192
+ version: packageECMAScriptVersion,
193
+ captureGroup: 2
194
+ },
195
+ default: {
196
+ string: `$1${ECMAScriptVersion}"`,
197
+ version: ECMAScriptVersion,
198
+ captureGroup: 2
199
+ }
200
+ }
70
201
  },
71
202
  {
203
+ type: "ecmascript",
72
204
  files: "**/tsconfig*.json",
73
205
  regex: () => /("lib":\s*\[)([\S\s]*?)(ES\d+)([\S\s]*?)(\])/gim,
74
- tests: [isPatchableServerlessVersion, isPatchableSkubaType],
75
- replace: `$1$2${ECMAScriptVersion}$4$5`
76
- },
77
- {
78
- files: "**/docker-compose*.y*ml",
79
- regex: () => /(image: )(public.ecr.aws\/docker\/library\/)?(node:)[0-9.]+(\.[^- \n]+)?(-[^ \n]+)?$/gm,
80
- replace: `$1$2$3${nodeVersion}$5`
206
+ replace: {
207
+ package: {
208
+ string: `$1$2${packageECMAScriptVersion}$4$5`,
209
+ version: packageECMAScriptVersion,
210
+ captureGroup: 3
211
+ },
212
+ default: {
213
+ string: `$1$2${ECMAScriptVersion}$4$5`,
214
+ version: ECMAScriptVersion,
215
+ captureGroup: 3
216
+ }
217
+ }
81
218
  }
82
219
  ];
220
+ const getTemplatedReplace = async (path, replace) => {
221
+ if (!replace.package) {
222
+ return replace.default;
223
+ }
224
+ const isPackage = await (0, import_checks.isLikelyPackage)(path);
225
+ if (isPackage) {
226
+ return replace.package;
227
+ }
228
+ return replace.default;
229
+ };
83
230
  const runSubPatch = async (dir, patch) => {
84
- const readFile = createDestinationFileReader(dir);
85
- const paths = patch.file ? [patch.file] : await glob(patch.files ?? [], {
231
+ const readFile = (0, import_project.createDestinationFileReader)(dir);
232
+ const paths = patch.file ? [patch.file] : await (0, import_fast_glob.glob)(patch.files ?? [], {
86
233
  cwd: dir,
87
234
  ignore: ["**/node_modules/**"]
88
235
  });
@@ -92,35 +239,48 @@ const runSubPatch = async (dir, patch) => {
92
239
  if (!contents) {
93
240
  return;
94
241
  }
95
- if (patch.regex && !patch.regex().test(contents)) {
242
+ const regexResult = patch.regex().exec(contents);
243
+ if (!regexResult) {
96
244
  return;
97
245
  }
98
- if (patch.tests) {
99
- const results = await Promise.all(
100
- patch.tests.map((test) => test(path))
101
- );
102
- if (!results.every(Boolean)) {
103
- return;
104
- }
246
+ const templateReplace = await getTemplatedReplace(path, patch.replace);
247
+ if (!lessThan(
248
+ regexResult[templateReplace.captureGroup],
249
+ templateReplace.version
250
+ )) {
251
+ return;
105
252
  }
106
253
  await writePatchedContents({
107
254
  path,
108
255
  contents,
109
- templated: patch.replace,
256
+ templated: templateReplace.string,
110
257
  regex: patch.regex
111
258
  });
112
259
  })
113
260
  );
114
261
  };
262
+ const lessThan = (versionA, versionB) => {
263
+ if (versionA.toLowerCase().startsWith("es")) {
264
+ return Number(versionA.slice(2)) < Number(versionB.slice(2));
265
+ }
266
+ const coersedA = (0, import_semver.coerce)(versionA);
267
+ const coersedB = (0, import_semver.coerce)(versionB);
268
+ if (!coersedA || !coersedB) {
269
+ throw new Error(
270
+ `Unable to coerce versions for comparison: "${versionA}" and "${versionB}"`
271
+ );
272
+ }
273
+ return (0, import_semver.lt)(coersedA, coersedB);
274
+ };
115
275
  const writePatchedContents = async ({
116
276
  path,
117
277
  contents,
118
278
  templated,
119
279
  regex
120
- }) => await fs.promises.writeFile(
121
- path,
122
- regex ? contents.replaceAll(regex(), templated) : templated
123
- );
280
+ }) => {
281
+ const modified = contents.replaceAll(regex(), templated);
282
+ await import_fs_extra.default.promises.writeFile(path, modified);
283
+ };
124
284
  const upgrade = async (versions, dir) => {
125
285
  for (const subPatch of subPatches(versions)) {
126
286
  await runSubPatch(dir, subPatch);
@@ -128,22 +288,36 @@ const upgrade = async (versions, dir) => {
128
288
  };
129
289
  const nodeVersionMigration = async ({
130
290
  nodeVersion,
131
- ECMAScriptVersion
291
+ ECMAScriptVersion,
292
+ packageNodeVersion,
293
+ packageECMAScriptVersion,
294
+ infraPackages
132
295
  }, dir = process.cwd()) => {
133
- log.ok(`Upgrading to Node.js ${nodeVersion}`);
296
+ import_logging.log.ok(
297
+ `Upgrading project to Node.js ${nodeVersion} and package targets to Node.js ${packageNodeVersion}`
298
+ );
134
299
  try {
135
- if (!await isPatchableNodeVersion(nodeVersion, dir)) {
136
- throw new Error("Node.js version is not patchable");
137
- }
138
- await upgrade({ nodeVersion, ECMAScriptVersion }, dir);
139
- log.ok("Upgraded to Node.js", nodeVersion);
300
+ await (0, import_upgrade.tryUpgradeInfraPackages)("format", infraPackages);
301
+ await upgrade(
302
+ {
303
+ nodeVersion,
304
+ ECMAScriptVersion,
305
+ packageNodeVersion,
306
+ packageECMAScriptVersion
307
+ },
308
+ dir
309
+ );
310
+ import_logging.log.ok(
311
+ `Upgraded project to Node.js ${nodeVersion} and package targets to Node.js ${packageNodeVersion}`
312
+ );
140
313
  } catch (error) {
141
- log.err("Failed to upgrade");
142
- log.subtle(inspect(error));
314
+ import_logging.log.err("Failed to upgrade");
315
+ import_logging.log.subtle((0, import_util.inspect)(error));
143
316
  process.exitCode = 1;
144
317
  }
145
318
  };
146
- export {
319
+ // Annotate the CommonJS export names for ESM import in node:
320
+ 0 && (module.exports = {
147
321
  nodeVersionMigration
148
- };
322
+ });
149
323
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/migrate/nodeVersion/index.ts"],
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 { createDestinationFileReader } from '../../configure/analysis/project.js';\n\nimport {\n isPatchableNodeVersion,\n isPatchableServerlessVersion,\n isPatchableSkubaType,\n} from './checks.js';\n\ntype FileSelector =\n | { files: string; file?: never }\n | { file: string; files?: never };\n\ntype SubPatch = FileSelector & {\n tests?: Array<(path: string) => Promise<boolean>>;\n regex?: () => RegExp;\n replace: string;\n};\n\nconst subPatches = ({\n nodeVersion,\n ECMAScriptVersion,\n}: Versions): SubPatch[] => [\n { file: '.nvmrc', replace: `${nodeVersion}\\n` },\n {\n files: '**/Dockerfile*',\n\n regex: () =>\n /^FROM(.*) (public.ecr.aws\\/docker\\/library\\/)?node:([0-9]+(?:\\.[0-9]+(?:\\.[0-9]+)?)?)(-[a-z0-9]+)?(@sha256:[a-f0-9]{64})?( .*)?$/gm,\n replace: `FROM$1 $2node:${nodeVersion}$4$6`,\n },\n {\n files: '**/Dockerfile*',\n regex: () =>\n /^FROM(.*) gcr.io\\/distroless\\/nodejs\\d+-debian(\\d+)(@sha256:[a-f0-9]{64})?(\\.[^- \\n]+)?(-[^ \\n]+)?( .+|)$/gm,\n replace: `FROM$1 gcr.io/distroless/nodejs${nodeVersion}-debian$2$4$5$6`,\n },\n\n {\n files: '**/serverless*.y*ml',\n regex: () => /\\bnodejs\\d+.x\\b/gm,\n tests: [isPatchableServerlessVersion],\n replace: `nodejs${nodeVersion}.x`,\n },\n {\n files: '**/serverless*.y*ml',\n regex: () => /\\bnode\\d+\\b/gm,\n tests: [isPatchableServerlessVersion],\n replace: `node${nodeVersion}`,\n },\n\n {\n files: '**/infra/**/*.ts',\n regex: () => /NODEJS_\\d+_X/g,\n replace: `NODEJS_${nodeVersion}_X`,\n },\n {\n files: '**/infra/**/*.ts',\n regex: () => /(target:\\s*'node)(\\d+)(.+)$/gm,\n replace: `$1${nodeVersion}$3`,\n },\n\n {\n files: '**/.buildkite/*',\n regex: () =>\n /(image: )(public.ecr.aws\\/docker\\/library\\/)?(node:)[0-9.]+(\\.[^- \\n]+)?(-[^ \\n]+)?$/gm,\n replace: `$1$2$3${nodeVersion}$5`,\n },\n {\n files: '.node-version*',\n regex: () => /(\\d+(?:\\.\\d+)*)/g,\n replace: `${nodeVersion}`,\n },\n\n {\n files: '**/package.json',\n regex: () =>\n /([\"']engines[\"']:\\s*{[\\s\\S]*?[\"']node[\"']:\\s*[\"']>=)(\\d+(?:\\.\\d+)*)(['\"]\\s*})/gm,\n tests: [isPatchableServerlessVersion, isPatchableSkubaType],\n replace: `$1${nodeVersion}$3`,\n },\n\n {\n files: '**/tsconfig*.json',\n regex: () => /(\"target\":\\s*\")(ES\\d+)\"/gim,\n tests: [isPatchableServerlessVersion, isPatchableSkubaType],\n replace: `$1${ECMAScriptVersion}\"`,\n },\n {\n files: '**/tsconfig*.json',\n regex: () => /(\"lib\":\\s*\\[)([\\S\\s]*?)(ES\\d+)([\\S\\s]*?)(\\])/gim,\n tests: [isPatchableServerlessVersion, isPatchableSkubaType],\n replace: `$1$2${ECMAScriptVersion}$4$5`,\n },\n\n {\n files: '**/docker-compose*.y*ml',\n regex: () =>\n /(image: )(public.ecr.aws\\/docker\\/library\\/)?(node:)[0-9.]+(\\.[^- \\n]+)?(-[^ \\n]+)?$/gm,\n\n replace: `$1$2$3${nodeVersion}$5`,\n },\n];\n\ntype Versions = {\n nodeVersion: number;\n ECMAScriptVersion: string;\n};\n\nconst runSubPatch = async (dir: string, patch: SubPatch) => {\n const readFile = createDestinationFileReader(dir);\n const paths = patch.file\n ? [patch.file]\n : await glob(patch.files ?? [], {\n cwd: dir,\n ignore: ['**/node_modules/**'],\n });\n\n await Promise.all(\n paths.map(async (path) => {\n const contents = await readFile(path);\n if (!contents) {\n return;\n }\n\n if (patch.regex && !patch.regex().test(contents)) {\n return;\n }\n\n if (patch.tests) {\n const results = await Promise.all(\n patch.tests.map((test) => test(path)),\n );\n if (!results.every(Boolean)) {\n return;\n }\n }\n\n await writePatchedContents({\n path,\n contents,\n templated: patch.replace,\n regex: patch.regex,\n });\n }),\n );\n};\n\nconst writePatchedContents = async ({\n path,\n contents,\n templated,\n regex,\n}: {\n path: string;\n contents: string;\n templated: string;\n regex?: () => RegExp;\n}) =>\n await fs.promises.writeFile(\n path,\n regex ? contents.replaceAll(regex(), templated) : templated,\n );\n\nconst upgrade = async (versions: Versions, dir: string) => {\n for (const subPatch of subPatches(versions)) {\n await runSubPatch(dir, subPatch);\n }\n};\n\nexport const nodeVersionMigration = async (\n {\n nodeVersion,\n ECMAScriptVersion,\n }: {\n nodeVersion: number;\n ECMAScriptVersion: string;\n },\n dir = process.cwd(),\n) => {\n log.ok(`Upgrading to Node.js ${nodeVersion}`);\n try {\n if (!(await isPatchableNodeVersion(nodeVersion, dir))) {\n throw new Error('Node.js version is not patchable');\n }\n\n await upgrade({ nodeVersion, ECMAScriptVersion }, dir);\n\n log.ok('Upgraded to Node.js', nodeVersion);\n } catch (error) {\n log.err('Failed to upgrade');\n log.subtle(inspect(error));\n process.exitCode = 1;\n }\n};\n"],
5
- "mappings": "AAAA,SAAS,eAAe;AAExB,SAAS,YAAY;AACrB,OAAO,QAAQ;AAEf,SAAS,WAAW;AACpB,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MAAM,UAAU,OAAO,UAAoB,QAAgB;AACzD,aAAW,YAAY,WAAW,QAAQ,GAAG;AAC3C,UAAM,YAAY,KAAK,QAAQ;AAAA,EACjC;AACF;AAEO,MAAM,uBAAuB,OAClC;AAAA,EACE;AAAA,EACA;AACF,GAIA,MAAM,QAAQ,IAAI,MACf;AACH,MAAI,GAAG,wBAAwB,WAAW,EAAE;AAC5C,MAAI;AACF,QAAI,CAAE,MAAM,uBAAuB,aAAa,GAAG,GAAI;AACrD,YAAM,IAAI,MAAM,kCAAkC;AAAA,IACpD;AAEA,UAAM,QAAQ,EAAE,aAAa,kBAAkB,GAAG,GAAG;AAErD,QAAI,GAAG,uBAAuB,WAAW;AAAA,EAC3C,SAAS,OAAO;AACd,QAAI,IAAI,mBAAmB;AAC3B,QAAI,OAAO,QAAQ,KAAK,CAAC;AACzB,YAAQ,WAAW;AAAA,EACrB;AACF;",
6
- "names": []
4
+ "sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\nimport { coerce, lt } from 'semver';\n\nimport { log } from '../../../utils/logging.js';\nimport { createDestinationFileReader } from '../../configure/analysis/project.js';\n\nimport { isLikelyPackage } from './checks.js';\nimport { tryUpgradeInfraPackages } from './upgrade.js';\n\ntype FileSelector =\n | { files: string; file?: never }\n | { file: string; files?: never };\n\ntype ReplaceOptions = {\n version: string;\n string: string;\n captureGroup: number;\n};\n\ntype SubPatch = FileSelector & {\n type: 'nodejs' | 'ecmascript';\n regex: () => RegExp;\n replace: {\n package?: ReplaceOptions;\n default: ReplaceOptions;\n };\n};\n\nconst subPatches = ({\n nodeVersion,\n ECMAScriptVersion,\n packageECMAScriptVersion,\n packageNodeVersion,\n}: Versions): SubPatch[] => [\n {\n type: 'nodejs',\n file: '.nvmrc',\n regex: () => /.*([0-9.]+).*/gm,\n replace: {\n default: {\n captureGroup: 1,\n string: nodeVersion,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'nodejs',\n files: '**/Dockerfile*',\n\n regex: () =>\n /^FROM(.*) (public.ecr.aws\\/docker\\/library\\/)?node:([0-9]+(?:\\.[0-9]+(?:\\.[0-9]+)?)?)(-[a-z0-9]+)?(@sha256:[a-f0-9]{64})?( .*)?$/gm,\n replace: {\n default: {\n captureGroup: 3,\n string: `FROM$1 $2node:${nodeVersion}$4$6`,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'nodejs',\n files: '**/Dockerfile*',\n regex: () =>\n /^FROM(.*) gcr.io\\/distroless\\/nodejs(\\d+)-debian(\\d+)(@sha256:[a-f0-9]{64})?(\\.[^- \\n]+)?(-[^ \\n]+)?( .+|)$/gm,\n replace: {\n default: {\n captureGroup: 2,\n string: `FROM$1 gcr.io/distroless/nodejs${nodeVersion}-debian$3$6$7`,\n version: nodeVersion,\n },\n },\n },\n\n {\n type: 'nodejs',\n files: '**/serverless*.y*ml',\n regex: () => /\\bnodejs(\\d+).x\\b/gm,\n replace: {\n default: {\n captureGroup: 1,\n string: `nodejs${nodeVersion}.x`,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'nodejs',\n files: '**/serverless*.y*ml',\n regex: () => /\\bnode(\\d+)\\b/gm,\n replace: {\n default: {\n captureGroup: 1,\n string: `node${nodeVersion}`,\n version: nodeVersion,\n },\n },\n },\n\n {\n type: 'nodejs',\n files: '**/infra/**/*.ts',\n regex: () => /NODEJS_(\\d+)_X/g,\n replace: {\n default: {\n captureGroup: 1,\n string: `NODEJS_${nodeVersion}_X`,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'nodejs',\n files: '**/infra/**/*.ts',\n regex: () => /(target:\\s*'node)(\\d+)(.+)$/gm,\n replace: {\n default: {\n captureGroup: 2,\n string: `$1${nodeVersion}$3`,\n version: nodeVersion,\n },\n },\n },\n\n {\n type: 'nodejs',\n files: '**/.buildkite/*',\n regex: () =>\n /(image: )(public.ecr.aws\\/docker\\/library\\/)?(node:)([0-9.]+)(\\.[^- \\n]+)?(-[^ \\n]+)?$/gm,\n replace: {\n default: {\n captureGroup: 4,\n string: `$1$2$3${nodeVersion}$5$6`,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'nodejs',\n files: '.node-version*',\n regex: () => /(\\d+(?:\\.\\d+)*)/g,\n replace: {\n default: {\n captureGroup: 1,\n string: `${nodeVersion}`,\n version: nodeVersion,\n },\n },\n },\n\n {\n type: 'nodejs',\n files: '**/package.json',\n regex: () =>\n /([\"']engines[\"']:\\s*{[\\s\\S]*?[\"']node[\"']:\\s*[\"']>=)(\\d+(?:\\.\\d+)*)(['\"]\\s*})/gm,\n replace: {\n package: {\n string: `$1${packageNodeVersion}$3`,\n version: packageNodeVersion,\n captureGroup: 2,\n },\n default: {\n string: `$1${nodeVersion}$3`,\n version: nodeVersion,\n captureGroup: 2,\n },\n },\n },\n {\n type: 'nodejs',\n files: '**/docker-compose*.y*ml',\n regex: () =>\n /(image: )(public.ecr.aws\\/docker\\/library\\/)?(node:)([0-9.]+)(\\.[^- \\n]+)?(-[^ \\n]+)?$/gm,\n\n replace: {\n default: {\n captureGroup: 4,\n string: `$1$2$3${nodeVersion}$5$6`,\n version: nodeVersion,\n },\n },\n },\n {\n type: 'ecmascript',\n files: '**/tsconfig*.json',\n regex: () => /(\"target\":\\s*\")(ES\\d+)\"/gim,\n replace: {\n package: {\n string: `$1${packageECMAScriptVersion}\"`,\n version: packageECMAScriptVersion,\n captureGroup: 2,\n },\n default: {\n string: `$1${ECMAScriptVersion}\"`,\n version: ECMAScriptVersion,\n captureGroup: 2,\n },\n },\n },\n {\n type: 'ecmascript',\n files: '**/tsconfig*.json',\n regex: () => /(\"lib\":\\s*\\[)([\\S\\s]*?)(ES\\d+)([\\S\\s]*?)(\\])/gim,\n replace: {\n package: {\n string: `$1$2${packageECMAScriptVersion}$4$5`,\n version: packageECMAScriptVersion,\n captureGroup: 3,\n },\n default: {\n string: `$1$2${ECMAScriptVersion}$4$5`,\n version: ECMAScriptVersion,\n captureGroup: 3,\n },\n },\n },\n];\n\ntype Versions = {\n nodeVersion: string;\n ECMAScriptVersion: string;\n packageNodeVersion: string;\n packageECMAScriptVersion: string;\n};\n\nconst getTemplatedReplace = async (\n path: string,\n replace: SubPatch['replace'],\n): Promise<ReplaceOptions> => {\n if (!replace.package) {\n return replace.default;\n }\n\n const isPackage = await isLikelyPackage(path);\n\n if (isPackage) {\n return replace.package;\n }\n\n return replace.default;\n};\n\nconst runSubPatch = async (dir: string, patch: SubPatch) => {\n const readFile = createDestinationFileReader(dir);\n const paths = patch.file\n ? [patch.file]\n : await glob(patch.files ?? [], {\n cwd: dir,\n ignore: ['**/node_modules/**'],\n });\n\n await Promise.all(\n paths.map(async (path) => {\n const contents = await readFile(path);\n if (!contents) {\n return;\n }\n\n const regexResult = patch.regex().exec(contents);\n\n if (!regexResult) {\n return;\n }\n\n const templateReplace = await getTemplatedReplace(path, patch.replace);\n\n if (\n !lessThan(\n regexResult[templateReplace.captureGroup] as string,\n templateReplace.version,\n )\n ) {\n return;\n }\n\n await writePatchedContents({\n path,\n contents,\n templated: templateReplace.string,\n regex: patch.regex,\n });\n }),\n );\n};\n\nconst lessThan = (versionA: string, versionB: string) => {\n if (versionA.toLowerCase().startsWith('es')) {\n return Number(versionA.slice(2)) < Number(versionB.slice(2));\n }\n\n const coersedA = coerce(versionA);\n const coersedB = coerce(versionB);\n\n if (!coersedA || !coersedB) {\n throw new Error(\n `Unable to coerce versions for comparison: \"${versionA}\" and \"${versionB}\"`,\n );\n }\n\n return lt(coersedA, coersedB);\n};\n\nconst writePatchedContents = async ({\n path,\n contents,\n templated,\n regex,\n}: {\n path: string;\n contents: string;\n templated: string;\n regex: () => RegExp;\n}) => {\n const modified = contents.replaceAll(regex(), templated);\n await fs.promises.writeFile(path, modified);\n};\n\nconst upgrade = async (versions: Versions, dir: string) => {\n for (const subPatch of subPatches(versions)) {\n await runSubPatch(dir, subPatch);\n }\n};\n\nexport const nodeVersionMigration = async (\n {\n nodeVersion,\n ECMAScriptVersion,\n packageNodeVersion,\n packageECMAScriptVersion,\n infraPackages,\n }: {\n nodeVersion: string;\n ECMAScriptVersion: string;\n packageNodeVersion: string;\n packageECMAScriptVersion: string;\n infraPackages: Array<{ name: string; version: string }>;\n },\n dir = process.cwd(),\n) => {\n log.ok(\n `Upgrading project to Node.js ${nodeVersion} and package targets to Node.js ${packageNodeVersion}`,\n );\n\n try {\n await tryUpgradeInfraPackages('format', infraPackages);\n await upgrade(\n {\n nodeVersion,\n ECMAScriptVersion,\n packageNodeVersion,\n packageECMAScriptVersion,\n },\n dir,\n );\n\n log.ok(\n `Upgraded project to Node.js ${nodeVersion} and package targets to Node.js ${packageNodeVersion}`,\n );\n } catch (error) {\n log.err('Failed to upgrade');\n log.subtle(inspect(error));\n process.exitCode = 1;\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AACf,oBAA2B;AAE3B,qBAAoB;AACpB,qBAA4C;AAE5C,oBAAgC;AAChC,qBAAwC;AAqBxC,MAAM,aAAa,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4B;AAAA,EAC1B;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO,MAAM;AAAA,IACb,SAAS;AAAA,MACP,SAAS;AAAA,QACP,cAAc;AAAA,QACd,QAAQ;AAAA,QACR,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IAEP,OAAO,MACL;AAAA,IACF,SAAS;AAAA,MACP,SAAS;AAAA,QACP,cAAc;AAAA,QACd,QAAQ,iBAAiB,WAAW;AAAA,QACpC,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IACP,OAAO,MACL;AAAA,IACF,SAAS;AAAA,MACP,SAAS;AAA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QAAQ;AAAA,IAC1E;AAAA,EACF;AAEA,aAAO,kBAAG,UAAU,QAAQ;AAC9B;AAEA,MAAM,uBAAuB,OAAO;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACJ,QAAM,WAAW,SAAS,WAAW,MAAM,GAAG,SAAS;AACvD,QAAM,gBAAAA,QAAG,SAAS,UAAU,MAAM,QAAQ;AAC5C;AAEA,MAAM,UAAU,OAAO,UAAoB,QAAgB;AACzD,aAAW,YAAY,WAAW,QAAQ,GAAG;AAC3C,UAAM,YAAY,KAAK,QAAQ;AAAA,EACjC;AACF;AAEO,MAAM,uBAAuB,OAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOA,MAAM,QAAQ,IAAI,MACf;AACH,qBAAI;AAAA,IACF,gCAAgC,WAAW,mCAAmC,kBAAkB;AAAA,EAClG;AAEA,MAAI;AACF,cAAM,wCAAwB,UAAU,aAAa;AACrD,UAAM;AAAA,MACJ;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAEA,uBAAI;AAAA,MACF,+BAA+B,WAAW,mCAAmC,kBAAkB;AAAA,IACjG;AAAA,EACF,SAAS,OAAO;AACd,uBAAI,IAAI,mBAAmB;AAC3B,uBAAI,WAAO,qBAAQ,KAAK,CAAC;AACzB,YAAQ,WAAW;AAAA,EACrB;AACF;",
6
+ "names": ["fs"]
7
7
  }
@@ -0,0 +1,8 @@
1
+ import type { PatchReturnType } from '../../lint/internalLints/upgrade/index.js';
2
+ type PackageInfo = {
3
+ name: string;
4
+ version: string;
5
+ };
6
+ export declare const upgradeInfraPackages: (mode: "lint" | "format", packages: PackageInfo[]) => Promise<PatchReturnType>;
7
+ export declare const tryUpgradeInfraPackages: (mode: "lint" | "format", packages: PackageInfo[]) => Promise<PatchReturnType>;
8
+ export {};
@@ -0,0 +1,179 @@
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 upgrade_exports = {};
30
+ __export(upgrade_exports, {
31
+ tryUpgradeInfraPackages: () => tryUpgradeInfraPackages,
32
+ upgradeInfraPackages: () => upgradeInfraPackages
33
+ });
34
+ module.exports = __toCommonJS(upgrade_exports);
35
+ var import_node_util = require("node:util");
36
+ var import_fast_glob = require("fast-glob");
37
+ var import_fs_extra = __toESM(require("fs-extra"));
38
+ var import_semver = require("semver");
39
+ var import_exec = require("../../../utils/exec.js");
40
+ var import_logging = require("../../../utils/logging.js");
41
+ var import_packageManager = require("../../../utils/packageManager.js");
42
+ const packageVersionRegex = (packageName) => new RegExp(`"\\b${packageName}\\b"\\s*:\\s*"([^"]+)"`, "g");
43
+ const yamlPackageVersionRegex = (packageName) => new RegExp(`\\b${packageName}\\b:\\s*([^\\s]+)`, "g");
44
+ const normalizeVersionRange = (currentVersion, newVersion) => {
45
+ if (currentVersion.startsWith("^")) {
46
+ return `^${newVersion}`;
47
+ }
48
+ if (currentVersion.startsWith("~")) {
49
+ return `~${newVersion}`;
50
+ }
51
+ if (currentVersion.startsWith(">=") || currentVersion.startsWith(">") || currentVersion.startsWith("<=") || currentVersion.startsWith("<")) {
52
+ return `^${newVersion}`;
53
+ }
54
+ if (currentVersion.includes("x") || currentVersion.includes("X")) {
55
+ return `^${newVersion}`;
56
+ }
57
+ if (currentVersion.includes(" - ")) {
58
+ return `^${newVersion}`;
59
+ }
60
+ const coercedCurrent = (0, import_semver.coerce)(currentVersion);
61
+ if (coercedCurrent && (0, import_semver.lt)(coercedCurrent, newVersion)) {
62
+ return newVersion;
63
+ }
64
+ return currentVersion;
65
+ };
66
+ const upgradeInfraPackages = async (mode, packages) => {
67
+ const [packageJsonPaths, pnpmWorkspacePaths] = await Promise.all([
68
+ (0, import_fast_glob.glob)(["**/package.json"], {
69
+ ignore: ["**/.git", "**/node_modules"]
70
+ }),
71
+ (0, import_fast_glob.glob)("**/pnpm-workspace.yaml", {
72
+ ignore: ["**/.git", "**/node_modules"]
73
+ })
74
+ ]);
75
+ if (packageJsonPaths.length === 0 && pnpmWorkspacePaths.length === 0) {
76
+ return {
77
+ result: "skip",
78
+ reason: "no package.json or pnpm-workspace.yaml files found"
79
+ };
80
+ }
81
+ const [packageJsons, pnpmWorkspaces] = await Promise.all([
82
+ Promise.all(
83
+ packageJsonPaths.map(async (file) => {
84
+ const contents = await import_fs_extra.default.readFile(file, "utf8");
85
+ return {
86
+ file,
87
+ contents
88
+ };
89
+ })
90
+ ),
91
+ Promise.all(
92
+ pnpmWorkspacePaths.map(async (file) => {
93
+ const contents = await import_fs_extra.default.readFile(file, "utf8");
94
+ return {
95
+ file,
96
+ contents
97
+ };
98
+ })
99
+ )
100
+ ]);
101
+ const patchedPackageJsons = packageJsons.map((file) => {
102
+ const updated = packages.reduce((contents, packageName) => {
103
+ const regex = packageVersionRegex(packageName.name);
104
+ return contents.replaceAll(regex, (match, currentVersion) => {
105
+ if (currentVersion.startsWith("*") || currentVersion.startsWith("workspace:") || currentVersion.startsWith("link:") || currentVersion.startsWith("file:") || currentVersion.startsWith("catalog:")) {
106
+ return match;
107
+ }
108
+ const newVersion = normalizeVersionRange(
109
+ currentVersion,
110
+ packageName.version
111
+ );
112
+ return newVersion === currentVersion ? match : `"${packageName.name}":"${newVersion}"`;
113
+ });
114
+ }, file.contents);
115
+ return {
116
+ ...file,
117
+ updated
118
+ };
119
+ }).filter(({ contents, updated }) => contents !== updated);
120
+ const patchedPnpmWorkspaces = pnpmWorkspaces.map((file) => {
121
+ const updated = packages.reduce((contents, packageName) => {
122
+ const regex = yamlPackageVersionRegex(packageName.name);
123
+ return contents.replace(regex, (match, currentVersion) => {
124
+ const newVersion = normalizeVersionRange(
125
+ currentVersion,
126
+ packageName.version
127
+ );
128
+ return newVersion === currentVersion ? match : `${packageName.name}: ${newVersion}`;
129
+ });
130
+ }, file.contents);
131
+ return {
132
+ ...file,
133
+ updated
134
+ };
135
+ }).filter(({ contents, updated }) => contents !== updated);
136
+ if (patchedPackageJsons.length === 0 && patchedPnpmWorkspaces.length === 0) {
137
+ return {
138
+ result: "skip",
139
+ reason: "no package.json or pnpm-workspace.yaml files to patch"
140
+ };
141
+ }
142
+ if (mode === "lint") {
143
+ return {
144
+ result: "apply"
145
+ };
146
+ }
147
+ await Promise.all(
148
+ [...patchedPackageJsons, ...patchedPnpmWorkspaces].map(
149
+ async ({ file, updated }) => {
150
+ await import_fs_extra.default.writeFile(file, updated, "utf8");
151
+ }
152
+ )
153
+ );
154
+ const packageManager = await (0, import_packageManager.detectPackageManager)();
155
+ await (0, import_exec.exec)(
156
+ packageManager.command,
157
+ "install",
158
+ "--frozen-lockfile=false",
159
+ "--prefer-offline"
160
+ );
161
+ return {
162
+ result: "apply"
163
+ };
164
+ };
165
+ const tryUpgradeInfraPackages = async (mode, packages) => {
166
+ try {
167
+ return await upgradeInfraPackages(mode, packages);
168
+ } catch (err) {
169
+ import_logging.log.err("Failed to upgrade infrastructure packages");
170
+ import_logging.log.subtle((0, import_node_util.inspect)(err));
171
+ return { result: "skip", reason: "due to an error" };
172
+ }
173
+ };
174
+ // Annotate the CommonJS export names for ESM import in node:
175
+ 0 && (module.exports = {
176
+ tryUpgradeInfraPackages,
177
+ upgradeInfraPackages
178
+ });
179
+ //# sourceMappingURL=upgrade.js.map