skuba 0.0.0-master-20231002013336 → 0.0.0-master-20240206001217

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 (221) hide show
  1. package/README.md +3 -3
  2. package/jest/transform.test.ts +3 -1
  3. package/lib/api/jest/index.d.ts +3 -3
  4. package/lib/api/jest/index.js +19 -1
  5. package/lib/api/jest/index.js.map +2 -2
  6. package/lib/api/net/compose.js +2 -1
  7. package/lib/api/net/compose.js.map +2 -2
  8. package/lib/cli/adapter/prettier.d.ts +1 -1
  9. package/lib/cli/adapter/prettier.js +11 -10
  10. package/lib/cli/adapter/prettier.js.map +2 -2
  11. package/lib/cli/build/index.js +0 -2
  12. package/lib/cli/build/index.js.map +2 -2
  13. package/lib/cli/buildPackage.js +0 -2
  14. package/lib/cli/buildPackage.js.map +2 -2
  15. package/lib/cli/configure/analyseConfiguration.d.ts +2 -0
  16. package/lib/cli/configure/analyseConfiguration.js.map +2 -2
  17. package/lib/cli/configure/getEntryPoint.js +1 -1
  18. package/lib/cli/configure/getEntryPoint.js.map +2 -2
  19. package/lib/cli/configure/getProjectType.d.ts +1 -1
  20. package/lib/cli/configure/getProjectType.js +6 -3
  21. package/lib/cli/configure/getProjectType.js.map +2 -2
  22. package/lib/cli/configure/index.js +11 -12
  23. package/lib/cli/configure/index.js.map +2 -2
  24. package/lib/cli/configure/modules/index.js +0 -2
  25. package/lib/cli/configure/modules/index.js.map +2 -2
  26. package/lib/cli/configure/modules/package.d.ts +1 -1
  27. package/lib/cli/configure/modules/package.js +2 -1
  28. package/lib/cli/configure/modules/package.js.map +2 -2
  29. package/lib/cli/configure/patchRenovateConfig.d.ts +2 -1
  30. package/lib/cli/configure/patchRenovateConfig.js +36 -21
  31. package/lib/cli/configure/patchRenovateConfig.js.map +2 -2
  32. package/lib/cli/configure/types.d.ts +2 -0
  33. package/lib/cli/configure/types.js.map +1 -1
  34. package/lib/cli/configure/upgrade/index.d.ts +15 -0
  35. package/lib/cli/configure/upgrade/index.js +130 -0
  36. package/lib/cli/configure/upgrade/index.js.map +7 -0
  37. package/lib/cli/configure/{addEmptyExports.d.ts → upgrade/patches/7.3.1/addEmptyExports.d.ts} +2 -2
  38. package/lib/cli/configure/{addEmptyExports.js → upgrade/patches/7.3.1/addEmptyExports.js} +15 -11
  39. package/lib/cli/configure/upgrade/patches/7.3.1/addEmptyExports.js.map +7 -0
  40. package/lib/cli/configure/upgrade/patches/7.3.1/index.d.ts +2 -0
  41. package/lib/cli/configure/upgrade/patches/7.3.1/index.js +55 -0
  42. package/lib/cli/configure/upgrade/patches/7.3.1/index.js.map +7 -0
  43. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.d.ts +2 -0
  44. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js +94 -0
  45. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js.map +7 -0
  46. package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.d.ts +2 -0
  47. package/lib/cli/configure/{patchDockerfile.js → upgrade/patches/7.3.1/patchDockerfile.js} +18 -12
  48. package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.js.map +7 -0
  49. package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.d.ts +2 -0
  50. package/lib/cli/configure/{patchServerListener.js → upgrade/patches/7.3.1/patchServerListener.js} +18 -14
  51. package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.js.map +7 -0
  52. package/lib/cli/format.js +7 -14
  53. package/lib/cli/format.js.map +2 -2
  54. package/lib/cli/init/getConfig.d.ts +7 -5
  55. package/lib/cli/init/getConfig.js +61 -34
  56. package/lib/cli/init/getConfig.js.map +2 -2
  57. package/lib/cli/init/git.d.ts +2 -1
  58. package/lib/cli/init/git.js +2 -9
  59. package/lib/cli/init/git.js.map +2 -2
  60. package/lib/cli/init/index.d.ts +1 -1
  61. package/lib/cli/init/index.js +19 -10
  62. package/lib/cli/init/index.js.map +2 -2
  63. package/lib/cli/init/prompts.d.ts +26 -3
  64. package/lib/cli/init/prompts.js +10 -2
  65. package/lib/cli/init/prompts.js.map +2 -2
  66. package/lib/cli/init/types.d.ts +120 -27
  67. package/lib/cli/init/types.js +30 -35
  68. package/lib/cli/init/types.js.map +2 -2
  69. package/lib/cli/init/writePackageJson.d.ts +6 -0
  70. package/lib/cli/init/writePackageJson.js.map +2 -2
  71. package/lib/cli/lint/annotate/buildkite/index.d.ts +2 -1
  72. package/lib/cli/lint/annotate/buildkite/index.js +5 -3
  73. package/lib/cli/lint/annotate/buildkite/index.js.map +2 -2
  74. package/lib/cli/lint/annotate/buildkite/internal.d.ts +2 -0
  75. package/lib/cli/lint/annotate/buildkite/internal.js +45 -0
  76. package/lib/cli/lint/annotate/buildkite/internal.js.map +7 -0
  77. package/lib/cli/lint/annotate/github/index.d.ts +2 -1
  78. package/lib/cli/lint/annotate/github/index.js +4 -2
  79. package/lib/cli/lint/annotate/github/index.js.map +2 -2
  80. package/lib/cli/lint/annotate/github/internal.d.ts +3 -0
  81. package/lib/cli/lint/annotate/github/internal.js +36 -0
  82. package/lib/cli/lint/annotate/github/internal.js.map +7 -0
  83. package/lib/cli/lint/annotate/index.d.ts +4 -3
  84. package/lib/cli/lint/annotate/index.js +9 -3
  85. package/lib/cli/lint/annotate/index.js.map +2 -2
  86. package/lib/cli/lint/autofix.d.ts +3 -1
  87. package/lib/cli/lint/autofix.js +36 -59
  88. package/lib/cli/lint/autofix.js.map +3 -3
  89. package/lib/cli/lint/external.d.ts +6 -1
  90. package/lib/cli/lint/external.js +6 -29
  91. package/lib/cli/lint/external.js.map +2 -2
  92. package/lib/cli/lint/index.d.ts +2 -1
  93. package/lib/cli/lint/index.js +46 -14
  94. package/lib/cli/lint/index.js.map +2 -2
  95. package/lib/cli/lint/internal.d.ts +12 -1
  96. package/lib/cli/lint/internal.js +55 -19
  97. package/lib/cli/lint/internal.js.map +3 -3
  98. package/lib/cli/lint/internalLints/deleteFiles.d.ts +3 -0
  99. package/lib/cli/lint/internalLints/deleteFiles.js +102 -0
  100. package/lib/cli/lint/internalLints/deleteFiles.js.map +7 -0
  101. package/lib/cli/lint/internalLints/noSkubaTemplateJs.d.ts +3 -0
  102. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +75 -0
  103. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +7 -0
  104. package/lib/cli/lint/internalLints/refreshConfigFiles.d.ts +11 -0
  105. package/lib/cli/lint/internalLints/refreshConfigFiles.js +147 -0
  106. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +7 -0
  107. package/lib/cli/test/index.js +0 -2
  108. package/lib/cli/test/index.js.map +2 -2
  109. package/lib/skuba.d.ts +1 -1
  110. package/lib/skuba.js.map +1 -1
  111. package/lib/utils/error.d.ts +30 -10
  112. package/lib/utils/error.js +10 -20
  113. package/lib/utils/error.js.map +2 -2
  114. package/lib/utils/exec.d.ts +2 -1
  115. package/lib/utils/exec.js +3 -2
  116. package/lib/utils/exec.js.map +2 -2
  117. package/lib/utils/logging.d.ts +2 -0
  118. package/lib/utils/logging.js +1 -0
  119. package/lib/utils/logging.js.map +2 -2
  120. package/lib/utils/logo.js +6 -10
  121. package/lib/utils/logo.js.map +3 -3
  122. package/lib/utils/manifest.d.ts +4 -4
  123. package/lib/utils/manifest.js +10 -10
  124. package/lib/utils/manifest.js.map +2 -2
  125. package/lib/utils/npmrc.d.ts +1 -0
  126. package/lib/utils/npmrc.js +29 -0
  127. package/lib/utils/npmrc.js.map +7 -0
  128. package/lib/utils/packageManager.d.ts +24 -0
  129. package/lib/utils/packageManager.js +97 -0
  130. package/lib/utils/packageManager.js.map +7 -0
  131. package/lib/utils/template.d.ts +46 -13
  132. package/lib/utils/template.js +17 -15
  133. package/lib/utils/template.js.map +2 -2
  134. package/lib/utils/worker.d.ts +1 -0
  135. package/lib/wrapper/http.d.ts +1 -0
  136. package/package.json +50 -47
  137. package/template/base/_.dockerignore +0 -1
  138. package/template/base/_.eslintignore +1 -0
  139. package/template/base/_.gitignore +1 -1
  140. package/template/base/_.npmrc +8 -0
  141. package/template/express-rest-api/.buildkite/pipeline.yml +16 -12
  142. package/template/express-rest-api/.gantry/dev.yml +3 -0
  143. package/template/express-rest-api/.nvmrc +1 -1
  144. package/template/express-rest-api/Dockerfile +6 -12
  145. package/template/express-rest-api/Dockerfile.dev-deps +8 -7
  146. package/template/express-rest-api/README.md +12 -12
  147. package/template/express-rest-api/docker-compose.yml +0 -10
  148. package/template/express-rest-api/gantry.apply.yml +5 -0
  149. package/template/express-rest-api/gantry.build.yml +1 -2
  150. package/template/express-rest-api/package.json +4 -4
  151. package/template/express-rest-api/skuba.template.js +1 -0
  152. package/template/greeter/.buildkite/pipeline.yml +15 -11
  153. package/template/greeter/.nvmrc +1 -1
  154. package/template/greeter/Dockerfile +8 -7
  155. package/template/greeter/README.md +9 -9
  156. package/template/greeter/docker-compose.yml +0 -10
  157. package/template/greeter/package.json +3 -3
  158. package/template/greeter/skuba.template.js +1 -0
  159. package/template/koa-rest-api/.buildkite/pipeline.yml +16 -12
  160. package/template/koa-rest-api/.gantry/dev.yml +3 -0
  161. package/template/koa-rest-api/.nvmrc +1 -1
  162. package/template/koa-rest-api/Dockerfile +6 -12
  163. package/template/koa-rest-api/Dockerfile.dev-deps +8 -7
  164. package/template/koa-rest-api/README.md +12 -12
  165. package/template/koa-rest-api/docker-compose.yml +0 -10
  166. package/template/koa-rest-api/gantry.apply.yml +5 -0
  167. package/template/koa-rest-api/gantry.build.yml +1 -2
  168. package/template/koa-rest-api/package.json +10 -8
  169. package/template/koa-rest-api/skuba.template.js +1 -0
  170. package/template/koa-rest-api/src/app.test.ts +8 -4
  171. package/template/koa-rest-api/src/framework/validation.test.ts +48 -15
  172. package/template/koa-rest-api/src/framework/validation.ts +31 -8
  173. package/template/koa-rest-api/src/testing/types.ts +16 -4
  174. package/template/lambda-sqs-worker/.buildkite/pipeline.yml +25 -18
  175. package/template/lambda-sqs-worker/.nvmrc +1 -1
  176. package/template/lambda-sqs-worker/Dockerfile +8 -8
  177. package/template/lambda-sqs-worker/README.md +14 -14
  178. package/template/lambda-sqs-worker/_.npmrc +12 -0
  179. package/template/lambda-sqs-worker/docker-compose.yml +0 -15
  180. package/template/lambda-sqs-worker/package.json +6 -7
  181. package/template/lambda-sqs-worker/serverless.yml +5 -2
  182. package/template/lambda-sqs-worker/skuba.template.js +1 -0
  183. package/template/lambda-sqs-worker/src/framework/validation.test.ts +1 -1
  184. package/template/lambda-sqs-worker/src/hooks.ts +1 -2
  185. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +46 -21
  186. package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
  187. package/template/lambda-sqs-worker-cdk/Dockerfile +11 -9
  188. package/template/lambda-sqs-worker-cdk/cdk.json +12 -6
  189. package/template/lambda-sqs-worker-cdk/docker-compose.yml +0 -15
  190. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +1590 -228
  191. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +23 -3
  192. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +128 -15
  193. package/template/lambda-sqs-worker-cdk/package.json +9 -7
  194. package/template/lambda-sqs-worker-cdk/shared/context-types.ts +1 -0
  195. package/template/lambda-sqs-worker-cdk/skuba.template.js +1 -0
  196. package/template/lambda-sqs-worker-cdk/src/app.ts +14 -1
  197. package/template/lambda-sqs-worker-cdk/src/postHook.ts +154 -0
  198. package/template/lambda-sqs-worker-cdk/src/preHook.ts +95 -0
  199. package/template/oss-npm-package/.github/workflows/release.yml +10 -7
  200. package/template/oss-npm-package/.github/workflows/validate.yml +10 -7
  201. package/template/oss-npm-package/.nvmrc +1 -1
  202. package/template/oss-npm-package/.releaserc +16 -0
  203. package/template/oss-npm-package/README.md +18 -18
  204. package/template/oss-npm-package/_package.json +3 -2
  205. package/template/oss-npm-package/skuba.template.js +1 -0
  206. package/template/private-npm-package/.nvmrc +1 -1
  207. package/template/private-npm-package/.releaserc +16 -0
  208. package/template/private-npm-package/README.md +18 -18
  209. package/template/private-npm-package/_package.json +3 -3
  210. package/template/private-npm-package/skuba.template.js +1 -0
  211. package/lib/cli/configure/addEmptyExports.js.map +0 -7
  212. package/lib/cli/configure/modules/tsconfig.d.ts +0 -2
  213. package/lib/cli/configure/modules/tsconfig.js +0 -87
  214. package/lib/cli/configure/modules/tsconfig.js.map +0 -7
  215. package/lib/cli/configure/patchDockerfile.d.ts +0 -1
  216. package/lib/cli/configure/patchDockerfile.js.map +0 -7
  217. package/lib/cli/configure/patchServerListener.d.ts +0 -3
  218. package/lib/cli/configure/patchServerListener.js.map +0 -7
  219. package/lib/cli/configure/refreshIgnoreFiles.d.ts +0 -3
  220. package/lib/cli/configure/refreshIgnoreFiles.js +0 -78
  221. package/lib/cli/configure/refreshIgnoreFiles.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/init/types.ts"],
