skuba 4.4.1 → 5.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/config/tsconfig.json +1 -0
  2. package/jest/moduleNameMapper.js +50 -78
  3. package/jest/moduleNameMapper.test.ts +4 -14
  4. package/jest/transform.js +10 -1
  5. package/jest/tsConfig.js +26 -0
  6. package/lib/api/buildkite/annotate.js +46 -33
  7. package/lib/api/buildkite/annotate.js.map +7 -1
  8. package/lib/api/buildkite/index.js +31 -7
  9. package/lib/api/buildkite/index.js.map +7 -1
  10. package/lib/api/buildkite/md.js +31 -8
  11. package/lib/api/buildkite/md.js.map +7 -1
  12. package/lib/api/git/commit.js +45 -17
  13. package/lib/api/git/commit.js.map +7 -1
  14. package/lib/api/git/commitAllChanges.js +57 -27
  15. package/lib/api/git/commitAllChanges.js.map +7 -1
  16. package/lib/api/git/currentBranch.js +50 -28
  17. package/lib/api/git/currentBranch.js.map +7 -1
  18. package/lib/api/git/getChangedFiles.js +49 -27
  19. package/lib/api/git/getChangedFiles.js.map +7 -1
  20. package/lib/api/git/index.js +54 -22
  21. package/lib/api/git/index.js.map +7 -1
  22. package/lib/api/git/log.js +63 -42
  23. package/lib/api/git/log.js.map +7 -1
  24. package/lib/api/git/pull.js +62 -31
  25. package/lib/api/git/pull.js.map +7 -1
  26. package/lib/api/git/push.js +63 -31
  27. package/lib/api/git/push.js.map +7 -1
  28. package/lib/api/git/remote.js +59 -56
  29. package/lib/api/git/remote.js.map +7 -1
  30. package/lib/api/git/reset.js +55 -27
  31. package/lib/api/git/reset.js.map +7 -1
  32. package/lib/api/git/statusMatrix.js +46 -13
  33. package/lib/api/git/statusMatrix.js.map +7 -1
  34. package/lib/api/github/checkRun.js +70 -79
  35. package/lib/api/github/checkRun.js.map +7 -1
  36. package/lib/api/github/environment.js +40 -33
  37. package/lib/api/github/environment.js.map +7 -1
  38. package/lib/api/github/index.js +47 -17
  39. package/lib/api/github/index.js.map +7 -1
  40. package/lib/api/github/issueComment.js +73 -81
  41. package/lib/api/github/issueComment.js.map +7 -1
  42. package/lib/api/github/pullRequest.js +60 -61
  43. package/lib/api/github/pullRequest.js.map +7 -1
  44. package/lib/api/github/push.js +138 -133
  45. package/lib/api/github/push.js.map +7 -1
  46. package/lib/api/jest/index.d.ts +2 -1
  47. package/lib/api/jest/index.js +35 -14
  48. package/lib/api/jest/index.js.map +7 -1
  49. package/lib/api/net/compose.js +45 -17
  50. package/lib/api/net/compose.js.map +7 -1
  51. package/lib/api/net/index.js +28 -5
  52. package/lib/api/net/index.js.map +7 -1
  53. package/lib/api/net/socket.js +58 -36
  54. package/lib/api/net/socket.js.map +7 -1
  55. package/lib/api/net/waitFor.js +38 -18
  56. package/lib/api/net/waitFor.js.map +7 -1
  57. package/lib/cli/adapter/eslint.js +95 -72
  58. package/lib/cli/adapter/eslint.js.map +7 -1
  59. package/lib/cli/adapter/prettier.js +126 -124
  60. package/lib/cli/adapter/prettier.js.map +7 -1
  61. package/lib/cli/build/args.d.ts +7 -0
  62. package/lib/cli/build/args.js +69 -0
  63. package/lib/cli/build/args.js.map +7 -0
  64. package/lib/cli/build/esbuild.d.ts +5 -0
  65. package/lib/cli/build/esbuild.js +128 -0
  66. package/lib/cli/build/esbuild.js.map +7 -0
  67. package/lib/cli/build/index.d.ts +1 -1
  68. package/lib/cli/build/index.js +68 -5
  69. package/lib/cli/build/index.js.map +7 -1
  70. package/lib/cli/build/tsc.d.ts +1 -1
  71. package/lib/cli/build/tsc.js +34 -23
  72. package/lib/cli/build/tsc.js.map +7 -1
  73. package/lib/cli/buildPackage.js +53 -23
  74. package/lib/cli/buildPackage.js.map +7 -1
  75. package/lib/cli/configure/addEmptyExports.d.ts +5 -0
  76. package/lib/cli/configure/addEmptyExports.js +67 -0
  77. package/lib/cli/configure/addEmptyExports.js.map +7 -0
  78. package/lib/cli/configure/analyseConfiguration.js +61 -31
  79. package/lib/cli/configure/analyseConfiguration.js.map +7 -1
  80. package/lib/cli/configure/analyseDependencies.js +122 -113
  81. package/lib/cli/configure/analyseDependencies.js.map +7 -1
  82. package/lib/cli/configure/analysis/diff.js +37 -11
  83. package/lib/cli/configure/analysis/diff.js.map +7 -1
  84. package/lib/cli/configure/analysis/files.js +49 -22
  85. package/lib/cli/configure/analysis/files.js.map +7 -1
  86. package/lib/cli/configure/analysis/git.js +46 -16
  87. package/lib/cli/configure/analysis/git.js.map +7 -1
  88. package/lib/cli/configure/analysis/package.js +99 -52
  89. package/lib/cli/configure/analysis/package.js.map +7 -1
  90. package/lib/cli/configure/analysis/project.js +90 -54
  91. package/lib/cli/configure/analysis/project.js.map +7 -1
  92. package/lib/cli/configure/dependencies/index.js +40 -13
  93. package/lib/cli/configure/dependencies/index.js.map +7 -1
  94. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +57 -32
  95. package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +7 -1
  96. package/lib/cli/configure/dependencies/seekKoala.js +53 -31
  97. package/lib/cli/configure/dependencies/seekKoala.js.map +7 -1
  98. package/lib/cli/configure/dependencies/skuba.js +49 -27
  99. package/lib/cli/configure/dependencies/skuba.js.map +7 -1
  100. package/lib/cli/configure/dependencies/skubaDeps.js +49 -28
  101. package/lib/cli/configure/dependencies/skubaDeps.js.map +7 -1
  102. package/lib/cli/configure/dependencies/skubaDive.js +65 -38
  103. package/lib/cli/configure/dependencies/skubaDive.js.map +7 -1
  104. package/lib/cli/configure/ensureTemplateCompletion.js +69 -41
  105. package/lib/cli/configure/ensureTemplateCompletion.js.map +7 -1
  106. package/lib/cli/configure/getEntryPoint.js +62 -32
  107. package/lib/cli/configure/getEntryPoint.js.map +7 -1
  108. package/lib/cli/configure/getProjectType.js +50 -28
  109. package/lib/cli/configure/getProjectType.js.map +7 -1
  110. package/lib/cli/configure/index.js +134 -109
  111. package/lib/cli/configure/index.js.map +7 -1
  112. package/lib/cli/configure/modules/eslint.js +57 -26
  113. package/lib/cli/configure/modules/eslint.js.map +7 -1
  114. package/lib/cli/configure/modules/ignore.js +37 -14
  115. package/lib/cli/configure/modules/ignore.js.map +7 -1
  116. package/lib/cli/configure/modules/index.js +53 -28
  117. package/lib/cli/configure/modules/index.js.map +7 -1
  118. package/lib/cli/configure/modules/jest.js +84 -47
  119. package/lib/cli/configure/modules/jest.js.map +7 -1
  120. package/lib/cli/configure/modules/nodemon.js +29 -6
  121. package/lib/cli/configure/modules/nodemon.js.map +7 -1
  122. package/lib/cli/configure/modules/package.js +113 -92
  123. package/lib/cli/configure/modules/package.js.map +7 -1
  124. package/lib/cli/configure/modules/prettier.js +48 -19
  125. package/lib/cli/configure/modules/prettier.js.map +7 -1
  126. package/lib/cli/configure/modules/renovate.js +52 -39
  127. package/lib/cli/configure/modules/renovate.js.map +7 -1
  128. package/lib/cli/configure/modules/serverless.js +33 -15
  129. package/lib/cli/configure/modules/serverless.js.map +7 -1
  130. package/lib/cli/configure/modules/skubaDive.js +63 -37
  131. package/lib/cli/configure/modules/skubaDive.js.map +7 -1
  132. package/lib/cli/configure/modules/tsconfig.js +79 -63
  133. package/lib/cli/configure/modules/tsconfig.js.map +7 -1
  134. package/lib/cli/configure/modules/tslint.js +29 -6
  135. package/lib/cli/configure/modules/tslint.js.map +7 -1
  136. package/lib/cli/configure/processing/deleteFiles.js +30 -8
  137. package/lib/cli/configure/processing/deleteFiles.js.map +7 -1
  138. package/lib/cli/configure/processing/ignoreFile.js +65 -59
  139. package/lib/cli/configure/processing/ignoreFile.js.map +7 -1
  140. package/lib/cli/configure/processing/javascript.js +35 -15
  141. package/lib/cli/configure/processing/javascript.js.map +7 -1
  142. package/lib/cli/configure/processing/json.js +51 -20
  143. package/lib/cli/configure/processing/json.js.map +7 -1
  144. package/lib/cli/configure/processing/loadFiles.js +30 -8
  145. package/lib/cli/configure/processing/loadFiles.js.map +7 -1
  146. package/lib/cli/configure/processing/module.js +37 -14
  147. package/lib/cli/configure/processing/module.js.map +7 -1
  148. package/lib/cli/configure/processing/package.js +73 -43
  149. package/lib/cli/configure/processing/package.js.map +7 -1
  150. package/lib/cli/configure/processing/prettier.js +37 -11
  151. package/lib/cli/configure/processing/prettier.js.map +7 -1
  152. package/lib/cli/configure/processing/record.js +54 -31
  153. package/lib/cli/configure/processing/record.js.map +7 -1
  154. package/lib/cli/configure/processing/typescript.js +176 -158
  155. package/lib/cli/configure/processing/typescript.js.map +7 -1
  156. package/lib/cli/configure/refreshIgnoreFiles.js +64 -40
  157. package/lib/cli/configure/refreshIgnoreFiles.js.map +7 -1
  158. package/lib/cli/configure/types.js +16 -2
  159. package/lib/cli/configure/types.js.map +7 -1
  160. package/lib/cli/format.js +58 -31
  161. package/lib/cli/format.js.map +7 -1
  162. package/lib/cli/help.js +31 -8
  163. package/lib/cli/help.js.map +7 -1
  164. package/lib/cli/init/getConfig.js +238 -207
  165. package/lib/cli/init/getConfig.js.map +7 -1
  166. package/lib/cli/init/git.js +70 -63
  167. package/lib/cli/init/git.js.map +7 -1
  168. package/lib/cli/init/index.js +133 -100
  169. package/lib/cli/init/index.js.map +7 -1
  170. package/lib/cli/init/prompts.js +84 -54
  171. package/lib/cli/init/prompts.js.map +7 -1
  172. package/lib/cli/init/types.js +52 -52
  173. package/lib/cli/init/types.js.map +7 -1
  174. package/lib/cli/init/validation.js +34 -12
  175. package/lib/cli/init/validation.js.map +7 -1
  176. package/lib/cli/init/writePackageJson.js +51 -22
  177. package/lib/cli/init/writePackageJson.js.map +7 -1
  178. package/lib/cli/lint/annotate/buildkite/eslint.js +34 -28
  179. package/lib/cli/lint/annotate/buildkite/eslint.js.map +7 -1
  180. package/lib/cli/lint/annotate/buildkite/index.js +50 -44
  181. package/lib/cli/lint/annotate/buildkite/index.js.map +7 -1
  182. package/lib/cli/lint/annotate/buildkite/prettier.js +41 -35
  183. package/lib/cli/lint/annotate/buildkite/prettier.js.map +7 -1
  184. package/lib/cli/lint/annotate/buildkite/tsc.js +39 -39
  185. package/lib/cli/lint/annotate/buildkite/tsc.js.map +7 -1
  186. package/lib/cli/lint/annotate/github/eslint.js +40 -16
  187. package/lib/cli/lint/annotate/github/eslint.js.map +7 -1
  188. package/lib/cli/lint/annotate/github/index.js +55 -51
  189. package/lib/cli/lint/annotate/github/index.js.map +7 -1
  190. package/lib/cli/lint/annotate/github/prettier.js +36 -13
  191. package/lib/cli/lint/annotate/github/prettier.js.map +7 -1
  192. package/lib/cli/lint/annotate/github/tsc.js +52 -52
  193. package/lib/cli/lint/annotate/github/tsc.js.map +7 -1
  194. package/lib/cli/lint/annotate/index.js +33 -10
  195. package/lib/cli/lint/annotate/index.js.map +7 -1
  196. package/lib/cli/lint/autofix.js +122 -117
  197. package/lib/cli/lint/autofix.js.map +7 -1
  198. package/lib/cli/lint/eslint.js +48 -18
  199. package/lib/cli/lint/eslint.js.map +7 -1
  200. package/lib/cli/lint/external.js +102 -81
  201. package/lib/cli/lint/external.js.map +7 -1
  202. package/lib/cli/lint/index.js +42 -18
  203. package/lib/cli/lint/index.js.map +7 -1
  204. package/lib/cli/lint/internal.js +54 -21
  205. package/lib/cli/lint/internal.js.map +7 -1
  206. package/lib/cli/lint/prettier.js +48 -18
  207. package/lib/cli/lint/prettier.js.map +7 -1
  208. package/lib/cli/lint/tsc.js +56 -32
  209. package/lib/cli/lint/tsc.js.map +7 -1
  210. package/lib/cli/lint/types.js +16 -2
  211. package/lib/cli/lint/types.js.map +7 -1
  212. package/lib/cli/node.js +65 -58
  213. package/lib/cli/node.js.map +7 -1
  214. package/lib/cli/release.js +29 -6
  215. package/lib/cli/release.js.map +7 -1
  216. package/lib/cli/start.js +61 -24
  217. package/lib/cli/start.js.map +7 -1
  218. package/lib/cli/test/index.js +35 -11
  219. package/lib/cli/test/index.js.map +7 -1
  220. package/lib/cli/test/reporters/github/annotations.js +89 -92
  221. package/lib/cli/test/reporters/github/annotations.js.map +7 -1
  222. package/lib/cli/test/reporters/github/index.js +68 -68
  223. package/lib/cli/test/reporters/github/index.js.map +7 -1
  224. package/lib/cli/version.js +31 -8
  225. package/lib/cli/version.js.map +7 -1
  226. package/lib/enquirer.d.js +2 -0
  227. package/lib/enquirer.d.js.map +7 -0
  228. package/lib/index.d.ts +6 -0
  229. package/lib/index.js +45 -41
  230. package/lib/index.js.map +7 -1
  231. package/lib/skuba.js +45 -38
  232. package/lib/skuba.js.map +7 -1
  233. package/lib/utils/args.js +97 -96
  234. package/lib/utils/args.js.map +7 -1
  235. package/lib/utils/command.js +64 -33
  236. package/lib/utils/command.js.map +7 -1
  237. package/lib/utils/copy.js +88 -51
  238. package/lib/utils/copy.js.map +7 -1
  239. package/lib/utils/dir.js +79 -67
  240. package/lib/utils/dir.js.map +7 -1
  241. package/lib/utils/env.js +27 -7
  242. package/lib/utils/env.js.map +7 -1
  243. package/lib/utils/error.js +58 -56
  244. package/lib/utils/error.js.map +7 -1
  245. package/lib/utils/exec.js +139 -110
  246. package/lib/utils/exec.js.map +7 -1
  247. package/lib/utils/help.js +31 -8
  248. package/lib/utils/help.js.map +7 -1
  249. package/lib/utils/logging.js +52 -24
  250. package/lib/utils/logging.js.map +7 -1
  251. package/lib/utils/logo.js +65 -27
  252. package/lib/utils/logo.js.map +7 -1
  253. package/lib/utils/manifest.d.ts +1 -0
  254. package/lib/utils/manifest.js +65 -51
  255. package/lib/utils/manifest.js.map +7 -1
  256. package/lib/utils/port.js +38 -17
  257. package/lib/utils/port.js.map +7 -1
  258. package/lib/utils/template.js +106 -87
  259. package/lib/utils/template.js.map +7 -1
  260. package/lib/utils/validation.js +43 -18
  261. package/lib/utils/validation.js.map +7 -1
  262. package/lib/utils/version.js +72 -82
  263. package/lib/utils/version.js.map +7 -1
  264. package/lib/utils/wait.js +52 -25
  265. package/lib/utils/wait.js.map +7 -1
  266. package/lib/utils/worker.js +59 -44
  267. package/lib/utils/worker.js.map +7 -1
  268. package/lib/wrapper/function-arguments.d.js +2 -0
  269. package/lib/wrapper/function-arguments.d.js.map +7 -0
  270. package/lib/wrapper/functionHandler.js +56 -29
  271. package/lib/wrapper/functionHandler.js.map +7 -1
  272. package/lib/wrapper/http.js +66 -56
  273. package/lib/wrapper/http.js.map +7 -1
  274. package/lib/wrapper/index.js +9 -21
  275. package/lib/wrapper/index.js.map +7 -1
  276. package/lib/wrapper/main.js +39 -20
  277. package/lib/wrapper/main.js.map +7 -1
  278. package/lib/wrapper/requestListener.js +50 -35
  279. package/lib/wrapper/requestListener.js.map +7 -1
  280. package/package.json +19 -13
  281. package/template/base/jest.config.ts +0 -6
  282. package/template/base/jest.setup.ts +2 -0
  283. package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
  284. package/template/express-rest-api/package.json +1 -1
  285. package/template/greeter/.buildkite/pipeline.yml +1 -1
  286. package/template/greeter/package.json +1 -1
  287. package/template/greeter/src/app.test.ts +3 -1
  288. package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
  289. package/template/koa-rest-api/package.json +6 -7
  290. package/template/koa-rest-api/src/api/jobs/postJob.test.ts +3 -7
  291. package/template/koa-rest-api/src/api/jobs/postJob.ts +2 -2
  292. package/template/koa-rest-api/src/framework/validation.test.ts +17 -15
  293. package/template/koa-rest-api/src/framework/validation.ts +50 -9
  294. package/template/koa-rest-api/src/testing/types.ts +5 -10
  295. package/template/koa-rest-api/src/types/jobs.ts +5 -10
  296. package/template/lambda-sqs-worker/.buildkite/pipeline.yml +3 -3
  297. package/template/lambda-sqs-worker/package.json +2 -6
  298. package/template/lambda-sqs-worker/src/app.ts +2 -2
  299. package/template/lambda-sqs-worker/src/framework/validation.test.ts +37 -17
  300. package/template/lambda-sqs-worker/src/framework/validation.ts +4 -2
  301. package/template/lambda-sqs-worker/src/services/jobScorer.ts +2 -2
  302. package/template/lambda-sqs-worker/src/testing/types.ts +5 -10
  303. package/template/lambda-sqs-worker/src/types/jobScorer.ts +9 -16
  304. package/template/lambda-sqs-worker/src/types/pipelineEvents.ts +13 -20
  305. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +3 -3
  306. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +6 -0
  307. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +3 -3
  308. package/template/lambda-sqs-worker-cdk/infra/index.ts +2 -2
  309. package/template/lambda-sqs-worker-cdk/package.json +2 -2
  310. package/template/lambda-sqs-worker-cdk/shared/context-types.ts +16 -25
  311. package/template/oss-npm-package/_package.json +1 -1
  312. package/template/private-npm-package/_package.json +1 -1
  313. package/jest/resolver.js +0 -24
