skuba 13.0.0-subpath-imports-20250730060533 → 13.0.0-subpath-imports-20251003052152

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 (266) hide show
  1. package/README.md +1 -2
  2. package/config/tsconfig.json +2 -1
  3. package/jest/moduleNameMapper.js +3 -11
  4. package/lib/cli/build/assets.js +4 -8
  5. package/lib/cli/build/assets.js.map +2 -2
  6. package/lib/cli/build/esbuild.d.ts +2 -1
  7. package/lib/cli/build/esbuild.js +5 -4
  8. package/lib/cli/build/esbuild.js.map +2 -2
  9. package/lib/cli/build/index.js +9 -5
  10. package/lib/cli/build/index.js.map +2 -2
  11. package/lib/cli/build/tsc.d.ts +9 -2
  12. package/lib/cli/build/tsc.js +76 -40
  13. package/lib/cli/build/tsc.js.map +3 -3
  14. package/lib/cli/configure/analyseDependencies.d.ts +2 -2
  15. package/lib/cli/configure/analyseDependencies.js.map +1 -1
  16. package/lib/cli/configure/analysis/package.d.ts +1 -1
  17. package/lib/cli/configure/analysis/package.js +1 -1
  18. package/lib/cli/configure/analysis/package.js.map +2 -2
  19. package/lib/cli/configure/ensureTemplateCompletion.d.ts +2 -2
  20. package/lib/cli/configure/ensureTemplateCompletion.js.map +1 -1
  21. package/lib/cli/configure/getEntryPoint.d.ts +2 -2
  22. package/lib/cli/configure/getEntryPoint.js.map +1 -1
  23. package/lib/cli/configure/getProjectType.d.ts +2 -2
  24. package/lib/cli/configure/getProjectType.js.map +1 -1
  25. package/lib/cli/configure/processing/configFile.d.ts +1 -1
  26. package/lib/cli/configure/processing/configFile.js +48 -6
  27. package/lib/cli/configure/processing/configFile.js.map +2 -2
  28. package/lib/cli/configure/processing/package.js +8 -2
  29. package/lib/cli/configure/processing/package.js.map +2 -2
  30. package/lib/cli/init/getConfig.js +1 -1
  31. package/lib/cli/init/getConfig.js.map +2 -2
  32. package/lib/cli/init/git.js +1 -1
  33. package/lib/cli/init/git.js.map +2 -2
  34. package/lib/cli/init/index.js +4 -4
  35. package/lib/cli/init/index.js.map +3 -3
  36. package/lib/cli/lint/annotate/buildkite/eslint.js +1 -1
  37. package/lib/cli/lint/annotate/buildkite/eslint.js.map +2 -2
  38. package/lib/cli/lint/annotate/buildkite/index.js +1 -1
  39. package/lib/cli/lint/annotate/buildkite/index.js.map +2 -2
  40. package/lib/cli/lint/annotate/buildkite/internal.js +1 -1
  41. package/lib/cli/lint/annotate/buildkite/internal.js.map +2 -2
  42. package/lib/cli/lint/annotate/buildkite/prettier.js +1 -1
  43. package/lib/cli/lint/annotate/buildkite/prettier.js.map +2 -2
  44. package/lib/cli/lint/annotate/buildkite/tsc.js +1 -1
  45. package/lib/cli/lint/annotate/buildkite/tsc.js.map +2 -2
  46. package/lib/cli/lint/annotate/github/eslint.d.ts +1 -1
  47. package/lib/cli/lint/annotate/github/eslint.js.map +2 -2
  48. package/lib/cli/lint/annotate/github/index.js +3 -4
  49. package/lib/cli/lint/annotate/github/index.js.map +2 -2
  50. package/lib/cli/lint/annotate/github/internal.d.ts +1 -1
  51. package/lib/cli/lint/annotate/github/internal.js.map +2 -2
  52. package/lib/cli/lint/annotate/github/prettier.d.ts +1 -1
  53. package/lib/cli/lint/annotate/github/prettier.js.map +2 -2
  54. package/lib/cli/lint/annotate/github/tsc.d.ts +1 -1
  55. package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
  56. package/lib/cli/lint/autofix.d.ts +1 -1
  57. package/lib/cli/lint/autofix.js +3 -3
  58. package/lib/cli/lint/autofix.js.map +2 -2
  59. package/lib/cli/lint/internal.js +1 -1
  60. package/lib/cli/lint/internal.js.map +2 -2
  61. package/lib/cli/lint/internalLints/patchRenovateConfig.js +3 -3
  62. package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
  63. package/lib/cli/lint/internalLints/refreshConfigFiles.js +5 -3
  64. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
  65. package/lib/cli/lint/internalLints/upgrade/index.d.ts +2 -2
  66. package/lib/cli/lint/internalLints/upgrade/index.js.map +1 -1
  67. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +3 -3
  68. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +2 -2
  69. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.d.ts +4 -0
  70. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +162 -0
  71. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +7 -0
  72. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.d.ts +2 -0
  73. package/lib/{api/buildkite → cli/lint/internalLints/upgrade/patches/12.1.1}/index.js +12 -9
  74. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +7 -0
  75. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.d.ts +3 -0
  76. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +105 -0
  77. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +7 -0
  78. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.d.ts +2 -0
  79. package/lib/{api/git/statusMatrix.js → cli/lint/internalLints/upgrade/patches/12.3.0/index.js} +18 -25
  80. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js.map +7 -0
  81. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.d.ts +3 -0
  82. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js +100 -0
  83. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +7 -0
  84. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.d.ts +3 -0
  85. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +99 -0
  86. package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +7 -0
  87. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.d.ts +2 -0
  88. package/lib/{api/buildkite/md.js → cli/lint/internalLints/upgrade/patches/12.4.0/index.js} +13 -11
  89. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js.map +7 -0
  90. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.d.ts +3 -0
  91. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js +101 -0
  92. package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +7 -0
  93. package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/index.d.ts +2 -0
  94. package/lib/{api/net → cli/lint/internalLints/upgrade/patches/13.0.0}/index.js +12 -6
  95. package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/index.js.map +7 -0
  96. package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/rewriteSrcImports.d.ts +13 -0
  97. package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/rewriteSrcImports.js +221 -0
  98. package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/rewriteSrcImports.js.map +7 -0
  99. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +1 -1
  100. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +2 -2
  101. package/lib/cli/node/index.js +6 -0
  102. package/lib/cli/node/index.js.map +2 -2
  103. package/lib/cli/start/index.js +6 -0
  104. package/lib/cli/start/index.js.map +2 -2
  105. package/lib/cli/test/index.d.ts +1 -1
  106. package/lib/cli/test/index.js +18 -4
  107. package/lib/cli/test/index.js.map +2 -2
  108. package/lib/cli/test/reporters/github/annotations.d.ts +1 -1
  109. package/lib/cli/test/reporters/github/annotations.js.map +1 -1
  110. package/lib/cli/test/reporters/github/index.js +3 -4
  111. package/lib/cli/test/reporters/github/index.js.map +2 -2
  112. package/lib/index.d.ts +4 -4
  113. package/lib/index.js +4 -4
  114. package/lib/index.js.map +2 -2
  115. package/lib/utils/args.d.ts +2 -0
  116. package/lib/utils/args.js +5 -0
  117. package/lib/utils/args.js.map +2 -2
  118. package/lib/utils/dir.js +2 -2
  119. package/lib/utils/dir.js.map +3 -3
  120. package/lib/utils/manifest.d.ts +6 -2
  121. package/lib/utils/manifest.js +17 -8
  122. package/lib/utils/manifest.js.map +2 -2
  123. package/lib/utils/template.d.ts +1 -1
  124. package/package.json +19 -21
  125. package/template/base/_.prettierrc.js +1 -1
  126. package/template/base/_eslint.config.js +1 -1
  127. package/template/base/_pnpm-workspace.yaml +11 -0
  128. package/template/base/jest.config.ts +4 -0
  129. package/template/base/jest.setup.ts +1 -1
  130. package/template/express-rest-api/.buildkite/pipeline.yml +6 -0
  131. package/template/express-rest-api/.env +1 -1
  132. package/template/express-rest-api/.gantry/dev.yml +5 -1
  133. package/template/express-rest-api/.gantry/prod.yml +5 -1
  134. package/template/express-rest-api/Dockerfile +2 -2
  135. package/template/express-rest-api/Dockerfile.dev-deps +0 -2
  136. package/template/express-rest-api/README.md +5 -5
  137. package/template/express-rest-api/gantry.apply.yml +17 -1
  138. package/template/express-rest-api/package.json +11 -5
  139. package/template/express-rest-api/src/api/healthCheck.ts +2 -2
  140. package/template/express-rest-api/src/config.ts +7 -7
  141. package/template/express-rest-api/src/framework/logging.ts +11 -7
  142. package/template/express-rest-api/src/framework/metrics.ts +1 -1
  143. package/template/express-rest-api/src/listen.ts +6 -0
  144. package/template/express-rest-api/src/tracing.ts +56 -0
  145. package/template/greeter/Dockerfile +0 -2
  146. package/template/greeter/README.md +2 -2
  147. package/template/greeter/package.json +2 -2
  148. package/template/koa-rest-api/.buildkite/pipeline.yml +6 -0
  149. package/template/koa-rest-api/.env +1 -1
  150. package/template/koa-rest-api/.gantry/dev.yml +3 -3
  151. package/template/koa-rest-api/.gantry/prod.yml +3 -3
  152. package/template/koa-rest-api/Dockerfile +1 -1
  153. package/template/koa-rest-api/Dockerfile.dev-deps +0 -2
  154. package/template/koa-rest-api/README.md +6 -6
  155. package/template/koa-rest-api/gantry.apply.yml +15 -3
  156. package/template/koa-rest-api/package.json +10 -11
  157. package/template/koa-rest-api/src/api/healthCheck.ts +2 -2
  158. package/template/koa-rest-api/src/config.ts +7 -7
  159. package/template/koa-rest-api/src/framework/logging.ts +12 -8
  160. package/template/koa-rest-api/src/framework/metrics.ts +1 -1
  161. package/template/koa-rest-api/src/framework/server.test.ts +7 -8
  162. package/template/koa-rest-api/src/framework/server.ts +1 -4
  163. package/template/koa-rest-api/src/listen.ts +6 -0
  164. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +6 -2
  165. package/template/lambda-sqs-worker-cdk/.env +1 -1
  166. package/template/lambda-sqs-worker-cdk/Dockerfile +0 -2
  167. package/template/lambda-sqs-worker-cdk/README.md +8 -8
  168. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +54 -26
  169. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +5 -22
  170. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +16 -9
  171. package/template/lambda-sqs-worker-cdk/infra/config.ts +34 -20
  172. package/template/lambda-sqs-worker-cdk/infra/index.ts +1 -1
  173. package/template/lambda-sqs-worker-cdk/package.json +7 -9
  174. package/template/lambda-sqs-worker-cdk/src/app.test.ts +91 -51
  175. package/template/lambda-sqs-worker-cdk/src/app.ts +10 -9
  176. package/template/lambda-sqs-worker-cdk/src/config.ts +11 -16
  177. package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +10 -5
  178. package/template/lambda-sqs-worker-cdk/src/framework/handler.ts +48 -24
  179. package/template/lambda-sqs-worker-cdk/src/framework/logging.ts +23 -11
  180. package/template/lambda-sqs-worker-cdk/src/framework/metrics.ts +1 -4
  181. package/template/lambda-sqs-worker-cdk/src/testing/handler.ts +4 -1
  182. package/template/oss-npm-package/.github/workflows/release.yml +7 -8
  183. package/template/oss-npm-package/.github/workflows/validate.yml +6 -6
  184. package/template/oss-npm-package/README.md +1 -1
  185. package/template/oss-npm-package/_package.json +0 -3
  186. package/template/oss-npm-package/skuba.template.js +1 -1
  187. package/lib/api/buildkite/annotate.d.ts +0 -28
  188. package/lib/api/buildkite/annotate.js +0 -62
  189. package/lib/api/buildkite/annotate.js.map +0 -7
  190. package/lib/api/buildkite/index.d.ts +0 -3
  191. package/lib/api/buildkite/index.js.map +0 -7
  192. package/lib/api/buildkite/md.d.ts +0 -6
  193. package/lib/api/buildkite/md.js.map +0 -7
  194. package/lib/api/git/commit.d.ts +0 -15
  195. package/lib/api/git/commit.js +0 -52
  196. package/lib/api/git/commit.js.map +0 -7
  197. package/lib/api/git/commitAllChanges.d.ts +0 -19
  198. package/lib/api/git/commitAllChanges.js +0 -83
  199. package/lib/api/git/commitAllChanges.js.map +0 -7
  200. package/lib/api/git/currentBranch.d.ts +0 -10
  201. package/lib/api/git/currentBranch.js +0 -59
  202. package/lib/api/git/currentBranch.js.map +0 -7
  203. package/lib/api/git/findRoot.d.ts +0 -9
  204. package/lib/api/git/findRoot.js +0 -52
  205. package/lib/api/git/findRoot.js.map +0 -7
  206. package/lib/api/git/getChangedFiles.d.ts +0 -20
  207. package/lib/api/git/getChangedFiles.js +0 -81
  208. package/lib/api/git/getChangedFiles.js.map +0 -7
  209. package/lib/api/git/index.d.ts +0 -12
  210. package/lib/api/git/index.js +0 -61
  211. package/lib/api/git/index.js.map +0 -7
  212. package/lib/api/git/isFileGitIgnored.d.ts +0 -4
  213. package/lib/api/git/isFileGitIgnored.js +0 -49
  214. package/lib/api/git/isFileGitIgnored.js.map +0 -7
  215. package/lib/api/git/log.d.ts +0 -19
  216. package/lib/api/git/log.js +0 -71
  217. package/lib/api/git/log.js.map +0 -7
  218. package/lib/api/git/pull.d.ts +0 -35
  219. package/lib/api/git/pull.js +0 -69
  220. package/lib/api/git/pull.js.map +0 -7
  221. package/lib/api/git/push.d.ts +0 -52
  222. package/lib/api/git/push.js +0 -70
  223. package/lib/api/git/push.js.map +0 -7
  224. package/lib/api/git/remote.d.ts +0 -20
  225. package/lib/api/git/remote.js +0 -73
  226. package/lib/api/git/remote.js.map +0 -7
  227. package/lib/api/git/reset.d.ts +0 -12
  228. package/lib/api/git/reset.js +0 -62
  229. package/lib/api/git/reset.js.map +0 -7
  230. package/lib/api/git/statusMatrix.d.ts +0 -7
  231. package/lib/api/git/statusMatrix.js.map +0 -7
  232. package/lib/api/github/checkRun.d.ts +0 -44
  233. package/lib/api/github/checkRun.js +0 -81
  234. package/lib/api/github/checkRun.js.map +0 -7
  235. package/lib/api/github/environment.d.ts +0 -17
  236. package/lib/api/github/environment.js +0 -48
  237. package/lib/api/github/environment.js.map +0 -7
  238. package/lib/api/github/index.d.ts +0 -7
  239. package/lib/api/github/index.js +0 -48
  240. package/lib/api/github/index.js.map +0 -7
  241. package/lib/api/github/issueComment.d.ts +0 -61
  242. package/lib/api/github/issueComment.js +0 -99
  243. package/lib/api/github/issueComment.js.map +0 -7
  244. package/lib/api/github/octokit.d.ts +0 -6
  245. package/lib/api/github/octokit.js +0 -42
  246. package/lib/api/github/octokit.js.map +0 -7
  247. package/lib/api/github/pullRequest.d.ts +0 -21
  248. package/lib/api/github/pullRequest.js +0 -69
  249. package/lib/api/github/pullRequest.js.map +0 -7
  250. package/lib/api/github/push.d.ts +0 -85
  251. package/lib/api/github/push.js +0 -166
  252. package/lib/api/github/push.js.map +0 -7
  253. package/lib/api/net/compose.d.ts +0 -4
  254. package/lib/api/net/compose.js +0 -51
  255. package/lib/api/net/compose.js.map +0 -7
  256. package/lib/api/net/index.d.ts +0 -1
  257. package/lib/api/net/index.js.map +0 -7
  258. package/lib/api/net/socket.d.ts +0 -5
  259. package/lib/api/net/socket.js +0 -68
  260. package/lib/api/net/socket.js.map +0 -7
  261. package/lib/api/net/waitFor.d.ts +0 -22
  262. package/lib/api/net/waitFor.js +0 -40
  263. package/lib/api/net/waitFor.js.map +0 -7
  264. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/rewriteSrcImports.d.ts +0 -6
  265. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/rewriteSrcImports.js +0 -104
  266. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/rewriteSrcImports.js.map +0 -7
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var unhandledRejections_exports = {};
30
+ __export(unhandledRejections_exports, {
31
+ IMPORT_REGEX: () => IMPORT_REGEX,
32
+ NAMED_EXPORT_REGEX: () => NAMED_EXPORT_REGEX,
33
+ tryPatchUnhandledRejections: () => tryPatchUnhandledRejections
34
+ });
35
+ module.exports = __toCommonJS(unhandledRejections_exports);
36
+ var import_path = __toESM(require("path"));
37
+ var import_util = require("util");
38
+ var import_fast_glob = require("fast-glob");
39
+ var import_fs_extra = __toESM(require("fs-extra"));
40
+ var import_error = require("../../../../../../utils/error.js");
41
+ var import_logging = require("../../../../../../utils/logging.js");
42
+ var import_prettier = require("../../../../../configure/processing/prettier.js");
43
+ const addListener = (identifier) => `
44
+ // Report unhandled rejections instead of crashing the process
45
+ // Make sure to monitor these reports and alert as appropriate
46
+ process.on('unhandledRejection', (err) =>
47
+ ${identifier}.error(err, 'Unhandled promise rejection'),
48
+ );
49
+ `.trim();
50
+ const tryReadFilesSequentially = async (filepaths) => {
51
+ for (const filepath of filepaths) {
52
+ try {
53
+ const contents = await import_fs_extra.default.promises.readFile(filepath, "utf8");
54
+ return { contents, filepath };
55
+ } catch (err) {
56
+ if ((0, import_error.isErrorWithCode)(err, "ENOENT")) {
57
+ continue;
58
+ }
59
+ throw err;
60
+ }
61
+ }
62
+ return;
63
+ };
64
+ const IMPORT_REGEX = /import\s+(?:\{\s*(\w*[Ll]ogger)(?:\s+as\s+(\w*[Ll]ogger))?\s*\}|(\w*[Ll]ogger))\s+from\s+['"][^'"]+\/(?:logger|logging)(?:\/index)?(?:\.[jt]s)?['"]/u;
65
+ const NAMED_EXPORT_REGEX = /export\s+(?:const\s+|\{[^{}]*)\b(\w*[Ll]ogger)\b/u;
66
+ const findLogger = async ({
67
+ contents,
68
+ root
69
+ }) => {
70
+ const importResult = IMPORT_REGEX.exec(contents);
71
+ {
72
+ const identifier = importResult?.[3] ?? importResult?.[2] ?? importResult?.[1];
73
+ if (identifier) {
74
+ return { identifier };
75
+ }
76
+ }
77
+ const loggerPaths = await (0, import_fast_glob.glob)("**/{logger,logging}.ts", {
78
+ cwd: root,
79
+ ignore: ["**/.git", "**/node_modules"]
80
+ });
81
+ const loggingModule = await tryReadFilesSequentially(loggerPaths);
82
+ if (!loggingModule) {
83
+ return { identifier: "console" };
84
+ }
85
+ const parsedPath = import_path.default.parse(import_path.default.relative(root, loggingModule.filepath));
86
+ const importPath = import_path.default.join(parsedPath.dir, parsedPath.name);
87
+ const namedExportResult = NAMED_EXPORT_REGEX.exec(loggingModule.contents);
88
+ if (namedExportResult?.[1]) {
89
+ const identifier = namedExportResult[1];
90
+ return {
91
+ identifier: namedExportResult[1],
92
+ import: `import { ${identifier} } from '${importPath}';`
93
+ };
94
+ }
95
+ if (loggingModule.contents.includes("export default")) {
96
+ return {
97
+ identifier: "logger",
98
+ import: `import logger from '${importPath}';`
99
+ };
100
+ }
101
+ return { identifier: "console" };
102
+ };
103
+ const patchUnhandledRejections = async (mode) => {
104
+ const filepaths = await (0, import_fast_glob.glob)("**/src/listen.ts", {
105
+ ignore: ["**/.git", "**/node_modules"]
106
+ });
107
+ let hasPatched = false;
108
+ for (const filepath of filepaths) {
109
+ const contents = await import_fs_extra.default.promises.readFile(filepath, "utf8");
110
+ if (contents.includes("unhandledRejection")) {
111
+ import_logging.log.subtle(
112
+ "Skipping entry point that appears to have an unhandled rejection listener:",
113
+ filepath
114
+ );
115
+ continue;
116
+ }
117
+ const root = import_path.default.dirname(import_path.default.dirname(filepath));
118
+ const logger = await findLogger({ contents, root });
119
+ import_logging.log.subtle(
120
+ "Logging unhandled rejections to",
121
+ logger.identifier,
122
+ "in file:",
123
+ filepath
124
+ );
125
+ const patched = [
126
+ contents,
127
+ ...[logger.import ? [logger.import] : []],
128
+ addListener(logger.identifier)
129
+ ].join("\n\n");
130
+ const newContents = await (0, import_prettier.formatPrettier)(patched, { parser: "typescript" });
131
+ if (mode === "lint") {
132
+ return { result: "apply" };
133
+ }
134
+ await import_fs_extra.default.promises.writeFile(filepath, newContents);
135
+ hasPatched = true;
136
+ }
137
+ if (hasPatched) {
138
+ return { result: "apply" };
139
+ }
140
+ return {
141
+ result: "skip",
142
+ reason: "no applicable src/listen.ts entry points found"
143
+ };
144
+ };
145
+ const tryPatchUnhandledRejections = async ({
146
+ mode
147
+ }) => {
148
+ try {
149
+ return await patchUnhandledRejections(mode);
150
+ } catch (err) {
151
+ import_logging.log.warn("Failed to patch listeners for unhandled promise rejections");
152
+ import_logging.log.subtle((0, import_util.inspect)(err));
153
+ return { result: "skip", reason: "due to an error" };
154
+ }
155
+ };
156
+ // Annotate the CommonJS export names for ESM import in node:
157
+ 0 && (module.exports = {
158
+ IMPORT_REGEX,
159
+ NAMED_EXPORT_REGEX,
160
+ tryPatchUnhandledRejections
161
+ });
162
+ //# sourceMappingURL=unhandledRejections.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.ts"],
4
+ "sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { isErrorWithCode } from '../../../../../../utils/error.js';\nimport { log } from '../../../../../../utils/logging.js';\nimport { formatPrettier } from '../../../../../configure/processing/prettier.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst addListener = (identifier: string) =>\n `\n// Report unhandled rejections instead of crashing the process\n// Make sure to monitor these reports and alert as appropriate\nprocess.on('unhandledRejection', (err) =>\n ${identifier}.error(err, 'Unhandled promise rejection'),\n);\n`.trim();\n\nconst tryReadFilesSequentially = async (\n filepaths: string[],\n): Promise<{ contents: string; filepath: string } | undefined> => {\n for (const filepath of filepaths) {\n try {\n const contents = await fs.promises.readFile(filepath, 'utf8');\n\n return { contents, filepath };\n } catch (err) {\n if (isErrorWithCode(err, 'ENOENT')) {\n continue;\n }\n\n throw err;\n }\n }\n\n return;\n};\n\nexport const IMPORT_REGEX =\n /import\\s+(?:\\{\\s*(\\w*[Ll]ogger)(?:\\s+as\\s+(\\w*[Ll]ogger))?\\s*\\}|(\\w*[Ll]ogger))\\s+from\\s+['\"][^'\"]+\\/(?:logger|logging)(?:\\/index)?(?:\\.[jt]s)?['\"]/u;\n\nexport const NAMED_EXPORT_REGEX =\n /export\\s+(?:const\\s+|\\{[^{}]*)\\b(\\w*[Ll]ogger)\\b/u;\n\nconst findLogger = async ({\n contents,\n root,\n}: {\n contents: string;\n root: string;\n}): Promise<{ identifier: string; import?: string }> => {\n const importResult = IMPORT_REGEX.exec(contents);\n\n {\n const identifier =\n importResult?.[3] ?? importResult?.[2] ?? importResult?.[1];\n\n if (identifier) {\n return { identifier };\n }\n }\n\n const loggerPaths = await glob('**/{logger,logging}.ts', {\n cwd: root,\n ignore: ['**/.git', '**/node_modules'],\n });\n\n const loggingModule = await tryReadFilesSequentially(loggerPaths);\n\n if (!loggingModule) {\n return { identifier: 'console' };\n }\n\n const parsedPath = path.parse(path.relative(root, loggingModule.filepath));\n\n const importPath = path.join(parsedPath.dir, parsedPath.name);\n\n const namedExportResult = NAMED_EXPORT_REGEX.exec(loggingModule.contents);\n\n if (namedExportResult?.[1]) {\n const identifier = namedExportResult[1];\n\n return {\n identifier: namedExportResult[1],\n import: `import { ${identifier} } from '${importPath}';`,\n };\n }\n\n if (loggingModule.contents.includes('export default')) {\n return {\n identifier: 'logger',\n import: `import logger from '${importPath}';`,\n };\n }\n\n return { identifier: 'console' };\n};\n\nconst patchUnhandledRejections = async (\n mode: 'format' | 'lint',\n): Promise<PatchReturnType> => {\n const filepaths = await glob('**/src/listen.ts', {\n ignore: ['**/.git', '**/node_modules'],\n });\n\n let hasPatched = false;\n\n for (const filepath of filepaths) {\n const contents = await fs.promises.readFile(filepath, 'utf8');\n\n if (contents.includes('unhandledRejection')) {\n log.subtle(\n 'Skipping entry point that appears to have an unhandled rejection listener:',\n filepath,\n );\n continue;\n }\n\n const root = path.dirname(path.dirname(filepath));\n\n const logger = await findLogger({ contents, root });\n\n log.subtle(\n 'Logging unhandled rejections to',\n logger.identifier,\n 'in file:',\n filepath,\n );\n\n const patched = [\n contents,\n\n ...[logger.import ? [logger.import] : []],\n\n addListener(logger.identifier),\n ].join('\\n\\n');\n\n const newContents = await formatPrettier(patched, { parser: 'typescript' });\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n await fs.promises.writeFile(filepath, newContents);\n\n hasPatched = true;\n }\n\n if (hasPatched) {\n return { result: 'apply' };\n }\n\n return {\n result: 'skip',\n reason: 'no applicable src/listen.ts entry points found',\n };\n};\n\nexport const tryPatchUnhandledRejections: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n try {\n return await patchUnhandledRejections(mode);\n } catch (err) {\n log.warn('Failed to patch listeners for unhandled promise rejections');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,mBAAgC;AAChC,qBAAoB;AACpB,sBAA+B;AAG/B,MAAM,cAAc,CAAC,eACnB;AAAA;AAAA;AAAA;AAAA,IAIE,UAAU;AAAA;AAAA,EAEZ,KAAK;AAEP,MAAM,2BAA2B,OAC/B,cACgE;AAChE,aAAW,YAAY,WAAW;AAChC,QAAI;AACF,YAAM,WAAW,MAAM,gBAAAA,QAAG,SAAS,SAAS,UAAU,MAAM;AAE5D,aAAO,EAAE,UAAU,SAAS;AAAA,IAC9B,SAAS,KAAK;AACZ,cAAI,8BAAgB,KAAK,QAAQ,GAAG;AAClC;AAAA,MACF;AAEA,YAAM;AAAA,IACR;AAAA,EACF;AAEA;AACF;AAEO,MAAM,eACX;AAEK,MAAM,qBACX;AAEF,MAAM,aAAa,OAAO;AAAA,EACxB;AAAA,EACA;AACF,MAGwD;AACtD,QAAM,eAAe,aAAa,KAAK,QAAQ;AAE/C;AACE,UAAM,aACJ,eAAe,CAAC,KAAK,eAAe,CAAC,KAAK,eAAe,CAAC;AAE5D,QAAI,YAAY;AACd,aAAO,EAAE,WAAW;AAAA,IACtB;AAAA,EACF;AAEA,QAAM,cAAc,UAAM,uBAAK,0BAA0B;AAAA,IACvD,KAAK;AAAA,IACL,QAAQ,CAAC,WAAW,iBAAiB;AAAA,EACvC,CAAC;AAED,QAAM,gBAAgB,MAAM,yBAAyB,WAAW;AAEhE,MAAI,CAAC,eAAe;AAClB,WAAO,EAAE,YAAY,UAAU;AAAA,EACjC;AAEA,QAAM,aAAa,YAAAC,QAAK,MAAM,YAAAA,QAAK,SAAS,MAAM,cAAc,QAAQ,CAAC;AAEzE,QAAM,aAAa,YAAAA,QAAK,KAAK,WAAW,KAAK,WAAW,IAAI;AAE5D,QAAM,oBAAoB,mBAAmB,KAAK,cAAc,QAAQ;AAExE,MAAI,oBAAoB,CAAC,GAAG;AAC1B,UAAM,aAAa,kBAAkB,CAAC;AAEtC,WAAO;AAAA,MACL,YAAY,kBAAkB,CAAC;AAAA,MAC/B,QAAQ,YAAY,UAAU,YAAY,UAAU;AAAA,IACtD;AAAA,EACF;AAEA,MAAI,cAAc,SAAS,SAAS,gBAAgB,GAAG;AACrD,WAAO;AAAA,MACL,YAAY;AAAA,MACZ,QAAQ,uBAAuB,UAAU;AAAA,IAC3C;AAAA,EACF;AAEA,SAAO,EAAE,YAAY,UAAU;AACjC;AAEA,MAAM,2BAA2B,OAC/B,SAC6B;AAC7B,QAAM,YAAY,UAAM,uBAAK,oBAAoB;AAAA,IAC/C,QAAQ,CAAC,WAAW,iBAAiB;AAAA,EACvC,CAAC;AAED,MAAI,aAAa;AAEjB,aAAW,YAAY,WAAW;AAChC,UAAM,WAAW,MAAM,gBAAAD,QAAG,SAAS,SAAS,UAAU,MAAM;AAE5D,QAAI,SAAS,SAAS,oBAAoB,GAAG;AAC3C,yBAAI;AAAA,QACF;AAAA,QACA;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,OAAO,YAAAC,QAAK,QAAQ,YAAAA,QAAK,QAAQ,QAAQ,CAAC;AAEhD,UAAM,SAAS,MAAM,WAAW,EAAE,UAAU,KAAK,CAAC;AAElD,uBAAI;AAAA,MACF;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,IACF;AAEA,UAAM,UAAU;AAAA,MACd;AAAA,MAEA,GAAG,CAAC,OAAO,SAAS,CAAC,OAAO,MAAM,IAAI,CAAC,CAAC;AAAA,MAExC,YAAY,OAAO,UAAU;AAAA,IAC/B,EAAE,KAAK,MAAM;AAEb,UAAM,cAAc,UAAM,gCAAe,SAAS,EAAE,QAAQ,aAAa,CAAC;AAE1E,QAAI,SAAS,QAAQ;AACnB,aAAO,EAAE,QAAQ,QAAQ;AAAA,IAC3B;AAEA,UAAM,gBAAAD,QAAG,SAAS,UAAU,UAAU,WAAW;AAEjD,iBAAa;AAAA,EACf;AAEA,MAAI,YAAY;AACd,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,8BAA6C,OAAO;AAAA,EAC/D;AACF,MAAgC;AAC9B,MAAI;AACF,WAAO,MAAM,yBAAyB,IAAI;AAAA,EAC5C,SAAS,KAAK;AACZ,uBAAI,KAAK,4DAA4D;AACrE,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs", "path"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { Patches } from '../../index.js';
2
+ export declare const patches: Patches;
@@ -16,17 +16,20 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var buildkite_exports = {};
20
- __export(buildkite_exports, {
21
- annotate: () => import_annotate.annotate,
22
- md: () => import_md.md
19
+ var __exports = {};
20
+ __export(__exports, {
21
+ patches: () => patches
23
22
  });
24
- module.exports = __toCommonJS(buildkite_exports);
25
- var import_annotate = require("./annotate.js");
26
- var import_md = require("./md.js");
23
+ module.exports = __toCommonJS(__exports);
24
+ var import_patchJestSnapshots = require("./patchJestSnapshots.js");
25
+ const patches = [
26
+ {
27
+ apply: import_patchJestSnapshots.tryPatchJestSnapshots,
28
+ description: "Update Jest snapshot URLs to the new documentation site"
29
+ }
30
+ ];
27
31
  // Annotate the CommonJS export names for ESM import in node:
28
32
  0 && (module.exports = {
29
- annotate,
30
- md
33
+ patches
31
34
  });
32
35
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.1.1/index.ts"],
4
+ "sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { tryPatchJestSnapshots } from './patchJestSnapshots.js';\n\nexport const patches: Patches = [\n {\n apply: tryPatchJestSnapshots,\n description: 'Update Jest snapshot URLs to the new documentation site',\n },\n];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gCAAsC;AAE/B,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { PatchFunction, PatchReturnType } from '../../index.js';
2
+ export declare const patchJestSnapshots: (mode: "lint" | "format") => Promise<PatchReturnType>;
3
+ export declare const tryPatchJestSnapshots: PatchFunction;
@@ -0,0 +1,105 @@
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 patchJestSnapshots_exports = {};
30
+ __export(patchJestSnapshots_exports, {
31
+ patchJestSnapshots: () => patchJestSnapshots,
32
+ tryPatchJestSnapshots: () => tryPatchJestSnapshots
33
+ });
34
+ module.exports = __toCommonJS(patchJestSnapshots_exports);
35
+ var import_util = require("util");
36
+ var import_fast_glob = __toESM(require("fast-glob"));
37
+ var import_fs_extra = __toESM(require("fs-extra"));
38
+ var import_logging = require("../../../../../../utils/logging.js");
39
+ const JEST_SNAPSHOT_OLD_URL = "https://goo.gl/fbAQLP";
40
+ const JEST_SNAPSHOT_NEW_URL = "https://jestjs.io/docs/snapshot-testing";
41
+ const patchJestSnapshots = async (mode) => {
42
+ const testFilePaths = await (0, import_fast_glob.default)(["**/*.test.ts", "**/*.test.ts.snap"], {
43
+ ignore: [
44
+ "**/.git",
45
+ "**/node_modules",
46
+ "src/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.test.ts"
47
+ ]
48
+ });
49
+ if (testFilePaths.length === 0) {
50
+ return {
51
+ result: "skip",
52
+ reason: "no test files found"
53
+ };
54
+ }
55
+ const testsFiles = await Promise.all(
56
+ testFilePaths.map(async (file) => {
57
+ const contents = await import_fs_extra.default.readFile(file, "utf8");
58
+ return {
59
+ file,
60
+ contents
61
+ };
62
+ })
63
+ );
64
+ const testFilesToPatch = testsFiles.filter(
65
+ ({ contents }) => contents.includes(JEST_SNAPSHOT_OLD_URL)
66
+ );
67
+ if (testFilesToPatch.length === 0) {
68
+ return {
69
+ result: "skip",
70
+ reason: "no test files to patch"
71
+ };
72
+ }
73
+ if (mode === "lint") {
74
+ return {
75
+ result: "apply"
76
+ };
77
+ }
78
+ await Promise.all(
79
+ testFilesToPatch.map(async ({ file, contents }) => {
80
+ const updatedContents = contents.replaceAll(
81
+ JEST_SNAPSHOT_OLD_URL,
82
+ JEST_SNAPSHOT_NEW_URL
83
+ );
84
+ await import_fs_extra.default.writeFile(file, updatedContents, "utf8");
85
+ })
86
+ );
87
+ return {
88
+ result: "apply"
89
+ };
90
+ };
91
+ const tryPatchJestSnapshots = async ({ mode }) => {
92
+ try {
93
+ return await patchJestSnapshots(mode);
94
+ } catch (err) {
95
+ import_logging.log.warn("Failed to apply Jest snapshot URL patch.");
96
+ import_logging.log.subtle((0, import_util.inspect)(err));
97
+ return { result: "skip", reason: "due to an error" };
98
+ }
99
+ };
100
+ // Annotate the CommonJS export names for ESM import in node:
101
+ 0 && (module.exports = {
102
+ patchJestSnapshots,
103
+ tryPatchJestSnapshots
104
+ });
105
+ //# sourceMappingURL=patchJestSnapshots.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.ts"],
4
+ "sourcesContent": ["import { inspect } from 'util';\n\nimport fg from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst JEST_SNAPSHOT_OLD_URL = 'https://goo.gl/fbAQLP';\nconst JEST_SNAPSHOT_NEW_URL = 'https://jestjs.io/docs/snapshot-testing';\n\nexport const patchJestSnapshots = async (\n mode: 'lint' | 'format',\n): Promise<PatchReturnType> => {\n const testFilePaths = await fg(['**/*.test.ts', '**/*.test.ts.snap'], {\n ignore: [\n '**/.git',\n '**/node_modules',\n 'src/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.test.ts',\n ],\n });\n\n if (testFilePaths.length === 0) {\n return {\n result: 'skip',\n reason: 'no test files found',\n };\n }\n\n const testsFiles = await Promise.all(\n testFilePaths.map(async (file) => {\n const contents = await fs.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\n const testFilesToPatch = testsFiles.filter(({ contents }) =>\n contents.includes(JEST_SNAPSHOT_OLD_URL),\n );\n\n if (testFilesToPatch.length === 0) {\n return {\n result: 'skip',\n reason: 'no test files to patch',\n };\n }\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all(\n testFilesToPatch.map(async ({ file, contents }) => {\n const updatedContents = contents.replaceAll(\n JEST_SNAPSHOT_OLD_URL,\n JEST_SNAPSHOT_NEW_URL,\n );\n await fs.writeFile(file, updatedContents, 'utf8');\n }),\n );\n\n return {\n result: 'apply',\n };\n};\n\nexport const tryPatchJestSnapshots: PatchFunction = async ({ mode }) => {\n try {\n return await patchJestSnapshots(mode);\n } catch (err) {\n log.warn('Failed to apply Jest snapshot URL patch.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAe;AACf,sBAAe;AAEf,qBAAoB;AAGpB,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAEvB,MAAM,qBAAqB,OAChC,SAC6B;AAC7B,QAAM,gBAAgB,UAAM,iBAAAA,SAAG,CAAC,gBAAgB,mBAAmB,GAAG;AAAA,IACpE,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AAED,MAAI,cAAc,WAAW,GAAG;AAC9B,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,aAAa,MAAM,QAAQ;AAAA,IAC/B,cAAc,IAAI,OAAO,SAAS;AAChC,YAAM,WAAW,MAAM,gBAAAC,QAAG,SAAS,MAAM,MAAM;AAE/C,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,mBAAmB,WAAW;AAAA,IAAO,CAAC,EAAE,SAAS,MACrD,SAAS,SAAS,qBAAqB;AAAA,EACzC;AAEA,MAAI,iBAAiB,WAAW,GAAG;AACjC,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,iBAAiB,IAAI,OAAO,EAAE,MAAM,SAAS,MAAM;AACjD,YAAM,kBAAkB,SAAS;AAAA,QAC/B;AAAA,QACA;AAAA,MACF;AACA,YAAM,gBAAAA,QAAG,UAAU,MAAM,iBAAiB,MAAM;AAAA,IAClD,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,wBAAuC,OAAO,EAAE,KAAK,MAAM;AACtE,MAAI;AACF,WAAO,MAAM,mBAAmB,IAAI;AAAA,EACtC,SAAS,KAAK;AACZ,uBAAI,KAAK,0CAA0C;AACnD,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fg", "fs"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { Patches } from '../../index.js';
2
+ export declare const patches: Patches;
@@ -16,32 +16,25 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var statusMatrix_exports = {};
20
- __export(statusMatrix_exports, {
21
- ABSENT: () => ABSENT,
22
- FILEPATH: () => FILEPATH,
23
- HEAD: () => HEAD,
24
- MODIFIED: () => MODIFIED,
25
- STAGE: () => STAGE,
26
- UNMODIFIED: () => UNMODIFIED,
27
- WORKDIR: () => WORKDIR
19
+ var __exports = {};
20
+ __export(__exports, {
21
+ patches: () => patches
28
22
  });
29
- module.exports = __toCommonJS(statusMatrix_exports);
30
- const FILEPATH = 0;
31
- const HEAD = 1;
32
- const WORKDIR = 2;
33
- const STAGE = 3;
34
- const ABSENT = 0;
35
- const UNMODIFIED = 1;
36
- const MODIFIED = 2;
23
+ module.exports = __toCommonJS(__exports);
24
+ var import_patchApiTokenFromEnvironment = require("./patchApiTokenFromEnvironment.js");
25
+ var import_patchDockerfileSyntaxDirective = require("./patchDockerfileSyntaxDirective.js");
26
+ const patches = [
27
+ {
28
+ apply: import_patchDockerfileSyntaxDirective.tryPatchDockerfileSyntaxDirective,
29
+ description: "Remove Dockerfile syntax directives"
30
+ },
31
+ {
32
+ apply: import_patchApiTokenFromEnvironment.tryPatchApiTokenFromEnvironment,
33
+ description: "Update import for `apiTokenFromEnvironment`"
34
+ }
35
+ ];
37
36
  // Annotate the CommonJS export names for ESM import in node:
38
37
  0 && (module.exports = {
39
- ABSENT,
40
- FILEPATH,
41
- HEAD,
42
- MODIFIED,
43
- STAGE,
44
- UNMODIFIED,
45
- WORKDIR
38
+ patches
46
39
  });
47
- //# sourceMappingURL=statusMatrix.js.map
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.3.0/index.ts"],
4
+ "sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { tryPatchApiTokenFromEnvironment } from './patchApiTokenFromEnvironment.js';\nimport { tryPatchDockerfileSyntaxDirective } from './patchDockerfileSyntaxDirective.js';\n\nexport const patches: Patches = [\n {\n apply: tryPatchDockerfileSyntaxDirective,\n description: 'Remove Dockerfile syntax directives',\n },\n {\n apply: tryPatchApiTokenFromEnvironment,\n description: 'Update import for `apiTokenFromEnvironment`',\n },\n];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0CAAgD;AAChD,4CAAkD;AAE3C,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { PatchFunction, PatchReturnType } from '../../index.js';
2
+ export declare const patchApiTokenFromEnvironment: (mode: "lint" | "format") => Promise<PatchReturnType>;
3
+ export declare const tryPatchApiTokenFromEnvironment: PatchFunction;
@@ -0,0 +1,100 @@
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 patchApiTokenFromEnvironment_exports = {};
30
+ __export(patchApiTokenFromEnvironment_exports, {
31
+ patchApiTokenFromEnvironment: () => patchApiTokenFromEnvironment,
32
+ tryPatchApiTokenFromEnvironment: () => tryPatchApiTokenFromEnvironment
33
+ });
34
+ module.exports = __toCommonJS(patchApiTokenFromEnvironment_exports);
35
+ var import_util = require("util");
36
+ var import_fast_glob = __toESM(require("fast-glob"));
37
+ var import_fs_extra = __toESM(require("fs-extra"));
38
+ var import_logging = require("../../../../../../utils/logging.js");
39
+ const importRegex = /import { apiTokenFromEnvironment } from 'skuba\/lib\/api\/github\/environment';\n/;
40
+ const usageRegex = /apiTokenFromEnvironment\(\)/;
41
+ const patchApiTokenFromEnvironment = async (mode) => {
42
+ const scriptPaths = await (0, import_fast_glob.default)(["scripts/**/*.ts"], {
43
+ ignore: ["**/.git", "**/node_modules"]
44
+ });
45
+ if (scriptPaths.length === 0) {
46
+ return {
47
+ result: "skip",
48
+ reason: "no scripts found"
49
+ };
50
+ }
51
+ const scripts = await Promise.all(
52
+ scriptPaths.map(async (file) => {
53
+ const contents = await import_fs_extra.default.readFile(file, "utf8");
54
+ return {
55
+ file,
56
+ contents
57
+ };
58
+ })
59
+ );
60
+ const scriptsToPatch = scripts.filter(
61
+ ({ contents }) => importRegex.exec(contents) ?? usageRegex.exec(contents)
62
+ );
63
+ if (scriptsToPatch.length === 0) {
64
+ return {
65
+ result: "skip",
66
+ reason: "no scripts to patch"
67
+ };
68
+ }
69
+ if (mode === "lint") {
70
+ return {
71
+ result: "apply"
72
+ };
73
+ }
74
+ await Promise.all(
75
+ scriptsToPatch.map(async ({ file, contents }) => {
76
+ const updatedContents = contents.replace(importRegex, "import { GitHub } from 'skuba';\n").replace(usageRegex, "GitHub.apiTokenFromEnvironment()");
77
+ await import_fs_extra.default.writeFile(file, updatedContents, "utf8");
78
+ })
79
+ );
80
+ return {
81
+ result: "apply"
82
+ };
83
+ };
84
+ const tryPatchApiTokenFromEnvironment = async ({
85
+ mode
86
+ }) => {
87
+ try {
88
+ return await patchApiTokenFromEnvironment(mode);
89
+ } catch (err) {
90
+ import_logging.log.warn("Failed to apply apiTokenFromEnvironment patch.");
91
+ import_logging.log.subtle((0, import_util.inspect)(err));
92
+ return { result: "skip", reason: "due to an error" };
93
+ }
94
+ };
95
+ // Annotate the CommonJS export names for ESM import in node:
96
+ 0 && (module.exports = {
97
+ patchApiTokenFromEnvironment,
98
+ tryPatchApiTokenFromEnvironment
99
+ });
100
+ //# sourceMappingURL=patchApiTokenFromEnvironment.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.ts"],
4
+ "sourcesContent": ["import { inspect } from 'util';\n\nimport fg from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst importRegex =\n /import { apiTokenFromEnvironment } from 'skuba\\/lib\\/api\\/github\\/environment';\\n/;\nconst usageRegex = /apiTokenFromEnvironment\\(\\)/;\n\nexport const patchApiTokenFromEnvironment = async (\n mode: 'lint' | 'format',\n): Promise<PatchReturnType> => {\n const scriptPaths = await fg(['scripts/**/*.ts'], {\n ignore: ['**/.git', '**/node_modules'],\n });\n\n if (scriptPaths.length === 0) {\n return {\n result: 'skip',\n reason: 'no scripts found',\n };\n }\n\n const scripts = await Promise.all(\n scriptPaths.map(async (file) => {\n const contents = await fs.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\n const scriptsToPatch = scripts.filter(\n ({ contents }) => importRegex.exec(contents) ?? usageRegex.exec(contents),\n );\n\n if (scriptsToPatch.length === 0) {\n return {\n result: 'skip',\n reason: 'no scripts to patch',\n };\n }\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all(\n scriptsToPatch.map(async ({ file, contents }) => {\n const updatedContents = contents\n .replace(importRegex, \"import { GitHub } from 'skuba';\\n\")\n .replace(usageRegex, 'GitHub.apiTokenFromEnvironment()');\n await fs.writeFile(file, updatedContents, 'utf8');\n }),\n );\n\n return {\n result: 'apply',\n };\n};\n\nexport const tryPatchApiTokenFromEnvironment: PatchFunction = async ({\n mode,\n}) => {\n try {\n return await patchApiTokenFromEnvironment(mode);\n } catch (err) {\n log.warn('Failed to apply apiTokenFromEnvironment patch.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAe;AACf,sBAAe;AAEf,qBAAoB;AAGpB,MAAM,cACJ;AACF,MAAM,aAAa;AAEZ,MAAM,+BAA+B,OAC1C,SAC6B;AAC7B,QAAM,cAAc,UAAM,iBAAAA,SAAG,CAAC,iBAAiB,GAAG;AAAA,IAChD,QAAQ,CAAC,WAAW,iBAAiB;AAAA,EACvC,CAAC;AAED,MAAI,YAAY,WAAW,GAAG;AAC5B,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,UAAU,MAAM,QAAQ;AAAA,IAC5B,YAAY,IAAI,OAAO,SAAS;AAC9B,YAAM,WAAW,MAAM,gBAAAC,QAAG,SAAS,MAAM,MAAM;AAE/C,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,iBAAiB,QAAQ;AAAA,IAC7B,CAAC,EAAE,SAAS,MAAM,YAAY,KAAK,QAAQ,KAAK,WAAW,KAAK,QAAQ;AAAA,EAC1E;AAEA,MAAI,eAAe,WAAW,GAAG;AAC/B,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,eAAe,IAAI,OAAO,EAAE,MAAM,SAAS,MAAM;AAC/C,YAAM,kBAAkB,SACrB,QAAQ,aAAa,mCAAmC,EACxD,QAAQ,YAAY,kCAAkC;AACzD,YAAM,gBAAAA,QAAG,UAAU,MAAM,iBAAiB,MAAM;AAAA,IAClD,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,kCAAiD,OAAO;AAAA,EACnE;AACF,MAAM;AACJ,MAAI;AACF,WAAO,MAAM,6BAA6B,IAAI;AAAA,EAChD,SAAS,KAAK;AACZ,uBAAI,KAAK,gDAAgD;AACzD,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fg", "fs"]
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { PatchFunction, PatchReturnType } from '../../index.js';
2
+ export declare const patchDockerfileSyntaxDirective: (mode: "lint" | "format") => Promise<PatchReturnType>;
3
+ export declare const tryPatchDockerfileSyntaxDirective: PatchFunction;
@@ -0,0 +1,99 @@
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 patchDockerfileSyntaxDirective_exports = {};
30
+ __export(patchDockerfileSyntaxDirective_exports, {
31
+ patchDockerfileSyntaxDirective: () => patchDockerfileSyntaxDirective,
32
+ tryPatchDockerfileSyntaxDirective: () => tryPatchDockerfileSyntaxDirective
33
+ });
34
+ module.exports = __toCommonJS(patchDockerfileSyntaxDirective_exports);
35
+ var import_util = require("util");
36
+ var import_fast_glob = __toESM(require("fast-glob"));
37
+ var import_fs_extra = __toESM(require("fs-extra"));
38
+ var import_logging = require("../../../../../../utils/logging.js");
39
+ const dockerSyntaxRegex = /^#\s*syntax=\s*docker\/dockerfile:\S+\n+/;
40
+ const patchDockerfileSyntaxDirective = async (mode) => {
41
+ const dockerfilePaths = await (0, import_fast_glob.default)(["**/Dockerfile*"], {
42
+ ignore: ["**/.git", "**/node_modules"]
43
+ });
44
+ if (dockerfilePaths.length === 0) {
45
+ return {
46
+ result: "skip",
47
+ reason: "no dockerfiles found"
48
+ };
49
+ }
50
+ const dockerfiles = await Promise.all(
51
+ dockerfilePaths.map(async (file) => {
52
+ const contents = await import_fs_extra.default.readFile(file, "utf8");
53
+ return {
54
+ file,
55
+ contents
56
+ };
57
+ })
58
+ );
59
+ const dockerfilesToPatch = dockerfiles.filter(
60
+ ({ contents }) => dockerSyntaxRegex.test(contents)
61
+ );
62
+ if (dockerfilesToPatch.length === 0) {
63
+ return {
64
+ result: "skip",
65
+ reason: "no dockerfiles to patch"
66
+ };
67
+ }
68
+ if (mode === "lint") {
69
+ return {
70
+ result: "apply"
71
+ };
72
+ }
73
+ await Promise.all(
74
+ dockerfilesToPatch.map(async ({ file, contents }) => {
75
+ const updatedContents = contents.replace(dockerSyntaxRegex, "");
76
+ await import_fs_extra.default.writeFile(file, updatedContents, "utf8");
77
+ })
78
+ );
79
+ return {
80
+ result: "apply"
81
+ };
82
+ };
83
+ const tryPatchDockerfileSyntaxDirective = async ({
84
+ mode
85
+ }) => {
86
+ try {
87
+ return await patchDockerfileSyntaxDirective(mode);
88
+ } catch (err) {
89
+ import_logging.log.warn("Failed to apply Dockerfile syntax directive patch.");
90
+ import_logging.log.subtle((0, import_util.inspect)(err));
91
+ return { result: "skip", reason: "due to an error" };
92
+ }
93
+ };
94
+ // Annotate the CommonJS export names for ESM import in node:
95
+ 0 && (module.exports = {
96
+ patchDockerfileSyntaxDirective,
97
+ tryPatchDockerfileSyntaxDirective
98
+ });
99
+ //# sourceMappingURL=patchDockerfileSyntaxDirective.js.map