@@ -104,6 +104,7 @@ export default {
104
104
const htmlList = []; // array populated with substrings '<div>' '</div>' '<p>' etc.
105
105
let compName = data[0 ].slice (data[0 ].lastIndexOf (' /' ) + 1 ).replace (/ [^ a-z0-9 -_. ] / gi , ' ' ).replace (/ . vue/ , ' ' );
106
106
const vueFile = fs .readFileSync (data[0 ], " utf8" );
107
+
107
108
108
109
for (const key in this .$store .state .componentMap ) {
109
110
if (this .$store .state .componentMap [key].componentName === compName) {
@@ -138,21 +139,23 @@ export default {
138
139
139
140
let htmlString = vueFile .substring (vueFile .indexOf (' <template >' ) + 10 , vueFile .indexOf (' </template>' ));
140
141
let scriptString = vueFile .substring (vueFile .indexOf (` <script>` ) + 8 , vueFile .indexOf (` /script>` ) - 1 )
141
-
142
+
142
143
htmlParser (htmlString);
143
144
importObj .props = this .parsingStringToProps (scriptString);
144
145
importObj .actions = this .parsingStringToAction (scriptString);
145
146
importObj .state = this .parsingStringToState (scriptString);
146
147
147
148
htmlList .pop (); htmlList .shift (); // OverVue adds a <div></div> wrapper to all components. remove this before importing.
148
-
149
+ console . log (htmlList)
149
150
let groupings = findGroupings (htmlList);
150
151
let groupingObj = objectGenerator (groupings);
151
152
let groupingArray = [];
152
153
for (const key in groupingObj) {
153
154
groupingArray .push (groupingObj[key])
154
155
}
155
156
importObj .htmlList = groupingArray;
157
+ console .log (' importObj:' )
158
+ console .log (importObj)
156
159
this .createImport (importObj) // send the importObj to CreateComponent.
157
160
158
161
/**
@@ -214,6 +217,8 @@ export default {
214
217
*/
215
218
216
219
function findGroupings (array ) {
220
+ console .log (" grouping:" )
221
+ console .log (array)
217
222
let count = 0 ; // tracks where the parent ends
218
223
let stopIndexes = []; // an array that will be used to slice out the parent/child relationships
219
224
for (let i = 0 ; i < array .length ; i++ ) {
@@ -251,6 +256,8 @@ export default {
251
256
*/
252
257
253
258
function objectGenerator (array ) {
259
+ console .log (" obj gen:" )
260
+ console .log (array)
254
261
let groupingObj = {};
255
262
for (let i = 0 ; i < array .length ; i++ ) {
256
263
for (const key in htmlElementMap) {
@@ -261,16 +268,18 @@ export default {
261
268
}
262
269
array[i].pop ();
263
270
array[i].shift ();
271
+
264
272
if (array[i].length > 0 ) {
265
273
const childGroupings = findGroupings (array[i]);
266
274
const childrenObj = objectGenerator (childGroupings);
267
275
const childrenArray = [];
268
276
for (const key in childrenObj) {
269
277
childrenArray .push (childrenObj[key])
270
278
}
279
+ console .log (groupingObj[i])
271
280
groupingObj[i].children = childrenArray;
272
281
} else {
273
- groupingObj[i].children = [];
282
+ // groupingObj[i].children = [];
274
283
}
275
284
}
276
285
return groupingObj;
0 commit comments