package/lib/cli/format.js CHANGED
@@ -1,34 +1,61 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
4
11
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.format = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const args_1 = require("../utils/args");
9
- const logging_1 = require("../utils/logging");
10
- const eslint_1 = require("./adapter/eslint");
11
- const prettier_1 = require("./adapter/prettier");
12
- const refreshIgnoreFiles_1 = require("./configure/refreshIgnoreFiles");
13
- const format = async (args = process.argv) => {
14
- await (0, refreshIgnoreFiles_1.tryRefreshIgnoreFiles)();
15
- const debug = (0, args_1.hasDebugFlag)(args);
16
- const logger = (0, logging_1.createLogger)(debug);
17
- logging_1.log.plain(chalk_1.default.magenta('ESLint'));
18
- const eslint = await (0, eslint_1.runESLint)('format', logger);
19
- logging_1.log.newline();
20
- logging_1.log.plain(chalk_1.default.cyan('Prettier'));
21
- const prettier = await (0, prettier_1.runPrettier)('format', logger);
22
- if (eslint.ok && prettier.ok) {
23
- return;
24
- }
25
- const tools = [
26
- ...(eslint.ok ? [] : ['ESLint']),
27
- ...(prettier.ok ? [] : ['Prettier']),
28
- ];
29
- logging_1.log.newline();
30
- logging_1.log.err(tools.join(', '), 'found issues that require triage.');
31
- process.exitCode = 1;
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;
32
19
  };
