skuba 4.4.1 → 5.0.0

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 (330) hide show
  1. package/config/tsconfig.json +1 -0
  2. package/jest/moduleNameMapper.js +50 -78
  3. package/jest/moduleNameMapper.test.ts +4 -14
  4. package/jest/transform.js +10 -1
  5. package/jest/tsConfig.js +26 -0
  6. package/lib/api/buildkite/annotate.js +46 -33
  7. package/lib/api/buildkite/annotate.js.map +7 -1
  8. package/lib/api/buildkite/index.js +31 -7
  9. package/lib/api/buildkite/index.js.map +7 -1
  10. package/lib/api/buildkite/md.js +31 -8
  11. package/lib/api/buildkite/md.js.map +7 -1
  12. package/lib/api/git/commit.js +45 -17
  13. package/lib/api/git/commit.js.map +7 -1
  14. package/lib/api/git/commitAllChanges.js +57 -27
  15. package/lib/api/git/commitAllChanges.js.map +7 -1
  16. package/lib/api/git/currentBranch.js +50 -28
  17. package/lib/api/git/currentBranch.js.map +7 -1
  18. package/lib/api/git/getChangedFiles.js +49 -27
  19. package/lib/api/git/getChangedFiles.js.map +7 -1
  20. package/lib/api/git/index.js +54 -22
  21. package/lib/api/git/index.js.map +7 -1
  22. package/lib/api/git/log.js +63 -42
  23. package/lib/api/git/log.js.map +7 -1
  24. package/lib/api/git/pull.js +62 -31
  25. package/lib/api/git/pull.js.map +7 -1
  26. package/lib/api/git/push.js +63 -31
  27. package/lib/api/git/push.js.map +7 -1
  28. package/lib/api/git/remote.js +59 -56
  29. package/lib/api/git/remote.js.map +7 -1
  30. package/lib/api/git/reset.js +55 -27
  31. package/lib/api/git/reset.js.map +7 -1
  32. package/lib/api/git/statusMatrix.js +46 -13
  33. package/lib/api/git/statusMatrix.js.map +7 -1
  34. package/lib/api/github/checkRun.js +70 -79
  35. package/lib/api/github/checkRun.js.map +7 -1
  36. package/lib/api/github/environment.js +40 -33
  37. package/lib/api/github/environment.js.map +7 -1
  38. package/lib/api/github/index.js +47 -17
  39. package/lib/api/github/index.js.map +7 -1
  40. package/lib/api/github/issueComment.js +73 -81
  41. package/lib/api/github/issueComment.js.map +7 -1
  42. package/lib/api/github/pullRequest.js +60 -61
  43. package/lib/api/github/pullRequest.js.map +7 -1
  44. package/lib/api/github/push.js +138 -133
  45. package/lib/api/github/push.js.map +7 -1
  46. package/lib/api/jest/index.d.ts +2 -1
  47. package/lib/api/jest/index.js +35 -14
  48. package/lib/api/jest/index.js.map +7 -1
  49. package/lib/api/net/compose.js +45 -17
  50. package/lib/api/net/compose.js.map +7 -1
  51. package/lib/api/net/index.js +28 -5
  52. package/lib/api/net/index.js.map +7 -1
  53. package/lib/api/net/socket.js +58 -36
  54. package/lib/api/net/socket.js.map +7 -1
  55. package/lib/api/net/waitFor.js +38 -18
  56. package/lib/api/net/waitFor.js.map +7 -1
  57. package/lib/cli/adapter/eslint.js +95 -72
  58. package/lib/cli/adapter/eslint.js.map +7 -1
  59. package/lib/cli/adapter/prettier.js +135 -123
  60. package/lib/cli/adapter/prettier.js.map +7 -1
  61. package/lib/cli/build/args.d.ts +7 -0
  62. package/lib/cli/build/args.js +69 -0
  63. package/lib/cli/build/args.js.map +7 -0
  64. package/lib/cli/build/esbuild.d.ts +5 -0
  65. package/lib/cli/build/esbuild.js +128 -0
  66. package/lib/cli/build/esbuild.js.map +7 -0
  67. package/lib/cli/build/index.d.ts +1 -1
  68. package/lib/cli/build/index.js +68 -5
  69. package/lib/cli/build/index.js.map +7 -1
  70. package/lib/cli/build/tsc.d.ts +1 -1
  71. package/lib/cli/build/tsc.js +34 -23
  72. package/lib/cli/build/tsc.js.map +7 -1
  73. package/lib/cli/buildPackage.js +53 -23
  74. package/lib/cli/buildPackage.js.map +7 -1
  75. package/lib/cli/configure/addEmptyExports.d.ts +5 -0
  76. package/lib/cli/configure/addEmptyExports.js +67 -0
  77. package/lib/cli/configure/addEmptyExports.js.map +7 -0
  78. package/lib/cli/configure/analyseConfiguration.js +61 -31
  79. package/lib/cli/configure/analyseConfiguration.js.map +7 -1
  80. package/lib/cli/configure/analyseDependencies.js +122 -113
  81. package/lib/cli/configure/analyseDependencies.js.map +7 -1
  82. package/lib/cli/configure/analysis/diff.js +37 -11
  83. package/lib/cli/configure/analysis/diff.js.map +7 -1
  84. package/lib/cli/configure/analysis/files.js +49 -22
  85. package/lib/cli/configure/analysis/files.js.map +7 -1
  86. package/lib/cli/configure/analysis/git.js +46 -16
  87. package/lib/cli/configure/analysis/git.js.map +7 -1
  88. package/lib/cli/configure/analysis/package.js +99 -52
  89. package/lib/cli/configure/analysis/package.js.map +7 -1
  90. package/lib/cli/configure/analysis/project.js +90 -54
  91. package/lib/cli/configure/analysis/project.js.map +7 -1
  92. package/lib/cli/configure/dependencies/index.js +40 -13
  93. package/lib/cli/configure/dependencies/index.js.map +7 -1
  94. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +57 -32
  95. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +7 -1
  96. package/lib/cli/configure/dependencies/seekKoala.js +53 -31
  97. package/lib/cli/configure/dependencies/seekKoala.js.map +7 -1
  98. package/lib/cli/configure/dependencies/skuba.js +49 -27
  99. package/lib/cli/configure/dependencies/skuba.js.map +7 -1
  100. package/lib/cli/configure/dependencies/skubaDeps.js +49 -28
  101. package/lib/cli/configure/dependencies/skubaDeps.js.map +7 -1
  102. package/lib/cli/configure/dependencies/skubaDive.js +65 -38
  103. package/lib/cli/configure/dependencies/skubaDive.js.map +7 -1
  104. package/lib/cli/configure/ensureTemplateCompletion.js +69 -41
  105. package/lib/cli/configure/ensureTemplateCompletion.js.map +7 -1
  106. package/lib/cli/configure/getEntryPoint.js +62 -32
  107. package/lib/cli/configure/getEntryPoint.js.map +7 -1
  108. package/lib/cli/configure/getProjectType.js +50 -28
  109. package/lib/cli/configure/getProjectType.js.map +7 -1
  110. package/lib/cli/configure/index.js +134 -109
  111. package/lib/cli/configure/index.js.map +7 -1
  112. package/lib/cli/configure/modules/eslint.js +57 -26
  113. package/lib/cli/configure/modules/eslint.js.map +7 -1
  114. package/lib/cli/configure/modules/ignore.js +37 -14
  115. package/lib/cli/configure/modules/ignore.js.map +7 -1
  116. package/lib/cli/configure/modules/index.js +53 -28
  117. package/lib/cli/configure/modules/index.js.map +7 -1
  118. package/lib/cli/configure/modules/jest.js +82 -47
  119. package/lib/cli/configure/modules/jest.js.map +7 -1
  120. package/lib/cli/configure/modules/nodemon.js +29 -6
  121. package/lib/cli/configure/modules/nodemon.js.map +7 -1
  122. package/lib/cli/configure/modules/package.js +113 -92
  123. package/lib/cli/configure/modules/package.js.map +7 -1
  124. package/lib/cli/configure/modules/prettier.js +48 -19
  125. package/lib/cli/configure/modules/prettier.js.map +7 -1
  126. package/lib/cli/configure/modules/renovate.js +52 -39
  127. package/lib/cli/configure/modules/renovate.js.map +7 -1
  128. package/lib/cli/configure/modules/serverless.js +33 -15
  129. package/lib/cli/configure/modules/serverless.js.map +7 -1
  130. package/lib/cli/configure/modules/skubaDive.js +63 -37
  131. package/lib/cli/configure/modules/skubaDive.js.map +7 -1
  132. package/lib/cli/configure/modules/tsconfig.js +84 -63
  133. package/lib/cli/configure/modules/tsconfig.js.map +7 -1
  134. package/lib/cli/configure/modules/tslint.js +29 -6
  135. package/lib/cli/configure/modules/tslint.js.map +7 -1
  136. package/lib/cli/configure/processing/deleteFiles.js +30 -8
  137. package/lib/cli/configure/processing/deleteFiles.js.map +7 -1
  138. package/lib/cli/configure/processing/ignoreFile.js +65 -59
  139. package/lib/cli/configure/processing/ignoreFile.js.map +7 -1
  140. package/lib/cli/configure/processing/javascript.js +35 -15
  141. package/lib/cli/configure/processing/javascript.js.map +7 -1
  142. package/lib/cli/configure/processing/json.js +51 -20
  143. package/lib/cli/configure/processing/json.js.map +7 -1
  144. package/lib/cli/configure/processing/loadFiles.js +30 -8
  145. package/lib/cli/configure/processing/loadFiles.js.map +7 -1
  146. package/lib/cli/configure/processing/module.js +37 -14
  147. package/lib/cli/configure/processing/module.js.map +7 -1
  148. package/lib/cli/configure/processing/package.js +73 -43
  149. package/lib/cli/configure/processing/package.js.map +7 -1
  150. package/lib/cli/configure/processing/prettier.js +37 -11
  151. package/lib/cli/configure/processing/prettier.js.map +7 -1
  152. package/lib/cli/configure/processing/record.js +54 -31
  153. package/lib/cli/configure/processing/record.js.map +7 -1
  154. package/lib/cli/configure/processing/typescript.js +176 -158
  155. package/lib/cli/configure/processing/typescript.js.map +7 -1
  156. package/lib/cli/configure/refreshIgnoreFiles.js +64 -40
  157. package/lib/cli/configure/refreshIgnoreFiles.js.map +7 -1
  158. package/lib/cli/configure/types.js +16 -2
  159. package/lib/cli/configure/types.js.map +7 -1
  160. package/lib/cli/format.js +58 -31
  161. package/lib/cli/format.js.map +7 -1
  162. package/lib/cli/help.js +31 -8
  163. package/lib/cli/help.js.map +7 -1
  164. package/lib/cli/init/getConfig.d.ts +1 -1
  165. package/lib/cli/init/getConfig.js +238 -207
  166. package/lib/cli/init/getConfig.js.map +7 -1
  167. package/lib/cli/init/git.js +70 -63
  168. package/lib/cli/init/git.js.map +7 -1
  169. package/lib/cli/init/index.js +133 -100
  170. package/lib/cli/init/index.js.map +7 -1
  171. package/lib/cli/init/prompts.js +84 -54
  172. package/lib/cli/init/prompts.js.map +7 -1
  173. package/lib/cli/init/types.js +52 -52
  174. package/lib/cli/init/types.js.map +7 -1
  175. package/lib/cli/init/validation.js +34 -12
  176. package/lib/cli/init/validation.js.map +7 -1
  177. package/lib/cli/init/writePackageJson.js +51 -22
  178. package/lib/cli/init/writePackageJson.js.map +7 -1
  179. package/lib/cli/lint/annotate/buildkite/eslint.js +34 -28
  180. package/lib/cli/lint/annotate/buildkite/eslint.js.map +7 -1
  181. package/lib/cli/lint/annotate/buildkite/index.js +50 -44
  182. package/lib/cli/lint/annotate/buildkite/index.js.map +7 -1
  183. package/lib/cli/lint/annotate/buildkite/prettier.js +41 -35
  184. package/lib/cli/lint/annotate/buildkite/prettier.js.map +7 -1
  185. package/lib/cli/lint/annotate/buildkite/tsc.js +39 -39
  186. package/lib/cli/lint/annotate/buildkite/tsc.js.map +7 -1
  187. package/lib/cli/lint/annotate/github/eslint.js +40 -16
  188. package/lib/cli/lint/annotate/github/eslint.js.map +7 -1
  189. package/lib/cli/lint/annotate/github/index.js +55 -51
  190. package/lib/cli/lint/annotate/github/index.js.map +7 -1
  191. package/lib/cli/lint/annotate/github/prettier.js +36 -13
  192. package/lib/cli/lint/annotate/github/prettier.js.map +7 -1
  193. package/lib/cli/lint/annotate/github/tsc.js +52 -52
  194. package/lib/cli/lint/annotate/github/tsc.js.map +7 -1
  195. package/lib/cli/lint/annotate/index.d.ts +1 -1
  196. package/lib/cli/lint/annotate/index.js +33 -10
  197. package/lib/cli/lint/annotate/index.js.map +7 -1
  198. package/lib/cli/lint/autofix.js +122 -117
  199. package/lib/cli/lint/autofix.js.map +7 -1
  200. package/lib/cli/lint/eslint.js +48 -18
  201. package/lib/cli/lint/eslint.js.map +7 -1
  202. package/lib/cli/lint/external.js +102 -81
  203. package/lib/cli/lint/external.js.map +7 -1
  204. package/lib/cli/lint/index.js +42 -18
  205. package/lib/cli/lint/index.js.map +7 -1
  206. package/lib/cli/lint/internal.js +54 -21
  207. package/lib/cli/lint/internal.js.map +7 -1
  208. package/lib/cli/lint/prettier.js +48 -18
  209. package/lib/cli/lint/prettier.js.map +7 -1
  210. package/lib/cli/lint/tsc.js +56 -32
  211. package/lib/cli/lint/tsc.js.map +7 -1
  212. package/lib/cli/lint/types.js +16 -2
  213. package/lib/cli/lint/types.js.map +7 -1
  214. package/lib/cli/node.js +65 -58
  215. package/lib/cli/node.js.map +7 -1
  216. package/lib/cli/release.js +29 -6
  217. package/lib/cli/release.js.map +7 -1
  218. package/lib/cli/start.js +61 -24
  219. package/lib/cli/start.js.map +7 -1
  220. package/lib/cli/test/index.js +35 -11
  221. package/lib/cli/test/index.js.map +7 -1
  222. package/lib/cli/test/reporters/github/annotations.js +89 -92
  223. package/lib/cli/test/reporters/github/annotations.js.map +7 -1
  224. package/lib/cli/test/reporters/github/index.js +68 -68
  225. package/lib/cli/test/reporters/github/index.js.map +7 -1
  226. package/lib/cli/version.js +31 -8
  227. package/lib/cli/version.js.map +7 -1
  228. package/lib/enquirer.d.js +2 -0
  229. package/lib/enquirer.d.js.map +7 -0
  230. package/lib/index.d.ts +6 -0
  231. package/lib/index.js +45 -41
  232. package/lib/index.js.map +7 -1
  233. package/lib/skuba.js +45 -38
  234. package/lib/skuba.js.map +7 -1
  235. package/lib/utils/args.js +97 -96
  236. package/lib/utils/args.js.map +7 -1
  237. package/lib/utils/command.js +64 -33
  238. package/lib/utils/command.js.map +7 -1
  239. package/lib/utils/copy.js +88 -51
  240. package/lib/utils/copy.js.map +7 -1
  241. package/lib/utils/dir.js +79 -67
  242. package/lib/utils/dir.js.map +7 -1
  243. package/lib/utils/env.js +27 -7
  244. package/lib/utils/env.js.map +7 -1
  245. package/lib/utils/error.js +58 -56
  246. package/lib/utils/error.js.map +7 -1
  247. package/lib/utils/exec.js +139 -110
  248. package/lib/utils/exec.js.map +7 -1
  249. package/lib/utils/help.js +31 -8
  250. package/lib/utils/help.js.map +7 -1
  251. package/lib/utils/logging.js +52 -24
  252. package/lib/utils/logging.js.map +7 -1
  253. package/lib/utils/logo.js +65 -27
  254. package/lib/utils/logo.js.map +7 -1
  255. package/lib/utils/manifest.d.ts +1 -0
  256. package/lib/utils/manifest.js +65 -51
  257. package/lib/utils/manifest.js.map +7 -1
  258. package/lib/utils/port.js +38 -17
  259. package/lib/utils/port.js.map +7 -1
  260. package/lib/utils/template.js +106 -87
  261. package/lib/utils/template.js.map +7 -1
  262. package/lib/utils/validation.js +43 -18
  263. package/lib/utils/validation.js.map +7 -1
  264. package/lib/utils/version.js +72 -82
  265. package/lib/utils/version.js.map +7 -1
  266. package/lib/utils/wait.js +52 -25
  267. package/lib/utils/wait.js.map +7 -1
  268. package/lib/utils/worker.js +59 -44
  269. package/lib/utils/worker.js.map +7 -1
  270. package/lib/wrapper/function-arguments.d.js +2 -0
  271. package/lib/wrapper/function-arguments.d.js.map +7 -0
  272. package/lib/wrapper/functionHandler.js +56 -29
  273. package/lib/wrapper/functionHandler.js.map +7 -1
  274. package/lib/wrapper/http.js +66 -56
  275. package/lib/wrapper/http.js.map +7 -1
  276. package/lib/wrapper/index.js +9 -21
  277. package/lib/wrapper/index.js.map +7 -1
  278. package/lib/wrapper/main.js +39 -20
  279. package/lib/wrapper/main.js.map +7 -1
  280. package/lib/wrapper/requestListener.js +50 -35
  281. package/lib/wrapper/requestListener.js.map +7 -1
  282. package/package.json +85 -79
  283. package/template/base/jest.config.ts +0 -6
  284. package/template/base/jest.setup.ts +2 -0
  285. package/template/base/tsconfig.json +2 -2
  286. package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
  287. package/template/express-rest-api/.nvmrc +1 -1
  288. package/template/express-rest-api/Dockerfile +1 -1
  289. package/template/express-rest-api/Dockerfile.dev-deps +1 -1
  290. package/template/express-rest-api/package.json +14 -14
  291. package/template/greeter/.buildkite/pipeline.yml +1 -1
  292. package/template/greeter/.nvmrc +1 -1
  293. package/template/greeter/Dockerfile +1 -1
  294. package/template/greeter/package.json +11 -11
  295. package/template/greeter/src/app.test.ts +3 -1
  296. package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
  297. package/template/koa-rest-api/.nvmrc +1 -1
  298. package/template/koa-rest-api/Dockerfile +1 -1
  299. package/template/koa-rest-api/Dockerfile.dev-deps +1 -1
  300. package/template/koa-rest-api/package.json +20 -21
  301. package/template/koa-rest-api/src/api/jobs/postJob.test.ts +3 -7
  302. package/template/koa-rest-api/src/api/jobs/postJob.ts +2 -2
  303. package/template/koa-rest-api/src/framework/validation.test.ts +17 -15
  304. package/template/koa-rest-api/src/framework/validation.ts +66 -12
  305. package/template/koa-rest-api/src/testing/types.ts +5 -10
  306. package/template/koa-rest-api/src/types/jobs.ts +5 -10
  307. package/template/lambda-sqs-worker/.buildkite/pipeline.yml +4 -4
  308. package/template/lambda-sqs-worker/Dockerfile +1 -1
  309. package/template/lambda-sqs-worker/package.json +16 -20
  310. package/template/lambda-sqs-worker/src/app.ts +2 -2
  311. package/template/lambda-sqs-worker/src/framework/validation.test.ts +37 -17
  312. package/template/lambda-sqs-worker/src/framework/validation.ts +10 -2
  313. package/template/lambda-sqs-worker/src/services/jobScorer.ts +2 -2
  314. package/template/lambda-sqs-worker/src/testing/types.ts +5 -10
  315. package/template/lambda-sqs-worker/src/types/jobScorer.ts +9 -16
  316. package/template/lambda-sqs-worker/src/types/pipelineEvents.ts +13 -20
  317. package/template/lambda-sqs-worker/tsconfig.json +13 -0
  318. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +4 -4
  319. package/template/lambda-sqs-worker-cdk/Dockerfile +1 -1
  320. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +6 -0
  321. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +3 -3
  322. package/template/lambda-sqs-worker-cdk/infra/index.ts +2 -2
  323. package/template/lambda-sqs-worker-cdk/package.json +14 -14
  324. package/template/lambda-sqs-worker-cdk/shared/context-types.ts +16 -25
  325. package/template/lambda-sqs-worker-cdk/tsconfig.json +13 -0
  326. package/template/oss-npm-package/.nvmrc +1 -1
  327. package/template/oss-npm-package/_package.json +1 -1
  328. package/template/private-npm-package/.nvmrc +1 -1
  329. package/template/private-npm-package/_package.json +1 -1
  330. package/jest/resolver.js +0 -24
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "incremental": true,
4
+ "isolatedModules": true,
4
5
  "moduleResolution": "node",
