@simitgroup/simpleapp-generator 1.0.19 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -10
- package/backend1/.env +5 -0
- package/backend1/.eslintrc.js +25 -0
- package/backend1/.prettierrc +4 -0
- package/backend1/README.md +73 -0
- package/backend1/nest-cli.json +8 -0
- package/backend1/package.json +75 -0
- package/backend1/pnpm-lock.yaml +5459 -0
- package/backend1/src/app.controller.js +71 -0
- package/backend1/src/app.controller.js.map +1 -0
- package/backend1/src/app.controller.spec.js +21 -0
- package/backend1/src/app.controller.spec.js.map +1 -0
- package/backend1/src/app.controller.spec.ts +22 -0
- package/backend1/src/app.controller.ts +12 -0
- package/backend1/src/app.module.js +67 -0
- package/backend1/src/app.module.js.map +1 -0
- package/backend1/src/app.module.ts +10 -0
- package/backend1/src/app.service.js +64 -0
- package/backend1/src/app.service.js.map +1 -0
- package/backend1/src/app.service.ts +8 -0
- package/backend1/src/class/SimpleAppController.js +38 -0
- package/backend1/src/class/SimpleAppController.js.map +1 -0
- package/backend1/src/class/SimpleAppController.ts +69 -0
- package/backend1/src/class/SimpleAppService.js +264 -0
- package/backend1/src/class/SimpleAppService.js.map +1 -0
- package/backend1/src/class/SimpleAppService.ts +213 -0
- package/backend1/src/main.js +22 -0
- package/backend1/src/main.js.map +1 -0
- package/backend1/src/main.ts +20 -0
- package/backend1/test/app.e2e-spec.js +45 -0
- package/backend1/test/app.e2e-spec.js.map +1 -0
- package/backend1/test/app.e2e-spec.ts +24 -0
- package/backend1/test/jest-e2e.json +9 -0
- package/backend1/tsconfig.build.json +4 -0
- package/backend1/tsconfig.json +1 -0
- package/dist/createproject.js +6 -1
- package/dist/createproject.js.map +1 -1
- package/dist/framework.js +161 -0
- package/dist/framework.js.map +1 -0
- package/dist/generate.js +2 -2
- package/dist/generate.js.map +1 -1
- package/dist/index.js +54 -58
- package/dist/index.js.map +1 -1
- package/dist/index2.js +118 -0
- package/dist/index2.js.map +1 -0
- package/dist/installdependency.js +20 -0
- package/dist/installdependency.js.map +1 -0
- package/dist/installnest.js +2 -0
- package/dist/installnest.js.map +1 -0
- package/dist/installnuxt.js +2 -0
- package/dist/installnuxt.js.map +1 -0
- package/dist/validation.js +2 -0
- package/dist/validation.js.map +1 -0
- package/frontend1/README.md +63 -0
- package/frontend1/app.vue +8 -0
- package/frontend1/assets/css/tailwind.css +28 -0
- package/frontend1/components/CrudSimple.vue +112 -0
- package/frontend1/components/DebugDocumentData.vue +20 -0
- package/frontend1/components/EventMonitor.vue +79 -0
- package/frontend1/components/Menus.vue +18 -0
- package/frontend1/layouts/default.vue +10 -0
- package/frontend1/nuxt.config.js +42 -0
- package/frontend1/nuxt.config.js.map +1 -0
- package/frontend1/nuxt.config.ts +42 -0
- package/frontend1/package-lock.json +11877 -0
- package/frontend1/package.json +38 -0
- package/frontend1/pages/index.vue +3 -0
- package/frontend1/plugins/simpleapp.js +73 -0
- package/frontend1/plugins/simpleapp.js.map +1 -0
- package/frontend1/plugins/simpleapp.ts +73 -0
- package/frontend1/pnpm-lock.yaml +8339 -0
- package/frontend1/public/favicon.ico +0 -0
- package/frontend1/server/api/[...].js +117 -0
- package/frontend1/server/api/[...].js.map +1 -0
- package/frontend1/server/api/[...].ts +131 -0
- package/frontend1/server/tsconfig.json +3 -0
- package/frontend1/tailwind.config.js +10 -0
- package/frontend1/tailwind.config.js.map +1 -0
- package/frontend1/tailwind.config.ts +9 -0
- package/frontend1/tsconfig.json +4 -0
- package/openapitools.json +0 -0
- package/package.json +2 -6
- package/sampleconfig.json +2 -2
- package/src/createproject.ts +5 -0
- package/src/framework.ts +133 -0
- package/src/generate.ts +2 -2
- package/src/index.ts +38 -69
- package/src/index2.ts +132 -0
- package/src/installdependency.sh +5 -0
- package/src/installdependency.ts +4 -0
- package/src/installnest.ts +0 -0
- package/src/installnuxt.ts +0 -0
- package/src/validation.ts +0 -0
- package/templates/basic/pageindex.vue.eta +9 -9
- package/templates/nuxt/plugins.simpleapp.ts.eta +3 -3
|
Binary file
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
// import { getServerSession } from '#auth'
|
|
8
|
+
// import type { Session } from 'next-auth';
|
|
9
|
+
exports.default = defineEventHandler(async (event) => {
|
|
10
|
+
// let session: Session | null = null
|
|
11
|
+
// try {
|
|
12
|
+
// session = await getServerSession(event)
|
|
13
|
+
// } catch (error) {
|
|
14
|
+
// return sendRedirect(event, '/login', 401)
|
|
15
|
+
// }
|
|
16
|
+
return new Promise(async (resolve, reject) => {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f;
|
|
18
|
+
// if(!session || !session.accessToken) {
|
|
19
|
+
// reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
20
|
+
// throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
21
|
+
// }
|
|
22
|
+
// console.log("------hihi------")
|
|
23
|
+
const seperateSymbol = '.';
|
|
24
|
+
// const seperateSymbol = '&';
|
|
25
|
+
const key = (_b = (_a = event.context.params) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : '';
|
|
26
|
+
const platform = (_d = (_c = event.context.params) === null || _c === void 0 ? void 0 : _c.platform) !== null && _d !== void 0 ? _d : '';
|
|
27
|
+
const otherLink = (_f = (_e = event.context.params) === null || _e === void 0 ? void 0 : _e._) !== null && _f !== void 0 ? _f : '';
|
|
28
|
+
// console.error("event.context???",event.context)
|
|
29
|
+
// const accessToken = session?.accessToken;
|
|
30
|
+
// const allowPlatform = ['report-api', 'cloudapi'];
|
|
31
|
+
// if(!key || !platform || !allowPlatform.includes(platform) || !accessToken) {
|
|
32
|
+
// reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
33
|
+
// // throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
34
|
+
// }
|
|
35
|
+
// let tenantKey = '', organizationKey = '';
|
|
36
|
+
// let xOrg = '';
|
|
37
|
+
// if(key !== 'system') {
|
|
38
|
+
// [tenantKey, organizationKey] = key.split(seperateSymbol);
|
|
39
|
+
// xOrg = `${tenantKey}/${organizationKey}/`;
|
|
40
|
+
// }
|
|
41
|
+
// if(key === 'system' && platform == 'cloudapi') {
|
|
42
|
+
// // xOrg = 'MC0wLTA'
|
|
43
|
+
// }
|
|
44
|
+
let forwardData = {};
|
|
45
|
+
const req = event.node.req;
|
|
46
|
+
if (req.method == 'POST' || req.method == 'PUT') {
|
|
47
|
+
forwardData = await readBody(event);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
forwardData = getQuery(event);
|
|
51
|
+
}
|
|
52
|
+
// if(typeof forwardData === "object" && "_branch" in forwardData) {
|
|
53
|
+
// xOrg = xOrg + forwardData._branch;
|
|
54
|
+
// delete forwardData._branch;
|
|
55
|
+
// }
|
|
56
|
+
const frontEndRes = event.node.res;
|
|
57
|
+
const url = process.env.SIMPLEAPP_BACKEND_URL + platform + '/' + otherLink;
|
|
58
|
+
// console.warn('backend server-----',req.method,url,forwardData)
|
|
59
|
+
const axiosConfig = {
|
|
60
|
+
method: req.method,
|
|
61
|
+
url: url,
|
|
62
|
+
headers: {
|
|
63
|
+
// Authorization: `Bearer ${accessToken}`,
|
|
64
|
+
// 'X-Org': `${xOrg}`,
|
|
65
|
+
},
|
|
66
|
+
data: forwardData,
|
|
67
|
+
params: forwardData,
|
|
68
|
+
};
|
|
69
|
+
// if(key === 'system') {
|
|
70
|
+
// axiosConfig.headers["X-Global"] = true;
|
|
71
|
+
// delete axiosConfig.headers["X-Org"];
|
|
72
|
+
// }
|
|
73
|
+
// if(otherLink.includes('avatar')) {
|
|
74
|
+
// axiosConfig.responseType = 'arraybuffer';
|
|
75
|
+
// // axiosConfig.headers['Acceptable'] = 'text/html,image/avif,image/webp,image/apng';
|
|
76
|
+
// }
|
|
77
|
+
(0, axios_1.default)(axiosConfig).then((res) => {
|
|
78
|
+
if (res.headers['content-type'] === 'image/png') {
|
|
79
|
+
// Set the response headers for the image
|
|
80
|
+
frontEndRes.setHeader('Content-Type', 'image/png');
|
|
81
|
+
frontEndRes.setHeader('Content-Disposition', 'inline');
|
|
82
|
+
// Send the image data as the response body
|
|
83
|
+
frontEndRes.end(Buffer.from(res.data, 'binary'));
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// For non-image responses, set the Content-Type header and send the response body
|
|
87
|
+
// setHeader(event, 'Content-type', <string>res.headers['Content-Type']);
|
|
88
|
+
frontEndRes.statusCode = res.status;
|
|
89
|
+
if (res.statusText) {
|
|
90
|
+
frontEndRes.statusMessage = res.statusText;
|
|
91
|
+
}
|
|
92
|
+
resolve(res.data);
|
|
93
|
+
}
|
|
94
|
+
}).catch((error) => {
|
|
95
|
+
// console.log("==============================================================")
|
|
96
|
+
// console.log('@@@@@@@@@@@@@ API error', error)
|
|
97
|
+
// console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
|
|
98
|
+
// console.log('######### response', error.response)
|
|
99
|
+
// console.log('#####################################')
|
|
100
|
+
// console.log(axiosConfig);
|
|
101
|
+
// console.log('#####################################')
|
|
102
|
+
var _a;
|
|
103
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) && error.response.status == '401') {
|
|
104
|
+
return reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
105
|
+
// throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
106
|
+
}
|
|
107
|
+
// reject(error.data)
|
|
108
|
+
reject({ statusMessage: error.response.statusText, statusCode: error.response.status });
|
|
109
|
+
// resolve({ status: 'ok' })
|
|
110
|
+
// throw createError({ statusMessage: 'Bad Requests', statusCode: 404 })
|
|
111
|
+
});
|
|
112
|
+
// resolve({
|
|
113
|
+
// status: 'ok'
|
|
114
|
+
// })
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=%5B...%5D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"[...].js","sourceRoot":"","sources":["[...].ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
// import { getServerSession } from '#auth'
|
|
3
|
+
// import type { Session } from 'next-auth';
|
|
4
|
+
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
// let session: Session | null = null
|
|
7
|
+
// try {
|
|
8
|
+
// session = await getServerSession(event)
|
|
9
|
+
// } catch (error) {
|
|
10
|
+
// return sendRedirect(event, '/login', 401)
|
|
11
|
+
// }
|
|
12
|
+
|
|
13
|
+
return new Promise<any>(async (resolve, reject) => {
|
|
14
|
+
// if(!session || !session.accessToken) {
|
|
15
|
+
// reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
16
|
+
// throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
17
|
+
// }
|
|
18
|
+
// console.log("------hihi------")
|
|
19
|
+
const seperateSymbol = '.';
|
|
20
|
+
// const seperateSymbol = '&';
|
|
21
|
+
const key = event.context.params?.key ?? ''
|
|
22
|
+
const platform = event.context.params?.platform ?? ''
|
|
23
|
+
const otherLink = event.context.params?._ ?? ''
|
|
24
|
+
|
|
25
|
+
// console.error("event.context???",event.context)
|
|
26
|
+
// const accessToken = session?.accessToken;
|
|
27
|
+
|
|
28
|
+
// const allowPlatform = ['report-api', 'cloudapi'];
|
|
29
|
+
// if(!key || !platform || !allowPlatform.includes(platform) || !accessToken) {
|
|
30
|
+
// reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
31
|
+
// // throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
32
|
+
// }
|
|
33
|
+
|
|
34
|
+
// let tenantKey = '', organizationKey = '';
|
|
35
|
+
// let xOrg = '';
|
|
36
|
+
|
|
37
|
+
// if(key !== 'system') {
|
|
38
|
+
// [tenantKey, organizationKey] = key.split(seperateSymbol);
|
|
39
|
+
// xOrg = `${tenantKey}/${organizationKey}/`;
|
|
40
|
+
// }
|
|
41
|
+
|
|
42
|
+
// if(key === 'system' && platform == 'cloudapi') {
|
|
43
|
+
// // xOrg = 'MC0wLTA'
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
let forwardData: any = {};
|
|
47
|
+
|
|
48
|
+
const req = event.node.req;
|
|
49
|
+
|
|
50
|
+
if(req.method == 'POST' || req.method == 'PUT') {
|
|
51
|
+
|
|
52
|
+
forwardData = await readBody(event);
|
|
53
|
+
} else {
|
|
54
|
+
forwardData = getQuery(event);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// if(typeof forwardData === "object" && "_branch" in forwardData) {
|
|
58
|
+
// xOrg = xOrg + forwardData._branch;
|
|
59
|
+
// delete forwardData._branch;
|
|
60
|
+
// }
|
|
61
|
+
|
|
62
|
+
const frontEndRes = event.node.res;
|
|
63
|
+
const url = process.env.SIMPLEAPP_BACKEND_URL +platform + '/' + otherLink;
|
|
64
|
+
// console.warn('backend server-----',req.method,url,forwardData)
|
|
65
|
+
const axiosConfig: any = {
|
|
66
|
+
method: req.method,
|
|
67
|
+
url: url,
|
|
68
|
+
headers: {
|
|
69
|
+
// Authorization: `Bearer ${accessToken}`,
|
|
70
|
+
// 'X-Org': `${xOrg}`,
|
|
71
|
+
},
|
|
72
|
+
data: forwardData,
|
|
73
|
+
params: forwardData,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// if(key === 'system') {
|
|
77
|
+
// axiosConfig.headers["X-Global"] = true;
|
|
78
|
+
// delete axiosConfig.headers["X-Org"];
|
|
79
|
+
// }
|
|
80
|
+
|
|
81
|
+
// if(otherLink.includes('avatar')) {
|
|
82
|
+
// axiosConfig.responseType = 'arraybuffer';
|
|
83
|
+
// // axiosConfig.headers['Acceptable'] = 'text/html,image/avif,image/webp,image/apng';
|
|
84
|
+
// }
|
|
85
|
+
|
|
86
|
+
axios(axiosConfig).then((res) => {
|
|
87
|
+
if (res.headers['content-type'] === 'image/png') {
|
|
88
|
+
// Set the response headers for the image
|
|
89
|
+
frontEndRes.setHeader('Content-Type', 'image/png');
|
|
90
|
+
frontEndRes.setHeader('Content-Disposition', 'inline');
|
|
91
|
+
|
|
92
|
+
// Send the image data as the response body
|
|
93
|
+
frontEndRes.end(Buffer.from(res.data, 'binary'));
|
|
94
|
+
} else {
|
|
95
|
+
// For non-image responses, set the Content-Type header and send the response body
|
|
96
|
+
// setHeader(event, 'Content-type', <string>res.headers['Content-Type']);
|
|
97
|
+
|
|
98
|
+
frontEndRes.statusCode = res.status;
|
|
99
|
+
if(res.statusText) {
|
|
100
|
+
frontEndRes.statusMessage = res.statusText;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
resolve(res.data);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
}).catch((error) => {
|
|
107
|
+
// console.log("==============================================================")
|
|
108
|
+
// console.log('@@@@@@@@@@@@@ API error', error)
|
|
109
|
+
// console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
|
|
110
|
+
// console.log('######### response', error.response)
|
|
111
|
+
// console.log('#####################################')
|
|
112
|
+
// console.log(axiosConfig);
|
|
113
|
+
// console.log('#####################################')
|
|
114
|
+
|
|
115
|
+
if (error.response?.status && error.response.status == '401') {
|
|
116
|
+
return reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
117
|
+
// throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// reject(error.data)
|
|
121
|
+
reject({ statusMessage: error.response.statusText, statusCode: error.response.status });
|
|
122
|
+
// resolve({ status: 'ok' })
|
|
123
|
+
// throw createError({ statusMessage: 'Bad Requests', statusCode: 404 })
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
// resolve({
|
|
127
|
+
// status: 'ok'
|
|
128
|
+
// })
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Default are on https://tailwindcss.nuxtjs.org/tailwind/config#default-configuration
|
|
4
|
+
exports.default = {
|
|
5
|
+
theme: {},
|
|
6
|
+
plugins: [],
|
|
7
|
+
content: [],
|
|
8
|
+
darkMode: 'class',
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=tailwind.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind.config.js","sourceRoot":"","sources":["tailwind.config.ts"],"names":[],"mappings":";;AAEA,sFAAsF;AACtF,kBAAgC;IAC9B,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,OAAO;CAClB,CAAA"}
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simitgroup/simpleapp-generator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "frontend nuxtjs and backend nests code generator using jsonschema",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,12 +20,9 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@apidevtools/json-schema-ref-parser": "^10.1.0",
|
|
23
|
-
"@nestjs/config": "^3.0.0",
|
|
24
|
-
"@nestjs/mongoose": "^10.0.1",
|
|
25
|
-
"@nestjs/swagger": "^7.1.8",
|
|
26
23
|
"ajv": "^8.12.0",
|
|
27
24
|
"ajv-formats": "^2.1.1",
|
|
28
|
-
"axios": "^1.
|
|
25
|
+
"axios": "^1.5.0",
|
|
29
26
|
"child_process": "^1.0.2",
|
|
30
27
|
"cli-color": "^2.0.3",
|
|
31
28
|
"commander": "^11.0.0",
|
|
@@ -34,7 +31,6 @@
|
|
|
34
31
|
"fs": "0.0.1-security",
|
|
35
32
|
"json-schema": "^0.4.0",
|
|
36
33
|
"json-schema-ref-parser": "^9.0.9",
|
|
37
|
-
"mongoose": "^7.4.4",
|
|
38
34
|
"path": "^0.12.7",
|
|
39
35
|
"tslog": "^4.9.1"
|
|
40
36
|
},
|
package/sampleconfig.json
CHANGED
package/src/createproject.ts
CHANGED
|
@@ -29,6 +29,11 @@ const checkNestCli = (callback)=>{
|
|
|
29
29
|
}
|
|
30
30
|
})
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
export const installDependency = async () =>{
|
|
34
|
+
log.info("installDependency 'npm install -g pnpm @nestjs/cli @openapitools/openapi-generator-cli nuxi'")
|
|
35
|
+
return await exec("npm install -g pnpm @nestjs/cli @openapitools/openapi-generator-cli nuxi")
|
|
36
|
+
}
|
|
32
37
|
export const createNuxt= (targetfolder:string,callback)=>{
|
|
33
38
|
log.info("setting up nuxt frontend ${targetfolder}")
|
|
34
39
|
|
package/src/framework.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import {spawn,exec} from "child_process"
|
|
3
|
+
import { Logger, ILogObj } from "tslog";
|
|
4
|
+
import * as constants from './constant'
|
|
5
|
+
import {Eta} from 'eta';
|
|
6
|
+
const log: Logger<ILogObj> = new Logger();
|
|
7
|
+
|
|
8
|
+
export let backendFolder='';
|
|
9
|
+
export let frontendFolder='';
|
|
10
|
+
//create empty nest project
|
|
11
|
+
export const runCreateNest= (bkFolder:string,callback:Function) =>{
|
|
12
|
+
backendFolder=bkFolder
|
|
13
|
+
if(!fs.existsSync(backendFolder)){
|
|
14
|
+
const child = spawn('npm',['install','-g','pnpm', '@nestjs/cli', '@openapitools/openapi-generator-cli', 'nuxi'],
|
|
15
|
+
{ stdio: 'inherit',})
|
|
16
|
+
child.on('close',(exitCode)=>{
|
|
17
|
+
const child2 = spawn('nest',['new', '-p', 'pnpm', backendFolder],{ stdio: "inherit"})
|
|
18
|
+
child2.on('close',(exitCode)=>{
|
|
19
|
+
callback()
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
}else{
|
|
23
|
+
callback()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//create empty nuxt project
|
|
27
|
+
export const runCreateNuxt = (fefolder:string,callback:Function) =>{
|
|
28
|
+
frontendFolder=fefolder
|
|
29
|
+
if(!fs.existsSync(frontendFolder)){
|
|
30
|
+
const child3 = spawn('npx',['nuxi@latest','init',frontendFolder],{ stdio: 'inherit',})
|
|
31
|
+
child3.on('close',(exitCode)=>{
|
|
32
|
+
callback()
|
|
33
|
+
})
|
|
34
|
+
}else{
|
|
35
|
+
callback()
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const prepareNest = (targetfolder:string,callback:Function)=>{
|
|
40
|
+
|
|
41
|
+
log.info(`creating backend project ${targetfolder}`)
|
|
42
|
+
exec(`cd ${targetfolder};pnpm install --save @nestjs/swagger @nestjs/mongoose mongoose ajv ajv-formats @nestjs/config`,async (error, stdout, stderr)=>{
|
|
43
|
+
// log.info(`dependency installed`)
|
|
44
|
+
if(!error){
|
|
45
|
+
exec(`pnpm install ajv ajv-formats axios json-schema`, (error, stdout, stderr)=>{
|
|
46
|
+
const eta = new Eta({views: constants.templatedir});
|
|
47
|
+
const variables=[]
|
|
48
|
+
const txtEnv = eta.render('./nest.env.eta', variables);
|
|
49
|
+
const txtMain = eta.render('./nest.main.eta', variables);
|
|
50
|
+
|
|
51
|
+
fs.writeFileSync(`${targetfolder}/.env`, txtEnv);
|
|
52
|
+
fs.writeFileSync(`${targetfolder}/src/main.ts`, txtMain);
|
|
53
|
+
const tsconfigpath = process.cwd()+'/'+`${targetfolder}/tsconfig.json`
|
|
54
|
+
const tsconfig = require(tsconfigpath)
|
|
55
|
+
tsconfig.compilerOptions.esModuleInterop=true
|
|
56
|
+
tsconfig.compilerOptions.resolveJsonModule=true
|
|
57
|
+
fs.writeFileSync(tsconfigpath, JSON.stringify(tsconfig));
|
|
58
|
+
|
|
59
|
+
log.info("nest project completed")
|
|
60
|
+
callback()
|
|
61
|
+
})
|
|
62
|
+
} else{
|
|
63
|
+
log.error(stderr)
|
|
64
|
+
throw error
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
//prepare nuxt project for simpleapp generator
|
|
69
|
+
export const prepareNuxt = (targetfolder:string,callback:Function)=>{
|
|
70
|
+
if(!fs.existsSync(`${targetfolder}/.env`)){
|
|
71
|
+
//asume no environment. prepare now
|
|
72
|
+
exec(`cd ${targetfolder};pnpm install;pnpm install -D @types/node @vueuse/nuxt @sidebase/nuxt-auth @vueuse/core nuxt-security prettier @nuxtjs/tailwindcss`, (error, stdout, stderr)=>{
|
|
73
|
+
//;pnpm install
|
|
74
|
+
console.log(error, stdout, stderr)
|
|
75
|
+
exec(`cd ${targetfolder};pnpm install --save ajv dotenv @fullcalendar/core @fullcalendar/vue3 quill uuid ajv-formats primeflex primeicons prettier primevue axios json-schema mitt @simitgroup/simpleapp-vue-component@latest`, (error, stdout, stderr)=>{
|
|
76
|
+
console.log(error, stdout, stderr)
|
|
77
|
+
|
|
78
|
+
fs.mkdirSync(`${targetfolder}/assets/css/`,{recursive:true})
|
|
79
|
+
fs.mkdirSync(`${targetfolder}/layouts`,{recursive:true})
|
|
80
|
+
fs.mkdirSync(`${targetfolder}/components`,{recursive:true})
|
|
81
|
+
fs.mkdirSync(`${targetfolder}/server/api`,{recursive:true})
|
|
82
|
+
fs.mkdirSync(`${targetfolder}/pages`,{recursive:true})
|
|
83
|
+
fs.mkdirSync(`${targetfolder}/plugins`,{recursive:true})
|
|
84
|
+
const eta = new Eta({views: `${constants.templatedir}/nuxt`});
|
|
85
|
+
const variables=[]
|
|
86
|
+
const writes = {
|
|
87
|
+
'./app.vue.eta':'app.vue',
|
|
88
|
+
'./components.eventmonitor.vue.eta':'components/EventMonitor.vue',
|
|
89
|
+
'./components.menus.vue.eta':'components/Menus.vue',
|
|
90
|
+
'./components.crudsimple.vue.eta':'components/CrudSimple.vue',
|
|
91
|
+
'./components.debugdocdata.vue.eta':'components/DebugDocumentData.vue',
|
|
92
|
+
'./layouts.default.vue.eta':'layouts/default.vue',
|
|
93
|
+
'./server.api.ts.eta':'server/api/[...].ts',
|
|
94
|
+
'./nuxt.config.ts.eta':'nuxt.config.ts',
|
|
95
|
+
'./pages.index.vue.eta':'pages/index.vue',
|
|
96
|
+
'./plugins.simpleapp.ts.eta':'plugins/simpleapp.ts',
|
|
97
|
+
'./tailwind.config.ts.eta':'tailwind.config.ts',
|
|
98
|
+
'./tailwind.css.eta':'assets/css/tailwind.css',
|
|
99
|
+
'./env.eta':'.env',
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const templates = Object.getOwnPropertyNames(writes)
|
|
103
|
+
for(let i=0; i<templates.length;i++){
|
|
104
|
+
const template = templates[i]
|
|
105
|
+
const filename = writes[template]
|
|
106
|
+
const txt = eta.render(template, variables);
|
|
107
|
+
const file =`${targetfolder}/${filename}`
|
|
108
|
+
log.info("writing ",file)
|
|
109
|
+
fs.writeFileSync(file, txt);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
log.info("nuxt project completed")
|
|
113
|
+
callback()
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
})
|
|
117
|
+
}else{
|
|
118
|
+
//assume environment ready
|
|
119
|
+
callback()
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export const prettyNuxt = (frontendFolder:string)=>{
|
|
124
|
+
exec(`cd ${frontendFolder};npx prettier --write "./pages/**/*.vue" "./simpleapp/**/*" `)
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
export const prettyNest = (backendFolder:string)=>{
|
|
128
|
+
exec(`cd ${backendFolder};npx run format `)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export const prepareOpenApiClient = (openapi3Yaml:string,frontendFolder:string) => {
|
|
132
|
+
exec(`openapi-generator-cli generate -i ${openapi3Yaml} -o ${frontendFolder}/simpleapp/openapi -g typescript-axios --skip-validate-spec`)
|
|
133
|
+
}
|
package/src/generate.ts
CHANGED
|
@@ -21,7 +21,7 @@ const extjsonschema = '.jsonschema.json';
|
|
|
21
21
|
let jsonschemas = {};
|
|
22
22
|
const docs = [];
|
|
23
23
|
|
|
24
|
-
export const initialize = async (defFolder:string,backendfolder:string,frontendfolder:string) => {
|
|
24
|
+
export const initialize = async (defFolder:string,backendfolder:string,frontendfolder:string,callback:Function) => {
|
|
25
25
|
prepareEnvironments(backendfolder,frontendfolder)
|
|
26
26
|
let activatemodules:ModuleObject[]=[]
|
|
27
27
|
//
|
|
@@ -58,7 +58,7 @@ export const initialize = async (defFolder:string,backendfolder:string,frontend
|
|
|
58
58
|
log.info("Activated backend modules: ",JSON.stringify(activatemodules))
|
|
59
59
|
// log.info(activatemodules)
|
|
60
60
|
finalize(activatemodules,backendfolder,frontendfolder)
|
|
61
|
-
|
|
61
|
+
callback()
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
|
|
3
2
|
import { error } from "console"
|
|
4
|
-
|
|
3
|
+
import * as fw from './framework'
|
|
4
|
+
import * as generate from './generate'
|
|
5
5
|
const program = require("commander") // add this line
|
|
6
6
|
const Fieldtypes= require( './type')
|
|
7
|
-
const
|
|
8
|
-
const fs = require( 'fs')
|
|
9
|
-
const {createNuxt,createNest} =require( './createproject')
|
|
10
|
-
const {exec} = require( "child_process")
|
|
7
|
+
// const generate= require( './generate')
|
|
11
8
|
|
|
9
|
+
const fs = require( 'fs')
|
|
10
|
+
const createproject =require( './createproject')
|
|
11
|
+
const ps = require( "child_process")
|
|
12
12
|
const capitalizeFirstLetter= require( './libs')
|
|
13
13
|
const {Logger, ILogObj} = require( "tslog");
|
|
14
14
|
|
|
@@ -23,76 +23,45 @@ program
|
|
|
23
23
|
.version(version)
|
|
24
24
|
.description("An simpleapp CLI tool for generate frontend (vuejs) and backend(nestjs) codes")
|
|
25
25
|
.option("-c, --config-file <value>", 'configuration file content such as:{"definationsFolder":"./definations", "backendFolder":"./nestproject/src/docs", "frontendFolder":"./nuxt/server"}')
|
|
26
|
-
// .option("-s, --definations-folder <value>", "load defination files from which folder")
|
|
27
|
-
// .option("-b, --backend-folder <value>", "Create backend code at which folder")
|
|
28
|
-
// .option("-f, --frontend-folder <value>", "Create frontend code at which folder")
|
|
29
|
-
// .option("-i, --openapi3-yaml <value>", 'openapi3.yaml generated by backend server')
|
|
30
26
|
.parse(process.argv);
|
|
31
27
|
|
|
32
|
-
|
|
28
|
+
let path=''
|
|
33
29
|
const options = program.opts();
|
|
34
30
|
console.log(figlet.textSync(`SimpleApp Generator ${version}`));
|
|
35
|
-
// console.log(options)
|
|
36
|
-
let path=''
|
|
37
31
|
if(!options.configFile){
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
else if(options.configFile && options.configFile[0]=='.'){
|
|
42
|
-
path=process.cwd()+'/'+options.configFile
|
|
43
|
-
}else{
|
|
44
|
-
path=options.configFile
|
|
45
|
-
}
|
|
46
|
-
const configs = require(path)
|
|
47
|
-
console.log("configurations: ",configs)
|
|
48
|
-
const definationsFolder = configs.definationsFolder ?? options.definationsFolder
|
|
49
|
-
const backendFolder = configs.backendFolder ?? options.backendFolder
|
|
50
|
-
const frontendFolder = configs.frontendFolder ?? options.frontendFolder
|
|
51
|
-
const openapi3Yaml:string = configs.openapi3Yaml ?? options.openapi3Yaml
|
|
52
|
-
|
|
53
|
-
const runGenNext = (callback)=>{
|
|
54
|
-
if(!fs.existsSync(backendFolder)){
|
|
55
|
-
log.error(`${backendFolder} does not exists, please run "nest new -p pnpm ${backendFolder}"`)
|
|
56
|
-
}else if(!fs.existsSync(`${backendFolder}/.env`)){
|
|
57
|
-
log.info(`initial nest configuratoin for simpleapp generator`)
|
|
58
|
-
createNest(backendFolder,callback)
|
|
59
|
-
}else{
|
|
60
|
-
log.warn(`.env file exists, skip nest initialization`)
|
|
61
|
-
callback()
|
|
32
|
+
log.error("Config file parameter is required. Example: simpleapp-generator -c ./config.json")
|
|
33
|
+
throw "Undefine configuration file"
|
|
62
34
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
log.info(`initial nuxt configuratoin for simpleapp generator`)
|
|
69
|
-
createNuxt(frontendFolder,callback)
|
|
35
|
+
else if(options.configFile && options.configFile[0]=='/'){
|
|
36
|
+
path=options.configFile
|
|
37
|
+
}
|
|
38
|
+
else if(options.configFile){
|
|
39
|
+
path=process.cwd()+'/'+options.configFile
|
|
70
40
|
}else{
|
|
71
|
-
log.
|
|
72
|
-
|
|
73
|
-
|
|
41
|
+
log.error("undefine configuration file, use command simpleapp-generator -c <configfilename.json>")
|
|
42
|
+
throw error
|
|
74
43
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
generator.initialize(definationsFolder,backendFolder,frontendFolder)
|
|
82
|
-
exec(`cd ${frontendFolder};npx prettier --write "./pages/**/*.vue" "./simpleapp/**/*" `)
|
|
83
|
-
exec(`cd ${backendFolder};npx run format `)
|
|
84
|
-
if(openapi3Yaml !=''){
|
|
85
|
-
|
|
86
|
-
exec(`openapi-generator generate -i ${openapi3Yaml} -o ${frontendFolder}/simpleapp/openapi -g typescript-axios --skip-validate-spec`,(error, stdout, stderr)=>{
|
|
87
|
-
if(error){
|
|
88
|
-
log.error(stderr);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
|
|
44
|
+
const configs = require(path)
|
|
45
|
+
console.log("configurations: ",configs)
|
|
46
|
+
const definationsFolder = configs.definationsFolder
|
|
47
|
+
const backendFolder = configs.backendFolder
|
|
48
|
+
const frontendFolder = configs.frontendFolder
|
|
49
|
+
const openapi3Yaml = configs.openapi3Yaml
|
|
95
50
|
|
|
51
|
+
const run = async()=>{
|
|
52
|
+
fw.runCreateNest(backendFolder,()=>{
|
|
53
|
+
fw.runCreateNuxt(frontendFolder,()=>{
|
|
54
|
+
fw.prepareNest(backendFolder,()=>{
|
|
55
|
+
fw.prepareNuxt(frontendFolder,()=>{
|
|
56
|
+
generate.initialize(definationsFolder,backendFolder,frontendFolder,()=>{
|
|
57
|
+
fw.prepareOpenApiClient(openapi3Yaml,frontendFolder)
|
|
58
|
+
fw.prettyNuxt(frontendFolder)
|
|
59
|
+
fw.prettyNest(backendFolder)
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
}
|
|
96
66
|
|
|
97
|
-
|
|
98
|
-
// pnpm exec prettier ./apiclients --write
|
|
67
|
+
run()
|