@@ -24,14 +24,18 @@ import facetSampleConfiguration from '../facet-sample-configuration';
2424import facetSampleStyles from '../facet-sample-styles' ;
2525import facetVuejs from '../facet-vuejs' ;
2626
27- import type { Options , Target } from '..' ;
27+ import type { Facet , Options , Target } from '..' ;
28+
29+ export interface LiferayTargetFacet extends Facet {
30+ isPortlet : boolean ;
31+ }
2832
2933const {
3034 PkgJson : { addDependencies} ,
3135} = TRANSFORM_OPERATIONS ;
3236const { info, print} = format ;
3337
34- const frameworkFacets = {
38+ const projectTypeFacets : { [ name : string ] : LiferayTargetFacet } = {
3539 'Angular' : facetAngular ,
3640 'Plain JavaScript' : facetPlainJs ,
3741 'React' : facetReact ,
@@ -55,28 +59,40 @@ const target: Target = {
5559 type : 'list' ,
5660 } ,
5761 {
58- choices : Object . keys ( frameworkFacets ) ,
62+ choices : Object . keys ( projectTypeFacets ) ,
5963 default : 'React' ,
60- defaultDescription : 'Using framework : {React}' ,
61- message : 'Which will be your application framework ?' ,
62- name : 'framework ' ,
64+ defaultDescription : 'Using project type : {React}' ,
65+ message : 'Which will be your project type ?' ,
66+ name : 'projectType ' ,
6367 type : 'list' ,
6468 } ,
6569 ] ) ;
6670
67- options = await facetLocalization . prompt ( true , options ) ;
68- options = await facetConfiguration . prompt ( true , options ) ;
69- options = await facetPortlet . prompt ( useDefaults , options ) ;
71+ const projectTypeFacet =
72+ projectTypeFacets [ options . projectType as string ] ;
73+
74+ options = await facetLocalization . prompt (
75+ useDefaults || projectTypeFacet . isPortlet ,
76+ options
77+ ) ;
78+ options = await facetConfiguration . prompt (
79+ useDefaults || projectTypeFacet . isPortlet ,
80+ options
81+ ) ;
82+
83+ if ( projectTypeFacet . isPortlet ) {
84+ options = await facetPortlet . prompt ( useDefaults , options ) ;
85+ }
7086
71- const frameworkFacet = frameworkFacets [ options . framework as string ] ;
87+ options = await facetBuildable . prompt ( true , options ) ;
88+ options = await projectTypeFacet . prompt ( useDefaults , options ) ;
7289
73- if ( frameworkFacet ) {
74- options = await facetBuildable . prompt ( true , options ) ;
75- options = await frameworkFacet . prompt ( useDefaults , options ) ;
90+ if ( projectTypeFacet . isPortlet ) {
7691 options = await facetSampleStyles . prompt ( true , options ) ;
77- options = await facetSampleConfiguration . prompt ( true , options ) ;
7892 }
7993
94+ options = await facetSampleConfiguration . prompt ( true , options ) ;
95+
8096 return options ;
8197 } ,
8298
@@ -99,18 +115,24 @@ const target: Target = {
99115 } )
100116 ) ;
101117
118+ const projectTypeFacet =
119+ projectTypeFacets [ options . projectType as string ] ;
120+
102121 await facetLocalization . render ( options ) ;
103122 await facetConfiguration . render ( options ) ;
104- await facetPortlet . render ( options ) ;
105123
106- const frameworkFacet = frameworkFacets [ options . framework as string ] ;
124+ if ( projectTypeFacet . isPortlet ) {
125+ await facetPortlet . render ( options ) ;
126+ }
107127
108- if ( frameworkFacet ) {
109- await facetBuildable . render ( options ) ;
110- await frameworkFacet . render ( options ) ;
128+ await facetBuildable . render ( options ) ;
129+ await projectTypeFacet . render ( options ) ;
130+
131+ if ( projectTypeFacet . isPortlet ) {
111132 await facetSampleStyles . render ( options ) ;
112- await facetSampleConfiguration . render ( options ) ;
113133 }
134+
135+ await facetSampleConfiguration . render ( options ) ;
114136 } ,
115137} ;
116138
0 commit comments