tmui-cli 1.1.1 → 1.1.3
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 +5 -4
- package/bin/cmd/cmdTool.js +219 -0
- package/bin/cmd/dirTool.js +174 -0
- package/bin/cmd/selectedDir.js +27 -0
- package/bin/donet.js +50 -0
- package/bin/hooks.js +170 -0
- package/bin/tmui.js +64 -16
- package/package.json +69 -53
- package/src/create4xhbx.js +98 -0
- package/src/util.js +2 -0
package/README.md
CHANGED
|
@@ -21,10 +21,11 @@ npm -g install tmui-cli
|
|
|
21
21
|
|
|
22
22
|
#### 命令解释
|
|
23
23
|
|
|
24
|
-
0. tmui
|
|
25
|
-
1. tmui
|
|
26
|
-
2. tmui
|
|
27
|
-
3. tmui
|
|
24
|
+
0. tmui 4x 创建uniappx 平台的hbx tmui4.0x项目
|
|
25
|
+
1. tmui cli 创建uniapp 平台的cli初始项目,内部已经包含了tmui最新框架(自动更新)
|
|
26
|
+
2. tmui hbx 创建uniapp 平台的HBX初始项目,内部已经包含了tmui最新框架(自动更新)
|
|
27
|
+
3. tmui rcli 为【已有】uniapp 平台的cli项目,更新和下载tmui最新框架(自动更新)
|
|
28
|
+
4. tmui rhbx 为【已有】uniapp 平台的HBX项目,更新和下载tmui最新框架(自动更新)
|
|
28
29
|
4. tmui use 为保姆级引导式下载安装上述功能项目。
|
|
29
30
|
|
|
30
31
|
#### 注意事项
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { spawn, exec } = require('child_process');
|
|
4
|
+
const process = require('process');
|
|
5
|
+
var codecs = require('codecs')
|
|
6
|
+
const psTree = require('ps-tree');
|
|
7
|
+
var iconv = require('iconv-lite');
|
|
8
|
+
|
|
9
|
+
function detectEncoding(str) {
|
|
10
|
+
const buffer = Buffer.from(str);
|
|
11
|
+
if (buffer[0] < 128) {
|
|
12
|
+
return 'ascii';
|
|
13
|
+
} else if (buffer[0] < 224) {
|
|
14
|
+
return 'utf8';
|
|
15
|
+
} else if (buffer[0] < 240) {
|
|
16
|
+
return 'utf16le';
|
|
17
|
+
} else {
|
|
18
|
+
return 'utf32le';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function send(ws,arg){
|
|
24
|
+
ws.forEach(el=>{
|
|
25
|
+
el.send(arg)
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function execCmd(cb, end, command) {
|
|
30
|
+
try {
|
|
31
|
+
// const npmPath = path.join(process.env.APPDATA, 'npm', 'npm.cmd');
|
|
32
|
+
const spawnObj = exec(command, { encoding: 'binary' })
|
|
33
|
+
// const spawnObj = spawn("npm.cmd",["run","dev:h5"],{detached:true})
|
|
34
|
+
|
|
35
|
+
spawnObj.stdout?.on('data', function (chunk) {
|
|
36
|
+
// Buffer.from(chunk,'binary').toString('utf-8')
|
|
37
|
+
// var str = iconv.decode(, 'cp936');
|
|
38
|
+
if (cb) {
|
|
39
|
+
let str = Buffer.from(chunk, 'binary').toString("utf8")
|
|
40
|
+
|
|
41
|
+
var codecsDecode = codecs(detectEncoding(chunk))
|
|
42
|
+
let strii = codecsDecode.decode(Buffer.from(chunk,'binary')).toString('utf-8');
|
|
43
|
+
// 去除控制符
|
|
44
|
+
const cleanStr = strii.replace(/[\u001B\u009B][[\]()#;?]*(?:(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[A-PR-Za-z~])/g, '');
|
|
45
|
+
cb(cleanStr,spawnObj.pid||0)
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
spawnObj.addListener('error', (err) => {
|
|
49
|
+
if (end) {
|
|
50
|
+
cb(err)
|
|
51
|
+
end('error')
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
spawnObj.on('close', function (code) {
|
|
55
|
+
// console.log('close code : ' + code);
|
|
56
|
+
if (end) {
|
|
57
|
+
end('end')
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
spawnObj.on('exit', (code) => {
|
|
61
|
+
// console.log('exit code : ' + code);
|
|
62
|
+
if (end) {
|
|
63
|
+
end('end')
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return spawnObj;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (end) {
|
|
70
|
+
cb(error)
|
|
71
|
+
end('end')
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// 杀死子进程及其所有子孙进程
|
|
77
|
+
function killChildAndGrandChildren(pid) {
|
|
78
|
+
|
|
79
|
+
if (process.platform === 'win32') {
|
|
80
|
+
// 在 Windows 系统上执行的代码
|
|
81
|
+
const command = `taskkill /T /F /PID ${pid}`;
|
|
82
|
+
exec(command, (err, stdout, stderr) => {
|
|
83
|
+
if (err) {
|
|
84
|
+
console.error(`服务进程退出失败!不要担心,当你关闭主进程时,未退出的子进程会一并关闭哦`);
|
|
85
|
+
}
|
|
86
|
+
// console.log(`stdout: ${stdout}`);
|
|
87
|
+
// console.error(`stderr: ${stderr}`);
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
// 在 Linux/Unix/Mac 系统上执行的代码
|
|
91
|
+
psTree(pid, (err, children) => {
|
|
92
|
+
// 使用 kill 命令杀死所有子孙进程
|
|
93
|
+
console.log(5555)
|
|
94
|
+
exec(`kill -TERM ${pid} ${children.map(c => c.PID).join(' ')}`);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
function devRunApp(ws, obj) {
|
|
100
|
+
|
|
101
|
+
const nowcd = process.cwd();
|
|
102
|
+
process.chdir(path.normalize(obj.data.path));
|
|
103
|
+
|
|
104
|
+
const childreProcess = execCmd(function (msg,pid) {
|
|
105
|
+
send(ws,JSON.stringify({
|
|
106
|
+
event: 'info',
|
|
107
|
+
data: msg
|
|
108
|
+
}))
|
|
109
|
+
const reg_1 = /http:\/\/localhost(:\d+)?(\/[^\s]*)?/g;
|
|
110
|
+
const reg_2 = /http:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d+)?(\/[^\s]*)?/g;
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
if(reg_1.test(msg)){
|
|
114
|
+
send(ws,JSON.stringify({
|
|
115
|
+
event: '1',
|
|
116
|
+
data: {
|
|
117
|
+
id:obj.data.id,
|
|
118
|
+
msg:msg.match(reg_1)[0],
|
|
119
|
+
pid:pid
|
|
120
|
+
}
|
|
121
|
+
}))
|
|
122
|
+
}
|
|
123
|
+
if(reg_2.test(msg)){
|
|
124
|
+
send(ws,JSON.stringify({
|
|
125
|
+
event: '1',
|
|
126
|
+
data: {
|
|
127
|
+
id:obj.data.id,
|
|
128
|
+
msg:msg.match(reg_2)[0],
|
|
129
|
+
pid:pid
|
|
130
|
+
}
|
|
131
|
+
}))
|
|
132
|
+
}
|
|
133
|
+
if(msg.indexOf('ready')>-1){
|
|
134
|
+
send(ws,JSON.stringify({
|
|
135
|
+
event: 'ready',
|
|
136
|
+
data: {
|
|
137
|
+
id:obj.data.id,
|
|
138
|
+
pid:pid
|
|
139
|
+
},
|
|
140
|
+
}))
|
|
141
|
+
}
|
|
142
|
+
}, function (type) {
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if(type=='end'){
|
|
146
|
+
send(ws,JSON.stringify({
|
|
147
|
+
event: 'end',
|
|
148
|
+
data: {
|
|
149
|
+
id:obj.data.id
|
|
150
|
+
},
|
|
151
|
+
}))
|
|
152
|
+
}else{
|
|
153
|
+
send(ws,JSON.stringify({
|
|
154
|
+
event: 'error',
|
|
155
|
+
data: {
|
|
156
|
+
id:obj.data.id
|
|
157
|
+
},
|
|
158
|
+
}))
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
}, obj.command)
|
|
163
|
+
|
|
164
|
+
return childreProcess;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function buildApp(ws, obj,end) {
|
|
168
|
+
|
|
169
|
+
const nowcd = process.cwd();
|
|
170
|
+
process.chdir(path.normalize(obj.data.path));
|
|
171
|
+
|
|
172
|
+
const childreProcess = execCmd(function (msg,pid) {
|
|
173
|
+
send(ws,JSON.stringify({
|
|
174
|
+
event: 'info',
|
|
175
|
+
data: msg
|
|
176
|
+
}))
|
|
177
|
+
if(msg.indexOf('DONE')>-1){
|
|
178
|
+
send(ws,JSON.stringify({
|
|
179
|
+
event: 'buildSucess',
|
|
180
|
+
data: {
|
|
181
|
+
id:obj.data.id,
|
|
182
|
+
pid:pid
|
|
183
|
+
},
|
|
184
|
+
}))
|
|
185
|
+
}
|
|
186
|
+
}, function (type) {
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
if(type=='end'){
|
|
190
|
+
send(ws,JSON.stringify({
|
|
191
|
+
event: 'end',
|
|
192
|
+
data: {
|
|
193
|
+
id:obj.data.id
|
|
194
|
+
},
|
|
195
|
+
}))
|
|
196
|
+
|
|
197
|
+
console.log('编译完成')
|
|
198
|
+
}else{
|
|
199
|
+
send(ws,JSON.stringify({
|
|
200
|
+
event: 'error',
|
|
201
|
+
data: {
|
|
202
|
+
id:obj.data.id
|
|
203
|
+
},
|
|
204
|
+
}))
|
|
205
|
+
}
|
|
206
|
+
if(end){
|
|
207
|
+
end()
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
}, obj.command)
|
|
211
|
+
|
|
212
|
+
return childreProcess;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
exports.execCmd = execCmd;
|
|
217
|
+
exports.devRunApp = devRunApp;
|
|
218
|
+
exports.killChildAndGrandChildren = killChildAndGrandChildren;
|
|
219
|
+
exports.buildApp = buildApp;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const process = require('process');
|
|
5
|
+
const { spawn, exec } = require('child_process');
|
|
6
|
+
|
|
7
|
+
function getJsonFiles(jsonPath) {
|
|
8
|
+
let jsonFiles = [];
|
|
9
|
+
function findJsonFile(www) {
|
|
10
|
+
let files = fs.readdirSync(www);
|
|
11
|
+
files.forEach(function (item, index) {
|
|
12
|
+
let fPath = path.join(www, item);
|
|
13
|
+
let stat = fs.statSync(fPath);
|
|
14
|
+
if (stat.isDirectory() === true) {
|
|
15
|
+
findJsonFile(fPath);
|
|
16
|
+
}
|
|
17
|
+
if (stat.isFile() === true) {
|
|
18
|
+
jsonFiles.push(fPath);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
findJsonFile(jsonPath);
|
|
23
|
+
return jsonFiles;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getJsonDir(basePath = './') {
|
|
27
|
+
const dirPath = basePath;
|
|
28
|
+
const root = { name: '', type: 'dir', parent: dirPath, children: [] };
|
|
29
|
+
const files = fs.readdirSync(dirPath);
|
|
30
|
+
|
|
31
|
+
const tree = [];
|
|
32
|
+
for (let i = 0; i < files.length; i++) {
|
|
33
|
+
const filename = files[i];
|
|
34
|
+
const filePath = path.join(dirPath, filename);
|
|
35
|
+
try {
|
|
36
|
+
if (filename.lastIndexOf('.tmp') == -1 && filename.lastIndexOf('.sys') == -1) {
|
|
37
|
+
const stats = fs.statSync(filePath);
|
|
38
|
+
if (stats.isFile()) {
|
|
39
|
+
const fileNode = { name: filename, type: 'file', parent: dirPath };
|
|
40
|
+
tree.push(fileNode);
|
|
41
|
+
} else if (stats.isDirectory()) {
|
|
42
|
+
const dirNode = { name: filename, type: 'dir', parent: dirPath, children: [] };
|
|
43
|
+
tree.push(dirNode);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
} catch (error) {
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
root.children = tree;
|
|
52
|
+
|
|
53
|
+
return root;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**读取项目信息根据提供的路径。 */
|
|
57
|
+
function checkProject(obj) {
|
|
58
|
+
// const {id,path,type} = obj;
|
|
59
|
+
let mainsetStrPath = "";
|
|
60
|
+
// 检查是否有tmui文件。和目录。
|
|
61
|
+
let tmuiDir = ""
|
|
62
|
+
//可运行的命令行。
|
|
63
|
+
let scriptsPackagePath = ""
|
|
64
|
+
if (obj.type == 'cli') {
|
|
65
|
+
mainsetStrPath = path.join(obj.path, 'src', 'manifest.json')
|
|
66
|
+
tmuiDir = path.join(obj.path, 'src', 'tmui', 'package.json')
|
|
67
|
+
scriptsPackagePath = path.join(obj.path, 'package.json')
|
|
68
|
+
} else {
|
|
69
|
+
mainsetStrPath = path.join(obj.path, 'manifest.json')
|
|
70
|
+
tmuiDir = path.join(obj.path, 'tmui', 'package.json')
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let str = fs.readFileSync(mainsetStrPath).toString('utf-8');
|
|
74
|
+
|
|
75
|
+
reg = /("([^\\\"]*(\\.)?)*")|('([^\\\']*(\\.)?)*')|(\/{2,}.*?(\r|\n|$))|(\/\*(\n|.)*?\*\/)/g;
|
|
76
|
+
|
|
77
|
+
str = str.replace(reg, function (word) {
|
|
78
|
+
// 去除注释后的文本
|
|
79
|
+
return /^\/{2,}/.test(word) || /^\/\*/.test(word) ? "" : word;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const d = JSON.parse(str);
|
|
83
|
+
let tmui = "";
|
|
84
|
+
if (fs.existsSync(tmuiDir)) {
|
|
85
|
+
let str2 = fs.readFileSync(tmuiDir).toString('utf-8');
|
|
86
|
+
const p = JSON.parse(str2);
|
|
87
|
+
tmui = p.version
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 读取运行的命令行。
|
|
91
|
+
let scripts = ""
|
|
92
|
+
if (fs.existsSync(scriptsPackagePath)) {
|
|
93
|
+
let str2 = fs.readFileSync(scriptsPackagePath).toString('utf-8');
|
|
94
|
+
const p = JSON.parse(str2);
|
|
95
|
+
scripts = p.scripts
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
name: d.name,
|
|
100
|
+
appid: d.appid,
|
|
101
|
+
versionName: d.versionName,
|
|
102
|
+
tmui: tmui,
|
|
103
|
+
id: obj.id,
|
|
104
|
+
scripts: scripts
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**获取系统磁盘。 */
|
|
108
|
+
function getDirver(callbck) {
|
|
109
|
+
if (process.platform === 'win32') {
|
|
110
|
+
// 执行 wmic 命令
|
|
111
|
+
const cmd = spawn('wmic', ['logicaldisk', 'get', 'name']);
|
|
112
|
+
// 监听命令输出流
|
|
113
|
+
cmd.stdout.on('data', data => {
|
|
114
|
+
// 解析命令输出结果
|
|
115
|
+
const disks = data.toString()
|
|
116
|
+
.split('\r\r\n') // 分割为行
|
|
117
|
+
.slice(1) // 跳过标题行
|
|
118
|
+
.map(line => line.trim()) // 去除行首尾空格
|
|
119
|
+
.filter(name => /^[A-Za-z]:$/.test(name)); // 过滤掉非磁盘名称
|
|
120
|
+
const pdist = disks.map(el=>el+"\\")
|
|
121
|
+
|
|
122
|
+
if(callbck){
|
|
123
|
+
callbck(pdist)
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// 监听命令错误流
|
|
128
|
+
cmd.stderr.on('data', data => {
|
|
129
|
+
// console.error(`执行 wmic 命令出错:${data}`);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// 监听命令退出事件
|
|
133
|
+
cmd.on('exit', code => {
|
|
134
|
+
// console.log(`wmic 命令退出,返回码:${code}`);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
} else {
|
|
139
|
+
// 在 Linux/Unix/Mac 系统上执行的代码
|
|
140
|
+
// 获取系统中的所有磁盘名称
|
|
141
|
+
fs.readFile('/proc/mounts', 'utf8', (err, data) => {
|
|
142
|
+
if (err) {
|
|
143
|
+
console.error(`获取磁盘信息失败:${err}`);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const lines = data.split('\n');
|
|
147
|
+
const disks = [];
|
|
148
|
+
for (const line of lines) {
|
|
149
|
+
const parts = line.split(' ');
|
|
150
|
+
const mountpoint = parts[1];
|
|
151
|
+
|
|
152
|
+
if (mountpoint.startsWith('/dev/')) {
|
|
153
|
+
const disk = parts[0];
|
|
154
|
+
disks.push(disk);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
console.log(`系统中的所有磁盘:${disks}`);
|
|
159
|
+
if (callbck) {
|
|
160
|
+
callbck(disks)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
exports.getJsonFiles = getJsonFiles;
|
|
171
|
+
exports.getJsonDir = getJsonDir;
|
|
172
|
+
exports.checkProject = checkProject;
|
|
173
|
+
exports.getDirver = getDirver;
|
|
174
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const globalDirectories = require('global-dirs');
|
|
4
|
+
const { getJsonDir } = require("./dirTool");
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async function selectedDir(cb, end, pathStr) {
|
|
9
|
+
try {
|
|
10
|
+
let dirpath = globalDirectories.npm.prefix
|
|
11
|
+
if(pathStr){
|
|
12
|
+
dirpath = path.normalize(pathStr);
|
|
13
|
+
}
|
|
14
|
+
let str = getJsonDir(dirpath);
|
|
15
|
+
cb(str)
|
|
16
|
+
end('end')
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.log(error,'---')
|
|
19
|
+
if (end) {
|
|
20
|
+
cb(error)
|
|
21
|
+
end('end')
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
exports.selectedDir = selectedDir;
|
package/bin/donet.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const {spawn} = require('child_process');
|
|
4
|
+
var iconv = require('iconv-lite');
|
|
5
|
+
var BufferHelper = require('bufferhelper');
|
|
6
|
+
const app = express();
|
|
7
|
+
const {getJsonFiles} = require("./cmd/dirTool")
|
|
8
|
+
const open = require('open');
|
|
9
|
+
|
|
10
|
+
app.post("/api/dirlist",(req,res)=>{
|
|
11
|
+
res.setHeader("Access-Control-Allow-Headers","*")
|
|
12
|
+
res.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS")
|
|
13
|
+
res.setHeader("Access-Control-Allow-Headers","DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization")
|
|
14
|
+
|
|
15
|
+
const ls = getJsonFiles( __dirname )
|
|
16
|
+
res.json(ls)
|
|
17
|
+
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
app.post("/api/cmd",(req,res)=>{
|
|
21
|
+
res.setHeader("Access-Control-Allow-Headers","*")
|
|
22
|
+
res.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS")
|
|
23
|
+
res.setHeader("Access-Control-Allow-Headers","DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
res.json(["响应中..."])
|
|
27
|
+
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
app.listen(6170)
|
|
33
|
+
// open('http://localhost:6170')
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
package/bin/hooks.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
|
|
2
|
+
const ws = require('ws')
|
|
3
|
+
const wss = new ws.WebSocketServer({ port: 6169 });
|
|
4
|
+
const { execCmd, devRunApp, killChildAndGrandChildren, buildApp } = require("./cmd/cmdTool");
|
|
5
|
+
const { selectedDir } = require('./cmd/selectedDir');
|
|
6
|
+
const { checkProject, getDirver } = require('./cmd/dirTool');
|
|
7
|
+
const osUtils = require('node-os-utils');
|
|
8
|
+
|
|
9
|
+
var client
|
|
10
|
+
var processList = [];
|
|
11
|
+
var runAppInfoList = [];
|
|
12
|
+
var wslist = [];
|
|
13
|
+
console.log(getDirver())
|
|
14
|
+
function uuid(len = 24, radix) {
|
|
15
|
+
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
|
16
|
+
var uuid = [], i;
|
|
17
|
+
radix = radix || chars.length;
|
|
18
|
+
if (len) {
|
|
19
|
+
// Compact form
|
|
20
|
+
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
|
|
21
|
+
} else {
|
|
22
|
+
// rfc4122, version 4 form
|
|
23
|
+
var r;
|
|
24
|
+
// rfc4122 requires these characters
|
|
25
|
+
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
26
|
+
uuid[14] = '4';
|
|
27
|
+
for (i = 0; i < 36; i++) {
|
|
28
|
+
if (!uuid[i]) {
|
|
29
|
+
r = 0 | Math.random() * 16;
|
|
30
|
+
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return uuid.join('');
|
|
39
|
+
}
|
|
40
|
+
function removeWs(id) {
|
|
41
|
+
const index = wslist.findIndex(el => el.uuid == id)
|
|
42
|
+
if (index > -1) {
|
|
43
|
+
wslist.splice(index, 1)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function send(arg) {
|
|
47
|
+
wslist.forEach(el => {
|
|
48
|
+
el.send(arg)
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
wss.on('connection', function connection(ws) {
|
|
52
|
+
|
|
53
|
+
ws.uuid = uuid();
|
|
54
|
+
wslist.push(ws)
|
|
55
|
+
ws.on('error', console.error);
|
|
56
|
+
ws.on('message', function message(data) {
|
|
57
|
+
try {
|
|
58
|
+
let obj = JSON.parse(data)
|
|
59
|
+
// 执行命令
|
|
60
|
+
if (obj.event == 'cmd') {
|
|
61
|
+
execCmd(function (str) {
|
|
62
|
+
send(JSON.stringify({
|
|
63
|
+
event: 'info',
|
|
64
|
+
data: str
|
|
65
|
+
}))
|
|
66
|
+
}, function () {
|
|
67
|
+
send(JSON.stringify({
|
|
68
|
+
event: 'end',
|
|
69
|
+
data: ""
|
|
70
|
+
}))
|
|
71
|
+
}, obj.command)
|
|
72
|
+
// 选择文件目录。
|
|
73
|
+
} else if (obj.event == '18') {
|
|
74
|
+
selectedDir(function (str) {
|
|
75
|
+
send(JSON.stringify({
|
|
76
|
+
event: '18',
|
|
77
|
+
data: str
|
|
78
|
+
}))
|
|
79
|
+
}, function () {
|
|
80
|
+
send(JSON.stringify({
|
|
81
|
+
event: 'end',
|
|
82
|
+
data: ""
|
|
83
|
+
}))
|
|
84
|
+
}, obj.command)
|
|
85
|
+
// 查询目录项目的信息
|
|
86
|
+
} else if (obj.event == '17') {
|
|
87
|
+
let result = checkProject(obj.command)
|
|
88
|
+
let runfl = runAppInfoList.filter(el => el.id == result.id)
|
|
89
|
+
send(JSON.stringify({
|
|
90
|
+
event: '17',
|
|
91
|
+
data: result,
|
|
92
|
+
run: runfl
|
|
93
|
+
}))
|
|
94
|
+
send(JSON.stringify({
|
|
95
|
+
event: 'end',
|
|
96
|
+
data: ""
|
|
97
|
+
}))
|
|
98
|
+
/**运行项目dev:xxx */
|
|
99
|
+
} else if (obj.event == '1') {
|
|
100
|
+
|
|
101
|
+
const childrenProcess = devRunApp(wslist, obj.command)
|
|
102
|
+
if (childrenProcess) {
|
|
103
|
+
processList.push(childrenProcess)
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
/**关闭并退出运行的项目服务 */
|
|
107
|
+
} else if (obj.event == '2') {
|
|
108
|
+
try {
|
|
109
|
+
if (!obj.command) return;
|
|
110
|
+
// process.kill(Number(obj.command||0))
|
|
111
|
+
const pid = Number(obj.command || 0);
|
|
112
|
+
const index = processList.findIndex(el => el.pid == pid)
|
|
113
|
+
if (index > -1) {
|
|
114
|
+
// process.kill(sflit[0].pid)
|
|
115
|
+
killChildAndGrandChildren(processList[index].pid)
|
|
116
|
+
processList.splice(index, 1)
|
|
117
|
+
const index2 = runAppInfoList.findIndex(el => el.pid == pid)
|
|
118
|
+
runAppInfoList.splice(index2, 1)
|
|
119
|
+
}
|
|
120
|
+
} catch (error) {
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
/**编译应用build:xx */
|
|
124
|
+
} else if (obj.event == '3') {
|
|
125
|
+
const id = obj.command.data.id;
|
|
126
|
+
const childrenProcess = buildApp(wslist, obj.command, () => {
|
|
127
|
+
const index2 = runAppInfoList.findIndex(el => el.id == id)
|
|
128
|
+
console.log("编译结束")
|
|
129
|
+
if (index2 > -1) {
|
|
130
|
+
runAppInfoList.splice(index2, 1)
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
/**保存当前运行的用户信息。 */
|
|
134
|
+
} else if (obj.event == 'saveRunInfo') {
|
|
135
|
+
const index2 = runAppInfoList.findIndex(el => el.id == obj.command.id)
|
|
136
|
+
if (index2 > -1) {
|
|
137
|
+
runAppInfoList.splice(index2, 1, obj.command)
|
|
138
|
+
} else {
|
|
139
|
+
runAppInfoList.push(obj.command)
|
|
140
|
+
}
|
|
141
|
+
/**获取系统使用率 */
|
|
142
|
+
} else if (obj.event == 'getCpu') {
|
|
143
|
+
|
|
144
|
+
Promise.all([osUtils.mem.info(),osUtils.cpu.usage()])
|
|
145
|
+
.then(arg=>{
|
|
146
|
+
send(JSON.stringify({
|
|
147
|
+
event: 'getCpu',
|
|
148
|
+
data: {
|
|
149
|
+
memUsage:arg[0].usedMemPercentage.toFixed(2),
|
|
150
|
+
cpuUsage:arg[1].toFixed(2)
|
|
151
|
+
}
|
|
152
|
+
}))
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
} catch (error) {
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
ws.on('close', () => {
|
|
164
|
+
removeWs(ws.uuid)
|
|
165
|
+
})
|
|
166
|
+
send('something');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
package/bin/tmui.js
CHANGED
|
@@ -5,52 +5,90 @@ const chalk = import("chalk")
|
|
|
5
5
|
const { Command } = require('commander');
|
|
6
6
|
const program = new Command();
|
|
7
7
|
const create = require("../src/create")
|
|
8
|
+
const create4xhbx = require("../src/create4xhbx")
|
|
8
9
|
const createHbx = require("../src/createHbx")
|
|
9
10
|
const rhbx = require("../src/rhbx")
|
|
10
11
|
const rcli = require("../src/rcli")
|
|
11
12
|
const viewTmuiVer = require("../src/viewTmuiVer")
|
|
12
13
|
const tm2 = require("../src/tmui2")
|
|
13
|
-
const inquirer = import(
|
|
14
|
-
const
|
|
14
|
+
const inquirer = import("inquirer")
|
|
15
|
+
const fetch = import("node-fetch")
|
|
15
16
|
var clear = require('clear');
|
|
16
17
|
var figlet = require('figlet');
|
|
18
|
+
// require('./donet')
|
|
19
|
+
// require('./hooks')
|
|
20
|
+
const ft = import("node-fetch")
|
|
17
21
|
clear()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// async function main(){
|
|
26
|
+
// const Chalk = await (await chalk).default
|
|
27
|
+
// const Inquirer = await (await inquirer).default
|
|
28
|
+
// const Fetch = await (await fetch).default
|
|
29
|
+
// figlet('TMUI3.1.0',figletSucess)
|
|
30
|
+
// function figletSucess(err,d){
|
|
31
|
+
// console.log(Chalk.green(d))
|
|
32
|
+
// console.log(Chalk.white('请注意浏览器打开状态,如果打开失败'))
|
|
33
|
+
// console.log(Chalk.white('请访问:http://localhost:6170'))
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
// }
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// main()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
18
51
|
chalk.then(v=>{
|
|
19
52
|
const ck = new v.Chalk();
|
|
20
53
|
|
|
21
|
-
figlet('
|
|
54
|
+
figlet('TMUI4.0x CLI', function(err, data) {
|
|
22
55
|
if (err) {
|
|
23
56
|
console.log('Something went wrong...');
|
|
24
57
|
console.dir(err);
|
|
25
58
|
return;
|
|
26
59
|
}
|
|
27
|
-
console.log(ck.white(`---------------------------------------------------`))
|
|
28
|
-
console.log(ck.white(`---------------------------------------------------`))
|
|
29
60
|
console.log(ck.green(data))
|
|
30
|
-
console.log(ck.green(
|
|
61
|
+
console.log(ck.green(`tmui2.0文档地址:https://jx2d.cn`))
|
|
62
|
+
console.log(ck.blue(`tmui3.0文档地址:https://tmui.design`))
|
|
63
|
+
console.log(ck.yellow(`tmui4.0x文档地址:https://xui.tmui.design`))
|
|
31
64
|
console.log(ck.white(`---------------------------------------------------`))
|
|
65
|
+
console.log(ck.white(`命令使用方式为:tmui xxx命令 比如:tmui use`))
|
|
32
66
|
console.log(ck.white(`---------------------------------------------------`))
|
|
33
|
-
|
|
34
67
|
inquirer.then(ivk=>{
|
|
35
68
|
program
|
|
36
|
-
.version(require('../package').version)
|
|
69
|
+
.version(require('../package').version)
|
|
70
|
+
program.command('4x')
|
|
71
|
+
.description('创建uniapp的tmui4.0x hbx项目')
|
|
72
|
+
.action(function(type, name){
|
|
73
|
+
create4xhbx.run(type,name,null,null)
|
|
74
|
+
})
|
|
37
75
|
program.command('cli')
|
|
38
|
-
.description('
|
|
76
|
+
.description('创建uniapp的cli项目包含tmui3.0[推荐]')
|
|
39
77
|
.action(function(type, name){
|
|
40
78
|
create.run(type,name)
|
|
41
79
|
})
|
|
42
80
|
program.command('hbx')
|
|
43
|
-
.description('
|
|
81
|
+
.description('创建uniapp的hbx项目包含tmui3.0[不推荐]')
|
|
44
82
|
.action(function(type, name){
|
|
45
83
|
createHbx.run(type,name)
|
|
46
84
|
})
|
|
47
85
|
program.command('rcli')
|
|
48
|
-
.description('
|
|
86
|
+
.description('为cli项目下载/更新tmui3.0')
|
|
49
87
|
.action(function(type, name){
|
|
50
88
|
rcli.run(type,name)
|
|
51
89
|
})
|
|
52
90
|
program.command('rhbx')
|
|
53
|
-
.description('
|
|
91
|
+
.description('为hbx项目下载/更新tmui3.0')
|
|
54
92
|
.action(function(type, name){
|
|
55
93
|
rhbx.run(type,name)
|
|
56
94
|
})
|
|
@@ -60,17 +98,18 @@ chalk.then(v=>{
|
|
|
60
98
|
viewTmuiVer.run(type,name)
|
|
61
99
|
})
|
|
62
100
|
program.command('use')
|
|
63
|
-
.description('引导式安装
|
|
101
|
+
.description('引导式安装tmui3.0项目[自定义安装]')
|
|
64
102
|
.action(function(type, name){
|
|
65
103
|
const { prompt,Separator} = ivk.default;
|
|
66
104
|
prompt([
|
|
67
105
|
{
|
|
68
106
|
type: 'list',
|
|
69
107
|
name: 'tmuiVerName',
|
|
70
|
-
message: '请选择你的uniApp项目的vue
|
|
108
|
+
message: '请选择你的uniApp项目的vue版本/项目类型',
|
|
71
109
|
choices: [
|
|
72
110
|
'vue2',
|
|
73
|
-
'vue3'
|
|
111
|
+
'vue3',
|
|
112
|
+
'tmui4.0x'
|
|
74
113
|
],
|
|
75
114
|
}
|
|
76
115
|
])
|
|
@@ -139,6 +178,16 @@ chalk.then(v=>{
|
|
|
139
178
|
|
|
140
179
|
})
|
|
141
180
|
|
|
181
|
+
}else if(answers.tmuiVerName=='tmui4.0x'){
|
|
182
|
+
|
|
183
|
+
prompt([{
|
|
184
|
+
type: 'input',
|
|
185
|
+
name: 'filename',
|
|
186
|
+
message: '在当前路径下创建项目,请输入项目名称:',
|
|
187
|
+
}, ])
|
|
188
|
+
.then(answers2 => {
|
|
189
|
+
create4xhbx.run(null,null,null,answers2.filename)
|
|
190
|
+
})
|
|
142
191
|
}
|
|
143
192
|
});
|
|
144
193
|
|
|
@@ -154,4 +203,3 @@ chalk.then(v=>{
|
|
|
154
203
|
|
|
155
204
|
})
|
|
156
205
|
|
|
157
|
-
|
package/package.json
CHANGED
|
@@ -1,53 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_from": "tmui-cli",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"commander": "^9.4.0",
|
|
37
|
-
"compressing": "^1.6.2",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
{
|
|
2
|
+
"_from": "tmui-cli",
|
|
3
|
+
"_inBundle": false,
|
|
4
|
+
"_integrity": "sha512-mnddgPs3eUjTuxQGv6hxlc0b98d53YXtjd0tvrlzWvrAnf0IS0qQMo4bZHi+ImwOEYqbNLX9jhd9pq1cVb9tjw==",
|
|
5
|
+
"_location": "/tmui-cli",
|
|
6
|
+
"_phantomChildren": {},
|
|
7
|
+
"_requested": {
|
|
8
|
+
"type": "tag",
|
|
9
|
+
"registry": true,
|
|
10
|
+
"raw": "tmui-cli",
|
|
11
|
+
"name": "tmui-cli",
|
|
12
|
+
"escapedName": "tmui-cli",
|
|
13
|
+
"rawSpec": "",
|
|
14
|
+
"saveSpec": null,
|
|
15
|
+
"fetchSpec": "latest"
|
|
16
|
+
},
|
|
17
|
+
"_requiredBy": [
|
|
18
|
+
"#USER"
|
|
19
|
+
],
|
|
20
|
+
"_resolved": "https://registry.npmjs.org/tmui-cli/-/tmui-cli-1.0.3.tgz",
|
|
21
|
+
"_shasum": "162803da7d6cc696e3f4a908b223a15f0b33d245",
|
|
22
|
+
"_spec": "tmui-cli",
|
|
23
|
+
"_where": "C:\\Users\\zsylp",
|
|
24
|
+
"author": {
|
|
25
|
+
"name": "tmzdy tmui"
|
|
26
|
+
},
|
|
27
|
+
"bin": {
|
|
28
|
+
"tmui": "bin/tmui.js"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"bufferhelper": "^0.2.1",
|
|
32
|
+
"chalk": "^5.0.1",
|
|
33
|
+
"clear": "^0.1.0",
|
|
34
|
+
"clui": "^0.3.6",
|
|
35
|
+
"codecs": "^3.0.0",
|
|
36
|
+
"commander": "^9.4.0",
|
|
37
|
+
"compressing": "^1.6.2",
|
|
38
|
+
"express": "^4.18.2",
|
|
39
|
+
"figlet": "^1.5.2",
|
|
40
|
+
"global-dirs": "^3.0.1",
|
|
41
|
+
"iconv-lite": "^0.6.3",
|
|
42
|
+
"inquirer": "^9.1.4",
|
|
43
|
+
"node-fetch": "^3.2.10",
|
|
44
|
+
"node-os-utils": "^1.3.7",
|
|
45
|
+
"open": "^8.4.2",
|
|
46
|
+
"ps-tree": "^1.2.0",
|
|
47
|
+
"ws": "^8.13.0"
|
|
48
|
+
},
|
|
49
|
+
"deprecated": false,
|
|
50
|
+
"description": "tmui3.0,tmui4.0x,tmui2.0",
|
|
51
|
+
"keywords": [
|
|
52
|
+
"tmui",
|
|
53
|
+
"tm-vuetify",
|
|
54
|
+
"tmui4",
|
|
55
|
+
"tmui4.0x",
|
|
56
|
+
"tmui2.0",
|
|
57
|
+
"uts",
|
|
58
|
+
"uvue",
|
|
59
|
+
"uniappx",
|
|
60
|
+
"uniapp"
|
|
61
|
+
],
|
|
62
|
+
"license": "ISC",
|
|
63
|
+
"main": "./bin/tmui.js",
|
|
64
|
+
"name": "tmui-cli",
|
|
65
|
+
"scripts": {
|
|
66
|
+
"run": "node ./bin/tmui.js"
|
|
67
|
+
},
|
|
68
|
+
"version": "1.1.3"
|
|
69
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const chalk = import("chalk")
|
|
2
|
+
const path = require("path")
|
|
3
|
+
const {
|
|
4
|
+
Command
|
|
5
|
+
} = require('commander');
|
|
6
|
+
const fs = require("fs")
|
|
7
|
+
const ft = import("node-fetch")
|
|
8
|
+
const compressing = require("compressing")
|
|
9
|
+
const chilPro = require("child_process")
|
|
10
|
+
var clear = require('clear');
|
|
11
|
+
var figlet = require('figlet');
|
|
12
|
+
const program = new Command();
|
|
13
|
+
const inquirer = import("inquirer")
|
|
14
|
+
var CLI = require('clui'),
|
|
15
|
+
Spinner = CLI.Spinner;
|
|
16
|
+
const delFile = require("./util").default.delFile
|
|
17
|
+
|
|
18
|
+
// https://cdn.tmui.design/tmui4.0/tmui4.0xhbxModel.zip
|
|
19
|
+
exports.run = function(type, name, vr, packname) {
|
|
20
|
+
chalk.then(v => {
|
|
21
|
+
clear()
|
|
22
|
+
const ck = new v.Chalk();
|
|
23
|
+
const nowPath = path.resolve('./');
|
|
24
|
+
console.log(ck.white('不 要 关闭窗体,正在创建中....'))
|
|
25
|
+
|
|
26
|
+
inquirer.then(ivk => {
|
|
27
|
+
function build(fname){
|
|
28
|
+
let filemul = path.join(nowPath, fname)
|
|
29
|
+
console.log(ck.green(`正在当前目录${filemul}创建项目`))
|
|
30
|
+
fetch(`https://cdn.tmui.design/tmui4.0/tmui4.0xhbxModel.zip`).then(async (rf) => {
|
|
31
|
+
if(!fs.existsSync(filemul)){
|
|
32
|
+
fs.mkdirSync(filemul)
|
|
33
|
+
}
|
|
34
|
+
let d = await rf.arrayBuffer()
|
|
35
|
+
|
|
36
|
+
fs.writeFile(path.join(filemul, 'tmui4.0xhbxModel.zip'), Buffer.from(d), (err) => {
|
|
37
|
+
if (err) {
|
|
38
|
+
console.log(ck.bgRed(err))
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
compressing.zip.uncompress(path.join(filemul, 'tmui4.0xhbxModel.zip'), path.join(
|
|
42
|
+
filemul))
|
|
43
|
+
.then(revalue => {
|
|
44
|
+
console.log(ck.green( '非常nice,安装成功,正在清理'))
|
|
45
|
+
if (fs.existsSync(path.join(
|
|
46
|
+
filemul,
|
|
47
|
+
'tmui4.0xhbxModel.zip'))) {
|
|
48
|
+
fs.unlinkSync(path.join(
|
|
49
|
+
filemul,
|
|
50
|
+
'tmui4.0xhbxModel.zip'))
|
|
51
|
+
}
|
|
52
|
+
figlet('TMUI4.0x OK!!', function(err, data) {
|
|
53
|
+
if (err) {
|
|
54
|
+
console.log('Something went wrong...');
|
|
55
|
+
console.dir(err);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
console.log(ck.bgGreen(data))
|
|
59
|
+
console.log(ck.green(`---------------------------------------------------`))
|
|
60
|
+
console.log(ck.green(`---------------------------------------------------`))
|
|
61
|
+
console.log(ck.green('请使用hbx4.21+以上版本导入项目目录并运行'))
|
|
62
|
+
console.log(ck.yellow('想要运行成功:您还需要导入tmui4.0x组件库及插件库,请联系作者购买授权并下载'))
|
|
63
|
+
console.log(ck.blue('市场购买地址:https://ext.dcloud.net.cn/plugin?id=16369'))
|
|
64
|
+
console.log(ck.green('文档地址:https://xui.tmui.design/'))
|
|
65
|
+
console.log(ck.yellow('线上WEB、H5预览:https://xui.tmui.design/h5'))
|
|
66
|
+
console.log(ck.yellow('安卓安装:https://gitee.com/LYTB/tmui4.0/releases/download/1.07/%20tmui4.0for%20unix%201.0.7.apk'))
|
|
67
|
+
console.log(ck.white('敬请期待4.0x的鸿蒙,小程序版本!!!'))
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
}).catch(errs => {
|
|
71
|
+
console.log(ck.bgRed(errs))
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
}).catch(e => {
|
|
75
|
+
console.log(ck.bgRed(e))
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
if(packname==null){
|
|
79
|
+
const {
|
|
80
|
+
prompt,
|
|
81
|
+
Separator
|
|
82
|
+
} = ivk.default;
|
|
83
|
+
prompt([{
|
|
84
|
+
type: 'input',
|
|
85
|
+
name: 'filename',
|
|
86
|
+
message: '在当前路径下创建项目,请输入项目名称:',
|
|
87
|
+
}, ])
|
|
88
|
+
.then(answers => {
|
|
89
|
+
build(answers.filename)
|
|
90
|
+
});
|
|
91
|
+
}else{
|
|
92
|
+
build(packname)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
})
|
|
98
|
+
}
|