skuba 7.3.1 → 7.4.0-horrible-hacks-20240206024353

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 (207) hide show
  1. package/README.md +3 -3
  2. package/jest/transform.test.ts +3 -1
  3. package/lib/api/jest/index.d.ts +1 -1
  4. package/lib/api/jest/index.js.map +2 -2
  5. package/lib/cli/adapter/prettier.d.ts +1 -1
  6. package/lib/cli/adapter/prettier.js +11 -10
  7. package/lib/cli/adapter/prettier.js.map +2 -2
  8. package/lib/cli/build/index.js +0 -2
  9. package/lib/cli/build/index.js.map +2 -2
  10. package/lib/cli/buildPackage.js +0 -2
  11. package/lib/cli/buildPackage.js.map +2 -2
  12. package/lib/cli/configure/analyseConfiguration.d.ts +2 -0
  13. package/lib/cli/configure/analyseConfiguration.js.map +2 -2
  14. package/lib/cli/configure/getEntryPoint.js +1 -1
  15. package/lib/cli/configure/getEntryPoint.js.map +2 -2
  16. package/lib/cli/configure/getProjectType.js +1 -1
  17. package/lib/cli/configure/getProjectType.js.map +2 -2
  18. package/lib/cli/configure/index.js +11 -8
  19. package/lib/cli/configure/index.js.map +2 -2
  20. package/lib/cli/configure/modules/index.js +0 -2
  21. package/lib/cli/configure/modules/index.js.map +2 -2
  22. package/lib/cli/configure/modules/package.d.ts +1 -1
  23. package/lib/cli/configure/modules/package.js +2 -1
  24. package/lib/cli/configure/modules/package.js.map +2 -2
  25. package/lib/cli/configure/patchRenovateConfig.d.ts +2 -1
  26. package/lib/cli/configure/patchRenovateConfig.js +23 -10
  27. package/lib/cli/configure/patchRenovateConfig.js.map +2 -2
  28. package/lib/cli/configure/types.d.ts +2 -0
  29. package/lib/cli/configure/types.js.map +1 -1
  30. package/lib/cli/configure/upgrade/index.d.ts +15 -0
  31. package/lib/cli/configure/upgrade/index.js +130 -0
  32. package/lib/cli/configure/upgrade/index.js.map +7 -0
  33. package/lib/cli/configure/{addEmptyExports.d.ts → upgrade/patches/7.3.1/addEmptyExports.d.ts} +2 -2
  34. package/lib/cli/configure/{addEmptyExports.js → upgrade/patches/7.3.1/addEmptyExports.js} +15 -11
  35. package/lib/cli/configure/upgrade/patches/7.3.1/addEmptyExports.js.map +7 -0
  36. package/lib/cli/configure/upgrade/patches/7.3.1/index.d.ts +2 -0
  37. package/lib/cli/configure/upgrade/patches/7.3.1/index.js +55 -0
  38. package/lib/cli/configure/upgrade/patches/7.3.1/index.js.map +7 -0
  39. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.d.ts +2 -0
  40. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js +94 -0
  41. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js.map +7 -0
  42. package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.d.ts +2 -0
  43. package/lib/cli/configure/{patchDockerfile.js → upgrade/patches/7.3.1/patchDockerfile.js} +18 -12
  44. package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.js.map +7 -0
  45. package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.d.ts +2 -0
  46. package/lib/cli/configure/{patchServerListener.js → upgrade/patches/7.3.1/patchServerListener.js} +18 -14
  47. package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.js.map +7 -0
  48. package/lib/cli/format.js +7 -14
  49. package/lib/cli/format.js.map +2 -2
  50. package/lib/cli/init/getConfig.d.ts +4 -2
  51. package/lib/cli/init/getConfig.js +53 -26
  52. package/lib/cli/init/getConfig.js.map +2 -2
  53. package/lib/cli/init/git.d.ts +2 -1
  54. package/lib/cli/init/git.js +2 -9
  55. package/lib/cli/init/git.js.map +2 -2
  56. package/lib/cli/init/index.d.ts +1 -1
  57. package/lib/cli/init/index.js +19 -9
  58. package/lib/cli/init/index.js.map +2 -2
  59. package/lib/cli/init/prompts.d.ts +26 -3
  60. package/lib/cli/init/prompts.js +10 -2
  61. package/lib/cli/init/prompts.js.map +2 -2
  62. package/lib/cli/init/types.d.ts +21 -0
  63. package/lib/cli/init/types.js +5 -1
  64. package/lib/cli/init/types.js.map +2 -2
  65. package/lib/cli/init/writePackageJson.d.ts +6 -0
  66. package/lib/cli/init/writePackageJson.js.map +2 -2
  67. package/lib/cli/lint/annotate/buildkite/index.d.ts +2 -1
  68. package/lib/cli/lint/annotate/buildkite/index.js +5 -3
  69. package/lib/cli/lint/annotate/buildkite/index.js.map +2 -2
  70. package/lib/cli/lint/annotate/buildkite/internal.d.ts +2 -0
  71. package/lib/cli/lint/annotate/buildkite/internal.js +45 -0
  72. package/lib/cli/lint/annotate/buildkite/internal.js.map +7 -0
  73. package/lib/cli/lint/annotate/github/index.d.ts +2 -1
  74. package/lib/cli/lint/annotate/github/index.js +4 -2
  75. package/lib/cli/lint/annotate/github/index.js.map +2 -2
  76. package/lib/cli/lint/annotate/github/internal.d.ts +3 -0
  77. package/lib/cli/lint/annotate/github/internal.js +36 -0
  78. package/lib/cli/lint/annotate/github/internal.js.map +7 -0
  79. package/lib/cli/lint/annotate/index.d.ts +4 -3
  80. package/lib/cli/lint/annotate/index.js +9 -3
  81. package/lib/cli/lint/annotate/index.js.map +2 -2
  82. package/lib/cli/lint/autofix.d.ts +3 -1
  83. package/lib/cli/lint/autofix.js +36 -59
  84. package/lib/cli/lint/autofix.js.map +3 -3
  85. package/lib/cli/lint/external.d.ts +6 -1
  86. package/lib/cli/lint/external.js +6 -29
  87. package/lib/cli/lint/external.js.map +2 -2
  88. package/lib/cli/lint/index.d.ts +2 -1
  89. package/lib/cli/lint/index.js +46 -14
  90. package/lib/cli/lint/index.js.map +2 -2
  91. package/lib/cli/lint/internal.d.ts +12 -1
  92. package/lib/cli/lint/internal.js +55 -19
  93. package/lib/cli/lint/internal.js.map +3 -3
  94. package/lib/cli/lint/internalLints/deleteFiles.d.ts +3 -0
  95. package/lib/cli/lint/internalLints/deleteFiles.js +102 -0
  96. package/lib/cli/lint/internalLints/deleteFiles.js.map +7 -0
  97. package/lib/cli/lint/internalLints/noSkubaTemplateJs.d.ts +3 -0
  98. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +75 -0
  99. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +7 -0
  100. package/lib/cli/lint/internalLints/refreshConfigFiles.d.ts +11 -0
  101. package/lib/cli/lint/internalLints/refreshConfigFiles.js +147 -0
  102. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +7 -0
  103. package/lib/cli/test/index.js +0 -2
  104. package/lib/cli/test/index.js.map +2 -2
  105. package/lib/skuba.d.ts +1 -1
  106. package/lib/skuba.js.map +1 -1
  107. package/lib/utils/exec.d.ts +2 -1
  108. package/lib/utils/exec.js +1 -0
  109. package/lib/utils/exec.js.map +2 -2
  110. package/lib/utils/logging.d.ts +2 -0
  111. package/lib/utils/logging.js +1 -0
  112. package/lib/utils/logging.js.map +2 -2
  113. package/lib/utils/logo.js +6 -10
  114. package/lib/utils/logo.js.map +3 -3
  115. package/lib/utils/manifest.d.ts +1 -1
  116. package/lib/utils/manifest.js +1 -1
  117. package/lib/utils/manifest.js.map +2 -2
  118. package/lib/utils/npmrc.d.ts +1 -0
  119. package/lib/utils/npmrc.js +29 -0
  120. package/lib/utils/npmrc.js.map +7 -0
  121. package/lib/utils/packageManager.d.ts +24 -0
  122. package/lib/utils/packageManager.js +97 -0
  123. package/lib/utils/packageManager.js.map +7 -0
  124. package/lib/utils/template.d.ts +3 -0
  125. package/lib/utils/template.js +2 -0
  126. package/lib/utils/template.js.map +2 -2
  127. package/lib/utils/worker.d.ts +1 -0
  128. package/lib/wrapper/http.d.ts +1 -0
  129. package/package.json +39 -36
  130. package/template/base/_.dockerignore +0 -1
  131. package/template/base/_.eslintignore +1 -0
  132. package/template/base/_.gitignore +1 -1
  133. package/template/base/_.npmrc +8 -0
  134. package/template/express-rest-api/.buildkite/pipeline.yml +13 -10
  135. package/template/express-rest-api/.gantry/dev.yml +3 -0
  136. package/template/express-rest-api/Dockerfile +6 -12
  137. package/template/express-rest-api/Dockerfile.dev-deps +6 -5
  138. package/template/express-rest-api/README.md +6 -6
  139. package/template/express-rest-api/docker-compose.yml +0 -10
  140. package/template/express-rest-api/gantry.apply.yml +5 -0
  141. package/template/express-rest-api/gantry.build.yml +1 -2
  142. package/template/express-rest-api/package.json +2 -2
  143. package/template/express-rest-api/skuba.template.js +1 -0
  144. package/template/greeter/.buildkite/pipeline.yml +12 -9
  145. package/template/greeter/Dockerfile +6 -5
  146. package/template/greeter/README.md +6 -6
  147. package/template/greeter/docker-compose.yml +0 -10
  148. package/template/greeter/package.json +1 -1
  149. package/template/greeter/skuba.template.js +1 -0
  150. package/template/koa-rest-api/.buildkite/pipeline.yml +13 -10
  151. package/template/koa-rest-api/.gantry/dev.yml +3 -0
  152. package/template/koa-rest-api/.nvmrc +1 -1
  153. package/template/koa-rest-api/Dockerfile +6 -12
  154. package/template/koa-rest-api/Dockerfile.dev-deps +6 -5
  155. package/template/koa-rest-api/README.md +6 -6
  156. package/template/koa-rest-api/docker-compose.yml +0 -10
  157. package/template/koa-rest-api/gantry.apply.yml +5 -0
  158. package/template/koa-rest-api/gantry.build.yml +1 -2
  159. package/template/koa-rest-api/package.json +8 -6
  160. package/template/koa-rest-api/skuba.template.js +1 -0
  161. package/template/koa-rest-api/src/framework/validation.test.ts +48 -15
  162. package/template/koa-rest-api/src/framework/validation.ts +31 -8
  163. package/template/koa-rest-api/src/testing/types.ts +16 -4
  164. package/template/lambda-sqs-worker/.buildkite/pipeline.yml +21 -15
  165. package/template/lambda-sqs-worker/Dockerfile +6 -6
  166. package/template/lambda-sqs-worker/README.md +8 -8
  167. package/template/lambda-sqs-worker/_.npmrc +12 -0
  168. package/template/lambda-sqs-worker/docker-compose.yml +0 -15
  169. package/template/lambda-sqs-worker/package.json +3 -4
  170. package/template/lambda-sqs-worker/serverless.yml +4 -1
  171. package/template/lambda-sqs-worker/skuba.template.js +1 -0
  172. package/template/lambda-sqs-worker/src/hooks.ts +1 -2
  173. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +42 -18
  174. package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
  175. package/template/lambda-sqs-worker-cdk/Dockerfile +9 -7
  176. package/template/lambda-sqs-worker-cdk/cdk.json +12 -6
  177. package/template/lambda-sqs-worker-cdk/docker-compose.yml +0 -15
  178. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +1587 -225
  179. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +23 -3
  180. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +127 -14
  181. package/template/lambda-sqs-worker-cdk/package.json +5 -3
  182. package/template/lambda-sqs-worker-cdk/shared/context-types.ts +1 -0
  183. package/template/lambda-sqs-worker-cdk/skuba.template.js +1 -0
  184. package/template/lambda-sqs-worker-cdk/src/app.ts +14 -1
  185. package/template/lambda-sqs-worker-cdk/src/postHook.ts +154 -0
  186. package/template/lambda-sqs-worker-cdk/src/preHook.ts +95 -0
  187. package/template/oss-npm-package/.github/workflows/release.yml +10 -7
  188. package/template/oss-npm-package/.github/workflows/validate.yml +10 -7
  189. package/template/oss-npm-package/.releaserc +16 -0
  190. package/template/oss-npm-package/README.md +17 -17
  191. package/template/oss-npm-package/_package.json +3 -2
  192. package/template/oss-npm-package/skuba.template.js +1 -0
  193. package/template/private-npm-package/.releaserc +16 -0
  194. package/template/private-npm-package/README.md +16 -16
  195. package/template/private-npm-package/_package.json +3 -3
  196. package/template/private-npm-package/skuba.template.js +1 -0
  197. package/lib/cli/configure/addEmptyExports.js.map +0 -7
  198. package/lib/cli/configure/modules/tsconfig.d.ts +0 -2
  199. package/lib/cli/configure/modules/tsconfig.js +0 -87
  200. package/lib/cli/configure/modules/tsconfig.js.map +0 -7
  201. package/lib/cli/configure/patchDockerfile.d.ts +0 -1
  202. package/lib/cli/configure/patchDockerfile.js.map +0 -7
  203. package/lib/cli/configure/patchServerListener.d.ts +0 -3
  204. package/lib/cli/configure/patchServerListener.js.map +0 -7
  205. package/lib/cli/configure/refreshIgnoreFiles.d.ts +0 -3
  206. package/lib/cli/configure/refreshIgnoreFiles.js +0 -78
  207. package/lib/cli/configure/refreshIgnoreFiles.js.map +0 -7
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/cli/configure/upgrade/patches/7.3.1/patchDockerfile.ts"],
4
+ "sourcesContent": ["import { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../utils/logging';\nimport { createDestinationFileReader } from '../../../analysis/project';\n\nconst DOCKERFILE_FILENAME = 'Dockerfile';\n\nconst NON_DEBIAN_REGEX = /gcr.io\\/distroless\\/nodejs:(18|20)/g;\nconst DEBIAN_REGEX = /gcr.io\\/distroless\\/nodejs(18|20)-debian11/g;\nconst VERSION_DEBIAN_REPLACE = 'gcr.io/distroless/nodejs$1-debian12';\n\nconst patchDockerfile = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n const maybeDockerfile = await readFile(DOCKERFILE_FILENAME);\n\n if (!maybeDockerfile) {\n return { result: 'skip', reason: 'no Dockerfile found' };\n }\n\n const patched = maybeDockerfile\n .replaceAll(NON_DEBIAN_REGEX, VERSION_DEBIAN_REPLACE)\n .replaceAll(DEBIAN_REGEX, VERSION_DEBIAN_REPLACE);\n\n if (patched === maybeDockerfile) {\n return { result: 'skip' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n await fs.promises.writeFile(DOCKERFILE_FILENAME, patched);\n\n return { result: 'apply' };\n};\n\nexport const tryPatchDockerfile: PatchFunction = async (\n mode: 'format' | 'lint',\n dir = process.cwd(),\n) => {\n try {\n return await patchDockerfile(mode, dir);\n } catch (err) {\n log.warn('Failed to patch Dockerfile.');\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,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,qBAA4C;AAE5C,MAAM,sBAAsB;AAE5B,MAAM,mBAAmB;AACzB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAE/B,MAAM,kBAAkB,OACtB,MACA,QAC6B;AAC7B,QAAM,eAAW,4CAA4B,GAAG;AAEhD,QAAM,kBAAkB,MAAM,SAAS,mBAAmB;AAE1D,MAAI,CAAC,iBAAiB;AACpB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,sBAAsB;AAAA,EACzD;AAEA,QAAM,UAAU,gBACb,WAAW,kBAAkB,sBAAsB,EACnD,WAAW,cAAc,sBAAsB;AAElD,MAAI,YAAY,iBAAiB;AAC/B,WAAO,EAAE,QAAQ,OAAO;AAAA,EAC1B;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,gBAAAA,QAAG,SAAS,UAAU,qBAAqB,OAAO;AAExD,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,qBAAoC,OAC/C,MACA,MAAM,QAAQ,IAAI,MACf;AACH,MAAI;AACF,WAAO,MAAM,gBAAgB,MAAM,GAAG;AAAA,EACxC,SAAS,KAAK;AACZ,uBAAI,KAAK,6BAA6B;AACtC,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { PatchFunction } from '../..';
2
+ export declare const tryPatchServerListener: PatchFunction;
@@ -28,16 +28,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var patchServerListener_exports = {};
30
30
  __export(patchServerListener_exports, {
31
- KEEP_ALIVE_CODE: () => KEEP_ALIVE_CODE,
32
- SERVER_LISTENER_FILENAME: () => SERVER_LISTENER_FILENAME,
33
31
  tryPatchServerListener: () => tryPatchServerListener
34
32
  });
35
33
  module.exports = __toCommonJS(patchServerListener_exports);
36
34
  var import_util = require("util");
37
35
  var import_fs_extra = __toESM(require("fs-extra"));
38
- var import_logging = require("../../utils/logging");
39
- var import_project = require("./analysis/project");
40
- var import_prettier = require("./processing/prettier");
36
+ var import_logging = require("../../../../../utils/logging");
37
+ var import_project = require("../../../analysis/project");
38
+ var import_prettier = require("../../../processing/prettier");
39
+ const SERVER_LISTENER_FILENAME = "src/listen.ts";
41
40
  const KEEP_ALIVE_CODE = `
42
41
  // Gantry ALB default idle timeout is 30 seconds
43
42
  // https://nodejs.org/docs/latest-v18.x/api/http.html#serverkeepalivetimeout
@@ -46,12 +45,14 @@ const KEEP_ALIVE_CODE = `
46
45
  // AWS recommends setting an application timeout larger than the load balancer
47
46
  listener.keepAliveTimeout = 31000;
48
47
  `;
49
- const SERVER_LISTENER_FILENAME = "src/listen.ts";
50
- const patchServerListener = async (dir) => {
48
+ const patchServerListener = async (mode, dir) => {
51
49
  const readFile = (0, import_project.createDestinationFileReader)(dir);
52
50
  let listener = await readFile(SERVER_LISTENER_FILENAME);
53
- if (!listener || listener.includes("keepAliveTimeout")) {
54
- return;
51
+ if (!listener) {
52
+ return { result: "skip", reason: "no listener file found" };
53
+ }
54
+ if (listener.includes("keepAliveTimeout")) {
55
+ return { result: "skip", reason: "keepAliveTimeout already configured" };
55
56
  }
56
57
  if (listener.includes("\napp.listen(")) {
57
58
  listener = listener.replace(
@@ -60,7 +61,10 @@ const patchServerListener = async (dir) => {
60
61
  );
61
62
  }
62
63
  if (!listener.includes("\nconst listener = app.listen(")) {
63
- return;
64
+ return { result: "skip", reason: "no server listener found" };
65
+ }
66
+ if (mode === "lint") {
67
+ return { result: "apply" };
64
68
  }
65
69
  listener = `${listener}${KEEP_ALIVE_CODE}`;
66
70
  await import_fs_extra.default.promises.writeFile(
@@ -69,19 +73,19 @@ const patchServerListener = async (dir) => {
69
73
  parser: "typescript"
70
74
  })
71
75
  );
76
+ return { result: "apply" };
72
77
  };
73
- const tryPatchServerListener = async (dir = process.cwd()) => {
78
+ const tryPatchServerListener = async (mode, dir = process.cwd()) => {
74
79
  try {
75
- await patchServerListener(dir);
80
+ return await patchServerListener(mode, dir);
76
81
  } catch (err) {
77
82
  import_logging.log.warn("Failed to patch server listener.");
78
83
  import_logging.log.subtle((0, import_util.inspect)(err));
84
+ return { result: "skip", reason: "due to an error" };
79
85
  }
80
86
  };
81
87
  // Annotate the CommonJS export names for ESM import in node:
82
88
  0 && (module.exports = {
83
- KEEP_ALIVE_CODE,
84
- SERVER_LISTENER_FILENAME,
85
89
  tryPatchServerListener
86
90
  });
87
91
  //# sourceMappingURL=patchServerListener.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/cli/configure/upgrade/patches/7.3.1/patchServerListener.ts"],
4
+ "sourcesContent": ["import { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../utils/logging';\nimport { createDestinationFileReader } from '../../../analysis/project';\nimport { formatPrettier } from '../../../processing/prettier';\n\nconst SERVER_LISTENER_FILENAME = 'src/listen.ts';\n\nconst KEEP_ALIVE_CODE = `\n// Gantry ALB default idle timeout is 30 seconds\n// https://nodejs.org/docs/latest-v18.x/api/http.html#serverkeepalivetimeout\n// Node default is 5 seconds\n// https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout\n// AWS recommends setting an application timeout larger than the load balancer\nlistener.keepAliveTimeout = 31000;\n`;\n\nconst patchServerListener = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n let listener = await readFile(SERVER_LISTENER_FILENAME);\n if (!listener) {\n return { result: 'skip', reason: 'no listener file found' };\n }\n\n if (listener.includes('keepAliveTimeout')) {\n return { result: 'skip', reason: 'keepAliveTimeout already configured' };\n }\n\n if (listener.includes('\\napp.listen(')) {\n listener = listener.replace(\n '\\napp.listen(',\n '\\nconst listener = app.listen(',\n );\n }\n\n if (!listener.includes('\\nconst listener = app.listen(')) {\n return { result: 'skip', reason: 'no server listener found' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n listener = `${listener}${KEEP_ALIVE_CODE}`;\n\n await fs.promises.writeFile(\n SERVER_LISTENER_FILENAME,\n await formatPrettier(listener, {\n parser: 'typescript',\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const tryPatchServerListener: PatchFunction = async (\n mode: 'format' | 'lint',\n dir = process.cwd(),\n) => {\n try {\n return await patchServerListener(mode, dir);\n } catch (err) {\n log.warn('Failed to patch server listener.');\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,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,qBAA4C;AAC5C,sBAA+B;AAE/B,MAAM,2BAA2B;AAEjC,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASxB,MAAM,sBAAsB,OAC1B,MACA,QAC6B;AAC7B,QAAM,eAAW,4CAA4B,GAAG;AAEhD,MAAI,WAAW,MAAM,SAAS,wBAAwB;AACtD,MAAI,CAAC,UAAU;AACb,WAAO,EAAE,QAAQ,QAAQ,QAAQ,yBAAyB;AAAA,EAC5D;AAEA,MAAI,SAAS,SAAS,kBAAkB,GAAG;AACzC,WAAO,EAAE,QAAQ,QAAQ,QAAQ,sCAAsC;AAAA,EACzE;AAEA,MAAI,SAAS,SAAS,eAAe,GAAG;AACtC,eAAW,SAAS;AAAA,MAClB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,SAAS,SAAS,gCAAgC,GAAG;AACxD,WAAO,EAAE,QAAQ,QAAQ,QAAQ,2BAA2B;AAAA,EAC9D;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,aAAW,GAAG,QAAQ,GAAG,eAAe;AAExC,QAAM,gBAAAA,QAAG,SAAS;AAAA,IAChB;AAAA,IACA,UAAM,gCAAe,UAAU;AAAA,MAC7B,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,yBAAwC,OACnD,MACA,MAAM,QAAQ,IAAI,MACf;AACH,MAAI;AACF,WAAO,MAAM,oBAAoB,MAAM,GAAG;AAAA,EAC5C,SAAS,KAAK;AACZ,uBAAI,KAAK,kCAAkC;AAC3C,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs"]
7
+ }
package/lib/cli/format.js CHANGED
@@ -36,32 +36,25 @@ var import_args = require("../utils/args");
36
36
  var import_logging = require("../utils/logging");
