@teambit/workspace 1.0.543 → 1.0.545

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.
@@ -1 +1 @@
1
- {"version":3,"names":["_legacy","data","require","_findRoot","_interopRequireDefault","_toolboxModules","_aspectLoader","_cli","_fsExtra","_harmonyModules","_workspaceModules","_componentId","_legacy2","_pMapSeries","_lodash","_bitError","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","WorkspaceAspectsLoader","constructor","workspace","scope","aspectLoader","envs","dependencyResolver","logger","globalConfig","harmony","onAspectsResolveSlot","onRootAspectAddedSlot","resolveAspectsFromNodeModules","resolveEnvsFromRoots","consumer","resolvedInstalledAspects","Map","hasRootComponents","loadAspects","ids","throwOnError","neededFor","opts","calculatedThrowOnError","defaultOpts","useScopeAspectsCapsule","runSubscribers","skipDeps","hideMissingModuleError","inInstallContext","ignoreErrorFunc","ignoreAspectLoadingError","ignoreErrors","forceLoad","mergedOpts","callId","Math","floor","random","loggerPrefix","profile","info","join","JSON","stringify","localAspects","nonLocalAspects","partition","id","startsWith","localAspectsMap","loadAspectFromPath","notLoadedIds","isAspectLoaded","coreAspectsStringIds","getCoreAspectIds","idsWithoutCore","difference","componentIds","resolveMultipleComponentIds","workspaceIds","nonWorkspaceIds","groupIdsByWorkspaceExistence","logFoundWorkspaceVsScope","idsToLoadFromWs","scopeAspectIds","loadFromScopeAspectsCapsule","aspectsDefs","resolveAspects","undefined","excludeCore","requestedOnly","manifests","requireableComponents","loadAspectDefsByOrder","potentialPluginsIndexes","compact","map","manifest","index","isValidAspect","pluginsRequireableComponents","pluginsManifests","getManifestsFromRequireableExtensions","loadExtensionsByManifests","manifestIds","debug","concat","currentLane","getCurrentLaneObject","nonWorkspaceIdsString","toString","packageManagerConfigRootDir","path","workspaceName","name","err","throwWsJsoncAspectNotFoundError","ComponentNotFound","config","get","configStr","workspaceConfig","raw","includes","BitError","seeders","nonWorkspaceDefs","groupAspectDefsByWorkspaceExistence","scopeAspectsLoader","getScopeAspectsLoader","scopeIds","aspectDef","getId","scopeIdsGrouped","groupAspectIdsByEnvOfTheList","aspectDefsToRequireableComponents","runtimeName","filterByRuntime","idsToResolve","extensionsIds","workspaceLocalAspectsIds","localAspectsIds","nonLocalAspectsIds","localDefs","resolveLocalAspects","coreAspectsIds","configuredAspects","getConfiguredAspects","userAspectsIds","split","rootAspectsIds","componentIdsToResolve","components","importAndGetAspects","runOnAspectsResolveFunctions","wsAspectDefs","getWorkspaceAspectResolver","coreAspectDefs","Promise","all","coreId","rawDef","getAspectDef","loadDefinition","idsToFilter","idStr","ComponentID","fromString","targetDefs","finalDefs","filterAspectDefs","groupedByIsPlugin","groupBy","component","hasPluginFiles","graph","getAspectsGraphWithoutCore","false","isAspect","bind","aspectsComponents","nodes","node","attr","true","workspaceComps","nonWorkspaceComps","groupComponentsByWorkspaceExistence","workspaceCompsIds","c","nonWorkspaceCompsIds","stringIds","linkIfMissingWorkspaceAspects","componentsToResolveFromScope","componentsToResolveFromInstalled","nonWorkspaceCompsGroups","isEnv","scopeAspectsDefs","installedAspectsDefs","getInstalledAspectResolver","coreAspect","runtimePath","localResolved","allDefsExceptLocal","withoutLocalAspects","aspectId","find","localAspect","toStringWithoutVersion","allDefs","filteredDefs","shouldUseHashForCapsules","getSync","CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR","getCapsulePath","defaultPath","workspaceIdsStr","nonWorkspaceIdsStr","use","aspectIdStr","resolveComponentId","inWs","hasId","aspectIdToAdd","aspectsComponent","Error","setExtension","overrideExisting","ignoreVersion","write","reasonForChange","addInMemoryConfiguredAspect","runOnRootAspectAddedFunctions","getConfiguredUserAspectsPackages","options","rawConfiguredAspects","getWorkspaceConfig","componentsToGetPackages","externalsOnly","packages","aspectComponent","packageName","getPackageName","version","aspectDefs","localPath","aspectPath","requireFunc","plugins","getPlugins","has","load","MainRuntime","isModule","isEsmModule","aspect","loadEsm","getRuntimePath","RequireableComponent","aspects","idsToLink","isInWs","exist","fs","pathExists","idsToLinkWithoutNull","linkToNodeModulesByIds","workspaceAspectResolver","compStringId","getComponentPackagePath","aspectFilePath","getAspectFilePath","funcs","getOnAspectsResolveFunctions","pMapSeries","func","error","aspectsResolveFunctions","values","aspectsId","getOnRootAspectAddedFunctions","RootAspectAddedFunctions","rootIds","installedAspectsResolver","resolveInstalledAspectRecursively","aspectStringId","resolvedPath","set","parent","predecessors","parentPath","resolveFrom","findRoot","consoleWarning","message","buildOneGraphForComponents","loadComponentsExtensions","extensions","originatedFrom","extensionsIdsP","extensionEntry","extensionId","stringId","harmonyExtensions","loadedExtensions","extId","loaded","extensionsToLoad","isUsingAspectEnv","isUsingEnvEnv","loadOpts","idsToNotLoadAsAspects","importAndGetMany","existOnWorkspace","rootComps","nonRootComps","groupComponentsByLoadFromRootComps","shouldLoadFromRootComps","rootDir","rootDirExist","aspectFilePathExist","pluginFiles","getPluginFiles","hasEnvManifest","workspaceDefs","scopeComponents","exports"],"sources":["workspace-aspects-loader.ts"],"sourcesContent":["import { CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR } from '@teambit/legacy.constants';\nimport { GlobalConfigMain } from '@teambit/global-config';\nimport findRoot from 'find-root';\nimport { resolveFrom } from '@teambit/toolbox.modules.module-resolver';\nimport { Graph } from '@teambit/graph.cleargraph';\nimport { ExtensionDataList } from '@teambit/legacy.extension-data';\nimport { ExtensionManifest, Harmony, Aspect } from '@teambit/harmony';\nimport {\n AspectDefinition,\n AspectLoaderMain,\n AspectResolver,\n getAspectDef,\n ResolvedAspect,\n} from '@teambit/aspect-loader';\nimport { MainRuntime } from '@teambit/cli';\nimport fs from 'fs-extra';\nimport { RequireableComponent } from '@teambit/harmony.modules.requireable-component';\nimport { linkToNodeModulesByIds } from '@teambit/workspace.modules.node-modules-linker';\nimport { ComponentID } from '@teambit/component-id';\nimport { ComponentNotFound } from '@teambit/legacy.scope';\nimport pMapSeries from 'p-map-series';\nimport { difference, compact, groupBy, partition } from 'lodash';\nimport { Consumer } from '@teambit/legacy.consumer';\nimport { Component, LoadAspectsOptions, ResolveAspectsOptions } from '@teambit/component';\nimport { ScopeMain } from '@teambit/scope';\nimport { Logger } from '@teambit/logger';\nimport { BitError } from '@teambit/bit-error';\nimport { EnvsMain } from '@teambit/envs';\nimport { ConfigMain } from '@teambit/config';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { ShouldLoadFunc } from './build-graph-from-fs';\nimport type { Workspace } from './workspace';\nimport {\n OnAspectsResolve,\n OnAspectsResolveSlot,\n OnRootAspectAdded,\n OnRootAspectAddedSlot,\n} from './workspace.main.runtime';\nimport { ComponentLoadOptions } from './workspace-component/workspace-component-loader';\n\nexport type GetConfiguredUserAspectsPackagesOptions = {\n externalsOnly?: boolean;\n};\n\nexport type WorkspaceLoadAspectsOptions = LoadAspectsOptions & {\n useScopeAspectsCapsule?: boolean;\n runSubscribers?: boolean;\n skipDeps?: boolean;\n resolveEnvsFromRoots?: boolean;\n};\n\nexport type AspectPackage = { packageName: string; version: string };\n\nexport class WorkspaceAspectsLoader {\n private consumer: Consumer;\n private resolvedInstalledAspects: Map<string, string | null>;\n\n constructor(\n private workspace: Workspace,\n private scope: ScopeMain,\n private aspectLoader: AspectLoaderMain,\n private envs: EnvsMain,\n private dependencyResolver: DependencyResolverMain,\n private logger: Logger,\n private globalConfig: GlobalConfigMain,\n private harmony: Harmony,\n private onAspectsResolveSlot: OnAspectsResolveSlot,\n private onRootAspectAddedSlot: OnRootAspectAddedSlot,\n private resolveAspectsFromNodeModules = false,\n private resolveEnvsFromRoots = false\n ) {\n this.consumer = this.workspace.consumer;\n this.resolvedInstalledAspects = new Map();\n // Only enable this when root components is enabled as well\n this.resolveEnvsFromRoots = this.resolveEnvsFromRoots && this.dependencyResolver.hasRootComponents();\n }\n\n /**\n * load aspects from the workspace and if not exists in the workspace, load from the node_modules.\n * keep in mind that the graph may have circles.\n */\n async loadAspects(\n ids: string[] = [],\n throwOnError?: boolean,\n neededFor?: string,\n opts: WorkspaceLoadAspectsOptions = {}\n ): Promise<string[]> {\n const calculatedThrowOnError: boolean = throwOnError ?? false;\n const defaultOpts: Required<WorkspaceLoadAspectsOptions> = {\n useScopeAspectsCapsule: false,\n throwOnError: calculatedThrowOnError,\n runSubscribers: true,\n skipDeps: false,\n hideMissingModuleError: !!this.workspace.inInstallContext,\n ignoreErrorFunc: this.workspace.inInstallContext ? ignoreAspectLoadingError : () => false,\n ignoreErrors: false,\n resolveEnvsFromRoots: this.resolveEnvsFromRoots,\n forceLoad: false,\n };\n const mergedOpts: Required<WorkspaceLoadAspectsOptions> = { ...defaultOpts, ...opts };\n\n // generate a random callId to be able to identify the call from the logs\n const callId = Math.floor(Math.random() * 1000);\n const loggerPrefix = `[${callId}] loadAspects,`;\n this.logger.profile(`[${callId}] workspace.loadAspects`);\n this.logger.info(`${loggerPrefix} loading ${ids.length} aspects.\nids: ${ids.join(', ')}\nneeded-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts, null, 2)}`);\n const [localAspects, nonLocalAspects] = partition(ids, (id) => id.startsWith('file:'));\n const localAspectsMap = await this.aspectLoader.loadAspectFromPath(localAspects);\n this.workspace.localAspects = { ...this.workspace.localAspects, ...localAspectsMap };\n\n let notLoadedIds = nonLocalAspects;\n if (!mergedOpts.forceLoad) {\n notLoadedIds = nonLocalAspects.filter((id) => !this.aspectLoader.isAspectLoaded(id));\n }\n if (!notLoadedIds.length) {\n this.logger.profile(`[${callId}] workspace.loadAspects`);\n return [];\n }\n const coreAspectsStringIds = this.aspectLoader.getCoreAspectIds();\n const idsWithoutCore: string[] = difference(notLoadedIds, coreAspectsStringIds);\n\n const componentIds = await this.workspace.resolveMultipleComponentIds(idsWithoutCore);\n\n const { workspaceIds, nonWorkspaceIds } = await this.groupIdsByWorkspaceExistence(\n componentIds,\n mergedOpts.resolveEnvsFromRoots\n );\n\n this.logFoundWorkspaceVsScope(loggerPrefix, workspaceIds, nonWorkspaceIds);\n let idsToLoadFromWs = componentIds;\n let scopeAspectIds: string[] = [];\n\n // TODO: hard coded use the old approach and loading from the scope capsules\n // This is because right now loading from the ws node_modules causes issues in some cases\n // like for the cloud app\n // it should be removed once we fix the issues\n if (!this.resolveAspectsFromNodeModules) {\n mergedOpts.useScopeAspectsCapsule = true;\n }\n\n if (mergedOpts.useScopeAspectsCapsule) {\n idsToLoadFromWs = workspaceIds;\n scopeAspectIds = await this.loadFromScopeAspectsCapsule(nonWorkspaceIds, throwOnError, neededFor);\n }\n\n const aspectsDefs = await this.resolveAspects(undefined, idsToLoadFromWs, {\n excludeCore: true,\n requestedOnly: false,\n ...mergedOpts,\n });\n\n const { manifests, requireableComponents } = await this.loadAspectDefsByOrder(\n aspectsDefs,\n idsWithoutCore,\n mergedOpts.throwOnError,\n mergedOpts.hideMissingModuleError,\n mergedOpts.ignoreErrorFunc,\n neededFor,\n mergedOpts.runSubscribers\n );\n\n const potentialPluginsIndexes = compact(\n manifests.map((manifest, index) => {\n if (this.aspectLoader.isValidAspect(manifest)) return undefined;\n return index;\n })\n );\n\n // Try require components for potential plugins\n const pluginsRequireableComponents = potentialPluginsIndexes.map((index) => {\n return requireableComponents[index];\n });\n // Do the require again now that the plugins defs already registered\n const pluginsManifests = await this.aspectLoader.getManifestsFromRequireableExtensions(\n pluginsRequireableComponents,\n throwOnError,\n opts.runSubscribers\n );\n await this.aspectLoader.loadExtensionsByManifests(pluginsManifests, undefined, { throwOnError });\n const manifestIds = manifests.map((manifest) => manifest.id);\n this.logger.debug(`${loggerPrefix} finish loading aspects`);\n this.logger.profile(`[${callId}] workspace.loadAspects`);\n return compact(manifestIds.concat(scopeAspectIds));\n }\n\n private async loadFromScopeAspectsCapsule(ids: ComponentID[], throwOnError?: boolean, neededFor?: string) {\n let scopeAspectIds: string[] = [];\n const currentLane = await this.consumer.getCurrentLaneObject();\n\n if (!ids.length) return [];\n\n const nonWorkspaceIdsString = ids.map((id) => id.toString());\n try {\n scopeAspectIds = await this.scope.loadAspects(nonWorkspaceIdsString, throwOnError, neededFor, currentLane, {\n packageManagerConfigRootDir: this.workspace.path,\n workspaceName: this.workspace.name,\n });\n return scopeAspectIds;\n } catch (err: any) {\n this.throwWsJsoncAspectNotFoundError(err);\n return scopeAspectIds;\n\n throw err;\n }\n }\n\n throwWsJsoncAspectNotFoundError(err: any) {\n if (err instanceof ComponentNotFound) {\n const config = this.harmony.get<ConfigMain>('teambit.harmony/config');\n const configStr = JSON.stringify(config.workspaceConfig?.raw || {});\n if (configStr.includes(err.id)) {\n throw new BitError(`error: a component \"${err.id}\" was not found\nyour workspace.jsonc has this component-id set. you might want to remove/change it.`);\n }\n }\n }\n\n private async loadAspectDefsByOrder(\n aspectsDefs: AspectDefinition[],\n seeders: string[],\n throwOnError: boolean,\n hideMissingModuleError: boolean,\n ignoreErrorFunc?: (err: Error) => boolean,\n neededFor?: string,\n runSubscribers = true\n ): Promise<{ manifests: Array<Aspect | ExtensionManifest>; requireableComponents: RequireableComponent[] }> {\n const { nonWorkspaceDefs } = await this.groupAspectDefsByWorkspaceExistence(aspectsDefs);\n const scopeAspectsLoader = this.scope.getScopeAspectsLoader();\n const scopeIds: string[] = compact(nonWorkspaceDefs.map((aspectDef) => aspectDef.getId));\n const scopeIdsGrouped = await scopeAspectsLoader.groupAspectIdsByEnvOfTheList(scopeIds);\n\n // Make sure to first load envs from the list otherwise it will fail when trying to load other aspects\n // as their envs might not be loaded yet\n if (scopeIdsGrouped.envs && scopeIdsGrouped.envs.length && !runSubscribers) {\n await this.scope.loadAspects(scopeIdsGrouped.envs, throwOnError, 'workspace.loadAspects loading scope aspects');\n }\n const requireableComponents = this.aspectDefsToRequireableComponents(aspectsDefs);\n const manifests = await this.aspectLoader.getManifestsFromRequireableExtensions(\n requireableComponents,\n throwOnError,\n runSubscribers\n );\n await this.aspectLoader.loadExtensionsByManifests(\n manifests,\n { seeders, neededFor },\n { throwOnError, hideMissingModuleError, ignoreErrorFunc }\n );\n return { manifests, requireableComponents };\n }\n\n async resolveAspects(\n runtimeName?: string,\n componentIds?: ComponentID[],\n opts?: ResolveAspectsOptions\n ): Promise<AspectDefinition[]> {\n const callId = Math.floor(Math.random() * 1000);\n const loggerPrefix = `[${callId}] workspace resolveAspects,`;\n\n this.logger.debug(\n `${loggerPrefix}, resolving aspects for - runtimeName: ${runtimeName}, componentIds: ${componentIds}`\n );\n const defaultOpts: ResolveAspectsOptions = {\n excludeCore: false,\n requestedOnly: false,\n filterByRuntime: true,\n useScopeAspectsCapsule: false,\n workspaceName: this.workspace.name,\n resolveEnvsFromRoots: this.resolveEnvsFromRoots,\n packageManagerConfigRootDir: this.workspace.path,\n };\n const mergedOpts = { ...defaultOpts, ...opts };\n const idsToResolve = componentIds ? componentIds.map((id) => id.toString()) : this.harmony.extensionsIds;\n const workspaceLocalAspectsIds = Object.keys(this.workspace.localAspects);\n const [localAspectsIds, nonLocalAspectsIds] = partition(idsToResolve, (id) =>\n workspaceLocalAspectsIds.includes(id)\n );\n\n const localDefs = await this.aspectLoader.resolveLocalAspects(\n localAspectsIds.map((id) => this.workspace.localAspects[id]),\n runtimeName\n );\n const coreAspectsIds = this.aspectLoader.getCoreAspectIds();\n const configuredAspects = this.aspectLoader.getConfiguredAspects();\n // it's possible that componentIds are core-aspects that got version for some reason, remove the version to\n // correctly filter them out later.\n const userAspectsIds: string[] = nonLocalAspectsIds\n ? nonLocalAspectsIds.filter((id) => !coreAspectsIds.includes(id.split('@')[0])).map((id) => id.toString())\n : difference(this.harmony.extensionsIds, coreAspectsIds);\n const rootAspectsIds: string[] = difference(configuredAspects, coreAspectsIds);\n const componentIdsToResolve = await this.workspace.resolveMultipleComponentIds(userAspectsIds);\n const components = await this.importAndGetAspects(componentIdsToResolve, opts?.throwOnError);\n // Run the on load slot\n await this.runOnAspectsResolveFunctions(components);\n\n if (opts?.skipDeps) {\n const wsAspectDefs = await this.aspectLoader.resolveAspects(\n components,\n this.getWorkspaceAspectResolver([], runtimeName)\n );\n\n const coreAspectDefs = await Promise.all(\n coreAspectsIds.map(async (coreId) => {\n const rawDef = await getAspectDef(coreId, runtimeName);\n return this.aspectLoader.loadDefinition(rawDef);\n })\n );\n\n const idsToFilter = idsToResolve.map((idStr) => ComponentID.fromString(idStr));\n const targetDefs = wsAspectDefs.concat(coreAspectDefs).concat(localDefs);\n const finalDefs = this.aspectLoader.filterAspectDefs(targetDefs, idsToFilter, runtimeName, mergedOpts);\n\n return finalDefs;\n }\n\n const groupedByIsPlugin = groupBy(components, (component) => {\n return this.aspectLoader.hasPluginFiles(component);\n });\n const graph = await this.getAspectsGraphWithoutCore(groupedByIsPlugin.false, this.isAspect.bind(this));\n const aspectsComponents = graph.nodes.map((node) => node.attr).concat(groupedByIsPlugin.true || []);\n this.logger.debug(`${loggerPrefix} found ${aspectsComponents.length} aspects in the aspects-graph`);\n const { workspaceComps, nonWorkspaceComps } = await this.groupComponentsByWorkspaceExistence(\n aspectsComponents,\n mergedOpts.resolveEnvsFromRoots\n );\n\n const workspaceCompsIds = workspaceComps.map((c) => c.id);\n const nonWorkspaceCompsIds = nonWorkspaceComps.map((c) => c.id);\n this.logFoundWorkspaceVsScope(loggerPrefix, workspaceCompsIds, nonWorkspaceCompsIds);\n\n const stringIds: string[] = [];\n const wsAspectDefs = await this.aspectLoader.resolveAspects(\n workspaceComps,\n this.getWorkspaceAspectResolver(stringIds, runtimeName)\n );\n\n await this.linkIfMissingWorkspaceAspects(wsAspectDefs);\n\n // TODO: hard coded use the old approach and loading from the scope capsules\n // This is because right now loading from the ws node_modules causes issues in some cases\n // like for the cloud app\n // it should be removed once we fix the issues\n if (!this.resolveAspectsFromNodeModules) {\n mergedOpts.useScopeAspectsCapsule = true;\n }\n\n let componentsToResolveFromScope = nonWorkspaceComps;\n let componentsToResolveFromInstalled: Component[] = [];\n if (!mergedOpts.useScopeAspectsCapsule) {\n const nonWorkspaceCompsGroups = groupBy(nonWorkspaceComps, (component) => this.envs.isEnv(component));\n componentsToResolveFromScope = nonWorkspaceCompsGroups.true || [];\n componentsToResolveFromInstalled = nonWorkspaceCompsGroups.false || [];\n }\n\n const scopeIds = componentsToResolveFromScope.map((c) => c.id);\n this.logger.debug(\n `${loggerPrefix} ${\n scopeIds.length\n } components are not in the workspace and are loaded from the scope capsules:\\n${scopeIds\n .map((id) => id.toString())\n .join('\\n')}`\n );\n const scopeAspectsDefs: AspectDefinition[] = scopeIds.length\n ? await this.scope.resolveAspects(runtimeName, scopeIds, mergedOpts)\n : [];\n\n this.logger.debug(\n `${loggerPrefix} ${\n componentsToResolveFromInstalled.length\n } components are not in the workspace and are loaded from the node_modules:\\n${componentsToResolveFromInstalled\n .map((c) => c.id.toString())\n .join('\\n')}`\n );\n const installedAspectsDefs: AspectDefinition[] = componentsToResolveFromInstalled.length\n ? await this.aspectLoader.resolveAspects(\n componentsToResolveFromInstalled,\n this.getInstalledAspectResolver(graph, rootAspectsIds, runtimeName, {\n throwOnError: opts?.throwOnError ?? false,\n })\n )\n : [];\n\n let coreAspectDefs = await Promise.all(\n coreAspectsIds.map(async (coreId) => {\n const rawDef = await getAspectDef(coreId, runtimeName);\n return this.aspectLoader.loadDefinition(rawDef);\n })\n );\n\n // due to lack of workspace and scope runtimes. TODO: fix after adding them.\n if (runtimeName && mergedOpts.filterByRuntime) {\n coreAspectDefs = coreAspectDefs.filter((coreAspect) => {\n return coreAspect.runtimePath;\n });\n }\n const localResolved = await this.aspectLoader.resolveLocalAspects(\n Object.keys(this.workspace.localAspects),\n runtimeName\n );\n const allDefsExceptLocal = [...wsAspectDefs, ...coreAspectDefs, ...scopeAspectsDefs, ...installedAspectsDefs];\n const withoutLocalAspects = allDefsExceptLocal.filter((aspectId) => {\n return !localResolved.find((localAspect) => {\n return localAspect.id === aspectId.component?.id?.toStringWithoutVersion();\n });\n });\n const allDefs = [...withoutLocalAspects, ...localResolved];\n const idsToFilter = idsToResolve.map((idStr) => ComponentID.fromString(idStr));\n const filteredDefs = this.aspectLoader.filterAspectDefs(allDefs, idsToFilter, runtimeName, mergedOpts);\n return filteredDefs;\n }\n\n shouldUseHashForCapsules(): boolean {\n return !this.globalConfig.getSync(CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR);\n }\n\n getCapsulePath() {\n const defaultPath = this.workspace.path;\n return this.globalConfig.getSync(CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR) || defaultPath;\n }\n\n private logFoundWorkspaceVsScope(loggerPrefix: string, workspaceIds: ComponentID[], nonWorkspaceIds: ComponentID[]) {\n const workspaceIdsStr = workspaceIds.length ? workspaceIds.map((id) => id.toString()).join('\\n') : '';\n const nonWorkspaceIdsStr = nonWorkspaceIds.length ? nonWorkspaceIds.map((id) => id.toString()).join('\\n') : '';\n this.logger.debug(\n `${loggerPrefix} found ${workspaceIds.length} components in the workspace, ${nonWorkspaceIds.length} not in the workspace`\n );\n if (workspaceIdsStr) this.logger.debug(`${loggerPrefix} workspace components:\\n${workspaceIdsStr}`);\n if (nonWorkspaceIdsStr)\n this.logger.debug(\n `${loggerPrefix} non workspace components (loaded from the scope capsules or from the node_modules):\\n${nonWorkspaceIdsStr}`\n );\n }\n\n async use(aspectIdStr: string): Promise<string> {\n let aspectId = await this.workspace.resolveComponentId(aspectIdStr);\n const inWs = await this.workspace.hasId(aspectId);\n let aspectIdToAdd = aspectId.toStringWithoutVersion();\n\n let aspectsComponent;\n // let aspectPackage;\n if (!inWs) {\n const aspectsComponents = await this.importAndGetAspects([aspectId]);\n if (aspectsComponents[0]) {\n aspectsComponent = aspectsComponents[0];\n aspectId = aspectsComponent.id;\n aspectIdToAdd = aspectId.toString();\n }\n }\n\n const config = this.harmony.get<ConfigMain>('teambit.harmony/config').workspaceConfig;\n if (!config) {\n throw new Error(`use() unable to get the workspace config`);\n }\n config.setExtension(\n aspectIdToAdd,\n {},\n {\n overrideExisting: false,\n ignoreVersion: false,\n }\n );\n await config.write({ reasonForChange: `use (${aspectIdStr})` });\n this.aspectLoader.addInMemoryConfiguredAspect(aspectIdToAdd);\n await this.runOnRootAspectAddedFunctions(aspectId, inWs);\n return aspectIdToAdd;\n }\n\n async getConfiguredUserAspectsPackages(\n options: GetConfiguredUserAspectsPackagesOptions = {}\n ): Promise<AspectPackage[]> {\n const rawConfiguredAspects = this.workspace.getWorkspaceConfig()?.extensionsIds;\n const coreAspectsIds = this.aspectLoader.getCoreAspectIds();\n const userAspectsIds: string[] = difference(rawConfiguredAspects, coreAspectsIds);\n const componentIdsToResolve = await this.workspace.resolveMultipleComponentIds(\n userAspectsIds.filter((id) => !id.startsWith('file:'))\n );\n const aspectsComponents = await this.importAndGetAspects(componentIdsToResolve);\n let componentsToGetPackages = aspectsComponents;\n if (options.externalsOnly) {\n const { nonWorkspaceComps } = await this.groupComponentsByWorkspaceExistence(aspectsComponents);\n componentsToGetPackages = nonWorkspaceComps;\n }\n const packages = componentsToGetPackages.map((aspectComponent) => {\n const packageName = this.dependencyResolver.getPackageName(aspectComponent);\n const version = aspectComponent.id.version || '*';\n return { packageName, version };\n });\n return packages;\n }\n\n private aspectDefsToRequireableComponents(aspectDefs: AspectDefinition[]): RequireableComponent[] {\n const requireableComponents = aspectDefs.map((aspectDef) => {\n const localPath = aspectDef.aspectPath;\n const component = aspectDef.component;\n if (!component) return undefined;\n const requireFunc = async () => {\n const plugins = this.aspectLoader.getPlugins(component, localPath);\n if (plugins.has()) {\n return plugins.load(MainRuntime.name);\n }\n\n const isModule = await this.aspectLoader.isEsmModule(localPath);\n\n const aspect = !isModule\n ? // eslint-disable-next-line global-require, import/no-dynamic-require\n require(localPath)\n : // : await this.aspectLoader.loadEsm(join(localPath, 'dist', 'index.js'));\n await this.aspectLoader.loadEsm(localPath);\n\n // require aspect runtimes\n const runtimePath = await this.aspectLoader.getRuntimePath(component, localPath, MainRuntime.name);\n if (runtimePath) {\n if (isModule) await this.aspectLoader.loadEsm(runtimePath);\n // eslint-disable-next-line global-require, import/no-dynamic-require\n require(runtimePath);\n }\n return aspect;\n };\n return new RequireableComponent(component, requireFunc);\n });\n return compact(requireableComponents);\n }\n\n private async linkIfMissingWorkspaceAspects(aspects: AspectDefinition[]) {\n const idsToLink = await Promise.all(\n aspects.map(async (aspect) => {\n if (!aspect.component)\n throw new Error(`linkIfMissingWorkspaceAspects, aspect.component is missing for ${aspect.aspectPath}`);\n const isInWs = await this.workspace.hasId(aspect.component.id);\n if (!isInWs) return null;\n const exist = await fs.pathExists(aspect.aspectPath);\n if (!exist) return aspect.component.id;\n return null;\n })\n );\n const idsToLinkWithoutNull = compact(idsToLink);\n if (!idsToLinkWithoutNull.length) return;\n await linkToNodeModulesByIds(this.workspace, idsToLinkWithoutNull);\n }\n\n /**\n * This will return a resolver that knows to resolve aspects which are part of the workspace.\n * means aspects exist in the bitmap file\n * @param stringIds\n * @param runtimeName\n * @returns\n */\n private getWorkspaceAspectResolver(stringIds: string[], runtimeName?: string): AspectResolver {\n const workspaceAspectResolver = async (component: Component): Promise<ResolvedAspect> => {\n const compStringId = component.id.toString();\n stringIds.push(compStringId);\n const localPath = await this.workspace.getComponentPackagePath(component);\n\n const runtimePath = runtimeName\n ? await this.aspectLoader.getRuntimePath(component, localPath, runtimeName)\n : null;\n\n const aspectFilePath = await this.aspectLoader.getAspectFilePath(component, localPath);\n\n this.logger.debug(\n `workspace resolveAspects, resolving id: ${compStringId}, localPath: ${localPath}, runtimePath: ${runtimePath}`\n );\n return {\n aspectPath: localPath,\n aspectFilePath,\n runtimePath,\n };\n };\n return workspaceAspectResolver;\n }\n\n private async runOnAspectsResolveFunctions(aspectsComponents: Component[]): Promise<void> {\n const funcs = this.getOnAspectsResolveFunctions();\n await pMapSeries(funcs, async (func) => {\n try {\n await func(aspectsComponents);\n } catch (err) {\n this.logger.error('failed running onAspectsResolve function', err);\n }\n });\n }\n\n private getOnAspectsResolveFunctions(): OnAspectsResolve[] {\n const aspectsResolveFunctions = this.onAspectsResolveSlot.values();\n return aspectsResolveFunctions;\n }\n\n private async runOnRootAspectAddedFunctions(aspectsId: ComponentID, inWs: boolean): Promise<void> {\n const funcs = this.getOnRootAspectAddedFunctions();\n await pMapSeries(funcs, async (func) => {\n try {\n await func(aspectsId, inWs);\n } catch (err) {\n this.logger.error('failed running onRootAspectAdded function', err);\n }\n });\n }\n\n private getOnRootAspectAddedFunctions(): OnRootAspectAdded[] {\n const RootAspectAddedFunctions = this.onRootAspectAddedSlot.values();\n return RootAspectAddedFunctions;\n }\n\n /**\n * This will return a resolver that knows to resolve aspects which are not part of the workspace.\n * means aspects that does not exist in the bitmap file\n * instead it will resolve them from the node_modules recursively\n * @param graph\n * @param rootIds\n * @param runtimeName\n * @returns\n */\n private getInstalledAspectResolver(\n graph: Graph<Component, string>,\n rootIds: string[],\n runtimeName?: string,\n opts: { throwOnError: boolean } = { throwOnError: false }\n ): AspectResolver {\n const installedAspectsResolver = async (component: Component): Promise<ResolvedAspect | undefined> => {\n const compStringId = component.id.toString();\n // stringIds.push(compStringId);\n const localPath = await this.resolveInstalledAspectRecursively(component, rootIds, graph, opts);\n if (!localPath) return undefined;\n\n const runtimePath = runtimeName\n ? await this.aspectLoader.getRuntimePath(component, localPath, runtimeName)\n : null;\n\n const aspectFilePath = await this.aspectLoader.getAspectFilePath(component, localPath);\n\n this.logger.debug(\n `workspace resolveInstalledAspects, resolving id: ${compStringId}, localPath: ${localPath}, runtimePath: ${runtimePath}`\n );\n return {\n aspectPath: localPath,\n aspectFilePath,\n runtimePath,\n };\n };\n return installedAspectsResolver;\n }\n\n private async resolveInstalledAspectRecursively(\n aspectComponent: Component,\n rootIds: string[],\n graph: Graph<Component, string>,\n opts: { throwOnError: boolean } = { throwOnError: false }\n ): Promise<string | null | undefined> {\n const aspectStringId = aspectComponent.id.toString();\n if (this.resolvedInstalledAspects.has(aspectStringId)) {\n const resolvedPath = this.resolvedInstalledAspects.get(aspectStringId);\n return resolvedPath;\n }\n if (rootIds.includes(aspectStringId)) {\n const localPath = await this.workspace.getComponentPackagePath(aspectComponent);\n this.resolvedInstalledAspects.set(aspectStringId, localPath);\n return localPath;\n }\n const parent = graph.predecessors(aspectStringId)[0];\n if (!parent) return undefined;\n const parentPath = await this.resolveInstalledAspectRecursively(parent.attr, rootIds, graph);\n if (!parentPath) {\n this.resolvedInstalledAspects.set(aspectStringId, null);\n return undefined;\n }\n const packageName = this.dependencyResolver.getPackageName(aspectComponent);\n try {\n const resolvedPath = resolveFrom(parentPath, [packageName]);\n const localPath = findRoot(resolvedPath);\n this.resolvedInstalledAspects.set(aspectStringId, localPath);\n return localPath;\n } catch (error: any) {\n this.resolvedInstalledAspects.set(aspectStringId, null);\n if (opts.throwOnError) {\n throw error;\n }\n this.logger.consoleWarning(\n `failed resolving aspect ${aspectStringId} from ${parentPath}, error: ${error.message}`\n );\n return undefined;\n }\n }\n\n /**\n * Create a graph of aspects without the core aspects.\n * @param components\n * @param isAspect\n * @returns\n */\n private async getAspectsGraphWithoutCore(\n components: Component[] = [],\n isAspect?: ShouldLoadFunc\n ): Promise<Graph<Component, string>> {\n const ids = components.map((component) => component.id);\n const coreAspectsStringIds = this.aspectLoader.getCoreAspectIds();\n // TODO: @gilad it causes many issues we need to find a better solution. removed for now.\n // const coreAspectsComponentIds = coreAspectsStringIds.map((id) => ComponentID.fromString(id));\n // const aspectsIds = components.reduce((acc, curr) => {\n // const currIds = curr.state.aspects.ids;\n // acc = acc.concat(currIds);\n // return acc;\n // }, [] as any);\n // const otherDependenciesMap = components.reduce((acc, curr) => {\n // // const currIds = curr.state.dependencies.dependencies.map(dep => dep.id.toString());\n // const currMap = curr.state.dependencies.getIdsMap();\n // Object.assign(acc, currMap);\n // return acc;\n // }, {});\n\n // const depsWhichAreNotAspects = difference(Object.keys(otherDependenciesMap), aspectsIds);\n // const depsWhichAreNotAspectsBitIds = depsWhichAreNotAspects.map((strId) => otherDependenciesMap[strId]);\n // We only want to load into the graph components which are aspects and not regular dependencies\n // This come to solve a circular loop when an env aspect use an aspect (as regular dep) and the aspect use the env aspect as its env\n return this.workspace.buildOneGraphForComponents(ids, coreAspectsStringIds, isAspect);\n }\n\n /**\n * Load all unloaded extensions from an extension list\n * this will resolve the extensions from the scope aspects capsules if they are not in the ws\n * Only use it for component extensions\n * for workspace/scope root aspect use the load aspects directly\n *\n * The reason we are loading component extensions with \"scope aspects capsules\" is because for component extensions\n * we might have the same extension in multiple versions\n * (for example I might have 2 components using different versions of the same env)\n * in such case, I can't install both version into the root of the node_modules so I need to place it somewhere else (capsules)\n * @param extensions list of extensions with config to load\n */\n async loadComponentsExtensions(\n extensions: ExtensionDataList,\n originatedFrom?: ComponentID,\n opts: WorkspaceLoadAspectsOptions = {}\n ): Promise<void> {\n const defaultOpts: WorkspaceLoadAspectsOptions = {\n useScopeAspectsCapsule: true,\n throwOnError: false,\n hideMissingModuleError: !!this.workspace.inInstallContext,\n ignoreErrorFunc: this.workspace.inInstallContext ? ignoreAspectLoadingError : undefined,\n resolveEnvsFromRoots: this.resolveEnvsFromRoots,\n };\n const mergedOpts = { ...defaultOpts, ...opts };\n const extensionsIdsP = extensions.map(async (extensionEntry) => {\n // Core extension\n if (!extensionEntry.extensionId) {\n return extensionEntry.stringId as string;\n }\n\n const id = await this.workspace.resolveComponentId(extensionEntry.extensionId);\n // return this.resolveComponentId(extensionEntry.extensionId);\n return id.toString();\n });\n const extensionsIds: string[] = await Promise.all(extensionsIdsP);\n const harmonyExtensions = this.harmony.extensionsIds;\n const loadedExtensions = harmonyExtensions.filter((extId) => {\n return this.harmony.extensions.get(extId)?.loaded;\n });\n const extensionsToLoad = difference(extensionsIds, loadedExtensions);\n if (!extensionsToLoad.length) return;\n await this.loadAspects(extensionsToLoad, undefined, originatedFrom?.toString(), mergedOpts);\n }\n\n private async isAspect(id: ComponentID) {\n const component = await this.workspace.get(id);\n const isUsingAspectEnv = this.envs.isUsingAspectEnv(component);\n const isUsingEnvEnv = this.envs.isUsingEnvEnv(component);\n const isValidAspect = isUsingAspectEnv || isUsingEnvEnv;\n return isValidAspect;\n }\n\n /**\n * same as `this.importAndGetMany()` with a specific error handling of ComponentNotFound\n */\n private async importAndGetAspects(componentIds: ComponentID[], throwOnError = true): Promise<Component[]> {\n try {\n // We don't want to load the seeders as aspects as it will cause an infinite loop\n // once you try to load the seeder it will try to load the workspace component\n // that will arrive here again and again\n const loadOpts: ComponentLoadOptions = {\n idsToNotLoadAsAspects: componentIds.map((id) => id.toString()),\n };\n return await this.workspace.importAndGetMany(\n componentIds,\n 'to load aspects from the workspace',\n loadOpts,\n throwOnError\n );\n } catch (err: any) {\n this.throwWsJsoncAspectNotFoundError(err);\n\n throw err;\n }\n }\n\n /**\n * split the provided components into 2 groups, one which are workspace components and the other which are not.\n * @param components\n * @returns\n */\n private async groupComponentsByWorkspaceExistence(\n components: Component[],\n resolveEnvsFromRoots?: boolean\n ): Promise<{ workspaceComps: Component[]; nonWorkspaceComps: Component[] }> {\n let workspaceComps: Component[] = [];\n let nonWorkspaceComps: Component[] = [];\n await Promise.all(\n components.map(async (component) => {\n const existOnWorkspace = await this.workspace.hasId(component.id);\n existOnWorkspace ? workspaceComps.push(component) : nonWorkspaceComps.push(component);\n })\n );\n if (resolveEnvsFromRoots) {\n const { rootComps, nonRootComps } = await this.groupComponentsByLoadFromRootComps(nonWorkspaceComps);\n workspaceComps = workspaceComps.concat(rootComps);\n nonWorkspaceComps = nonRootComps;\n }\n return { workspaceComps, nonWorkspaceComps };\n }\n\n private async groupComponentsByLoadFromRootComps(\n components: Component[]\n ): Promise<{ rootComps: Component[]; nonRootComps: Component[] }> {\n const rootComps: Component[] = [];\n const nonRootComps: Component[] = [];\n await Promise.all(\n components.map(async (component) => {\n const shouldLoadFromRootComps = await this.shouldLoadFromRootComps(component);\n if (shouldLoadFromRootComps) {\n rootComps.push(component);\n return;\n }\n nonRootComps.push(component);\n })\n );\n return { rootComps, nonRootComps };\n }\n\n private async shouldLoadFromRootComps(component: Component): Promise<boolean> {\n const rootDir = await this.workspace.getComponentPackagePath(component);\n const rootDirExist = await fs.pathExists(rootDir);\n const aspectFilePath = await this.aspectLoader.getAspectFilePath(component, rootDir);\n const aspectFilePathExist = aspectFilePath ? await fs.pathExists(aspectFilePath) : false;\n const pluginFiles = await this.aspectLoader.getPluginFiles(component, rootDir);\n\n // checking that we have the root dir (this means it's an aspect that needs to be loaded from there)\n // and validate that localPathExist so we can\n // really load the component from that path (if it's there it means that it's an env)\n if (rootDirExist && (aspectFilePathExist || pluginFiles.length)) {\n return true;\n }\n // If the component has env.jsonc we want to list it to be loaded from the root folder\n // even if it's not there yet\n // in that case we will fail to load it, and the user will need to run bit install\n if (this.envs.hasEnvManifest(component)) {\n return true;\n }\n return false;\n }\n\n /**\n * split the provided components into 2 groups, one which are workspace components and the other which are not.\n * @param components\n * @returns\n */\n private async groupAspectDefsByWorkspaceExistence(\n aspectDefs: AspectDefinition[]\n ): Promise<{ workspaceDefs: AspectDefinition[]; nonWorkspaceDefs: AspectDefinition[] }> {\n const workspaceDefs: AspectDefinition[] = [];\n const nonWorkspaceDefs: AspectDefinition[] = [];\n await Promise.all(\n aspectDefs.map(async (aspectDef) => {\n const id = aspectDef.component?.id;\n const existOnWorkspace = id ? await this.workspace.hasId(id) : true;\n if (existOnWorkspace) {\n workspaceDefs.push(aspectDef);\n return;\n }\n const shouldLoadFromRootComps = aspectDef.component\n ? await this.shouldLoadFromRootComps(aspectDef.component)\n : undefined;\n if (shouldLoadFromRootComps) {\n workspaceDefs.push(aspectDef);\n return;\n }\n nonWorkspaceDefs.push(aspectDef);\n })\n );\n return { workspaceDefs, nonWorkspaceDefs };\n }\n\n private async groupIdsByWorkspaceExistence(\n ids: ComponentID[],\n resolveEnvsFromRoots?: boolean\n ): Promise<{ workspaceIds: ComponentID[]; nonWorkspaceIds: ComponentID[] }> {\n let workspaceIds: ComponentID[] = [];\n let nonWorkspaceIds: ComponentID[] = [];\n await Promise.all(\n ids.map(async (id) => {\n const existOnWorkspace = await this.workspace.hasId(id);\n existOnWorkspace ? workspaceIds.push(id) : nonWorkspaceIds.push(id);\n })\n );\n // We need to bring the components in order to really group them with taking the root comps into account\n const scopeComponents = await this.importAndGetAspects(nonWorkspaceIds);\n const { nonWorkspaceComps, workspaceComps } = await this.groupComponentsByWorkspaceExistence(\n scopeComponents,\n resolveEnvsFromRoots\n );\n workspaceIds = workspaceIds.concat(workspaceComps.map((c) => c.id));\n nonWorkspaceIds = nonWorkspaceComps.map((c) => c.id);\n return { workspaceIds, nonWorkspaceIds };\n }\n}\n\nfunction ignoreAspectLoadingError(err: Error) {\n // Ignoring that error as probably we are in the middle of the installation process\n // so we didn't yet compile the aspect to esm correctly\n if (err.message.includes(`Cannot use 'import.meta' outside a module`)) {\n return true;\n }\n return false;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,eAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAK,cAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,aAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAOA,SAAAM,KAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,IAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,SAAA;EAAA,MAAAP,IAAA,GAAAG,sBAAA,CAAAF,O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GAAG0G,iBAAiB,CAAC1F,GAAG,CAAE6F,CAAC,IAAKA,CAAC,CAAC1H,EAAE,CAAC;IACpD,OAAO;MAAEY,YAAY;MAAEC;IAAgB,CAAC;EAC1C;AACF;AAACsP,OAAA,CAAAnT,sBAAA,GAAAA,sBAAA;AAED,SAAS+B,wBAAwBA,CAACiE,GAAU,EAAE;EAC5C;EACA;EACA,IAAIA,GAAG,CAACmL,OAAO,CAAC3K,QAAQ,CAAC,2CAA2C,CAAC,EAAE;IACrE,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd","ignoreList":[]}
1
+ {"version":3,"names":["_legacy","data","require","_findRoot","_interopRequireDefault","_toolboxModules","_aspectLoader","_cli","_fsExtra","_harmonyModules","_workspaceModules","_componentId","_legacy2","_pMapSeries","_lodash","_bitError","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","WorkspaceAspectsLoader","constructor","workspace","scope","aspectLoader","envs","dependencyResolver","logger","configStore","harmony","onAspectsResolveSlot","onRootAspectAddedSlot","resolveAspectsFromNodeModules","resolveEnvsFromRoots","consumer","resolvedInstalledAspects","Map","hasRootComponents","loadAspects","ids","throwOnError","neededFor","opts","calculatedThrowOnError","defaultOpts","useScopeAspectsCapsule","runSubscribers","skipDeps","hideMissingModuleError","inInstallContext","ignoreErrorFunc","ignoreAspectLoadingError","ignoreErrors","forceLoad","mergedOpts","callId","Math","floor","random","loggerPrefix","profile","info","join","JSON","stringify","localAspects","nonLocalAspects","partition","id","startsWith","localAspectsMap","loadAspectFromPath","notLoadedIds","isAspectLoaded","coreAspectsStringIds","getCoreAspectIds","idsWithoutCore","difference","componentIds","resolveMultipleComponentIds","workspaceIds","nonWorkspaceIds","groupIdsByWorkspaceExistence","logFoundWorkspaceVsScope","idsToLoadFromWs","scopeAspectIds","loadFromScopeAspectsCapsule","aspectsDefs","resolveAspects","undefined","excludeCore","requestedOnly","manifests","requireableComponents","loadAspectDefsByOrder","potentialPluginsIndexes","compact","map","manifest","index","isValidAspect","pluginsRequireableComponents","pluginsManifests","getManifestsFromRequireableExtensions","loadExtensionsByManifests","manifestIds","debug","concat","currentLane","getCurrentLaneObject","nonWorkspaceIdsString","toString","packageManagerConfigRootDir","path","workspaceName","name","err","throwWsJsoncAspectNotFoundError","ComponentNotFound","config","get","configStr","workspaceConfig","raw","includes","BitError","seeders","nonWorkspaceDefs","groupAspectDefsByWorkspaceExistence","scopeAspectsLoader","getScopeAspectsLoader","scopeIds","aspectDef","getId","scopeIdsGrouped","groupAspectIdsByEnvOfTheList","aspectDefsToRequireableComponents","runtimeName","filterByRuntime","idsToResolve","extensionsIds","workspaceLocalAspectsIds","localAspectsIds","nonLocalAspectsIds","localDefs","resolveLocalAspects","coreAspectsIds","configuredAspects","getConfiguredAspects","userAspectsIds","split","rootAspectsIds","componentIdsToResolve","components","importAndGetAspects","runOnAspectsResolveFunctions","wsAspectDefs","getWorkspaceAspectResolver","coreAspectDefs","Promise","all","coreId","rawDef","getAspectDef","loadDefinition","idsToFilter","idStr","ComponentID","fromString","targetDefs","finalDefs","filterAspectDefs","groupedByIsPlugin","groupBy","component","hasPluginFiles","graph","getAspectsGraphWithoutCore","false","isAspect","bind","aspectsComponents","nodes","node","attr","true","workspaceComps","nonWorkspaceComps","groupComponentsByWorkspaceExistence","workspaceCompsIds","c","nonWorkspaceCompsIds","stringIds","linkIfMissingWorkspaceAspects","componentsToResolveFromScope","componentsToResolveFromInstalled","nonWorkspaceCompsGroups","isEnv","scopeAspectsDefs","installedAspectsDefs","getInstalledAspectResolver","coreAspect","runtimePath","localResolved","allDefsExceptLocal","withoutLocalAspects","aspectId","find","localAspect","toStringWithoutVersion","allDefs","filteredDefs","shouldUseHashForCapsules","getConfig","CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR","getCapsulePath","defaultPath","workspaceIdsStr","nonWorkspaceIdsStr","use","aspectIdStr","resolveComponentId","inWs","hasId","aspectIdToAdd","aspectsComponent","Error","setExtension","overrideExisting","ignoreVersion","write","reasonForChange","addInMemoryConfiguredAspect","runOnRootAspectAddedFunctions","getConfiguredUserAspectsPackages","options","rawConfiguredAspects","getWorkspaceConfig","componentsToGetPackages","externalsOnly","packages","aspectComponent","packageName","getPackageName","version","aspectDefs","localPath","aspectPath","requireFunc","plugins","getPlugins","has","load","MainRuntime","isModule","isEsmModule","aspect","loadEsm","getRuntimePath","RequireableComponent","aspects","idsToLink","isInWs","exist","fs","pathExists","idsToLinkWithoutNull","linkToNodeModulesByIds","workspaceAspectResolver","compStringId","getComponentPackagePath","aspectFilePath","getAspectFilePath","funcs","getOnAspectsResolveFunctions","pMapSeries","func","error","aspectsResolveFunctions","values","aspectsId","getOnRootAspectAddedFunctions","RootAspectAddedFunctions","rootIds","installedAspectsResolver","resolveInstalledAspectRecursively","aspectStringId","resolvedPath","set","parent","predecessors","parentPath","resolveFrom","findRoot","consoleWarning","message","buildOneGraphForComponents","loadComponentsExtensions","extensions","originatedFrom","extensionsIdsP","extensionEntry","extensionId","stringId","harmonyExtensions","loadedExtensions","extId","loaded","extensionsToLoad","isUsingAspectEnv","isUsingEnvEnv","loadOpts","idsToNotLoadAsAspects","importAndGetMany","existOnWorkspace","rootComps","nonRootComps","groupComponentsByLoadFromRootComps","shouldLoadFromRootComps","rootDir","rootDirExist","aspectFilePathExist","pluginFiles","getPluginFiles","hasEnvManifest","workspaceDefs","scopeComponents","exports"],"sources":["workspace-aspects-loader.ts"],"sourcesContent":["import { CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR } from '@teambit/legacy.constants';\nimport findRoot from 'find-root';\nimport { resolveFrom } from '@teambit/toolbox.modules.module-resolver';\nimport { Graph } from '@teambit/graph.cleargraph';\nimport { ExtensionDataList } from '@teambit/legacy.extension-data';\nimport { ExtensionManifest, Harmony, Aspect } from '@teambit/harmony';\nimport {\n AspectDefinition,\n AspectLoaderMain,\n AspectResolver,\n getAspectDef,\n ResolvedAspect,\n} from '@teambit/aspect-loader';\nimport { MainRuntime } from '@teambit/cli';\nimport fs from 'fs-extra';\nimport { RequireableComponent } from '@teambit/harmony.modules.requireable-component';\nimport { linkToNodeModulesByIds } from '@teambit/workspace.modules.node-modules-linker';\nimport { ComponentID } from '@teambit/component-id';\nimport { ComponentNotFound } from '@teambit/legacy.scope';\nimport pMapSeries from 'p-map-series';\nimport { difference, compact, groupBy, partition } from 'lodash';\nimport { Consumer } from '@teambit/legacy.consumer';\nimport { Component, LoadAspectsOptions, ResolveAspectsOptions } from '@teambit/component';\nimport { ScopeMain } from '@teambit/scope';\nimport { Logger } from '@teambit/logger';\nimport { BitError } from '@teambit/bit-error';\nimport { EnvsMain } from '@teambit/envs';\nimport { ConfigMain } from '@teambit/config';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { ShouldLoadFunc } from './build-graph-from-fs';\nimport type { Workspace } from './workspace';\nimport {\n OnAspectsResolve,\n OnAspectsResolveSlot,\n OnRootAspectAdded,\n OnRootAspectAddedSlot,\n} from './workspace.main.runtime';\nimport { ComponentLoadOptions } from './workspace-component/workspace-component-loader';\nimport { ConfigStoreMain } from '@teambit/config-store';\n\nexport type GetConfiguredUserAspectsPackagesOptions = {\n externalsOnly?: boolean;\n};\n\nexport type WorkspaceLoadAspectsOptions = LoadAspectsOptions & {\n useScopeAspectsCapsule?: boolean;\n runSubscribers?: boolean;\n skipDeps?: boolean;\n resolveEnvsFromRoots?: boolean;\n};\n\nexport type AspectPackage = { packageName: string; version: string };\n\nexport class WorkspaceAspectsLoader {\n private consumer: Consumer;\n private resolvedInstalledAspects: Map<string, string | null>;\n\n constructor(\n private workspace: Workspace,\n private scope: ScopeMain,\n private aspectLoader: AspectLoaderMain,\n private envs: EnvsMain,\n private dependencyResolver: DependencyResolverMain,\n private logger: Logger,\n private configStore: ConfigStoreMain,\n private harmony: Harmony,\n private onAspectsResolveSlot: OnAspectsResolveSlot,\n private onRootAspectAddedSlot: OnRootAspectAddedSlot,\n private resolveAspectsFromNodeModules = false,\n private resolveEnvsFromRoots = false\n ) {\n this.consumer = this.workspace.consumer;\n this.resolvedInstalledAspects = new Map();\n // Only enable this when root components is enabled as well\n this.resolveEnvsFromRoots = this.resolveEnvsFromRoots && this.dependencyResolver.hasRootComponents();\n }\n\n /**\n * load aspects from the workspace and if not exists in the workspace, load from the node_modules.\n * keep in mind that the graph may have circles.\n */\n async loadAspects(\n ids: string[] = [],\n throwOnError?: boolean,\n neededFor?: string,\n opts: WorkspaceLoadAspectsOptions = {}\n ): Promise<string[]> {\n const calculatedThrowOnError: boolean = throwOnError ?? false;\n const defaultOpts: Required<WorkspaceLoadAspectsOptions> = {\n useScopeAspectsCapsule: false,\n throwOnError: calculatedThrowOnError,\n runSubscribers: true,\n skipDeps: false,\n hideMissingModuleError: !!this.workspace.inInstallContext,\n ignoreErrorFunc: this.workspace.inInstallContext ? ignoreAspectLoadingError : () => false,\n ignoreErrors: false,\n resolveEnvsFromRoots: this.resolveEnvsFromRoots,\n forceLoad: false,\n };\n const mergedOpts: Required<WorkspaceLoadAspectsOptions> = { ...defaultOpts, ...opts };\n\n // generate a random callId to be able to identify the call from the logs\n const callId = Math.floor(Math.random() * 1000);\n const loggerPrefix = `[${callId}] loadAspects,`;\n this.logger.profile(`[${callId}] workspace.loadAspects`);\n this.logger.info(`${loggerPrefix} loading ${ids.length} aspects.\nids: ${ids.join(', ')}\nneeded-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts, null, 2)}`);\n const [localAspects, nonLocalAspects] = partition(ids, (id) => id.startsWith('file:'));\n const localAspectsMap = await this.aspectLoader.loadAspectFromPath(localAspects);\n this.workspace.localAspects = { ...this.workspace.localAspects, ...localAspectsMap };\n\n let notLoadedIds = nonLocalAspects;\n if (!mergedOpts.forceLoad) {\n notLoadedIds = nonLocalAspects.filter((id) => !this.aspectLoader.isAspectLoaded(id));\n }\n if (!notLoadedIds.length) {\n this.logger.profile(`[${callId}] workspace.loadAspects`);\n return [];\n }\n const coreAspectsStringIds = this.aspectLoader.getCoreAspectIds();\n const idsWithoutCore: string[] = difference(notLoadedIds, coreAspectsStringIds);\n\n const componentIds = await this.workspace.resolveMultipleComponentIds(idsWithoutCore);\n\n const { workspaceIds, nonWorkspaceIds } = await this.groupIdsByWorkspaceExistence(\n componentIds,\n mergedOpts.resolveEnvsFromRoots\n );\n\n this.logFoundWorkspaceVsScope(loggerPrefix, workspaceIds, nonWorkspaceIds);\n let idsToLoadFromWs = componentIds;\n let scopeAspectIds: string[] = [];\n\n // TODO: hard coded use the old approach and loading from the scope capsules\n // This is because right now loading from the ws node_modules causes issues in some cases\n // like for the cloud app\n // it should be removed once we fix the issues\n if (!this.resolveAspectsFromNodeModules) {\n mergedOpts.useScopeAspectsCapsule = true;\n }\n\n if (mergedOpts.useScopeAspectsCapsule) {\n idsToLoadFromWs = workspaceIds;\n scopeAspectIds = await this.loadFromScopeAspectsCapsule(nonWorkspaceIds, throwOnError, neededFor);\n }\n\n const aspectsDefs = await this.resolveAspects(undefined, idsToLoadFromWs, {\n excludeCore: true,\n requestedOnly: false,\n ...mergedOpts,\n });\n\n const { manifests, requireableComponents } = await this.loadAspectDefsByOrder(\n aspectsDefs,\n idsWithoutCore,\n mergedOpts.throwOnError,\n mergedOpts.hideMissingModuleError,\n mergedOpts.ignoreErrorFunc,\n neededFor,\n mergedOpts.runSubscribers\n );\n\n const potentialPluginsIndexes = compact(\n manifests.map((manifest, index) => {\n if (this.aspectLoader.isValidAspect(manifest)) return undefined;\n return index;\n })\n );\n\n // Try require components for potential plugins\n const pluginsRequireableComponents = potentialPluginsIndexes.map((index) => {\n return requireableComponents[index];\n });\n // Do the require again now that the plugins defs already registered\n const pluginsManifests = await this.aspectLoader.getManifestsFromRequireableExtensions(\n pluginsRequireableComponents,\n throwOnError,\n opts.runSubscribers\n );\n await this.aspectLoader.loadExtensionsByManifests(pluginsManifests, undefined, { throwOnError });\n const manifestIds = manifests.map((manifest) => manifest.id);\n this.logger.debug(`${loggerPrefix} finish loading aspects`);\n this.logger.profile(`[${callId}] workspace.loadAspects`);\n return compact(manifestIds.concat(scopeAspectIds));\n }\n\n private async loadFromScopeAspectsCapsule(ids: ComponentID[], throwOnError?: boolean, neededFor?: string) {\n let scopeAspectIds: string[] = [];\n const currentLane = await this.consumer.getCurrentLaneObject();\n\n if (!ids.length) return [];\n\n const nonWorkspaceIdsString = ids.map((id) => id.toString());\n try {\n scopeAspectIds = await this.scope.loadAspects(nonWorkspaceIdsString, throwOnError, neededFor, currentLane, {\n packageManagerConfigRootDir: this.workspace.path,\n workspaceName: this.workspace.name,\n });\n return scopeAspectIds;\n } catch (err: any) {\n this.throwWsJsoncAspectNotFoundError(err);\n return scopeAspectIds;\n\n throw err;\n }\n }\n\n throwWsJsoncAspectNotFoundError(err: any) {\n if (err instanceof ComponentNotFound) {\n const config = this.harmony.get<ConfigMain>('teambit.harmony/config');\n const configStr = JSON.stringify(config.workspaceConfig?.raw || {});\n if (configStr.includes(err.id)) {\n throw new BitError(`error: a component \"${err.id}\" was not found\nyour workspace.jsonc has this component-id set. you might want to remove/change it.`);\n }\n }\n }\n\n private async loadAspectDefsByOrder(\n aspectsDefs: AspectDefinition[],\n seeders: string[],\n throwOnError: boolean,\n hideMissingModuleError: boolean,\n ignoreErrorFunc?: (err: Error) => boolean,\n neededFor?: string,\n runSubscribers = true\n ): Promise<{ manifests: Array<Aspect | ExtensionManifest>; requireableComponents: RequireableComponent[] }> {\n const { nonWorkspaceDefs } = await this.groupAspectDefsByWorkspaceExistence(aspectsDefs);\n const scopeAspectsLoader = this.scope.getScopeAspectsLoader();\n const scopeIds: string[] = compact(nonWorkspaceDefs.map((aspectDef) => aspectDef.getId));\n const scopeIdsGrouped = await scopeAspectsLoader.groupAspectIdsByEnvOfTheList(scopeIds);\n\n // Make sure to first load envs from the list otherwise it will fail when trying to load other aspects\n // as their envs might not be loaded yet\n if (scopeIdsGrouped.envs && scopeIdsGrouped.envs.length && !runSubscribers) {\n await this.scope.loadAspects(scopeIdsGrouped.envs, throwOnError, 'workspace.loadAspects loading scope aspects');\n }\n const requireableComponents = this.aspectDefsToRequireableComponents(aspectsDefs);\n const manifests = await this.aspectLoader.getManifestsFromRequireableExtensions(\n requireableComponents,\n throwOnError,\n runSubscribers\n );\n await this.aspectLoader.loadExtensionsByManifests(\n manifests,\n { seeders, neededFor },\n { throwOnError, hideMissingModuleError, ignoreErrorFunc }\n );\n return { manifests, requireableComponents };\n }\n\n async resolveAspects(\n runtimeName?: string,\n componentIds?: ComponentID[],\n opts?: ResolveAspectsOptions\n ): Promise<AspectDefinition[]> {\n const callId = Math.floor(Math.random() * 1000);\n const loggerPrefix = `[${callId}] workspace resolveAspects,`;\n\n this.logger.debug(\n `${loggerPrefix}, resolving aspects for - runtimeName: ${runtimeName}, componentIds: ${componentIds}`\n );\n const defaultOpts: ResolveAspectsOptions = {\n excludeCore: false,\n requestedOnly: false,\n filterByRuntime: true,\n useScopeAspectsCapsule: false,\n workspaceName: this.workspace.name,\n resolveEnvsFromRoots: this.resolveEnvsFromRoots,\n packageManagerConfigRootDir: this.workspace.path,\n };\n const mergedOpts = { ...defaultOpts, ...opts };\n const idsToResolve = componentIds ? componentIds.map((id) => id.toString()) : this.harmony.extensionsIds;\n const workspaceLocalAspectsIds = Object.keys(this.workspace.localAspects);\n const [localAspectsIds, nonLocalAspectsIds] = partition(idsToResolve, (id) =>\n workspaceLocalAspectsIds.includes(id)\n );\n\n const localDefs = await this.aspectLoader.resolveLocalAspects(\n localAspectsIds.map((id) => this.workspace.localAspects[id]),\n runtimeName\n );\n const coreAspectsIds = this.aspectLoader.getCoreAspectIds();\n const configuredAspects = this.aspectLoader.getConfiguredAspects();\n // it's possible that componentIds are core-aspects that got version for some reason, remove the version to\n // correctly filter them out later.\n const userAspectsIds: string[] = nonLocalAspectsIds\n ? nonLocalAspectsIds.filter((id) => !coreAspectsIds.includes(id.split('@')[0])).map((id) => id.toString())\n : difference(this.harmony.extensionsIds, coreAspectsIds);\n const rootAspectsIds: string[] = difference(configuredAspects, coreAspectsIds);\n const componentIdsToResolve = await this.workspace.resolveMultipleComponentIds(userAspectsIds);\n const components = await this.importAndGetAspects(componentIdsToResolve, opts?.throwOnError);\n // Run the on load slot\n await this.runOnAspectsResolveFunctions(components);\n\n if (opts?.skipDeps) {\n const wsAspectDefs = await this.aspectLoader.resolveAspects(\n components,\n this.getWorkspaceAspectResolver([], runtimeName)\n );\n\n const coreAspectDefs = await Promise.all(\n coreAspectsIds.map(async (coreId) => {\n const rawDef = await getAspectDef(coreId, runtimeName);\n return this.aspectLoader.loadDefinition(rawDef);\n })\n );\n\n const idsToFilter = idsToResolve.map((idStr) => ComponentID.fromString(idStr));\n const targetDefs = wsAspectDefs.concat(coreAspectDefs).concat(localDefs);\n const finalDefs = this.aspectLoader.filterAspectDefs(targetDefs, idsToFilter, runtimeName, mergedOpts);\n\n return finalDefs;\n }\n\n const groupedByIsPlugin = groupBy(components, (component) => {\n return this.aspectLoader.hasPluginFiles(component);\n });\n const graph = await this.getAspectsGraphWithoutCore(groupedByIsPlugin.false, this.isAspect.bind(this));\n const aspectsComponents = graph.nodes.map((node) => node.attr).concat(groupedByIsPlugin.true || []);\n this.logger.debug(`${loggerPrefix} found ${aspectsComponents.length} aspects in the aspects-graph`);\n const { workspaceComps, nonWorkspaceComps } = await this.groupComponentsByWorkspaceExistence(\n aspectsComponents,\n mergedOpts.resolveEnvsFromRoots\n );\n\n const workspaceCompsIds = workspaceComps.map((c) => c.id);\n const nonWorkspaceCompsIds = nonWorkspaceComps.map((c) => c.id);\n this.logFoundWorkspaceVsScope(loggerPrefix, workspaceCompsIds, nonWorkspaceCompsIds);\n\n const stringIds: string[] = [];\n const wsAspectDefs = await this.aspectLoader.resolveAspects(\n workspaceComps,\n this.getWorkspaceAspectResolver(stringIds, runtimeName)\n );\n\n await this.linkIfMissingWorkspaceAspects(wsAspectDefs);\n\n // TODO: hard coded use the old approach and loading from the scope capsules\n // This is because right now loading from the ws node_modules causes issues in some cases\n // like for the cloud app\n // it should be removed once we fix the issues\n if (!this.resolveAspectsFromNodeModules) {\n mergedOpts.useScopeAspectsCapsule = true;\n }\n\n let componentsToResolveFromScope = nonWorkspaceComps;\n let componentsToResolveFromInstalled: Component[] = [];\n if (!mergedOpts.useScopeAspectsCapsule) {\n const nonWorkspaceCompsGroups = groupBy(nonWorkspaceComps, (component) => this.envs.isEnv(component));\n componentsToResolveFromScope = nonWorkspaceCompsGroups.true || [];\n componentsToResolveFromInstalled = nonWorkspaceCompsGroups.false || [];\n }\n\n const scopeIds = componentsToResolveFromScope.map((c) => c.id);\n this.logger.debug(\n `${loggerPrefix} ${\n scopeIds.length\n } components are not in the workspace and are loaded from the scope capsules:\\n${scopeIds\n .map((id) => id.toString())\n .join('\\n')}`\n );\n const scopeAspectsDefs: AspectDefinition[] = scopeIds.length\n ? await this.scope.resolveAspects(runtimeName, scopeIds, mergedOpts)\n : [];\n\n this.logger.debug(\n `${loggerPrefix} ${\n componentsToResolveFromInstalled.length\n } components are not in the workspace and are loaded from the node_modules:\\n${componentsToResolveFromInstalled\n .map((c) => c.id.toString())\n .join('\\n')}`\n );\n const installedAspectsDefs: AspectDefinition[] = componentsToResolveFromInstalled.length\n ? await this.aspectLoader.resolveAspects(\n componentsToResolveFromInstalled,\n this.getInstalledAspectResolver(graph, rootAspectsIds, runtimeName, {\n throwOnError: opts?.throwOnError ?? false,\n })\n )\n : [];\n\n let coreAspectDefs = await Promise.all(\n coreAspectsIds.map(async (coreId) => {\n const rawDef = await getAspectDef(coreId, runtimeName);\n return this.aspectLoader.loadDefinition(rawDef);\n })\n );\n\n // due to lack of workspace and scope runtimes. TODO: fix after adding them.\n if (runtimeName && mergedOpts.filterByRuntime) {\n coreAspectDefs = coreAspectDefs.filter((coreAspect) => {\n return coreAspect.runtimePath;\n });\n }\n const localResolved = await this.aspectLoader.resolveLocalAspects(\n Object.keys(this.workspace.localAspects),\n runtimeName\n );\n const allDefsExceptLocal = [...wsAspectDefs, ...coreAspectDefs, ...scopeAspectsDefs, ...installedAspectsDefs];\n const withoutLocalAspects = allDefsExceptLocal.filter((aspectId) => {\n return !localResolved.find((localAspect) => {\n return localAspect.id === aspectId.component?.id?.toStringWithoutVersion();\n });\n });\n const allDefs = [...withoutLocalAspects, ...localResolved];\n const idsToFilter = idsToResolve.map((idStr) => ComponentID.fromString(idStr));\n const filteredDefs = this.aspectLoader.filterAspectDefs(allDefs, idsToFilter, runtimeName, mergedOpts);\n return filteredDefs;\n }\n\n shouldUseHashForCapsules(): boolean {\n return !this.configStore.getConfig(CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR);\n }\n\n getCapsulePath() {\n const defaultPath = this.workspace.path;\n return this.configStore.getConfig(CFG_CAPSULES_BUILD_COMPONENTS_BASE_DIR) || defaultPath;\n }\n\n private logFoundWorkspaceVsScope(loggerPrefix: string, workspaceIds: ComponentID[], nonWorkspaceIds: ComponentID[]) {\n const workspaceIdsStr = workspaceIds.length ? workspaceIds.map((id) => id.toString()).join('\\n') : '';\n const nonWorkspaceIdsStr = nonWorkspaceIds.length ? nonWorkspaceIds.map((id) => id.toString()).join('\\n') : '';\n this.logger.debug(\n `${loggerPrefix} found ${workspaceIds.length} components in the workspace, ${nonWorkspaceIds.length} not in the workspace`\n );\n if (workspaceIdsStr) this.logger.debug(`${loggerPrefix} workspace components:\\n${workspaceIdsStr}`);\n if (nonWorkspaceIdsStr)\n this.logger.debug(\n `${loggerPrefix} non workspace components (loaded from the scope capsules or from the node_modules):\\n${nonWorkspaceIdsStr}`\n );\n }\n\n async use(aspectIdStr: string): Promise<string> {\n let aspectId = await this.workspace.resolveComponentId(aspectIdStr);\n const inWs = await this.workspace.hasId(aspectId);\n let aspectIdToAdd = aspectId.toStringWithoutVersion();\n\n let aspectsComponent;\n // let aspectPackage;\n if (!inWs) {\n const aspectsComponents = await this.importAndGetAspects([aspectId]);\n if (aspectsComponents[0]) {\n aspectsComponent = aspectsComponents[0];\n aspectId = aspectsComponent.id;\n aspectIdToAdd = aspectId.toString();\n }\n }\n\n const config = this.harmony.get<ConfigMain>('teambit.harmony/config').workspaceConfig;\n if (!config) {\n throw new Error(`use() unable to get the workspace config`);\n }\n config.setExtension(\n aspectIdToAdd,\n {},\n {\n overrideExisting: false,\n ignoreVersion: false,\n }\n );\n await config.write({ reasonForChange: `use (${aspectIdStr})` });\n this.aspectLoader.addInMemoryConfiguredAspect(aspectIdToAdd);\n await this.runOnRootAspectAddedFunctions(aspectId, inWs);\n return aspectIdToAdd;\n }\n\n async getConfiguredUserAspectsPackages(\n options: GetConfiguredUserAspectsPackagesOptions = {}\n ): Promise<AspectPackage[]> {\n const rawConfiguredAspects = this.workspace.getWorkspaceConfig()?.extensionsIds;\n const coreAspectsIds = this.aspectLoader.getCoreAspectIds();\n const userAspectsIds: string[] = difference(rawConfiguredAspects, coreAspectsIds);\n const componentIdsToResolve = await this.workspace.resolveMultipleComponentIds(\n userAspectsIds.filter((id) => !id.startsWith('file:'))\n );\n const aspectsComponents = await this.importAndGetAspects(componentIdsToResolve);\n let componentsToGetPackages = aspectsComponents;\n if (options.externalsOnly) {\n const { nonWorkspaceComps } = await this.groupComponentsByWorkspaceExistence(aspectsComponents);\n componentsToGetPackages = nonWorkspaceComps;\n }\n const packages = componentsToGetPackages.map((aspectComponent) => {\n const packageName = this.dependencyResolver.getPackageName(aspectComponent);\n const version = aspectComponent.id.version || '*';\n return { packageName, version };\n });\n return packages;\n }\n\n private aspectDefsToRequireableComponents(aspectDefs: AspectDefinition[]): RequireableComponent[] {\n const requireableComponents = aspectDefs.map((aspectDef) => {\n const localPath = aspectDef.aspectPath;\n const component = aspectDef.component;\n if (!component) return undefined;\n const requireFunc = async () => {\n const plugins = this.aspectLoader.getPlugins(component, localPath);\n if (plugins.has()) {\n return plugins.load(MainRuntime.name);\n }\n\n const isModule = await this.aspectLoader.isEsmModule(localPath);\n\n const aspect = !isModule\n ? // eslint-disable-next-line global-require, import/no-dynamic-require\n require(localPath)\n : // : await this.aspectLoader.loadEsm(join(localPath, 'dist', 'index.js'));\n await this.aspectLoader.loadEsm(localPath);\n\n // require aspect runtimes\n const runtimePath = await this.aspectLoader.getRuntimePath(component, localPath, MainRuntime.name);\n if (runtimePath) {\n if (isModule) await this.aspectLoader.loadEsm(runtimePath);\n // eslint-disable-next-line global-require, import/no-dynamic-require\n require(runtimePath);\n }\n return aspect;\n };\n return new RequireableComponent(component, requireFunc);\n });\n return compact(requireableComponents);\n }\n\n private async linkIfMissingWorkspaceAspects(aspects: AspectDefinition[]) {\n const idsToLink = await Promise.all(\n aspects.map(async (aspect) => {\n if (!aspect.component)\n throw new Error(`linkIfMissingWorkspaceAspects, aspect.component is missing for ${aspect.aspectPath}`);\n const isInWs = await this.workspace.hasId(aspect.component.id);\n if (!isInWs) return null;\n const exist = await fs.pathExists(aspect.aspectPath);\n if (!exist) return aspect.component.id;\n return null;\n })\n );\n const idsToLinkWithoutNull = compact(idsToLink);\n if (!idsToLinkWithoutNull.length) return;\n await linkToNodeModulesByIds(this.workspace, idsToLinkWithoutNull);\n }\n\n /**\n * This will return a resolver that knows to resolve aspects which are part of the workspace.\n * means aspects exist in the bitmap file\n * @param stringIds\n * @param runtimeName\n * @returns\n */\n private getWorkspaceAspectResolver(stringIds: string[], runtimeName?: string): AspectResolver {\n const workspaceAspectResolver = async (component: Component): Promise<ResolvedAspect> => {\n const compStringId = component.id.toString();\n stringIds.push(compStringId);\n const localPath = await this.workspace.getComponentPackagePath(component);\n\n const runtimePath = runtimeName\n ? await this.aspectLoader.getRuntimePath(component, localPath, runtimeName)\n : null;\n\n const aspectFilePath = await this.aspectLoader.getAspectFilePath(component, localPath);\n\n this.logger.debug(\n `workspace resolveAspects, resolving id: ${compStringId}, localPath: ${localPath}, runtimePath: ${runtimePath}`\n );\n return {\n aspectPath: localPath,\n aspectFilePath,\n runtimePath,\n };\n };\n return workspaceAspectResolver;\n }\n\n private async runOnAspectsResolveFunctions(aspectsComponents: Component[]): Promise<void> {\n const funcs = this.getOnAspectsResolveFunctions();\n await pMapSeries(funcs, async (func) => {\n try {\n await func(aspectsComponents);\n } catch (err) {\n this.logger.error('failed running onAspectsResolve function', err);\n }\n });\n }\n\n private getOnAspectsResolveFunctions(): OnAspectsResolve[] {\n const aspectsResolveFunctions = this.onAspectsResolveSlot.values();\n return aspectsResolveFunctions;\n }\n\n private async runOnRootAspectAddedFunctions(aspectsId: ComponentID, inWs: boolean): Promise<void> {\n const funcs = this.getOnRootAspectAddedFunctions();\n await pMapSeries(funcs, async (func) => {\n try {\n await func(aspectsId, inWs);\n } catch (err) {\n this.logger.error('failed running onRootAspectAdded function', err);\n }\n });\n }\n\n private getOnRootAspectAddedFunctions(): OnRootAspectAdded[] {\n const RootAspectAddedFunctions = this.onRootAspectAddedSlot.values();\n return RootAspectAddedFunctions;\n }\n\n /**\n * This will return a resolver that knows to resolve aspects which are not part of the workspace.\n * means aspects that does not exist in the bitmap file\n * instead it will resolve them from the node_modules recursively\n * @param graph\n * @param rootIds\n * @param runtimeName\n * @returns\n */\n private getInstalledAspectResolver(\n graph: Graph<Component, string>,\n rootIds: string[],\n runtimeName?: string,\n opts: { throwOnError: boolean } = { throwOnError: false }\n ): AspectResolver {\n const installedAspectsResolver = async (component: Component): Promise<ResolvedAspect | undefined> => {\n const compStringId = component.id.toString();\n // stringIds.push(compStringId);\n const localPath = await this.resolveInstalledAspectRecursively(component, rootIds, graph, opts);\n if (!localPath) return undefined;\n\n const runtimePath = runtimeName\n ? await this.aspectLoader.getRuntimePath(component, localPath, runtimeName)\n : null;\n\n const aspectFilePath = await this.aspectLoader.getAspectFilePath(component, localPath);\n\n this.logger.debug(\n `workspace resolveInstalledAspects, resolving id: ${compStringId}, localPath: ${localPath}, runtimePath: ${runtimePath}`\n );\n return {\n aspectPath: localPath,\n aspectFilePath,\n runtimePath,\n };\n };\n return installedAspectsResolver;\n }\n\n private async resolveInstalledAspectRecursively(\n aspectComponent: Component,\n rootIds: string[],\n graph: Graph<Component, string>,\n opts: { throwOnError: boolean } = { throwOnError: false }\n ): Promise<string | null | undefined> {\n const aspectStringId = aspectComponent.id.toString();\n if (this.resolvedInstalledAspects.has(aspectStringId)) {\n const resolvedPath = this.resolvedInstalledAspects.get(aspectStringId);\n return resolvedPath;\n }\n if (rootIds.includes(aspectStringId)) {\n const localPath = await this.workspace.getComponentPackagePath(aspectComponent);\n this.resolvedInstalledAspects.set(aspectStringId, localPath);\n return localPath;\n }\n const parent = graph.predecessors(aspectStringId)[0];\n if (!parent) return undefined;\n const parentPath = await this.resolveInstalledAspectRecursively(parent.attr, rootIds, graph);\n if (!parentPath) {\n this.resolvedInstalledAspects.set(aspectStringId, null);\n return undefined;\n }\n const packageName = this.dependencyResolver.getPackageName(aspectComponent);\n try {\n const resolvedPath = resolveFrom(parentPath, [packageName]);\n const localPath = findRoot(resolvedPath);\n this.resolvedInstalledAspects.set(aspectStringId, localPath);\n return localPath;\n } catch (error: any) {\n this.resolvedInstalledAspects.set(aspectStringId, null);\n if (opts.throwOnError) {\n throw error;\n }\n this.logger.consoleWarning(\n `failed resolving aspect ${aspectStringId} from ${parentPath}, error: ${error.message}`\n );\n return undefined;\n }\n }\n\n /**\n * Create a graph of aspects without the core aspects.\n * @param components\n * @param isAspect\n * @returns\n */\n private async getAspectsGraphWithoutCore(\n components: Component[] = [],\n isAspect?: ShouldLoadFunc\n ): Promise<Graph<Component, string>> {\n const ids = components.map((component) => component.id);\n const coreAspectsStringIds = this.aspectLoader.getCoreAspectIds();\n // TODO: @gilad it causes many issues we need to find a better solution. removed for now.\n // const coreAspectsComponentIds = coreAspectsStringIds.map((id) => ComponentID.fromString(id));\n // const aspectsIds = components.reduce((acc, curr) => {\n // const currIds = curr.state.aspects.ids;\n // acc = acc.concat(currIds);\n // return acc;\n // }, [] as any);\n // const otherDependenciesMap = components.reduce((acc, curr) => {\n // // const currIds = curr.state.dependencies.dependencies.map(dep => dep.id.toString());\n // const currMap = curr.state.dependencies.getIdsMap();\n // Object.assign(acc, currMap);\n // return acc;\n // }, {});\n\n // const depsWhichAreNotAspects = difference(Object.keys(otherDependenciesMap), aspectsIds);\n // const depsWhichAreNotAspectsBitIds = depsWhichAreNotAspects.map((strId) => otherDependenciesMap[strId]);\n // We only want to load into the graph components which are aspects and not regular dependencies\n // This come to solve a circular loop when an env aspect use an aspect (as regular dep) and the aspect use the env aspect as its env\n return this.workspace.buildOneGraphForComponents(ids, coreAspectsStringIds, isAspect);\n }\n\n /**\n * Load all unloaded extensions from an extension list\n * this will resolve the extensions from the scope aspects capsules if they are not in the ws\n * Only use it for component extensions\n * for workspace/scope root aspect use the load aspects directly\n *\n * The reason we are loading component extensions with \"scope aspects capsules\" is because for component extensions\n * we might have the same extension in multiple versions\n * (for example I might have 2 components using different versions of the same env)\n * in such case, I can't install both version into the root of the node_modules so I need to place it somewhere else (capsules)\n * @param extensions list of extensions with config to load\n */\n async loadComponentsExtensions(\n extensions: ExtensionDataList,\n originatedFrom?: ComponentID,\n opts: WorkspaceLoadAspectsOptions = {}\n ): Promise<void> {\n const defaultOpts: WorkspaceLoadAspectsOptions = {\n useScopeAspectsCapsule: true,\n throwOnError: false,\n hideMissingModuleError: !!this.workspace.inInstallContext,\n ignoreErrorFunc: this.workspace.inInstallContext ? ignoreAspectLoadingError : undefined,\n resolveEnvsFromRoots: this.resolveEnvsFromRoots,\n };\n const mergedOpts = { ...defaultOpts, ...opts };\n const extensionsIdsP = extensions.map(async (extensionEntry) => {\n // Core extension\n if (!extensionEntry.extensionId) {\n return extensionEntry.stringId as string;\n }\n\n const id = await this.workspace.resolveComponentId(extensionEntry.extensionId);\n // return this.resolveComponentId(extensionEntry.extensionId);\n return id.toString();\n });\n const extensionsIds: string[] = await Promise.all(extensionsIdsP);\n const harmonyExtensions = this.harmony.extensionsIds;\n const loadedExtensions = harmonyExtensions.filter((extId) => {\n return this.harmony.extensions.get(extId)?.loaded;\n });\n const extensionsToLoad = difference(extensionsIds, loadedExtensions);\n if (!extensionsToLoad.length) return;\n await this.loadAspects(extensionsToLoad, undefined, originatedFrom?.toString(), mergedOpts);\n }\n\n private async isAspect(id: ComponentID) {\n const component = await this.workspace.get(id);\n const isUsingAspectEnv = this.envs.isUsingAspectEnv(component);\n const isUsingEnvEnv = this.envs.isUsingEnvEnv(component);\n const isValidAspect = isUsingAspectEnv || isUsingEnvEnv;\n return isValidAspect;\n }\n\n /**\n * same as `this.importAndGetMany()` with a specific error handling of ComponentNotFound\n */\n private async importAndGetAspects(componentIds: ComponentID[], throwOnError = true): Promise<Component[]> {\n try {\n // We don't want to load the seeders as aspects as it will cause an infinite loop\n // once you try to load the seeder it will try to load the workspace component\n // that will arrive here again and again\n const loadOpts: ComponentLoadOptions = {\n idsToNotLoadAsAspects: componentIds.map((id) => id.toString()),\n };\n return await this.workspace.importAndGetMany(\n componentIds,\n 'to load aspects from the workspace',\n loadOpts,\n throwOnError\n );\n } catch (err: any) {\n this.throwWsJsoncAspectNotFoundError(err);\n\n throw err;\n }\n }\n\n /**\n * split the provided components into 2 groups, one which are workspace components and the other which are not.\n * @param components\n * @returns\n */\n private async groupComponentsByWorkspaceExistence(\n components: Component[],\n resolveEnvsFromRoots?: boolean\n ): Promise<{ workspaceComps: Component[]; nonWorkspaceComps: Component[] }> {\n let workspaceComps: Component[] = [];\n let nonWorkspaceComps: Component[] = [];\n await Promise.all(\n components.map(async (component) => {\n const existOnWorkspace = await this.workspace.hasId(component.id);\n existOnWorkspace ? workspaceComps.push(component) : nonWorkspaceComps.push(component);\n })\n );\n if (resolveEnvsFromRoots) {\n const { rootComps, nonRootComps } = await this.groupComponentsByLoadFromRootComps(nonWorkspaceComps);\n workspaceComps = workspaceComps.concat(rootComps);\n nonWorkspaceComps = nonRootComps;\n }\n return { workspaceComps, nonWorkspaceComps };\n }\n\n private async groupComponentsByLoadFromRootComps(\n components: Component[]\n ): Promise<{ rootComps: Component[]; nonRootComps: Component[] }> {\n const rootComps: Component[] = [];\n const nonRootComps: Component[] = [];\n await Promise.all(\n components.map(async (component) => {\n const shouldLoadFromRootComps = await this.shouldLoadFromRootComps(component);\n if (shouldLoadFromRootComps) {\n rootComps.push(component);\n return;\n }\n nonRootComps.push(component);\n })\n );\n return { rootComps, nonRootComps };\n }\n\n private async shouldLoadFromRootComps(component: Component): Promise<boolean> {\n const rootDir = await this.workspace.getComponentPackagePath(component);\n const rootDirExist = await fs.pathExists(rootDir);\n const aspectFilePath = await this.aspectLoader.getAspectFilePath(component, rootDir);\n const aspectFilePathExist = aspectFilePath ? await fs.pathExists(aspectFilePath) : false;\n const pluginFiles = await this.aspectLoader.getPluginFiles(component, rootDir);\n\n // checking that we have the root dir (this means it's an aspect that needs to be loaded from there)\n // and validate that localPathExist so we can\n // really load the component from that path (if it's there it means that it's an env)\n if (rootDirExist && (aspectFilePathExist || pluginFiles.length)) {\n return true;\n }\n // If the component has env.jsonc we want to list it to be loaded from the root folder\n // even if it's not there yet\n // in that case we will fail to load it, and the user will need to run bit install\n if (this.envs.hasEnvManifest(component)) {\n return true;\n }\n return false;\n }\n\n /**\n * split the provided components into 2 groups, one which are workspace components and the other which are not.\n * @param components\n * @returns\n */\n private async groupAspectDefsByWorkspaceExistence(\n aspectDefs: AspectDefinition[]\n ): Promise<{ workspaceDefs: AspectDefinition[]; nonWorkspaceDefs: AspectDefinition[] }> {\n const workspaceDefs: AspectDefinition[] = [];\n const nonWorkspaceDefs: AspectDefinition[] = [];\n await Promise.all(\n aspectDefs.map(async (aspectDef) => {\n const id = aspectDef.component?.id;\n const existOnWorkspace = id ? await this.workspace.hasId(id) : true;\n if (existOnWorkspace) {\n workspaceDefs.push(aspectDef);\n return;\n }\n const shouldLoadFromRootComps = aspectDef.component\n ? await this.shouldLoadFromRootComps(aspectDef.component)\n : undefined;\n if (shouldLoadFromRootComps) {\n workspaceDefs.push(aspectDef);\n return;\n }\n nonWorkspaceDefs.push(aspectDef);\n })\n );\n return { workspaceDefs, nonWorkspaceDefs };\n }\n\n private async groupIdsByWorkspaceExistence(\n ids: ComponentID[],\n resolveEnvsFromRoots?: boolean\n ): Promise<{ workspaceIds: ComponentID[]; nonWorkspaceIds: ComponentID[] }> {\n let workspaceIds: ComponentID[] = [];\n let nonWorkspaceIds: ComponentID[] = [];\n await Promise.all(\n ids.map(async (id) => {\n const existOnWorkspace = await this.workspace.hasId(id);\n existOnWorkspace ? workspaceIds.push(id) : nonWorkspaceIds.push(id);\n })\n );\n // We need to bring the components in order to really group them with taking the root comps into account\n const scopeComponents = await this.importAndGetAspects(nonWorkspaceIds);\n const { nonWorkspaceComps, workspaceComps } = await this.groupComponentsByWorkspaceExistence(\n scopeComponents,\n resolveEnvsFromRoots\n );\n workspaceIds = workspaceIds.concat(workspaceComps.map((c) => c.id));\n nonWorkspaceIds = nonWorkspaceComps.map((c) => c.id);\n return { workspaceIds, nonWorkspaceIds };\n }\n}\n\nfunction ignoreAspectLoadingError(err: Error) {\n // Ignoring that error as probably we are in the middle of the installation process\n // so we didn't yet compile the aspect to esm correctly\n if (err.message.includes(`Cannot use 'import.meta' outside a module`)) {\n return true;\n }\n return false;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,eAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAK,cAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,aAAA,YAAAA,CAAA;IAAA,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E0G,iBAAiB;MAAED;IAAe,CAAC,GAAG,MAAM,IAAI,CAACE,mCAAmC,CAC1F0I,eAAe,EACfrS,oBACF,CAAC;IACD+C,YAAY,GAAGA,YAAY,CAAC2B,MAAM,CAAC+E,cAAc,CAACzF,GAAG,CAAE6F,CAAC,IAAKA,CAAC,CAAC1H,EAAE,CAAC,CAAC;IACnEa,eAAe,GAAG0G,iBAAiB,CAAC1F,GAAG,CAAE6F,CAAC,IAAKA,CAAC,CAAC1H,EAAE,CAAC;IACpD,OAAO;MAAEY,YAAY;MAAEC;IAAgB,CAAC;EAC1C;AACF;AAACsP,OAAA,CAAAnT,sBAAA,GAAAA,sBAAA;AAED,SAAS+B,wBAAwBA,CAACiE,GAAU,EAAE;EAC5C;EACA;EACA,IAAIA,GAAG,CAACmL,OAAO,CAAC3K,QAAQ,CAAC,2CAA2C,CAAC,EAAE;IACrE,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd","ignoreList":[]}
@@ -39,6 +39,7 @@ import { MergeConflictFile } from './merge-conflict-file';
39
39
  import { CompFiles } from './workspace-component/comp-files';
40
40
  import { Filter } from './filter';
41
41
  import { ComponentStatusLegacy, ComponentStatusResult } from './workspace-component/component-status-loader';
42
+ import { ConfigStoreMain, Store } from '@teambit/config-store';
42
43
  export type EjectConfResult = {
43
44
  configPath: string;
44
45
  };
@@ -112,6 +113,7 @@ export declare class Workspace implements ComponentFactory {
112
113
  private graphql;
113
114
  private onBitmapChangeSlot;
114
115
  private onWorkspaceConfigChangeSlot;
116
+ private configStore;
115
117
  private warnedAboutMisconfiguredEnvs;
116
118
  priority: boolean;
117
119
  owner?: string;
@@ -168,7 +170,7 @@ export declare class Workspace implements ComponentFactory {
168
170
  /**
169
171
  * on component add slot.
170
172
  */
171
- onComponentAddSlot: OnComponentAddSlot, onComponentRemoveSlot: OnComponentRemoveSlot, onAspectsResolveSlot: OnAspectsResolveSlot, onRootAspectAddedSlot: OnRootAspectAddedSlot, graphql: GraphqlMain, onBitmapChangeSlot: OnBitmapChangeSlot, onWorkspaceConfigChangeSlot: OnWorkspaceConfigChangeSlot);
173
+ onComponentAddSlot: OnComponentAddSlot, onComponentRemoveSlot: OnComponentRemoveSlot, onAspectsResolveSlot: OnAspectsResolveSlot, onRootAspectAddedSlot: OnRootAspectAddedSlot, graphql: GraphqlMain, onBitmapChangeSlot: OnBitmapChangeSlot, onWorkspaceConfigChangeSlot: OnWorkspaceConfigChangeSlot, configStore: ConfigStoreMain);
172
174
  private validateConfig;
173
175
  get componentList(): ComponentsList;
174
176
  /**
@@ -196,6 +198,7 @@ export declare class Workspace implements ComponentFactory {
196
198
  */
197
199
  get name(): string;
198
200
  get icon(): string;
201
+ getConfigStore(): Store;
199
202
  getAutoTagInfo(changedComponents: ComponentIdList): Promise<import("./auto-tag").AutoTagResult[]>;
200
203
  listAutoTagPendingComponentIds(): Promise<ComponentID[]>;
201
204
  hasModifiedDependencies(component: Component): Promise<boolean>;
package/dist/workspace.js CHANGED
@@ -312,6 +312,13 @@ function _autoTag() {
312
312
  };
313
313
  return data;
314
314
  }
315
+ function _configStore() {
316
+ const data = require("@teambit/config-store");
317
+ _configStore = function () {
318
+ return data;
319
+ };
320
+ return data;
321
+ }
315
322
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
316
323
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
317
324
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -356,7 +363,7 @@ class Workspace {
356
363
  /**
357
364
  * on component add slot.
358
365
  */
359
- onComponentAddSlot, onComponentRemoveSlot, onAspectsResolveSlot, onRootAspectAddedSlot, graphql, onBitmapChangeSlot, onWorkspaceConfigChangeSlot) {
366
+ onComponentAddSlot, onComponentRemoveSlot, onAspectsResolveSlot, onRootAspectAddedSlot, graphql, onBitmapChangeSlot, onWorkspaceConfigChangeSlot, configStore) {
360
367
  this.config = config;
361
368
  this.consumer = consumer;
362
369
  this.scope = scope;
@@ -377,6 +384,7 @@ class Workspace {
377
384
  this.graphql = graphql;
378
385
  this.onBitmapChangeSlot = onBitmapChangeSlot;
379
386
  this.onWorkspaceConfigChangeSlot = onWorkspaceConfigChangeSlot;
387
+ this.configStore = configStore;
380
388
  _defineProperty(this, "warnedAboutMisconfiguredEnvs", []);
381
389
  // cache env-ids that have been errored about not having "env" type
382
390
  _defineProperty(this, "priority", true);
@@ -503,6 +511,38 @@ class Workspace {
503
511
  get icon() {
504
512
  return this.config.icon;
505
513
  }
514
+ getConfigStore() {
515
+ return {
516
+ list: () => this.getWorkspaceConfig().extension(_configStore().ConfigStoreAspect.id, true) || {},
517
+ set: (key, value) => {
518
+ this.getWorkspaceConfig().setExtension(_configStore().ConfigStoreAspect.id, {
519
+ [key]: value
520
+ }, {
521
+ ignoreVersion: true,
522
+ mergeIntoExisting: true
523
+ });
524
+ },
525
+ del: key => {
526
+ const current = this.getWorkspaceConfig().extension(_configStore().ConfigStoreAspect.id, true) || {};
527
+ delete current[key];
528
+ this.getWorkspaceConfig().setExtension(_configStore().ConfigStoreAspect.id, current, {
529
+ ignoreVersion: true,
530
+ overrideExisting: true
531
+ });
532
+ },
533
+ write: async () => {
534
+ await this.getWorkspaceConfig().write({
535
+ reasonForChange: 'store-config changes'
536
+ });
537
+ },
538
+ invalidateCache: async () => {
539
+ // no need to invalidate anything.
540
+ // if this is the same process, it'll get the updated one already.
541
+ // if this is another process, it'll react to "this.triggerOnWorkspaceConfigChange()" anyway.
542
+ },
543
+ getPath: () => this.getWorkspaceConfig().path
544
+ };
545
+ }
506
546
  async getAutoTagInfo(changedComponents) {
507
547
  return (0, _autoTag().getAutoTagInfo)(this.consumer, changedComponents);
508
548
  }
@@ -983,6 +1023,7 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
983
1023
  const configOfDepResolverAspect = workspaceConfig.extensions.findExtension(_dependencyResolver().DependencyResolverAspect.id);
984
1024
  if (configOfDepResolverAspect) this.dependencyResolver.setConfig(configOfDepResolverAspect.config);
985
1025
  this.dependencyResolver.clearCache();
1026
+ this.configStore.invalidateCache();
986
1027
  const onWorkspaceConfigChangeEntries = this.onWorkspaceConfigChangeSlot.toArray(); // e.g. [ [ 'teambit.bit/compiler', [Function: bound onComponentChange] ] ]
987
1028
  await (0, _pMapSeries().default)(onWorkspaceConfigChangeEntries, async ([, onWorkspaceConfigFunc]) => {
988
1029
  await onWorkspaceConfigFunc();
@@ -1668,13 +1709,13 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1668
1709
  getWorkspaceAspectsLoader() {
1669
1710
  let resolveEnvsFromRoots = this.config.resolveEnvsFromRoots;
1670
1711
  if (resolveEnvsFromRoots === undefined) {
1671
- const resolveEnvsFromRootsConfig = this.globalConfig.getSync(_legacy5().CFG_DEFAULT_RESOLVE_ENVS_FROM_ROOTS);
1712
+ const resolveEnvsFromRootsConfig = this.configStore.getConfig(_legacy5().CFG_DEFAULT_RESOLVE_ENVS_FROM_ROOTS);
1672
1713
  const defaultResolveEnvsFromRoots =
1673
1714
  // @ts-ignore
1674
1715
  resolveEnvsFromRootsConfig === 'true' || resolveEnvsFromRootsConfig === true;
1675
1716
  resolveEnvsFromRoots = defaultResolveEnvsFromRoots;
1676
1717
  }
1677
- const workspaceAspectsLoader = new (_workspaceAspectsLoader().WorkspaceAspectsLoader)(this, this.scope, this.aspectLoader, this.envs, this.dependencyResolver, this.logger, this.globalConfig, this.harmony, this.onAspectsResolveSlot, this.onRootAspectAddedSlot, this.config.resolveAspectsFromNodeModules, resolveEnvsFromRoots);
1718
+ const workspaceAspectsLoader = new (_workspaceAspectsLoader().WorkspaceAspectsLoader)(this, this.scope, this.aspectLoader, this.envs, this.dependencyResolver, this.logger, this.configStore, this.harmony, this.onAspectsResolveSlot, this.onRootAspectAddedSlot, this.config.resolveAspectsFromNodeModules, resolveEnvsFromRoots);
1678
1719
  return workspaceAspectsLoader;
1679
1720
  }
1680
1721
  getCapsulePath() {
@@ -1756,7 +1797,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1756
1797
  }
1757
1798
  async resolveComponentIdFromRegistryManifest(packageName, errMsgPrefix) {
1758
1799
  const url = `https://node-registry.bit.cloud/${packageName}`;
1759
- const token = await this.globalConfig.get(_legacy5().CFG_USER_TOKEN_KEY);
1800
+ const token = this.configStore.getConfig(_legacy5().CFG_USER_TOKEN_KEY);
1760
1801
  const headers = token ? (0, _scope2().getAuthHeader)(token) : {};
1761
1802
  const res = await (0, _scope2().fetchWithAgent)(url, {
1762
1803
  headers