@@ -43,7 +43,6 @@ import {
43
43
} from " ../../../types" ;
44
44
import { useExportComponent } from " ../composables/useExportComponent" ;
45
45
import { createBoilerOptions , createBoilerComposition } from " ../right-sidebar/createBoilerFuncs"
46
- import { createBoilerOptions , createBoilerComposition } from " ../right-sidebar/createBoilerFuncs"
47
46
// import * as fs from "fs"
48
47
// import { fs } from "electron";
49
48
// import { path } from 'path';
@@ -86,7 +85,7 @@ const showExportProjectDialog = () => {
86
85
.catch ((err : Error ) => console .log (err ));
87
86
};
88
87
89
- export const writeFile = async (filePath : any , content : any ) => {
88
+ const writeFile = async (filePath : any , content : any ) => {
90
89
if (! filePath ) {
91
90
console .error (' filePath is undefined' );
92
91
return ;
@@ -95,18 +94,18 @@ export const writeFile = async(filePath: any, content: any) => {
95
94
.catch ((error : any ) => console .error (error ));
96
95
}
97
96
98
- export async function checkFileExists(path : string ) {
97
+ async function checkFileExists(path : string ) {
99
98
const fileExistBool = await ipcRenderer .invoke (' check-file-exists' , path );
100
99
return fileExistBool .status ;
101
100
};
102
101
103
- export const mkdirSync = async (... args : string []) => {
102
+ const mkdirSync = async (... args : string []) => {
104
103
await ipcRenderer .invoke (' mkdirSync' , [... args ])
105
-
104
+ . then (( response : any ) => console . log ( ' mkdirSync response is ' , response ))
106
105
.catch ((error : any ) => console .error (error ));
107
106
}
108
107
109
- export const pathJoin = (... args : string []) => {
108
+ const pathJoin = (... args : string []) => {
110
109
if (args .some (arg => arg === undefined )) { // undefined handler for if any args are undefined
111
110
console .error (' arguments are undefined)' );
112
111
return ;
@@ -253,10 +252,9 @@ const createComponentCode = async(
253
252
await writeFile (
254
253
componentLocation + " .vue" ,
255
254
await writeTemplate (componentName , children , routes .value ) +
256
- await writeStyle (componentName )
255
+ await writeStyle (componentName )
257
256
);
258
257
console .log (' finished write createComponent code' )
259
- // fs.writeFileSync() console.log('about to write createComponent code for not App')
260
258
} else {
261
259
if (store .composition === false ) {
262
260
// fs.writeFileSync(
@@ -265,9 +263,9 @@ const createComponentCode = async(
265
263
componentLocation + " .vue" ,
266
264
await writeComments (componentName ) +
267
265
await writeTemplate (componentName , children , routes .value ) +
268
- await createBoilerOptions (componentName , children )
266
+ await createBoilerOptions (componentName , children )
269
267
// + await writeStyle(componentName)
270
- );
268
+ );
271
269
console .log (' finished to write createComponent code' )
272
270
} else {
273
271
// fs.writeFileSync(
@@ -276,7 +274,7 @@ const createComponentCode = async(
276
274
componentLocation + " .vue" ,
277
275
await writeComments (componentName ) +
278
276
await writeTemplate (componentName , children , routes .value ) +
279
- await createBoilerComposition (componentName , children )
277
+ await createBoilerComposition (componentName , children )
280
278
// + await writeStyle(componentName)
281
279
);
282
280
console .log (' finished to write createComponent code' )
@@ -1009,45 +1007,91 @@ const createTSDeclaration = async(location: string) => {
1009
1007
const createStore = async (location : string ) => {
1010
1008
let str = ` import { createStore } from 'pinia';\n ` ;
1011
1009
str += ` \n const store = createStore({` ;
1012
- str += ` \n\t state () {` ;
1013
- str += ` \n\t\t return {` ;
1014
- if (! userState .value .length ) {
1015
- str += ` \n\t\t\t //placeholder for state` ;
1016
- }
1017
- for (let i = 0 ; i < userState .value .length ; i ++ ) {
1018
- str += ` \n\t\t\t ${userState .value [i ]}: "PLACEHOLDER FOR VALUE",` ;
1019
- if (i === userState .value .length - 1 ) {
1020
- str = str .slice (0 , - 1 );
1010
+
1011
+
1012
+ if (store .composition ) { // in composition API
1013
+
1014
+
1015
+ str += ` \n\t state: () => ({` ;
1016
+ if (! userState .value .length ) {
1017
+ str += ` \n\t\t //PLACE YOUR STATE OBJECT HERE` ;
1021
1018
}
1022
- }
1023
- str += ` \n\t\t }` ;
1024
- str += ` \n\t },` ;
1025
- str += ` \n\t mutations: {` ;
1026
- if (! userActions .value .length ) {
1027
- str += ` \n\t\t\t //placeholder for mutations` ;
1028
- }
1029
- for (let i = 0 ; i < userActions .value .length ; i ++ ) {
1030
- str += ` \n\t\t ${userActions .value [i ]} (state) {` ;
1031
- str += ` \n\t\t\t //placeholder for your mutation` ;
1032
- str += ` \n\t\t },` ;
1033
- if (i === userActions .value .length - 1 ) {
1034
- str = str .slice (0 , - 1 );
1019
+ for (let i = 0 ; i < userState .value .length ; i ++ ) {
1020
+ str += ` \n\t\t ${userState .value [i ]}: "PLACE YOUR STATE'S VALUE HERE",` ;
1021
+ if (i === userState .value .length - 1 ) {
1022
+ str = str .slice (0 , - 1 );
1023
+ }
1024
+ }
1025
+ str += ` \n\t }),` ;
1026
+ str += ` \n\t actions: {` ;
1027
+ if (! userActions .value .length ) {
1028
+ str += ` \n\t\t\t //PLACE YOUR ACTIONS OBJECT HERE` ;
1029
+ }
1030
+ for (let i = 0 ; i < userActions .value .length ; i ++ ) {
1031
+ str += ` \n\t\t ${userActions .value [i ]} () {` ;
1032
+ if (userState .value [0 ]) {
1033
+ str += ` \n\t\t\t // EX. this.${userState .value [0 ]} += 1` ;
1034
+ } else {
1035
+ str += ` \n\t\t\t // EX. this.firstStateProperty += 1')` ;
1036
+ }
1037
+ str += ` \n\t\t },` ;
1038
+ if (i === userActions .value .length - 1 ) {
1039
+ str = str .slice (0 , - 1 );
1040
+ }
1041
+ }
1042
+ str += ` \n\t }` ;
1043
+
1044
+ } else { // in options API
1045
+
1046
+ str += ` \n\t state: {` ;
1047
+
1048
+ if (! userState .value .length ) {
1049
+ str += ` \n\t\t //PLACE YOUR STATE OBJECT HERE` ;
1050
+ }
1051
+ for (let i = 0 ; i < userState .value .length ; i ++ ) {
1052
+ str += ` \n\t\t ${userState .value [i ]}: "PLACE YOUR STATE'S VALUE HERE",` ;
1053
+ if (i === userState .value .length - 1 ) {
1054
+ str = str .slice (0 , - 1 );
1055
+ }
1035
1056
}
1036
- }
1037
- str += ` \n\t },` ;
1038
- str += ` \n\t actions: {` ;
1039
- if (! userActions .value .length ) {
1040
- str += ` \n\t\t\t //placeholder for actions` ;
1041
- }
1042
- for (let i = 0 ; i < userActions .value .length ; i ++ ) {
1043
- str += ` \n\t\t ${userActions .value [i ]} () {` ;
1044
- str += ` \n\t\t\t store.commit('${userActions .value [i ]}')` ;
1045
1057
str += ` \n\t\t },` ;
1046
- if (i === userActions .value .length - 1 ) {
1047
- str = str .slice (0 , - 1 );
1058
+
1059
+
1060
+ str += ` \n\t mutations: {` ;
1061
+ if (! userActions .value .length ) {
1062
+ str += ` \n\t\t\t //PLACE YOUR MUTATIONS OBJECT HERE` ;
1063
+ }
1064
+ for (let i = 0 ; i < userActions .value .length ; i ++ ) {
1065
+ str += ` \n\t\t ${userActions .value [i ]} (state) {` ;
1066
+ str += ` \n\t\t\t //placeholder for your mutation` ;
1067
+ str += ` \n\t\t },` ;
1068
+ if (i === userActions .value .length - 1 ) {
1069
+ str = str .slice (0 , - 1 );
1070
+ }
1071
+ }
1072
+ str += ` \n\t },` ;
1073
+ str += ` \n\t actions: {` ;
1074
+ if (! userActions .value .length ) {
1075
+ str += ` \n\t\t\t //PLACE YOUR ACTIONS OBJECT HERE` ;
1048
1076
}
1077
+ for (let i = 0 ; i < userActions .value .length ; i ++ ) {
1078
+ str += ` \n\t\t ${userActions .value [i ]} () {` ;
1079
+ str += ` \n\t\t\t store.commit('${userActions .value [i ]}')` ;
1080
+ str += ` \n\t\t },` ;
1081
+ if (i === userActions .value .length - 1 ) {
1082
+ str = str .slice (0 , - 1 );
1083
+ }
1084
+ }
1085
+ str += ` \n\t }` ;
1049
1086
}
1050
- str += ` \n\t }` ;
1087
+
1088
+
1089
+
1090
+
1091
+
1092
+
1093
+
1094
+
1051
1095
str += " \n })\n " ;
1052
1096
str += ` \n export default store;` ;
1053
1097
if (exportAsTypescript .value === " on" ) {
@@ -1087,10 +1131,9 @@ const createPackage = async(location: string) => {
1087
1131
str += ` \n\t },` ;
1088
1132
str += ` \n\t "dependencies": {` ;
1089
1133
str += ` \n\t\t "vue": "^3.4.21",` ;
1090
- str += ` \n\t\t "vue-router": "^4.0.12 ",` ;
1134
+ str += ` \n\t\t "vue-router": "^4.3.0 ",` ;
1091
1135
str += ` \n\t\t "pinia": "^2.1.7"` ;
1092
- str += ` \n\t\t "vuex": "^4.0.2"` ;
1093
- str += ` ,\n\t\t "element-plus": "^2.2.16" ` ;
1136
+ str += ` ,\n\t\t "element-plus": "^2.6.2" ` ;
1094
1137
1095
1138
if (exportOauth .value === " on" || exportOauthGithub .value === " on" ) {
1096
1139
str += ` ,\n\t\t "firebase": "^9.6.9" ` ;
@@ -1099,8 +1142,8 @@ const createPackage = async(location: string) => {
1099
1142
str += ` \n\t "devDependencies": {` ;
1100
1143
str += ` \n\t\t "@vitejs/plugin-vue": "^5.0.4",` ;
1101
1144
str += ` \n\t\t "eslint": "^8.5.0",` ;
1102
- str += ` \n\t\t "eslint-plugin-vue": "^8.2 .0",` ;
1103
- str += ` \n\t\t "vite": "^5.2.0 "` ;
1145
+ str += ` \n\t\t "eslint-plugin-vue": "^9.24 .0",` ;
1146
+ str += ` \n\t\t "vite": "^5.2.6 "` ;
1104
1147
if (importTest .value === " on" ) {
1105
1148
str += ` ,\n\t\t "@babel/core": "^7.12.16", ` ;
1106
1149
str += ` \n\t\t "@babel/eslint-parser": "^7.12.16",` ;
@@ -1114,12 +1157,12 @@ const createPackage = async(location: string) => {
1114
1157
str += ` \n\t\t "jest": "^27.0.5"` ;
1115
1158
}
1116
1159
if (exportAsTypescript .value === " on" ) {
1117
- str += ` ,\n\t\t "@rushstack/eslint-patch": "^1.1 .0", ` ;
1160
+ str += ` ,\n\t\t "@rushstack/eslint-patch": "^1.8 .0", ` ;
1118
1161
str += ` \n\t\t "@vue/tsconfig": "^0.1.3",` ;
1119
- str += ` \n\t\t "typescript": "^5.2.2 ",` ;
1120
- str += ` \n\t\t "vue-tsc": "^2.0.6 ",` ;
1121
- str += ` \n\t\t "@types/node": "^16 .11.25 ",` ;
1122
- str += ` \n\t\t "@vue/eslint-config-typescript": "^10 .0.0"` ;
1162
+ str += ` \n\t\t "typescript": "^5.4.3 ",` ;
1163
+ str += ` \n\t\t "vue-tsc": "^2.0.7 ",` ;
1164
+ str += ` \n\t\t "@types/node": "^20 .11.30 ",` ;
1165
+ str += ` \n\t\t "@vue/eslint-config-typescript": "^13 .0.0"` ;
1123
1166
}
1124
1167
str += ` \n\t }\n }` ;
1125
1168
// fs.writeFileSync(path.join(location, "package.json"), str);
0 commit comments