37
37
  var import_eslint = require("./adapter/eslint");
38
38
  var import_prettier = require("./adapter/prettier");
39
- var import_addEmptyExports = require("./configure/addEmptyExports");
40
- var import_patchDockerfile = require("./configure/patchDockerfile");
41
- var import_patchRenovateConfig = require("./configure/patchRenovateConfig");
42
- var import_patchServerListener = require("./configure/patchServerListener");
43
- var import_refreshIgnoreFiles = require("./configure/refreshIgnoreFiles");
39
+ var import_internal = require("./lint/internal");
44
40
  const format = async (args = process.argv.slice(2)) => {
45
- await Promise.all([
46
- (0, import_addEmptyExports.tryAddEmptyExports)(),
47
- (0, import_patchRenovateConfig.tryPatchRenovateConfig)(),
48
- (0, import_patchDockerfile.tryPatchDockerfile)(),
49
- (0, import_patchServerListener.tryPatchServerListener)(),
50
- (0, import_refreshIgnoreFiles.tryRefreshIgnoreFiles)()
51
- ]);
52
41
  const debug = (0, import_args.hasDebugFlag)(args);
42
+ import_logging.log.plain(import_chalk.default.blueBright("skuba lints"));
43
+ const internal = await (0, import_internal.internalLint)("format", { debug, serial: true });
53
44
  const logger = (0, import_logging.createLogger)(debug);
45
+ import_logging.log.newline();
54
46
  import_logging.log.plain(import_chalk.default.magenta("ESLint"));
55
47
  const eslint = await (0, import_eslint.runESLint)("format", logger);
56
48
  import_logging.log.newline();
57
49
  import_logging.log.plain(import_chalk.default.cyan("Prettier"));
58
50
  const prettier = await (0, import_prettier.runPrettier)("format", logger);
59
- if (eslint.ok && prettier.ok) {
51
+ if (eslint.ok && prettier.ok && internal.ok) {
60
52
  return;
61
53
  }
62
54
  const tools = [
63
55
  ...eslint.ok ? [] : ["ESLint"],
64
- ...prettier.ok ? [] : ["Prettier"]
56
+ ...prettier.ok ? [] : ["Prettier"],
57
+ ...internal.ok ? [] : ["skuba"]
65
58
  ];
66
59
  import_logging.log.newline();
67
60
  import_logging.log.err(tools.join(", "), "found issues that require triage.");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/cli/format.ts"],
4
- "sourcesContent": ["import chalk from 'chalk';\n\nimport { hasDebugFlag } from '../utils/args';\nimport { createLogger, log } from '../utils/logging';\n\nimport { runESLint } from './adapter/eslint';\nimport { runPrettier } from './adapter/prettier';\nimport { tryAddEmptyExports } from './configure/addEmptyExports';\nimport { tryPatchDockerfile } from './configure/patchDockerfile';\nimport { tryPatchRenovateConfig } from './configure/patchRenovateConfig';\nimport { tryPatchServerListener } from './configure/patchServerListener';\nimport { tryRefreshIgnoreFiles } from './configure/refreshIgnoreFiles';\n\nexport const format = async (args = process.argv.slice(2)): Promise<void> => {\n await Promise.all([\n tryAddEmptyExports(),\n tryPatchRenovateConfig(),\n tryPatchDockerfile(),\n tryPatchServerListener(),\n tryRefreshIgnoreFiles(),\n ]);\n\n const debug = hasDebugFlag(args);\n const logger = createLogger(debug);\n\n log.plain(chalk.magenta('ESLint'));\n\n const eslint = await runESLint('format', logger);\n\n log.newline();\n log.plain(chalk.cyan('Prettier'));\n\n const prettier = await runPrettier('format', logger);\n\n if (eslint.ok && prettier.ok) {\n return;\n }\n\n const tools = [\n ...(eslint.ok ? [] : ['ESLint']),\n ...(prettier.ok ? [] : ['Prettier']),\n ];\n\n log.newline();\n log.err(tools.join(', '), 'found issues that require triage.');\n\n process.exitCode = 1;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,kBAA6B;AAC7B,qBAAkC;AAElC,oBAA0B;AAC1B,sBAA4B;AAC5B,6BAAmC;AACnC,6BAAmC;AACnC,iCAAuC;AACvC,iCAAuC;AACvC,gCAAsC;AAE/B,MAAM,SAAS,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAqB;AAC3E,QAAM,QAAQ,IAAI;AAAA,QAChB,2CAAmB;AAAA,QACnB,mDAAuB;AAAA,QACvB,2CAAmB;AAAA,QACnB,mDAAuB;AAAA,QACvB,iDAAsB;AAAA,EACxB,CAAC;AAED,QAAM,YAAQ,0BAAa,IAAI;AAC/B,QAAM,aAAS,6BAAa,KAAK;AAEjC,qBAAI,MAAM,aAAAA,QAAM,QAAQ,QAAQ,CAAC;AAEjC,QAAM,SAAS,UAAM,yBAAU,UAAU,MAAM;AAE/C,qBAAI,QAAQ;AACZ,qBAAI,MAAM,aAAAA,QAAM,KAAK,UAAU,CAAC;AAEhC,QAAM,WAAW,UAAM,6BAAY,UAAU,MAAM;AAEnD,MAAI,OAAO,MAAM,SAAS,IAAI;AAC5B;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,GAAI,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ;AAAA,IAC9B,GAAI,SAAS,KAAK,CAAC,IAAI,CAAC,UAAU;AAAA,EACpC;AAEA,qBAAI,QAAQ;AACZ,qBAAI,IAAI,MAAM,KAAK,IAAI,GAAG,mCAAmC;AAE7D,UAAQ,WAAW;AACrB;",
4
+ "sourcesContent": ["import chalk from 'chalk';\n\nimport { hasDebugFlag } from '../utils/args';\nimport { createLogger, log } from '../utils/logging';\n\nimport { runESLint } from './adapter/eslint';\nimport { runPrettier } from './adapter/prettier';\nimport { internalLint } from './lint/internal';\n\nexport const format = async (args = process.argv.slice(2)): Promise<void> => {\n const debug = hasDebugFlag(args);\n\n log.plain(chalk.blueBright('skuba lints'));\n const internal = await internalLint('format', { debug, serial: true });\n\n const logger = createLogger(debug);\n\n log.newline();\n log.plain(chalk.magenta('ESLint'));\n\n const eslint = await runESLint('format', logger);\n\n log.newline();\n log.plain(chalk.cyan('Prettier'));\n\n const prettier = await runPrettier('format', logger);\n\n if (eslint.ok && prettier.ok && internal.ok) {\n return;\n }\n\n const tools = [\n ...(eslint.ok ? [] : ['ESLint']),\n ...(prettier.ok ? [] : ['Prettier']),\n ...(internal.ok ? [] : ['skuba']),\n ];\n\n log.newline();\n log.err(tools.join(', '), 'found issues that require triage.');\n\n process.exitCode = 1;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,kBAA6B;AAC7B,qBAAkC;AAElC,oBAA0B;AAC1B,sBAA4B;AAC5B,sBAA6B;AAEtB,MAAM,SAAS,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAqB;AAC3E,QAAM,YAAQ,0BAAa,IAAI;AAE/B,qBAAI,MAAM,aAAAA,QAAM,WAAW,aAAa,CAAC;AACzC,QAAM,WAAW,UAAM,8BAAa,UAAU,EAAE,OAAO,QAAQ,KAAK,CAAC;AAErE,QAAM,aAAS,6BAAa,KAAK;AAEjC,qBAAI,QAAQ;AACZ,qBAAI,MAAM,aAAAA,QAAM,QAAQ,QAAQ,CAAC;AAEjC,QAAM,SAAS,UAAM,yBAAU,UAAU,MAAM;AAE/C,qBAAI,QAAQ;AACZ,qBAAI,MAAM,aAAAA,QAAM,KAAK,UAAU,CAAC;AAEhC,QAAM,WAAW,UAAM,6BAAY,UAAU,MAAM;AAEnD,MAAI,OAAO,MAAM,SAAS,MAAM,SAAS,IAAI;AAC3C;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,GAAI,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ;AAAA,IAC9B,GAAI,SAAS,KAAK,CAAC,IAAI,CAAC,UAAU;AAAA,IAClC,GAAI,SAAS,KAAK,CAAC,IAAI,CAAC,OAAO;AAAA,EACjC;AAEA,qBAAI,QAAQ;AACZ,qBAAI,IAAI,MAAM,KAAK,IAAI,GAAG,mCAAmC;AAE7D,UAAQ,WAAW;AACrB;",
6
6
  "names": ["chalk"]
7
7
  }
@@ -1,19 +1,21 @@
1
1
  import { type TemplateConfig } from '../../utils/template';
2
+ import { type Choice } from './prompts';
2
3
  import { type InitConfig } from './types';
3
- import { type FormChoice } from 'enquirer';
4
4
  export declare const runForm: <T = Record<string, string>>(props: {
5
- choices: Readonly<FormChoice[]>;
5
+ choices: Readonly<Choice[]>;
6
6
  message: string;
7
7
  name: string;
8
8
  }) => Promise<T>;
9
9
  export declare const getTemplateConfig: (dir: string) => TemplateConfig;
10
10
  export declare const configureFromPrompt: () => Promise<InitConfig>;
11
11
  export declare const getConfig: () => Promise<{
12
+ packageManager: "yarn" | "pnpm";
12
13
  templateName: string;
13
14
  destinationDir: string;
14
15
  templateComplete: boolean;
15
16
  templateData: {
16
17
  port: string;
18
+ defaultBranch: string;
17
19
  orgName: string;
18
20
  repoName: string;
19
21
  ownerName: string;
@@ -36,22 +36,23 @@ __export(getConfig_exports, {
36
36
  module.exports = __toCommonJS(getConfig_exports);
37
37
  var import_path = __toESM(require("path"));
38
38
  var import_chalk = __toESM(require("chalk"));
39
+ var import_enquirer = require("enquirer");
39
40
  var import_fs_extra = __toESM(require("fs-extra"));
40
41
  var import_copy = require("../../utils/copy");
41
42
  var import_error = require("../../utils/error");
42
43
  var import_logging = require("../../utils/logging");
44
+ var import_packageManager = require("../../utils/packageManager");
43
45
  var import_port = require("../../utils/port");
44
46
  var import_template = require("../../utils/template");
45
47
  var import_git = require("./git");
46
48
  var import_prompts = require("./prompts");
47
49
  var import_types = require("./types");
48
- var import_enquirer = require("enquirer");
49
50
  const runForm = (props) => {
50
51
  const { message, name } = props;
51
52
  const choices = props.choices.map((choice) => ({
52
53
  ...choice,
53
54
  validate: (value) => {
54
- if (!value || value === "" || value === choice.initial) {
55
+ if (!value || value === "" || value === choice.initial && !choice.allowInitial) {
55
56
  return "Form is not complete";
56
57
  }
57
58
  return choice.validate?.(value) ?? true;
@@ -92,20 +93,38 @@ const createDirectory = async (dir) => {
92
93
  }
93
94
  };
94
95
  const cloneTemplate = async (templateName, destinationDir) => {
95
- if (templateName.startsWith("github:")) {
96
+ const isCustomTemplate = templateName.startsWith("github:");
97
+ if (isCustomTemplate) {
96
98
  const gitHubPath = templateName.slice("github:".length);
97
- return (0, import_git.downloadGitHubTemplate)(gitHubPath, destinationDir);
99
+ await (0, import_git.downloadGitHubTemplate)(gitHubPath, destinationDir);
100
+ } else {
101
+ const templateDir = import_path.default.join(import_template.TEMPLATE_DIR, templateName);
102
+ await (0, import_copy.copyFiles)({
103
+ // assume built-in templates have no extraneous files
104
+ include: () => true,
105
+ sourceRoot: templateDir,
106
+ destinationRoot: destinationDir,
107
+ processors: [],
108
+ // built-in templates have files like _package.json
109
+ stripUnderscorePrefix: true
110
+ });
98
111
  }
99
- const templateDir = import_path.default.join(import_template.TEMPLATE_DIR, templateName);
100
- await (0, import_copy.copyFiles)({
101
- // assume built-in templates have no extraneous files
102
- include: () => true,
103
- sourceRoot: templateDir,
104
- destinationRoot: destinationDir,
105
- processors: [],
106
- // built-in templates have files like _package.json
107
- stripUnderscorePrefix: true
108
- });
112
+ const templateConfig = getTemplateConfig(
113
+ import_path.default.join(process.cwd(), destinationDir)
114
+ );
115
+ if (isCustomTemplate) {
116
+ import_logging.log.newline();
117
+ import_logging.log.warn(
118
+ "You may need to run",
119
+ import_logging.log.bold(
120
+ (0, import_packageManager.configForPackageManager)(templateConfig.packageManager).exec,
121
+ "skuba",
122
+ "configure"
123
+ ),
124
+ "once this is done."
125
+ );
126
+ }
127
+ return templateConfig;
109
128
  };
110
129
  const getTemplateName = async () => {
111
130
  const templateSelection = await import_prompts.TEMPLATE_PROMPT.run();
@@ -128,6 +147,7 @@ const getTemplateConfig = (dir) => {
128
147
  return {
129
148
  entryPoint: void 0,
130
149
  fields: [],
150
+ packageManager: import_packageManager.DEFAULT_PACKAGE_MANAGER,
131
151
  type: void 0
132
152
  };
133
153
  }
@@ -137,7 +157,8 @@ const getTemplateConfig = (dir) => {
137
157
  const baseToTemplateData = async ({
138
158
  ownerName,
139
159
  platformName,
140
- repoName
160
+ repoName,
161
+ defaultBranch
141
162
  }) => {
142
163
  const [orgName, teamName] = ownerName.split("/");
143
164
  const port = String(await (0, import_port.getRandomPort)());
@@ -148,6 +169,7 @@ const baseToTemplateData = async ({
148
169
  orgName,
149
170
  ownerName,
150
171
  repoName,
172
+ defaultBranch,
151
173
  // Use standalone username in `teamName` contexts
152
174
  teamName: teamName ?? orgName,
153
175
  port,
@@ -157,25 +179,24 @@ const baseToTemplateData = async ({
157
179
  };
158
180
  };
159
181
  const configureFromPrompt = async () => {
160
- const { ownerName, platformName, repoName } = await runForm(import_prompts.BASE_PROMPT_PROPS);
182
+ const { ownerName, platformName, repoName, defaultBranch } = await runForm(import_prompts.BASE_PROMPT_PROPS);
161
183
  import_logging.log.plain(import_chalk.default.cyan(repoName), "by", import_chalk.default.cyan(ownerName));
162
184
  const templateData = await baseToTemplateData({
163
185
  ownerName,
164
186
  platformName,
165
- repoName
187
+ repoName,
188
+ defaultBranch
166
189
  });
167
190
  const destinationDir = repoName;
168
191
  await createDirectory(destinationDir);
169
192
  import_logging.log.newline();
170
193
  const templateName = await getTemplateName();
171
- await cloneTemplate(templateName, destinationDir);
172
- const { entryPoint, fields, noSkip, type } = getTemplateConfig(
173
- import_path.default.join(process.cwd(), destinationDir)
174
- );
194
+ const { entryPoint, fields, noSkip, packageManager, type } = await cloneTemplate(templateName, destinationDir);
175
195
  if (fields.length === 0) {
176
196
  return {
177
197
  destinationDir,
178
198
  entryPoint,
199
+ packageManager,
179
200
  templateComplete: true,
180
201
  templateData,
181
202
  templateName,
@@ -193,6 +214,7 @@ const configureFromPrompt = async () => {
193
214
  return {
194
215
  destinationDir,
195
216
  entryPoint,
217
+ packageManager,
196
218
  templateComplete: true,
197
219
  templateData: { ...templateData, ...customAnswers2 },
198
220
  templateName,
@@ -200,11 +222,17 @@ const configureFromPrompt = async () => {
200
222
  };
201
223
  }
202
224
  import_logging.log.newline();
203
- import_logging.log.warn(`Resume this later with ${import_chalk.default.bold("yarn skuba configure")}.`);
225
+ import_logging.log.warn(
226
+ `Resume this later with ${import_chalk.default.bold(
227
+ (0, import_packageManager.configForPackageManager)(packageManager).exec,
228
+ "skuba configure"
229
+ )}.`
230
+ );
204
231
  const customAnswers = generatePlaceholders(fields);
205
232
  return {
206
233
  destinationDir,
207
234
  entryPoint,
235
+ packageManager,
208
236
  templateComplete: false,
209
237
  templateData: { ...templateData, ...customAnswers },
210
238
  templateName,
@@ -240,10 +268,7 @@ const configureFromPipe = async () => {
240
268
  ...result.data.templateData
241
269
  };
242
270
  await createDirectory(destinationDir);
243
- await cloneTemplate(templateName, destinationDir);
244
- const { entryPoint, fields, noSkip, type } = getTemplateConfig(
245
- import_path.default.join(process.cwd(), destinationDir)
246
- );
271
+ const { entryPoint, fields, noSkip, packageManager, type } = await cloneTemplate(templateName, destinationDir);
247
272
  if (!templateComplete) {
248
273
  if (noSkip) {
249
274
  import_logging.log.err("Templating for", import_logging.log.bold(templateName), "cannot be skipped.");
@@ -252,6 +277,7 @@ const configureFromPipe = async () => {
252
277
  return {
253
278
  ...result.data,
254
279
  entryPoint,
280
+ packageManager,
255
281
  templateData: {
256
282
  ...templateData,
257
283
  ...generatePlaceholders(fields)
@@ -271,6 +297,7 @@ const configureFromPipe = async () => {
271
297
  return {
272
298
  ...result.data,
273
299
  entryPoint,
300
+ packageManager,
274
301
  templateData,
275
302
  type
276
303
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/init/getConfig.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\n\nimport { copyFiles } from '../../utils/copy';\nimport { isErrorWithCode } from '../../utils/error';\nimport { log } from '../../utils/logging';\nimport { getRandomPort } from '../../utils/port';\nimport {\n TEMPLATE_CONFIG_FILENAME,\n TEMPLATE_DIR,\n type TemplateConfig,\n templateConfigSchema,\n} from '../../utils/template';\n\nimport { downloadGitHubTemplate } from './git';\nimport {\n BASE_PROMPT_PROPS,\n type BaseFields,\n GIT_PATH_PROMPT,\n SHOULD_CONTINUE_PROMPT,\n TEMPLATE_PROMPT,\n} from './prompts';\nimport { type InitConfig, initConfigInputSchema } from './types';\n\nimport { Form, type FormChoice } from 'enquirer';\n\nexport const runForm = <T = Record<string, string>>(props: {\n choices: Readonly<FormChoice[]>;\n message: string;\n name: string;\n}) => {\n const { message, name } = props;\n\n const choices = props.choices.map((choice) => ({\n ...choice,\n validate: (value: string | undefined) => {\n if (!value || value === '' || value === choice.initial) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(value) ?? true;\n },\n }));\n\n const form = new Form<T>({\n choices,\n message,\n name,\n validate: async (values) => {\n const results = await Promise.all(\n choices.map((choice) => choice.validate(values[choice.name])),\n );\n\n return (\n results.find((result) => typeof result === 'string') ??\n results.every((result) => result === true)\n );\n },\n });\n\n return form.run();\n};\n\nconst confirmShouldContinue = async (choices: Readonly<FormChoice[]>) => {\n const fieldsList = choices.map((choice) => choice.message);\n\n log.newline();\n log.plain('This template uses the following information:');\n log.newline();\n fieldsList.forEach((message) => log.subtle(`- ${message}`));\n\n log.newline();\n const result = await SHOULD_CONTINUE_PROMPT.run();\n\n return result === 'yes';\n};\n\nconst createDirectory = async (dir: string) => {\n try {\n await fs.promises.mkdir(dir);\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n log.err(`The directory '${dir}' already exists.`);\n process.exit(1);\n }\n\n throw err;\n }\n};\n\nconst cloneTemplate = async (templateName: string, destinationDir: string) => {\n if (templateName.startsWith('github:')) {\n const gitHubPath = templateName.slice('github:'.length);\n return downloadGitHubTemplate(gitHubPath, destinationDir);\n }\n\n const templateDir = path.join(TEMPLATE_DIR, templateName);\n\n await copyFiles({\n // assume built-in templates have no extraneous files\n include: () => true,\n sourceRoot: templateDir,\n destinationRoot: destinationDir,\n processors: [],\n // built-in templates have files like _package.json\n stripUnderscorePrefix: true,\n });\n};\n\nconst getTemplateName = async () => {\n const templateSelection = await TEMPLATE_PROMPT.run();\n\n if (templateSelection === 'github \u2192') {\n const gitHubPath = await GIT_PATH_PROMPT.run();\n return `github:${gitHubPath}`;\n }\n\n return templateSelection;\n};\n\nconst generatePlaceholders = (choices: FormChoice[]) =>\n Object.fromEntries(\n choices.map(({ name }) => [name, `<%- ${name} %>`] as const),\n );\n\nexport const getTemplateConfig = (dir: string): TemplateConfig => {\n const templateConfigPath = path.join(dir, TEMPLATE_CONFIG_FILENAME);\n\n try {\n /* eslint-disable-next-line @typescript-eslint/no-var-requires */\n const templateConfig = require(templateConfigPath) as unknown;\n\n return templateConfigSchema.parse(templateConfig);\n } catch (err) {\n if (isErrorWithCode(err, 'MODULE_NOT_FOUND')) {\n return {\n entryPoint: undefined,\n fields: [],\n type: undefined,\n };\n }\n\n throw err;\n }\n};\n\nconst baseToTemplateData = async ({\n ownerName,\n platformName,\n repoName,\n}: BaseFields) => {\n const [orgName, teamName] = ownerName.split('/');\n\n const port = String(await getRandomPort());\n\n if (!orgName) {\n throw new Error(`Invalid format for owner name: ${ownerName}`);\n }\n\n return {\n orgName,\n ownerName,\n repoName,\n // Use standalone username in `teamName` contexts\n teamName: teamName ?? orgName,\n\n port,\n\n platformName,\n lambdaCdkArchitecture: platformName === 'amd64' ? 'X86_64' : 'ARM_64',\n lambdaServerlessArchitecture:\n platformName === 'amd64' ? 'x86_64' : platformName,\n };\n};\n\nexport const configureFromPrompt = async (): Promise<InitConfig> => {\n const { ownerName, platformName, repoName } =\n await runForm<BaseFields>(BASE_PROMPT_PROPS);\n log.plain(chalk.cyan(repoName), 'by', chalk.cyan(ownerName));\n\n const templateData = await baseToTemplateData({\n ownerName,\n platformName,\n repoName,\n });\n\n const destinationDir = repoName;\n\n await createDirectory(destinationDir);\n\n log.newline();\n const templateName = await getTemplateName();\n\n await cloneTemplate(templateName, destinationDir);\n\n const { entryPoint, fields, noSkip, type } = getTemplateConfig(\n path.join(process.cwd(), destinationDir),\n );\n\n if (fields.length === 0) {\n return {\n destinationDir,\n entryPoint,\n templateComplete: true,\n templateData,\n templateName,\n type,\n };\n }\n\n const shouldContinue = noSkip ? true : await confirmShouldContinue(fields);\n\n if (shouldContinue) {\n log.newline();\n const customAnswers = await runForm({\n choices: fields,\n message: chalk.bold(`Complete ${chalk.cyan(templateName)}:`),\n name: 'customAnswers',\n });\n\n return {\n destinationDir,\n entryPoint,\n templateComplete: true,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n }\n\n log.newline();\n log.warn(`Resume this later with ${chalk.bold('yarn skuba configure')}.`);\n\n const customAnswers = generatePlaceholders(fields);\n\n return {\n destinationDir,\n entryPoint,\n templateComplete: false,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n};\n\nconst configureFromPipe = async (): Promise<InitConfig> => {\n let text = '';\n\n await new Promise((resolve) =>\n process.stdin\n .on('data', (chunk) => (text += chunk.toString()))\n .once('end', resolve),\n );\n\n text = text.trim();\n\n if (text === '') {\n log.err('No data from stdin.');\n process.exit(1);\n }\n\n let value: unknown;\n\n try {\n value = JSON.parse(text) as unknown;\n } catch {\n log.err('Invalid JSON from stdin.');\n process.exit(1);\n }\n\n const result = initConfigInputSchema.safeParse(value);\n\n if (!result.success) {\n log.err('Invalid data from stdin:');\n log.err(result.error);\n process.exit(1);\n }\n\n const { destinationDir, templateComplete, templateName } = result.data;\n\n const templateData = {\n ...(await baseToTemplateData(result.data.templateData)),\n ...result.data.templateData,\n };\n\n await createDirectory(destinationDir);\n\n await cloneTemplate(templateName, destinationDir);\n\n const { entryPoint, fields, noSkip, type } = getTemplateConfig(\n path.join(process.cwd(), destinationDir),\n );\n\n if (!templateComplete) {\n if (noSkip) {\n log.err('Templating for', log.bold(templateName), 'cannot be skipped.');\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n templateData: {\n ...templateData,\n ...generatePlaceholders(fields),\n },\n type,\n };\n }\n\n const required = fields.map(({ name }) => name);\n\n const provided = new Set(Object.keys(templateData));\n\n const missing = required.filter((name) => !provided.has(name));\n\n if (missing.length > 0) {\n log.err('This template uses the following information:');\n log.newline();\n missing.forEach((name) => log.err(`- ${name}`));\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n templateData,\n type,\n };\n};\n\nexport const getConfig = () =>\n process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,mBAAkB;AAClB,sBAAe;AAEf,kBAA0B;AAC1B,mBAAgC;AAChC,qBAAoB;AACpB,kBAA8B;AAC9B,sBAKO;AAEP,iBAAuC;AACvC,qBAMO;AACP,mBAAuD;AAEvD,sBAAsC;AAE/B,MAAM,UAAU,CAA6B,UAI9C;AACJ,QAAM,EAAE,SAAS,KAAK,IAAI;AAE1B,QAAM,UAAU,MAAM,QAAQ,IAAI,CAAC,YAAY;AAAA,IAC7C,GAAG;AAAA,IACH,UAAU,CAAC,UAA8B;AACvC,UAAI,CAAC,SAAS,UAAU,MAAM,UAAU,OAAO,SAAS;AACtD,eAAO;AAAA,MACT;AAEA,aAAO,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AA,IAChB;AAEA,WAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV;AAAA,MACA,cAAc;AAAA,QACZ,GAAG;AAAA,QACH,GAAG,qBAAqB,MAAM;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAW,OAAO,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI;AAE9C,QAAM,WAAW,IAAI,IAAI,OAAO,KAAK,YAAY,CAAC;AAElD,QAAM,UAAU,SAAS,OAAO,CAAC,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC;AAE7D,MAAI,QAAQ,SAAS,GAAG;AACtB,uBAAI,IAAI,+CAA+C;AACvD,uBAAI,QAAQ;AACZ,YAAQ,QAAQ,CAAC,SAAS,mBAAI,IAAI,KAAK,IAAI,EAAE,CAAC;AAC9C,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,SAAO;AAAA,IACL,GAAG,OAAO;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,YAAY,MACvB,QAAQ,MAAM,QAAQ,oBAAoB,IAAI,kBAAkB;",
4
+ "sourcesContent": ["import path from 'path';\n\nimport chalk from 'chalk';\nimport { Form, type FormChoice } from 'enquirer';\nimport fs from 'fs-extra';\n\nimport { copyFiles } from '../../utils/copy';\nimport { isErrorWithCode } from '../../utils/error';\nimport { log } from '../../utils/logging';\nimport {\n DEFAULT_PACKAGE_MANAGER,\n configForPackageManager,\n} from '../../utils/packageManager';\nimport { getRandomPort } from '../../utils/port';\nimport {\n TEMPLATE_CONFIG_FILENAME,\n TEMPLATE_DIR,\n type TemplateConfig,\n templateConfigSchema,\n} from '../../utils/template';\n\nimport { downloadGitHubTemplate } from './git';\nimport {\n BASE_PROMPT_PROPS,\n type BaseFields,\n type Choice,\n GIT_PATH_PROMPT,\n SHOULD_CONTINUE_PROMPT,\n TEMPLATE_PROMPT,\n} from './prompts';\nimport { type InitConfig, initConfigInputSchema } from './types';\n\nexport const runForm = <T = Record<string, string>>(props: {\n choices: Readonly<Choice[]>;\n message: string;\n name: string;\n}) => {\n const { message, name } = props;\n\n const choices = props.choices.map((choice) => ({\n ...choice,\n validate: (value: string | undefined) => {\n if (\n !value ||\n value === '' ||\n (value === choice.initial && !choice.allowInitial)\n ) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(value) ?? true;\n },\n }));\n\n const form = new Form<T>({\n choices,\n message,\n name,\n validate: async (values) => {\n const results = await Promise.all(\n choices.map((choice) => choice.validate(values[choice.name])),\n );\n\n return (\n results.find((result) => typeof result === 'string') ??\n results.every((result) => result === true)\n );\n },\n });\n\n return form.run();\n};\n\nconst confirmShouldContinue = async (choices: Readonly<FormChoice[]>) => {\n const fieldsList = choices.map((choice) => choice.message);\n\n log.newline();\n log.plain('This template uses the following information:');\n log.newline();\n fieldsList.forEach((message) => log.subtle(`- ${message}`));\n\n log.newline();\n const result = await SHOULD_CONTINUE_PROMPT.run();\n\n return result === 'yes';\n};\n\nconst createDirectory = async (dir: string) => {\n try {\n await fs.promises.mkdir(dir);\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n log.err(`The directory '${dir}' already exists.`);\n process.exit(1);\n }\n\n throw err;\n }\n};\n\nconst cloneTemplate = async (\n templateName: string,\n destinationDir: string,\n): Promise<TemplateConfig> => {\n const isCustomTemplate = templateName.startsWith('github:');\n\n if (isCustomTemplate) {\n const gitHubPath = templateName.slice('github:'.length);\n\n await downloadGitHubTemplate(gitHubPath, destinationDir);\n } else {\n const templateDir = path.join(TEMPLATE_DIR, templateName);\n\n await copyFiles({\n // assume built-in templates have no extraneous files\n include: () => true,\n sourceRoot: templateDir,\n destinationRoot: destinationDir,\n processors: [],\n // built-in templates have files like _package.json\n stripUnderscorePrefix: true,\n });\n }\n\n const templateConfig = getTemplateConfig(\n path.join(process.cwd(), destinationDir),\n );\n\n if (isCustomTemplate) {\n log.newline();\n log.warn(\n 'You may need to run',\n log.bold(\n configForPackageManager(templateConfig.packageManager).exec,\n 'skuba',\n 'configure',\n ),\n 'once this is done.',\n );\n }\n\n return templateConfig;\n};\n\nconst getTemplateName = async () => {\n const templateSelection = await TEMPLATE_PROMPT.run();\n\n if (templateSelection === 'github \u2192') {\n const gitHubPath = await GIT_PATH_PROMPT.run();\n return `github:${gitHubPath}`;\n }\n\n return templateSelection;\n};\n\nconst generatePlaceholders = (choices: FormChoice[]) =>\n Object.fromEntries(\n choices.map(({ name }) => [name, `<%- ${name} %>`] as const),\n );\n\nexport const getTemplateConfig = (dir: string): TemplateConfig => {\n const templateConfigPath = path.join(dir, TEMPLATE_CONFIG_FILENAME);\n\n try {\n /* eslint-disable-next-line @typescript-eslint/no-var-requires */\n const templateConfig = require(templateConfigPath) as unknown;\n\n return templateConfigSchema.parse(templateConfig);\n } catch (err) {\n if (isErrorWithCode(err, 'MODULE_NOT_FOUND')) {\n return {\n entryPoint: undefined,\n fields: [],\n packageManager: DEFAULT_PACKAGE_MANAGER,\n type: undefined,\n };\n }\n\n throw err;\n }\n};\n\nconst baseToTemplateData = async ({\n ownerName,\n platformName,\n repoName,\n defaultBranch,\n}: BaseFields) => {\n const [orgName, teamName] = ownerName.split('/');\n\n const port = String(await getRandomPort());\n\n if (!orgName) {\n throw new Error(`Invalid format for owner name: ${ownerName}`);\n }\n\n return {\n orgName,\n ownerName,\n repoName,\n defaultBranch,\n // Use standalone username in `teamName` contexts\n teamName: teamName ?? orgName,\n\n port,\n\n platformName,\n lambdaCdkArchitecture: platformName === 'amd64' ? 'X86_64' : 'ARM_64',\n lambdaServerlessArchitecture:\n platformName === 'amd64' ? 'x86_64' : platformName,\n };\n};\n\nexport const configureFromPrompt = async (): Promise<InitConfig> => {\n const { ownerName, platformName, repoName, defaultBranch } =\n await runForm<BaseFields>(BASE_PROMPT_PROPS);\n log.plain(chalk.cyan(repoName), 'by', chalk.cyan(ownerName));\n\n const templateData = await baseToTemplateData({\n ownerName,\n platformName,\n repoName,\n defaultBranch,\n });\n\n const destinationDir = repoName;\n\n await createDirectory(destinationDir);\n\n log.newline();\n const templateName = await getTemplateName();\n\n const { entryPoint, fields, noSkip, packageManager, type } =\n await cloneTemplate(templateName, destinationDir);\n\n if (fields.length === 0) {\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: true,\n templateData,\n templateName,\n type,\n };\n }\n\n const shouldContinue = noSkip ? true : await confirmShouldContinue(fields);\n\n if (shouldContinue) {\n log.newline();\n const customAnswers = await runForm({\n choices: fields,\n message: chalk.bold(`Complete ${chalk.cyan(templateName)}:`),\n name: 'customAnswers',\n });\n\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: true,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n }\n\n log.newline();\n log.warn(\n `Resume this later with ${chalk.bold(\n configForPackageManager(packageManager).exec,\n 'skuba configure',\n )}.`,\n );\n\n const customAnswers = generatePlaceholders(fields);\n\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: false,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n};\n\nconst configureFromPipe = async (): Promise<InitConfig> => {\n let text = '';\n\n await new Promise((resolve) =>\n process.stdin\n .on('data', (chunk) => (text += chunk.toString()))\n .once('end', resolve),\n );\n\n text = text.trim();\n\n if (text === '') {\n log.err('No data from stdin.');\n process.exit(1);\n }\n\n let value: unknown;\n\n try {\n value = JSON.parse(text) as unknown;\n } catch {\n log.err('Invalid JSON from stdin.');\n process.exit(1);\n }\n\n const result = initConfigInputSchema.safeParse(value);\n\n if (!result.success) {\n log.err('Invalid data from stdin:');\n log.err(result.error);\n process.exit(1);\n }\n\n const { destinationDir, templateComplete, templateName } = result.data;\n\n const templateData = {\n ...(await baseToTemplateData(result.data.templateData)),\n ...result.data.templateData,\n };\n\n await createDirectory(destinationDir);\n\n const { entryPoint, fields, noSkip, packageManager, type } =\n await cloneTemplate(templateName, destinationDir);\n\n if (!templateComplete) {\n if (noSkip) {\n log.err('Templating for', log.bold(templateName), 'cannot be skipped.');\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n packageManager,\n templateData: {\n ...templateData,\n ...generatePlaceholders(fields),\n },\n type,\n };\n }\n\n const required = fields.map(({ name }) => name);\n\n const provided = new Set(Object.keys(templateData));\n\n const missing = required.filter((name) => !provided.has(name));\n\n if (missing.length > 0) {\n log.err('This template uses the following information:');\n log.newline();\n missing.forEach((name) => log.err(`- ${name}`));\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n packageManager,\n templateData,\n type,\n };\n};\n\nexport const getConfig = () =>\n process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,mBAAkB;AAClB,sBAAsC;AACtC,sBAAe;AAEf,kBAA0B;AAC1B,mBAAgC;AAChC,qBAAoB;AACpB,4BAGO;AACP,kBAA8B;AAC9B,sBAKO;AAEP,iBAAuC;AACvC,qBAOO;AACP,mBAAuD;AAEhD,MAAM,UAAU,CAA6B,UAI9C;AACJ,QAAM,EAAE,SAAS,KAAK,IAAI;AAE1B,QAAM,UAAU,MAAM,QAAQ,IAAI,CAAC,YAAY;AAAA,IAC7C,GAAG;AAAA,IACH,UAAU,CAAC,UAA8B;AACvC,UACE,CAAC,SACD,UAAU,MACT,UAAU,OAAO,WAAW,CAAC,OAAO,cACrC;AACA,eAAO;AAAA,MACT;AAEA,aAAO,OAAO,WAAW,KAAK,KAAK;AAAA,IACrC;AAAA,EACF,EAAE;AAEF,QAAM,OAAO,IAAI,qBAAQ;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,OAAO,WAAW;AAC1B,YAAM,UAAU,MAAM,QAAQ;AAAA,QAC5B,QAAQ,IAAI,CAAC,WAAW,OAAO,SAAS,OAAO,OAAO,IAAI,CAAC,CAAC;AAAA,MAC9D;AAEA,aACE,QAAQ,KAAK,CAA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B;AACtE,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,WAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV;AAAA,MACA;AAAA,MACA,cAAc;AAAA,QACZ,GAAG;AAAA,QACH,GAAG,qBAAqB,MAAM;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAW,OAAO,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI;AAE9C,QAAM,WAAW,IAAI,IAAI,OAAO,KAAK,YAAY,CAAC;AAElD,QAAM,UAAU,SAAS,OAAO,CAAC,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC;AAE7D,MAAI,QAAQ,SAAS,GAAG;AACtB,uBAAI,IAAI,+CAA+C;AACvD,uBAAI,QAAQ;AACZ,YAAQ,QAAQ,CAAC,SAAS,mBAAI,IAAI,KAAK,IAAI,EAAE,CAAC;AAC9C,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,SAAO;AAAA,IACL,GAAG,OAAO;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,YAAY,MACvB,QAAQ,MAAM,QAAQ,oBAAoB,IAAI,kBAAkB;",
6
6
  "names": ["fs", "path", "chalk", "customAnswers"]
7
7
  }
@@ -1,7 +1,8 @@
1
1
  interface GitHubProject {
2
2
  orgName: string;
3
3
  repoName: string;
4
+ defaultBranch: string;
4
5
  }
5
- export declare const initialiseRepo: (dir: string, { orgName, repoName }: GitHubProject) => Promise<void>;
6
+ export declare const initialiseRepo: (dir: string, { orgName, repoName, defaultBranch }: GitHubProject) => Promise<void>;
6
7
  export declare const downloadGitHubTemplate: (gitHubPath: string, destinationDir: string) => Promise<void>;
7
8
  export {};
@@ -38,10 +38,9 @@ var import_isomorphic_git = __toESM(require("isomorphic-git"));
38
38
  var import_simple_git = __toESM(require("simple-git"));
39
39
  var Git = __toESM(require("../../api/git"));
40
40
  var import_logging = require("../../utils/logging");
41
- const initialiseRepo = async (dir, { orgName, repoName }) => {
41
+ const initialiseRepo = async (dir, { orgName, repoName, defaultBranch }) => {
42
42
  await import_isomorphic_git.default.init({
43
- // TODO: support main as an alternative.
44
- defaultBranch: "master",
43
+ defaultBranch,
45
44
  dir,
46
45
  fs: import_fs_extra.default
47
46
  });
@@ -67,12 +66,6 @@ const downloadGitHubTemplate = async (gitHubPath, destinationDir) => {
67
66
  force: true,
68
67
  recursive: true
69
68
  });
70
- import_logging.log.newline();
71
- import_logging.log.warn(
72
- "You may need to run",
73
- import_logging.log.bold("yarn skuba configure"),
74
- "once this is done."
75
- );
76
69
  };
77
70
  // Annotate the CommonJS export names for ESM import in node:
78
71
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/init/git.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport git from 'isomorphic-git';\nimport simpleGit from 'simple-git';\n\nimport * as Git from '../../api/git';\nimport { log } from '../../utils/logging';\n\ninterface GitHubProject {\n orgName: string;\n repoName: string;\n}\n\nexport const initialiseRepo = async (\n dir: string,\n { orgName, repoName }: GitHubProject,\n) => {\n await git.init({\n // TODO: support main as an alternative.\n defaultBranch: 'master',\n dir,\n fs,\n });\n\n await Git.commit({\n dir,\n message: 'Initial commit',\n });\n\n await git.addRemote({\n dir,\n fs,\n remote: 'origin',\n url: `git@github.com:${orgName}/${repoName}.git`,\n });\n};\n\nexport const downloadGitHubTemplate = async (\n gitHubPath: string,\n destinationDir: string,\n) => {\n log.newline();\n log.plain('Downloading', log.bold(gitHubPath), 'from GitHub...');\n\n await simpleGit().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [\n '--depth=1',\n '--quiet',\n ]);\n\n await fs.promises.rm(path.join(destinationDir, '.git'), {\n force: true,\n recursive: true,\n });\n\n log.newline();\n log.warn(\n 'You may need to run',\n log.bold('yarn skuba configure'),\n 'once this is done.',\n );\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,4BAAgB;AAChB,wBAAsB;AAEtB,UAAqB;AACrB,qBAAoB;AAOb,MAAM,iBAAiB,OAC5B,KACA,EAAE,SAAS,SAAS,MACjB;AACH,QAAM,sBAAAA,QAAI,KAAK;AAAA;AAAA,IAEb,eAAe;AAAA,IACf;AAAA,IACA,oBAAAC;AAAA,EACF,CAAC;AAED,QAAM,IAAI,OAAO;AAAA,IACf;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAED,QAAM,sBAAAD,QAAI,UAAU;AAAA,IAClB;AAAA,IACA,oBAAAC;AAAA,IACA,QAAQ;AAAA,IACR,KAAK,kBAAkB,OAAO,IAAI,QAAQ;AAAA,EAC5C,CAAC;AACH;AAEO,MAAM,yBAAyB,OACpC,YACA,mBACG;AACH,qBAAI,QAAQ;AACZ,qBAAI,MAAM,eAAe,mBAAI,KAAK,UAAU,GAAG,gBAAgB;AAE/D,YAAM,kBAAAC,SAAU,EAAE,MAAM,kBAAkB,UAAU,QAAQ,gBAAgB;AAAA,IAC1E;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,gBAAAD,QAAG,SAAS,GAAG,YAAAE,QAAK,KAAK,gBAAgB,MAAM,GAAG;AAAA,IACtD,OAAO;AAAA,IACP,WAAW;AAAA,EACb,CAAC;AAED,qBAAI,QAAQ;AACZ,qBAAI;AAAA,IACF;AAAA,IACA,mBAAI,KAAK,sBAAsB;AAAA,IAC/B;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport git from 'isomorphic-git';\nimport simpleGit from 'simple-git';\n\nimport * as Git from '../../api/git';\nimport { log } from '../../utils/logging';\n\ninterface GitHubProject {\n orgName: string;\n repoName: string;\n defaultBranch: string;\n}\n\nexport const initialiseRepo = async (\n dir: string,\n { orgName, repoName, defaultBranch }: GitHubProject,\n) => {\n await git.init({\n defaultBranch,\n dir,\n fs,\n });\n\n await Git.commit({\n dir,\n message: 'Initial commit',\n });\n\n await git.addRemote({\n dir,\n fs,\n remote: 'origin',\n url: `git@github.com:${orgName}/${repoName}.git`,\n });\n};\n\nexport const downloadGitHubTemplate = async (\n gitHubPath: string,\n destinationDir: string,\n) => {\n log.newline();\n log.plain('Downloading', log.bold(gitHubPath), 'from GitHub...');\n\n await simpleGit().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [\n '--depth=1',\n '--quiet',\n ]);\n\n await fs.promises.rm(path.join(destinationDir, '.git'), {\n force: true,\n recursive: true,\n });\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,4BAAgB;AAChB,wBAAsB;AAEtB,UAAqB;AACrB,qBAAoB;AAQb,MAAM,iBAAiB,OAC5B,KACA,EAAE,SAAS,UAAU,cAAc,MAChC;AACH,QAAM,sBAAAA,QAAI,KAAK;AAAA,IACb;AAAA,IACA;AAAA,IACA,oBAAAC;AAAA,EACF,CAAC;AAED,QAAM,IAAI,OAAO;AAAA,IACf;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAED,QAAM,sBAAAD,QAAI,UAAU;AAAA,IAClB;AAAA,IACA,oBAAAC;AAAA,IACA,QAAQ;AAAA,IACR,KAAK,kBAAkB,OAAO,IAAI,QAAQ;AAAA,EAC5C,CAAC;AACH;AAEO,MAAM,yBAAyB,OACpC,YACA,mBACG;AACH,qBAAI,QAAQ;AACZ,qBAAI,MAAM,eAAe,mBAAI,KAAK,UAAU,GAAG,gBAAgB;AAE/D,YAAM,kBAAAC,SAAU,EAAE,MAAM,kBAAkB,UAAU,QAAQ,gBAAgB;AAAA,IAC1E;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,gBAAAD,QAAG,SAAS,GAAG,YAAAE,QAAK,KAAK,gBAAgB,MAAM,GAAG;AAAA,IACtD,OAAO;AAAA,IACP,WAAW;AAAA,EACb,CAAC;AACH;",
6
6
  "names": ["git", "fs", "simpleGit", "path"]
7
7
  }
@@ -1 +1 @@
1
- export declare const init: () => Promise<void>;
1
+ export declare const init: (args?: string[]) => Promise<void>;
@@ -32,28 +32,35 @@ __export(init_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(init_exports);
34
34
  var import_path = __toESM(require("path"));
35
+ var import_util = require("util");
35
36
  var import_git = require("../../api/git");
37
+ var import_args = require("../../utils/args");
36
38
  var import_copy = require("../../utils/copy");
37
39
  var import_dir = require("../../utils/dir");
38
40
  var import_exec = require("../../utils/exec");
39
41
  var import_logging = require("../../utils/logging");
40
42
  var import_logo = require("../../utils/logo");
41
43
  var import_template = require("../../utils/template");
44
+ var import_prettier = require("../adapter/prettier");
42
45
  var import_patchRenovateConfig = require("../configure/patchRenovateConfig");
43
46
  var import_getConfig = require("./getConfig");
44
47
  var import_git2 = require("./git");
45
48
  var import_writePackageJson = require("./writePackageJson");
46
- const init = async () => {
49
+ const init = async (args = process.argv.slice(2)) => {
50
+ const opts = {
51
+ debug: (0, import_args.hasDebugFlag)(args)
52
+ };
47
53
  const skubaVersionInfo = await (0, import_logo.showLogoAndVersionInfo)();
48
- await (0, import_exec.ensureCommands)("yarn");
49
54
  const {
50
55
  destinationDir,
51
56
  entryPoint,
57
+ packageManager,
52
58
  templateComplete,
53
59
  templateData,
54
60
  templateName,
55
61
  type
56
62
  } = await (0, import_getConfig.getConfig)();
63
+ await (0, import_exec.ensureCommands)(packageManager);
57
64
  const include = await (0, import_dir.createInclusionFilter)([
58
65
  import_path.default.join(destinationDir, ".gitignore"),
59
66
  import_path.default.join(import_template.BASE_TEMPLATE_DIR, "_.gitignore")
@@ -88,17 +95,19 @@ const init = async () => {
88
95
  const exec = (0, import_exec.createExec)({
89
96
  cwd: destinationDir,
90
97
  stdio: "pipe",
91
- streamStdio: "yarn"
98
+ streamStdio: packageManager
92
99
  });
93
100
  import_logging.log.newline();
94
101
  await (0, import_git2.initialiseRepo)(destinationDir, templateData);
95
- await (0, import_patchRenovateConfig.tryPatchRenovateConfig)(destinationDir);
102
+ await (0, import_patchRenovateConfig.tryPatchRenovateConfig)("format", destinationDir);
96
103
  const skubaSlug = `skuba@${skubaVersionInfo.local}`;
97
104
  let depsInstalled = false;
98
105
  try {
99
- await exec("yarn", "add", "--dev", skubaSlug);
106
+ await exec(packageManager, "add", "-D", skubaSlug);
107
+ await (0, import_prettier.runPrettier)("format", (0, import_logging.createLogger)(opts.debug), destinationDir);
100
108
  depsInstalled = true;
101
- } catch {
109
+ } catch (err) {
110
+ import_logging.log.warn((0, import_util.inspect)(err));
102
111
  }
103
112
  await (0, import_git.commitAllChanges)({
104
113
  dir: destinationDir,
@@ -120,10 +129,11 @@ const init = async () => {
120
129
  import_logging.log.newline();
121
130
  import_logging.log.plain("Then, resume initialisation:");
122
131
  import_logging.log.ok("cd", destinationDir);
123
- import_logging.log.ok("yarn add --dev", skubaSlug);
132
+ import_logging.log.ok(packageManager, "add", "-D", skubaSlug);
133
+ import_logging.log.ok(packageManager, "run", "format");
124
134
  import_logging.log.ok("git add --all");
125
135
  import_logging.log.ok("git commit --message", `'Pin ${skubaSlug}'`);
126
- import_logging.log.ok("git push --set-upstream origin master");
136
+ import_logging.log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);
127
137
  import_logging.log.newline();
128
138
  process.exitCode = 1;
129
139
  return;
@@ -135,7 +145,7 @@ const init = async () => {
135
145
  import_logging.log.newline();
136
146
  import_logging.log.plain("Then, push your local changes:");
137
147
  import_logging.log.ok("cd", destinationDir);
138
- import_logging.log.ok("git push --set-upstream origin master");
148
+ import_logging.log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);
139
149
  import_logging.log.newline();
140
150
  };
141
151
  // Annotate the CommonJS export names for ESM import in node: