@hugojosefson/cli 0.11.0 → 0.12.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 (207) hide show
  1. package/esm/deno.js +16 -8
  2. package/esm/node_modules/@conventional-changelog/template/LICENSE.md +21 -0
  3. package/esm/node_modules/@conventional-changelog/template/README.md +66 -0
  4. package/esm/node_modules/@conventional-changelog/template/dist/elements.d.ts +78 -0
  5. package/esm/node_modules/@conventional-changelog/template/dist/elements.d.ts.map +1 -0
  6. package/esm/node_modules/@conventional-changelog/template/dist/elements.js +132 -0
  7. package/esm/node_modules/@conventional-changelog/template/dist/index.d.ts +6 -0
  8. package/esm/node_modules/@conventional-changelog/template/dist/index.d.ts.map +1 -0
  9. package/esm/node_modules/@conventional-changelog/template/dist/index.js +5 -0
  10. package/esm/node_modules/@conventional-changelog/template/dist/legacy.d.ts +20 -0
  11. package/esm/node_modules/@conventional-changelog/template/dist/legacy.d.ts.map +1 -0
  12. package/esm/node_modules/@conventional-changelog/template/dist/legacy.js +22 -0
  13. package/esm/node_modules/@conventional-changelog/template/dist/references.d.ts +43 -0
  14. package/esm/node_modules/@conventional-changelog/template/dist/references.d.ts.map +1 -0
  15. package/esm/node_modules/@conventional-changelog/template/dist/references.js +82 -0
  16. package/esm/node_modules/@conventional-changelog/template/dist/templates.d.ts +74 -0
  17. package/esm/node_modules/@conventional-changelog/template/dist/templates.d.ts.map +1 -0
  18. package/esm/node_modules/@conventional-changelog/template/dist/templates.js +125 -0
  19. package/esm/node_modules/@conventional-changelog/template/dist/types/commit.d.ts +37 -0
  20. package/esm/node_modules/@conventional-changelog/template/dist/types/commit.d.ts.map +1 -0
  21. package/esm/node_modules/@conventional-changelog/template/dist/types/commit.js +2 -0
  22. package/esm/node_modules/@conventional-changelog/template/dist/types/context.d.ts +113 -0
  23. package/esm/node_modules/@conventional-changelog/template/dist/types/context.d.ts.map +1 -0
  24. package/esm/node_modules/@conventional-changelog/template/dist/types/context.js +2 -0
  25. package/esm/node_modules/@conventional-changelog/template/dist/types/index.d.ts +4 -0
  26. package/esm/node_modules/@conventional-changelog/template/dist/types/index.d.ts.map +1 -0
  27. package/esm/node_modules/@conventional-changelog/template/dist/types/index.js +2 -0
  28. package/esm/node_modules/@conventional-changelog/template/dist/types/utils.d.ts +2 -0
  29. package/esm/node_modules/@conventional-changelog/template/dist/types/utils.d.ts.map +1 -0
  30. package/esm/node_modules/@conventional-changelog/template/dist/types/utils.js +2 -0
  31. package/esm/node_modules/@conventional-changelog/template/package.json +38 -0
  32. package/esm/node_modules/@simple-libs/stream-utils/LICENSE +21 -0
  33. package/esm/node_modules/@simple-libs/stream-utils/README.md +79 -0
  34. package/esm/node_modules/@simple-libs/stream-utils/dist/index.d.ts +51 -0
  35. package/esm/node_modules/@simple-libs/stream-utils/dist/index.d.ts.map +1 -0
  36. package/esm/node_modules/@simple-libs/stream-utils/dist/index.js +116 -0
  37. package/esm/node_modules/@simple-libs/stream-utils/package.json +38 -0
  38. package/esm/node_modules/argue-cli/LICENSE +21 -0
  39. package/esm/node_modules/argue-cli/README.md +239 -0
  40. package/esm/node_modules/argue-cli/dist/args.d.ts +30 -0
  41. package/esm/node_modules/argue-cli/dist/args.d.ts.map +1 -0
  42. package/esm/node_modules/argue-cli/dist/argv.d.ts +14 -0
  43. package/esm/node_modules/argue-cli/dist/argv.d.ts.map +1 -0
  44. package/esm/node_modules/argue-cli/dist/core.d.ts +24 -0
  45. package/esm/node_modules/argue-cli/dist/core.d.ts.map +1 -0
  46. package/esm/node_modules/argue-cli/dist/index.d.ts +6 -0
  47. package/esm/node_modules/argue-cli/dist/index.d.ts.map +1 -0
  48. package/esm/node_modules/argue-cli/dist/index.js +254 -0
  49. package/esm/node_modules/argue-cli/dist/index.js.map +1 -0
  50. package/esm/node_modules/argue-cli/dist/options.d.ts +9 -0
  51. package/esm/node_modules/argue-cli/dist/options.d.ts.map +1 -0
  52. package/esm/node_modules/argue-cli/dist/types.d.ts +16 -0
  53. package/esm/node_modules/argue-cli/dist/types.d.ts.map +1 -0
  54. package/esm/node_modules/argue-cli/dist/utils.d.ts +24 -0
  55. package/esm/node_modules/argue-cli/dist/utils.d.ts.map +1 -0
  56. package/esm/node_modules/argue-cli/package.json +34 -0
  57. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-changelog-writer/LICENSE.md +21 -0
  58. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-changelog-writer/README.md +369 -0
  59. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-changelog-writer/package.json +53 -0
  60. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-filter/LICENSE +21 -0
  61. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-filter/README.md +184 -0
  62. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-filter/package.json +31 -0
  63. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-parser/LICENSE.md +21 -0
  64. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-parser/README.md +383 -0
  65. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-parser/package.json +47 -0
  66. package/esm/node_modules/conventional-changelog-writer/README.md +49 -342
  67. package/esm/node_modules/conventional-changelog-writer/dist/cli/index.d.ts +3 -0
  68. package/esm/node_modules/conventional-changelog-writer/dist/cli/index.d.ts.map +1 -0
  69. package/esm/node_modules/conventional-changelog-writer/dist/cli/index.js +68 -0
  70. package/esm/node_modules/conventional-changelog-writer/dist/cli/utils.d.ts +4 -0
  71. package/esm/node_modules/conventional-changelog-writer/dist/cli/utils.d.ts.map +1 -0
  72. package/esm/node_modules/conventional-changelog-writer/dist/cli/utils.js +39 -0
  73. package/esm/node_modules/conventional-changelog-writer/dist/commit.d.ts +10 -0
  74. package/esm/node_modules/conventional-changelog-writer/dist/commit.d.ts.map +1 -0
  75. package/esm/node_modules/conventional-changelog-writer/dist/commit.js +43 -0
  76. package/esm/node_modules/conventional-changelog-writer/dist/context.d.ts +27 -0
  77. package/esm/node_modules/conventional-changelog-writer/dist/context.d.ts.map +1 -0
  78. package/esm/node_modules/conventional-changelog-writer/dist/context.js +134 -0
  79. package/esm/node_modules/conventional-changelog-writer/dist/index.d.ts +7 -0
  80. package/esm/node_modules/conventional-changelog-writer/dist/index.d.ts.map +1 -0
  81. package/esm/node_modules/conventional-changelog-writer/dist/index.js +6 -0
  82. package/esm/node_modules/conventional-changelog-writer/dist/options.d.ts +25 -0
  83. package/esm/node_modules/conventional-changelog-writer/dist/options.d.ts.map +1 -0
  84. package/esm/node_modules/conventional-changelog-writer/dist/options.js +79 -0
  85. package/esm/node_modules/conventional-changelog-writer/dist/template.d.ts +10 -0
  86. package/esm/node_modules/conventional-changelog-writer/dist/template.d.ts.map +1 -0
  87. package/esm/node_modules/conventional-changelog-writer/dist/template.js +18 -0
  88. package/esm/node_modules/conventional-changelog-writer/dist/types/index.d.ts +8 -0
  89. package/esm/node_modules/conventional-changelog-writer/dist/types/index.d.ts.map +1 -0
  90. package/esm/node_modules/conventional-changelog-writer/dist/types/index.js +2 -0
  91. package/esm/node_modules/conventional-changelog-writer/dist/types/options.d.ts +122 -0
  92. package/esm/node_modules/conventional-changelog-writer/dist/types/options.d.ts.map +1 -0
  93. package/esm/node_modules/conventional-changelog-writer/dist/types/options.js +2 -0
  94. package/esm/node_modules/conventional-changelog-writer/dist/types/utils.d.ts +9 -0
  95. package/esm/node_modules/conventional-changelog-writer/dist/types/utils.d.ts.map +1 -0
  96. package/esm/node_modules/conventional-changelog-writer/dist/types/utils.js +2 -0
  97. package/esm/node_modules/conventional-changelog-writer/dist/utils.d.ts +20 -0
  98. package/esm/node_modules/conventional-changelog-writer/dist/utils.d.ts.map +1 -0
  99. package/esm/node_modules/conventional-changelog-writer/dist/utils.js +70 -0
  100. package/esm/node_modules/conventional-changelog-writer/dist/writers.d.ts +29 -0
  101. package/esm/node_modules/conventional-changelog-writer/dist/writers.d.ts.map +1 -0
  102. package/esm/node_modules/conventional-changelog-writer/dist/writers.js +94 -0
  103. package/esm/node_modules/conventional-changelog-writer/package.json +24 -26
  104. package/esm/node_modules/conventional-commits-filter/README.md +51 -170
  105. package/esm/node_modules/conventional-commits-filter/dist/RevertedCommitsFilter.d.ts +17 -0
  106. package/esm/node_modules/conventional-commits-filter/dist/RevertedCommitsFilter.d.ts.map +1 -0
  107. package/esm/node_modules/conventional-commits-filter/dist/RevertedCommitsFilter.js +46 -0
  108. package/esm/node_modules/conventional-commits-filter/dist/filters.d.ts +19 -0
  109. package/esm/node_modules/conventional-commits-filter/dist/filters.d.ts.map +1 -0
  110. package/esm/node_modules/conventional-commits-filter/dist/filters.js +34 -0
  111. package/esm/node_modules/conventional-commits-filter/dist/index.d.ts +4 -0
  112. package/esm/node_modules/conventional-commits-filter/dist/index.d.ts.map +1 -0
  113. package/esm/node_modules/conventional-commits-filter/dist/index.js +3 -0
  114. package/esm/node_modules/conventional-commits-filter/dist/types.d.ts +6 -0
  115. package/esm/node_modules/conventional-commits-filter/dist/types.d.ts.map +1 -0
  116. package/esm/node_modules/conventional-commits-filter/dist/types.js +2 -0
  117. package/esm/node_modules/conventional-commits-filter/dist/utils.d.ts +16 -0
  118. package/esm/node_modules/conventional-commits-filter/dist/utils.d.ts.map +1 -0
  119. package/esm/node_modules/conventional-commits-filter/dist/utils.js +43 -0
  120. package/esm/node_modules/conventional-commits-filter/package.json +22 -16
  121. package/esm/node_modules/conventional-commits-parser/README.md +49 -353
  122. package/esm/node_modules/conventional-commits-parser/dist/CommitParser.d.ts +40 -0
  123. package/esm/node_modules/conventional-commits-parser/dist/CommitParser.d.ts.map +1 -0
  124. package/esm/node_modules/conventional-commits-parser/dist/CommitParser.js +319 -0
  125. package/esm/node_modules/conventional-commits-parser/dist/cli/index.d.ts +3 -0
  126. package/esm/node_modules/conventional-commits-parser/dist/cli/index.d.ts.map +1 -0
  127. package/esm/node_modules/conventional-commits-parser/dist/cli/index.js +67 -0
  128. package/esm/node_modules/conventional-commits-parser/dist/cli/options.d.ts +3 -0
  129. package/esm/node_modules/conventional-commits-parser/dist/cli/options.d.ts.map +1 -0
  130. package/esm/node_modules/conventional-commits-parser/dist/cli/options.js +40 -0
  131. package/esm/node_modules/conventional-commits-parser/dist/cli/utils.d.ts +5 -0
  132. package/esm/node_modules/conventional-commits-parser/dist/cli/utils.d.ts.map +1 -0
  133. package/esm/node_modules/conventional-commits-parser/dist/cli/utils.js +49 -0
  134. package/esm/node_modules/conventional-commits-parser/dist/index.d.ts +4 -0
  135. package/esm/node_modules/conventional-commits-parser/dist/index.d.ts.map +1 -0
  136. package/esm/node_modules/conventional-commits-parser/dist/index.js +3 -0
  137. package/esm/node_modules/conventional-commits-parser/dist/options.d.ts +3 -0
  138. package/esm/node_modules/conventional-commits-parser/dist/options.d.ts.map +1 -0
  139. package/esm/node_modules/conventional-commits-parser/dist/options.js +27 -0
  140. package/esm/node_modules/conventional-commits-parser/dist/regex.d.ts +8 -0
  141. package/esm/node_modules/conventional-commits-parser/dist/regex.d.ts.map +1 -0
  142. package/esm/node_modules/conventional-commits-parser/dist/regex.js +63 -0
  143. package/esm/node_modules/conventional-commits-parser/dist/stream.d.ts +14 -0
  144. package/esm/node_modules/conventional-commits-parser/dist/stream.d.ts.map +1 -0
  145. package/esm/node_modules/conventional-commits-parser/dist/stream.js +38 -0
  146. package/esm/node_modules/conventional-commits-parser/dist/types.d.ts +100 -0
  147. package/esm/node_modules/conventional-commits-parser/dist/types.d.ts.map +1 -0
  148. package/esm/node_modules/conventional-commits-parser/dist/types.js +2 -0
  149. package/esm/node_modules/conventional-commits-parser/dist/utils.d.ts +41 -0
  150. package/esm/node_modules/conventional-commits-parser/dist/utils.d.ts.map +1 -0
  151. package/esm/node_modules/conventional-commits-parser/dist/utils.js +75 -0
  152. package/esm/node_modules/conventional-commits-parser/package.json +22 -23
  153. package/esm/src/cli/command-help.js +15 -0
  154. package/esm/src/cli/repair-configuration-description.js +98 -0
  155. package/esm/src/cli/run-changelog.js +51 -0
  156. package/esm/src/cli/run-cli.js +8 -0
  157. package/esm/src/features/built-in-feature-registry.js +2 -0
  158. package/esm/src/features/changelog-feature.js +155 -0
  159. package/esm/src/features/github-ci-artifacts.js +17 -3
  160. package/esm/src/features/github-ci-runtime-matrix.js +50 -0
  161. package/esm/src/features/github-release-publish-artifacts.js +5 -4
  162. package/esm/src/features/github-release-publish-feature.js +4 -0
  163. package/esm/src/features/github-workflow-cache.js +18 -0
  164. package/esm/src/features/workflow-deno.js +1 -1
  165. package/esm/src/release/changelog-markdown.js +41 -0
  166. package/esm/src/release/changelog.js +155 -7
  167. package/esm/src/release/format-changelog.js +15 -0
  168. package/esm/src/release/migrate-changelog.js +92 -0
  169. package/esm/src/release/publish-github.js +7 -3
  170. package/esm/src/release/publish-tag-prepare.js +63 -78
  171. package/esm/src/release/release-history.js +53 -0
  172. package/npm-dependencies.lock.json +115 -48
  173. package/package.json +5 -3
  174. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/dependencies.js +0 -11036
  175. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/index.d.ts +0 -1416
  176. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/index.js +0 -100
  177. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/licenses.md +0 -1767
  178. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/options.js +0 -92
  179. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/parser.js +0 -84
  180. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/utils.js +0 -7
  181. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/validate.js +0 -122
  182. package/esm/node_modules/conventional-commits-parser/node_modules/meow/license +0 -9
  183. package/esm/node_modules/conventional-commits-parser/node_modules/meow/package.json +0 -107
  184. package/esm/node_modules/conventional-commits-parser/node_modules/meow/readme.md +0 -314
  185. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/cli.mjs +0 -0
  186. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/index.js +0 -0
  187. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/lib/util.js +0 -0
  188. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/templates/commit.hbs +0 -0
  189. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/templates/footer.hbs +0 -0
  190. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/templates/header.hbs +0 -0
  191. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/templates/template.hbs +0 -0
  192. /package/esm/node_modules/{conventional-commits-filter → conventional-changelog-core/node_modules/conventional-commits-filter}/index.js +0 -0
  193. /package/esm/node_modules/{conventional-commits-parser → conventional-changelog-core/node_modules/conventional-commits-parser}/cli.mjs +0 -0
  194. /package/esm/node_modules/{conventional-commits-parser → conventional-changelog-core/node_modules/conventional-commits-parser}/index.js +0 -0
  195. /package/esm/node_modules/{conventional-commits-parser → conventional-changelog-core/node_modules/conventional-commits-parser}/lib/parser.js +0 -0
  196. /package/esm/node_modules/{conventional-commits-parser → conventional-changelog-core/node_modules/conventional-commits-parser}/lib/regex.js +0 -0
  197. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/dependencies.js +0 -0
  198. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/index.d.ts +0 -0
  199. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/index.js +0 -0
  200. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/licenses.md +0 -0
  201. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/options.js +0 -0
  202. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/parser.js +0 -0
  203. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/utils.js +0 -0
  204. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/validate.js +0 -0
  205. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/license +0 -0
  206. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/package.json +0 -0
  207. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/readme.md +0 -0
