skuba 13.0.0-subpath-imports-20250722044721 → 13.0.0-subpath-imports-20251003044159

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 (268) 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/{api/buildkite/md.js → cli/lint/internalLints/upgrade/patches/12.0.2/index.js} +13 -11
  68. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +7 -0
  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/net → cli/lint/internalLints/upgrade/patches/12.1.1}/index.js +12 -6
  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/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +40 -0
  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 → cli/lint/internalLints/upgrade/patches/12.4.0}/index.js +12 -9
  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/cli/lint/internalLints/upgrade/patches/{12.2.0 → 13.0.0}/index.js.map +1 -1
  95. package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/rewriteSrcImports.d.ts +13 -0
  96. package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/rewriteSrcImports.js +221 -0
  97. package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/rewriteSrcImports.js.map +7 -0
  98. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +1 -1
  99. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +2 -2
  100. package/lib/cli/node/index.js +8 -2
  101. package/lib/cli/node/index.js.map +2 -2
  102. package/lib/cli/start/index.js +8 -2
  103. package/lib/cli/start/index.js.map +2 -2
  104. package/lib/cli/test/index.d.ts +1 -1
  105. package/lib/cli/test/index.js +18 -4
  106. package/lib/cli/test/index.js.map +2 -2
  107. package/lib/cli/test/reporters/github/annotations.d.ts +1 -1
  108. package/lib/cli/test/reporters/github/annotations.js.map +1 -1
  109. package/lib/cli/test/reporters/github/index.js +3 -4
  110. package/lib/cli/test/reporters/github/index.js.map +2 -2
  111. package/lib/index.d.ts +4 -4
  112. package/lib/index.js +4 -4
  113. package/lib/index.js.map +2 -2
  114. package/lib/utils/args.d.ts +2 -0
  115. package/lib/utils/args.js +5 -0
  116. package/lib/utils/args.js.map +2 -2
  117. package/lib/utils/dir.js +2 -2
  118. package/lib/utils/dir.js.map +3 -3
  119. package/lib/utils/manifest.d.ts +6 -2
  120. package/lib/utils/manifest.js +17 -8
  121. package/lib/utils/manifest.js.map +2 -2
  122. package/lib/utils/template.d.ts +1 -1
  123. package/package.json +21 -24
  124. package/template/base/_.prettierrc.js +1 -1
  125. package/template/base/_eslint.config.js +1 -1
  126. package/template/base/_pnpm-workspace.yaml +14 -3
  127. package/template/base/jest.config.ts +7 -12
  128. package/template/base/jest.setup.ts +1 -1
  129. package/template/express-rest-api/.buildkite/pipeline.yml +6 -0
  130. package/template/express-rest-api/.env +1 -1
  131. package/template/express-rest-api/.gantry/dev.yml +5 -1
  132. package/template/express-rest-api/.gantry/prod.yml +5 -1
  133. package/template/express-rest-api/Dockerfile +2 -2
  134. package/template/express-rest-api/Dockerfile.dev-deps +0 -2
  135. package/template/express-rest-api/README.md +5 -5
  136. package/template/express-rest-api/gantry.apply.yml +17 -1
  137. package/template/express-rest-api/package.json +11 -5
  138. package/template/express-rest-api/src/api/healthCheck.ts +2 -2
  139. package/template/express-rest-api/src/config.ts +7 -7
  140. package/template/express-rest-api/src/framework/logging.ts +11 -7
  141. package/template/express-rest-api/src/framework/metrics.ts +1 -1
  142. package/template/express-rest-api/src/listen.ts +6 -0
  143. package/template/express-rest-api/src/tracing.ts +56 -0
  144. package/template/greeter/Dockerfile +0 -2
  145. package/template/greeter/README.md +2 -2
  146. package/template/greeter/package.json +2 -2
  147. package/template/koa-rest-api/.buildkite/pipeline.yml +6 -0
  148. package/template/koa-rest-api/.env +1 -1
  149. package/template/koa-rest-api/.gantry/dev.yml +3 -3
  150. package/template/koa-rest-api/.gantry/prod.yml +3 -3
  151. package/template/koa-rest-api/Dockerfile +1 -1
  152. package/template/koa-rest-api/Dockerfile.dev-deps +0 -2
  153. package/template/koa-rest-api/README.md +6 -6
  154. package/template/koa-rest-api/gantry.apply.yml +15 -3
  155. package/template/koa-rest-api/package.json +13 -14
  156. package/template/koa-rest-api/src/api/healthCheck.ts +2 -2
  157. package/template/koa-rest-api/src/config.ts +7 -7
  158. package/template/koa-rest-api/src/framework/logging.ts +12 -8
  159. package/template/koa-rest-api/src/framework/metrics.ts +1 -1
  160. package/template/koa-rest-api/src/framework/server.test.ts +7 -8
  161. package/template/koa-rest-api/src/framework/server.ts +1 -4
  162. package/template/koa-rest-api/src/listen.ts +6 -0
  163. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +6 -2
  164. package/template/lambda-sqs-worker-cdk/.env +1 -1
  165. package/template/lambda-sqs-worker-cdk/Dockerfile +0 -2
  166. package/template/lambda-sqs-worker-cdk/README.md +8 -8
  167. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +54 -26
  168. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +5 -22
  169. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +16 -9
  170. package/template/lambda-sqs-worker-cdk/infra/config.ts +34 -20
  171. package/template/lambda-sqs-worker-cdk/infra/index.ts +1 -1
  172. package/template/lambda-sqs-worker-cdk/package.json +7 -9
  173. package/template/lambda-sqs-worker-cdk/src/app.test.ts +91 -51
  174. package/template/lambda-sqs-worker-cdk/src/app.ts +10 -9
  175. package/template/lambda-sqs-worker-cdk/src/config.ts +11 -16
  176. package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +10 -5
  177. package/template/lambda-sqs-worker-cdk/src/framework/handler.ts +48 -24
  178. package/template/lambda-sqs-worker-cdk/src/framework/logging.ts +23 -11
  179. package/template/lambda-sqs-worker-cdk/src/framework/metrics.ts +1 -4
  180. package/template/lambda-sqs-worker-cdk/src/testing/handler.ts +4 -1
  181. package/template/oss-npm-package/.github/workflows/release.yml +7 -8
  182. package/template/oss-npm-package/.github/workflows/validate.yml +6 -6
  183. package/template/oss-npm-package/README.md +1 -1
  184. package/template/oss-npm-package/_package.json +0 -3
  185. package/template/oss-npm-package/skuba.template.js +1 -1
  186. package/lib/api/buildkite/annotate.d.ts +0 -28
  187. package/lib/api/buildkite/annotate.js +0 -62
  188. package/lib/api/buildkite/annotate.js.map +0 -7
  189. package/lib/api/buildkite/index.d.ts +0 -3
  190. package/lib/api/buildkite/index.js.map +0 -7
  191. package/lib/api/buildkite/md.d.ts +0 -6
  192. package/lib/api/buildkite/md.js.map +0 -7
  193. package/lib/api/git/commit.d.ts +0 -15
  194. package/lib/api/git/commit.js +0 -52
  195. package/lib/api/git/commit.js.map +0 -7
  196. package/lib/api/git/commitAllChanges.d.ts +0 -19
  197. package/lib/api/git/commitAllChanges.js +0 -83
  198. package/lib/api/git/commitAllChanges.js.map +0 -7
  199. package/lib/api/git/currentBranch.d.ts +0 -10
  200. package/lib/api/git/currentBranch.js +0 -59
  201. package/lib/api/git/currentBranch.js.map +0 -7
  202. package/lib/api/git/findRoot.d.ts +0 -9
  203. package/lib/api/git/findRoot.js +0 -52
  204. package/lib/api/git/findRoot.js.map +0 -7
  205. package/lib/api/git/getChangedFiles.d.ts +0 -20
  206. package/lib/api/git/getChangedFiles.js +0 -81
  207. package/lib/api/git/getChangedFiles.js.map +0 -7
  208. package/lib/api/git/index.d.ts +0 -12
  209. package/lib/api/git/index.js +0 -61
  210. package/lib/api/git/index.js.map +0 -7
  211. package/lib/api/git/isFileGitIgnored.d.ts +0 -4
  212. package/lib/api/git/isFileGitIgnored.js +0 -49
  213. package/lib/api/git/isFileGitIgnored.js.map +0 -7
  214. package/lib/api/git/log.d.ts +0 -19
  215. package/lib/api/git/log.js +0 -71
  216. package/lib/api/git/log.js.map +0 -7
  217. package/lib/api/git/pull.d.ts +0 -35
  218. package/lib/api/git/pull.js +0 -69
  219. package/lib/api/git/pull.js.map +0 -7
  220. package/lib/api/git/push.d.ts +0 -52
  221. package/lib/api/git/push.js +0 -70
  222. package/lib/api/git/push.js.map +0 -7
  223. package/lib/api/git/remote.d.ts +0 -20
  224. package/lib/api/git/remote.js +0 -73
  225. package/lib/api/git/remote.js.map +0 -7
  226. package/lib/api/git/reset.d.ts +0 -12
  227. package/lib/api/git/reset.js +0 -62
  228. package/lib/api/git/reset.js.map +0 -7
  229. package/lib/api/git/statusMatrix.d.ts +0 -7
  230. package/lib/api/git/statusMatrix.js +0 -47
  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.2.0/rewriteSrcImports.d.ts +0 -6
  265. package/lib/cli/lint/internalLints/upgrade/patches/12.2.0/rewriteSrcImports.js +0 -104
  266. package/lib/cli/lint/internalLints/upgrade/patches/12.2.0/rewriteSrcImports.js.map +0 -7
  267. /package/lib/cli/lint/internalLints/upgrade/patches/{12.2.0 → 12.0.2}/index.d.ts +0 -0
  268. /package/lib/cli/lint/internalLints/upgrade/patches/{12.2.0 → 13.0.0}/index.js +0 -0
