@teambit/cli 0.0.590 → 0.0.592
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.
- package/dist/cli-parser.js +21 -106
- package/dist/cli-parser.js.map +1 -1
- package/dist/cli.aspect.js +0 -6
- package/dist/cli.aspect.js.map +1 -1
- package/dist/cli.cmd.js +3 -44
- package/dist/cli.cmd.js.map +1 -1
- package/dist/cli.composition.js +0 -6
- package/dist/cli.composition.js.map +1 -1
- package/dist/cli.main.runtime.js +11 -79
- package/dist/cli.main.runtime.js.map +1 -1
- package/dist/command-runner.js +6 -73
- package/dist/command-runner.js.map +1 -1
- package/dist/completion.cmd.js +0 -7
- package/dist/completion.cmd.js.map +1 -1
- package/dist/exceptions/already-exists.js +0 -6
- package/dist/exceptions/already-exists.js.map +1 -1
- package/dist/exceptions/command-not-found.js +0 -16
- package/dist/exceptions/command-not-found.js.map +1 -1
- package/dist/exceptions/index.js +0 -3
- package/dist/exceptions/index.js.map +1 -1
- package/dist/generate-doc-md.js +0 -33
- package/dist/generate-doc-md.js.map +1 -1
- package/dist/get-command-id.js +0 -3
- package/dist/get-command-id.js.map +1 -1
- package/dist/help.cmd.js +1 -12
- package/dist/help.cmd.js.map +1 -1
- package/dist/help.js +0 -23
- package/dist/help.js.map +1 -1
- package/dist/index.js +0 -11
- package/dist/index.js.map +1 -1
- package/dist/legacy-command-adapter.js +0 -14
- package/dist/legacy-command-adapter.js.map +1 -1
- package/dist/yargs-adapter.js +6 -41
- package/dist/yargs-adapter.js.map +1 -1
- package/package-tar/teambit-cli-0.0.592.tgz +0 -0
- package/package.json +5 -5
- package/{preview-1666312873430.js → preview-1666669368175.js} +2 -2
- package/package-tar/teambit-cli-0.0.590.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GenerateCommandsDoc","constructor","commands","options","generate","getAllPublicCommandsSorted","output","getFrontmatter","map","cmd","generateCommand","join","generateJson","commandsToObjects","command","cmdObject","oneCommandToObject","length","metadata","metadataStr","Object","keys","key","publicCommands","filter","private","sort","a","b","name","localeCompare","commandName","getCommandId","result","alias","skipWorkspace","formatDescription","generateSubCommands","generateOptions","subCommands","ret","forEach","subCommand","subcommandName","usage","opt","flag","description","aliasFormatted","flagFormatted","formatStringToMD","str","split","extendedDescription","pick"],"sources":["generate-doc-md.ts"],"sourcesContent":["import { Command } from '@teambit/legacy/dist/cli/command';\nimport { CommandOptions } from '@teambit/legacy/dist/cli/legacy-command';\nimport { 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(private commands: Command[], private options: GenerateOpts) {}\n\n generate(): string {\n const commands = this.getAllPublicCommandsSorted();\n let output = `${this.getFrontmatter()}\n# CLI Reference\n\nCommands that are marked as workspace only must be executed inside a workspace. Commands that are marked as not workspace only, can be executed from anywhere and will run on a remote server.\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 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 += `**Workspace only**: ${cmd.skipWorkspace ? 'no' : 'yes'} \\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.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.generateOptions(subCommand.options);\n });\n return ret;\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}|\\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":"
|
|
1
|
+
{"version":3,"names":["GenerateCommandsDoc","constructor","commands","options","generate","getAllPublicCommandsSorted","output","getFrontmatter","map","cmd","generateCommand","join","generateJson","commandsToObjects","command","cmdObject","oneCommandToObject","length","metadata","metadataStr","Object","keys","key","publicCommands","filter","private","sort","a","b","name","localeCompare","commandName","getCommandId","result","alias","skipWorkspace","formatDescription","generateSubCommands","generateOptions","subCommands","ret","forEach","subCommand","subcommandName","usage","opt","flag","description","aliasFormatted","flagFormatted","formatStringToMD","str","split","extendedDescription","pick"],"sources":["generate-doc-md.ts"],"sourcesContent":["import { Command } from '@teambit/legacy/dist/cli/command';\nimport { CommandOptions } from '@teambit/legacy/dist/cli/legacy-command';\nimport { 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(private commands: Command[], private options: GenerateOpts) {}\n\n generate(): string {\n const commands = this.getAllPublicCommandsSorted();\n let output = `${this.getFrontmatter()}\n# CLI Reference\n\nCommands that are marked as workspace only must be executed inside a workspace. Commands that are marked as not workspace only, can be executed from anywhere and will run on a remote server.\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 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 += `**Workspace only**: ${cmd.skipWorkspace ? 'no' : 'yes'} \\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.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.generateOptions(subCommand.options);\n });\n return ret;\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}|\\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 '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ACd,OAAOA,MAAM;EACf;EAEQ4C,gBAAgB,CAACC,GAAW,EAAU;IAC5C,OAAOA,GAAG,CAACC,KAAK,CAAC,IAAI,CAAC,CAACzC,IAAI,CAAC,MAAM,CAAC;EACrC;EAEQyB,iBAAiB,CAACtB,OAAgB,EAAU;IAClD,MAAMuC,mBAAmB,GAAGvC,OAAO,CAACuC,mBAAmB,GAClD,OAAM,IAAI,CAACH,gBAAgB,CAACpC,OAAO,CAACuC,mBAAmB,CAAE,EAAC,GAC3D,EAAE;IACN,MAAMN,WAAW,GAAG,IAAI,CAACG,gBAAgB,CAACpC,OAAO,CAACiC,WAAW,CAAW;IACxE,OAAQ,GAAEA,WAAY,GAAEM,mBAAoB,QAAO;EACrD;AACF;AAAC;AAED,SAASrC,kBAAkB,CAACF,OAAgB,EAAE;EAC5C,OAAO,IAAAwC,cAAI,EAACxC,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"}
|
package/dist/get-command-id.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.regexp.exec.js");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.string.trim.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.getCommandId = getCommandId;
|
|
11
|
-
|
|
12
9
|
function getCommandId(cmdName) {
|
|
13
10
|
return cmdName.split(' ')[0].trim();
|
|
14
11
|
}
|
|
@@ -1 +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":"
|
|
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,YAAY,CAACC,OAAe,EAAE;EAC5C,OAAOA,OAAO,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAACC,IAAI,EAAE;AACrC"}
|
package/dist/help.cmd.js
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.promise.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.HelpCmd = void 0;
|
|
11
|
-
|
|
12
9
|
function _defineProperty2() {
|
|
13
10
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
|
|
15
11
|
_defineProperty2 = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function _help() {
|
|
23
17
|
const data = require("./help");
|
|
24
|
-
|
|
25
18
|
_help = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
class HelpCmd {
|
|
33
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
|
+
|
|
34
26
|
constructor(cliMain, docsDomain) {
|
|
35
27
|
this.cliMain = cliMain;
|
|
36
28
|
this.docsDomain = docsDomain;
|
|
@@ -41,13 +33,10 @@ class HelpCmd {
|
|
|
41
33
|
(0, _defineProperty2().default)(this, "group", 'general');
|
|
42
34
|
(0, _defineProperty2().default)(this, "options", []);
|
|
43
35
|
}
|
|
44
|
-
|
|
45
36
|
async report() {
|
|
46
37
|
return (0, _help().formatHelp)(this.cliMain.commands, this.cliMain.groups, this.docsDomain);
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
}
|
|
50
|
-
|
|
51
40
|
exports.HelpCmd = HelpCmd;
|
|
52
41
|
|
|
53
42
|
//# sourceMappingURL=help.cmd.js.map
|
package/dist/help.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HelpCmd","constructor","cliMain","docsDomain","report","formatHelp","commands","groups"],"sources":["help.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { CLIMain } from './cli.main.runtime';\nimport { formatHelp } from './help';\n\nexport class HelpCmd implements Command {\n name = 'help';\n description = 'shows help';\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 = 'general';\n options = [] as CommandOptions;\n\n constructor(private cliMain: CLIMain, private docsDomain: string) {}\n\n async report() {\n return formatHelp(this.cliMain.commands, this.cliMain.groups, this.docsDomain);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["HelpCmd","constructor","cliMain","docsDomain","report","formatHelp","commands","groups"],"sources":["help.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { CLIMain } from './cli.main.runtime';\nimport { formatHelp } from './help';\n\nexport class HelpCmd implements Command {\n name = 'help';\n description = 'shows help';\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 = 'general';\n options = [] as CommandOptions;\n\n constructor(private cliMain: CLIMain, private docsDomain: string) {}\n\n async report() {\n return formatHelp(this.cliMain.commands, this.cliMain.groups, this.docsDomain);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,OAAO,CAAoB;EAGxB;;EAKdC,WAAW,CAASC,OAAgB,EAAUC,UAAkB,EAAE;IAAA,KAA9CD,OAAgB,GAAhBA,OAAgB;IAAA,KAAUC,UAAkB,GAAlBA,UAAkB;IAAA,8CAPzD,MAAM;IAAA,qDACC,YAAY;IAAA,+CAClB,IAAI;IAAA,gDACH,KAAK;IAAA,+CACN,SAAS;IAAA,iDACP,EAAE;EAEuD;EAEnE,MAAMC,MAAM,GAAG;IACb,OAAO,IAAAC,kBAAU,EAAC,IAAI,CAACH,OAAO,CAACI,QAAQ,EAAE,IAAI,CAACJ,OAAO,CAACK,MAAM,EAAE,IAAI,CAACJ,UAAU,CAAC;EAChF;AACF;AAAC"}
|
package/dist/help.js
CHANGED
|
@@ -1,59 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.symbol.description.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.formatHelp = formatHelp;
|
|
11
|
-
|
|
12
9
|
function _chalk() {
|
|
13
10
|
const data = _interopRequireDefault(require("chalk"));
|
|
14
|
-
|
|
15
11
|
_chalk = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function _padRight() {
|
|
23
17
|
const data = _interopRequireDefault(require("pad-right"));
|
|
24
|
-
|
|
25
18
|
_padRight = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function _lodash() {
|
|
33
24
|
const data = require("lodash");
|
|
34
|
-
|
|
35
25
|
_lodash = function () {
|
|
36
26
|
return data;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
return data;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
function _getCommandId() {
|
|
43
31
|
const data = require("./get-command-id");
|
|
44
|
-
|
|
45
32
|
_getCommandId = function () {
|
|
46
33
|
return data;
|
|
47
34
|
};
|
|
48
|
-
|
|
49
35
|
return data;
|
|
50
36
|
}
|
|
51
|
-
|
|
52
37
|
const SPACE = ' ';
|
|
53
38
|
const TITLE_LEFT_SPACES_NUMBER = 2;
|
|
54
39
|
const COMMAND_LEFT_SPACES_NUMBER = 4;
|
|
55
40
|
const NAME_WITH_SPACES_LENGTH = 15;
|
|
56
|
-
|
|
57
41
|
function formatHelp(commands, groups, docsDomain) {
|
|
58
42
|
const helpProps = groupCommands(commands, groups);
|
|
59
43
|
const commandsStr = formatCommandsHelp(helpProps);
|
|
@@ -63,11 +47,9 @@ ${commandsStr}
|
|
|
63
47
|
|
|
64
48
|
${getFooter()}`;
|
|
65
49
|
}
|
|
66
|
-
|
|
67
50
|
function groupCommands(commands, groups) {
|
|
68
51
|
const help = commands.filter(command => !command.private && command.description).reduce(function (partialHelp, command) {
|
|
69
52
|
const groupName = command.group; // at this stage, it must be set
|
|
70
|
-
|
|
71
53
|
partialHelp[groupName] = partialHelp[groupName] || {
|
|
72
54
|
commands: {},
|
|
73
55
|
description: groups[groupName] || (0, _lodash().capitalize)(command.group)
|
|
@@ -78,11 +60,9 @@ function groupCommands(commands, groups) {
|
|
|
78
60
|
}, {});
|
|
79
61
|
return help;
|
|
80
62
|
}
|
|
81
|
-
|
|
82
63
|
function formatCommandsHelp(helpProps) {
|
|
83
64
|
return Object.keys(helpProps).map(groupName => commandsSectionTemplate(helpProps[groupName])).join('\n\n');
|
|
84
65
|
}
|
|
85
|
-
|
|
86
66
|
function commandsSectionTemplate(section) {
|
|
87
67
|
const titleSpace = SPACE.repeat(TITLE_LEFT_SPACES_NUMBER);
|
|
88
68
|
const title = `${titleSpace}${_chalk().default.underline.bold.blue(section.description)}`;
|
|
@@ -90,20 +70,17 @@ function commandsSectionTemplate(section) {
|
|
|
90
70
|
const res = `${title}\n${commands}`;
|
|
91
71
|
return res;
|
|
92
72
|
}
|
|
93
|
-
|
|
94
73
|
function commandTemplate(name, description) {
|
|
95
74
|
const nameSpace = SPACE.repeat(COMMAND_LEFT_SPACES_NUMBER);
|
|
96
75
|
const nameWithRightSpace = (0, _padRight().default)(name, NAME_WITH_SPACES_LENGTH, SPACE);
|
|
97
76
|
const res = `${nameSpace}${_chalk().default.green(nameWithRightSpace)}${description}`;
|
|
98
77
|
return res;
|
|
99
78
|
}
|
|
100
|
-
|
|
101
79
|
function getHeader(docsDomain) {
|
|
102
80
|
return `${_chalk().default.bold('usage: bit [--version] [--help] <command> [<args>]')}
|
|
103
81
|
|
|
104
82
|
${_chalk().default.yellow(`bit documentation: https://${docsDomain}`)}`;
|
|
105
83
|
}
|
|
106
|
-
|
|
107
84
|
function getFooter() {
|
|
108
85
|
return `${_chalk().default.yellow("please use 'bit <command> --help' for more information and guides on specific commands.")}`;
|
|
109
86
|
}
|
package/dist/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SPACE","TITLE_LEFT_SPACES_NUMBER","COMMAND_LEFT_SPACES_NUMBER","NAME_WITH_SPACES_LENGTH","formatHelp","commands","groups","docsDomain","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 { GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { 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 = 15;\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, docsDomain: string) {\n const helpProps = groupCommands(commands, groups);\n const commandsStr = formatCommandsHelp(helpProps);\n\n return `${getHeader(docsDomain)}\n\n${commandsStr}\n\n${getFooter()}`;\n}\n\nfunction groupCommands(commands: CommandList, groups: GroupsType): HelpProps {\n const help: HelpProps = commands\n .filter((command) => !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(docsDomain: string): string {\n return `${chalk.bold('usage: bit [--version] [--help] <command> [<args>]')}\n\n${chalk.yellow(`bit documentation: https://${docsDomain}`)}`;\n}\n\nfunction getFooter(): string {\n return `${chalk.yellow(\"please use 'bit <command> --help' for more information and guides on specific commands.\")}`;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["SPACE","TITLE_LEFT_SPACES_NUMBER","COMMAND_LEFT_SPACES_NUMBER","NAME_WITH_SPACES_LENGTH","formatHelp","commands","groups","docsDomain","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 { GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { 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 = 15;\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, docsDomain: string) {\n const helpProps = groupCommands(commands, groups);\n const commandsStr = formatCommandsHelp(helpProps);\n\n return `${getHeader(docsDomain)}\n\n${commandsStr}\n\n${getFooter()}`;\n}\n\nfunction groupCommands(commands: CommandList, groups: GroupsType): HelpProps {\n const help: HelpProps = commands\n .filter((command) => !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(docsDomain: string): string {\n return `${chalk.bold('usage: bit [--version] [--help] <command> [<args>]')}\n\n${chalk.yellow(`bit documentation: https://${docsDomain}`)}`;\n}\n\nfunction getFooter(): string {\n return `${chalk.yellow(\"please use 'bit <command> --help' for more information and guides on specific commands.\")}`;\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA,MAAMA,KAAK,GAAG,GAAG;AACjB,MAAMC,wBAAwB,GAAG,CAAC;AAClC,MAAMC,0BAA0B,GAAG,CAAC;AACpC,MAAMC,uBAAuB,GAAG,EAAE;AAW3B,SAASC,UAAU,CAACC,QAAqB,EAAEC,MAAkB,EAAEC,UAAkB,EAAE;EACxF,MAAMC,SAAS,GAAGC,aAAa,CAACJ,QAAQ,EAAEC,MAAM,CAAC;EACjD,MAAMI,WAAW,GAAGC,kBAAkB,CAACH,SAAS,CAAC;EAEjD,OAAQ,GAAEI,SAAS,CAACL,UAAU,CAA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AW,CAAE,EAAC;EAC9E,MAAMb,QAAQ,GAAGsB,MAAM,CAACC,IAAI,CAACI,OAAO,CAAC3B,QAAQ,CAAC,CAC3CwB,GAAG,CAAEW,OAAO,IAAKC,eAAe,CAACD,OAAO,EAAER,OAAO,CAAC3B,QAAQ,CAACmC,OAAO,CAAC,CAAC,CAAC,CACrET,IAAI,CAAC,IAAI,CAAC;EACb,MAAMW,GAAG,GAAI,GAAEP,KAAM,KAAI9B,QAAS,EAAC;EACnC,OAAOqC,GAAG;AACZ;AAEA,SAASD,eAAe,CAACf,IAAY,EAAER,WAAmB,EAAU;EAClE,MAAMyB,SAAS,GAAG3C,KAAK,CAACkC,MAAM,CAAChC,0BAA0B,CAAC;EAC1D,MAAM0C,kBAAkB,GAAG,IAAAC,mBAAQ,EAACnB,IAAI,EAAEvB,uBAAuB,EAAEH,KAAK,CAAC;EACzE,MAAM0C,GAAG,GAAI,GAAEC,SAAU,GAAEP,gBAAK,CAACU,KAAK,CAACF,kBAAkB,CAAE,GAAE1B,WAAY,EAAC;EAC1E,OAAOwB,GAAG;AACZ;AAEA,SAAS9B,SAAS,CAACL,UAAkB,EAAU;EAC7C,OAAQ,GAAE6B,gBAAK,CAACE,IAAI,CAAC,oDAAoD,CAAE;AAC7E;AACA,EAAEF,gBAAK,CAACW,MAAM,CAAE,8BAA6BxC,UAAW,EAAC,CAAE,EAAC;AAC5D;AAEA,SAASM,SAAS,GAAW;EAC3B,OAAQ,GAAEuB,gBAAK,CAACW,MAAM,CAAC,yFAAyF,CAAE,EAAC;AACrH"}
|
package/dist/index.js
CHANGED
|
@@ -54,29 +54,21 @@ Object.defineProperty(exports, "MainRuntime", {
|
|
|
54
54
|
return _cli().MainRuntime;
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
-
|
|
58
57
|
function _command() {
|
|
59
58
|
const data = require("@teambit/legacy/dist/cli/command");
|
|
60
|
-
|
|
61
59
|
_command = function () {
|
|
62
60
|
return data;
|
|
63
61
|
};
|
|
64
|
-
|
|
65
62
|
return data;
|
|
66
63
|
}
|
|
67
|
-
|
|
68
64
|
function _legacyCommand() {
|
|
69
65
|
const data = require("@teambit/legacy/dist/cli/legacy-command");
|
|
70
|
-
|
|
71
66
|
_legacyCommand = function () {
|
|
72
67
|
return data;
|
|
73
68
|
};
|
|
74
|
-
|
|
75
69
|
return data;
|
|
76
70
|
}
|
|
77
|
-
|
|
78
71
|
var _exceptions = require("./exceptions");
|
|
79
|
-
|
|
80
72
|
Object.keys(_exceptions).forEach(function (key) {
|
|
81
73
|
if (key === "default" || key === "__esModule") return;
|
|
82
74
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -88,14 +80,11 @@ Object.keys(_exceptions).forEach(function (key) {
|
|
|
88
80
|
}
|
|
89
81
|
});
|
|
90
82
|
});
|
|
91
|
-
|
|
92
83
|
function _cli() {
|
|
93
84
|
const data = require("./cli.aspect");
|
|
94
|
-
|
|
95
85
|
_cli = function () {
|
|
96
86
|
return data;
|
|
97
87
|
};
|
|
98
|
-
|
|
99
88
|
return data;
|
|
100
89
|
}
|
|
101
90
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type { CLIMain, CommandList, CommandsSlot } from './cli.main.runtime';\nexport { Command, CLIArgs, Flags, GenericObject } from '@teambit/legacy/dist/cli/command';\nexport { CommandOptions } from '@teambit/legacy/dist/cli/legacy-command';\nexport * from './exceptions';\nexport { CLIAspect, MainRuntime } from './cli.aspect';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type { CLIMain, CommandList, CommandsSlot } from './cli.main.runtime';\nexport { Command, CLIArgs, Flags, GenericObject } from '@teambit/legacy/dist/cli/command';\nexport { CommandOptions } from '@teambit/legacy/dist/cli/legacy-command';\nexport * from './exceptions';\nexport { CLIAspect, MainRuntime } from './cli.aspect';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
|
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.symbol.description.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.promise.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.LegacyCommandAdapter = void 0;
|
|
13
|
-
|
|
14
10
|
function _defineProperty2() {
|
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
|
|
17
12
|
_defineProperty2 = function () {
|
|
18
13
|
return data;
|
|
19
14
|
};
|
|
20
|
-
|
|
21
15
|
return data;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
class LegacyCommandAdapter {
|
|
25
18
|
constructor(cmd, cliExtension) {
|
|
26
19
|
this.cmd = cmd;
|
|
@@ -52,24 +45,20 @@ class LegacyCommandAdapter {
|
|
|
52
45
|
this.internal = cmd.internal;
|
|
53
46
|
this.commands = (cmd.commands || []).map(sub => new LegacyCommandAdapter(sub, cliExtension));
|
|
54
47
|
}
|
|
55
|
-
|
|
56
48
|
async action(params, options) {
|
|
57
49
|
const res = await this.cmd.action(params, options, this._packageManagerArgs);
|
|
58
50
|
let data = res;
|
|
59
51
|
let code = 0;
|
|
60
|
-
|
|
61
52
|
if (res && res.__code !== undefined) {
|
|
62
53
|
data = res.data;
|
|
63
54
|
code = res.__code;
|
|
64
55
|
}
|
|
65
|
-
|
|
66
56
|
const report = this.cmd.report(data, params, options);
|
|
67
57
|
return {
|
|
68
58
|
code,
|
|
69
59
|
report
|
|
70
60
|
};
|
|
71
61
|
}
|
|
72
|
-
|
|
73
62
|
async report(params, options) {
|
|
74
63
|
const actionResult = await this.action(params, options);
|
|
75
64
|
return {
|
|
@@ -77,7 +66,6 @@ class LegacyCommandAdapter {
|
|
|
77
66
|
code: actionResult.code
|
|
78
67
|
};
|
|
79
68
|
}
|
|
80
|
-
|
|
81
69
|
async json(params, options) {
|
|
82
70
|
const actionResult = await this.action(params, options);
|
|
83
71
|
return {
|
|
@@ -85,9 +73,7 @@ class LegacyCommandAdapter {
|
|
|
85
73
|
code: actionResult.code
|
|
86
74
|
};
|
|
87
75
|
}
|
|
88
|
-
|
|
89
76
|
}
|
|
90
|
-
|
|
91
77
|
exports.LegacyCommandAdapter = LegacyCommandAdapter;
|
|
92
78
|
|
|
93
79
|
//# sourceMappingURL=legacy-command-adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LegacyCommandAdapter","constructor","cmd","cliExtension","name","description","helpUrl","options","opts","alias","extendedDescription","skipWorkspace","group","loader","private","migration","internal","commands","map","sub","action","params","res","_packageManagerArgs","data","code","__code","undefined","report","actionResult","json","JSON","parse"],"sources":["legacy-command-adapter.ts"],"sourcesContent":["import { LegacyCommand } from '@teambit/legacy/dist/cli/legacy-command';\nimport { Command, CommandOptions, GenericObject } from '.';\nimport { CLIMain } from './cli.main.runtime';\n\nexport class LegacyCommandAdapter implements Command {\n alias: string;\n name: string;\n description: string;\n options: CommandOptions;\n extendedDescription?: string;\n group?: string;\n loader?: boolean;\n commands: Command[];\n private?: boolean;\n migration?: boolean;\n internal?: boolean;\n skipWorkspace?: boolean;\n helpUrl?: string;\n _packageManagerArgs?: string[];\n constructor(private cmd: LegacyCommand, cliExtension: CLIMain) {\n this.name = cmd.name;\n this.description = cmd.description;\n this.helpUrl = cmd.helpUrl;\n this.options = cmd.opts || [];\n this.alias = cmd.alias;\n this.extendedDescription = cmd.extendedDescription;\n this.skipWorkspace = cmd.skipWorkspace;\n this.group = cmd.group;\n this.loader = cmd.loader;\n this.private = cmd.private;\n this.migration = cmd.migration;\n this.internal = cmd.internal;\n this.commands = (cmd.commands || []).map((sub) => new LegacyCommandAdapter(sub, cliExtension));\n }\n\n private async action(params: any, options: { [key: string]: any }): Promise<ActionResult> {\n const res = await this.cmd.action(params, options, this._packageManagerArgs);\n let data = res;\n let code = 0;\n if (res && res.__code !== undefined) {\n data = res.data;\n code = res.__code;\n }\n const report = this.cmd.report(data, params, options);\n return {\n code,\n report,\n };\n }\n\n async report(params: any, options: { [key: string]: any }): Promise<{ data: string; code: number }> {\n const actionResult = await this.action(params, options);\n return { data: actionResult.report, code: actionResult.code };\n }\n\n async json(params: any, options: { [key: string]: any }): Promise<GenericObject> {\n const actionResult = await this.action(params, options);\n return {\n data: JSON.parse(actionResult.report),\n code: actionResult.code,\n };\n }\n}\n\ntype ActionResult = {\n code: number;\n report: string;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["LegacyCommandAdapter","constructor","cmd","cliExtension","name","description","helpUrl","options","opts","alias","extendedDescription","skipWorkspace","group","loader","private","migration","internal","commands","map","sub","action","params","res","_packageManagerArgs","data","code","__code","undefined","report","actionResult","json","JSON","parse"],"sources":["legacy-command-adapter.ts"],"sourcesContent":["import { LegacyCommand } from '@teambit/legacy/dist/cli/legacy-command';\nimport { Command, CommandOptions, GenericObject } from '.';\nimport { CLIMain } from './cli.main.runtime';\n\nexport class LegacyCommandAdapter implements Command {\n alias: string;\n name: string;\n description: string;\n options: CommandOptions;\n extendedDescription?: string;\n group?: string;\n loader?: boolean;\n commands: Command[];\n private?: boolean;\n migration?: boolean;\n internal?: boolean;\n skipWorkspace?: boolean;\n helpUrl?: string;\n _packageManagerArgs?: string[];\n constructor(private cmd: LegacyCommand, cliExtension: CLIMain) {\n this.name = cmd.name;\n this.description = cmd.description;\n this.helpUrl = cmd.helpUrl;\n this.options = cmd.opts || [];\n this.alias = cmd.alias;\n this.extendedDescription = cmd.extendedDescription;\n this.skipWorkspace = cmd.skipWorkspace;\n this.group = cmd.group;\n this.loader = cmd.loader;\n this.private = cmd.private;\n this.migration = cmd.migration;\n this.internal = cmd.internal;\n this.commands = (cmd.commands || []).map((sub) => new LegacyCommandAdapter(sub, cliExtension));\n }\n\n private async action(params: any, options: { [key: string]: any }): Promise<ActionResult> {\n const res = await this.cmd.action(params, options, this._packageManagerArgs);\n let data = res;\n let code = 0;\n if (res && res.__code !== undefined) {\n data = res.data;\n code = res.__code;\n }\n const report = this.cmd.report(data, params, options);\n return {\n code,\n report,\n };\n }\n\n async report(params: any, options: { [key: string]: any }): Promise<{ data: string; code: number }> {\n const actionResult = await this.action(params, options);\n return { data: actionResult.report, code: actionResult.code };\n }\n\n async json(params: any, options: { [key: string]: any }): Promise<GenericObject> {\n const actionResult = await this.action(params, options);\n return {\n data: JSON.parse(actionResult.report),\n code: actionResult.code,\n };\n }\n}\n\ntype ActionResult = {\n code: number;\n report: string;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAIO,MAAMA,oBAAoB,CAAoB;EAenDC,WAAW,CAASC,GAAkB,EAAEC,YAAqB,EAAE;IAAA,KAA3CD,GAAkB,GAAlBA,GAAkB;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IACpC,IAAI,CAACE,IAAI,GAAGF,GAAG,CAACE,IAAI;IACpB,IAAI,CAACC,WAAW,GAAGH,GAAG,CAACG,WAAW;IAClC,IAAI,CAACC,OAAO,GAAGJ,GAAG,CAACI,OAAO;IAC1B,IAAI,CAACC,OAAO,GAAGL,GAAG,CAACM,IAAI,IAAI,EAAE;IAC7B,IAAI,CAACC,KAAK,GAAGP,GAAG,CAACO,KAAK;IACtB,IAAI,CAACC,mBAAmB,GAAGR,GAAG,CAACQ,mBAAmB;IACl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C/D;EAEA,MAAMK,IAAI,CAACT,MAAW,EAAEd,OAA+B,EAA0B;IAC/E,MAAMsB,YAAY,GAAG,MAAM,IAAI,CAACT,MAAM,CAACC,MAAM,EAAEd,OAAO,CAAC;IACvD,OAAO;MACLiB,IAAI,EAAEO,IAAI,CAACC,KAAK,CAACH,YAAY,CAACD,MAAM,CAAC;MACrCH,IAAI,EAAEI,YAAY,CAACJ;IACrB,CAAC;EACH;AACF;AAAC"}
|
package/dist/yargs-adapter.js
CHANGED
|
@@ -1,69 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.symbol.description.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.array.iterator.js");
|
|
8
|
-
|
|
9
6
|
require("core-js/modules/es.regexp.exec.js");
|
|
10
|
-
|
|
11
7
|
require("core-js/modules/es.string.trim.js");
|
|
12
|
-
|
|
13
8
|
Object.defineProperty(exports, "__esModule", {
|
|
14
9
|
value: true
|
|
15
10
|
});
|
|
16
11
|
exports.YargsAdapter = exports.STANDARD_GROUP = exports.GLOBAL_GROUP = void 0;
|
|
17
|
-
|
|
18
12
|
function _defineProperty2() {
|
|
19
13
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
20
|
-
|
|
21
14
|
_defineProperty2 = function () {
|
|
22
15
|
return data;
|
|
23
16
|
};
|
|
24
|
-
|
|
25
17
|
return data;
|
|
26
18
|
}
|
|
27
|
-
|
|
28
19
|
function _constants() {
|
|
29
20
|
const data = require("@teambit/legacy/dist/constants");
|
|
30
|
-
|
|
31
21
|
_constants = function () {
|
|
32
22
|
return data;
|
|
33
23
|
};
|
|
34
|
-
|
|
35
24
|
return data;
|
|
36
25
|
}
|
|
37
|
-
|
|
38
26
|
function _lodash() {
|
|
39
27
|
const data = require("lodash");
|
|
40
|
-
|
|
41
28
|
_lodash = function () {
|
|
42
29
|
return data;
|
|
43
30
|
};
|
|
44
|
-
|
|
45
31
|
return data;
|
|
46
32
|
}
|
|
47
|
-
|
|
48
33
|
function _commandRunner() {
|
|
49
34
|
const data = require("./command-runner");
|
|
50
|
-
|
|
51
35
|
_commandRunner = function () {
|
|
52
36
|
return data;
|
|
53
37
|
};
|
|
54
|
-
|
|
55
38
|
return data;
|
|
56
39
|
}
|
|
57
|
-
|
|
58
40
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
59
|
-
|
|
60
41
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
61
|
-
|
|
62
42
|
const GLOBAL_GROUP = 'Global';
|
|
63
43
|
exports.GLOBAL_GROUP = GLOBAL_GROUP;
|
|
64
44
|
const STANDARD_GROUP = 'Options';
|
|
65
45
|
exports.STANDARD_GROUP = STANDARD_GROUP;
|
|
66
|
-
|
|
67
46
|
class YargsAdapter {
|
|
68
47
|
constructor(commanderCommand) {
|
|
69
48
|
this.commanderCommand = commanderCommand;
|
|
@@ -74,10 +53,8 @@ class YargsAdapter {
|
|
|
74
53
|
this.describe = commanderCommand.description;
|
|
75
54
|
this.aliases = commanderCommand.alias;
|
|
76
55
|
}
|
|
77
|
-
|
|
78
56
|
builder(yargs) {
|
|
79
57
|
var _this$commanderComman, _this$commanderComman2;
|
|
80
|
-
|
|
81
58
|
const options = YargsAdapter.optionsToBuilder(this.commanderCommand);
|
|
82
59
|
yargs.option(options);
|
|
83
60
|
(_this$commanderComman = this.commanderCommand.arguments) === null || _this$commanderComman === void 0 ? void 0 : _this$commanderComman.forEach(arg => {
|
|
@@ -90,14 +67,13 @@ class YargsAdapter {
|
|
|
90
67
|
});
|
|
91
68
|
return yargs;
|
|
92
69
|
}
|
|
93
|
-
|
|
94
70
|
handler(argv) {
|
|
95
71
|
const enteredArgs = getArgsFromCommandName(this.commanderCommand.name);
|
|
96
|
-
const argsValues = enteredArgs.map(a => argv[a]);
|
|
97
|
-
|
|
72
|
+
const argsValues = enteredArgs.map(a => argv[a]);
|
|
73
|
+
// a workaround to get a flag syntax such as "--all [version]" work with yargs.
|
|
98
74
|
const flags = Object.keys(argv).reduce((acc, current) => {
|
|
99
|
-
if (current === '_' || current === '$0' || current === '--') return acc;
|
|
100
|
-
|
|
75
|
+
if (current === '_' || current === '$0' || current === '--') return acc;
|
|
76
|
+
// const flagName = current.split(' ')[0];
|
|
101
77
|
const val = typeof argv[current] === 'string' && !argv[current] ? true : argv[current];
|
|
102
78
|
acc[current] = val;
|
|
103
79
|
return acc;
|
|
@@ -106,11 +82,9 @@ class YargsAdapter {
|
|
|
106
82
|
const commandRunner = new (_commandRunner().CommandRunner)(this.commanderCommand, argsValues, flags);
|
|
107
83
|
return commandRunner.runCommand();
|
|
108
84
|
}
|
|
109
|
-
|
|
110
85
|
get positional() {
|
|
111
86
|
return this.commanderCommand.arguments;
|
|
112
87
|
}
|
|
113
|
-
|
|
114
88
|
static optionsToBuilder(command) {
|
|
115
89
|
const option = command.options.reduce((acc, [alias, opt, desc]) => {
|
|
116
90
|
const optName = opt.split(' ')[0];
|
|
@@ -126,17 +100,14 @@ class YargsAdapter {
|
|
|
126
100
|
const globalOptions = YargsAdapter.getGlobalOptions(command);
|
|
127
101
|
return _objectSpread(_objectSpread({}, option), globalOptions);
|
|
128
102
|
}
|
|
129
|
-
|
|
130
103
|
static getGlobalOptions(command) {
|
|
131
104
|
const globalOptions = {};
|
|
132
|
-
|
|
133
105
|
if (command.remoteOp) {
|
|
134
106
|
globalOptions[_constants().TOKEN_FLAG] = {
|
|
135
107
|
describe: 'authentication token',
|
|
136
108
|
group: GLOBAL_GROUP
|
|
137
109
|
};
|
|
138
110
|
}
|
|
139
|
-
|
|
140
111
|
if (!command.internal) {
|
|
141
112
|
globalOptions.log = {
|
|
142
113
|
describe: 'print log messages to the screen, options are: [trace, debug, info, warn, error, fatal], the default is info',
|
|
@@ -147,26 +118,20 @@ class YargsAdapter {
|
|
|
147
118
|
group: GLOBAL_GROUP
|
|
148
119
|
};
|
|
149
120
|
}
|
|
150
|
-
|
|
151
121
|
return globalOptions;
|
|
152
122
|
}
|
|
153
|
-
|
|
154
123
|
}
|
|
155
|
-
|
|
156
124
|
exports.YargsAdapter = YargsAdapter;
|
|
157
|
-
|
|
158
125
|
function getArgsFromCommandName(commandName) {
|
|
159
126
|
const commandSplit = commandName.split(' ');
|
|
160
127
|
commandSplit.shift(); // remove the first element, it's the command-name
|
|
161
128
|
|
|
162
129
|
return commandSplit.map(existArg => {
|
|
163
130
|
const trimmed = existArg.trim();
|
|
164
|
-
|
|
165
131
|
if (!trimmed.startsWith('<') && !trimmed.startsWith('[') || !trimmed.endsWith('>') && !trimmed.endsWith(']')) {
|
|
166
132
|
throw new Error(`expect arg "${trimmed}" of "${commandName}" to be wrapped with "[]" or "<>"`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
133
|
+
}
|
|
134
|
+
// remove the opening and closing brackets
|
|
170
135
|
const withoutBrackets = trimmed.slice(1, -1);
|
|
171
136
|
return (0, _lodash().camelCase)(withoutBrackets);
|
|
172
137
|
});
|