33
- exports.format = format;
34
- //# sourceMappingURL=format.js.map
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var format_exports = {};
26
+ __export(format_exports, {
27
+ format: () => format
28
+ });
29
+ module.exports = __toCommonJS(format_exports);
30
+ var import_chalk = __toESM(require("chalk"));
31
+ var import_args = require("../utils/args");
32
+ var import_logging = require("../utils/logging");
33
+ var import_eslint = require("./adapter/eslint");
34
+ var import_prettier = require("./adapter/prettier");
35
+ var import_addEmptyExports = require("./configure/addEmptyExports");
36
+ var import_refreshIgnoreFiles = require("./configure/refreshIgnoreFiles");
37
+ const format = async (args = process.argv.slice(2)) => {
38
+ await Promise.all([(0, import_addEmptyExports.tryAddEmptyExports)(), (0, import_refreshIgnoreFiles.tryRefreshIgnoreFiles)()]);
39
+ const debug = (0, import_args.hasDebugFlag)(args);
40
+ const logger = (0, import_logging.createLogger)(debug);
41
+ import_logging.log.plain(import_chalk.default.magenta("ESLint"));
42
+ const eslint = await (0, import_eslint.runESLint)("format", logger);
43
+ import_logging.log.newline();
44
+ import_logging.log.plain(import_chalk.default.cyan("Prettier"));
45
+ const prettier = await (0, import_prettier.runPrettier)("format", logger);
46
+ if (eslint.ok && prettier.ok) {
47
+ return;
48
+ }
49
+ const tools = [
50
+ ...eslint.ok ? [] : ["ESLint"],
51
+ ...prettier.ok ? [] : ["Prettier"]
52
+ ];
53
+ import_logging.log.newline();
54
+ import_logging.log.err(tools.join(", "), "found issues that require triage.");
55
+ process.exitCode = 1;
56
+ };
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ format
60
+ });
61
+ //# sourceMappingURL=format.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/cli/format.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,wCAA6C;AAC7C,8CAAqD;AAErD,6CAA6C;AAC7C,iDAAiD;AACjD,uEAAuE;AAEhE,MAAM,MAAM,GAAG,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,EAAiB,EAAE;IACjE,MAAM,IAAA,0CAAqB,GAAE,CAAC;IAE9B,MAAM,KAAK,GAAG,IAAA,mBAAY,EAAC,IAAI,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAA,sBAAY,EAAC,KAAK,CAAC,CAAC;IAEnC,aAAG,CAAC,KAAK,CAAC,eAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEnC,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEjD,aAAG,CAAC,OAAO,EAAE,CAAC;IACd,aAAG,CAAC,KAAK,CAAC,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAElC,MAAM,QAAQ,GAAG,MAAM,IAAA,sBAAW,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAErD,IAAI,MAAM,CAAC,EAAE,IAAI,QAAQ,CAAC,EAAE,EAAE;QAC5B,OAAO;KACR;IAED,MAAM,KAAK,GAAG;QACZ,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAChC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;KACrC,CAAC;IAEF,aAAG,CAAC,OAAO,EAAE,CAAC;IACd,aAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,mCAAmC,CAAC,CAAC;IAE/D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC;AA5BW,QAAA,MAAM,UA4BjB"}
1
+ {
2
+ "version": 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 { tryRefreshIgnoreFiles } from './configure/refreshIgnoreFiles';\n\nexport const format = async (args = process.argv.slice(2)): Promise<void> => {\n await Promise.all([tryAddEmptyExports(), tryRefreshIgnoreFiles()]);\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,gCAAsC;AAE/B,MAAM,SAAS,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAqB;AAC3E,QAAM,QAAQ,IAAI,KAAC,2CAAmB,OAAG,iDAAsB,CAAC,CAAC;AAEjE,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;",
6
+ "names": ["chalk"]
7
+ }
package/lib/cli/help.js CHANGED
@@ -1,11 +1,34 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.help = void 0;
4
- const help_1 = require("../utils/help");
5
- const logo_1 = require("../utils/logo");
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 help_exports = {};
20
+ __export(help_exports, {
21
+ help: () => help
22
+ });
23
+ module.exports = __toCommonJS(help_exports);
24
+ var import_help = require("../utils/help");
25
+ var import_logo = require("../utils/logo");
6
26
  const help = async () => {
7
- await (0, logo_1.showLogoAndVersionInfo)();
8
- (0, help_1.showHelp)();
27
+ await (0, import_logo.showLogoAndVersionInfo)();
28
+ (0, import_help.showHelp)();
9
29
  };
10
- exports.help = help;
11
- //# sourceMappingURL=help.js.map
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ help
33
+ });
34
+ //# sourceMappingURL=help.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":";;;AAAA,wCAAyC;AACzC,wCAAuD;AAEhD,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;IAC7B,MAAM,IAAA,6BAAsB,GAAE,CAAC;IAE/B,IAAA,eAAQ,GAAE,CAAC;AACb,CAAC,CAAC;AAJW,QAAA,IAAI,QAIf"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/cli/help.ts"],
4
+ "sourcesContent": ["import { showHelp } from '../utils/help';\nimport { showLogoAndVersionInfo } from '../utils/logo';\n\nexport const help = async () => {\n await showLogoAndVersionInfo();\n\n showHelp();\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AACzB,kBAAuC;AAEhC,MAAM,OAAO,YAAY;AAC9B,YAAM,oCAAuB;AAE7B,4BAAS;AACX;",
6
+ "names": []
7
+ }
@@ -1,234 +1,265 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
4
11
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getConfig = exports.configureFromPrompt = exports.getTemplateConfig = exports.runForm = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const enquirer_1 = require("enquirer");
10
- const fs_extra_1 = __importDefault(require("fs-extra"));
11
- const copy_1 = require("../../utils/copy");
12
- const error_1 = require("../../utils/error");
13
- const logging_1 = require("../../utils/logging");
14
- const port_1 = require("../../utils/port");
15
- const template_1 = require("../../utils/template");
16
- const git_1 = require("./git");
17
- const prompts_1 = require("./prompts");
18
- const types_1 = require("./types");
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var getConfig_exports = {};
26
+ __export(getConfig_exports, {
27
+ configureFromPrompt: () => configureFromPrompt,
28
+ getConfig: () => getConfig,
29
+ getTemplateConfig: () => getTemplateConfig,
30
+ runForm: () => runForm
31
+ });
32
+ module.exports = __toCommonJS(getConfig_exports);
33
+ var import_path = __toESM(require("path"));
34
+ var import_chalk = __toESM(require("chalk"));
35
+ var import_enquirer = require("enquirer");
36
+ var import_fs_extra = __toESM(require("fs-extra"));
37
+ var import_copy = require("../../utils/copy");
38
+ var import_error = require("../../utils/error");
39
+ var import_logging = require("../../utils/logging");
40
+ var import_port = require("../../utils/port");
41
+ var import_template = require("../../utils/template");
42
+ var import_git = require("./git");
43
+ var import_prompts = require("./prompts");
44
+ var import_types = require("./types");
19
45
  const runForm = (props) => {
20
- const { message, name } = props;
21
- const choices = props.choices.map((choice) => ({
22
- ...choice,
23
- validate: (value) => {
24
- if (value === '' || value === choice.initial) {
25
- return 'Form is not complete';
26
- }
27
- return choice.validate?.(value) ?? true;
28
- },
29
- }));
30
- const form = new enquirer_1.Form({
31
- choices,
32
- message,
33
- name,
34
- validate: async (values) => {
35
- const results = await Promise.all(choices.map((choice) => choice.validate(values[choice.name])));
36
- return (results.find((result) => typeof result === 'string') ??
37
- results.every((result) => result === true));
38
- },
39
- });
40
- return form.run();
46
+ const { message, name } = props;
47
+ const choices = props.choices.map((choice) => ({
48
+ ...choice,
49
+ validate: (value) => {
50
+ if (value === "" || value === choice.initial) {
51
+ return "Form is not complete";
52
+ }
53
+ return choice.validate?.(value) ?? true;
54
+ }
55
+ }));
56
+ const form = new import_enquirer.Form({
57
+ choices,
58
+ message,
59
+ name,
60
+ validate: async (values) => {
61
+ const results = await Promise.all(
62
+ choices.map((choice) => choice.validate(values[choice.name]))
63
+ );
64
+ return results.find((result) => typeof result === "string") ?? results.every((result) => result === true);
65
+ }
66
+ });
67
+ return form.run();
41
68
  };
