skuba 14.0.0-replace-global-vars-20251121010036 → 14.0.0-rfc-pnpm-config-skuba-20260106120954

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 (414) 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 +2 -2
  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.js +60 -28
  19. package/lib/cli/build/assets.js.map +2 -2
  20. package/lib/cli/build/esbuild.js +45 -21
  21. package/lib/cli/build/esbuild.js.map +2 -2
  22. package/lib/cli/build/index.js +45 -21
  23. package/lib/cli/build/index.js.map +1 -1
  24. package/lib/cli/build/tsc.js +59 -22
  25. package/lib/cli/build/tsc.js.map +2 -2
  26. package/lib/cli/buildPackage/index.js +32 -8
  27. package/lib/cli/buildPackage/index.js.map +1 -1
  28. package/lib/cli/configure/analyseConfiguration.js +50 -16
  29. package/lib/cli/configure/analyseConfiguration.js.map +2 -2
  30. package/lib/cli/configure/analyseDependencies.d.ts +1 -1
  31. package/lib/cli/configure/analyseDependencies.js +59 -25
  32. package/lib/cli/configure/analyseDependencies.js.map +3 -3
  33. package/lib/cli/configure/analysis/diff.js +29 -5
  34. package/lib/cli/configure/analysis/diff.js.map +1 -1
  35. package/lib/cli/configure/analysis/files.js +42 -8
  36. package/lib/cli/configure/analysis/files.js.map +2 -2
  37. package/lib/cli/configure/analysis/git.js +46 -12
  38. package/lib/cli/configure/analysis/git.js.map +2 -2
  39. package/lib/cli/configure/analysis/package.d.ts +3 -2
  40. package/lib/cli/configure/analysis/package.js +45 -10
  41. package/lib/cli/configure/analysis/package.js.map +3 -3
  42. package/lib/cli/configure/analysis/project.js +50 -18
  43. package/lib/cli/configure/analysis/project.js.map +2 -2
  44. package/lib/cli/configure/dependencies/index.js +35 -7
  45. package/lib/cli/configure/dependencies/index.js.map +1 -1
  46. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +28 -4
  47. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
  48. package/lib/cli/configure/dependencies/seekKoala.js +28 -4
  49. package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
  50. package/lib/cli/configure/dependencies/skuba.js +28 -4
  51. package/lib/cli/configure/dependencies/skuba.js.map +1 -1
  52. package/lib/cli/configure/dependencies/skubaDeps.js +26 -2
  53. package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
  54. package/lib/cli/configure/dependencies/skubaDive.js +29 -4
  55. package/lib/cli/configure/dependencies/skubaDive.js.map +1 -1
  56. package/lib/cli/configure/ensureTemplateCompletion.d.ts +1 -1
  57. package/lib/cli/configure/ensureTemplateCompletion.js +61 -33
  58. package/lib/cli/configure/ensureTemplateCompletion.js.map +3 -3
  59. package/lib/cli/configure/getEntryPoint.d.ts +1 -1
  60. package/lib/cli/configure/getEntryPoint.js +48 -14
  61. package/lib/cli/configure/getEntryPoint.js.map +3 -3
  62. package/lib/cli/configure/getProjectType.d.ts +1 -1
  63. package/lib/cli/configure/getProjectType.js +35 -14
  64. package/lib/cli/configure/getProjectType.js.map +2 -2
  65. package/lib/cli/configure/index.js +84 -50
  66. package/lib/cli/configure/index.js.map +2 -2
  67. package/lib/cli/configure/modules/eslint.js +34 -10
  68. package/lib/cli/configure/modules/eslint.js.map +1 -1
  69. package/lib/cli/configure/modules/ignore.js +32 -8
  70. package/lib/cli/configure/modules/ignore.js.map +1 -1
  71. package/lib/cli/configure/modules/index.js +44 -18
  72. package/lib/cli/configure/modules/index.js.map +2 -2
  73. package/lib/cli/configure/modules/jest.d.ts +2 -0
  74. package/lib/cli/configure/modules/jest.js +86 -0
  75. package/lib/cli/configure/modules/jest.js.map +7 -0
  76. package/lib/cli/configure/modules/nodemon.js +28 -4
  77. package/lib/cli/configure/modules/nodemon.js.map +1 -1
  78. package/lib/cli/configure/modules/package.js +34 -10
  79. package/lib/cli/configure/modules/package.js.map +1 -1
  80. package/lib/cli/configure/modules/prettier.js +35 -11
  81. package/lib/cli/configure/modules/prettier.js.map +1 -1
  82. package/lib/cli/configure/modules/renovate.js +40 -17
  83. package/lib/cli/configure/modules/renovate.js.map +2 -2
  84. package/lib/cli/configure/modules/serverless.js +26 -2
  85. package/lib/cli/configure/modules/serverless.js.map +1 -1
  86. package/lib/cli/configure/modules/tslint.js +28 -4
  87. package/lib/cli/configure/modules/tslint.js.map +1 -1
  88. package/lib/cli/configure/processing/configFile.d.ts +1 -1
  89. package/lib/cli/configure/processing/configFile.js +34 -43
  90. package/lib/cli/configure/processing/configFile.js.map +2 -2
  91. package/lib/cli/configure/processing/deleteFiles.js +26 -2
  92. package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
  93. package/lib/cli/configure/processing/javascript.js +27 -2
  94. package/lib/cli/configure/processing/javascript.js.map +1 -1
  95. package/lib/cli/configure/processing/json.js +31 -6
  96. package/lib/cli/configure/processing/json.js.map +1 -1
  97. package/lib/cli/configure/processing/loadFiles.js +26 -2
  98. package/lib/cli/configure/processing/loadFiles.js.map +1 -1
  99. package/lib/cli/configure/processing/module.js +28 -4
  100. package/lib/cli/configure/processing/module.js.map +1 -1
  101. package/lib/cli/configure/processing/package.d.ts +67 -1
  102. package/lib/cli/configure/processing/package.js +45 -8
  103. package/lib/cli/configure/processing/package.js.map +3 -3
  104. package/lib/cli/configure/processing/prettier.js +38 -4
  105. package/lib/cli/configure/processing/prettier.js.map +2 -2
  106. package/lib/cli/configure/processing/record.js +41 -5
  107. package/lib/cli/configure/processing/record.js.map +2 -2
  108. package/lib/cli/configure/processing/typescript.js +63 -26
  109. package/lib/cli/configure/processing/typescript.js.map +2 -2
  110. package/lib/cli/configure/types.d.ts +4 -15
  111. package/lib/cli/configure/types.js +16 -0
  112. package/lib/cli/configure/types.js.map +3 -3
  113. package/lib/cli/format/index.js +44 -20
  114. package/lib/cli/format/index.js.map +1 -1
  115. package/lib/cli/help/index.js +30 -6
  116. package/lib/cli/help/index.js.map +1 -1
  117. package/lib/cli/init/getConfig.d.ts +1 -1
  118. package/lib/cli/init/getConfig.js +100 -74
  119. package/lib/cli/init/getConfig.js.map +3 -3
  120. package/lib/cli/init/git.js +51 -16
  121. package/lib/cli/init/git.js.map +2 -2
  122. package/lib/cli/init/index.js +117 -68
  123. package/lib/cli/init/index.js.map +3 -3
  124. package/lib/cli/init/prompts.d.ts +4 -4
  125. package/lib/cli/init/prompts.js +48 -27
  126. package/lib/cli/init/prompts.js.map +2 -2
  127. package/lib/cli/init/types.js +41 -7
  128. package/lib/cli/init/types.js.map +1 -1
  129. package/lib/cli/init/validation.js +30 -2
  130. package/lib/cli/init/validation.js.map +1 -1
  131. package/lib/cli/init/writePackageJson.js +42 -8
  132. package/lib/cli/init/writePackageJson.js.map +2 -2
  133. package/lib/cli/lint/annotate/buildkite/eslint.js +37 -3
  134. package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
  135. package/lib/cli/lint/annotate/buildkite/index.js +45 -11
  136. package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
  137. package/lib/cli/lint/annotate/buildkite/internal.js +37 -3
  138. package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
  139. package/lib/cli/lint/annotate/buildkite/prettier.js +37 -3
  140. package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
  141. package/lib/cli/lint/annotate/buildkite/tsc.js +37 -3
  142. package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
  143. package/lib/cli/lint/annotate/github/eslint.js +26 -2
  144. package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
  145. package/lib/cli/lint/annotate/github/index.js +45 -11
  146. package/lib/cli/lint/annotate/github/index.js.map +1 -1
  147. package/lib/cli/lint/annotate/github/internal.js +26 -2
  148. package/lib/cli/lint/annotate/github/internal.js.map +1 -1
  149. package/lib/cli/lint/annotate/github/prettier.js +26 -2
  150. package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
  151. package/lib/cli/lint/annotate/github/tsc.js +28 -4
  152. package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
  153. package/lib/cli/lint/annotate/index.js +30 -6
  154. package/lib/cli/lint/annotate/index.js.map +1 -1
  155. package/lib/cli/lint/autofix.js +73 -37
  156. package/lib/cli/lint/autofix.js.map +1 -1
  157. package/lib/cli/lint/eslint.js +51 -16
  158. package/lib/cli/lint/eslint.js.map +3 -3
  159. package/lib/cli/lint/external.js +51 -19
  160. package/lib/cli/lint/external.js.map +2 -2
  161. package/lib/cli/lint/index.js +49 -25
  162. package/lib/cli/lint/index.js.map +1 -1
  163. package/lib/cli/lint/internal.js +42 -18
  164. package/lib/cli/lint/internal.js.map +1 -1
  165. package/lib/cli/lint/internalLints/detectBadCodeowners.js +33 -8
  166. package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
  167. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +45 -11
  168. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +2 -2
  169. package/lib/cli/lint/internalLints/patchRenovateConfig.js +55 -21
  170. package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
  171. package/lib/cli/lint/internalLints/refreshConfigFiles.d.ts +1 -1
  172. package/lib/cli/lint/internalLints/refreshConfigFiles.js +65 -42
  173. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +3 -3
  174. package/lib/cli/lint/internalLints/upgrade/index.d.ts +1 -1
  175. package/lib/cli/lint/internalLints/upgrade/index.js +53 -22
  176. package/lib/cli/lint/internalLints/upgrade/index.js.map +3 -3
  177. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +28 -4
  178. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js.map +1 -1
  179. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js +45 -11
  180. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js.map +2 -2
  181. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +30 -6
  182. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +1 -1
  183. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js +65 -34
  184. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +2 -2
  185. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +46 -11
  186. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +2 -2
  187. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +28 -4
  188. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +1 -1
  189. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +59 -23
  190. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +2 -2
  191. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js +28 -4
  192. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +1 -1
  193. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +46 -11
  194. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +2 -2
  195. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +30 -6
  196. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js.map +1 -1
  197. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js +46 -11
  198. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +2 -2
  199. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +46 -11
  200. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +2 -2
  201. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js +28 -4
  202. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js.map +1 -1
  203. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js +46 -11
  204. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +2 -2
  205. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js +67 -29
  206. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js.map +2 -2
  207. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js +34 -10
  208. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js.map +1 -1
  209. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js +45 -11
  210. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js.map +2 -2
  211. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.d.ts +0 -4
  212. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js +63 -18
  213. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js.map +3 -3
  214. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js +50 -15
  215. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +2 -2
  216. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/index.js +45 -0
  217. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/index.js.map +7 -0
  218. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/migrateToPnpmConfig.d.ts +3 -0
  219. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/migrateToPnpmConfig.js +139 -0
  220. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/migrateToPnpmConfig.js.map +7 -0
  221. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.d.ts +3 -0
  222. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.js +133 -0
  223. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/patchRootTsconfig.js.map +7 -0
  224. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/upgradeNode.js +55 -0
  225. package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/upgradeNode.js.map +7 -0
  226. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +51 -17
  227. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js.map +2 -2
  228. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js +34 -10
  229. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js.map +1 -1
  230. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js +44 -10
  231. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js.map +2 -2
  232. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js +46 -12
  233. package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js.map +2 -2
  234. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js +28 -4
  235. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js.map +1 -1
  236. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js +49 -15
  237. package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js.map +2 -2
  238. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +45 -11
  239. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +2 -2
  240. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +34 -10
  241. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +1 -1
  242. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js +45 -11
  243. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js.map +2 -2
  244. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js +45 -11
  245. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js.map +2 -2
  246. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js +47 -13
  247. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js.map +2 -2
  248. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js +28 -4
  249. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js.map +1 -1
  250. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js +45 -11
  251. package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +2 -2
  252. package/lib/cli/lint/prettier.js +50 -15
  253. package/lib/cli/lint/prettier.js.map +3 -3
  254. package/lib/cli/lint/tsc.js +28 -4
  255. package/lib/cli/lint/tsc.js.map +1 -1
  256. package/lib/cli/lint/types.js +16 -0
  257. package/lib/cli/lint/types.js.map +3 -3
  258. package/lib/cli/migrate/index.d.ts +5 -0
  259. package/lib/cli/migrate/index.js +79 -15
  260. package/lib/cli/migrate/index.js.map +2 -2
  261. package/lib/cli/migrate/nodeVersion/checks.d.ts +1 -14
  262. package/lib/cli/migrate/nodeVersion/checks.js +51 -120
  263. package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
  264. package/lib/cli/migrate/nodeVersion/index.d.ts +8 -2
  265. package/lib/cli/migrate/nodeVersion/index.js +239 -65
  266. package/lib/cli/migrate/nodeVersion/index.js.map +3 -3
  267. package/lib/cli/migrate/nodeVersion/upgrade.d.ts +8 -0
  268. package/lib/cli/migrate/nodeVersion/upgrade.js +179 -0
  269. package/lib/cli/migrate/nodeVersion/upgrade.js.map +7 -0
  270. package/lib/cli/node/index.js +57 -20
  271. package/lib/cli/node/index.js.map +3 -3
  272. package/lib/cli/release/index.js +28 -4
  273. package/lib/cli/release/index.js.map +1 -1
  274. package/lib/cli/start/index.js +50 -16
  275. package/lib/cli/start/index.js.map +3 -3
  276. package/lib/cli/test/index.js +44 -4
  277. package/lib/cli/test/index.js.map +2 -2
  278. package/lib/cli/test/reporters/github/annotations.d.ts +9 -0
  279. package/lib/cli/test/reporters/github/annotations.js +102 -0
  280. package/lib/cli/test/reporters/github/annotations.js.map +7 -0
  281. package/lib/cli/test/reporters/github/index.d.ts +5 -0
  282. package/lib/cli/test/reporters/github/index.js +74 -0
  283. package/lib/cli/test/reporters/github/index.js.map +7 -0
  284. package/lib/cli/version/index.js +30 -6
  285. package/lib/cli/version/index.js.map +1 -1
  286. package/lib/index.d.ts +1 -0
  287. package/lib/index.js +46 -6
  288. package/lib/index.js.map +2 -2
  289. package/lib/skuba.js +45 -26
  290. package/lib/skuba.js.map +3 -3
  291. package/lib/utils/args.js +43 -6
  292. package/lib/utils/args.js.map +2 -2
  293. package/lib/utils/command.js +42 -4
  294. package/lib/utils/command.js.map +3 -3
  295. package/lib/utils/copy.js +57 -20
  296. package/lib/utils/copy.js.map +2 -2
  297. package/lib/utils/dir.js +72 -32
  298. package/lib/utils/dir.js.map +2 -2
  299. package/lib/utils/env.js +26 -2
  300. package/lib/utils/env.js.map +1 -1
  301. package/lib/utils/error.js +47 -10
  302. package/lib/utils/error.js.map +1 -1
  303. package/lib/utils/exec.js +61 -23
  304. package/lib/utils/exec.js.map +3 -3
  305. package/lib/utils/fs.js +40 -6
  306. package/lib/utils/fs.js.map +2 -2
  307. package/lib/utils/help.js +30 -6
  308. package/lib/utils/help.js.map +1 -1
  309. package/lib/utils/logging.js +38 -11
  310. package/lib/utils/logging.js.map +1 -1
  311. package/lib/utils/logo.js +48 -24
  312. package/lib/utils/logo.js.map +1 -1
  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.js +35 -10
  333. package/lib/utils/worker.js.map +1 -1
  334. package/lib/wrapper/function-arguments.d.js +1 -0
  335. package/lib/wrapper/functionHandler.js +49 -18
  336. package/lib/wrapper/functionHandler.js.map +2 -2
  337. package/lib/wrapper/http.js +43 -8
  338. package/lib/wrapper/http.js.map +2 -2
  339. package/lib/wrapper/index.js +7 -6
  340. package/lib/wrapper/index.js.map +1 -1
  341. package/lib/wrapper/main.js +42 -8
  342. package/lib/wrapper/main.js.map +3 -3
  343. package/lib/wrapper/requestListener.js +47 -13
  344. package/lib/wrapper/requestListener.js.map +2 -2
  345. package/lib/wrapper/server.js +28 -4
  346. package/lib/wrapper/server.js.map +1 -1
  347. package/package.json +45 -45
  348. package/template/base/_.prettierrc.js +1 -1
  349. package/template/base/_eslint.config.js +1 -1
  350. package/template/base/_pnpm-workspace.yaml +0 -23
  351. package/template/base/jest.config.ts +19 -0
  352. package/template/base/jest.setup.ts +3 -0
  353. package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
  354. package/template/express-rest-api/.nvmrc +1 -1
  355. package/template/express-rest-api/package.json +8 -9
  356. package/template/express-rest-api/skuba.template.js +1 -1
  357. package/template/express-rest-api/src/app.test.ts +0 -1
  358. package/template/greeter/.buildkite/pipeline.yml +1 -1
  359. package/template/greeter/.nvmrc +1 -1
  360. package/template/greeter/package.json +4 -5
  361. package/template/greeter/skuba.template.js +1 -1
  362. package/template/greeter/src/app.test.ts +1 -3
  363. package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
  364. package/template/koa-rest-api/.nvmrc +1 -1
  365. package/template/koa-rest-api/package.json +9 -11
  366. package/template/koa-rest-api/skuba.template.js +1 -1
  367. package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +0 -2
  368. package/template/koa-rest-api/src/api/jobs/postJob.test.ts +0 -2
  369. package/template/koa-rest-api/src/app.test.ts +0 -2
  370. package/template/koa-rest-api/src/framework/server.test.ts +2 -2
  371. package/template/koa-rest-api/src/framework/validation.test.ts +0 -2
  372. package/template/koa-rest-api/src/testing/metrics.ts +0 -2
  373. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -2
  374. package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
  375. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +7 -19
  376. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +9 -11
  377. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +3 -3
  378. package/template/lambda-sqs-worker-cdk/infra/config.ts +2 -4
  379. package/template/lambda-sqs-worker-cdk/package.json +9 -9
  380. package/template/lambda-sqs-worker-cdk/skuba.template.js +13 -1
  381. package/template/lambda-sqs-worker-cdk/src/app.test.ts +13 -22
  382. package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +0 -1
  383. package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +31 -33
  384. package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +2 -8
  385. package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +2 -3
  386. package/template/lambda-sqs-worker-cdk/src/testing/services.ts +3 -4
  387. package/template/oss-npm-package/.github/workflows/release.yml +1 -1
  388. package/template/oss-npm-package/.github/workflows/validate.yml +1 -1
  389. package/template/oss-npm-package/.nvmrc +1 -1
  390. package/template/oss-npm-package/_package.json +1 -2
  391. package/template/oss-npm-package/skuba.template.js +1 -1
  392. package/template/oss-npm-package/src/index.test.ts +0 -2
  393. package/template/private-npm-package/.nvmrc +1 -1
  394. package/template/private-npm-package/_package.json +2 -3
  395. package/template/private-npm-package/skuba.template.js +2 -2
  396. package/template/private-npm-package/src/index.test.ts +0 -2
  397. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/addTypeModuleToPackageJson.d.ts +0 -6
  398. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/addTypeModuleToPackageJson.js +0 -86
  399. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/addTypeModuleToPackageJson.js.map +0 -7
  400. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.js +0 -16
  401. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.js.map +0 -7
  402. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.d.ts +0 -7
  403. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.js +0 -76
  404. package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.js.map +0 -7
  405. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.d.ts +0 -2
  406. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js +0 -11
  407. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js.map +0 -7
  408. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js +0 -34
  409. package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +0 -7
  410. package/lib/eslint.d.js +0 -1
  411. package/lib/eslint.d.js.map +0 -7
  412. package/template/base/vitest.config.ts +0 -25
  413. /package/lib/cli/lint/internalLints/upgrade/patches/{12.5.0 → 13.1.1}/index.d.ts +0 -0
  414. /package/lib/cli/lint/internalLints/upgrade/patches/{9.1.0 → 13.1.1}/upgradeNode.d.ts +0 -0
