@@ -4,25 +4,40 @@ const path = require('path');
44const { spawn } = require ( 'child_process' ) ;
55const promptsQuestions = require ( './prompts-questions' ) ;
66const fileSystemUtils = require ( '../shared/fs-utils' ) ;
7- const menuMetaUtils = require ( './menu-meta-utils' ) ;
7+ const menuMetaUtils = require ( '../shared /menu-meta-utils' ) ;
88const menuMetaData = require ( '../../menuMeta.json' ) ;
99
1010const existingApproaches = [ 'jQuery' , 'Angular' , 'React' , 'Vue' ] ;
11-
12- // const descriptionFileName = 'description.md';
11+ const extraModules = [
12+ 'signalr' ,
13+ 'devextreme-aspnet-data-nojquery' ,
14+ 'globalize' ,
15+ 'devextreme-exceljs-fork&file-saver' ,
16+ 'jspdf' ,
17+ 'jspdf&jspdf-autotable' ,
18+ 'devextreme-intl' ,
19+ 'canvg' ,
20+ 'whatwg-fetch' ,
21+ 'vectormap' ,
22+ 'unified' ,
23+ 'openai' ,
24+ 'html-react-parser' ,
25+ 'vuex' ,
26+ ] ;
1327
1428const menuMetaFilePath = './menuMeta.json' ;
1529
1630const baseDemosDir = 'Demos' ;
1731
1832const openDemoInEditor = ( demoPath ) => spawn ( 'code' , [ demoPath ] , { shell : true } ) ;
1933
20- const addDemo = async ( category , group , meta ) => {
21- const demo = await promptsQuestions . askDemo ( meta , category , group ) ;
34+ const addDemo = async ( meta , pathParts ) => {
35+ const demo = await promptsQuestions . askDemo ( meta , pathParts ) ;
2236 let demoPath ;
2337 let missingApproaches = [ ] ;
2438
2539 if ( demo . name === 'new' ) {
40+ const equivalents = await promptsQuestions . askEquivalents ( ) ;
2641 const widget = await promptsQuestions . askWidget ( baseDemosDir ) ;
2742 if ( widget . name === 'new' ) {
2843 const pathToNewWidget = path . join ( baseDemosDir , widget . newName ) ;
@@ -35,17 +50,17 @@ const addDemo = async (category, group, meta) => {
3550 }
3651 menuMetaUtils . addDemo (
3752 meta ,
38- category . name ,
39- group . name ,
53+ pathParts ,
4054 demo . newName ,
4155 widget . newName ? widget . newName : widget . name ,
56+ equivalents . value ,
4257 ) ;
58+ pathParts . push ( demo . newName . replace ( / / g, '' ) ) ;
4359 missingApproaches = existingApproaches ;
4460 } else {
61+ pathParts . push ( demo . name ) ;
4562 demoPath = fileSystemUtils . getDemoPathByMeta (
46- category . name ,
47- group . name ,
48- demo . name ,
63+ pathParts ,
4964 baseDemosDir ,
5065 meta ,
5166 ) ;
@@ -60,12 +75,19 @@ const addDemo = async (category, group, meta) => {
6075 if ( newOrExisting . choice === 'existing' ) {
6176 menuMetaUtils . updateDemoProperties (
6277 meta ,
63- category . name ,
64- group . name ,
65- demo . newName ,
78+ pathParts ,
6679 newOrExisting ,
6780 ) ;
6881 }
82+ if ( newOrExisting . choice === 'new' ) {
83+ const extraModulesAnswer = await promptsQuestions . askForExtraModules ( extraModules ) ;
84+ const modules = menuMetaUtils . prepareModules ( extraModulesAnswer . modules ) ;
85+ menuMetaUtils . addDemoModules (
86+ meta ,
87+ pathParts ,
88+ modules ,
89+ ) ;
90+ }
6991 fileSystemUtils . copyDemos (
7092 demoPath ,
7193 approaches . selectedApproaches ,
@@ -74,7 +96,6 @@ const addDemo = async (category, group, meta) => {
7496 baseDemosDir ,
7597 ) ;
7698 fileSystemUtils . saveMetaDataFile ( menuMetaFilePath , meta ) ;
77- console . log ( demoPath ) ;
7899 openDemoInEditor ( demoPath ) ;
79100} ;
80101
@@ -85,13 +106,23 @@ const mainRoutine = async (meta) => {
85106 fileSystemUtils . saveMetaDataFile ( menuMetaFilePath , meta ) ;
86107 console . log ( '-> New category has been added.' ) ;
87108 } else {
88- const group = await promptsQuestions . askGroup ( meta , category ) ;
89- if ( group . name === 'new' ) {
90- menuMetaUtils . addGroup ( meta , category . name , group . newName ) ;
91- fileSystemUtils . saveMetaDataFile ( menuMetaFilePath , meta ) ;
92- console . log ( '-> New group has been added.' ) ;
93- } else {
94- await addDemo ( category , group , meta ) ;
109+ const pathParts = [ category . name ] ;
110+ let shouldAskForGroup = true ;
111+ let group ;
112+ while ( shouldAskForGroup ) {
113+ group = await promptsQuestions . askGroup ( meta , pathParts ) ;
114+ if ( group . name === 'new' ) {
115+ menuMetaUtils . addGroup ( meta , pathParts , group . newName ) ;
116+ fileSystemUtils . saveMetaDataFile ( menuMetaFilePath , meta ) ;
117+ console . log ( '-> New group has been added.' ) ;
118+ shouldAskForGroup = false ;
119+ } else {
120+ pathParts . push ( group . name ) ;
121+ if ( menuMetaUtils . hasDemos ( meta , pathParts ) ) {
122+ shouldAskForGroup = false ;
123+ await addDemo ( meta , pathParts ) ;
124+ }
125+ }
95126 }
96127 }
97128} ;
0 commit comments