42
- exports.runForm = runForm;
43
69
  const confirmShouldContinue = async (choices) => {
44
- const fieldsList = choices.map((choice) => choice.message);
45
- logging_1.log.newline();
46
- logging_1.log.plain('This template uses the following information:');
47
- logging_1.log.newline();
48
- fieldsList.forEach((message) => logging_1.log.subtle(`- ${message}`));
49
- logging_1.log.newline();
50
- const result = await prompts_1.SHOULD_CONTINUE_PROMPT.run();
51
- return result === 'yes';
70
+ const fieldsList = choices.map((choice) => choice.message);
71
+ import_logging.log.newline();
72
+ import_logging.log.plain("This template uses the following information:");
73
+ import_logging.log.newline();
74
+ fieldsList.forEach((message) => import_logging.log.subtle(`- ${message}`));
75
+ import_logging.log.newline();
76
+ const result = await import_prompts.SHOULD_CONTINUE_PROMPT.run();
77
+ return result === "yes";
52
78
  };
53
79
  const createDirectory = async (dir) => {
54
- try {
55
- await fs_extra_1.default.promises.mkdir(dir);
56
- }
57
- catch (err) {
58
- if ((0, error_1.isErrorWithCode)(err, 'EEXIST')) {
59
- logging_1.log.err(`The directory '${dir}' already exists.`);
60
- process.exit(1);
61
- }
62
- throw err;
80
+ try {
81
+ await import_fs_extra.default.promises.mkdir(dir);
82
+ } catch (err) {
83
+ if ((0, import_error.isErrorWithCode)(err, "EEXIST")) {
84
+ import_logging.log.err(`The directory '${dir}' already exists.`);
85
+ process.exit(1);
63
86
  }
87
+ throw err;
88
+ }
64
89
  };
65
90
  const cloneTemplate = async (templateName, destinationDir) => {
66
- if (templateName.startsWith('github:')) {
67
- const gitHubPath = templateName.slice('github:'.length);
68
- return (0, git_1.downloadGitHubTemplate)(gitHubPath, destinationDir);
69
- }
70
- const templateDir = path_1.default.join(template_1.TEMPLATE_DIR, templateName);
71
- await (0, copy_1.copyFiles)({
72
- // assume built-in templates have no extraneous files
73
- include: () => true,
74
- sourceRoot: templateDir,
75
- destinationRoot: destinationDir,
76
- processors: [],
77
- // built-in templates have files like _package.json
78
- stripUnderscorePrefix: true,
79
- });
91
+ if (templateName.startsWith("github:")) {
92
+ const gitHubPath = templateName.slice("github:".length);
93
+ return (0, import_git.downloadGitHubTemplate)(gitHubPath, destinationDir);
94
+ }
95
+ const templateDir = import_path.default.join(import_template.TEMPLATE_DIR, templateName);
96
+ await (0, import_copy.copyFiles)({
97
+ include: () => true,
98
+ sourceRoot: templateDir,
99
+ destinationRoot: destinationDir,
100
+ processors: [],
101
+ stripUnderscorePrefix: true
102
+ });
80
103
  };
81
104
  const getTemplateName = async () => {
82
- const templateSelection = await prompts_1.TEMPLATE_PROMPT.run();
83
- if (templateSelection === 'github →') {
84
- const gitHubPath = await prompts_1.GIT_PATH_PROMPT.run();
85
- return `github:${gitHubPath}`;
86
- }
87
- return templateSelection;
105
+ const templateSelection = await import_prompts.TEMPLATE_PROMPT.run();
106
+ if (templateSelection === "github \u2192") {
107
+ const gitHubPath = await import_prompts.GIT_PATH_PROMPT.run();
108
+ return `github:${gitHubPath}`;
109
+ }
110
+ return templateSelection;
88
111
  };
89
- const generatePlaceholders = (choices) => Object.fromEntries(choices.map(({ name }) => [name, `<%- ${name} %>`]));
112
+ const generatePlaceholders = (choices) => Object.fromEntries(
113
+ choices.map(({ name }) => [name, `<%- ${name} %>`])
114
+ );
90
115
  const getTemplateConfig = (dir) => {
91
- const templateConfigPath = path_1.default.join(dir, template_1.TEMPLATE_CONFIG_FILENAME);
92
- try {
93
- /* eslint-disable-next-line @typescript-eslint/no-var-requires */
94
- const templateConfig = require(templateConfigPath);
95
- return template_1.TemplateConfig.check(templateConfig);
96
- }
97
- catch (err) {
98
- if ((0, error_1.isErrorWithCode)(err, 'MODULE_NOT_FOUND')) {
99
- return {
100
- entryPoint: undefined,
101
- fields: [],
102
- type: undefined,
103
- };
104
- }
105
- throw err;
116
+ const templateConfigPath = import_path.default.join(dir, import_template.TEMPLATE_CONFIG_FILENAME);
117
+ try {
118
+ const templateConfig = require(templateConfigPath);
119
+ return import_template.TemplateConfig.check(templateConfig);
120
+ } catch (err) {
121
+ if ((0, import_error.isErrorWithCode)(err, "MODULE_NOT_FOUND")) {
122
+ return {
123
+ entryPoint: void 0,
124
+ fields: [],
125
+ type: void 0
126
+ };
106
127
  }
128
+ throw err;
129
+ }
107
130
  };
108
- exports.getTemplateConfig = getTemplateConfig;
109
131
  const baseToTemplateData = async ({ ownerName, repoName }) => {
110
- const [orgName, teamName] = ownerName.split('/');
111
- const port = String(await (0, port_1.getRandomPort)());
112
- return {
113
- orgName,
114
- ownerName,
115
- port,
116
- repoName,
117
- // Use standalone username in `teamName` contexts
118
- teamName: teamName ?? orgName,
119
- };
132
+ const [orgName, teamName] = ownerName.split("/");
133
+ const port = String(await (0, import_port.getRandomPort)());
134
+ return {
135
+ orgName,
136
+ ownerName,
137
+ port,
138
+ repoName,
139
+ teamName: teamName ?? orgName
140
+ };
120
141
  };
121
142
  const configureFromPrompt = async () => {
122
- const { ownerName, repoName } = await (0, exports.runForm)(prompts_1.BASE_PROMPT_PROPS);
123
- logging_1.log.plain(chalk_1.default.cyan(repoName), 'by', chalk_1.default.cyan(ownerName));
124
- const templateData = await baseToTemplateData({ ownerName, repoName });
125
- const destinationDir = repoName;
126
- await createDirectory(destinationDir);
127
- logging_1.log.newline();
128
- const templateName = await getTemplateName();
129
- await cloneTemplate(templateName, destinationDir);
130
- const { entryPoint, fields, noSkip, type } = (0, exports.getTemplateConfig)(path_1.default.join(process.cwd(), destinationDir));
131
- if (fields.length === 0) {
132
- return {
133
- destinationDir,
134
- entryPoint,
135
- templateComplete: true,
136
- templateData,
137
- templateName,
138
- type,
139
- };
140
- }
141
- const shouldContinue = noSkip ? true : await confirmShouldContinue(fields);
142
- if (shouldContinue) {
143
- logging_1.log.newline();
144
- const customAnswers = await (0, exports.runForm)({
145
- choices: fields,
146
- message: chalk_1.default.bold(`Complete ${chalk_1.default.cyan(templateName)}:`),
147
- name: 'customAnswers',
148
- });
149
- return {
150
- destinationDir,
151
- entryPoint,
152
- templateComplete: true,
153
- templateData: { ...templateData, ...customAnswers },
154
- templateName,
155
- type,
156
- };
157
- }
158
- logging_1.log.newline();
159
- logging_1.log.warn(`Resume this later with ${chalk_1.default.bold('yarn skuba configure')}.`);
160
- const customAnswers = generatePlaceholders(fields);
143
+ const { ownerName, repoName } = await runForm(import_prompts.BASE_PROMPT_PROPS);
144
+ import_logging.log.plain(import_chalk.default.cyan(repoName), "by", import_chalk.default.cyan(ownerName));
145
+ const templateData = await baseToTemplateData({ ownerName, repoName });
146
+ const destinationDir = repoName;
147
+ await createDirectory(destinationDir);
148
+ import_logging.log.newline();
149
+ const templateName = await getTemplateName();
150
+ await cloneTemplate(templateName, destinationDir);
151
+ const { entryPoint, fields, noSkip, type } = getTemplateConfig(
152
+ import_path.default.join(process.cwd(), destinationDir)
153
+ );
154
+ if (fields.length === 0) {
155
+ return {
156
+ destinationDir,
157
+ entryPoint,
158
+ templateComplete: true,
159
+ templateData,
160
+ templateName,
161
+ type
162
+ };
163
+ }
164
+ const shouldContinue = noSkip ? true : await confirmShouldContinue(fields);
165
+ if (shouldContinue) {
166
+ import_logging.log.newline();
167
+ const customAnswers2 = await runForm({
168
+ choices: fields,
169
+ message: import_chalk.default.bold(`Complete ${import_chalk.default.cyan(templateName)}:`),
170
+ name: "customAnswers"
171
+ });
161
172
  return {
162
- destinationDir,
163
- entryPoint,
164
- templateComplete: false,
165
- templateData: { ...templateData, ...customAnswers },
166
- templateName,
167
- type,
173
+ destinationDir,
174
+ entryPoint,
175
+ templateComplete: true,
176
+ templateData: { ...templateData, ...customAnswers2 },
177
+ templateName,
178
+ type
168
179
  };
180
+ }
181
+ import_logging.log.newline();
182
+ import_logging.log.warn(`Resume this later with ${import_chalk.default.bold("yarn skuba configure")}.`);
183
+ const customAnswers = generatePlaceholders(fields);
184
+ return {
185
+ destinationDir,
186
+ entryPoint,
187
+ templateComplete: false,
188
+ templateData: { ...templateData, ...customAnswers },
189
+ templateName,
190
+ type
191
+ };
169
192
  };
170
- exports.configureFromPrompt = configureFromPrompt;
171
193
  const configureFromPipe = async () => {
172
- let text = '';
173
- await new Promise((resolve) => process.stdin.on('data', (chunk) => (text += chunk)).once('end', resolve));
174
- text = text.trim();
175
- if (text === '') {
176
- logging_1.log.err('No data from stdin.');
177
- process.exit(1);
178
- }
179
- let value;
180
- try {
181
- value = JSON.parse(text);
182
- }
183
- catch {
184
- logging_1.log.err('Invalid JSON from stdin.');
185
- process.exit(1);
186
- }
187
- const result = types_1.InitConfigInput.validate(value);
188
- if (!result.success) {
189
- logging_1.log.err('Invalid data from stdin:');
190
- logging_1.log.err(result.message);
191
- process.exit(1);
192
- }
193
- const { destinationDir, templateComplete, templateName } = result.value;
194
- const templateData = {
195
- ...(await baseToTemplateData(result.value.templateData)),
196
- ...result.value.templateData,
197
- };
198
- await createDirectory(destinationDir);
199
- await cloneTemplate(templateName, destinationDir);
200
- const { entryPoint, fields, noSkip, type } = (0, exports.getTemplateConfig)(path_1.default.join(process.cwd(), destinationDir));
201
- if (!templateComplete) {
202
- if (noSkip) {
203
- logging_1.log.err('Templating for', logging_1.log.bold(templateName), 'cannot be skipped.');
204
- process.exit(1);
205
- }
206
- return {
207
- ...result.value,
208
- entryPoint,
209
- templateData: {
210
- ...templateData,
211
- ...generatePlaceholders(fields),
212
- },
213
- type,
214
- };
215
- }
216
- const required = fields.map(({ name }) => name);
217
- const provided = new Set(Object.keys(templateData));
218
- const missing = required.filter((name) => !provided.has(name));
219
- if (missing.length > 0) {
220
- logging_1.log.err('This template uses the following information:');
221
- logging_1.log.newline();
222
- missing.forEach((name) => logging_1.log.err(`- ${name}`));
223
- process.exit(1);
194
+ let text = "";
195
+ await new Promise(
196
+ (resolve) => process.stdin.on("data", (chunk) => text += chunk).once("end", resolve)
197
+ );
198
+ text = text.trim();
199
+ if (text === "") {
200
+ import_logging.log.err("No data from stdin.");
201
+ process.exit(1);
202
+ }
203
+ let value;
204
+ try {
205
+ value = JSON.parse(text);
206
+ } catch {
207
+ import_logging.log.err("Invalid JSON from stdin.");
208
+ process.exit(1);
209
+ }
210
+ const result = import_types.InitConfigInput.validate(value);
211
+ if (!result.success) {
212
+ import_logging.log.err("Invalid data from stdin:");
213
+ import_logging.log.err(result.message);
214
+ process.exit(1);
215
+ }
216
+ const { destinationDir, templateComplete, templateName } = result.value;
217
+ const templateData = {
218
+ ...await baseToTemplateData(result.value.templateData),
219
+ ...result.value.templateData
220
+ };
221
+ await createDirectory(destinationDir);
222
+ await cloneTemplate(templateName, destinationDir);
223
+ const { entryPoint, fields, noSkip, type } = getTemplateConfig(
224
+ import_path.default.join(process.cwd(), destinationDir)
225
+ );
226
+ if (!templateComplete) {
227
+ if (noSkip) {
228
+ import_logging.log.err("Templating for", import_logging.log.bold(templateName), "cannot be skipped.");
229
+ process.exit(1);
224
230
  }
225
231
  return {
226
- ...result.value,
227
- entryPoint,
228
- templateData,
229
- type,
232
+ ...result.value,
233
+ entryPoint,
234
+ templateData: {
235
+ ...templateData,
236
+ ...generatePlaceholders(fields)
237
+ },
238
+ type
230
239
  };
240
+ }
241
+ const required = fields.map(({ name }) => name);
242
+ const provided = new Set(Object.keys(templateData));
243
+ const missing = required.filter((name) => !provided.has(name));
244
+ if (missing.length > 0) {
245
+ import_logging.log.err("This template uses the following information:");
246
+ import_logging.log.newline();
247
+ missing.forEach((name) => import_logging.log.err(`- ${name}`));
248
+ process.exit(1);
249
+ }
250
+ return {
251
+ ...result.value,
252
+ entryPoint,
253
+ templateData,
254
+ type
255
+ };
231
256
  };
232
- const getConfig = () => process.stdin.isTTY ? (0, exports.configureFromPrompt)() : configureFromPipe();
233
- exports.getConfig = getConfig;
234
- //# sourceMappingURL=getConfig.js.map
257
+ const getConfig = () => process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();
258
+ // Annotate the CommonJS export names for ESM import in node:
259
+ 0 && (module.exports = {
260
+ configureFromPrompt,
261
+ getConfig,
262
+ getTemplateConfig,
263
+ runForm
264
+ });
265
+ //# sourceMappingURL=getConfig.js.map