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/utils/copy.js CHANGED
@@ -1,59 +1,96 @@
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.copyFiles = exports.createStringReplacer = exports.createEjsRenderer = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const ejs_1 = __importDefault(require("ejs"));
9
- const fs_extra_1 = __importDefault(require("fs-extra"));
10
- const error_1 = require("./error");
11
- const logging_1 = require("./logging");
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 copy_exports = {};
26
+ __export(copy_exports, {
27
+ copyFiles: () => copyFiles,
28
+ createEjsRenderer: () => createEjsRenderer,
29
+ createStringReplacer: () => createStringReplacer
30
+ });
31
+ module.exports = __toCommonJS(copy_exports);
32
+ var import_path = __toESM(require("path"));
33
+ var import_ejs = __toESM(require("ejs"));
34
+ var import_fs_extra = __toESM(require("fs-extra"));
35
+ var import_error = require("./error");
36
+ var import_logging = require("./logging");
12
37
  const copyFile = async (sourcePath, destinationPath, { overwrite = true, processors }) => {
13
- const oldContents = await fs_extra_1.default.promises.readFile(sourcePath, 'utf8');
14
- const newContents = processors.reduce((contents, process) => process(contents), oldContents);
15
- if (oldContents === newContents && sourcePath === destinationPath) {
16
- return;
17
- }
18
- try {
19
- await fs_extra_1.default.promises.writeFile(destinationPath, newContents, {
20
- flag: overwrite ? 'w' : 'wx',
21
- });
22
- }
23
- catch (err) {
24
- if ((0, error_1.isErrorWithCode)(err, 'EEXIST')) {
25
- return;
26
- }
27
- throw err;
38
+ const oldContents = await import_fs_extra.default.promises.readFile(sourcePath, "utf8");
39
+ const newContents = processors.reduce(
40
+ (contents, process) => process(contents),
41
+ oldContents
42
+ );
43
+ if (oldContents === newContents && sourcePath === destinationPath) {
44
+ return;
45
+ }
46
+ try {
47
+ await import_fs_extra.default.promises.writeFile(destinationPath, newContents, {
48
+ flag: overwrite ? "w" : "wx"
49
+ });
50
+ } catch (err) {
51
+ if ((0, import_error.isErrorWithCode)(err, "EEXIST")) {
52
+ return;
28
53
  }
54
+ throw err;
55
+ }
29
56
  };
30
- const createEjsRenderer = (templateData) => (contents) => ejs_1.default.render(contents, templateData);
31
- exports.createEjsRenderer = createEjsRenderer;
32
- const createStringReplacer = (replacements) => (contents) => replacements.reduce((newContents, { input, output }) => newContents.replace(input, output), contents);
33
- exports.createStringReplacer = createStringReplacer;
57
+ const createEjsRenderer = (templateData) => (contents) => import_ejs.default.render(contents, templateData);
58
+ const createStringReplacer = (replacements) => (contents) => replacements.reduce(
59
+ (newContents, { input, output }) => newContents.replace(input, output),
60
+ contents
61
+ );
34
62
  const copyFiles = async (opts, currentSourceDir = opts.sourceRoot, currentDestinationDir = opts.destinationRoot) => {
35
- const filenames = await fs_extra_1.default.promises.readdir(currentSourceDir);
36
- const toDestinationPath = (filename) => path_1.default.join(currentDestinationDir, opts.stripUnderscorePrefix
37
- ? filename
38
- .replace(/^_\./, '.')
39
- .replace(/^_package\.json/, 'package.json')
40
- : filename);
41
- const filteredFilenames = filenames.filter((filename) => opts.include(path_1.default.relative(opts.destinationRoot, toDestinationPath(filename))));
42
- await Promise.all(filteredFilenames.map(async (filename) => {
43
- const sourcePath = path_1.default.join(currentSourceDir, filename);
44
- const destinationPath = toDestinationPath(filename);
45
- try {
46
- await copyFile(sourcePath, destinationPath, opts);
47
- }
48
- catch (err) {
49
- if ((0, error_1.isErrorWithCode)(err, 'EISDIR')) {
50
- await fs_extra_1.default.promises.mkdir(destinationPath, { recursive: true });
51
- return (0, exports.copyFiles)(opts, sourcePath, destinationPath);
52
- }
53
- logging_1.log.err('Failed to render', logging_1.log.bold(sourcePath));
54
- throw err;
63
+ const filenames = await import_fs_extra.default.promises.readdir(currentSourceDir);
64
+ const toDestinationPath = (filename) => import_path.default.join(
65
+ currentDestinationDir,
66
+ opts.stripUnderscorePrefix ? filename.replace(/^_\./, ".").replace(/^_package\.json/, "package.json") : filename
67
+ );
68
+ const filteredFilenames = filenames.filter(
69
+ (filename) => opts.include(
70
+ import_path.default.relative(opts.destinationRoot, toDestinationPath(filename))
71
+ )
72
+ );
73
+ await Promise.all(
74
+ filteredFilenames.map(async (filename) => {
75
+ const sourcePath = import_path.default.join(currentSourceDir, filename);
76
+ const destinationPath = toDestinationPath(filename);
77
+ try {
78
+ await copyFile(sourcePath, destinationPath, opts);
79
+ } catch (err) {
80
+ if ((0, import_error.isErrorWithCode)(err, "EISDIR")) {
81
+ await import_fs_extra.default.promises.mkdir(destinationPath, { recursive: true });
82
+ return copyFiles(opts, sourcePath, destinationPath);
55
83
  }
56
- }));
84
+ import_logging.log.err("Failed to render", import_logging.log.bold(sourcePath));
85
+ throw err;
86
+ }
87
+ })
88
+ );
57
89
  };
58
- exports.copyFiles = copyFiles;
59
- //# sourceMappingURL=copy.js.map
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ copyFiles,
93
+ createEjsRenderer,
94
+ createStringReplacer
95
+ });
96
+ //# sourceMappingURL=copy.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"copy.js","sourceRoot":"","sources":["../../src/utils/copy.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,8CAAsB;AACtB,wDAA0B;AAE1B,mCAA0C;AAC1C,uCAAgC;AAIhC,MAAM,QAAQ,GAAG,KAAK,EACpB,UAAkB,EAClB,eAAuB,EACvB,EAAE,SAAS,GAAG,IAAI,EAAE,UAAU,EAAoB,EAClD,EAAE;IACF,MAAM,WAAW,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAEnE,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CACnC,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EACxC,WAAW,CACZ,CAAC;IAEF,IAAI,WAAW,KAAK,WAAW,IAAI,UAAU,KAAK,eAAe,EAAE;QACjE,OAAO;KACR;IAED,IAAI;QACF,MAAM,kBAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,eAAe,EAAE,WAAW,EAAE;YACxD,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI;SAC7B,CAAC,CAAC;KACJ;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,IAAA,uBAAe,EAAC,GAAG,EAAE,QAAQ,CAAC,EAAE;YAClC,OAA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AC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QACvC,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QACzD,MAAM,eAAe,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAEpD,IAAI;YACF,MAAM,QAAQ,CAAC,UAAU,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;SACnD;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,IAAA,uBAAe,EAAC,GAAG,EAAE,QAAQ,CAAC,EAAE;gBAClC,MAAM,kBAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC9D,OAAO,IAAA,iBAAS,EAAC,IAAI,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;aACrD;YAED,aAAG,CAAC,GAAG,CAAC,kBAAkB,EAAE,aAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YAElD,MAAM,GAAG,CAAC;SACX;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AA1CW,QAAA,SAAS,aA0CpB"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/copy.ts"],
4
+ "sourcesContent": ["import path from 'path';\n\nimport ejs from 'ejs';\nimport fs from 'fs-extra';\n\nimport { isErrorWithCode } from './error';\nimport { log } from './logging';\n\nexport type TextProcessor = (contents: string) => string;\n\nconst copyFile = async (\n sourcePath: string,\n destinationPath: string,\n { overwrite = true, processors }: CopyFilesOptions,\n) => {\n const oldContents = await fs.promises.readFile(sourcePath, 'utf8');\n\n const newContents = processors.reduce(\n (contents, process) => process(contents),\n oldContents,\n );\n\n if (oldContents === newContents && sourcePath === destinationPath) {\n return;\n }\n\n try {\n await fs.promises.writeFile(destinationPath, newContents, {\n flag: overwrite ? 'w' : 'wx',\n });\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n return;\n }\n\n throw err;\n }\n};\n\ninterface CopyFilesOptions {\n sourceRoot: string;\n destinationRoot: string;\n\n include: (pathname: string) => boolean;\n overwrite?: boolean;\n processors: Array<TextProcessor>;\n stripUnderscorePrefix?: boolean;\n}\n\nexport const createEjsRenderer =\n (templateData: Record<string, unknown>): TextProcessor =>\n (contents) =>\n ejs.render(contents, templateData);\n\nexport const createStringReplacer =\n (\n replacements: Array<{\n input: RegExp;\n output: string;\n }>,\n ): TextProcessor =>\n (contents) =>\n replacements.reduce(\n (newContents, { input, output }) => newContents.replace(input, output),\n contents,\n );\n\nexport const copyFiles = async (\n opts: CopyFilesOptions,\n currentSourceDir: string = opts.sourceRoot,\n currentDestinationDir: string = opts.destinationRoot,\n) => {\n const filenames = await fs.promises.readdir(currentSourceDir);\n\n const toDestinationPath = (filename: string) =>\n path.join(\n currentDestinationDir,\n opts.stripUnderscorePrefix\n ? filename\n .replace(/^_\\./, '.')\n .replace(/^_package\\.json/, 'package.json')\n : filename,\n );\n\n const filteredFilenames = filenames.filter((filename) =>\n opts.include(\n path.relative(opts.destinationRoot, toDestinationPath(filename)),\n ),\n );\n\n await Promise.all(\n filteredFilenames.map(async (filename) => {\n const sourcePath = path.join(currentSourceDir, filename);\n const destinationPath = toDestinationPath(filename);\n\n try {\n await copyFile(sourcePath, destinationPath, opts);\n } catch (err) {\n if (isErrorWithCode(err, 'EISDIR')) {\n await fs.promises.mkdir(destinationPath, { recursive: true });\n return copyFiles(opts, sourcePath, destinationPath);\n }\n\n log.err('Failed to render', log.bold(sourcePath));\n\n throw err;\n }\n }),\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,iBAAgB;AAChB,sBAAe;AAEf,mBAAgC;AAChC,qBAAoB;AAIpB,MAAM,WAAW,OACf,YACA,iBACA,EAAE,YAAY,MAAM,WAAW,MAC5B;AACH,QAAM,cAAc,M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,iBAAiB,IAAI;AAAA,MAClD,SAAS,KAAP;AACA,gBAAI,8BAAgB,KAAK,QAAQ,GAAG;AAClC,gBAAM,gBAAAF,QAAG,SAAS,MAAM,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAC5D,iBAAO,UAAU,MAAM,YAAY,eAAe;AAAA,QACpD;AAEA,2BAAI,IAAI,oBAAoB,mBAAI,KAAK,UAAU,CAAC;AAEhD,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
6
+ "names": ["fs", "ejs", "path"]
7
+ }
package/lib/utils/dir.js CHANGED
@@ -1,75 +1,87 @@
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.createInclusionFilter = exports.crawlDirectory = exports.buildPatternToFilepathMap = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const fdir_1 = require("fdir");
9
- const fs_extra_1 = __importDefault(require("fs-extra"));
10
- const ignore_1 = __importDefault(require("ignore"));
11
- const picomatch_1 = __importDefault(require("picomatch"));
12
- const error_1 = require("./error");
13
- /**
14
- * Build a map that associates each glob pattern with its matching filepaths.
15
- */
16
- const buildPatternToFilepathMap = (patterns, allFilepaths) => Object.fromEntries(patterns.map((pattern) => {
17
- const isMatch = (0, picomatch_1.default)(pattern);
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 dir_exports = {};
26
+ __export(dir_exports, {
27
+ buildPatternToFilepathMap: () => buildPatternToFilepathMap,
28
+ crawlDirectory: () => crawlDirectory,
29
+ createInclusionFilter: () => createInclusionFilter
30
+ });
31
+ module.exports = __toCommonJS(dir_exports);
32
+ var import_path = __toESM(require("path"));
33
+ var import_fdir = require("fdir");
34
+ var import_fs_extra = __toESM(require("fs-extra"));
35
+ var import_ignore = __toESM(require("ignore"));
36
+ var import_picomatch = __toESM(require("picomatch"));
37
+ var import_error = require("./error");
38
+ const buildPatternToFilepathMap = (patterns, allFilepaths) => Object.fromEntries(
39
+ patterns.map((pattern) => {
40
+ const isMatch = (0, import_picomatch.default)(pattern);
18
41
  const filepaths = allFilepaths.filter((filepath) => isMatch(filepath));
19
42
  return [pattern, filepaths];
20
- }));
21
- exports.buildPatternToFilepathMap = buildPatternToFilepathMap;
22
- /**
23
- * List relative filepaths contained within a directory root.
24
- *
25
- * This excludes:
26
- *
27
- * - Patterns in the ignore files specified in `ignoreFilenames`
28
- * - `.git` subdirectories
29
- * - `node_modules` subdirectories
30
- */
31
- const crawlDirectory = async (root, ignoreFilename = '.gitignore') => {
32
- const ignoreFileFilter = await (0, exports.createInclusionFilter)([
33
- path_1.default.join(root, ignoreFilename),
34
- ]);
35
- const output = await new fdir_1.fdir()
36
- .crawlWithOptions(root, {
37
- exclude: (dirname) => ['.git', 'node_modules'].includes(dirname),
38
- filters: [
39
- (pathname) => {
40
- const relativePathname = path_1.default.relative(root, pathname);
41
- return ignoreFileFilter(relativePathname);
42
- },
43
- ],
44
- includeBasePath: true,
45
- })
46
- .withPromise();
47
- // Patch over non-specific `fdir` typings.
48
- const absoluteFilenames = output;
49
- const relativeFilepaths = absoluteFilenames.map((filepath) => path_1.default.relative(root, filepath));
50
- return relativeFilepaths;
43
+ })
44
+ );
45
+ const crawlDirectory = async (root, ignoreFilename = ".gitignore") => {
46
+ const ignoreFileFilter = await createInclusionFilter([
47
+ import_path.default.join(root, ignoreFilename)
48
+ ]);
49
+ const output = await new import_fdir.fdir().crawlWithOptions(root, {
50
+ exclude: (dirname) => [".git", "node_modules"].includes(dirname),
51
+ filters: [
52
+ (pathname) => {
53
+ const relativePathname = import_path.default.relative(root, pathname);
54
+ return ignoreFileFilter(relativePathname);
55
+ }
56
+ ],
57
+ includeBasePath: true
58
+ }).withPromise();
59
+ const absoluteFilenames = output;
60
+ const relativeFilepaths = absoluteFilenames.map(
61
+ (filepath) => import_path.default.relative(root, filepath)
62
+ );
63
+ return relativeFilepaths;
51
64
  };
52
- exports.crawlDirectory = crawlDirectory;
53
- /**
54
- * Create a filter function that excludes filepaths based on ignore files like
55
- * `.gitignore` and `.prettierignore`.
56
- */
57
65
  const createInclusionFilter = async (ignoreFilepaths) => {
58
- const ignoreFiles = await Promise.all(ignoreFilepaths.map(async (ignoreFilepath) => {
59
- try {
60
- return await fs_extra_1.default.promises.readFile(ignoreFilepath, 'utf8');
66
+ const ignoreFiles = await Promise.all(
67
+ ignoreFilepaths.map(async (ignoreFilepath) => {
68
+ try {
69
+ return await import_fs_extra.default.promises.readFile(ignoreFilepath, "utf8");
70
+ } catch (err) {
71
+ if ((0, import_error.isErrorWithCode)(err, "ENOENT")) {
72
+ return;
61
73
  }
62
- catch (err) {
63
- if ((0, error_1.isErrorWithCode)(err, 'ENOENT')) {
64
- return;
65
- }
66
- throw err;
67
- }
68
- }));
69
- const managers = ignoreFiles
70
- .filter((value) => typeof value === 'string')
71
- .map((value) => (0, ignore_1.default)().add(value));
72
- return (0, ignore_1.default)().add('.git').add(managers).createFilter();
74
+ throw err;
75
+ }
76
+ })
77
+ );
78
+ const managers = ignoreFiles.filter((value) => typeof value === "string").map((value) => (0, import_ignore.default)().add(value));
79
+ return (0, import_ignore.default)().add(".git").add(managers).createFilter();
73
80
  };
74
- exports.createInclusionFilter = createInclusionFilter;
75
- //# sourceMappingURL=dir.js.map
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ buildPatternToFilepathMap,
84
+ crawlDirectory,
85
+ createInclusionFilter
86
+ });
87
+ //# sourceMappingURL=dir.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"dir.js","sourceRoot":"","sources":["../../src/utils/dir.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,+BAAoC;AACpC,wDAA0B;AAC1B,oDAA4B;AAC5B,0DAAkC;AAElC,mCAA0C;AAE1C;;GAEG;AACI,MAAM,yBAAyB,GAAG,CACvC,QAAkB,EAClB,YAAsB,EACtB,EAAE,CACF,MAAM,CAAC,WAAW,CAChB,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;IACvB,MAAM,OAAO,GAAG,IAAA,mBAAS,EAAC,OAAO,CAAC,CAAC;IAEnC,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEvE,OAAO,CAAC,OAAO,EAAE,SAAS,CAAU,CAAC;AACvC,CAAC,CAAC,CACH,CAAC;AAZS,QAAA,yBAAyB,6BAYlC;AAEJ;;;;;;;;GAQG;AACI,MAAM,cAAc,GAAG,KAAK,EACjC,IAAY,EACZ,cAAc,GAAG,YAAY,EAC7B,EAAE;IACF,MAAM,gBAAgB,GAAG,MAAM,IAAA,6BAAqB,EAAC;QACnD,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC;KAChC,CAAC,CAAC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KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;SAC7D,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,gBAAM,GAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAEvC,OAAO,IAAA,gBAAM,GAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,YAAY,EAAE,CAAC;AAC3D,CAAC,CAAC;AApBW,QAAA,qBAAqB,yBAoBhC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/dir.ts"],
4
+ "sourcesContent": ["import path from 'path';\n\nimport { fdir as FDir } from 'fdir';\nimport fs from 'fs-extra';\nimport ignore from 'ignore';\nimport picomatch from 'picomatch';\n\nimport { isErrorWithCode } from './error';\n\n/**\n * Build a map that associates each glob pattern with its matching filepaths.\n */\nexport const buildPatternToFilepathMap = (\n patterns: string[],\n allFilepaths: string[],\n) =>\n Object.fromEntries(\n patterns.map((pattern) => {\n const isMatch = picomatch(pattern);\n\n const filepaths = allFilepaths.filter((filepath) => isMatch(filepath));\n\n return [pattern, filepaths] as const;\n }),\n );\n\n/**\n * List relative filepaths contained within a directory root.\n *\n * This excludes:\n *\n * - Patterns in the ignore files specified in `ignoreFilenames`\n * - `.git` subdirectories\n * - `node_modules` subdirectories\n */\nexport const crawlDirectory = async (\n root: string,\n ignoreFilename = '.gitignore',\n) => {\n const ignoreFileFilter = await createInclusionFilter([\n path.join(root, ignoreFilename),\n ]);\n\n const output = await new FDir()\n .crawlWithOptions(root, {\n exclude: (dirname) => ['.git', 'node_modules'].includes(dirname),\n filters: [\n (pathname) => {\n const relativePathname = path.relative(root, pathname);\n\n return ignoreFileFilter(relativePathname);\n },\n ],\n includeBasePath: true,\n })\n .withPromise();\n\n // Patch over non-specific `fdir` typings.\n const absoluteFilenames = output as string[];\n\n const relativeFilepaths = absoluteFilenames.map((filepath) =>\n path.relative(root, filepath),\n );\n\n return relativeFilepaths;\n};\n\n/**\n * Create a filter function that excludes filepaths based on ignore files like\n * `.gitignore` and `.prettierignore`.\n */\nexport const createInclusionFilter = async (ignoreFilepaths: string[]) => {\n const ignoreFiles = await Promise.all(\n ignoreFilepaths.map(async (ignoreFilepath) => {\n try {\n return await fs.promises.readFile(ignoreFilepath, 'utf8');\n } catch (err) {\n if (isErrorWithCode(err, 'ENOENT')) {\n return;\n }\n\n throw err;\n }\n }),\n );\n\n const managers = ignoreFiles\n .filter((value): value is string => typeof value === 'string')\n .map((value) => ignore().add(value));\n\n return ignore().add('.git').add(managers).createFilter();\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,kBAA6B;AAC7B,sBAAe;AACf,oBAAmB;AACnB,uBAAsB;AAEtB,mBAAgC;AAKzB,MAAM,4BAA4B,CACvC,UACA,iBAEA,OAAO;AAAA,EACL,SAAS,IAAI,CAAC,YAAY;AACxB,UAAM,cAAU,iBAAAA,SAAU,OAAO;AAEjC,UAAM,YAAY,aAAa,OAAO,CAAC,aAAa,QAAQ,QAAQ,CAAC;AAErE,WAAO,CAAC,SAAS,SAAS;AAAA,EAC5B,CAAC;AACH;AAWK,MAAM,iBAAiB,OAC5B,MACA,iBAAiB,iBACd;AACH,QAAM,mBAAmB,MAAM,sBAAsB;AAAA,IACnD,YAAAC,QAAK,KAAK,MAAM,cAAc;AAAA,EAChC,CAAC;AAED,QAAM,SAAS,MAAM,IAAI,YAAAC,KAAK,EAC3B,iBAAiB,MAAM;AAAA,IACtB,SAAS,CAAC,YAAY,CAAC,QAAQ,cAAc,EAAE,SAAS,OAAO;AAAA,IAC/D,SAAS;AAAA,MACP,CAAC,aAAa;AACZ,cAAM,mBAAmB,YAAAD,QAAK,SAAS,MAAM,QAAQ;AAErD,eAAO,iBAAiB,gBAAgB;AAAA,MAC1C;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,EACnB,CAAC,EACA,YAAY;AAGf,QAAM,oBAAoB;AAE1B,QAAM,oBAAoB,kBAAkB;AAAA,IAAI,CAAC,aAC/C,YAAAA,QAAK,SAAS,MAAM,QAAQ;AAAA,EAC9B;AAEA,SAAO;AACT;AAMO,MAAM,wBAAwB,OAAO,oBAA8B;AACxE,QAAM,cAAc,MAAM,QAAQ;AAAA,IAChC,gBAAgB,IAAI,OAAO,mBAAmB;AAC5C,UAAI;AACF,eAAO,MAAM,gBAAAE,QAAG,SAAS,SAAS,gBAAgB,MAAM;AAAA,MAC1D,SAAS,KAAP;AACA,gBAAI,8BAAgB,KAAK,QAAQ,GAAG;AAClC;AAAA,QACF;AAEA,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,YACd,OAAO,CAAC,UAA2B,OAAO,UAAU,QAAQ,EAC5D,IAAI,CAAC,cAAU,cAAAC,SAAO,EAAE,IAAI,KAAK,CAAC;AAErC,aAAO,cAAAA,SAAO,EAAE,IAAI,MAAM,EAAE,IAAI,QAAQ,EAAE,aAAa;AACzD;",
6
+ "names": ["picomatch", "path", "FDir", "fs", "ignore"]
7
+ }
package/lib/utils/env.js CHANGED
@@ -1,9 +1,29 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCiEnv = void 0;
4
- /**
5
- * Whether the code is executing in a CI environment.
6
- */
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 env_exports = {};
20
+ __export(env_exports, {
21
+ isCiEnv: () => isCiEnv
22
+ });
23
+ module.exports = __toCommonJS(env_exports);
7
24
  const isCiEnv = (env = process.env) => Boolean(env.BUILDKITE || env.CI || env.GITHUB_ACTIONS);