5
6
  "resolveJsonModule": true
6
7
  },
@@ -1,86 +1,58 @@
1
1
  const path = require('path');
2
2
 
3
3
  const { pathsToModuleNameMapper } = require('ts-jest');
4
- const {
5
- sys,
6
- findConfigFile,
7
- readConfigFile,
8
- parseJsonConfigFileContent,
9
- } = require('typescript');
10
4
 
11
- /**
12
- * Set a default `src` module alias for backward compatibility.
13
- *
14
- * TODO: drop this default in skuba v5.
15
- */
16
- const DEFAULT_PATHS = { src: ['src'], 'src/*': ['src/*'] };
5
+ const { tryParseTsConfig } = require('./tsConfig');
17
6
 
18
- /**
19
- * @returns {unknown}
20
- */
21
- const getConfigFromDisk = () => {
22
- const filename =
23
- findConfigFile('.', sys.fileExists.bind(this)) ?? 'tsconfig.json';
7
+ module.exports.createModuleNameMapper = (getConfig) => {
8
+ const maybeTsConfig = tryParseTsConfig(getConfig);
24
9
 
25
- return readConfigFile(filename, sys.readFile.bind(this)).config;
26
- };
27
-
28
- module.exports.createModuleNameMapper = (getConfig = getConfigFromDisk) => {
29
- try {
30
- const json = getConfig();
31
-
32
- const parsedConfig = parseJsonConfigFileContent(json, sys, '.');
33
-
34
- const paths = Object.fromEntries(
35
- Object.entries(parsedConfig.options.paths ?? DEFAULT_PATHS).flatMap(
36
- ([key, values]) => [
37
- // Pass through the input path entry almost verbatim.
38
- // We trim a trailing slash because TypeScript allows `import 'src'`
39
- // to be resolved by the alias `src/`, but Jest's mapper does not.
40
- [
41
- key.replace(/\/$/, ''),
42
- values.map((value) => value.replace(/\/$/, '')),
43
- ],
44
- // Append a variant of the input path entry.
45
- // As TypeScript allows both `import 'src'` and `import 'src/nested'`
46
- // to be resolved by the alias `src/*` (and likewise for plain `src`),
47
- // we need to seed two Jest mappings per path.
48
- ...(key.endsWith('/*')
49
- ? [
50
- [
51
- // Given a path `src/*`, seed an extra `src`.
52
- key.replace(/\/\*$/, ''),
53
- values.map((value) => value.replace(/\/\*$/, '')),
54
- ],
55
- ]
56
- : [
57
- [
58
- // Given a path `src`, seed an extra `src/*`.
59
- path.join(key, '*'),
60
- values.map((value) => path.join(value, '*')),
61
- ],
62
- ]),
10
+ const paths = Object.fromEntries(
11
+ Object.entries(maybeTsConfig?.options.paths ?? {}).flatMap(
12
+ ([key, values]) => [
13
+ // Pass through the input path entry almost verbatim.
14
+ // We trim a trailing slash because TypeScript allows `import 'src'`
15
+ // to be resolved by the alias `src/`, but Jest's mapper does not.
16
+ [
17
+ key.replace(/\/$/, ''),
18
+ values.map((value) => value.replace(/\/$/, '')),
63
19
  ],
64
- ),
65
- );
66
-
67
- const prefix = path.join('<rootDir>', parsedConfig.options.baseUrl ?? '.');
68
-
69
- const moduleNameMapper = pathsToModuleNameMapper(paths, { prefix });
70
-
71
- // Normalise away any `..`s that may crop up from `baseUrl` usage.
72
- // For example, a `baseUrl` of `src` and a path of `../cli` will result in
73
- // `<rootDir>/src/../cli`, which can be normalised to `<rootDir>/cli`.
74
- return Object.fromEntries(
75
- Object.entries(moduleNameMapper).map(([key, values]) => [
76
- key,
77
- Array.isArray(values)
78
- ? values.map((value) => path.normalize(value))
79
- : path.normalize(values),
80
- ]),
81
- );
82
- } catch {
83
- // Bail out here to support zero-config mode.
84
- return pathsToModuleNameMapper(DEFAULT_PATHS, { prefix: '<rootDir>' });
85
- }
20
+ // Append a variant of the input path entry.
21
+ // As TypeScript allows both `import 'src'` and `import 'src/nested'`
22
+ // to be resolved by the alias `src/*` (and likewise for plain `src`),
23
+ // we need to seed two Jest mappings per path.
24
+ ...(key.endsWith('/*')
25
+ ? [
26
+ [
27
+ // Given a path `src/*`, seed an extra `src`.
28
+ key.replace(/\/\*$/, ''),
29
+ values.map((value) => value.replace(/\/\*$/, '')),
30
+ ],
31
+ ]
32
+ : [
33
+ [
34
+ // Given a path `src`, seed an extra `src/*`.
35
+ path.join(key, '*'),
36
+ values.map((value) => path.join(value, '*')),
37
+ ],
38
+ ]),
39
+ ],
40
+ ),
41
+ );
42
+
43
+ const prefix = path.join('<rootDir>', maybeTsConfig?.options.baseUrl ?? '.');
44
+
45
+ const moduleNameMapper = pathsToModuleNameMapper(paths, { prefix });
46
+
47
+ // Normalise away any `..`s that may crop up from `baseUrl` usage.
48
+ // For example, a `baseUrl` of `src` and a path of `../cli` will result in
49
+ // `<rootDir>/src/../cli`, which can be normalised to `<rootDir>/cli`.
50
+ return Object.fromEntries(
51
+ Object.entries(moduleNameMapper).map(([key, values]) => [
52
+ key,
53
+ Array.isArray(values)
54
+ ? values.map((value) => path.normalize(value))
55
+ : path.normalize(values),
56
+ ]),
57
+ );
86
58
  };
@@ -56,19 +56,9 @@ describe('moduleNameMapper', () => {
56
56
 
57
57
  it('respects no paths', () => expect(act({})).toMatchInlineSnapshot(`{}`));
58
58
 
59
- it('falls back on undefined paths', () =>
60
- expect(act(undefined)).toMatchInlineSnapshot(`
61
- {
62
- "^src$": "<rootDir>/src",
63
- "^src/(.*)$": "<rootDir>/src/$1",
64
- }
65
- `));
59
+ it('defaults to no paths on undefined', () =>
60
+ expect(act(undefined)).toMatchInlineSnapshot(`{}`));
66
61
 
67
- it('falls back on invalid config', () =>
68
- expect(act('INVALID')).toMatchInlineSnapshot(`
69
- {
70
- "^src$": "<rootDir>/src",
71
- "^src/(.*)$": "<rootDir>/src/$1",
72
- }
73
- `));
62
+ it('defaults to no paths on invalid config', () =>
63
+ expect(act('INVALID')).toMatchInlineSnapshot(`{}`));
74
64
  });
package/jest/transform.js CHANGED
@@ -1,5 +1,7 @@
1
1
  const { defaults } = require('ts-jest/presets');
2
2
 
3
+ const { tryParseTsConfig } = require('./tsConfig');
4
+
3
5
  const TS_JEST_NAME = 'ts-jest';
4
6
 
5
7
  /**
@@ -10,10 +12,17 @@ const TS_JEST_NAME = 'ts-jest';
10
12
  */
11
13
  const TS_JEST_PATH = require.resolve(TS_JEST_NAME);
12
14
 
15
+ const maybeTsConfig = tryParseTsConfig();
16
+
13
17
  // Rewrite `ts-jest` transformations using our resolved `TS_JEST_PATH`.
14
18
  module.exports.transform = Object.fromEntries(
15
19
  Object.entries(defaults.transform).map(([key, value]) => [
16
20
  key,
17
- value === TS_JEST_NAME ? TS_JEST_PATH : value,
21
+ value === TS_JEST_NAME
22
+ ? [
23
+ TS_JEST_PATH,
24
+ { isolatedModules: maybeTsConfig?.options.isolatedModules ?? true },
25
+ ]
26
+ : value,
18
27
  ]),
19
28
  );
@@ -0,0 +1,26 @@
1
+ const {
2
+ sys,
3
+ findConfigFile,
4
+ readConfigFile,
5
+ parseJsonConfigFileContent,
6
+ } = require('typescript');
7
+
8
+ /**
9
+ * @returns {unknown}
10
+ */
11
+ const getTsConfigFromDisk = () => {
12
+ const filename =
13
+ findConfigFile('.', sys.fileExists.bind(this)) ?? 'tsconfig.json';
14
+
15
+ return readConfigFile(filename, sys.readFile.bind(this)).config;
16
+ };
17
+
18
+ module.exports.tryParseTsConfig = (getConfig = getTsConfigFromDisk) => {
19
+ try {
20
+ const json = getConfig();
21
+
22
+ return parseJsonConfigFileContent(json, sys, '.');
23
+ } catch {
24
+ // Bail out here to support zero-config mode.
25
+ }
26
+ };
@@ -1,36 +1,49 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.annotate = void 0;
4
- const exec_1 = require("../../utils/exec");
5
- const isAnnotationEnabled = async () => Boolean(process.env.BUILDKITE &&
6
- process.env.BUILDKITE_AGENT_ACCESS_TOKEN &&
7
- process.env.BUILDKITE_JOB_ID &&
8
- (await (0, exec_1.hasCommand)('buildkite-agent')));
9
- /**
10
- * Asynchronously uploads a Buildkite annotation.
11
- *
12
- * If the following environment variables are not present,
13
- * the function will silently return without attempting to annotate:
14
- *
15
- * - `BUILDKITE`
16
- * - `BUILDKITE_AGENT_ACCESS_TOKEN`
17
- * - `BUILDKITE_JOB_ID`
18
- *
19
- * The `buildkite-agent` binary must also be on your `PATH`.
20
- */
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 annotate_exports = {};
20
+ __export(annotate_exports, {
21
+ annotate: () => annotate
22
+ });
23
+ module.exports = __toCommonJS(annotate_exports);
24
+ var import_exec = require("../../utils/exec");
25
+ const isAnnotationEnabled = async () => Boolean(
26
+ process.env.BUILDKITE && process.env.BUILDKITE_AGENT_ACCESS_TOKEN && process.env.BUILDKITE_JOB_ID && await (0, import_exec.hasCommand)("buildkite-agent")
27
+ );
21
28
  const annotate = async (markdown, opts = {}) => {
22
- if (!(await isAnnotationEnabled())) {
23
- return;
24
- }
25
- // Always scope to the current Buildkite step.
26
- const context = [
27
- opts.scopeContextToStep && process.env.BUILDKITE_STEP_ID,
28
- opts.context,
29
- ]
30
- .filter(Boolean)
31
- .join('|');
32
- const { style } = opts;
33
- await (0, exec_1.exec)('buildkite-agent', 'annotate', ...(context ? ['--context', context] : []), ...(style ? ['--style', style] : []), markdown);
29
+ if (!await isAnnotationEnabled()) {
30
+ return;
31
+ }
32
+ const context = [
33
+ opts.scopeContextToStep && process.env.BUILDKITE_STEP_ID,
34
+ opts.context
35
+ ].filter(Boolean).join("|");
36
+ const { style } = opts;
37
+ await (0, import_exec.exec)(
38
+ "buildkite-agent",
39
+ "annotate",
40
+ ...context ? ["--context", context] : [],
41
+ ...style ? ["--style", style] : [],
42
+ markdown
43
+ );
34
44
  };
35
- exports.annotate = annotate;
36
- //# sourceMappingURL=annotate.js.map
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ annotate
48
+ });
49
+ //# sourceMappingURL=annotate.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"annotate.js","sourceRoot":"","sources":["../../../src/api/buildkite/annotate.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAIpD,MAAM,mBAAmB,GAAG,KAAK,IAAI,EAAE,CACrC,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,SAAS;IACnB,OAAO,CAAC,GAAG,CAAC,4BAA4B;IACxC,OAAO,CAAC,GAAG,CAAC,gBAAgB;IAC5B,CAAC,MAAM,IAAA,iBAAU,EAAC,iBAAiB,CAAC,CAAC,CACxC,CAAC;AAgBJ;;;;;;;;;;;GAWG;AACI,MAAM,QAAQ,GAAG,KAAK,EAC3B,QAAgB,EAChB,OAA0B,EAAE,EACb,EAAE;IACjB,IAAI,CAAC,CAAC,MAAM,mBAAmB,EAAE,CAAC,EAAE;QAClC,OAAO;KACR;IAED,8CAA8C;IAC9C,MAAM,OAAO,GAAG;QACd,IAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB;QACxD,IAAI,CAAC,OAAO;KACb;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAEvB,MAAM,IAAA,WAAI,EACR,iBAAiB,EACjB,UAAU,EACV,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAC1C,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EACpC,QAAQ,CACT,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,QAAQ,YAyBnB"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/api/buildkite/annotate.ts"],
4
+ "sourcesContent": ["import { exec, hasCommand } from '../../utils/exec';\n\nexport type AnnotationStyle = 'success' | 'info' | 'warning' | 'error';\n\nconst isAnnotationEnabled = async () =>\n Boolean(\n process.env.BUILDKITE &&\n process.env.BUILDKITE_AGENT_ACCESS_TOKEN &&\n process.env.BUILDKITE_JOB_ID &&\n (await hasCommand('buildkite-agent')),\n );\n\ninterface AnnotationOptions {\n context?: string;\n\n /**\n * Scopes an annotation's context to the Buildkite step ID.\n *\n * This lets you emit distinct annotations per step, and only takes effect if\n * the `BUILDKITE_STEP_ID` environment variable is present.\n */\n scopeContextToStep?: boolean;\n\n style?: AnnotationStyle;\n}\n\n/**\n * Asynchronously uploads a Buildkite annotation.\n *\n * If the following environment variables are not present,\n * the function will silently return without attempting to annotate:\n *\n * - `BUILDKITE`\n * - `BUILDKITE_AGENT_ACCESS_TOKEN`\n * - `BUILDKITE_JOB_ID`\n *\n * The `buildkite-agent` binary must also be on your `PATH`.\n */\nexport const annotate = async (\n markdown: string,\n opts: AnnotationOptions = {},\n): Promise<void> => {\n if (!(await isAnnotationEnabled())) {\n return;\n }\n\n // Always scope to the current Buildkite step.\n const context = [\n opts.scopeContextToStep && process.env.BUILDKITE_STEP_ID,\n opts.context,\n ]\n .filter(Boolean)\n .join('|');\n\n const { style } = opts;\n\n await exec(\n 'buildkite-agent',\n 'annotate',\n ...(context ? ['--context', context] : []),\n ...(style ? ['--style', style] : []),\n markdown,\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AAIjC,MAAM,sBAAsB,YAC1B;AAAA,EACE,QAAQ,IAAI,aACV,QAAQ,IAAI,gCACZ,QAAQ,IAAI,oBACX,UAAM,wBAAW,iBAAiB;AACvC;AA4BK,MAAM,WAAW,OACtB,UACA,OAA0B,CAAC,MACT;AAClB,MAAI,CAAE,MAAM,oBAAoB,GAAI;AAClC;AAAA,EACF;AAGA,QAAM,UAAU;AAAA,IACd,KAAK,sBAAsB,QAAQ,IAAI;AAAA,IACvC,KAAK;AAAA,EACP,EACG,OAAO,OAAO,EACd,KAAK,GAAG;AAEX,QAAM,EAAE,MAAM,IAAI;AAElB,YAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,GAAI,UAAU,CAAC,aAAa,OAAO,IAAI,CAAC;AAAA,IACxC,GAAI,QAAQ,CAAC,WAAW,KAAK,IAAI,CAAC;AAAA,IAClC;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,8 +1,32 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.md = exports.annotate = void 0;
4
- var annotate_1 = require("./annotate");
5
- Object.defineProperty(exports, "annotate", { enumerable: true, get: function () { return annotate_1.annotate; } });
6
- var md_1 = require("./md");
7
- Object.defineProperty(exports, "md", { enumerable: true, get: function () { return md_1.md; } });
8
- //# sourceMappingURL=index.js.map
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 buildkite_exports = {};
20
+ __export(buildkite_exports, {
21
+ annotate: () => import_annotate.annotate,
22
+ md: () => import_md.md
23
+ });
24
+ module.exports = __toCommonJS(buildkite_exports);
25
+ var import_annotate = require("./annotate");
26
+ var import_md = require("./md");
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ annotate,
30
+ md
31
+ });
32
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/buildkite/index.ts"],"names":[],"mappings":";;;AACA,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,2BAA0B;AAAjB,wFAAA,EAAE,OAAA"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/api/buildkite/index.ts"],
4
+ "sourcesContent": ["export type { AnnotationStyle } from './annotate';\nexport { annotate } from './annotate';\nexport { md } from './md';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAyB;AACzB,gBAAmB;",
6
+ "names": []
7
+ }
@@ -1,10 +1,33 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.md = void 0;
4
- /**
5
- * @internal
6
- */
7
- exports.md = {
8
- terminal: (code) => `\`\`\`term\n${code.replace(/```/g, '\\`\\`\\`')}\n\`\`\``,
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
9
  };
