@teambit/component 1.0.26 → 1.0.28
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/dependencies/dependencies.ts +2 -2
- package/dist/aspect-list.d.ts +1 -1
- package/dist/aspect-list.js +5 -5
- package/dist/aspect-list.js.map +1 -1
- package/dist/component-factory.d.ts +3 -4
- package/dist/component-factory.js.map +1 -1
- package/dist/component.main.runtime.d.ts +1 -1
- package/dist/component.main.runtime.js +2 -2
- package/dist/component.main.runtime.js.map +1 -1
- package/dist/component.ui.runtime.d.ts +1 -0
- package/dist/dependencies/dependencies.d.ts +2 -2
- package/dist/dependencies/dependencies.js +4 -4
- package/dist/dependencies/dependencies.js.map +1 -1
- package/dist/preview-1697836073970.js +7 -0
- package/dist/show/show.cmd.js +4 -4
- package/dist/show/show.cmd.js.map +1 -1
- package/package.json +21 -22
- package/show/show.cmd.ts +2 -2
- package/dist/preview-1697599041985.js +0 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-classes-per-file */
|
|
2
2
|
import { BitError } from '@teambit/bit-error';
|
|
3
|
-
import {
|
|
3
|
+
import { ComponentID } from '@teambit/component-id';
|
|
4
4
|
|
|
5
5
|
const DEV_ENV = 'development';
|
|
6
6
|
const RUNTIME_ENV = 'runtime';
|
|
@@ -9,7 +9,7 @@ const RUNTIME_ENV = 'runtime';
|
|
|
9
9
|
type Environment = 'development' | 'runtime';
|
|
10
10
|
// type WrappingMethod = 'component' | 'package';
|
|
11
11
|
|
|
12
|
-
export class DependencyId extends
|
|
12
|
+
export class DependencyId extends ComponentID {}
|
|
13
13
|
|
|
14
14
|
export class Dependency {
|
|
15
15
|
constructor(public id: DependencyId) {}
|
package/dist/aspect-list.d.ts
CHANGED
|
@@ -39,5 +39,5 @@ export declare class AspectList {
|
|
|
39
39
|
toLegacy(): ExtensionDataList;
|
|
40
40
|
stringIds(): string[];
|
|
41
41
|
clone(): AspectList;
|
|
42
|
-
static fromLegacyExtensions(legacyDataList: ExtensionDataList
|
|
42
|
+
static fromLegacyExtensions(legacyDataList: ExtensionDataList): AspectList;
|
|
43
43
|
}
|
package/dist/aspect-list.js
CHANGED
|
@@ -33,7 +33,7 @@ class AspectList {
|
|
|
33
33
|
this.entries = entries;
|
|
34
34
|
}
|
|
35
35
|
addEntry(aspectId, data = {}) {
|
|
36
|
-
const extensionDataEntry = new (_extensionData().ExtensionDataEntry)(undefined, aspectId
|
|
36
|
+
const extensionDataEntry = new (_extensionData().ExtensionDataEntry)(undefined, aspectId, undefined, {}, data);
|
|
37
37
|
const entry = new (_aspectEntry().AspectEntry)(aspectId, extensionDataEntry);
|
|
38
38
|
this.entries.push(entry);
|
|
39
39
|
return entry;
|
|
@@ -130,17 +130,17 @@ class AspectList {
|
|
|
130
130
|
clone() {
|
|
131
131
|
return new AspectList(this.entries.map(entry => entry.clone()));
|
|
132
132
|
}
|
|
133
|
-
static fromLegacyExtensions(legacyDataList
|
|
133
|
+
static fromLegacyExtensions(legacyDataList) {
|
|
134
134
|
const newEntries = legacyDataList.map(entry => {
|
|
135
|
-
return new (_aspectEntry().AspectEntry)(getAspectId(entry
|
|
135
|
+
return new (_aspectEntry().AspectEntry)(getAspectId(entry), entry);
|
|
136
136
|
});
|
|
137
137
|
return new AspectList(newEntries);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
exports.AspectList = AspectList;
|
|
141
|
-
function getAspectId(entry
|
|
141
|
+
function getAspectId(entry) {
|
|
142
142
|
if (!entry.extensionId && entry.name) return _componentId().ComponentID.fromString(entry.name);
|
|
143
|
-
if (entry.extensionId) return
|
|
143
|
+
if (entry.extensionId) return entry.extensionId;
|
|
144
144
|
throw new Error('aspect cannot be loaded without setting an ID');
|
|
145
145
|
}
|
|
146
146
|
|
package/dist/aspect-list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_extensionData","data","require","_componentId","_aspectEntry","AspectList","constructor","entries","addEntry","aspectId","extensionDataEntry","ExtensionDataEntry","undefined","
|
|
1
|
+
{"version":3,"names":["_extensionData","data","require","_componentId","_aspectEntry","AspectList","constructor","entries","addEntry","aspectId","extensionDataEntry","ExtensionDataEntry","undefined","entry","AspectEntry","push","upsertEntry","existingEntry","find","id","isEqual","withoutEntries","aspectIds","filter","includes","legacy","stringId","ids","list","map","toString","get","toStringWithoutVersion","ignoreVersion","aspectEntry","predicate","pmap","entriesP","Promise","all","toConfigObject","res","forEach","config","removeInternalConfigFields","serialize","serializedEntries","length","toLegacy","legacyEntries","ExtensionDataList","fromArray","stringIds","clone","fromLegacyExtensions","legacyDataList","newEntries","getAspectId","exports","extensionId","name","ComponentID","fromString","Error"],"sources":["aspect-list.ts"],"sourcesContent":["import {\n ExtensionDataList,\n ExtensionDataEntry,\n removeInternalConfigFields,\n} from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { ComponentID } from '@teambit/component-id';\nimport { AspectEntry, SerializableMap } from './aspect-entry';\n\n/**\n * list of aspects, each may have data and artifacts saved per component.\n */\nexport class AspectList {\n constructor(readonly entries: AspectEntry[]) {}\n\n addEntry(aspectId: ComponentID, data: SerializableMap = {}) {\n const extensionDataEntry = new ExtensionDataEntry(undefined, aspectId, undefined, {}, data);\n const entry = new AspectEntry(aspectId, extensionDataEntry);\n this.entries.push(entry);\n return entry;\n }\n\n upsertEntry(aspectId: ComponentID, data: SerializableMap = {}) {\n const existingEntry = this.entries.find((entry) => entry.id.isEqual(aspectId));\n if (existingEntry) {\n existingEntry.data = data;\n return existingEntry;\n }\n return this.addEntry(aspectId, data);\n }\n\n /**\n * transform an aspect list into a new one without the given aspect ids\n */\n withoutEntries(aspectIds: string[]): AspectList {\n const entries = this.entries.filter((entry) => !aspectIds.includes(entry.legacy.stringId));\n return new AspectList(entries);\n }\n\n /**\n * get all ids as strings from the aspect list.\n */\n get ids(): string[] {\n const list = this.entries.map((entry) => entry.id.toString());\n return list;\n }\n\n /**\n * get an aspect from the list using a serialized ID.\n */\n get(id: string): AspectEntry | undefined {\n return this.entries.find((entry) => {\n return entry.legacy.stringId === id || entry.id.toStringWithoutVersion() === id;\n });\n }\n\n /**\n * find aspect by component ID.\n */\n find(id: ComponentID, ignoreVersion = false): AspectEntry | undefined {\n return this.entries.find((aspectEntry) => {\n return id.isEqual(aspectEntry.id, { ignoreVersion });\n });\n }\n\n /**\n * transform an aspect list into a new one.\n */\n map(predicate: (entry: AspectEntry) => AspectEntry) {\n const entries = this.entries.map(predicate);\n return new AspectList(entries);\n }\n\n /**\n * transform an aspect list into a new one.\n */\n async pmap(predicate: (entry: AspectEntry) => Promise<AspectEntry>) {\n const entriesP = this.entries.map(predicate);\n const entries = await Promise.all(entriesP);\n return new AspectList(entries);\n }\n\n toConfigObject() {\n const res = {};\n this.entries.forEach((entry) => {\n if (entry.config) {\n res[entry.id.toString()] = removeInternalConfigFields(entry.config);\n }\n });\n return res;\n }\n\n serialize() {\n const serializedEntries = this.entries.map((entry) => entry.serialize());\n return serializedEntries;\n }\n\n filter(ids?: string[]): AspectList {\n if (!ids?.length) return new AspectList(this.entries);\n const entries = this.entries.filter((aspectEntry) => {\n return ids?.includes(aspectEntry.id.toStringWithoutVersion());\n });\n return new AspectList(entries);\n }\n\n toLegacy(): ExtensionDataList {\n const legacyEntries = this.entries.map((entry) => entry.legacy);\n return ExtensionDataList.fromArray(legacyEntries);\n }\n\n stringIds(): string[] {\n const ids = this.entries.map((entry) => entry.id.toString());\n return ids;\n }\n\n clone(): AspectList {\n return new AspectList(this.entries.map((entry) => entry.clone()));\n }\n\n static fromLegacyExtensions(legacyDataList: ExtensionDataList): AspectList {\n const newEntries = legacyDataList.map((entry) => {\n return new AspectEntry(getAspectId(entry), entry);\n });\n\n return new AspectList(newEntries);\n }\n}\n\nfunction getAspectId(entry: ExtensionDataEntry) {\n if (!entry.extensionId && entry.name) return ComponentID.fromString(entry.name);\n if (entry.extensionId) return entry.extensionId;\n throw new Error('aspect cannot be loaded without setting an ID');\n}\n"],"mappings":";;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iB,CAACC,SAAS,CAACF,aAAa,CAAC;EACnD;EAEAG,SAASA,CAAA,EAAa;IACpB,MAAMzB,GAAG,GAAG,IAAI,CAACpB,OAAO,CAACsB,GAAG,CAAEhB,KAAK,IAAKA,KAAK,CAACM,EAAE,CAACW,QAAQ,CAAC,CAAC,CAAC;IAC5D,OAAOH,GAAG;EACZ;EAEA0B,KAAKA,CAAA,EAAe;IAClB,OAAO,IAAIhD,UAAU,CAAC,IAAI,CAACE,OAAO,CAACsB,GAAG,CAAEhB,KAAK,IAAKA,KAAK,CAACwC,KAAK,CAAC,CAAC,CAAC,CAAC;EACnE;EAEA,OAAOC,oBAAoBA,CAACC,cAAiC,EAAc;IACzE,MAAMC,UAAU,GAAGD,cAAc,CAAC1B,GAAG,CAAEhB,KAAK,IAAK;MAC/C,OAAO,KAAIC,0BAAW,EAAC2C,WAAW,CAAC5C,KAAK,CAAC,EAAEA,KAAK,CAAC;IACnD,CAAC,CAAC;IAEF,OAAO,IAAIR,UAAU,CAACmD,UAAU,CAAC;EACnC;AACF;AAACE,OAAA,CAAArD,UAAA,GAAAA,UAAA;AAED,SAASoD,WAAWA,CAAC5C,KAAyB,EAAE;EAC9C,IAAI,CAACA,KAAK,CAAC8C,WAAW,IAAI9C,KAAK,CAAC+C,IAAI,EAAE,OAAOC,0BAAW,CAACC,UAAU,CAACjD,KAAK,CAAC+C,IAAI,CAAC;EAC/E,IAAI/C,KAAK,CAAC8C,WAAW,EAAE,OAAO9C,KAAK,CAAC8C,WAAW;EAC/C,MAAM,IAAII,KAAK,CAAC,+CAA+C,CAAC;AAClE"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Graph } from '@teambit/graph.cleargraph';
|
|
2
|
-
import {
|
|
2
|
+
import { ComponentID } from '@teambit/component-id';
|
|
3
3
|
import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
|
|
4
4
|
import { CompIdGraph } from '@teambit/graph';
|
|
5
5
|
import type { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component';
|
|
6
6
|
import type { AspectDefinition } from '@teambit/aspect-loader';
|
|
7
|
-
import { ComponentID } from '@teambit/component-id';
|
|
8
7
|
import { Component, InvalidComponent } from './component';
|
|
9
8
|
import { State } from './state';
|
|
10
9
|
import { Snap } from './snap';
|
|
@@ -48,11 +47,11 @@ export interface ComponentFactory {
|
|
|
48
47
|
/**
|
|
49
48
|
* resolve a `string` component ID to an instance of a ComponentID.
|
|
50
49
|
*/
|
|
51
|
-
resolveComponentId(id: string | ComponentID |
|
|
50
|
+
resolveComponentId(id: string | ComponentID | ComponentID): Promise<ComponentID>;
|
|
52
51
|
/**
|
|
53
52
|
* resolve multiple `string` component ID to an instance of a ComponentID.
|
|
54
53
|
*/
|
|
55
|
-
resolveMultipleComponentIds(ids: (string | ComponentID |
|
|
54
|
+
resolveMultipleComponentIds(ids: (string | ComponentID | ComponentID)[]): Promise<ComponentID[]>;
|
|
56
55
|
/**
|
|
57
56
|
* returns a component by ID.
|
|
58
57
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["component-factory.ts"],"sourcesContent":["import { Graph } from '@teambit/graph.cleargraph';\nimport {
|
|
1
|
+
{"version":3,"names":[],"sources":["component-factory.ts"],"sourcesContent":["import { Graph } from '@teambit/graph.cleargraph';\nimport { ComponentID } from '@teambit/component-id';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { CompIdGraph } from '@teambit/graph';\nimport type { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component';\nimport type { AspectDefinition } from '@teambit/aspect-loader';\nimport { Component, InvalidComponent } from './component';\nimport { State } from './state';\nimport { Snap } from './snap';\n\nexport type ResolveAspectsOptions = FilterAspectsOptions & {\n throwOnError?: boolean;\n useScopeAspectsCapsule?: boolean;\n workspaceName?: string;\n skipDeps?: boolean;\n resolveEnvsFromRoots?: boolean;\n};\n\nexport type LoadAspectsOptions = {\n /* `throwOnError` is an optional parameter that can be passed to the loadAspects method in the `ComponentFactory` interface. If\n set to `true`, it will cause the method to throw an error if an error occurs during its execution. If set to `false`\n or not provided, the method will print a warning instead of throwing it. */\n throwOnError?: boolean;\n /* `hideMissingModuleError` is an optional parameter that can be passed to the `loadAspects` method in the\n `ComponentFactory` interface. If set to `true`, it will prevent the method from throwing/printing an error if a required module\n is missing during the loading of an aspect. Instead, it will continue loading the other\n aspects. If set to `false` or not provided, the method will print/throw an error if a required module is missing.\n (considering throwOnError as well) */\n hideMissingModuleError?: boolean;\n\n /* The `ignoreErrors` property is an optional boolean parameter that can be passed to the `LoadAspectsOptions` object in\n the `ComponentFactory` interface. If set to `true`, it will cause the `loadAspects` method to ignore any errors that\n occur during the loading of aspects and continue loading the other aspects. If set to `false` or not provided, the\n method will print/throw an error if a required module is missing or if any other error occurs during the loading of\n aspects. */\n ignoreErrors?: boolean;\n [key: string]: any;\n};\n\nexport type FilterAspectsOptions = {\n /**\n * Do not return results for the core aspects\n */\n excludeCore?: boolean;\n /**\n * Only return results for the provided list of ids\n */\n requestedOnly?: boolean;\n /**\n * Only return results for aspects that have a path to the specified runtime name\n */\n filterByRuntime?: boolean;\n};\n\nexport interface ComponentFactory {\n /**\n * name of the component host.\n */\n name: string;\n\n /**\n * path to the component host.\n */\n path: string;\n\n isLegacy: boolean;\n\n /**\n * resolve a `string` component ID to an instance of a ComponentID.\n */\n resolveComponentId(id: string | ComponentID | ComponentID): Promise<ComponentID>;\n\n /**\n * resolve multiple `string` component ID to an instance of a ComponentID.\n */\n resolveMultipleComponentIds(ids: (string | ComponentID | ComponentID)[]): Promise<ComponentID[]>;\n\n /**\n * returns a component by ID.\n */\n get(id: ComponentID): Promise<Component | undefined>;\n\n /**\n * returns the legacy representation of a component with minimal loading.\n * when loaded from the workspace, it won't run any Harmony hooks and even won't load dependencies.\n * it's good to get raw aspects data or some basic properties.\n * use carefully. prefer using `get()` instead.\n */\n getLegacyMinimal(id: ComponentID): Promise<ConsumerComponent | undefined>;\n\n /**\n * returns many components by ids.\n */\n getMany(ids: ComponentID[]): Promise<Component[]>;\n\n /**\n * returns many components by their legacy representation.\n */\n getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;\n\n /**\n * get a component from a remote without importing it\n */\n getRemoteComponent?: (id: ComponentID) => Promise<Component>;\n\n /**\n * important - prefer using `getGraphIds()` if you don't need the component objects.\n * this method has a performance penalty. it must import all flattened-dependencies objects from the remotes.\n */\n getGraph(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<Graph<Component, string>>;\n\n /**\n * get graph of the given component-ids and all their dependencies (recursively/flattened).\n * the nodes are ComponentIds and is much faster than `this.getGraph()`.\n */\n getGraphIds(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<CompIdGraph>;\n\n getLogs(id: ComponentID, shortHash?: boolean, startsFrom?: string): Promise<ComponentLog[]>;\n\n /**\n * returns a specific state of a component by hash or semver.\n */\n getState(id: ComponentID, snapId: string): Promise<State>;\n\n /**\n * returns a specific snap of a component by hash.\n */\n getSnap(id: ComponentID, snapId: string): Promise<Snap>;\n\n /**\n * load aspects.\n * returns the loaded aspect ids including the loaded versions.\n */\n loadAspects: (ids: string[], throwOnError?: boolean, neededFor?: string, opts?: any) => Promise<string[]>;\n\n /**\n * Resolve dirs for aspects\n */\n resolveAspects: (\n runtimeName?: string,\n componentIds?: ComponentID[],\n opts?: ResolveAspectsOptions\n ) => Promise<AspectDefinition[]>;\n\n /**\n * list all components in the host.\n */\n list(filter?: { offset: number; limit: number }): Promise<Component[]>;\n\n /**\n * list invalid components, such as components with missing files on the fs.\n */\n listInvalid(): Promise<InvalidComponent[]>;\n\n listIds(): Promise<ComponentID[]>;\n\n /**\n * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma.\n * it uses multimatch (https://www.npmjs.com/package/multimatch) package for the matching algorithm, which supports\n * (among others) negate character \"!\" to exclude ids. See the package page for more supported characters.\n */\n idsByPattern(pattern: string, throwForNoMatch?: boolean): Promise<ComponentID[]>;\n\n hasId(componentId: ComponentID): Promise<boolean>;\n\n /**\n * Check if the host has the id, if no, search for the id in inner host (for example, workspace will search in the scope)\n * @param componentId\n */\n hasIdNested(componentId: ComponentID, includeCache?: boolean): Promise<boolean>;\n\n /**\n * whether a component is not the same as its head.\n * for a new component, it'll return \"true\" as it has no head yet.\n * this is relevant for component from the workspace, where it can be locally changed. on the scope it's always false\n */\n isModified(component: Component): Promise<boolean>;\n\n /**\n * write the component to the filesystem when applicable (no-op for scope).\n * to change the component-path, specify the \"rootPath\", which should be a relative path inside the workspace.\n */\n write(component: Component, rootPath?: string): Promise<void>;\n\n /**\n * determine whether host should be the prior one in case multiple hosts persist.\n */\n priority?: boolean;\n}\n"],"mappings":""}
|
|
@@ -44,7 +44,7 @@ export declare class ComponentMain {
|
|
|
44
44
|
* to fix this possibly incorrect scope-name, the `workspace.resolveScopeAspectListIds()` checks whether the
|
|
45
45
|
* scope-name is the same as scope.name, and if so, resolve it to the correct scope-name.
|
|
46
46
|
*/
|
|
47
|
-
createAspectListFromLegacy(legacyExtensionDataList: ExtensionDataList
|
|
47
|
+
createAspectListFromLegacy(legacyExtensionDataList: ExtensionDataList): AspectList;
|
|
48
48
|
createAspectListFromEntries(entries: AspectEntry[]): AspectList;
|
|
49
49
|
registerRoute(routes: RegisteredComponentRoute[]): this;
|
|
50
50
|
/**
|
|
@@ -118,8 +118,8 @@ class ComponentMain {
|
|
|
118
118
|
* to fix this possibly incorrect scope-name, the `workspace.resolveScopeAspectListIds()` checks whether the
|
|
119
119
|
* scope-name is the same as scope.name, and if so, resolve it to the correct scope-name.
|
|
120
120
|
*/
|
|
121
|
-
createAspectListFromLegacy(legacyExtensionDataList
|
|
122
|
-
return _aspectList().AspectList.fromLegacyExtensions(legacyExtensionDataList
|
|
121
|
+
createAspectListFromLegacy(legacyExtensionDataList) {
|
|
122
|
+
return _aspectList().AspectList.fromLegacyExtensions(legacyExtensionDataList);
|
|
123
123
|
}
|
|
124
124
|
createAspectListFromEntries(entries) {
|
|
125
125
|
return new (_aspectList().AspectList)(entries);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_express","_graphql","_harmony","_lodash","_component","_component2","_component3","_aspectList","_exceptions","_show","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","ComponentMain","constructor","hostSlot","express","showFragmentSlot","registerHost","host","register","createAspectListFromLegacy","legacyExtensionDataList","scope","AspectList","fromLegacyExtensions","createAspectListFromEntries","entries","registerRoute","routes","routeEntries","map","route","ComponentRoute","flattenRoutes","flatten","setHostPriority","id","get","HostNotFound","_priorHost","getHost","getPriorHost","getRoute","routeName","toString","hosts","values","priorityHost","find","priority","getShowFragments","fragments","orderBy","isHost","name","registerShowFragments","showFragments","provider","graphql","cli","config","componentExtension","ShowCmd","NameFragment","MainFileFragment","IDFragment","ScopeFragment","FilesFragment","ExtensionsFragment","componentSchema","exports","Slot","withType","MainRuntime","GraphqlAspect","ExpressAspect","CLIAspect","ComponentAspect","addRuntime"],"sources":["component.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ExpressAspect, ExpressMain, Route } from '@teambit/express';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { ComponentID } from '@teambit/component-id';\nimport { flatten, orderBy } from 'lodash';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config';\nimport { ComponentFactory } from './component-factory';\nimport { ComponentAspect } from './component.aspect';\nimport { componentSchema } from './component.graphql';\nimport { ComponentRoute } from './component.route';\nimport { AspectList } from './aspect-list';\nimport { HostNotFound } from './exceptions';\nimport { AspectEntry } from './aspect-entry';\nimport {\n ShowCmd,\n ShowFragment,\n NameFragment,\n MainFileFragment,\n IDFragment,\n ScopeFragment,\n FilesFragment,\n ExtensionsFragment,\n} from './show';\nimport { RegisteredComponentRoute } from '.';\n\nexport type ComponentHostSlot = SlotRegistry<ComponentFactory>;\n\nexport type ShowFragmentSlot = SlotRegistry<ShowFragment[]>;\n\nexport class ComponentMain {\n constructor(\n /**\n * slot for component hosts to register.\n */\n private hostSlot: ComponentHostSlot,\n\n /**\n * Express Extension\n */\n private express: ExpressMain,\n\n private showFragmentSlot: ShowFragmentSlot\n ) {}\n\n /**\n * register a new component host.\n */\n registerHost(host: ComponentFactory) {\n this.hostSlot.register(host);\n return this;\n }\n\n /**\n * important! avoid using this method.\n * seems like this method was written to work around a very specific case when the ComponentID of the aspects are\n * not available. in case of new components, to get the ComponentID, the workspace-aspect is needed to get the\n * default-scope. when this method is called from the scope, there is no way to get the real component-id.\n * instead, this method asks for the \"scope\", which when called by the scope-aspect is the current scope-name.\n * it may or may not be the real scope-name of the aspect.\n * to fix this possibly incorrect scope-name, the `workspace.resolveScopeAspectListIds()` checks whether the\n * scope-name is the same as scope.name, and if so, resolve it to the correct scope-name.\n */\n createAspectListFromLegacy(legacyExtensionDataList: ExtensionDataList, scope?: string) {\n return AspectList.fromLegacyExtensions(legacyExtensionDataList, scope);\n }\n\n createAspectListFromEntries(entries: AspectEntry[]) {\n return new AspectList(entries);\n }\n\n registerRoute(routes: RegisteredComponentRoute[]) {\n const routeEntries = routes.map((route: RegisteredComponentRoute) => {\n return new ComponentRoute(route, this);\n });\n\n const flattenRoutes = flatten(routeEntries) as any as Route[];\n\n this.express.register(flattenRoutes);\n return this;\n }\n\n /**\n * set the prior host.\n */\n setHostPriority(id: string) {\n const host = this.hostSlot.get(id);\n if (!host) {\n throw new HostNotFound(id);\n }\n\n this._priorHost = host;\n return this;\n }\n\n /**\n * get component host by extension ID.\n */\n getHost(id?: string): ComponentFactory {\n if (id) {\n const host = this.hostSlot.get(id);\n if (!host) throw new HostNotFound(id);\n return host;\n }\n\n return this.getPriorHost();\n }\n\n getRoute(id: ComponentID, routeName: string) {\n return `/api/${id.toString()}/~aspect/${routeName}`;\n }\n\n /**\n * get the prior host.\n */\n private getPriorHost() {\n if (this._priorHost) return this._priorHost;\n\n const hosts = this.hostSlot.values();\n const priorityHost = hosts.find((host) => host.priority);\n return priorityHost || hosts[0];\n }\n\n getShowFragments() {\n const fragments = orderBy(flatten(this.showFragmentSlot.values()), ['weight', ['asc']]);\n return fragments;\n }\n\n isHost(name: string) {\n return !!this.hostSlot.get(name);\n }\n\n /**\n * register a show fragment to display further information in the `bit show` command.\n */\n registerShowFragments(showFragments: ShowFragment[]) {\n this.showFragmentSlot.register(showFragments);\n return this;\n }\n\n private _priorHost: ComponentFactory | undefined;\n\n static slots = [Slot.withType<ComponentFactory>(), Slot.withType<Route[]>(), Slot.withType<ShowFragment[]>()];\n\n static runtime = MainRuntime;\n static dependencies = [GraphqlAspect, ExpressAspect, CLIAspect];\n\n static async provider(\n [graphql, express, cli]: [GraphqlMain, ExpressMain, CLIMain],\n config,\n [hostSlot, showFragmentSlot]: [ComponentHostSlot, ShowFragmentSlot]\n ) {\n const componentExtension = new ComponentMain(hostSlot, express, showFragmentSlot);\n cli.register(new ShowCmd(componentExtension));\n\n componentExtension.registerShowFragments([\n new NameFragment(),\n new MainFileFragment(),\n new IDFragment(),\n new ScopeFragment(),\n new FilesFragment(),\n new ExtensionsFragment(),\n ]);\n graphql.register(componentSchema(componentExtension));\n\n return componentExtension;\n }\n}\n\nComponentAspect.addRuntime(ComponentMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;E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ACS,OAAA,CAAA1D,aAAA,GAAAA,aAAA;AAAAvB,eAAA,CAzIYuB,aAAa,WAgHT,CAAC2D,eAAI,CAACC,QAAQ,CAAmB,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAU,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAiB,CAAC,CAAC;AAAAnF,eAAA,CAhHlGuB,aAAa,aAkHP6D,kBAAW;AAAApF,eAAA,CAlHjBuB,aAAa,kBAmHF,CAAC8D,wBAAa,EAAEC,wBAAa,EAAEC,gBAAS,CAAC;AAwBjEC,4BAAe,CAACC,UAAU,CAAClE,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_express","_graphql","_harmony","_lodash","_component","_component2","_component3","_aspectList","_exceptions","_show","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","ComponentMain","constructor","hostSlot","express","showFragmentSlot","registerHost","host","register","createAspectListFromLegacy","legacyExtensionDataList","AspectList","fromLegacyExtensions","createAspectListFromEntries","entries","registerRoute","routes","routeEntries","map","route","ComponentRoute","flattenRoutes","flatten","setHostPriority","id","get","HostNotFound","_priorHost","getHost","getPriorHost","getRoute","routeName","toString","hosts","values","priorityHost","find","priority","getShowFragments","fragments","orderBy","isHost","name","registerShowFragments","showFragments","provider","graphql","cli","config","componentExtension","ShowCmd","NameFragment","MainFileFragment","IDFragment","ScopeFragment","FilesFragment","ExtensionsFragment","componentSchema","exports","Slot","withType","MainRuntime","GraphqlAspect","ExpressAspect","CLIAspect","ComponentAspect","addRuntime"],"sources":["component.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ExpressAspect, ExpressMain, Route } from '@teambit/express';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { ComponentID } from '@teambit/component-id';\nimport { flatten, orderBy } from 'lodash';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config';\nimport { ComponentFactory } from './component-factory';\nimport { ComponentAspect } from './component.aspect';\nimport { componentSchema } from './component.graphql';\nimport { ComponentRoute } from './component.route';\nimport { AspectList } from './aspect-list';\nimport { HostNotFound } from './exceptions';\nimport { AspectEntry } from './aspect-entry';\nimport {\n ShowCmd,\n ShowFragment,\n NameFragment,\n MainFileFragment,\n IDFragment,\n ScopeFragment,\n FilesFragment,\n ExtensionsFragment,\n} from './show';\nimport { RegisteredComponentRoute } from '.';\n\nexport type ComponentHostSlot = SlotRegistry<ComponentFactory>;\n\nexport type ShowFragmentSlot = SlotRegistry<ShowFragment[]>;\n\nexport class ComponentMain {\n constructor(\n /**\n * slot for component hosts to register.\n */\n private hostSlot: ComponentHostSlot,\n\n /**\n * Express Extension\n */\n private express: ExpressMain,\n\n private showFragmentSlot: ShowFragmentSlot\n ) {}\n\n /**\n * register a new component host.\n */\n registerHost(host: ComponentFactory) {\n this.hostSlot.register(host);\n return this;\n }\n\n /**\n * important! avoid using this method.\n * seems like this method was written to work around a very specific case when the ComponentID of the aspects are\n * not available. in case of new components, to get the ComponentID, the workspace-aspect is needed to get the\n * default-scope. when this method is called from the scope, there is no way to get the real component-id.\n * instead, this method asks for the \"scope\", which when called by the scope-aspect is the current scope-name.\n * it may or may not be the real scope-name of the aspect.\n * to fix this possibly incorrect scope-name, the `workspace.resolveScopeAspectListIds()` checks whether the\n * scope-name is the same as scope.name, and if so, resolve it to the correct scope-name.\n */\n createAspectListFromLegacy(legacyExtensionDataList: ExtensionDataList) {\n return AspectList.fromLegacyExtensions(legacyExtensionDataList);\n }\n\n createAspectListFromEntries(entries: AspectEntry[]) {\n return new AspectList(entries);\n }\n\n registerRoute(routes: RegisteredComponentRoute[]) {\n const routeEntries = routes.map((route: RegisteredComponentRoute) => {\n return new ComponentRoute(route, this);\n });\n\n const flattenRoutes = flatten(routeEntries) as any as Route[];\n\n this.express.register(flattenRoutes);\n return this;\n }\n\n /**\n * set the prior host.\n */\n setHostPriority(id: string) {\n const host = this.hostSlot.get(id);\n if (!host) {\n throw new HostNotFound(id);\n }\n\n this._priorHost = host;\n return this;\n }\n\n /**\n * get component host by extension ID.\n */\n getHost(id?: string): ComponentFactory {\n if (id) {\n const host = this.hostSlot.get(id);\n if (!host) throw new HostNotFound(id);\n return host;\n }\n\n return this.getPriorHost();\n }\n\n getRoute(id: ComponentID, routeName: string) {\n return `/api/${id.toString()}/~aspect/${routeName}`;\n }\n\n /**\n * get the prior host.\n */\n private getPriorHost() {\n if (this._priorHost) return this._priorHost;\n\n const hosts = this.hostSlot.values();\n const priorityHost = hosts.find((host) => host.priority);\n return priorityHost || hosts[0];\n }\n\n getShowFragments() {\n const fragments = orderBy(flatten(this.showFragmentSlot.values()), ['weight', ['asc']]);\n return fragments;\n }\n\n isHost(name: string) {\n return !!this.hostSlot.get(name);\n }\n\n /**\n * register a show fragment to display further information in the `bit show` command.\n */\n registerShowFragments(showFragments: ShowFragment[]) {\n this.showFragmentSlot.register(showFragments);\n return this;\n }\n\n private _priorHost: ComponentFactory | undefined;\n\n static slots = [Slot.withType<ComponentFactory>(), Slot.withType<Route[]>(), Slot.withType<ShowFragment[]>()];\n\n static runtime = MainRuntime;\n static dependencies = [GraphqlAspect, ExpressAspect, CLIAspect];\n\n static async provider(\n [graphql, express, cli]: [GraphqlMain, ExpressMain, CLIMain],\n config,\n [hostSlot, showFragmentSlot]: [ComponentHostSlot, ShowFragmentSlot]\n ) {\n const componentExtension = new ComponentMain(hostSlot, express, showFragmentSlot);\n cli.register(new ShowCmd(componentExtension));\n\n componentExtension.registerShowFragments([\n new NameFragment(),\n new MainFileFragment(),\n new IDFragment(),\n new ScopeFragment(),\n new FilesFragment(),\n new ExtensionsFragment(),\n ]);\n graphql.register(componentSchema(componentExtension));\n\n return componentExtension;\n }\n}\n\nComponentAspect.addRuntime(ComponentMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAA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AY,EAAC,CAAC,EAClB,KAAIC,wBAAgB,EAAC,CAAC,EACtB,KAAIC,kBAAU,EAAC,CAAC,EAChB,KAAIC,qBAAa,EAAC,CAAC,EACnB,KAAIC,qBAAa,EAAC,CAAC,EACnB,KAAIC,0BAAkB,EAAC,CAAC,CACzB,CAAC;IACFV,OAAO,CAACtC,QAAQ,CAAC,IAAAiD,6BAAe,EAACR,kBAAkB,CAAC,CAAC;IAErD,OAAOA,kBAAkB;EAC3B;AACF;AAACS,OAAA,CAAAzD,aAAA,GAAAA,aAAA;AAAAvB,eAAA,CAzIYuB,aAAa,WAgHT,CAAC0D,eAAI,CAACC,QAAQ,CAAmB,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAU,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAiB,CAAC,CAAC;AAAAlF,eAAA,CAhHlGuB,aAAa,aAkHP4D,kBAAW;AAAAnF,eAAA,CAlHjBuB,aAAa,kBAmHF,CAAC6D,wBAAa,EAAEC,wBAAa,EAAEC,gBAAS,CAAC;AAwBjEC,4BAAe,CAACC,UAAU,CAACjE,aAAa,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class DependencyId extends
|
|
1
|
+
import { ComponentID } from '@teambit/component-id';
|
|
2
|
+
export declare class DependencyId extends ComponentID {
|
|
3
3
|
}
|
|
4
4
|
export declare class Dependency {
|
|
5
5
|
id: DependencyId;
|
|
@@ -11,9 +11,9 @@ function _bitError() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const data = require("@teambit/
|
|
16
|
-
|
|
14
|
+
function _componentId() {
|
|
15
|
+
const data = require("@teambit/component-id");
|
|
16
|
+
_componentId = function () {
|
|
17
17
|
return data;
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
@@ -27,7 +27,7 @@ const RUNTIME_ENV = 'runtime';
|
|
|
27
27
|
|
|
28
28
|
// type WrappingMethod = 'component' | 'package';
|
|
29
29
|
|
|
30
|
-
class DependencyId extends
|
|
30
|
+
class DependencyId extends _componentId().ComponentID {}
|
|
31
31
|
exports.DependencyId = DependencyId;
|
|
32
32
|
class Dependency {
|
|
33
33
|
constructor(id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_bitError","data","require","
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","_componentId","DEV_ENV","RUNTIME_ENV","DependencyId","ComponentID","exports","Dependency","constructor","id","PackageDependency","ComponentDependency","DependencyList","Array","packages","filter","dep","components","fromArray","dependencies","Dependencies","runtime","dev","peer","getByEnvironment","env","concat","BitError","computeDev","computeRuntime"],"sources":["dependencies.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component-id';\n\nconst DEV_ENV = 'development';\nconst RUNTIME_ENV = 'runtime';\n\n// type Environment = DEV_ENV | RUNTIME_ENV;\ntype Environment = 'development' | 'runtime';\n// type WrappingMethod = 'component' | 'package';\n\nexport class DependencyId extends ComponentID {}\n\nexport class Dependency {\n constructor(public id: DependencyId) {}\n}\n\nexport class PackageDependency extends Dependency {}\n\nexport class ComponentDependency extends Dependency {}\n\nexport class DependencyList extends Array<Dependency> {\n /**\n * Get only package dependencies\n *\n * @readonly\n * @memberof DependencyList\n */\n get packages(): PackageDependency[] {\n return this.filter((dep) => dep instanceof PackageDependency);\n }\n\n get components(): ComponentDependency[] {\n return this.filter((dep) => dep instanceof ComponentDependency);\n }\n\n static fromArray(dependencies: Dependency[]): DependencyList {\n return new DependencyList(...dependencies);\n }\n}\n\nexport class Dependencies {\n constructor(public runtime: DependencyList, public dev: DependencyList, public peer: DependencyList) {}\n\n private getByEnvironment(env: Environment): DependencyList {\n if (env === DEV_ENV) {\n return DependencyList.fromArray(this.runtime.concat(this.dev).concat(this.peer));\n }\n if (env === RUNTIME_ENV) {\n return DependencyList.fromArray(this.runtime.concat(this.peer));\n }\n throw new BitError(`env ${env} is not supported`);\n }\n\n /**\n * Get dependencies needed for development environnement such as runtime, dev and peer\n *\n * @returns {DependencyList}\n * @memberof Dependencies\n */\n computeDev(): DependencyList {\n return this.getByEnvironment(DEV_ENV);\n }\n\n /**\n * Get dependencies needed for runtime environnement such as runtime and peer\n *\n * @returns {DependencyList}\n * @memberof Dependencies\n */\n computeRuntime(): DependencyList {\n return this.getByEnvironment(RUNTIME_ENV);\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAFA;;AAIA,MAAMG,OAAO,GAAG,aAAa;AAC7B,MAAMC,WAAW,GAAG,SAAS;;AAE7B;;AAEA;;AAEO,MAAMC,YAAY,SAASC,0BAAW,CAAC;AAAEC,OAAA,CAAAF,YAAA,GAAAA,YAAA;AAEzC,MAAMG,UAAU,CAAC;EACtBC,WAAWA,CAAQC,EAAgB,EAAE;IAAA,KAAlBA,EAAgB,GAAhBA,EAAgB;EAAG;AACxC;AAACH,OAAA,CAAAC,UAAA,GAAAA,UAAA;AAEM,MAAMG,iBAAiB,SAASH,UAAU,CAAC;AAAED,OAAA,CAAAI,iBAAA,GAAAA,iBAAA;AAE7C,MAAMC,mBAAmB,SAASJ,UAAU,CAAC;AAAED,OAAA,CAAAK,mBAAA,GAAAA,mBAAA;AAE/C,MAAMC,cAAc,SAASC,KAAK,CAAa;EACpD;AACF;AACA;AACA;AACA;AACA;EACE,IAAIC,QAAQA,CAAA,EAAwB;IAClC,OAAO,IAAI,CAACC,MAAM,CAAEC,GAAG,IAAKA,GAAG,YAAYN,iBAAiB,CAAC;EAC/D;EAEA,IAAIO,UAA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st/Library/Caches/Bit/capsules/4ff44c81b43ba7bd510274165d0509db76ae43db/teambit.component_component@1.0.28/dist/component.composition.js';
|
|
2
|
+
import * as overview_0 from '/Users/davidfirst/Library/Caches/Bit/capsules/4ff44c81b43ba7bd510274165d0509db76ae43db/teambit.component_component@1.0.28/dist/component.docs.mdx';
|
|
3
|
+
|
|
4
|
+
export const compositions = [compositions_0];
|
|
5
|
+
export const overview = [overview_0];
|
|
6
|
+
|
|
7
|
+
export const compositions_metadata = {"compositions":[{"displayName":"Logo","identifier":"Logo"}]};
|
package/dist/show/show.cmd.js
CHANGED
|
@@ -25,9 +25,9 @@ function _exceptions() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const data = require("@teambit/
|
|
30
|
-
|
|
28
|
+
function _componentId() {
|
|
29
|
+
const data = require("@teambit/component-id");
|
|
30
|
+
_componentId = function () {
|
|
31
31
|
return data;
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
@@ -59,7 +59,7 @@ class ShowCmd {
|
|
|
59
59
|
}
|
|
60
60
|
async getComponent(idStr, remote) {
|
|
61
61
|
if (remote) {
|
|
62
|
-
const bitId =
|
|
62
|
+
const bitId = _componentId().ComponentID.fromString(idStr); // user used --remote so we know it has a scope
|
|
63
63
|
const host = this.component.getHost('teambit.scope/scope');
|
|
64
64
|
const id = await host.resolveComponentId(bitId);
|
|
65
65
|
if (!host.getRemoteComponent) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_lodash","data","require","_cliTable","_exceptions","
|
|
1
|
+
{"version":3,"names":["_lodash","data","require","_cliTable","_exceptions","_componentId","_showCmd","_interopRequireDefault","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","ShowCmd","constructor","component","name","description","getComponent","idStr","remote","bitId","ComponentID","fromString","host","getHost","id","resolveComponentId","getRemoteComponent","Error","get","MissingBitMapComponent","useLegacy","json","compare","legacyShow","LegacyShow","showData","action","versions","report","legacy","fragments","getShowFragments","rows","Promise","all","map","fragment","row","renderRow","content","title","table","CLITable","compact","render","JSON","parse","filter","exports"],"sources":["show.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { compact } from 'lodash';\n// import { Logger } from '@teambit/logger';\n// import chalk from 'chalk';\nimport { CLITable } from '@teambit/cli-table';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { ComponentID } from '@teambit/component-id';\nimport LegacyShow from '@teambit/legacy/dist/cli/commands/public-cmds/show-cmd';\nimport { ComponentMain } from '../component.main.runtime';\n\nexport class ShowCmd implements Command {\n name = 'show <component-name>';\n description = \"display the component's essential information\";\n alias = '';\n group = 'info';\n arguments = [{ name: 'component-name', description: 'component name or component id' }];\n options = [\n ['j', 'json', 'return the component data in json format'],\n ['l', 'legacy', 'use the legacy bit show.'],\n ['r', 'remote', 'show data for a remote component'],\n [\n 'c',\n 'compare',\n 'legacy-only. compare current file system component to its latest tagged version [default=latest]',\n ],\n ] as CommandOptions;\n\n constructor(private component: ComponentMain) {}\n\n private async getComponent(idStr: string, remote: boolean) {\n if (remote) {\n const bitId: ComponentID = ComponentID.fromString(idStr); // user used --remote so we know it has a scope\n const host = this.component.getHost('teambit.scope/scope');\n const id = await host.resolveComponentId(bitId);\n if (!host.getRemoteComponent) {\n throw new Error('Component Host does not implement getRemoteComponent()');\n }\n const component = await host.getRemoteComponent(id);\n return component;\n }\n const host = this.component.getHost();\n const id = await host.resolveComponentId(idStr);\n const component = await host.get(id);\n if (!component) throw new MissingBitMapComponent(idStr);\n return component;\n }\n\n async useLegacy(id: string, json = false, remote = false, compare = false) {\n const legacyShow = new LegacyShow();\n const showData = await legacyShow.action([id], {\n json,\n versions: undefined,\n remote,\n compare,\n });\n\n return legacyShow.report(showData);\n }\n\n async report([idStr]: [string], { legacy, remote, compare }: { legacy: boolean; remote: boolean; compare: boolean }) {\n if (legacy) return this.useLegacy(idStr, false, remote, compare);\n const component = await this.getComponent(idStr, remote);\n const fragments = this.component.getShowFragments();\n const rows = await Promise.all(\n fragments.map(async (fragment) => {\n const row = await fragment.renderRow(component);\n if (!row.content) return null;\n return [row.title, row.content];\n })\n );\n\n const table = new CLITable([], compact(rows));\n return table.render();\n }\n\n async json([idStr]: [string], { remote, legacy }: { remote: boolean; legacy: boolean }) {\n if (legacy) return JSON.parse(await this.useLegacy(idStr, true, remote));\n const component = await this.getComponent(idStr, remote);\n const fragments = this.component.getShowFragments();\n const rows = await Promise.all(\n fragments.map(async (fragment) => {\n return fragment.json ? fragment.json(component) : undefined;\n })\n );\n\n return rows.filter((row) => !!row);\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,aAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,YAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAM,sBAAA,CAAAL,OAAA;EAAAI,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAgF,SAAAM,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,G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AAI,CAAC3B,SAAS,CAAC4B,gBAAgB,CAAC,CAAC;IACnD,MAAMC,IAAI,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC5BJ,SAAS,CAACK,GAAG,CAAC,MAAOC,QAAQ,IAAK;MAChC,OAAOA,QAAQ,CAACf,IAAI,GAAGe,QAAQ,CAACf,IAAI,CAAClB,SAAS,CAAC,GAAGP,SAAS;IAC7D,CAAC,CACH,CAAC;IAED,OAAOoC,IAAI,CAACe,MAAM,CAAEV,GAAG,IAAK,CAAC,CAACA,GAAG,CAAC;EACpC;AACF;AAACW,OAAA,CAAA/C,OAAA,GAAAA,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/component",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/component/component",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "component",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.28"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/any-fs": "0.0.5",
|
|
@@ -21,16 +21,20 @@
|
|
|
21
21
|
"lodash.compact": "3.0.1",
|
|
22
22
|
"core-js": "^3.0.0",
|
|
23
23
|
"@babel/runtime": "7.20.0",
|
|
24
|
+
"@teambit/component-id": "1.1.0",
|
|
24
25
|
"@teambit/ui-foundation.ui.menu-widget-icon": "0.0.502",
|
|
25
26
|
"@teambit/graph.cleargraph": "0.0.1",
|
|
26
27
|
"@teambit/harmony": "0.4.6",
|
|
28
|
+
"@teambit/bit-error": "0.0.404",
|
|
27
29
|
"@teambit/base-react.navigation.link": "2.0.27",
|
|
28
30
|
"@teambit/component.ui.deprecation-icon": "0.0.509",
|
|
29
31
|
"@teambit/ui-foundation.ui.is-browser": "0.0.500",
|
|
30
32
|
"@teambit/ui-foundation.ui.main-dropdown": "0.0.502",
|
|
31
33
|
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.506",
|
|
32
34
|
"@teambit/ui-foundation.ui.use-box.menu": "1.0.5",
|
|
35
|
+
"@teambit/component-issues": "0.0.100",
|
|
33
36
|
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.505",
|
|
37
|
+
"@teambit/legacy-component-log": "0.0.402",
|
|
34
38
|
"@teambit/ui-foundation.ui.react-router.use-query": "0.0.501",
|
|
35
39
|
"@teambit/design.ui.empty-box": "0.0.363",
|
|
36
40
|
"@teambit/documenter.ui.heading": "4.1.1",
|
|
@@ -45,30 +49,25 @@
|
|
|
45
49
|
"@teambit/lanes.hooks.use-lanes": "0.0.254",
|
|
46
50
|
"@teambit/lanes.ui.models.lanes-model": "0.0.207",
|
|
47
51
|
"@teambit/ui-foundation.ui.use-box.dropdown": "0.0.141",
|
|
48
|
-
"@teambit/
|
|
49
|
-
"@teambit/
|
|
50
|
-
"@teambit/graph": "1.0.26",
|
|
51
|
-
"@teambit/legacy-bit-id": "1.0.3",
|
|
52
|
+
"@teambit/aspect-loader": "1.0.28",
|
|
53
|
+
"@teambit/graph": "1.0.28",
|
|
52
54
|
"@teambit/toolbox.path.match-patterns": "0.0.11",
|
|
53
55
|
"@teambit/toolbox.string.capitalize": "0.0.492",
|
|
54
|
-
"@teambit/cli": "0.0.
|
|
55
|
-
"@teambit/express": "0.0.
|
|
56
|
-
"@teambit/graphql": "1.0.
|
|
57
|
-
"@teambit/
|
|
58
|
-
"@teambit/command-bar": "1.0.26",
|
|
56
|
+
"@teambit/cli": "0.0.800",
|
|
57
|
+
"@teambit/express": "0.0.899",
|
|
58
|
+
"@teambit/graphql": "1.0.28",
|
|
59
|
+
"@teambit/command-bar": "1.0.28",
|
|
59
60
|
"@teambit/component-package-version": "0.0.428",
|
|
60
|
-
"@teambit/preview": "1.0.
|
|
61
|
-
"@teambit/pubsub": "1.0.
|
|
62
|
-
"@teambit/react-router": "1.0.
|
|
63
|
-
"@teambit/ui": "1.0.
|
|
64
|
-
"@teambit/component-issues": "0.0.99",
|
|
61
|
+
"@teambit/preview": "1.0.28",
|
|
62
|
+
"@teambit/pubsub": "1.0.28",
|
|
63
|
+
"@teambit/react-router": "1.0.28",
|
|
64
|
+
"@teambit/ui": "1.0.28",
|
|
65
65
|
"@teambit/cli-table": "0.0.43",
|
|
66
|
-
"@teambit/
|
|
67
|
-
"@teambit/component-descriptor": "0.0.365",
|
|
66
|
+
"@teambit/component-descriptor": "0.0.366",
|
|
68
67
|
"@teambit/harmony.ui.aspect-box": "0.0.502",
|
|
69
|
-
"@teambit/compositions": "1.0.
|
|
70
|
-
"@teambit/deprecation": "1.0.
|
|
71
|
-
"@teambit/envs": "1.0.
|
|
68
|
+
"@teambit/compositions": "1.0.28",
|
|
69
|
+
"@teambit/deprecation": "1.0.28",
|
|
70
|
+
"@teambit/envs": "1.0.28",
|
|
72
71
|
"@teambit/envs.ui.env-icon": "0.0.500"
|
|
73
72
|
},
|
|
74
73
|
"devDependencies": {
|
|
@@ -88,7 +87,7 @@
|
|
|
88
87
|
"peerDependencies": {
|
|
89
88
|
"@apollo/client": "^3.6.0",
|
|
90
89
|
"react-router-dom": "^6.0.0",
|
|
91
|
-
"@teambit/legacy": "1.0.
|
|
90
|
+
"@teambit/legacy": "1.0.580",
|
|
92
91
|
"react": "^16.8.0 || ^17.0.0",
|
|
93
92
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
94
93
|
},
|
package/show/show.cmd.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { compact } from 'lodash';
|
|
|
4
4
|
// import chalk from 'chalk';
|
|
5
5
|
import { CLITable } from '@teambit/cli-table';
|
|
6
6
|
import { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';
|
|
7
|
-
import {
|
|
7
|
+
import { ComponentID } from '@teambit/component-id';
|
|
8
8
|
import LegacyShow from '@teambit/legacy/dist/cli/commands/public-cmds/show-cmd';
|
|
9
9
|
import { ComponentMain } from '../component.main.runtime';
|
|
10
10
|
|
|
@@ -29,7 +29,7 @@ export class ShowCmd implements Command {
|
|
|
29
29
|
|
|
30
30
|
private async getComponent(idStr: string, remote: boolean) {
|
|
31
31
|
if (remote) {
|
|
32
|
-
const bitId:
|
|
32
|
+
const bitId: ComponentID = ComponentID.fromString(idStr); // user used --remote so we know it has a scope
|
|
33
33
|
const host = this.component.getHost('teambit.scope/scope');
|
|
34
34
|
const id = await host.resolveComponentId(bitId);
|
|
35
35
|
if (!host.getRemoteComponent) {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@1.0.26/dist/component.composition.js';
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@1.0.26/dist/component.docs.mdx';
|
|
3
|
-
|
|
4
|
-
export const compositions = [compositions_0];
|
|
5
|
-
export const overview = [overview_0];
|
|
6
|
-
|
|
7
|
-
export const compositions_metadata = {"compositions":[{"displayName":"Logo","identifier":"Logo"}]};
|