@teambit/workspace 0.0.937 → 0.0.939
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exceptions/merge-config-conflict.d.ts +4 -0
- package/dist/exceptions/merge-config-conflict.js +21 -0
- package/dist/exceptions/merge-config-conflict.js.map +1 -0
- package/dist/{preview-1671506809302.js → preview-1671679531372.js} +2 -2
- package/dist/workspace-component/workspace-component-loader.js +13 -10
- package/dist/workspace-component/workspace-component-loader.js.map +1 -1
- package/dist/workspace.d.ts +6 -2
- package/dist/workspace.js +87 -21
- package/dist/workspace.js.map +1 -1
- package/exceptions/merge-config-conflict.ts +7 -0
- package/package-tar/teambit-workspace-0.0.939.tgz +0 -0
- package/package.json +34 -34
- package/workspace-component/workspace-component-loader.ts +8 -13
- package/package-tar/teambit-workspace-0.0.937.tgz +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MergeConfigConflict = void 0;
|
|
7
|
+
function _bitError() {
|
|
8
|
+
const data = require("@teambit/bit-error");
|
|
9
|
+
_bitError = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
class MergeConfigConflict extends _bitError().BitError {
|
|
15
|
+
constructor(filePath) {
|
|
16
|
+
super(`unable to parse the merge-config file ${filePath} as it has unresolved conflicts`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.MergeConfigConflict = MergeConfigConflict;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=merge-config-conflict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MergeConfigConflict","BitError","constructor","filePath"],"sources":["merge-config-conflict.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\n\nexport class MergeConfigConflict extends BitError {\n constructor(filePath: string) {\n super(`unable to parse the merge-config file ${filePath} as it has unresolved conflicts`);\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,mBAAmB,SAASC,oBAAQ,CAAC;EAChDC,WAAW,CAACC,QAAgB,EAAE;IAC5B,KAAK,CAAE,yCAAwCA,QAAS,iCAAgC,CAAC;EAC3F;AACF;AAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.939/dist/workspace.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.939/dist/workspace.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -127,6 +127,13 @@ function _workspaceComponent() {
|
|
|
127
127
|
};
|
|
128
128
|
return data;
|
|
129
129
|
}
|
|
130
|
+
function _mergeConfigConflict() {
|
|
131
|
+
const data = require("../exceptions/merge-config-conflict");
|
|
132
|
+
_mergeConfigConflict = function () {
|
|
133
|
+
return data;
|
|
134
|
+
};
|
|
135
|
+
return data;
|
|
136
|
+
}
|
|
130
137
|
class WorkspaceComponentLoader {
|
|
131
138
|
// cache loaded components
|
|
132
139
|
constructor(workspace, logger, dependencyResolver, envs) {
|
|
@@ -240,8 +247,12 @@ class WorkspaceComponentLoader {
|
|
|
240
247
|
return componentFromScope;
|
|
241
248
|
}
|
|
242
249
|
const {
|
|
243
|
-
extensions
|
|
250
|
+
extensions,
|
|
251
|
+
errors
|
|
244
252
|
} = await this.workspace.componentExtensions(id, componentFromScope);
|
|
253
|
+
if (errors !== null && errors !== void 0 && errors.some(err => err instanceof _mergeConfigConflict().MergeConfigConflict)) {
|
|
254
|
+
consumerComponent.issues.getOrCreate(_componentIssues().IssuesClasses.MergeConfigHasConflict).data = true;
|
|
255
|
+
}
|
|
245
256
|
const extensionsFromConsumerComponent = consumerComponent.extensions || new (_extensionData().ExtensionDataList)();
|
|
246
257
|
// Merge extensions added by the legacy code in memory (for example data of dependency resolver)
|
|
247
258
|
const extensionDataList = _extensionData().ExtensionDataList.mergeConfigs([extensionsFromConsumerComponent, extensions]).filterRemovedExtensions();
|
|
@@ -311,16 +322,8 @@ class WorkspaceComponentLoader {
|
|
|
311
322
|
// Move to deps resolver main runtime once we switch ws<> deps resolver direction
|
|
312
323
|
const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions, component.id._legacy, component.state._consumer.files);
|
|
313
324
|
const dependenciesList = await this.dependencyResolver.extractDepsFromLegacy(component, policy);
|
|
314
|
-
let dependenciesFromUnmergedHead;
|
|
315
|
-
// Get dependencies from unmerged head if needed
|
|
316
|
-
// we take it from there, as they might not be installed yet and we need to get their versions from the model
|
|
317
|
-
const unmergedComponent = await this.workspace.getUnmergedComponent(component.id);
|
|
318
|
-
if (unmergedComponent) {
|
|
319
|
-
dependenciesFromUnmergedHead = await this.dependencyResolver.extractDepsFromLegacy(unmergedComponent, policy);
|
|
320
|
-
}
|
|
321
|
-
const mergedDependencies = dependenciesFromUnmergedHead ? _dependencyResolver().DependencyList.merge([dependenciesList, dependenciesFromUnmergedHead]) : dependenciesList;
|
|
322
325
|
const depResolverData = {
|
|
323
|
-
dependencies:
|
|
326
|
+
dependencies: dependenciesList.serialize(),
|
|
324
327
|
policy: policy.serialize()
|
|
325
328
|
};
|
|
326
329
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","createInMemoryCache","maxSize","getMaxSizeForComponents","getMany","ids","loadOpts","idsWithoutEmpty","compact","errors","longProcessLogger","createLongProcessLogger","length","componentsP","mapSeries","id","logProgress","toString","get","undefined","catch","err","isComponentNotExistsError","push","components","forEach","console","warn","filteredComponents","end","getInvalid","consumer","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","getLatestVersionNumber","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","uniq","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","cacheKey","keys","startsWith","delete","componentFromScope","MissingBitMapComponent","extensions","componentExtensions","extensionsFromConsumerComponent","ExtensionDataList","extensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","updatedComp","executeLoadSlot","newComponentFromState","createComponentCacheKey","set","isEqual","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","_consumer","removed","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","dependenciesList","extractDepsFromLegacy","dependenciesFromUnmergedHead","unmergedComponent","getUnmergedComponent","mergedDependencies","DependencyList","merge","depResolverData","serialize","Promise","all","upsertExtensionData","EnvsAspect","DependencyResolverAspect","aspectListWithEnvsAndDeps","aspects","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","updatedAspectList","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry","JSON","stringify","sortKeys","obj","fromPairs","sort","k1","k2","localeCompare"],"sources":["workspace-component-loader.ts"],"sourcesContent":["import { Component, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact, fromPairs, uniq } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyList, DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, loadOpts?: ComponentLoadOptions): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id, undefined, undefined, undefined, loadOpts).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true,\n loadOpts?: ComponentLoadOptions\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, loadOpts);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent, loadOpts);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, loadOpts);\n }\n return component;\n }\n\n async getIfExist(componentId: ComponentID) {\n try {\n return await this.get(componentId);\n } catch (err: any) {\n if (this.isComponentNotExistsError(err)) {\n return undefined;\n }\n throw err;\n }\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n const envIds = uniq(envs.map((env) => env.id));\n if (envIds.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envIds;\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n for (const cacheKey of this.componentsCache.keys()) {\n if (cacheKey === idStr || cacheKey.startsWith(`${idStr}:`)) {\n this.componentsCache.delete(cacheKey);\n }\n }\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent, loadOpts?: ComponentLoadOptions) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n const { extensions } = await this.workspace.componentExtensions(id, componentFromScope);\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n const extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensions,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n const updatedComp = await this.executeLoadSlot(workspaceComponent, loadOpts);\n return updatedComp;\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state), loadOpts);\n }\n\n private saveInCache(component: Component, loadOpts?: ComponentLoadOptions): void {\n const cacheKey = createComponentCacheKey(component.id, loadOpts);\n this.componentsCache.set(cacheKey, component);\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, loadOpts?: ComponentLoadOptions): Component | undefined {\n const cacheKey = createComponentCacheKey(id, loadOpts);\n const fromCache = this.componentsCache.get(cacheKey);\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID): Promise<ConsumerComponent | undefined> {\n try {\n return await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component, loadOpts?: ComponentLoadOptions) {\n if (component.state._consumer.removed) {\n // if it was soft-removed now, the component is not in the FS. loading aspects such as composition ends up with\n // errors as they try to read component files from the filesystem.\n return component;\n }\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(\n component.config.extensions,\n component.id._legacy,\n component.state._consumer.files\n );\n const dependenciesList = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n let dependenciesFromUnmergedHead;\n // Get dependencies from unmerged head if needed\n // we take it from there, as they might not be installed yet and we need to get their versions from the model\n const unmergedComponent = await this.workspace.getUnmergedComponent(component.id);\n if (unmergedComponent) {\n dependenciesFromUnmergedHead = await this.dependencyResolver.extractDepsFromLegacy(unmergedComponent, policy);\n }\n const mergedDependencies = dependenciesFromUnmergedHead\n ? DependencyList.merge([dependenciesList, dependenciesFromUnmergedHead])\n : dependenciesList;\n\n const depResolverData = {\n dependencies: mergedDependencies.serialize(),\n policy: policy.serialize(),\n };\n\n // Make sure we are adding the envs / deps data first because other on load events might depend on it\n await Promise.all([\n this.upsertExtensionData(component, EnvsAspect.id, envsData),\n this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData),\n ]);\n\n // We are updating the component state with the envs and deps data here, so in case we have other slots that depend on this data\n // they will be able to get it, as it's very common use case that during on load someone want to access to the component env for example\n const aspectListWithEnvsAndDeps = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = aspectListWithEnvsAndDeps;\n\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component, loadOpts);\n return this.upsertExtensionData(component, extension, data);\n });\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n if (!data) return;\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n\nfunction createComponentCacheKey(id: ComponentID, loadOpts?: ComponentLoadOptions): string {\n return `${id.toString()}:${JSON.stringify(sortKeys(loadOpts ?? {}))}`;\n}\n\nfunction sortKeys(obj: Object) {\n return fromPairs(Object.entries(obj).sort(([k1], [k2]) => k1.localeCompare(k2)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,wBAAwB,CAAC;EACe;EACnDC,WAAW,CACDC,SAAoB,EACpBC,MAAc,EACdC,kBAA0C,EAC1CC,IAAc,EACtB;IAAA,KAJQH,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAA,KACdC,kBAA0C,GAA1C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;EACjF;AACF;AAAC;AAED,SAASiC,uBAAuB,CAACtF,EAAe,EAAET,QAA+B,EAAU;EACzF,OAAQ,GAAES,EAAE,CAACE,QAAQ,EAAG,IAAGkI,IAAI,CAACC,SAAS,CAACC,QAAQ,CAAC/I,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI,CAAC,CAAC,CAAC,CAAE,EAAC;AACvE;AAEA,SAAS+I,QAAQ,CAACC,GAAW,EAAE;EAC7B,OAAO,IAAAC,mBAAS,EAACR,MAAM,CAACV,OAAO,CAACiB,GAAG,CAAC,CAACE,IAAI,CAAC,CAAC,CAACC,EAAE,CAAC,EAAE,CAACC,EAAE,CAAC,KAAKD,EAAE,CAACE,aAAa,CAACD,EAAE,CAAC,CAAC,CAAC;AAClF"}
|
|
1
|
+
{"version":3,"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","createInMemoryCache","maxSize","getMaxSizeForComponents","getMany","ids","loadOpts","idsWithoutEmpty","compact","errors","longProcessLogger","createLongProcessLogger","length","componentsP","mapSeries","id","logProgress","toString","get","undefined","catch","err","isComponentNotExistsError","push","components","forEach","console","warn","filteredComponents","end","getInvalid","consumer","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","getLatestVersionNumber","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","uniq","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","cacheKey","keys","startsWith","delete","componentFromScope","MissingBitMapComponent","extensions","componentExtensions","some","MergeConfigConflict","MergeConfigHasConflict","extensionsFromConsumerComponent","ExtensionDataList","extensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","updatedComp","executeLoadSlot","newComponentFromState","createComponentCacheKey","set","isEqual","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","_consumer","removed","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","dependenciesList","extractDepsFromLegacy","depResolverData","serialize","Promise","all","upsertExtensionData","EnvsAspect","DependencyResolverAspect","aspectListWithEnvsAndDeps","aspects","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","updatedAspectList","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry","JSON","stringify","sortKeys","obj","fromPairs","sort","k1","k2","localeCompare"],"sources":["workspace-component-loader.ts"],"sourcesContent":["import { Component, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact, fromPairs, uniq } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\nimport { MergeConfigConflict } from '../exceptions/merge-config-conflict';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, loadOpts?: ComponentLoadOptions): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id, undefined, undefined, undefined, loadOpts).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true,\n loadOpts?: ComponentLoadOptions\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, loadOpts);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent, loadOpts);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, loadOpts);\n }\n return component;\n }\n\n async getIfExist(componentId: ComponentID) {\n try {\n return await this.get(componentId);\n } catch (err: any) {\n if (this.isComponentNotExistsError(err)) {\n return undefined;\n }\n throw err;\n }\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n const envIds = uniq(envs.map((env) => env.id));\n if (envIds.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envIds;\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n for (const cacheKey of this.componentsCache.keys()) {\n if (cacheKey === idStr || cacheKey.startsWith(`${idStr}:`)) {\n this.componentsCache.delete(cacheKey);\n }\n }\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent, loadOpts?: ComponentLoadOptions) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n const { extensions, errors } = await this.workspace.componentExtensions(id, componentFromScope);\n if (errors?.some((err) => err instanceof MergeConfigConflict)) {\n consumerComponent.issues.getOrCreate(IssuesClasses.MergeConfigHasConflict).data = true;\n }\n\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n const extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensions,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n const updatedComp = await this.executeLoadSlot(workspaceComponent, loadOpts);\n return updatedComp;\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state), loadOpts);\n }\n\n private saveInCache(component: Component, loadOpts?: ComponentLoadOptions): void {\n const cacheKey = createComponentCacheKey(component.id, loadOpts);\n this.componentsCache.set(cacheKey, component);\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, loadOpts?: ComponentLoadOptions): Component | undefined {\n const cacheKey = createComponentCacheKey(id, loadOpts);\n const fromCache = this.componentsCache.get(cacheKey);\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID): Promise<ConsumerComponent | undefined> {\n try {\n return await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component, loadOpts?: ComponentLoadOptions) {\n if (component.state._consumer.removed) {\n // if it was soft-removed now, the component is not in the FS. loading aspects such as composition ends up with\n // errors as they try to read component files from the filesystem.\n return component;\n }\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(\n component.config.extensions,\n component.id._legacy,\n component.state._consumer.files\n );\n const dependenciesList = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n dependencies: dependenciesList.serialize(),\n policy: policy.serialize(),\n };\n\n // Make sure we are adding the envs / deps data first because other on load events might depend on it\n await Promise.all([\n this.upsertExtensionData(component, EnvsAspect.id, envsData),\n this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData),\n ]);\n\n // We are updating the component state with the envs and deps data here, so in case we have other slots that depend on this data\n // they will be able to get it, as it's very common use case that during on load someone want to access to the component env for example\n const aspectListWithEnvsAndDeps = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = aspectListWithEnvsAndDeps;\n\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component, loadOpts);\n return this.upsertExtensionData(component, extension, data);\n });\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n if (!data) return;\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n\nfunction createComponentCacheKey(id: ComponentID, loadOpts?: ComponentLoadOptions): string {\n return `${id.toString()}:${JSON.stringify(sortKeys(loadOpts ?? {}))}`;\n}\n\nfunction sortKeys(obj: Object) {\n return fromPairs(Object.entries(obj).sort(([k1], [k2]) => k1.localeCompare(k2)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AA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AAY,CAACR,SAAiB,EAAElE,IAA4B,EAA+B;IACvG;IACA,OAAO,KAAI2E,4BAAkB,EAAC5H,SAAS,EAAEA,SAAS,EAAEmH,SAAS,EAAEnH,SAAS,EAAEiD,IAAI,CAAC;EACjF;AACF;AAAC;AAED,SAASoC,uBAAuB,CAACzF,EAAe,EAAET,QAA+B,EAAU;EACzF,OAAQ,GAAES,EAAE,CAACE,QAAQ,EAAG,IAAG+H,IAAI,CAACC,SAAS,CAACC,QAAQ,CAAC5I,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI,CAAC,CAAC,CAAC,CAAE,EAAC;AACvE;AAEA,SAAS4I,QAAQ,CAACC,GAAW,EAAE;EAC7B,OAAO,IAAAC,mBAAS,EAACR,MAAM,CAACV,OAAO,CAACiB,GAAG,CAAC,CAACE,IAAI,CAAC,CAAC,CAACC,EAAE,CAAC,EAAE,CAACC,EAAE,CAAC,KAAKD,EAAE,CAACE,aAAa,CAACD,EAAE,CAAC,CAAC,CAAC;AAClF"}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export declare type TrackData = {
|
|
|
55
55
|
[aspectName: string]: any;
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
|
-
export declare type ExtensionsOrigin = 'BitmapFile' | 'ModelSpecific' | 'ModelNonSpecific' | '
|
|
58
|
+
export declare type ExtensionsOrigin = 'BitmapFile' | 'ModelSpecific' | 'ModelNonSpecific' | 'ConfigMerge' | 'WorkspaceVariants' | 'ComponentJsonFile' | 'WorkspaceDefault' | 'FinalAfterMerge';
|
|
59
59
|
export declare type TrackResult = {
|
|
60
60
|
componentName: string;
|
|
61
61
|
files: string[];
|
|
@@ -370,9 +370,13 @@ export declare class Workspace implements ComponentFactory {
|
|
|
370
370
|
origin: ExtensionsOrigin;
|
|
371
371
|
extraData: any;
|
|
372
372
|
}>;
|
|
373
|
+
errors?: Error[];
|
|
373
374
|
}>;
|
|
374
|
-
|
|
375
|
+
getConfigMergeFilePath(componentId: ComponentID): string;
|
|
376
|
+
listComponentsDuringMerge(): Promise<ComponentID[]>;
|
|
377
|
+
private getConfigMergeFile;
|
|
375
378
|
getUnmergedComponent(componentId: ComponentID): Promise<Component | undefined>;
|
|
379
|
+
private getUnmergedData;
|
|
376
380
|
private warnAboutMisconfiguredEnv;
|
|
377
381
|
isModified(component: Component): Promise<boolean>;
|
|
378
382
|
private filterEnvsFromExtensionsIfNeeded;
|
package/dist/workspace.js
CHANGED
|
@@ -214,6 +214,13 @@ function _lodash() {
|
|
|
214
214
|
};
|
|
215
215
|
return data;
|
|
216
216
|
}
|
|
217
|
+
function _constants() {
|
|
218
|
+
const data = require("@teambit/legacy/dist/constants");
|
|
219
|
+
_constants = function () {
|
|
220
|
+
return data;
|
|
221
|
+
};
|
|
222
|
+
return data;
|
|
223
|
+
}
|
|
217
224
|
function _path2() {
|
|
218
225
|
const data = _interopRequireDefault(require("path"));
|
|
219
226
|
_path2 = function () {
|
|
@@ -312,6 +319,13 @@ function _buildGraphIdsFromFs() {
|
|
|
312
319
|
};
|
|
313
320
|
return data;
|
|
314
321
|
}
|
|
322
|
+
function _mergeConfigConflict() {
|
|
323
|
+
const data = require("./exceptions/merge-config-conflict");
|
|
324
|
+
_mergeConfigConflict = function () {
|
|
325
|
+
return data;
|
|
326
|
+
};
|
|
327
|
+
return data;
|
|
328
|
+
}
|
|
315
329
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
316
330
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
317
331
|
const AspectSpecificField = '__specific';
|
|
@@ -1209,19 +1223,46 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1209
1223
|
let variantsExtensions;
|
|
1210
1224
|
let wsDefaultExtensions;
|
|
1211
1225
|
const mergeFromScope = true;
|
|
1226
|
+
const errors = [];
|
|
1212
1227
|
const bitMapEntry = this.consumer.bitMap.getComponentIfExist(componentId._legacy);
|
|
1213
1228
|
const bitMapExtensions = bitMapEntry === null || bitMapEntry === void 0 ? void 0 : bitMapEntry.config;
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1229
|
+
let configMergeFile;
|
|
1230
|
+
try {
|
|
1231
|
+
configMergeFile = await this.getConfigMergeFile(componentId);
|
|
1232
|
+
} catch (err) {
|
|
1233
|
+
if (!(err instanceof _mergeConfigConflict().MergeConfigConflict)) {
|
|
1234
|
+
throw err;
|
|
1235
|
+
}
|
|
1236
|
+
this.logger.error(`unable to parse the config file for ${componentId.toString()} due to conflicts`);
|
|
1237
|
+
errors.push(err);
|
|
1238
|
+
}
|
|
1239
|
+
const adjustEnvsOnConfigMerge = conf => {
|
|
1240
|
+
var _conf$EnvsAspect$id;
|
|
1241
|
+
const env = (_conf$EnvsAspect$id = conf[_envs().EnvsAspect.id]) === null || _conf$EnvsAspect$id === void 0 ? void 0 : _conf$EnvsAspect$id.env;
|
|
1242
|
+
if (!env) return;
|
|
1243
|
+
const [id] = env.split('@');
|
|
1244
|
+
conf[_envs().EnvsAspect.id] = {
|
|
1245
|
+
env: id
|
|
1246
|
+
};
|
|
1247
|
+
conf[env] = {};
|
|
1248
|
+
};
|
|
1249
|
+
const unmergedData = this.getUnmergedData(componentId);
|
|
1250
|
+
const unmergedDataMergeConf = unmergedData === null || unmergedData === void 0 ? void 0 : unmergedData.mergedConfig;
|
|
1251
|
+
const getMergeConfigCombined = () => {
|
|
1252
|
+
if (!configMergeFile && !unmergedDataMergeConf) return undefined;
|
|
1253
|
+
if (!configMergeFile) return unmergedDataMergeConf;
|
|
1254
|
+
if (!unmergedDataMergeConf) return configMergeFile;
|
|
1255
|
+
return (0, _lodash().mergeWith)(configMergeFile, unmergedDataMergeConf, (objValue, srcValue) => {
|
|
1256
|
+
if (Array.isArray(objValue)) {
|
|
1257
|
+
// critical for dependencyResolver.policy.*dependencies. otherwise, it will override the array
|
|
1258
|
+
return objValue.concat(srcValue);
|
|
1259
|
+
}
|
|
1260
|
+
return undefined;
|
|
1261
|
+
});
|
|
1262
|
+
};
|
|
1263
|
+
const mergeConfigCombined = getMergeConfigCombined();
|
|
1264
|
+
adjustEnvsOnConfigMerge(mergeConfigCombined || {});
|
|
1265
|
+
const configMergeExtensions = mergeConfigCombined ? _extensionData().ExtensionDataList.fromConfigObject(mergeConfigCombined) : undefined;
|
|
1225
1266
|
const scopeExtensions = (componentFromScope === null || componentFromScope === void 0 ? void 0 : (_componentFromScope$c = componentFromScope.config) === null || _componentFromScope$c === void 0 ? void 0 : _componentFromScope$c.extensions) || new (_extensionData().ExtensionDataList)();
|
|
1226
1267
|
const [specific, nonSpecific] = (0, _lodash().partition)(scopeExtensions, entry => entry.config[AspectSpecificField] === true);
|
|
1227
1268
|
const scopeExtensionsNonSpecific = new (_extensionData().ExtensionDataList)(...nonSpecific);
|
|
@@ -1278,6 +1319,9 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1278
1319
|
const setDataListAsSpecific = extensions => {
|
|
1279
1320
|
extensions.forEach(dataEntry => dataEntry.config[AspectSpecificField] = true);
|
|
1280
1321
|
};
|
|
1322
|
+
if (configMergeExtensions && !excludeOrigins.includes('ConfigMerge')) {
|
|
1323
|
+
await addExtensionsToMerge(_extensionData().ExtensionDataList.fromArray(configMergeExtensions), 'ConfigMerge');
|
|
1324
|
+
}
|
|
1281
1325
|
if (bitMapExtensions && !excludeOrigins.includes('BitmapFile')) {
|
|
1282
1326
|
const extensionDataList = _extensionData().ExtensionDataList.fromConfigObject(bitMapExtensions);
|
|
1283
1327
|
setDataListAsSpecific(extensionDataList);
|
|
@@ -1287,9 +1331,6 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1287
1331
|
setDataListAsSpecific(configFileExtensions);
|
|
1288
1332
|
await addExtensionsToMerge(configFileExtensions, 'ComponentJsonFile');
|
|
1289
1333
|
}
|
|
1290
|
-
if (unmergedExtensionsSpecific && !excludeOrigins.includes('UnmergedSpecific')) {
|
|
1291
|
-
await addExtensionsToMerge(_extensionData().ExtensionDataList.fromArray(unmergedExtensionsSpecific), 'UnmergedSpecific');
|
|
1292
|
-
}
|
|
1293
1334
|
if (!excludeOrigins.includes('ModelSpecific')) {
|
|
1294
1335
|
await addExtensionsToMerge(_extensionData().ExtensionDataList.fromArray(scopeExtensionsSpecific), 'ModelSpecific');
|
|
1295
1336
|
}
|
|
@@ -1312,9 +1353,6 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1312
1353
|
if (wsDefaultExtensions && continuePropagating && !isDefaultExtension && !excludeOrigins.includes('WorkspaceDefault')) {
|
|
1313
1354
|
await addExtensionsToMerge(wsDefaultExtensions, 'WorkspaceDefault');
|
|
1314
1355
|
}
|
|
1315
|
-
if (unmergedExtensionsNonSpecific && mergeFromScope && continuePropagating && !excludeOrigins.includes('UnmergedNonSpecific')) {
|
|
1316
|
-
await addExtensionsToMerge(unmergedExtensionsNonSpecific, 'UnmergedNonSpecific');
|
|
1317
|
-
}
|
|
1318
1356
|
if (mergeFromScope && continuePropagating && !excludeOrigins.includes('ModelNonSpecific')) {
|
|
1319
1357
|
await addExtensionsToMerge(scopeExtensionsNonSpecific, 'ModelNonSpecific');
|
|
1320
1358
|
}
|
|
@@ -1328,12 +1366,37 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1328
1366
|
const extensions = _extensionData().ExtensionDataList.fromArray(withoutRemoved);
|
|
1329
1367
|
return {
|
|
1330
1368
|
extensions,
|
|
1331
|
-
beforeMerge: extensionsToMerge
|
|
1369
|
+
beforeMerge: extensionsToMerge,
|
|
1370
|
+
errors
|
|
1332
1371
|
};
|
|
1333
1372
|
}
|
|
1334
|
-
|
|
1335
|
-
const
|
|
1336
|
-
|
|
1373
|
+
getConfigMergeFilePath(componentId) {
|
|
1374
|
+
const compDir = this.componentDir(componentId, {
|
|
1375
|
+
ignoreVersion: true
|
|
1376
|
+
});
|
|
1377
|
+
return _path2().default.join(compDir, _constants().MergeConfigFilename);
|
|
1378
|
+
}
|
|
1379
|
+
async listComponentsDuringMerge() {
|
|
1380
|
+
const unmergedComps = this.scope.legacyScope.objects.unmergedComponents.getComponents();
|
|
1381
|
+
const bitIds = unmergedComps.map(u => new (_legacyBitId().BitId)(u.id));
|
|
1382
|
+
return this.resolveMultipleComponentIds(bitIds);
|
|
1383
|
+
}
|
|
1384
|
+
async getConfigMergeFile(componentId) {
|
|
1385
|
+
const configMergePath = this.getConfigMergeFilePath(componentId);
|
|
1386
|
+
let fileContent;
|
|
1387
|
+
try {
|
|
1388
|
+
fileContent = await _fsExtra().default.readFile(configMergePath, 'utf-8');
|
|
1389
|
+
} catch (err) {
|
|
1390
|
+
if (err.code === 'ENOENT') {
|
|
1391
|
+
return undefined;
|
|
1392
|
+
}
|
|
1393
|
+
throw err;
|
|
1394
|
+
}
|
|
1395
|
+
try {
|
|
1396
|
+
return JSON.parse(fileContent);
|
|
1397
|
+
} catch (err) {
|
|
1398
|
+
throw new (_mergeConfigConflict().MergeConfigConflict)(configMergePath);
|
|
1399
|
+
}
|
|
1337
1400
|
}
|
|
1338
1401
|
async getUnmergedComponent(componentId) {
|
|
1339
1402
|
const unmerged = this.scope.legacyScope.objects.unmergedComponents.getEntry(componentId._legacy.name);
|
|
@@ -1342,6 +1405,9 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1342
1405
|
}
|
|
1343
1406
|
return undefined;
|
|
1344
1407
|
}
|
|
1408
|
+
getUnmergedData(componentId) {
|
|
1409
|
+
return this.scope.legacyScope.objects.unmergedComponents.getEntry(componentId._legacy.name);
|
|
1410
|
+
}
|
|
1345
1411
|
async warnAboutMisconfiguredEnv(componentId, extensionDataList) {
|
|
1346
1412
|
if (!(await this.hasId(componentId))) {
|
|
1347
1413
|
// if this is a dependency and not belong to the workspace, don't show the warning
|