Skip to content

Commit 8a47007

Browse files
committed
removed console logs
1 parent 5317d8a commit 8a47007

File tree

1 file changed

+25
-33
lines changed

1 file changed

+25
-33
lines changed

src/components/left-sidebar/ComponentTab/ImportComponent.vue

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ export default {
102102
103103
const importObj = {}; //final output
104104
const htmlList = []; //array populated with substrings '<div>' '</div>' '<p>' etc.
105+
105106
let compName = data[0].slice(data[0].lastIndexOf('/') + 1).replace(/[^a-z0-9-_.]/gi, '').replace(/.vue/, '');
106107
const vueFile = fs.readFileSync(data[0], "utf8");
107-
108108
109109
for (const key in this.$store.state.componentMap) {
110110
if (this.$store.state.componentMap[key].componentName === compName) {
@@ -113,49 +113,47 @@ export default {
113113
}
114114
importObj.componentName = compName;
115115
116-
const htmlElementMap = {
117-
div: ["<div", "</div>"],
118-
button: ["<button", "</button>"],
119-
form: ["<form", "</form>"],
120-
img: ["<img", ""], //single
121-
link: ['<a href="#"', ""], //single
122-
list: ["<li", "</li>"],
123-
paragraph: ["<p", "</p>"],
124-
"list-ol": ["<ol", "</ol>"],
125-
"list-ul": ["<ul", "</ul>"],
126-
input: ["<input", ""], //single
127-
navbar: ["<nav", "</nav>"],
128-
header: ["<header", "</header>"],
129-
footer: ["<footer", "</footer>"],
130-
meta: ["<meta", "</meta>"],
131-
h1: ["<h1", "</h1>"],
132-
h2: ["<h2", "</h2>"],
133-
h3: ["<h3", "</h3>"],
134-
h4: ["<h4", "</h4>"],
135-
h5: ["<h5", "</h5>"],
136-
h6: ["<h6", "</h6>"],
116+
const htmlElementMap = { //OverVue state management only handles these HTML tags.
117+
div: ["<div>", "</div>"],
118+
button: ["<button>", "</button>"],
119+
form: ["<form>", "</form>"],
120+
img: ["<img>", ""],
121+
link: ['<a href="#"/>', ""],
122+
list: ["<li>", "</li>"],
123+
paragraph: ["<p>", "</p>"],
124+
"list-ol": ["<ol>", "</ol>"],
125+
"list-ul": ["<ul>", "</ul>"],
126+
input: ["<input />", ""],
127+
navbar: ["<nav>", "</nav>"],
128+
header:["<header>", "</header>"],
129+
footer:["<footer>", "</footer>"],
130+
meta: ["<meta>", "</meta>"],
131+
h1:["<h1>", "</h1>"],
132+
h2:["<h2>", "</h2>"],
133+
h3:["<h3>", "</h3>"],
134+
h4:["<h4>", "</h4>"],
135+
h5:["<h5>", "</h5>"],
136+
h6:["<h6>", "</h6>"],
137137
};
138138
139139
140140
let htmlString = vueFile.substring(vueFile.indexOf('<template >') + 10, vueFile.indexOf('</template>'));
141141
let scriptString = vueFile.substring(vueFile.indexOf(`<script>`) + 8, vueFile.indexOf(`/script>`) - 1)
142-
142+
143143
htmlParser(htmlString);
144144
importObj.props = this.parsingStringToProps(scriptString);
145145
importObj.actions = this.parsingStringToAction(scriptString);
146146
importObj.state = this.parsingStringToState(scriptString);
147147
148148
htmlList.pop(); htmlList.shift(); //OverVue adds a <div></div> wrapper to all components. remove this before importing.
149-
console.log(htmlList)
149+
150150
let groupings = findGroupings(htmlList);
151151
let groupingObj = objectGenerator(groupings);
152152
let groupingArray = [];
153153
for (const key in groupingObj) {
154154
groupingArray.push(groupingObj[key])
155155
}
156156
importObj.htmlList = groupingArray;
157-
console.log('importObj:')
158-
console.log(importObj)
159157
this.createImport(importObj) //send the importObj to CreateComponent.
160158
161159
/**
@@ -217,8 +215,6 @@ console.log(htmlList)
217215
*/
218216
219217
function findGroupings(array) {
220-
console.log("grouping:")
221-
console.log(array)
222218
let count = 0; //tracks where the parent ends
223219
let stopIndexes = []; //an array that will be used to slice out the parent/child relationships
224220
for (let i = 0; i < array.length; i++) {
@@ -256,8 +252,6 @@ console.log(htmlList)
256252
*/
257253
258254
function objectGenerator(array) {
259-
console.log("obj gen:")
260-
console.log(array)
261255
let groupingObj = {};
262256
for (let i = 0; i < array.length; i++) {
263257
for (const key in htmlElementMap) {
@@ -268,18 +262,16 @@ console.log(htmlList)
268262
}
269263
array[i].pop();
270264
array[i].shift();
271-
272265
if (array[i].length > 0) {
273266
const childGroupings = findGroupings(array[i]);
274267
const childrenObj = objectGenerator(childGroupings);
275268
const childrenArray = [];
276269
for (const key in childrenObj) {
277270
childrenArray.push(childrenObj[key])
278271
}
279-
console.log(groupingObj[i])
280272
groupingObj[i].children = childrenArray;
281273
} else {
282-
// groupingObj[i].children = [];
274+
groupingObj[i].children = [];
283275
}
284276
}
285277
return groupingObj;

0 commit comments

Comments
 (0)