@dypnb/dev-tools 1.0.12 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/genSwagger/index.browser.js +1 -1
- package/dist/genSwagger/index.cjs +1 -1
- package/dist/genSwagger/index.mjs +1 -1
- package/package.json +2 -3
- package/src/dome.vue +0 -25
- package/src/gen-page/config.js +0 -40
- package/src/gen-page/index.js +0 -122
- package/src/gen-page/template.js +0 -568
- package/src/gen-swagger/index.js +0 -228
- package/src/index.js +0 -12
- package/src/publish-server/index.js +0 -144
- package/src/utils/index.js +0 -82
- package/src/wx-server-notice/README.md +0 -59
- package/src/wx-server-notice/api.js +0 -45
- package/src/wx-server-notice/images/qiyewx-1.png +0 -0
- package/src/wx-server-notice/images/qiyewx-2.png +0 -0
- package/src/wx-server-notice/images/qiyewx-3-1.png +0 -0
- package/src/wx-server-notice/images/qiyewx-3-2.png +0 -0
- package/src/wx-server-notice/images/qiyewx-3.png +0 -0
- package/src/wx-server-notice/images/qiyewx-4.png +0 -0
- package/src/wx-server-notice/images/qiyewx-5-1.jpg +0 -0
- package/src/wx-server-notice/images/qiyewx-5.jpg +0 -0
- package/src/wx-server-notice/images/qiyewx-6.png +0 -0
- package/src/wx-server-notice/index.js +0 -62
package/src/gen-page/config.js
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
// 导入模板
|
2
|
-
import templateData from "./template.js";
|
3
|
-
export default {
|
4
|
-
// 是否命令行创建
|
5
|
-
isEnter: true,
|
6
|
-
// 文件名
|
7
|
-
name: 'genPageTable',
|
8
|
-
// 默认 view 目录下生成,如果需要指定父目录则写入 fatherFileName
|
9
|
-
path: 'dome',
|
10
|
-
// 子文件配置
|
11
|
-
child: [
|
12
|
-
{
|
13
|
-
name: 'index.vue',
|
14
|
-
template: (params = {}) => {
|
15
|
-
return templateData.tablePageTemplate({
|
16
|
-
// 文件标题,替换模板
|
17
|
-
title: 'pageTable',
|
18
|
-
...params,
|
19
|
-
})
|
20
|
-
},
|
21
|
-
templateConfig: {
|
22
|
-
|
23
|
-
},
|
24
|
-
},
|
25
|
-
{
|
26
|
-
name: 'constants.js',
|
27
|
-
template: (params = {}) => {
|
28
|
-
return templateData.constantsTemplate ({
|
29
|
-
// 文件标题,替换模板
|
30
|
-
title: 'pageTable',
|
31
|
-
...params,
|
32
|
-
})
|
33
|
-
},
|
34
|
-
templateConfig: {
|
35
|
-
// 文件标题,替换模板
|
36
|
-
title: '',
|
37
|
-
},
|
38
|
-
},
|
39
|
-
]
|
40
|
-
}
|
package/src/gen-page/index.js
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
#! /usr/bin/env node
|
2
|
-
import path from "path";
|
3
|
-
import fs from "fs";
|
4
|
-
import { getGlobalConfig, getDirname, log, successLog, errorLog } from "../utils/index.js";
|
5
|
-
import defaultConfig from "./config.js";
|
6
|
-
const __dirname = getDirname();
|
7
|
-
const resolve = (...file) => path.resolve(__dirname, ...file);
|
8
|
-
|
9
|
-
async function getGenPageConfig() {
|
10
|
-
return await getGlobalConfig('genPageConfig');
|
11
|
-
}
|
12
|
-
|
13
|
-
// 模板配置
|
14
|
-
getGenPageConfig().then(res => {
|
15
|
-
const genPageConfig = res || defaultConfig;
|
16
|
-
if (!genPageConfig) {
|
17
|
-
errorLog('全局模板未配置,使用默认配置')
|
18
|
-
}
|
19
|
-
genPage(genPageConfig);
|
20
|
-
});
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
// 生成文件
|
26
|
-
const generateFile = (path, data) => {
|
27
|
-
if (fs.existsSync(path)) {
|
28
|
-
errorLog(`${path}文件已存在`)
|
29
|
-
return
|
30
|
-
}
|
31
|
-
fs.writeFileSync(path, data, 'utf8', err => {
|
32
|
-
if (err) {
|
33
|
-
errorLog(err.message)
|
34
|
-
reject(err)
|
35
|
-
} else {
|
36
|
-
resolve(true)
|
37
|
-
}
|
38
|
-
})
|
39
|
-
}
|
40
|
-
|
41
|
-
function dotExistDirectoryCreate(directory) {
|
42
|
-
return new Promise((resolve) => {
|
43
|
-
mkdirs(directory, function() {
|
44
|
-
resolve(true)
|
45
|
-
})
|
46
|
-
})
|
47
|
-
}
|
48
|
-
// 递归创建目录
|
49
|
-
function mkdirs(directory, callback) {
|
50
|
-
var exists = fs.existsSync(directory)
|
51
|
-
if (exists) {
|
52
|
-
callback()
|
53
|
-
} else {
|
54
|
-
mkdirs(path.dirname(directory), function() {
|
55
|
-
fs.mkdirSync(directory)
|
56
|
-
callback()
|
57
|
-
})
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
|
62
|
-
async function genPageProcess(config, enterName) {
|
63
|
-
// 组件名称
|
64
|
-
const pageName = !enterName ? config.name : enterName;
|
65
|
-
// Vue页面组件路径
|
66
|
-
const pathStr = !config.path ? `${process.env.PWD}/src/views` : `${process.env.PWD}/src/views/${config.path}`;
|
67
|
-
const pagePath = resolve(pathStr, pageName)
|
68
|
-
|
69
|
-
// 判断组件文件夹是否存在
|
70
|
-
const hasComponentExists = fs.existsSync(pagePath)
|
71
|
-
if (hasComponentExists) {
|
72
|
-
errorLog(`${pageName}页面已存在`)
|
73
|
-
if (pageName) {
|
74
|
-
process.stdin.emit('end')
|
75
|
-
}
|
76
|
-
return
|
77
|
-
} else {
|
78
|
-
log(`正在生成${pageName}目录 ${pagePath}`)
|
79
|
-
await dotExistDirectoryCreate(pagePath)
|
80
|
-
}
|
81
|
-
try {
|
82
|
-
// // 获取组件名
|
83
|
-
// if (enterName.includes('/')) {
|
84
|
-
// const inputArr = enterName.split('/')
|
85
|
-
// pageName = inputArr[inputArr.length - 1]
|
86
|
-
// } else {
|
87
|
-
// pageName = enterName
|
88
|
-
// }
|
89
|
-
|
90
|
-
config.child.forEach((item) => {
|
91
|
-
const filePath = resolve(pagePath, item.name)
|
92
|
-
log(`正在生成子文件${item.name} ${filePath}`)
|
93
|
-
generateFile(filePath, item.template({name: pageName}))
|
94
|
-
})
|
95
|
-
|
96
|
-
successLog('生成成功')
|
97
|
-
} catch (e) {
|
98
|
-
errorLog(e.message)
|
99
|
-
}
|
100
|
-
|
101
|
-
}
|
102
|
-
|
103
|
-
function genPage(config) {
|
104
|
-
if (!config.isEnter) {
|
105
|
-
genPageProcess(config);
|
106
|
-
} else {
|
107
|
-
log('请输入要生成的页面组件名称、会生成在 views/目录下')
|
108
|
-
process.stdin.on('data', async chunk => {
|
109
|
-
// 组件名称
|
110
|
-
const enterName = String(chunk).trim().toString();
|
111
|
-
genPageProcess(config, enterName);
|
112
|
-
process.stdin.emit('end')
|
113
|
-
})
|
114
|
-
|
115
|
-
process.stdin.on('end', () => {
|
116
|
-
log('exit')
|
117
|
-
process.exit()
|
118
|
-
})
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
|
-
|