10
- //# sourceMappingURL=md.js.map
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 md_exports = {};
20
+ __export(md_exports, {
21
+ md: () => md
22
+ });
23
+ module.exports = __toCommonJS(md_exports);
24
+ const md = {
25
+ terminal: (code) => `\`\`\`term
26
+ ${code.replace(/```/g, "\\`\\`\\`")}
27
+ \`\`\``
28
+ };
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ md
32
+ });
33
+ //# sourceMappingURL=md.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"md.js","sourceRoot":"","sources":["../../../src/api/buildkite/md.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,EAAE,GAAG;IAChB,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE,CACzB,eAAe,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,UAAU;CAC7D,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/api/buildkite/md.ts"],
4
+ "sourcesContent": ["/**\n * @internal\n */\nexport const md = {\n terminal: (code: string) =>\n `\\`\\`\\`term\\n${code.replace(/```/g, '\\\\`\\\\`\\\\`')}\\n\\`\\`\\``,\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,KAAK;AAAA,EAChB,UAAU,CAAC,SACT;AAAA,EAAe,KAAK,QAAQ,QAAQ,WAAW;AAAA;AACnD;",
6
+ "names": []
7
+ }
@@ -1,20 +1,48 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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 });
4
11
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.commit = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const isomorphic_git_1 = __importDefault(require("isomorphic-git"));
9
- /**
10
- * Writes a commit to the local Git repository.
11
- */
12
- const commit = async ({ author = { name: 'skuba' }, committer = { name: 'skuba' }, dir, message, }) => isomorphic_git_1.default.commit({
13
- author,
14
- committer,
15
- dir,
16
- fs: fs_extra_1.default,
17
- message,
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
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var commit_exports = {};
26
+ __export(commit_exports, {
27
+ commit: () => commit
28
+ });
29
+ module.exports = __toCommonJS(commit_exports);
30
+ var import_fs_extra = __toESM(require("fs-extra"));
31
+ var import_isomorphic_git = __toESM(require("isomorphic-git"));
32
+ const commit = async ({
33
+ author = { name: "skuba" },
34
+ committer = { name: "skuba" },
35
+ dir,
36
+ message
37
+ }) => import_isomorphic_git.default.commit({
38
+ author,
39
+ committer,
40
+ dir,
41
+ fs: import_fs_extra.default,
42
+ message
43
+ });
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ commit
18
47
  });
