tmui-cli 1.2.3 → 1.2.5
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/bin/cmdTool.js +229 -229
- package/bin/createTmui.js +382 -382
- package/bin/dirTool.js +152 -152
- package/bin/hooks.js +215 -216
- package/bin/net.js +145 -144
- package/bin/selectedDir.js +28 -28
- package/bin/tmui.js +28 -23
- package/dist/tmui.js +1 -1
- package/package.json +50 -51
- package/webpack.config.js +16 -16
- package/website/index.html +20 -20
- package/website/js/app.js +996 -996
- package/website/js/chunk-vendors.js +13591 -13591
package/bin/net.js
CHANGED
|
@@ -1,144 +1,145 @@
|
|
|
1
|
-
const Open = import("open")
|
|
2
|
-
const
|
|
3
|
-
const Fetch = import("node-fetch")
|
|
4
|
-
const express = require("express")
|
|
5
|
-
|
|
6
|
-
const app = express();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
app.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
lis.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
open(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
// const
|
|
97
|
-
// const
|
|
98
|
-
//
|
|
99
|
-
// var
|
|
100
|
-
//
|
|
101
|
-
// const
|
|
102
|
-
// const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
// res.setHeader("Access-Control-Allow-
|
|
107
|
-
// res.setHeader("Access-Control-Allow-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
//
|
|
116
|
-
// res.setHeader("Access-Control-Allow-
|
|
117
|
-
// res.setHeader("Access-Control-Allow-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
1
|
+
const Open = import("open")
|
|
2
|
+
const bodyParserS = import("body-parser")
|
|
3
|
+
const Fetch = import("node-fetch")
|
|
4
|
+
const express = require("express")
|
|
5
|
+
|
|
6
|
+
const app = express();
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function setResHeader(res){
|
|
10
|
+
res.setHeader("Access-Control-Allow-Headers","*")
|
|
11
|
+
res.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS")
|
|
12
|
+
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")
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
app.use(express.static('website'))
|
|
17
|
+
app.use('/store', express.static('websitemod'))
|
|
18
|
+
|
|
19
|
+
app.all("/api/dirlist",function (req,res){
|
|
20
|
+
setResHeader(res)
|
|
21
|
+
// const ls = getJsonFiles( __dirname )
|
|
22
|
+
// res.json(ls)
|
|
23
|
+
|
|
24
|
+
res.json({'code':0})
|
|
25
|
+
})
|
|
26
|
+
//获取tmui版本
|
|
27
|
+
app.post("/api/cehckTmuiVer",async function (req,res){
|
|
28
|
+
const fetch = (await Fetch).default;
|
|
29
|
+
|
|
30
|
+
setResHeader(res)
|
|
31
|
+
let type = req.body?.type??'uniapp'
|
|
32
|
+
|
|
33
|
+
let resdata = await fetch(`https:cdn.tmui.design/${type=='uniapp'?'tmuiVer':'tmui4x'}.txt`,{method:'GET',headers:{'Content-Type':'text/plan'}})
|
|
34
|
+
let texts = await resdata.text();
|
|
35
|
+
let version = texts.split("\n")
|
|
36
|
+
res.json({'code':0,'version':version,'type':type})
|
|
37
|
+
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
app.post("/api/checkUniappVer",async function (req,res){
|
|
41
|
+
const fetch = (await Fetch).default;
|
|
42
|
+
|
|
43
|
+
setResHeader(res)
|
|
44
|
+
// https://registry.npmjs.org/@dcloudio/uni-app
|
|
45
|
+
let resdata = await fetch(`https://mirrors.huaweicloud.com/repository/npm/@dcloudio/uni-app`,{method:'GET',headers:{'Content-Type':'text/plan'}})
|
|
46
|
+
let texts = await resdata.text();
|
|
47
|
+
let data = JSON.parse(texts)
|
|
48
|
+
let obj = {
|
|
49
|
+
dist:[
|
|
50
|
+
data['dist-tags'].alpha,
|
|
51
|
+
data['dist-tags'].next,
|
|
52
|
+
data['dist-tags'].vue3
|
|
53
|
+
],
|
|
54
|
+
versions:[]
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
let lis = []
|
|
58
|
+
for(let i in data.versions){
|
|
59
|
+
lis.push(i)
|
|
60
|
+
}
|
|
61
|
+
lis.reverse()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
lis = lis.slice(0,40)
|
|
65
|
+
lis = lis.filter(function(el){ return el[0]!='2'})
|
|
66
|
+
obj.versions = lis
|
|
67
|
+
res.json({'code':0,'data':obj})
|
|
68
|
+
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
async function createNet (){
|
|
76
|
+
const bodyParser = (await bodyParserS).default;
|
|
77
|
+
var jsonParser = bodyParser.json()
|
|
78
|
+
var urlencodedParser = bodyParser.urlencoded({ extended: false })
|
|
79
|
+
app.use(urlencodedParser)
|
|
80
|
+
app.use(jsonParser)
|
|
81
|
+
|
|
82
|
+
app.listen(6170,async function (){
|
|
83
|
+
const open = (await Open).default;
|
|
84
|
+
open('http://localhost:6170')
|
|
85
|
+
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = {
|
|
90
|
+
createNet
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
// open('http://localhost:6170')
|
|
95
|
+
|
|
96
|
+
// const express = require('express');
|
|
97
|
+
// const fs = require('fs');
|
|
98
|
+
// const {spawn} = require('child_process');
|
|
99
|
+
// var iconv = require('iconv-lite');
|
|
100
|
+
// var BufferHelper = require('bufferhelper');
|
|
101
|
+
// const app = express();
|
|
102
|
+
// const {getJsonFiles} = require("./cmd/dirTool")
|
|
103
|
+
// const open = require('open');
|
|
104
|
+
|
|
105
|
+
// app.post("/api/dirlist",(req,res)=>{
|
|
106
|
+
// res.setHeader("Access-Control-Allow-Headers","*")
|
|
107
|
+
// res.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS")
|
|
108
|
+
// 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")
|
|
109
|
+
|
|
110
|
+
// const ls = getJsonFiles( __dirname )
|
|
111
|
+
// res.json(ls)
|
|
112
|
+
|
|
113
|
+
// })
|
|
114
|
+
|
|
115
|
+
// app.post("/api/cmd",(req,res)=>{
|
|
116
|
+
// res.setHeader("Access-Control-Allow-Headers","*")
|
|
117
|
+
// res.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS")
|
|
118
|
+
// 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")
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
// res.json(["响应中..."])
|
|
122
|
+
|
|
123
|
+
// })
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
// app.listen(6170)
|
|
128
|
+
// // open('http://localhost:6170')
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
package/bin/selectedDir.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
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
|
-
|
|
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
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
process.title = 'tmui-cli';
|
|
4
|
+
|
|
5
|
+
var figletS = import("figlet");
|
|
6
|
+
const chalks = import("chalk")
|
|
7
|
+
const {createNet} = 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
|
+
createNet()
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main();
|
|
28
|
+
|
package/dist/tmui.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e,t,i={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")},590:(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)}}},643:(e,t,i)=>{const n=i(928),{execCmd:r}=i(590),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`,O=await u(j),w=await O.arrayBuffer(),b=n.join(p,"tmui.zip");if(o.existsSync(b)&&o.rmSync(b),o.writeFileSync(b,Buffer.from(w)),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}},113:(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}}}},248:(e,t,i)=>{i(679);const n=Promise.resolve().then(i.t.bind(i,895,23)),{createTmui:r,UpdateTmui:o}=i(643),{checkProject:s}=i(113),{selectedDir:c}=i(480),a=i(845),{WebSocketServer:u}=i(86),{execCmd:d,devRunApp:l,killChildAndGrandChildren:p,buildApp:f}=i(590),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")}))},879:(e,t,i)=>{const n=Promise.resolve().then(i.t.bind(i,80,23)),r=i(268),o=Promise.resolve().then(i.t.bind(i,229,23)),s=i(252),c=s();var a=r.json(),u=r.urlencoded({extended:!1});function d(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(u),c.use(a),c.use(s.static("website")),c.use("/store",s.static("websitemod")),c.all("/api/dirlist",(function(e,t){d(t),t.json({code:0})})),c.post("/api/cehckTmuiVer",(async function(e,t){const i=(await o).default;d(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;d(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:[]},a=[];for(let e in s.versions)a.push(e);a.reverse(),a=a.slice(0,40),a=a.filter((function(e){return"2"!=e[0]})),c.versions=a,t.json({code:0,data:c})})),e.exports={createNet:function(){c.listen(6170,(async function(){(0,(await n).default)("http://localhost:6170")}))}}},480:(e,t,i)=>{const n=i(928),r=i(270),{getJsonDir:o}=i(113);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"))}}}}},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})};const o=r(679),s=Promise.resolve().then(r.t.bind(r,895,23)),{createNet:c}=r(879);r(248),(async()=>{const e=(await s).default;o("TMUI for UniApp",(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()}))})()})();
|
|
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/package.json
CHANGED
|
@@ -1,51 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tmui-cli",
|
|
3
|
-
"version": "1.2.
|
|
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
|
-
"node-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"@babel/
|
|
42
|
-
"@babel/plugin-transform-
|
|
43
|
-
"@babel/
|
|
44
|
-
"
|
|
45
|
-
"babel-
|
|
46
|
-
"
|
|
47
|
-
"webpack": "^5.
|
|
48
|
-
"webpack-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "tmui-cli",
|
|
3
|
+
"version": "1.2.5",
|
|
4
|
+
"description": "tmui2.0,3.0,4.0x,3.2",
|
|
5
|
+
"main": "./bin/tmui.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "node ./bin/tmui.js",
|
|
8
|
+
"test": "node ./dist/tmui.js",
|
|
9
|
+
"build": "webpack --mode production"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"tmui"
|
|
13
|
+
],
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "tmzdy"
|
|
16
|
+
},
|
|
17
|
+
"bin": {
|
|
18
|
+
"tmui": "bin/tmui.js"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@babel/runtime": "^7.25.7",
|
|
23
|
+
"babel-polyfill": "^6.26.0",
|
|
24
|
+
"body-parser": "^1.20.3",
|
|
25
|
+
"bufferhelper": "^0.2.1",
|
|
26
|
+
"chalk": "^5.3.0",
|
|
27
|
+
"codecs": "^3.1.0",
|
|
28
|
+
"compressing": "^1.10.1",
|
|
29
|
+
"express": "^4.21.1",
|
|
30
|
+
"figlet": "^1.8.0",
|
|
31
|
+
"global-dirs": "^4.0.0",
|
|
32
|
+
"inquirer": "^12.0.0",
|
|
33
|
+
"node-fetch": "^3.3.2",
|
|
34
|
+
"node-os-utils": "^1.3.7",
|
|
35
|
+
"open": "^10.1.0",
|
|
36
|
+
"ps-tree": "^1.2.0",
|
|
37
|
+
"ws": "^8.18.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@babel/core": "^7.25.8",
|
|
41
|
+
"@babel/plugin-transform-modules-commonjs": "^7.25.7",
|
|
42
|
+
"@babel/plugin-transform-runtime": "^7.25.7",
|
|
43
|
+
"@babel/preset-env": "^7.25.8",
|
|
44
|
+
"babel-core": "^6.26.3",
|
|
45
|
+
"babel-loader": "^9.2.1",
|
|
46
|
+
"webpack": "^5.95.0",
|
|
47
|
+
"webpack-cli": "^5.1.4",
|
|
48
|
+
"webpack-node-externals": "^3.0.0"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/webpack.config.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
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
|
-
],
|
|
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
17
|
}
|