@@ -6,10 +6,17 @@ import {
66import { updateWorkspace } from '@schematics/angular/utility/workspace' ;
77import chalk from 'chalk' ;
88
9+ import {
10+ daffJson ,
11+ syncProjects ,
12+ } from '../../../bin/daff' ;
13+ import packagesJson from '../../../versioning/packages.json' ;
14+ import {
15+ DAFF_JSON_DEFAULT ,
16+ isSupportedPlatform ,
17+ } from '../../../versioning/public_api' ;
918import { NgAddOptions } from '../../schema' ;
1019
11- export const DEFAULT_MAGENTO_VERSION = '2.4.3' ;
12-
1320const DAFF_JSON_PATH = 'daff.json' ;
1421
1522const shouldScaffoldDaffConfig = ( options : NgAddOptions ) : boolean =>
@@ -29,14 +36,18 @@ export const createDaffJson = (options: NgAddOptions, projectName: string): Rule
2936 }
3037
3138 const body = {
32- projects : {
39+ ...DAFF_JSON_DEFAULT ,
40+ } ;
41+
42+ if ( isSupportedPlatform ( options . driver ) && options . driverVersion ) {
43+ body . projects = {
3344 [ projectName ] : {
3445 drivers : {
35- magento : DEFAULT_MAGENTO_VERSION ,
46+ [ options . driver ] : options . driverVersion ,
3647 } ,
3748 } ,
38- } ,
39- } ;
49+ } ;
50+ }
4051
4152 tree . create ( DAFF_JSON_PATH , JSON . stringify ( body , null , 2 ) + '\n' ) ;
4253 return tree ;
@@ -47,18 +58,7 @@ export const addBuildCondition = (options: NgAddOptions, projectName: string): R
4758 return ( tree : Tree ) => tree ;
4859 }
4960
50- const workspaceRule = updateWorkspace ( ( workspace ) => {
51- const project = workspace . projects . get ( projectName ) ;
52- const build = project ?. targets . get ( 'build' ) ;
53- if ( ! build ) {
54- return ;
55- }
56-
57- build . configurations ??= { } ;
58- const production = < { conditions ?: string [ ] } > ( build . configurations . production ??= { } ) ;
59- const cond = `magento-${ DEFAULT_MAGENTO_VERSION } ` ;
60- production . conditions = Array . from ( new Set ( [ ...( production . conditions ?? [ ] ) , cond ] ) ) ;
61+ return updateWorkspace ( async ( workspace ) => {
62+ syncProjects ( await daffJson ( DAFF_JSON_PATH ) . read ( ) , workspace , < any > packagesJson ) ;
6163 } ) ;
62-
63- return < Rule > < unknown > workspaceRule ;
6464} ;
0 commit comments