From ed7540bcbc44cb703122d6fba81455613dd7273f Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Sun, 14 Aug 2022 16:13:29 +0300 Subject: [PATCH 01/16] do not add extension with empty data and config to the component extension list on load --- .../workspace-component/workspace-component-loader.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts index 9887b230cd19..d12aedfb4f85 100644 --- a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts +++ b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts @@ -285,7 +285,9 @@ export class WorkspaceComponentLoader { Object.assign(existingExtension.data, data); return; } - component.state.config.extensions.push(await this.getDataEntry(extension, data)); + if (data){ + component.state.config.extensions.push(await this.getDataEntry(extension, data)); + } } private async getDataEntry(extension: string, data: { [key: string]: any }): Promise { From e551b251600169365aa1fc9dd63d4842aab446f4 Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Sun, 14 Aug 2022 16:14:46 +0300 Subject: [PATCH 02/16] add non core aspects with id rather than name when they only register data on load (and has no component's config) --- .../workspace-component/workspace-component-loader.ts | 5 +++-- src/consumer/config/extension-data.ts | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts index d12aedfb4f85..f46edc171e76 100644 --- a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts +++ b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts @@ -290,9 +290,10 @@ export class WorkspaceComponentLoader { } } - private async getDataEntry(extension: string, data: { [key: string]: any }): Promise { + private async getDataEntry(extensionId: string, data: { [key: string]: any }): Promise { // TODO: @gilad we need to refactor the extension data entry api. - return new ExtensionDataEntry(undefined, undefined, extension, undefined, data); + const entry = ExtensionDataEntry.create(extensionId, undefined, data); + return entry; } } diff --git a/src/consumer/config/extension-data.ts b/src/consumer/config/extension-data.ts index 82a7660acc40..6bde11aec98a 100644 --- a/src/consumer/config/extension-data.ts +++ b/src/consumer/config/extension-data.ts @@ -99,6 +99,16 @@ export class ExtensionDataEntry { R.clone(this.data) ); } + + static create(extensionId: string, config?: any, data?: any): ExtensionDataEntry { + // eslint-disable-next-line @typescript-eslint/no-use-before-define + const isCore = ExtensionDataList.coreExtensionsNames.has(extensionId); + if (!isCore) { + const parsedId = BitId.parse(extensionId, true); + return new ExtensionDataEntry(undefined, parsedId, undefined, config, data); + } + return new ExtensionDataEntry(undefined, undefined, extensionId, config, data); + } } export class ExtensionDataList extends Array { From 4d409137114ca1b93aaad039cb3e8a0339f660f3 Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Mon, 15 Aug 2022 22:58:39 +0300 Subject: [PATCH 03/16] fix aspect id when aspect only register data on component load but not configured on the component --- .../workspace-component/workspace-component-loader.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts index f46edc171e76..3922f546788f 100644 --- a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts +++ b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts @@ -286,7 +286,14 @@ export class WorkspaceComponentLoader { return; } if (data){ - component.state.config.extensions.push(await this.getDataEntry(extension, data)); + const dataEntry = await this.getDataEntry(extension, data); + const cloned = dataEntry.clone(); + if (cloned.extensionId) { + const compId = await this.workspace.resolveComponentId(cloned.extensionId); + cloned.extensionId = compId._legacy; + cloned.newExtensionId = compId; + } + component.state.config.extensions.push(cloned); } } From a26cab716903cad206796ca92a67ce8aa08c9364 Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Mon, 15 Aug 2022 22:59:10 +0300 Subject: [PATCH 04/16] fix find extension - compare also with new extension id --- src/consumer/config/extension-data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/consumer/config/extension-data.ts b/src/consumer/config/extension-data.ts index 6bde11aec98a..d283596e9dcd 100644 --- a/src/consumer/config/extension-data.ts +++ b/src/consumer/config/extension-data.ts @@ -169,7 +169,7 @@ export class ExtensionDataList extends Array { if (ignoreScope) { return extEntry.extensionId?.toStringWithoutScope() === extensionId; } - return extEntry.stringId === extensionId; + return extEntry.stringId === extensionId || extEntry.newExtensionId?.toString() === extensionId; }); } From fc1e91d48e53c64fd6a26649f6e82d2037179e0d Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Tue, 16 Aug 2022 13:09:43 +0300 Subject: [PATCH 05/16] increase test timeout --- scopes/component/snapping/snapping.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scopes/component/snapping/snapping.spec.ts b/scopes/component/snapping/snapping.spec.ts index 35f89c4f3e8b..586758978681 100644 --- a/scopes/component/snapping/snapping.spec.ts +++ b/scopes/component/snapping/snapping.spec.ts @@ -28,7 +28,7 @@ describe('Snapping aspect', () => { const compiler: CompilerMain = await loadAspect(CompilerAspect, workspacePath); await compiler.compileOnWorkspace(); snapping = await loadAspect(SnappingAspect, workspacePath); - }); + }, 50000); it('tag should throw an ComponentsHaveIssues error', async () => { try { await snapping.tag({ ids: ['comp1'] }); From cd3842e4b58ff0e4238f9dbda7b42f7296b58848 Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Tue, 16 Aug 2022 14:10:48 +0300 Subject: [PATCH 06/16] trying to increase timeouts in more places --- scopes/component/snapping/snapping.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scopes/component/snapping/snapping.spec.ts b/scopes/component/snapping/snapping.spec.ts index 586758978681..13ad69735362 100644 --- a/scopes/component/snapping/snapping.spec.ts +++ b/scopes/component/snapping/snapping.spec.ts @@ -35,7 +35,7 @@ describe('Snapping aspect', () => { } catch (err: any) { expect(err.constructor.name).toEqual(ComponentsHaveIssues.name); } - }); + }, 50000); // @todo: this test fails during "bit build" for some reason. It passes on "bit test"; it.skip('should not throw an error if the config was set to ignore MissingPackagesDependenciesOnFs error', async () => { await setWorkspaceConfig(workspaceData.workspacePath, IssuesAspect.id, { @@ -48,5 +48,5 @@ describe('Snapping aspect', () => { afterAll(async () => { await destroyWorkspace(workspaceData); }); - }); + }, 50000); }); From 4d133ae0907056e1b275a3db195631f8a9d22d96 Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Tue, 16 Aug 2022 14:13:20 +0300 Subject: [PATCH 07/16] remove wrong timeout --- scopes/component/snapping/snapping.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scopes/component/snapping/snapping.spec.ts b/scopes/component/snapping/snapping.spec.ts index 13ad69735362..6f49ece0d55b 100644 --- a/scopes/component/snapping/snapping.spec.ts +++ b/scopes/component/snapping/snapping.spec.ts @@ -48,5 +48,5 @@ describe('Snapping aspect', () => { afterAll(async () => { await destroyWorkspace(workspaceData); }); - }, 50000); + }); }); From fac069ef2bb34a567ba30d3a6828132e188954e2 Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Tue, 16 Aug 2022 15:14:49 +0300 Subject: [PATCH 08/16] moving jest timeout to base config --- scopes/component/snapping/snapping.spec.ts | 4 ++-- scopes/react/react/jest/jest.base.config.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scopes/component/snapping/snapping.spec.ts b/scopes/component/snapping/snapping.spec.ts index 6f49ece0d55b..35f89c4f3e8b 100644 --- a/scopes/component/snapping/snapping.spec.ts +++ b/scopes/component/snapping/snapping.spec.ts @@ -28,14 +28,14 @@ describe('Snapping aspect', () => { const compiler: CompilerMain = await loadAspect(CompilerAspect, workspacePath); await compiler.compileOnWorkspace(); snapping = await loadAspect(SnappingAspect, workspacePath); - }, 50000); + }); it('tag should throw an ComponentsHaveIssues error', async () => { try { await snapping.tag({ ids: ['comp1'] }); } catch (err: any) { expect(err.constructor.name).toEqual(ComponentsHaveIssues.name); } - }, 50000); + }); // @todo: this test fails during "bit build" for some reason. It passes on "bit test"; it.skip('should not throw an error if the config was set to ignore MissingPackagesDependenciesOnFs error', async () => { await setWorkspaceConfig(workspaceData.workspacePath, IssuesAspect.id, { diff --git a/scopes/react/react/jest/jest.base.config.js b/scopes/react/react/jest/jest.base.config.js index 7b921bd88ff2..076ec6f706af 100644 --- a/scopes/react/react/jest/jest.base.config.js +++ b/scopes/react/react/jest/jest.base.config.js @@ -26,6 +26,6 @@ module.exports = { '^.+\\.module\\.(css|sass|scss)$': require.resolve('identity-obj-proxy'), }, moduleFileExtensions: ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'], - testTimeout: 30000, // @todo remove this once mocha-tester is ready and aspect-api testing are using it. + testTimeout: 50000, // @todo remove this once mocha-tester is ready and aspect-api testing are using it. // watchPlugins: [require.resolve('jest-watch-typeahead/filename'), require.resolve('jest-watch-typeahead/testname')], }; From 36995aa6769452d5419d9fe5e8c74a3f84c82c0c Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Tue, 16 Aug 2022 16:07:02 +0300 Subject: [PATCH 09/16] types --- scopes/workspace/workspace/build-graph-from-fs.ts | 6 +++--- scopes/workspace/workspace/workspace.ts | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scopes/workspace/workspace/build-graph-from-fs.ts b/scopes/workspace/workspace/build-graph-from-fs.ts index 6ddb11f60895..1ddaf5ea8fa6 100644 --- a/scopes/workspace/workspace/build-graph-from-fs.ts +++ b/scopes/workspace/workspace/build-graph-from-fs.ts @@ -70,7 +70,7 @@ export class GraphFromFsBuilder { return this.graph; } - private getAllDepsUnfiltered(component: Component) { + private getAllDepsUnfiltered(component: Component): BitIds { return component.getAllDependenciesIds().difference(this.ignoreIds); } @@ -78,7 +78,7 @@ export class GraphFromFsBuilder { const depsWithoutIgnore = this.getAllDepsUnfiltered(component); const shouldLoadFunc = this.shouldLoadItsDeps; if (!shouldLoadFunc) return depsWithoutIgnore; - const deps = await mapSeries(depsWithoutIgnore, async (depId) => { + const deps = await mapSeries(depsWithoutIgnore, async (depId: BitId) => { const shouldLoad = await shouldLoadFunc(depId); if (!shouldLoad) this.ignoreIds.push(depId); return shouldLoad ? depId : null; @@ -111,7 +111,7 @@ export class GraphFromFsBuilder { const allIds = await this.getAllDepsFiltered(component); const allDependencies = await this.loadManyComponents(allIds, idStr); - Object.entries(component.depsIdsGroupedByType).forEach(([depType, depsIds]) => { + Object.entries(component.depsIdsGroupedByType).forEach(([depType, depsIds]: [string, BitIds]) => { depsIds.forEach((depId) => { if (this.ignoreIds.has(depId)) return; if (!this.graph.hasNode(depId.toString())) { diff --git a/scopes/workspace/workspace/workspace.ts b/scopes/workspace/workspace/workspace.ts index 43c921cb7ead..5075d4f5888d 100644 --- a/scopes/workspace/workspace/workspace.ts +++ b/scopes/workspace/workspace/workspace.ts @@ -1148,7 +1148,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`); extensionsToMerge.push({ origin, extensions: extensionDataListFiltered, extraData }); loadedExtensionIds.push( - ...compact(extensionDataListFiltered.map((e) => e.extensionId?.toStringWithoutVersion())) + ...compact(extensionDataListFiltered.map((e: ExtensionDataEntry) => e.extensionId?.toStringWithoutVersion())) ); }; const setDataListAsSpecific = (extensions: ExtensionDataList) => { @@ -1250,7 +1250,10 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`); return componentStatus.modified === true; } - private filterEnvsFromExtensionsIfNeeded(extensionDataList: ExtensionDataList, envWasFoundPreviously: boolean) { + private filterEnvsFromExtensionsIfNeeded( + extensionDataList: ExtensionDataList, + envWasFoundPreviously: boolean + ): { extensionDataListFiltered: ExtensionDataList; envIsCurrentlySet: boolean } { const envAspect = extensionDataList.findExtension(EnvsAspect.id); const envFromEnvsAspect = envAspect?.config.env; const [envsNotFromEnvsAspect, nonEnvs] = partition(extensionDataList, (ext) => From b889cc9672d4903446820a8f27ed4646b1ce4310 Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Tue, 16 Aug 2022 16:08:15 +0300 Subject: [PATCH 10/16] increase timeout --- scopes/react/react/jest/jest.base.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scopes/react/react/jest/jest.base.config.js b/scopes/react/react/jest/jest.base.config.js index 076ec6f706af..a85efa85899b 100644 --- a/scopes/react/react/jest/jest.base.config.js +++ b/scopes/react/react/jest/jest.base.config.js @@ -26,6 +26,6 @@ module.exports = { '^.+\\.module\\.(css|sass|scss)$': require.resolve('identity-obj-proxy'), }, moduleFileExtensions: ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'], - testTimeout: 50000, // @todo remove this once mocha-tester is ready and aspect-api testing are using it. + testTimeout: 100000, // @todo remove this once mocha-tester is ready and aspect-api testing are using it. // watchPlugins: [require.resolve('jest-watch-typeahead/filename'), require.resolve('jest-watch-typeahead/testname')], }; From 61dfbff4cc18199becce14b1c33056f8c0c62f59 Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Tue, 16 Aug 2022 16:09:46 +0300 Subject: [PATCH 11/16] tsignore for this.timeout in legacy tests to prevent conflicts between jest and mocha when build legacy types --- src/consumer/bit-map/bit-map.spec.ts | 1 + src/consumer/component/components-list.spec.ts | 2 ++ src/consumer/component/consumer-component.spec.ts | 1 + .../files-dependency-builder/dependency-tree/index.spec.ts | 2 ++ src/consumer/component/sources/data-to-persist.spec.ts | 1 + src/consumer/consumer.spec.ts | 1 + src/jsdoc/jsdoc/jsdoc-parser.spec.ts | 1 + src/utils/bit/package-name-to-component-id.spec.ts | 1 + 8 files changed, 10 insertions(+) diff --git a/src/consumer/bit-map/bit-map.spec.ts b/src/consumer/bit-map/bit-map.spec.ts index 7534c0c9edb9..39c25d11cb59 100644 --- a/src/consumer/bit-map/bit-map.spec.ts +++ b/src/consumer/bit-map/bit-map.spec.ts @@ -30,6 +30,7 @@ describe('BitMap', function () { logger.debug = () => {}; // @ts-ignore logger.info = () => {}; + // @ts-ignore this.timeout(0); describe('toObject', () => { let bitMap: BitMap; diff --git a/src/consumer/component/components-list.spec.ts b/src/consumer/component/components-list.spec.ts index acc5f162258f..d669844cd99f 100644 --- a/src/consumer/component/components-list.spec.ts +++ b/src/consumer/component/components-list.spec.ts @@ -5,6 +5,7 @@ import { ModelComponent } from '../../scope/models'; import ComponentsList from './components-list'; describe('ComponentList', function () { + // @ts-ignore this.timeout(0); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! const getModelComponent = () => ModelComponent.fromBitId({ name: 'myName', scope: 'scope' }); @@ -16,6 +17,7 @@ describe('ComponentList', function () { describe('listLocalScope', function () { let modelComponent; before(() => { + // @ts-ignore this.timeout(0); modelComponent = getModelComponent(); }); diff --git a/src/consumer/component/consumer-component.spec.ts b/src/consumer/component/consumer-component.spec.ts index 3df450b6c1de..23403476e1cd 100644 --- a/src/consumer/component/consumer-component.spec.ts +++ b/src/consumer/component/consumer-component.spec.ts @@ -3,6 +3,7 @@ import Component from './consumer-component'; import { SourceFile } from './sources'; describe('ConsumerComponent', function () { + // @ts-ignore this.timeout(0); describe('docs', () => { const componentProps = { diff --git a/src/consumer/component/dependencies/files-dependency-builder/dependency-tree/index.spec.ts b/src/consumer/component/dependencies/files-dependency-builder/dependency-tree/index.spec.ts index bad7b557d802..e9d4a1c05701 100644 --- a/src/consumer/component/dependencies/files-dependency-builder/dependency-tree/index.spec.ts +++ b/src/consumer/component/dependencies/files-dependency-builder/dependency-tree/index.spec.ts @@ -32,6 +32,7 @@ const dependencyTree = dependencyTreeRewired.default; const fixtures = path.resolve(`${__dirname}/../../../../../../fixtures/dependency-tree`); describe('dependencyTree', function () { + // @ts-ignore this.timeout(8000); function testTreesForFormat(format, ext = '.js') { it('returns an object form of the dependency tree for a file', () => { @@ -560,6 +561,7 @@ describe('dependencyTree', function () { }); it('resolves unaliased modules', () => { + // @ts-ignore this.timeout(5000); // @ts-ignore this._testResolution('unaliased'); diff --git a/src/consumer/component/sources/data-to-persist.spec.ts b/src/consumer/component/sources/data-to-persist.spec.ts index cf61aa14ed21..2eb6a852659d 100644 --- a/src/consumer/component/sources/data-to-persist.spec.ts +++ b/src/consumer/component/sources/data-to-persist.spec.ts @@ -4,6 +4,7 @@ import * as path from 'path'; import DataToPersist from './data-to-persist'; describe('DataToPersist', function () { + // @ts-ignore this.timeout(0); describe('addFile', () => { describe('dir/file collision', () => { diff --git a/src/consumer/consumer.spec.ts b/src/consumer/consumer.spec.ts index 853cd1176534..d535a562e9c9 100644 --- a/src/consumer/consumer.spec.ts +++ b/src/consumer/consumer.spec.ts @@ -6,6 +6,7 @@ import Consumer from '../consumer/consumer'; import { MissingBitMapComponent } from './bit-map/exceptions'; describe('Consumer', function () { + // @ts-ignore this.timeout(0); let sandbox; const getConsumerInstance = () => { diff --git a/src/jsdoc/jsdoc/jsdoc-parser.spec.ts b/src/jsdoc/jsdoc/jsdoc-parser.spec.ts index 35e90ba76bac..22896708a47a 100644 --- a/src/jsdoc/jsdoc/jsdoc-parser.spec.ts +++ b/src/jsdoc/jsdoc/jsdoc-parser.spec.ts @@ -127,6 +127,7 @@ describe('JSDoc Parser', () => { expect(doclet).to.have.property('description').that.equals('Get the y value.'); }); it('should recognize the fromString method as the last doclet', function () { + // @ts-ignore this.timeout(0); const doclet = doclets[doclets.length - 1]; expect(doclet).to.have.property('name').that.equals('fromString'); diff --git a/src/utils/bit/package-name-to-component-id.spec.ts b/src/utils/bit/package-name-to-component-id.spec.ts index 38be1a105b03..caa92e62d06b 100644 --- a/src/utils/bit/package-name-to-component-id.spec.ts +++ b/src/utils/bit/package-name-to-component-id.spec.ts @@ -5,6 +5,7 @@ import { Consumer } from '../../consumer'; import { packageNameToComponentId } from './package-name-to-component-id'; describe('packageNameToComponentId', function () { + // @ts-ignore this.timeout(0); let consumer: Consumer; before(() => { From d78d0590de53a9317ca553f1911166cb7d44e43c Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Thu, 1 Sep 2022 11:25:38 +0300 Subject: [PATCH 12/16] do not add data to self on component load --- .../workspace-component/workspace-component-loader.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts index 6e2f9f1f71d4..57fecf0a8757 100644 --- a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts +++ b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts @@ -230,7 +230,12 @@ export class WorkspaceComponentLoader { const entries = this.workspace.onComponentLoadSlot.toArray(); const promises = entries.map(async ([extension, onLoad]) => { const data = await onLoad(component, loadOpts); - return this.upsertExtensionData(component, extension, data); + const compId = component.id.toString(); + const compIdWithoutVersion = component.id.toStringWithoutVersion(); + if (compId !== extension && compIdWithoutVersion !== extension) { + return this.upsertExtensionData(component, extension, data); + } + return undefined; }); // Special load events which runs from the workspace but should run from the correct aspect From 5c41731a31647661585c1bccd47f6aec94c60184 Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Thu, 1 Sep 2022 13:40:26 +0300 Subject: [PATCH 13/16] improve legacy extension list find function --- src/consumer/config/extension-data.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/consumer/config/extension-data.ts b/src/consumer/config/extension-data.ts index d283596e9dcd..6920e112ab6a 100644 --- a/src/consumer/config/extension-data.ts +++ b/src/consumer/config/extension-data.ts @@ -156,15 +156,22 @@ export class ExtensionDataList extends Array { } findExtension(extensionId: string, ignoreVersion = false, ignoreScope = false): ExtensionDataEntry | undefined { + const extensionIdWithoutVersion = ignoreVersion ? extensionId.split('@')[0] : extensionId; if (ExtensionDataList.coreExtensionsNames.has(extensionId)) { return this.findCoreExtension(extensionId); } return this.find((extEntry) => { if (ignoreVersion && ignoreScope) { - return extEntry.extensionId?.toStringWithoutScopeAndVersion() === extensionId; + return ( + extEntry.extensionId?.toStringWithoutScopeAndVersion() === extensionId || + extEntry.extensionId?.toStringWithoutScopeAndVersion() === extensionIdWithoutVersion || + extEntry.newExtensionId?.toStringWithoutVersion() === extensionIdWithoutVersion + ); } if (ignoreVersion) { - return extEntry.extensionId?.toStringWithoutVersion() === extensionId; + return extEntry.extensionId?.toStringWithoutVersion() === extensionId || + extEntry.extensionId?.toStringWithoutVersion() === extensionIdWithoutVersion || + extEntry.newExtensionId?.toStringWithoutVersion() === extensionIdWithoutVersion } if (ignoreScope) { return extEntry.extensionId?.toStringWithoutScope() === extensionId; From 60ef1a4cc8ae6879ee1b7d33a02300089c4e2cfb Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Thu, 1 Sep 2022 13:41:11 +0300 Subject: [PATCH 14/16] ignore version when upserting extension data --- .../workspace/workspace-component/workspace-component-loader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts index 57fecf0a8757..33efdc18a7ce 100644 --- a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts +++ b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts @@ -267,7 +267,7 @@ export class WorkspaceComponentLoader { } private async upsertExtensionData(component: Component, extension: string, data: any) { - const existingExtension = component.state.config.extensions.findExtension(extension); + const existingExtension = component.state.config.extensions.findExtension(extension, true); if (existingExtension && data) { // Only merge top level of extension data Object.assign(existingExtension.data, data); From 7d06e4b1e9e033261938f7b1ecf26e7b77f2d4c8 Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Thu, 1 Sep 2022 17:07:13 +0300 Subject: [PATCH 15/16] aspect get fixes --- scopes/component/component/aspect-list.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scopes/component/component/aspect-list.ts b/scopes/component/component/aspect-list.ts index 659c0044caaf..d8070e96f687 100644 --- a/scopes/component/component/aspect-list.ts +++ b/scopes/component/component/aspect-list.ts @@ -40,7 +40,7 @@ export class AspectList { */ get(id: string): AspectEntry | undefined { return this.entries.find((entry) => { - return entry.legacy.stringId === id || entry.id.toStringWithoutVersion() === id; + return entry.legacy.stringId === id || entry.id.toString() === id || entry.id.toStringWithoutVersion() === id; }); } From 3b2d4704b0c474a18ae46e7fc9b42e3df07632da Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Sun, 4 Sep 2022 13:26:43 +0300 Subject: [PATCH 16/16] do save aspect data on aspect itself if it's a core aspect (to make sure we have main prop in package.json of the pkg correctly) --- .../workspace-component/workspace-component-loader.ts | 6 ++++-- scopes/workspace/workspace/workspace.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts index 33efdc18a7ce..2c49bb3e7875 100644 --- a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts +++ b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts @@ -5,6 +5,7 @@ import mapSeries from 'p-map-series'; import { compact, fromPairs, uniq } from 'lodash'; import ConsumerComponent from '@teambit/legacy/dist/consumer/component'; import { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions'; +import { AspectLoaderMain } from '@teambit/aspect-loader'; import { getLatestVersionNumber } from '@teambit/legacy/dist/utils'; import { IssuesClasses } from '@teambit/component-issues'; import { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions'; @@ -25,7 +26,8 @@ export class WorkspaceComponentLoader { private workspace: Workspace, private logger: Logger, private dependencyResolver: DependencyResolverMain, - private envs: EnvsMain + private envs: EnvsMain, + private aspectLoader: AspectLoaderMain ) { this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() }); } @@ -232,7 +234,7 @@ export class WorkspaceComponentLoader { const data = await onLoad(component, loadOpts); const compId = component.id.toString(); const compIdWithoutVersion = component.id.toStringWithoutVersion(); - if (compId !== extension && compIdWithoutVersion !== extension) { + if ((compId !== extension && compIdWithoutVersion !== extension) || (this.aspectLoader.isCoreAspect(extension))) { return this.upsertExtensionData(component, extension, data); } return undefined; diff --git a/scopes/workspace/workspace/workspace.ts b/scopes/workspace/workspace/workspace.ts index 0ba273621e7c..993811823594 100644 --- a/scopes/workspace/workspace/workspace.ts +++ b/scopes/workspace/workspace/workspace.ts @@ -245,7 +245,7 @@ export class Workspace implements ComponentFactory { // TODO: refactor - prefer to avoid code inside the constructor. this.owner = this.config?.defaultOwner; - this.componentLoader = new WorkspaceComponentLoader(this, logger, dependencyResolver, envs); + this.componentLoader = new WorkspaceComponentLoader(this, logger, dependencyResolver, envs, aspectLoader); this.validateConfig(); this.bitMap = new BitMap(this.consumer.bitMap, this.consumer); // memoize this method to improve performance.