19
- exports.commit = commit;
20
- //# sourceMappingURL=commit.js.map
48
+ //# sourceMappingURL=commit.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"commit.js","sourceRoot":"","sources":["../../../src/api/git/commit.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAC1B,oEAAiC;AAcjC;;GAEG;AACI,MAAM,MAAM,GAAG,KAAK,EAAE,EAC3B,MAAM,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAC1B,SAAS,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAC7B,GAAG,EACH,OAAO,GACU,EAAmB,EAAE,CACtC,wBAAG,CAAC,MAAM,CAAC;IACT,MAAM;IACN,SAAS;IACT,GAAG;IACH,EAAE,EAAF,kBAAE;IACF,OAAO;CACR,CAAC,CAAC;AAZQ,QAAA,MAAM,UAYd"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/api/git/commit.ts"],
4
+ "sourcesContent": ["import fs from 'fs-extra';\nimport git from 'isomorphic-git';\n\nexport interface Identity {\n email?: string;\n name?: string;\n}\n\ninterface CommitParameters {\n author?: Identity;\n committer?: Identity;\n dir: string;\n message: string;\n}\n\n/**\n * Writes a commit to the local Git repository.\n */\nexport const commit = async ({\n author = { name: 'skuba' },\n committer = { name: 'skuba' },\n dir,\n message,\n}: CommitParameters): Promise<string> =>\n git.commit({\n author,\n committer,\n dir,\n fs,\n message,\n });\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAe;AACf,4BAAgB;AAiBT,MAAM,SAAS,OAAO;AAAA,EAC3B,SAAS,EAAE,MAAM,QAAQ;AAAA,EACzB,YAAY,EAAE,MAAM,QAAQ;AAAA,EAC5B;AAAA,EACA;AACF,MACE,sBAAAA,QAAI,OAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA,oBAAAC;AAAA,EACA;AACF,CAAC;",
6
+ "names": ["git", "fs"]
7
+ }
@@ -1,30 +1,60 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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 });
4
11
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.commitAllChanges = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const isomorphic_git_1 = __importDefault(require("isomorphic-git"));
9
- const commit_1 = require("./commit");
10
- const getChangedFiles_1 = require("./getChangedFiles");
11
- /**
12
- * Stages all changes and writes a commit to the local Git repository.
13
- */
14
- const commitAllChanges = async ({ dir, message, author, committer, }) => {
15
- const changedFiles = await (0, getChangedFiles_1.getChangedFiles)({ dir });
16
- if (!changedFiles.length) {
17
- return;
18
- }
19
- await Promise.all(changedFiles.map((file) => file.state === 'deleted'
20
- ? isomorphic_git_1.default.remove({ fs: fs_extra_1.default, dir, filepath: file.path })
21
- : isomorphic_git_1.default.add({ fs: fs_extra_1.default, dir, filepath: file.path })));
22
- return (0, commit_1.commit)({
23
- dir,
24
- message,
25
- author,
26
- committer,
27
- });
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;
28
19
  };
