@teambit/cli 0.0.475 → 0.0.478

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.
@@ -215,7 +215,7 @@ class CLIMain {
215
215
 
216
216
 
217
217
  getCommand(name) {
218
- return this.commands.find(command => command.name === name);
218
+ return this.commands.find(command => (0, _getCommandId().getCommandId)(command.name) === name);
219
219
  }
220
220
  /**
221
221
  * when running `bit help`, commands are grouped by categories.
@@ -1 +1 @@
1
- {"version":3,"sources":["cli.main.runtime.ts"],"names":["CLIMain","constructor","commandsSlot","onStartSlot","community","groups","register","commands","forEach","command","setDefaults","cmd","unregister","commandName","toArray","aspectId","filteredCommands","filter","name","map","set","values","flat","getCommand","find","registerGroup","description","AlreadyExistsError","registerOnStart","onStartFn","run","hasWorkspace","invokeOnStart","CliParser","CLIParser","undefined","getDocsDomain","parse","onStartFns","promises","onStart","Promise","all","alias","shortDescription","group","options","private","loader","internal","provider","config","cliMain","legacyExtensions","extension","registerHookActionsOnHooksManager","extensionsCommands","reduce","acc","curr","length","concat","legacyRegistry","legacyCommands","legacyCommandsAdapters","LegacyCommandAdapter","cliGenerateCmd","CliGenerateCmd","cliCmd","CliCmd","helpCmd","HelpCmd","push","CompletionCmd","CommunityAspect","MainRuntime","Slot","withType","CLIAspect","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;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ry } from '@teambit/harmony';\nimport { buildRegistry } from '@teambit/legacy/dist/cli';\nimport { Command } from '@teambit/legacy/dist/cli/command';\nimport LegacyLoadExtensions from '@teambit/legacy/dist/legacy-extensions/extensions-loader';\nimport { CommunityAspect } from '@teambit/community';\nimport type { CommunityMain } from '@teambit/community';\n\nimport { groups, GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { clone } from 'lodash';\nimport { CLIAspect, MainRuntime } from './cli.aspect';\nimport { AlreadyExistsError } from './exceptions/already-exists';\nimport { getCommandId } from './get-command-id';\nimport { LegacyCommandAdapter } from './legacy-command-adapter';\nimport { CLIParser } from './cli-parser';\nimport { CompletionCmd } from './completion.cmd';\nimport { CliCmd, CliGenerateCmd } from './cli.cmd';\nimport { HelpCmd } from './help.cmd';\n\nexport type CommandList = Array<Command>;\nexport type OnStart = (hasWorkspace: boolean) => Promise<void>;\n\nexport type OnStartSlot = SlotRegistry<OnStart>;\nexport type CommandsSlot = SlotRegistry<CommandList>;\n\nexport class CLIMain {\n public groups: GroupsType = clone(groups); // if it's not cloned, it is cached across loadBit() instances\n\n constructor(private commandsSlot: CommandsSlot, private onStartSlot: OnStartSlot, private community: CommunityMain) {}\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 (legacy and Harmony)\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) => command.name === name);\n }\n\n /**\n * when running `bit help`, commands are grouped by categories.\n * this method helps registering a new group by providing its name and a description.\n * the name is what needs to be assigned to the `group` property of the Command interface.\n * the description is what shown in the `bit help` output.\n */\n registerGroup(name: string, description: string) {\n if (this.groups[name]) {\n throw new AlreadyExistsError('group', name);\n }\n this.groups[name] = description;\n }\n\n registerOnStart(onStartFn: OnStart) {\n this.onStartSlot.register(onStartFn);\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, undefined, this.community.getDocsDomain());\n await CliParser.parse();\n }\n\n private async invokeOnStart(hasWorkspace: boolean) {\n const onStartFns = this.onStartSlot.values();\n const promises = onStartFns.map(async (onStart) => onStart(hasWorkspace));\n return Promise.all(promises);\n }\n\n private setDefaults(command: Command) {\n command.alias = command.alias || '';\n command.description = command.description || '';\n command.shortDescription = command.shortDescription || '';\n command.group = command.group || 'ungrouped';\n command.options = command.options || [];\n command.private = command.private || false;\n command.commands = command.commands || [];\n if (command.loader === undefined) {\n if (command.internal) {\n command.loader = false;\n } else {\n command.loader = true;\n }\n }\n }\n\n static dependencies = [CommunityAspect];\n static runtime = MainRuntime;\n static slots = [Slot.withType<CommandList>(), Slot.withType<OnStart>()];\n\n static async provider(\n [community]: [CommunityMain],\n config,\n [commandsSlot, onStartSlot]: [CommandsSlot, OnStartSlot]\n ) {\n const cliMain = new CLIMain(commandsSlot, onStartSlot, community);\n const legacyExtensions = await LegacyLoadExtensions();\n // Make sure to register all the hooks actions in the global hooks manager\n legacyExtensions.forEach((extension) => {\n extension.registerHookActionsOnHooksManager();\n });\n\n const extensionsCommands = legacyExtensions.reduce((acc, curr) => {\n if (curr.commands && curr.commands.length) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n acc = acc.concat(curr.commands);\n }\n return acc;\n }, []);\n\n const legacyRegistry = buildRegistry(extensionsCommands);\n const legacyCommands = legacyRegistry.commands.concat(legacyRegistry.extensionsCommands || []);\n const legacyCommandsAdapters = legacyCommands.map((command) => new LegacyCommandAdapter(command, cliMain));\n const cliGenerateCmd = new CliGenerateCmd(cliMain);\n const cliCmd = new CliCmd(cliMain, community.getDocsDomain());\n const helpCmd = new HelpCmd(cliMain, community.getDocsDomain());\n cliCmd.commands.push(cliGenerateCmd);\n cliMain.register(...legacyCommandsAdapters, new CompletionCmd(), cliCmd, helpCmd);\n return cliMain;\n }\n}\n\nCLIAspect.addRuntime(CLIMain);\n"]}
1
+ {"version":3,"sources":["cli.main.runtime.ts"],"names":["CLIMain","constructor","commandsSlot","onStartSlot","community","groups","register","commands","forEach","command","setDefaults","cmd","unregister","commandName","toArray","aspectId","filteredCommands","filter","name","map","set","values","flat","getCommand","find","registerGroup","description","AlreadyExistsError","registerOnStart","onStartFn","run","hasWorkspace","invokeOnStart","CliParser","CLIParser","undefined","getDocsDomain","parse","onStartFns","promises","onStart","Promise","all","alias","shortDescription","group","options","private","loader","internal","provider","config","cliMain","legacyExtensions","extension","registerHookActionsOnHooksManager","extensionsCommands","reduce","acc","curr","length","concat","legacyRegistry","legacyCommands","legacyCommandsAdapters","LegacyCommandAdapter","cliGenerateCmd","CliGenerateCmd","cliCmd","CliCmd","helpCmd","HelpCmd","push","CompletionCmd","CommunityAspect","MainRuntime","Slot","withType","CLIAspect","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AA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AA/B,C;;AAkCjBC,kBAAUC,UAAV,CAAqB/E,OAArB","sourcesContent":["import { Slot, SlotRegistry } from '@teambit/harmony';\nimport { buildRegistry } from '@teambit/legacy/dist/cli';\nimport { Command } from '@teambit/legacy/dist/cli/command';\nimport LegacyLoadExtensions from '@teambit/legacy/dist/legacy-extensions/extensions-loader';\nimport { CommunityAspect } from '@teambit/community';\nimport type { CommunityMain } from '@teambit/community';\n\nimport { groups, GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { clone } from 'lodash';\nimport { CLIAspect, MainRuntime } from './cli.aspect';\nimport { AlreadyExistsError } from './exceptions/already-exists';\nimport { getCommandId } from './get-command-id';\nimport { LegacyCommandAdapter } from './legacy-command-adapter';\nimport { CLIParser } from './cli-parser';\nimport { CompletionCmd } from './completion.cmd';\nimport { CliCmd, CliGenerateCmd } from './cli.cmd';\nimport { HelpCmd } from './help.cmd';\n\nexport type CommandList = Array<Command>;\nexport type OnStart = (hasWorkspace: boolean) => Promise<void>;\n\nexport type OnStartSlot = SlotRegistry<OnStart>;\nexport type CommandsSlot = SlotRegistry<CommandList>;\n\nexport class CLIMain {\n public groups: GroupsType = clone(groups); // if it's not cloned, it is cached across loadBit() instances\n\n constructor(private commandsSlot: CommandsSlot, private onStartSlot: OnStartSlot, private community: CommunityMain) {}\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 (legacy and Harmony)\n */\n unregister(commandName: string) {\n this.commandsSlot.toArray().forEach(([aspectId, commands]) => {\n const filteredCommands = commands.filter((command) => {\n return getCommandId(command.name) !== commandName;\n });\n this.commandsSlot.map.set(aspectId, filteredCommands);\n });\n }\n\n /**\n * list of all registered commands. (legacy and new).\n */\n get commands(): CommandList {\n return this.commandsSlot.values().flat();\n }\n\n /**\n * get an instance of a registered command. (useful for aspects to modify and extend existing commands)\n */\n getCommand(name: string): Command | undefined {\n return this.commands.find((command) => getCommandId(command.name) === name);\n }\n\n /**\n * when running `bit help`, commands are grouped by categories.\n * this method helps registering a new group by providing its name and a description.\n * the name is what needs to be assigned to the `group` property of the Command interface.\n * the description is what shown in the `bit help` output.\n */\n registerGroup(name: string, description: string) {\n if (this.groups[name]) {\n throw new AlreadyExistsError('group', name);\n }\n this.groups[name] = description;\n }\n\n registerOnStart(onStartFn: OnStart) {\n this.onStartSlot.register(onStartFn);\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, undefined, this.community.getDocsDomain());\n await CliParser.parse();\n }\n\n private async invokeOnStart(hasWorkspace: boolean) {\n const onStartFns = this.onStartSlot.values();\n const promises = onStartFns.map(async (onStart) => onStart(hasWorkspace));\n return Promise.all(promises);\n }\n\n private setDefaults(command: Command) {\n command.alias = command.alias || '';\n command.description = command.description || '';\n command.shortDescription = command.shortDescription || '';\n command.group = command.group || 'ungrouped';\n command.options = command.options || [];\n command.private = command.private || false;\n command.commands = command.commands || [];\n if (command.loader === undefined) {\n if (command.internal) {\n command.loader = false;\n } else {\n command.loader = true;\n }\n }\n }\n\n static dependencies = [CommunityAspect];\n static runtime = MainRuntime;\n static slots = [Slot.withType<CommandList>(), Slot.withType<OnStart>()];\n\n static async provider(\n [community]: [CommunityMain],\n config,\n [commandsSlot, onStartSlot]: [CommandsSlot, OnStartSlot]\n ) {\n const cliMain = new CLIMain(commandsSlot, onStartSlot, community);\n const legacyExtensions = await LegacyLoadExtensions();\n // Make sure to register all the hooks actions in the global hooks manager\n legacyExtensions.forEach((extension) => {\n extension.registerHookActionsOnHooksManager();\n });\n\n const extensionsCommands = legacyExtensions.reduce((acc, curr) => {\n if (curr.commands && curr.commands.length) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n acc = acc.concat(curr.commands);\n }\n return acc;\n }, []);\n\n const legacyRegistry = buildRegistry(extensionsCommands);\n const legacyCommands = legacyRegistry.commands.concat(legacyRegistry.extensionsCommands || []);\n const legacyCommandsAdapters = legacyCommands.map((command) => new LegacyCommandAdapter(command, cliMain));\n const cliGenerateCmd = new CliGenerateCmd(cliMain);\n const cliCmd = new CliCmd(cliMain, community.getDocsDomain());\n const helpCmd = new HelpCmd(cliMain, community.getDocsDomain());\n cliCmd.commands.push(cliGenerateCmd);\n cliMain.register(...legacyCommandsAdapters, new CompletionCmd(), cliCmd, helpCmd);\n return cliMain;\n }\n}\n\nCLIAspect.addRuntime(CLIMain);\n"]}
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@teambit/cli",
3
- "version": "0.0.475",
3
+ "version": "0.0.478",
4
4
  "homepage": "https://bit.dev/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.475"
9
+ "version": "0.0.478"
10
10
  },
11
11
  "dependencies": {
12
- "chalk": "2.4.2",
12
+ "chalk": "4.1.2",
13
13
  "didyoumean": "1.2.1",
14
14
  "lodash": "4.17.21",
15
15
  "yargs": "17.0.1",
@@ -18,7 +18,7 @@
18
18
  "@babel/runtime": "7.12.18",
19
19
  "core-js": "^3.0.0",
20
20
  "@teambit/harmony": "0.3.3",
21
- "@teambit/community": "0.0.23",
21
+ "@teambit/community": "0.0.26",
22
22
  "@teambit/bit-error": "0.0.394"
23
23
  },
24
24
  "devDependencies": {
@@ -33,7 +33,7 @@
33
33
  "@types/node": "12.20.4"
34
34
  },
35
35
  "peerDependencies": {
36
- "@teambit/legacy": "1.0.255",
36
+ "@teambit/legacy": "1.0.258",
37
37
  "react-dom": "^16.8.0 || ^17.0.0",
38
38
  "react": "^16.8.0 || ^17.0.0"
39
39
  },
@@ -61,7 +61,7 @@
61
61
  "react": "-"
62
62
  },
63
63
  "peerDependencies": {
64
- "@teambit/legacy": "1.0.255",
64
+ "@teambit/legacy": "1.0.258",
65
65
  "react-dom": "^16.8.0 || ^17.0.0",
66
66
  "react": "^16.8.0 || ^17.0.0"
67
67
  }
@@ -1,2 +1,2 @@
1
- export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.475/dist/cli.composition.js')]
2
- export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.475/dist/cli.docs.mdx')]
1
+ export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.478/dist/cli.composition.js')]
2
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.478/dist/cli.docs.mdx')]
Binary file