@teambit/workspace 0.0.635 → 0.0.639
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/{__preview-1643340137110.js → __preview-1643772133658.js} +0 -0
- package/dist/bit-map.d.ts +1 -1
- package/dist/bit-map.js +19 -4
- package/dist/bit-map.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/workspace-component/workspace-component-loader.js +5 -2
- package/dist/workspace-component/workspace-component-loader.js.map +1 -1
- package/dist/workspace.d.ts +10 -1
- package/dist/workspace.js +70 -16
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.provider.js +3 -1
- package/dist/workspace.provider.js.map +1 -1
- package/package-tar/teambit-workspace-0.0.639.tgz +0 -0
- package/package.json +27 -27
- package/workspace-component/workspace-component-loader.ts +3 -4
- package/package-tar/teambit-workspace-0.0.635.tgz +0 -0
|
File without changes
|
package/dist/bit-map.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare class BitMap {
|
|
|
17
17
|
* returns a boolean indicating whether a change has been made.
|
|
18
18
|
*/
|
|
19
19
|
addComponentConfig(id: ComponentID, aspectId: string, config?: Record<string, any>): boolean;
|
|
20
|
-
removeComponentConfig(id: ComponentID, aspectId: string): boolean;
|
|
20
|
+
removeComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): boolean;
|
|
21
21
|
/**
|
|
22
22
|
* write .bitmap object to the filesystem
|
|
23
23
|
*/
|
package/dist/bit-map.js
CHANGED
|
@@ -17,6 +17,16 @@ function _lodash() {
|
|
|
17
17
|
return data;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
function _config() {
|
|
21
|
+
const data = require("@teambit/legacy/dist/consumer/config");
|
|
22
|
+
|
|
23
|
+
_config = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
/**
|
|
21
31
|
* consider extracting to a new component.
|
|
22
32
|
* (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace)
|
|
@@ -54,18 +64,23 @@ class BitMap {
|
|
|
54
64
|
return true; // changes have been made
|
|
55
65
|
}
|
|
56
66
|
|
|
57
|
-
removeComponentConfig(id, aspectId) {
|
|
67
|
+
removeComponentConfig(id, aspectId, markWithMinusIfNotExist) {
|
|
58
68
|
if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);
|
|
59
69
|
const bitMapEntry = this.getBitmapEntry(id, {
|
|
60
70
|
ignoreScopeAndVersion: true
|
|
61
71
|
});
|
|
62
72
|
const currentConfig = (bitMapEntry.config || (bitMapEntry.config = {}))[aspectId];
|
|
63
73
|
|
|
64
|
-
if (
|
|
65
|
-
|
|
74
|
+
if (currentConfig) {
|
|
75
|
+
delete bitMapEntry.config[aspectId];
|
|
76
|
+
} else {
|
|
77
|
+
if (!markWithMinusIfNotExist) {
|
|
78
|
+
return false; // no changes
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
bitMapEntry.config[aspectId] = _config().REMOVE_EXTENSION_SPECIAL_SIGN;
|
|
66
82
|
}
|
|
67
83
|
|
|
68
|
-
delete bitMapEntry.config[aspectId];
|
|
69
84
|
this.legacyBitMap.markAsChanged();
|
|
70
85
|
return true; // changes have been made
|
|
71
86
|
}
|
package/dist/bit-map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["bit-map.ts"],"names":["BitMap","constructor","legacyBitMap","consumer","addComponentConfig","id","aspectId","config","Error","bitMapEntry","getBitmapEntry","ignoreScopeAndVersion","currentConfig","markAsChanged","removeComponentConfig","write","writeBitMap","ignoreVersion","getComponent","_legacy","renameNewComponent","sourceId","targetId","hasVersion","toString","removeComponent","setComponent"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAMA;AACA;AACA;AACA;AACO,MAAMA,MAAN,CAAa;AAClBC,EAAAA,WAAW,CAASC,YAAT,EAA6CC,QAA7C,EAAiE;AAAA,SAAxDD,YAAwD,GAAxDA,YAAwD;AAAA,SAApBC,QAAoB,GAApBA,QAAoB;AAAE;AAE9E;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,kBAAkB,CAACC,EAAD,EAAkBC,QAAlB,EAAoCC,MAA2B,GAAG,EAAlE,EAA+E;AAC/F,QAAI,CAACD,QAAD,IAAa,OAAOA,QAAP,KAAoB,QAArC,EAA+C,MAAM,IAAIE,KAAJ,CAAW,qCAAoCF,QAAS,EAAxD,CAAN;AAC/C,UAAMG,WAAW,GAAG,KAAKC,cAAL,CAAoBL,EAApB,EAAwB;AAAEM,MAAAA,qBAAqB,EAAE;AAAzB,KAAxB,CAApB;AACA,UAAMC,aAAa,GAAG,CAACH,WAAW,CAACF,MAAb,KAACE,WAAW,CAACF,MAAb,GAAwB,EAAxB,GAA4BD,QAA5B,CAAtB;;AACA,QAAI,uBAAQM,aAAR,EAAuBL,MAAvB,CAAJ,EAAoC;AAClC,aAAO,KAAP,CADkC,CACpB;AACf;;AACD,QAAI,CAACA,MAAL,EAAa;AACX,aAAOE,WAAW,CAACF,MAAZ,CAAmBD,QAAnB,CAAP;AACD,KAFD,MAEO;AACLG,MAAAA,WAAW,CAACF,MAAZ,CAAmBD,QAAnB,IAA+BC,MAA/B;AACD;;AACD,SAAKL,YAAL,CAAkBW,aAAlB;AAEA,WAAO,IAAP,CAd+F,CAclF;AACd;;AAEDC,EAAAA,qBAAqB,CAACT,EAAD,EAAkBC,QAAlB,
|
|
1
|
+
{"version":3,"sources":["bit-map.ts"],"names":["BitMap","constructor","legacyBitMap","consumer","addComponentConfig","id","aspectId","config","Error","bitMapEntry","getBitmapEntry","ignoreScopeAndVersion","currentConfig","markAsChanged","removeComponentConfig","markWithMinusIfNotExist","REMOVE_EXTENSION_SPECIAL_SIGN","write","writeBitMap","ignoreVersion","getComponent","_legacy","renameNewComponent","sourceId","targetId","hasVersion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AKxB,YAAL,CAAkByB,eAAlB,CAAkClB,WAAW,CAACJ,EAA9C;AACAI,IAAAA,WAAW,CAACJ,EAAZ,GAAiBmB,QAAQ,CAACH,OAA1B;AACA,SAAKnB,YAAL,CAAkB0B,YAAlB,CAA+BnB,WAAW,CAACJ,EAA3C,EAA+CI,WAA/C;AACD;;AAvEiB","sourcesContent":["import { isEqual } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport LegacyBitMap from '@teambit/legacy/dist/consumer/bit-map';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { GetBitMapComponentOptions } from '@teambit/legacy/dist/consumer/bit-map/bit-map';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\n/**\n * consider extracting to a new component.\n * (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace)\n */\nexport class BitMap {\n constructor(private legacyBitMap: LegacyBitMap, private consumer: Consumer) {}\n\n /**\n * adds component config to the .bitmap file.\n * later, upon `bit tag`, the data is saved in the scope.\n * returns a boolean indicating whether a change has been made.\n */\n addComponentConfig(id: ComponentID, aspectId: string, config: Record<string, any> = {}): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (isEqual(currentConfig, config)) {\n return false; // no changes\n }\n if (!config) {\n delete bitMapEntry.config[aspectId];\n } else {\n bitMapEntry.config[aspectId] = config;\n }\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n removeComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (currentConfig) {\n delete bitMapEntry.config[aspectId];\n } else {\n if (!markWithMinusIfNotExist) {\n return false; // no changes\n }\n bitMapEntry.config[aspectId] = REMOVE_EXTENSION_SPECIAL_SIGN;\n }\n\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n /**\n * write .bitmap object to the filesystem\n */\n async write() {\n await this.consumer.writeBitMap();\n }\n\n /**\n * get the data saved in the .bitmap file for this component-id.\n */\n getBitmapEntry(\n id: ComponentID,\n { ignoreVersion, ignoreScopeAndVersion }: GetBitMapComponentOptions = {}\n ): ComponentMap {\n return this.legacyBitMap.getComponent(id._legacy, { ignoreVersion, ignoreScopeAndVersion });\n }\n\n /**\n * components that were not tagged yet are safe to rename them from the .bitmap file.\n */\n renameNewComponent(sourceId: ComponentID, targetId: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(sourceId);\n if (bitMapEntry.id.hasVersion()) {\n throw new Error(`unable to rename tagged or exported component: ${bitMapEntry.id.toString()}`);\n }\n this.legacyBitMap.removeComponent(bitMapEntry.id);\n bitMapEntry.id = targetId._legacy;\n this.legacyBitMap.setComponent(bitMapEntry.id, bitMapEntry);\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WorkspaceAspect } from './workspace.aspect';
|
|
2
|
-
export type { default as Workspace } from './workspace';
|
|
2
|
+
export type { default as Workspace, ExtensionsOrigin } from './workspace';
|
|
3
3
|
export type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';
|
|
4
4
|
export type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';
|
|
5
5
|
export type { WorkspaceMain } from './workspace.main.runtime';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":["WorkspaceAspect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAQA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;eAIeA,4B","sourcesContent":["import { WorkspaceAspect } from './workspace.aspect';\n// eslint-disable-next-line import/prefer-default-export\nexport type { default as Workspace } from './workspace';\n// TODO: change to module path once track the utils folder\nexport type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';\nexport type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';\nexport type { WorkspaceMain } from './workspace.main.runtime';\nexport type { WatchOptions } from './watch/watcher';\nexport { CheckTypes } from './watch/check-types';\nexport * from './events';\nexport type { WorkspaceUI } from './workspace.ui.runtime';\nexport type { SerializableResults, OnComponentEventResult } from './on-component-events';\nexport { ComponentStatus } from './workspace-component';\nexport { WorkspaceModelComponent } from './ui/workspace/workspace-model';\nexport { WorkspaceContext } from './ui/workspace/workspace-context';\nexport type { WorkspaceComponent } from './workspace-component';\n\nexport { WorkspaceAspect };\nexport default WorkspaceAspect;\n"]}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["WorkspaceAspect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAQA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;eAIeA,4B","sourcesContent":["import { WorkspaceAspect } from './workspace.aspect';\n// eslint-disable-next-line import/prefer-default-export\nexport type { default as Workspace, ExtensionsOrigin } from './workspace';\n// TODO: change to module path once track the utils folder\nexport type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';\nexport type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';\nexport type { WorkspaceMain } from './workspace.main.runtime';\nexport type { WatchOptions } from './watch/watcher';\nexport { CheckTypes } from './watch/check-types';\nexport * from './events';\nexport type { WorkspaceUI } from './workspace.ui.runtime';\nexport type { SerializableResults, OnComponentEventResult } from './on-component-events';\nexport { ComponentStatus } from './workspace-component';\nexport { WorkspaceModelComponent } from './ui/workspace/workspace-model';\nexport { WorkspaceContext } from './ui/workspace/workspace-context';\nexport type { WorkspaceComponent } from './workspace-component';\n\nexport { WorkspaceAspect };\nexport default WorkspaceAspect;\n"]}
|
|
@@ -320,12 +320,15 @@ class WorkspaceComponentLoader {
|
|
|
320
320
|
return componentFromScope;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
|
|
323
|
+
const {
|
|
324
|
+
extensions
|
|
325
|
+
} = await this.workspace.componentExtensions(id, componentFromScope);
|
|
324
326
|
const extensionsFromConsumerComponent = consumerComponent.extensions || new (_extensionData().ExtensionDataList)(); // Merge extensions added by the legacy code in memory (for example data of dependency resolver)
|
|
325
327
|
|
|
326
|
-
extensionDataList = _extensionData().ExtensionDataList.mergeConfigs([extensionsFromConsumerComponent,
|
|
328
|
+
const extensionDataList = _extensionData().ExtensionDataList.mergeConfigs([extensionsFromConsumerComponent, extensions]).filterRemovedExtensions(); // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data
|
|
327
329
|
// TODO: remove this once we remove all direct access from legacy code to extensions data
|
|
328
330
|
|
|
331
|
+
|
|
329
332
|
consumerComponent.extensions = extensionDataList;
|
|
330
333
|
const state = new (_component().State)(new (_component().Config)(consumerComponent.mainFile, extensionDataList), await this.workspace.createAspectList(extensionDataList), _component().ComponentFS.fromVinyls(consumerComponent.files), consumerComponent.dependencies, consumerComponent);
|
|
331
334
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["workspace-component-loader.ts"],"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","maxSize","componentsCacheForCapsule","getMany","ids","forCapsule","idsWithoutEmpty","errors","longProcessLogger","createLongProcessLogger","length","componentsP","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","consumer","isLegacy","console","warn","filteredComponents","end","getInvalid","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","delete","componentFromScope","MissingBitMapComponent","extensionDataList","componentExtensions","extensionsFromConsumerComponent","extensions","ExtensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","set","isEqual","loadComponentForCapsule","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","upsertExtensionData","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","extractDepsFromLegacy","depResolverData","serialize","EnvsAspect","DependencyResolverAspect","Promise","all","updatedAspectList","aspects","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AA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KAAV,CAAgBqD,MAAhB,CAAuBrC,UAAvB,CAAkCxD,IAAlC,CAAuC,MAAM,KAAK4G,YAAL,CAAkBtB,SAAlB,EAA6BzC,IAA7B,CAA7C;AACD;;AAEyB,QAAZ+D,YAAY,CAACtB,SAAD,EAAoBzC,IAApB,EAA+E;AACvG;AACA,WAAO,KAAIgE,4BAAJ,EAAuB5G,SAAvB,EAAkCA,SAAlC,EAA6CqF,SAA7C,EAAwDrF,SAAxD,EAAmE4C,IAAnE,CAAP;AACD;;AA1QmC","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, 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 { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n private componentsCacheForCapsule: InMemoryCache<Component>; // cache loaded components for capsule, must not use the cache for the workspace\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 this.componentsCacheForCapsule = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, forCapsule = false): 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, forCapsule).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 if (!this.workspace.consumer.isLegacy) {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n }\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 forCapsule = false,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true\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, forCapsule);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id, forCapsule));\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);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, forCapsule);\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 this.componentsCacheForCapsule.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n this.componentsCache.delete(idStr);\n this.componentsCacheForCapsule.delete(idStr);\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent) {\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\n let extensionDataList = 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 extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensionDataList,\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 return this.executeLoadSlot(workspaceComponent);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state));\n }\n\n private saveInCache(component: Component, forCapsule: boolean): void {\n if (forCapsule) {\n this.componentsCacheForCapsule.set(component.id.toString(), component);\n } else {\n this.componentsCache.set(component.id.toString(), component);\n }\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, forCapsule: boolean): Component | undefined {\n const fromCache = forCapsule\n ? this.componentsCacheForCapsule.get(id.toString())\n : this.componentsCache.get(id.toString());\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID, forCapsule = false): Promise<ConsumerComponent | undefined> {\n try {\n return forCapsule\n ? // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponentForCapsule(id._legacy)\n : // eslint-disable-next-line @typescript-eslint/return-await\n 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) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component);\n return this.upsertExtensionData(component, extension, data);\n });\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions);\n const dependencies = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n dependencies,\n policy: policy.serialize(),\n };\n\n promises.push(this.upsertExtensionData(component, EnvsAspect.id, envsData));\n promises.push(this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData));\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 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"]}
|
|
1
|
+
{"version":3,"sources":["workspace-component-loader.ts"],"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","maxSize","componentsCacheForCapsule","getMany","ids","forCapsule","idsWithoutEmpty","errors","longProcessLogger","createLongProcessLogger","length","componentsP","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","consumer","isLegacy","console","warn","filteredComponents","end","getInvalid","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","delete","componentFromScope","MissingBitMapComponent","extensions","componentExtensions","extensionsFromConsumerComponent","ExtensionDataList","extensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","set","isEqual","loadComponentForCapsule","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","upsertExtensionData","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","extractDepsFromLegacy","depResolverData","serialize","EnvsAspect","DependencyResolverAspect","Promise","all","updatedAspectList","aspects","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AA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AACvG;AACA,WAAO,KAAIgE,4BAAJ,EAAuB5G,SAAvB,EAAkCA,SAAlC,EAA6CqF,SAA7C,EAAwDrF,SAAxD,EAAmE4C,IAAnE,CAAP;AACD;;AAzQmC","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, 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 { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n private componentsCacheForCapsule: InMemoryCache<Component>; // cache loaded components for capsule, must not use the cache for the workspace\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 this.componentsCacheForCapsule = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, forCapsule = false): 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, forCapsule).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 if (!this.workspace.consumer.isLegacy) {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n }\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 forCapsule = false,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true\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, forCapsule);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id, forCapsule));\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);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, forCapsule);\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 this.componentsCacheForCapsule.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n this.componentsCache.delete(idStr);\n this.componentsCacheForCapsule.delete(idStr);\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent) {\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 return this.executeLoadSlot(workspaceComponent);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state));\n }\n\n private saveInCache(component: Component, forCapsule: boolean): void {\n if (forCapsule) {\n this.componentsCacheForCapsule.set(component.id.toString(), component);\n } else {\n this.componentsCache.set(component.id.toString(), component);\n }\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, forCapsule: boolean): Component | undefined {\n const fromCache = forCapsule\n ? this.componentsCacheForCapsule.get(id.toString())\n : this.componentsCache.get(id.toString());\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID, forCapsule = false): Promise<ConsumerComponent | undefined> {\n try {\n return forCapsule\n ? // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponentForCapsule(id._legacy)\n : // eslint-disable-next-line @typescript-eslint/return-await\n 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) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component);\n return this.upsertExtensionData(component, extension, data);\n });\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions);\n const dependencies = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n dependencies,\n policy: policy.serialize(),\n };\n\n promises.push(this.upsertExtensionData(component, EnvsAspect.id, envsData));\n promises.push(this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData));\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 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"]}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ import { BitMap } from './bit-map';
|
|
|
38
38
|
export declare type EjectConfResult = {
|
|
39
39
|
configPath: string;
|
|
40
40
|
};
|
|
41
|
+
export declare const AspectSpecificField = "__specific";
|
|
41
42
|
export declare const ComponentAdded = "componentAdded";
|
|
42
43
|
export declare const ComponentChanged = "componentChanged";
|
|
43
44
|
export declare const ComponentRemoved = "componentRemoved";
|
|
@@ -67,6 +68,7 @@ export declare type TrackData = {
|
|
|
67
68
|
[aspectName: string]: any;
|
|
68
69
|
};
|
|
69
70
|
};
|
|
71
|
+
export declare type ExtensionsOrigin = 'BitmapFile' | 'ModelSpecific' | 'ModelNonSpecific' | 'WorkspaceVariants' | 'ComponentJsonFile' | 'WorkspaceDefault' | 'FinalAfterMerge';
|
|
70
72
|
export declare type TrackResult = {
|
|
71
73
|
componentName: string;
|
|
72
74
|
files: string[];
|
|
@@ -362,7 +364,14 @@ export declare class Workspace implements ComponentFactory {
|
|
|
362
364
|
* defaults extensions from workspace config
|
|
363
365
|
* extensions from the model.
|
|
364
366
|
*/
|
|
365
|
-
componentExtensions(componentId: ComponentID, componentFromScope?: Component): Promise<
|
|
367
|
+
componentExtensions(componentId: ComponentID, componentFromScope?: Component): Promise<{
|
|
368
|
+
extensions: ExtensionDataList;
|
|
369
|
+
beforeMerge: Array<{
|
|
370
|
+
extensions: ExtensionDataList;
|
|
371
|
+
origin: ExtensionsOrigin;
|
|
372
|
+
extraData: any;
|
|
373
|
+
}>;
|
|
374
|
+
}>;
|
|
366
375
|
private filterEnvsFromExtensionsIfNeeded;
|
|
367
376
|
triggerOnPreWatch(componentIds: ComponentID[], watchOpts: WatchOptions): Promise<void>;
|
|
368
377
|
/**
|
package/dist/workspace.js
CHANGED
|
@@ -17,7 +17,7 @@ require("core-js/modules/es.regexp.exec.js");
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", {
|
|
18
18
|
value: true
|
|
19
19
|
});
|
|
20
|
-
exports.default = exports.Workspace = exports.ComponentRemoved = exports.ComponentChanged = exports.ComponentAdded = void 0;
|
|
20
|
+
exports.default = exports.Workspace = exports.ComponentRemoved = exports.ComponentChanged = exports.ComponentAdded = exports.AspectSpecificField = void 0;
|
|
21
21
|
|
|
22
22
|
function _defineProperty2() {
|
|
23
23
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -119,6 +119,16 @@ function _bitError() {
|
|
|
119
119
|
return data;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
function _config() {
|
|
123
|
+
const data = require("@teambit/legacy/dist/consumer/config");
|
|
124
|
+
|
|
125
|
+
_config = function () {
|
|
126
|
+
return data;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
return data;
|
|
130
|
+
}
|
|
131
|
+
|
|
122
132
|
function _dependencyResolver() {
|
|
123
133
|
const data = require("@teambit/dependency-resolver");
|
|
124
134
|
|
|
@@ -490,6 +500,8 @@ function _bitMap() {
|
|
|
490
500
|
}
|
|
491
501
|
|
|
492
502
|
/* eslint-disable max-lines */
|
|
503
|
+
const AspectSpecificField = '__specific';
|
|
504
|
+
exports.AspectSpecificField = AspectSpecificField;
|
|
493
505
|
const ComponentAdded = 'componentAdded';
|
|
494
506
|
exports.ComponentAdded = ComponentAdded;
|
|
495
507
|
const ComponentChanged = 'componentChanged';
|
|
@@ -1355,6 +1367,9 @@ class Workspace {
|
|
|
1355
1367
|
let wsDefaultExtensions;
|
|
1356
1368
|
const mergeFromScope = true;
|
|
1357
1369
|
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)();
|
|
1370
|
+
const [specific, nonSpecific] = (0, _lodash().partition)(scopeExtensions, entry => entry.config[AspectSpecificField] === true);
|
|
1371
|
+
const scopeExtensionsNonSpecific = new (_extensionData().ExtensionDataList)(...nonSpecific);
|
|
1372
|
+
const scopeExtensionsSpecific = new (_extensionData().ExtensionDataList)(...specific);
|
|
1358
1373
|
const bitMapEntry = this.consumer.bitMap.getComponentIfExist(componentId._legacy);
|
|
1359
1374
|
const bitMapExtensions = bitMapEntry === null || bitMapEntry === void 0 ? void 0 : bitMapEntry.config;
|
|
1360
1375
|
const componentConfigFile = await this.componentConfigFile(componentId);
|
|
@@ -1388,8 +1403,14 @@ class Workspace {
|
|
|
1388
1403
|
|
|
1389
1404
|
const extensionsToMerge = [];
|
|
1390
1405
|
let envWasFoundPreviously = false;
|
|
1406
|
+
const removedExtensionIds = [];
|
|
1407
|
+
|
|
1408
|
+
const addAndLoadExtensions = async (extensions, origin, extraData) => {
|
|
1409
|
+
if (!extensions.length) {
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1391
1412
|
|
|
1392
|
-
|
|
1413
|
+
removedExtensionIds.push(...extensions.filter(extData => extData.isRemoved).map(extData => extData.stringId));
|
|
1393
1414
|
const extsWithoutRemoved = extensions.filterRemovedExtensions();
|
|
1394
1415
|
const selfInMergedExtensions = extsWithoutRemoved.findExtension(componentId._legacy.toStringWithoutScopeAndVersion(), true, true);
|
|
1395
1416
|
const extsWithoutSelf = selfInMergedExtensions !== null && selfInMergedExtensions !== void 0 && selfInMergedExtensions.extensionId ? extsWithoutRemoved.remove(selfInMergedExtensions.extensionId) : extsWithoutRemoved;
|
|
@@ -1399,24 +1420,44 @@ class Workspace {
|
|
|
1399
1420
|
envIsCurrentlySet
|
|
1400
1421
|
} = this.filterEnvsFromExtensionsIfNeeded(extsWithoutSelf, envWasFoundPreviously);
|
|
1401
1422
|
if (envIsCurrentlySet) envWasFoundPreviously = true;
|
|
1402
|
-
extensionsToMerge.push(
|
|
1423
|
+
extensionsToMerge.push({
|
|
1424
|
+
origin,
|
|
1425
|
+
extensions: extensionDataListFiltered,
|
|
1426
|
+
extraData
|
|
1427
|
+
});
|
|
1428
|
+
};
|
|
1429
|
+
|
|
1430
|
+
const setDataListAsSpecific = extensions => {
|
|
1431
|
+
extensions.forEach(dataEntry => dataEntry.config[AspectSpecificField] = true);
|
|
1403
1432
|
};
|
|
1404
1433
|
|
|
1405
1434
|
if (bitMapExtensions) {
|
|
1406
1435
|
const extensionsDataEntries = Object.keys(bitMapExtensions).map(aspectId => new (_extensionData().ExtensionDataEntry)(aspectId, undefined, aspectId, bitMapExtensions[aspectId]));
|
|
1407
1436
|
const extensionDataList = new (_extensionData().ExtensionDataList)(...extensionsDataEntries);
|
|
1408
|
-
|
|
1437
|
+
setDataListAsSpecific(extensionDataList);
|
|
1438
|
+
await addAndLoadExtensions(extensionDataList, 'BitmapFile');
|
|
1409
1439
|
}
|
|
1410
1440
|
|
|
1411
1441
|
if (configFileExtensions) {
|
|
1412
|
-
|
|
1442
|
+
setDataListAsSpecific(configFileExtensions);
|
|
1443
|
+
await addAndLoadExtensions(configFileExtensions, 'ComponentJsonFile');
|
|
1413
1444
|
}
|
|
1414
1445
|
|
|
1446
|
+
await addAndLoadExtensions(scopeExtensionsSpecific, 'ModelSpecific');
|
|
1415
1447
|
let continuePropagating = (_componentConfigFile$ = componentConfigFile === null || componentConfigFile === void 0 ? void 0 : componentConfigFile.propagate) !== null && _componentConfigFile$ !== void 0 ? _componentConfigFile$ : true;
|
|
1416
1448
|
|
|
1417
1449
|
if (variantsExtensions && continuePropagating) {
|
|
1418
1450
|
// Put it in the start to make sure the config file is stronger
|
|
1419
|
-
|
|
1451
|
+
const appliedRules = variantConfig === null || variantConfig === void 0 ? void 0 : variantConfig.sortedMatches.map(({
|
|
1452
|
+
pattern,
|
|
1453
|
+
specificity
|
|
1454
|
+
}) => ({
|
|
1455
|
+
pattern,
|
|
1456
|
+
specificity
|
|
1457
|
+
}));
|
|
1458
|
+
await addAndLoadExtensions(variantsExtensions, 'WorkspaceVariants', {
|
|
1459
|
+
appliedRules
|
|
1460
|
+
});
|
|
1420
1461
|
}
|
|
1421
1462
|
|
|
1422
1463
|
continuePropagating = continuePropagating && ((_variantConfig$propag = variantConfig === null || variantConfig === void 0 ? void 0 : variantConfig.propagate) !== null && _variantConfig$propag !== void 0 ? _variantConfig$propag : true); // Do not apply default extensions on the default extensions (it will create infinite loop when loading them)
|
|
@@ -1425,19 +1466,29 @@ class Workspace {
|
|
|
1425
1466
|
|
|
1426
1467
|
if (wsDefaultExtensions && continuePropagating && !isDefaultExtension) {
|
|
1427
1468
|
// Put it in the start to make sure the config file is stronger
|
|
1428
|
-
await addAndLoadExtensions(wsDefaultExtensions);
|
|
1469
|
+
await addAndLoadExtensions(wsDefaultExtensions, 'WorkspaceDefault');
|
|
1429
1470
|
} // It's before the scope extensions, since there is no need to resolve extensions from scope they are already resolved
|
|
1430
1471
|
// await Promise.all(extensionsToMerge.map((extensions) => this.resolveExtensionsList(extensions)));
|
|
1431
1472
|
|
|
1432
1473
|
|
|
1433
1474
|
if (mergeFromScope && continuePropagating) {
|
|
1434
|
-
await addAndLoadExtensions(
|
|
1475
|
+
await addAndLoadExtensions(scopeExtensionsNonSpecific, 'ModelNonSpecific');
|
|
1435
1476
|
} // It's important to do this resolution before the merge, otherwise we have issues with extensions
|
|
1436
1477
|
// coming from scope with local scope name, as opposed to the same extension comes from the workspace with default scope name
|
|
1437
1478
|
|
|
1438
1479
|
|
|
1439
|
-
await Promise.all(extensionsToMerge.map(list => this.resolveExtensionListIds(list)));
|
|
1440
|
-
|
|
1480
|
+
await Promise.all(extensionsToMerge.map(list => this.resolveExtensionListIds(list.extensions)));
|
|
1481
|
+
|
|
1482
|
+
const afterMerge = _extensionData().ExtensionDataList.mergeConfigs(extensionsToMerge.map(ext => ext.extensions));
|
|
1483
|
+
|
|
1484
|
+
const withoutRemoved = afterMerge.filter(extData => !removedExtensionIds.includes(extData.stringId));
|
|
1485
|
+
|
|
1486
|
+
const extensions = _extensionData().ExtensionDataList.fromArray(withoutRemoved);
|
|
1487
|
+
|
|
1488
|
+
return {
|
|
1489
|
+
extensions,
|
|
1490
|
+
beforeMerge: extensionsToMerge
|
|
1491
|
+
};
|
|
1441
1492
|
}
|
|
1442
1493
|
|
|
1443
1494
|
filterEnvsFromExtensionsIfNeeded(extensionDataList, envWasFoundPreviously) {
|
|
@@ -2370,10 +2421,12 @@ your workspace.jsonc has this component-id set. you might want to remove/change
|
|
|
2370
2421
|
|
|
2371
2422
|
async setEnvToComponents(envId, components) {
|
|
2372
2423
|
const envIdStr = envId.toString();
|
|
2424
|
+
const existsOnWorkspace = await this.hasId(envId);
|
|
2425
|
+
const envIdStrNoVersion = envId.toStringWithoutVersion();
|
|
2373
2426
|
components.forEach(component => {
|
|
2374
|
-
this.bitMap.addComponentConfig(component.id, envIdStr);
|
|
2427
|
+
this.bitMap.addComponentConfig(component.id, existsOnWorkspace ? envIdStrNoVersion : envIdStr);
|
|
2375
2428
|
this.bitMap.addComponentConfig(component.id, _envs().EnvsAspect.id, {
|
|
2376
|
-
env:
|
|
2429
|
+
env: envIdStrNoVersion
|
|
2377
2430
|
});
|
|
2378
2431
|
});
|
|
2379
2432
|
await this.bitMap.write();
|
|
@@ -2387,18 +2440,19 @@ your workspace.jsonc has this component-id set. you might want to remove/change
|
|
|
2387
2440
|
const changed = [];
|
|
2388
2441
|
const unchanged = [];
|
|
2389
2442
|
components.forEach(comp => {
|
|
2390
|
-
var _bitMapEntry$config
|
|
2443
|
+
var _bitMapEntry$config;
|
|
2391
2444
|
|
|
2392
2445
|
const bitMapEntry = this.bitMap.getBitmapEntry(comp.id);
|
|
2393
|
-
const
|
|
2446
|
+
const envsAspect = (_bitMapEntry$config = bitMapEntry.config) === null || _bitMapEntry$config === void 0 ? void 0 : _bitMapEntry$config[_envs().EnvsAspect.id];
|
|
2447
|
+
const currentEnv = envsAspect && envsAspect !== _config().REMOVE_EXTENSION_SPECIAL_SIGN ? envsAspect.env : null;
|
|
2394
2448
|
|
|
2395
2449
|
if (!currentEnv) {
|
|
2396
2450
|
unchanged.push(comp.id);
|
|
2397
2451
|
return;
|
|
2398
2452
|
}
|
|
2399
2453
|
|
|
2400
|
-
this.bitMap.removeComponentConfig(comp.id, currentEnv);
|
|
2401
|
-
this.bitMap.removeComponentConfig(comp.id, _envs().EnvsAspect.id);
|
|
2454
|
+
this.bitMap.removeComponentConfig(comp.id, currentEnv, false);
|
|
2455
|
+
this.bitMap.removeComponentConfig(comp.id, _envs().EnvsAspect.id, false);
|
|
2402
2456
|
changed.push(comp.id);
|
|
2403
2457
|
});
|
|
2404
2458
|
await this.bitMap.write();
|