@teambit/workspace 0.0.917 → 0.0.919
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.d.ts +3 -2
- package/dist/build-graph-from-fs.js +17 -26
- package/dist/build-graph-from-fs.js.map +1 -1
- package/dist/build-graph-ids-from-fs.d.ts +45 -0
- package/dist/build-graph-ids-from-fs.js +222 -0
- package/dist/build-graph-ids-from-fs.js.map +1 -0
- package/dist/workspace-component/workspace-component-loader.js +1 -1
- package/dist/workspace-component/workspace-component-loader.js.map +1 -1
- package/dist/workspace.d.ts +3 -1
- package/dist/workspace.js +53 -2
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.ui.runtime.js +1 -1
- package/dist/workspace.ui.runtime.js.map +1 -1
- package/package-tar/teambit-workspace-0.0.919.tgz +0 -0
- package/package.json +33 -33
- package/{preview-1669433164317.js → preview-1669865271197.js} +2 -2
- package/workspace-component/workspace-component-loader.ts +4 -1
- package/workspace.ui.runtime.tsx +1 -1
- package/package-tar/teambit-workspace-0.0.917.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","createInMemoryCache","maxSize","getMaxSizeForComponents","getMany","ids","loadOpts","idsWithoutEmpty","compact","errors","longProcessLogger","createLongProcessLogger","length","componentsP","mapSeries","id","logProgress","toString","get","undefined","catch","err","isComponentNotExistsError","push","components","forEach","console","warn","filteredComponents","end","getInvalid","consumer","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","getLatestVersionNumber","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","uniq","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","cacheKey","keys","startsWith","delete","componentFromScope","MissingBitMapComponent","extensions","componentExtensions","extensionsFromConsumerComponent","ExtensionDataList","extensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","updatedComp","executeLoadSlot","newComponentFromState","createComponentCacheKey","set","isEqual","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","_consumer","removed","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","dependenciesList","extractDepsFromLegacy","dependenciesFromUnmergedHead","unmergedComponent","getUnmergedComponent","mergedDependencies","DependencyList","merge","depResolverData","serialize","Promise","all","upsertExtensionData","EnvsAspect","DependencyResolverAspect","aspectListWithEnvsAndDeps","aspects","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","updatedAspectList","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry","JSON","stringify","sortKeys","obj","fromPairs","sort","k1","k2","localeCompare"],"sources":["workspace-component-loader.ts"],"sourcesContent":["import { Component, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact, fromPairs, uniq } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyList, DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, loadOpts?: ComponentLoadOptions): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id, undefined, undefined, undefined, loadOpts).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true,\n loadOpts?: ComponentLoadOptions\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, loadOpts);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent, loadOpts);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, loadOpts);\n }\n return component;\n }\n\n async getIfExist(componentId: ComponentID) {\n try {\n return await this.get(componentId);\n } catch (err: any) {\n if (this.isComponentNotExistsError(err)) {\n return undefined;\n }\n throw err;\n }\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n const envIds = uniq(envs.map((env) => env.id));\n if (envIds.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envIds;\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n for (const cacheKey of this.componentsCache.keys()) {\n if (cacheKey === idStr || cacheKey.startsWith(`${idStr}:`)) {\n this.componentsCache.delete(cacheKey);\n }\n }\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent, loadOpts?: ComponentLoadOptions) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n const { extensions } = await this.workspace.componentExtensions(id, componentFromScope);\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n const extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensions,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n const updatedComp = await this.executeLoadSlot(workspaceComponent, loadOpts);\n return updatedComp;\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state), loadOpts);\n }\n\n private saveInCache(component: Component, loadOpts?: ComponentLoadOptions): void {\n const cacheKey = createComponentCacheKey(component.id, loadOpts);\n this.componentsCache.set(cacheKey, component);\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, loadOpts?: ComponentLoadOptions): Component | undefined {\n const cacheKey = createComponentCacheKey(id, loadOpts);\n const fromCache = this.componentsCache.get(cacheKey);\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID): Promise<ConsumerComponent | undefined> {\n try {\n return await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component, loadOpts?: ComponentLoadOptions) {\n if (component.state._consumer.removed) {\n // if it was soft-removed now, the component is not in the FS. loading aspects such as composition ends up with\n // errors as they try to read component files from the filesystem.\n return component;\n }\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions);\n const dependenciesList = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n let dependenciesFromUnmergedHead;\n // Get dependencies from unmerged head if needed\n // we take it from there, as they might not be installed yet and we need to get their versions from the model\n const unmergedComponent = await this.workspace.getUnmergedComponent(component.id);\n if (unmergedComponent) {\n dependenciesFromUnmergedHead = await this.dependencyResolver.extractDepsFromLegacy(unmergedComponent, policy);\n }\n const mergedDependencies = dependenciesFromUnmergedHead\n ? DependencyList.merge([dependenciesList, dependenciesFromUnmergedHead])\n : dependenciesList;\n\n const depResolverData = {\n dependencies: mergedDependencies.serialize(),\n policy: policy.serialize(),\n };\n\n // Make sure we are adding the envs / deps data first because other on load events might depend on it\n await Promise.all([\n this.upsertExtensionData(component, EnvsAspect.id, envsData),\n this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData),\n ]);\n\n // We are updating the component state with the envs and deps data here, so in case we have other slots that depend on this data\n // they will be able to get it, as it's very common use case that during on load someone want to access to the component env for example\n const aspectListWithEnvsAndDeps = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = aspectListWithEnvsAndDeps;\n\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component, loadOpts);\n return this.upsertExtensionData(component, extension, data);\n });\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n if (!data) return;\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n\nfunction createComponentCacheKey(id: ComponentID, loadOpts?: ComponentLoadOptions): string {\n return `${id.toString()}:${JSON.stringify(sortKeys(loadOpts ?? {}))}`;\n}\n\nfunction sortKeys(obj: Object) {\n return fromPairs(Object.entries(obj).sort(([k1], [k2]) => k1.localeCompare(k2)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;E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IAAS,EAAE;IACpF,IAAI,CAACA,IAAI,EAAE;IACX,MAAMyE,iBAAiB,GAAGxF,SAAS,CAACU,KAAK,CAACoD,MAAM,CAACpC,UAAU,CAAC+D,aAAa,CAACL,SAAS,CAAC;IACpF,IAAII,iBAAiB,EAAE;MACrB;MACAE,MAAM,CAACC,MAAM,CAACH,iBAAiB,CAACzE,IAAI,EAAEA,IAAI,CAAC;MAC3C;IACF;IACAf,SAAS,CAACU,KAAK,CAACoD,MAAM,CAACpC,UAAU,CAACxD,IAAI,CAAC,MAAM,IAAI,CAAC0H,YAAY,CAACR,SAAS,EAAErE,IAAI,CAAC,CAAC;EAClF;EAEA,MAAc6E,YAAY,CAACR,SAAiB,EAAErE,IAA4B,EAA+B;IACvG;IACA,OAAO,KAAI8E,4BAAkB,EAAC/H,SAAS,EAAEA,SAAS,EAAEsH,SAAS,EAAEtH,SAAS,EAAEiD,IAAI,CAAC;EACjF;AACF;AAAC;AAED,SAASiC,uBAAuB,CAACtF,EAAe,EAAET,QAA+B,EAAU;EACzF,OAAQ,GAAES,EAAE,CAACE,QAAQ,EAAG,IAAGkI,IAAI,CAACC,SAAS,CAACC,QAAQ,CAAC/I,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI,CAAC,CAAC,CAAC,CAAE,EAAC;AACvE;AAEA,SAAS+I,QAAQ,CAACC,GAAW,EAAE;EAC7B,OAAO,IAAAC,mBAAS,EAACR,MAAM,CAACV,OAAO,CAACiB,GAAG,CAAC,CAACE,IAAI,CAAC,CAAC,CAACC,EAAE,CAAC,EAAE,CAACC,EAAE,CAAC,KAAKD,EAAE,CAACE,aAAa,CAACD,EAAE,CAAC,CAAC,CAAC;AAClF"}
|
|
1
|
+
{"version":3,"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","createInMemoryCache","maxSize","getMaxSizeForComponents","getMany","ids","loadOpts","idsWithoutEmpty","compact","errors","longProcessLogger","createLongProcessLogger","length","componentsP","mapSeries","id","logProgress","toString","get","undefined","catch","err","isComponentNotExistsError","push","components","forEach","console","warn","filteredComponents","end","getInvalid","consumer","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","getLatestVersionNumber","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","uniq","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","cacheKey","keys","startsWith","delete","componentFromScope","MissingBitMapComponent","extensions","componentExtensions","extensionsFromConsumerComponent","ExtensionDataList","extensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","updatedComp","executeLoadSlot","newComponentFromState","createComponentCacheKey","set","isEqual","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","_consumer","removed","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","dependenciesList","extractDepsFromLegacy","dependenciesFromUnmergedHead","unmergedComponent","getUnmergedComponent","mergedDependencies","DependencyList","merge","depResolverData","serialize","Promise","all","upsertExtensionData","EnvsAspect","DependencyResolverAspect","aspectListWithEnvsAndDeps","aspects","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","updatedAspectList","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry","JSON","stringify","sortKeys","obj","fromPairs","sort","k1","k2","localeCompare"],"sources":["workspace-component-loader.ts"],"sourcesContent":["import { Component, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact, fromPairs, uniq } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyList, DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, loadOpts?: ComponentLoadOptions): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id, undefined, undefined, undefined, loadOpts).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true,\n loadOpts?: ComponentLoadOptions\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, loadOpts);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent, loadOpts);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, loadOpts);\n }\n return component;\n }\n\n async getIfExist(componentId: ComponentID) {\n try {\n return await this.get(componentId);\n } catch (err: any) {\n if (this.isComponentNotExistsError(err)) {\n return undefined;\n }\n throw err;\n }\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n const envIds = uniq(envs.map((env) => env.id));\n if (envIds.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envIds;\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n for (const cacheKey of this.componentsCache.keys()) {\n if (cacheKey === idStr || cacheKey.startsWith(`${idStr}:`)) {\n this.componentsCache.delete(cacheKey);\n }\n }\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent, loadOpts?: ComponentLoadOptions) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n const { extensions } = await this.workspace.componentExtensions(id, componentFromScope);\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n const extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensions,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n const updatedComp = await this.executeLoadSlot(workspaceComponent, loadOpts);\n return updatedComp;\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state), loadOpts);\n }\n\n private saveInCache(component: Component, loadOpts?: ComponentLoadOptions): void {\n const cacheKey = createComponentCacheKey(component.id, loadOpts);\n this.componentsCache.set(cacheKey, component);\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, loadOpts?: ComponentLoadOptions): Component | undefined {\n const cacheKey = createComponentCacheKey(id, loadOpts);\n const fromCache = this.componentsCache.get(cacheKey);\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID): Promise<ConsumerComponent | undefined> {\n try {\n return await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component, loadOpts?: ComponentLoadOptions) {\n if (component.state._consumer.removed) {\n // if it was soft-removed now, the component is not in the FS. loading aspects such as composition ends up with\n // errors as they try to read component files from the filesystem.\n return component;\n }\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(\n component.config.extensions,\n component.id._legacy\n );\n const dependenciesList = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n let dependenciesFromUnmergedHead;\n // Get dependencies from unmerged head if needed\n // we take it from there, as they might not be installed yet and we need to get their versions from the model\n const unmergedComponent = await this.workspace.getUnmergedComponent(component.id);\n if (unmergedComponent) {\n dependenciesFromUnmergedHead = await this.dependencyResolver.extractDepsFromLegacy(unmergedComponent, policy);\n }\n const mergedDependencies = dependenciesFromUnmergedHead\n ? DependencyList.merge([dependenciesList, dependenciesFromUnmergedHead])\n : dependenciesList;\n\n const depResolverData = {\n dependencies: mergedDependencies.serialize(),\n policy: policy.serialize(),\n };\n\n // Make sure we are adding the envs / deps data first because other on load events might depend on it\n await Promise.all([\n this.upsertExtensionData(component, EnvsAspect.id, envsData),\n this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData),\n ]);\n\n // We are updating the component state with the envs and deps data here, so in case we have other slots that depend on this data\n // they will be able to get it, as it's very common use case that during on load someone want to access to the component env for example\n const aspectListWithEnvsAndDeps = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = aspectListWithEnvsAndDeps;\n\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component, loadOpts);\n return this.upsertExtensionData(component, extension, data);\n });\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n if (!data) return;\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n\nfunction createComponentCacheKey(id: ComponentID, loadOpts?: ComponentLoadOptions): string {\n return `${id.toString()}:${JSON.stringify(sortKeys(loadOpts ?? {}))}`;\n}\n\nfunction sortKeys(obj: Object) {\n return fromPairs(Object.entries(obj).sort(([k1], [k2]) => k1.localeCompare(k2)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,wBAAwB,CAAC;EACe;EACnDC,WAAW,CACDC,SAAoB,EACpBC,MAAc,EACdC,kBAA0C,EAC1CC,IAAc,EACtB;IAAA,KAJQH,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAA,KACdC,kBAA0C,GAA1CA,kBAA0C;IAAA,KAC1CC,IAAc,GAAdA,IAAc;IAAA;IAEtB,IAAI,CAACC,eAAe,GAAG,IAAAC,mCAAmB,EAAC;MAAEC,OAAO,EAAE,IAAAC,wCAAuB;IAAG,CAAC,CAAC;EACpF;EAEA,MAAMC,OAAO,CAACC,GAAuB,EAAEC,QA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,CAACC,GAAW,EAAE;EAC7B,OAAO,IAAAC,mBAAS,EAACR,MAAM,CAACV,OAAO,CAACiB,GAAG,CAAC,CAACE,IAAI,CAAC,CAAC,CAACC,EAAE,CAAC,EAAE,CAACC,EAAE,CAAC,KAAKD,EAAE,CAACE,aAAa,CAACD,EAAE,CAAC,CAAC,CAAC;AAClF"}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ import type { AddActionResults, Warnings } from '@teambit/legacy/dist/consumer/c
|
|
|
20
20
|
import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
|
|
21
21
|
import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
|
|
22
22
|
import { PathOsBased, PathOsBasedRelative, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
|
|
23
|
+
import { CompIdGraph, DepEdgeType } from '@teambit/graph';
|
|
23
24
|
import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
|
|
24
25
|
import type { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component';
|
|
25
26
|
import { CompilationInitiator } from '@teambit/compiler';
|
|
@@ -228,6 +229,8 @@ export declare class Workspace implements ComponentFactory {
|
|
|
228
229
|
newAndModified(): Promise<Component[]>;
|
|
229
230
|
getLogs(id: ComponentID, shortHash?: boolean, startsFrom?: string): Promise<ComponentLog[]>;
|
|
230
231
|
getGraph(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<Graph<Component, string>>;
|
|
232
|
+
getGraphIds(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<CompIdGraph>;
|
|
233
|
+
getSavedGraphOfComponentIfExist(component: Component): Promise<Graph<ComponentID, DepEdgeType> | null>;
|
|
231
234
|
/**
|
|
232
235
|
* given component ids, find their dependents in the workspace
|
|
233
236
|
*/
|
|
@@ -413,7 +416,6 @@ export declare class Workspace implements ComponentFactory {
|
|
|
413
416
|
*/
|
|
414
417
|
loadAspects(ids?: string[], throwOnError?: boolean, neededFor?: string): Promise<string[]>;
|
|
415
418
|
/**
|
|
416
|
-
* Note - this gets called from Harmony only.
|
|
417
419
|
* returns one graph that includes all dependencies types. each edge has a label of the dependency
|
|
418
420
|
* type. the nodes content is the Component object.
|
|
419
421
|
*/
|
package/dist/workspace.js
CHANGED
|
@@ -32,6 +32,13 @@ function _pMapSeries() {
|
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
34
34
|
}
|
|
35
|
+
function _graph() {
|
|
36
|
+
const data = require("@teambit/graph.cleargraph");
|
|
37
|
+
_graph = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
35
42
|
function _aspectLoader() {
|
|
36
43
|
const data = require("@teambit/aspect-loader");
|
|
37
44
|
_aspectLoader = function () {
|
|
@@ -298,6 +305,13 @@ function _workspace() {
|
|
|
298
305
|
};
|
|
299
306
|
return data;
|
|
300
307
|
}
|
|
308
|
+
function _buildGraphIdsFromFs() {
|
|
309
|
+
const data = require("./build-graph-ids-from-fs");
|
|
310
|
+
_buildGraphIdsFromFs = function () {
|
|
311
|
+
return data;
|
|
312
|
+
};
|
|
313
|
+
return data;
|
|
314
|
+
}
|
|
301
315
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
302
316
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
303
317
|
const AspectSpecificField = '__specific';
|
|
@@ -586,6 +600,44 @@ class Workspace {
|
|
|
586
600
|
if (!ids || ids.length < 1) ids = await this.listIds();
|
|
587
601
|
return this.buildOneGraphForComponents(ids, undefined, undefined, shouldThrowOnMissingDep);
|
|
588
602
|
}
|
|
603
|
+
async getGraphIds(ids, shouldThrowOnMissingDep = true) {
|
|
604
|
+
if (!ids || ids.length < 1) ids = await this.listIds();
|
|
605
|
+
const graphIdsFromFsBuilder = new (_buildGraphIdsFromFs().GraphIdsFromFsBuilder)(this, this.logger, this.dependencyResolver, shouldThrowOnMissingDep);
|
|
606
|
+
return graphIdsFromFsBuilder.buildGraph(ids);
|
|
607
|
+
}
|
|
608
|
+
async getSavedGraphOfComponentIfExist(component) {
|
|
609
|
+
let versionObj;
|
|
610
|
+
try {
|
|
611
|
+
versionObj = await this.scope.legacyScope.getVersionInstance(component.id._legacy);
|
|
612
|
+
} catch (err) {
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
const flattenedEdges = versionObj.flattenedEdges;
|
|
616
|
+
if (!flattenedEdges.length && versionObj.flattenedDependencies.length) {
|
|
617
|
+
// there are flattenedDependencies, so must be edges, if they're empty, it's because the component was tagged
|
|
618
|
+
// with a version < ~0.0.901, so this flattenedEdges wasn't exist.
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
const flattenedBitIdCompIdMap = {};
|
|
622
|
+
flattenedBitIdCompIdMap[component.id._legacy.toString()] = component.id;
|
|
623
|
+
await Promise.all(versionObj.flattenedDependencies.map(async bitId => {
|
|
624
|
+
flattenedBitIdCompIdMap[bitId.toString()] = await this.resolveComponentId(bitId);
|
|
625
|
+
}));
|
|
626
|
+
const getCompIdByIdStr = idStr => {
|
|
627
|
+
const compId = flattenedBitIdCompIdMap[idStr];
|
|
628
|
+
if (!compId) throw new Error(`id ${idStr} exists in flattenedEdges but not in flattened`);
|
|
629
|
+
return compId;
|
|
630
|
+
};
|
|
631
|
+
const nodes = Object.values(flattenedBitIdCompIdMap);
|
|
632
|
+
const edges = flattenedEdges.map(edge => _objectSpread(_objectSpread({}, edge), {}, {
|
|
633
|
+
source: getCompIdByIdStr(edge.source.toString()),
|
|
634
|
+
target: getCompIdByIdStr(edge.target.toString())
|
|
635
|
+
}));
|
|
636
|
+
const graph = new (_graph().Graph)();
|
|
637
|
+
nodes.forEach(node => graph.setNode(new (_graph().Node)(node.toString(), node)));
|
|
638
|
+
edges.forEach(edge => graph.setEdge(new (_graph().Edge)(edge.source.toString(), edge.target.toString(), edge.type)));
|
|
639
|
+
return graph;
|
|
640
|
+
}
|
|
589
641
|
|
|
590
642
|
/**
|
|
591
643
|
* given component ids, find their dependents in the workspace
|
|
@@ -1614,12 +1666,11 @@ needed-for: ${neededFor || '<unknown>'}`);
|
|
|
1614
1666
|
}
|
|
1615
1667
|
|
|
1616
1668
|
/**
|
|
1617
|
-
* Note - this gets called from Harmony only.
|
|
1618
1669
|
* returns one graph that includes all dependencies types. each edge has a label of the dependency
|
|
1619
1670
|
* type. the nodes content is the Component object.
|
|
1620
1671
|
*/
|
|
1621
1672
|
async buildOneGraphForComponents(ids, ignoreIds, shouldLoadFunc, shouldThrowOnMissingDep = true) {
|
|
1622
|
-
const graphFromFsBuilder = new (_buildGraphFromFs().GraphFromFsBuilder)(this, this.logger, ignoreIds, shouldLoadFunc, shouldThrowOnMissingDep);
|
|
1673
|
+
const graphFromFsBuilder = new (_buildGraphFromFs().GraphFromFsBuilder)(this, this.logger, this.dependencyResolver, ignoreIds, shouldLoadFunc, shouldThrowOnMissingDep);
|
|
1623
1674
|
return graphFromFsBuilder.buildGraph(ids);
|
|
1624
1675
|
}
|
|
1625
1676
|
async resolveAspects(runtimeName, componentIds, opts) {
|