@teambit/cli 0.0.1350 → 0.0.1351
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/command-runner.js +12 -0
- package/dist/command-runner.js.map +1 -1
- package/dist/command.d.ts +8 -0
- package/dist/command.js.map +1 -1
- package/dist/pager.d.ts +35 -0
- package/dist/pager.js +178 -0
- package/dist/pager.js.map +1 -0
- package/dist/{preview-1783716905245.js → preview-1783970347336.js} +2 -2
- package/dist/yargs-adapter.js +12 -0
- package/dist/yargs-adapter.js.map +1 -1
- package/package.json +7 -6
package/dist/command-runner.js
CHANGED
|
@@ -40,6 +40,13 @@ function _globalFlags() {
|
|
|
40
40
|
};
|
|
41
41
|
return data;
|
|
42
42
|
}
|
|
43
|
+
function _pager() {
|
|
44
|
+
const data = require("./pager");
|
|
45
|
+
_pager = function () {
|
|
46
|
+
return data;
|
|
47
|
+
};
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
43
50
|
function _legacy4() {
|
|
44
51
|
const data = require("@teambit/legacy.analytics");
|
|
45
52
|
_legacy4 = function () {
|
|
@@ -202,6 +209,11 @@ class CommandRunner {
|
|
|
202
209
|
}
|
|
203
210
|
}
|
|
204
211
|
async writeAndExit(data, exitCode) {
|
|
212
|
+
if ((0, _pager().shouldUsePager)(this.command, this.flags, data)) {
|
|
213
|
+
const paged = await (0, _pager().writeToPager)(data, Boolean(this.flags.pager));
|
|
214
|
+
// if the pager couldn't launch, fall through to a direct write so output is never lost.
|
|
215
|
+
if (paged) return _legacy().logger.exitAfterFlush(exitCode, this.commandName, data);
|
|
216
|
+
}
|
|
205
217
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
206
218
|
return process.stdout.write(data, async () => _legacy().logger.exitAfterFlush(exitCode, this.commandName, data));
|
|
207
219
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_legacy","data","require","_legacy2","_handleErrors","_legacy3","_globalFlags","_interopRequireDefault","_legacy4","_pMapSeries","_fsExtra","_path","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","LAST_COMMAND_DETAILS_DIR","exports","path","join","CACHE_ROOT","CommandRunner","constructor","command","args","flags","onCommandStartSlot","commandName","parseCommandName","name","runCommand","shouldReturnResult","bootstrapCommand","invokeOnCommandStart","determineConsoleWritingDuringCommand","json","runJsonHandler","report","runReportHandler","wait","runWaitHandler","err","handleErrorAndExit","Error","redactedFlags","getRedactedFlagsForReporting","Analytics","init","logger","error","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","details","persistDetails","catch","fs","ensureDir","meta","timestamp","Date","toISOString","Promise","all","writeFile","shouldDisableLoader","on","start","shouldWriteToConsole","process","stdout","write","exitAfterFlush","split"],"sources":["command-runner.ts"],"sourcesContent":["import { logger, shouldDisableLoader } from '@teambit/legacy.logger';\nimport type { CLIArgs, Command, Flags } from './command';\nimport { loader } from '@teambit/legacy.loader';\nimport { handleErrorAndExit } from './handle-errors';\nimport { TOKEN_FLAG_NAME, CACHE_ROOT } from '@teambit/legacy.constants';\nimport globalFlags from './global-flags';\nimport { Analytics } from '@teambit/legacy.analytics';\nimport type { OnCommandStartSlot } from './cli.main.runtime';\nimport pMapSeries from 'p-map-series';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nexport const LAST_COMMAND_DETAILS_DIR = path.join(CACHE_ROOT, 'last-command-details');\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 // Redact --token before anything is logged or sent to analytics. The raw token\n // is the user's bit.cloud credential; debug logs are persisted to disk and\n // routinely shared in support tickets / issues.\n const redactedFlags = this.getRedactedFlagsForReporting();\n try {\n Analytics.init(this.commandName, redactedFlags, this.args);\n } catch (err: any) {\n // ignoring the error, we don't want to fail the app if analytics failed.\n logger.error('failed to initialize analytics', err);\n }\n logger.info(`[*] started a new command: \"${this.commandName}\" with the following data:`, {\n args: this.args,\n flags: redactedFlags,\n });\n const token = this.flags[TOKEN_FLAG_NAME];\n if (token) {\n globalFlags.token = token.toString();\n }\n }\n\n private getRedactedFlagsForReporting(): Flags {\n if (this.flags[TOKEN_FLAG_NAME] == null) return this.flags;\n return { ...this.flags, [TOKEN_FLAG_NAME]: '<redacted>' };\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 const details = typeof result === 'string' ? undefined : result.details;\n if (details) {\n await this.persistDetails(details).catch((err) => logger.error('failed to persist command details', err));\n }\n await this.writeAndExit(`${data}\\n`, exitCode);\n }\n\n private async persistDetails(details: string) {\n await fs.ensureDir(LAST_COMMAND_DETAILS_DIR);\n const meta = JSON.stringify({ command: this.commandName, timestamp: new Date().toISOString() });\n await Promise.all([\n fs.writeFile(path.join(LAST_COMMAND_DETAILS_DIR, 'content'), details),\n fs.writeFile(path.join(LAST_COMMAND_DETAILS_DIR, 'meta.json'), meta),\n ]);\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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,CAACpG,IAAY,EAAE4F,QAAgB,EAAE;IACzD;IACA,OAAO2B,OAAO,CAACC,MAAM,CAACC,KAAK,CAACzH,IAAI,EAAE,YAAY8E,gBAAM,CAAC4C,cAAc,CAAC9B,QAAQ,EAAE,IAAI,CAACnC,WAAW,EAAEzD,IAAI,CAAC,CAAC;EACxG;AACF;AAAC+C,OAAA,CAAAI,aAAA,GAAAA,aAAA;AAEM,SAASO,gBAAgBA,CAACD,WAAmB,EAAU;EAC5D,IAAI,CAACA,WAAW,EAAE,OAAO,EAAE;EAC3B,OAAOA,WAAW,CAACkE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAClC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_legacy","data","require","_legacy2","_handleErrors","_legacy3","_globalFlags","_interopRequireDefault","_pager","_legacy4","_pMapSeries","_fsExtra","_path","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","LAST_COMMAND_DETAILS_DIR","exports","path","join","CACHE_ROOT","CommandRunner","constructor","command","args","flags","onCommandStartSlot","commandName","parseCommandName","name","runCommand","shouldReturnResult","bootstrapCommand","invokeOnCommandStart","determineConsoleWritingDuringCommand","json","runJsonHandler","report","runReportHandler","wait","runWaitHandler","err","handleErrorAndExit","Error","redactedFlags","getRedactedFlagsForReporting","Analytics","init","logger","error","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","details","persistDetails","catch","fs","ensureDir","meta","timestamp","Date","toISOString","Promise","all","writeFile","shouldDisableLoader","on","start","shouldWriteToConsole","shouldUsePager","paged","writeToPager","pager","exitAfterFlush","process","stdout","write","split"],"sources":["command-runner.ts"],"sourcesContent":["import { logger, shouldDisableLoader } from '@teambit/legacy.logger';\nimport type { CLIArgs, Command, Flags } from './command';\nimport { loader } from '@teambit/legacy.loader';\nimport { handleErrorAndExit } from './handle-errors';\nimport { TOKEN_FLAG_NAME, CACHE_ROOT } from '@teambit/legacy.constants';\nimport globalFlags from './global-flags';\nimport { shouldUsePager, writeToPager } from './pager';\nimport { Analytics } from '@teambit/legacy.analytics';\nimport type { OnCommandStartSlot } from './cli.main.runtime';\nimport pMapSeries from 'p-map-series';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nexport const LAST_COMMAND_DETAILS_DIR = path.join(CACHE_ROOT, 'last-command-details');\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 // Redact --token before anything is logged or sent to analytics. The raw token\n // is the user's bit.cloud credential; debug logs are persisted to disk and\n // routinely shared in support tickets / issues.\n const redactedFlags = this.getRedactedFlagsForReporting();\n try {\n Analytics.init(this.commandName, redactedFlags, this.args);\n } catch (err: any) {\n // ignoring the error, we don't want to fail the app if analytics failed.\n logger.error('failed to initialize analytics', err);\n }\n logger.info(`[*] started a new command: \"${this.commandName}\" with the following data:`, {\n args: this.args,\n flags: redactedFlags,\n });\n const token = this.flags[TOKEN_FLAG_NAME];\n if (token) {\n globalFlags.token = token.toString();\n }\n }\n\n private getRedactedFlagsForReporting(): Flags {\n if (this.flags[TOKEN_FLAG_NAME] == null) return this.flags;\n return { ...this.flags, [TOKEN_FLAG_NAME]: '<redacted>' };\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 const details = typeof result === 'string' ? undefined : result.details;\n if (details) {\n await this.persistDetails(details).catch((err) => logger.error('failed to persist command details', err));\n }\n await this.writeAndExit(`${data}\\n`, exitCode);\n }\n\n private async persistDetails(details: string) {\n await fs.ensureDir(LAST_COMMAND_DETAILS_DIR);\n const meta = JSON.stringify({ command: this.commandName, timestamp: new Date().toISOString() });\n await Promise.all([\n fs.writeFile(path.join(LAST_COMMAND_DETAILS_DIR, 'content'), details),\n fs.writeFile(path.join(LAST_COMMAND_DETAILS_DIR, 'meta.json'), meta),\n ]);\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 if (shouldUsePager(this.command, this.flags, data)) {\n const paged = await writeToPager(data, Boolean(this.flags.pager));\n // if the pager couldn't launch, fall through to a direct write so output is never lost.\n if (paged) return logger.exitAfterFlush(exitCode, this.commandName, data);\n }\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,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,Y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OAAO6H,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC/H,IAAI,EAAE,YAAY+E,gBAAM,CAAC6C,cAAc,CAAC/B,QAAQ,EAAE,IAAI,CAACnC,WAAW,EAAE1D,IAAI,CAAC,CAAC;EACxG;AACF;AAACgD,OAAA,CAAAI,aAAA,GAAAA,aAAA;AAEM,SAASO,gBAAgBA,CAACD,WAAmB,EAAU;EAC5D,IAAI,CAACA,WAAW,EAAE,OAAO,EAAE;EAC3B,OAAOA,WAAW,CAACsE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAClC","ignoreList":[]}
|
package/dist/command.d.ts
CHANGED
|
@@ -43,6 +43,14 @@ export interface Command {
|
|
|
43
43
|
* @see cliMain.setDefaults()
|
|
44
44
|
*/
|
|
45
45
|
loader?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* opt this command's `report` output into paging (like git's log/diff).
|
|
48
|
+
* when true, and stdout is an interactive human terminal, the output is piped through a pager
|
|
49
|
+
* (`less` by default). non-interactive contexts (piped output, CI, ai-agents, bit-cli-server)
|
|
50
|
+
* always get the full output at once. users can override with --pager / --no-pager.
|
|
51
|
+
* the default is false.
|
|
52
|
+
*/
|
|
53
|
+
pager?: boolean;
|
|
46
54
|
/**
|
|
47
55
|
* Array of command options where each element is a tuple.
|
|
48
56
|
* ['flag alias', 'flag name', 'flag description']
|
package/dist/command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["command.ts"],"sourcesContent":["import type { Group } from './command-groups';\n\ntype CommandOption = [string, string, string];\nexport type CommandOptions = Array<CommandOption>;\n\nexport interface Command {\n /**\n * Name of command with arguments:\n * <> for mandatory arguments.\n * [] for optional arguments.\n * e.g. 'add <path>'\n */\n name: string;\n\n /**\n * command alias (for example: 't' for 'tag')\n */\n alias?: string;\n\n /**\n * The description of the command. Being used in the commands summery (`bit --help`) and the help (e.g. `bit create --help`).\n * should be short and precise. not more than one line. (use extendedDescription for more info).\n */\n description: string;\n\n /**\n * The extended description of the command. Will be seen in only in the command help, just after the description.\n */\n extendedDescription?: string;\n\n /**\n * url to a doc page explaining the command. shown in the command help just after the extendedDescription.\n * if a relative url is entered, the base url will be retrieved from `teambit.community/community` aspect.\n */\n helpUrl?: string;\n\n /**\n * allow grouping of commands to hint summery renderer\n * Places in default automatic help\n */\n group?: Group | string;\n\n /**\n * should a command be exposed to the user (by bit help).\n * e.g. experimental or plumbing commands should be hidden.\n */\n private?: boolean;\n\n /**\n * should turn on Loader.\n * the default is false for internal-commands and true for others.\n * @see cliMain.setDefaults()\n */\n loader?: boolean;\n\n /**\n * Array of command options where each element is a tuple.\n * ['flag alias', 'flag name', 'flag description']\n * for example:\n * ['j', 'json', 'output json format']\n */\n options: CommandOptions;\n\n /**\n * arguments are defined in the \"name\" property, and that's where the source of truth is.\n * this prop is optional and provides a way to describe the args. later, it'll support more fields, such as defaultValue.\n * if this is set, it'll be shown in the command help under \"Arguments\" section.\n */\n arguments?: CommandArg[];\n\n /**\n * sub commands for example:\n * bit capsule list to list active capsules.\n */\n commands?: Command[];\n\n /**\n * interact with a remote, e.g. \"export\" push to a remote\n * for now, the only difference is that they get a \"token\" flag to authenticate anonymously.\n */\n remoteOp?: boolean;\n\n /**\n * if true, it indicates that it doesn't need the workspace to work and can be executed outside a\n * workspace\n */\n skipWorkspace?: boolean;\n\n /**\n * optionally, give some examples how to use the command.\n */\n examples?: Example[];\n\n /**\n * whether to load aspects set in workspace.jsonc before running the command.\n * default is true.\n */\n loadAspects?: boolean;\n\n /**\n * do not set this. it is being set once the command run.\n * the values are those followed `--` in the command line. (e.g. `bit import -- --no-optional`)\n */\n _packageManagerArgs?: string[];\n\n /**\n * Command handler which prints the return value to the console and exits.\n * If the command has both, `render` and `report`, this one will be called when process.isTTY is false.\n * @param args - arguments object as defined in name.\n * @param flags - command flags as described in options.\n * @return - Report object. The Report.data is printed to the stdout as is.\n * Optionally include Report.details for expanded output accessible via `bit details` after the command completes.\n */\n report?(args: CLIArgs, flags: Flags): Promise<string | Report>;\n\n /**\n * Command handler which never exits the process\n * @param args - arguments object as defined in name.\n * @param flags - command flags as described in options.\n */\n wait?(args: CLIArgs, flags: Flags): Promise<void>;\n\n /**\n * Optional handler to provide a raw result of the command.\n * Will be go called if '-j'/'--json' option is provided by user.\n * @param args - arguments object as defined in name.\n * @param flags - command flags as described in options.\n * @return a GenericObject to be rendered to string (by json.stringify) in the console.\n */\n json?(args: CLIArgs, flags: Flags): Promise<GenericObject>;\n}\nexport type Flags = { [flagName: string]: string | boolean | undefined | any };\nexport type CLIArgs = Array<string[] | string>;\nexport type GenericObject = { [k: string]: any };\nexport type Report = {\n data: string;\n code: number;\n /**\n * Optional expanded output persisted to disk and viewable via `bit details`.\n * Use this for verbose information (e.g. auto-tagged dependents) that would clutter\n * the default output but is useful after a one-shot command has already completed.\n */\n details?: string;\n};\nexport type CommandArg = { name: string; description?: string };\nexport type Example = { cmd: string; description: string };\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["command.ts"],"sourcesContent":["import type { Group } from './command-groups';\n\ntype CommandOption = [string, string, string];\nexport type CommandOptions = Array<CommandOption>;\n\nexport interface Command {\n /**\n * Name of command with arguments:\n * <> for mandatory arguments.\n * [] for optional arguments.\n * e.g. 'add <path>'\n */\n name: string;\n\n /**\n * command alias (for example: 't' for 'tag')\n */\n alias?: string;\n\n /**\n * The description of the command. Being used in the commands summery (`bit --help`) and the help (e.g. `bit create --help`).\n * should be short and precise. not more than one line. (use extendedDescription for more info).\n */\n description: string;\n\n /**\n * The extended description of the command. Will be seen in only in the command help, just after the description.\n */\n extendedDescription?: string;\n\n /**\n * url to a doc page explaining the command. shown in the command help just after the extendedDescription.\n * if a relative url is entered, the base url will be retrieved from `teambit.community/community` aspect.\n */\n helpUrl?: string;\n\n /**\n * allow grouping of commands to hint summery renderer\n * Places in default automatic help\n */\n group?: Group | string;\n\n /**\n * should a command be exposed to the user (by bit help).\n * e.g. experimental or plumbing commands should be hidden.\n */\n private?: boolean;\n\n /**\n * should turn on Loader.\n * the default is false for internal-commands and true for others.\n * @see cliMain.setDefaults()\n */\n loader?: boolean;\n\n /**\n * opt this command's `report` output into paging (like git's log/diff).\n * when true, and stdout is an interactive human terminal, the output is piped through a pager\n * (`less` by default). non-interactive contexts (piped output, CI, ai-agents, bit-cli-server)\n * always get the full output at once. users can override with --pager / --no-pager.\n * the default is false.\n */\n pager?: boolean;\n\n /**\n * Array of command options where each element is a tuple.\n * ['flag alias', 'flag name', 'flag description']\n * for example:\n * ['j', 'json', 'output json format']\n */\n options: CommandOptions;\n\n /**\n * arguments are defined in the \"name\" property, and that's where the source of truth is.\n * this prop is optional and provides a way to describe the args. later, it'll support more fields, such as defaultValue.\n * if this is set, it'll be shown in the command help under \"Arguments\" section.\n */\n arguments?: CommandArg[];\n\n /**\n * sub commands for example:\n * bit capsule list to list active capsules.\n */\n commands?: Command[];\n\n /**\n * interact with a remote, e.g. \"export\" push to a remote\n * for now, the only difference is that they get a \"token\" flag to authenticate anonymously.\n */\n remoteOp?: boolean;\n\n /**\n * if true, it indicates that it doesn't need the workspace to work and can be executed outside a\n * workspace\n */\n skipWorkspace?: boolean;\n\n /**\n * optionally, give some examples how to use the command.\n */\n examples?: Example[];\n\n /**\n * whether to load aspects set in workspace.jsonc before running the command.\n * default is true.\n */\n loadAspects?: boolean;\n\n /**\n * do not set this. it is being set once the command run.\n * the values are those followed `--` in the command line. (e.g. `bit import -- --no-optional`)\n */\n _packageManagerArgs?: string[];\n\n /**\n * Command handler which prints the return value to the console and exits.\n * If the command has both, `render` and `report`, this one will be called when process.isTTY is false.\n * @param args - arguments object as defined in name.\n * @param flags - command flags as described in options.\n * @return - Report object. The Report.data is printed to the stdout as is.\n * Optionally include Report.details for expanded output accessible via `bit details` after the command completes.\n */\n report?(args: CLIArgs, flags: Flags): Promise<string | Report>;\n\n /**\n * Command handler which never exits the process\n * @param args - arguments object as defined in name.\n * @param flags - command flags as described in options.\n */\n wait?(args: CLIArgs, flags: Flags): Promise<void>;\n\n /**\n * Optional handler to provide a raw result of the command.\n * Will be go called if '-j'/'--json' option is provided by user.\n * @param args - arguments object as defined in name.\n * @param flags - command flags as described in options.\n * @return a GenericObject to be rendered to string (by json.stringify) in the console.\n */\n json?(args: CLIArgs, flags: Flags): Promise<GenericObject>;\n}\nexport type Flags = { [flagName: string]: string | boolean | undefined | any };\nexport type CLIArgs = Array<string[] | string>;\nexport type GenericObject = { [k: string]: any };\nexport type Report = {\n data: string;\n code: number;\n /**\n * Optional expanded output persisted to disk and viewable via `bit details`.\n * Use this for verbose information (e.g. auto-tagged dependents) that would clutter\n * the default output but is useful after a one-shot command has already completed.\n */\n details?: string;\n};\nexport type CommandArg = { name: string; description?: string };\nexport type Example = { cmd: string; description: string };\n"],"mappings":"","ignoreList":[]}
|
package/dist/pager.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Command, Flags } from './command';
|
|
2
|
+
/**
|
|
3
|
+
* detect whether the output is going to an interactive human terminal.
|
|
4
|
+
* anything non-interactive (piped output, CI, ai-agents, bit-cli-server) gets the full output
|
|
5
|
+
* with no pager.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isInteractiveTerminal(): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* whether the output already fits within the current terminal, in which case there's no reason
|
|
10
|
+
* to page it (avoids the "press q to exit" annoyance for short output, without relying on the
|
|
11
|
+
* version-dependent `less -F` behavior which is broken by `-X` in modern less). accounts for line
|
|
12
|
+
* wrapping and ignores ansi color codes when measuring width. returns false when the terminal size
|
|
13
|
+
* is unknown.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fitsOnScreen(output: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* decide whether a command's report output should be piped through a pager.
|
|
18
|
+
* mirrors git: on by default for interactive terminals, off for anything else. explicit flags
|
|
19
|
+
* (--pager / --no-pager) and the BIT_NO_PAGER env var override the automatic behavior. in the
|
|
20
|
+
* automatic case, output that already fits on the screen is printed directly (no pager).
|
|
21
|
+
*/
|
|
22
|
+
export declare function shouldUsePager(command: Command, flags: Flags, output: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* pipe the given output through a pager (`less` by default). resolves to `true` only after the
|
|
25
|
+
* pager process has exited cleanly — the caller must await this before exiting the process so the
|
|
26
|
+
* pager isn't cut off. resolves to `false` when paging is disabled, the pager couldn't launch, or
|
|
27
|
+
* it exited with an error, in which case the caller must write the data directly so nothing is lost.
|
|
28
|
+
*
|
|
29
|
+
* the pager binary is taken from BIT_PAGER, then PAGER, defaulting to `less`. an empty or `cat`
|
|
30
|
+
* pager means the user disabled paging via the env — honored unless `force` is set (the `--pager`
|
|
31
|
+
* flag), which falls back to a real pager so the flag is a true override. for `less` we set
|
|
32
|
+
* `LESS=FRX` (unless already set, matching git's default): keep ansi colors (-R), don't clear the
|
|
33
|
+
* screen on exit (-X), and quit if the output fits one screen (-F).
|
|
34
|
+
*/
|
|
35
|
+
export declare function writeToPager(data: string, force?: boolean): Promise<boolean>;
|
package/dist/pager.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fitsOnScreen = fitsOnScreen;
|
|
7
|
+
exports.isInteractiveTerminal = isInteractiveTerminal;
|
|
8
|
+
exports.shouldUsePager = shouldUsePager;
|
|
9
|
+
exports.writeToPager = writeToPager;
|
|
10
|
+
function _child_process() {
|
|
11
|
+
const data = require("child_process");
|
|
12
|
+
_child_process = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
function _path() {
|
|
18
|
+
const data = require("path");
|
|
19
|
+
_path = function () {
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
function _legacy() {
|
|
25
|
+
const data = require("@teambit/legacy.logger");
|
|
26
|
+
_legacy = function () {
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
function _legacy2() {
|
|
32
|
+
const data = require("@teambit/legacy.utils");
|
|
33
|
+
_legacy2 = function () {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
39
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
40
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
41
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
42
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
43
|
+
/**
|
|
44
|
+
* best-effort list of env vars set by ai-agent / automation runners. when any is present we
|
|
45
|
+
* never page, so agents always receive the full command output at once (never partial/paged
|
|
46
|
+
* data), even in the rare case they allocate a pseudo-tty.
|
|
47
|
+
*/
|
|
48
|
+
const AI_AGENT_ENV_VARS = ['CLAUDECODE', 'CLAUDE_CODE', 'CURSOR_AGENT'];
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* an env var counts as "set" when it's present at all, even if its value is an empty string. the
|
|
52
|
+
* vars we gate on (CI, ai-agent markers, BIT_NO_PAGER) are opt-outs, so presence — not truthiness —
|
|
53
|
+
* is what disables paging; this also matches automation runners that inject empty-string values.
|
|
54
|
+
*/
|
|
55
|
+
const isEnvSet = name => process.env[name] !== undefined;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* detect whether the output is going to an interactive human terminal.
|
|
59
|
+
* anything non-interactive (piped output, CI, ai-agents, bit-cli-server) gets the full output
|
|
60
|
+
* with no pager.
|
|
61
|
+
*/
|
|
62
|
+
function isInteractiveTerminal() {
|
|
63
|
+
if (!process.stdout.isTTY) return false;
|
|
64
|
+
// daemon contexts don't page: the bit-cli-server (output travels over IPC, no terminal) and the
|
|
65
|
+
// experimental `bit cli` REPL (a pager would fight its readline interface over the TTY).
|
|
66
|
+
if (_legacy().logger.isDaemon) return false;
|
|
67
|
+
if (isEnvSet('CI')) return false;
|
|
68
|
+
if (AI_AGENT_ENV_VARS.some(isEnvSet)) return false;
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* whether the output already fits within the current terminal, in which case there's no reason
|
|
74
|
+
* to page it (avoids the "press q to exit" annoyance for short output, without relying on the
|
|
75
|
+
* version-dependent `less -F` behavior which is broken by `-X` in modern less). accounts for line
|
|
76
|
+
* wrapping and ignores ansi color codes when measuring width. returns false when the terminal size
|
|
77
|
+
* is unknown.
|
|
78
|
+
*/
|
|
79
|
+
function fitsOnScreen(output) {
|
|
80
|
+
const {
|
|
81
|
+
rows,
|
|
82
|
+
columns
|
|
83
|
+
} = process.stdout;
|
|
84
|
+
if (!rows || !columns) return false;
|
|
85
|
+
// split at most rows+1 lines — enough to prove overflow — so the array never scales with the
|
|
86
|
+
// full (potentially huge) output; the loop below also early-exits once one screen is exceeded.
|
|
87
|
+
const lines = output.replace(/\n$/, '').split('\n', rows + 1);
|
|
88
|
+
let usedRows = 0;
|
|
89
|
+
for (const line of lines) {
|
|
90
|
+
const width = ((0, _legacy2().removeChalkCharacters)(line) || '').length;
|
|
91
|
+
usedRows += width === 0 ? 1 : Math.ceil(width / columns);
|
|
92
|
+
if (usedRows > rows) return false; // stop early once we know it overflows one screen
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* decide whether a command's report output should be piped through a pager.
|
|
99
|
+
* mirrors git: on by default for interactive terminals, off for anything else. explicit flags
|
|
100
|
+
* (--pager / --no-pager) and the BIT_NO_PAGER env var override the automatic behavior. in the
|
|
101
|
+
* automatic case, output that already fits on the screen is printed directly (no pager).
|
|
102
|
+
*/
|
|
103
|
+
function shouldUsePager(command, flags, output) {
|
|
104
|
+
if (!command.pager) return false; // command didn't opt-in to paging
|
|
105
|
+
if (flags.json) return false; // json is for machine consumption, never page it
|
|
106
|
+
// explicit CLI flags win over the BIT_NO_PAGER env var, so `--pager` can force paging for a
|
|
107
|
+
// single invocation even when the user exports BIT_NO_PAGER globally.
|
|
108
|
+
if (flags['no-pager']) return false;
|
|
109
|
+
if (flags.pager) return true; // explicit force-on, even when non-interactive / fits on screen
|
|
110
|
+
if (isEnvSet('BIT_NO_PAGER')) return false; // env opt-out (overridable by --pager above)
|
|
111
|
+
if (!isInteractiveTerminal()) return false;
|
|
112
|
+
return !fitsOnScreen(output); // only page when the output is longer than one screen
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* split a configured pager string (BIT_PAGER / PAGER) into [command, ...args], honoring single and
|
|
117
|
+
* double quotes so an executable path that contains spaces can be configured, e.g.
|
|
118
|
+
* `"/Applications/My Pager/less" -R`. we deliberately don't run the pager through a shell (avoids
|
|
119
|
+
* shell-injection and the ENOENT-swallows-output problem), so quoting is how a spaced path is
|
|
120
|
+
* expressed.
|
|
121
|
+
*/
|
|
122
|
+
function parsePagerCommand(pager) {
|
|
123
|
+
const tokens = pager.match(/"[^"]*"|'[^']*'|\S+/g) || [];
|
|
124
|
+
return tokens.map(token => token.replace(/^["']|["']$/g, ''));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* pipe the given output through a pager (`less` by default). resolves to `true` only after the
|
|
129
|
+
* pager process has exited cleanly — the caller must await this before exiting the process so the
|
|
130
|
+
* pager isn't cut off. resolves to `false` when paging is disabled, the pager couldn't launch, or
|
|
131
|
+
* it exited with an error, in which case the caller must write the data directly so nothing is lost.
|
|
132
|
+
*
|
|
133
|
+
* the pager binary is taken from BIT_PAGER, then PAGER, defaulting to `less`. an empty or `cat`
|
|
134
|
+
* pager means the user disabled paging via the env — honored unless `force` is set (the `--pager`
|
|
135
|
+
* flag), which falls back to a real pager so the flag is a true override. for `less` we set
|
|
136
|
+
* `LESS=FRX` (unless already set, matching git's default): keep ansi colors (-R), don't clear the
|
|
137
|
+
* screen on exit (-X), and quit if the output fits one screen (-F).
|
|
138
|
+
*/
|
|
139
|
+
function writeToPager(data, force = false) {
|
|
140
|
+
return new Promise(resolve => {
|
|
141
|
+
// BIT_PAGER wins over PAGER; default to `less` only when neither is set. use `??` (not `||`)
|
|
142
|
+
// so an explicit empty string is preserved rather than treated as unset — that lets
|
|
143
|
+
// BIT_PAGER="" disable paging.
|
|
144
|
+
const configuredPager = process.env.BIT_PAGER ?? process.env.PAGER ?? 'less';
|
|
145
|
+
const tokens = parsePagerCommand(configuredPager);
|
|
146
|
+
// an empty / "cat" pager means the user disabled paging. honor that, unless `--pager` forces
|
|
147
|
+
// paging on, in which case fall back to a real pager so the flag is a true override.
|
|
148
|
+
const disabled = !tokens[0] || tokens[0] === 'cat';
|
|
149
|
+
if (disabled && !force) {
|
|
150
|
+
resolve(false);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const [cmd, ...args] = disabled ? ['less'] : tokens;
|
|
154
|
+
const env = _objectSpread({}, process.env);
|
|
155
|
+
// LESS=FRX only makes sense for `less` itself; don't leak it into other pagers or wrapper scripts.
|
|
156
|
+
if (/^less(\.exe)?$/i.test((0, _path().basename)(cmd)) && !env.LESS) env.LESS = 'FRX';
|
|
157
|
+
try {
|
|
158
|
+
const child = (0, _child_process().spawn)(cmd, args, {
|
|
159
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
160
|
+
env
|
|
161
|
+
});
|
|
162
|
+
// pager missing (ENOENT) or otherwise failed to launch => fall back to a direct write.
|
|
163
|
+
child.on('error', () => resolve(false));
|
|
164
|
+
// resolve success only on a clean exit (code 0) or a signal (code null, e.g. the user killed
|
|
165
|
+
// it). a non-zero exit means the pager failed (bad args, couldn't render) without showing the
|
|
166
|
+
// output, so fall back to a direct write and never lose it.
|
|
167
|
+
child.on('close', code => resolve(code === 0 || code === null));
|
|
168
|
+
// ignore EPIPE that happens when the user quits the pager (e.g. "q") before all data is read.
|
|
169
|
+
child.stdin?.on('error', () => {});
|
|
170
|
+
child.stdin?.write(data);
|
|
171
|
+
child.stdin?.end();
|
|
172
|
+
} catch {
|
|
173
|
+
resolve(false);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
//# sourceMappingURL=pager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_child_process","data","require","_path","_legacy","_legacy2","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","AI_AGENT_ENV_VARS","isEnvSet","name","process","env","undefined","isInteractiveTerminal","stdout","isTTY","logger","isDaemon","some","fitsOnScreen","output","rows","columns","lines","replace","split","usedRows","line","width","removeChalkCharacters","Math","ceil","shouldUsePager","command","flags","pager","json","parsePagerCommand","tokens","match","map","token","writeToPager","force","Promise","resolve","configuredPager","BIT_PAGER","PAGER","disabled","cmd","args","test","basename","LESS","child","spawn","stdio","on","code","stdin","write","end"],"sources":["pager.ts"],"sourcesContent":["import { spawn } from 'child_process';\nimport { basename } from 'path';\nimport { logger } from '@teambit/legacy.logger';\nimport { removeChalkCharacters } from '@teambit/legacy.utils';\nimport type { Command, Flags } from './command';\n\n/**\n * best-effort list of env vars set by ai-agent / automation runners. when any is present we\n * never page, so agents always receive the full command output at once (never partial/paged\n * data), even in the rare case they allocate a pseudo-tty.\n */\nconst AI_AGENT_ENV_VARS = ['CLAUDECODE', 'CLAUDE_CODE', 'CURSOR_AGENT'];\n\n/**\n * an env var counts as \"set\" when it's present at all, even if its value is an empty string. the\n * vars we gate on (CI, ai-agent markers, BIT_NO_PAGER) are opt-outs, so presence — not truthiness —\n * is what disables paging; this also matches automation runners that inject empty-string values.\n */\nconst isEnvSet = (name: string): boolean => process.env[name] !== undefined;\n\n/**\n * detect whether the output is going to an interactive human terminal.\n * anything non-interactive (piped output, CI, ai-agents, bit-cli-server) gets the full output\n * with no pager.\n */\nexport function isInteractiveTerminal(): boolean {\n if (!process.stdout.isTTY) return false;\n // daemon contexts don't page: the bit-cli-server (output travels over IPC, no terminal) and the\n // experimental `bit cli` REPL (a pager would fight its readline interface over the TTY).\n if (logger.isDaemon) return false;\n if (isEnvSet('CI')) return false;\n if (AI_AGENT_ENV_VARS.some(isEnvSet)) return false;\n return true;\n}\n\n/**\n * whether the output already fits within the current terminal, in which case there's no reason\n * to page it (avoids the \"press q to exit\" annoyance for short output, without relying on the\n * version-dependent `less -F` behavior which is broken by `-X` in modern less). accounts for line\n * wrapping and ignores ansi color codes when measuring width. returns false when the terminal size\n * is unknown.\n */\nexport function fitsOnScreen(output: string): boolean {\n const { rows, columns } = process.stdout;\n if (!rows || !columns) return false;\n // split at most rows+1 lines — enough to prove overflow — so the array never scales with the\n // full (potentially huge) output; the loop below also early-exits once one screen is exceeded.\n const lines = output.replace(/\\n$/, '').split('\\n', rows + 1);\n let usedRows = 0;\n for (const line of lines) {\n const width = (removeChalkCharacters(line) || '').length;\n usedRows += width === 0 ? 1 : Math.ceil(width / columns);\n if (usedRows > rows) return false; // stop early once we know it overflows one screen\n }\n return true;\n}\n\n/**\n * decide whether a command's report output should be piped through a pager.\n * mirrors git: on by default for interactive terminals, off for anything else. explicit flags\n * (--pager / --no-pager) and the BIT_NO_PAGER env var override the automatic behavior. in the\n * automatic case, output that already fits on the screen is printed directly (no pager).\n */\nexport function shouldUsePager(command: Command, flags: Flags, output: string): boolean {\n if (!command.pager) return false; // command didn't opt-in to paging\n if (flags.json) return false; // json is for machine consumption, never page it\n // explicit CLI flags win over the BIT_NO_PAGER env var, so `--pager` can force paging for a\n // single invocation even when the user exports BIT_NO_PAGER globally.\n if (flags['no-pager']) return false;\n if (flags.pager) return true; // explicit force-on, even when non-interactive / fits on screen\n if (isEnvSet('BIT_NO_PAGER')) return false; // env opt-out (overridable by --pager above)\n if (!isInteractiveTerminal()) return false;\n return !fitsOnScreen(output); // only page when the output is longer than one screen\n}\n\n/**\n * split a configured pager string (BIT_PAGER / PAGER) into [command, ...args], honoring single and\n * double quotes so an executable path that contains spaces can be configured, e.g.\n * `\"/Applications/My Pager/less\" -R`. we deliberately don't run the pager through a shell (avoids\n * shell-injection and the ENOENT-swallows-output problem), so quoting is how a spaced path is\n * expressed.\n */\nfunction parsePagerCommand(pager: string): string[] {\n const tokens = pager.match(/\"[^\"]*\"|'[^']*'|\\S+/g) || [];\n return tokens.map((token) => token.replace(/^[\"']|[\"']$/g, ''));\n}\n\n/**\n * pipe the given output through a pager (`less` by default). resolves to `true` only after the\n * pager process has exited cleanly — the caller must await this before exiting the process so the\n * pager isn't cut off. resolves to `false` when paging is disabled, the pager couldn't launch, or\n * it exited with an error, in which case the caller must write the data directly so nothing is lost.\n *\n * the pager binary is taken from BIT_PAGER, then PAGER, defaulting to `less`. an empty or `cat`\n * pager means the user disabled paging via the env — honored unless `force` is set (the `--pager`\n * flag), which falls back to a real pager so the flag is a true override. for `less` we set\n * `LESS=FRX` (unless already set, matching git's default): keep ansi colors (-R), don't clear the\n * screen on exit (-X), and quit if the output fits one screen (-F).\n */\nexport function writeToPager(data: string, force = false): Promise<boolean> {\n return new Promise<boolean>((resolve) => {\n // BIT_PAGER wins over PAGER; default to `less` only when neither is set. use `??` (not `||`)\n // so an explicit empty string is preserved rather than treated as unset — that lets\n // BIT_PAGER=\"\" disable paging.\n const configuredPager = process.env.BIT_PAGER ?? process.env.PAGER ?? 'less';\n const tokens = parsePagerCommand(configuredPager);\n // an empty / \"cat\" pager means the user disabled paging. honor that, unless `--pager` forces\n // paging on, in which case fall back to a real pager so the flag is a true override.\n const disabled = !tokens[0] || tokens[0] === 'cat';\n if (disabled && !force) {\n resolve(false);\n return;\n }\n const [cmd, ...args] = disabled ? ['less'] : tokens;\n const env = { ...process.env };\n // LESS=FRX only makes sense for `less` itself; don't leak it into other pagers or wrapper scripts.\n if (/^less(\\.exe)?$/i.test(basename(cmd)) && !env.LESS) env.LESS = 'FRX';\n\n try {\n const child = spawn(cmd, args, { stdio: ['pipe', 'inherit', 'inherit'], env });\n // pager missing (ENOENT) or otherwise failed to launch => fall back to a direct write.\n child.on('error', () => resolve(false));\n // resolve success only on a clean exit (code 0) or a signal (code null, e.g. the user killed\n // it). a non-zero exit means the pager failed (bad args, couldn't render) without showing the\n // output, so fall back to a direct write and never lose it.\n child.on('close', (code) => resolve(code === 0 || code === null));\n // ignore EPIPE that happens when the user quits the pager (e.g. \"q\") before all data is read.\n child.stdin?.on('error', () => {});\n child.stdin?.write(data);\n child.stdin?.end();\n } catch {\n resolve(false);\n }\n });\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;A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B,CAACyC,IAAI,CAAC,IAAAC,gBAAQ,EAACH,GAAG,CAAC,CAAC,IAAI,CAACvC,GAAG,CAAC2C,IAAI,EAAE3C,GAAG,CAAC2C,IAAI,GAAG,KAAK;IAExE,IAAI;MACF,MAAMC,KAAK,GAAG,IAAAC,sBAAK,EAACN,GAAG,EAAEC,IAAI,EAAE;QAAEM,KAAK,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC;QAAE9C;MAAI,CAAC,CAAC;MAC9E;MACA4C,KAAK,CAACG,EAAE,CAAC,OAAO,EAAE,MAAMb,OAAO,CAAC,KAAK,CAAC,CAAC;MACvC;MACA;MACA;MACAU,KAAK,CAACG,EAAE,CAAC,OAAO,EAAGC,IAAI,IAAKd,OAAO,CAACc,IAAI,KAAK,CAAC,IAAIA,IAAI,KAAK,IAAI,CAAC,CAAC;MACjE;MACAJ,KAAK,CAACK,KAAK,EAAEF,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;MAClCH,KAAK,CAACK,KAAK,EAAEC,KAAK,CAAC5F,IAAI,CAAC;MACxBsF,KAAK,CAACK,KAAK,EAAEE,GAAG,CAAC,CAAC;IACpB,CAAC,CAAC,MAAM;MACNjB,OAAO,CAAC,KAAK,CAAC;IAChB;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_cli@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_cli@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_cli@0.0.1351/dist/cli.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_cli@0.0.1351/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
|
@@ -106,6 +106,18 @@ class YargsAdapter {
|
|
|
106
106
|
describe: 'useful when it fails to load normally. it skips loading aspects from workspace.jsonc, and for legacy-commands it initializes only the CLI aspect',
|
|
107
107
|
group: GLOBAL_GROUP
|
|
108
108
|
};
|
|
109
|
+
if (command.pager) {
|
|
110
|
+
globalOptions.pager = {
|
|
111
|
+
describe: 'force paging the output through a pager (e.g. less), even if it fits on one screen',
|
|
112
|
+
group: GLOBAL_GROUP,
|
|
113
|
+
type: 'boolean'
|
|
114
|
+
};
|
|
115
|
+
globalOptions['no-pager'] = {
|
|
116
|
+
describe: 'do not use a pager; print all output at once (default for ai-agents, CI, and piped output)',
|
|
117
|
+
group: GLOBAL_GROUP,
|
|
118
|
+
type: 'boolean'
|
|
119
|
+
};
|
|
120
|
+
}
|
|
109
121
|
return globalOptions;
|
|
110
122
|
}
|
|
111
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_legacy","data","require","_commandRunner","_commandHelper","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","GLOBAL_GROUP","exports","STANDARD_GROUP","YargsAdapter","constructor","commanderCommand","onCommandStartSlot","command","name","describe","description","aliases","alias","builder","yargs","options","optionsToBuilder","option","arg","positional","examples","example","cmd","handler","argv","commandArgs","getArgsData","map","nameCamelCase","argsValues","a","flags","reduce","acc","current","val","_packageManagerArgs","commandRunner","CommandRunner","flagsData","getFlagsData","flag","group","type","requiresArg","globalOptions","getGlobalOptions","remoteOp","TOKEN_FLAG","log"],"sources":["yargs-adapter.ts"],"sourcesContent":["import type { Command } from './command';\nimport type { Arguments, CommandModule, Argv, Options } from 'yargs';\nimport { TOKEN_FLAG } from '@teambit/legacy.constants';\nimport { CommandRunner } from './command-runner';\nimport type { OnCommandStartSlot } from './cli.main.runtime';\nimport { getArgsData, getFlagsData } from './command-helper';\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 commandRunner?: CommandRunner;\n constructor(\n private commanderCommand: Command,\n private onCommandStartSlot: OnCommandStartSlot\n ) {\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 commandArgs = getArgsData(this.commanderCommand).map((arg) => arg.nameCamelCase);\n const argsValues = commandArgs.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, this.onCommandStartSlot);\n this.commandRunner = commandRunner;\n }\n\n get positional() {\n return this.commanderCommand.arguments;\n }\n\n static optionsToBuilder(command: Command): { [key: string]: Options } {\n const flagsData = getFlagsData(command);\n const option = flagsData.reduce((acc, flag) => {\n acc[flag.name] = {\n alias: flag.alias,\n describe: flag.description,\n group: STANDARD_GROUP,\n type: flag.type,\n requiresArg: flag.requiresArg,\n } as Options;\n return acc;\n }, {});\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 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 'useful when it fails to load normally. it skips loading aspects from workspace.jsonc, and for legacy-commands it initializes only the CLI aspect',\n group: GLOBAL_GROUP,\n };\n return globalOptions;\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,eAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,cAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,eAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,cAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA6D,SAAAI,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA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AAE6B,IAAI,CAAC7B,KAAK;QACjBH,QAAQ,EAAEgC,IAAI,CAAC/B,WAAW;QAC1BgC,KAAK,EAAExC,cAAc;QACrByC,IAAI,EAAEF,IAAI,CAACE,IAAI;QACfC,WAAW,EAAEH,IAAI,CAACG;MACpB,CAAY;MACZ,OAAOX,GAAG;IACZ,CAAC,EAAE,CAAC,CAAC,CAAC;IAEN,MAAMY,aAAa,GAAG1C,YAAY,CAAC2C,gBAAgB,CAACvC,OAAO,CAAC;IAE5D,OAAA3B,aAAA,CAAAA,aAAA,KAAYqC,MAAM,GAAK4B,aAAa;EACtC;EAEA,OAAOC,gBAAgBA,CAACvC,OAAgB,EAAuB;IAC7D,MAAMsC,aAAkC,GAAG,CAAC,CAAC;IAC7C,IAAItC,OAAO,CAACwC,QAAQ,EAAE;MACpBF,aAAa,CAACG,oBAAU,CAAC,GAAG;QAC1BvC,QAAQ,EAAE,sBAAsB;QAChCiC,KAAK,EAAE1C;MACT,CAAC;IACH;IACA6C,aAAa,CAACI,GAAG,GAAG;MAClBxC,QAAQ,EACN,8GAA8G;MAChHiC,KAAK,EAAE1C;IACT,CAAC;IACD6C,aAAa,CAAC,WAAW,CAAC,GAAG;MAC3BpC,QAAQ,EACN,kJAAkJ;MACpJiC,KAAK,EAAE1C;IACT,CAAC;IACD,
|
|
1
|
+
{"version":3,"names":["_legacy","data","require","_commandRunner","_commandHelper","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","GLOBAL_GROUP","exports","STANDARD_GROUP","YargsAdapter","constructor","commanderCommand","onCommandStartSlot","command","name","describe","description","aliases","alias","builder","yargs","options","optionsToBuilder","option","arg","positional","examples","example","cmd","handler","argv","commandArgs","getArgsData","map","nameCamelCase","argsValues","a","flags","reduce","acc","current","val","_packageManagerArgs","commandRunner","CommandRunner","flagsData","getFlagsData","flag","group","type","requiresArg","globalOptions","getGlobalOptions","remoteOp","TOKEN_FLAG","log","pager"],"sources":["yargs-adapter.ts"],"sourcesContent":["import type { Command } from './command';\nimport type { Arguments, CommandModule, Argv, Options } from 'yargs';\nimport { TOKEN_FLAG } from '@teambit/legacy.constants';\nimport { CommandRunner } from './command-runner';\nimport type { OnCommandStartSlot } from './cli.main.runtime';\nimport { getArgsData, getFlagsData } from './command-helper';\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 commandRunner?: CommandRunner;\n constructor(\n private commanderCommand: Command,\n private onCommandStartSlot: OnCommandStartSlot\n ) {\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 commandArgs = getArgsData(this.commanderCommand).map((arg) => arg.nameCamelCase);\n const argsValues = commandArgs.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, this.onCommandStartSlot);\n this.commandRunner = commandRunner;\n }\n\n get positional() {\n return this.commanderCommand.arguments;\n }\n\n static optionsToBuilder(command: Command): { [key: string]: Options } {\n const flagsData = getFlagsData(command);\n const option = flagsData.reduce((acc, flag) => {\n acc[flag.name] = {\n alias: flag.alias,\n describe: flag.description,\n group: STANDARD_GROUP,\n type: flag.type,\n requiresArg: flag.requiresArg,\n } as Options;\n return acc;\n }, {});\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 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 'useful when it fails to load normally. it skips loading aspects from workspace.jsonc, and for legacy-commands it initializes only the CLI aspect',\n group: GLOBAL_GROUP,\n };\n if (command.pager) {\n globalOptions.pager = {\n describe: 'force paging the output through a pager (e.g. less), even if it fits on one screen',\n group: GLOBAL_GROUP,\n type: 'boolean',\n };\n globalOptions['no-pager'] = {\n describe: 'do not use a pager; print all output at once (default for ai-agents, CI, and piped output)',\n group: GLOBAL_GROUP,\n type: 'boolean',\n };\n }\n return globalOptions;\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,eAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,cAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,eAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,cAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA6D,SAAAI,QAAAC,CAAA,EAA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E;MACjBL,aAAa,CAACK,KAAK,GAAG;QACpBzC,QAAQ,EAAE,oFAAoF;QAC9FiC,KAAK,EAAE1C,YAAY;QACnB2C,IAAI,EAAE;MACR,CAAC;MACDE,aAAa,CAAC,UAAU,CAAC,GAAG;QAC1BpC,QAAQ,EAAE,4FAA4F;QACtGiC,KAAK,EAAE1C,YAAY;QACnB2C,IAAI,EAAE;MACR,CAAC;IACH;IACA,OAAOE,aAAa;EACtB;AACF;AAAC5C,OAAA,CAAAE,YAAA,GAAAA,YAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1351",
|
|
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.1351"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "4.1.2",
|
|
@@ -16,16 +16,17 @@
|
|
|
16
16
|
"p-map-series": "2.1.0",
|
|
17
17
|
"fs-extra": "10.0.0",
|
|
18
18
|
"pad-right": "0.2.2",
|
|
19
|
-
"@teambit/harmony": "0.4.12",
|
|
20
|
-
"@teambit/bit-error": "0.0.404",
|
|
21
19
|
"@teambit/legacy.consumer": "0.0.136",
|
|
22
20
|
"@teambit/legacy.loader": "0.0.23",
|
|
23
21
|
"@teambit/legacy.logger": "0.0.49",
|
|
22
|
+
"@teambit/harmony": "0.4.12",
|
|
24
23
|
"@teambit/bit.get-bit-version": "0.0.20",
|
|
25
|
-
"@teambit/logger": "0.0.1443",
|
|
26
24
|
"@teambit/legacy.analytics": "0.0.98",
|
|
27
25
|
"@teambit/legacy.constants": "0.0.34",
|
|
28
|
-
"@teambit/
|
|
26
|
+
"@teambit/bit-error": "0.0.404",
|
|
27
|
+
"@teambit/legacy.cli.error": "0.0.49",
|
|
28
|
+
"@teambit/legacy.utils": "0.0.42",
|
|
29
|
+
"@teambit/logger": "0.0.1444"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@types/didyoumean": "1.2.0",
|