tmui-cli 1.3.0 → 2.0.0
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 +18 -90
- package/dist/main.mjs +81 -0
- package/package.json +48 -50
- package/bin/cmdTool.js +0 -229
- package/bin/createTmui.js +0 -383
- package/bin/dirTool.js +0 -152
- package/bin/hooks.js +0 -233
- package/bin/net.js +0 -139
- package/bin/selectedDir.js +0 -28
- package/bin/tmui.js +0 -28
- package/dist/tmui.js +0 -1
- package/webpack.config.js +0 -17
- package/website/css/app.fa961c8f.css +0 -1
- package/website/css/chunk-vendors.4ad1cdb5.css +0 -2
- package/website/favicon.ico +0 -0
- package/website/index.html +0 -1
- package/website/js/app.b68ad484.js +0 -2
- package/website/js/app.b68ad484.js.map +0 -1
- package/website/js/chunk-vendors.d9ea5cfa.js +0 -15
- package/website/js/chunk-vendors.d9ea5cfa.js.map +0 -1
package/bin/hooks.js
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
const chalks = import("chalk")
|
|
2
|
-
|
|
3
|
-
const {createTmui,UpdateTmui} = require("./createTmui.js")
|
|
4
|
-
const {checkProject} = require("./dirTool.js")
|
|
5
|
-
const {selectedDir} = require("./selectedDir.js")
|
|
6
|
-
const osUtils = require("node-os-utils")
|
|
7
|
-
const {WebSocketServer} = require("ws")
|
|
8
|
-
const {execCmd, devRunApp, killChildAndGrandChildren, buildApp} = require("./cmdTool.js")
|
|
9
|
-
const os = require('os');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const wss = new WebSocketServer({ port: 6169 });
|
|
15
|
-
var client
|
|
16
|
-
var processList = [];
|
|
17
|
-
var runAppInfoList = [];
|
|
18
|
-
var wslist = [];
|
|
19
|
-
|
|
20
|
-
function uuid(len = 24, radix) {
|
|
21
|
-
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
|
22
|
-
var uuid = [], i;
|
|
23
|
-
radix = radix || chars.length;
|
|
24
|
-
if (len) {
|
|
25
|
-
// Compact form
|
|
26
|
-
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
|
|
27
|
-
} else {
|
|
28
|
-
// rfc4122, version 4 form
|
|
29
|
-
var r;
|
|
30
|
-
// rfc4122 requires these characters
|
|
31
|
-
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
32
|
-
uuid[14] = '4';
|
|
33
|
-
for (i = 0; i < 36; i++) {
|
|
34
|
-
if (!uuid[i]) {
|
|
35
|
-
r = 0 | Math.random() * 16;
|
|
36
|
-
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return uuid.join('');
|
|
45
|
-
}
|
|
46
|
-
function removeWs(id) {
|
|
47
|
-
const index = wslist.findIndex(function(el) {return el.uuid == id})
|
|
48
|
-
if (index > -1) {
|
|
49
|
-
wslist.splice(index, 1)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function send(arg) {
|
|
53
|
-
wslist.forEach(function(el) {
|
|
54
|
-
el.send(arg)
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
wss.on('connection', async function connection(ws) {
|
|
58
|
-
const chalk = (await chalks).default;
|
|
59
|
-
|
|
60
|
-
ws.uuid = uuid();
|
|
61
|
-
wslist.push(ws)
|
|
62
|
-
ws.on('error', console.error);
|
|
63
|
-
ws.on('message', function message(data) {
|
|
64
|
-
try {
|
|
65
|
-
|
|
66
|
-
let obj = JSON.parse(data)
|
|
67
|
-
if(obj.event!='getCpu'){
|
|
68
|
-
// console.log(chalk.white(data))
|
|
69
|
-
}
|
|
70
|
-
// 执行命令
|
|
71
|
-
if (obj.event == 'cmd') {
|
|
72
|
-
execCmd(function (str) {
|
|
73
|
-
send(JSON.stringify({
|
|
74
|
-
event: 'info',
|
|
75
|
-
data: str
|
|
76
|
-
}))
|
|
77
|
-
}, function () {
|
|
78
|
-
send(JSON.stringify({
|
|
79
|
-
event: 'end',
|
|
80
|
-
data: ""
|
|
81
|
-
}))
|
|
82
|
-
}, obj.command)
|
|
83
|
-
// 选择文件目录。
|
|
84
|
-
} else if (obj.event == '18') {
|
|
85
|
-
|
|
86
|
-
selectedDir(function (str) {
|
|
87
|
-
send(JSON.stringify({
|
|
88
|
-
event: '18',
|
|
89
|
-
flag:'',
|
|
90
|
-
data: str
|
|
91
|
-
}))
|
|
92
|
-
}, function () {
|
|
93
|
-
send(JSON.stringify({
|
|
94
|
-
event: '18',
|
|
95
|
-
flag:'end',
|
|
96
|
-
data: ""
|
|
97
|
-
}))
|
|
98
|
-
}, obj.command)
|
|
99
|
-
// 查询目录项目的信息
|
|
100
|
-
} else if (obj.event == '17') {
|
|
101
|
-
let result = checkProject(obj.command)
|
|
102
|
-
let runfl = runAppInfoList.filter(function(el){ return el.id == result.id})
|
|
103
|
-
send(JSON.stringify({
|
|
104
|
-
event: '17',
|
|
105
|
-
data: result,
|
|
106
|
-
flag:'',
|
|
107
|
-
run: runfl
|
|
108
|
-
}))
|
|
109
|
-
send(JSON.stringify({
|
|
110
|
-
event: '17',
|
|
111
|
-
flag:'end',
|
|
112
|
-
data: ""
|
|
113
|
-
}))
|
|
114
|
-
/**运行项目dev:xxx */
|
|
115
|
-
} else if (obj.event == '1') {
|
|
116
|
-
|
|
117
|
-
const childrenProcess = devRunApp(wslist, obj.command)
|
|
118
|
-
if (childrenProcess) {
|
|
119
|
-
processList.push(childrenProcess)
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
/**关闭并退出运行的项目服务 */
|
|
123
|
-
} else if (obj.event == '2') {
|
|
124
|
-
try {
|
|
125
|
-
if (!obj.command) return;
|
|
126
|
-
// process.kill(Number(obj.command||0))
|
|
127
|
-
const pid = Number(obj.command || 0);
|
|
128
|
-
const index = processList.findIndex(function(el){ return el.pid == pid})
|
|
129
|
-
if (index > -1) {
|
|
130
|
-
// process.kill(sflit[0].pid)
|
|
131
|
-
killChildAndGrandChildren(processList[index].pid)
|
|
132
|
-
processList.splice(index, 1)
|
|
133
|
-
const index2 = runAppInfoList.findIndex(function(el){ return el.pid == pid})
|
|
134
|
-
runAppInfoList.splice(index2, 1)
|
|
135
|
-
}
|
|
136
|
-
} catch (error) {
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
/**编译应用build:xx */
|
|
140
|
-
} else if (obj.event == '3') {
|
|
141
|
-
const id = obj.command.data.id;
|
|
142
|
-
const childrenProcess = buildApp(wslist, obj.command, function() {
|
|
143
|
-
const index2 = runAppInfoList.findIndex(function(el){ return el.id == id})
|
|
144
|
-
console.log("编译结束")
|
|
145
|
-
if (index2 > -1) {
|
|
146
|
-
runAppInfoList.splice(index2, 1)
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
/**保存当前运行的用户信息。 */
|
|
150
|
-
} else if (obj.event == 'saveRunInfo') {
|
|
151
|
-
const index2 = runAppInfoList.findIndex(function(el){return el.id == obj.command.id})
|
|
152
|
-
if (index2 > -1) {
|
|
153
|
-
runAppInfoList.splice(index2, 1, obj.command)
|
|
154
|
-
} else {
|
|
155
|
-
runAppInfoList.push(obj.command)
|
|
156
|
-
}
|
|
157
|
-
/**获取系统使用率 */
|
|
158
|
-
} else if (obj.event == 'getCpu') {
|
|
159
|
-
|
|
160
|
-
Promise.all([osUtils.mem.info(),osUtils.cpu.usage()])
|
|
161
|
-
.then(function(arg){
|
|
162
|
-
send(JSON.stringify({
|
|
163
|
-
event: 'getCpu',
|
|
164
|
-
data: {
|
|
165
|
-
memUsage:arg[0].usedMemPercentage.toFixed(2),
|
|
166
|
-
cpuUsage:arg[1].toFixed(2)
|
|
167
|
-
}
|
|
168
|
-
}))
|
|
169
|
-
})
|
|
170
|
-
}else if(obj.event=='21'){
|
|
171
|
-
// npm view @dcloudio/uni-app versions --json
|
|
172
|
-
UpdateTmui(obj.command,function(str){
|
|
173
|
-
send(JSON.stringify({
|
|
174
|
-
event: 'info',
|
|
175
|
-
flag:'',
|
|
176
|
-
data: str
|
|
177
|
-
}))
|
|
178
|
-
},function(){
|
|
179
|
-
send(JSON.stringify({
|
|
180
|
-
event: '21',
|
|
181
|
-
flag:'end',
|
|
182
|
-
data: '完成'
|
|
183
|
-
}))
|
|
184
|
-
})
|
|
185
|
-
// 创建项目.
|
|
186
|
-
}else if(obj.event=='22'){
|
|
187
|
-
// npm view @dcloudio/uni-app versions --json
|
|
188
|
-
createTmui(obj.command,function(str){
|
|
189
|
-
send(JSON.stringify({
|
|
190
|
-
event: 'info',
|
|
191
|
-
flag:'',
|
|
192
|
-
data: str
|
|
193
|
-
}))
|
|
194
|
-
},function(prejectdir){
|
|
195
|
-
send(JSON.stringify({
|
|
196
|
-
event: '22',
|
|
197
|
-
flag:'end',
|
|
198
|
-
data: prejectdir
|
|
199
|
-
}))
|
|
200
|
-
})
|
|
201
|
-
}
|
|
202
|
-
// 获取用户电脑的根目录
|
|
203
|
-
else if(obj.event=='23'){
|
|
204
|
-
const userHomeDirectory = os.homedir();
|
|
205
|
-
let drawerRoot = ''
|
|
206
|
-
const platform = os.platform();
|
|
207
|
-
if (platform === 'win32') {
|
|
208
|
-
drawerRoot = path.parse(process.cwd()).root;
|
|
209
|
-
} else if (platform === 'darwin') {
|
|
210
|
-
drawerRoot = "/usr"
|
|
211
|
-
}
|
|
212
|
-
send(JSON.stringify({
|
|
213
|
-
event: '23',
|
|
214
|
-
flag:'end',
|
|
215
|
-
data: JSON.stringify({
|
|
216
|
-
user:userHomeDirectory,
|
|
217
|
-
root:drawerRoot
|
|
218
|
-
})
|
|
219
|
-
}))
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
} catch (error) {
|
|
224
|
-
console.log(chalk.red(data))
|
|
225
|
-
console.log(chalk.red(error))
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
ws.on('close', function() {
|
|
229
|
-
removeWs(ws.uuid)
|
|
230
|
-
})
|
|
231
|
-
send('something');
|
|
232
|
-
});
|
|
233
|
-
|
package/bin/net.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
const Open = import("open")
|
|
2
|
-
const bodyParser = require("body-parser")
|
|
3
|
-
const Fetch = import("node-fetch")
|
|
4
|
-
const express = require("express");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
|
|
7
|
-
const app = express();
|
|
8
|
-
const website = path.join(__dirname,'../','website')
|
|
9
|
-
const webstore = path.join(__dirname,'../','store')
|
|
10
|
-
|
|
11
|
-
app.use(express.static(website))
|
|
12
|
-
app.use('/store', express.static(webstore))
|
|
13
|
-
var jsonParser = bodyParser.json()
|
|
14
|
-
var urlencodedParser = bodyParser.urlencoded({ extended: false })
|
|
15
|
-
app.use(urlencodedParser)
|
|
16
|
-
app.use(jsonParser)
|
|
17
|
-
|
|
18
|
-
function setResHeader(res){
|
|
19
|
-
res.setHeader("Access-Control-Allow-Headers","*")
|
|
20
|
-
res.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS")
|
|
21
|
-
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")
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
app.all("/api/dirlist",function (req,res){
|
|
27
|
-
setResHeader(res)
|
|
28
|
-
// const ls = getJsonFiles( __dirname )
|
|
29
|
-
// res.json(ls)
|
|
30
|
-
|
|
31
|
-
res.json({'code':0})
|
|
32
|
-
})
|
|
33
|
-
//获取tmui版本
|
|
34
|
-
app.post("/api/cehckTmuiVer",async function (req,res){
|
|
35
|
-
const fetch = (await Fetch).default;
|
|
36
|
-
|
|
37
|
-
setResHeader(res)
|
|
38
|
-
let type = req.body?.type??'uniapp'
|
|
39
|
-
|
|
40
|
-
let resdata = await fetch(`https:cdn.tmui.design/${type=='uniapp'?'tmuiVer':'tmui4x'}.txt`,{method:'GET',headers:{'Content-Type':'text/plan'}})
|
|
41
|
-
let texts = await resdata.text();
|
|
42
|
-
let version = texts.split("\n")
|
|
43
|
-
res.json({'code':0,'version':version,'type':type})
|
|
44
|
-
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
app.post("/api/checkUniappVer",async function (req,res){
|
|
48
|
-
const fetch = (await Fetch).default;
|
|
49
|
-
|
|
50
|
-
setResHeader(res)
|
|
51
|
-
// https://registry.npmjs.org/@dcloudio/uni-app
|
|
52
|
-
let resdata = await fetch(`https://mirrors.huaweicloud.com/repository/npm/@dcloudio/uni-app`,{method:'GET',headers:{'Content-Type':'text/plan'}})
|
|
53
|
-
let texts = await resdata.text();
|
|
54
|
-
let data = JSON.parse(texts)
|
|
55
|
-
let obj = {
|
|
56
|
-
dist:[
|
|
57
|
-
data['dist-tags'].alpha,
|
|
58
|
-
data['dist-tags'].next,
|
|
59
|
-
data['dist-tags'].vue3
|
|
60
|
-
],
|
|
61
|
-
versions:[]
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
let lis = []
|
|
65
|
-
for(let i in data.versions){
|
|
66
|
-
lis.push(i)
|
|
67
|
-
}
|
|
68
|
-
lis.reverse()
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
lis = lis.slice(0,40)
|
|
72
|
-
lis = lis.filter(function(el){ return el[0]!='2'})
|
|
73
|
-
obj.versions = lis
|
|
74
|
-
res.json({'code':0,'data':obj})
|
|
75
|
-
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
app.listen(6170,async function (){
|
|
80
|
-
const open = (await Open).default;
|
|
81
|
-
open('http://localhost:6170')
|
|
82
|
-
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// open('http://localhost:6170')
|
|
89
|
-
|
|
90
|
-
// const express = require('express');
|
|
91
|
-
// const fs = require('fs');
|
|
92
|
-
// const {spawn} = require('child_process');
|
|
93
|
-
// var iconv = require('iconv-lite');
|
|
94
|
-
// var BufferHelper = require('bufferhelper');
|
|
95
|
-
// const app = express();
|
|
96
|
-
// const {getJsonFiles} = require("./cmd/dirTool")
|
|
97
|
-
// const open = require('open');
|
|
98
|
-
|
|
99
|
-
// app.post("/api/dirlist",(req,res)=>{
|
|
100
|
-
// res.setHeader("Access-Control-Allow-Headers","*")
|
|
101
|
-
// res.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS")
|
|
102
|
-
// 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")
|
|
103
|
-
|
|
104
|
-
// const ls = getJsonFiles( __dirname )
|
|
105
|
-
// res.json(ls)
|
|
106
|
-
|
|
107
|
-
// })
|
|
108
|
-
|
|
109
|
-
// app.post("/api/cmd",(req,res)=>{
|
|
110
|
-
// res.setHeader("Access-Control-Allow-Headers","*")
|
|
111
|
-
// res.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS")
|
|
112
|
-
// 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")
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// res.json(["响应中..."])
|
|
116
|
-
|
|
117
|
-
// })
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// app.listen(6170)
|
|
122
|
-
// // open('http://localhost:6170')
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
package/bin/selectedDir.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const path = require("path")
|
|
2
|
-
const globalDirectories = require("global-dirs")
|
|
3
|
-
const { getJsonDir } = require("./dirTool.js")
|
|
4
|
-
|
|
5
|
-
/**读取项目目录 */
|
|
6
|
-
function selectedDir(cb, end, pathStr) {
|
|
7
|
-
try {
|
|
8
|
-
let dirpath = globalDirectories.npm.prefix
|
|
9
|
-
if (pathStr) {
|
|
10
|
-
dirpath = path.normalize(pathStr);
|
|
11
|
-
}
|
|
12
|
-
let str = getJsonDir(dirpath);
|
|
13
|
-
cb(str)
|
|
14
|
-
end('end')
|
|
15
|
-
} catch (error) {
|
|
16
|
-
console.log(error, '---')
|
|
17
|
-
if (end) {
|
|
18
|
-
cb(error)
|
|
19
|
-
end('end')
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
selectedDir
|
|
27
|
-
}
|
|
28
|
-
|
package/bin/tmui.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
process.title = 'tmui-cli';
|
|
4
|
-
|
|
5
|
-
var figletS = import("figlet");
|
|
6
|
-
const chalks = import("chalk")
|
|
7
|
-
require("./net.js")
|
|
8
|
-
require("./hooks.js")
|
|
9
|
-
|
|
10
|
-
const main = async ()=>{
|
|
11
|
-
const chalk = (await chalks).default;
|
|
12
|
-
const figlet = (await figletS).default;
|
|
13
|
-
|
|
14
|
-
figlet('TMUI for UniApp', { font: 'Standard' }, function(err,d){
|
|
15
|
-
if(err){
|
|
16
|
-
console.log(chalk.red(err))
|
|
17
|
-
console.dir(err)
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
console.log(chalk.green(d))
|
|
21
|
-
console.log(chalk.yellow('请注意浏览器打开状态,如果打开失败'))
|
|
22
|
-
console.log(chalk.yellow('请访问:http://localhost:6170'))
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
main();
|
|
28
|
-
|
package/dist/tmui.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{var e,t,i={25:(e,t,i)=>{const n=i(928),{spawn:r,exec:o}=(i(896),i(317)),s=i(932),c=i(199),a=i(344);function u(e,t){e.forEach((function(e){e.send(t)}))}function d(e,t,i){try{const n=o(i,{encoding:"binary"});return n.stdout?.on("data",(function(t){if(e){Buffer.from(t,"binary").toString("utf8");const i=c(function(e){const t=Buffer.from(e);return t[0]<128?"ascii":t[0]<224?"utf8":t[0]<240?"utf16le":"utf32le"}(t)).decode(Buffer.from(t,"binary")).toString("utf-8").replace(/[\u001B\u009B][[\]()#;?]*(?:(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[A-PR-Za-z~])/g,"");e(i,n.pid||0)}})),n.addListener("error",(function(i){t&&(e(i),t("error"))})),n.on("close",(function(e){t&&t("end")})),n.on("exit",(function(e){t&&t("end")})),n}catch(i){return t&&(e(i),t("end")),null}}e.exports={execCmd:d,killChildAndGrandChildren:function(e){"win32"===s.platform?o(`taskkill /T /F /PID ${e}`,(function(e,t,i){e&&console.error("服务进程退出失败!不要担心,当你关闭主进程时,未退出的子进程会一并关闭哦")})):a(e,(function(t,i){console.log(5555),o(`kill -TERM ${e} ${i.map((function(e){return e.PID})).join(" ")}`)}))},devRunApp:function(e,t){return s.cwd(),s.chdir(n.normalize(t.data.path)),d((function(i,n){u(e,JSON.stringify({event:"info",data:i}));const r=/http:\/\/localhost(:\d+)?(\/[^\s]*)?/g,o=/http:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d+)?(\/[^\s]*)?/g;r.test(i)&&u(e,JSON.stringify({event:"1",data:{id:t.data.id,msg:i.match(r)[0],pid:n}})),o.test(i)&&u(e,JSON.stringify({event:"1",data:{id:t.data.id,msg:i.match(o)[0],pid:n}})),i.indexOf("ready")>-1&&u(e,JSON.stringify({event:"ready",data:{id:t.data.id,pid:n}}))}),(function(i){u(e,"end"==i?JSON.stringify({event:"end",data:{id:t.data.id}}):JSON.stringify({event:"error",data:{id:t.data.id}}))}),t.command)},buildApp:function(e,t,i){return s.cwd(),s.chdir(n.normalize(t.data.path)),d((function(i,n){u(e,JSON.stringify({event:"info",data:i})),i.indexOf("DONE")>-1&&u(e,JSON.stringify({event:"buildSucess",data:{id:t.data.id,pid:n}}))}),(function(n){"end"==n?(u(e,JSON.stringify({event:"end",data:{id:t.data.id}})),console.log("编译完成")):u(e,JSON.stringify({event:"error",data:{id:t.data.id}})),i&&i()}),t.command)}}},802:(e,t,i)=>{const n=i(928),{execCmd:r}=i(25),o=i(896),s=i(988),c=Promise.resolve().then(i.t.bind(i,229,23)),a=["@dcloudio/uni-app","@dcloudio/uni-app-plus","@dcloudio/uni-components","@dcloudio/uni-h5","@dcloudio/uni-mp-alipay","@dcloudio/uni-mp-baidu","@dcloudio/uni-mp-kuaishou","@dcloudio/uni-mp-lark","@dcloudio/uni-mp-qq","@dcloudio/uni-mp-toutiao","@dcloudio/uni-mp-weixin","@dcloudio/uni-quickapp-webview","@dcloudio/uni-automator","@dcloudio/uni-cli-shared","@dcloudio/vite-plugin-uni"];function u(e,t){if(o.existsSync(e))if(o.statSync(e).isDirectory()){var i=o.readdirSync(e),n=i.length,r=0;n>0?(i.forEach((function(t){r++,o.statSync(e+"/"+t);var i=e+"/"+t;o.statSync(i).isDirectory()?u(i,!0):o.unlinkSync(i)})),n==r&&t&&o.rmdirSync(e)):0==n&&t&&o.rmdirSync(e)}else o.unlinkSync(e),console.log("删除文件"+e+"成功")}function d(e){let t=o.readFileSync(e).toString("utf-8");return t=t.replace(/("([^\\\"]*(\\.)?)*")|('([^\\\']*(\\.)?)*')|(\/{2,}.*?(\r|\n|$))|(\/\*(\n|.)*?\*\/)/g,(function(e){return/^\/{2,}/.test(e)||/^\/\*/.test(e)?"":e})),JSON.parse(t)}function l(e,t){o.writeFileSync(e,t,{encoding:"utf-8"})}e.exports={createTmui:async function(e,t,i){const u=(await c).default;let p=n.normalize(e.rootDir);if(t("检测目录..."),!o.existsSync(p))return t("目录有误..."),void i();if(p=n.join(p,e.name),o.existsSync(p)||o.mkdirSync(p),"uniappx"==e.type){t("暂不支持uniappx更新sdk及下载更新tmui库,请联系作者授权,当前仅是创建一个空项目."),t("开始创建项目中...");let e="https://cdn.tmui.design/tmui4.0/tmui4.0xhbxModel.zip",r=await u(e),c=await r.arrayBuffer(),a=n.join(p,"tmui.zip");return o.existsSync(a)&&o.rmSync(a),o.writeFileSync(a,Buffer.from(c)),t("正在解压处理中..."),await s.zip.uncompress(a,p),t("创建uniAppx tmui4.0x 项目成功"),t("正在清理缓存文件..."),o.existsSync(a)&&o.rmSync(a),t("恭喜成功!!!"),void i(p)}process.chdir(p);let f=parseFloat(e.ver.replace(".",""))>=32,m=`https://cdn.tmui.design/public/static/${f?"tmuiHBX32":"tmuiHBX"}.zip`,y=`https://cdn.tmui.design/public/static/${f?"cli32":"cli"}.zip`,S="uniapp"==e.type&&"cli"==e.uniappBuildType?y:m,g=await u(S),h=await g.arrayBuffer(),x=n.join(p,"tmuimode.zip");o.existsSync(x)&&o.rmSync(x),o.writeFileSync(x,Buffer.from(h)),t("正在创建项目模板"),await s.zip.uncompress(x,p),t("tmui模板创建成功,正在下载tmuiUi库"),o.existsSync(x)&&o.rmSync(x);let v="";if("hbx"==e.uniappBuildType)if(f){let e=n.join(p,"uni_modules");o.existsSync(e)||o.mkdirSync(e),e=n.join(e,"tm-ui"),o.existsSync(e)||o.mkdirSync(e),v=e}else{let e=n.join(p,"tmui");o.existsSync(e)||o.mkdirSync(e),v=e}else if("cli"==e.uniappBuildType)if(f){let e=n.join(p,"src","uni_modules");o.existsSync(e)||o.mkdirSync(e),e=n.join(e,"tm-ui"),o.existsSync(e)||o.mkdirSync(e),v=e}else{let e=n.join(p,"src","tmui");o.existsSync(e)||o.mkdirSync(e),v=e}t("下载tmui中,版本号为:"+e.ver);let j=`https://cdn.tmui.design/public/static/tmui${e.ver}.zip`,w=await u(j),O=await w.arrayBuffer(),b=n.join(p,"tmui.zip");if(o.existsSync(b)&&o.rmSync(b),o.writeFileSync(b,Buffer.from(O)),t(`tmui${e.ver}下载完成,正在解压处理中...`),await s.zip.uncompress(b,v),t(`tmui${e.ver}安装成功`),t("正在清理缓存文件..."),o.existsSync(b)&&o.rmSync(b),t("恭喜安装tmui成功!!!"),e.uniappver&&"cli"==e.uniappBuildType){t("正在检查cli sdk 版本...");let o=n.join(p,"package.json"),s=d(o);return a.forEach((function(t){s.dependencies[t]&&(s.dependencies[t]=e.uniappver),s.devDependencies[t]&&(s.devDependencies[t]=e.uniappver)})),t("更新版本号完成,正在重新安装依赖,这个过程可能比较缓慢,如果失败,请手动在项目目录执行npm install或者重试"),"arm"==e.machine&&(s.dependencies["@esbuild/darwin-x64"]="^0.21.5",s.dependencies["@rollup/rollup-darwin-x64"]="^4.24.0"),l(o,JSON.stringify(s,null,4)),void r((function(e){t(e)}),(function(){i(p)}),"npm install --save --registry=https://registry.npmmirror.com/")}i(p)},UpdateTmui:async function(e,t,i){const p=(await c).default;let f=n.normalize(e.path);if(t("检测目录..."),!o.existsSync(f))return t("项目目录有误..."),void i();process.chdir(e.path);let m="",y=parseFloat(e.tmui.replace(".",""))>=32;if("hbx"==e.type)if(y){let e=n.join(f,"uni_modules");o.existsSync(e)||o.mkdirSync(e),e=n.join(e,"tm-ui"),o.existsSync(e)||o.mkdirSync(e),m=e}else{let e=n.join(f,"tmui");o.existsSync(e)||o.mkdirSync(e),m=e}else if("cli"==e.type)if(y){let e=n.join(f,"src","uni_modules");o.existsSync(e)||o.mkdirSync(e),e=n.join(e,"tm-ui"),o.existsSync(e)||o.mkdirSync(e),m=e}else{let e=n.join(f,"src","tmui");o.existsSync(e)||o.mkdirSync(e),m=e}if(t("已创建/检测/清除...tmui目录..."),!o.existsSync(m))return t("无法检测和创建目录,请检查权限..."),void i();u(m,!0),o.mkdirSync(m),t("下载tmui中,版本号为:"+e.tmui);let S=`https://cdn.tmui.design/public/static/tmui${e.tmui}.zip`,g=await p(S),h=await g.arrayBuffer(),x=n.join(f,"tmui.zip");if(o.existsSync(x)&&o.rmSync(x),o.writeFileSync(x,Buffer.from(h)),t(`tmui${e.tmui}下载完成,正在解压处理中...`),await s.zip.uncompress(x,m),t(`tmui${e.tmui}安装成功`),t("正在清理缓存文件..."),o.existsSync(x)&&o.rmSync(x),t("恭喜安装tmui成功!!!"),e.uniappver&&"cli"==e.type){t("正在检查cli sdk 版本...");let o=n.join(f,"package.json"),s=d(o);if(s.dependencies["@dcloudio/uni-app"]!=e.uniappver)return t("检测到cli版本与你选中的不一样,正在设置你选中的版本号"),a.forEach((function(t){s.dependencies[t]&&(s.dependencies[t]=e.uniappver),s.devDependencies[t]&&(s.devDependencies[t]=e.uniappver)})),t("更新版本号完成,正在重新安装依赖,这个过程可能比较缓慢,如果失败,请手动在项目目录执行npm install或者重试"),l(o,JSON.stringify(s,null,4)),void r((function(e){t(e)}),(function(){i()}),"npm install --save --registry=https://registry.npmmirror.com/");t("检测到cli版本与你选中的一样,跳过更新")}i()},delFile:u}},838:(e,t,i)=>{const n=i(928),r=i(896);e.exports={getJsonFiles:function(e){let t=[];return function e(i){r.readdirSync(i).forEach((function(o,s){let c=n.join(i,o),a=r.statSync(c);!0===a.isDirectory()&&e(c),!0===a.isFile()&&t.push(c)}))}(e),t},getJsonDir:function(e="./"){const t=e,i={name:"",type:"dir",parent:t,children:[]},o=r.readdirSync(t),s=[];for(let e=0;e<o.length;e++){const i=o[e],c=n.join(t,i),a=n.extname(i);try{if(-1==i.lastIndexOf(".tmp")&&-1==i.lastIndexOf(".sys")&&"."!=i[0]){const e=r.statSync(c);if(e.isFile()){const e={name:i,type:"file",parent:t,suffix:a};s.push(e)}else if(e.isDirectory()){const e={name:i,type:"dir",parent:t,suffix:"",children:[]};s.push(e)}}}catch(e){}}return i.children=s,i},checkProject:function(e){let t="",i="",o="",s="";"cli"==e.type?(t=n.join(e.path,"src","manifest.json"),i=n.join(e.path,"src","tmui","package.json"),r.existsSync(i)||(i=n.join(e.path,"src","uni_modules","tm-ui","package.json")),o=n.join(e.path,"package.json")):(t=n.join(e.path,"manifest.json"),i=n.join(e.path,"tmui","package.json"),r.existsSync(i)||(i=n.join(e.path,"uni_modules","tm-ui","package.json")),s=n.join(e.path,"uni_modules","tmx-ui","package.json"));let c=r.readFileSync(t).toString("utf-8");c=c.replace(/("([^\\\"]*(\\.)?)*")|('([^\\\']*(\\.)?)*')|(\/{2,}.*?(\r|\n|$))|(\/\*(\n|.)*?\*\/)/g,(function(e){return/^\/{2,}/.test(e)||/^\/\*/.test(e)?"":e}));const a=JSON.parse(c),u=a["uni-app-x"];let d="";if(u){if(r.existsSync(s)){let e=r.readFileSync(s).toString("utf-8");d=JSON.parse(e).version}}else if(r.existsSync(i)){let e=r.readFileSync(i).toString("utf-8");d=JSON.parse(e).version}let l="";if(r.existsSync(o)){let e=r.readFileSync(o).toString("utf-8");l=JSON.parse(e).scripts}return{name:a.name,appid:a.appid,versionName:a.versionName,tmui:d,unix:u,id:e.id,scripts:l}}}},487:(e,t,i)=>{const n=Promise.resolve().then(i.t.bind(i,895,23)),{createTmui:r,UpdateTmui:o}=i(802),{checkProject:s}=i(838),{selectedDir:c}=i(259),a=i(845),{WebSocketServer:u}=i(86),{execCmd:d,devRunApp:l,killChildAndGrandChildren:p,buildApp:f}=i(25),m=new u({port:6169});var y=[],S=[],g=[];function h(e){g.forEach((function(t){t.send(e)}))}m.on("connection",(async function(e){const t=(await n).default;e.uuid=function(e=24,t){var i,n,r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];if(t=t||r.length,e)for(i=0;i<e;i++)o[i]=r[0|Math.random()*t];else for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",i=0;i<36;i++)o[i]||(n=0|16*Math.random(),o[i]=r[19==i?3&n|8:n]);return o.join("")}(),g.push(e),e.on("error",console.error),e.on("message",(function(e){try{let i=JSON.parse(e);if("getCpu"!=i.event&&console.log(t.white(e)),"cmd"==i.event)d((function(e){h(JSON.stringify({event:"info",data:e}))}),(function(){h(JSON.stringify({event:"end",data:""}))}),i.command);else if("18"==i.event)c((function(e){h(JSON.stringify({event:"18",flag:"",data:e}))}),(function(){h(JSON.stringify({event:"18",flag:"end",data:""}))}),i.command);else if("17"==i.event){let e=s(i.command),t=S.filter((function(t){return t.id==e.id}));h(JSON.stringify({event:"17",data:e,flag:"",run:t})),h(JSON.stringify({event:"17",flag:"end",data:""}))}else if("1"==i.event){const e=l(g,i.command);e&&y.push(e)}else if("2"==i.event)try{if(!i.command)return;const e=Number(i.command||0),t=y.findIndex((function(t){return t.pid==e}));if(t>-1){p(y[t].pid),y.splice(t,1);const i=S.findIndex((function(t){return t.pid==e}));S.splice(i,1)}}catch(e){}else if("3"==i.event){const e=i.command.data.id;f(g,i.command,(function(){const t=S.findIndex((function(t){return t.id==e}));console.log("编译结束"),t>-1&&S.splice(t,1)}))}else if("saveRunInfo"==i.event){const e=S.findIndex((function(e){return e.id==i.command.id}));e>-1?S.splice(e,1,i.command):S.push(i.command)}else"getCpu"==i.event?Promise.all([a.mem.info(),a.cpu.usage()]).then((function(e){h(JSON.stringify({event:"getCpu",data:{memUsage:e[0].usedMemPercentage.toFixed(2),cpuUsage:e[1].toFixed(2)}}))})):"21"==i.event?o(i.command,(function(e){h(JSON.stringify({event:"info",flag:"",data:e}))}),(function(){h(JSON.stringify({event:"21",flag:"end",data:"完成"}))})):"22"==i.event&&r(i.command,(function(e){h(JSON.stringify({event:"info",flag:"",data:e}))}),(function(e){h(JSON.stringify({event:"22",flag:"end",data:e}))}))}catch(i){console.log(t.red(e)),console.log(t.red(i))}})),e.on("close",(function(){!function(e){const t=g.findIndex((function(t){return t.uuid==e}));t>-1&&g.splice(t,1)}(e.uuid)})),h("something")}))},628:(e,t,i)=>{const n=Promise.resolve().then(i.t.bind(i,80,23)),r=Promise.resolve().then(i.t.bind(i,268,23)),o=Promise.resolve().then(i.t.bind(i,229,23)),s=i(252),c=s();function a(e){e.setHeader("Access-Control-Allow-Headers","*"),e.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS"),e.setHeader("Access-Control-Allow-Headers","DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization")}c.use(s.static("website")),c.use("/store",s.static("websitemod")),c.all("/api/dirlist",(function(e,t){a(t),t.json({code:0})})),c.post("/api/cehckTmuiVer",(async function(e,t){const i=(await o).default;a(t);let n=e.body?.type??"uniapp",r=await i(`https:cdn.tmui.design/${"uniapp"==n?"tmuiVer":"tmui4x"}.txt`,{method:"GET",headers:{"Content-Type":"text/plan"}}),s=(await r.text()).split("\n");t.json({code:0,version:s,type:n})})),c.post("/api/checkUniappVer",(async function(e,t){const i=(await o).default;a(t);let n=await i("https://mirrors.huaweicloud.com/repository/npm/@dcloudio/uni-app",{method:"GET",headers:{"Content-Type":"text/plan"}}),r=await n.text(),s=JSON.parse(r),c={dist:[s["dist-tags"].alpha,s["dist-tags"].next,s["dist-tags"].vue3],versions:[]},u=[];for(let e in s.versions)u.push(e);u.reverse(),u=u.slice(0,40),u=u.filter((function(e){return"2"!=e[0]})),c.versions=u,t.json({code:0,data:c})})),e.exports={createNet:async function(){const e=(await r).default;var t=e.json(),i=e.urlencoded({extended:!1});c.use(i),c.use(t),c.listen(6170,(async function(){(0,(await n).default)("http://localhost:6170")}))}}},259:(e,t,i)=>{const n=i(928),r=i(270),{getJsonDir:o}=i(838);e.exports={selectedDir:function(e,t,i){try{let s=r.npm.prefix;i&&(s=n.normalize(i)),e(o(s)),t("end")}catch(i){console.log(i,"---"),t&&(e(i),t("end"))}}}},268:e=>{"use strict";e.exports=require("body-parser")},895:e=>{"use strict";e.exports=require("chalk")},199:e=>{"use strict";e.exports=require("codecs")},988:e=>{"use strict";e.exports=require("compressing")},252:e=>{"use strict";e.exports=require("express")},679:e=>{"use strict";e.exports=require("figlet")},270:e=>{"use strict";e.exports=require("global-dirs")},229:e=>{"use strict";e.exports=require("node-fetch")},845:e=>{"use strict";e.exports=require("node-os-utils")},80:e=>{"use strict";e.exports=require("open")},344:e=>{"use strict";e.exports=require("ps-tree")},86:e=>{"use strict";e.exports=require("ws")},317:e=>{"use strict";e.exports=require("child_process")},896:e=>{"use strict";e.exports=require("fs")},928:e=>{"use strict";e.exports=require("path")},932:e=>{"use strict";e.exports=require("process")}},n={};function r(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return i[e](o,o.exports,r),o.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,r.t=function(i,n){if(1&n&&(i=this(i)),8&n)return i;if("object"==typeof i&&i){if(4&n&&i.__esModule)return i;if(16&n&&"function"==typeof i.then)return i}var o=Object.create(null);r.r(o);var s={};e=e||[null,t({}),t([]),t(t)];for(var c=2&n&&i;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((e=>s[e]=()=>i[e]));return s.default=()=>i,r.d(o,s),o},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},process.title="tmui-cli";var o=Promise.resolve().then(r.t.bind(r,679,23));const s=Promise.resolve().then(r.t.bind(r,895,23)),{createNet:c}=r(628);r(487),(async()=>{const e=(await s).default;(0,(await o).default)("TMUI for UniApp",{font:"Standard"},(function(t,i){if(t)return console.log(e.red(t)),void console.dir(t);console.log(e.green(i)),console.log(e.yellow("请注意浏览器打开状态,如果打开失败")),console.log(e.yellow("请访问:http://localhost:6170")),c()}))})()})();
|
package/webpack.config.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const nodeExternals = require('webpack-node-externals');
|
|
3
|
-
module.exports = {
|
|
4
|
-
entry: './bin/tmui.js',
|
|
5
|
-
output: {
|
|
6
|
-
path: path.resolve(__dirname, 'dist'),
|
|
7
|
-
filename: 'tmui.js',
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
resolve: {
|
|
11
|
-
extensions: ['.js'], // 解析扩展名
|
|
12
|
-
},
|
|
13
|
-
target: 'node',
|
|
14
|
-
externals: [
|
|
15
|
-
nodeExternals()
|
|
16
|
-
],
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
*,body,html{margin:0;padding:0}.appbody{min-height:100vh}.arco-layout-content{display:flex;flex-direction:column}.arco-layout-sider{background:#000724!important}.arco-menu-dark,.arco-menu-dark .arco-menu-group-title,.arco-menu-dark .arco-menu-inline-header,.arco-menu-dark .arco-menu-item,.arco-menu-dark .arco-menu-pop-header{background:transparent!important}.removeClse[data-v-e821f0f4]{position:absolute;z-index:4;right:10px;top:10px}.header[data-v-e821f0f4]{height:60px;display:flex;flex-flow:column;justify-content:center;align-items:center;background:#fff;color:#000;width:100%;height:100%;border-radius:10px;overflow:hidden;box-shadow:0 0 24px rgba(36,76,255,.1);transition:all .3s;position:relative}.header[data-v-e821f0f4]:hover{color:#fff;cursor:pointer;background:#244cff;box-shadow:0 0 24px rgba(36,76,255,.4)}.header.on[data-v-e821f0f4]{background:linear-gradient(45deg,#021406,#256133)}.header.on[data-v-e821f0f4]:hover{cursor:default}.header.onux[data-v-e821f0f4]{background:linear-gradient(45deg,#1c0303,#6c2525)}.header .etitle[data-v-e821f0f4]{margin-top:12px}.headerRunMasker[data-v-e821f0f4]{font-size:12px;color:#fff;padding:0;margin:0;background:rgba(0,12,38,.1);width:100%;height:100%;display:flex;flex-flow:column;justify-content:center;align-items:center;position:absolute;left:0;top:0;z-index:5;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}.headerRunMasker a[data-v-e821f0f4]{padding:10px 0}.itemcell.dir[data-v-0c5d396a]:hover{background-color:rgba(36,76,255,.1);color:#244cff;cursor:pointer}.body[data-v-2674685f]{display:grid;grid-template-columns:repeat(1,1fr);gap:20px;padding:10px}.body .item[data-v-2674685f]{background-color:grey;height:450px;border-radius:10px}@media screen and (min-width:900px){.body[data-v-2674685f]{display:grid;grid-template-columns:repeat(2,1fr)}}@media screen and (min-width:1200px){.body[data-v-2674685f]{display:grid;grid-template-columns:repeat(3,1fr)}}@media screen and (min-width:1500px){.body[data-v-2674685f]{display:grid;grid-template-columns:repeat(4,1fr)}}@media screen and (min-width:1800px){.body[data-v-2674685f]{display:grid;grid-template-columns:repeat(4,1fr)}}@media screen and (min-width:2100px){.body[data-v-2674685f]{display:grid;grid-template-columns:repeat(5,1fr)}}.box[data-v-5efaaea3]{margin:24px;margin-top:0;display:flex;flex-direction:row;flex-wrap:wrap}.title[data-v-5efaaea3]{font-size:24px;margin-bottom:16px}.card[data-v-5efaaea3]{margin:24px 0;padding:24px;box-shadow:0 0 20px rgba(0,0,0,.05);border-radius:5px;box-sizing:border-box;max-width:450px}ul li[data-v-5efaaea3]{padding:6px 0;list-style:none}p[data-v-5efaaea3]{margin-bottom:16px;line-height:28px;font-size:14px}.header[data-v-6469922e]{height:60px;display:flex;flex-flow:row;justify-content:space-between;align-items:center;background:#000724;padding:0 24px;color:#fff}.header .logo[data-v-6469922e]{font-size:21px}
|