4
- "sourcesContent": ["/* eslint-disable new-cap */\n\nimport * as t from 'runtypes';\n\nimport { ProjectType } from '../../utils/manifest';\n\nconst INIT_CONFIG_INPUT_FIELDS = {\n destinationDir: t.String,\n templateComplete: t.Boolean,\n templateData: t\n .Record({\n ownerName: t.String,\n repoName: t.String,\n platformName: t.Union(t.Literal('amd64'), t.Literal('arm64')),\n })\n .And(t.Dictionary(t.String, t.String)),\n templateName: t.String,\n};\n\nexport type InitConfigInput = t.Static<typeof InitConfigInput>;\n\nexport const InitConfigInput = t.Record(INIT_CONFIG_INPUT_FIELDS);\n\nexport type InitConfig = t.Static<typeof InitConfig>;\n\nconst InitConfig = t.Record({\n ...INIT_CONFIG_INPUT_FIELDS,\n\n templateData: t\n .Record({\n ownerName: t.String,\n repoName: t.String,\n\n // Derived from ownerName\n orgName: t.String,\n teamName: t.String,\n\n // Generated by init command\n port: t.String,\n })\n .And(t.Dictionary(t.String, t.String)),\n\n entryPoint: t.String.optional(),\n type: ProjectType.optional(),\n});\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,QAAmB;AAEnB,sBAA4B;AAE5B,MAAM,2BAA2B;AAAA,EAC/B,gBAAgB,EAAE;AAAA,EAClB,kBAAkB,EAAE;AAAA,EACpB,cAAc,EACX,OAAO;AAAA,IACN,WAAW,EAAE;AAAA,IACb,UAAU,EAAE;AAAA,IACZ,cAAc,EAAE,MAAM,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,CAAC;AAAA,EAC9D,CAAC,EACA,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC;AAAA,EACvC,cAAc,EAAE;AAClB;AAIO,MAAM,kBAAkB,EAAE,OAAO,wBAAwB;AAIhE,MAAM,aAAa,EAAE,OAAO;AAAA,EAC1B,GAAG;AAAA,EAEH,cAAc,EACX,OAAO;AAAA,IACN,WAAW,EAAE;AAAA,IACb,UAAU,EAAE;AAAA;AAAA,IAGZ,SAAS,EAAE;AAAA,IACX,UAAU,EAAE;AAAA;AAAA,IAGZ,MAAM,EAAE;AAAA,EACV,CAAC,EACA,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC;AAAA,EAEvC,YAAY,EAAE,OAAO,SAAS;AAAA,EAC9B,MAAM,4BAAY,SAAS;AAC7B,CAAC;",
4
+ "sourcesContent": ["import { z } from 'zod';\n\nimport { projectTypeSchema } from '../../utils/manifest';\nimport { packageManagerSchema } from '../../utils/packageManager';\n\nexport interface Input {\n /**\n * Whether to enable verbose debug logging.\n *\n * Defaults to `false`.\n */\n debug: boolean;\n}\n\nexport type InitConfigInput = z.infer<typeof initConfigInputSchema>;\n\nexport const initConfigInputSchema = z.object({\n destinationDir: z.string(),\n templateComplete: z.boolean(),\n templateData: z\n .object({\n ownerName: z.string(),\n repoName: z.string(),\n platformName: z.union([z.literal('amd64'), z.literal('arm64')]),\n defaultBranch: z.string(),\n })\n .catchall(z.string()),\n templateName: z.string(),\n});\n\nexport type InitConfig = z.infer<typeof initConfigSchema>;\n\nconst initConfigSchema = initConfigInputSchema\n .omit({\n templateData: true,\n })\n .extend({\n templateData: z\n .object({\n ownerName: z.string(),\n repoName: z.string(),\n defaultBranch: z.string(),\n\n // Derived from ownerName\n // TODO: use zod to transform `InitConfigInput` -> `InitConfig`?\n orgName: z.string(),\n teamName: z.string(),\n\n // Generated by init command\n port: z.string(),\n })\n .catchall(z.string()),\n\n entryPoint: z.string().optional(),\n packageManager: packageManagerSchema,\n type: projectTypeSchema.optional(),\n });\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAElB,sBAAkC;AAClC,4BAAqC;AAa9B,MAAM,wBAAwB,aAAE,OAAO;AAAA,EAC5C,gBAAgB,aAAE,OAAO;AAAA,EACzB,kBAAkB,aAAE,QAAQ;AAAA,EAC5B,cAAc,aACX,OAAO;AAAA,IACN,WAAW,aAAE,OAAO;AAAA,IACpB,UAAU,aAAE,OAAO;AAAA,IACnB,cAAc,aAAE,MAAM,CAAC,aAAE,QAAQ,OAAO,GAAG,aAAE,QAAQ,OAAO,CAAC,CAAC;AAAA,IAC9D,eAAe,aAAE,OAAO;AAAA,EAC1B,CAAC,EACA,SAAS,aAAE,OAAO,CAAC;AAAA,EACtB,cAAc,aAAE,OAAO;AACzB,CAAC;AAID,MAAM,mBAAmB,sBACtB,KAAK;AAAA,EACJ,cAAc;AAChB,CAAC,EACA,OAAO;AAAA,EACN,cAAc,aACX,OAAO;AAAA,IACN,WAAW,aAAE,OAAO;AAAA,IACpB,UAAU,aAAE,OAAO;AAAA,IACnB,eAAe,aAAE,OAAO;AAAA;AAAA;AAAA,IAIxB,SAAS,aAAE,OAAO;AAAA,IAClB,UAAU,aAAE,OAAO;AAAA;AAAA,IAGnB,MAAM,aAAE,OAAO;AAAA,EACjB,CAAC,EACA,SAAS,aAAE,OAAO,CAAC;AAAA,EAEtB,YAAY,aAAE,OAAO,EAAE,SAAS;AAAA,EAChC,gBAAgB;AAAA,EAChB,MAAM,kCAAkB,SAAS;AACnC,CAAC;",
6
6
  "names": []
7
7
  }
@@ -6,6 +6,12 @@ interface WritePackageJsonProps {
6
6
  type?: ProjectType;
7
7
  version: string;
8
8
  }
9
+ export interface SkubaPackageJson {
10
+ entryPoint: string | null;
11
+ template: string;
12
+ type?: string;
13
+ version: string;
14
+ }
9
15
  /**
10
16
  * Write a `skuba` section into the destination `package.json`.
11
17
  */
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/init/writePackageJson.ts"],
4
- "sourcesContent": ["import fs from 'fs-extra';\n\nimport type { ProjectType } from '../../utils/manifest';\nimport { getDestinationManifest } from '../configure/analysis/package';\nimport { formatPackage } from '../configure/processing/package';\n\ninterface WritePackageJsonProps {\n cwd: string;\n entryPoint?: string;\n template: string;\n type?: ProjectType;\n version: string;\n}\n\n/**\n * Write a `skuba` section into the destination `package.json`.\n */\nexport const writePackageJson = async ({\n cwd,\n entryPoint,\n template,\n type,\n version,\n}: WritePackageJsonProps) => {\n const manifest = await getDestinationManifest({ cwd });\n\n manifest.packageJson.skuba = {\n entryPoint: entryPoint ?? null,\n template,\n type,\n version,\n };\n\n const updatedPackageJson = await formatPackage(manifest.packageJson);\n\n await fs.promises.writeFile(manifest.path, updatedPackageJson);\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAe;AAGf,qBAAuC;AACvC,IAAAA,kBAA8B;AAavB,MAAM,mBAAmB,OAAO;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA6B;AAC3B,QAAM,WAAW,UAAM,uCAAuB,EAAE,IAAI,CAAC;AAErD,WAAS,YAAY,QAAQ;AAAA,IAC3B,YAAY,cAAc;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,qBAAqB,UAAM,+BAAc,SAAS,WAAW;AAEnE,QAAM,gBAAAC,QAAG,SAAS,UAAU,SAAS,MAAM,kBAAkB;AAC/D;",
4
+ "sourcesContent": ["import fs from 'fs-extra';\n\nimport type { ProjectType } from '../../utils/manifest';\nimport { getDestinationManifest } from '../configure/analysis/package';\nimport { formatPackage } from '../configure/processing/package';\n\ninterface WritePackageJsonProps {\n cwd: string;\n entryPoint?: string;\n template: string;\n type?: ProjectType;\n version: string;\n}\n\nexport interface SkubaPackageJson {\n entryPoint: string | null;\n template: string;\n type?: string;\n version: string;\n}\n\n/**\n * Write a `skuba` section into the destination `package.json`.\n */\nexport const writePackageJson = async ({\n cwd,\n entryPoint,\n template,\n type,\n version,\n}: WritePackageJsonProps) => {\n const manifest = await getDestinationManifest({ cwd });\n\n manifest.packageJson.skuba = {\n entryPoint: entryPoint ?? null,\n template,\n type,\n version,\n } satisfies SkubaPackageJson;\n\n const updatedPackageJson = await formatPackage(manifest.packageJson);\n\n await fs.promises.writeFile(manifest.path, updatedPackageJson);\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAe;AAGf,qBAAuC;AACvC,IAAAA,kBAA8B;AAoBvB,MAAM,mBAAmB,OAAO;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA6B;AAC3B,QAAM,WAAW,UAAM,uCAAuB,EAAE,IAAI,CAAC;AAErD,WAAS,YAAY,QAAQ;AAAA,IAC3B,YAAY,cAAc;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,qBAAqB,UAAM,+BAAc,SAAS,WAAW;AAEnE,QAAM,gBAAAC,QAAG,SAAS,UAAU,SAAS,MAAM,kBAAkB;AAC/D;",
6
6
  "names": ["import_package", "fs"]
7
7
  }
@@ -1,4 +1,5 @@
1
1
  import type { ESLintOutput } from '../../../adapter/eslint';
2
2
  import type { PrettierOutput } from '../../../adapter/prettier';
3
3
  import type { StreamInterceptor } from '../../../lint/external';
4
- export declare const createBuildkiteAnnotations: (eslint: ESLintOutput, prettier: PrettierOutput, tscOk: boolean, tscOutputStream: StreamInterceptor) => Promise<void>;
4
+ import type { InternalLintResult } from '../../internal';
5
+ export declare const createBuildkiteAnnotations: (internal: InternalLintResult, eslint: ESLintOutput, prettier: PrettierOutput, tscOk: boolean, tscOutputStream: StreamInterceptor) => Promise<void>;
@@ -33,20 +33,22 @@ __export(buildkite_exports, {
33
33
  module.exports = __toCommonJS(buildkite_exports);
34
34
  var Buildkite = __toESM(require("../../../../api/buildkite"));
35
35
  var import_eslint = require("./eslint");
36
+ var import_internal = require("./internal");
36
37
  var import_prettier = require("./prettier");
37
38
  var import_tsc = require("./tsc");
38
- const createBuildkiteAnnotations = async (eslint, prettier, tscOk, tscOutputStream) => {
39
- if (eslint.ok && prettier.ok && tscOk) {
39
+ const createBuildkiteAnnotations = async (internal, eslint, prettier, tscOk, tscOutputStream) => {
40
+ if (internal.ok && eslint.ok && prettier.ok && tscOk) {
40
41
  return;
41
42
  }
42
43
  const buildkiteOutput = [
43
44
  "`skuba lint` found issues that require triage:",
45
+ ...(0, import_internal.createInternalAnnotations)(internal),
44
46
  ...(0, import_eslint.createEslintAnnotations)(eslint),
45
47
  ...(0, import_prettier.createPrettierAnnotations)(prettier),
46
48
  ...(0, import_tsc.createTscAnnotations)(tscOk, tscOutputStream)
47
49
  ].join("\n\n");
48
50
  await Buildkite.annotate(buildkiteOutput, {
49
- context: "skuba-lint-external",
51
+ context: "skuba-lint",
50
52
  scopeContextToStep: true,
51
53
  style: "error"
52
54
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/cli/lint/annotate/buildkite/index.ts"],
4
- "sourcesContent": ["import * as Buildkite from '../../../../api/buildkite';\nimport type { ESLintOutput } from '../../../adapter/eslint';\nimport type { PrettierOutput } from '../../../adapter/prettier';\nimport type { StreamInterceptor } from '../../../lint/external';\n\nimport { createEslintAnnotations } from './eslint';\nimport { createPrettierAnnotations } from './prettier';\nimport { createTscAnnotations } from './tsc';\n\nexport const createBuildkiteAnnotations = async (\n eslint: ESLintOutput,\n prettier: PrettierOutput,\n tscOk: boolean,\n tscOutputStream: StreamInterceptor,\n): Promise<void> => {\n if (eslint.ok && prettier.ok && tscOk) {\n return;\n }\n\n const buildkiteOutput = [\n '`skuba lint` found issues that require triage:',\n ...createEslintAnnotations(eslint),\n ...createPrettierAnnotations(prettier),\n ...createTscAnnotations(tscOk, tscOutputStream),\n ].join('\\n\\n');\n\n await Buildkite.annotate(buildkiteOutput, {\n context: 'skuba-lint-external',\n scopeContextToStep: true,\n style: 'error',\n });\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA2B;AAK3B,oBAAwC;AACxC,sBAA0C;AAC1C,iBAAqC;AAE9B,MAAM,6BAA6B,OACxC,QACA,UACA,OACA,oBACkB;AAClB,MAAI,OAAO,MAAM,SAAS,MAAM,OAAO;AACrC;AAAA,EACF;AAEA,QAAM,kBAAkB;AAAA,IACtB;AAAA,IACA,OAAG,uCAAwB,MAAM;AAAA,IACjC,OAAG,2CAA0B,QAAQ;AAAA,IACrC,OAAG,iCAAqB,OAAO,eAAe;AAAA,EAChD,EAAE,KAAK,MAAM;AAEb,QAAM,UAAU,SAAS,iBAAiB;AAAA,IACxC,SAAS;AAAA,IACT,oBAAoB;AAAA,IACpB,OAAO;AAAA,EACT,CAAC;AACH;",
4
+ "sourcesContent": ["import * as Buildkite from '../../../../api/buildkite';\nimport type { ESLintOutput } from '../../../adapter/eslint';\nimport type { PrettierOutput } from '../../../adapter/prettier';\nimport type { StreamInterceptor } from '../../../lint/external';\nimport type { InternalLintResult } from '../../internal';\n\nimport { createEslintAnnotations } from './eslint';\nimport { createInternalAnnotations } from './internal';\nimport { createPrettierAnnotations } from './prettier';\nimport { createTscAnnotations } from './tsc';\n\nexport const createBuildkiteAnnotations = async (\n internal: InternalLintResult,\n eslint: ESLintOutput,\n prettier: PrettierOutput,\n tscOk: boolean,\n tscOutputStream: StreamInterceptor,\n): Promise<void> => {\n if (internal.ok && eslint.ok && prettier.ok && tscOk) {\n return;\n }\n\n const buildkiteOutput = [\n '`skuba lint` found issues that require triage:',\n ...createInternalAnnotations(internal),\n ...createEslintAnnotations(eslint),\n ...createPrettierAnnotations(prettier),\n ...createTscAnnotations(tscOk, tscOutputStream),\n ].join('\\n\\n');\n\n await Buildkite.annotate(buildkiteOutput, {\n context: 'skuba-lint',\n scopeContextToStep: true,\n style: 'error',\n });\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA2B;AAM3B,oBAAwC;AACxC,sBAA0C;AAC1C,sBAA0C;AAC1C,iBAAqC;AAE9B,MAAM,6BAA6B,OACxC,UACA,QACA,UACA,OACA,oBACkB;AAClB,MAAI,SAAS,MAAM,OAAO,MAAM,SAAS,MAAM,OAAO;AACpD;AAAA,EACF;AAEA,QAAM,kBAAkB;AAAA,IACtB;AAAA,IACA,OAAG,2CAA0B,QAAQ;AAAA,IACrC,OAAG,uCAAwB,MAAM;AAAA,IACjC,OAAG,2CAA0B,QAAQ;AAAA,IACrC,OAAG,iCAAqB,OAAO,eAAe;AAAA,EAChD,EAAE,KAAK,MAAM;AAEb,QAAM,UAAU,SAAS,iBAAiB;AAAA,IACxC,SAAS;AAAA,IACT,oBAAoB;AAAA,IACpB,OAAO;AAAA,EACT,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,2 @@
1
+ import type { InternalLintResult } from '../../internal';
2
+ export declare const createInternalAnnotations: (internal: InternalLintResult) => string[];
@@ -0,0 +1,45 @@
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 internal_exports = {};
30
+ __export(internal_exports, {
31
+ createInternalAnnotations: () => createInternalAnnotations
32
+ });
33
+ module.exports = __toCommonJS(internal_exports);
34
+ var Buildkite = __toESM(require("../../../../api/buildkite"));
35
+ const createInternalAnnotations = (internal) => !internal.ok && internal.annotations?.length ? [
36
+ "**skuba**",
37
+ Buildkite.md.terminal(
38
+ internal.annotations.map(({ message, path }) => `${path} ${message}`).join("\n")
39
+ )
40
+ ] : [];
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ createInternalAnnotations
44
+ });
45
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/cli/lint/annotate/buildkite/internal.ts"],
4
+ "sourcesContent": ["import * as Buildkite from '../../../../api/buildkite';\nimport type { InternalLintResult } from '../../internal';\n\nexport const createInternalAnnotations = (\n internal: InternalLintResult,\n): string[] =>\n !internal.ok && internal.annotations?.length\n ? [\n '**skuba**',\n Buildkite.md.terminal(\n internal.annotations\n .map(({ message, path }) => `${path} ${message}`)\n .join('\\n'),\n ),\n ]\n : [];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA2B;AAGpB,MAAM,4BAA4B,CACvC,aAEA,CAAC,SAAS,MAAM,SAAS,aAAa,SAClC;AAAA,EACE;AAAA,EACA,UAAU,GAAG;AAAA,IACX,SAAS,YACN,IAAI,CAAC,EAAE,SAAS,KAAK,MAAM,GAAG,IAAI,IAAI,OAAO,EAAE,EAC/C,KAAK,IAAI;AAAA,EACd;AACF,IACA,CAAC;",
6
+ "names": []
7
+ }
@@ -1,4 +1,5 @@
1
1
  import type { ESLintOutput } from '../../../adapter/eslint';
2
2
  import type { PrettierOutput } from '../../../adapter/prettier';
3
3
  import type { StreamInterceptor } from '../../../lint/external';
4
- export declare const createGitHubAnnotations: (eslint: ESLintOutput, prettier: PrettierOutput, tscOk: boolean, tscOutputStream: StreamInterceptor) => Promise<void>;
4
+ import type { InternalLintResult } from '../../internal';
5
+ export declare const createGitHubAnnotations: (internal: InternalLintResult, eslint: ESLintOutput, prettier: PrettierOutput, tscOk: boolean, tscOutputStream: StreamInterceptor) => Promise<void>;
@@ -34,18 +34,20 @@ module.exports = __toCommonJS(github_exports);
34
34
  var GitHub = __toESM(require("../../../../api/github"));
35
35
  var import_environment = require("../../../../api/github/environment");
36
36
  var import_eslint = require("./eslint");
37
+ var import_internal = require("./internal");
37
38
  var import_prettier = require("./prettier");
38
39
  var import_tsc = require("./tsc");
39
- const createGitHubAnnotations = async (eslint, prettier, tscOk, tscOutputStream) => {
40
+ const createGitHubAnnotations = async (internal, eslint, prettier, tscOk, tscOutputStream) => {
40
41
  if (!(0, import_environment.enabledFromEnvironment)()) {
41
42
  return;
42
43
  }
43
44
  const annotations = [
45
+ ...(0, import_internal.createInternalAnnotations)(internal),
44
46
  ...(0, import_eslint.createEslintAnnotations)(eslint),
45
47
  ...(0, import_prettier.createPrettierAnnotations)(prettier),
46
48
  ...(0, import_tsc.createTscAnnotations)(tscOk, tscOutputStream)
47
49
  ];
48
- const isOk = eslint.ok && prettier.ok && tscOk;
50
+ const isOk = eslint.ok && prettier.ok && internal.ok && tscOk;
49
51
  const summary = isOk ? "`skuba lint` passed." : "`skuba lint` found issues that require triage.";
50
52
  const build = (0, import_environment.buildNameFromEnvironment)();
51
53
  await GitHub.createCheckRun({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/cli/lint/annotate/github/index.ts"],
4
- "sourcesContent": ["import * as GitHub from '../../../../api/github';\nimport {\n buildNameFromEnvironment,\n enabledFromEnvironment,\n} from '../../../../api/github/environment';\nimport type { ESLintOutput } from '../../../adapter/eslint';\nimport type { PrettierOutput } from '../../../adapter/prettier';\nimport type { StreamInterceptor } from '../../../lint/external';\n\nimport { createEslintAnnotations } from './eslint';\nimport { createPrettierAnnotations } from './prettier';\nimport { createTscAnnotations } from './tsc';\n\nexport const createGitHubAnnotations = async (\n eslint: ESLintOutput,\n prettier: PrettierOutput,\n tscOk: boolean,\n tscOutputStream: StreamInterceptor,\n) => {\n if (!enabledFromEnvironment()) {\n return;\n }\n\n const annotations: GitHub.Annotation[] = [\n ...createEslintAnnotations(eslint),\n ...createPrettierAnnotations(prettier),\n ...createTscAnnotations(tscOk, tscOutputStream),\n ];\n\n const isOk = eslint.ok && prettier.ok && tscOk;\n\n const summary = isOk\n ? '`skuba lint` passed.'\n : '`skuba lint` found issues that require triage.';\n\n const build = buildNameFromEnvironment();\n\n await GitHub.createCheckRun({\n name: 'skuba/lint',\n summary,\n annotations,\n conclusion: isOk ? 'success' : 'failure',\n title: `${build} ${isOk ? 'passed' : 'failed'}`,\n });\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,yBAGO;AAKP,oBAAwC;AACxC,sBAA0C;AAC1C,iBAAqC;AAE9B,MAAM,0BAA0B,OACrC,QACA,UACA,OACA,oBACG;AACH,MAAI,KAAC,2CAAuB,GAAG;AAC7B;AAAA,EACF;AAEA,QAAM,cAAmC;AAAA,IACvC,OAAG,uCAAwB,MAAM;AAAA,IACjC,OAAG,2CAA0B,QAAQ;AAAA,IACrC,OAAG,iCAAqB,OAAO,eAAe;AAAA,EAChD;AAEA,QAAM,OAAO,OAAO,MAAM,SAAS,MAAM;AAEzC,QAAM,UAAU,OACZ,yBACA;AAEJ,QAAM,YAAQ,6CAAyB;AAEvC,QAAM,OAAO,eAAe;AAAA,IAC1B,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,YAAY,OAAO,YAAY;AAAA,IAC/B,OAAO,GAAG,KAAK,IAAI,OAAO,WAAW,QAAQ;AAAA,EAC/C,CAAC;AACH;",
4
+ "sourcesContent": ["import * as GitHub from '../../../../api/github';\nimport {\n buildNameFromEnvironment,\n enabledFromEnvironment,\n} from '../../../../api/github/environment';\nimport type { ESLintOutput } from '../../../adapter/eslint';\nimport type { PrettierOutput } from '../../../adapter/prettier';\nimport type { StreamInterceptor } from '../../../lint/external';\nimport type { InternalLintResult } from '../../internal';\n\nimport { createEslintAnnotations } from './eslint';\nimport { createInternalAnnotations } from './internal';\nimport { createPrettierAnnotations } from './prettier';\nimport { createTscAnnotations } from './tsc';\n\nexport const createGitHubAnnotations = async (\n internal: InternalLintResult,\n eslint: ESLintOutput,\n prettier: PrettierOutput,\n tscOk: boolean,\n tscOutputStream: StreamInterceptor,\n) => {\n if (!enabledFromEnvironment()) {\n return;\n }\n\n const annotations: GitHub.Annotation[] = [\n ...createInternalAnnotations(internal),\n ...createEslintAnnotations(eslint),\n ...createPrettierAnnotations(prettier),\n ...createTscAnnotations(tscOk, tscOutputStream),\n ];\n\n const isOk = eslint.ok && prettier.ok && internal.ok && tscOk;\n\n const summary = isOk\n ? '`skuba lint` passed.'\n : '`skuba lint` found issues that require triage.';\n\n const build = buildNameFromEnvironment();\n\n await GitHub.createCheckRun({\n name: 'skuba/lint',\n summary,\n annotations,\n conclusion: isOk ? 'success' : 'failure',\n title: `${build} ${isOk ? 'passed' : 'failed'}`,\n });\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,yBAGO;AAMP,oBAAwC;AACxC,sBAA0C;AAC1C,sBAA0C;AAC1C,iBAAqC;AAE9B,MAAM,0BAA0B,OACrC,UACA,QACA,UACA,OACA,oBACG;AACH,MAAI,KAAC,2CAAuB,GAAG;AAC7B;AAAA,EACF;AAEA,QAAM,cAAmC;AAAA,IACvC,OAAG,2CAA0B,QAAQ;AAAA,IACrC,OAAG,uCAAwB,MAAM;AAAA,IACjC,OAAG,2CAA0B,QAAQ;AAAA,IACrC,OAAG,iCAAqB,OAAO,eAAe;AAAA,EAChD;AAEA,QAAM,OAAO,OAAO,MAAM,SAAS,MAAM,SAAS,MAAM;AAExD,QAAM,UAAU,OACZ,yBACA;AAEJ,QAAM,YAAQ,6CAAyB;AAEvC,QAAM,OAAO,eAAe;AAAA,IAC1B,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,YAAY,OAAO,YAAY;AAAA,IAC/B,OAAO,GAAG,KAAK,IAAI,OAAO,WAAW,QAAQ;AAAA,EAC/C,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,3 @@
1
+ import type * as GitHub from '../../../../api/github';
2
+ import type { InternalLintResult } from '../../internal';
3
+ export declare const createInternalAnnotations: (internal: InternalLintResult) => GitHub.Annotation[];
@@ -0,0 +1,36 @@
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 internal_exports = {};
20
+ __export(internal_exports, {
21
+ createInternalAnnotations: () => createInternalAnnotations
22
+ });
23
+ module.exports = __toCommonJS(internal_exports);
24
+ const createInternalAnnotations = (internal) => (internal.annotations ?? []).map((annotation) => ({
25
+ annotation_level: "failure",
26
+ start_line: annotation.start_line ?? 1,
27
+ end_line: annotation.end_line ?? annotation.start_line ?? 1,
28
+ path: annotation.path,
29
+ message: annotation.message,
30
+ title: "skuba lint"
31
+ }));
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ createInternalAnnotations
35
+ });
36
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/cli/lint/annotate/github/internal.ts"],
4
+ "sourcesContent": ["import type * as GitHub from '../../../../api/github';\nimport type { InternalLintResult } from '../../internal';\n\nexport const createInternalAnnotations = (\n internal: InternalLintResult,\n): GitHub.Annotation[] =>\n (internal.annotations ?? []).map((annotation) => ({\n annotation_level: 'failure',\n start_line: annotation.start_line ?? 1,\n end_line: annotation.end_line ?? annotation.start_line ?? 1,\n path: annotation.path,\n message: annotation.message,\n title: 'skuba lint',\n }));\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,4BAA4B,CACvC,cAEC,SAAS,eAAe,CAAC,GAAG,IAAI,CAAC,gBAAgB;AAAA,EAChD,kBAAkB;AAAA,EAClB,YAAY,WAAW,cAAc;AAAA,EACrC,UAAU,WAAW,YAAY,WAAW,cAAc;AAAA,EAC1D,MAAM,WAAW;AAAA,EACjB,SAAS,WAAW;AAAA,EACpB,OAAO;AACT,EAAE;",
6
+ "names": []
7
+ }
@@ -1,4 +1,5 @@
1
+ import type { ESLintOutput } from '../../../cli/adapter/eslint';
2
+ import type { PrettierOutput } from '../../../cli/adapter/prettier';
1
3
  import type { StreamInterceptor } from '../external';
2
- import type { ESLintOutput } from 'cli/adapter/eslint';
3
- import type { PrettierOutput } from 'cli/adapter/prettier';
4
- export declare const createAnnotations: (eslint: ESLintOutput, prettier: PrettierOutput, tscOk: boolean, tscOutputStream: StreamInterceptor) => Promise<void>;
4
+ import type { InternalLintResult } from '../internal';
5
+ export declare const createAnnotations: (internal: InternalLintResult, eslint: ESLintOutput, prettier: PrettierOutput, tscOk: boolean, tscOutputStream: StreamInterceptor) => Promise<void>;
@@ -23,10 +23,16 @@ __export(annotate_exports, {
23
23
  module.exports = __toCommonJS(annotate_exports);
24
24
  var import_buildkite = require("./buildkite");
25
25
  var import_github = require("./github");
26
- const createAnnotations = async (eslint, prettier, tscOk, tscOutputStream) => {
26
+ const createAnnotations = async (internal, eslint, prettier, tscOk, tscOutputStream) => {
27
27
  await Promise.all([
28
- (0, import_github.createGitHubAnnotations)(eslint, prettier, tscOk, tscOutputStream),
29
- (0, import_buildkite.createBuildkiteAnnotations)(eslint, prettier, tscOk, tscOutputStream)
28
+ (0, import_github.createGitHubAnnotations)(internal, eslint, prettier, tscOk, tscOutputStream),
29
+ (0, import_buildkite.createBuildkiteAnnotations)(
30
+ internal,
31
+ eslint,
32
+ prettier,
33
+ tscOk,
34
+ tscOutputStream
35
+ )
30
36
  ]);
31
37
  };
32
38
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/lint/annotate/index.ts"],
4
- "sourcesContent": ["import type { StreamInterceptor } from '../external';\n\nimport { createBuildkiteAnnotations } from './buildkite';\nimport { createGitHubAnnotations } from './github';\n\nimport type { ESLintOutput } from 'cli/adapter/eslint';\nimport type { PrettierOutput } from 'cli/adapter/prettier';\n\nexport const createAnnotations = async (\n eslint: ESLintOutput,\n prettier: PrettierOutput,\n tscOk: boolean,\n tscOutputStream: StreamInterceptor,\n): Promise<void> => {\n await Promise.all([\n createGitHubAnnotations(eslint, prettier, tscOk, tscOutputStream),\n createBuildkiteAnnotations(eslint, prettier, tscOk, tscOutputStream),\n ]);\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uBAA2C;AAC3C,oBAAwC;AAKjC,MAAM,oBAAoB,OAC/B,QACA,UACA,OACA,oBACkB;AAClB,QAAM,QAAQ,IAAI;AAAA,QAChB,uCAAwB,QAAQ,UAAU,OAAO,eAAe;AAAA,QAChE,6CAA2B,QAAQ,UAAU,OAAO,eAAe;AAAA,EACrE,CAAC;AACH;",
4
+ "sourcesContent": ["import type { ESLintOutput } from '../../../cli/adapter/eslint';\nimport type { PrettierOutput } from '../../../cli/adapter/prettier';\nimport type { StreamInterceptor } from '../external';\nimport type { InternalLintResult } from '../internal';\n\nimport { createBuildkiteAnnotations } from './buildkite';\nimport { createGitHubAnnotations } from './github';\n\nexport const createAnnotations = async (\n internal: InternalLintResult,\n eslint: ESLintOutput,\n prettier: PrettierOutput,\n tscOk: boolean,\n tscOutputStream: StreamInterceptor,\n): Promise<void> => {\n await Promise.all([\n createGitHubAnnotations(internal, eslint, prettier, tscOk, tscOutputStream),\n createBuildkiteAnnotations(\n internal,\n eslint,\n prettier,\n tscOk,\n tscOutputStream,\n ),\n ]);\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,uBAA2C;AAC3C,oBAAwC;AAEjC,MAAM,oBAAoB,OAC/B,UACA,QACA,UACA,OACA,oBACkB;AAClB,QAAM,QAAQ,IAAI;AAAA,QAChB,uCAAwB,UAAU,QAAQ,UAAU,OAAO,eAAe;AAAA,QAC1E;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,12 @@
1
1
  import * as Git from '../../api/git';
2
2
  import type { Input } from './types';
3
- export declare const AUTOFIX_IGNORE_FILES: Git.ChangedFile[];
3
+ export declare const AUTOFIX_IGNORE_FILES_BASE: Git.ChangedFile[];
4
+ export declare const AUTOFIX_IGNORE_FILES_NPMRC: Git.ChangedFile[];
4
5
  interface AutofixParameters {
5
6
  debug: Input['debug'];
6
7
  eslint: boolean;
7
8
  prettier: boolean;
9
+ internal: boolean;
8
10
  }
9
11
  export declare const autofix: (params: AutofixParameters) => Promise<void>;
10
12
  export {};
@@ -28,54 +28,40 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var autofix_exports = {};
30
30
  __export(autofix_exports, {
31
- AUTOFIX_IGNORE_FILES: () => AUTOFIX_IGNORE_FILES,
31
+ AUTOFIX_IGNORE_FILES_BASE: () => AUTOFIX_IGNORE_FILES_BASE,
32
+ AUTOFIX_IGNORE_FILES_NPMRC: () => AUTOFIX_IGNORE_FILES_NPMRC,
32
33
  autofix: () => autofix
33
34
  });
34
35
  module.exports = __toCommonJS(autofix_exports);
35
- var import_path = __toESM(require("path"));
36
36
  var import_util = require("util");
37
- var import_fs_extra = __toESM(require("fs-extra"));
38
37
  var import_simple_git = __toESM(require("simple-git"));
39
38
  var Buildkite = __toESM(require("../../api/buildkite"));
40
39
  var Git = __toESM(require("../../api/git"));
41
40
  var GitHub = __toESM(require("../../api/github"));
42
41
  var import_env = require("../../utils/env");
43
42
  var import_logging = require("../../utils/logging");
43
+ var import_npmrc = require("../../utils/npmrc");
44
44
  var import_wait = require("../../utils/wait");
45
45
  var import_eslint = require("../adapter/eslint");
46
46
  var import_prettier = require("../adapter/prettier");
47
- var import_addEmptyExports = require("../configure/addEmptyExports");
48
- var import_renovate = require("../configure/modules/renovate");
49
- var import_patchServerListener = require("../configure/patchServerListener");
50
- var import_refreshIgnoreFiles = require("../configure/refreshIgnoreFiles");
47
+ var import_project = require("../configure/analysis/project");
48
+ var import_internal = require("./internal");
51
49
  const RENOVATE_DEFAULT_PREFIX = "renovate";
52
50
  const AUTOFIX_COMMIT_MESSAGE = "Run `skuba format`";
53
- const AUTOFIX_DELETE_FILES = [
54
- // Try to delete this SEEK-Jobs/gutenberg automation file that may have been
55
- // accidentally committed in a prior autofix.
56
- "Dockerfile-incunabulum"
51
+ const AUTOFIX_IGNORE_FILES_BASE = [
52
+ {
53
+ path: "Dockerfile-incunabulum",
54
+ state: "added"
55
+ }
57
56
  ];
58
- const AUTOFIX_CODEGEN_FILES = /* @__PURE__ */ new Set([
59
- ...AUTOFIX_DELETE_FILES,
60
- ...import_addEmptyExports.JEST_SETUP_FILES,
61
- ...import_refreshIgnoreFiles.REFRESHABLE_IGNORE_FILES,
62
- ...import_renovate.RENOVATE_CONFIG_FILENAMES,
63
- import_patchServerListener.SERVER_LISTENER_FILENAME
64
- ]);
65
- const AUTOFIX_IGNORE_FILES = [
57
+ const AUTOFIX_IGNORE_FILES_NPMRC = [
66
58
  {
67
59
  path: ".npmrc",
68
60
  state: "added"
69
61
  },
70
62
  {
71
- // This file may already exist in version control, but we shouldn't commit
72
- // further changes as the CI environment may have appended an npm token.
73
63
  path: ".npmrc",
74
64
  state: "modified"
75
- },
76
- {
77
- path: "Dockerfile-incunabulum",
78
- state: "added"
79
65
  }
80
66
  ];
81
67
  const shouldPush = async ({
@@ -115,30 +101,16 @@ const shouldPush = async ({
115
101
  }
116
102
  return true;
117
103
  };
118
- const tryCodegen = async (dir) => {
119
- try {
120
- await Promise.all(
121
- AUTOFIX_DELETE_FILES.map(
122
- (filename) => import_fs_extra.default.promises.rm(import_path.default.join(dir, filename), { force: true })
123
- )
124
- );
125
- const changedFiles = await Git.getChangedFiles({
126
- dir,
127
- ignore: AUTOFIX_IGNORE_FILES
128
- });
129
- return changedFiles.some(
130
- (changedFile) => AUTOFIX_CODEGEN_FILES.has(changedFile.path)
131
- );
132
- } catch (err) {
133
- import_logging.log.warn(import_logging.log.bold("Failed to evaluate codegen changes."));
134
- import_logging.log.subtle((0, import_util.inspect)(err));
135
- return false;
104
+ const getIgnores = async (dir) => {
105
+ const contents = await (0, import_project.createDestinationFileReader)(dir)(".npmrc");
106
+ if ((0, import_npmrc.hasNpmrcSecret)(contents ?? "")) {
107
+ return [...AUTOFIX_IGNORE_FILES_BASE, ...AUTOFIX_IGNORE_FILES_NPMRC];
136
108
  }
109
+ return AUTOFIX_IGNORE_FILES_BASE;
137
110
  };
138
111
  const autofix = async (params) => {
139
112
  const dir = process.cwd();
140
- const codegen = await tryCodegen(dir);
141
- if (!params.eslint && !params.prettier && !codegen) {
113
+ if (!params.eslint && !params.prettier && !params.internal) {
142
114
  return;
143
115
  }
144
116
  let currentBranch;
@@ -151,23 +123,27 @@ const autofix = async (params) => {
151
123
  }
152
124
  try {
153
125
  import_logging.log.newline();
154
- if (!params.eslint && !params.prettier) {
155
- import_logging.log.warn("Trying to push codegen updates...");
156
- } else {
157
- import_logging.log.warn(
158
- `Trying to autofix with ${params.eslint ? "ESLint and " : ""}Prettier...`
159
- );
160
- const logger = (0, import_logging.createLogger)(params.debug);
161
- if (params.eslint) {
162
- await (0, import_eslint.runESLint)("format", logger);
163
- }
164
- await (0, import_prettier.runPrettier)("format", logger);
126
+ import_logging.log.warn(
127
+ `Attempting to autofix issues (${[
128
+ params.eslint ? "ESLint" : void 0,
129
+ params.internal ? "skuba" : void 0,
130
+ "Prettier"
131
+ // Prettier is always run
132
+ ].filter((s) => s !== void 0).join(", ")})...`
133
+ );
134
+ const logger = (0, import_logging.createLogger)(params.debug);
135
+ if (params.internal) {
136
+ await (0, import_internal.internalLint)("format");
137
+ }
138
+ if (params.eslint) {
139
+ await (0, import_eslint.runESLint)("format", logger);
165
140
  }
141
+ await (0, import_prettier.runPrettier)("format", logger);
166
142
  if (process.env.GITHUB_ACTIONS) {
167
143
  const ref2 = await Git.commitAllChanges({
168
144
  dir,
169
145
  message: AUTOFIX_COMMIT_MESSAGE,
170
- ignore: AUTOFIX_IGNORE_FILES
146
+ ignore: await getIgnores(dir)
171
147
  });
172
148
  if (!ref2) {
173
149
  return import_logging.log.warn("No autofixes detected.");
@@ -188,7 +164,7 @@ const autofix = async (params) => {
188
164
  branch: currentBranch,
189
165
  dir,
190
166
  messageHeadline: AUTOFIX_COMMIT_MESSAGE,
191
- ignore: AUTOFIX_IGNORE_FILES
167
+ ignore: await getIgnores(dir)
192
168
  }),
193
169
  { s: 30 }
194
170
  );
@@ -208,7 +184,8 @@ const autofix = async (params) => {
208
184
  };
209
185
  // Annotate the CommonJS export names for ESM import in node:
210
186
  0 && (module.exports = {
211
- AUTOFIX_IGNORE_FILES,
187
+ AUTOFIX_IGNORE_FILES_BASE,
188
+ AUTOFIX_IGNORE_FILES_NPMRC,
212
189
  autofix
213
190
  });
214
191
  //# sourceMappingURL=autofix.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/lint/autofix.ts"],
4
- "sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\nimport simpleGit from 'simple-git';\n\nimport * as Buildkite from '../../api/buildkite';\nimport * as Git from '../../api/git';\nimport * as GitHub from '../../api/github';\nimport { isCiEnv } from '../../utils/env';\nimport { createLogger, log } from '../../utils/logging';\nimport { throwOnTimeout } from '../../utils/wait';\nimport { runESLint } from '../adapter/eslint';\nimport { runPrettier } from '../adapter/prettier';\nimport { JEST_SETUP_FILES } from '../configure/addEmptyExports';\nimport { RENOVATE_CONFIG_FILENAMES } from '../configure/modules/renovate';\nimport { SERVER_LISTENER_FILENAME } from '../configure/patchServerListener';\nimport { REFRESHABLE_IGNORE_FILES } from '../configure/refreshIgnoreFiles';\n\nimport type { Input } from './types';\n\nconst RENOVATE_DEFAULT_PREFIX = 'renovate';\n\nconst AUTOFIX_COMMIT_MESSAGE = 'Run `skuba format`';\n\nconst AUTOFIX_DELETE_FILES = [\n // Try to delete this SEEK-Jobs/gutenberg automation file that may have been\n // accidentally committed in a prior autofix.\n 'Dockerfile-incunabulum',\n];\n\nconst AUTOFIX_CODEGEN_FILES = new Set<string>([\n ...AUTOFIX_DELETE_FILES,\n ...JEST_SETUP_FILES,\n ...REFRESHABLE_IGNORE_FILES,\n ...RENOVATE_CONFIG_FILENAMES,\n SERVER_LISTENER_FILENAME,\n]);\n\nexport const AUTOFIX_IGNORE_FILES: Git.ChangedFile[] = [\n {\n path: '.npmrc',\n state: 'added',\n },\n {\n // This file may already exist in version control, but we shouldn't commit\n // further changes as the CI environment may have appended an npm token.\n path: '.npmrc',\n state: 'modified',\n },\n {\n path: 'Dockerfile-incunabulum',\n state: 'added',\n },\n];\n\nconst shouldPush = async ({\n currentBranch,\n dir,\n}: {\n currentBranch?: string;\n dir: string;\n}) => {\n if (!isCiEnv()) {\n // We're not running in a CI environment so we don't need to push autofixes.\n // Ideally we'd drive this off of repository write permissions, but that is\n // non-trivial to infer without attempting an actual write.\n return false;\n }\n\n const isDefaultBuildkiteBranch =\n currentBranch &&\n [process.env.BUILDKITE_PIPELINE_DEFAULT_BRANCH, 'master', 'main'].includes(\n currentBranch,\n );\n\n const isProtectedGitHubBranch = process.env.GITHUB_REF_PROTECTED === 'true';\n\n if (isDefaultBuildkiteBranch || isProtectedGitHubBranch) {\n // The current branch is a protected branch.\n // We respect GitHub Flow; avoid pushing directly to the default branch.\n return false;\n }\n\n if (currentBranch?.startsWith(RENOVATE_DEFAULT_PREFIX)) {\n try {\n await GitHub.getPullRequestNumber();\n } catch (error) {\n const warning =\n 'An autofix is available, but it was not pushed because an open pull request for this Renovate branch could not be found. If a pull request has since been created, retry the lint step to push the fix.';\n log.warn(warning);\n try {\n await Buildkite.annotate(Buildkite.md.terminal(warning));\n } catch {}\n\n return false;\n }\n }\n\n let headCommitMessage;\n try {\n headCommitMessage = await Git.getHeadCommitMessage({ dir });\n } catch {}\n\n if (headCommitMessage?.startsWith(AUTOFIX_COMMIT_MESSAGE)) {\n // Short circuit when the head commit appears to be one of our autofixes.\n // Repeating the same operation is unlikely to correct outstanding issues.\n return false;\n }\n\n // Allow the push attempt to go ahead if our guards have been cleared.\n return true;\n};\n\ninterface AutofixParameters {\n debug: Input['debug'];\n\n eslint: boolean;\n prettier: boolean;\n}\n\n/**\n * @returns Whether skuba codegenned a file change which should be included in\n * an autofix commit.\n */\nconst tryCodegen = async (dir: string): Promise<boolean> => {\n try {\n // Try to forcibly remove `AUTOFIX_DELETE_FILES` from source control.\n // These may include outdated configuration files or internal files that\n // were accidentally committed by an autofix.\n await Promise.all(\n AUTOFIX_DELETE_FILES.map((filename) =>\n fs.promises.rm(path.join(dir, filename), { force: true }),\n ),\n );\n\n // Search codegenned file changes in the local Git working directory.\n // These may include the `AUTOFIX_DELETE_FILES` deleted above or fixups to\n // ignore files and module exports that were run at the start of the\n // `skuba lint` command.\n const changedFiles = await Git.getChangedFiles({\n dir,\n\n ignore: AUTOFIX_IGNORE_FILES,\n });\n\n // Determine if a meaningful codegen change\n return changedFiles.some((changedFile) =>\n AUTOFIX_CODEGEN_FILES.has(changedFile.path),\n );\n } catch (err) {\n log.warn(log.bold('Failed to evaluate codegen changes.'));\n log.subtle(inspect(err));\n\n return false;\n }\n};\n\nexport const autofix = async (params: AutofixParameters): Promise<void> => {\n const dir = process.cwd();\n\n const codegen = await tryCodegen(dir);\n\n if (!params.eslint && !params.prettier && !codegen) {\n return;\n }\n\n let currentBranch;\n try {\n currentBranch = await Git.currentBranch({ dir });\n } catch {}\n\n if (!(await shouldPush({ currentBranch, dir }))) {\n return;\n }\n\n try {\n log.newline();\n if (!params.eslint && !params.prettier) {\n log.warn('Trying to push codegen updates...');\n } else {\n log.warn(\n `Trying to autofix with ${\n params.eslint ? 'ESLint and ' : ''\n }Prettier...`,\n );\n\n const logger = createLogger(params.debug);\n\n if (params.eslint) {\n await runESLint('format', logger);\n }\n // Unconditionally re-run Prettier; reaching here means we have pre-existing\n // format violations or may have created new ones through ESLint fixes.\n await runPrettier('format', logger);\n }\n\n if (process.env.GITHUB_ACTIONS) {\n // GitHub runners have Git installed locally\n const ref = await Git.commitAllChanges({\n dir,\n message: AUTOFIX_COMMIT_MESSAGE,\n\n ignore: AUTOFIX_IGNORE_FILES,\n });\n\n if (!ref) {\n return log.warn('No autofixes detected.');\n }\n\n await throwOnTimeout(simpleGit().push(), { s: 30 });\n log.warn(`Pushed fix commit ${ref}.`);\n return;\n }\n\n // Other CI Environments, use GitHub API\n if (!currentBranch) {\n log.warn('Could not determine the current branch.');\n log.warn(\n 'Please propagate BUILDKITE_BRANCH, GITHUB_HEAD_REF, GITHUB_REF_NAME, or the .git directory to your container.',\n );\n return;\n }\n\n const ref = await throwOnTimeout(\n GitHub.uploadAllFileChanges({\n branch: currentBranch,\n dir,\n messageHeadline: AUTOFIX_COMMIT_MESSAGE,\n\n ignore: AUTOFIX_IGNORE_FILES,\n }),\n { s: 30 },\n );\n\n if (!ref) {\n return log.warn('No autofixes detected.');\n }\n\n log.warn(`Pushed fix commit ${ref}.`);\n } catch (err) {\n log.warn(log.bold('Failed to push fix commit.'));\n log.warn(\n log.bold(\n 'Does your CI environment have write access to your Git repository?',\n ),\n );\n log.subtle(inspect(err));\n }\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA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0BACE,OAAO,SAAS,gBAAgB,EAClC;AAAA,MACF;AAEA,YAAM,aAAS,6BAAa,OAAO,KAAK;AAExC,UAAI,OAAO,QAAQ;AACjB,kBAAM,yBAAU,UAAU,MAAM;AAAA,MAClC;AAGA,gBAAM,6BAAY,UAAU,MAAM;AAAA,IACpC;AAEA,QAAI,QAAQ,IAAI,gBAAgB;AAE9B,YAAMC,OAAM,MAAM,IAAI,iBAAiB;AAAA,QACrC;AAAA,QACA,SAAS;AAAA,QAET,QAAQ;AAAA,MACV,CAAC;AAED,UAAI,CAACA,MAAK;AACR,eAAO,mBAAI,KAAK,wBAAwB;AAAA,MAC1C;AAEA,gBAAM,gCAAe,kBAAAC,SAAU,EAAE,KAAK,GAAG,EAAE,GAAG,GAAG,CAAC;AAClD,yBAAI,KAAK,qBAAqBD,IAAG,GAAG;AACpC;AAAA,IACF;AAGA,QAAI,CAAC,eAAe;AAClB,yBAAI,KAAK,yCAAyC;AAClD,yBAAI;AAAA,QACF;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,MAAM,UAAM;AAAA,MAChB,OAAO,qBAAqB;AAAA,QAC1B,QAAQ;AAAA,QACR;AAAA,QACA,iBAAiB;AAAA,QAEjB,QAAQ;AAAA,MACV,CAAC;AAAA,MACD,EAAE,GAAG,GAAG;AAAA,IACV;AAEA,QAAI,CAAC,KAAK;AACR,aAAO,mBAAI,KAAK,wBAAwB;AAAA,IAC1C;AAEA,uBAAI,KAAK,qBAAqB,GAAG,GAAG;AAAA,EACtC,SAAS,KAAK;AACZ,uBAAI,KAAK,mBAAI,KAAK,4BAA4B,CAAC;AAC/C,uBAAI;AAAA,MACF,mBAAI;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AAAA,EACzB;AACF;",
6
- "names": ["fs", "path", "ref", "simpleGit"]
4
+ "sourcesContent": ["import { inspect } from 'util';\n\nimport simpleGit from 'simple-git';\n\nimport * as Buildkite from '../../api/buildkite';\nimport * as Git from '../../api/git';\nimport * as GitHub from '../../api/github';\nimport { isCiEnv } from '../../utils/env';\nimport { createLogger, log } from '../../utils/logging';\nimport { hasNpmrcSecret } from '../../utils/npmrc';\nimport { throwOnTimeout } from '../../utils/wait';\nimport { runESLint } from '../adapter/eslint';\nimport { runPrettier } from '../adapter/prettier';\nimport { createDestinationFileReader } from '../configure/analysis/project';\n\nimport { internalLint } from './internal';\nimport type { Input } from './types';\n\nconst RENOVATE_DEFAULT_PREFIX = 'renovate';\n\nconst AUTOFIX_COMMIT_MESSAGE = 'Run `skuba format`';\n\nexport const AUTOFIX_IGNORE_FILES_BASE: Git.ChangedFile[] = [\n {\n path: 'Dockerfile-incunabulum',\n state: 'added',\n },\n];\n\nexport const AUTOFIX_IGNORE_FILES_NPMRC: Git.ChangedFile[] = [\n {\n path: '.npmrc',\n state: 'added',\n },\n {\n path: '.npmrc',\n state: 'modified',\n },\n];\n\nconst shouldPush = async ({\n currentBranch,\n dir,\n}: {\n currentBranch?: string;\n dir: string;\n}) => {\n if (!isCiEnv()) {\n // We're not running in a CI environment so we don't need to push autofixes.\n // Ideally we'd drive this off of repository write permissions, but that is\n // non-trivial to infer without attempting an actual write.\n return false;\n }\n\n const isDefaultBuildkiteBranch =\n currentBranch &&\n [process.env.BUILDKITE_PIPELINE_DEFAULT_BRANCH, 'master', 'main'].includes(\n currentBranch,\n );\n\n const isProtectedGitHubBranch = process.env.GITHUB_REF_PROTECTED === 'true';\n\n if (isDefaultBuildkiteBranch || isProtectedGitHubBranch) {\n // The current branch is a protected branch.\n // We respect GitHub Flow; avoid pushing directly to the default branch.\n return false;\n }\n\n if (currentBranch?.startsWith(RENOVATE_DEFAULT_PREFIX)) {\n try {\n await GitHub.getPullRequestNumber();\n } catch (error) {\n const warning =\n 'An autofix is available, but it was not pushed because an open pull request for this Renovate branch could not be found. If a pull request has since been created, retry the lint step to push the fix.';\n log.warn(warning);\n try {\n await Buildkite.annotate(Buildkite.md.terminal(warning));\n } catch {}\n\n return false;\n }\n }\n\n let headCommitMessage;\n try {\n headCommitMessage = await Git.getHeadCommitMessage({ dir });\n } catch {}\n\n if (headCommitMessage?.startsWith(AUTOFIX_COMMIT_MESSAGE)) {\n // Short circuit when the head commit appears to be one of our autofixes.\n // Repeating the same operation is unlikely to correct outstanding issues.\n return false;\n }\n\n // Allow the push attempt to go ahead if our guards have been cleared.\n return true;\n};\n\nconst getIgnores = async (dir: string): Promise<Git.ChangedFile[]> => {\n const contents = await createDestinationFileReader(dir)('.npmrc');\n\n // If an .npmrc has secrets, we need to ignore it\n if (hasNpmrcSecret(contents ?? '')) {\n return [...AUTOFIX_IGNORE_FILES_BASE, ...AUTOFIX_IGNORE_FILES_NPMRC];\n }\n\n return AUTOFIX_IGNORE_FILES_BASE;\n};\n\ninterface AutofixParameters {\n debug: Input['debug'];\n\n eslint: boolean;\n prettier: boolean;\n internal: boolean;\n}\n\nexport const autofix = async (params: AutofixParameters): Promise<void> => {\n const dir = process.cwd();\n\n if (!params.eslint && !params.prettier && !params.internal) {\n return;\n }\n\n let currentBranch;\n try {\n currentBranch = await Git.currentBranch({ dir });\n } catch {}\n\n if (!(await shouldPush({ currentBranch, dir }))) {\n return;\n }\n\n try {\n log.newline();\n\n log.warn(\n `Attempting to autofix issues (${[\n params.eslint ? 'ESLint' : undefined,\n params.internal ? 'skuba' : undefined,\n 'Prettier', // Prettier is always run\n ]\n .filter((s) => s !== undefined)\n .join(', ')})...`,\n );\n\n const logger = createLogger(params.debug);\n\n if (params.internal) {\n await internalLint('format');\n }\n\n if (params.eslint) {\n await runESLint('format', logger);\n }\n\n // Unconditionally re-run Prettier; reaching here means we have pre-existing\n // format violations or may have created new ones through ESLint/internal fixes.\n await runPrettier('format', logger);\n\n if (process.env.GITHUB_ACTIONS) {\n // GitHub runners have Git installed locally\n const ref = await Git.commitAllChanges({\n dir,\n message: AUTOFIX_COMMIT_MESSAGE,\n\n ignore: await getIgnores(dir),\n });\n\n if (!ref) {\n return log.warn('No autofixes detected.');\n }\n\n await throwOnTimeout(simpleGit().push(), { s: 30 });\n log.warn(`Pushed fix commit ${ref}.`);\n return;\n }\n\n // Other CI Environments, use GitHub API\n if (!currentBranch) {\n log.warn('Could not determine the current branch.');\n log.warn(\n 'Please propagate BUILDKITE_BRANCH, GITHUB_HEAD_REF, GITHUB_REF_NAME, or the .git directory to your container.',\n );\n return;\n }\n\n const ref = await throwOnTimeout(\n GitHub.uploadAllFileChanges({\n branch: currentBranch,\n dir,\n messageHeadline: AUTOFIX_COMMIT_MESSAGE,\n\n ignore: await getIgnores(dir),\n }),\n { s: 30 },\n );\n\n if (!ref) {\n return log.warn('No autofixes detected.');\n }\n\n log.warn(`Pushed fix commit ${ref}.`);\n } catch (err) {\n log.warn(log.bold('Failed to push fix commit.'));\n log.warn(\n log.bold(\n 'Does your CI environment have write access to your Git repository?',\n ),\n );\n log.subtle(inspect(err));\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,wBAAsB;AAEtB,gBAA2B;AAC3B,UAAqB;AACrB,aAAwB;AACxB,iBAAwB;AACxB,qBAAkC;AAClC,mBAA+B;AAC/B,kBAA+B;AAC/B,oBAA0B;AAC1B,sBAA4B;AAC5B,qBAA4C;AAE5C,sBAA6B;AAG7B,MAAM,0BAA0B;AAEhC,MAAM,yBAAyB;AAExB,MAAM,4BAA+C;AAAA,EAC1D;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AACF;AAEO,MAAM,6BAAgD;AAAA,EAC3D;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AACF;AAEA,MAAM,aAAa,OAAO;AAAA,EACxB;AAAA,EACA;AACF,MAGM;AACJ,MAAI,KAAC,oBAAQ,GAAG;AAId,WAAO;AAAA,EACT;AAEA,Q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F,mBAAI;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AAAA,EACzB;AACF;",
6
+ "names": ["ref", "simpleGit"]
7
7
  }
@@ -7,4 +7,9 @@ export declare class StreamInterceptor extends stream.Transform {
7
7
  output(): string;
8
8
  _transform(chunk: Uint8Array, _encoding: BufferEncoding, callback: stream.TransformCallback): void;
9
9
  }
10
- export declare const externalLint: (input: Input) => Promise<void>;
10
+ export declare const externalLint: (input: Input) => Promise<{
11
+ eslint: import("../adapter/eslint").ESLintOutput;
12
+ prettier: import("../adapter/prettier").PrettierOutput;
13
+ tscOk: boolean;
14
+ tscOutputStream: StreamInterceptor;
15
+ }>;
@@ -33,11 +33,6 @@ __export(external_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(external_exports);
35
35
  var import_stream = __toESM(require("stream"));
36
- var import_util = require("util");
37
- var import_logging = require("../../utils/logging");
38
- var import_wait = require("../../utils/wait");
39
- var import_annotate = require("./annotate");
40
- var import_autofix = require("./autofix");
41
36
  var import_eslint = require("./eslint");
42
37
  var import_prettier = require("./prettier");
43
38
  var import_tsc = require("./tsc");
@@ -84,30 +79,12 @@ const externalLint = async (input) => {
84
79
  const tscOutputStream = new StreamInterceptor();
85
80
  tscOutputStream.pipe(input.tscOutputStream ?? process.stdout);
86
81
  const { eslint, prettier, tscOk } = await lint({ ...input, tscOutputStream });
87
- try {
88
- await (0, import_wait.throwOnTimeout)(
89
- (0, import_annotate.createAnnotations)(eslint, prettier, tscOk, tscOutputStream),
90
- { s: 30 }
91
- );
92
- } catch (err) {
93
- import_logging.log.warn("Failed to annotate lint results.");
94
- import_logging.log.subtle((0, import_util.inspect)(err));
95
- }
96
- if (!eslint.ok || !prettier.ok || !tscOk) {
97
- const tools = [
98
- ...eslint.ok ? [] : ["ESLint"],
99
- ...prettier.ok ? [] : ["Prettier"],
100
- ...tscOk ? [] : ["tsc"]
101
- ];
102
- import_logging.log.newline();
103
- import_logging.log.err(`${tools.join(", ")} found issues that require triage.`);
104
- process.exitCode = 1;
105
- }
106
- await (0, import_autofix.autofix)({
107
- debug: input.debug,
108
- eslint: eslint.fixable,
109
- prettier: !prettier.ok
110
- });
82
+ return {
83
+ eslint,
84
+ prettier,
85
+ tscOk,
86
+ tscOutputStream
87
+ };
111
88
  };
112
89
  // Annotate the CommonJS export names for ESM import in node:
113
90
  0 && (module.exports = {