@@ -1,18 +1,48 @@
1
- import path from "path";
2
- import { inspect, stripVTControlCharacters as stripAnsi } from "util";
3
- import fs from "fs-extra";
4
- import { Git } from "../../../index.js";
5
- import {
6
- findCurrentWorkspaceProjectRoot,
7
- findWorkspaceRoot
8
- } from "../../../utils/dir.js";
9
- import {
10
- detectPackageManager
11
- } from "../../../utils/packageManager.js";
12
- import { readBaseTemplateFile } from "../../../utils/template.js";
13
- import { getDestinationManifest } from "../../configure/analysis/package.js";
14
- import { createDestinationFileReader } from "../../configure/analysis/project.js";
15
- import { mergeWithConfigFile } from "../../configure/processing/configFile.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 refreshConfigFiles_exports = {};
30
+ __export(refreshConfigFiles_exports, {
31
+ REFRESHABLE_CONFIG_FILES: () => REFRESHABLE_CONFIG_FILES,
32
+ refreshConfigFiles: () => refreshConfigFiles,
33
+ tryRefreshConfigFiles: () => tryRefreshConfigFiles
34
+ });
35
+ module.exports = __toCommonJS(refreshConfigFiles_exports);
36
+ var import_path = __toESM(require("path"));
37
+ var import_util = require("util");
38
+ var import_fs_extra = __toESM(require("fs-extra"));
39
+ var import__ = require("../../../index.js");
40
+ var import_dir = require("../../../utils/dir.js");
41
+ var import_packageManager = require("../../../utils/packageManager.js");
42
+ var import_template = require("../../../utils/template.js");
43
+ var import_package = require("../../configure/analysis/package.js");
44
+ var import_project = require("../../configure/analysis/project.js");
45
+ var import_configFile = require("../../configure/processing/configFile.js");
16
46
  const OLD_IGNORE_WARNING = `# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.
17
47
  # IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.
18
48
  # You can use \`skuba format\` to generate the file or otherwise commit an empty file.
@@ -28,11 +58,6 @@ const REFRESHABLE_CONFIG_FILES = [
28
58
  additionalMapping: removeOldWarning
29
59
  },
30
60
  { name: ".prettierignore", type: "ignore" },
31
- {
32
- name: "pnpm-workspace.yaml",
33
- type: "pnpm-workspace",
34
- if: ({ packageManager, isInWorkspaceRoot }) => isInWorkspaceRoot && packageManager.command === "pnpm"
35
- },
36
61
  {
37
62
  name: ".dockerignore",
38
63
  type: "ignore",
@@ -41,45 +66,42 @@ const REFRESHABLE_CONFIG_FILES = [
41
66
  ];
42
67
  const refreshConfigFiles = async (mode, logger) => {
43
68
  const [manifest, gitRoot, workspaceRoot, currentWorkspaceProjectRoot] = await Promise.all([
44
- getDestinationManifest(),
45
- Git.findRoot({ dir: process.cwd() }),
46
- findWorkspaceRoot(),
47
- findCurrentWorkspaceProjectRoot()
69
+ (0, import_package.getDestinationManifest)(),
70
+ import__.Git.findRoot({ dir: process.cwd() }),
71
+ (0, import_dir.findWorkspaceRoot)(),
72
+ (0, import_dir.findCurrentWorkspaceProjectRoot)()
48
73
  ]);
49
- const destinationRoot = path.dirname(manifest.path);
50
- const readDestinationFile = createDestinationFileReader(destinationRoot);
74
+ const destinationRoot = import_path.default.dirname(manifest.path);
75
+ const readDestinationFile = (0, import_project.createDestinationFileReader)(destinationRoot);
51
76
  const refreshConfigFile = async ({
52
77
  name: filename,
53
- type: fileType,
54
78
  additionalMapping = (s) => s,
55
79
  if: condition = () => true
56
80
  }, conditionOptions) => {
57
81
  if (!condition(conditionOptions)) {
58
82
  return { needsChange: false };
59
83
  }
60
- const maybeReadPackageJson = async (type) => type === "pnpm-workspace" ? await readDestinationFile("package.json") : void 0;
61
- const [inputFile, templateFile, isGitIgnored, packageJson] = await Promise.all([
84
+ const [inputFile, templateFile, isGitIgnored] = await Promise.all([
62
85
  readDestinationFile(filename),
63
- readBaseTemplateFile(`_${filename}`),
64
- gitRoot ? Git.isFileGitIgnored({
86
+ (0, import_template.readBaseTemplateFile)(`_${filename}`),
87
+ gitRoot ? import__.Git.isFileGitIgnored({
65
88
  gitRoot,
66
- absolutePath: path.join(destinationRoot, filename)
67
- }) : false,
68
- maybeReadPackageJson(fileType)
89
+ absolutePath: import_path.default.join(destinationRoot, filename)
90
+ }) : false
69
91
  ]);
70
92
  if (inputFile === void 0 && isGitIgnored) {
71
93
  return { needsChange: false };
72
94
  }
73
95
  const data = additionalMapping(
74
- inputFile ? mergeWithConfigFile(templateFile, fileType, packageJson)(inputFile) : templateFile,
96
+ inputFile ? (0, import_configFile.mergeWithConfigFile)(templateFile)(inputFile) : templateFile,
75
97
  packageManager
76
98
  );
77
- const filepath = path.join(destinationRoot, filename);
99
+ const filepath = import_path.default.join(destinationRoot, filename);
78
100
  if (mode === "format") {
79
101
  if (data === inputFile) {
80
102
  return { needsChange: false };
81
103
  }
82
- await fs.writeFile(filepath, data);
104
+ await import_fs_extra.default.writeFile(filepath, data);
83
105
  return {
84
106
  needsChange: false,
85
107
  msg: `Refreshed ${logger.bold(filename)}.`,
@@ -99,7 +121,7 @@ const refreshConfigFiles = async (mode, logger) => {
99
121
  }
100
122
  return { needsChange: false };
101
123
  };
102
- const packageManager = await detectPackageManager(destinationRoot);
124
+ const packageManager = await (0, import_packageManager.detectPackageManager)(destinationRoot);
103
125
  const results = await Promise.all(
104
126
  REFRESHABLE_CONFIG_FILES.map(
105
127
  (conf) => refreshConfigFile(conf, {
@@ -121,7 +143,7 @@ const refreshConfigFiles = async (mode, logger) => {
121
143
  ({ needsChange, filename, msg }) => needsChange && msg ? [
122
144
  {
123
145
  path: filename,
124
- message: stripAnsi(msg)
146
+ message: (0, import_util.stripVTControlCharacters)(msg)
125
147
  }
126
148
  ] : []
127
149
  )
@@ -132,7 +154,7 @@ const tryRefreshConfigFiles = async (mode, logger) => {
132
154
  return await refreshConfigFiles(mode, logger);
133
155
  } catch (err) {
134
156
  logger.warn("Failed to refresh config files.");
135
- logger.subtle(inspect(err));
157
+ logger.subtle((0, import_util.inspect)(err));
136
158
  return {
137
159
  ok: false,
138
160
  fixable: false,
@@ -140,9 +162,10 @@ const tryRefreshConfigFiles = async (mode, logger) => {
140
162
  };
141
163
  }
142
164
  };
143
- export {
165
+ // Annotate the CommonJS export names for ESM import in node:
166
+ 0 && (module.exports = {
144
167
  REFRESHABLE_CONFIG_FILES,
145
168
  refreshConfigFiles,
146
169
  tryRefreshConfigFiles
147
- };
170
+ });
148
171
  //# sourceMappingURL=refreshConfigFiles.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/lint/internalLints/refreshConfigFiles.ts"],
4
- "sourcesContent": ["import path from 'path';\nimport { inspect, stripVTControlCharacters as stripAnsi } from 'util';\n\nimport fs from 'fs-extra';\n\nimport { Git } from '../../../index.js';\nimport {\n findCurrentWorkspaceProjectRoot,\n findWorkspaceRoot,\n} from '../../../utils/dir.js';\nimport type { Logger } from '../../../utils/logging.js';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../utils/packageManager.js';\nimport { readBaseTemplateFile } from '../../../utils/template.js';\nimport { getDestinationManifest } from '../../configure/analysis/package.js';\nimport { createDestinationFileReader } from '../../configure/analysis/project.js';\nimport { mergeWithConfigFile } from '../../configure/processing/configFile.js';\nimport type { InternalLintResult } from '../internal.js';\n\ntype ConditionOptions = {\n packageManager: PackageManagerConfig;\n isInWorkspaceRoot: boolean;\n};\n\ntype RefreshableConfigFile = {\n name: string;\n type: 'ignore' | 'pnpm-workspace';\n additionalMapping?: (\n s: string,\n packageManager: PackageManagerConfig,\n ) => string;\n if?: (options: ConditionOptions) => boolean;\n};\n\nconst OLD_IGNORE_WARNING = `# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.\n# IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.\n# You can use \\`skuba format\\` to generate the file or otherwise commit an empty file.\n# Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.\n.npmrc\n`;\n\nconst removeOldWarning = (contents: string) =>\n contents.includes(OLD_IGNORE_WARNING)\n ? `${contents.replace(OLD_IGNORE_WARNING, '').trim()}\\n`\n : contents;\n\nexport const REFRESHABLE_CONFIG_FILES: RefreshableConfigFile[] = [\n {\n name: '.gitignore',\n type: 'ignore',\n additionalMapping: removeOldWarning,\n },\n { name: '.prettierignore', type: 'ignore' },\n {\n name: 'pnpm-workspace.yaml',\n type: 'pnpm-workspace',\n if: ({ packageManager, isInWorkspaceRoot }) =>\n isInWorkspaceRoot && packageManager.command === 'pnpm',\n },\n {\n name: '.dockerignore',\n type: 'ignore',\n additionalMapping: removeOldWarning,\n },\n];\n\nexport const refreshConfigFiles = async (\n mode: 'format' | 'lint',\n logger: Logger,\n) => {\n const [manifest, gitRoot, workspaceRoot, currentWorkspaceProjectRoot] =\n await Promise.all([\n getDestinationManifest(),\n Git.findRoot({ dir: process.cwd() }),\n findWorkspaceRoot(),\n findCurrentWorkspaceProjectRoot(),\n ]);\n\n const destinationRoot = path.dirname(manifest.path);\n\n const readDestinationFile = createDestinationFileReader(destinationRoot);\n\n const refreshConfigFile = async (\n {\n name: filename,\n type: fileType,\n additionalMapping = (s) => s,\n if: condition = () => true,\n }: RefreshableConfigFile,\n conditionOptions: ConditionOptions,\n ) => {\n if (!condition(conditionOptions)) {\n return { needsChange: false };\n }\n\n const maybeReadPackageJson = async (type: RefreshableConfigFile['type']) =>\n type === 'pnpm-workspace'\n ? await readDestinationFile('package.json')\n : undefined;\n\n const [inputFile, templateFile, isGitIgnored, packageJson] =\n await Promise.all([\n readDestinationFile(filename),\n readBaseTemplateFile(`_${filename}`),\n gitRoot\n ? Git.isFileGitIgnored({\n gitRoot,\n absolutePath: path.join(destinationRoot, filename),\n })\n : false,\n maybeReadPackageJson(fileType),\n ]);\n\n // If the file is gitignored and doesn't exist, don't make it\n if (inputFile === undefined && isGitIgnored) {\n return { needsChange: false };\n }\n\n const data = additionalMapping(\n inputFile\n ? mergeWithConfigFile(templateFile, fileType, packageJson)(inputFile)\n : templateFile,\n packageManager,\n );\n\n const filepath = path.join(destinationRoot, filename);\n\n if (mode === 'format') {\n if (data === inputFile) {\n return { needsChange: false };\n }\n\n await fs.writeFile(filepath, data);\n return {\n needsChange: false,\n msg: `Refreshed ${logger.bold(filename)}.`,\n filename,\n };\n }\n\n if (data !== inputFile) {\n return {\n needsChange: true,\n msg: `The ${logger.bold(\n filename,\n )} file is out of date. Run \\`${logger.bold(\n `${packageManager.print.exec} skuba format`,\n )}\\` to update it.`,\n filename,\n };\n }\n\n return { needsChange: false };\n };\n\n const packageManager = await detectPackageManager(destinationRoot);\n\n const results = await Promise.all(\n REFRESHABLE_CONFIG_FILES.map((conf) =>\n refreshConfigFile(conf, {\n packageManager,\n isInWorkspaceRoot: workspaceRoot === currentWorkspaceProjectRoot,\n }),\n ),\n );\n\n // Log after for reproducible test output ordering\n results.forEach((result) => {\n if (result.msg) {\n logger.warn(result.msg);\n }\n });\n\n const anyNeedChanging = results.some(({ needsChange }) => needsChange);\n\n return {\n ok: !anyNeedChanging,\n fixable: anyNeedChanging,\n annotations: results.flatMap(({ needsChange, filename, msg }) =>\n needsChange && msg\n ? [\n {\n path: filename,\n message: stripAnsi(msg),\n },\n ]\n : [],\n ),\n };\n};\n\nexport const tryRefreshConfigFiles = async (\n mode: 'format' | 'lint',\n logger: Logger,\n): Promise<InternalLintResult> => {\n try {\n return await refreshConfigFiles(mode, logger);\n } catch (err) {\n logger.warn('Failed to refresh config files.');\n logger.subtle(inspect(err));\n\n return {\n ok: false,\n fixable: false,\n annotations: [],\n };\n }\n};\n"],
5
- "mappings": "AAAA,OAAO,UAAU;AACjB,SAAS,SAAS,4BAA4B,iBAAiB;AAE/D,OAAO,QAAQ;AAEf,SAAS,WAAW;AACpB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EAEE;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,mCAAmC;AAC5C,SAAS,2BAA2B;AAkBpC,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAO3B,MAAM,mBAAmB,CAAC,aACxB,SAAS,SAAS,kBAAkB,IAChC,GAAG,SAAS,QAAQ,oBAAoB,EAAE,EAAE,KAAK,CAAC;AAAA,IAClD;AAEC,MAAM,2BAAoD;AAAA,EAC/D;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,mBAAmB;AAAA,EACrB;AAAA,EACA,EAAE,MAAM,mBAAmB,MAAM,SAAS;AAAA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A,IACP;AAAA,EACF;AACF;AAEO,MAAM,wBAAwB,OACnC,MACA,WACgC;AAChC,MAAI;AACF,WAAO,MAAM,mBAAmB,MAAM,MAAM;AAAA,EAC9C,SAAS,KAAK;AACZ,WAAO,KAAK,iCAAiC;AAC7C,WAAO,OAAO,QAAQ,GAAG,CAAC;AAE1B,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa,CAAC;AAAA,IAChB;AAAA,EACF;AACF;",
6
- "names": []
4
+ "sourcesContent": ["import path from 'path';\nimport { inspect, stripVTControlCharacters as stripAnsi } from 'util';\n\nimport fs from 'fs-extra';\n\nimport { Git } from '../../../index.js';\nimport {\n findCurrentWorkspaceProjectRoot,\n findWorkspaceRoot,\n} from '../../../utils/dir.js';\nimport type { Logger } from '../../../utils/logging.js';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../utils/packageManager.js';\nimport { readBaseTemplateFile } from '../../../utils/template.js';\nimport { getDestinationManifest } from '../../configure/analysis/package.js';\nimport { createDestinationFileReader } from '../../configure/analysis/project.js';\nimport { mergeWithConfigFile } from '../../configure/processing/configFile.js';\nimport type { InternalLintResult } from '../internal.js';\n\ntype ConditionOptions = {\n packageManager: PackageManagerConfig;\n isInWorkspaceRoot: boolean;\n};\n\ntype RefreshableConfigFile = {\n name: string;\n type: 'ignore';\n additionalMapping?: (\n s: string,\n packageManager: PackageManagerConfig,\n ) => string;\n if?: (options: ConditionOptions) => boolean;\n};\n\nconst OLD_IGNORE_WARNING = `# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.\n# IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.\n# You can use \\`skuba format\\` to generate the file or otherwise commit an empty file.\n# Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.\n.npmrc\n`;\n\nconst removeOldWarning = (contents: string) =>\n contents.includes(OLD_IGNORE_WARNING)\n ? `${contents.replace(OLD_IGNORE_WARNING, '').trim()}\\n`\n : contents;\n\nexport const REFRESHABLE_CONFIG_FILES: RefreshableConfigFile[] = [\n {\n name: '.gitignore',\n type: 'ignore',\n additionalMapping: removeOldWarning,\n },\n { name: '.prettierignore', type: 'ignore' },\n {\n name: '.dockerignore',\n type: 'ignore',\n additionalMapping: removeOldWarning,\n },\n];\n\nexport const refreshConfigFiles = async (\n mode: 'format' | 'lint',\n logger: Logger,\n) => {\n const [manifest, gitRoot, workspaceRoot, currentWorkspaceProjectRoot] =\n await Promise.all([\n getDestinationManifest(),\n Git.findRoot({ dir: process.cwd() }),\n findWorkspaceRoot(),\n findCurrentWorkspaceProjectRoot(),\n ]);\n\n const destinationRoot = path.dirname(manifest.path);\n\n const readDestinationFile = createDestinationFileReader(destinationRoot);\n\n const refreshConfigFile = async (\n {\n name: filename,\n additionalMapping = (s) => s,\n if: condition = () => true,\n }: RefreshableConfigFile,\n conditionOptions: ConditionOptions,\n ) => {\n if (!condition(conditionOptions)) {\n return { needsChange: false };\n }\n\n const [inputFile, templateFile, isGitIgnored] = await Promise.all([\n readDestinationFile(filename),\n readBaseTemplateFile(`_${filename}`),\n gitRoot\n ? Git.isFileGitIgnored({\n gitRoot,\n absolutePath: path.join(destinationRoot, filename),\n })\n : false,\n ]);\n\n // If the file is gitignored and doesn't exist, don't make it\n if (inputFile === undefined && isGitIgnored) {\n return { needsChange: false };\n }\n\n const data = additionalMapping(\n inputFile ? mergeWithConfigFile(templateFile)(inputFile) : templateFile,\n packageManager,\n );\n\n const filepath = path.join(destinationRoot, filename);\n\n if (mode === 'format') {\n if (data === inputFile) {\n return { needsChange: false };\n }\n\n await fs.writeFile(filepath, data);\n return {\n needsChange: false,\n msg: `Refreshed ${logger.bold(filename)}.`,\n filename,\n };\n }\n\n if (data !== inputFile) {\n return {\n needsChange: true,\n msg: `The ${logger.bold(\n filename,\n )} file is out of date. Run \\`${logger.bold(\n `${packageManager.print.exec} skuba format`,\n )}\\` to update it.`,\n filename,\n };\n }\n\n return { needsChange: false };\n };\n\n const packageManager = await detectPackageManager(destinationRoot);\n\n const results = await Promise.all(\n REFRESHABLE_CONFIG_FILES.map((conf) =>\n refreshConfigFile(conf, {\n packageManager,\n isInWorkspaceRoot: workspaceRoot === currentWorkspaceProjectRoot,\n }),\n ),\n );\n\n // Log after for reproducible test output ordering\n results.forEach((result) => {\n if (result.msg) {\n logger.warn(result.msg);\n }\n });\n\n const anyNeedChanging = results.some(({ needsChange }) => needsChange);\n\n return {\n ok: !anyNeedChanging,\n fixable: anyNeedChanging,\n annotations: results.flatMap(({ needsChange, filename, msg }) =>\n needsChange && msg\n ? [\n {\n path: filename,\n message: stripAnsi(msg),\n },\n ]\n : [],\n ),\n };\n};\n\nexport const tryRefreshConfigFiles = async (\n mode: 'format' | 'lint',\n logger: Logger,\n): Promise<InternalLintResult> => {\n try {\n return await refreshConfigFiles(mode, logger);\n } catch (err) {\n logger.warn('Failed to refresh config files.');\n logger.subtle(inspect(err));\n\n return {\n ok: false,\n fixable: false,\n annotations: [],\n };\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAA+D;AAE/D,sBAAe;AAEf,eAAoB;AACpB,iBAGO;AAEP,4BAGO;AACP,sBAAqC;AACrC,qBAAuC;AACvC,qBAA4C;AAC5C,wBAAoC;AAkBpC,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAO3B,MAAM,mBAAmB,CAAC,aACxB,SAAS,SAAS,kBAAkB,IAChC,GAAG,SAAS,QAAQ,oBAAoB,EAAE,EAAE,KAAK,CAAC;AAAA,IAClD;AAEC,MAAM,2BAAoD;AAAA,EAC/D;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,mBAAmB;AAAA,EACrB;AAAA,EACA,EAAE,MAAM,mBAAmB,MAAM,SAAS;AAAA,EAC1C;AAAA,IACE,MAAM;AAAA,IACN,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,aAAa,CAAC;AAAA,IAChB;AAAA,EACF;AACF;",
6
+ "names": ["path", "fs", "stripAnsi"]
7
7
  }
