@modern-js/utils 1.3.4 → 1.3.7-alpha.prebundle.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (355) hide show
  1. package/.eslintrc.js +9 -0
  2. package/CHANGELOG.md +18 -0
  3. package/compiled/browserslist/index.d.ts +178 -0
  4. package/compiled/browserslist/index.js +1 -0
  5. package/compiled/browserslist/license +20 -0
  6. package/compiled/browserslist/package.json +1 -0
  7. package/compiled/chalk/index.d.ts +415 -0
  8. package/compiled/chalk/index.js +1 -0
  9. package/compiled/chalk/license +9 -0
  10. package/compiled/chalk/package.json +1 -0
  11. package/compiled/chokidar/anymatch/index.d.ts +19 -0
  12. package/compiled/chokidar/fsevents.node +0 -0
  13. package/compiled/chokidar/index.js +40 -0
  14. package/compiled/chokidar/license +21 -0
  15. package/compiled/chokidar/package.json +1 -0
  16. package/compiled/chokidar/types/index.d.ts +188 -0
  17. package/compiled/commander/index.js +1 -0
  18. package/compiled/commander/license +22 -0
  19. package/compiled/commander/package.json +1 -0
  20. package/compiled/commander/typings/index.d.ts +774 -0
  21. package/compiled/debug/index.d.ts +54 -0
  22. package/compiled/debug/index.js +1 -0
  23. package/compiled/debug/license +20 -0
  24. package/compiled/debug/ms/index.d.ts +25 -0
  25. package/compiled/debug/package.json +1 -0
  26. package/compiled/execa/index.d.ts +564 -0
  27. package/compiled/execa/index.js +1 -0
  28. package/compiled/execa/license +9 -0
  29. package/compiled/execa/package.json +1 -0
  30. package/compiled/filesize/filesize.d.ts +131 -0
  31. package/compiled/filesize/index.js +9 -0
  32. package/compiled/filesize/license +28 -0
  33. package/compiled/filesize/package.json +1 -0
  34. package/compiled/fs-extra/index.d.ts +563 -0
  35. package/compiled/fs-extra/index.js +1 -0
  36. package/compiled/fs-extra/license +15 -0
  37. package/compiled/fs-extra/package.json +1 -0
  38. package/compiled/glob/index.d.ts +91 -0
  39. package/compiled/glob/index.js +1 -0
  40. package/compiled/glob/license +21 -0
  41. package/compiled/glob/minimatch/index.d.ts +204 -0
  42. package/compiled/glob/package.json +1 -0
  43. package/compiled/gzip-size/index.d.ts +96 -0
  44. package/compiled/gzip-size/index.js +1 -0
  45. package/compiled/gzip-size/license +9 -0
  46. package/compiled/gzip-size/package.json +1 -0
  47. package/compiled/import-lazy/index.d.ts +26 -0
  48. package/compiled/import-lazy/index.js +1 -0
  49. package/compiled/import-lazy/license +9 -0
  50. package/compiled/import-lazy/package.json +1 -0
  51. package/compiled/js-yaml/index.d.ts +154 -0
  52. package/compiled/js-yaml/index.js +1 -0
  53. package/compiled/js-yaml/license +21 -0
  54. package/compiled/js-yaml/package.json +1 -0
  55. package/compiled/lodash/common/array.d.ts +2126 -0
  56. package/compiled/lodash/common/collection.d.ts +1930 -0
  57. package/compiled/lodash/common/common.d.ts +280 -0
  58. package/compiled/lodash/common/date.d.ts +23 -0
  59. package/compiled/lodash/common/function.d.ts +1446 -0
  60. package/compiled/lodash/common/lang.d.ts +1693 -0
  61. package/compiled/lodash/common/math.d.ts +405 -0
  62. package/compiled/lodash/common/number.d.ts +131 -0
  63. package/compiled/lodash/common/object.d.ts +2519 -0
  64. package/compiled/lodash/common/seq.d.ts +210 -0
  65. package/compiled/lodash/common/string.d.ts +788 -0
  66. package/compiled/lodash/common/util.d.ts +1220 -0
  67. package/compiled/lodash/index.d.ts +46 -0
  68. package/compiled/lodash/index.js +9 -0
  69. package/compiled/lodash/license +47 -0
  70. package/compiled/lodash/package.json +1 -0
  71. package/compiled/pkg-up/index.d.ts +48 -0
  72. package/compiled/pkg-up/index.js +1 -0
  73. package/compiled/pkg-up/license +9 -0
  74. package/compiled/pkg-up/package.json +1 -0
  75. package/compiled/recursive-readdir/index.d.ts +21 -0
  76. package/compiled/recursive-readdir/index.js +1 -0
  77. package/compiled/recursive-readdir/license +21 -0
  78. package/compiled/recursive-readdir/package.json +1 -0
  79. package/compiled/signale/index.d.ts +162 -0
  80. package/compiled/signale/index.js +1 -0
  81. package/compiled/signale/package.json +1 -0
  82. package/compiled/strip-ansi/index.d.ts +17 -0
  83. package/compiled/strip-ansi/index.js +1 -0
  84. package/compiled/strip-ansi/license +9 -0
  85. package/compiled/strip-ansi/package.json +1 -0
  86. package/compiled/upath/index.js +1 -0
  87. package/compiled/upath/license +22 -0
  88. package/compiled/upath/package.json +1 -0
  89. package/compiled/upath/upath.d.ts +241 -0
  90. package/dist/{types/FileSizeReporter.d.ts → FileSizeReporter.d.ts} +5 -5
  91. package/dist/FileSizeReporter.js +151 -0
  92. package/dist/{types/alias.d.ts → alias.d.ts} +12 -14
  93. package/dist/alias.js +62 -0
  94. package/dist/applyOptionsChain.d.ts +6 -0
  95. package/dist/applyOptionsChain.js +30 -0
  96. package/dist/clearConsole.d.ts +1 -0
  97. package/dist/clearConsole.js +9 -0
  98. package/dist/{types/compatRequire.d.ts → compatRequire.d.ts} +1 -1
  99. package/dist/compatRequire.js +28 -0
  100. package/dist/compiled/upath/index.d.ts +225 -0
  101. package/dist/compiled/upath/index.js +1 -0
  102. package/dist/compiled.d.ts +21 -0
  103. package/dist/compiled.js +33 -0
  104. package/dist/constants.d.ts +209 -0
  105. package/dist/constants.js +264 -0
  106. package/dist/{js/modern/debug.js → debug.d.ts} +1 -3
  107. package/dist/debug.js +11 -0
  108. package/dist/emptyDir.d.ts +1 -0
  109. package/dist/emptyDir.js +19 -0
  110. package/dist/{types/ensureAbsolutePath.d.ts → ensureAbsolutePath.d.ts} +1 -1
  111. package/dist/ensureAbsolutePath.js +15 -0
  112. package/dist/{types/findExists.d.ts → findExists.d.ts} +1 -1
  113. package/dist/findExists.js +21 -0
  114. package/dist/{types/format.d.ts → format.d.ts} +5 -5
  115. package/dist/format.js +113 -0
  116. package/dist/{types/generateMetaTags.d.ts → generateMetaTags.d.ts} +3 -3
  117. package/dist/generateMetaTags.js +48 -0
  118. package/dist/{types/getBrowserslist.d.ts → getBrowserslist.d.ts} +1 -1
  119. package/dist/getBrowserslist.js +7 -0
  120. package/dist/{types/getCacheIdentifier.d.ts → getCacheIdentifier.d.ts} +3 -3
  121. package/dist/getCacheIdentifier.js +24 -0
  122. package/dist/{types/getEntryOptions.d.ts → getEntryOptions.d.ts} +1 -1
  123. package/dist/getEntryOptions.js +26 -0
  124. package/dist/{types/getPackageManager.d.ts → getPackageManager.d.ts} +1 -1
  125. package/dist/getPackageManager.js +47 -0
  126. package/dist/{types/getPort.d.ts → getPort.d.ts} +1 -1
  127. package/dist/getPort.js +62 -0
  128. package/dist/{types/import.d.ts → import.d.ts} +2 -2
  129. package/dist/import.js +10 -0
  130. package/dist/index.d.ts +31 -0
  131. package/dist/index.js +43 -0
  132. package/dist/{types/is → is}/index.d.ts +1 -4
  133. package/dist/is/index.js +82 -0
  134. package/dist/{types/is → is}/node-env.d.ts +1 -1
  135. package/dist/is/node-env.js +12 -0
  136. package/dist/is/platform.d.ts +2 -0
  137. package/dist/is/platform.js +10 -0
  138. package/dist/is/type.d.ts +8 -0
  139. package/dist/is/type.js +38 -0
  140. package/dist/logger.d.ts +63 -0
  141. package/dist/logger.js +128 -0
  142. package/dist/{types/monorepo.d.ts → monorepo.d.ts} +3 -3
  143. package/dist/monorepo.js +80 -0
  144. package/dist/{types/nodeEnv.d.ts → nodeEnv.d.ts} +1 -1
  145. package/dist/nodeEnv.js +49 -0
  146. package/dist/{types/path.d.ts → path.d.ts} +1 -1
  147. package/dist/path.js +14 -0
  148. package/dist/{types/pkgUp.d.ts → pkgUp.d.ts} +1 -1
  149. package/dist/pkgUp.js +8 -0
  150. package/dist/{types/prettyInstructions.d.ts → prettyInstructions.d.ts} +2 -2
  151. package/dist/prettyInstructions.js +64 -0
  152. package/dist/{types/printBuildError.d.ts → printBuildError.d.ts} +1 -1
  153. package/dist/printBuildError.js +43 -0
  154. package/dist/{types/readTsConfig.d.ts → readTsConfig.d.ts} +1 -1
  155. package/dist/readTsConfig.js +19 -0
  156. package/dist/{types/removeSlash.d.ts → removeSlash.d.ts} +1 -1
  157. package/dist/removeSlash.js +9 -0
  158. package/dist/{types/runtimeExports.d.ts → runtimeExports.d.ts} +3 -3
  159. package/dist/runtimeExports.js +53 -0
  160. package/dist/src/FileSizeReporter.d.ts +16 -0
  161. package/dist/src/FileSizeReporter.js +152 -0
  162. package/dist/src/alias.d.ts +21 -0
  163. package/dist/src/alias.js +62 -0
  164. package/dist/src/applyOptionsChain.d.ts +6 -0
  165. package/dist/src/applyOptionsChain.js +30 -0
  166. package/dist/src/clearConsole.d.ts +1 -0
  167. package/dist/src/clearConsole.js +9 -0
  168. package/dist/src/compatRequire.d.ts +8 -0
  169. package/dist/src/compatRequire.js +28 -0
  170. package/dist/src/compiled.d.ts +7 -0
  171. package/dist/src/compiled.js +19 -0
  172. package/dist/src/constants.d.ts +209 -0
  173. package/dist/src/constants.js +264 -0
  174. package/dist/{types → src}/debug.d.ts +1 -2
  175. package/dist/src/debug.js +14 -0
  176. package/dist/src/emptyDir.d.ts +1 -0
  177. package/dist/src/emptyDir.js +22 -0
  178. package/dist/{js/modern/ensureAbsolutePath.js → src/ensureAbsolutePath.d.ts} +1 -3
  179. package/dist/src/ensureAbsolutePath.js +15 -0
  180. package/dist/src/findExists.d.ts +6 -0
  181. package/dist/src/findExists.js +21 -0
  182. package/dist/src/format.d.ts +16 -0
  183. package/dist/src/format.js +115 -0
  184. package/dist/src/generateMetaTags.d.ts +16 -0
  185. package/dist/src/generateMetaTags.js +48 -0
  186. package/dist/src/getBrowserslist.d.ts +2 -0
  187. package/dist/src/getBrowserslist.js +7 -0
  188. package/dist/src/getCacheIdentifier.d.ts +7 -0
  189. package/dist/src/getCacheIdentifier.js +24 -0
  190. package/dist/src/getEntryOptions.d.ts +1 -0
  191. package/dist/src/getEntryOptions.js +26 -0
  192. package/dist/src/getPackageManager.d.ts +1 -0
  193. package/dist/src/getPackageManager.js +47 -0
  194. package/dist/src/getPort.d.ts +7 -0
  195. package/dist/src/getPort.js +62 -0
  196. package/dist/src/import.d.ts +5 -0
  197. package/dist/src/import.js +10 -0
  198. package/dist/{types → src}/index.d.ts +2 -3
  199. package/dist/src/index.js +57 -0
  200. package/dist/src/is/index.d.ts +34 -0
  201. package/dist/src/is/index.js +82 -0
  202. package/dist/src/is/node-env.d.ts +4 -0
  203. package/dist/src/is/node-env.js +12 -0
  204. package/dist/src/is/platform.d.ts +2 -0
  205. package/dist/src/is/platform.js +10 -0
  206. package/dist/src/is/type.d.ts +8 -0
  207. package/dist/src/is/type.js +38 -0
  208. package/dist/src/logger.d.ts +63 -0
  209. package/dist/src/logger.js +129 -0
  210. package/dist/src/monorepo.d.ts +11 -0
  211. package/dist/src/monorepo.js +81 -0
  212. package/dist/src/nodeEnv.d.ts +3 -0
  213. package/dist/src/nodeEnv.js +52 -0
  214. package/dist/src/path.d.ts +3 -0
  215. package/dist/src/path.js +14 -0
  216. package/dist/src/prettyInstructions.d.ts +6 -0
  217. package/dist/src/prettyInstructions.js +64 -0
  218. package/dist/src/printBuildError.d.ts +8 -0
  219. package/dist/src/printBuildError.js +43 -0
  220. package/dist/src/readTsConfig.d.ts +2 -0
  221. package/dist/src/readTsConfig.js +19 -0
  222. package/dist/src/removeSlash.d.ts +3 -0
  223. package/dist/src/removeSlash.js +9 -0
  224. package/dist/src/runtimeExports.d.ts +4 -0
  225. package/dist/src/runtimeExports.js +53 -0
  226. package/dist/{types → src}/wait.d.ts +1 -1
  227. package/dist/src/wait.js +7 -0
  228. package/dist/{types → src}/watch.d.ts +3 -3
  229. package/dist/src/watch.js +65 -0
  230. package/dist/wait.d.ts +2 -0
  231. package/dist/wait.js +7 -0
  232. package/dist/watch.d.ts +8 -0
  233. package/dist/watch.js +64 -0
  234. package/jest.config.js +0 -1
  235. package/package.json +55 -39
  236. package/tests/debug.test.ts +2 -2
  237. package/tests/is.test.ts +27 -0
  238. package/tests/isPlatform.test.ts +19 -0
  239. package/tests/isType.test.ts +70 -2
  240. package/tests/prettyInstructions.test.ts +1 -1
  241. package/tsconfig.json +3 -5
  242. package/dist/js/modern/FileSizeReporter.js +0 -156
  243. package/dist/js/modern/alias.js +0 -74
  244. package/dist/js/modern/applyOptionsChain.js +0 -27
  245. package/dist/js/modern/chalk.js +0 -2
  246. package/dist/js/modern/clearConsole.js +0 -5
  247. package/dist/js/modern/compatRequire.js +0 -26
  248. package/dist/js/modern/constants.js +0 -338
  249. package/dist/js/modern/emptyDir.js +0 -6
  250. package/dist/js/modern/findExists.js +0 -16
  251. package/dist/js/modern/format.js +0 -137
  252. package/dist/js/modern/generateMetaTags.js +0 -49
  253. package/dist/js/modern/getBrowserslist.js +0 -5
  254. package/dist/js/modern/getCacheIdentifier.js +0 -20
  255. package/dist/js/modern/getEntryOptions.js +0 -24
  256. package/dist/js/modern/getPackageManager.js +0 -37
  257. package/dist/js/modern/getPort.js +0 -52
  258. package/dist/js/modern/import.js +0 -11
  259. package/dist/js/modern/index.js +0 -34
  260. package/dist/js/modern/is/index.js +0 -77
  261. package/dist/js/modern/is/node-env.js +0 -5
  262. package/dist/js/modern/is/platform.js +0 -2
  263. package/dist/js/modern/is/type.js +0 -28
  264. package/dist/js/modern/logger.js +0 -152
  265. package/dist/js/modern/monorepo.js +0 -84
  266. package/dist/js/modern/nodeEnv.js +0 -31
  267. package/dist/js/modern/path.js +0 -5
  268. package/dist/js/modern/pkgUp.js +0 -2
  269. package/dist/js/modern/prettyInstructions.js +0 -79
  270. package/dist/js/modern/printBuildError.js +0 -40
  271. package/dist/js/modern/readTsConfig.js +0 -13
  272. package/dist/js/modern/removeSlash.js +0 -3
  273. package/dist/js/modern/runtimeExports.js +0 -52
  274. package/dist/js/modern/wait.js +0 -5
  275. package/dist/js/modern/watch.js +0 -43
  276. package/dist/js/node/FileSizeReporter.js +0 -175
  277. package/dist/js/node/alias.js +0 -97
  278. package/dist/js/node/applyOptionsChain.js +0 -37
  279. package/dist/js/node/chalk.js +0 -15
  280. package/dist/js/node/clearConsole.js +0 -14
  281. package/dist/js/node/compatRequire.js +0 -41
  282. package/dist/js/node/constants.js +0 -358
  283. package/dist/js/node/debug.js +0 -19
  284. package/dist/js/node/emptyDir.js +0 -18
  285. package/dist/js/node/ensureAbsolutePath.js +0 -20
  286. package/dist/js/node/findExists.js +0 -27
  287. package/dist/js/node/format.js +0 -141
  288. package/dist/js/node/generateMetaTags.js +0 -58
  289. package/dist/js/node/getBrowserslist.js +0 -17
  290. package/dist/js/node/getCacheIdentifier.js +0 -27
  291. package/dist/js/node/getEntryOptions.js +0 -35
  292. package/dist/js/node/getPackageManager.js +0 -51
  293. package/dist/js/node/getPort.js +0 -67
  294. package/dist/js/node/import.js +0 -19
  295. package/dist/js/node/index.js +0 -465
  296. package/dist/js/node/is/index.js +0 -150
  297. package/dist/js/node/is/node-env.js +0 -23
  298. package/dist/js/node/is/platform.js +0 -14
  299. package/dist/js/node/is/type.js +0 -49
  300. package/dist/js/node/logger.js +0 -162
  301. package/dist/js/node/monorepo.js +0 -118
  302. package/dist/js/node/nodeEnv.js +0 -45
  303. package/dist/js/node/path.js +0 -24
  304. package/dist/js/node/pkgUp.js +0 -15
  305. package/dist/js/node/prettyInstructions.js +0 -95
  306. package/dist/js/node/printBuildError.js +0 -52
  307. package/dist/js/node/readTsConfig.js +0 -28
  308. package/dist/js/node/removeSlash.js +0 -18
  309. package/dist/js/node/runtimeExports.js +0 -68
  310. package/dist/js/node/wait.js +0 -12
  311. package/dist/js/node/watch.js +0 -61
  312. package/dist/js/treeshaking/FileSizeReporter.js +0 -185
  313. package/dist/js/treeshaking/alias.js +0 -72
  314. package/dist/js/treeshaking/applyOptionsChain.js +0 -31
  315. package/dist/js/treeshaking/chalk.js +0 -2
  316. package/dist/js/treeshaking/clearConsole.js +0 -5
  317. package/dist/js/treeshaking/compatRequire.js +0 -29
  318. package/dist/js/treeshaking/constants.js +0 -338
  319. package/dist/js/treeshaking/debug.js +0 -10
  320. package/dist/js/treeshaking/emptyDir.js +0 -37
  321. package/dist/js/treeshaking/ensureAbsolutePath.js +0 -11
  322. package/dist/js/treeshaking/findExists.js +0 -33
  323. package/dist/js/treeshaking/format.js +0 -167
  324. package/dist/js/treeshaking/generateMetaTags.js +0 -55
  325. package/dist/js/treeshaking/getBrowserslist.js +0 -7
  326. package/dist/js/treeshaking/getCacheIdentifier.js +0 -35
  327. package/dist/js/treeshaking/getEntryOptions.js +0 -26
  328. package/dist/js/treeshaking/getPackageManager.js +0 -101
  329. package/dist/js/treeshaking/getPort.js +0 -103
  330. package/dist/js/treeshaking/import.js +0 -11
  331. package/dist/js/treeshaking/index.js +0 -34
  332. package/dist/js/treeshaking/is/index.js +0 -81
  333. package/dist/js/treeshaking/is/node-env.js +0 -13
  334. package/dist/js/treeshaking/is/platform.js +0 -6
  335. package/dist/js/treeshaking/is/type.js +0 -30
  336. package/dist/js/treeshaking/logger.js +0 -188
  337. package/dist/js/treeshaking/monorepo.js +0 -95
  338. package/dist/js/treeshaking/nodeEnv.js +0 -108
  339. package/dist/js/treeshaking/path.js +0 -11
  340. package/dist/js/treeshaking/pkgUp.js +0 -2
  341. package/dist/js/treeshaking/prettyInstructions.js +0 -100
  342. package/dist/js/treeshaking/printBuildError.js +0 -40
  343. package/dist/js/treeshaking/readTsConfig.js +0 -13
  344. package/dist/js/treeshaking/removeSlash.js +0 -9
  345. package/dist/js/treeshaking/runtimeExports.js +0 -61
  346. package/dist/js/treeshaking/wait.js +0 -8
  347. package/dist/js/treeshaking/watch.js +0 -112
  348. package/dist/types/applyOptionsChain.d.ts +0 -6
  349. package/dist/types/chalk.d.ts +0 -2
  350. package/dist/types/clearConsole.d.ts +0 -1
  351. package/dist/types/constants.d.ts +0 -219
  352. package/dist/types/emptyDir.d.ts +0 -1
  353. package/dist/types/is/platform.d.ts +0 -2
  354. package/dist/types/is/type.d.ts +0 -8
  355. package/dist/types/logger.d.ts +0 -63