29
- exports.commitAllChanges = commitAllChanges;
30
- //# sourceMappingURL=commitAllChanges.js.map
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var commitAllChanges_exports = {};
26
+ __export(commitAllChanges_exports, {
27
+ commitAllChanges: () => commitAllChanges
28
+ });
29
+ module.exports = __toCommonJS(commitAllChanges_exports);
30
+ var import_fs_extra = __toESM(require("fs-extra"));
31
+ var import_isomorphic_git = __toESM(require("isomorphic-git"));
32
+ var import_commit = require("./commit");
33
+ var import_getChangedFiles = require("./getChangedFiles");
34
+ const commitAllChanges = async ({
35
+ dir,
36
+ message,
37
+ author,
38
+ committer
39
+ }) => {
40
+ const changedFiles = await (0, import_getChangedFiles.getChangedFiles)({ dir });
41
+ if (!changedFiles.length) {
42
+ return;
43
+ }
44
+ await Promise.all(
45
+ changedFiles.map(
46
+ (file) => file.state === "deleted" ? import_isomorphic_git.default.remove({ fs: import_fs_extra.default, dir, filepath: file.path }) : import_isomorphic_git.default.add({ fs: import_fs_extra.default, dir, filepath: file.path })
47
+ )
48
+ );
49
+ return (0, import_commit.commit)({
50
+ dir,
51
+ message,
52
+ author,
53
+ committer
54
+ });
55
+ };
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ commitAllChanges
59
+ });
60
+ //# sourceMappingURL=commitAllChanges.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"commitAllChanges.js","sourceRoot":"","sources":["../../../src/api/git/commitAllChanges.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAC1B,oEAAiC;AAEjC,qCAAkC;AAElC,uDAAoD;AASpD;;GAEG;AACI,MAAM,gBAAgB,GAAG,KAAK,EAAE,EACrC,GAAG,EACH,OAAO,EACP,MAAM,EACN,SAAS,GACW,EAA+B,EAAE;IACrD,MAAM,YAAY,GAAG,MAAM,IAAA,iCAAe,EAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAEpD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACxB,OAAO;KACR;IAED,MAAM,OAAO,CAAC,GAAG,CACf,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACxB,IAAI,CAAC,KAAK,KAAK,SAAS;QACtB,CAAC,CAAC,wBAAG,CAAC,MAAM,CAAC,EAAE,EAAE,EAAF,kBAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;QAC9C,CAAC,CAAC,wBAAG,CAAC,GAAG,CAAC,EAAE,EAAE,EAAF,kBAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAC9C,CACF,CAAC;IAEF,OAAO,IAAA,eAAM,EAAC;QACZ,GAAG;QACH,OAAO;QACP,MAAM;QACN,SAAS;KACV,CAAC,CAAC;AACL,CAAC,CAAC;AA1BW,QAAA,gBAAgB,oBA0B3B"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/api/git/commitAllChanges.ts"],
4
+ "sourcesContent": ["import fs from 'fs-extra';\nimport git from 'isomorphic-git';\n\nimport { commit } from './commit';\nimport type { Identity } from './commit';\nimport { getChangedFiles } from './getChangedFiles';\n\ninterface CommitAllParameters {\n dir: string;\n message: string;\n author?: Identity;\n committer?: Identity;\n}\n\n/**\n * Stages all changes and writes a commit to the local Git repository.\n */\nexport const commitAllChanges = async ({\n dir,\n message,\n author,\n committer,\n}: CommitAllParameters): Promise<string | undefined> => {\n const changedFiles = await getChangedFiles({ dir });\n\n if (!changedFiles.length) {\n return;\n }\n\n await Promise.all(\n changedFiles.map((file) =>\n file.state === 'deleted'\n ? git.remove({ fs, dir, filepath: file.path })\n : git.add({ fs, dir, filepath: file.path }),\n ),\n );\n\n return commit({\n dir,\n message,\n author,\n committer,\n });\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAe;AACf,4BAAgB;AAEhB,oBAAuB;AAEvB,6BAAgC;AAYzB,MAAM,mBAAmB,OAAO;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAwD;AACtD,QAAM,eAAe,UAAM,wCAAgB,EAAE,IAAI,CAAC;AAElD,MAAI,CAAC,aAAa,QAAQ;AACxB;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,aAAa;AAAA,MAAI,CAAC,SAChB,KAAK,UAAU,YACX,sBAAAA,QAAI,OAAO,EAAE,oBAAAC,SAAI,KAAK,UAAU,KAAK,KAAK,CAAC,IAC3C,sBAAAD,QAAI,IAAI,EAAE,oBAAAC,SAAI,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,IAC9C;AAAA,EACF;AAEA,aAAO,sBAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
6
+ "names": ["git", "fs"]
7
+ }