@teambit/cli 0.0.772 → 0.0.773
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 +5 -13
- package/dist/cli-parser.js.map +1 -1
- package/dist/cli.cmd.js +17 -26
- package/dist/cli.cmd.js.map +1 -1
- package/dist/cli.composition.js +1 -1
- package/dist/cli.composition.js.map +1 -1
- package/dist/cli.main.runtime.js +8 -18
- package/dist/cli.main.runtime.js.map +1 -1
- package/dist/command-runner.js +5 -11
- package/dist/command-runner.js.map +1 -1
- package/dist/completion.cmd.js +8 -13
- package/dist/completion.cmd.js.map +1 -1
- package/dist/exceptions/command-not-found.js +6 -10
- package/dist/exceptions/command-not-found.js.map +1 -1
- package/dist/generate-doc-md.js +0 -4
- package/dist/generate-doc-md.js.map +1 -1
- package/dist/get-command-id.js +0 -2
- package/dist/get-command-id.js.map +1 -1
- package/dist/help.cmd.js +9 -15
- package/dist/help.cmd.js.map +1 -1
- package/dist/help.js +1 -2
- package/dist/help.js.map +1 -1
- package/dist/legacy-command-adapter.js +17 -24
- package/dist/legacy-command-adapter.js.map +1 -1
- package/dist/{preview-1694575035715.js → preview-1694624356552.js} +2 -2
- package/dist/yargs-adapter.js +7 -16
- package/dist/yargs-adapter.js.map +1 -1
- package/package.json +4 -6
package/dist/cli-parser.js
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.array.iterator.js");
|
|
5
|
-
require("core-js/modules/es.promise.js");
|
|
6
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
7
|
-
require("core-js/modules/es.string.replace.js");
|
|
8
3
|
Object.defineProperty(exports, "__esModule", {
|
|
9
4
|
value: true
|
|
10
5
|
});
|
|
11
6
|
exports.CLIParser = void 0;
|
|
12
|
-
function _defineProperty2() {
|
|
13
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
_defineProperty2 = function () {
|
|
15
|
-
return data;
|
|
16
|
-
};
|
|
17
|
-
return data;
|
|
18
|
-
}
|
|
19
7
|
function _didyoumean() {
|
|
20
8
|
const data = _interopRequireDefault(require("didyoumean"));
|
|
21
9
|
_didyoumean = function () {
|
|
@@ -93,11 +81,15 @@ function _commandNotFound() {
|
|
|
93
81
|
};
|
|
94
82
|
return data;
|
|
95
83
|
}
|
|
84
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
85
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
86
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
87
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
96
88
|
class CLIParser {
|
|
97
89
|
constructor(commands, groups) {
|
|
98
90
|
this.commands = commands;
|
|
99
91
|
this.groups = groups;
|
|
100
|
-
(
|
|
92
|
+
_defineProperty(this, "parser", _yargs().default);
|
|
101
93
|
}
|
|
102
94
|
async parse(args = process.argv.slice(2)) {
|
|
103
95
|
this.throwForNonExistsCommand(args[0]);
|
package/dist/cli-parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_didyoumean","data","_interopRequireDefault","require","_yargs","_lodash","_consumer","_logger","_loader","_chalk","_getCommandId","_help","_yargsAdapter","_commandNotFound","CLIParser","constructor","commands","groups","_defineProperty2","default","yargs","parse","args","process","argv","slice","throwForNonExistsCommand","logger","debug","join","help","configureParser","forEach","command","length","parseCommandWithSubCommands","yargsCommand","getYargsCommand","configureGlobalFlags","setHelpMiddleware","handleCommandFailure","configureCompletion","strict","wrap","middleware","_","shouldShowInternalCommands","Boolean","internal","printHelp","exit","loader","off","showHelp","logCommandHelp","bind","isDaemon","fail","msg","err","stop","isHelpFlagEntered","includes","isMsgAboutMissingArgs","startsWith","console","log","chalk","yellow","commandsToShowComponentIdsForCompletion","completion","current","completionFilter","done","consumer","loadConsumerIfExist","bitmapIdsFromCurrentLane","map","id","toStringWithoutVersion","formatHelp","parserConfiguration","yarnCommand","builderFunc","_command$commands","cmd","subCommand","options","YargsAdapter","getGlobalOptions","builder","handler","option","alias","describe","group","GLOBAL_GROUP","global","commandName","commandsNames","c","getCommandId","name","aliases","filter","a","existingGlobalFlags","validCommands","commandExist","didYouMean","returnFirstMatch","suggestions","private","suggestion","Array","isArray","CommandNotFound","findCommandByArgv","replacer","p1","p2","green","lines","split","linesWithoutEmpty","compact","cmdLine","description","globalOptions","subCommands","examples","optionsStarted","globalStarted","subCommandsStarted","positionalsStarted","examplesStarted","i","currentLine","STANDARD_GROUP","push","optionsColored","opt","replace","argsColored","arg","argName","optionsStr","argumentsStr","examplesStr","subCommandsStr","descriptionColored","desc","bold","extendedDescription","helpUrl","underline","descriptionStr","globalOptionsStr","finalOutput","enteredCommand","enteredSubCommand","undefined","isCommandMatch","str","find","exports"],"sources":["cli-parser.ts"],"sourcesContent":["import didYouMean from 'didyoumean';\nimport yargs from 'yargs';\nimport { Command } from '@teambit/legacy/dist/cli/command';\nimport { GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { compact } from 'lodash';\nimport { loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport chalk from 'chalk';\nimport { getCommandId } from './get-command-id';\nimport { formatHelp } from './help';\nimport { GLOBAL_GROUP, STANDARD_GROUP, YargsAdapter } from './yargs-adapter';\nimport { CommandNotFound } from './exceptions/command-not-found';\n\nexport class CLIParser {\n public parser = yargs;\n constructor(private commands: Command[], private groups: GroupsType) {}\n\n async parse(args = process.argv.slice(2)) {\n this.throwForNonExistsCommand(args[0]);\n logger.debug(`[+] CLI-INPUT: ${args.join(' ')}`);\n yargs(args);\n yargs.help(false);\n this.configureParser();\n this.commands.forEach((command: Command) => {\n if (command.commands && command.commands.length) {\n this.parseCommandWithSubCommands(command);\n } else {\n const yargsCommand = this.getYargsCommand(command);\n yargs.command(yargsCommand);\n }\n });\n this.configureGlobalFlags();\n this.setHelpMiddleware();\n this.handleCommandFailure();\n this.configureCompletion();\n yargs.strict(); // don't allow non-exist flags and non-exist commands\n\n yargs\n // .recommendCommands() // don't use it, it brings the global help of yargs, we have a custom one\n .wrap(null);\n\n await yargs.parse();\n }\n\n private setHelpMiddleware() {\n yargs.middleware((argv) => {\n if (argv._.length === 0 && argv.help) {\n const shouldShowInternalCommands = Boolean(argv.internal);\n // this is the main help page\n this.printHelp(shouldShowInternalCommands);\n process.exit(0);\n }\n if (argv.help) {\n loader.off(); // stop the \"loading bit...\" before showing help if needed\n // this is a command help page\n yargs.showHelp(this.logCommandHelp.bind(this));\n if (!logger.isDaemon) process.exit(0);\n }\n }, true);\n }\n\n private handleCommandFailure() {\n yargs.fail((msg, err) => {\n loader.stop();\n if (err) {\n throw err;\n }\n yargs.showHelp(this.logCommandHelp.bind(this));\n const args = process.argv.slice(2);\n const isHelpFlagEntered = args.includes('--help') || args.includes('-h');\n const isMsgAboutMissingArgs = msg.startsWith('Not enough non-option arguments');\n // avoid showing the \"Not enough non-option arguments\" message when the user is trying to get the command help\n if (!isMsgAboutMissingArgs || !isHelpFlagEntered) {\n // eslint-disable-next-line no-console\n console.log(`\\n${chalk.yellow(msg)}`);\n }\n if (!logger.isDaemon) process.exit(1);\n });\n }\n\n private configureCompletion() {\n const commandsToShowComponentIdsForCompletion = [\n 'show',\n 'diff',\n 'tag',\n 'export',\n 'env',\n 'envs',\n 'compile',\n 'build',\n 'test',\n 'lint',\n 'log',\n 'dependents',\n 'dependencies',\n ];\n // @ts-ignore\n yargs.completion('completion', async function (current, argv, completionFilter, done) {\n if (!current.startsWith('-') && commandsToShowComponentIdsForCompletion.includes(argv._[1])) {\n const consumer = await loadConsumerIfExist();\n done(consumer?.bitmapIdsFromCurrentLane.map((id) => id.toStringWithoutVersion()));\n } else {\n completionFilter();\n }\n });\n }\n\n private printHelp(shouldShowInternalCommands = false) {\n const help = formatHelp(this.commands, this.groups, shouldShowInternalCommands);\n // eslint-disable-next-line no-console\n console.log(help);\n }\n\n private configureParser() {\n yargs.parserConfiguration({\n // 'strip-dashed': true, // we can't enable it, otherwise, the completion doesn't work\n 'strip-aliased': true,\n 'boolean-negation': false,\n 'populate--': true,\n });\n }\n\n private parseCommandWithSubCommands(command: Command) {\n const yarnCommand = this.getYargsCommand(command);\n const builderFunc = () => {\n command.commands?.forEach((cmd) => {\n const subCommand = this.getYargsCommand(cmd);\n yargs.command(subCommand);\n });\n // since the \"builder\" method is overridden, the global flags of the main command are gone, this fixes it.\n yargs.options(YargsAdapter.getGlobalOptions(command));\n return yargs;\n };\n yarnCommand.builder = builderFunc;\n yargs.command(yarnCommand);\n }\n\n private getYargsCommand(command: Command): YargsAdapter {\n const yarnCommand = new YargsAdapter(command);\n yarnCommand.builder = yarnCommand.builder.bind(yarnCommand);\n yarnCommand.handler = yarnCommand.handler.bind(yarnCommand);\n\n return yarnCommand;\n }\n\n private configureGlobalFlags() {\n yargs\n .option('help', {\n alias: 'h',\n describe: 'show help',\n group: GLOBAL_GROUP,\n })\n .option('version', {\n global: false,\n alias: 'v',\n describe: 'show version',\n group: GLOBAL_GROUP,\n });\n }\n\n private throwForNonExistsCommand(commandName: string) {\n if (!commandName || commandName.startsWith('-')) {\n return;\n }\n const commandsNames = this.commands.map((c) => getCommandId(c.name));\n const aliases = this.commands.map((c) => c.alias).filter((a) => a);\n const existingGlobalFlags = ['-V', '--version'];\n const validCommands = [...commandsNames, ...aliases, ...existingGlobalFlags];\n const commandExist = validCommands.includes(commandName);\n\n if (!commandExist) {\n didYouMean.returnFirstMatch = true;\n const suggestions = didYouMean(\n commandName,\n this.commands.filter((c) => !c.private).map((c) => getCommandId(c.name))\n );\n const suggestion = suggestions && Array.isArray(suggestions) ? suggestions[0] : suggestions;\n\n throw new CommandNotFound(commandName, suggestion as string);\n }\n }\n\n /**\n * manipulate the command help output. there is no API from Yarn to do any of this, so it needs to be done manually.\n * see https://github.com/yargs/yargs/issues/1956\n *\n * the original order of the output:\n * description\n * Options\n * Commands\n * Global\n * Positionals\n * Examples\n */\n private logCommandHelp(help: string) {\n const command = this.findCommandByArgv();\n\n const replacer = (_, p1, p2) => `${p1}${chalk.green(p2)}`;\n const lines = help.split('\\n');\n const linesWithoutEmpty = compact(lines);\n const cmdLine = linesWithoutEmpty[0];\n const description: string[] = [];\n const options: string[] = [];\n const globalOptions: string[] = [];\n const subCommands: string[] = [];\n const args: string[] = [];\n const examples: string[] = [];\n\n let optionsStarted = false;\n let globalStarted = false;\n let subCommandsStarted = false;\n let positionalsStarted = false;\n let examplesStarted = false;\n for (let i = 1; i < linesWithoutEmpty.length; i += 1) {\n const currentLine = linesWithoutEmpty[i];\n if (currentLine === STANDARD_GROUP) {\n optionsStarted = true;\n } else if (currentLine === GLOBAL_GROUP) {\n globalStarted = true;\n } else if (currentLine === 'Commands:') {\n subCommandsStarted = true;\n } else if (currentLine === 'Positionals:') {\n positionalsStarted = true;\n } else if (currentLine === 'Examples:') {\n examplesStarted = true;\n } else if (examplesStarted) {\n examples.push(currentLine);\n } else if (positionalsStarted) {\n args.push(currentLine);\n } else if (globalStarted) {\n globalOptions.push(currentLine);\n } else if (optionsStarted) {\n options.push(currentLine);\n } else if (subCommandsStarted) {\n subCommands.push(currentLine);\n } else {\n description.push(currentLine);\n }\n }\n\n // show the flags in green\n const optionsColored = options.map((opt) => opt.replace(/(--)([\\w-]+)/, replacer).replace(/(-)([\\w-]+)/, replacer));\n const argsColored = args.map((arg) => arg.replace(/^ {2}\\S+/, (argName) => chalk.green(argName))); // regex: two spaces then the first word until a white space\n const optionsStr = options.length ? `\\n${STANDARD_GROUP}\\n${optionsColored.join('\\n')}\\n` : '';\n const argumentsStr = args.length ? `\\nArguments:\\n${argsColored.join('\\n')}\\n` : '';\n const examplesStr = examples.length ? `\\nExamples:\\n${examples.join('\\n')}\\n` : '';\n const subCommandsStr = subCommands.length ? `\\n${'Commands:'}\\n${subCommands.join('\\n')}\\n` : '';\n // show the description in bold\n const descriptionColored = description.map((desc) => chalk.bold(desc));\n if (command?.extendedDescription) {\n descriptionColored.push(command?.extendedDescription);\n }\n if (command?.helpUrl) {\n descriptionColored.push(`for more info, visit: ${chalk.underline(command.helpUrl)}`);\n }\n const descriptionStr = descriptionColored.join('\\n');\n const globalOptionsStr = globalOptions.join('\\n');\n\n const finalOutput = `${cmdLine}\n\n${descriptionStr}\n${argumentsStr}${subCommandsStr}${optionsStr}${examplesStr}\n${GLOBAL_GROUP}\n${globalOptionsStr}`;\n\n // eslint-disable-next-line no-console\n console.log(finalOutput);\n }\n\n private findCommandByArgv(): Command | undefined {\n const args = process.argv.slice(2);\n const enteredCommand = args[0];\n const enteredSubCommand = args[1];\n if (!enteredCommand) {\n return undefined;\n }\n const isCommandMatch = (cmd: Command, str: string) => {\n return (\n cmd.name.startsWith(`${str} `) || // e.g. \"tag <id>\".startsWith(\"tag \")\n cmd.name === str || // e.g. \"globals\" === \"globals\"\n cmd.alias === str\n ); // e.g. \"t\" === \"t\"\n };\n const command = this.commands.find((cmd) => isCommandMatch(cmd, enteredCommand));\n if (!command) {\n return undefined;\n }\n if (!command.commands || !enteredSubCommand) {\n return command; // no sub-commands.\n }\n const subCommand = command.commands.find((cmd) => isCommandMatch(cmd, enteredSubCommand));\n return subCommand || command;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YA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BAAiB,EAAC;;IAEhB;IACA5F,OAAO,CAACC,GAAG,CAAC4F,WAAW,CAAC;EAC1B;EAEQzC,iBAAiBA,CAAA,EAAwB;IAC/C,MAAM/F,IAAI,GAAGC,OAAO,CAACC,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC;IAClC,MAAMsI,cAAc,GAAGzI,IAAI,CAAC,CAAC,CAAC;IAC9B,MAAM0I,iBAAiB,GAAG1I,IAAI,CAAC,CAAC,CAAC;IACjC,IAAI,CAACyI,cAAc,EAAE;MACnB,OAAOE,SAAS;IAClB;IACA,MAAMC,cAAc,GAAGA,CAAC7E,GAAY,EAAE8E,GAAW,KAAK;MACpD,OACE9E,GAAG,CAACiB,IAAI,CAACtC,UAAU,CAAE,GAAEmG,GAAI,GAAE,CAAC;MAAI;MAClC9E,GAAG,CAACiB,IAAI,KAAK6D,GAAG;MAAI;MACpB9E,GAAG,CAACQ,KAAK,KAAKsE,GAAG,CACjB,CAAC;IACL,CAAC;;IACD,MAAMlI,OAAO,GAAG,IAAI,CAACjB,QAAQ,CAACoJ,IAAI,CAAE/E,GAAG,IAAK6E,cAAc,CAAC7E,GAAG,EAAE0E,cAAc,CAAC,CAAC;IAChF,IAAI,CAAC9H,OAAO,EAAE;MACZ,OAAOgI,SAAS;IAClB;IACA,IAAI,CAAChI,OAAO,CAACjB,QAAQ,IAAI,CAACgJ,iBAAiB,EAAE;MAC3C,OAAO/H,OAAO,CAAC,CAAC;IAClB;;IACA,MAAMqD,UAAU,GAAGrD,OAAO,CAACjB,QAAQ,CAACoJ,IAAI,CAAE/E,GAAG,IAAK6E,cAAc,CAAC7E,GAAG,EAAE2E,iBAAiB,CAAC,CAAC;IACzF,OAAO1E,UAAU,IAAIrD,OAAO;EAC9B;AACF;AAACoI,OAAA,CAAAvJ,SAAA,GAAAA,SAAA"}
|
|
1
|
+
{"version":3,"names":["_didyoumean","data","_interopRequireDefault","require","_yargs","_lodash","_consumer","_logger","_loader","_chalk","_getCommandId","_help","_yargsAdapter","_commandNotFound","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","CLIParser","constructor","commands","groups","yargs","parse","args","process","argv","slice","throwForNonExistsCommand","logger","debug","join","help","configureParser","forEach","command","length","parseCommandWithSubCommands","yargsCommand","getYargsCommand","configureGlobalFlags","setHelpMiddleware","handleCommandFailure","configureCompletion","strict","wrap","middleware","_","shouldShowInternalCommands","Boolean","internal","printHelp","exit","loader","off","showHelp","logCommandHelp","bind","isDaemon","fail","msg","err","stop","isHelpFlagEntered","includes","isMsgAboutMissingArgs","startsWith","console","log","chalk","yellow","commandsToShowComponentIdsForCompletion","completion","current","completionFilter","done","consumer","loadConsumerIfExist","bitmapIdsFromCurrentLane","map","id","toStringWithoutVersion","formatHelp","parserConfiguration","yarnCommand","builderFunc","_command$commands","cmd","subCommand","options","YargsAdapter","getGlobalOptions","builder","handler","option","alias","describe","group","GLOBAL_GROUP","global","commandName","commandsNames","c","getCommandId","name","aliases","filter","a","existingGlobalFlags","validCommands","commandExist","didYouMean","returnFirstMatch","suggestions","private","suggestion","Array","isArray","CommandNotFound","findCommandByArgv","replacer","p1","p2","green","lines","split","linesWithoutEmpty","compact","cmdLine","description","globalOptions","subCommands","examples","optionsStarted","globalStarted","subCommandsStarted","positionalsStarted","examplesStarted","i","currentLine","STANDARD_GROUP","push","optionsColored","opt","replace","argsColored","argName","optionsStr","argumentsStr","examplesStr","subCommandsStr","descriptionColored","desc","bold","extendedDescription","helpUrl","underline","descriptionStr","globalOptionsStr","finalOutput","enteredCommand","enteredSubCommand","isCommandMatch","str","find","exports"],"sources":["cli-parser.ts"],"sourcesContent":["import didYouMean from 'didyoumean';\nimport yargs from 'yargs';\nimport { Command } from '@teambit/legacy/dist/cli/command';\nimport { GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { compact } from 'lodash';\nimport { loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport chalk from 'chalk';\nimport { getCommandId } from './get-command-id';\nimport { formatHelp } from './help';\nimport { GLOBAL_GROUP, STANDARD_GROUP, YargsAdapter } from './yargs-adapter';\nimport { CommandNotFound } from './exceptions/command-not-found';\n\nexport class CLIParser {\n public parser = yargs;\n constructor(private commands: Command[], private groups: GroupsType) {}\n\n async parse(args = process.argv.slice(2)) {\n this.throwForNonExistsCommand(args[0]);\n logger.debug(`[+] CLI-INPUT: ${args.join(' ')}`);\n yargs(args);\n yargs.help(false);\n this.configureParser();\n this.commands.forEach((command: Command) => {\n if (command.commands && command.commands.length) {\n this.parseCommandWithSubCommands(command);\n } else {\n const yargsCommand = this.getYargsCommand(command);\n yargs.command(yargsCommand);\n }\n });\n this.configureGlobalFlags();\n this.setHelpMiddleware();\n this.handleCommandFailure();\n this.configureCompletion();\n yargs.strict(); // don't allow non-exist flags and non-exist commands\n\n yargs\n // .recommendCommands() // don't use it, it brings the global help of yargs, we have a custom one\n .wrap(null);\n\n await yargs.parse();\n }\n\n private setHelpMiddleware() {\n yargs.middleware((argv) => {\n if (argv._.length === 0 && argv.help) {\n const shouldShowInternalCommands = Boolean(argv.internal);\n // this is the main help page\n this.printHelp(shouldShowInternalCommands);\n process.exit(0);\n }\n if (argv.help) {\n loader.off(); // stop the \"loading bit...\" before showing help if needed\n // this is a command help page\n yargs.showHelp(this.logCommandHelp.bind(this));\n if (!logger.isDaemon) process.exit(0);\n }\n }, true);\n }\n\n private handleCommandFailure() {\n yargs.fail((msg, err) => {\n loader.stop();\n if (err) {\n throw err;\n }\n yargs.showHelp(this.logCommandHelp.bind(this));\n const args = process.argv.slice(2);\n const isHelpFlagEntered = args.includes('--help') || args.includes('-h');\n const isMsgAboutMissingArgs = msg.startsWith('Not enough non-option arguments');\n // avoid showing the \"Not enough non-option arguments\" message when the user is trying to get the command help\n if (!isMsgAboutMissingArgs || !isHelpFlagEntered) {\n // eslint-disable-next-line no-console\n console.log(`\\n${chalk.yellow(msg)}`);\n }\n if (!logger.isDaemon) process.exit(1);\n });\n }\n\n private configureCompletion() {\n const commandsToShowComponentIdsForCompletion = [\n 'show',\n 'diff',\n 'tag',\n 'export',\n 'env',\n 'envs',\n 'compile',\n 'build',\n 'test',\n 'lint',\n 'log',\n 'dependents',\n 'dependencies',\n ];\n // @ts-ignore\n yargs.completion('completion', async function (current, argv, completionFilter, done) {\n if (!current.startsWith('-') && commandsToShowComponentIdsForCompletion.includes(argv._[1])) {\n const consumer = await loadConsumerIfExist();\n done(consumer?.bitmapIdsFromCurrentLane.map((id) => id.toStringWithoutVersion()));\n } else {\n completionFilter();\n }\n });\n }\n\n private printHelp(shouldShowInternalCommands = false) {\n const help = formatHelp(this.commands, this.groups, shouldShowInternalCommands);\n // eslint-disable-next-line no-console\n console.log(help);\n }\n\n private configureParser() {\n yargs.parserConfiguration({\n // 'strip-dashed': true, // we can't enable it, otherwise, the completion doesn't work\n 'strip-aliased': true,\n 'boolean-negation': false,\n 'populate--': true,\n });\n }\n\n private parseCommandWithSubCommands(command: Command) {\n const yarnCommand = this.getYargsCommand(command);\n const builderFunc = () => {\n command.commands?.forEach((cmd) => {\n const subCommand = this.getYargsCommand(cmd);\n yargs.command(subCommand);\n });\n // since the \"builder\" method is overridden, the global flags of the main command are gone, this fixes it.\n yargs.options(YargsAdapter.getGlobalOptions(command));\n return yargs;\n };\n yarnCommand.builder = builderFunc;\n yargs.command(yarnCommand);\n }\n\n private getYargsCommand(command: Command): YargsAdapter {\n const yarnCommand = new YargsAdapter(command);\n yarnCommand.builder = yarnCommand.builder.bind(yarnCommand);\n yarnCommand.handler = yarnCommand.handler.bind(yarnCommand);\n\n return yarnCommand;\n }\n\n private configureGlobalFlags() {\n yargs\n .option('help', {\n alias: 'h',\n describe: 'show help',\n group: GLOBAL_GROUP,\n })\n .option('version', {\n global: false,\n alias: 'v',\n describe: 'show version',\n group: GLOBAL_GROUP,\n });\n }\n\n private throwForNonExistsCommand(commandName: string) {\n if (!commandName || commandName.startsWith('-')) {\n return;\n }\n const commandsNames = this.commands.map((c) => getCommandId(c.name));\n const aliases = this.commands.map((c) => c.alias).filter((a) => a);\n const existingGlobalFlags = ['-V', '--version'];\n const validCommands = [...commandsNames, ...aliases, ...existingGlobalFlags];\n const commandExist = validCommands.includes(commandName);\n\n if (!commandExist) {\n didYouMean.returnFirstMatch = true;\n const suggestions = didYouMean(\n commandName,\n this.commands.filter((c) => !c.private).map((c) => getCommandId(c.name))\n );\n const suggestion = suggestions && Array.isArray(suggestions) ? suggestions[0] : suggestions;\n\n throw new CommandNotFound(commandName, suggestion as string);\n }\n }\n\n /**\n * manipulate the command help output. there is no API from Yarn to do any of this, so it needs to be done manually.\n * see https://github.com/yargs/yargs/issues/1956\n *\n * the original order of the output:\n * description\n * Options\n * Commands\n * Global\n * Positionals\n * Examples\n */\n private logCommandHelp(help: string) {\n const command = this.findCommandByArgv();\n\n const replacer = (_, p1, p2) => `${p1}${chalk.green(p2)}`;\n const lines = help.split('\\n');\n const linesWithoutEmpty = compact(lines);\n const cmdLine = linesWithoutEmpty[0];\n const description: string[] = [];\n const options: string[] = [];\n const globalOptions: string[] = [];\n const subCommands: string[] = [];\n const args: string[] = [];\n const examples: string[] = [];\n\n let optionsStarted = false;\n let globalStarted = false;\n let subCommandsStarted = false;\n let positionalsStarted = false;\n let examplesStarted = false;\n for (let i = 1; i < linesWithoutEmpty.length; i += 1) {\n const currentLine = linesWithoutEmpty[i];\n if (currentLine === STANDARD_GROUP) {\n optionsStarted = true;\n } else if (currentLine === GLOBAL_GROUP) {\n globalStarted = true;\n } else if (currentLine === 'Commands:') {\n subCommandsStarted = true;\n } else if (currentLine === 'Positionals:') {\n positionalsStarted = true;\n } else if (currentLine === 'Examples:') {\n examplesStarted = true;\n } else if (examplesStarted) {\n examples.push(currentLine);\n } else if (positionalsStarted) {\n args.push(currentLine);\n } else if (globalStarted) {\n globalOptions.push(currentLine);\n } else if (optionsStarted) {\n options.push(currentLine);\n } else if (subCommandsStarted) {\n subCommands.push(currentLine);\n } else {\n description.push(currentLine);\n }\n }\n\n // show the flags in green\n const optionsColored = options.map((opt) => opt.replace(/(--)([\\w-]+)/, replacer).replace(/(-)([\\w-]+)/, replacer));\n const argsColored = args.map((arg) => arg.replace(/^ {2}\\S+/, (argName) => chalk.green(argName))); // regex: two spaces then the first word until a white space\n const optionsStr = options.length ? `\\n${STANDARD_GROUP}\\n${optionsColored.join('\\n')}\\n` : '';\n const argumentsStr = args.length ? `\\nArguments:\\n${argsColored.join('\\n')}\\n` : '';\n const examplesStr = examples.length ? `\\nExamples:\\n${examples.join('\\n')}\\n` : '';\n const subCommandsStr = subCommands.length ? `\\n${'Commands:'}\\n${subCommands.join('\\n')}\\n` : '';\n // show the description in bold\n const descriptionColored = description.map((desc) => chalk.bold(desc));\n if (command?.extendedDescription) {\n descriptionColored.push(command?.extendedDescription);\n }\n if (command?.helpUrl) {\n descriptionColored.push(`for more info, visit: ${chalk.underline(command.helpUrl)}`);\n }\n const descriptionStr = descriptionColored.join('\\n');\n const globalOptionsStr = globalOptions.join('\\n');\n\n const finalOutput = `${cmdLine}\n\n${descriptionStr}\n${argumentsStr}${subCommandsStr}${optionsStr}${examplesStr}\n${GLOBAL_GROUP}\n${globalOptionsStr}`;\n\n // eslint-disable-next-line no-console\n console.log(finalOutput);\n }\n\n private findCommandByArgv(): Command | undefined {\n const args = process.argv.slice(2);\n const enteredCommand = args[0];\n const enteredSubCommand = args[1];\n if (!enteredCommand) {\n return undefined;\n }\n const isCommandMatch = (cmd: Command, str: string) => {\n return (\n cmd.name.startsWith(`${str} `) || // e.g. \"tag <id>\".startsWith(\"tag \")\n cmd.name === str || // e.g. \"globals\" === \"globals\"\n cmd.alias === str\n ); // e.g. \"t\" === \"t\"\n };\n const command = this.commands.find((cmd) => isCommandMatch(cmd, enteredCommand));\n if (!command) {\n return undefined;\n }\n if (!command.commands || !enteredSubCommand) {\n return command; // no sub-commands.\n }\n const subCommand = command.commands.find((cmd) => isCommandMatch(cmd, enteredSubCommand));\n return subCommand || command;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,UAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,SAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,QAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAK,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,OAAA;EAAA,MAAAR,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAM,MAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,cAAA;EAAA,MAAAT,IAAA,GAAAE,OAAA;EAAAO,aAAA,YAAAA,CAAA;IAAA,OAAAT,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAU,MAAA;EAAA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xI,IAAI,CAAC,CAAC,CAAC;IAC9B,MAAMyI,iBAAiB,GAAGzI,IAAI,CAAC,CAAC,CAAC;IACjC,IAAI,CAACwI,cAAc,EAAE;MACnB,OAAOnJ,SAAS;IAClB;IACA,MAAMqJ,cAAc,GAAGA,CAAC3E,GAAY,EAAE4E,GAAW,KAAK;MACpD,OACE5E,GAAG,CAACiB,IAAI,CAACtC,UAAU,CAAE,GAAEiG,GAAI,GAAE,CAAC;MAAI;MAClC5E,GAAG,CAACiB,IAAI,KAAK2D,GAAG;MAAI;MACpB5E,GAAG,CAACQ,KAAK,KAAKoE,GAAG,CACjB,CAAC;IACL,CAAC;;IACD,MAAMhI,OAAO,GAAG,IAAI,CAACf,QAAQ,CAACgJ,IAAI,CAAE7E,GAAG,IAAK2E,cAAc,CAAC3E,GAAG,EAAEyE,cAAc,CAAC,CAAC;IAChF,IAAI,CAAC7H,OAAO,EAAE;MACZ,OAAOtB,SAAS;IAClB;IACA,IAAI,CAACsB,OAAO,CAACf,QAAQ,IAAI,CAAC6I,iBAAiB,EAAE;MAC3C,OAAO9H,OAAO,CAAC,CAAC;IAClB;;IACA,MAAMqD,UAAU,GAAGrD,OAAO,CAACf,QAAQ,CAACgJ,IAAI,CAAE7E,GAAG,IAAK2E,cAAc,CAAC3E,GAAG,EAAE0E,iBAAiB,CAAC,CAAC;IACzF,OAAOzE,UAAU,IAAIrD,OAAO;EAC9B;AACF;AAACkI,OAAA,CAAAnJ,SAAA,GAAAA,SAAA"}
|
package/dist/cli.cmd.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.promise.js");
|
|
5
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
6
|
-
require("core-js/modules/es.string.trim.js");
|
|
7
3
|
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
6
|
exports.CliGenerateCmd = exports.CliCmd = void 0;
|
|
11
|
-
function _defineProperty2() {
|
|
12
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
_defineProperty2 = function () {
|
|
14
|
-
return data;
|
|
15
|
-
};
|
|
16
|
-
return data;
|
|
17
|
-
}
|
|
18
7
|
function _logger() {
|
|
19
8
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/logger/logger"));
|
|
20
9
|
_logger = function () {
|
|
@@ -64,17 +53,19 @@ function _generateDocMd() {
|
|
|
64
53
|
};
|
|
65
54
|
return data;
|
|
66
55
|
}
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
57
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
58
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
59
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // eslint-disable-next-line max-classes-per-file
|
|
69
60
|
class CliGenerateCmd {
|
|
70
61
|
constructor(cliMain) {
|
|
71
62
|
this.cliMain = cliMain;
|
|
72
|
-
(
|
|
73
|
-
(
|
|
74
|
-
(
|
|
75
|
-
(
|
|
76
|
-
(
|
|
77
|
-
(
|
|
63
|
+
_defineProperty(this, "name", 'generate');
|
|
64
|
+
_defineProperty(this, "description", 'generate an .md file with all commands details');
|
|
65
|
+
_defineProperty(this, "alias", '');
|
|
66
|
+
_defineProperty(this, "loader", false);
|
|
67
|
+
_defineProperty(this, "group", 'general');
|
|
68
|
+
_defineProperty(this, "options", [['', 'metadata', 'metadata/front-matter to place at the top of the .md file, enter as an object e.g. --metadata.id=cli --metadata.title=commands'], ['', 'docs', 'generate the cli-reference.docs.mdx file'], ['j', 'json', 'output the commands info as JSON']]);
|
|
78
69
|
}
|
|
79
70
|
async report(args, {
|
|
80
71
|
metadata,
|
|
@@ -99,13 +90,13 @@ exports.CliGenerateCmd = CliGenerateCmd;
|
|
|
99
90
|
class CliCmd {
|
|
100
91
|
constructor(cliMain) {
|
|
101
92
|
this.cliMain = cliMain;
|
|
102
|
-
(
|
|
103
|
-
(
|
|
104
|
-
(
|
|
105
|
-
(
|
|
106
|
-
(
|
|
107
|
-
(
|
|
108
|
-
(
|
|
93
|
+
_defineProperty(this, "name", 'cli');
|
|
94
|
+
_defineProperty(this, "description", 'EXPERIMENTAL. enters bit cli program and generates commands list');
|
|
95
|
+
_defineProperty(this, "alias", '');
|
|
96
|
+
_defineProperty(this, "commands", []);
|
|
97
|
+
_defineProperty(this, "loader", false);
|
|
98
|
+
_defineProperty(this, "group", 'general');
|
|
99
|
+
_defineProperty(this, "options", []);
|
|
109
100
|
}
|
|
110
101
|
async report() {
|
|
111
102
|
_logger().default.isDaemon = true;
|
package/dist/cli.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_logger","data","_interopRequireDefault","require","_handleErrors","_consumer","_bootstrap","_readline","_cliParser","_generateDocMd","
|
|
1
|
+
{"version":3,"names":["_logger","data","_interopRequireDefault","require","_handleErrors","_consumer","_bootstrap","_readline","_cliParser","_generateDocMd","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","CliGenerateCmd","constructor","cliMain","report","args","metadata","docs","getHarmonyVersion","GenerateCommandsDoc","commands","generate","json","generateJson","exports","CliCmd","legacyLogger","isDaemon","rl","readline","createInterface","process","stdin","output","stdout","prompt","completer","line","cb","cliParser","CLIParser","groups","Promise","resolve","on","cmd","trim","split","parse","err","handleErrorAndExit","lineSplit","values","length","completeCommand","loadConsumerIfExist","then","consumer","comps","bitmapIdsFromCurrentLane","map","id","toStringWithoutVersion","filter","c","includes","catch","name","startsWith"],"sources":["cli.cmd.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport { Command, CommandOptions } from '@teambit/cli';\nimport legacyLogger from '@teambit/legacy/dist/logger/logger';\nimport { handleErrorAndExit } from '@teambit/legacy/dist/cli/handle-errors';\nimport { loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport { getHarmonyVersion } from '@teambit/legacy/dist/bootstrap';\nimport readline from 'readline';\nimport { CLIParser } from './cli-parser';\nimport { CLIMain } from './cli.main.runtime';\nimport { GenerateCommandsDoc, GenerateOpts } from './generate-doc-md';\n\nexport class CliGenerateCmd implements Command {\n name = 'generate';\n description = 'generate an .md file with all commands details';\n alias = '';\n loader = false;\n group = 'general';\n options = [\n [\n '',\n 'metadata',\n 'metadata/front-matter to place at the top of the .md file, enter as an object e.g. --metadata.id=cli --metadata.title=commands',\n ],\n ['', 'docs', 'generate the cli-reference.docs.mdx file'],\n ['j', 'json', 'output the commands info as JSON'],\n ] as CommandOptions;\n\n constructor(private cliMain: CLIMain) {}\n\n async report(args, { metadata, docs }: GenerateOpts & { docs?: boolean }): Promise<string> {\n if (docs) {\n return `---\ndescription: 'Bit command synopses. Bit version: ${getHarmonyVersion()}'\nlabels: ['cli', 'mdx', 'docs']\n---\n `;\n }\n return new GenerateCommandsDoc(this.cliMain.commands, { metadata }).generate();\n }\n\n async json() {\n return new GenerateCommandsDoc(this.cliMain.commands, {}).generateJson();\n }\n}\n\nexport class CliCmd implements Command {\n name = 'cli';\n description = 'EXPERIMENTAL. enters bit cli program and generates commands list';\n alias = '';\n commands: Command[] = [];\n loader = false;\n group = 'general';\n options = [] as CommandOptions;\n\n constructor(private cliMain: CLIMain) {}\n\n async report(): Promise<string> {\n legacyLogger.isDaemon = true;\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n prompt: 'bit > ',\n completer: (line, cb) => completer(line, cb, this.cliMain),\n });\n\n const cliParser = new CLIParser(this.cliMain.commands, this.cliMain.groups);\n\n rl.prompt();\n\n return new Promise((resolve) => {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n rl.on('line', async (line) => {\n const cmd = line.trim().split(' ');\n try {\n await cliParser.parse(cmd);\n } catch (err: any) {\n await handleErrorAndExit(err, cmd[0]);\n }\n rl.prompt();\n }).on('close', () => {\n resolve('Have a great day!');\n });\n });\n }\n}\n\nfunction completer(line: string, cb: Function, cliMain: CLIMain) {\n const lineSplit = line.split(' ');\n let values: string[] = [];\n if (lineSplit.length <= 1) {\n values = completeCommand(line, cliMain);\n cb(null, [values, line]);\n }\n loadConsumerIfExist()\n .then((consumer) => {\n const comps = consumer?.bitmapIdsFromCurrentLane.map((id) => id.toStringWithoutVersion()) || [];\n values = comps.filter((c) => c.includes(lineSplit[1]));\n // eslint-disable-next-line promise/no-callback-in-promise\n cb(null, [values, line]);\n })\n .catch((err) => {\n // eslint-disable-next-line promise/no-callback-in-promise\n cb(err, [[], line]);\n });\n}\n\nfunction completeCommand(line: string, cliMain: CLIMain): string[] {\n const commands = cliMain.commands.filter((cmd) => cmd.name.startsWith(line));\n return commands.map((c) => c.name).map((name) => name.split(' ')[0]);\n}\n"],"mappings":";;;;;;AAEA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,SAAA,YAAAA,CAA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,CAAEI,CAAC,IAAKA,CAAC,CAACG,IAAI,CAAC,CAACP,GAAG,CAAEO,IAAI,IAAKA,IAAI,CAACpB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACtE"}
|
package/dist/cli.composition.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -12,6 +11,7 @@ function _react() {
|
|
|
12
11
|
};
|
|
13
12
|
return data;
|
|
14
13
|
}
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
|
16
16
|
style: {
|
|
17
17
|
height: '100%',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","obj","__esModule","default","Logo","createElement","style","height","display","justifyContent","width","src","exports"],"sources":["cli.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/cli.svg\" />\n </div>\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;AAA0B,SAAAC,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEnB,MAAMG,IAAI,GAAGA,CAAA,kBAClBP,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxEZ,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEI,KAAK,EAAE;EAAG,CAAE;EAACC,GAAG,EAAC;AAAiD,CAAE,CAC/E,CACN;AAACC,OAAA,CAAAR,IAAA,GAAAA,IAAA"}
|
package/dist/cli.main.runtime.js
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.symbol.description.js");
|
|
5
|
-
require("core-js/modules/es.array.flat.js");
|
|
6
|
-
require("core-js/modules/es.array.iterator.js");
|
|
7
|
-
require("core-js/modules/es.array.unscopables.flat.js");
|
|
8
|
-
require("core-js/modules/es.promise.js");
|
|
9
|
-
require("core-js/modules/es.string.trim.js");
|
|
10
3
|
Object.defineProperty(exports, "__esModule", {
|
|
11
4
|
value: true
|
|
12
5
|
});
|
|
13
6
|
exports.CLIMain = void 0;
|
|
14
|
-
function _defineProperty2() {
|
|
15
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
_defineProperty2 = function () {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
7
|
function _harmony() {
|
|
22
8
|
const data = require("@teambit/harmony");
|
|
23
9
|
_harmony = function () {
|
|
@@ -123,6 +109,10 @@ function _help() {
|
|
|
123
109
|
};
|
|
124
110
|
return data;
|
|
125
111
|
}
|
|
112
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
113
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
114
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
115
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
126
116
|
class CLIMain {
|
|
127
117
|
// if it's not cloned, it is cached across loadBit() instances
|
|
128
118
|
constructor(commandsSlot, onStartSlot, onBeforeExitSlot, logger) {
|
|
@@ -130,7 +120,7 @@ class CLIMain {
|
|
|
130
120
|
this.onStartSlot = onStartSlot;
|
|
131
121
|
this.onBeforeExitSlot = onBeforeExitSlot;
|
|
132
122
|
this.logger = logger;
|
|
133
|
-
(
|
|
123
|
+
_defineProperty(this, "groups", (0, _lodash().clone)(_commandGroups().groups));
|
|
134
124
|
}
|
|
135
125
|
|
|
136
126
|
/**
|
|
@@ -260,9 +250,9 @@ class CLIMain {
|
|
|
260
250
|
}
|
|
261
251
|
}
|
|
262
252
|
exports.CLIMain = CLIMain;
|
|
263
|
-
(
|
|
264
|
-
(
|
|
265
|
-
(
|
|
253
|
+
_defineProperty(CLIMain, "dependencies", [_logger2().LoggerAspect]);
|
|
254
|
+
_defineProperty(CLIMain, "runtime", _cli2().MainRuntime);
|
|
255
|
+
_defineProperty(CLIMain, "slots", [_harmony().Slot.withType(), _harmony().Slot.withType(), _harmony().Slot.withType()]);
|
|
266
256
|
_cli2().CLIAspect.addRuntime(CLIMain);
|
|
267
257
|
|
|
268
258
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_harmony","data","require","_cli","_logger","_interopRequireDefault","_pMapSeries","_commandGroups","_consumer","_logger2","_lodash","_cli2","_getCommandId","_legacyCommandAdapter","_cliParser","_completion","_cli3","_help","CLIMain","constructor","commandsSlot","onStartSlot","onBeforeExitSlot","logger","_defineProperty2","default","clone","groups","register","commands","forEach","command","setDefaults","cmd","unregister","commandName","toArray","aspectId","filteredCommands","filter","getCommandId","name","map","set","values","flat","getCommand","find","registerGroup","description","consoleWarning","registerOnStart","onStartFn","registerOnBeforeExit","onBeforeExitFn","legacyLogger","registerOnBeforeExitFn","run","hasWorkspace","invokeOnStart","CliParser","CLIParser","parse","onStartFns","currentCommand","process","argv","pMapSeries","onStart","alias","extendedDescription","group","options","private","trim","loader","undefined","internal","helpUrl","isFullUrl","provider","loggerMain","config","createLogger","CLIAspect","id","cliMain","legacyRegistry","buildRegistry","ensureWorkspaceAndScope","legacyCommands","legacyCommandsAdapters","LegacyCommandAdapter","cliGenerateCmd","CliGenerateCmd","cliCmd","CliCmd","helpCmd","HelpCmd","push","CompletionCmd","exports","LoggerAspect","MainRuntime","Slot","withType","addRuntime","loadConsumerIfExist","err","url","startsWith"],"sources":["cli.main.runtime.ts"],"sourcesContent":["import { Slot, SlotRegistry } from '@teambit/harmony';\nimport { buildRegistry } from '@teambit/legacy/dist/cli';\nimport legacyLogger from '@teambit/legacy/dist/logger/logger';\nimport { Command } from '@teambit/legacy/dist/cli/command';\nimport pMapSeries from 'p-map-series';\nimport { groups, GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { clone } from 'lodash';\nimport { CLIAspect, MainRuntime } from './cli.aspect';\nimport { getCommandId } from './get-command-id';\nimport { LegacyCommandAdapter } from './legacy-command-adapter';\nimport { CLIParser } from './cli-parser';\nimport { CompletionCmd } from './completion.cmd';\nimport { CliCmd, CliGenerateCmd } from './cli.cmd';\nimport { HelpCmd } from './help.cmd';\n\nexport type CommandList = Array<Command>;\nexport type OnStart = (hasWorkspace: boolean, currentCommand: string) => Promise<void>;\nexport type OnBeforeExitFn = () => Promise<void>;\n\nexport type OnStartSlot = SlotRegistry<OnStart>;\nexport type CommandsSlot = SlotRegistry<CommandList>;\nexport type OnBeforeExitSlot = SlotRegistry<OnBeforeExitFn>;\n\nexport class CLIMain {\n public groups: GroupsType = clone(groups); // if it's not cloned, it is cached across loadBit() instances\n constructor(\n private commandsSlot: CommandsSlot,\n private onStartSlot: OnStartSlot,\n private onBeforeExitSlot: OnBeforeExitSlot,\n private logger: Logger\n ) {}\n\n /**\n * registers a new command in to the CLI.\n */\n register(...commands: CommandList) {\n commands.forEach((command) => {\n this.setDefaults(command);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n command.commands!.forEach((cmd) => this.setDefaults(cmd));\n });\n this.commandsSlot.register(commands);\n }\n\n /**\n * helpful for having the same command name in different environments (e.g. legacy and non-legacy).\n * for example `cli.unregister('tag');` removes the \"bit tag\" command.\n */\n unregister(commandName: string) {\n this.commandsSlot.toArray().forEach(([aspectId, commands]) => {\n const filteredCommands = commands.filter((command) => {\n return getCommandId(command.name) !== commandName;\n });\n this.commandsSlot.map.set(aspectId, filteredCommands);\n });\n }\n\n /**\n * list of all registered commands. (legacy and new).\n */\n get commands(): CommandList {\n return this.commandsSlot.values().flat();\n }\n\n /**\n * get an instance of a registered command. (useful for aspects to modify and extend existing commands)\n */\n getCommand(name: string): Command | undefined {\n return this.commands.find((command) => getCommandId(command.name) === name);\n }\n\n /**\n * when running `bit help`, commands are grouped by categories.\n * this method helps registering a new group by providing its name and a description.\n * the name is what needs to be assigned to the `group` property of the Command interface.\n * the description is what shown in the `bit help` output.\n */\n registerGroup(name: string, description: string) {\n if (this.groups[name]) {\n this.logger.consoleWarning(`CLI group \"${name}\" is already registered`);\n } else {\n this.groups[name] = description;\n }\n }\n\n registerOnStart(onStartFn: OnStart) {\n this.onStartSlot.register(onStartFn);\n return this;\n }\n\n /**\n * This will register a function to be called before the process exits.\n * This will run only for \"regular\" exits\n * e.g.\n * yes - command run and finished successfully\n * yes - command run and failed gracefully (code 1)\n * not SIGKILL (kill -9)\n * not SIGINT (Ctrl+C)\n * not SIGTERM (kill)\n * not uncaughtException\n * not unhandledRejection\n *\n * @param onBeforeExitFn\n * @returns\n */\n registerOnBeforeExit(onBeforeExitFn: OnBeforeExitFn) {\n this.onBeforeExitSlot.register(onBeforeExitFn);\n legacyLogger.registerOnBeforeExitFn(onBeforeExitFn);\n return this;\n }\n\n /**\n * execute commands registered to this aspect.\n */\n async run(hasWorkspace: boolean) {\n await this.invokeOnStart(hasWorkspace);\n const CliParser = new CLIParser(this.commands, this.groups);\n await CliParser.parse();\n }\n\n private async invokeOnStart(hasWorkspace: boolean) {\n const onStartFns = this.onStartSlot.values();\n const currentCommand = process.argv[2];\n await pMapSeries(onStartFns, (onStart) => onStart(hasWorkspace, currentCommand));\n }\n\n private setDefaults(command: Command) {\n command.alias = command.alias || '';\n command.description = command.description || '';\n command.extendedDescription = command.extendedDescription || '';\n command.group = command.group || 'ungrouped';\n command.options = command.options || [];\n command.private = command.private || false;\n command.commands = command.commands || [];\n command.name = command.name.trim();\n if (command.loader === undefined) {\n if (command.internal) {\n command.loader = false;\n } else {\n command.loader = true;\n }\n }\n if (command.helpUrl && !isFullUrl(command.helpUrl)) {\n command.helpUrl = `https://bit.dev/${command.helpUrl}`;\n }\n }\n\n static dependencies = [LoggerAspect];\n static runtime = MainRuntime;\n static slots = [Slot.withType<CommandList>(), Slot.withType<OnStart>(), Slot.withType<OnBeforeExitFn>()];\n\n static async provider(\n [loggerMain]: [LoggerMain],\n config,\n [commandsSlot, onStartSlot, onBeforeExitSlot]: [CommandsSlot, OnStartSlot, OnBeforeExitSlot]\n ) {\n const logger = loggerMain.createLogger(CLIAspect.id);\n const cliMain = new CLIMain(commandsSlot, onStartSlot, onBeforeExitSlot, logger);\n const legacyRegistry = buildRegistry();\n await ensureWorkspaceAndScope();\n const legacyCommands = legacyRegistry.commands;\n const legacyCommandsAdapters = legacyCommands.map((command) => new LegacyCommandAdapter(command, cliMain));\n const cliGenerateCmd = new CliGenerateCmd(cliMain);\n const cliCmd = new CliCmd(cliMain);\n const helpCmd = new HelpCmd(cliMain);\n cliCmd.commands.push(cliGenerateCmd);\n cliMain.register(...legacyCommandsAdapters, new CompletionCmd(), cliCmd, helpCmd);\n return cliMain;\n }\n}\n\nCLIAspect.addRuntime(CLIMain);\n\n/**\n * kind of a hack.\n * in the legacy, this is running at the beginning and it take care of issues when Bit files are missing,\n * such as \".bit\".\n * (to make this process better, you can easily remove it and run the e2e-tests. you'll see some failing)\n */\nasync function ensureWorkspaceAndScope() {\n try {\n await loadConsumerIfExist();\n } catch (err) {\n // do nothing. it could fail for example with ScopeNotFound error, which is taken care of in \"bit init\".\n }\n}\n\nfunction isFullUrl(url: string) {\n return url.startsWith('http://') || url.startsWith('https://');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,YAAA;EAAA,MAAAL,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAI,WAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,eAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,cAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,UAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,SAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAA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,uBAAuBA,CAAA,EAAG;EACvC,IAAI;IACF,MAAM,IAAAkB,+BAAmB,EAAC,CAAC;EAC7B,CAAC,CAAC,OAAOC,GAAG,EAAE;IACZ;EAAA;AAEJ;AAEA,SAAS7B,SAASA,CAAC8B,GAAW,EAAE;EAC9B,OAAOA,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,UAAU,CAAC;AAChE"}
|
|
1
|
+
{"version":3,"names":["_harmony","data","require","_cli","_logger","_interopRequireDefault","_pMapSeries","_commandGroups","_consumer","_logger2","_lodash","_cli2","_getCommandId","_legacyCommandAdapter","_cliParser","_completion","_cli3","_help","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","CLIMain","constructor","commandsSlot","onStartSlot","onBeforeExitSlot","logger","clone","groups","register","commands","forEach","command","setDefaults","cmd","unregister","commandName","toArray","aspectId","filteredCommands","filter","getCommandId","name","map","set","values","flat","getCommand","find","registerGroup","description","consoleWarning","registerOnStart","onStartFn","registerOnBeforeExit","onBeforeExitFn","legacyLogger","registerOnBeforeExitFn","run","hasWorkspace","invokeOnStart","CliParser","CLIParser","parse","onStartFns","currentCommand","process","argv","pMapSeries","onStart","alias","extendedDescription","group","options","private","trim","loader","internal","helpUrl","isFullUrl","provider","loggerMain","config","createLogger","CLIAspect","id","cliMain","legacyRegistry","buildRegistry","ensureWorkspaceAndScope","legacyCommands","legacyCommandsAdapters","LegacyCommandAdapter","cliGenerateCmd","CliGenerateCmd","cliCmd","CliCmd","helpCmd","HelpCmd","push","CompletionCmd","exports","LoggerAspect","MainRuntime","Slot","withType","addRuntime","loadConsumerIfExist","err","url","startsWith"],"sources":["cli.main.runtime.ts"],"sourcesContent":["import { Slot, SlotRegistry } from '@teambit/harmony';\nimport { buildRegistry } from '@teambit/legacy/dist/cli';\nimport legacyLogger from '@teambit/legacy/dist/logger/logger';\nimport { Command } from '@teambit/legacy/dist/cli/command';\nimport pMapSeries from 'p-map-series';\nimport { groups, GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { clone } from 'lodash';\nimport { CLIAspect, MainRuntime } from './cli.aspect';\nimport { getCommandId } from './get-command-id';\nimport { LegacyCommandAdapter } from './legacy-command-adapter';\nimport { CLIParser } from './cli-parser';\nimport { CompletionCmd } from './completion.cmd';\nimport { CliCmd, CliGenerateCmd } from './cli.cmd';\nimport { HelpCmd } from './help.cmd';\n\nexport type CommandList = Array<Command>;\nexport type OnStart = (hasWorkspace: boolean, currentCommand: string) => Promise<void>;\nexport type OnBeforeExitFn = () => Promise<void>;\n\nexport type OnStartSlot = SlotRegistry<OnStart>;\nexport type CommandsSlot = SlotRegistry<CommandList>;\nexport type OnBeforeExitSlot = SlotRegistry<OnBeforeExitFn>;\n\nexport class CLIMain {\n public groups: GroupsType = clone(groups); // if it's not cloned, it is cached across loadBit() instances\n constructor(\n private commandsSlot: CommandsSlot,\n private onStartSlot: OnStartSlot,\n private onBeforeExitSlot: OnBeforeExitSlot,\n private logger: Logger\n ) {}\n\n /**\n * registers a new command in to the CLI.\n */\n register(...commands: CommandList) {\n commands.forEach((command) => {\n this.setDefaults(command);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n command.commands!.forEach((cmd) => this.setDefaults(cmd));\n });\n this.commandsSlot.register(commands);\n }\n\n /**\n * helpful for having the same command name in different environments (e.g. legacy and non-legacy).\n * for example `cli.unregister('tag');` removes the \"bit tag\" command.\n */\n unregister(commandName: string) {\n this.commandsSlot.toArray().forEach(([aspectId, commands]) => {\n const filteredCommands = commands.filter((command) => {\n return getCommandId(command.name) !== commandName;\n });\n this.commandsSlot.map.set(aspectId, filteredCommands);\n });\n }\n\n /**\n * list of all registered commands. (legacy and new).\n */\n get commands(): CommandList {\n return this.commandsSlot.values().flat();\n }\n\n /**\n * get an instance of a registered command. (useful for aspects to modify and extend existing commands)\n */\n getCommand(name: string): Command | undefined {\n return this.commands.find((command) => getCommandId(command.name) === name);\n }\n\n /**\n * when running `bit help`, commands are grouped by categories.\n * this method helps registering a new group by providing its name and a description.\n * the name is what needs to be assigned to the `group` property of the Command interface.\n * the description is what shown in the `bit help` output.\n */\n registerGroup(name: string, description: string) {\n if (this.groups[name]) {\n this.logger.consoleWarning(`CLI group \"${name}\" is already registered`);\n } else {\n this.groups[name] = description;\n }\n }\n\n registerOnStart(onStartFn: OnStart) {\n this.onStartSlot.register(onStartFn);\n return this;\n }\n\n /**\n * This will register a function to be called before the process exits.\n * This will run only for \"regular\" exits\n * e.g.\n * yes - command run and finished successfully\n * yes - command run and failed gracefully (code 1)\n * not SIGKILL (kill -9)\n * not SIGINT (Ctrl+C)\n * not SIGTERM (kill)\n * not uncaughtException\n * not unhandledRejection\n *\n * @param onBeforeExitFn\n * @returns\n */\n registerOnBeforeExit(onBeforeExitFn: OnBeforeExitFn) {\n this.onBeforeExitSlot.register(onBeforeExitFn);\n legacyLogger.registerOnBeforeExitFn(onBeforeExitFn);\n return this;\n }\n\n /**\n * execute commands registered to this aspect.\n */\n async run(hasWorkspace: boolean) {\n await this.invokeOnStart(hasWorkspace);\n const CliParser = new CLIParser(this.commands, this.groups);\n await CliParser.parse();\n }\n\n private async invokeOnStart(hasWorkspace: boolean) {\n const onStartFns = this.onStartSlot.values();\n const currentCommand = process.argv[2];\n await pMapSeries(onStartFns, (onStart) => onStart(hasWorkspace, currentCommand));\n }\n\n private setDefaults(command: Command) {\n command.alias = command.alias || '';\n command.description = command.description || '';\n command.extendedDescription = command.extendedDescription || '';\n command.group = command.group || 'ungrouped';\n command.options = command.options || [];\n command.private = command.private || false;\n command.commands = command.commands || [];\n command.name = command.name.trim();\n if (command.loader === undefined) {\n if (command.internal) {\n command.loader = false;\n } else {\n command.loader = true;\n }\n }\n if (command.helpUrl && !isFullUrl(command.helpUrl)) {\n command.helpUrl = `https://bit.dev/${command.helpUrl}`;\n }\n }\n\n static dependencies = [LoggerAspect];\n static runtime = MainRuntime;\n static slots = [Slot.withType<CommandList>(), Slot.withType<OnStart>(), Slot.withType<OnBeforeExitFn>()];\n\n static async provider(\n [loggerMain]: [LoggerMain],\n config,\n [commandsSlot, onStartSlot, onBeforeExitSlot]: [CommandsSlot, OnStartSlot, OnBeforeExitSlot]\n ) {\n const logger = loggerMain.createLogger(CLIAspect.id);\n const cliMain = new CLIMain(commandsSlot, onStartSlot, onBeforeExitSlot, logger);\n const legacyRegistry = buildRegistry();\n await ensureWorkspaceAndScope();\n const legacyCommands = legacyRegistry.commands;\n const legacyCommandsAdapters = legacyCommands.map((command) => new LegacyCommandAdapter(command, cliMain));\n const cliGenerateCmd = new CliGenerateCmd(cliMain);\n const cliCmd = new CliCmd(cliMain);\n const helpCmd = new HelpCmd(cliMain);\n cliCmd.commands.push(cliGenerateCmd);\n cliMain.register(...legacyCommandsAdapters, new CompletionCmd(), cliCmd, helpCmd);\n return cliMain;\n }\n}\n\nCLIAspect.addRuntime(CLIMain);\n\n/**\n * kind of a hack.\n * in the legacy, this is running at the beginning and it take care of issues when Bit files are missing,\n * such as \".bit\".\n * (to make this process better, you can easily remove it and run the e2e-tests. you'll see some failing)\n */\nasync function ensureWorkspaceAndScope() {\n try {\n await loadConsumerIfExist();\n } catch (err) {\n // do nothing. it could fail for example with ScopeNotFound error, which is taken care of in \"bit init\".\n }\n}\n\nfunction isFullUrl(url: string) {\n return url.startsWith('http://') || url.startsWith('https://');\n}\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAA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AsB1GrB,iBAAS,CAACsB,UAAU,CAACrF,OAAO,CAAC;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA,eAAeoE,uBAAuBA,CAAA,EAAG;EACvC,IAAI;IACF,MAAM,IAAAkB,+BAAmB,EAAC,CAAC;EAC7B,CAAC,CAAC,OAAOC,GAAG,EAAE;IACZ;EAAA;AAEJ;AAEA,SAAS7B,SAASA,CAAC8B,GAAW,EAAE;EAC9B,OAAOA,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,UAAU,CAAC;AAChE"}
|
package/dist/command-runner.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.promise.js");
|
|
5
|
-
require("core-js/modules/es.regexp.flags.js");
|
|
6
3
|
Object.defineProperty(exports, "__esModule", {
|
|
7
4
|
value: true
|
|
8
5
|
});
|
|
9
6
|
exports.CommandRunner = void 0;
|
|
10
|
-
function _defineProperty2() {
|
|
11
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
_defineProperty2 = function () {
|
|
13
|
-
return data;
|
|
14
|
-
};
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
7
|
function _ink() {
|
|
18
8
|
const data = require("ink");
|
|
19
9
|
_ink = function () {
|
|
@@ -77,12 +67,16 @@ function _analytics() {
|
|
|
77
67
|
};
|
|
78
68
|
return data;
|
|
79
69
|
}
|
|
70
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
71
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
72
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
73
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
80
74
|
class CommandRunner {
|
|
81
75
|
constructor(command, args, flags) {
|
|
82
76
|
this.command = command;
|
|
83
77
|
this.args = args;
|
|
84
78
|
this.flags = flags;
|
|
85
|
-
(
|
|
79
|
+
_defineProperty(this, "commandName", void 0);
|
|
86
80
|
this.commandName = (0, _commandRegistry().parseCommandName)(this.command.name);
|
|
87
81
|
}
|
|
88
82
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ink","data","require","_consumer","_logger","_interopRequireDefault","_commandRegistry","_loader","_handleErrors","_constants","_globalFlags","_analytics","CommandRunner","constructor","command","args","flags","_defineProperty2","default","commandName","parseCommandName","name","runCommand","bootstrapCommand","runMigrateIfNeeded","determineConsoleWritingDuringCommand","json","runJsonHandler","shouldRunRender","runRenderHandler","report","runReportHandler","err","handleErrorAndExit","internal","Error","Analytics","init","logger","info","token","TOKEN_FLAG_NAME","globalFlags","toString","isTerminal","process","stdout","isTTY","Boolean","render","result","code","writeAndExit","JSON","stringify","loader","off","toRenderResult","waitUntilExit","exitAfterFlush","exitCode","on","start","shouldWriteToConsole","log","logValue","undefined","switchToConsoleLogger","write","migration","debug","migrate","exports","obj","isRenderResult","hasOwnProperty"],"sources":["command-runner.ts"],"sourcesContent":["import { render } from 'ink';\nimport { migrate } from '@teambit/legacy/dist/api/consumer';\nimport logger, { LoggerLevel } from '@teambit/legacy/dist/logger/logger';\nimport { CLIArgs, Command, Flags, RenderResult } from '@teambit/legacy/dist/cli/command';\nimport { parseCommandName } from '@teambit/legacy/dist/cli/command-registry';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { handleErrorAndExit } from '@teambit/legacy/dist/cli/handle-errors';\nimport { TOKEN_FLAG_NAME } from '@teambit/legacy/dist/constants';\nimport globalFlags from '@teambit/legacy/dist/cli/global-flags';\nimport { Analytics } from '@teambit/legacy/dist/analytics/analytics';\n\nexport class CommandRunner {\n private commandName: string;\n constructor(private command: Command, private args: CLIArgs, private flags: Flags) {\n this.commandName = parseCommandName(this.command.name);\n }\n\n /**\n * run command using one of the handler, \"json\"/\"report\"/\"render\". once done, exit the process.\n */\n async runCommand() {\n try {\n this.bootstrapCommand();\n await this.runMigrateIfNeeded();\n this.determineConsoleWritingDuringCommand();\n if (this.flags.json) {\n return await this.runJsonHandler();\n }\n if (this.shouldRunRender()) {\n return await this.runRenderHandler();\n }\n if (this.command.report) {\n return await this.runReportHandler();\n }\n } catch (err: any) {\n return handleErrorAndExit(err, this.commandName, this.command.internal);\n }\n\n throw new Error(`command \"${this.commandName}\" doesn't implement \"render\" nor \"report\" methods`);\n }\n\n private bootstrapCommand() {\n Analytics.init(this.commandName, this.flags, this.args);\n logger.info(`[*] started a new command: \"${this.commandName}\" with the following data:`, {\n args: this.args,\n flags: this.flags,\n });\n const token = this.flags[TOKEN_FLAG_NAME];\n if (token) {\n globalFlags.token = token.toString();\n }\n }\n\n /**\n * when both \"render\" and \"report\" were implemented, check whether it's a terminal.\n * if it's a terminal, use \"render\", if not, use \"report\" because \"report\" is just a string\n */\n private shouldRunRender() {\n const isTerminal = process.stdout.isTTY;\n if (this.command.report && !isTerminal) {\n return false;\n }\n return Boolean(this.command.render);\n }\n\n /**\n * this works for both, Harmony commands and Legacy commands (the legacy-command-adapter\n * implements json() method)\n */\n private async runJsonHandler() {\n if (!this.flags.json) return null;\n if (!this.command.json) throw new Error(`command \"${this.commandName}\" doesn't implement \"json\" method`);\n const result = await this.command.json(this.args, this.flags);\n const code = result.code || 0;\n const data = result.data || result;\n return this.writeAndExit(JSON.stringify(data, null, 2), code);\n }\n\n private async runRenderHandler() {\n if (!this.command.render) throw new Error('runRenderHandler expects command.render to be implemented');\n const result = await this.command.render(this.args, this.flags);\n loader.off();\n\n const { data, code } = toRenderResult(result);\n\n const { waitUntilExit } = render(data);\n await waitUntilExit();\n return logger.exitAfterFlush(code, this.commandName);\n }\n\n private async runReportHandler() {\n if (!this.command.report) throw new Error('runReportHandler expects command.report to be implemented');\n const result = await this.command.report(this.args, this.flags);\n loader.off();\n const data = typeof result === 'string' ? result : result.data;\n const exitCode = typeof result === 'string' ? 0 : result.code;\n return this.writeAndExit(`${data}\\n`, exitCode);\n }\n\n /**\n * the loader and logger.console write output to the console during the command execution.\n * for internals commands, such as, _put, _fetch, the command.loader = false.\n */\n private determineConsoleWritingDuringCommand() {\n if (this.command.loader && !this.flags.json && !this.flags['get-yargs-completions']) {\n loader.on();\n loader.start(`running command \"${this.commandName}\"...`);\n logger.shouldWriteToConsole = true;\n } else {\n loader.off();\n logger.shouldWriteToConsole = false;\n }\n if (this.flags.log) {\n // probably not necessary anymore. it is handled in src/logger - determineWritingLogToScreen()\n const logValue = typeof this.flags.log === 'string' ? this.flags.log : undefined;\n logger.switchToConsoleLogger(logValue as LoggerLevel);\n }\n }\n\n private async writeAndExit(data: string, exitCode: number) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return process.stdout.write(data, async () => logger.exitAfterFlush(exitCode, this.commandName, data));\n }\n\n private async runMigrateIfNeeded(): Promise<any> {\n // @ts-ignore LegacyCommandAdapter has .migration\n if (this.command.migration) {\n logger.debug('Checking if a migration is needed');\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return migrate(null, false);\n }\n return null;\n }\n}\n\nfunction toRenderResult(obj: RenderResult | React.ReactElement) {\n return isRenderResult(obj) ? obj : { data: obj, code: 0 };\n}\n\nfunction isRenderResult(obj: RenderResult | any): obj is RenderResult {\n // eslint-disable-next-line no-prototype-builtins\n return typeof obj === 'object' && typeof obj.code === 'number' && obj.hasOwnProperty('data');\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,I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,GAAG,CAACE,cAAc,CAAC,MAAM,CAAC;AAC9F"}
|
|
1
|
+
{"version":3,"names":["_ink","data","require","_consumer","_logger","_interopRequireDefault","_commandRegistry","_loader","_handleErrors","_constants","_globalFlags","_analytics","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","CommandRunner","constructor","command","args","flags","commandName","parseCommandName","name","runCommand","bootstrapCommand","runMigrateIfNeeded","determineConsoleWritingDuringCommand","json","runJsonHandler","shouldRunRender","runRenderHandler","report","runReportHandler","err","handleErrorAndExit","internal","Error","Analytics","init","logger","info","token","TOKEN_FLAG_NAME","globalFlags","toString","isTerminal","process","stdout","isTTY","Boolean","render","result","code","writeAndExit","JSON","stringify","loader","off","toRenderResult","waitUntilExit","exitAfterFlush","exitCode","on","start","shouldWriteToConsole","log","logValue","switchToConsoleLogger","write","migration","debug","migrate","exports","isRenderResult","hasOwnProperty"],"sources":["command-runner.ts"],"sourcesContent":["import { render } from 'ink';\nimport { migrate } from '@teambit/legacy/dist/api/consumer';\nimport logger, { LoggerLevel } from '@teambit/legacy/dist/logger/logger';\nimport { CLIArgs, Command, Flags, RenderResult } from '@teambit/legacy/dist/cli/command';\nimport { parseCommandName } from '@teambit/legacy/dist/cli/command-registry';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { handleErrorAndExit } from '@teambit/legacy/dist/cli/handle-errors';\nimport { TOKEN_FLAG_NAME } from '@teambit/legacy/dist/constants';\nimport globalFlags from '@teambit/legacy/dist/cli/global-flags';\nimport { Analytics } from '@teambit/legacy/dist/analytics/analytics';\n\nexport class CommandRunner {\n private commandName: string;\n constructor(private command: Command, private args: CLIArgs, private flags: Flags) {\n this.commandName = parseCommandName(this.command.name);\n }\n\n /**\n * run command using one of the handler, \"json\"/\"report\"/\"render\". once done, exit the process.\n */\n async runCommand() {\n try {\n this.bootstrapCommand();\n await this.runMigrateIfNeeded();\n this.determineConsoleWritingDuringCommand();\n if (this.flags.json) {\n return await this.runJsonHandler();\n }\n if (this.shouldRunRender()) {\n return await this.runRenderHandler();\n }\n if (this.command.report) {\n return await this.runReportHandler();\n }\n } catch (err: any) {\n return handleErrorAndExit(err, this.commandName, this.command.internal);\n }\n\n throw new Error(`command \"${this.commandName}\" doesn't implement \"render\" nor \"report\" methods`);\n }\n\n private bootstrapCommand() {\n Analytics.init(this.commandName, this.flags, this.args);\n logger.info(`[*] started a new command: \"${this.commandName}\" with the following data:`, {\n args: this.args,\n flags: this.flags,\n });\n const token = this.flags[TOKEN_FLAG_NAME];\n if (token) {\n globalFlags.token = token.toString();\n }\n }\n\n /**\n * when both \"render\" and \"report\" were implemented, check whether it's a terminal.\n * if it's a terminal, use \"render\", if not, use \"report\" because \"report\" is just a string\n */\n private shouldRunRender() {\n const isTerminal = process.stdout.isTTY;\n if (this.command.report && !isTerminal) {\n return false;\n }\n return Boolean(this.command.render);\n }\n\n /**\n * this works for both, Harmony commands and Legacy commands (the legacy-command-adapter\n * implements json() method)\n */\n private async runJsonHandler() {\n if (!this.flags.json) return null;\n if (!this.command.json) throw new Error(`command \"${this.commandName}\" doesn't implement \"json\" method`);\n const result = await this.command.json(this.args, this.flags);\n const code = result.code || 0;\n const data = result.data || result;\n return this.writeAndExit(JSON.stringify(data, null, 2), code);\n }\n\n private async runRenderHandler() {\n if (!this.command.render) throw new Error('runRenderHandler expects command.render to be implemented');\n const result = await this.command.render(this.args, this.flags);\n loader.off();\n\n const { data, code } = toRenderResult(result);\n\n const { waitUntilExit } = render(data);\n await waitUntilExit();\n return logger.exitAfterFlush(code, this.commandName);\n }\n\n private async runReportHandler() {\n if (!this.command.report) throw new Error('runReportHandler expects command.report to be implemented');\n const result = await this.command.report(this.args, this.flags);\n loader.off();\n const data = typeof result === 'string' ? result : result.data;\n const exitCode = typeof result === 'string' ? 0 : result.code;\n return this.writeAndExit(`${data}\\n`, exitCode);\n }\n\n /**\n * the loader and logger.console write output to the console during the command execution.\n * for internals commands, such as, _put, _fetch, the command.loader = false.\n */\n private determineConsoleWritingDuringCommand() {\n if (this.command.loader && !this.flags.json && !this.flags['get-yargs-completions']) {\n loader.on();\n loader.start(`running command \"${this.commandName}\"...`);\n logger.shouldWriteToConsole = true;\n } else {\n loader.off();\n logger.shouldWriteToConsole = false;\n }\n if (this.flags.log) {\n // probably not necessary anymore. it is handled in src/logger - determineWritingLogToScreen()\n const logValue = typeof this.flags.log === 'string' ? this.flags.log : undefined;\n logger.switchToConsoleLogger(logValue as LoggerLevel);\n }\n }\n\n private async writeAndExit(data: string, exitCode: number) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return process.stdout.write(data, async () => logger.exitAfterFlush(exitCode, this.commandName, data));\n }\n\n private async runMigrateIfNeeded(): Promise<any> {\n // @ts-ignore LegacyCommandAdapter has .migration\n if (this.command.migration) {\n logger.debug('Checking if a migration is needed');\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return migrate(null, false);\n }\n return null;\n }\n}\n\nfunction toRenderResult(obj: RenderResult | React.ReactElement) {\n return isRenderResult(obj) ? obj : { data: obj, code: 0 };\n}\n\nfunction isRenderResult(obj: RenderResult | any): obj is RenderResult {\n // eslint-disable-next-line no-prototype-builtins\n return typeof obj === 'object' && typeof obj.code === 'number' && obj.hasOwnProperty('data');\n}\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OA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,CAACR,OAAO,CAACoD,SAAS,EAAE;MAC1B9B,iBAAM,CAAC+B,KAAK,CAAC,mCAAmC,CAAC;MACjD;MACA,OAAO,IAAAC,mBAAO,EAAC,IAAI,EAAE,KAAK,CAAC;IAC7B;IACA,OAAO,IAAI;EACb;AACF;AAACC,OAAA,CAAAzD,aAAA,GAAAA,aAAA;AAED,SAAS2C,cAAcA,CAACpE,GAAsC,EAAE;EAC9D,OAAOmF,cAAc,CAACnF,GAAG,CAAC,GAAGA,GAAG,GAAG;IAAEX,IAAI,EAAEW,GAAG;IAAE8D,IAAI,EAAE;EAAE,CAAC;AAC3D;AAEA,SAASqB,cAAcA,CAACnF,GAAuB,EAAuB;EACpE;EACA,OAAO,OAAOA,GAAG,KAAK,QAAQ,IAAI,OAAOA,GAAG,CAAC8D,IAAI,KAAK,QAAQ,IAAI9D,GAAG,CAACoF,cAAc,CAAC,MAAM,CAAC;AAC9F"}
|
package/dist/completion.cmd.js
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.CompletionCmd = void 0;
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return data;
|
|
12
|
-
};
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
9
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
10
|
class CompletionCmd {
|
|
16
11
|
constructor() {
|
|
17
|
-
(
|
|
18
|
-
(
|
|
19
|
-
(
|
|
20
|
-
(
|
|
21
|
-
(
|
|
12
|
+
_defineProperty(this, "name", 'completion');
|
|
13
|
+
_defineProperty(this, "description", 'enable bash/zsh-completion shortcuts for commands and options');
|
|
14
|
+
_defineProperty(this, "alias", '');
|
|
15
|
+
_defineProperty(this, "group", 'general');
|
|
16
|
+
_defineProperty(this, "options", []);
|
|
22
17
|
}
|
|
23
18
|
}
|
|
24
19
|
exports.CompletionCmd = CompletionCmd;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CompletionCmd","constructor","
|
|
1
|
+
{"version":3,"names":["CompletionCmd","constructor","_defineProperty","exports"],"sources":["completion.cmd.ts"],"sourcesContent":["import { Command } from '@teambit/legacy/dist/cli/command';\n\nexport class CompletionCmd implements Command {\n name = 'completion';\n description = 'enable bash/zsh-completion shortcuts for commands and options';\n alias = '';\n group = 'general';\n options = [];\n}\n"],"mappings":";;;;;;;;;AAEO,MAAMA,aAAa,CAAoB;EAAAC,YAAA;IAAAC,eAAA,eACrC,YAAY;IAAAA,eAAA,sBACL,+DAA+D;IAAAA,eAAA,gBACrE,EAAE;IAAAA,eAAA,gBACF,SAAS;IAAAA,eAAA,kBACP,EAAE;EAAA;AACd;AAACC,OAAA,CAAAH,aAAA,GAAAA,aAAA"}
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.CommandNotFound = void 0;
|
|
8
|
-
function _defineProperty2() {
|
|
9
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
_defineProperty2 = function () {
|
|
11
|
-
return data;
|
|
12
|
-
};
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
15
7
|
function _bitError() {
|
|
16
8
|
const data = require("@teambit/bit-error");
|
|
17
9
|
_bitError = function () {
|
|
@@ -26,11 +18,15 @@ function _chalk() {
|
|
|
26
18
|
};
|
|
27
19
|
return data;
|
|
28
20
|
}
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
24
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
29
25
|
class CommandNotFound extends _bitError().BitError {
|
|
30
26
|
constructor(commandName, suggestion) {
|
|
31
27
|
super(`command ${commandName} was not found`);
|
|
32
|
-
(
|
|
33
|
-
(
|
|
28
|
+
_defineProperty(this, "commandName", void 0);
|
|
29
|
+
_defineProperty(this, "suggestion", void 0);
|
|
34
30
|
this.commandName = commandName;
|
|
35
31
|
this.suggestion = suggestion;
|
|
36
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_bitError","data","require","_chalk","_interopRequireDefault","
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","_chalk","_interopRequireDefault","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","CommandNotFound","BitError","constructor","commandName","suggestion","report","output","chalk","yellow","bold","exports"],"sources":["command-not-found.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport chalk from 'chalk';\n\nexport class CommandNotFound extends BitError {\n commandName: string;\n suggestion?: string;\n constructor(commandName: string, suggestion?: string) {\n super(`command ${commandName} was not found`);\n this.commandName = commandName;\n this.suggestion = suggestion;\n }\n report() {\n let output = chalk.yellow(\n `warning: '${chalk.bold(this.commandName)}' is not a valid command.\nsee 'bit help' for additional information`\n );\n if (this.suggestion) {\n output += `\\nDid you mean ${chalk.bold(this.suggestion)}?`;\n }\n return output;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAX,GAAA,CAAAI,GAAA,IAAAC,KAAA,WAAAL,GAAA;AAAA,SAAAM,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AAEnB,MAAMU,eAAe,SAASC,oBAAQ,CAAC;EAG5CC,WAAWA,CAACC,WAAmB,EAAEC,UAAmB,EAAE;IACpD,KAAK,CAAE,WAAUD,WAAY,gBAAe,CAAC;IAACzB,eAAA;IAAAA,eAAA;IAC9C,IAAI,CAACyB,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,UAAU,GAAGA,UAAU;EAC9B;EACAC,MAAMA,CAAA,EAAG;IACP,IAAIC,MAAM,GAAGC,gBAAK,CAACC,MAAM,CACtB,aAAYD,gBAAK,CAACE,IAAI,CAAC,IAAI,CAACN,WAAW,CAAE;AAChD,0CACI,CAAC;IACD,IAAI,IAAI,CAACC,UAAU,EAAE;MACnBE,MAAM,IAAK,kBAAiBC,gBAAK,CAACE,IAAI,CAAC,IAAI,CAACL,UAAU,CAAE,GAAE;IAC5D;IACA,OAAOE,MAAM;EACf;AACF;AAACI,OAAA,CAAAV,eAAA,GAAAA,eAAA"}
|
package/dist/generate-doc-md.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.description.js");
|
|
4
|
-
require("core-js/modules/es.array.iterator.js");
|
|
5
|
-
require("core-js/modules/es.array.sort.js");
|
|
6
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
7
3
|
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_lodash","data","require","_getCommandId","GenerateCommandsDoc","constructor","commands","options","generate","getAllPublicCommandsSorted","output","getFrontmatter","map","cmd","generateCommand","join","generateJson","commandsToObjects","command","_command$commands","cmdObject","oneCommandToObject","length","metadata","metadataStr","Object","keys","key","publicCommands","filter","private","sort","a","b","name","localeCompare","commandName","getCommandId","result","alias","formatDescription","generateSubCommands","generateArguments","arguments","generateOptions","subCommands","ret","forEach","subCommand","subcommandName","usage","args","arg","description","replaceAll","opt","flag","aliasFormatted","flagFormatted","formatStringToMD","str","split","extendedDescription","exports","pick"],"sources":["generate-doc-md.ts"],"sourcesContent":["import { Command, CommandArg } 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\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 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,CAASC,QAAmB,EAAUC,OAAqB,EAAE;IAAA,KAApDD,QAAmB,GAAnBA,QAAmB;IAAA,KAAUC,OAAqB,GAArBA,OAAqB;EAAG;EAEzEC,QAAQA,CAAA,EAAW;IACjB,MAAMF,QAAQ,GAAG,IAAI,CAACG,0BAA0B,CAAC,CAAC;IAClD,IAAIC,MAAM,GAAI,GAAE,IAAI,CAACC,cAAc,CAAC,CAAE;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;IACGD,MAAM,IAAIJ,QAAQ,CAACM,GAAG,CAAEC,GAAG,IAAK,IAAI,CAACC,eAAe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AAc,MAAKD,cAAe,IAAGJ,WAAW,CAACC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAE,KAAI;IAC7F,CAAC,CAAC;IACF5C,MAAM,IAAK,IAAG;IACd,OAAOA,MAAM;EACf;EAEQiD,gBAAgBA,CAACC,GAAW,EAAU;IAC5C,OAAOA,GAAG,CAACC,KAAK,CAAC,IAAI,CAAC,CAAC9C,IAAI,CAAC,MAAM,CAAC;EACrC;EAEQyB,iBAAiBA,CAACtB,OAAgB,EAAU;IAClD,MAAM4C,mBAAmB,GAAG5C,OAAO,CAAC4C,mBAAmB,GAClD,OAAM,IAAI,CAACH,gBAAgB,CAACzC,OAAO,CAAC4C,mBAAmB,CAAE,EAAC,GAC3D,EAAE;IACN,MAAMT,WAAW,GAAG,IAAI,CAACM,gBAAgB,CAACzC,OAAO,CAACmC,WAAqB,CAAC;IACxE,OAAQ,GAAEA,WAAY,GAAES,mBAAoB,QAAO;EACrD;AACF;AAACC,OAAA,CAAA3D,mBAAA,GAAAA,mBAAA;AAED,SAASiB,kBAAkBA,CAACH,OAAgB,EAAE;EAC5C,OAAO,IAAA8C,cAAI,EAAC9C,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"}
|
|
1
|
+
{"version":3,"names":["_lodash","data","require","_getCommandId","GenerateCommandsDoc","constructor","commands","options","generate","getAllPublicCommandsSorted","output","getFrontmatter","map","cmd","generateCommand","join","generateJson","commandsToObjects","command","_command$commands","cmdObject","oneCommandToObject","length","metadata","metadataStr","Object","keys","key","publicCommands","filter","private","sort","a","b","name","localeCompare","commandName","getCommandId","result","alias","formatDescription","generateSubCommands","generateArguments","arguments","generateOptions","subCommands","ret","forEach","subCommand","subcommandName","usage","args","arg","description","replaceAll","opt","flag","aliasFormatted","flagFormatted","formatStringToMD","str","split","extendedDescription","exports","pick"],"sources":["generate-doc-md.ts"],"sourcesContent":["import { Command, CommandArg } 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\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 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,CAASC,QAAmB,EAAUC,OAAqB,EAAE;IAAA,KAApDD,QAAmB,GAAnBA,QAAmB;IAAA,KAAUC,OAAqB,GAArBA,OAAqB;EAAG;EAEzEC,QAAQA,CAAA,EAAW;IACjB,MAAMF,QAAQ,GAAG,IAAI,CAACG,0BAA0B,CAAC,CAAC;IAClD,IAAIC,MAAM,GAAI,GAAE,IAAI,CAACC,cAAc,CAAC,CAAE;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;IACGD,MAAM,IAAIJ,QAAQ,CAACM,GAAG,CAAEC,GAAG,IAAK,IAAI,CAACC,eAAe,CAACD,GAAG,CAAC,CAAC,CAACE,IAAI,CAAC,IAAI,CAAC;IAErE,OAAOL,MAAM;EACf;EAEAM,YAAYA,CAAA,EAAG;IACb,OAAO,IAAI,CAACC,iBAAiB,CAAC,CAAC;EACjC;EAEQA,iBAAiBA,CAACX,QAAmB,GAAG,IAAI,CAACA,QAAQ,EAAmB;IAC9E,OAAOA,QAAQ,CAACM,GAAG,CAAEM,OAAO,IAAK;MAAA,IAAAC,iBAAA;MAC/B,MAAMC,S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AAU;IAClD,MAAM4C,mBAAmB,GAAG5C,OAAO,CAAC4C,mBAAmB,GAClD,OAAM,IAAI,CAACH,gBAAgB,CAACzC,OAAO,CAAC4C,mBAAmB,CAAE,EAAC,GAC3D,EAAE;IACN,MAAMT,WAAW,GAAG,IAAI,CAACM,gBAAgB,CAACzC,OAAO,CAACmC,WAAqB,CAAC;IACxE,OAAQ,GAAEA,WAAY,GAAES,mBAAoB,QAAO;EACrD;AACF;AAACC,OAAA,CAAA3D,mBAAA,GAAAA,mBAAA;AAED,SAASiB,kBAAkBA,CAACH,OAAgB,EAAE;EAC5C,OAAO,IAAA8C,cAAI,EAAC9C,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 +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,YAAYA,CAACC,OAAe,EAAE;EAC5C,OAAOA,OAAO,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC;AACrC"}
|
package/dist/help.cmd.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.promise.js");
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.HelpCmd = void 0;
|
|
9
|
-
function _defineProperty2() {
|
|
10
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
_defineProperty2 = function () {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
return data;
|
|
15
|
-
}
|
|
16
7
|
function _help() {
|
|
17
8
|
const data = require("./help");
|
|
18
9
|
_help = function () {
|
|
@@ -20,16 +11,19 @@ function _help() {
|
|
|
20
11
|
};
|
|
21
12
|
return data;
|
|
22
13
|
}
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
16
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
23
17
|
class HelpCmd {
|
|
24
18
|
constructor(cliMain) {
|
|
25
19
|
this.cliMain = cliMain;
|
|
26
|
-
(
|
|
27
|
-
(
|
|
28
|
-
(
|
|
20
|
+
_defineProperty(this, "name", 'help');
|
|
21
|
+
_defineProperty(this, "description", 'shows help');
|
|
22
|
+
_defineProperty(this, "alias", '$0');
|
|
29
23
|
// 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
|
|
30
|
-
(
|
|
31
|
-
(
|
|
32
|
-
(
|
|
24
|
+
_defineProperty(this, "loader", false);
|
|
25
|
+
_defineProperty(this, "group", 'general');
|
|
26
|
+
_defineProperty(this, "options", [['', 'internal', 'show internal commands']]);
|
|
33
27
|
}
|
|
34
28
|
async report(_, {
|
|
35
29
|
internal
|
package/dist/help.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_help","data","require","
|
|
1
|
+
{"version":3,"names":["_help","data","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","HelpCmd","constructor","cliMain","report","_","internal","formatHelp","commands","groups","exports"],"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 = [['', '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 }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAoC,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AAE7B,MAAMU,OAAO,CAAoB;EAQtCC,WAAWA,CAASC,OAAgB,EAAE;IAAA,KAAlBA,OAAgB,GAAhBA,OAAgB;IAAAzB,eAAA,eAP7B,MAAM;IAAAA,eAAA,sBACC,YAAY;IAAAA,eAAA,gBAClB,IAAI;IAAE;IAAAA,eAAA,iBACL,KAAK;IAAAA,eAAA,gBACN,SAAS;IAAAA,eAAA,kBACP,CAAC,CAAC,EAAE,EAAE,UAAU,EAAE,wBAAwB,CAAC,CAAC;EAEf;EAEvC,MAAM0B,MAAMA,CAACC,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"}
|
package/dist/help.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.symbol.description.js");
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -34,6 +32,7 @@ function _getCommandId() {
|
|
|
34
32
|
};
|
|
35
33
|
return data;
|
|
36
34
|
}
|
|
35
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
36
|
const SPACE = ' ';
|
|
38
37
|
const TITLE_LEFT_SPACES_NUMBER = 2;
|
|
39
38
|
const COMMAND_LEFT_SPACES_NUMBER = 4;
|
package/dist/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_padRight","_lodash","_getCommandId","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 { 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, 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(\"please use 'bit <command> --help' for more information and guides on specific commands.\")}`;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_padRight","_lodash","_getCommandId","obj","__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 { 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, 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(\"please use 'bit <command> --help' for more information and guides on specific 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,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhD,MAAMG,KAAK,GAAG,GAAG;AACjB,MAAMC,wBAAwB,GAAG,CAAC;AAClC,MAAMC,0BAA0B,GAAG,CAAC;AACpC,MAAMC,uBAAuB,GAAG,EAAE;AAW3B,SAASC,UAAUA,CAACC,QAAqB,EAAEC,MAAkB,EAAEC,mBAAmB,GAAG,KAAK,EAAE;EACjG,MAAMC,SAA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|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.symbol.description.js");
|
|
5
|
-
require("core-js/modules/es.promise.js");
|
|
6
3
|
Object.defineProperty(exports, "__esModule", {
|
|
7
4
|
value: true
|
|
8
5
|
});
|
|
9
6
|
exports.LegacyCommandAdapter = void 0;
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return data;
|
|
14
|
-
};
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
9
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
10
|
class LegacyCommandAdapter {
|
|
18
11
|
constructor(cmd, cliExtension) {
|
|
19
12
|
this.cmd = cmd;
|
|
20
|
-
(
|
|
21
|
-
(
|
|
22
|
-
(
|
|
23
|
-
(
|
|
24
|
-
(
|
|
25
|
-
(
|
|
26
|
-
(
|
|
27
|
-
(
|
|
28
|
-
(
|
|
29
|
-
(
|
|
30
|
-
(
|
|
31
|
-
(
|
|
32
|
-
(
|
|
33
|
-
(
|
|
13
|
+
_defineProperty(this, "alias", void 0);
|
|
14
|
+
_defineProperty(this, "name", void 0);
|
|
15
|
+
_defineProperty(this, "description", void 0);
|
|
16
|
+
_defineProperty(this, "options", void 0);
|
|
17
|
+
_defineProperty(this, "extendedDescription", void 0);
|
|
18
|
+
_defineProperty(this, "group", void 0);
|
|
19
|
+
_defineProperty(this, "loader", void 0);
|
|
20
|
+
_defineProperty(this, "commands", void 0);
|
|
21
|
+
_defineProperty(this, "private", void 0);
|
|
22
|
+
_defineProperty(this, "migration", void 0);
|
|
23
|
+
_defineProperty(this, "internal", void 0);
|
|
24
|
+
_defineProperty(this, "skipWorkspace", void 0);
|
|
25
|
+
_defineProperty(this, "helpUrl", void 0);
|
|
26
|
+
_defineProperty(this, "_packageManagerArgs", void 0);
|
|
34
27
|
this.name = cmd.name;
|
|
35
28
|
this.description = cmd.description;
|
|
36
29
|
this.helpUrl = cmd.helpUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LegacyCommandAdapter","constructor","cmd","cliExtension","
|
|
1
|
+
{"version":3,"names":["LegacyCommandAdapter","constructor","cmd","cliExtension","_defineProperty","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","exports"],"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,WAAWA,CAASC,GAAkB,EAAEC,YAAqB,EAAE;IAAA,KAA3CD,GAAkB,GAAlBA,GAAkB;IAAAE,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACpC,IAAI,CAACC,IAAI,GAAGH,GAAG,CAACG,IAAI;IACpB,IAAI,CAACC,WAAW,GAAGJ,GAAG,CAACI,WAAW;IAClC,IAAI,CAACC,OAAO,GAAGL,GAAG,CAACK,OAAO;IAC1B,IAAI,CAACC,OAAO,GAAGN,GAAG,CAACO,IAAI,IAAI,EAAE;IAC7B,IAAI,CAACC,KAAK,GAAGR,GAAG,CAACQ,KAAK;IACtB,IAAI,CAACC,mBAAmB,GAAGT,GAAG,CAACS,mBAAmB;IAClD,IAAI,CAACC,aAAa,GAAGV,GAAG,CAACU,aAAa;IACtC,IAAI,CAACC,KAAK,GAAGX,GAAG,CAACW,KAAK;IACtB,IAAI,CAACC,MAAM,GAAGZ,GAAG,CAACY,MAAM;IACxB,IAAI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AO;MACLiB,IAAI,EAAEO,IAAI,CAACC,KAAK,CAACH,YAAY,CAACD,MAAM,CAAC;MACrCH,IAAI,EAAEI,YAAY,CAACJ;IACrB,CAAC;EACH;AACF;AAACQ,OAAA,CAAAlC,oBAAA,GAAAA,oBAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.773/dist/cli.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.773/dist/cli.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/dist/yargs-adapter.js
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.symbol.description.js");
|
|
5
|
-
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
7
|
-
require("core-js/modules/es.string.trim.js");
|
|
8
3
|
Object.defineProperty(exports, "__esModule", {
|
|
9
4
|
value: true
|
|
10
5
|
});
|
|
11
6
|
exports.YargsAdapter = exports.STANDARD_GROUP = exports.GLOBAL_GROUP = void 0;
|
|
12
|
-
function _defineProperty2() {
|
|
13
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
_defineProperty2 = function () {
|
|
15
|
-
return data;
|
|
16
|
-
};
|
|
17
|
-
return data;
|
|
18
|
-
}
|
|
19
7
|
function _constants() {
|
|
20
8
|
const data = require("@teambit/legacy/dist/constants");
|
|
21
9
|
_constants = function () {
|
|
@@ -38,7 +26,10 @@ function _commandRunner() {
|
|
|
38
26
|
return data;
|
|
39
27
|
}
|
|
40
28
|
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; }
|
|
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) { (
|
|
29
|
+
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) { _defineProperty(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; }
|
|
30
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
32
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
42
33
|
const GLOBAL_GROUP = 'Global';
|
|
43
34
|
exports.GLOBAL_GROUP = GLOBAL_GROUP;
|
|
44
35
|
const STANDARD_GROUP = 'Options';
|
|
@@ -46,9 +37,9 @@ exports.STANDARD_GROUP = STANDARD_GROUP;
|
|
|
46
37
|
class YargsAdapter {
|
|
47
38
|
constructor(commanderCommand) {
|
|
48
39
|
this.commanderCommand = commanderCommand;
|
|
49
|
-
(
|
|
50
|
-
(
|
|
51
|
-
(
|
|
40
|
+
_defineProperty(this, "command", void 0);
|
|
41
|
+
_defineProperty(this, "describe", void 0);
|
|
42
|
+
_defineProperty(this, "aliases", void 0);
|
|
52
43
|
this.command = commanderCommand.name;
|
|
53
44
|
this.describe = commanderCommand.description;
|
|
54
45
|
this.aliases = commanderCommand.alias;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_constants","data","require","_lodash","_commandRunner","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","GLOBAL_GROUP","exports","STANDARD_GROUP","YargsAdapter","constructor","commanderCommand","command","name","describe","description","aliases","alias","builder","yargs","_this$commanderComman","_this$commanderComman2","options","optionsToBuilder","option","arg","positional","examples","example","cmd","handler","argv","enteredArgs","getArgsFromCommandName","argsValues","map","a","flags","reduce","acc","current","val","_packageManagerArgs","commandRunner","CommandRunner","runCommand","opt","desc","optName","split","group","type","includes","requiresArg","globalOptions","getGlobalOptions","remoteOp","TOKEN_FLAG","internal","log","commandName","commandSplit","shift","existArg","trimmed","trim","startsWith","endsWith","Error","withoutBrackets","slice","camelCase"],"sources":["yargs-adapter.ts"],"sourcesContent":["import { Command } from '@teambit/legacy/dist/cli/command';\nimport { Arguments, CommandModule, Argv, Options } from 'yargs';\nimport { TOKEN_FLAG } from '@teambit/legacy/dist/constants';\nimport { camelCase } from 'lodash';\nimport { CommandRunner } from './command-runner';\n\nexport const GLOBAL_GROUP = 'Global';\nexport const STANDARD_GROUP = 'Options';\n\nexport class YargsAdapter implements CommandModule {\n command: string;\n describe?: string;\n aliases?: string;\n constructor(private commanderCommand: Command) {\n this.command = commanderCommand.name;\n this.describe = commanderCommand.description;\n this.aliases = commanderCommand.alias;\n }\n\n builder(yargs: Argv) {\n const options = YargsAdapter.optionsToBuilder(this.commanderCommand);\n yargs.option(options);\n this.commanderCommand.arguments?.forEach((arg) => {\n yargs.positional(arg.name, { description: arg.description });\n });\n this.commanderCommand.examples?.forEach((example) => {\n yargs.example(example.cmd, example.description);\n });\n\n return yargs;\n }\n\n handler(argv: Arguments) {\n const enteredArgs = getArgsFromCommandName(this.commanderCommand.name);\n const argsValues = enteredArgs.map((a) => argv[a]) as any[];\n // a workaround to get a flag syntax such as \"--all [version]\" work with yargs.\n const flags = Object.keys(argv).reduce((acc, current) => {\n if (current === '_' || current === '$0' || current === '--') return acc;\n // const flagName = current.split(' ')[0];\n const val = typeof argv[current] === 'string' && !argv[current] ? true : argv[current];\n acc[current] = val;\n return acc;\n }, {});\n this.commanderCommand._packageManagerArgs = (argv['--'] || []) as string[];\n\n const commandRunner = new CommandRunner(this.commanderCommand, argsValues, flags);\n return commandRunner.runCommand();\n }\n\n get positional() {\n return this.commanderCommand.arguments;\n }\n\n static optionsToBuilder(command: Command): { [key: string]: Options } {\n const option = command.options.reduce((acc, [alias, opt, desc]) => {\n const optName = opt.split(' ')[0];\n acc[optName] = {\n alias,\n describe: desc,\n group: STANDARD_GROUP,\n type: opt.includes(' ') ? 'string' : 'boolean',\n requiresArg: opt.includes('<'),\n } as Options;\n return acc;\n }, {});\n const globalOptions = YargsAdapter.getGlobalOptions(command);\n\n return { ...option, ...globalOptions };\n }\n\n static getGlobalOptions(command: Command): Record<string, any> {\n const globalOptions: Record<string, any> = {};\n if (command.remoteOp) {\n globalOptions[TOKEN_FLAG] = {\n describe: 'authentication token',\n group: GLOBAL_GROUP,\n };\n }\n if (!command.internal) {\n globalOptions.log = {\n describe:\n 'print log messages to the screen, options are: [trace, debug, info, warn, error, fatal], the default is info',\n group: GLOBAL_GROUP,\n };\n globalOptions['safe-mode'] = {\n describe:\n 'bootstrap the bare-minimum with only the CLI aspect. useful mainly for low-level commands when bit refuses to load',\n group: GLOBAL_GROUP,\n };\n }\n return globalOptions;\n }\n}\n\nfunction getArgsFromCommandName(commandName: string) {\n const commandSplit = commandName.split(' ');\n commandSplit.shift(); // remove the first element, it's the command-name\n\n return commandSplit.map((existArg) => {\n const trimmed = existArg.trim();\n if ((!trimmed.startsWith('<') && !trimmed.startsWith('[')) || (!trimmed.endsWith('>') && !trimmed.endsWith(']'))) {\n throw new Error(`expect arg \"${trimmed}\" of \"${commandName}\" to be wrapped with \"[]\" or \"<>\"`);\n }\n // remove the opening and closing brackets\n const withoutBrackets = trimmed.slice(1, -1);\n\n return camelCase(withoutBrackets);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAEA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,eAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,cAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiD,SAAAI,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,w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AACJ"}
|
|
1
|
+
{"version":3,"names":["_constants","data","require","_lodash","_commandRunner","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","GLOBAL_GROUP","exports","STANDARD_GROUP","YargsAdapter","constructor","commanderCommand","command","name","describe","description","aliases","alias","builder","yargs","_this$commanderComman","_this$commanderComman2","options","optionsToBuilder","option","positional","examples","example","cmd","handler","argv","enteredArgs","getArgsFromCommandName","argsValues","map","a","flags","reduce","acc","current","val","_packageManagerArgs","commandRunner","CommandRunner","runCommand","opt","desc","optName","split","group","type","includes","requiresArg","globalOptions","getGlobalOptions","remoteOp","TOKEN_FLAG","internal","log","commandName","commandSplit","shift","existArg","trimmed","trim","startsWith","endsWith","Error","withoutBrackets","slice","camelCase"],"sources":["yargs-adapter.ts"],"sourcesContent":["import { Command } from '@teambit/legacy/dist/cli/command';\nimport { Arguments, CommandModule, Argv, Options } from 'yargs';\nimport { TOKEN_FLAG } from '@teambit/legacy/dist/constants';\nimport { camelCase } from 'lodash';\nimport { CommandRunner } from './command-runner';\n\nexport const GLOBAL_GROUP = 'Global';\nexport const STANDARD_GROUP = 'Options';\n\nexport class YargsAdapter implements CommandModule {\n command: string;\n describe?: string;\n aliases?: string;\n constructor(private commanderCommand: Command) {\n this.command = commanderCommand.name;\n this.describe = commanderCommand.description;\n this.aliases = commanderCommand.alias;\n }\n\n builder(yargs: Argv) {\n const options = YargsAdapter.optionsToBuilder(this.commanderCommand);\n yargs.option(options);\n this.commanderCommand.arguments?.forEach((arg) => {\n yargs.positional(arg.name, { description: arg.description });\n });\n this.commanderCommand.examples?.forEach((example) => {\n yargs.example(example.cmd, example.description);\n });\n\n return yargs;\n }\n\n handler(argv: Arguments) {\n const enteredArgs = getArgsFromCommandName(this.commanderCommand.name);\n const argsValues = enteredArgs.map((a) => argv[a]) as any[];\n // a workaround to get a flag syntax such as \"--all [version]\" work with yargs.\n const flags = Object.keys(argv).reduce((acc, current) => {\n if (current === '_' || current === '$0' || current === '--') return acc;\n // const flagName = current.split(' ')[0];\n const val = typeof argv[current] === 'string' && !argv[current] ? true : argv[current];\n acc[current] = val;\n return acc;\n }, {});\n this.commanderCommand._packageManagerArgs = (argv['--'] || []) as string[];\n\n const commandRunner = new CommandRunner(this.commanderCommand, argsValues, flags);\n return commandRunner.runCommand();\n }\n\n get positional() {\n return this.commanderCommand.arguments;\n }\n\n static optionsToBuilder(command: Command): { [key: string]: Options } {\n const option = command.options.reduce((acc, [alias, opt, desc]) => {\n const optName = opt.split(' ')[0];\n acc[optName] = {\n alias,\n describe: desc,\n group: STANDARD_GROUP,\n type: opt.includes(' ') ? 'string' : 'boolean',\n requiresArg: opt.includes('<'),\n } as Options;\n return acc;\n }, {});\n const globalOptions = YargsAdapter.getGlobalOptions(command);\n\n return { ...option, ...globalOptions };\n }\n\n static getGlobalOptions(command: Command): Record<string, any> {\n const globalOptions: Record<string, any> = {};\n if (command.remoteOp) {\n globalOptions[TOKEN_FLAG] = {\n describe: 'authentication token',\n group: GLOBAL_GROUP,\n };\n }\n if (!command.internal) {\n globalOptions.log = {\n describe:\n 'print log messages to the screen, options are: [trace, debug, info, warn, error, fatal], the default is info',\n group: GLOBAL_GROUP,\n };\n globalOptions['safe-mode'] = {\n describe:\n 'bootstrap the bare-minimum with only the CLI aspect. useful mainly for low-level commands when bit refuses to load',\n group: GLOBAL_GROUP,\n };\n }\n return globalOptions;\n }\n}\n\nfunction getArgsFromCommandName(commandName: string) {\n const commandSplit = commandName.split(' ');\n commandSplit.shift(); // remove the first element, it's the command-name\n\n return commandSplit.map((existArg) => {\n const trimmed = existArg.trim();\n if ((!trimmed.startsWith('<') && !trimmed.startsWith('[')) || (!trimmed.endsWith('>') && !trimmed.endsWith(']'))) {\n throw new Error(`expect arg \"${trimmed}\" of \"${commandName}\" to be wrapped with \"[]\" or \"<>\"`);\n }\n // remove the opening and closing brackets\n const withoutBrackets = trimmed.slice(1, -1);\n\n return camelCase(withoutBrackets);\n });\n}\n"],"mappings":";;;;;;AAEA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,eAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,cAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiD,SAAAI,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,IAAAC,eAAA,CAAAP,MAAA,EAAAM,G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I,CAACH,OAAO,CAACG,QAAQ,CAAC,GAAG,CAAE,EAAE;MAChH,MAAM,IAAIC,KAAK,CAAE,eAAcJ,OAAQ,SAAQJ,WAAY,mCAAkC,CAAC;IAChG;IACA;IACA,MAAMS,eAAe,GAAGL,OAAO,CAACM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE5C,OAAO,IAAAC,mBAAS,EAACF,eAAe,CAAC;EACnC,CAAC,CAAC;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.773",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/harmony/cli",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.harmony",
|
|
8
8
|
"name": "cli",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.773"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -16,10 +16,8 @@
|
|
|
16
16
|
"p-map-series": "2.1.0",
|
|
17
17
|
"ink": "3.2.0",
|
|
18
18
|
"pad-right": "0.2.2",
|
|
19
|
-
"core-js": "^3.0.0",
|
|
20
|
-
"@babel/runtime": "7.20.0",
|
|
21
19
|
"@teambit/harmony": "0.4.6",
|
|
22
|
-
"@teambit/logger": "0.0.
|
|
20
|
+
"@teambit/logger": "0.0.866",
|
|
23
21
|
"@teambit/bit-error": "0.0.402"
|
|
24
22
|
},
|
|
25
23
|
"devDependencies": {
|
|
@@ -34,7 +32,7 @@
|
|
|
34
32
|
"@types/testing-library__jest-dom": "5.9.5"
|
|
35
33
|
},
|
|
36
34
|
"peerDependencies": {
|
|
37
|
-
"@teambit/legacy": "1.0.
|
|
35
|
+
"@teambit/legacy": "1.0.558",
|
|
38
36
|
"react": "^16.8.0 || ^17.0.0",
|
|
39
37
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
40
38
|
},
|