@@ -0,0 +1,774 @@
1
+ // Type definitions for commander
2
+ // Original definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>
3
+
4
+ // Using method rather than property for method-signature-style, to document method overloads separately. Allow either.
5
+ /* eslint-disable @typescript-eslint/method-signature-style */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+
8
+ export class CommanderError extends Error {
9
+ code: string;
10
+ exitCode: number;
11
+ message: string;
12
+ nestedError?: string;
13
+
14
+ /**
15
+ * Constructs the CommanderError class
16
+ * @param exitCode - suggested exit code which could be used with process.exit
17
+ * @param code - an id string representing the error
18
+ * @param message - human-readable description of the error
19
+ * @constructor
20
+ */
21
+ constructor(exitCode: number, code: string, message: string);
22
+ }
23
+
24
+ export class InvalidArgumentError extends CommanderError {
25
+ /**
26
+ * Constructs the InvalidArgumentError class
27
+ * @param message - explanation of why argument is invalid
28
+ * @constructor
29
+ */
30
+ constructor(message: string);
31
+ }
32
+ export { InvalidArgumentError as InvalidOptionArgumentError }; // deprecated old name
33
+
34
+ export class Argument {
35
+ description: string;
36
+ required: boolean;
37
+ variadic: boolean;
38
+
39
+ /**
40
+ * Initialize a new command argument with the given name and description.
41
+ * The default is that the argument is required, and you can explicitly
42
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
43
+ */
44
+ constructor(arg: string, description?: string);
45
+
46
+ /**
47
+ * Return argument name.
48
+ */
49
+ name(): string;
50
+
51
+ /**
52
+ * Set the default value, and optionally supply the description to be displayed in the help.
53
+ */
54
+ default(value: unknown, description?: string): this;
55
+
56
+ /**
57
+ * Set the custom handler for processing CLI command arguments into argument values.
58
+ */
59
+ argParser<T>(fn: (value: string, previous: T) => T): this;
60
+
61
+ /**
62
+ * Only allow argument value to be one of choices.
63
+ */
64
+ choices(values: string[]): this;
65
+
66
+ /**
67
+ * Make option-argument required.
68
+ */
69
+ argRequired(): this;
70
+
71
+ /**
72
+ * Make option-argument optional.
73
+ */
74
+ argOptional(): this;
75
+ }
76
+
77
+ export class Option {
78
+ flags: string;
79
+ description: string;
80
+
81
+ required: boolean; // A value must be supplied when the option is specified.
82
+ optional: boolean; // A value is optional when the option is specified.
83
+ variadic: boolean;
84
+ mandatory: boolean; // The option must have a value after parsing, which usually means it must be specified on command line.
85
+ optionFlags: string;
86
+ short?: string;
87
+ long?: string;
88
+ negate: boolean;
89
+ defaultValue?: any;
90
+ defaultValueDescription?: string;
91
+ parseArg?: <T>(value: string, previous: T) => T;
92
+ hidden: boolean;
93
+ argChoices?: string[];
94
+
95
+ constructor(flags: string, description?: string);
96
+
97
+ /**
98
+ * Set the default value, and optionally supply the description to be displayed in the help.
99
+ */
100
+ default(value: unknown, description?: string): this;
101
+
102
+ /**
103
+ * Set environment variable to check for option value.
104
+ * Priority order of option values is default < env < cli
105
+ */
106
+ env(name: string): this;
107
+
108
+ /**
109
+ * Calculate the full description, including defaultValue etc.
110
+ */
111
+ fullDescription(): string;
112
+
113
+ /**
114
+ * Set the custom handler for processing CLI option arguments into option values.
115
+ */
116
+ argParser<T>(fn: (value: string, previous: T) => T): this;
117
+
118
+ /**
119
+ * Whether the option is mandatory and must have a value after parsing.
120
+ */
121
+ makeOptionMandatory(mandatory?: boolean): this;
122
+
123
+ /**
124
+ * Hide option in help.
125
+ */
126
+ hideHelp(hide?: boolean): this;
127
+
128
+ /**
129
+ * Only allow option value to be one of choices.
130
+ */
131
+ choices(values: string[]): this;
132
+
133
+ /**
134
+ * Return option name.
135
+ */
136
+ name(): string;
137
+
138
+ /**
139
+ * Return option name, in a camelcase format that can be used
140
+ * as a object attribute key.
141
+ */
142
+ attributeName(): string;
143
+ }
144
+
145
+ export class Help {
146
+ /** output helpWidth, long lines are wrapped to fit */
147
+ helpWidth?: number;
148
+ sortSubcommands: boolean;
149
+ sortOptions: boolean;
150
+
151
+ constructor();
152
+
153
+ /** Get the command term to show in the list of subcommands. */
154
+ subcommandTerm(cmd: Command): string;
155
+ /** Get the command description to show in the list of subcommands. */
156
+ subcommandDescription(cmd: Command): string;
157
+ /** Get the option term to show in the list of options. */
158
+ optionTerm(option: Option): string;
159
+ /** Get the option description to show in the list of options. */
160
+ optionDescription(option: Option): string;
161
+ /** Get the argument term to show in the list of arguments. */
162
+ argumentTerm(argument: Argument): string;
163
+ /** Get the argument description to show in the list of arguments. */
164
+ argumentDescription(argument: Argument): string;
165
+
166
+ /** Get the command usage to be displayed at the top of the built-in help. */
167
+ commandUsage(cmd: Command): string;
168
+ /** Get the description for the command. */
169
+ commandDescription(cmd: Command): string;
170
+
171
+ /** Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one. */
172
+ visibleCommands(cmd: Command): Command[];
173
+ /** Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one. */
174
+ visibleOptions(cmd: Command): Option[];
175
+ /** Get an array of the arguments which have descriptions. */
176
+ visibleArguments(cmd: Command): Argument[];
177
+
178
+ /** Get the longest command term length. */
179
+ longestSubcommandTermLength(cmd: Command, helper: Help): number;
180
+ /** Get the longest option term length. */
181
+ longestOptionTermLength(cmd: Command, helper: Help): number;
182
+ /** Get the longest argument term length. */
183
+ longestArgumentTermLength(cmd: Command, helper: Help): number;
184
+ /** Calculate the pad width from the maximum term length. */
185
+ padWidth(cmd: Command, helper: Help): number;
186
+
187
+ /**
188
+ * Wrap the given string to width characters per line, with lines after the first indented.
189
+ * Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
190
+ */
191
+ wrap(str: string, width: number, indent: number, minColumnWidth?: number): string;
192
+
193
+ /** Generate the built-in help text. */
194
+ formatHelp(cmd: Command, helper: Help): string;
195
+ }
196
+ export type HelpConfiguration = Partial<Help>;
197
+
198
+ export interface ParseOptions {
199
+ from: 'node' | 'electron' | 'user';
200
+ }
201
+ export interface HelpContext { // optional parameter for .help() and .outputHelp()
202
+ error: boolean;
203
+ }
204
+ export interface AddHelpTextContext { // passed to text function used with .addHelpText()
205
+ error: boolean;
206
+ command: Command;
207
+ }
208
+ export interface OutputConfiguration {
209
+ writeOut?(str: string): void;
210
+ writeErr?(str: string): void;
211
+ getOutHelpWidth?(): number;
212
+ getErrHelpWidth?(): number;
213
+ outputError?(str: string, write: (str: string) => void): void;
214
+
215
+ }
216
+
217
+ export type AddHelpTextPosition = 'beforeAll' | 'before' | 'after' | 'afterAll';
218
+ export type HookEvent = 'preAction' | 'postAction';
219
+ export type OptionValueSource = 'default' | 'env' | 'config' | 'cli';
220
+
221
+ export interface OptionValues {
222
+ [key: string]: any;
223
+ }
224
+
225
+ export class Command {
226
+ args: string[];
227
+ processedArgs: any[];
228
+ commands: Command[];
229
+ parent: Command | null;
230
+
231
+ constructor(name?: string);
232
+
233
+ /**
234
+ * Set the program version to `str`.
235
+ *
236
+ * This method auto-registers the "-V, --version" flag
237
+ * which will print the version number when passed.
238
+ *
239
+ * You can optionally supply the flags and description to override the defaults.
240
+ */
241
+ version(str: string, flags?: string, description?: string): this;
242
+
243
+ /**
244
+ * Define a command, implemented using an action handler.
245
+ *
246
+ * @remarks
247
+ * The command description is supplied using `.description`, not as a parameter to `.command`.
248
+ *
249
+ * @example
250
+ * ```ts
251
+ * program
252
+ * .command('clone <source> [destination]')
253
+ * .description('clone a repository into a newly created directory')
254
+ * .action((source, destination) => {
255
+ * console.log('clone command called');
256
+ * });
257
+ * ```
258
+ *
259
+ * @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
260
+ * @param opts - configuration options
261
+ * @returns new command
262
+ */
263
+ command(nameAndArgs: string, opts?: CommandOptions): ReturnType<this['createCommand']>;
264
+ /**
265
+ * Define a command, implemented in a separate executable file.
266
+ *
267
+ * @remarks
268
+ * The command description is supplied as the second parameter to `.command`.
269
+ *
270
+ * @example
271
+ * ```ts
272
+ * program
273
+ * .command('start <service>', 'start named service')
274
+ * .command('stop [service]', 'stop named service, or all if no name supplied');
275
+ * ```
276
+ *
277
+ * @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
278
+ * @param description - description of executable command
279
+ * @param opts - configuration options
280
+ * @returns `this` command for chaining
281
+ */
282
+ command(nameAndArgs: string, description: string, opts?: ExecutableCommandOptions): this;
283
+
284
+ /**
285
+ * Factory routine to create a new unattached command.
286
+ *
287
+ * See .command() for creating an attached subcommand, which uses this routine to
288
+ * create the command. You can override createCommand to customise subcommands.
289
+ */
290
+ createCommand(name?: string): Command;
291
+
292
+ /**
293
+ * Add a prepared subcommand.
294
+ *
295
+ * See .command() for creating an attached subcommand which inherits settings from its parent.
296
+ *
297
+ * @returns `this` command for chaining
298
+ */
299
+ addCommand(cmd: Command, opts?: CommandOptions): this;
300
+
301
+ /**
302
+ * Factory routine to create a new unattached argument.
303
+ *
304
+ * See .argument() for creating an attached argument, which uses this routine to
305
+ * create the argument. You can override createArgument to return a custom argument.
306
+ */
307
+ createArgument(name: string, description?: string): Argument;
308
+
309
+ /**
310
+ * Define argument syntax for command.
311
+ *
312
+ * The default is that the argument is required, and you can explicitly
313
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
314
+ *
315
+ * @example
316
+ * ```
317
+ * program.argument('<input-file>');
318
+ * program.argument('[output-file]');
319
+ * ```
320
+ *
321
+ * @returns `this` command for chaining
322
+ */
323
+ argument<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
324
+ argument(name: string, description?: string, defaultValue?: unknown): this;
325
+
326
+ /**
327
+ * Define argument syntax for command, adding a prepared argument.
328
+ *
329
+ * @returns `this` command for chaining
330
+ */
331
+ addArgument(arg: Argument): this;
332
+
333
+ /**
334
+ * Define argument syntax for command, adding multiple at once (without descriptions).
335
+ *
336
+ * See also .argument().
337
+ *
338
+ * @example
339
+ * ```
340
+ * program.arguments('<cmd> [env]');
341
+ * ```
342
+ *
343
+ * @returns `this` command for chaining
344
+ */
345
+ arguments(names: string): this;
346
+
347
+ /**
348
+ * Override default decision whether to add implicit help command.
349
+ *
350
+ * @example
351
+ * ```
352
+ * addHelpCommand() // force on
353
+ * addHelpCommand(false); // force off
354
+ * addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
355
+ * ```
356
+ *
357
+ * @returns `this` command for chaining
358
+ */
359
+ addHelpCommand(enableOrNameAndArgs?: string | boolean, description?: string): this;
360
+
361
+ /**
362
+ * Add hook for life cycle event.
363
+ */
364
+ hook(event: HookEvent, listener: (thisCommand: Command, actionCommand: Command) => void | Promise<void>): this;
365
+
366
+ /**
367
+ * Register callback to use as replacement for calling process.exit.
368
+ */
369
+ exitOverride(callback?: (err: CommanderError) => never|void): this;
370
+
371
+ /**
372
+ * You can customise the help with a subclass of Help by overriding createHelp,
373
+ * or by overriding Help properties using configureHelp().
374
+ */
375
+ createHelp(): Help;
376
+
377
+ /**
378
+ * You can customise the help by overriding Help properties using configureHelp(),
379
+ * or with a subclass of Help by overriding createHelp().
380
+ */
381
+ configureHelp(configuration: HelpConfiguration): this;
382
+ /** Get configuration */
383
+ configureHelp(): HelpConfiguration;
384
+
385
+ /**
386
+ * The default output goes to stdout and stderr. You can customise this for special
387
+ * applications. You can also customise the display of errors by overriding outputError.
388
+ *
389
+ * The configuration properties are all functions:
390
+ * ```
391
+ * // functions to change where being written, stdout and stderr
392
+ * writeOut(str)
393
+ * writeErr(str)
394
+ * // matching functions to specify width for wrapping help
395
+ * getOutHelpWidth()
396
+ * getErrHelpWidth()
397
+ * // functions based on what is being written out
398
+ * outputError(str, write) // used for displaying errors, and not used for displaying help
399
+ * ```
400
+ */
401
+ configureOutput(configuration: OutputConfiguration): this;
402
+ /** Get configuration */
403
+ configureOutput(): OutputConfiguration;
404
+
405
+ /**
406
+ * Copy settings that are useful to have in common across root command and subcommands.
407
+ *
408
+ * (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
409
+ */
410
+ copyInheritedSettings(sourceCommand: Command): this;
411
+
412
+ /**
413
+ * Display the help or a custom message after an error occurs.
414
+ */
415
+ showHelpAfterError(displayHelp?: boolean | string): this;
416
+
417
+ /**
418
+ * Display suggestion of similar commands for unknown commands, or options for unknown options.
419
+ */
420
+ showSuggestionAfterError(displaySuggestion?: boolean): this;
421
+
422
+ /**
423
+ * Register callback `fn` for the command.
424
+ *
425
+ * @example
426
+ * ```
427
+ * program
428
+ * .command('serve')
429
+ * .description('start service')
430
+ * .action(function() {
431
+ * // do work here
432
+ * });
433
+ * ```
434
+ *
435
+ * @returns `this` command for chaining
436
+ */
437
+ action(fn: (...args: any[]) => void | Promise<void>): this;
438
+
439
+ /**
440
+ * Define option with `flags`, `description` and optional
441
+ * coercion `fn`.
442
+ *
443
+ * The `flags` string contains the short and/or long flags,
444
+ * separated by comma, a pipe or space. The following are all valid
445
+ * all will output this way when `--help` is used.
446
+ *
447
+ * "-p, --pepper"
448
+ * "-p|--pepper"
449
+ * "-p --pepper"
450
+ *
451
+ * @example
452
+ * ```
453
+ * // simple boolean defaulting to false
454
+ * program.option('-p, --pepper', 'add pepper');
455
+ *
456
+ * --pepper
457
+ * program.pepper
458
+ * // => Boolean
459
+ *
460
+ * // simple boolean defaulting to true
461
+ * program.option('-C, --no-cheese', 'remove cheese');
462
+ *
463
+ * program.cheese
464
+ * // => true
465
+ *
466
+ * --no-cheese
467
+ * program.cheese
468
+ * // => false
469
+ *
470
+ * // required argument
471
+ * program.option('-C, --chdir <path>', 'change the working directory');
472
+ *
473
+ * --chdir /tmp
474
+ * program.chdir
475
+ * // => "/tmp"
476
+ *
477
+ * // optional argument
478
+ * program.option('-c, --cheese [type]', 'add cheese [marble]');
479
+ * ```
480
+ *
481
+ * @returns `this` command for chaining
482
+ */
483
+ option(flags: string, description?: string, defaultValue?: string | boolean): this;
484
+ option<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
485
+ /** @deprecated since v7, instead use choices or a custom function */
486
+ option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this;
487
+
488
+ /**
489
+ * Define a required option, which must have a value after parsing. This usually means
490
+ * the option must be specified on the command line. (Otherwise the same as .option().)
491
+ *
492
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
493
+ */
494
+ requiredOption(flags: string, description?: string, defaultValue?: string | boolean): this;
495
+ requiredOption<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
496
+ /** @deprecated since v7, instead use choices or a custom function */
497
+ requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this;
498
+
499
+ /**
500
+ * Factory routine to create a new unattached option.
501
+ *
502
+ * See .option() for creating an attached option, which uses this routine to
503
+ * create the option. You can override createOption to return a custom option.
504
+ */
505
+
506
+ createOption(flags: string, description?: string): Option;
507
+
508
+ /**
509
+ * Add a prepared Option.
510
+ *
511
+ * See .option() and .requiredOption() for creating and attaching an option in a single call.
512
+ */
513
+ addOption(option: Option): this;
514
+
515
+ /**
516
+ * Whether to store option values as properties on command object,
517
+ * or store separately (specify false). In both cases the option values can be accessed using .opts().
518
+ *
519
+ * @returns `this` command for chaining
520
+ */
521
+ storeOptionsAsProperties<T extends OptionValues>(): this & T;
522
+ storeOptionsAsProperties<T extends OptionValues>(storeAsProperties: true): this & T;
523
+ storeOptionsAsProperties(storeAsProperties?: boolean): this;
524
+
525
+ /**
526
+ * Retrieve option value.
527
+ */
528
+ getOptionValue(key: string): any;
529
+
530
+ /**
531
+ * Store option value.
532
+ */
533
+ setOptionValue(key: string, value: unknown): this;
534
+
535
+ /**
536
+ * Store option value and where the value came from.
537
+ */
538
+ setOptionValueWithSource(key: string, value: unknown, source: OptionValueSource): this;
539
+
540
+ /**
541
+ * Retrieve option value source.
542
+ */
543
+ getOptionValueSource(key: string): OptionValueSource;
544
+
545
+ /**
546
+ * Alter parsing of short flags with optional values.
547
+ *
548
+ * @example
549
+ * ```
550
+ * // for `.option('-f,--flag [value]'):
551
+ * .combineFlagAndOptionalValue(true) // `-f80` is treated like `--flag=80`, this is the default behaviour
552
+ * .combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
553
+ * ```
554
+ *
555
+ * @returns `this` command for chaining
556
+ */
557
+ combineFlagAndOptionalValue(combine?: boolean): this;
558
+
559
+ /**
560
+ * Allow unknown options on the command line.
561
+ *
562
+ * @returns `this` command for chaining
563
+ */
564
+ allowUnknownOption(allowUnknown?: boolean): this;
565
+
566
+ /**
567
+ * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
568
+ *
569
+ * @returns `this` command for chaining
570
+ */
571
+ allowExcessArguments(allowExcess?: boolean): this;
572
+
573
+ /**
574
+ * Enable positional options. Positional means global options are specified before subcommands which lets
575
+ * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
576
+ *
577
+ * The default behaviour is non-positional and global options may appear anywhere on the command line.
578
+ *
579
+ * @returns `this` command for chaining
580
+ */
581
+ enablePositionalOptions(positional?: boolean): this;
582
+
583
+ /**
584
+ * Pass through options that come after command-arguments rather than treat them as command-options,
585
+ * so actual command-options come before command-arguments. Turning this on for a subcommand requires
586
+ * positional options to have been enabled on the program (parent commands).
587
+ *
588
+ * The default behaviour is non-positional and options may appear before or after command-arguments.
589
+ *
590
+ * @returns `this` command for chaining
591
+ */
592
+ passThroughOptions(passThrough?: boolean): this;
593
+
594
+ /**
595
+ * Parse `argv`, setting options and invoking commands when defined.
596
+ *
597
+ * The default expectation is that the arguments are from node and have the application as argv[0]
598
+ * and the script being run in argv[1], with user parameters after that.
599
+ *
600
+ * @example
601
+ * ```
602
+ * program.parse(process.argv);
603
+ * program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
604
+ * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
605
+ * ```
606
+ *
607
+ * @returns `this` command for chaining
608
+ */
609
+ parse(argv?: string[], options?: ParseOptions): this;
610
+
611
+ /**
612
+ * Parse `argv`, setting options and invoking commands when defined.
613
+ *
614
+ * Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
615
+ *
616
+ * The default expectation is that the arguments are from node and have the application as argv[0]
617
+ * and the script being run in argv[1], with user parameters after that.
618
+ *
619
+ * @example
620
+ * ```
621
+ * program.parseAsync(process.argv);
622
+ * program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
623
+ * program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
624
+ * ```
625
+ *
626
+ * @returns Promise
627
+ */
628
+ parseAsync(argv?: string[], options?: ParseOptions): Promise<this>;
629
+
630
+ /**
631
+ * Parse options from `argv` removing known options,
632
+ * and return argv split into operands and unknown arguments.
633
+ *
634
+ * argv => operands, unknown
635
+ * --known kkk op => [op], []
636
+ * op --known kkk => [op], []
637
+ * sub --unknown uuu op => [sub], [--unknown uuu op]
638
+ * sub -- --unknown uuu op => [sub --unknown uuu op], []
639
+ */
640
+ parseOptions(argv: string[]): ParseOptionsResult;
641
+
642
+ /**
643
+ * Return an object containing options as key-value pairs
644
+ */
645
+ opts<T extends OptionValues>(): T;
646
+
647
+ /**
648
+ * Set the description.
649
+ *
650
+ * @returns `this` command for chaining
651
+ */
652
+
653
+ description(str: string): this;
654
+ /** @deprecated since v8, instead use .argument to add command argument with description */
655
+ description(str: string, argsDescription: {[argName: string]: string}): this;
656
+ /**
657
+ * Get the description.
658
+ */
659
+ description(): string;
660
+
661
+ /**
662
+ * Set an alias for the command.
663
+ *
664
+ * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
665
+ *
666
+ * @returns `this` command for chaining
667
+ */
668
+ alias(alias: string): this;
669
+ /**
670
+ * Get alias for the command.
671
+ */
672
+ alias(): string;
673
+
674
+ /**
675
+ * Set aliases for the command.
676
+ *
677
+ * Only the first alias is shown in the auto-generated help.
678
+ *
679
+ * @returns `this` command for chaining
680
+ */
681
+ aliases(aliases: string[]): this;
682
+ /**
683
+ * Get aliases for the command.
684
+ */
685
+ aliases(): string[];
686
+
687
+ /**
688
+ * Set the command usage.
689
+ *
690
+ * @returns `this` command for chaining
691
+ */
692
+ usage(str: string): this;
693
+ /**
694
+ * Get the command usage.
695
+ */
696
+ usage(): string;
697
+
698
+ /**
699
+ * Set the name of the command.
700
+ *
701
+ * @returns `this` command for chaining
702
+ */
703
+ name(str: string): this;
704
+ /**
705
+ * Get the name of the command.
706
+ */
707
+ name(): string;
708
+
709
+ /**
710
+ * Output help information for this command.
711
+ *
712
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
713
+ *
714
+ */
715
+ outputHelp(context?: HelpContext): void;
716
+ /** @deprecated since v7 */
717
+ outputHelp(cb?: (str: string) => string): void;
718
+
719
+ /**
720
+ * Return command help documentation.
721
+ */
722
+ helpInformation(context?: HelpContext): string;
723
+
724
+ /**
725
+ * You can pass in flags and a description to override the help
726
+ * flags and help description for your command. Pass in false
727
+ * to disable the built-in help option.
728
+ */
729
+ helpOption(flags?: string | boolean, description?: string): this;
730
+
731
+ /**
732
+ * Output help information and exit.
733
+ *
734
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
735
+ */
736
+ help(context?: HelpContext): never;
737
+ /** @deprecated since v7 */
738
+ help(cb?: (str: string) => string): never;
739
+
740
+ /**
741
+ * Add additional text to be displayed with the built-in help.
742
+ *
743
+ * Position is 'before' or 'after' to affect just this command,
744
+ * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
745
+ */
746
+ addHelpText(position: AddHelpTextPosition, text: string): this;
747
+ addHelpText(position: AddHelpTextPosition, text: (context: AddHelpTextContext) => string): this;
748
+
749
+ /**
750
+ * Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
751
+ */
752
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
753
+ }
754
+
755
+ export interface CommandOptions {
756
+ hidden?: boolean;
757
+ isDefault?: boolean;
758
+ /** @deprecated since v7, replaced by hidden */
759
+ noHelp?: boolean;
760
+ }
761
+ export interface ExecutableCommandOptions extends CommandOptions {
762
+ executableFile?: string;
763
+ }
764
+
765
+ export interface ParseOptionsResult {
766
+ operands: string[];
767
+ unknown: string[];
768
+ }
769
+
770
+ export function createCommand(name?: string): Command;
771
+ export function createOption(flags: string, description?: string): Option;
772
+ export function createArgument(name: string, description?: string): Argument;
773
+
774
+ export const program: Command;