diff --git a/integration-libs/cdc/schematics/add-cdc/__snapshots__/index_spec.ts.snap b/integration-libs/cdc/schematics/add-cdc/__snapshots__/index_spec.ts.snap index d070e7678d8..b141e1e35f4 100644 --- a/integration-libs/cdc/schematics/add-cdc/__snapshots__/index_spec.ts.snap +++ b/integration-libs/cdc/schematics/add-cdc/__snapshots__/index_spec.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Spartacus CDC schematics: ng-add CDC feature eager loading should import appropriate modules 1`] = ` +exports[`Spartacus CDC schematics: ng-add CDC-B2B feature eager loading should import appropriate modules 1`] = ` "import { NgModule } from '@angular/core'; import { CdcModule } from "@spartacus/cdc"; import { cdcTranslationChunksConfig, cdcTranslations } from "@spartacus/cdc/assets"; @@ -42,7 +42,7 @@ export class CdcFeatureModule { } " `; -exports[`Spartacus CDC schematics: ng-add CDC feature general setup should add the feature using the lazy loading syntax 1`] = ` +exports[`Spartacus CDC schematics: ng-add CDC-B2B feature general setup should add the feature using the lazy loading syntax 1`] = ` "import { NgModule } from '@angular/core'; import { cdcTranslationChunksConfig, cdcTranslations } from "@spartacus/cdc/assets"; import { CdcConfig, CdcRootModule, CDC_FEATURE } from "@spartacus/cdc/root"; @@ -82,7 +82,7 @@ export class CdcFeatureModule { } " `; -exports[`Spartacus CDC schematics: ng-add CDC feature general setup should install the appropriate dependencies 1`] = ` +exports[`Spartacus CDC schematics: ng-add CDC-B2B feature general setup should install the appropriate dependencies 1`] = ` "import { NgModule } from '@angular/core'; import { CDCUserAccountModule } from "@spartacus/cdc/user-account"; import { UserAccountModule } from "@spartacus/user/account"; @@ -98,7 +98,7 @@ export class UserAccountWrapperModule { } " `; -exports[`Spartacus CDC schematics: ng-add CDC feature general setup should install the appropriate dependencies 2`] = ` +exports[`Spartacus CDC schematics: ng-add CDC-B2B feature general setup should install the appropriate dependencies 2`] = ` "import { NgModule } from '@angular/core'; import { CDCUserProfileModule } from "@spartacus/cdc/user-profile"; import { UserProfileModule } from "@spartacus/user/profile"; @@ -114,7 +114,7 @@ export class UserProfileWrapperModule { } " `; -exports[`Spartacus CDC schematics: ng-add CDC feature general setup should install the appropriate dependencies 3`] = ` +exports[`Spartacus CDC schematics: ng-add CDC-B2B feature general setup should install the appropriate dependencies 3`] = ` "import { NgModule } from '@angular/core'; import { CdcAdministrationModule } from "@spartacus/cdc/organization/administration"; import { AdministrationModule } from "@spartacus/organization/administration"; @@ -130,7 +130,7 @@ export class AdministrationWrapperModule { } " `; -exports[`Spartacus CDC schematics: ng-add CDC feature general setup should install the appropriate dependencies 4`] = ` +exports[`Spartacus CDC schematics: ng-add CDC-B2B feature general setup should install the appropriate dependencies 4`] = ` "import { NgModule } from '@angular/core'; import { CDCB2BRegisterModule } from "@spartacus/cdc/organization/user-registration"; import { OrganizationUserRegistrationModule } from "@spartacus/organization/user-registration"; @@ -146,7 +146,157 @@ export class OrganizationUserRegistrationWrapperModule { } " `; -exports[`Spartacus CDC schematics: ng-add CDC feature validation of jsSDKUrl should set the given javascriptUrl 1`] = ` +exports[`Spartacus CDC schematics: ng-add CDC-B2B feature validation of jsSDKUrl should set the given javascriptUrl 1`] = ` +"import { NgModule } from '@angular/core'; +import { cdcTranslationChunksConfig, cdcTranslations } from "@spartacus/cdc/assets"; +import { CdcConfig, CdcRootModule, CDC_FEATURE } from "@spartacus/cdc/root"; +import { CmsConfig, I18nConfig, provideConfig } from "@spartacus/core"; + +@NgModule({ + declarations: [], + imports: [ + CdcRootModule + ], + providers: [provideConfig({ + featureModules: { + [CDC_FEATURE]: { + module: () => + import('@spartacus/cdc').then((m) => m.CdcModule), + }, + } + }), + provideConfig({ + i18n: { + resources: cdcTranslations, + chunks: cdcTranslationChunksConfig, + }, + }), + provideConfig({ + cdc: [ + { + baseSite: 'electronics-spa', + javascriptUrl: '.gigya.com/', + sessionExpiration: 3600 + }, + ], + }) + ] +}) +export class CdcFeatureModule { } +" +`; + +exports[`Spartacus CDC schematics: ng-add CDC-B2C feature eager loading should import appropriate modules 1`] = ` +"import { NgModule } from '@angular/core'; +import { CdcModule } from "@spartacus/cdc"; +import { cdcTranslationChunksConfig, cdcTranslations } from "@spartacus/cdc/assets"; +import { CdcConfig, CdcRootModule } from "@spartacus/cdc/root"; +import { CDCUserAccountModule } from "@spartacus/cdc/user-account"; +import { CDCUserProfileModule } from "@spartacus/cdc/user-profile"; +import { I18nConfig, provideConfig } from "@spartacus/core"; + +@NgModule({ + declarations: [], + imports: [ + CdcRootModule, + CdcModule, + CDCUserAccountModule, + CDCUserProfileModule + ], + providers: [provideConfig({ + i18n: { + resources: cdcTranslations, + chunks: cdcTranslationChunksConfig, + }, + }), + provideConfig({ + cdc: [ + { + baseSite: 'electronics-spa', + javascriptUrl: 'JS_SDK_URL_PLACEHOLDER', + sessionExpiration: 3600 + }, + ], + }) + ] +}) +export class CdcFeatureModule { } +" +`; + +exports[`Spartacus CDC schematics: ng-add CDC-B2C feature general setup should add the feature using the lazy loading syntax 1`] = ` +"import { NgModule } from '@angular/core'; +import { cdcTranslationChunksConfig, cdcTranslations } from "@spartacus/cdc/assets"; +import { CdcConfig, CdcRootModule, CDC_FEATURE } from "@spartacus/cdc/root"; +import { CmsConfig, I18nConfig, provideConfig } from "@spartacus/core"; + +@NgModule({ + declarations: [], + imports: [ + CdcRootModule + ], + providers: [provideConfig({ + featureModules: { + [CDC_FEATURE]: { + module: () => + import('@spartacus/cdc').then((m) => m.CdcModule), + }, + } + }), + provideConfig({ + i18n: { + resources: cdcTranslations, + chunks: cdcTranslationChunksConfig, + }, + }), + provideConfig({ + cdc: [ + { + baseSite: 'electronics-spa', + javascriptUrl: 'JS_SDK_URL_PLACEHOLDER', + sessionExpiration: 3600 + }, + ], + }) + ] +}) +export class CdcFeatureModule { } +" +`; + +exports[`Spartacus CDC schematics: ng-add CDC-B2C feature general setup should install the appropriate dependencies 1`] = ` +"import { NgModule } from '@angular/core'; +import { CDCUserAccountModule } from "@spartacus/cdc/user-account"; +import { UserAccountModule } from "@spartacus/user/account"; + +@NgModule({ + declarations: [], + imports: [ + UserAccountModule, + CDCUserAccountModule + ] +}) +export class UserAccountWrapperModule { } +" +`; + +exports[`Spartacus CDC schematics: ng-add CDC-B2C feature general setup should install the appropriate dependencies 2`] = ` +"import { NgModule } from '@angular/core'; +import { CDCUserProfileModule } from "@spartacus/cdc/user-profile"; +import { UserProfileModule } from "@spartacus/user/profile"; + +@NgModule({ + declarations: [], + imports: [ + UserProfileModule, + CDCUserProfileModule + ] +}) +export class UserProfileWrapperModule { } +" +`; + +exports[`Spartacus CDC schematics: ng-add CDC-B2C feature validation of jsSDKUrl should set the given javascriptUrl 1`] = ` "import { NgModule } from '@angular/core'; import { cdcTranslationChunksConfig, cdcTranslations } from "@spartacus/cdc/assets"; import { CdcConfig, CdcRootModule, CDC_FEATURE } from "@spartacus/cdc/root"; diff --git a/integration-libs/cdc/schematics/add-cdc/index_spec.ts b/integration-libs/cdc/schematics/add-cdc/index_spec.ts index 7c899a0de99..4ad54cf1312 100644 --- a/integration-libs/cdc/schematics/add-cdc/index_spec.ts +++ b/integration-libs/cdc/schematics/add-cdc/index_spec.ts @@ -1,5 +1,4 @@ /// - import { SchematicTestRunner, UnitTestTree, @@ -11,6 +10,7 @@ import { import { Schema as WorkspaceOptions } from '@schematics/angular/workspace/schema'; import { cdcFeatureModulePath, + CDC_B2B_FEATURE_NAME, CDC_FEATURE_NAME, LibraryOptions as SpartacusCdcOptions, organizationAdministrationWrapperModulePath, @@ -29,22 +29,17 @@ import { } from '@spartacus/schematics'; import * as path from 'path'; import { peerDependencies } from '../../package.json'; - const collectionPath = path.join(__dirname, '../collection.json'); - describe('Spartacus CDC schematics: ng-add', () => { const schematicRunner = new SchematicTestRunner( SPARTACUS_CDC, collectionPath ); - let appTree: UnitTestTree; - const workspaceOptions: WorkspaceOptions = { name: 'workspace', version: '0.5.0', }; - const appOptions: ApplicationOptions = { name: 'schematics-test', inlineStyle: false, @@ -54,24 +49,24 @@ describe('Spartacus CDC schematics: ng-add', () => { skipTests: false, projectRoot: '', }; - const spartacusDefaultOptions: SpartacusOptions = { project: 'schematics-test', lazy: true, features: [], }; - const libraryNoFeaturesOptions: SpartacusCdcOptions = { project: 'schematics-test', lazy: true, features: [], }; - const cdcFeatureOptions: SpartacusCdcOptions = { ...libraryNoFeaturesOptions, features: [CDC_FEATURE_NAME], }; - + const cdcB2bFeatureOptions: SpartacusCdcOptions = { + ...libraryNoFeaturesOptions, + features: [CDC_B2B_FEATURE_NAME], + }; beforeEach(async () => { schematicRunner.registerCollection( SPARTACUS_SCHEMATICS, @@ -91,20 +86,17 @@ describe('Spartacus CDC schematics: ng-add', () => { '../../../../feature-libs/user/schematics/collection.json' ) ); - appTree = await schematicRunner.runExternalSchematic( '@schematics/angular', 'workspace', workspaceOptions ); - appTree = await schematicRunner.runExternalSchematic( '@schematics/angular', 'application', appOptions, appTree ); - appTree = await schematicRunner.runExternalSchematic( SPARTACUS_SCHEMATICS, 'ng-add', @@ -112,7 +104,6 @@ describe('Spartacus CDC schematics: ng-add', () => { appTree ); }); - describe('Without features', () => { beforeEach(async () => { appTree = await schematicRunner.runSchematic( @@ -121,19 +112,115 @@ describe('Spartacus CDC schematics: ng-add', () => { appTree ); }); - it('should not create any of the feature modules', () => { expect(appTree.exists(cdcFeatureModulePath)).toBeFalsy(); }); }); - - describe('CDC feature', () => { + describe('CDC-B2C feature', () => { describe('validation of jsSDKUrl', () => { beforeEach(async () => { appTree = await schematicRunner.runSchematic( 'ng-add', { ...cdcFeatureOptions, + features: [USER_ACCOUNT_FEATURE_NAME, USER_PROFILE_FEATURE_NAME], + }, + appTree + ); + appTree = await schematicRunner.runSchematic( + 'ng-add', + { ...cdcFeatureOptions, javascriptUrl: '.gigya.com/' }, + appTree + ); + }); + it('should set the given javascriptUrl', async () => { + const featureModule = appTree.readContent(cdcFeatureModulePath); + expect(featureModule).toMatchSnapshot(); + }); + }); + describe('general setup', () => { + beforeEach(async () => { + appTree = await schematicRunner.runSchematic( + 'ng-add', + { + ...cdcFeatureOptions, + features: [USER_ACCOUNT_FEATURE_NAME, USER_PROFILE_FEATURE_NAME], + }, + appTree + ); + appTree = await schematicRunner.runSchematic( + 'ng-add', + cdcFeatureOptions, + appTree + ); + }); + it('should install necessary Spartacus libraries', () => { + const packageJson = JSON.parse(appTree.readContent('package.json')); + let dependencies: Record = {}; + dependencies = { ...packageJson.dependencies }; + dependencies = { ...dependencies, ...packageJson.devDependencies }; + for (const toAdd in peerDependencies) { + // skip the SPARTACUS_SCHEMATICS, as those are added only when running by the Angular CLI, and not in the testing environment + if ( + !peerDependencies.hasOwnProperty(toAdd) || + toAdd === SPARTACUS_SCHEMATICS + ) { + continue; + } + // CXSPA-4872: after 4.0: use this test, as we'll have synced versions between lib's and root package.json + // const expectedVersion = (peerDependencies as Record< + // string, + // string + // >)[toAdd]; + const expectedDependency = dependencies[toAdd]; + expect(expectedDependency).toBeTruthy(); + // expect(expectedDependency).toEqual(expectedVersion); + } + }); + it('should add the feature using the lazy loading syntax', async () => { + const featureModule = appTree.readContent(cdcFeatureModulePath); + expect(featureModule).toMatchSnapshot(); + }); + it('should install the appropriate dependencies', async () => { + const userAccountWrapperModule = appTree.readContent( + userAccountWrapperModulePath + ); + expect(userAccountWrapperModule).toMatchSnapshot(); + const userProfileWrapperModule = appTree.readContent( + userProfileWrapperModulePath + ); + expect(userProfileWrapperModule).toMatchSnapshot(); + }); + }); + describe('eager loading', () => { + beforeEach(async () => { + appTree = await schematicRunner.runSchematic( + 'ng-add', + { + ...cdcFeatureOptions, + features: [USER_ACCOUNT_FEATURE_NAME, USER_PROFILE_FEATURE_NAME], + }, + appTree + ); + appTree = await schematicRunner.runSchematic( + 'ng-add', + { ...cdcFeatureOptions, lazy: false }, + appTree + ); + }); + it('should import appropriate modules', async () => { + const featureModule = appTree.readContent(cdcFeatureModulePath); + expect(featureModule).toMatchSnapshot(); + }); + }); + }); + describe('CDC-B2B feature', () => { + describe('validation of jsSDKUrl', () => { + beforeEach(async () => { + appTree = await schematicRunner.runSchematic( + 'ng-add', + { + ...cdcB2bFeatureOptions, features: [ USER_ACCOUNT_FEATURE_NAME, USER_PROFILE_FEATURE_NAME, @@ -143,26 +230,26 @@ describe('Spartacus CDC schematics: ng-add', () => { }, appTree ); - appTree = await schematicRunner.runSchematic( 'ng-add', - { ...cdcFeatureOptions, javascriptUrl: '.gigya.com/' }, + { + ...cdcB2bFeatureOptions, + javascriptUrl: '.gigya.com/', + }, appTree ); }); - it('should set the given javascriptUrl', async () => { const featureModule = appTree.readContent(cdcFeatureModulePath); expect(featureModule).toMatchSnapshot(); }); }); - describe('general setup', () => { beforeEach(async () => { appTree = await schematicRunner.runSchematic( 'ng-add', { - ...cdcFeatureOptions, + ...cdcB2bFeatureOptions, features: [ USER_ACCOUNT_FEATURE_NAME, USER_PROFILE_FEATURE_NAME, @@ -172,20 +259,17 @@ describe('Spartacus CDC schematics: ng-add', () => { }, appTree ); - appTree = await schematicRunner.runSchematic( 'ng-add', - cdcFeatureOptions, + cdcB2bFeatureOptions, appTree ); }); - it('should install necessary Spartacus libraries', () => { const packageJson = JSON.parse(appTree.readContent('package.json')); let dependencies: Record = {}; dependencies = { ...packageJson.dependencies }; dependencies = { ...dependencies, ...packageJson.devDependencies }; - for (const toAdd in peerDependencies) { // skip the SPARTACUS_SCHEMATICS, as those are added only when running by the Angular CLI, and not in the testing environment if ( @@ -204,41 +288,35 @@ describe('Spartacus CDC schematics: ng-add', () => { // expect(expectedDependency).toEqual(expectedVersion); } }); - it('should add the feature using the lazy loading syntax', async () => { const featureModule = appTree.readContent(cdcFeatureModulePath); expect(featureModule).toMatchSnapshot(); }); - it('should install the appropriate dependencies', async () => { const userAccountWrapperModule = appTree.readContent( userAccountWrapperModulePath ); expect(userAccountWrapperModule).toMatchSnapshot(); - const userProfileWrapperModule = appTree.readContent( userProfileWrapperModulePath ); expect(userProfileWrapperModule).toMatchSnapshot(); - const administrationWrapperModule = appTree.readContent( organizationAdministrationWrapperModulePath ); expect(administrationWrapperModule).toMatchSnapshot(); - const organizationUserRegistrationWrapperModule = appTree.readContent( organizationUserRegistrationWrapperModulePath ); expect(organizationUserRegistrationWrapperModule).toMatchSnapshot(); }); }); - describe('eager loading', () => { beforeEach(async () => { appTree = await schematicRunner.runSchematic( 'ng-add', { - ...cdcFeatureOptions, + ...cdcB2bFeatureOptions, features: [ USER_ACCOUNT_FEATURE_NAME, USER_PROFILE_FEATURE_NAME, @@ -248,14 +326,12 @@ describe('Spartacus CDC schematics: ng-add', () => { }, appTree ); - appTree = await schematicRunner.runSchematic( 'ng-add', - { ...cdcFeatureOptions, lazy: false }, + { ...cdcB2bFeatureOptions, lazy: false }, appTree ); }); - it('should import appropriate modules', async () => { const featureModule = appTree.readContent(cdcFeatureModulePath); expect(featureModule).toMatchSnapshot(); diff --git a/integration-libs/cdc/schematics/add-cdc/schema.json b/integration-libs/cdc/schematics/add-cdc/schema.json index 807d1781010..5987a5150e0 100644 --- a/integration-libs/cdc/schematics/add-cdc/schema.json +++ b/integration-libs/cdc/schematics/add-cdc/schema.json @@ -24,7 +24,20 @@ "features": { "type": "array", "uniqueItems": true, - "default": ["CDC"] + "x-prompt": { + "message": "Which feature would you like to set up from the CDC library?", + "type": "list", + "items": [ + { + "value": "CDC", + "label": "CDC for B2C" + }, + { + "value": "CDC-B2B", + "label": "CDC for B2B" + } + ] + } }, "javascriptUrl": { "type": "string", diff --git a/projects/schematics/src/add-spartacus/schema.json b/projects/schematics/src/add-spartacus/schema.json index 1ca4a5f335b..bc2e4582b12 100644 --- a/projects/schematics/src/add-spartacus/schema.json +++ b/projects/schematics/src/add-spartacus/schema.json @@ -22,6 +22,7 @@ "Saved-Cart", "Quick-Order", "CDC", + "CDC-B2B", "CDS", "Cart", "WishList", @@ -104,7 +105,11 @@ }, { "value": "CDC", - "label": "Customer Data Cloud Integration" + "label": "Customer Data Cloud Integration - B2C" + }, + { + "value": "CDC-B2B", + "label": "Customer Data Cloud Integration - B2B" }, { "value": "CDS", diff --git a/projects/schematics/src/shared/lib-configs/integration-libs/cdc-schematics-config.ts b/projects/schematics/src/shared/lib-configs/integration-libs/cdc-schematics-config.ts index ba1676de488..41aab0e6b40 100644 --- a/projects/schematics/src/shared/lib-configs/integration-libs/cdc-schematics-config.ts +++ b/projects/schematics/src/shared/lib-configs/integration-libs/cdc-schematics-config.ts @@ -16,6 +16,7 @@ import { SPARTACUS_CDC_ORGANIZATION_ADMINISTRATION, SPARTACUS_CDC_ASSETS, SPARTACUS_CDC_ORGANIZATION_REGISTRATION, + CDC_B2B_FEATURE_NAME, } from '../../libs-constants'; import { AdditionalFeatureConfiguration } from '../../utils/feature-utils'; import { LibraryOptions, SchematicConfig } from '../../utils/lib-utils'; @@ -51,35 +52,37 @@ export const CDC_B2B_REGISTER_MODULE = 'CDCB2BRegisterModule'; export const CDC_TRANSLATION_CHUNKS_CONFIG = 'cdcTranslationChunksConfig'; export const CDC_TRANSLATIONS = 'cdcTranslations'; -export const CDC_SCHEMATICS_CONFIG: SchematicConfig = { - library: { - featureName: CDC_FEATURE_NAME, - mainScope: SPARTACUS_CDC, +const CDC_SHARED_FEATURE_MODULES = [ + { + importPath: SPARTACUS_CDC, + name: CDC_MODULE, + }, + { + name: CDC_USER_ACCOUNT_MODULE, + importPath: SPARTACUS_CDC_USER_ACCOUNT, + }, + { + name: CDC_USER_PROFILE_MODULE, + importPath: SPARTACUS_CDC_USER_PROFILE, + }, +]; + +const CDC_SHARED_IMPORT_AFTER = [ + { + markerModuleName: USER_ACCOUNT_MODULE, + featureModuleName: CDC_USER_ACCOUNT_MODULE, + }, + { + markerModuleName: USER_PROFILE_MODULE, + featureModuleName: CDC_USER_PROFILE_MODULE, }, +]; + +const CDC_SHARED_DEPENDENCY_FEATURES = [USER_PROFILE_FEATURE_NAME]; + +const CDC_SHARED_CONFIG = { folderName: CDC_FOLDER_NAME, moduleName: CDC_MODULE_NAME, - featureModule: [ - { - importPath: SPARTACUS_CDC, - name: CDC_MODULE, - }, - { - name: CDC_USER_ACCOUNT_MODULE, - importPath: SPARTACUS_CDC_USER_ACCOUNT, - }, - { - name: CDC_USER_PROFILE_MODULE, - importPath: SPARTACUS_CDC_USER_PROFILE, - }, - { - name: CDC_ADMINISTRATION_MODULE, - importPath: SPARTACUS_CDC_ORGANIZATION_ADMINISTRATION, - }, - { - name: CDC_B2B_REGISTER_MODULE, - importPath: SPARTACUS_CDC_ORGANIZATION_REGISTRATION, - }, - ], lazyLoadingChunk: { moduleSpecifier: SPARTACUS_CDC_ROOT, namedImports: [CDC_FEATURE_CONSTANT], @@ -95,20 +98,33 @@ export const CDC_SCHEMATICS_CONFIG: SchematicConfig = { chunks: CDC_TRANSLATION_CHUNKS_CONFIG, importPath: SPARTACUS_CDC_ASSETS, }, +}; + +export const CDC_B2B_SCHEMATICS_CONFIG: SchematicConfig = { + library: { + featureName: CDC_B2B_FEATURE_NAME, + mainScope: SPARTACUS_CDC, + b2b: true, + }, + ...CDC_SHARED_CONFIG, + featureModule: [ + ...CDC_SHARED_FEATURE_MODULES, + { + name: CDC_ADMINISTRATION_MODULE, + importPath: SPARTACUS_CDC_ORGANIZATION_ADMINISTRATION, + }, + { + name: CDC_B2B_REGISTER_MODULE, + importPath: SPARTACUS_CDC_ORGANIZATION_REGISTRATION, + }, + ], dependencyFeatures: [ - USER_PROFILE_FEATURE_NAME, + ...CDC_SHARED_DEPENDENCY_FEATURES, ORGANIZATION_ADMINISTRATION_FEATURE_NAME, ORGANIZATION_USER_REGISTRATION_FEATURE_NAME, ], importAfter: [ - { - markerModuleName: USER_ACCOUNT_MODULE, - featureModuleName: CDC_USER_ACCOUNT_MODULE, - }, - { - markerModuleName: USER_PROFILE_MODULE, - featureModuleName: CDC_USER_PROFILE_MODULE, - }, + ...CDC_SHARED_IMPORT_AFTER, { markerModuleName: ADMINISTRATION_MODULE, featureModuleName: CDC_ADMINISTRATION_MODULE, @@ -120,6 +136,17 @@ export const CDC_SCHEMATICS_CONFIG: SchematicConfig = { ], }; +export const CDC_SCHEMATICS_CONFIG: SchematicConfig = { + library: { + featureName: CDC_FEATURE_NAME, + mainScope: SPARTACUS_CDC, + }, + ...CDC_SHARED_CONFIG, + featureModule: [...CDC_SHARED_FEATURE_MODULES], + dependencyFeatures: [...CDC_SHARED_DEPENDENCY_FEATURES], + importAfter: [...CDC_SHARED_IMPORT_AFTER], +}; + function buildCdcConfig( options: SpartacusCdcOptions ): AdditionalFeatureConfiguration { diff --git a/projects/schematics/src/shared/libs-constants.ts b/projects/schematics/src/shared/libs-constants.ts index 4467f20a30c..3190083f949 100644 --- a/projects/schematics/src/shared/libs-constants.ts +++ b/projects/schematics/src/shared/libs-constants.ts @@ -276,6 +276,7 @@ export const USER_ACCOUNT_FEATURE_NAME = 'User-Account'; export const USER_PROFILE_FEATURE_NAME = 'User-Profile'; export const CDC_FEATURE_NAME = 'CDC'; +export const CDC_B2B_FEATURE_NAME = 'CDC-B2B'; export const CDS_FEATURE_NAME = 'CDS'; diff --git a/projects/schematics/src/shared/schematics-config-mappings.ts b/projects/schematics/src/shared/schematics-config-mappings.ts index 4dc28eff17c..fd47cf8b9a9 100644 --- a/projects/schematics/src/shared/schematics-config-mappings.ts +++ b/projects/schematics/src/shared/schematics-config-mappings.ts @@ -22,7 +22,10 @@ import { CHECKOUT_SCHEDULED_REPLENISHMENT_SCHEMATICS_CONFIG, } from './lib-configs/checkout-schematics-config'; import { CUSTOMER_TICKETING_SCHEMATICS_CONFIG } from './lib-configs/customer-ticketing-schematics-config'; -import { CDC_SCHEMATICS_CONFIG } from './lib-configs/integration-libs/cdc-schematics-config'; +import { + CDC_B2B_SCHEMATICS_CONFIG, + CDC_SCHEMATICS_CONFIG, +} from './lib-configs/integration-libs/cdc-schematics-config'; import { CDS_SCHEMATICS_CONFIG } from './lib-configs/integration-libs/cds-schematics-config'; import { DIGITAL_PAYMENTS_SCHEMATICS_CONFIG } from './lib-configs/integration-libs/digital-payments-schematics-config'; import { EPD_SCHEMATICS_CONFIG } from './lib-configs/integration-libs/epd-schematics-config'; @@ -123,6 +126,7 @@ export const SCHEMATICS_CONFIGS: SchematicConfig[] = [ // integration libraries start CDC_SCHEMATICS_CONFIG, + CDC_B2B_SCHEMATICS_CONFIG, CDS_SCHEMATICS_CONFIG, diff --git a/projects/schematics/src/shared/schematics-config-mappings_spec.ts b/projects/schematics/src/shared/schematics-config-mappings_spec.ts index a80277f0466..2508c7e6d70 100644 --- a/projects/schematics/src/shared/schematics-config-mappings_spec.ts +++ b/projects/schematics/src/shared/schematics-config-mappings_spec.ts @@ -28,6 +28,7 @@ import { import { ASM_FEATURE_NAME, CART_BASE_FEATURE_NAME, + CDC_B2B_FEATURE_NAME, CDC_FEATURE_NAME, CDS_FEATURE_NAME, CHECKOUT_B2B_FEATURE_NAME, @@ -65,7 +66,10 @@ describe('schematics-config-mappings', () => { CHECKOUT_SCHEDULED_REPLENISHMENT_FEATURE_NAME, ]); expect(result.get(SPARTACUS_ORDER)).toEqual([ORDER_FEATURE_NAME]); - expect(result.get(SPARTACUS_CDC)).toEqual([CDC_FEATURE_NAME]); + expect(result.get(SPARTACUS_CDC)).toEqual([ + CDC_FEATURE_NAME, + CDC_B2B_FEATURE_NAME, + ]); expect(result.get(SPARTACUS_S4OM)).toEqual([S4OM_FEATURE_NAME]); }); }); @@ -90,6 +94,11 @@ describe('schematics-config-mappings', () => { CDC_MODULE, CDC_USER_ACCOUNT_MODULE, CDC_USER_PROFILE_MODULE, + ]); + expect(result.get(CDC_B2B_FEATURE_NAME)).toEqual([ + CDC_MODULE, + CDC_USER_ACCOUNT_MODULE, + CDC_USER_PROFILE_MODULE, CDC_ADMINISTRATION_MODULE, CDC_B2B_REGISTER_MODULE, ]); @@ -116,6 +125,7 @@ describe('schematics-config-mappings', () => { expect(result.get(ORDER_FEATURE_NAME)).toEqual([ORDER_ROOT_MODULE]); expect(result.get(CDC_FEATURE_NAME)).toEqual([CDC_ROOT_MODULE]); expect(result.get(CDS_FEATURE_NAME)).toEqual([]); + expect(result.get(CDC_B2B_FEATURE_NAME)).toEqual([CDC_ROOT_MODULE]); expect(result.get(DIGITAL_PAYMENTS_FEATURE_NAME)).toEqual([]); expect(result.get(S4OM_FEATURE_NAME)).toEqual([S4OM_ROOT_MODULE]); }); diff --git a/projects/schematics/src/shared/utils/dependency-utils_spec.ts b/projects/schematics/src/shared/utils/dependency-utils_spec.ts index 43e43493e8d..6ee7683666c 100644 --- a/projects/schematics/src/shared/utils/dependency-utils_spec.ts +++ b/projects/schematics/src/shared/utils/dependency-utils_spec.ts @@ -23,6 +23,7 @@ import { SPARTACUS_USER, USER_ACCOUNT_FEATURE_NAME, USER_PROFILE_FEATURE_NAME, + CDC_B2B_FEATURE_NAME, SPARTACUS_PDF_INVOICES, } from '../libs-constants'; import { @@ -36,7 +37,7 @@ describe('dependency-util', () => { describe('analyzeCrossFeatureDependencies', () => { it('DP - should return the correct set of ordered sub-features', () => { const result = analyzeCrossFeatureDependencies([ - CDC_FEATURE_NAME, + CDC_B2B_FEATURE_NAME, DIGITAL_PAYMENTS_FEATURE_NAME, CHECKOUT_B2B_FEATURE_NAME, ]); @@ -51,7 +52,7 @@ describe('dependency-util', () => { ORGANIZATION_USER_REGISTRATION_FEATURE_NAME, ORGANIZATION_ADMINISTRATION_FEATURE_NAME, DIGITAL_PAYMENTS_FEATURE_NAME, - CDC_FEATURE_NAME, + CDC_B2B_FEATURE_NAME, ]); }); it('User Profile - should return the correct set of ordered sub-features', () => { diff --git a/projects/schematics/src/shared/utils/graph-utils_spec.ts b/projects/schematics/src/shared/utils/graph-utils_spec.ts index 3bd285f003b..d9844bdb289 100644 --- a/projects/schematics/src/shared/utils/graph-utils_spec.ts +++ b/projects/schematics/src/shared/utils/graph-utils_spec.ts @@ -189,6 +189,7 @@ describe('Graph utils', () => { "EPD-Visualization", "Digital-Payments", "CDS", + "CDC-B2B", "CDC", "Customer-Ticketing", "SmartEdit",