Skip to content

Commit ff6aa43

Browse files
committed
fix commerce
1 parent b456e4e commit ff6aa43

File tree

7 files changed

+26
-23
lines changed

7 files changed

+26
-23
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {
2+
inject,
3+
InjectionToken,
4+
} from '@angular/core';
5+
6+
import { DaffDevToolsConfigService } from '@daffodil/dev-tools';
7+
import { DaffMagentoDriverConfig } from '@daffodil/driver/magento';
8+
9+
export const DEMO_MAGENTO_DRIVER_CONFIG = new InjectionToken<DaffMagentoDriverConfig>('DEMO_MAGENTO_DRIVER_CONFIG', {
10+
factory: () => {
11+
const devTools = inject(DaffDevToolsConfigService);
12+
13+
return {
14+
uri: () => devTools.getStoredDriverConfiguration('@daffodil/driver','magento')?.['baseUrl'] ?? '',
15+
};
16+
},
17+
providedIn: 'root',
18+
});

tools/schematics/ng-add/files/app/daff/driver/magento/endpoint-switch.token.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

tools/schematics/ng-add/generators/providers/init.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class App {}
8383

8484
const appConfigContent = resultTree.read('/projects/test-app/src/app/app.config.ts')?.toString();
8585

86-
expect(appConfigContent).toContain('DEMO_MAGENTO_ENDPOINT_SWITCH');
86+
expect(appConfigContent).toContain('DEMO_MAGENTO_DRIVER_CONFIG');
8787
expect(appConfigContent).toContain('DEMO_SHOPIFY_ENDPOINT_SWITCH');
8888
});
8989
});

tools/schematics/ng-add/generators/providers/standalone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export const addCoreProvidersToStandalone = (options: NgAddOptions, project: any
137137
// Magento providers
138138
if(driver === 'demo') {
139139
coreProviders.push(
140-
'provideMagentoDriver(DEMO_MAGENTO_ENDPOINT_SWITCH)',
140+
'provideMagentoDriver(DEMO_MAGENTO_DRIVER_CONFIG)',
141141
);
142142
}
143143

tools/schematics/ng-add/index-standalone.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe('ng-add schematic - standalone apps', () => {
134134
expect(appConfigContent).toContain('from \'@angular/common/http\'');
135135
expect(appConfigContent).toContain('from \'@daffodil/dev-tools\'');
136136
expect(appConfigContent).toContain('from \'@daffodil/core\'');
137-
expect(appConfigContent).toContain('DEMO_MAGENTO_ENDPOINT_SWITCH');
137+
expect(appConfigContent).toContain('DEMO_MAGENTO_DRIVER_CONFIG');
138138
expect(appConfigContent).toContain('DynamicSwitchDriverService');
139139

140140
// Verify no malformed imports

tools/schematics/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"typescript": "0.0.0-PLACEHOLDER"
3737
},
3838
"devDependencies": {
39-
"@angular-devkit/schematics-cli": "0.0.0-PLACEHOLDER"
39+
"@angular-devkit/schematics-cli": "0.0.0-PLACEHOLDER",
40+
"@Daffodil/driver": "0.0.0-PLACEHOLDER"
4041
},
4142
"peerDependencies": {
4243
"@angular/core": "0.0.0-PLACEHOLDER",

tools/schematics/utils/module-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ export function addProvidersToStandaloneApp(tree: Tree, project: any, providers:
6767
}
6868
}
6969

70-
// Add DEMO_MAGENTO_ENDPOINT_SWITCH import when using provideMagentoDriver
71-
if (provider.includes('DEMO_MAGENTO_ENDPOINT_SWITCH')) {
72-
const endpointChange = insertImport(source, configPath, 'DEMO_MAGENTO_ENDPOINT_SWITCH', './daff/driver/magento/endpoint-switch.token');
70+
// Add DEMO_MAGENTO_DRIVER_CONFIG import when using provideMagentoDriver
71+
if (provider.includes('DEMO_MAGENTO_DRIVER_CONFIG')) {
72+
const endpointChange = insertImport(source, configPath, 'DEMO_MAGENTO_DRIVER_CONFIG', './daff/driver/magento/config.token');
7373
if (endpointChange instanceof InsertChange) {
7474
importChanges.push(endpointChange);
7575
}

0 commit comments

Comments
 (0)