@teambit/workspace 0.0.555 → 0.0.559
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/build-graph-from-fs.js +4 -1
- package/dist/build-graph-from-fs.js.map +1 -1
- package/dist/workspace.d.ts +7 -0
- package/dist/workspace.js +23 -0
- package/dist/workspace.js.map +1 -1
- package/package.json +65 -50
- package/tsconfig.json +1 -1
- package/build-graph-from-fs.ts +0 -160
- package/capsule.cmd.ts +0 -136
- package/component-config-file/component-config-file.ts +0 -98
- package/component-config-file/exceptions/already-exists.ts +0 -7
- package/component-config-file/exceptions/index.ts +0 -1
- package/component-config-file/index.ts +0 -2
- package/component-tree.widget.tsx +0 -16
- package/constants.ts +0 -1
- package/eject-conf.cmd.tsx +0 -62
- package/events/index.ts +0 -3
- package/events/on-component-add-event.ts +0 -14
- package/events/on-component-change-event.ts +0 -14
- package/events/on-component-removed-event.ts +0 -14
- package/exceptions/dependency-type-not-supported-in-policy.ts +0 -7
- package/exceptions/incorrect-env-aspect.ts +0 -8
- package/exceptions/index.ts +0 -1
- package/index.ts +0 -19
- package/install.cmd.tsx +0 -67
- package/link/component-list-links.ts +0 -50
- package/link/core-aspects-links.ts +0 -50
- package/link/get-package-name-from-target.ts +0 -5
- package/link/index.ts +0 -1
- package/link/link-row.ts +0 -20
- package/link/link-to-dir.ts +0 -13
- package/link/link.cmd.ts +0 -96
- package/link/nested-deps-in-nm-links.ts +0 -47
- package/link/rewire-row.ts +0 -17
- package/list.cmd.tsx +0 -30
- package/on-component-events.ts +0 -14
- package/package-tar/teambit-workspace-0.0.555.tgz +0 -0
- package/tag-cmd.ts +0 -247
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
- package/types.ts +0 -40
- package/ui/index.ts +0 -1
- package/ui/workspace/default-component.ts +0 -7
- package/ui/workspace/index.ts +0 -1
- package/ui/workspace/use-workspace.ts +0 -193
- package/ui/workspace/workspace-context.tsx +0 -5
- package/ui/workspace/workspace-model.ts +0 -66
- package/ui/workspace/workspace-overview/index.ts +0 -1
- package/ui/workspace/workspace-overview/workspace-overview.tsx +0 -21
- package/ui/workspace/workspace-provider.tsx +0 -23
- package/ui/workspace/workspace.tsx +0 -99
- package/ui/workspace-components-drawer/index.ts +0 -1
- package/ui/workspace-components-drawer/workspace-components.drawer.tsx +0 -49
- package/watch/check-types.ts +0 -5
- package/watch/output-formatter.ts +0 -50
- package/watch/watch.cmd.tsx +0 -142
- package/watch/watcher.ts +0 -289
- package/workspace-component/component-status.ts +0 -67
- package/workspace-component/index.ts +0 -2
- package/workspace-component/workspace-component-loader.ts +0 -276
- package/workspace-component/workspace-component.ts +0 -51
- package/workspace-section.ts +0 -14
- package/workspace.aspect.ts +0 -9
- package/workspace.graphql.ts +0 -133
- package/workspace.main.runtime.ts +0 -50
- package/workspace.provider.ts +0 -218
- package/workspace.ts +0 -1539
- package/workspace.ui-root.ts +0 -64
- package/workspace.ui.runtime.tsx +0 -215
|
@@ -188,7 +188,10 @@ class GraphFromFsBuilder {
|
|
|
188
188
|
const allDeps = components.map(c => this.getAllDepsUnfiltered(c)).flat();
|
|
189
189
|
const allDepsWithScope = allDeps.filter(dep => dep.hasScope());
|
|
190
190
|
const scopeComponentsImporter = new (_scopeComponentsImporter().default)(this.consumer.scope);
|
|
191
|
-
await scopeComponentsImporter.importMany(
|
|
191
|
+
await scopeComponentsImporter.importMany({
|
|
192
|
+
ids: _bitIds().default.uniqFromArray(allDepsWithScope),
|
|
193
|
+
throwForDependencyNotFound: this.shouldThrowOnMissingDep
|
|
194
|
+
});
|
|
192
195
|
}
|
|
193
196
|
|
|
194
197
|
async processOneComponent(component) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["build-graph-from-fs.ts"],"names":["GraphFromFsBuilder","constructor","workspace","logger","ignoreIds","BitIds","shouldLoadItsDeps","LegacyGraph","consumer","buildGraph","ids","debug","length","start","Date","now","components","loadManyComponents","processManyComponents","graph","getAllDepsUnfiltered","component","getAllDependenciesIds","difference","getAllDepsFiltered","depsWithoutIgnore","shouldLoadFunc","deps","depId","shouldLoad","push","fromArray","depth","importObjects","allDependencies","processOneComponent","allDependenciesFlattened","allDeps","map","c","flat","allDepsWithScope","filter","dep","hasScope","scopeComponentsImporter","ScopeComponentsImporter","scope","importMany","uniqFromArray","undefined","shouldThrowOnMissingDep","idStr","id","toString","completed","includes","allIds","Object","entries","depsIdsGroupedByType","forEach","depType","depsIds","has","hasNode","Error","setEdge","componentsIds","dependenciesOf","comp","fromGraph","node","loadComponent","setNode","err","ComponentNotFound","BitError","error","componentId","componentMap","bitMap","getComponentIfExist","isOnWorkspace","Boolean","loadComponentForCapsule","componentFromModel","loadComponentFromModel","clone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKO,MAAMA,kBAAN,CAAyB;AAM9BC,EAAAA,WAAW,CACDC,SADC,EAEDC,MAFC,EAGDC,SAAS,GAAG,KAAIC,iBAAJ,GAHX,EAIDC,iBAJC,EAKT;AAAA,SAJQJ,SAIR,GAJQA,SAIR;AAAA,SAHQC,MAGR,GAHQA,MAGR;AAAA,SAFQC,SAER,GAFQA,SAER;AAAA,SADQE,iBACR,GADQA,iBACR;AAAA,mDAVc,KAAIC,gBAAJ,GAUd;AAAA,uDAT4B,EAS5B;AAAA,mDARc,CAQd;AAAA,qEAPgC,IAOhC;AAAA;AACA,SAAKC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AnB,EAA0B/B,SAA1B;AACA,eAAOA,SAAP;AACD,OAJD,CAIE,OAAOsD,GAAP,EAAiB;AACjB,YAAIA,GAAG,YAAYC,0BAAnB,EAAsC;AACpC,gBAAM,KAAIC,oBAAJ,EACH,qBAAoBzB,KAAM,wDAAuDiB,cAAe,iDAD7F,CAAN;AAGD;;AACD,aAAKlE,MAAL,CAAY2E,KAAZ,CAAmB,kCAAiCT,cAAe,EAAnE;AACA,cAAMM,GAAN;AACD;AACF,KAjBwB,CAAzB;AAkBA,WAAO3D,UAAP;AACD;;AAC0B,QAAbyD,aAAa,CAACM,WAAD,EAAyC;AAClE,UAAMC,YAAY,GAAG,KAAKxE,QAAL,CAAcyE,MAAd,CAAqBC,mBAArB,CAAyCH,WAAzC,CAArB;AACA,UAAMI,aAAa,GAAGC,OAAO,CAACJ,YAAD,CAA7B;;AACA,QAAIG,aAAJ,EAAmB;AACjB,aAAO,KAAK3E,QAAL,CAAc6E,uBAAd,CAAsCN,WAAtC,CAAP;AACD,KALiE,CAMlE;AACA;;;AACA,UAAMO,kBAAkB,GAAG,MAAM,KAAK9E,QAAL,CAAc+E,sBAAd,CAAqCR,WAArC,CAAjC;AACA,WAAOO,kBAAkB,CAACE,KAAnB,EAAP;AACD;;AA9I6B","sourcesContent":["import mapSeries from 'p-map-series';\nimport { flatten } from 'lodash';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\nimport Component from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport LegacyGraph from '@teambit/legacy/dist/scope/graph/graph';\nimport ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';\nimport compact from 'lodash.compact';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { Logger } from '@teambit/logger';\nimport { ComponentNotFound } from '@teambit/scope';\nimport { BitError } from '@teambit/bit-error';\nimport { Workspace } from './workspace';\n\nexport type ShouldIgnoreFunc = (bitId: BitId) => Promise<boolean>;\n\nexport class GraphFromFsBuilder {\n private graph = new LegacyGraph();\n private completed: string[] = [];\n private depth = 1;\n private shouldThrowOnMissingDep = true;\n private consumer: Consumer;\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private ignoreIds = new BitIds(),\n private shouldLoadItsDeps?: ShouldIgnoreFunc\n ) {\n this.consumer = this.workspace.consumer;\n }\n\n /**\n * create a graph with all dependencies and flattened dependencies of the given components.\n * the nodes are components and the edges has a label of the dependency type.\n *\n * the way how it is done is iterations by depths. each depth we gather all the dependencies of\n * that depths, make sure all objects exist and then check their dependencies for the next depth.\n * once there is no dependency left, we're on the last depth level and the graph is ready.\n *\n * for example, imagine the following graph:\n * A1 -> A2 -> A3\n * B1 -> B2 -> B3\n * C1 -> C2 -> C3\n *\n * where the buildGraph is given [A1, B1, C1].\n * first, it saves all these components as nodes in the graph. then, it finds the dependencies of\n * the next level, in this case they're [A2, B2, C2]. it runs `importMany` in case some objects\n * are missing. then, it loads them all (some from FS, some from the model) and sets the edges\n * between the component and the dependencies.\n * once done, it finds all their dependencies, which are [A3, B3, C3] and repeat the process\n * above. since there are no more dependencies, the graph is completed.\n * in this case, the total depth levels are 3.\n *\n * even with a huge project, there are not many depth levels. by iterating through depth levels\n * we keep performance sane as the importMany doesn't run multiple time and therefore the round\n * trips to the remotes are minimal.\n *\n * normally, one importMany of the seeders is enough as importMany knows to fetch all flattened.\n * however, since this buildGraph is performed on the workspace, a dependency may be new or\n * modified and as such, we don't know its flattened yet.\n */\n async buildGraph(ids: BitId[]): Promise<LegacyGraph> {\n this.logger.debug(`GraphFromFsBuilder, buildGraph with ${ids.length} seeders`);\n const start = Date.now();\n const components = await this.loadManyComponents(ids, '<none>');\n await this.processManyComponents(components);\n this.logger.debug(\n `GraphFromFsBuilder, buildGraph with ${ids.length} seeders completed (${(Date.now() - start) / 1000} sec)`\n );\n return this.graph;\n }\n\n private getAllDepsUnfiltered(component: Component) {\n return component.getAllDependenciesIds().difference(this.ignoreIds);\n }\n\n private async getAllDepsFiltered(component: Component): Promise<BitIds> {\n const depsWithoutIgnore = this.getAllDepsUnfiltered(component);\n const shouldLoadFunc = this.shouldLoadItsDeps;\n if (!shouldLoadFunc) return depsWithoutIgnore;\n const deps = await mapSeries(depsWithoutIgnore, async (depId) => {\n const shouldLoad = await shouldLoadFunc(depId);\n if (!shouldLoad) this.ignoreIds.push(depId);\n return shouldLoad ? depId : null;\n });\n return BitIds.fromArray(compact(deps));\n }\n\n private async processManyComponents(components: Component[]) {\n this.logger.debug(`GraphFromFsBuilder.processManyComponents depth ${this.depth}, ${components.length} components`);\n this.depth += 1;\n await this.importObjects(components);\n const allDependencies = await mapSeries(components, (component) => this.processOneComponent(component));\n const allDependenciesFlattened = flatten(allDependencies);\n if (allDependenciesFlattened.length) await this.processManyComponents(allDependenciesFlattened);\n }\n\n private async importObjects(components: Component[]) {\n const allDeps = components.map((c) => this.getAllDepsUnfiltered(c)).flat();\n const allDepsWithScope = allDeps.filter((dep) => dep.hasScope());\n const scopeComponentsImporter = new ScopeComponentsImporter(this.consumer.scope);\n await scopeComponentsImporter.importMany(\n BitIds.uniqFromArray(allDepsWithScope),\n undefined,\n this.shouldThrowOnMissingDep\n );\n }\n\n private async processOneComponent(component: Component) {\n const idStr = component.id.toString();\n if (this.completed.includes(idStr)) return [];\n const allIds = await this.getAllDepsFiltered(component);\n\n const allDependencies = await this.loadManyComponents(allIds, idStr);\n Object.entries(component.depsIdsGroupedByType).forEach(([depType, depsIds]) => {\n depsIds.forEach((depId) => {\n if (this.ignoreIds.has(depId)) return;\n if (!this.graph.hasNode(depId.toString())) {\n throw new Error(`buildOneComponent: missing node of ${depId.toString()}`);\n }\n this.graph.setEdge(idStr, depId.toString(), depType);\n });\n });\n this.completed.push(idStr);\n return allDependencies;\n }\n\n private async loadManyComponents(componentsIds: BitId[], dependenciesOf: string): Promise<Component[]> {\n const components = await mapSeries(componentsIds, async (comp: BitId) => {\n const idStr = comp.toString();\n const fromGraph = this.graph.node(idStr);\n if (fromGraph) return fromGraph;\n try {\n const component = await this.loadComponent(comp);\n this.graph.setNode(idStr, component);\n return component;\n } catch (err: any) {\n if (err instanceof ComponentNotFound) {\n throw new BitError(\n `error: component \"${idStr}\" was not found.\\nthis component is a dependency of \"${dependenciesOf}\" and is needed as part of the graph generation`\n );\n }\n this.logger.error(`failed loading dependencies of ${dependenciesOf}`);\n throw err;\n }\n });\n return components;\n }\n private async loadComponent(componentId: BitId): Promise<Component> {\n const componentMap = this.consumer.bitMap.getComponentIfExist(componentId);\n const isOnWorkspace = Boolean(componentMap);\n if (isOnWorkspace) {\n return this.consumer.loadComponentForCapsule(componentId);\n }\n // a dependency might have been installed as a package in the workspace, and as such doesn't\n // have a componentMap.\n const componentFromModel = await this.consumer.loadComponentFromModel(componentId);\n return componentFromModel.clone();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["build-graph-from-fs.ts"],"names":["GraphFromFsBuilder","constructor","workspace","logger","ignoreIds","BitIds","shouldLoadItsDeps","LegacyGraph","consumer","buildGraph","ids","debug","length","start","Date","now","components","loadManyComponents","processManyComponents","graph","getAllDepsUnfiltered","component","getAllDependenciesIds","difference","getAllDepsFiltered","depsWithoutIgnore","shouldLoadFunc","deps","depId","shouldLoad","push","fromArray","depth","importObjects","allDependencies","processOneComponent","allDependenciesFlattened","allDeps","map","c","flat","allDepsWithScope","filter","dep","hasScope","scopeComponentsImporter","ScopeComponentsImporter","scope","importMany","uniqFromArray","throwForDependencyNotFound","shouldThrowOnMissingDep","idStr","id","toString","completed","includes","allIds","Object","entries","depsIdsGroupedByType","forEach","depType","depsIds","has","hasNode","Error","setEdge","componentsIds","dependenciesOf","comp","fromGraph","node","loadComponent","setNode","err","ComponentNotFound","BitError","error","componentId","componentMap","bitMap","getComponentIfExist","isOnWorkspace","Boolean","loadComponentForCapsule","componentFromModel","loadComponentFromModel","clone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;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GC,OAAO,CAACJ,YAAD,CAA7B;;AACA,QAAIG,aAAJ,EAAmB;AACjB,aAAO,KAAK3E,QAAL,CAAc6E,uBAAd,CAAsCN,WAAtC,CAAP;AACD,KALiE,CAMlE;AACA;;;AACA,UAAMO,kBAAkB,GAAG,MAAM,KAAK9E,QAAL,CAAc+E,sBAAd,CAAqCR,WAArC,CAAjC;AACA,WAAOO,kBAAkB,CAACE,KAAnB,EAAP;AACD;;AA7I6B","sourcesContent":["import mapSeries from 'p-map-series';\nimport { flatten } from 'lodash';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\nimport Component from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport LegacyGraph from '@teambit/legacy/dist/scope/graph/graph';\nimport ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';\nimport compact from 'lodash.compact';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { Logger } from '@teambit/logger';\nimport { ComponentNotFound } from '@teambit/scope';\nimport { BitError } from '@teambit/bit-error';\nimport { Workspace } from './workspace';\n\nexport type ShouldIgnoreFunc = (bitId: BitId) => Promise<boolean>;\n\nexport class GraphFromFsBuilder {\n private graph = new LegacyGraph();\n private completed: string[] = [];\n private depth = 1;\n private shouldThrowOnMissingDep = true;\n private consumer: Consumer;\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private ignoreIds = new BitIds(),\n private shouldLoadItsDeps?: ShouldIgnoreFunc\n ) {\n this.consumer = this.workspace.consumer;\n }\n\n /**\n * create a graph with all dependencies and flattened dependencies of the given components.\n * the nodes are components and the edges has a label of the dependency type.\n *\n * the way how it is done is iterations by depths. each depth we gather all the dependencies of\n * that depths, make sure all objects exist and then check their dependencies for the next depth.\n * once there is no dependency left, we're on the last depth level and the graph is ready.\n *\n * for example, imagine the following graph:\n * A1 -> A2 -> A3\n * B1 -> B2 -> B3\n * C1 -> C2 -> C3\n *\n * where the buildGraph is given [A1, B1, C1].\n * first, it saves all these components as nodes in the graph. then, it finds the dependencies of\n * the next level, in this case they're [A2, B2, C2]. it runs `importMany` in case some objects\n * are missing. then, it loads them all (some from FS, some from the model) and sets the edges\n * between the component and the dependencies.\n * once done, it finds all their dependencies, which are [A3, B3, C3] and repeat the process\n * above. since there are no more dependencies, the graph is completed.\n * in this case, the total depth levels are 3.\n *\n * even with a huge project, there are not many depth levels. by iterating through depth levels\n * we keep performance sane as the importMany doesn't run multiple time and therefore the round\n * trips to the remotes are minimal.\n *\n * normally, one importMany of the seeders is enough as importMany knows to fetch all flattened.\n * however, since this buildGraph is performed on the workspace, a dependency may be new or\n * modified and as such, we don't know its flattened yet.\n */\n async buildGraph(ids: BitId[]): Promise<LegacyGraph> {\n this.logger.debug(`GraphFromFsBuilder, buildGraph with ${ids.length} seeders`);\n const start = Date.now();\n const components = await this.loadManyComponents(ids, '<none>');\n await this.processManyComponents(components);\n this.logger.debug(\n `GraphFromFsBuilder, buildGraph with ${ids.length} seeders completed (${(Date.now() - start) / 1000} sec)`\n );\n return this.graph;\n }\n\n private getAllDepsUnfiltered(component: Component) {\n return component.getAllDependenciesIds().difference(this.ignoreIds);\n }\n\n private async getAllDepsFiltered(component: Component): Promise<BitIds> {\n const depsWithoutIgnore = this.getAllDepsUnfiltered(component);\n const shouldLoadFunc = this.shouldLoadItsDeps;\n if (!shouldLoadFunc) return depsWithoutIgnore;\n const deps = await mapSeries(depsWithoutIgnore, async (depId) => {\n const shouldLoad = await shouldLoadFunc(depId);\n if (!shouldLoad) this.ignoreIds.push(depId);\n return shouldLoad ? depId : null;\n });\n return BitIds.fromArray(compact(deps));\n }\n\n private async processManyComponents(components: Component[]) {\n this.logger.debug(`GraphFromFsBuilder.processManyComponents depth ${this.depth}, ${components.length} components`);\n this.depth += 1;\n await this.importObjects(components);\n const allDependencies = await mapSeries(components, (component) => this.processOneComponent(component));\n const allDependenciesFlattened = flatten(allDependencies);\n if (allDependenciesFlattened.length) await this.processManyComponents(allDependenciesFlattened);\n }\n\n private async importObjects(components: Component[]) {\n const allDeps = components.map((c) => this.getAllDepsUnfiltered(c)).flat();\n const allDepsWithScope = allDeps.filter((dep) => dep.hasScope());\n const scopeComponentsImporter = new ScopeComponentsImporter(this.consumer.scope);\n await scopeComponentsImporter.importMany({\n ids: BitIds.uniqFromArray(allDepsWithScope),\n throwForDependencyNotFound: this.shouldThrowOnMissingDep,\n });\n }\n\n private async processOneComponent(component: Component) {\n const idStr = component.id.toString();\n if (this.completed.includes(idStr)) return [];\n const allIds = await this.getAllDepsFiltered(component);\n\n const allDependencies = await this.loadManyComponents(allIds, idStr);\n Object.entries(component.depsIdsGroupedByType).forEach(([depType, depsIds]) => {\n depsIds.forEach((depId) => {\n if (this.ignoreIds.has(depId)) return;\n if (!this.graph.hasNode(depId.toString())) {\n throw new Error(`buildOneComponent: missing node of ${depId.toString()}`);\n }\n this.graph.setEdge(idStr, depId.toString(), depType);\n });\n });\n this.completed.push(idStr);\n return allDependencies;\n }\n\n private async loadManyComponents(componentsIds: BitId[], dependenciesOf: string): Promise<Component[]> {\n const components = await mapSeries(componentsIds, async (comp: BitId) => {\n const idStr = comp.toString();\n const fromGraph = this.graph.node(idStr);\n if (fromGraph) return fromGraph;\n try {\n const component = await this.loadComponent(comp);\n this.graph.setNode(idStr, component);\n return component;\n } catch (err: any) {\n if (err instanceof ComponentNotFound) {\n throw new BitError(\n `error: component \"${idStr}\" was not found.\\nthis component is a dependency of \"${dependenciesOf}\" and is needed as part of the graph generation`\n );\n }\n this.logger.error(`failed loading dependencies of ${dependenciesOf}`);\n throw err;\n }\n });\n return components;\n }\n private async loadComponent(componentId: BitId): Promise<Component> {\n const componentMap = this.consumer.bitMap.getComponentIfExist(componentId);\n const isOnWorkspace = Boolean(componentMap);\n if (isOnWorkspace) {\n return this.consumer.loadComponentForCapsule(componentId);\n }\n // a dependency might have been installed as a package in the workspace, and as such doesn't\n // have a componentMap.\n const componentFromModel = await this.consumer.loadComponentFromModel(componentId);\n return componentFromModel.clone();\n }\n}\n"]}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -224,6 +224,7 @@ export declare class Workspace implements ComponentFactory {
|
|
|
224
224
|
*/
|
|
225
225
|
getAllComponentIds(): Promise<ComponentID[]>;
|
|
226
226
|
getNewAndModifiedIds(): Promise<ComponentID[]>;
|
|
227
|
+
newAndModified(): Promise<Component[]>;
|
|
227
228
|
getLogs(id: ComponentID): Promise<ComponentLog[]>;
|
|
228
229
|
getLegacyGraph(ids?: ComponentID[]): Promise<LegacyGraph>;
|
|
229
230
|
loadCapsules(bitIds: string[]): Promise<import("@teambit/isolator").Capsule[]>;
|
|
@@ -260,6 +261,12 @@ export declare class Workspace implements ComponentFactory {
|
|
|
260
261
|
* @param scope scope name.
|
|
261
262
|
*/
|
|
262
263
|
byPattern(pattern: string, scope?: string): Promise<Component[]>;
|
|
264
|
+
/**
|
|
265
|
+
* useful for workspace commands, such as `bit build`, `bit compile`.
|
|
266
|
+
* by default, it should be running on new and modified components.
|
|
267
|
+
* a user can specify `--all` to run on all components or specify a pattern to limit to specific components.
|
|
268
|
+
*/
|
|
269
|
+
getComponentsByUserInputDefaultToChanged(all?: boolean, pattern?: string): Promise<Component[]>;
|
|
263
270
|
getMany(ids: Array<ComponentID>, forCapsule?: boolean): Promise<Component[]>;
|
|
264
271
|
getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;
|
|
265
272
|
/**
|
package/dist/workspace.js
CHANGED
|
@@ -670,6 +670,11 @@ class Workspace {
|
|
|
670
670
|
return this.resolveMultipleComponentIds(ids);
|
|
671
671
|
}
|
|
672
672
|
|
|
673
|
+
async newAndModified() {
|
|
674
|
+
const ids = await this.getNewAndModifiedIds();
|
|
675
|
+
return this.getMany(ids);
|
|
676
|
+
}
|
|
677
|
+
|
|
673
678
|
async getLogs(id) {
|
|
674
679
|
return this.scope.getLogs(id);
|
|
675
680
|
}
|
|
@@ -911,6 +916,24 @@ class Workspace {
|
|
|
911
916
|
const components = await this.getMany(targetIds);
|
|
912
917
|
return components;
|
|
913
918
|
}
|
|
919
|
+
/**
|
|
920
|
+
* useful for workspace commands, such as `bit build`, `bit compile`.
|
|
921
|
+
* by default, it should be running on new and modified components.
|
|
922
|
+
* a user can specify `--all` to run on all components or specify a pattern to limit to specific components.
|
|
923
|
+
*/
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
async getComponentsByUserInputDefaultToChanged(all, pattern) {
|
|
927
|
+
if (all) {
|
|
928
|
+
return this.list();
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
if (pattern) {
|
|
932
|
+
return this.byPattern(pattern);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
return this.newAndModified();
|
|
936
|
+
}
|
|
914
937
|
|
|
915
938
|
async getMany(ids, forCapsule = false) {
|
|
916
939
|
return this.componentLoader.getMany(ids, forCapsule);
|