skuba 13.0.0-subpath-imports-20250730060533 → 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 (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
@@ -1,85 +0,0 @@
1
- import * as Git from '../git/index.js';
2
- interface UploadAllFileChangesParams {
3
- dir: string;
4
- /**
5
- * The branch name
6
- */
7
- branch: string;
8
- /**
9
- * The headline of the commit message
10
- */
11
- messageHeadline: string;
12
- /**
13
- * File changes to exclude from the upload.
14
- *
15
- * Defaults to `[]` (no exclusions).
16
- */
17
- ignore?: Git.ChangedFile[];
18
- /**
19
- * The body of the commit message
20
- */
21
- messageBody?: string;
22
- /**
23
- * Updates the local Git repository to match the new remote branch state
24
- */
25
- updateLocal?: boolean;
26
- }
27
- /**
28
- * Retrieves all file changes from the local Git repository using
29
- * `getChangedFiles`, then uploads the changes to a specified GitHub branch
30
- * using `uploadFileChanges`.
31
- *
32
- * Returns the commit ID, or `undefined` if there are no changes to commit.
33
- *
34
- * The file changes will appear as verified commits on GitHub.
35
- *
36
- * This will not update the local Git repository unless `updateLocal` is
37
- * specified.
38
- */
39
- export declare const uploadAllFileChanges: ({ branch, dir, messageHeadline, ignore, messageBody, updateLocal, }: UploadAllFileChangesParams) => Promise<string | undefined>;
40
- interface FileAddition {
41
- contents: unknown;
42
- path: string;
43
- }
44
- interface FileDeletion {
45
- path: string;
46
- }
47
- export interface FileChanges {
48
- additions: FileAddition[];
49
- deletions: FileDeletion[];
50
- }
51
- /**
52
- * Takes a list of `ChangedFiles`, reads them from the file system, and maps
53
- * them to GitHub GraphQL `FileChanges`.
54
- *
55
- * https://docs.github.com/en/graphql/reference/input-objects#filechanges
56
- */
57
- export declare const readFileChanges: (dir: string, changedFiles: Git.ChangedFile[]) => Promise<FileChanges>;
58
- interface UploadFileChangesParams {
59
- dir: string;
60
- /**
61
- * The branch name
62
- */
63
- branch: string;
64
- /**
65
- * The headline of the commit message
66
- */
67
- messageHeadline: string;
68
- /**
69
- * The body of the commit message
70
- */
71
- messageBody?: string;
72
- /**
73
- * File additions and deletions
74
- */
75
- fileChanges: FileChanges;
76
- }
77
- /**
78
- * Uploads file changes from the local workspace to a specified GitHub branch.
79
- *
80
- * The file changes will appear as verified commits on GitHub.
81
- *
82
- * This will not update the local Git repository.
83
- */
84
- export declare const uploadFileChanges: ({ dir, branch, messageHeadline, messageBody, fileChanges, }: UploadFileChangesParams) => Promise<string>;
85
- export {};
@@ -1,166 +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 push_exports = {};
30
- __export(push_exports, {
31
- readFileChanges: () => readFileChanges,
32
- uploadAllFileChanges: () => uploadAllFileChanges,
33
- uploadFileChanges: () => uploadFileChanges
34
- });
35
- module.exports = __toCommonJS(push_exports);
36
- var import_path = __toESM(require("path"));
37
- var import_fs_extra = __toESM(require("fs-extra"));
38
- var Git = __toESM(require("../git/index.js"));
39
- var import_environment = require("./environment.js");
40
- var import_octokit = require("./octokit.js");
41
- const uploadAllFileChanges = async ({
42
- branch,
43
- dir,
44
- messageHeadline,
45
- ignore,
46
- messageBody,
47
- updateLocal = false
48
- }) => {
49
- const changedFiles = await Git.getChangedFiles({ dir, ignore });
50
- if (!changedFiles.length) {
51
- return;
52
- }
53
- const fileChanges = await readFileChanges(dir, changedFiles);
54
- const commitId = await uploadFileChanges({
55
- dir,
56
- branch,
57
- messageHeadline,
58
- messageBody,
59
- fileChanges
60
- });
61
- if (updateLocal) {
62
- await Promise.all(
63
- [...fileChanges.additions, ...fileChanges.deletions].map(
64
- (file) => import_fs_extra.default.rm(file.path)
65
- )
66
- );
67
- await Git.fastForwardBranch({
68
- ref: branch,
69
- auth: { type: "gitHubApp" },
70
- dir
71
- });
72
- }
73
- return commitId;
74
- };
75
- const readFileChanges = async (dir, changedFiles) => {
76
- const { added, deleted } = changedFiles.reduce(
77
- (files, changedFile) => {
78
- const filePath = changedFile.path;
79
- if (changedFile.state === "deleted") {
80
- files.deleted.push(filePath);
81
- } else {
82
- files.added.push(filePath);
83
- }
84
- return files;
85
- },
86
- { added: [], deleted: [] }
87
- );
88
- const gitRoot = await Git.findRoot({ dir });
89
- const toRootPath = (filePath) => {
90
- if (!gitRoot) {
91
- return filePath;
92
- }
93
- return import_path.default.resolve(gitRoot, filePath);
94
- };
95
- const additions = await Promise.all(
96
- added.map(async (filePath) => ({
97
- path: filePath,
98
- contents: await import_fs_extra.default.promises.readFile(toRootPath(filePath), {
99
- encoding: "base64"
100
- })
101
- }))
102
- );
103
- const deletions = deleted.map((filePath) => ({
104
- path: filePath
105
- }));
106
- return {
107
- additions,
108
- deletions
109
- };
110
- };
111
- const uploadFileChanges = async ({
112
- dir,
113
- branch,
114
- messageHeadline,
115
- messageBody,
116
- fileChanges
117
- }) => {
118
- const authToken = (0, import_environment.apiTokenFromEnvironment)();
119
- if (!authToken) {
120
- throw new Error(
121
- "Could not read a GitHub API token from the environment. Please set GITHUB_API_TOKEN or GITHUB_TOKEN."
122
- );
123
- }
124
- const [{ owner, repo }, headCommitId] = await Promise.all([
125
- Git.getOwnerAndRepo({ dir }),
126
- Git.getHeadCommitId({ dir })
127
- ]);
128
- const input = {
129
- branch: {
130
- repositoryNameWithOwner: `${owner}/${repo}`,
131
- branchName: branch
132
- },
133
- message: {
134
- headline: messageHeadline,
135
- body: messageBody
136
- },
137
- expectedHeadOid: headCommitId,
138
- clientMutationId: "skuba",
139
- fileChanges
140
- };
141
- const result = await (0, import_octokit.graphql)(
142
- `
143
- mutation Mutation($input: CreateCommitOnBranchInput!) {
144
- createCommitOnBranch(input: $input) {
145
- commit {
146
- oid
147
- }
148
- }
149
- }
150
- `,
151
- {
152
- input,
153
- headers: {
154
- authorization: `Bearer ${authToken}`
155
- }
156
- }
157
- );
158
- return result.createCommitOnBranch.commit.oid;
159
- };
160
- // Annotate the CommonJS export names for ESM import in node:
161
- 0 && (module.exports = {
162
- readFileChanges,
163
- uploadAllFileChanges,
164
- uploadFileChanges
165
- });
166
- //# sourceMappingURL=push.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/api/github/push.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport type { CreateCommitOnBranchInput } from '@octokit/graphql-schema';\nimport fs from 'fs-extra';\n\nimport * as Git from '../git/index.js';\n\nimport { apiTokenFromEnvironment } from './environment.js';\nimport { graphql } from './octokit.js';\n\ninterface CreateCommitResult {\n createCommitOnBranch: {\n commit: {\n oid: string;\n };\n };\n}\n\ninterface UploadAllFileChangesParams {\n dir: string;\n /**\n * The branch name\n */\n branch: string;\n /**\n * The headline of the commit message\n */\n messageHeadline: string;\n\n /**\n * File changes to exclude from the upload.\n *\n * Defaults to `[]` (no exclusions).\n */\n ignore?: Git.ChangedFile[];\n /**\n * The body of the commit message\n */\n messageBody?: string;\n /**\n * Updates the local Git repository to match the new remote branch state\n */\n updateLocal?: boolean;\n}\n\n/**\n * Retrieves all file changes from the local Git repository using\n * `getChangedFiles`, then uploads the changes to a specified GitHub branch\n * using `uploadFileChanges`.\n *\n * Returns the commit ID, or `undefined` if there are no changes to commit.\n *\n * The file changes will appear as verified commits on GitHub.\n *\n * This will not update the local Git repository unless `updateLocal` is\n * specified.\n */\nexport const uploadAllFileChanges = async ({\n branch,\n dir,\n messageHeadline,\n\n ignore,\n messageBody,\n updateLocal = false,\n}: UploadAllFileChangesParams): Promise<string | undefined> => {\n const changedFiles = await Git.getChangedFiles({ dir, ignore });\n\n if (!changedFiles.length) {\n return;\n }\n\n const fileChanges = await readFileChanges(dir, changedFiles);\n\n const commitId = await uploadFileChanges({\n dir,\n branch,\n messageHeadline,\n messageBody,\n fileChanges,\n });\n\n if (updateLocal) {\n await Promise.all(\n [...fileChanges.additions, ...fileChanges.deletions].map((file) =>\n fs.rm(file.path),\n ),\n );\n\n await Git.fastForwardBranch({\n ref: branch,\n auth: { type: 'gitHubApp' },\n dir,\n });\n }\n\n return commitId;\n};\n\ninterface FileAddition {\n contents: unknown;\n path: string;\n}\n\ninterface FileDeletion {\n path: string;\n}\n\nexport interface FileChanges {\n additions: FileAddition[];\n deletions: FileDeletion[];\n}\n\n/**\n * Takes a list of `ChangedFiles`, reads them from the file system, and maps\n * them to GitHub GraphQL `FileChanges`.\n *\n * https://docs.github.com/en/graphql/reference/input-objects#filechanges\n */\nexport const readFileChanges = async (\n dir: string,\n changedFiles: Git.ChangedFile[],\n): Promise<FileChanges> => {\n const { added, deleted } = changedFiles.reduce<{\n added: string[];\n deleted: string[];\n }>(\n (files, changedFile) => {\n const filePath = changedFile.path;\n if (changedFile.state === 'deleted') {\n files.deleted.push(filePath);\n } else {\n files.added.push(filePath);\n }\n\n return files;\n },\n { added: [], deleted: [] },\n );\n\n const gitRoot = await Git.findRoot({ dir });\n\n const toRootPath = (filePath: string) => {\n if (!gitRoot) {\n return filePath;\n }\n\n return path.resolve(gitRoot, filePath);\n };\n\n const additions: FileAddition[] = await Promise.all(\n added.map(async (filePath) => ({\n path: filePath,\n contents: await fs.promises.readFile(toRootPath(filePath), {\n encoding: 'base64',\n }),\n })),\n );\n\n const deletions: FileDeletion[] = deleted.map((filePath) => ({\n path: filePath,\n }));\n\n return {\n additions,\n deletions,\n };\n};\n\ninterface UploadFileChangesParams {\n dir: string;\n /**\n * The branch name\n */\n branch: string;\n /**\n * The headline of the commit message\n */\n messageHeadline: string;\n /**\n * The body of the commit message\n */\n messageBody?: string;\n /**\n * File additions and deletions\n */\n fileChanges: FileChanges;\n}\n\n/**\n * Uploads file changes from the local workspace to a specified GitHub branch.\n *\n * The file changes will appear as verified commits on GitHub.\n *\n * This will not update the local Git repository.\n */\nexport const uploadFileChanges = async ({\n dir,\n branch,\n messageHeadline,\n messageBody,\n fileChanges,\n}: UploadFileChangesParams): Promise<string> => {\n const authToken = apiTokenFromEnvironment();\n if (!authToken) {\n throw new Error(\n 'Could not read a GitHub API token from the environment. Please set GITHUB_API_TOKEN or GITHUB_TOKEN.',\n );\n }\n\n const [{ owner, repo }, headCommitId] = await Promise.all([\n Git.getOwnerAndRepo({ dir }),\n Git.getHeadCommitId({ dir }),\n ]);\n\n const input: CreateCommitOnBranchInput = {\n branch: {\n repositoryNameWithOwner: `${owner}/${repo}`,\n branchName: branch,\n },\n message: {\n headline: messageHeadline,\n body: messageBody,\n },\n expectedHeadOid: headCommitId,\n clientMutationId: 'skuba',\n fileChanges,\n };\n\n const result = await graphql<CreateCommitResult>(\n `\n mutation Mutation($input: CreateCommitOnBranchInput!) {\n createCommitOnBranch(input: $input) {\n commit {\n oid\n }\n }\n }\n `,\n {\n input,\n headers: {\n authorization: `Bearer ${authToken}`,\n },\n },\n );\n\n return result.createCommitOnBranch.commit.oid;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGjB,sBAAe;AAEf,UAAqB;AAErB,yBAAwC;AACxC,qBAAwB;AAiDjB,MAAM,uBAAuB,OAAO;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA,cAAc;AAChB,MAA+D;AAC7D,QAAM,eAAe,MAAM,IAAI,gBAAgB,EAAE,KAAK,OAAO,CAAC;AAE9D,MAAI,CAAC,aAAa,QAAQ;AACxB;AAAA,EACF;AAEA,QAAM,cAAc,MAAM,gBAAgB,KAAK,YAAY;AAE3D,QAAM,WAAW,MAAM,kBAAkB;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,MAAI,aAAa;AACf,UAAM,QAAQ;AAAA,MACZ,CAAC,GAAG,YAAY,WAAW,GAAG,YAAY,SAAS,EAAE;AAAA,QAAI,CAAC,SACxD,gBAAAA,QAAG,GAAG,KAAK,IAAI;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,IAAI,kBAAkB;AAAA,MAC1B,KAAK;AAAA,MACL,MAAM,EAAE,MAAM,YAAY;AAAA,MAC1B;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAsBO,MAAM,kBAAkB,OAC7B,KACA,iBACyB;AACzB,QAAM,EAAE,OAAO,QAAQ,IAAI,aAAa;AAAA,IAItC,CAAC,OAAO,gBAAgB;AACtB,YAAM,WAAW,YAAY;AAC7B,UAAI,YAAY,UAAU,WAAW;AACnC,cAAM,QAAQ,KAAK,QAAQ;AAAA,MAC7B,OAAO;AACL,cAAM,MAAM,KAAK,QAAQ;AAAA,MAC3B;AAEA,aAAO;AAAA,IACT;AAAA,IACA,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE;AAAA,EAC3B;AAEA,QAAM,UAAU,MAAM,IAAI,SAAS,EAAE,IAAI,CAAC;AAE1C,QAAM,aAAa,CAAC,aAAqB;AACvC,QAAI,CAAC,SAAS;AACZ,aAAO;AAAA,IACT;AAEA,WAAO,YAAAC,QAAK,QAAQ,SAAS,QAAQ;AAAA,EACvC;AAEA,QAAM,YAA4B,MAAM,QAAQ;AAAA,IAC9C,MAAM,IAAI,OAAO,cAAc;AAAA,MAC7B,MAAM;AAAA,MACN,UAAU,MAAM,gBAAAD,QAAG,SAAS,SAAS,WAAW,QAAQ,GAAG;AAAA,QACzD,UAAU;AAAA,MACZ,CAAC;AAAA,IACH,EAAE;AAAA,EACJ;AAEA,QAAM,YAA4B,QAAQ,IAAI,CAAC,cAAc;AAAA,IAC3D,MAAM;AAAA,EACR,EAAE;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AA6BO,MAAM,oBAAoB,OAAO;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAgD;AAC9C,QAAM,gBAAY,4CAAwB;AAC1C,MAAI,CAAC,WAAW;AACd,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,CAAC,EAAE,OAAO,KAAK,GAAG,YAAY,IAAI,MAAM,QAAQ,IAAI;AAAA,IACxD,IAAI,gBAAgB,EAAE,IAAI,CAAC;AAAA,IAC3B,IAAI,gBAAgB,EAAE,IAAI,CAAC;AAAA,EAC7B,CAAC;AAED,QAAM,QAAmC;AAAA,IACvC,QAAQ;AAAA,MACN,yBAAyB,GAAG,KAAK,IAAI,IAAI;AAAA,MACzC,YAAY;AAAA,IACd;AAAA,IACA,SAAS;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,IACA,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB;AAAA,EACF;AAEA,QAAM,SAAS,UAAM;AAAA,IACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA;AAAA,MACE;AAAA,MACA,SAAS;AAAA,QACP,eAAe,UAAU,SAAS;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,qBAAqB,OAAO;AAC5C;",
6
- "names": ["fs", "path"]
7
- }
@@ -1,4 +0,0 @@
1
- export declare const resolveComposeAddress: (privateHost: string, privatePort: number) => Promise<{
2
- host: string;
3
- port: number;
4
- }>;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var compose_exports = {};
20
- __export(compose_exports, {
21
- resolveComposeAddress: () => resolveComposeAddress
22
- });
23
- module.exports = __toCommonJS(compose_exports);
24
- var import_exec = require("../../utils/exec.js");
25
- const portStringToNumber = (portString) => {
26
- const port = Number(portString);
27
- if (!Number.isSafeInteger(port)) {
28
- throw Error(`received non-integer port: '${portString}'`);
29
- }
30
- return port;
31
- };
32
- const resolveComposeAddress = async (privateHost, privatePort) => {
33
- const exec = (0, import_exec.createExec)({ stdio: "pipe" });
34
- const { stdout } = await exec(
35
- "docker",
36
- "compose",
37
- "port",
38
- privateHost,
39
- String(privatePort)
40
- );
41
- const [host, portString] = stdout.trim().split(":");
42
- if (!host || !portString) {
43
- throw Error(`Docker Compose returned unrecognised address: '${stdout}'`);
44
- }
45
- return { host, port: portStringToNumber(portString) };
46
- };
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- resolveComposeAddress
50
- });
51
- //# sourceMappingURL=compose.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/api/net/compose.ts"],
4
- "sourcesContent": ["import { createExec } from '../../utils/exec.js';\n\nconst portStringToNumber = (portString: string) => {\n const port = Number(portString);\n\n if (!Number.isSafeInteger(port)) {\n throw Error(`received non-integer port: '${portString}'`);\n }\n\n return port;\n};\n\nexport const resolveComposeAddress = async (\n privateHost: string,\n privatePort: number,\n) => {\n const exec = createExec({ stdio: 'pipe' });\n\n const { stdout } = await exec(\n 'docker',\n 'compose',\n 'port',\n privateHost,\n String(privatePort),\n );\n\n const [host, portString] = stdout.trim().split(':');\n\n if (!host || !portString) {\n throw Error(`Docker Compose returned unrecognised address: '${stdout}'`);\n }\n\n return { host, port: portStringToNumber(portString) };\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAE3B,MAAM,qBAAqB,CAAC,eAAuB;AACjD,QAAM,OAAO,OAAO,UAAU;AAE9B,MAAI,CAAC,OAAO,cAAc,IAAI,GAAG;AAC/B,UAAM,MAAM,+BAA+B,UAAU,GAAG;AAAA,EAC1D;AAEA,SAAO;AACT;AAEO,MAAM,wBAAwB,OACnC,aACA,gBACG;AACH,QAAM,WAAO,wBAAW,EAAE,OAAO,OAAO,CAAC;AAEzC,QAAM,EAAE,OAAO,IAAI,MAAM;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,WAAW;AAAA,EACpB;AAEA,QAAM,CAAC,MAAM,UAAU,IAAI,OAAO,KAAK,EAAE,MAAM,GAAG;AAElD,MAAI,CAAC,QAAQ,CAAC,YAAY;AACxB,UAAM,MAAM,kDAAkD,MAAM,GAAG;AAAA,EACzE;AAEA,SAAO,EAAE,MAAM,MAAM,mBAAmB,UAAU,EAAE;AACtD;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- export { waitFor } from './waitFor.js';
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/api/net/index.ts"],
4
- "sourcesContent": ["export { waitFor } from './waitFor.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;",
6
- "names": []
7
- }
@@ -1,5 +0,0 @@
1
- export interface SocketAddress {
2
- host: string;
3
- port: number;
4
- }
5
- export declare const pollSocket: (host: string, port: number, timeout: number) => Promise<void>;
@@ -1,68 +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 socket_exports = {};
30
- __export(socket_exports, {
31
- pollSocket: () => pollSocket
32
- });
33
- module.exports = __toCommonJS(socket_exports);
34
- var import_net = __toESM(require("net"));
35
- const trySocket = async (host, port) => new Promise((resolve) => {
36
- const socket = new import_net.default.Socket();
37
- const onFailure = () => {
38
- socket.destroy();
39
- resolve(false);
40
- };
41
- const onSuccess = () => socket.end(() => resolve(true));
42
- socket.connect(port, host, onSuccess).once("error", onFailure).once("timeout", onFailure).setTimeout(1e3);
43
- });
44
- const pollSocket = async (host, port, timeout) => new Promise((resolve, reject) => {
45
- const callPort = async () => {
46
- const success = await trySocket(host, port);
47
- if (!success) {
48
- return;
49
- }
50
- clearTimeout(intervalId);
51
- clearTimeout(timeoutId);
52
- resolve();
53
- };
54
- const intervalId = setInterval(() => {
55
- callPort().catch(() => void 0);
56
- }, 250);
57
- const timeoutId = setTimeout(() => {
58
- clearTimeout(intervalId);
59
- clearTimeout(timeoutId);
60
- reject(Error(`could not reach ${host}:${port} within ${timeout}ms`));
61
- }, timeout);
62
- callPort().catch(() => void 0);
63
- });
64
- // Annotate the CommonJS export names for ESM import in node:
65
- 0 && (module.exports = {
66
- pollSocket
67
- });
68
- //# sourceMappingURL=socket.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/api/net/socket.ts"],
4
- "sourcesContent": ["import net from 'net';\n\nexport interface SocketAddress {\n host: string;\n port: number;\n}\n\nconst trySocket = async (host: string, port: number) =>\n new Promise((resolve) => {\n const socket = new net.Socket();\n\n const onFailure = () => {\n socket.destroy();\n resolve(false);\n };\n\n const onSuccess = () => socket.end(() => resolve(true));\n\n socket\n .connect(port, host, onSuccess)\n .once('error', onFailure)\n .once('timeout', onFailure)\n .setTimeout(1_000);\n });\n\nexport const pollSocket = async (host: string, port: number, timeout: number) =>\n new Promise<void>((resolve, reject) => {\n const callPort = async () => {\n const success = await trySocket(host, port);\n\n if (!success) {\n return;\n }\n\n clearTimeout(intervalId);\n clearTimeout(timeoutId);\n\n resolve();\n };\n\n const intervalId = setInterval(() => {\n callPort().catch(() => undefined);\n }, 250);\n\n const timeoutId = setTimeout(() => {\n clearTimeout(intervalId);\n clearTimeout(timeoutId);\n\n reject(Error(`could not reach ${host}:${port} within ${timeout}ms`));\n }, timeout);\n\n callPort().catch(() => undefined);\n });\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAgB;AAOhB,MAAM,YAAY,OAAO,MAAc,SACrC,IAAI,QAAQ,CAAC,YAAY;AACvB,QAAM,SAAS,IAAI,WAAAA,QAAI,OAAO;AAE9B,QAAM,YAAY,MAAM;AACtB,WAAO,QAAQ;AACf,YAAQ,KAAK;AAAA,EACf;AAEA,QAAM,YAAY,MAAM,OAAO,IAAI,MAAM,QAAQ,IAAI,CAAC;AAEtD,SACG,QAAQ,MAAM,MAAM,SAAS,EAC7B,KAAK,SAAS,SAAS,EACvB,KAAK,WAAW,SAAS,EACzB,WAAW,GAAK;AACrB,CAAC;AAEI,MAAM,aAAa,OAAO,MAAc,MAAc,YAC3D,IAAI,QAAc,CAAC,SAAS,WAAW;AACrC,QAAM,WAAW,YAAY;AAC3B,UAAM,UAAU,MAAM,UAAU,MAAM,IAAI;AAE1C,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AAEA,iBAAa,UAAU;AACvB,iBAAa,SAAS;AAEtB,YAAQ;AAAA,EACV;AAEA,QAAM,aAAa,YAAY,MAAM;AACnC,aAAS,EAAE,MAAM,MAAM,MAAS;AAAA,EAClC,GAAG,GAAG;AAEN,QAAM,YAAY,WAAW,MAAM;AACjC,iBAAa,UAAU;AACvB,iBAAa,SAAS;AAEtB,WAAO,MAAM,mBAAmB,IAAI,IAAI,IAAI,WAAW,OAAO,IAAI,CAAC;AAAA,EACrE,GAAG,OAAO;AAEV,WAAS,EAAE,MAAM,MAAM,MAAS;AAClC,CAAC;",
6
- "names": ["net"]
7
- }
@@ -1,22 +0,0 @@
1
- import { type SocketAddress } from './socket.js';
2
- /**
3
- * Wait for a resource to start listening on a socket address.
4
- *
5
- * The socket is polled on an interval until it accepts a connection or the
6
- * `timeout` is reached.
7
- */
8
- export declare const waitFor: ({ host, port, resolveCompose, timeout, }: {
9
- host?: string;
10
- port: number;
11
- /**
12
- * Whether to treat the `host` and `port` arguments as a private Docker
13
- * Compose network address and to resolve them to a public local address.
14
- *
15
- * This is typically:
16
- *
17
- * - Enabled locally, when the application is running directly on the machine
18
- * - Disabled in CI, when running in a container on the Docker Compose network
19
- */
20
- resolveCompose?: boolean;
21
- timeout?: number;
22
- }) => Promise<SocketAddress>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var waitFor_exports = {};
20
- __export(waitFor_exports, {
21
- waitFor: () => waitFor
22
- });
23
- module.exports = __toCommonJS(waitFor_exports);
24
- var import_compose = require("./compose.js");
25
- var import_socket = require("./socket.js");
26
- const waitFor = async ({
27
- host = "localhost",
28
- port,
29
- resolveCompose = false,
30
- timeout = 15e3
31
- }) => {
32
- const resolvedAddress = resolveCompose ? await (0, import_compose.resolveComposeAddress)(host, port) : { host, port };
33
- await (0, import_socket.pollSocket)(resolvedAddress.host, resolvedAddress.port, timeout);
34
- return resolvedAddress;
35
- };
36
- // Annotate the CommonJS export names for ESM import in node:
37
- 0 && (module.exports = {
38
- waitFor
39
- });
40
- //# sourceMappingURL=waitFor.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/api/net/waitFor.ts"],
4
- "sourcesContent": ["import { resolveComposeAddress } from './compose.js';\nimport { type SocketAddress, pollSocket } from './socket.js';\n\n/**\n * Wait for a resource to start listening on a socket address.\n *\n * The socket is polled on an interval until it accepts a connection or the\n * `timeout` is reached.\n */\nexport const waitFor = async ({\n host = 'localhost',\n port,\n resolveCompose = false,\n timeout = 15_000,\n}: {\n host?: string;\n\n port: number;\n\n /**\n * Whether to treat the `host` and `port` arguments as a private Docker\n * Compose network address and to resolve them to a public local address.\n *\n * This is typically:\n *\n * - Enabled locally, when the application is running directly on the machine\n * - Disabled in CI, when running in a container on the Docker Compose network\n */\n resolveCompose?: boolean;\n\n timeout?: number;\n}): Promise<SocketAddress> => {\n const resolvedAddress = resolveCompose\n ? await resolveComposeAddress(host, port)\n : { host, port };\n\n await pollSocket(resolvedAddress.host, resolvedAddress.port, timeout);\n\n return resolvedAddress;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsC;AACtC,oBAA+C;AAQxC,MAAM,UAAU,OAAO;AAAA,EAC5B,OAAO;AAAA,EACP;AAAA,EACA,iBAAiB;AAAA,EACjB,UAAU;AACZ,MAiB8B;AAC5B,QAAM,kBAAkB,iBACpB,UAAM,sCAAsB,MAAM,IAAI,IACtC,EAAE,MAAM,KAAK;AAEjB,YAAM,0BAAW,gBAAgB,MAAM,gBAAgB,MAAM,OAAO;AAEpE,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,6 +0,0 @@
1
- import type { PatchFunction } from '../../index.js';
2
- export declare const hasSkubaDiveRegisterImportRegex: RegExp;
3
- export declare const hasSrcImportRegex: RegExp;
4
- export declare const replaceSrcImport: (contents: string) => string;
5
- export declare const tryRewriteSrcImports: PatchFunction;
6
- export declare const rewriteSrcImports: PatchFunction;
@@ -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.0.2/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
- }