@teambit/cli 0.0.0-00805bd6ead01ffad26e598a8de15824e876ee5a

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 (100) hide show
  1. package/.npmignore +18 -0
  2. package/cli-output-style-guide.md +132 -0
  3. package/cli.composition.tsx +7 -0
  4. package/cli.docs.mdx +12 -0
  5. package/dist/cli-output-style-guide.md +132 -0
  6. package/dist/cli-parser.d.ts +38 -0
  7. package/dist/cli-parser.js +388 -0
  8. package/dist/cli-parser.js.map +1 -0
  9. package/dist/cli-parser.spec.d.ts +1 -0
  10. package/dist/cli-parser.spec.js +113 -0
  11. package/dist/cli-parser.spec.js.map +1 -0
  12. package/dist/cli.aspect.d.ts +4 -0
  13. package/dist/cli.aspect.js +22 -0
  14. package/dist/cli.aspect.js.map +1 -0
  15. package/dist/cli.cmd.d.ts +34 -0
  16. package/dist/cli.cmd.js +163 -0
  17. package/dist/cli.cmd.js.map +1 -0
  18. package/dist/cli.composition.d.ts +2 -0
  19. package/dist/cli.composition.js +29 -0
  20. package/dist/cli.composition.js.map +1 -0
  21. package/dist/cli.docs.mdx +12 -0
  22. package/dist/cli.main.runtime.d.ts +86 -0
  23. package/dist/cli.main.runtime.js +270 -0
  24. package/dist/cli.main.runtime.js.map +1 -0
  25. package/dist/command-groups.d.ts +31 -0
  26. package/dist/command-groups.js +44 -0
  27. package/dist/command-groups.js.map +1 -0
  28. package/dist/command-helper.d.ts +25 -0
  29. package/dist/command-helper.js +59 -0
  30. package/dist/command-helper.js.map +1 -0
  31. package/dist/command-runner.d.ts +38 -0
  32. package/dist/command-runner.js +227 -0
  33. package/dist/command-runner.js.map +1 -0
  34. package/dist/command.d.ts +145 -0
  35. package/dist/command.js +3 -0
  36. package/dist/command.js.map +1 -0
  37. package/dist/completion.cmd.d.ts +9 -0
  38. package/dist/completion.cmd.js +22 -0
  39. package/dist/completion.cmd.js.map +1 -0
  40. package/dist/default-error-handler.d.ts +12 -0
  41. package/dist/default-error-handler.js +80 -0
  42. package/dist/default-error-handler.js.map +1 -0
  43. package/dist/details.cmd.d.ts +12 -0
  44. package/dist/details.cmd.js +78 -0
  45. package/dist/details.cmd.js.map +1 -0
  46. package/dist/esm.mjs +17 -0
  47. package/dist/exceptions/already-exists.d.ts +4 -0
  48. package/dist/exceptions/already-exists.js +21 -0
  49. package/dist/exceptions/already-exists.js.map +1 -0
  50. package/dist/exceptions/command-not-found.d.ts +7 -0
  51. package/dist/exceptions/command-not-found.js +44 -0
  52. package/dist/exceptions/command-not-found.js.map +1 -0
  53. package/dist/exceptions/index.d.ts +2 -0
  54. package/dist/exceptions/index.js +33 -0
  55. package/dist/exceptions/index.js.map +1 -0
  56. package/dist/exceptions/yargs-exit-workaround.d.ts +6 -0
  57. package/dist/exceptions/yargs-exit-workaround.js +23 -0
  58. package/dist/exceptions/yargs-exit-workaround.js.map +1 -0
  59. package/dist/generate-doc-md.d.ts +39 -0
  60. package/dist/generate-doc-md.js +266 -0
  61. package/dist/generate-doc-md.js.map +1 -0
  62. package/dist/get-command-id.d.ts +1 -0
  63. package/dist/get-command-id.js +11 -0
  64. package/dist/get-command-id.js.map +1 -0
  65. package/dist/global-flags.d.ts +7 -0
  66. package/dist/global-flags.js +24 -0
  67. package/dist/global-flags.js.map +1 -0
  68. package/dist/handle-errors.d.ts +3 -0
  69. package/dist/handle-errors.js +78 -0
  70. package/dist/handle-errors.js.map +1 -0
  71. package/dist/help.cmd.d.ts +16 -0
  72. package/dist/help.cmd.js +37 -0
  73. package/dist/help.cmd.js.map +1 -0
  74. package/dist/help.d.ts +3 -0
  75. package/dist/help.js +88 -0
  76. package/dist/help.js.map +1 -0
  77. package/dist/index.d.ts +14 -0
  78. package/dist/index.js +245 -0
  79. package/dist/index.js.map +1 -0
  80. package/dist/output-formatter.d.ts +40 -0
  81. package/dist/output-formatter.js +115 -0
  82. package/dist/output-formatter.js.map +1 -0
  83. package/dist/pager.d.ts +35 -0
  84. package/dist/pager.js +178 -0
  85. package/dist/pager.js.map +1 -0
  86. package/dist/preview-1787076242549.js +7 -0
  87. package/dist/version.cmd.d.ts +13 -0
  88. package/dist/version.cmd.js +39 -0
  89. package/dist/version.cmd.js.map +1 -0
  90. package/dist/yargs-adapter.d.ts +22 -0
  91. package/dist/yargs-adapter.js +133 -0
  92. package/dist/yargs-adapter.js.map +1 -0
  93. package/esm.mjs +17 -0
  94. package/exceptions/already-exists.ts +7 -0
  95. package/exceptions/command-not-found.ts +22 -0
  96. package/exceptions/index.ts +2 -0
  97. package/exceptions/yargs-exit-workaround.ts +10 -0
  98. package/package.json +74 -0
  99. package/types/asset.d.ts +41 -0
  100. package/types/style.d.ts +46 -0