8
- exports.isCiEnv = isCiEnv;
9
- //# sourceMappingURL=env.js.map
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ isCiEnv
28
+ });
29
+ //# sourceMappingURL=env.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAW,EAAE,CACpD,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;AAD5C,QAAA,OAAO,WACqC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/env.ts"],
4
+ "sourcesContent": ["/**\n * Whether the code is executing in a CI environment.\n */\nexport const isCiEnv = (env = process.env): boolean =>\n Boolean(env.BUILDKITE || env.CI || env.GITHUB_ACTIONS);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,UAAU,CAAC,MAAM,QAAQ,QACpC,QAAQ,IAAI,aAAa,IAAI,MAAM,IAAI,cAAc;",
6
+ "names": []
7
+ }
@@ -1,66 +1,68 @@
1
1
  "use strict";
2
- /* eslint-disable new-cap */
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
25
19
  };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.isErrorWithCode = exports.handleCliError = exports.createTerseError = exports.ConcurrentlyErrors = void 0;
28
- const util_1 = require("util");
29
- const t = __importStar(require("runtypes"));
30
- const logging_1 = require("./logging");
31
- const validation_1 = require("./validation");
32
- exports.ConcurrentlyErrors = t.Array(t.Record({
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 error_exports = {};
26
+ __export(error_exports, {
27
+ ConcurrentlyErrors: () => ConcurrentlyErrors,
28
+ createTerseError: () => createTerseError,
29
+ handleCliError: () => handleCliError,
30
+ isErrorWithCode: () => isErrorWithCode
31
+ });
32
+ module.exports = __toCommonJS(error_exports);
33
+ var import_util = require("util");
34
+ var t = __toESM(require("runtypes"));
35
+ var import_logging = require("./logging");
36
+ var import_validation = require("./validation");
37
+ const ConcurrentlyErrors = t.Array(
38
+ t.Record({
33
39
  command: t.Record({
34
- command: t.String,
35
- name: t.String,
40
+ command: t.String,
41
+ name: t.String
36
42
  }),
37
43
  index: t.Number,
38
- exitCode: t.Number,
39
- }));
40
- /**
41
- * Creates an error that returns its plain `message` rather than a full stack
42
- * trace when `util.inspect`ed.
43
- *
44
- * This can be useful for terser handling and logging of known error scenarios
45
- * that have descriptive messages.
46
- *
47
- * https://nodejs.org/api/util.html#custom-inspection-functions-on-objects
48
- */
44
+ exitCode: t.Number
45
+ })
46
+ );
49
47
  const createTerseError = (message) => Object.assign(new Error(message), {
50
- [util_1.inspect.custom]: () => message,
48
+ [import_util.inspect.custom]: () => message
51
49
  });
