tmui-cli 1.1.5 → 1.1.7
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 +19 -7
- package/bin/cmdTool.js +223 -0
- package/bin/createTmui.js +375 -0
- package/bin/dirTool.js +152 -0
- package/bin/hooks.js +58 -15
- package/bin/net.js +136 -0
- package/bin/selectedDir.js +28 -0
- package/bin/tmui.js +22 -243
- package/package.json +23 -62
- package/website/favicon.ico +0 -0
- package/website/index.html +20 -0
- package/website/js/app.js +997 -0
- package/website/js/chunk-vendors.js +13592 -0
- package/bin/cmd/cmdTool.js +0 -219
- package/bin/cmd/dirTool.js +0 -174
- package/bin/cmd/selectedDir.js +0 -27
- package/bin/donet.js +0 -50
- package/src/create.js +0 -176
- package/src/create4xhbx.js +0 -98
- package/src/createHbx.js +0 -142
- package/src/rcli.js +0 -136
- package/src/rhbx.js +0 -131
- package/src/router.js +0 -28
- package/src/theme.js +0 -8
- package/src/tmui2.js +0 -60
- package/src/util.js +0 -37
- package/src/viewTmuiVer.js +0 -24
package/src/create4xhbx.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
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,filename) {
|
|
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
|
-
}
|
package/src/createHbx.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
const chalk = import("chalk")
|
|
2
|
-
const path = require("path")
|
|
3
|
-
const fs = require("fs")
|
|
4
|
-
const ft = import("node-fetch")
|
|
5
|
-
const compressing = require("compressing")
|
|
6
|
-
const chilPro = require("child_process")
|
|
7
|
-
var clear = require('clear');
|
|
8
|
-
var figlet = require('figlet');
|
|
9
|
-
var CLI = require('clui'),
|
|
10
|
-
Spinner = CLI.Spinner;
|
|
11
|
-
const delFile = require("./util").default.delFile
|
|
12
|
-
var countdown = new Spinner('请等待... ', ['/','\\','/','\\']);
|
|
13
|
-
exports.run = function(type, name,vr,packname="npm",filename) {
|
|
14
|
-
chalk.then(v=>{
|
|
15
|
-
clear()
|
|
16
|
-
const ck = new v.Chalk();
|
|
17
|
-
const nowPath = path.join(path.resolve('./'),filename);
|
|
18
|
-
var vrNumber = 0
|
|
19
|
-
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
20
|
-
let userInputVer = "";
|
|
21
|
-
if(vr!=null){
|
|
22
|
-
userInputVer = vr;
|
|
23
|
-
}else{
|
|
24
|
-
let args = name.parent.rawArgs.filter(el=>{
|
|
25
|
-
return el
|
|
26
|
-
})
|
|
27
|
-
if(args.includes('-c')){
|
|
28
|
-
if(args.length==5){
|
|
29
|
-
userInputVer = args.pop()||""
|
|
30
|
-
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
31
|
-
}
|
|
32
|
-
}else if(args.length==4){
|
|
33
|
-
userInputVer = args.pop()||""
|
|
34
|
-
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
vrNumber = parseInt(userInputVer.replace(/\./g,''))
|
|
38
|
-
if(isNaN(vrNumber)){
|
|
39
|
-
console.log(ck.red("没有输入版本号"))
|
|
40
|
-
}
|
|
41
|
-
if(!fs.existsSync(nowPath)){
|
|
42
|
-
fs.mkdirSync(nowPath);
|
|
43
|
-
}
|
|
44
|
-
ft.then((fah)=>{
|
|
45
|
-
const fetch = fah.default
|
|
46
|
-
|
|
47
|
-
fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
|
|
48
|
-
let verText = await res.text();
|
|
49
|
-
let ver = verText.split('\n')[0]
|
|
50
|
-
if(userInputVer){
|
|
51
|
-
ver = userInputVer;
|
|
52
|
-
}
|
|
53
|
-
let isVer = verText.includes(ver)
|
|
54
|
-
if(!isVer){
|
|
55
|
-
console.log(ck.red('不存在版本号:'+ver))
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
59
|
-
console.log(ck.green('正在使用版本号:'+ver))
|
|
60
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
61
|
-
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
62
|
-
fetch(`https://cdn.tmui.design/public/static/tmuiHBX.zip`).then(async (rf)=>{
|
|
63
|
-
let d = await rf.buffer()
|
|
64
|
-
fs.writeFile(path.join(nowPath,'tmuiHBX.zip'),d,(err)=>{
|
|
65
|
-
if(err){
|
|
66
|
-
console.log(ck.bgRed(err))
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
compressing.zip.uncompress(path.join(nowPath,'tmuiHBX.zip'),path.join(nowPath))
|
|
70
|
-
.then(revalue=>{
|
|
71
|
-
//创建tmui目录
|
|
72
|
-
let tmuipath = path.join(nowPath,'tmui');
|
|
73
|
-
if(vrNumber>=320){
|
|
74
|
-
tmuipath = path.join(nowPath,'uni_modules');
|
|
75
|
-
if(!fs.existsSync(tmuipath)){
|
|
76
|
-
fs.mkdirSync(tmuipath);
|
|
77
|
-
}
|
|
78
|
-
tmuipath = path.join(nowPath,'uni_modules','tm-ui');
|
|
79
|
-
}
|
|
80
|
-
if(!fs.existsSync(tmuipath)){
|
|
81
|
-
fs.mkdirSync(tmuipath);
|
|
82
|
-
}else{
|
|
83
|
-
delFile(tmuipath)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
countdown.start()
|
|
87
|
-
//下载tmui
|
|
88
|
-
let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
|
|
89
|
-
fetch(donloadTmui).then(async (tmuires)=>{
|
|
90
|
-
fs.writeFileSync(path.join(nowPath,'tmui.zip'),await tmuires.buffer())
|
|
91
|
-
compressing.zip.uncompress(path.join(nowPath,'tmui.zip'),tmuipath)
|
|
92
|
-
.then(comtmui=>{
|
|
93
|
-
console.log(ck.bgGreen('非常nice,安装成功,正在清理'))
|
|
94
|
-
if(fs.existsSync(path.join(nowPath,'tmui.zip'))){
|
|
95
|
-
fs.unlinkSync(path.join(nowPath,'tmui.zip'))
|
|
96
|
-
}
|
|
97
|
-
if(fs.existsSync(path.join(nowPath,'tmuiHBX.zip'))){
|
|
98
|
-
fs.unlinkSync(path.join(nowPath,'tmuiHBX.zip'))
|
|
99
|
-
}
|
|
100
|
-
console.log(ck.bgGreen('清理成功,正在安装依赖时间稍长~'))
|
|
101
|
-
chilPro.exec(packname+' install echarts --save',error=>{
|
|
102
|
-
countdown.stop()
|
|
103
|
-
if(error){
|
|
104
|
-
console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
|
|
105
|
-
console.log(ck.green(packname+' install'))
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
clear()
|
|
109
|
-
figlet('TMUI OK!!', function(err, data) {
|
|
110
|
-
if (err) {
|
|
111
|
-
console.log('Something went wrong...');
|
|
112
|
-
console.dir(err);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
console.log(ck.bgGreen(data))
|
|
116
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
117
|
-
console.log(ck.bgGreen('安装成功,请使用hbx导入项目,运行本项目。'))
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
})
|
|
121
|
-
}).catch(err=>{
|
|
122
|
-
countdown.stop()
|
|
123
|
-
console.log(ck.bgRed(err))
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
.catch(e=>{
|
|
127
|
-
countdown.stop()
|
|
128
|
-
console.log(ck.bgRed(e))
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
}).catch(errs=>{
|
|
132
|
-
console.log(ck.bgRed(errs))
|
|
133
|
-
})
|
|
134
|
-
})
|
|
135
|
-
}).catch(e=>{
|
|
136
|
-
console.log(ck.bgRed(e))
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
// fetch()tmuiVer.txt
|
|
141
|
-
})
|
|
142
|
-
}
|
package/src/rcli.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
const chalk = import("chalk")
|
|
2
|
-
const path = require("path")
|
|
3
|
-
const fs = require("fs")
|
|
4
|
-
const ft = import("node-fetch")
|
|
5
|
-
const compressing = require("compressing")
|
|
6
|
-
const chilPro = require("child_process")
|
|
7
|
-
var clear = require('clear');
|
|
8
|
-
var figlet = require('figlet');
|
|
9
|
-
var CLI = require('clui'),
|
|
10
|
-
Spinner = CLI.Spinner;
|
|
11
|
-
var countdown = new Spinner('请等待... ', ['/','\\','/','\\']);
|
|
12
|
-
const delFile = require("./util").default.delFile
|
|
13
|
-
exports.run = function(type, name,vr,packname="npm",filename="") {
|
|
14
|
-
chalk.then(v=>{
|
|
15
|
-
const ck = new v.Chalk();
|
|
16
|
-
const nowPath = path.join(path.resolve('./'),filename);
|
|
17
|
-
var vrNumber = 0
|
|
18
|
-
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
19
|
-
let userInputVer = "";
|
|
20
|
-
if(vr!=null){
|
|
21
|
-
userInputVer = vr;
|
|
22
|
-
}else{
|
|
23
|
-
let args = name.parent.rawArgs.filter(el=>{
|
|
24
|
-
return el
|
|
25
|
-
})
|
|
26
|
-
if(args.includes('-c')){
|
|
27
|
-
if(args.length==5){
|
|
28
|
-
userInputVer = args.pop()||""
|
|
29
|
-
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
30
|
-
}
|
|
31
|
-
}else if(args.length==4){
|
|
32
|
-
userInputVer = args.pop()||""
|
|
33
|
-
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
vrNumber = parseInt(userInputVer.replace(/\./g,''))
|
|
37
|
-
if(isNaN(vrNumber)){
|
|
38
|
-
console.log(ck.red("没有输入版本号"))
|
|
39
|
-
}
|
|
40
|
-
if(!fs.existsSync(nowPath)){
|
|
41
|
-
fs.mkdirSync(nowPath);
|
|
42
|
-
}
|
|
43
|
-
ft.then((fah)=>{
|
|
44
|
-
const fetch = fah.default
|
|
45
|
-
|
|
46
|
-
fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
|
|
47
|
-
let verText = await res.text();
|
|
48
|
-
let ver = verText.split('\n')[0]
|
|
49
|
-
if(userInputVer){
|
|
50
|
-
ver = userInputVer;
|
|
51
|
-
}
|
|
52
|
-
let isVer = verText.includes(ver)
|
|
53
|
-
if(!isVer){
|
|
54
|
-
console.log(ck.red('不存在版本号:'+ver))
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const fileName = `cli${ver}.zip`
|
|
58
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
59
|
-
console.log(ck.green('正在使用版本号:'+ver))
|
|
60
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
61
|
-
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
62
|
-
//创建tmui目录
|
|
63
|
-
if( !fs.existsSync(path.join(nowPath,'src'))){
|
|
64
|
-
console.log(ck.bgRed('非cli项目,请使用rhbx项目'))
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
//创建tmui目录
|
|
68
|
-
let tmuipath = path.join(nowPath,'src','tmui');
|
|
69
|
-
if(vrNumber>=320){
|
|
70
|
-
tmuipath = path.join(nowPath,'src','uni_modules');
|
|
71
|
-
if(!fs.existsSync(tmuipath)){
|
|
72
|
-
fs.mkdirSync(tmuipath);
|
|
73
|
-
}
|
|
74
|
-
tmuipath = path.join(nowPath,'src','uni_modules','tm-ui');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if(!fs.existsSync(tmuipath)){
|
|
78
|
-
fs.mkdirSync(tmuipath);
|
|
79
|
-
}else{
|
|
80
|
-
delFile(tmuipath)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
countdown.start()
|
|
84
|
-
//下载tmui
|
|
85
|
-
let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
|
|
86
|
-
fetch(donloadTmui).then(async (tmuires)=>{
|
|
87
|
-
fs.writeFileSync(path.join(nowPath,'tmui.zip'),await tmuires.buffer())
|
|
88
|
-
compressing.zip.uncompress(path.join(nowPath,'tmui.zip'),tmuipath)
|
|
89
|
-
.then(comtmui=>{
|
|
90
|
-
|
|
91
|
-
console.log(ck.bgGreen('非常nice,安装成功,正在清理'))
|
|
92
|
-
|
|
93
|
-
if(fs.existsSync(path.join(nowPath,'tmui.zip'))){
|
|
94
|
-
fs.unlinkSync(path.join(nowPath,'tmui.zip'))
|
|
95
|
-
}
|
|
96
|
-
if(fs.existsSync(path.join(nowPath,'cli.zip'))){
|
|
97
|
-
fs.unlinkSync(path.join(nowPath,'cli.zip'))
|
|
98
|
-
}
|
|
99
|
-
console.log(ck.bgGreen('清理成功,正在安装依赖时间稍长~'))
|
|
100
|
-
clear()
|
|
101
|
-
chilPro.exec(packname+' install',error=>{
|
|
102
|
-
countdown.stop()
|
|
103
|
-
if(error){
|
|
104
|
-
console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
|
|
105
|
-
console.log(ck.green(packname+' install'))
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
figlet('TMUI OK!!', function(err, data) {
|
|
110
|
-
if (err) {
|
|
111
|
-
console.log('Something went wrong...');
|
|
112
|
-
console.dir(err);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
console.log(ck.bgGreen(data))
|
|
116
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
117
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
118
|
-
console.log(ck.green('安装成功 请执行uni cli命令,编译一个H5项目试:'))
|
|
119
|
-
console.log(ck.green(packname+' run dev:h5'))
|
|
120
|
-
console.log(ck.green('在本窗口输入上述命令,按回车键编译。'))
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
})
|
|
124
|
-
}).catch(err=>{
|
|
125
|
-
console.log(ck.bgRed(err))
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
.catch(e=>{
|
|
129
|
-
countdown.stop()
|
|
130
|
-
console.log(ck.bgRed(e))
|
|
131
|
-
})
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
// fetch()tmuiVer.txt
|
|
135
|
-
})
|
|
136
|
-
}
|
package/src/rhbx.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
const chalk = import("chalk")
|
|
2
|
-
const path = require("path")
|
|
3
|
-
const fs = require("fs")
|
|
4
|
-
const ft = import("node-fetch")
|
|
5
|
-
const compressing = require("compressing")
|
|
6
|
-
const chilPro = require("child_process")
|
|
7
|
-
var clear = require('clear');
|
|
8
|
-
var figlet = require('figlet');
|
|
9
|
-
var CLI = require('clui'),
|
|
10
|
-
Spinner = CLI.Spinner;
|
|
11
|
-
const delFile = require("./util").default.delFile
|
|
12
|
-
|
|
13
|
-
var countdown = new Spinner('请等待... ', ['/','\\','/','\\']);
|
|
14
|
-
exports.run = function(type, name,vr,packname="npm",filename) {
|
|
15
|
-
chalk.then(v=>{
|
|
16
|
-
clear()
|
|
17
|
-
const ck = new v.Chalk();
|
|
18
|
-
const nowPath = path.join(path.resolve('./'),filename);
|
|
19
|
-
var vrNumber = 0
|
|
20
|
-
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
21
|
-
let userInputVer = "";
|
|
22
|
-
if(vr!=null){
|
|
23
|
-
userInputVer = vr;
|
|
24
|
-
}else{
|
|
25
|
-
let args = name.parent.rawArgs.filter(el=>{
|
|
26
|
-
return el
|
|
27
|
-
})
|
|
28
|
-
if(args.includes('-c')){
|
|
29
|
-
if(args.length==5){
|
|
30
|
-
userInputVer = args.pop()||""
|
|
31
|
-
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
32
|
-
}
|
|
33
|
-
}else if(args.length==4){
|
|
34
|
-
userInputVer = args.pop()||""
|
|
35
|
-
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
vrNumber = parseInt(userInputVer.replace(/\./g,''))
|
|
40
|
-
if(isNaN(vrNumber)){
|
|
41
|
-
console.log(ck.red("没有输入版本号"))
|
|
42
|
-
}
|
|
43
|
-
if(!fs.existsSync(nowPath)){
|
|
44
|
-
fs.mkdirSync(nowPath);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
ft.then((fah)=>{
|
|
48
|
-
const fetch = fah.default
|
|
49
|
-
//创建tmui目录
|
|
50
|
-
let tmuipath = path.join(nowPath,'tmui');
|
|
51
|
-
if(vrNumber>=320){
|
|
52
|
-
tmuipath = path.join(nowPath,'uni_modules');
|
|
53
|
-
if(!fs.existsSync(tmuipath)){
|
|
54
|
-
fs.mkdirSync(tmuipath);
|
|
55
|
-
}
|
|
56
|
-
tmuipath = path.join(nowPath,'uni_modules','tm-ui');
|
|
57
|
-
}
|
|
58
|
-
if(!fs.existsSync(tmuipath)){
|
|
59
|
-
fs.mkdirSync(tmuipath);
|
|
60
|
-
}else{
|
|
61
|
-
delFile(tmuipath)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
|
|
65
|
-
let verText = await res.text();
|
|
66
|
-
let ver = verText.split('\n')[0]
|
|
67
|
-
if(userInputVer){
|
|
68
|
-
ver = userInputVer;
|
|
69
|
-
}
|
|
70
|
-
let isVer = verText.includes(ver)
|
|
71
|
-
if(!isVer){
|
|
72
|
-
console.log(ck.red('不存在版本号:'+ver))
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
76
|
-
console.log(ck.green('正在使用版本号:'+ver))
|
|
77
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
78
|
-
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
79
|
-
countdown.start()
|
|
80
|
-
//下载tmui
|
|
81
|
-
let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
|
|
82
|
-
fetch(donloadTmui).then(async (tmuires)=>{
|
|
83
|
-
fs.writeFileSync(path.join(nowPath,'tmui.zip'),await tmuires.buffer())
|
|
84
|
-
compressing.zip.uncompress(path.join(nowPath,'tmui.zip'),tmuipath)
|
|
85
|
-
.then(comtmui=>{
|
|
86
|
-
console.log(ck.bgGreen('非常nice,安装成功,正在清理'))
|
|
87
|
-
|
|
88
|
-
if(fs.existsSync(path.join(nowPath,'tmui.zip'))){
|
|
89
|
-
fs.unlinkSync(path.join(nowPath,'tmui.zip'))
|
|
90
|
-
}
|
|
91
|
-
if(fs.existsSync(path.join(nowPath,'tmuiHBX.zip'))){
|
|
92
|
-
fs.unlinkSync(path.join(nowPath,'tmuiHBX.zip'))
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
console.log(ck.bgGreen('清理成功,正在安装依赖时间稍长~'))
|
|
96
|
-
chilPro.exec(packname+' install echarts --save',error=>{
|
|
97
|
-
countdown.stop()
|
|
98
|
-
if(error){
|
|
99
|
-
console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
|
|
100
|
-
console.log(ck.green(packname+' install'))
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
clear();
|
|
104
|
-
figlet('TMUI OK!!', function(err, data) {
|
|
105
|
-
if (err) {
|
|
106
|
-
console.log('Something went wrong...');
|
|
107
|
-
console.dir(err);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
console.log(ck.bgGreen(data))
|
|
111
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
112
|
-
console.log(ck.bgGreen('安装成功,请使用hbx导入项目,运行本项目。'))
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
})
|
|
116
|
-
}).catch(err=>{
|
|
117
|
-
countdown.stop()
|
|
118
|
-
console.log(ck.bgRed(err))
|
|
119
|
-
})
|
|
120
|
-
})
|
|
121
|
-
.catch(e=>{
|
|
122
|
-
countdown.stop()
|
|
123
|
-
console.log(ck.bgRed(e))
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
})
|
|
129
|
-
// fetch()tmuiVer.txt
|
|
130
|
-
})
|
|
131
|
-
}
|
package/src/router.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
exports.txt=`
|
|
2
|
-
import { ComponentPublicInstance, nextTick } from "vue"
|
|
3
|
-
//如果想要使用框架的自带工具函数请输入uni.$tm.u.?你的方法
|
|
4
|
-
//网络请示为uni.$tm.fetch.?你的方法
|
|
5
|
-
|
|
6
|
-
interface beforeRouterOpts {
|
|
7
|
-
path:string,//当前页面路径,不含前缀 /
|
|
8
|
-
opts?:any,//页面参数
|
|
9
|
-
context:ComponentPublicInstance|null,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 路由访问前执行的函数
|
|
14
|
-
* @param path 页面路径,不带前缀/
|
|
15
|
-
*/
|
|
16
|
-
export const useTmRouterBefore = (arg:beforeRouterOpts):void=>{
|
|
17
|
-
// 每一个页面在初化前都会执行
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* 路由访问后执行的函数
|
|
21
|
-
* @param path 页面路径,不带前缀/
|
|
22
|
-
* @param opts 页面加载完成后返回的参数
|
|
23
|
-
*/
|
|
24
|
-
export const useTmRouterAfter = (arg:beforeRouterOpts):void=>{
|
|
25
|
-
//每一个页面初始后都会执行
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
`
|
package/src/theme.js
DELETED
package/src/tmui2.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const chalk = import("chalk")
|
|
2
|
-
const path = require("path")
|
|
3
|
-
const fs = require("fs")
|
|
4
|
-
const ft = import("node-fetch")
|
|
5
|
-
const compressing = require("compressing")
|
|
6
|
-
const chilPro = require("child_process")
|
|
7
|
-
exports.run = function() {
|
|
8
|
-
chalk.then(v=>{
|
|
9
|
-
const ck = new v.Chalk();
|
|
10
|
-
const nowPath = path.resolve('./');
|
|
11
|
-
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
12
|
-
|
|
13
|
-
ft.then((fah)=>{
|
|
14
|
-
const fetch = fah.default
|
|
15
|
-
//创建tmui目录
|
|
16
|
-
let tmuipath = path.join(nowPath,'tm-vuetify');
|
|
17
|
-
if(!fs.existsSync(tmuipath)){
|
|
18
|
-
fs.mkdirSync(tmuipath);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
fetch('https://cdn.tmui.design/tmui2.0Ver.txt').then(async (res)=>{
|
|
22
|
-
let verText = await res.text();
|
|
23
|
-
let ver = verText.split('\n')[0]
|
|
24
|
-
|
|
25
|
-
let isVer = verText.includes(ver)
|
|
26
|
-
if(!isVer){
|
|
27
|
-
console.log(ck.red('不存在版本号:'+ver))
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
31
|
-
console.log(ck.green('正在使用版本号:'+ver))
|
|
32
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
33
|
-
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
34
|
-
//下载tmui
|
|
35
|
-
let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
|
|
36
|
-
fetch(donloadTmui).then(async (tmuires)=>{
|
|
37
|
-
fs.writeFileSync(path.join(nowPath,'tmui.zip'),await tmuires.buffer())
|
|
38
|
-
compressing.zip.uncompress(path.join(nowPath,'tmui.zip'),tmuipath)
|
|
39
|
-
.then(comtmui=>{
|
|
40
|
-
|
|
41
|
-
if(fs.existsSync(path.join(nowPath,'tmui.zip'))){
|
|
42
|
-
fs.unlinkSync(path.join(nowPath,'tmui.zip'))
|
|
43
|
-
}
|
|
44
|
-
console.log(ck.bgGreen('已成功将tmui2.0下载至你的项目根目录下!'))
|
|
45
|
-
console.log(ck.bgGreen('具体安装配置流程见文档:https://jx2d.cn'))
|
|
46
|
-
|
|
47
|
-
}).catch(err=>{
|
|
48
|
-
console.log(ck.bgRed(err))
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
.catch(e=>{
|
|
52
|
-
console.log(ck.bgRed(e))
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})
|
|
58
|
-
// fetch()tmuiVer.txt
|
|
59
|
-
})
|
|
60
|
-
}
|
package/src/util.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const fs = require("fs")
|
|
2
|
-
function delFile(fileUrl, flag) {
|
|
3
|
-
if (!fs.existsSync(fileUrl)) return;
|
|
4
|
-
// 当前文件为文件夹时
|
|
5
|
-
if (fs.statSync(fileUrl).isDirectory()) {
|
|
6
|
-
var files = fs.readdirSync(fileUrl);
|
|
7
|
-
var len = files.length,
|
|
8
|
-
removeNumber = 0;
|
|
9
|
-
if (len > 0) {
|
|
10
|
-
files.forEach(function (file) {
|
|
11
|
-
removeNumber++;
|
|
12
|
-
var stats = fs.statSync(fileUrl + '/' + file);
|
|
13
|
-
var url = fileUrl + '/' + file;
|
|
14
|
-
if (fs.statSync(url).isDirectory()) {
|
|
15
|
-
delFile(url, true);
|
|
16
|
-
} else {
|
|
17
|
-
fs.unlinkSync(url);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
if (len == removeNumber && flag) {
|
|
21
|
-
fs.rmdirSync(fileUrl);
|
|
22
|
-
}
|
|
23
|
-
} else if (len == 0 && flag) {
|
|
24
|
-
fs.rmdirSync(fileUrl);
|
|
25
|
-
}
|
|
26
|
-
} else {
|
|
27
|
-
// 当前文件为文件时
|
|
28
|
-
fs.unlinkSync(fileUrl);
|
|
29
|
-
console.log('删除文件' + fileUrl + '成功');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**检查 uni cli的最新版本号。*/
|
|
34
|
-
|
|
35
|
-
exports.default= {
|
|
36
|
-
delFile
|
|
37
|
-
}
|
package/src/viewTmuiVer.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const chalk = import("chalk")
|
|
2
|
-
const path = require("path")
|
|
3
|
-
const fs = require("fs")
|
|
4
|
-
const ft = import("node-fetch")
|
|
5
|
-
const compressing = require("compressing")
|
|
6
|
-
const chilPro = require("child_process")
|
|
7
|
-
exports.run = function(type, name) {
|
|
8
|
-
chalk.then(v=>{
|
|
9
|
-
const ck = new v.Chalk();
|
|
10
|
-
const nowPath = path.resolve('./');
|
|
11
|
-
|
|
12
|
-
ft.then((fah)=>{
|
|
13
|
-
const fetch = fah.default
|
|
14
|
-
|
|
15
|
-
fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
|
|
16
|
-
let verText = await res.text();
|
|
17
|
-
let ver = verText.split('\n')[0]
|
|
18
|
-
console.log(ck.green('查询到版本号如下:'))
|
|
19
|
-
console.log(verText)
|
|
20
|
-
})
|
|
21
|
-
})
|
|
22
|
-
// fetch()tmuiVer.txt
|
|
23
|
-
})
|
|
24
|
-
}
|