@teambit/cli 0.0.1047 → 0.0.1049

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.
@@ -40,9 +40,9 @@ function _logger() {
40
40
  };
41
41
  return data;
42
42
  }
43
- function _loader() {
44
- const data = _interopRequireDefault(require("@teambit/legacy/dist/cli/loader"));
45
- _loader = function () {
43
+ function _legacy() {
44
+ const data = require("@teambit/legacy.loader");
45
+ _legacy = function () {
46
46
  return data;
47
47
  };
48
48
  return data;
@@ -149,7 +149,7 @@ class CLIParser {
149
149
  process.exit(0);
150
150
  }
151
151
  if (argv.help) {
152
- _loader().default.off(); // stop the "loading bit..." before showing help if needed
152
+ _legacy().loader.off(); // stop the "loading bit..." before showing help if needed
153
153
  // this is a command help page
154
154
  _yargs().default.showHelp(this.logCommandHelp.bind(this));
155
155
  process.exit(0);
@@ -158,7 +158,7 @@ class CLIParser {
158
158
  }
159
159
  handleCommandFailure() {
160
160
  _yargs().default.fail((msg, err) => {
161
- _loader().default.stop();
161
+ _legacy().loader.stop();
162
162
  if (err) {
163
163
  throw err;
164
164
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_didyoumean","data","_interopRequireDefault","require","_yargs","_lodash","_consumer","_logger","_loader","_chalk","_getCommandId","_help","_yargsAdapter","_commandNotFound","_yargsExitWorkaround","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","CLIParser","constructor","commands","groups","onCommandStartSlot","yargs","parse","args","process","argv","slice","throwForNonExistsCommand","logger","debug","join","writeCommandHistoryStart","help","configureParser","forEach","command","length","parseCommandWithSubCommands","yargsCommand","getYargsCommand","addYargsCommand","configureGlobalFlags","setHelpMiddleware","handleCommandFailure","configureCompletion","strict","wrap","currentYargsCommand","yargsCommands","find","y","commandRunner","Error","push","middleware","_","shouldShowInternalCommands","Boolean","internal","printHelp","exit","loader","off","showHelp","logCommandHelp","bind","fail","msg","err","stop","isHelpFlagEntered","includes","msgForDaemon","error","YargsExitWorkaround","helpMsg","isMsgAboutMissingArgs","startsWith","console","log","chalk","yellow","isDaemon","commandsToShowComponentIdsForCompletion","completion","current","completionFilter","done","consumer","loadConsumerIfExist","bitmapIdsFromCurrentLane","map","id","toStringWithoutVersion","formatHelp","parserConfiguration","yarnCommand","builderFunc","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","lines","split","linesWithoutEmpty","compact","cmdLine","description","globalOptions","subCommands","examples","optionsStarted","globalStarted","subCommandsStarted","positionalsStarted","examplesStarted","currentLine","STANDARD_GROUP","optionsColored","optLine","match","leadingSpaces","optionPart","rest","coloredOptionPart","replace","m","p1","p2","green","argsColored","arg","argName","optionsStr","argumentsStr","examplesStr","subCommandsStr","descriptionColored","desc","bold","extendedDescription","helpUrl","underline","descriptionStr","globalOptionsStr","finalOutput","exports","enteredCommand","enteredSubCommand","undefined","isCommandMatch","str"],"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';\nimport { OnCommandStartSlot } from './cli.main.runtime';\nimport { CommandRunner } from './command-runner';\nimport { YargsExitWorkaround } from './exceptions/yargs-exit-workaround';\n\nexport class CLIParser {\n public parser = yargs;\n private yargsCommands: YargsAdapter[] = [];\n constructor(\n private commands: Command[],\n private groups: GroupsType,\n private onCommandStartSlot: OnCommandStartSlot\n ) {}\n\n async parse(args = process.argv.slice(2)): Promise<CommandRunner> {\n this.throwForNonExistsCommand(args[0]);\n logger.debug(`[+] CLI-INPUT: ${args.join(' ')}`);\n logger.writeCommandHistoryStart();\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 this.addYargsCommand(yargsCommand);\n }\n });\n this.configureGlobalFlags();\n this.setHelpMiddleware();\n this.handleCommandFailure();\n this.configureCompletion();\n // yargs.showHelpOnFail(false); // doesn't help. it still shows the help on failure.\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 const currentYargsCommand = this.yargsCommands.find((y) => y.commandRunner);\n if (!currentYargsCommand) {\n // this happens when the args/flags are wrong. in this case, it prints the help of the command and in most cases\n // exits the process before reaching this line. however, in case logger.isDaemon is true, which is for bit-cli-server,\n // it doesn't exits the process, so we need to return undefined here.\n throw new Error(`yargs failed to parse the command \"${args.join(' ')}\" and also failed to catch it properly`);\n }\n return currentYargsCommand.commandRunner as CommandRunner;\n }\n\n private addYargsCommand(yargsCommand: YargsAdapter) {\n this.yargsCommands.push(yargsCommand);\n yargs.command(yargsCommand);\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 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 const args = process.argv.slice(2);\n const isHelpFlagEntered = args.includes('--help') || args.includes('-h');\n let msgForDaemon = '';\n try {\n yargs.showHelp(this.logCommandHelp.bind(this));\n } catch (error: any) {\n if (error instanceof YargsExitWorkaround) {\n msgForDaemon = error.helpMsg;\n } else {\n throw error;\n }\n }\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 msgForDaemon += `\\n${chalk.yellow(msg)}`;\n }\n if (logger.isDaemon) throw new YargsExitWorkaround(1, msgForDaemon);\n 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 if (logger.isDaemon) throw new YargsExitWorkaround(0, help);\n else console.log(help); // eslint-disable-line no-console\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 this.addYargsCommand(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 this.addYargsCommand(yarnCommand);\n }\n\n private getYargsCommand(command: Command): YargsAdapter {\n const yargsCommand = new YargsAdapter(command, this.onCommandStartSlot);\n yargsCommand.builder = yargsCommand.builder.bind(yargsCommand);\n yargsCommand.handler = yargsCommand.handler.bind(yargsCommand);\n\n return yargsCommand;\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 = findCommandByArgv(this.commands);\n\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((optLine) => {\n const match = optLine.match(/^(\\s*)(.+?)(\\s{2,}.*)/);\n if (match) {\n const leadingSpaces = match[1];\n const optionPart = match[2];\n const rest = match[3];\n const coloredOptionPart = optionPart.replace(\n /(^|[^a-zA-Z0-9])(--?[a-zA-Z][a-zA-Z-]*)/g,\n (m, p1, p2) => p1 + chalk.green(p2)\n );\n return leadingSpaces + coloredOptionPart + rest;\n } else {\n return optLine;\n }\n });\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 if (logger.isDaemon) throw new YargsExitWorkaround(0, finalOutput);\n else console.log(finalOutput); // eslint-disable-line no-console\n }\n}\n\nexport function findCommandByArgv(commands: Command[]): 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 = 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"],"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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,KAAK0E,GAAG,CACjB,CAAC;EACL,CAAC;EACD,MAAMjJ,OAAO,GAAGjB,QAAQ,CAAC+B,IAAI,CAAEiD,GAAG,IAAKiF,cAAc,CAACjF,GAAG,EAAE8E,cAAc,CAAC,CAAC;EAC3E,IAAI,CAAC7I,OAAO,EAAE;IACZ,OAAO+I,SAAS;EAClB;EACA,IAAI,CAAC/I,OAAO,CAACjB,QAAQ,IAAI,CAAC+J,iBAAiB,EAAE;IAC3C,OAAO9I,OAAO,CAAC,CAAC;EAClB;EACA,MAAMgE,UAAU,GAAGhE,OAAO,CAACjB,QAAQ,CAAC+B,IAAI,CAAEiD,GAAG,IAAKiF,cAAc,CAACjF,GAAG,EAAE+E,iBAAiB,CAAC,CAAC;EACzF,OAAO9E,UAAU,IAAIhE,OAAO;AAC9B","ignoreList":[]}
1
+ {"version":3,"names":["_didyoumean","data","_interopRequireDefault","require","_yargs","_lodash","_consumer","_logger","_legacy","_chalk","_getCommandId","_help","_yargsAdapter","_commandNotFound","_yargsExitWorkaround","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","CLIParser","constructor","commands","groups","onCommandStartSlot","yargs","parse","args","process","argv","slice","throwForNonExistsCommand","logger","debug","join","writeCommandHistoryStart","help","configureParser","forEach","command","length","parseCommandWithSubCommands","yargsCommand","getYargsCommand","addYargsCommand","configureGlobalFlags","setHelpMiddleware","handleCommandFailure","configureCompletion","strict","wrap","currentYargsCommand","yargsCommands","find","y","commandRunner","Error","push","middleware","_","shouldShowInternalCommands","Boolean","internal","printHelp","exit","loader","off","showHelp","logCommandHelp","bind","fail","msg","err","stop","isHelpFlagEntered","includes","msgForDaemon","error","YargsExitWorkaround","helpMsg","isMsgAboutMissingArgs","startsWith","console","log","chalk","yellow","isDaemon","commandsToShowComponentIdsForCompletion","completion","current","completionFilter","done","consumer","loadConsumerIfExist","bitmapIdsFromCurrentLane","map","id","toStringWithoutVersion","formatHelp","parserConfiguration","yarnCommand","builderFunc","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","lines","split","linesWithoutEmpty","compact","cmdLine","description","globalOptions","subCommands","examples","optionsStarted","globalStarted","subCommandsStarted","positionalsStarted","examplesStarted","currentLine","STANDARD_GROUP","optionsColored","optLine","match","leadingSpaces","optionPart","rest","coloredOptionPart","replace","m","p1","p2","green","argsColored","arg","argName","optionsStr","argumentsStr","examplesStr","subCommandsStr","descriptionColored","desc","bold","extendedDescription","helpUrl","underline","descriptionStr","globalOptionsStr","finalOutput","exports","enteredCommand","enteredSubCommand","undefined","isCommandMatch","str"],"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.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';\nimport { OnCommandStartSlot } from './cli.main.runtime';\nimport { CommandRunner } from './command-runner';\nimport { YargsExitWorkaround } from './exceptions/yargs-exit-workaround';\n\nexport class CLIParser {\n public parser = yargs;\n private yargsCommands: YargsAdapter[] = [];\n constructor(\n private commands: Command[],\n private groups: GroupsType,\n private onCommandStartSlot: OnCommandStartSlot\n ) {}\n\n async parse(args = process.argv.slice(2)): Promise<CommandRunner> {\n this.throwForNonExistsCommand(args[0]);\n logger.debug(`[+] CLI-INPUT: ${args.join(' ')}`);\n logger.writeCommandHistoryStart();\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 this.addYargsCommand(yargsCommand);\n }\n });\n this.configureGlobalFlags();\n this.setHelpMiddleware();\n this.handleCommandFailure();\n this.configureCompletion();\n // yargs.showHelpOnFail(false); // doesn't help. it still shows the help on failure.\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 const currentYargsCommand = this.yargsCommands.find((y) => y.commandRunner);\n if (!currentYargsCommand) {\n // this happens when the args/flags are wrong. in this case, it prints the help of the command and in most cases\n // exits the process before reaching this line. however, in case logger.isDaemon is true, which is for bit-cli-server,\n // it doesn't exits the process, so we need to return undefined here.\n throw new Error(`yargs failed to parse the command \"${args.join(' ')}\" and also failed to catch it properly`);\n }\n return currentYargsCommand.commandRunner as CommandRunner;\n }\n\n private addYargsCommand(yargsCommand: YargsAdapter) {\n this.yargsCommands.push(yargsCommand);\n yargs.command(yargsCommand);\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 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 const args = process.argv.slice(2);\n const isHelpFlagEntered = args.includes('--help') || args.includes('-h');\n let msgForDaemon = '';\n try {\n yargs.showHelp(this.logCommandHelp.bind(this));\n } catch (error: any) {\n if (error instanceof YargsExitWorkaround) {\n msgForDaemon = error.helpMsg;\n } else {\n throw error;\n }\n }\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 msgForDaemon += `\\n${chalk.yellow(msg)}`;\n }\n if (logger.isDaemon) throw new YargsExitWorkaround(1, msgForDaemon);\n 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 if (logger.isDaemon) throw new YargsExitWorkaround(0, help);\n else console.log(help); // eslint-disable-line no-console\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 this.addYargsCommand(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 this.addYargsCommand(yarnCommand);\n }\n\n private getYargsCommand(command: Command): YargsAdapter {\n const yargsCommand = new YargsAdapter(command, this.onCommandStartSlot);\n yargsCommand.builder = yargsCommand.builder.bind(yargsCommand);\n yargsCommand.handler = yargsCommand.handler.bind(yargsCommand);\n\n return yargsCommand;\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 = findCommandByArgv(this.commands);\n\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((optLine) => {\n const match = optLine.match(/^(\\s*)(.+?)(\\s{2,}.*)/);\n if (match) {\n const leadingSpaces = match[1];\n const optionPart = match[2];\n const rest = match[3];\n const coloredOptionPart = optionPart.replace(\n /(^|[^a-zA-Z0-9])(--?[a-zA-Z][a-zA-Z-]*)/g,\n (m, p1, p2) => p1 + chalk.green(p2)\n );\n return leadingSpaces + coloredOptionPart + rest;\n } else {\n return optLine;\n }\n });\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 if (logger.isDaemon) throw new YargsExitWorkaround(0, finalOutput);\n else console.log(finalOutput); // eslint-disable-line no-console\n }\n}\n\nexport function findCommandByArgv(commands: Command[]): 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 = 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"],"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;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ClB;EACA,IAAI,CAAC/I,OAAO,CAACjB,QAAQ,IAAI,CAAC+J,iBAAiB,EAAE;IAC3C,OAAO9I,OAAO,CAAC,CAAC;EAClB;EACA,MAAMgE,UAAU,GAAGhE,OAAO,CAACjB,QAAQ,CAAC+B,IAAI,CAAEiD,GAAG,IAAKiF,cAAc,CAACjF,GAAG,EAAE+E,iBAAiB,CAAC,CAAC;EACzF,OAAO9E,UAAU,IAAIhE,OAAO;AAC9B","ignoreList":[]}
@@ -46,6 +46,13 @@ function _consumer() {
46
46
  };
47
47
  return data;
48
48
  }
49
+ function _workspaceModules() {
50
+ const data = require("@teambit/workspace.modules.workspace-locator");
51
+ _workspaceModules = function () {
52
+ return data;
53
+ };
54
+ return data;
55
+ }
49
56
  function _logger2() {
50
57
  const data = require("@teambit/logger");
51
58
  _logger2 = function () {
@@ -283,8 +290,8 @@ async function ensureWorkspaceAndScope() {
283
290
  await (0, _consumer().loadConsumerIfExist)();
284
291
  } catch (err) {
285
292
  const potentialWsPath = process.cwd();
286
- const consumerInfo = await (0, _consumer().getConsumerInfo)(potentialWsPath);
287
- if (consumerInfo && !consumerInfo.hasScope && consumerInfo.hasBitMap && consumerInfo.hasConsumerConfig) {
293
+ const consumerInfo = await (0, _workspaceModules().getWorkspaceInfo)(potentialWsPath);
294
+ if (consumerInfo && !consumerInfo.hasScope && consumerInfo.hasBitMap && consumerInfo.hasWorkspaceConfig) {
288
295
  await _hostInitializer().HostInitializerMain.init(potentialWsPath);
289
296
  }
290
297
  // do nothing. it could fail for example with ScopeNotFound error, which is taken care of in "bit init".
@@ -1 +1 @@
1
- {"version":3,"names":["_harmony","data","require","_logger","_interopRequireDefault","_pMapSeries","_commandGroups","_hostInitializer","_consumer","_logger2","_lodash","_cli","_getCommandId","_cliParser","_completion","_cli2","_help","_version","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","CLIMain","constructor","commandsSlot","onStartSlot","onCommandStartSlot","onBeforeExitSlot","logger","clone","groups","register","commands","forEach","command","setDefaults","cmd","unregister","commandName","toArray","aspectId","filteredCommands","filter","getCommandId","name","map","set","values","flat","getCommand","find","getCommandByNameOrAlias","alias","registerGroup","description","consoleWarning","registerOnStart","onStartFn","registerOnCommandStart","onCommandStartFn","registerOnBeforeExit","onBeforeExitFn","legacyLogger","registerOnBeforeExitFn","run","hasWorkspace","invokeOnStart","CliParser","CLIParser","commandRunner","parse","runCommand","onStartFns","foundCmd","findCommandByArgv","currentCommandName","process","argv","pMapSeries","onStart","extendedDescription","group","options","private","trim","loader","undefined","loadAspects","helpUrl","isFullUrl","provider","loggerMain","config","createLogger","CLIAspect","id","cliMain","ensureWorkspaceAndScope","cliGenerateCmd","CliGenerateCmd","cliCmd","CliCmd","helpCmd","HelpCmd","push","CompletionCmd","VersionCmd","exports","LoggerAspect","MainRuntime","Slot","withType","addRuntime","loadConsumerIfExist","err","potentialWsPath","cwd","consumerInfo","getConsumerInfo","hasScope","hasBitMap","hasConsumerConfig","HostInitializerMain","init","url","startsWith"],"sources":["cli.main.runtime.ts"],"sourcesContent":["import { Slot, SlotRegistry } from '@teambit/harmony';\nimport legacyLogger from '@teambit/legacy/dist/logger/logger';\nimport { CLIArgs, Flags, Command } from '@teambit/legacy/dist/cli/command';\nimport pMapSeries from 'p-map-series';\nimport { groups, GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { HostInitializerMain } from '@teambit/host-initializer';\nimport { loadConsumerIfExist, getConsumerInfo } 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 { CLIParser, findCommandByArgv } from './cli-parser';\nimport { CompletionCmd } from './completion.cmd';\nimport { CliCmd, CliGenerateCmd } from './cli.cmd';\nimport { HelpCmd } from './help.cmd';\nimport { VersionCmd } from './version.cmd';\n\nexport type CommandList = Array<Command>;\nexport type OnStart = (hasWorkspace: boolean, currentCommand: string, commandObject?: Command) => Promise<void>;\nexport type OnCommandStart = (commandName: string, args: CLIArgs, flags: Flags) => Promise<void>;\nexport type OnBeforeExitFn = () => Promise<void>;\n\nexport type OnStartSlot = SlotRegistry<OnStart>;\nexport type OnCommandStartSlot = SlotRegistry<OnCommandStart>;\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 readonly onCommandStartSlot: OnCommandStartSlot,\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 getCommandByNameOrAlias(name: string): Command | undefined {\n const command = this.getCommand(name);\n if (command) return command;\n return this.commands.find((cmd) => cmd.alias === 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 /**\n * onStart is when bootstrapping the CLI. (it happens before onCommandStart)\n */\n registerOnStart(onStartFn: OnStart) {\n this.onStartSlot.register(onStartFn);\n return this;\n }\n\n /**\n * onCommandStart is when a command is about to start and we have the command object and the parsed args and flags\n * already. (it happens after onStart)\n */\n registerOnCommandStart(onCommandStartFn: OnCommandStart) {\n this.onCommandStartSlot.register(onCommandStartFn);\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, this.onCommandStartSlot);\n const commandRunner = await CliParser.parse();\n await commandRunner.runCommand();\n }\n\n private async invokeOnStart(hasWorkspace: boolean) {\n const onStartFns = this.onStartSlot.values();\n const foundCmd = findCommandByArgv(this.commands);\n const currentCommandName = process.argv[2];\n await pMapSeries(onStartFns, (onStart) => onStart(hasWorkspace, currentCommandName, foundCmd));\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 command.loader = true;\n }\n if (command.loadAspects === undefined) {\n command.loadAspects = true;\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 = [\n Slot.withType<CommandList>(),\n Slot.withType<OnStart>(),\n Slot.withType<OnCommandStart>(),\n Slot.withType<OnBeforeExitFn>(),\n ];\n\n static async provider(\n [loggerMain]: [LoggerMain],\n config,\n [commandsSlot, onStartSlot, onCommandStartSlot, onBeforeExitSlot]: [\n CommandsSlot,\n OnStartSlot,\n OnCommandStartSlot,\n OnBeforeExitSlot,\n ]\n ) {\n const logger = loggerMain.createLogger(CLIAspect.id);\n const cliMain = new CLIMain(commandsSlot, onStartSlot, onCommandStartSlot, onBeforeExitSlot, logger);\n await ensureWorkspaceAndScope();\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(new CompletionCmd(), cliCmd, helpCmd, new VersionCmd());\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 const potentialWsPath = process.cwd();\n const consumerInfo = await getConsumerInfo(potentialWsPath);\n if (consumerInfo && !consumerInfo.hasScope && consumerInfo.hasBitMap && consumerInfo.hasConsumerConfig) {\n await HostInitializerMain.init(potentialWsPath);\n }\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":";;;;;;AAA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AAG,CAACC,UAAU,CAAC,SAAS,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,UAAU,CAAC;AAChE","ignoreList":[]}
1
+ {"version":3,"names":["_harmony","data","require","_logger","_interopRequireDefault","_pMapSeries","_commandGroups","_hostInitializer","_consumer","_workspaceModules","_logger2","_lodash","_cli","_getCommandId","_cliParser","_completion","_cli2","_help","_version","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","CLIMain","constructor","commandsSlot","onStartSlot","onCommandStartSlot","onBeforeExitSlot","logger","clone","groups","register","commands","forEach","command","setDefaults","cmd","unregister","commandName","toArray","aspectId","filteredCommands","filter","getCommandId","name","map","set","values","flat","getCommand","find","getCommandByNameOrAlias","alias","registerGroup","description","consoleWarning","registerOnStart","onStartFn","registerOnCommandStart","onCommandStartFn","registerOnBeforeExit","onBeforeExitFn","legacyLogger","registerOnBeforeExitFn","run","hasWorkspace","invokeOnStart","CliParser","CLIParser","commandRunner","parse","runCommand","onStartFns","foundCmd","findCommandByArgv","currentCommandName","process","argv","pMapSeries","onStart","extendedDescription","group","options","private","trim","loader","undefined","loadAspects","helpUrl","isFullUrl","provider","loggerMain","config","createLogger","CLIAspect","id","cliMain","ensureWorkspaceAndScope","cliGenerateCmd","CliGenerateCmd","cliCmd","CliCmd","helpCmd","HelpCmd","push","CompletionCmd","VersionCmd","exports","LoggerAspect","MainRuntime","Slot","withType","addRuntime","loadConsumerIfExist","err","potentialWsPath","cwd","consumerInfo","getWorkspaceInfo","hasScope","hasBitMap","hasWorkspaceConfig","HostInitializerMain","init","url","startsWith"],"sources":["cli.main.runtime.ts"],"sourcesContent":["import { Slot, SlotRegistry } from '@teambit/harmony';\nimport legacyLogger from '@teambit/legacy/dist/logger/logger';\nimport { CLIArgs, Flags, Command } from '@teambit/legacy/dist/cli/command';\nimport pMapSeries from 'p-map-series';\nimport { groups, GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { HostInitializerMain } from '@teambit/host-initializer';\nimport { loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport { getWorkspaceInfo } from '@teambit/workspace.modules.workspace-locator';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { clone } from 'lodash';\nimport { CLIAspect, MainRuntime } from './cli.aspect';\nimport { getCommandId } from './get-command-id';\nimport { CLIParser, findCommandByArgv } from './cli-parser';\nimport { CompletionCmd } from './completion.cmd';\nimport { CliCmd, CliGenerateCmd } from './cli.cmd';\nimport { HelpCmd } from './help.cmd';\nimport { VersionCmd } from './version.cmd';\n\nexport type CommandList = Array<Command>;\nexport type OnStart = (hasWorkspace: boolean, currentCommand: string, commandObject?: Command) => Promise<void>;\nexport type OnCommandStart = (commandName: string, args: CLIArgs, flags: Flags) => Promise<void>;\nexport type OnBeforeExitFn = () => Promise<void>;\n\nexport type OnStartSlot = SlotRegistry<OnStart>;\nexport type OnCommandStartSlot = SlotRegistry<OnCommandStart>;\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 readonly onCommandStartSlot: OnCommandStartSlot,\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 getCommandByNameOrAlias(name: string): Command | undefined {\n const command = this.getCommand(name);\n if (command) return command;\n return this.commands.find((cmd) => cmd.alias === 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 /**\n * onStart is when bootstrapping the CLI. (it happens before onCommandStart)\n */\n registerOnStart(onStartFn: OnStart) {\n this.onStartSlot.register(onStartFn);\n return this;\n }\n\n /**\n * onCommandStart is when a command is about to start and we have the command object and the parsed args and flags\n * already. (it happens after onStart)\n */\n registerOnCommandStart(onCommandStartFn: OnCommandStart) {\n this.onCommandStartSlot.register(onCommandStartFn);\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, this.onCommandStartSlot);\n const commandRunner = await CliParser.parse();\n await commandRunner.runCommand();\n }\n\n private async invokeOnStart(hasWorkspace: boolean) {\n const onStartFns = this.onStartSlot.values();\n const foundCmd = findCommandByArgv(this.commands);\n const currentCommandName = process.argv[2];\n await pMapSeries(onStartFns, (onStart) => onStart(hasWorkspace, currentCommandName, foundCmd));\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 command.loader = true;\n }\n if (command.loadAspects === undefined) {\n command.loadAspects = true;\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 = [\n Slot.withType<CommandList>(),\n Slot.withType<OnStart>(),\n Slot.withType<OnCommandStart>(),\n Slot.withType<OnBeforeExitFn>(),\n ];\n\n static async provider(\n [loggerMain]: [LoggerMain],\n config,\n [commandsSlot, onStartSlot, onCommandStartSlot, onBeforeExitSlot]: [\n CommandsSlot,\n OnStartSlot,\n OnCommandStartSlot,\n OnBeforeExitSlot,\n ]\n ) {\n const logger = loggerMain.createLogger(CLIAspect.id);\n const cliMain = new CLIMain(commandsSlot, onStartSlot, onCommandStartSlot, onBeforeExitSlot, logger);\n await ensureWorkspaceAndScope();\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(new CompletionCmd(), cliCmd, helpCmd, new VersionCmd());\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 const potentialWsPath = process.cwd();\n const consumerInfo = await getWorkspaceInfo(potentialWsPath);\n if (consumerInfo && !consumerInfo.hasScope && consumerInfo.hasBitMap && consumerInfo.hasWorkspaceConfig) {\n await HostInitializerMain.init(potentialWsPath);\n }\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,QAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,eAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,cAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,iBAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,gBAAA,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;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,kBAAA;EAAA,MAAAR,IAAA,GAA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,CAAC;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA,eAAe2E,uBAAuBA,CAAA,EAAG;EACvC,IAAI;IACF,MAAM,IAAAgB,+BAAmB,EAAC,CAAC;EAC7B,CAAC,CAAC,OAAOC,GAAG,EAAE;IACZ,MAAMC,eAAe,GAAGvC,OAAO,CAACwC,GAAG,CAAC,CAAC;IACrC,MAAMC,YAAY,GAAG,MAAM,IAAAC,oCAAgB,EAACH,eAAe,CAAC;IAC5D,IAAIE,YAAY,IAAI,CAACA,YAAY,CAACE,QAAQ,IAAIF,YAAY,CAACG,SAAS,IAAIH,YAAY,CAACI,kBAAkB,EAAE;MACvG,MAAMC,sCAAmB,CAACC,IAAI,CAACR,eAAe,CAAC;IACjD;IACA;EACF;AACF;AAEA,SAAS1B,SAASA,CAACmC,GAAW,EAAE;EAC9B,OAAOA,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,UAAU,CAAC;AAChE","ignoreList":[]}
@@ -12,9 +12,9 @@ function _logger() {
12
12
  };
13
13
  return data;
14
14
  }
15
- function _loader() {
16
- const data = _interopRequireDefault(require("@teambit/legacy/dist/cli/loader"));
17
- _loader = function () {
15
+ function _legacy() {
16
+ const data = require("@teambit/legacy.loader");
17
+ _legacy = function () {
18
18
  return data;
19
19
  };
20
20
  return data;
@@ -40,9 +40,9 @@ function _globalFlags() {
40
40
  };
41
41
  return data;
42
42
  }
43
- function _legacy() {
43
+ function _legacy2() {
44
44
  const data = require("@teambit/legacy.analytics");
45
- _legacy = function () {
45
+ _legacy2 = function () {
46
46
  return data;
47
47
  };
48
48
  return data;
@@ -94,7 +94,7 @@ class CommandRunner {
94
94
  throw new Error(`command "${this.commandName}" doesn't implement "render" nor "report" nor "wait" methods`);
95
95
  }
96
96
  bootstrapCommand() {
97
- _legacy().Analytics.init(this.commandName, this.flags, this.args);
97
+ _legacy2().Analytics.init(this.commandName, this.flags, this.args);
98
98
  _logger().default.info(`[*] started a new command: "${this.commandName}" with the following data:`, {
99
99
  args: this.args,
100
100
  flags: this.flags
@@ -131,7 +131,7 @@ class CommandRunner {
131
131
  async runReportHandler(shouldReturnResult = false) {
132
132
  if (!this.command.report) throw new Error('runReportHandler expects command.report to be implemented');
133
133
  const result = await this.command.report(this.args, this.flags);
134
- _loader().default.off();
134
+ _legacy().loader.off();
135
135
  const data = typeof result === 'string' ? result : result.data;
136
136
  const exitCode = typeof result === 'string' ? 0 : result.code;
137
137
  if (shouldReturnResult) return {
@@ -151,11 +151,11 @@ class CommandRunner {
151
151
  */
152
152
  determineConsoleWritingDuringCommand() {
153
153
  if (this.command.loader && !this.flags.json && !this.flags['get-yargs-completions'] && !_logger().shouldDisableLoader) {
154
- _loader().default.on();
155
- _loader().default.start(`running command "${this.commandName}"...`);
154
+ _legacy().loader.on();
155
+ _legacy().loader.start(`running command "${this.commandName}"...`);
156
156
  _logger().default.shouldWriteToConsole = true;
157
157
  } else {
158
- _loader().default.off();
158
+ _legacy().loader.off();
159
159
  _logger().default.shouldWriteToConsole = false;
160
160
  }
161
161
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_logger","data","_interopRequireWildcard","require","_loader","_interopRequireDefault","_handleErrors","_constants","_globalFlags","_legacy","_pMapSeries","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","CommandRunner","constructor","command","args","flags","onCommandStartSlot","commandName","parseCommandName","name","runCommand","shouldReturnResult","bootstrapCommand","invokeOnCommandStart","determineConsoleWritingDuringCommand","json","runJsonHandler","report","runReportHandler","wait","runWaitHandler","err","handleErrorAndExit","Error","Analytics","init","logger","info","token","TOKEN_FLAG_NAME","globalFlags","toString","funcs","values","pMapSeries","onCommandStart","undefined","result","code","exitCode","isJsonStream","Boolean","stream","end","jsonStr","JSON","stringify","writeAndExit","loader","off","shouldDisableLoader","on","start","shouldWriteToConsole","process","stdout","write","exitAfterFlush","exports","split"],"sources":["command-runner.ts"],"sourcesContent":["import logger, { shouldDisableLoader } from '@teambit/legacy/dist/logger/logger';\nimport { CLIArgs, Command, Flags } from '@teambit/legacy/dist/cli/command';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { handleErrorAndExit } from './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.analytics';\nimport { OnCommandStartSlot } from './cli.main.runtime';\nimport pMapSeries from 'p-map-series';\n\ntype CommandResult = { data: any; exitCode: number };\n\nexport class CommandRunner {\n private commandName: string;\n constructor(\n private command: Command,\n private args: CLIArgs,\n private flags: Flags,\n private onCommandStartSlot: OnCommandStartSlot\n ) {\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(shouldReturnResult = false): Promise<void | CommandResult> {\n try {\n this.bootstrapCommand();\n await this.invokeOnCommandStart();\n this.determineConsoleWritingDuringCommand();\n if (this.flags.json) {\n return await this.runJsonHandler(shouldReturnResult);\n }\n if (this.command.report) {\n return await this.runReportHandler(shouldReturnResult);\n }\n if (this.command.wait) {\n return await this.runWaitHandler();\n }\n } catch (err: any) {\n if (shouldReturnResult) throw err;\n return handleErrorAndExit(err, this.commandName);\n }\n\n throw new Error(`command \"${this.commandName}\" doesn't implement \"render\" nor \"report\" nor \"wait\" 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 private async invokeOnCommandStart() {\n const funcs = this.onCommandStartSlot.values();\n await pMapSeries(funcs, (onCommandStart) => onCommandStart(this.commandName, this.args, this.flags));\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(shouldReturnResult = false): Promise<CommandResult | undefined> {\n if (!this.flags.json) return undefined;\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 if (shouldReturnResult) return { data, exitCode: code };\n const isJsonStream = Boolean(this.flags.stream);\n if (isJsonStream) data.end = true;\n const jsonStr = isJsonStream ? `${JSON.stringify(data)}\\n` : JSON.stringify(data, null, 2);\n await this.writeAndExit(jsonStr, code);\n }\n\n private async runReportHandler(shouldReturnResult = false): Promise<CommandResult | undefined> {\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 if (shouldReturnResult) return { data, exitCode };\n await this.writeAndExit(`${data}\\n`, exitCode);\n }\n\n private async runWaitHandler() {\n if (!this.command.wait) throw new Error('runReportHandler expects command.wait to be implemented');\n await this.command.wait(this.args, this.flags);\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'] && !shouldDisableLoader) {\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 }\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\nexport function parseCommandName(commandName: string): string {\n if (!commandName) return '';\n return commandName.split(' ')[0];\n}\n"],"mappings":";;;;;;;AAAA,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KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAClC","ignoreList":[]}
1
+ {"version":3,"names":["_logger","data","_interopRequireWildcard","require","_legacy","_handleErrors","_constants","_globalFlags","_interopRequireDefault","_legacy2","_pMapSeries","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","CommandRunner","constructor","command","args","flags","onCommandStartSlot","commandName","parseCommandName","name","runCommand","shouldReturnResult","bootstrapCommand","invokeOnCommandStart","determineConsoleWritingDuringCommand","json","runJsonHandler","report","runReportHandler","wait","runWaitHandler","err","handleErrorAndExit","Error","Analytics","init","logger","info","token","TOKEN_FLAG_NAME","globalFlags","toString","funcs","values","pMapSeries","onCommandStart","undefined","result","code","exitCode","isJsonStream","Boolean","stream","end","jsonStr","JSON","stringify","writeAndExit","loader","off","shouldDisableLoader","on","start","shouldWriteToConsole","process","stdout","write","exitAfterFlush","exports","split"],"sources":["command-runner.ts"],"sourcesContent":["import logger, { shouldDisableLoader } from '@teambit/legacy/dist/logger/logger';\nimport { CLIArgs, Command, Flags } from '@teambit/legacy/dist/cli/command';\nimport { loader } from '@teambit/legacy.loader';\nimport { handleErrorAndExit } from './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.analytics';\nimport { OnCommandStartSlot } from './cli.main.runtime';\nimport pMapSeries from 'p-map-series';\n\ntype CommandResult = { data: any; exitCode: number };\n\nexport class CommandRunner {\n private commandName: string;\n constructor(\n private command: Command,\n private args: CLIArgs,\n private flags: Flags,\n private onCommandStartSlot: OnCommandStartSlot\n ) {\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(shouldReturnResult = false): Promise<void | CommandResult> {\n try {\n this.bootstrapCommand();\n await this.invokeOnCommandStart();\n this.determineConsoleWritingDuringCommand();\n if (this.flags.json) {\n return await this.runJsonHandler(shouldReturnResult);\n }\n if (this.command.report) {\n return await this.runReportHandler(shouldReturnResult);\n }\n if (this.command.wait) {\n return await this.runWaitHandler();\n }\n } catch (err: any) {\n if (shouldReturnResult) throw err;\n return handleErrorAndExit(err, this.commandName);\n }\n\n throw new Error(`command \"${this.commandName}\" doesn't implement \"render\" nor \"report\" nor \"wait\" 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 private async invokeOnCommandStart() {\n const funcs = this.onCommandStartSlot.values();\n await pMapSeries(funcs, (onCommandStart) => onCommandStart(this.commandName, this.args, this.flags));\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(shouldReturnResult = false): Promise<CommandResult | undefined> {\n if (!this.flags.json) return undefined;\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 if (shouldReturnResult) return { data, exitCode: code };\n const isJsonStream = Boolean(this.flags.stream);\n if (isJsonStream) data.end = true;\n const jsonStr = isJsonStream ? `${JSON.stringify(data)}\\n` : JSON.stringify(data, null, 2);\n await this.writeAndExit(jsonStr, code);\n }\n\n private async runReportHandler(shouldReturnResult = false): Promise<CommandResult | undefined> {\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 if (shouldReturnResult) return { data, exitCode };\n await this.writeAndExit(`${data}\\n`, exitCode);\n }\n\n private async runWaitHandler() {\n if (!this.command.wait) throw new Error('runReportHandler expects command.wait to be implemented');\n await this.command.wait(this.args, this.flags);\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'] && !shouldDisableLoader) {\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 }\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\nexport function parseCommandName(commandName: string): string {\n if (!commandName) return '';\n return commandName.split(' ')[0];\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,cAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,aAAA;EAAA,MAAAN,IAAA,GAAAO,sBAAA,CAAAL,OAAA;EAAAI,YAAA,YAAAA,CAAA;IAAA,OA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,CAACI,KAAK,CAAC,oBAAoB,IAAI,CAAC7C,WAAW,MAAM,CAAC;MACxDmB,iBAAM,CAAC2B,oBAAoB,GAAG,IAAI;IACpC,CAAC,MAAM;MACLL,gBAAM,CAACC,GAAG,CAAC,CAAC;MACZvB,iBAAM,CAAC2B,oBAAoB,GAAG,KAAK;IACrC;EACF;EAEA,MAAcN,YAAYA,CAACxF,IAAY,EAAEgF,QAAgB,EAAE;IACzD;IACA,OAAOe,OAAO,CAACC,MAAM,CAACC,KAAK,CAACjG,IAAI,EAAE,YAAYmE,iBAAM,CAAC+B,cAAc,CAAClB,QAAQ,EAAE,IAAI,CAAChC,WAAW,EAAEhD,IAAI,CAAC,CAAC;EACxG;AACF;AAACmG,OAAA,CAAAzD,aAAA,GAAAA,aAAA;AAEM,SAASO,gBAAgBA,CAACD,WAAmB,EAAU;EAC5D,IAAI,CAACA,WAAW,EAAE,OAAO,EAAE;EAC3B,OAAOA,WAAW,CAACoD,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAClC","ignoreList":[]}
@@ -20,9 +20,9 @@ function _defaultErrorHandler() {
20
20
  };
21
21
  return data;
22
22
  }
23
- function _loader() {
24
- const data = _interopRequireDefault(require("@teambit/legacy/dist/cli/loader"));
25
- _loader = function () {
23
+ function _legacy() {
24
+ const data = require("@teambit/legacy.loader");
25
+ _legacy = function () {
26
26
  return data;
27
27
  };
28
28
  return data;
@@ -40,7 +40,7 @@ function setExitOnUnhandledRejection(exit) {
40
40
  }
41
41
  async function handleErrorAndExit(err, commandName) {
42
42
  try {
43
- _loader().default.off();
43
+ _legacy().loader.off();
44
44
  _logger().default.error(`got an error from command ${commandName}: ${err}`, err);
45
45
  const {
46
46
  message
@@ -1 +1 @@
1
- {"version":3,"names":["_logger","data","_interopRequireDefault","require","_defaultErrorHandler","_loader","e","__esModule","default","exitOnUnhandled","setExitOnUnhandledRejection","exit","handleErrorAndExit","err","commandName","loader","off","logger","error","message","defaultHandleError","logErrAndExit","console","process","handleUnhandledRejection","Error","argv","errMsg","errObj","env","CI","exitAfterFlush","toString"],"sources":["handle-errors.ts"],"sourcesContent":["import logger from '@teambit/legacy/dist/logger/logger';\nimport defaultHandleError from '@teambit/legacy/dist/cli/default-error-handler';\nimport loader from '@teambit/legacy/dist/cli/loader';\n\nlet exitOnUnhandled = true;\n\n// This provide a way to not exit when an unhandled rejection is found\n// This is main required when we load plugins which are esm modules and they require cjs modules\n// and there is as an error in the cjs module\n// in such case the regular catch will not catch the error and the process will exit\n// we don't want to exit in such case (of plugins load) so we provide a way to not exit\nexport function setExitOnUnhandledRejection(exit: boolean) {\n exitOnUnhandled = exit;\n}\n\nexport async function handleErrorAndExit(err: Error, commandName: string): Promise<void> {\n try {\n loader.off();\n logger.error(`got an error from command ${commandName}: ${err}`, err);\n const { message } = defaultHandleError(err);\n await logErrAndExit(message, commandName, err);\n } catch (e: any) {\n // eslint-disable-next-line no-console\n console.error('failed to log the error properly, failure error', e);\n // eslint-disable-next-line no-console\n console.error('failed to log the error properly, original error', err);\n process.exit(1);\n }\n}\n\nexport async function handleUnhandledRejection(err: Error | null | undefined | {}) {\n // eslint-disable-next-line no-console\n console.error('** unhandled rejection found, please make sure the promise is resolved/rejected correctly! **', err);\n if (!exitOnUnhandled) {\n logger.error(`ignoring unhandled rejection error:`, err);\n return;\n }\n if (err instanceof Error) {\n return handleErrorAndExit(err, process.argv[2]);\n }\n console.error(err); // eslint-disable-line\n return handleErrorAndExit(new Error(`unhandledRejections found. err ${err}`), process.argv[2]);\n}\n\nasync function logErrAndExit(errMsg: Error | string, commandName: string, errObj: Error) {\n if (!errMsg) throw new Error(`logErrAndExit expects to get either an Error or a string, got nothing`);\n console.error(errMsg); // eslint-disable-line\n // for CI, print the entire error with the stacktrace\n if (process.env.CI) console.error(errObj); // eslint-disable-line\n await logger.exitAfterFlush(1, commandName, errMsg.toString());\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA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CAACJ,KAAK,CAAC,+FAA+F,EAAEL,GAAG,CAAC;EACnH,IAAI,CAACJ,eAAe,EAAE;IACpBQ,iBAAM,CAACC,KAAK,CAAC,qCAAqC,EAAEL,GAAG,CAAC;IACxD;EACF;EACA,IAAIA,GAAG,YAAYY,KAAK,EAAE;IACxB,OAAOb,kBAAkB,CAACC,GAAG,EAAEU,OAAO,CAACG,IAAI,CAAC,CAAC,CAAC,CAAC;EACjD;EACAJ,OAAO,CAACJ,KAAK,CAACL,GAAG,CAAC,CAAC,CAAC;EACpB,OAAOD,kBAAkB,CAAC,IAAIa,KAAK,CAAC,kCAAkCZ,GAAG,EAAE,CAAC,EAAEU,OAAO,CAACG,IAAI,CAAC,CAAC,CAAC,CAAC;AAChG;AAEA,eAAeL,aAAaA,CAACM,MAAsB,EAAEb,WAAmB,EAAEc,MAAa,EAAE;EACvF,IAAI,CAACD,MAAM,EAAE,MAAM,IAAIF,KAAK,CAAC,uEAAuE,CAAC;EACrGH,OAAO,CAACJ,KAAK,CAACS,MAAM,CAAC,CAAC,CAAC;EACvB;EACA,IAAIJ,OAAO,CAACM,GAAG,CAACC,EAAE,EAAER,OAAO,CAACJ,KAAK,CAACU,MAAM,CAAC,CAAC,CAAC;EAC3C,MAAMX,iBAAM,CAACc,cAAc,CAAC,CAAC,EAAEjB,WAAW,EAAEa,MAAM,CAACK,QAAQ,CAAC,CAAC,CAAC;AAChE","ignoreList":[]}
1
+ {"version":3,"names":["_logger","data","_interopRequireDefault","require","_defaultErrorHandler","_legacy","e","__esModule","default","exitOnUnhandled","setExitOnUnhandledRejection","exit","handleErrorAndExit","err","commandName","loader","off","logger","error","message","defaultHandleError","logErrAndExit","console","process","handleUnhandledRejection","Error","argv","errMsg","errObj","env","CI","exitAfterFlush","toString"],"sources":["handle-errors.ts"],"sourcesContent":["import logger from '@teambit/legacy/dist/logger/logger';\nimport defaultHandleError from '@teambit/legacy/dist/cli/default-error-handler';\nimport { loader } from '@teambit/legacy.loader';\n\nlet exitOnUnhandled = true;\n\n// This provide a way to not exit when an unhandled rejection is found\n// This is main required when we load plugins which are esm modules and they require cjs modules\n// and there is as an error in the cjs module\n// in such case the regular catch will not catch the error and the process will exit\n// we don't want to exit in such case (of plugins load) so we provide a way to not exit\nexport function setExitOnUnhandledRejection(exit: boolean) {\n exitOnUnhandled = exit;\n}\n\nexport async function handleErrorAndExit(err: Error, commandName: string): Promise<void> {\n try {\n loader.off();\n logger.error(`got an error from command ${commandName}: ${err}`, err);\n const { message } = defaultHandleError(err);\n await logErrAndExit(message, commandName, err);\n } catch (e: any) {\n // eslint-disable-next-line no-console\n console.error('failed to log the error properly, failure error', e);\n // eslint-disable-next-line no-console\n console.error('failed to log the error properly, original error', err);\n process.exit(1);\n }\n}\n\nexport async function handleUnhandledRejection(err: Error | null | undefined | {}) {\n // eslint-disable-next-line no-console\n console.error('** unhandled rejection found, please make sure the promise is resolved/rejected correctly! **', err);\n if (!exitOnUnhandled) {\n logger.error(`ignoring unhandled rejection error:`, err);\n return;\n }\n if (err instanceof Error) {\n return handleErrorAndExit(err, process.argv[2]);\n }\n console.error(err); // eslint-disable-line\n return handleErrorAndExit(new Error(`unhandledRejections found. err ${err}`), process.argv[2]);\n}\n\nasync function logErrAndExit(errMsg: Error | string, commandName: string, errObj: Error) {\n if (!errMsg) throw new Error(`logErrAndExit expects to get either an Error or a string, got nothing`);\n console.error(errMsg); // eslint-disable-line\n // for CI, print the entire error with the stacktrace\n if (process.env.CI) console.error(errObj); // eslint-disable-line\n await logger.exitAfterFlush(1, commandName, errMsg.toString());\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,qBAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,oBAAA,YAAAA,CAAA;IAAA,OA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B,CAACC,GAAG,EAAEU,OAAO,CAACG,IAAI,CAAC,CAAC,CAAC,CAAC;EACjD;EACAJ,OAAO,CAACJ,KAAK,CAACL,GAAG,CAAC,CAAC,CAAC;EACpB,OAAOD,kBAAkB,CAAC,IAAIa,KAAK,CAAC,kCAAkCZ,GAAG,EAAE,CAAC,EAAEU,OAAO,CAACG,IAAI,CAAC,CAAC,CAAC,CAAC;AAChG;AAEA,eAAeL,aAAaA,CAACM,MAAsB,EAAEb,WAAmB,EAAEc,MAAa,EAAE;EACvF,IAAI,CAACD,MAAM,EAAE,MAAM,IAAIF,KAAK,CAAC,uEAAuE,CAAC;EACrGH,OAAO,CAACJ,KAAK,CAACS,MAAM,CAAC,CAAC,CAAC;EACvB;EACA,IAAIJ,OAAO,CAACM,GAAG,CAACC,EAAE,EAAER,OAAO,CAACJ,KAAK,CAACU,MAAM,CAAC,CAAC,CAAC;EAC3C,MAAMX,iBAAM,CAACc,cAAc,CAAC,CAAC,EAAEjB,WAAW,EAAEa,MAAM,CAACK,QAAQ,CAAC,CAAC,CAAC;AAChE","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_cli@0.0.1047/dist/cli.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_cli@0.0.1047/dist/cli.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_cli@0.0.1049/dist/cli.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_cli@0.0.1049/dist/cli.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/cli",
3
- "version": "0.0.1047",
3
+ "version": "0.0.1049",
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.1047"
9
+ "version": "0.0.1049"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -17,10 +17,12 @@
17
17
  "pad-right": "0.2.2",
18
18
  "@teambit/harmony": "0.4.6",
19
19
  "@teambit/bit-error": "0.0.404",
20
+ "@teambit/legacy.loader": "0.0.1",
20
21
  "@teambit/bit.get-bit-version": "0.0.1",
21
- "@teambit/host-initializer": "0.0.183",
22
- "@teambit/logger": "0.0.1140",
23
- "@teambit/legacy.analytics": "0.0.51"
22
+ "@teambit/host-initializer": "0.0.185",
23
+ "@teambit/logger": "0.0.1142",
24
+ "@teambit/workspace.modules.workspace-locator": "0.0.1",
25
+ "@teambit/legacy.analytics": "0.0.52"
24
26
  },
25
27
  "devDependencies": {
26
28
  "@types/didyoumean": "1.2.0",