@teambit/cli 0.0.563 → 0.0.564
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.main.runtime.d.ts +4 -2
- package/dist/cli.main.runtime.js +18 -16
- package/dist/cli.main.runtime.js.map +1 -1
- package/package-tar/teambit-cli-0.0.564.tgz +0 -0
- package/package.json +5 -4
- package/{preview-1662281577904.js → preview-1662521943539.js} +2 -2
- package/package-tar/teambit-cli-0.0.563.tgz +0 -0
|
@@ -2,6 +2,7 @@ import { SlotRegistry } from '@teambit/harmony';
|
|
|
2
2
|
import { Command } from '@teambit/legacy/dist/cli/command';
|
|
3
3
|
import type { CommunityMain } from '@teambit/community';
|
|
4
4
|
import { GroupsType } from '@teambit/legacy/dist/cli/command-groups';
|
|
5
|
+
import { Logger, LoggerMain } from '@teambit/logger';
|
|
5
6
|
export declare type CommandList = Array<Command>;
|
|
6
7
|
export declare type OnStart = (hasWorkspace: boolean) => Promise<void>;
|
|
7
8
|
export declare type OnStartSlot = SlotRegistry<OnStart>;
|
|
@@ -10,8 +11,9 @@ export declare class CLIMain {
|
|
|
10
11
|
private commandsSlot;
|
|
11
12
|
private onStartSlot;
|
|
12
13
|
private community;
|
|
14
|
+
private logger;
|
|
13
15
|
groups: GroupsType;
|
|
14
|
-
constructor(commandsSlot: CommandsSlot, onStartSlot: OnStartSlot, community: CommunityMain);
|
|
16
|
+
constructor(commandsSlot: CommandsSlot, onStartSlot: OnStartSlot, community: CommunityMain, logger: Logger);
|
|
15
17
|
/**
|
|
16
18
|
* registers a new command in to the CLI.
|
|
17
19
|
*/
|
|
@@ -46,5 +48,5 @@ export declare class CLIMain {
|
|
|
46
48
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
47
49
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
48
50
|
static slots: (((registerFn: () => string) => SlotRegistry<CommandList>) | ((registerFn: () => string) => SlotRegistry<OnStart>))[];
|
|
49
|
-
static provider([community]: [CommunityMain], config: any, [commandsSlot, onStartSlot]: [CommandsSlot, OnStartSlot]): Promise<CLIMain>;
|
|
51
|
+
static provider([community, loggerMain]: [CommunityMain, LoggerMain], config: any, [commandsSlot, onStartSlot]: [CommandsSlot, OnStartSlot]): Promise<CLIMain>;
|
|
50
52
|
}
|
package/dist/cli.main.runtime.js
CHANGED
|
@@ -77,30 +77,30 @@ function _consumer() {
|
|
|
77
77
|
return data;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function
|
|
81
|
-
const data = require("
|
|
80
|
+
function _logger() {
|
|
81
|
+
const data = require("@teambit/logger");
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
_logger = function () {
|
|
84
84
|
return data;
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
return data;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
function
|
|
91
|
-
const data = require("
|
|
90
|
+
function _lodash() {
|
|
91
|
+
const data = require("lodash");
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
_lodash = function () {
|
|
94
94
|
return data;
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
return data;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
function
|
|
101
|
-
const data = require("./
|
|
100
|
+
function _cli2() {
|
|
101
|
+
const data = require("./cli.aspect");
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
_cli2 = function () {
|
|
104
104
|
return data;
|
|
105
105
|
};
|
|
106
106
|
|
|
@@ -169,10 +169,11 @@ function _help() {
|
|
|
169
169
|
|
|
170
170
|
class CLIMain {
|
|
171
171
|
// if it's not cloned, it is cached across loadBit() instances
|
|
172
|
-
constructor(commandsSlot, onStartSlot, community) {
|
|
172
|
+
constructor(commandsSlot, onStartSlot, community, logger) {
|
|
173
173
|
this.commandsSlot = commandsSlot;
|
|
174
174
|
this.onStartSlot = onStartSlot;
|
|
175
175
|
this.community = community;
|
|
176
|
+
this.logger = logger;
|
|
176
177
|
(0, _defineProperty2().default)(this, "groups", (0, _lodash().clone)(_commandGroups().groups));
|
|
177
178
|
}
|
|
178
179
|
/**
|
|
@@ -228,10 +229,10 @@ class CLIMain {
|
|
|
228
229
|
|
|
229
230
|
registerGroup(name, description) {
|
|
230
231
|
if (this.groups[name]) {
|
|
231
|
-
|
|
232
|
+
this.logger.consoleWarning(`CLI group "${name}" is already registered`);
|
|
233
|
+
} else {
|
|
234
|
+
this.groups[name] = description;
|
|
232
235
|
}
|
|
233
|
-
|
|
234
|
-
this.groups[name] = description;
|
|
235
236
|
}
|
|
236
237
|
|
|
237
238
|
registerOnStart(onStartFn) {
|
|
@@ -277,8 +278,9 @@ class CLIMain {
|
|
|
277
278
|
}
|
|
278
279
|
}
|
|
279
280
|
|
|
280
|
-
static async provider([community], config, [commandsSlot, onStartSlot]) {
|
|
281
|
-
const
|
|
281
|
+
static async provider([community, loggerMain], config, [commandsSlot, onStartSlot]) {
|
|
282
|
+
const logger = loggerMain.createLogger(_cli2().CLIAspect.id);
|
|
283
|
+
const cliMain = new CLIMain(commandsSlot, onStartSlot, community, logger);
|
|
282
284
|
const legacyRegistry = (0, _cli().buildRegistry)();
|
|
283
285
|
await ensureWorkspaceAndScope();
|
|
284
286
|
const legacyCommands = legacyRegistry.commands;
|
|
@@ -294,7 +296,7 @@ class CLIMain {
|
|
|
294
296
|
}
|
|
295
297
|
|
|
296
298
|
exports.CLIMain = CLIMain;
|
|
297
|
-
(0, _defineProperty2().default)(CLIMain, "dependencies", [_community().CommunityAspect]);
|
|
299
|
+
(0, _defineProperty2().default)(CLIMain, "dependencies", [_community().CommunityAspect, _logger().LoggerAspect]);
|
|
298
300
|
(0, _defineProperty2().default)(CLIMain, "runtime", _cli2().MainRuntime);
|
|
299
301
|
(0, _defineProperty2().default)(CLIMain, "slots", [_harmony().Slot.withType(), _harmony().Slot.withType()]);
|
|
300
302
|
|
|
@@ -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","helpUrl","isFullUrl","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","url","startsWith"],"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 if (command.helpUrl && !isFullUrl(command.helpUrl)) {\n command.helpUrl = `https://${this.community.getDocsDomain()}/${command.helpUrl}`;\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\nfunction isFullUrl(url: string) {\n return url.startsWith('http://') || url.startsWith('https://');\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;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AACC,UAAJ,CAAe,SAAf,KAA6BD,GAAG,CAACC,UAAJ,CAAe,UAAf,CAApC;AACD"}
|
|
1
|
+
{"version":3,"names":["CLIMain","constructor","commandsSlot","onStartSlot","community","logger","clone","groups","register","commands","forEach","command","setDefaults","cmd","unregister","commandName","toArray","aspectId","filteredCommands","filter","getCommandId","name","map","set","values","flat","getCommand","find","registerGroup","description","consoleWarning","registerOnStart","onStartFn","run","hasWorkspace","invokeOnStart","CliParser","CLIParser","undefined","getDocsDomain","parse","onStartFns","promises","onStart","Promise","all","alias","extendedDescription","group","options","private","loader","internal","helpUrl","isFullUrl","provider","loggerMain","config","createLogger","CLIAspect","id","cliMain","legacyRegistry","buildRegistry","ensureWorkspaceAndScope","legacyCommands","legacyCommandsAdapters","LegacyCommandAdapter","cliGenerateCmd","CliGenerateCmd","cliCmd","CliCmd","helpCmd","HelpCmd","push","CompletionCmd","CommunityAspect","LoggerAspect","MainRuntime","Slot","withType","addRuntime","loadConsumerIfExist","err","url","startsWith"],"sources":["cli.main.runtime.ts"],"sourcesContent":["import { Slot, SlotRegistry } from '@teambit/harmony';\nimport { buildRegistry } from '@teambit/legacy/dist/cli';\nimport { 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 { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { clone } from 'lodash';\nimport { CLIAspect, MainRuntime } from './cli.aspect';\nimport { getCommandId } from './get-command-id';\nimport { LegacyCommandAdapter } from './legacy-command-adapter';\nimport { CLIParser } from './cli-parser';\nimport { CompletionCmd } from './completion.cmd';\nimport { CliCmd, CliGenerateCmd } from './cli.cmd';\nimport { HelpCmd } from './help.cmd';\n\nexport type CommandList = Array<Command>;\nexport type OnStart = (hasWorkspace: boolean) => 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 constructor(\n private commandsSlot: CommandsSlot,\n private onStartSlot: OnStartSlot,\n private community: CommunityMain,\n private logger: Logger\n ) {}\n\n /**\n * registers a new command in to the CLI.\n */\n register(...commands: CommandList) {\n commands.forEach((command) => {\n this.setDefaults(command);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n command.commands!.forEach((cmd) => this.setDefaults(cmd));\n });\n this.commandsSlot.register(commands);\n }\n\n /**\n * helpful for having the same command name in different environments (e.g. legacy and non-legacy).\n * for example `cli.unregister('tag');` removes the \"bit tag\" command.\n */\n unregister(commandName: string) {\n this.commandsSlot.toArray().forEach(([aspectId, commands]) => {\n const filteredCommands = commands.filter((command) => {\n return getCommandId(command.name) !== commandName;\n });\n this.commandsSlot.map.set(aspectId, filteredCommands);\n });\n }\n\n /**\n * list of all registered commands. (legacy and new).\n */\n get commands(): CommandList {\n return this.commandsSlot.values().flat();\n }\n\n /**\n * get an instance of a registered command. (useful for aspects to modify and extend existing commands)\n */\n getCommand(name: string): Command | undefined {\n return this.commands.find((command) => getCommandId(command.name) === name);\n }\n\n /**\n * when running `bit help`, commands are grouped by categories.\n * this method helps registering a new group by providing its name and a description.\n * the name is what needs to be assigned to the `group` property of the Command interface.\n * the description is what shown in the `bit help` output.\n */\n registerGroup(name: string, description: string) {\n if (this.groups[name]) {\n this.logger.consoleWarning(`CLI group \"${name}\" is already registered`);\n } else {\n this.groups[name] = description;\n }\n }\n\n registerOnStart(onStartFn: OnStart) {\n this.onStartSlot.register(onStartFn);\n return this;\n }\n\n /**\n * 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 if (command.helpUrl && !isFullUrl(command.helpUrl)) {\n command.helpUrl = `https://${this.community.getDocsDomain()}/${command.helpUrl}`;\n }\n }\n\n static dependencies = [CommunityAspect, LoggerAspect];\n static runtime = MainRuntime;\n static slots = [Slot.withType<CommandList>(), Slot.withType<OnStart>()];\n\n static async provider(\n [community, loggerMain]: [CommunityMain, LoggerMain],\n config,\n [commandsSlot, onStartSlot]: [CommandsSlot, OnStartSlot]\n ) {\n const logger = loggerMain.createLogger(CLIAspect.id);\n const cliMain = new CLIMain(commandsSlot, onStartSlot, community, logger);\n const legacyRegistry = buildRegistry();\n await ensureWorkspaceAndScope();\n const legacyCommands = legacyRegistry.commands;\n const legacyCommandsAdapters = legacyCommands.map((command) => new LegacyCommandAdapter(command, cliMain));\n const cliGenerateCmd = new CliGenerateCmd(cliMain);\n const cliCmd = new CliCmd(cliMain, 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\nfunction is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gCAAR7D,O,kBAsGW,CAAC4E,4BAAD,EAAkBC,sBAAlB,C;gCAtGX7E,O,aAuGM8E,mB;gCAvGN9E,O,WAwGI,CAAC+E,eAAA,CAAKC,QAAL,EAAD,EAA+BD,eAAA,CAAKC,QAAL,EAA/B,C;;AAsBjBrB,iBAAA,CAAUsB,UAAV,CAAqBjF,OAArB;AAEA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAegE,uBAAf,GAAyC;EACvC,IAAI;IACF,MAAM,IAAAkB,+BAAA,GAAN;EACD,CAFD,CAEE,OAAOC,GAAP,EAAY,CACZ;EACD;AACF;;AAED,SAAS7B,SAAT,CAAmB8B,GAAnB,EAAgC;EAC9B,OAAOA,GAAG,CAACC,UAAJ,CAAe,SAAf,KAA6BD,GAAG,CAACC,UAAJ,CAAe,UAAf,CAApC;AACD"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.564",
|
|
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.
|
|
9
|
+
"version": "0.0.564"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -18,7 +18,8 @@
|
|
|
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.
|
|
21
|
+
"@teambit/community": "0.0.112",
|
|
22
|
+
"@teambit/logger": "0.0.657",
|
|
22
23
|
"@teambit/bit-error": "0.0.400"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"@types/node": "12.20.4"
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
36
|
-
"@teambit/legacy": "1.0.
|
|
37
|
+
"@teambit/legacy": "1.0.345",
|
|
37
38
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
38
39
|
"react": "^16.8.0 || ^17.0.0"
|
|
39
40
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.564/dist/cli.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.564/dist/cli.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
Binary file
|