@@ -1,92 +0,0 @@
1
- import process from 'node:process';
2
- import { dirname } from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import { a as readPackageUpSync } from './dependencies.js';
5
- import { joinFlagKeys, decamelizeFlagKey } from './utils.js';
6
-
7
- const validateOptions = options => {
8
- const invalidOptionFilters = {
9
- flags: {
10
- keyContainsDashes: {
11
- filter: ([flagKey]) => flagKey.includes('-') && flagKey !== '--',
12
- message: flagKeys => `Flag keys may not contain '-'. Invalid flags: ${joinFlagKeys(flagKeys, '')}`,
13
- },
14
- aliasIsSet: {
15
- filter: ([, flag]) => Object.hasOwn(flag, 'alias'),
16
- message: flagKeys => `The option \`alias\` has been renamed to \`shortFlag\`. The following flags need to be updated: ${joinFlagKeys(flagKeys)}`,
17
- },
18
- choicesNotAnArray: {
19
- filter: ([, flag]) => Object.hasOwn(flag, 'choices') && !Array.isArray(flag.choices),
20
- message: flagKeys => `The option \`choices\` must be an array. Invalid flags: ${joinFlagKeys(flagKeys)}`,
21
- },
22
- choicesNotMatchFlagType: {
23
- filter: ([, flag]) => flag.type && Array.isArray(flag.choices) && flag.choices.some(choice => typeof choice !== flag.type),
24
- message(flagKeys) {
25
- const flagKeysAndTypes = flagKeys.map(flagKey => `(\`${decamelizeFlagKey(flagKey)}\`, type: '${options.flags[flagKey].type}')`);
26
- return `Each value of the option \`choices\` must be of the same type as its flag. Invalid flags: ${flagKeysAndTypes.join(', ')}`;
27
- },
28
- },
29
- defaultNotInChoices: {
30
- filter: ([, flag]) => flag.default && Array.isArray(flag.choices) && ![flag.default].flat().every(value => flag.choices.includes(value)),
31
- message: flagKeys => `Each value of the option \`default\` must exist within the option \`choices\`. Invalid flags: ${joinFlagKeys(flagKeys)}`,
32
- },
33
- },
34
- };
35
-
36
- const errorMessages = [];
37
-
38
- for (const [optionKey, filters] of Object.entries(invalidOptionFilters)) {
39
- const optionEntries = Object.entries(options[optionKey]);
40
-
41
- for (const {filter, message} of Object.values(filters)) {
42
- const invalidOptions = optionEntries.filter(option => filter(option));
43
- const invalidOptionKeys = invalidOptions.map(([key]) => key);
44
-
45
- if (invalidOptions.length > 0) {
46
- errorMessages.push(message(invalidOptionKeys));
47
- }
48
- }
49
- }
50
-
51
- if (errorMessages.length > 0) {
52
- throw new Error(errorMessages.join('\n'));
53
- }
54
- };
55
-
56
- const buildOptions = (helpText, options) => {
57
- if (typeof helpText !== 'string') {
58
- options = helpText;
59
- helpText = '';
60
- }
61
-
62
- if (!options.importMeta?.url) {
63
- throw new TypeError('The `importMeta` option is required. Its value must be `import.meta`.');
64
- }
65
-
66
- const foundPackage = readPackageUpSync({
67
- cwd: dirname(fileURLToPath(options.importMeta.url)),
68
- normalize: false,
69
- });
70
-
71
- const parsedOptions = {
72
- pkg: foundPackage ? foundPackage.packageJson : {},
73
- argv: process.argv.slice(2),
74
- flags: {},
75
- inferType: false,
76
- input: 'string',
77
- help: helpText,
78
- autoHelp: true,
79
- autoVersion: true,
80
- booleanDefault: false,
81
- hardRejection: true,
82
- allowUnknownFlags: true,
83
- allowParentFlags: true,
84
- ...options,
85
- };
86
-
87
- validateOptions(parsedOptions);
88
-
89
- return parsedOptions;
90
- };
91
-
92
- export { buildOptions };
@@ -1,84 +0,0 @@
1
- import { d as decamelizeKeys, b as constructParserOptions } from './dependencies.js';
2
-
3
- const buildParserFlags = ({flags, booleanDefault}) => {
4
- const parserFlags = {};
5
-
6
- for (const [flagKey, flagValue] of Object.entries(flags)) {
7
- const flag = {...flagValue};
8
-
9
- // `minimist-options` expects `flag.alias`
10
- if (flag.shortFlag) {
11
- flag.alias = flag.shortFlag;
12
- delete flag.shortFlag;
13
- }
14
-
15
- if (
16
- booleanDefault !== undefined
17
- && flag.type === 'boolean'
18
- && !Object.hasOwn(flag, 'default')
19
- ) {
20
- flag.default = flag.isMultiple ? [booleanDefault] : booleanDefault;
21
- }
22
-
23
- if (flag.isMultiple) {
24
- flag.type = flag.type ? `${flag.type}-array` : 'array';
25
- flag.default = flag.default ?? [];
26
- delete flag.isMultiple;
27
- }
28
-
29
- if (Array.isArray(flag.aliases)) {
30
- if (flag.alias) {
31
- flag.aliases.push(flag.alias);
32
- }
33
-
34
- flag.alias = flag.aliases;
35
- delete flag.aliases;
36
- }
37
-
38
- parserFlags[flagKey] = flag;
39
- }
40
-
41
- return parserFlags;
42
- };
43
-
44
- const buildParserOptions = options => {
45
- let parserOptions = buildParserFlags(options);
46
- parserOptions.arguments = options.input;
47
-
48
- parserOptions = decamelizeKeys(parserOptions, {separator: '-', exclude: ['stopEarly', '--']});
49
-
50
- if (options.inferType) {
51
- delete parserOptions.arguments;
52
- }
53
-
54
- // Add --help and --version to known flags if autoHelp or autoVersion are set
55
- if (!options.allowUnknownFlags) {
56
- if (options.autoHelp && !parserOptions.help) {
57
- parserOptions.help = {type: 'boolean'};
58
- }
59
-
60
- if (options.autoVersion && !parserOptions.version) {
61
- parserOptions.version = {type: 'boolean'};
62
- }
63
- }
64
-
65
- parserOptions = constructParserOptions(parserOptions);
66
-
67
- parserOptions.configuration = {
68
- ...parserOptions.configuration,
69
- 'greedy-arrays': false,
70
- };
71
-
72
- if (parserOptions['--']) {
73
- parserOptions.configuration['populate--'] = true;
74
- }
75
-
76
- if (!options.allowUnknownFlags) {
77
- // Collect unknown options in `argv._` to be checked later.
78
- parserOptions.configuration['unknown-options-as-args'] = true;
79
- }
80
-
81
- return parserOptions;
82
- };
83
-
84
- export { buildParserOptions };
@@ -1,7 +0,0 @@
1
- import { e as decamelize } from './dependencies.js';
2
-
3
- const decamelizeFlagKey = flagKey => `--${decamelize(flagKey, {separator: '-'})}`;
4
-
5
- const joinFlagKeys = (flagKeys, prefix = '--') => `\`${prefix}${flagKeys.join(`\`, \`${prefix}`)}\``;
6
-
7
- export { decamelizeFlagKey, joinFlagKeys };
@@ -1,122 +0,0 @@
1
- import process from 'node:process';
2
- import { decamelizeFlagKey } from './utils.js';
3
-
4
- const validateFlags = (flags, options) => {
5
- for (const [flagKey, flagValue] of Object.entries(options.flags)) {
6
- if (flagKey !== '--' && !flagValue.isMultiple && Array.isArray(flags[flagKey])) {
7
- throw new Error(`The flag --${flagKey} can only be set once.`);
8
- }
9
- }
10
- };
11
-
12
- const validateChoicesByFlag = (flagKey, flagValue, receivedInput) => {
13
- const {choices, isRequired} = flagValue;
14
-
15
- if (!choices) {
16
- return;
17
- }
18
-
19
- const valueMustBeOneOf = `Value must be one of: [\`${choices.join('`, `')}\`]`;
20
-
21
- if (!receivedInput) {
22
- if (isRequired) {
23
- return `Flag \`${decamelizeFlagKey(flagKey)}\` has no value. ${valueMustBeOneOf}`;
24
- }
25
-
26
- return;
27
- }
28
-
29
- if (Array.isArray(receivedInput)) {
30
- const unknownValues = receivedInput.filter(index => !choices.includes(index));
31
-
32
- if (unknownValues.length > 0) {
33
- const valuesText = unknownValues.length > 1 ? 'values' : 'value';
34
-
35
- return `Unknown ${valuesText} for flag \`${decamelizeFlagKey(flagKey)}\`: \`${unknownValues.join('`, `')}\`. ${valueMustBeOneOf}`;
36
- }
37
- } else if (!choices.includes(receivedInput)) {
38
- return `Unknown value for flag \`${decamelizeFlagKey(flagKey)}\`: \`${receivedInput}\`. ${valueMustBeOneOf}`;
39
- }
40
- };
41
-
42
- const validateChoices = (flags, receivedFlags) => {
43
- const errors = [];
44
-
45
- for (const [flagKey, flagValue] of Object.entries(flags)) {
46
- const receivedInput = receivedFlags[flagKey];
47
- const errorMessage = validateChoicesByFlag(flagKey, flagValue, receivedInput);
48
-
49
- if (errorMessage) {
50
- errors.push(errorMessage);
51
- }
52
- }
53
-
54
- if (errors.length > 0) {
55
- throw new Error(`${errors.join('\n')}`);
56
- }
57
- };
58
-
59
- const validate = (flags, options) => {
60
- validateFlags(flags, options);
61
- validateChoices(options.flags, flags);
62
- };
63
-
64
- const reportUnknownFlags = unknownFlags => {
65
- console.error([
66
- `Unknown flag${unknownFlags.length > 1 ? 's' : ''}`,
67
- ...unknownFlags,
68
- ].join('\n'));
69
- };
70
-
71
- const checkUnknownFlags = input => {
72
- const unknownFlags = input.filter(item => typeof item === 'string' && item.startsWith('-'));
73
- if (unknownFlags.length > 0) {
74
- reportUnknownFlags(unknownFlags);
75
- process.exit(2);
76
- }
77
- };
78
-
79
- const isFlagMissing = (flagName, definedFlags, receivedFlags, input) => {
80
- const flag = definedFlags[flagName];
81
- let isFlagRequired = true;
82
-
83
- if (typeof flag.isRequired === 'function') {
84
- isFlagRequired = flag.isRequired(receivedFlags, input);
85
- if (typeof isFlagRequired !== 'boolean') {
86
- throw new TypeError(`Return value for isRequired callback should be of type boolean, but ${typeof isFlagRequired} was returned.`);
87
- }
88
- }
89
-
90
- if (receivedFlags[flagName] === undefined) {
91
- return isFlagRequired;
92
- }
93
-
94
- return flag.isMultiple && receivedFlags[flagName].length === 0 && isFlagRequired;
95
- };
96
-
97
- const reportMissingRequiredFlags = missingRequiredFlags => {
98
- console.error(`Missing required flag${missingRequiredFlags.length > 1 ? 's' : ''}`);
99
- for (const flag of missingRequiredFlags) {
100
- console.error(`\t${decamelizeFlagKey(flag.key)}${flag.shortFlag ? `, -${flag.shortFlag}` : ''}`);
101
- }
102
- };
103
-
104
- const checkMissingRequiredFlags = (flags, receivedFlags, input) => {
105
- const missingRequiredFlags = [];
106
- if (flags === undefined) {
107
- return [];
108
- }
109
-
110
- for (const flagName of Object.keys(flags)) {
111
- if (flags[flagName].isRequired && isFlagMissing(flagName, flags, receivedFlags, input)) {
112
- missingRequiredFlags.push({key: flagName, ...flags[flagName]});
113
- }
114
- }
115
-
116
- if (missingRequiredFlags.length > 0) {
117
- reportMissingRequiredFlags(missingRequiredFlags);
118
- process.exit(2);
119
- }
120
- };
121
-
122
- export { checkMissingRequiredFlags, checkUnknownFlags, validate };
@@ -1,9 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,107 +0,0 @@
1
- {
2
- "name": "meow",
3
- "version": "12.1.1",
4
- "description": "CLI app helper",
5
- "license": "MIT",
6
- "repository": "sindresorhus/meow",
7
- "funding": "https://github.com/sponsors/sindresorhus",
8
- "author": {
9
- "name": "Sindre Sorhus",
10
- "email": "sindresorhus@gmail.com",
11
- "url": "https://sindresorhus.com"
12
- },
13
- "type": "module",
14
- "exports": {
15
- "types": "./build/index.d.ts",
16
- "default": "./build/index.js"
17
- },
18
- "sideEffects": false,
19
- "engines": {
20
- "node": ">=16.10"
21
- },
22
- "scripts": {
23
- "prepare": "npm run build",
24
- "build": "rollup --config",
25
- "test": "xo && npm run build && ava && tsd --typings build/index.d.ts"
26
- },
27
- "files": [
28
- "build"
29
- ],
30
- "keywords": [
31
- "cli",
32
- "bin",
33
- "util",
34
- "utility",
35
- "helper",
36
- "argv",
37
- "command",
38
- "line",
39
- "meow",
40
- "cat",
41
- "kitten",
42
- "parser",
43
- "option",
44
- "flags",
45
- "input",
46
- "cmd",
47
- "console"
48
- ],
49
- "_actualDependencies": [
50
- "@types/minimist",
51
- "camelcase-keys",
52
- "decamelize",
53
- "decamelize-keys",
54
- "hard-rejection",
55
- "minimist-options",
56
- "normalize-package-data",
57
- "read-pkg-up",
58
- "redent",
59
- "trim-newlines",
60
- "type-fest",
61
- "yargs-parser"
62
- ],
63
- "devDependencies": {
64
- "@rollup/plugin-commonjs": "^25.0.3",
65
- "@rollup/plugin-json": "^6.0.0",
66
- "@rollup/plugin-node-resolve": "^15.1.0",
67
- "@types/minimist": "^1.2.2",
68
- "ava": "^5.3.1",
69
- "camelcase-keys": "^8.0.2",
70
- "common-tags": "^2.0.0-alpha.1",
71
- "decamelize": "^6.0.0",
72
- "decamelize-keys": "^2.0.1",
73
- "delete_comments": "^0.0.2",
74
- "execa": "^7.2.0",
75
- "globby": "^13.2.2",
76
- "hard-rejection": "^2.1.0",
77
- "indent-string": "^5.0.0",
78
- "minimist-options": "4.1.0",
79
- "normalize-package-data": "^5.0.0",
80
- "read-pkg": "^8.0.0",
81
- "read-pkg-up": "^10.0.0",
82
- "redent": "^4.0.0",
83
- "rollup": "^3.27.0",
84
- "rollup-plugin-dts": "^6.0.0",
85
- "rollup-plugin-license": "^3.0.1",
86
- "trim-newlines": "^5.0.0",
87
- "tsd": "^0.28.1",
88
- "type-fest": "^4.3.1",
89
- "typescript": "~5.1.6",
90
- "xo": "^0.56.0",
91
- "yargs-parser": "^21.1.1"
92
- },
93
- "xo": {
94
- "rules": {
95
- "unicorn/no-process-exit": "off",
96
- "unicorn/error-message": "off"
97
- },
98
- "ignores": [
99
- "build"
100
- ]
101
- },
102
- "ava": {
103
- "files": [
104
- "test/*"
105
- ]
106
- }
107
- }