@@ -199,40 +199,26 @@ export default class JHipsterClientGenerator extends BaseApplicationGenerator {
199199 get postWriting ( ) {
200200 return this . asPostWritingTaskGroup ( {
201201 packageJsonScripts ( { application } ) {
202- const packageJsonStorage = this . createStorage ( 'package.json' ) ;
203- const scriptsStorage = packageJsonStorage . createStorage ( 'scripts' ) ;
202+ const defaultEnvironment = process . env . JHI_PROFILE ?. includes ( 'dev' ) ? 'dev' : 'prod' ;
204203
205- const packageJsonConfigStorage = packageJsonStorage . createStorage ( 'config' ) . createProxy ( ) ;
206- if ( process . env . JHI_PROFILE ) {
207- packageJsonConfigStorage . default_environment = process . env . JHI_PROFILE . includes ( 'dev' ) ? 'dev' : 'prod' ;
208- }
209-
210- const devDependencies = packageJsonStorage . createStorage ( 'devDependencies' ) ;
211- devDependencies . set ( 'wait-on' , application . nodeDependencies [ 'wait-on' ] ) ;
212- devDependencies . set ( 'concurrently' , application . nodeDependencies . concurrently ) ;
204+ this . packageJson . merge ( {
205+ config : {
206+ default_environment : defaultEnvironment ,
207+ } ,
208+ devDependencies : {
209+ 'wait-on' : application . nodeDependencies [ 'wait-on' ] ,
210+ concurrently : application . nodeDependencies . concurrently ,
211+ } ,
212+ } ) ;
213213
214+ const scriptsStorage = this . packageJson . createStorage ( 'scripts' ) ;
214215 if ( application . clientFrameworkReact ) {
215216 scriptsStorage . set ( 'ci:frontend:test' , 'npm run webapp:build:$npm_package_config_default_environment && npm run test-ci' ) ;
216217 } else {
217218 scriptsStorage . set ( 'ci:frontend:build' , 'npm run webapp:build:$npm_package_config_default_environment' ) ;
218219 scriptsStorage . set ( 'ci:frontend:test' , 'npm run ci:frontend:build && npm test' ) ;
219220 }
220221 } ,
221-
222- microfrontend ( { application } ) {
223- if ( ! application . microfrontend ) return ;
224- if ( application . clientFrameworkAngular ) {
225- const conditional = application . applicationTypeMicroservice ? "targetOptions.target === 'serve' ? {} : " : '' ;
226- this . addWebpackConfig (
227- `${ conditional } require('./webpack.microfrontend')(config, options, targetOptions)` ,
228- application . clientFramework
229- ) ;
230- } else if ( application . clientFrameworkVue || application . clientFrameworkReact ) {
231- this . addWebpackConfig ( "require('./webpack.microfrontend')({ serve: options.env.WEBPACK_SERVE })" , application . clientFramework ) ;
232- } else {
233- throw new Error ( `Client framework ${ application . clientFramework } doesn't support microfrontends` ) ;
234- }
235- } ,
236222 } ) ;
237223 }
238224
0 commit comments