@@ -0,0 +1,266 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GenerateCommandsDoc = void 0;
7
+ function _lodash() {
8
+ const data = require("lodash");
9
+ _lodash = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _getCommandId() {
15
+ const data = require("./get-command-id");
16
+ _getCommandId = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ class GenerateCommandsDoc {
22
+ constructor(commands, options, groups = {}) {
23
+ this.commands = commands;
24
+ this.options = options;
25
+ this.groups = groups;
26
+ }
27
+ generate() {
28
+ const commands = this.getAllPublicCommandsSorted();
29
+ let output = `${this.getFrontmatter()}
30
+ # CLI Reference
31
+
32
+ Run the following to list all available Bit commands (alternatively, use the \`-h\` alias, instead of \`--help\`):
33
+
34
+ \`\`\`sh
35
+ bit --help
36
+ \`\`\`
37
+
38
+ Run the following to get help on a specific command:
39
+
40
+ \`\`\`sh
41
+ bit COMMAND --help
42
+ \`\`\`
43
+
44
+ Run the following to get help on a specific sub-command:
45
+
46
+ \`\`\`sh
47
+ bit COMMAND SUB_COMMAND --help
48
+ \`\`\`
49
+ `;
50
+ output += commands.map(cmd => this.generateCommand(cmd)).join('\n');
51
+ return output;
52
+ }
53
+ generateJson() {
54
+ return this.commandsToObjects();
55
+ }
56
+
57
+ /**
58
+ * Generate command list in the style of `bit --help` but without chalk colors.
59
+ * For use in Claude Code skills.
60
+ */
61
+ generateSkillCommands() {
62
+ const grouped = this.groupCommandsByGroup();
63
+ const sections = Object.keys(grouped).map(groupName => {
64
+ const groupDescription = this.groups[groupName] || (0, _lodash().capitalize)(groupName);
65
+ const cmds = grouped[groupName];
66
+ const commandLines = cmds.map(cmd => {
67
+ const paddedName = cmd.name.padEnd(30, ' ');
68
+ let line = ` ${paddedName} - ${cmd.description || ''}`;
69
+ if (cmd.commands && cmd.commands.length > 0) {
70
+ const subNames = cmd.commands.filter(sub => !sub.private).map(sub => (0, _getCommandId().getCommandId)(sub.name));
71
+ if (subNames.length > 0) {
72
+ line += `\n Subcommands: ${subNames.join(', ')}`;
73
+ }
74
+ }
75
+ return line;
76
+ }).join('\n');
77
+ return ` ${groupDescription}\n${commandLines}`;
78
+ }).join('\n\n');
79
+ return `---
80
+ name: bit-cli
81
+ description: "MUST consult before running ANY bit command. Do NOT guess bit commands from memory. This skill tells you the right command, correct syntax, subcommands, and flags."
82
+ ---
83
+
84
+ # Bit CLI Quick Reference
85
+
86
+ <!-- This content is auto-generated by: bit cli generate --skill commands -->
87
+
88
+ usage: bit [--version] [--help] <command> [<args>]
89
+
90
+ bit documentation: https://bit.dev/
91
+
92
+ ${sections}
93
+
94
+ IMPORTANT: When you need flags, arguments, or subcommand details, READ the file CLI_REFERENCE.md in this same directory using the Read tool. Only fall back to 'bit <command> --help' if the reference file doesn't cover what you need.`;
95
+ }
96
+
97
+ /**
98
+ * Generate command reference with subcommands, arguments, and flags.
99
+ * For use in Claude Code skills.
100
+ */
101
+ generateSkillReference() {
102
+ const publicCommands = this.getAllPublicCommandsSorted();
103
+ const sections = [];
104
+ for (const cmd of publicCommands) {
105
+ this.collectSkillCommandSections(cmd, '', sections);
106
+ }
107
+ return `# Bit CLI Command Reference
108
+
109
+ ${sections.join('\n\n')}
110
+
111
+ ---
112
+ Run \`bit <command> --help\` for more details.`;
113
+ }
114
+ collectSkillCommandSections(cmd, prefix, sections) {
115
+ const cmdId = prefix ? `${prefix} ${(0, _getCommandId().getCommandId)(cmd.name)}` : (0, _getCommandId().getCommandId)(cmd.name);
116
+ const lines = [];
117
+
118
+ // Command usage - use full cmd.name which may include args like "set <key> <val>"
119
+ let usage = prefix ? `bit ${prefix} ${cmd.name}` : `bit ${cmd.name}`;
120
+ // Only append arguments if they're not already in cmd.name
121
+ if (cmd.arguments && cmd.arguments.length > 0 && !cmd.name.includes('<') && !cmd.name.includes('[')) {
122
+ const args = cmd.arguments.map(arg => arg.name.includes('...') ? `[${arg.name}]` : `<${arg.name}>`).join(' ');
123
+ usage += ` ${args}`;
124
+ }
125
+ lines.push(`## ${usage}`);
126
+ lines.push(''); // Blank line after heading for proper Markdown
127
+
128
+ // Description with proper separation between description and extended description
129
+ const description = (cmd.description || '').trim();
130
+ const extended = cmd.extendedDescription ? cmd.extendedDescription.replace(/\n/g, ' ').trim() : '';
131
+ if (description && extended) {
132
+ lines.push(`${description}\n\n${extended}`);
133
+ } else if (description || extended) {
134
+ lines.push(description || extended);
135
+ }
136
+
137
+ // Flags (filtering out DEPRECATED and UNSUPPORTED)
138
+ if (cmd.options && cmd.options.length > 0) {
139
+ const flags = cmd.options.filter(opt => {
140
+ const desc = opt[2] || '';
141
+ return !desc.startsWith('DEPRECATED') && !desc.startsWith('UNSUPPORTED');
142
+ }).map(opt => `--${opt[1]}`);
143
+ if (flags.length > 0) {
144
+ lines.push(`Flags: ${flags.join(', ')}`);
145
+ }
146
+ }
147
+ sections.push(lines.join('\n'));
148
+
149
+ // Process subcommands
150
+ if (cmd.commands && cmd.commands.length > 0) {
151
+ for (const subCmd of cmd.commands) {
152
+ if (!subCmd.private) {
153
+ this.collectSkillCommandSections(subCmd, cmdId, sections);
154
+ }
155
+ }
156
+ }
157
+ }
158
+ groupCommandsByGroup() {
159
+ const publicCommands = this.commands.filter(cmd => !cmd.private && cmd.description);
160
+ const grouped = {};
161
+ for (const cmd of publicCommands) {
162
+ const group = cmd.group || 'ungrouped';
163
+ if (!grouped[group]) {
164
+ grouped[group] = [];
165
+ }
166
+ grouped[group].push(cmd);
167
+ }
168
+ return grouped;
169
+ }
170
+ commandsToObjects(commands = this.commands) {
171
+ return commands.map(command => {
172
+ const cmdObject = oneCommandToObject(command);
173
+ if (command.commands?.length) {
174
+ cmdObject.commands = this.commandsToObjects(command.commands);
175
+ }
176
+ return cmdObject;
177
+ });
178
+ }
179
+ getFrontmatter() {
180
+ const metadata = this.options.metadata;
181
+ if (!metadata) {
182
+ return '';
183
+ }
184
+ const metadataStr = Object.keys(metadata).map(key => `${key}: ${metadata[key]}`).join('\n');
185
+ return `---
186
+ ${metadataStr}
187
+ ---
188
+ `;
189
+ }
190
+ getAllPublicCommandsSorted() {
191
+ const publicCommands = this.commands.filter(cmd => !cmd.private);
192
+ return publicCommands.sort((a, b) => a.name.localeCompare(b.name));
193
+ }
194
+ generateCommand(cmd) {
195
+ const commandName = (0, _getCommandId().getCommandId)(cmd.name);
196
+ let result = `## ${commandName} \n\n`;
197
+ if (cmd.alias && cmd.alias.length > 0) {
198
+ result += `**Alias**: \`${cmd.alias}\` \n`;
199
+ }
200
+ result += `**Description**: ${this.formatDescription(cmd)}`;
201
+ result += `\`bit ${cmd.name}\` \n\n`;
202
+ if (cmd.commands && cmd.commands.length > 0) {
203
+ result += this.generateSubCommands(cmd.commands, cmd);
204
+ }
205
+ result += this.generateArguments(cmd.arguments);
206
+ result += this.generateOptions(cmd.options);
207
+ result += `--- \n`;
208
+ return result;
209
+ }
210
+ generateSubCommands(subCommands, command) {
211
+ let ret = '';
212
+ subCommands.forEach(subCommand => {
213
+ const commandName = (0, _getCommandId().getCommandId)(command.name);
214
+ const subcommandName = (0, _getCommandId().getCommandId)(subCommand.name);
215
+ const usage = `${commandName} ${subCommand.name}`;
216
+ ret += `### ${commandName} ${subcommandName} \n`;
217
+ ret += `**Usage**: \`${usage}\` \n\n`;
218
+ ret += `**Description**: ${this.formatDescription(subCommand)}`;
219
+ ret += '\n';
220
+ ret += this.generateArguments(subCommand.arguments);
221
+ ret += this.generateOptions(subCommand.options);
222
+ });
223
+ return ret;
224
+ }
225
+ generateArguments(args) {
226
+ if (!args || !args.length) return '';
227
+ let output = `| **Arg** | **Description** | \n`;
228
+ output += `|---|:-----:|\n`;
229
+ args.forEach(arg => {
230
+ const {
231
+ name,
232
+ description
233
+ } = arg;
234
+ output += `|\`${name}\`|${(description || '').replaceAll('\n', ' ')}|\n`;
235
+ });
236
+ output += `\n`;
237
+ return output;
238
+ }
239
+ generateOptions(options) {
240
+ if (!options || options.length <= 0) return '';
241
+ let output = `| **Option** | **Option alias** | **Description**| \n`;
242
+ output += `|---|:-----:|---|\n`;
243
+ options.forEach(opt => {
244
+ const [alias, flag, description] = opt;
245
+ const aliasFormatted = alias ? `\`-${alias}\`` : ' ';
246
+ const flagFormatted = `--${flag}`;
247
+ output += `|\`${flagFormatted}\`|${aliasFormatted}|${description.replaceAll('\n', ' ')}|\n`;
248
+ });
249
+ output += `\n`;
250
+ return output;
251
+ }
252
+ formatStringToMD(str) {
253
+ return str.split('\n').join(' \n');
254
+ }
255
+ formatDescription(command) {
256
+ const extendedDescription = command.extendedDescription ? ` \n${this.formatStringToMD(command.extendedDescription)}` : '';
257
+ const description = this.formatStringToMD(command.description);
258
+ return `${description}${extendedDescription} \n\n`;
259
+ }
260
+ }
261
+ exports.GenerateCommandsDoc = GenerateCommandsDoc;
262
+ function oneCommandToObject(command) {
263
+ return (0, _lodash().pick)(command, ['name', 'alias', 'options', 'description', 'extendedDescription', 'group', 'private', 'internal', 'remoteOp', 'skipWorkspace', 'arguments', 'examples']);
264
+ }
265
+
266
+ //# sourceMappingURL=generate-doc-md.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lodash","data","require","_getCommandId","GenerateCommandsDoc","constructor","commands","options","groups","generate","getAllPublicCommandsSorted","output","getFrontmatter","map","cmd","generateCommand","join","generateJson","commandsToObjects","generateSkillCommands","grouped","groupCommandsByGroup","sections","Object","keys","groupName","groupDescription","capitalize","cmds","commandLines","paddedName","name","padEnd","line","description","length","subNames","filter","sub","private","getCommandId","generateSkillReference","publicCommands","collectSkillCommandSections","prefix","cmdId","lines","usage","arguments","includes","args","arg","push","trim","extended","extendedDescription","replace","flags","opt","desc","startsWith","subCmd","group","command","cmdObject","oneCommandToObject","metadata","metadataStr","key","sort","a","b","localeCompare","commandName","result","alias","formatDescription","generateSubCommands","generateArguments","generateOptions","subCommands","ret","forEach","subCommand","subcommandName","replaceAll","flag","aliasFormatted","flagFormatted","formatStringToMD","str","split","exports","pick"],"sources":["generate-doc-md.ts"],"sourcesContent":["import type { CommandOptions, Command, CommandArg } from './command';\nimport type { GroupsType } from './command-groups';\nimport { capitalize, pick } from 'lodash';\nimport { getCommandId } from './get-command-id';\n\nexport type GenerateOpts = {\n metadata?: Record<string, string>;\n};\n\ntype CommandObject = ReturnType<typeof oneCommandToObject> & { commands?: any };\n\nexport class GenerateCommandsDoc {\n constructor(\n private commands: Command[],\n private options: GenerateOpts,\n private groups: GroupsType = {}\n ) {}\n\n generate(): string {\n const commands = this.getAllPublicCommandsSorted();\n let output = `${this.getFrontmatter()}\n# CLI Reference\n\nRun the following to list all available Bit commands (alternatively, use the \\`-h\\` alias, instead of \\`--help\\`):\n\n\\`\\`\\`sh\nbit --help\n\\`\\`\\`\n\nRun the following to get help on a specific command:\n\n\\`\\`\\`sh\nbit COMMAND --help\n\\`\\`\\`\n\nRun the following to get help on a specific sub-command:\n\n\\`\\`\\`sh\nbit COMMAND SUB_COMMAND --help\n\\`\\`\\`\n`;\n output += commands.map((cmd) => this.generateCommand(cmd)).join('\\n');\n\n return output;\n }\n\n generateJson() {\n return this.commandsToObjects();\n }\n\n /**\n * Generate command list in the style of `bit --help` but without chalk colors.\n * For use in Claude Code skills.\n */\n generateSkillCommands(): string {\n const grouped = this.groupCommandsByGroup();\n const sections = Object.keys(grouped)\n .map((groupName) => {\n const groupDescription = this.groups[groupName] || capitalize(groupName);\n const cmds = grouped[groupName];\n const commandLines = cmds\n .map((cmd) => {\n const paddedName = cmd.name.padEnd(30, ' ');\n let line = ` ${paddedName} - ${cmd.description || ''}`;\n if (cmd.commands && cmd.commands.length > 0) {\n const subNames = cmd.commands.filter((sub) => !sub.private).map((sub) => getCommandId(sub.name));\n if (subNames.length > 0) {\n line += `\\n Subcommands: ${subNames.join(', ')}`;\n }\n }\n return line;\n })\n .join('\\n');\n return ` ${groupDescription}\\n${commandLines}`;\n })\n .join('\\n\\n');\n\n return `---\nname: bit-cli\ndescription: \"MUST consult before running ANY bit command. Do NOT guess bit commands from memory. This skill tells you the right command, correct syntax, subcommands, and flags.\"\n---\n\n# Bit CLI Quick Reference\n\n<!-- This content is auto-generated by: bit cli generate --skill commands -->\n\nusage: bit [--version] [--help] <command> [<args>]\n\nbit documentation: https://bit.dev/\n\n${sections}\n\nIMPORTANT: When you need flags, arguments, or subcommand details, READ the file CLI_REFERENCE.md in this same directory using the Read tool. Only fall back to 'bit <command> --help' if the reference file doesn't cover what you need.`;\n }\n\n /**\n * Generate command reference with subcommands, arguments, and flags.\n * For use in Claude Code skills.\n */\n generateSkillReference(): string {\n const publicCommands = this.getAllPublicCommandsSorted();\n const sections: string[] = [];\n\n for (const cmd of publicCommands) {\n this.collectSkillCommandSections(cmd, '', sections);\n }\n\n return `# Bit CLI Command Reference\n\n${sections.join('\\n\\n')}\n\n---\nRun \\`bit <command> --help\\` for more details.`;\n }\n\n private collectSkillCommandSections(cmd: Command, prefix: string, sections: string[]): void {\n const cmdId = prefix ? `${prefix} ${getCommandId(cmd.name)}` : getCommandId(cmd.name);\n const lines: string[] = [];\n\n // Command usage - use full cmd.name which may include args like \"set <key> <val>\"\n let usage = prefix ? `bit ${prefix} ${cmd.name}` : `bit ${cmd.name}`;\n // Only append arguments if they're not already in cmd.name\n if (cmd.arguments && cmd.arguments.length > 0 && !cmd.name.includes('<') && !cmd.name.includes('[')) {\n const args = cmd.arguments.map((arg) => (arg.name.includes('...') ? `[${arg.name}]` : `<${arg.name}>`)).join(' ');\n usage += ` ${args}`;\n }\n lines.push(`## ${usage}`);\n lines.push(''); // Blank line after heading for proper Markdown\n\n // Description with proper separation between description and extended description\n const description = (cmd.description || '').trim();\n const extended = cmd.extendedDescription ? cmd.extendedDescription.replace(/\\n/g, ' ').trim() : '';\n if (description && extended) {\n lines.push(`${description}\\n\\n${extended}`);\n } else if (description || extended) {\n lines.push(description || extended);\n }\n\n // Flags (filtering out DEPRECATED and UNSUPPORTED)\n if (cmd.options && cmd.options.length > 0) {\n const flags = cmd.options\n .filter((opt) => {\n const desc = opt[2] || '';\n return !desc.startsWith('DEPRECATED') && !desc.startsWith('UNSUPPORTED');\n })\n .map((opt) => `--${opt[1]}`);\n\n if (flags.length > 0) {\n lines.push(`Flags: ${flags.join(', ')}`);\n }\n }\n\n sections.push(lines.join('\\n'));\n\n // Process subcommands\n if (cmd.commands && cmd.commands.length > 0) {\n for (const subCmd of cmd.commands) {\n if (!subCmd.private) {\n this.collectSkillCommandSections(subCmd, cmdId, sections);\n }\n }\n }\n }\n\n private groupCommandsByGroup(): { [group: string]: Command[] } {\n const publicCommands = this.commands.filter((cmd) => !cmd.private && cmd.description);\n const grouped: { [group: string]: Command[] } = {};\n\n for (const cmd of publicCommands) {\n const group = cmd.group || 'ungrouped';\n if (!grouped[group]) {\n grouped[group] = [];\n }\n grouped[group].push(cmd);\n }\n\n return grouped;\n }\n\n private commandsToObjects(commands: Command[] = this.commands): CommandObject[] {\n return commands.map((command) => {\n const cmdObject: CommandObject = oneCommandToObject(command);\n if (command.commands?.length) {\n cmdObject.commands = this.commandsToObjects(command.commands);\n }\n return cmdObject;\n });\n }\n\n private getFrontmatter() {\n const metadata = this.options.metadata;\n if (!metadata) {\n return '';\n }\n const metadataStr = Object.keys(metadata)\n .map((key) => `${key}: ${metadata[key]}`)\n .join('\\n');\n\n return `---\n ${metadataStr}\n ---\n`;\n }\n\n private getAllPublicCommandsSorted() {\n const publicCommands = this.commands.filter((cmd) => !cmd.private);\n return publicCommands.sort((a, b) => a.name.localeCompare(b.name));\n }\n\n private generateCommand(cmd: Command) {\n const commandName = getCommandId(cmd.name);\n let result = `## ${commandName} \\n\\n`;\n if (cmd.alias && cmd.alias.length > 0) {\n result += `**Alias**: \\`${cmd.alias}\\` \\n`;\n }\n result += `**Description**: ${this.formatDescription(cmd)}`;\n result += `\\`bit ${cmd.name}\\` \\n\\n`;\n\n if (cmd.commands && cmd.commands.length > 0) {\n result += this.generateSubCommands(cmd.commands, cmd);\n }\n result += this.generateArguments(cmd.arguments);\n result += this.generateOptions(cmd.options);\n result += `--- \\n`;\n\n return result;\n }\n\n private generateSubCommands(subCommands: Command[], command: Command) {\n let ret = '';\n subCommands.forEach((subCommand) => {\n const commandName = getCommandId(command.name);\n const subcommandName = getCommandId(subCommand.name);\n const usage = `${commandName} ${subCommand.name}`;\n ret += `### ${commandName} ${subcommandName} \\n`;\n ret += `**Usage**: \\`${usage}\\` \\n\\n`;\n ret += `**Description**: ${this.formatDescription(subCommand)}`;\n\n ret += '\\n';\n ret += this.generateArguments(subCommand.arguments);\n ret += this.generateOptions(subCommand.options);\n });\n return ret;\n }\n\n private generateArguments(args?: CommandArg[]): string {\n if (!args || !args.length) return '';\n let output = `| **Arg** | **Description** | \\n`;\n output += `|---|:-----:|\\n`;\n args.forEach((arg) => {\n const { name, description } = arg;\n output += `|\\`${name}\\`|${(description || '').replaceAll('\\n', ' ')}|\\n`;\n });\n output += `\\n`;\n return output;\n }\n\n private generateOptions(options: CommandOptions): string {\n if (!options || options.length <= 0) return '';\n let output = `| **Option** | **Option alias** | **Description**| \\n`;\n output += `|---|:-----:|---|\\n`;\n options.forEach((opt) => {\n const [alias, flag, description] = opt;\n const aliasFormatted = alias ? `\\`-${alias}\\`` : ' ';\n const flagFormatted = `--${flag}`;\n output += `|\\`${flagFormatted}\\`|${aliasFormatted}|${description.replaceAll('\\n', ' ')}|\\n`;\n });\n output += `\\n`;\n return output;\n }\n\n private formatStringToMD(str: string): string {\n return str.split('\\n').join(' \\n');\n }\n\n private formatDescription(command: Command): string {\n const extendedDescription = command.extendedDescription\n ? ` \\n${this.formatStringToMD(command.extendedDescription)}`\n : '';\n const description = this.formatStringToMD(command.description as string);\n return `${description}${extendedDescription} \\n\\n`;\n }\n}\n\nfunction oneCommandToObject(command: Command) {\n return pick(command, [\n 'name',\n 'alias',\n 'options',\n 'description',\n 'extendedDescription',\n 'group',\n 'private',\n 'internal',\n 'remoteOp',\n 'skipWorkspace',\n 'arguments',\n 'examples',\n ]);\n}\n"],"mappings":";;;;;;AAEA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,cAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQO,MAAMG,mBAAmB,CAAC;EAC/BC,WAAWA,CACDC,QAAmB,EACnBC,OAAqB,EACrBC,MAAkB,GAAG,CAAC,CAAC,EAC/B;IAAA,KAHQF,QAAmB,GAAnBA,QAAmB;IAAA,KACnBC,OAAqB,GAArBA,OAAqB;IAAA,KACrBC,MAAkB,GAAlBA,MAAkB;EACzB;EAEHC,QAAQA,CAAA,EAAW;IACjB,MAAMH,QAAQ,GAAG,IAAI,CAACI,0BAA0B,CAAC,CAAC;IAClD,IAAIC,MAAM,GAAG,GAAG,IAAI,CAACC,cAAc,CAAC,CAAC;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;IACGD,MAAM,IAAIL,QAAQ,CAACO,GAAG,CAAEC,GAAG,IAAK,IAAI,CAACC,eAAe,CAACD,GAAG,CAAC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M,CAAC;EACrC;EAEQ4D,iBAAiBA,CAACb,OAAgB,EAAU;IAClD,MAAMR,mBAAmB,GAAGQ,OAAO,CAACR,mBAAmB,GACnD,OAAO,IAAI,CAACkC,gBAAgB,CAAC1B,OAAO,CAACR,mBAAmB,CAAC,EAAE,GAC3D,EAAE;IACN,MAAMrB,WAAW,GAAG,IAAI,CAACuD,gBAAgB,CAAC1B,OAAO,CAAC7B,WAAqB,CAAC;IACxE,OAAO,GAAGA,WAAW,GAAGqB,mBAAmB,QAAQ;EACrD;AACF;AAACqC,OAAA,CAAAxF,mBAAA,GAAAA,mBAAA;AAED,SAAS6D,kBAAkBA,CAACF,OAAgB,EAAE;EAC5C,OAAO,IAAA8B,cAAI,EAAC9B,OAAO,EAAE,CACnB,MAAM,EACN,OAAO,EACP,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,OAAO,EACP,SAAS,EACT,UAAU,EACV,UAAU,EACV,eAAe,EACf,WAAW,EACX,UAAU,CACX,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export declare function getCommandId(cmdName: string): string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCommandId = getCommandId;
7
+ function getCommandId(cmdName) {
8
+ return cmdName.split(' ')[0].trim();
9
+ }
10
+
11
+ //# sourceMappingURL=get-command-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getCommandId","cmdName","split","trim"],"sources":["get-command-id.ts"],"sourcesContent":["export function getCommandId(cmdName: string) {\n return cmdName.split(' ')[0].trim();\n}\n"],"mappings":";;;;;;AAAO,SAASA,YAAYA,CAACC,OAAe,EAAE;EAC5C,OAAOA,OAAO,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC;AACrC","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ declare class GlobalFlags {
2
+ private _token?;
3
+ get token(): string | undefined;
4
+ set token(token: string | undefined);
5
+ }
6
+ declare const globalFlags: GlobalFlags;
7
+ export default globalFlags;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ class GlobalFlags {
11
+ constructor() {
12
+ _defineProperty(this, "_token", void 0);
13
+ }
14
+ get token() {
15
+ return this._token;
16
+ }
17
+ set token(token) {
18
+ this._token = token;
19
+ }
20
+ }
21
+ const globalFlags = new GlobalFlags();
22
+ var _default = exports.default = globalFlags;
23
+
24
+ //# sourceMappingURL=global-flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GlobalFlags","constructor","_defineProperty","token","_token","globalFlags","_default","exports","default"],"sources":["global-flags.ts"],"sourcesContent":["class GlobalFlags {\n private _token?: string;\n get token(): string | undefined {\n return this._token;\n }\n\n set token(token: string | undefined) {\n this._token = token;\n }\n}\n\nconst globalFlags = new GlobalFlags();\n\nexport default globalFlags;\n"],"mappings":";;;;;;;;;AAAA,MAAMA,WAAW,CAAC;EAAAC,YAAA;IAAAC,eAAA;EAAA;EAEhB,IAAIC,KAAKA,CAAA,EAAuB;IAC9B,OAAO,IAAI,CAACC,MAAM;EACpB;EAEA,IAAID,KAAKA,CAACA,KAAyB,EAAE;IACnC,IAAI,CAACC,MAAM,GAAGD,KAAK;EACrB;AACF;AAEA,MAAME,WAAW,GAAG,IAAIL,WAAW,CAAC,CAAC;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEvBH,WAAW","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export declare function setExitOnUnhandledRejection(exit: boolean): void;
2
+ export declare function handleErrorAndExit(err: Error, commandName: string): Promise<void>;
3
+ export declare function handleUnhandledRejection(err: Error | null | undefined | {}): Promise<void>;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.handleErrorAndExit = handleErrorAndExit;
7
+ exports.handleUnhandledRejection = handleUnhandledRejection;
8
+ exports.setExitOnUnhandledRejection = setExitOnUnhandledRejection;
9
+ function _legacy() {
10
+ const data = require("@teambit/legacy.logger");
11
+ _legacy = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
16
+ function _defaultErrorHandler() {
17
+ const data = _interopRequireDefault(require("./default-error-handler"));
18
+ _defaultErrorHandler = function () {
19
+ return data;
20
+ };
21
+ return data;
22
+ }
23
+ function _legacy2() {
24
+ const data = require("@teambit/legacy.loader");
25
+ _legacy2 = function () {
26
+ return data;
27
+ };
28
+ return data;
29
+ }
30
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
31
+ let exitOnUnhandled = true;
32
+
33
+ // This provide a way to not exit when an unhandled rejection is found
34
+ // This is main required when we load plugins which are esm modules and they require cjs modules
35
+ // and there is as an error in the cjs module
36
+ // in such case the regular catch will not catch the error and the process will exit
37
+ // we don't want to exit in such case (of plugins load) so we provide a way to not exit
38
+ function setExitOnUnhandledRejection(exit) {
39
+ exitOnUnhandled = exit;
40
+ }
41
+ async function handleErrorAndExit(err, commandName) {
42
+ try {
43
+ _legacy2().loader.off();
44
+ _legacy().logger.error(`got an error from command ${commandName}: ${err}`, err);
45
+ const {
46
+ message
47
+ } = (0, _defaultErrorHandler().default)(err);
48
+ await logErrAndExit(message, commandName, err);
49
+ } catch (e) {
50
+ // eslint-disable-next-line no-console
51
+ console.error('failed to log the error properly, failure error', e);
52
+ // eslint-disable-next-line no-console
53
+ console.error('failed to log the error properly, original error', err);
54
+ process.exit(1);
55
+ }
56
+ }
57
+ async function handleUnhandledRejection(err) {
58
+ // eslint-disable-next-line no-console
59
+ console.error('** unhandled rejection found, please make sure the promise is resolved/rejected correctly! **', err);
60
+ if (!exitOnUnhandled) {
61
+ _legacy().logger.error(`ignoring unhandled rejection error:`, err);
62
+ return;
63
+ }
64
+ if (err instanceof Error) {
65
+ return handleErrorAndExit(err, process.argv[2]);
66
+ }
67
+ console.error(err); // eslint-disable-line
68
+ return handleErrorAndExit(new Error(`unhandledRejections found. err ${err}`), process.argv[2]);
69
+ }
70
+ async function logErrAndExit(errMsg, commandName, errObj) {
71
+ if (!errMsg) throw new Error(`logErrAndExit expects to get either an Error or a string, got nothing`);
72
+ console.error(errMsg); // eslint-disable-line
73
+ // for CI, print the entire error with the stacktrace
74
+ if (process.env.CI) console.error(errObj); // eslint-disable-line
75
+ await _legacy().logger.exitAfterFlush(1, commandName, errMsg.toString());
76
+ }
77
+
78
+ //# sourceMappingURL=handle-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_legacy","data","require","_defaultErrorHandler","_interopRequireDefault","_legacy2","e","__esModule","default","exitOnUnhandled","setExitOnUnhandledRejection","exit","handleErrorAndExit","err","commandName","loader","off","logger","error","message","defaultHandleError","logErrAndExit","console","process","handleUnhandledRejection","Error","argv","errMsg","errObj","env","CI","exitAfterFlush","toString"],"sources":["handle-errors.ts"],"sourcesContent":["import { logger } from '@teambit/legacy.logger';\nimport defaultHandleError from './default-error-handler';\nimport { loader } from '@teambit/legacy.loader';\n\nlet exitOnUnhandled = true;\n\n// This provide a way to not exit when an unhandled rejection is found\n// This is main required when we load plugins which are esm modules and they require cjs modules\n// and there is as an error in the cjs module\n// in such case the regular catch will not catch the error and the process will exit\n// we don't want to exit in such case (of plugins load) so we provide a way to not exit\nexport function setExitOnUnhandledRejection(exit: boolean) {\n exitOnUnhandled = exit;\n}\n\nexport async function handleErrorAndExit(err: Error, commandName: string): Promise<void> {\n try {\n loader.off();\n logger.error(`got an error from command ${commandName}: ${err}`, err);\n const { message } = defaultHandleError(err);\n await logErrAndExit(message, commandName, err);\n } catch (e: any) {\n // eslint-disable-next-line no-console\n console.error('failed to log the error properly, failure error', e);\n // eslint-disable-next-line no-console\n console.error('failed to log the error properly, original error', err);\n process.exit(1);\n }\n}\n\nexport async function handleUnhandledRejection(err: Error | null | undefined | {}) {\n // eslint-disable-next-line no-console\n console.error('** unhandled rejection found, please make sure the promise is resolved/rejected correctly! **', err);\n if (!exitOnUnhandled) {\n logger.error(`ignoring unhandled rejection error:`, err);\n return;\n }\n if (err instanceof Error) {\n return handleErrorAndExit(err, process.argv[2]);\n }\n console.error(err); // eslint-disable-line\n return handleErrorAndExit(new Error(`unhandledRejections found. err ${err}`), process.argv[2]);\n}\n\nasync function logErrAndExit(errMsg: Error | string, commandName: string, errObj: Error) {\n if (!errMsg) throw new Error(`logErrAndExit expects to get either an Error or a string, got nothing`);\n console.error(errMsg); // eslint-disable-line\n // for CI, print the entire error with the stacktrace\n if (process.env.CI) console.error(errObj); // eslint-disable-line\n await logger.exitAfterFlush(1, commandName, errMsg.toString());\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,qBAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,oBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAgD,SAAAG,uBAAAE,CAAA,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,EAAEU,OAAO,CAACG,IAAI,CAAC,CAAC,CAAC,CAAC;AAChG;AAEA,eAAeL,aAAaA,CAACM,MAAsB,EAAEb,WAAmB,EAAEc,MAAa,EAAE;EACvF,IAAI,CAACD,MAAM,EAAE,MAAM,IAAIF,KAAK,CAAC,uEAAuE,CAAC;EACrGH,OAAO,CAACJ,KAAK,CAACS,MAAM,CAAC,CAAC,CAAC;EACvB;EACA,IAAIJ,OAAO,CAACM,GAAG,CAACC,EAAE,EAAER,OAAO,CAACJ,KAAK,CAACU,MAAM,CAAC,CAAC,CAAC;EAC3C,MAAMX,gBAAM,CAACc,cAAc,CAAC,CAAC,EAAEjB,WAAW,EAAEa,MAAM,CAACK,QAAQ,CAAC,CAAC,CAAC;AAChE","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ import type { Command, CommandOptions } from './command';
2
+ import type { CLIMain } from './cli.main.runtime';
3
+ export declare class HelpCmd implements Command {
4
+ private cliMain;
5
+ name: string;
6
+ description: string;
7
+ extendedDescription: string;
8
+ alias: string;
9
+ loader: boolean;
10
+ group: string;
11
+ options: CommandOptions;
12
+ constructor(cliMain: CLIMain);
13
+ report(_: any, { internal }: {
14
+ internal: boolean;
15
+ }): Promise<string>;
16
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.HelpCmd = void 0;
7
+ function _help() {
8
+ const data = require("./help");
9
+ _help = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
16
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
+ class HelpCmd {
18
+ constructor(cliMain) {
19
+ this.cliMain = cliMain;
20
+ _defineProperty(this, "name", 'help');
21
+ _defineProperty(this, "description", 'display available commands and usage information');
22
+ _defineProperty(this, "extendedDescription", 'shows a categorized list of all available Bit commands with brief descriptions. use `bit <command> --help` for detailed help on specific commands.');
23
+ _defineProperty(this, "alias", '$0');
24
+ // default command (meaning, if no args are provided, this will be used), see https://github.com/yargs/yargs/blob/master/docs/advanced.md#default-commands
25
+ _defineProperty(this, "loader", false);
26
+ _defineProperty(this, "group", 'system');
27
+ _defineProperty(this, "options", [['', 'internal', 'show internal commands']]);
28
+ }
29
+ async report(_, {
30
+ internal
31
+ }) {
32
+ return (0, _help().formatHelp)(this.cliMain.commands, this.cliMain.groups, internal);
33
+ }
34
+ }
35
+ exports.HelpCmd = HelpCmd;
36
+
37
+ //# sourceMappingURL=help.cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_help","data","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","HelpCmd","constructor","cliMain","report","_","internal","formatHelp","commands","groups","exports"],"sources":["help.cmd.ts"],"sourcesContent":["import type { Command, CommandOptions } from './command';\nimport type { CLIMain } from './cli.main.runtime';\nimport { formatHelp } from './help';\n\nexport class HelpCmd implements Command {\n name = 'help';\n description = 'display available commands and usage information';\n extendedDescription =\n 'shows a categorized list of all available Bit commands with brief descriptions. use `bit <command> --help` for detailed help on specific commands.';\n alias = '$0'; // default command (meaning, if no args are provided, this will be used), see https://github.com/yargs/yargs/blob/master/docs/advanced.md#default-commands\n loader = false;\n group = 'system';\n options = [['', 'internal', 'show internal commands']] as CommandOptions;\n\n constructor(private cliMain: CLIMain) {}\n\n async report(_, { internal }: { internal: boolean }) {\n return formatHelp(this.cliMain.commands, this.cliMain.groups, internal);\n }\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,CAAC,EAAE;IAAEC;EAAgC,CAAC,EAAE;IACnD,OAAO,IAAAC,kBAAU,EAAC,IAAI,CAACJ,OAAO,CAACK,QAAQ,EAAE,IAAI,CAACL,OAAO,CAACM,MAAM,EAAEH,QAAQ,CAAC;EACzE;AACF;AAACI,OAAA,CAAAT,OAAA,GAAAA,OAAA","ignoreList":[]}
package/dist/help.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { GroupsType } from './command-groups';
2
+ import type { CommandList } from './cli.main.runtime';
3
+ export declare function formatHelp(commands: CommandList, groups: GroupsType, showPrivateCommands?: boolean): string;
package/dist/help.js ADDED
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatHelp = formatHelp;
7
+ function _chalk() {
8
+ const data = _interopRequireDefault(require("chalk"));
9
+ _chalk = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _padRight() {
15
+ const data = _interopRequireDefault(require("pad-right"));
16
+ _padRight = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _lodash() {
22
+ const data = require("lodash");
23
+ _lodash = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _getCommandId() {
29
+ const data = require("./get-command-id");
30
+ _getCommandId = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
36
+ const SPACE = ' ';
37
+ const TITLE_LEFT_SPACES_NUMBER = 2;
38
+ const COMMAND_LEFT_SPACES_NUMBER = 4;
39
+ const NAME_WITH_SPACES_LENGTH = 16;
40
+ function formatHelp(commands, groups, showPrivateCommands = false) {
41
+ const helpProps = groupCommands(commands, groups, showPrivateCommands);
42
+ const commandsStr = formatCommandsHelp(helpProps);
43
+ return `${getHeader()}
44
+
45
+ ${commandsStr}
46
+
47
+ ${getFooter()}`;
48
+ }
49
+ function groupCommands(commands, groups, showPrivateCommands = false) {
50
+ const help = commands.filter(command => showPrivateCommands ? true : !command.private && command.description).reduce(function (partialHelp, command) {
51
+ const groupName = command.group; // at this stage, it must be set
52
+ partialHelp[groupName] = partialHelp[groupName] || {
53
+ commands: {},
54
+ description: groups[groupName] || (0, _lodash().capitalize)(command.group)
55
+ };
56
+ const cmdId = (0, _getCommandId().getCommandId)(command.name);
57
+ partialHelp[groupName].commands[cmdId] = command.description;
58
+ return partialHelp;
59
+ }, {});
60
+ return help;
61
+ }
62
+ function formatCommandsHelp(helpProps) {
63
+ return Object.keys(helpProps).map(groupName => commandsSectionTemplate(helpProps[groupName])).join('\n\n');
64
+ }
65
+ function commandsSectionTemplate(section) {
66
+ const titleSpace = SPACE.repeat(TITLE_LEFT_SPACES_NUMBER);
67
+ const title = `${titleSpace}${_chalk().default.underline.bold.blue(section.description)}`;
68
+ const commands = Object.keys(section.commands).map(cmdName => commandTemplate(cmdName, section.commands[cmdName])).join('\n');
69
+ const res = `${title}\n${commands}`;
70
+ return res;
71
+ }
72
+ function commandTemplate(name, description) {
73
+ const nameSpace = SPACE.repeat(COMMAND_LEFT_SPACES_NUMBER);
74
+ const nameWithRightSpace = (0, _padRight().default)(name, NAME_WITH_SPACES_LENGTH, SPACE);
75
+ const res = `${nameSpace}${_chalk().default.green(nameWithRightSpace)}${description}`;
76
+ return res;
77
+ }
78
+ function getHeader() {
79
+ return `${_chalk().default.bold('usage: bit [--version] [--help] <command> [<args>]')}
80
+
81
+ ${_chalk().default.yellow(`bit documentation: https://bit.dev/`)}`;
82
+ }
83
+ function getFooter() {
84
+ return _chalk().default.yellow(`use 'bit <command> --help' for more information and guides on specific commands.
85
+ use 'bit --internal' to show advanced commands.`);
86
+ }
87
+
88
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_padRight","_lodash","_getCommandId","e","__esModule","default","SPACE","TITLE_LEFT_SPACES_NUMBER","COMMAND_LEFT_SPACES_NUMBER","NAME_WITH_SPACES_LENGTH","formatHelp","commands","groups","showPrivateCommands","helpProps","groupCommands","commandsStr","formatCommandsHelp","getHeader","getFooter","help","filter","command","private","description","reduce","partialHelp","groupName","group","capitalize","cmdId","getCommandId","name","Object","keys","map","commandsSectionTemplate","join","section","titleSpace","repeat","title","chalk","underline","bold","blue","cmdName","commandTemplate","res","nameSpace","nameWithRightSpace","rightpad","green","yellow"],"sources":["help.ts"],"sourcesContent":["import chalk from 'chalk';\nimport rightpad from 'pad-right';\nimport { capitalize } from 'lodash';\nimport type { GroupsType } from './command-groups';\nimport type { CommandList } from './cli.main.runtime';\nimport { getCommandId } from './get-command-id';\n\nconst SPACE = ' ';\nconst TITLE_LEFT_SPACES_NUMBER = 2;\nconst COMMAND_LEFT_SPACES_NUMBER = 4;\nconst NAME_WITH_SPACES_LENGTH = 16;\n\ntype HelpProps = {\n [groupName: string]: GroupContent;\n};\n\ntype GroupContent = {\n commands: { [cmdName: string]: string };\n description: string;\n};\n\nexport function formatHelp(commands: CommandList, groups: GroupsType, showPrivateCommands = false) {\n const helpProps = groupCommands(commands, groups, showPrivateCommands);\n const commandsStr = formatCommandsHelp(helpProps);\n\n return `${getHeader()}\n\n${commandsStr}\n\n${getFooter()}`;\n}\n\nfunction groupCommands(commands: CommandList, groups: GroupsType, showPrivateCommands = false): HelpProps {\n const help: HelpProps = commands\n .filter((command) => (showPrivateCommands ? true : !command.private && command.description))\n .reduce(function (partialHelp, command) {\n const groupName = command.group as string; // at this stage, it must be set\n partialHelp[groupName] = partialHelp[groupName] || {\n commands: {},\n description: groups[groupName] || capitalize(command.group),\n };\n const cmdId = getCommandId(command.name);\n partialHelp[groupName].commands[cmdId] = command.description;\n return partialHelp;\n }, {});\n return help;\n}\n\nfunction formatCommandsHelp(helpProps: HelpProps): string {\n return Object.keys(helpProps)\n .map((groupName) => commandsSectionTemplate(helpProps[groupName]))\n .join('\\n\\n');\n}\n\nfunction commandsSectionTemplate(section: GroupContent): string {\n const titleSpace = SPACE.repeat(TITLE_LEFT_SPACES_NUMBER);\n const title = `${titleSpace}${chalk.underline.bold.blue(section.description)}`;\n const commands = Object.keys(section.commands)\n .map((cmdName) => commandTemplate(cmdName, section.commands[cmdName]))\n .join('\\n');\n const res = `${title}\\n${commands}`;\n return res;\n}\n\nfunction commandTemplate(name: string, description: string): string {\n const nameSpace = SPACE.repeat(COMMAND_LEFT_SPACES_NUMBER);\n const nameWithRightSpace = rightpad(name, NAME_WITH_SPACES_LENGTH, SPACE);\n const res = `${nameSpace}${chalk.green(nameWithRightSpace)}${description}`;\n return res;\n}\n\nfunction getHeader(): string {\n return `${chalk.bold('usage: bit [--version] [--help] <command> [<args>]')}\n\n${chalk.yellow(`bit documentation: https://bit.dev/`)}`;\n}\n\nfunction getFooter(): string {\n return chalk.yellow(`use 'bit <command> --help' for more information and guides on specific commands.\nuse 'bit --internal' to show advanced commands.`);\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAK,cAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,aAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAgD,SAAAC,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhD,MAAM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