@@ -1,104 +0,0 @@
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 rewriteSrcImports_exports = {};
30
- __export(rewriteSrcImports_exports, {
31
- hasSkubaDiveRegisterImportRegex: () => hasSkubaDiveRegisterImportRegex,
32
- hasSrcImportRegex: () => hasSrcImportRegex,
33
- replaceSrcImport: () => replaceSrcImport,
34
- rewriteSrcImports: () => rewriteSrcImports,
35
- tryRewriteSrcImports: () => tryRewriteSrcImports
36
- });
37
- module.exports = __toCommonJS(rewriteSrcImports_exports);
38
- var import_util = require("util");
39
- var import_fast_glob = require("fast-glob");
40
- var import_fs_extra = __toESM(require("fs-extra"));
41
- var import_logging = require("../../../../../../utils/logging.js");
42
- const fetchFiles = async (files) => Promise.all(
43
- files.map(async (file) => {
44
- const contents = await import_fs_extra.default.promises.readFile(file, "utf8");
45
- return {
46
- file,
47
- contents
48
- };
49
- })
50
- );
51
- const hasSkubaDiveRegisterImportRegex = /import\s+['"](?:skuba-dive\/register|\.\.?\/.*?register)(?:\.js)?['"];?\s*/gm;
52
- const hasSrcImportRegex = /import\s+(?:type\s+\{[^}]*\}|\{[^}]*\}|\*\s+as\s+\w+|\w+(?:\s*,\s*\{[^}]*\})?)\s+from\s+['"]src\/[^'"]*['"]/gm;
53
- const replaceSrcImport = (contents) => contents.replace(
54
- hasSrcImportRegex,
55
- (match) => match.replace(/(['"])src\//g, "$1#src/")
56
- );
57
- const removeSkubaDiveRegisterImport = (contents) => contents.replace(hasSkubaDiveRegisterImportRegex, "");
58
- const replaceAllImports = (contents) => removeSkubaDiveRegisterImport(replaceSrcImport(contents));
59
- const tryRewriteSrcImports = async ({
60
- mode
61
- }) => {
62
- const tsFileNames = await (0, import_fast_glob.glob)(["**/*.ts", "**/*.test.ts"]);
63
- if (!tsFileNames.length) {
64
- return {
65
- result: "skip",
66
- reason: "no .ts or test.ts files found"
67
- };
68
- }
69
- const tsFiles = await fetchFiles(tsFileNames);
70
- const mapped = tsFiles.map(({ file, contents }) => ({
71
- file,
72
- before: contents,
73
- after: replaceAllImports(contents)
74
- }));
75
- if (mode === "lint") {
76
- return {
77
- result: "apply"
78
- };
79
- }
80
- await Promise.all(
81
- mapped.map(async ({ file, after }) => {
82
- await import_fs_extra.default.promises.writeFile(file, after);
83
- })
84
- );
85
- return { result: "apply" };
86
- };
87
- const rewriteSrcImports = async (config) => {
88
- try {
89
- return await tryRewriteSrcImports(config);
90
- } catch (err) {
91
- import_logging.log.warn("Failed to rewrite src imports to #src");
92
- import_logging.log.subtle((0, import_util.inspect)(err));
93
- return { result: "skip", reason: "due to an error" };
94
- }
95
- };
96
- // Annotate the CommonJS export names for ESM import in node:
97
- 0 && (module.exports = {
98
- hasSkubaDiveRegisterImportRegex,
99
- hasSrcImportRegex,
100
- replaceSrcImport,
101
- rewriteSrcImports,
102
- tryRewriteSrcImports
103
- });
104
- //# sourceMappingURL=rewriteSrcImports.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.2.0/rewriteSrcImports.ts"],
4
- "sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst fetchFiles = async (files: string[]) =>\n Promise.all(\n files.map(async (file) => {\n const contents = await fs.promises.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\nexport const hasSkubaDiveRegisterImportRegex =\n /import\\s+['\"](?:skuba-dive\\/register|\\.\\.?\\/.*?register)(?:\\.js)?['\"];?\\s*/gm;\n\nexport const hasSrcImportRegex =\n /import\\s+(?:type\\s+\\{[^}]*\\}|\\{[^}]*\\}|\\*\\s+as\\s+\\w+|\\w+(?:\\s*,\\s*\\{[^}]*\\})?)\\s+from\\s+['\"]src\\/[^'\"]*['\"]/gm;\n\nexport const replaceSrcImport = (contents: string) =>\n contents.replace(hasSrcImportRegex, (match) =>\n match.replace(/(['\"])src\\//g, '$1#src/'),\n );\n\nconst removeSkubaDiveRegisterImport = (contents: string) =>\n contents.replace(hasSkubaDiveRegisterImportRegex, '');\n\nconst replaceAllImports = (contents: string) =>\n removeSkubaDiveRegisterImport(replaceSrcImport(contents));\n\nexport const tryRewriteSrcImports: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n const tsFileNames = await glob(['**/*.ts', '**/*.test.ts']);\n\n if (!tsFileNames.length) {\n return {\n result: 'skip',\n reason: 'no .ts or test.ts files found',\n };\n }\n\n const tsFiles = await fetchFiles(tsFileNames);\n\n const mapped = tsFiles.map(({ file, contents }) => ({\n file,\n before: contents,\n after: replaceAllImports(contents),\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 rewriteSrcImports: PatchFunction = async (config) => {\n try {\n return await tryRewriteSrcImports(config);\n } catch (err) {\n log.warn('Failed to rewrite src imports to #src');\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;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,qBAAoB;AAGpB,MAAM,aAAa,OAAO,UACxB,QAAQ;AAAA,EACN,MAAM,IAAI,OAAO,SAAS;AACxB,UAAM,WAAW,MAAM,gBAAAA,QAAG,SAAS,SAAS,MAAM,MAAM;AAExD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEK,MAAM,kCACX;AAEK,MAAM,oBACX;AAEK,MAAM,mBAAmB,CAAC,aAC/B,SAAS;AAAA,EAAQ;AAAA,EAAmB,CAAC,UACnC,MAAM,QAAQ,gBAAgB,SAAS;AACzC;AAEF,MAAM,gCAAgC,CAAC,aACrC,SAAS,QAAQ,iCAAiC,EAAE;AAEtD,MAAM,oBAAoB,CAAC,aACzB,8BAA8B,iBAAiB,QAAQ,CAAC;AAEnD,MAAM,uBAAsC,OAAO;AAAA,EACxD;AACF,MAAgC;AAC9B,QAAM,cAAc,UAAM,uBAAK,CAAC,WAAW,cAAc,CAAC;AAE1D,MAAI,CAAC,YAAY,QAAQ;AACvB,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,UAAU,MAAM,WAAW,WAAW;AAE5C,QAAM,SAAS,QAAQ,IAAI,CAAC,EAAE,MAAM,SAAS,OAAO;AAAA,IAClD;AAAA,IACA,QAAQ;AAAA,IACR,OAAO,kBAAkB,QAAQ;AAAA,EACnC,EAAE;AAEF,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,oBAAmC,OAAO,WAAW;AAChE,MAAI;AACF,WAAO,MAAM,qBAAqB,MAAM;AAAA,EAC1C,SAAS,KAAK;AACZ,uBAAI,KAAK,uCAAuC;AAChD,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
- "names": ["fs"]
7
- }