@@ -1,6 +1,6 @@
1
+ import type { ReadResult } from 'read-pkg-up';
1
2
  import type { Logger } from '../../../../utils/logging.js';
2
3
  import { type PackageManagerConfig } from '../../../../utils/packageManager.js';
3
- import type { ReadResult } from '../../../configure/types.js';
4
4
  import type { InternalLintResult } from '../../internal.js';
5
5
  export type Patches = Patch[];
6
6
  export type Patch = {
@@ -1,22 +1,53 @@
1
- import path from "path";
2
- import fs from "fs-extra";
3
- import { gte, sort } from "semver";
4
- import { getConsumerManifest } from "../../../../utils/manifest.js";
5
- import {
6
- detectPackageManager
7
- } from "../../../../utils/packageManager.js";
8
- import { getSkubaVersion } from "../../../../utils/version.js";
9
- import { formatPackage } from "../../../configure/processing/package.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 upgrade_exports = {};
30
+ __export(upgrade_exports, {
31
+ upgradeSkuba: () => upgradeSkuba
32
+ });
33
+ module.exports = __toCommonJS(upgrade_exports);
34
+ var import_path = __toESM(require("path"));
35
+ var import_fs_extra = __toESM(require("fs-extra"));
36
+ var import_semver = require("semver");
37
+ var import_manifest = require("../../../../utils/manifest.js");
38
+ var import_packageManager = require("../../../../utils/packageManager.js");
39
+ var import_version = require("../../../../utils/version.js");
40
+ var import_package = require("../../../configure/processing/package.js");
10
41
  const getPatches = async (manifestVersion) => {
11
- const patches = await fs.readdir(path.join(import.meta.dirname, "patches"), {
42
+ const patches = await import_fs_extra.default.readdir(import_path.default.join(__dirname, "patches"), {
12
43
  withFileTypes: true
13
44
  });
14
- const patchesForVersion = sort(
45
+ const patchesForVersion = (0, import_semver.sort)(
15
46
  patches.flatMap(
16
47
  (patch) => (
17
48
  // Is a directory rather than a JavaScript source file
18
49
  patch.isDirectory() && // Has been added since the last patch run on the project
19
- gte(patch.name, manifestVersion) ? patch.name : []
50
+ (0, import_semver.gte)(patch.name, manifestVersion) ? patch.name : []
20
51
  )
21
52
  )
22
53
  );
@@ -34,16 +65,16 @@ const resolvePatches = async (version) => {
34
65
  };
35
66
  const upgradeSkuba = async (mode, logger, additionalFlags = []) => {
36
67
  const [currentVersion, manifest, packageManager] = await Promise.all([
37
- getSkubaVersion(),
38
- getConsumerManifest(),
39
- detectPackageManager()
68
+ (0, import_version.getSkubaVersion)(),
69
+ (0, import_manifest.getConsumerManifest)(),
70
+ (0, import_packageManager.detectPackageManager)()
40
71
  ]);
41
72
  if (!manifest) {
42
73
  throw new Error("Could not find a package json for this project");
43
74
  }
44
75
  manifest.packageJson.skuba ??= { version: "1.0.0" };
45
76
  const manifestVersion = additionalFlags.includes("--force-apply-all-patches") ? "1.0.0" : manifest.packageJson.skuba.version;
46
- if (gte(manifestVersion, currentVersion)) {
77
+ if ((0, import_semver.gte)(manifestVersion, currentVersion)) {
47
78
  return { ok: true, fixable: false };
48
79
  }
49
80
  const patches = await getPatches(manifestVersion);
@@ -97,14 +128,13 @@ const upgradeSkuba = async (mode, logger, additionalFlags = []) => {
97
128
  logger.plain(`Patch applied: ${description}`);
98
129
  }
99
130
  }
100
- const updatedManifest = await getConsumerManifest();
131
+ const updatedManifest = await (0, import_manifest.getConsumerManifest)();
101
132
  if (!updatedManifest) {
102
133
  throw new Error("Could not find a package json for this project");
103
134
  }
104
- updatedManifest.packageJson.skuba ??= { version: currentVersion };
105
135
  updatedManifest.packageJson.skuba.version = currentVersion;
106
- const updatedPackageJson = await formatPackage(updatedManifest.packageJson);
107
- await fs.writeFile(updatedManifest.path, updatedPackageJson);
136
+ const updatedPackageJson = await (0, import_package.formatPackage)(updatedManifest.packageJson);
137
+ await import_fs_extra.default.writeFile(updatedManifest.path, updatedPackageJson);
108
138
  logger.newline();
109
139
  logger.plain("skuba update complete.");
110
140
  logger.newline();
@@ -113,7 +143,8 @@ const upgradeSkuba = async (mode, logger, additionalFlags = []) => {
113
143
  fixable: false
114
144
  };
115
145
  };
116
- export {
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
117
148
  upgradeSkuba
118
- };
149
+ });
119
150
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/cli/lint/internalLints/upgrade/index.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport { gte, sort } from 'semver';\n\nimport type { Logger } from '../../../../utils/logging.js';\nimport { getConsumerManifest } from '../../../../utils/manifest.js';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../../utils/packageManager.js';\nimport { getSkubaVersion } from '../../../../utils/version.js';\nimport { formatPackage } from '../../../configure/processing/package.js';\nimport type { ReadResult } from '../../../configure/types.js';\nimport type { SkubaPackageJson } from '../../../init/writePackageJson.js';\nimport type { InternalLintResult } from '../../internal.js';\n\nexport type Patches = Patch[];\nexport type Patch = {\n apply: PatchFunction;\n description: string;\n};\nexport type PatchReturnType =\n | { result: 'apply' }\n | { result: 'skip'; reason?: string };\n\nexport type PatchConfig = {\n mode: 'format' | 'lint';\n manifest: ReadResult;\n packageManager: PackageManagerConfig;\n dir?: string;\n};\n\nexport type PatchFunction = (config: PatchConfig) => Promise<PatchReturnType>;\n\nconst getPatches = async (manifestVersion: string): Promise<Patches> => {\n const patches = await fs.readdir(path.join(import.meta.dirname, 'patches'), {\n withFileTypes: true,\n });\n\n // The patches are sorted by the version they were added from.\n // Only return patches that are newer or equal to the current version.\n const patchesForVersion = sort(\n patches.flatMap((patch) =>\n // Is a directory rather than a JavaScript source file\n patch.isDirectory() &&\n // Has been added since the last patch run on the project\n gte(patch.name, manifestVersion)\n ? patch.name\n : [],\n ),\n );\n\n return (await Promise.all(patchesForVersion.map(resolvePatches))).flat();\n};\n\nconst fileExtensions = ['js', 'ts'];\n\n// Hack to allow our Jest environment/transform to resolve the patches\n// In normal scenarios this will resolve immediately after the .js import\nconst resolvePatches = async (version: string): Promise<Patches> => {\n for (const extension of fileExtensions) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (await import(`./patches/${version}/index.${extension}`)).patches;\n } catch {\n // Ignore\n }\n }\n throw new Error(`Could not resolve patches for ${version}`);\n};\n\nexport const upgradeSkuba = async (\n mode: 'lint' | 'format',\n logger: Logger,\n additionalFlags: string[] = [],\n): Promise<InternalLintResult> => {\n const [currentVersion, manifest, packageManager] = await Promise.all([\n getSkubaVersion(),\n getConsumerManifest(),\n detectPackageManager(),\n ]);\n\n if (!manifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n manifest.packageJson.skuba ??= { version: '1.0.0' };\n\n const manifestVersion = additionalFlags.includes('--force-apply-all-patches')\n ? '1.0.0'\n : (manifest.packageJson.skuba as SkubaPackageJson).version;\n\n // We are up to date, skip patches\n if (gte(manifestVersion, currentVersion)) {\n return { ok: true, fixable: false };\n }\n\n const patches = await getPatches(manifestVersion);\n // No patches to apply even if version out of date. Early exit to avoid unnecessary commits.\n if (patches.length === 0) {\n return { ok: true, fixable: false };\n }\n\n if (mode === 'lint') {\n const results = await Promise.all(\n patches.map(\n async ({ apply }) =>\n await apply({\n mode,\n manifest,\n packageManager,\n }),\n ),\n );\n\n // No patches are applicable. Early exit to avoid unnecessary commits.\n if (results.every(({ result }) => result === 'skip')) {\n return { ok: true, fixable: false };\n }\n\n logger.warn(\n `skuba has patches to apply. Run ${logger.bold(\n `${packageManager.print.exec} skuba format`,\n )} to run them.`,\n );\n\n return {\n ok: false,\n fixable: true,\n annotations: [\n {\n // package.json as likely skuba version has changed\n // TODO: locate the \"skuba\": {} config in the package.json and annotate on the version property\n path: manifest.path,\n message: `skuba has patches to apply. Run ${packageManager.print.exec} skuba format to run them.`,\n },\n ],\n };\n }\n\n logger.plain('Updating skuba...');\n\n // Run these in series in case a subsequent patch relies on a previous patch\n for (const { apply, description } of patches) {\n const result = await apply({\n mode,\n manifest,\n packageManager,\n });\n logger.newline();\n if (result.result === 'skip') {\n logger.plain(\n `Patch skipped: ${description}${\n result.reason ? ` - ${result.reason}` : ''\n }`,\n );\n } else {\n logger.plain(`Patch applied: ${description}`);\n }\n }\n\n const updatedManifest = await getConsumerManifest();\n if (!updatedManifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n updatedManifest.packageJson.skuba ??= { version: currentVersion };\n updatedManifest.packageJson.skuba.version = currentVersion;\n\n const updatedPackageJson = await formatPackage(updatedManifest.packageJson);\n\n await fs.writeFile(updatedManifest.path, updatedPackageJson);\n logger.newline();\n logger.plain('skuba update complete.');\n logger.newline();\n\n return {\n ok: true,\n fixable: false,\n };\n};\n"],
5
- "mappings": "AAAA,OAAO,UAAU;AAEjB,OAAO,QAAQ;AACf,SA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A,kBAAgB,YAAY,UAAU,EAAE,SAAS,eAAe;AAChE,kBAAgB,YAAY,MAAM,UAAU;AAE5C,QAAM,qBAAqB,MAAM,cAAc,gBAAgB,WAAW;AAE1E,QAAM,GAAG,UAAU,gBAAgB,MAAM,kBAAkB;AAC3D,SAAO,QAAQ;AACf,SAAO,MAAM,wBAAwB;AACrC,SAAO,QAAQ;AAEf,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,SAAS;AAAA,EACX;AACF;",
6
- "names": []
4
+ "sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport type { ReadResult } from 'read-pkg-up';\nimport { gte, sort } from 'semver';\n\nimport type { Logger } from '../../../../utils/logging.js';\nimport { getConsumerManifest } from '../../../../utils/manifest.js';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../../utils/packageManager.js';\nimport { getSkubaVersion } from '../../../../utils/version.js';\nimport { formatPackage } from '../../../configure/processing/package.js';\nimport type { SkubaPackageJson } from '../../../init/writePackageJson.js';\nimport type { InternalLintResult } from '../../internal.js';\n\nexport type Patches = Patch[];\nexport type Patch = {\n apply: PatchFunction;\n description: string;\n};\nexport type PatchReturnType =\n | { result: 'apply' }\n | { result: 'skip'; reason?: string };\n\nexport type PatchConfig = {\n mode: 'format' | 'lint';\n manifest: ReadResult;\n packageManager: PackageManagerConfig;\n dir?: string;\n};\n\nexport type PatchFunction = (config: PatchConfig) => Promise<PatchReturnType>;\n\nconst getPatches = async (manifestVersion: string): Promise<Patches> => {\n const patches = await fs.readdir(path.join(__dirname, 'patches'), {\n withFileTypes: true,\n });\n\n // The patches are sorted by the version they were added from.\n // Only return patches that are newer or equal to the current version.\n const patchesForVersion = sort(\n patches.flatMap((patch) =>\n // Is a directory rather than a JavaScript source file\n patch.isDirectory() &&\n // Has been added since the last patch run on the project\n gte(patch.name, manifestVersion)\n ? patch.name\n : [],\n ),\n );\n\n return (await Promise.all(patchesForVersion.map(resolvePatches))).flat();\n};\n\nconst fileExtensions = ['js', 'ts'];\n\n// Hack to allow our Jest environment/transform to resolve the patches\n// In normal scenarios this will resolve immediately after the .js import\nconst resolvePatches = async (version: string): Promise<Patches> => {\n for (const extension of fileExtensions) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (await import(`./patches/${version}/index.${extension}`)).patches;\n } catch {\n // Ignore\n }\n }\n throw new Error(`Could not resolve patches for ${version}`);\n};\n\nexport const upgradeSkuba = async (\n mode: 'lint' | 'format',\n logger: Logger,\n additionalFlags: string[] = [],\n): Promise<InternalLintResult> => {\n const [currentVersion, manifest, packageManager] = await Promise.all([\n getSkubaVersion(),\n getConsumerManifest(),\n detectPackageManager(),\n ]);\n\n if (!manifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n manifest.packageJson.skuba ??= { version: '1.0.0' };\n\n const manifestVersion = additionalFlags.includes('--force-apply-all-patches')\n ? '1.0.0'\n : (manifest.packageJson.skuba as SkubaPackageJson).version;\n\n // We are up to date, skip patches\n if (gte(manifestVersion, currentVersion)) {\n return { ok: true, fixable: false };\n }\n\n const patches = await getPatches(manifestVersion);\n // No patches to apply even if version out of date. Early exit to avoid unnecessary commits.\n if (patches.length === 0) {\n return { ok: true, fixable: false };\n }\n\n if (mode === 'lint') {\n const results = await Promise.all(\n patches.map(\n async ({ apply }) =>\n await apply({\n mode,\n manifest,\n packageManager,\n }),\n ),\n );\n\n // No patches are applicable. Early exit to avoid unnecessary commits.\n if (results.every(({ result }) => result === 'skip')) {\n return { ok: true, fixable: false };\n }\n\n logger.warn(\n `skuba has patches to apply. Run ${logger.bold(\n `${packageManager.print.exec} skuba format`,\n )} to run them.`,\n );\n\n return {\n ok: false,\n fixable: true,\n annotations: [\n {\n // package.json as likely skuba version has changed\n // TODO: locate the \"skuba\": {} config in the package.json and annotate on the version property\n path: manifest.path,\n message: `skuba has patches to apply. Run ${packageManager.print.exec} skuba format to run them.`,\n },\n ],\n };\n }\n\n logger.plain('Updating skuba...');\n\n // Run these in series in case a subsequent patch relies on a previous patch\n for (const { apply, description } of patches) {\n const result = await apply({\n mode,\n manifest,\n packageManager,\n });\n logger.newline();\n if (result.result === 'skip') {\n logger.plain(\n `Patch skipped: ${description}${\n result.reason ? ` - ${result.reason}` : ''\n }`,\n );\n } else {\n logger.plain(`Patch applied: ${description}`);\n }\n }\n\n const updatedManifest = await getConsumerManifest();\n if (!updatedManifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n (updatedManifest.packageJson.skuba as SkubaPackageJson).version =\n currentVersion;\n\n const updatedPackageJson = await formatPackage(updatedManifest.packageJson);\n\n await fs.writeFile(updatedManifest.path, updatedPackageJson);\n logger.newline();\n logger.plain('skuba update complete.');\n logger.newline();\n\n return {\n ok: true,\n fixable: false,\n };\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AAEf,oBAA0B;AAG1B,sBAAoC;AACpC,4BAGO;AACP,qBAAgC;AAChC,qBAA8B;AAsB9B,MAAM,aAAa,OAAO,oBAA8C;AACtE,QAAM,UAAU,MAAM,gBAAAA,QAAG,QAAQ,YAAAC,QAAK,KAAK,WAAW,SAAS,GAAG;AAAA,IAChE,eAAe;AAAA,EACjB,CAAC;AAID,QAAM,wBAAoB;AAAA,IACxB,QAAQ;AAAA,MAAQ,CAAC;AAAA;AAAA,QAEf,MAAM,YAAY;AAAA,YAElB,mBAAI,MAAM,MAAM,eAAe,IAC3B,MAAM,OACN,CAAC;AAAA;AAAA,IACP;AAAA,EACF;AAEA,UAAQ,MAAM,QAAQ,IAAI,kBAAkB,IAAI,cAAc,CAAC,GAAG,KAAK;AACzE;AAEA,MAAM,iBAAiB,CAAC,MAAM,IAAI;AAIlC,MAAM,iBAAiB,OAAO,YAAsC;AAClE,aAAW,aAAa,gBAAgB;AACtC,QAAI;AAEF,cAAQ,MAAM,OAAO,aAAa,OAAO,UAAU,SAAS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UACf,SAAS,mCAAmC,eAAe,MAAM,IAAI;AAAA,QACvE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,MAAM,mBAAmB;AAGhC,aAAW,EAAE,OAAO,YAAY,KAAK,SAAS;AAC5C,UAAM,SAAS,MAAM,MAAM;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AACD,WAAO,QAAQ;AACf,QAAI,OAAO,WAAW,QAAQ;AAC5B,aAAO;AAAA,QACL,kBAAkB,WAAW,GAC3B,OAAO,SAAS,MAAM,OAAO,MAAM,KAAK,EAC1C;AAAA,MACF;AAAA,IACF,OAAO;AACL,aAAO,MAAM,kBAAkB,WAAW,EAAE;AAAA,IAC9C;AAAA,EACF;AAEA,QAAM,kBAAkB,UAAM,qCAAoB;AAClD,MAAI,CAAC,iBAAiB;AACpB,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AAEA,EAAC,gBAAgB,YAAY,MAA2B,UACtD;AAEF,QAAM,qBAAqB,UAAM,8BAAc,gBAAgB,WAAW;AAE1E,QAAM,gBAAAD,QAAG,UAAU,gBAAgB,MAAM,kBAAkB;AAC3D,SAAO,QAAQ;AACf,SAAO,MAAM,wBAAwB;AACrC,SAAO,QAAQ;AAEf,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,SAAS;AAAA,EACX;AACF;",
6
+ "names": ["fs", "path"]
7
7
  }
@@ -1,11 +1,35 @@
1
- import { tryRemoveYarnIgnoreOptionalFlags } from "./removeYarnIgnoreOptionalFlags.js";
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_removeYarnIgnoreOptionalFlags = require("./removeYarnIgnoreOptionalFlags.js");
2
25
  const patches = [
3
26
  {
4
- apply: tryRemoveYarnIgnoreOptionalFlags,
27
+ apply: import_removeYarnIgnoreOptionalFlags.tryRemoveYarnIgnoreOptionalFlags,
5
28
  description: "Remove yarn --ignore-optional flags in Dockerfiles"
6
29
  }
7
30
  ];
8
- export {
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
9
33
  patches
10
- };
34
+ });
11
35
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/10.0.4/index.ts"],
4
4
  "sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { tryRemoveYarnIgnoreOptionalFlags } from './removeYarnIgnoreOptionalFlags.js';\n\nexport const patches: Patches = [\n {\n apply: tryRemoveYarnIgnoreOptionalFlags,\n description: 'Remove yarn --ignore-optional flags in Dockerfiles',\n },\n];\n"],