52
- exports.createTerseError = createTerseError;
53
- const isExecaError = (err) => (0, validation_1.hasNumberProp)(err, 'exitCode');
50
+ const isExecaError = (err) => (0, import_validation.hasNumberProp)(err, "exitCode");
54
51
  const handleCliError = (err) => {
55
- if (isExecaError(err)) {
56
- process.exitCode = err.exitCode;
57
- return;
58
- }
59
- logging_1.log.err((0, util_1.inspect)(err));
60
- process.exitCode = 1;
52
+ if (isExecaError(err)) {
53
+ process.exitCode = err.exitCode;
61
54
  return;
55
+ }
56
+ import_logging.log.err((0, import_util.inspect)(err));
57
+ process.exitCode = 1;
58
+ return;
62
59
  };
63
- exports.handleCliError = handleCliError;
64
- const isErrorWithCode = (err, code) => (0, validation_1.hasProp)(err, 'code') && err.code === code;
65
- exports.isErrorWithCode = isErrorWithCode;
66
- //# sourceMappingURL=error.js.map
60
+ const isErrorWithCode = (err, code) => (0, import_validation.hasProp)(err, "code") && err.code === code;
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ ConcurrentlyErrors,
64
+ createTerseError,
65
+ handleCliError,
66
+ isErrorWithCode
67
+ });
68
+ //# sourceMappingURL=error.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":";AAAA,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5B,+BAA+B;AAG/B,4CAA8B;AAE9B,uCAAgC;AAChC,6CAAsD;AAIzC,QAAA,kBAAkB,GAAG,CAAC,CAAC,KAAK,CACvC,CAAC,CAAC,MAAM,CAAC;IACP,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,OAAO,EAAE,CAAC,CAAC,MAAM;QACjB,IAAI,EAAE,CAAC,CAAC,MAAM;KACf,CAAC;IACF,KAAK,EAAE,CAAC,CAAC,MAAM;IACf,QAAQ,EAAE,CAAC,CAAC,MAAM;CACnB,CAAC,CACH,CAAC;AAEF;;;;;;;;GAQG;AACI,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAE,EAAE,CACnD,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE;IAChC,CAAC,cAAO,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,OAAO;CAChC,CAAC,CAAC;AAHQ,QAAA,gBAAgB,oBAGxB;AAEL,MAAM,YAAY,GAAG,CAAC,GAAY,EAAqB,EAAE,CACvD,IAAA,0BAAa,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAE1B,MAAM,cAAc,GAAG,CAAC,GAAY,EAAE,EAAE;IAC7C,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE;QACrB,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAChC,OAAO;KACR;IAED,aAAG,CAAC,GAAG,CAAC,IAAA,cAAO,EAAC,GAAG,CAAC,CAAC,CAAC;IACtB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACrB,OAAO;AACT,CAAC,CAAC;AATW,QAAA,cAAc,kBASzB;AAEK,MAAM,eAAe,GAAG,CAC7B,GAAY,EACZ,IAAO,EAC4C,EAAE,CACrD,IAAA,oBAAO,EAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC;AAJ/B,QAAA,eAAe,mBAIgB"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/error.ts"],
4
+ "sourcesContent": ["/* eslint-disable new-cap */\n\nimport { inspect } from 'util';\n\nimport type { ExecaError } from 'execa';\nimport * as t from 'runtypes';\n\nimport { log } from './logging';\nimport { hasNumberProp, hasProp } from './validation';\n\nexport type ConcurrentlyErrors = t.Static<typeof ConcurrentlyErrors>;\n\nexport const ConcurrentlyErrors = t.Array(\n t.Record({\n command: t.Record({\n command: t.String,\n name: t.String,\n }),\n index: t.Number,\n exitCode: t.Number,\n }),\n);\n\n/**\n * Creates an error that returns its plain `message` rather than a full stack\n * trace when `util.inspect`ed.\n *\n * This can be useful for terser handling and logging of known error scenarios\n * that have descriptive messages.\n *\n * https://nodejs.org/api/util.html#custom-inspection-functions-on-objects\n */\nexport const createTerseError = (message?: string) =>\n Object.assign(new Error(message), {\n [inspect.custom]: () => message,\n });\n\nconst isExecaError = (err: unknown): err is ExecaError =>\n hasNumberProp(err, 'exitCode');\n\nexport const handleCliError = (err: unknown) => {\n if (isExecaError(err)) {\n process.exitCode = err.exitCode;\n return;\n }\n\n log.err(inspect(err));\n process.exitCode = 1;\n return;\n};\n\nexport const isErrorWithCode = <T>(\n err: unknown,\n code: T,\n): err is Record<PropertyKey, unknown> & { code: T } =>\n hasProp(err, 'code') && err.code === code;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAwB;AAGxB,QAAmB;AAEnB,qBAAoB;AACpB,wBAAuC;AAIhC,MAAM,qBAAqB,EAAE;AAAA,EAClC,EAAE,OAAO;AAAA,IACP,SAAS,EAAE,OAAO;AAAA,MAChB,SAAS,EAAE;AAAA,MACX,MAAM,EAAE;AAAA,IACV,CAAC;AAAA,IACD,OAAO,EAAE;AAAA,IACT,UAAU,EAAE;AAAA,EACd,CAAC;AACH;AAWO,MAAM,mBAAmB,CAAC,YAC/B,OAAO,OAAO,IAAI,MAAM,OAAO,GAAG;AAAA,EAChC,CAAC,oBAAQ,SAAS,MAAM;AAC1B,CAAC;AAEH,MAAM,eAAe,CAAC,YACpB,iCAAc,KAAK,UAAU;AAExB,MAAM,iBAAiB,CAAC,QAAiB;AAC9C,MAAI,aAAa,GAAG,GAAG;AACrB,YAAQ,WAAW,IAAI;AACvB;AAAA,EACF;AAEA,qBAAI,QAAI,qBAAQ,GAAG,CAAC;AACpB,UAAQ,WAAW;AACnB;AACF;AAEO,MAAM,kBAAkB,CAC7B,KACA,aAEA,2BAAQ,KAAK,MAAM,KAAK,IAAI,SAAS;",
6
+ "names": []
7
+ }