@teambit/cli 0.0.518 → 0.0.521

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.
@@ -17,7 +17,8 @@ export declare class CLIMain {
17
17
  */
18
18
  register(...commands: CommandList): void;
19
19
  /**
20
- * helpful for having the same command name in different environments (legacy and Harmony)
20
+ * helpful for having the same command name in different environments (e.g. legacy and non-legacy).
21
+ * for example `cli.unregister('tag');` removes the "bit tag" command.
21
22
  */
22
23
  unregister(commandName: string): void;
23
24
  /**
@@ -47,30 +47,30 @@ function _cli() {
47
47
  return data;
48
48
  }
49
49
 
50
- function _extensionsLoader() {
51
- const data = _interopRequireDefault(require("@teambit/legacy/dist/legacy-extensions/extensions-loader"));
50
+ function _community() {
51
+ const data = require("@teambit/community");
52
52
 
53
- _extensionsLoader = function () {
53
+ _community = function () {
54
54
  return data;
55
55
  };
56
56
 
57
57
  return data;
58
58
  }
59
59
 
60
- function _community() {
61
- const data = require("@teambit/community");
60
+ function _commandGroups() {
61
+ const data = require("@teambit/legacy/dist/cli/command-groups");
62
62
 
63
- _community = function () {
63
+ _commandGroups = function () {
64
64
  return data;
65
65
  };
66
66
 
67
67
  return data;
68
68
  }
69
69
 
70
- function _commandGroups() {
71
- const data = require("@teambit/legacy/dist/cli/command-groups");
70
+ function _consumer() {
71
+ const data = require("@teambit/legacy/dist/consumer");
72
72
 
73
- _commandGroups = function () {
73
+ _consumer = function () {
74
74
  return data;
75
75
  };
76
76
 
@@ -189,7 +189,8 @@ class CLIMain {
189
189
  this.commandsSlot.register(commands);
190
190
  }
191
191
  /**
192
- * helpful for having the same command name in different environments (legacy and Harmony)
192
+ * helpful for having the same command name in different environments (e.g. legacy and non-legacy).
193
+ * for example `cli.unregister('tag');` removes the "bit tag" command.
193
194
  */
194
195
 
195
196
 
@@ -274,21 +275,9 @@ class CLIMain {
274
275
 
275
276
  static async provider([community], config, [commandsSlot, onStartSlot]) {
276
277
  const cliMain = new CLIMain(commandsSlot, onStartSlot, community);
277
- const legacyExtensions = await (0, _extensionsLoader().default)(); // Make sure to register all the hooks actions in the global hooks manager
278
-
279
- legacyExtensions.forEach(extension => {
280
- extension.registerHookActionsOnHooksManager();
281
- });
282
- const extensionsCommands = legacyExtensions.reduce((acc, curr) => {
283
- if (curr.commands && curr.commands.length) {
284
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
285
- acc = acc.concat(curr.commands);
286
- }
287
-
288
- return acc;
289
- }, []);
290
- const legacyRegistry = (0, _cli().buildRegistry)(extensionsCommands);
291
- const legacyCommands = legacyRegistry.commands.concat(legacyRegistry.extensionsCommands || []);
278
+ const legacyRegistry = (0, _cli().buildRegistry)();
279
+ await ensureWorkspaceAndScope();
280
+ const legacyCommands = legacyRegistry.commands;
292
281
  const legacyCommandsAdapters = legacyCommands.map(command => new (_legacyCommandAdapter().LegacyCommandAdapter)(command, cliMain));
293
282
  const cliGenerateCmd = new (_cli3().CliGenerateCmd)(cliMain);
294
283
  const cliCmd = new (_cli3().CliCmd)(cliMain, community.getDocsDomain());
@@ -306,5 +295,19 @@ exports.CLIMain = CLIMain;
306
295
  (0, _defineProperty2().default)(CLIMain, "slots", [_harmony().Slot.withType(), _harmony().Slot.withType()]);
307
296
 
308
297
  _cli2().CLIAspect.addRuntime(CLIMain);
298
+ /**
299
+ * kind of a hack.
300
+ * in the legacy, this is running at the beginning and it take care of issues when Bit files are missing,
301
+ * such as ".bit".
302
+ * (to make this process better, you can easily remove it and run the e2e-tests. you'll see some failing)
303
+ */
304
+
305
+
306
+ async function ensureWorkspaceAndScope() {
307
+ try {
308
+ await (0, _consumer().loadConsumerIfExist)();
309
+ } catch (err) {// do nothing. it could fail for example with ScopeNotFound error, which is taken care of in "bit init".
310
+ }
311
+ }
309
312
 
310
313
  //# sourceMappingURL=cli.main.runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CLIMain","constructor","commandsSlot","onStartSlot","community","clone","groups","register","commands","forEach","command","setDefaults","cmd","unregister","commandName","toArray","aspectId","filteredCommands","filter","getCommandId","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","extendedDescription","group","options","private","loader","internal","provider","config","cliMain","legacyExtensions","LegacyLoadExtensions","extension","registerHookActionsOnHooksManager","extensionsCommands","reduce","acc","curr","length","concat","legacyRegistry","buildRegistry","legacyCommands","legacyCommandsAdapters","LegacyCommandAdapter","cliGenerateCmd","CliGenerateCmd","cliCmd","CliCmd","helpCmd","HelpCmd","push","CompletionCmd","CommunityAspect","MainRuntime","Slot","withType","CLIAspect","addRuntime"],"sources":["cli.main.runtime.ts"],"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.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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;A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lot","onStartSlot","community","clone","groups","register","commands","forEach","command","setDefaults","cmd","unregister","commandName","toArray","aspectId","filteredCommands","filter","getCommandId","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","extendedDescription","group","options","private","loader","internal","provider","config","cliMain","legacyRegistry","buildRegistry","ensureWorkspaceAndScope","legacyCommands","legacyCommandsAdapters","LegacyCommandAdapter","cliGenerateCmd","CliGenerateCmd","cliCmd","CliCmd","helpCmd","HelpCmd","push","CompletionCmd","CommunityAspect","MainRuntime","Slot","withType","CLIAspect","addRuntime","loadConsumerIfExist","err"],"sources":["cli.main.runtime.ts"],"sourcesContent":["import { Slot, SlotRegistry } from '@teambit/harmony';\nimport { buildRegistry } from '@teambit/legacy/dist/cli';\nimport { Command } from '@teambit/legacy/dist/cli/command';\nimport { CommunityAspect } from '@teambit/community';\nimport type { CommunityMain } from '@teambit/community';\n\nimport { groups, GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\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 (e.g. legacy and non-legacy).\n * for example `cli.unregister('tag');` removes the \"bit tag\" command.\n */\n unregister(commandName: string) {\n this.commandsSlot.toArray().forEach(([aspectId, commands]) => {\n const filteredCommands = commands.filter((command) => {\n return getCommandId(command.name) !== commandName;\n });\n this.commandsSlot.map.set(aspectId, filteredCommands);\n });\n }\n\n /**\n * list of all registered commands. (legacy and new).\n */\n get commands(): CommandList {\n return this.commandsSlot.values().flat();\n }\n\n /**\n * get an instance of a registered command. (useful for aspects to modify and extend existing commands)\n */\n getCommand(name: string): Command | undefined {\n return this.commands.find((command) => getCommandId(command.name) === name);\n }\n\n /**\n * when running `bit help`, commands are grouped by categories.\n * this method helps registering a new group by providing its name and a description.\n * the name is what needs to be assigned to the `group` property of the Command interface.\n * the description is what shown in the `bit help` output.\n */\n registerGroup(name: string, description: string) {\n if (this.groups[name]) {\n 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.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 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 legacyRegistry = buildRegistry();\n await ensureWorkspaceAndScope();\n const legacyCommands = legacyRegistry.commands;\n const legacyCommandsAdapters = legacyCommands.map((command) => new LegacyCommandAdapter(command, cliMain));\n const cliGenerateCmd = new CliGenerateCmd(cliMain);\n const cliCmd = new CliCmd(cliMain, 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\n/**\n * kind of a hack.\n * in the legacy, this is running at the beginning and it take care of issues when Bit files are missing,\n * such as \".bit\".\n * (to make this process better, you can easily remove it and run the e2e-tests. you'll see some failing)\n */\nasync function ensureWorkspaceAndScope() {\n try {\n await loadConsumerIfExist();\n } catch (err) {\n // do nothing. it could fail for example with ScopeNotFound error, which is taken care of in \"bit init\".\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;E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ACA,MAAMO,cAAc,GAAG,KAAIC,sBAAJ,EAAmBR,OAAnB,CAAvB;IACA,MAAMS,MAAM,GAAG,KAAIC,cAAJ,EAAWV,OAAX,EAAoBlD,SAAS,CAACkC,aAAV,EAApB,CAAf;IACA,MAAM2B,OAAO,GAAG,KAAIC,eAAJ,EAAYZ,OAAZ,EAAqBlD,SAAS,CAACkC,aAAV,EAArB,CAAhB;IACAyB,MAAM,CAACvD,QAAP,CAAgB2D,IAAhB,CAAqBN,cAArB;IACAP,OAAO,CAAC/C,QAAR,CAAiB,GAAGoD,sBAApB,EAA4C,KAAIS,2BAAJ,GAA5C,EAAiEL,MAAjE,EAAyEE,OAAzE;IACA,OAAOX,OAAP;EACD;;AAlHkB;;;gCAARtD,O,kBA8FW,CAACqE,4BAAD,C;gCA9FXrE,O,aA+FMsE,mB;gCA/FNtE,O,WAgGI,CAACuE,eAAA,CAAKC,QAAL,EAAD,EAA+BD,eAAA,CAAKC,QAAL,EAA/B,C;;AAqBjBC,iBAAA,CAAUC,UAAV,CAAqB1E,OAArB;AAEA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAeyD,uBAAf,GAAyC;EACvC,IAAI;IACF,MAAM,IAAAkB,+BAAA,GAAN;EACD,CAFD,CAEE,OAAOC,GAAP,EAAY,CACZ;EACD;AACF"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/cli",
3
- "version": "0.0.518",
3
+ "version": "0.0.521",
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.518"
9
+ "version": "0.0.521"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -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.66",
21
+ "@teambit/community": "0.0.69",
22
22
  "@teambit/bit-error": "0.0.394"
23
23
  },
24
24
  "devDependencies": {
@@ -33,40 +33,11 @@
33
33
  "@types/node": "12.20.4"
34
34
  },
35
35
  "peerDependencies": {
36
- "@teambit/legacy": "1.0.299",
36
+ "@teambit/legacy": "1.0.303",
37
37
  "react-dom": "^16.8.0 || ^17.0.0",
38
38
  "react": "^16.8.0 || ^17.0.0"
39
39
  },
40
40
  "license": "Apache-2.0",
41
- "bit": {
42
- "bindingPrefix": "@teambit",
43
- "env": {},
44
- "overrides": {
45
- "dependencies": {
46
- "@teambit/legacy": "-",
47
- "@babel/runtime": "7.12.18",
48
- "core-js": "^3.0.0",
49
- "react-dom": "-",
50
- "react": "-"
51
- },
52
- "devDependencies": {
53
- "@teambit/legacy": "-",
54
- "@types/mocha": "9.1.0",
55
- "@types/testing-library__jest-dom": "5.9.5",
56
- "@types/jest": "^26.0.0",
57
- "@types/react-dom": "^17.0.5",
58
- "@types/react": "^17.0.8",
59
- "@types/node": "12.20.4",
60
- "react-dom": "-",
61
- "react": "-"
62
- },
63
- "peerDependencies": {
64
- "@teambit/legacy": "1.0.299",
65
- "react-dom": "^16.8.0 || ^17.0.0",
66
- "react": "^16.8.0 || ^17.0.0"
67
- }
68
- }
69
- },
70
41
  "private": false,
71
42
  "engines": {
72
43
  "node": ">=12.22.0"
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.518/dist/cli.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.518/dist/cli.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.521/dist/cli.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.521/dist/cli.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
Binary file