5
- "mappings": "AAEA,SAAS,wCAAwC;AAE1C,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2CAAiD;AAE1C,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,43 @@
1
- import { inspect } from "util";
2
- import { glob } from "fast-glob";
3
- import fs from "fs-extra";
4
- import { log } from "../../../../../../utils/logging.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 removeYarnIgnoreOptionalFlags_exports = {};
30
+ __export(removeYarnIgnoreOptionalFlags_exports, {
31
+ tryRemoveYarnIgnoreOptionalFlags: () => tryRemoveYarnIgnoreOptionalFlags
32
+ });
33
+ module.exports = __toCommonJS(removeYarnIgnoreOptionalFlags_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_logging = require("../../../../../../utils/logging.js");
5
38
  const fetchFiles = async (files) => Promise.all(
6
39
  files.map(async (file) => {
7
- const contents = await fs.promises.readFile(file, "utf8");
40
+ const contents = await import_fs_extra.default.promises.readFile(file, "utf8");
8
41
  return {
9
42
  file,
10
43
  contents
@@ -43,7 +76,7 @@ const removeYarnIgnoreFlag = (contents) => {
43
76
  const removeYarnIgnoreOptionalFlags = async ({
44
77
  mode
45
78
  }) => {
46
- const maybeDockerFilesPaths = await glob(["Dockerfile*"]);
79
+ const maybeDockerFilesPaths = await (0, import_fast_glob.glob)(["Dockerfile*"]);
47
80
  if (!maybeDockerFilesPaths.length) {
48
81
  return {
49
82
  result: "skip",
@@ -69,7 +102,7 @@ const removeYarnIgnoreOptionalFlags = async ({
69
102
  }
70
103
  await Promise.all(
71
104
  mapped.map(async ({ file, after }) => {
72
- await fs.promises.writeFile(file, after);
105
+ await import_fs_extra.default.promises.writeFile(file, after);
73
106
  })
74
107
  );
75
108
  return { result: "apply" };
@@ -78,12 +111,13 @@ const tryRemoveYarnIgnoreOptionalFlags = async (config) => {
78
111
  try {
79
112
  return await removeYarnIgnoreOptionalFlags(config);
80
113
  } catch (err) {
81
- log.warn("Failed to remove yarn --ignore-optional flags");
82
- log.subtle(inspect(err));
114
+ import_logging.log.warn("Failed to remove yarn --ignore-optional flags");
115
+ import_logging.log.subtle((0, import_util.inspect)(err));
83
116
  return { result: "skip", reason: "due to an error" };
84
117
  }
85
118
  };
86
- export {
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
87
121
  tryRemoveYarnIgnoreOptionalFlags
88
- };
122
+ });
89
123
  //# sourceMappingURL=removeYarnIgnoreOptionalFlags.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.ts"],
4
4
  "sourcesContent": ["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport { 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\nconst regex = /\\s*--ignore-optional/;\n\nconst removeYarnIgnoreFlag = (contents: string) => {\n let isInYarn = false;\n\n const lines = contents.split('\\n');\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!;\n\n if (line.includes('yarn')) {\n isInYarn = true;\n }\n\n if (isInYarn && regex.test(line)) {\n lines[i] = line.replace(regex, '');\n\n // If we're now an empty line, remove it and get rid of the \\ at the end of the previous line\n if (!lines[i]!.trim()) {\n lines.splice(i, 1);\n if (i > 0) {\n lines[i - 1] = lines[i - 1]!.replace(/\\s*\\\\$/, '');\n }\n i--;\n } else if (lines[i] === '\\\\') {\n lines.splice(i, 1);\n i--;\n }\n\n isInYarn = false;\n }\n\n if (!line.endsWith('\\\\')) {\n isInYarn = false;\n }\n }\n\n return lines.join('\\n');\n};\n\nconst removeYarnIgnoreOptionalFlags: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n const maybeDockerFilesPaths = await glob(['Dockerfile*']);\n\n if (!maybeDockerFilesPaths.length) {\n return {\n result: 'skip',\n reason: 'no Dockerfiles found',\n };\n }\n\n const dockerFiles = await fetchFiles(maybeDockerFilesPaths);\n\n const mapped = dockerFiles.map(({ file, contents }) => ({\n file,\n before: contents,\n after: removeYarnIgnoreFlag(contents),\n }));\n\n if (!mapped.some(({ before, after }) => before !== after)) {\n return {\n result: 'skip',\n reason: 'no Dockerfiles to patch',\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 tryRemoveYarnIgnoreOptionalFlags: PatchFunction = async (\n config,\n) => {\n try {\n return await removeYarnIgnoreOptionalFlags(config);\n } catch (err) {\n log.warn('Failed to remove yarn --ignore-optional flags');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
5
- "mappings": "AACA,SAAS,eAAe;AAExB,SAAS,YAAY;AACrB,OAAO,QAAQ;AAEf,SAAS,WAAW;AAGpB,MAAM,aAAa,OAAO,UACxB,QAAQ;AAAA,EACN,MAAM,IAAI,OAAO,SAAS;AACxB,UAAM,WAAW,MAAM,GAAG,SAAS,SAAS,MAAM,MAAM;AAExD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEF,MAAM,QAAQ;AAEd,MAAM,uBAAuB,CAAC,aAAqB;AACjD,MAAI,WAAW;AAEf,QAAM,QAAQ,SAAS,MAAM,IAAI;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,OAAO,MAAM,CAAC;AAEpB,QAAI,KAAK,SAAS,MAAM,GAAG;AACzB,iBAAW;AAAA,IACb;AAEA,QAAI,YAAY,MAAM,KAAK,IAAI,GAAG;AAChC,YAAM,CAAC,IAAI,KAAK,QAAQ,OAAO,EAAE;AAGjC,UAAI,CAAC,MAAM,CAAC,EAAG,KAAK,GAAG;AACrB,cAAM,OAAO,GAAG,CAAC;AACjB,YAAI,IAAI,GAAG;AACT,gBAAM,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,EAAG,QAAQ,UAAU,EAAE;AAAA,QACnD;AACA;AAAA,MACF,WAAW,MAAM,CAAC,MAAM,MAAM;AAC5B,cAAM,OAAO,GAAG,CAAC;AACjB;AAAA,MACF;AAEA,iBAAW;AAAA,IACb;AAEA,QAAI,CAAC,KAAK,SAAS,IAAI,GAAG;AACxB,iBAAW;AAAA,IACb;AAAA,EACF;AAEA,SAAO,MAAM,KAAK,IAAI;AACxB;AAEA,MAAM,gCAA+C,OAAO;AAAA,EAC1D;AACF,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EACtC,EAAE;AAEF,MAAI,CAAC,OAAO,KAAK,CAAC,EAAE,QAAQ,MAAM,MAAM,WAAW,KAAK,GAAG;AACzD,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO;AAAA,MACL,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,OAAO,IAAI,OAAO,EAAE,MAAM,MAAM,MAAM;AACpC,YAAM,gBAAAA,QAAG,SAAS,UAAU,MAAM,KAAK;AAAA,IACzC,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,mCAAkD,OAC7D,WACG;AACH,MAAI;AACF,WAAO,MAAM,8BAA8B,MAAM;AAAA,EACnD,SAAS,KAAK;AACZ,uBAAI,KAAK,+CAA+C;AACxD,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs"]
7
7
  }
@@ -1,16 +1,40 @@
1
- import { tryMigrateNpmrcToPnpmWorkspace } from "./migrateNpmrcToPnpmWorkspace.js";
2
- import { tryStopBundlingInCDKTests } from "./stopBundlingInCDKTests.js";
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_migrateNpmrcToPnpmWorkspace = require("./migrateNpmrcToPnpmWorkspace.js");
25
+ var import_stopBundlingInCDKTests = require("./stopBundlingInCDKTests.js");
3
26
  const patches = [
4
27
  {
5
- apply: tryStopBundlingInCDKTests,
28
+ apply: import_stopBundlingInCDKTests.tryStopBundlingInCDKTests,
6
29
  description: "Stop bundling inside CDK unit tests"
7
30
  },
8
31
  {
9
- apply: tryMigrateNpmrcToPnpmWorkspace,
32
+ apply: import_migrateNpmrcToPnpmWorkspace.tryMigrateNpmrcToPnpmWorkspace,
10
33
  description: "Move .npmrc config to pnpm-workspace.yaml"
11
34
  }
12
35
  ];
13
- export {
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
14
38
  patches
15
- };
39
+ });
16
40
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/10.1.0/index.ts"],
4
4
  "sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { tryMigrateNpmrcToPnpmWorkspace } from './migrateNpmrcToPnpmWorkspace.js';\nimport { tryStopBundlingInCDKTests } from './stopBundlingInCDKTests.js';\n\nexport const patches: Patches = [\n {\n apply: tryStopBundlingInCDKTests,\n description: 'Stop bundling inside CDK unit tests',\n },\n {\n apply: tryMigrateNpmrcToPnpmWorkspace,\n description: 'Move .npmrc config to pnpm-workspace.yaml',\n },\n];\n"],
5
- "mappings": "AAEA,SAAS,sCAAsC;AAC/C,SAAS,iCAAiC;AAEnC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yCAA+C;AAC/C,oCAA0C;AAEnC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
6
6
  "names": []
7
7
  }