tmui-cli 1.0.5 → 1.0.8
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 +8 -5
- package/bin/tmui.js +121 -109
- package/package.json +5 -2
- package/src/create.js +45 -19
- package/src/createHbx.js +26 -3
- package/src/rcli.js +29 -6
- package/src/rhbx.js +27 -3
- package/src/util.js +35 -0
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
```npm
|
|
12
12
|
npm -g install tmui-cli
|
|
13
|
+
安装成功后输入:tmui
|
|
14
|
+
即可查看所有可用命令
|
|
13
15
|
```
|
|
14
16
|
|
|
15
17
|
#### 使用
|
|
@@ -18,11 +20,12 @@ npm -g install tmui-cli
|
|
|
18
20
|
即可取得所有可控的命令行
|
|
19
21
|
|
|
20
22
|
#### 命令解释
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
|
|
24
|
+
0. tmui cli 创建uniapp 平台的cli初始项目,内部已经包含了tmui最新框架(自动更新)
|
|
25
|
+
1. tmui hbx 创建uniapp 平台的HBX初始项目,内部已经包含了tmui最新框架(自动更新)
|
|
26
|
+
2. tmui rcli 为【已有】uniapp 平台的cli项目,更新和下载tmui最新框架(自动更新)
|
|
27
|
+
3. tmui rhbx 为【已有】uniapp 平台的HBX项目,更新和下载tmui最新框架(自动更新)
|
|
28
|
+
4. tmui use 为保姆级引导式下载安装上述功能项目。
|
|
26
29
|
|
|
27
30
|
#### 注意事项
|
|
28
31
|
如果你是需要创建tmui新项目可以使用命令行创建全新的项目。<br>
|
package/bin/tmui.js
CHANGED
|
@@ -12,120 +12,132 @@ const viewTmuiVer = require("../src/viewTmuiVer")
|
|
|
12
12
|
const tm2 = require("../src/tmui2")
|
|
13
13
|
const inquirer = import('inquirer');
|
|
14
14
|
const ft = import("node-fetch")
|
|
15
|
+
var clear = require('clear');
|
|
16
|
+
var figlet = require('figlet');
|
|
17
|
+
clear()
|
|
15
18
|
chalk.then(v=>{
|
|
16
19
|
const ck = new v.Chalk();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.action(function(type, name){
|
|
31
|
-
create.run(type,name)
|
|
32
|
-
})
|
|
33
|
-
program.command('hbx')
|
|
34
|
-
.description('[可选指定版本号] 创建hbx uniapp tmui3.0 项目[不推荐]')
|
|
35
|
-
.action(function(type, name){
|
|
36
|
-
createHbx.run(type,name)
|
|
37
|
-
})
|
|
38
|
-
program.command('rcli')
|
|
39
|
-
.description('[可选指定版本号] 已有cli项目下载/更新tmui3.0')
|
|
40
|
-
.action(function(type, name){
|
|
41
|
-
rcli.run(type,name)
|
|
42
|
-
})
|
|
43
|
-
program.command('rhbx')
|
|
44
|
-
.description('[可选指定版本号] 已有hbx项目下载/更新tmui3.0')
|
|
45
|
-
.action(function(type, name){
|
|
46
|
-
rhbx.run(type,name)
|
|
47
|
-
})
|
|
48
|
-
program.command('ver')
|
|
49
|
-
.description('查看tmui可用版本号')
|
|
50
|
-
.action(function(type, name){
|
|
51
|
-
viewTmuiVer.run(type,name)
|
|
52
|
-
})
|
|
53
|
-
program.command('use')
|
|
54
|
-
.description('引导式安装tmui组件!!!')
|
|
55
|
-
.action(function(type, name){
|
|
56
|
-
const { prompt,Separator} = ivk.default;
|
|
57
|
-
prompt([
|
|
58
|
-
{
|
|
59
|
-
type: 'list',
|
|
60
|
-
name: 'tmuiVerName',
|
|
61
|
-
message: '请选择你的uniApp项目的vue版本',
|
|
62
|
-
choices: [
|
|
63
|
-
'vue2',
|
|
64
|
-
'vue3'
|
|
65
|
-
],
|
|
66
|
-
}
|
|
67
|
-
])
|
|
68
|
-
.then((answers) => {
|
|
69
|
-
if(answers.tmuiVerName=="vue2"){
|
|
70
|
-
console.log("tmui2.0版本只支持uniApp HBX项目,请务必当前目录在你的项目文件夹下/或者一个空文件都可以。")
|
|
71
|
-
console.log("正在为你的项目下载/更新tmui2.0的最新版本。")
|
|
72
|
-
tm2.run()
|
|
73
|
-
}else if(answers.tmuiVerName=='vue3'){
|
|
20
|
+
|
|
21
|
+
figlet('TMUI3.0 CLI', function(err, data) {
|
|
22
|
+
if (err) {
|
|
23
|
+
console.log('Something went wrong...');
|
|
24
|
+
console.dir(err);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
console.log(ck.white(`---------------------------------------------------`))
|
|
28
|
+
console.log(ck.white(`---------------------------------------------------`))
|
|
29
|
+
console.log(ck.green(data))
|
|
30
|
+
console.log(ck.green(`文档地址:https://tmui.design`))
|
|
31
|
+
console.log(ck.white(`---------------------------------------------------`))
|
|
32
|
+
console.log(ck.white(`---------------------------------------------------`))
|
|
74
33
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
34
|
+
inquirer.then(ivk=>{
|
|
35
|
+
program
|
|
36
|
+
.version(require('../package').version)
|
|
37
|
+
program.command('cli')
|
|
38
|
+
.description('[可选指定版本号] 创建cli uniapp tmui3.0 项目[推荐]')
|
|
39
|
+
.action(function(type, name){
|
|
40
|
+
create.run(type,name)
|
|
41
|
+
})
|
|
42
|
+
program.command('hbx')
|
|
43
|
+
.description('[可选指定版本号] 创建hbx uniapp tmui3.0 项目[不推荐]')
|
|
44
|
+
.action(function(type, name){
|
|
45
|
+
createHbx.run(type,name)
|
|
46
|
+
})
|
|
47
|
+
program.command('rcli')
|
|
48
|
+
.description('[可选指定版本号] 已有cli项目下载/更新tmui3.0')
|
|
49
|
+
.action(function(type, name){
|
|
50
|
+
rcli.run(type,name)
|
|
51
|
+
})
|
|
52
|
+
program.command('rhbx')
|
|
53
|
+
.description('[可选指定版本号] 已有hbx项目下载/更新tmui3.0')
|
|
54
|
+
.action(function(type, name){
|
|
55
|
+
rhbx.run(type,name)
|
|
56
|
+
})
|
|
57
|
+
program.command('ver')
|
|
58
|
+
.description('查看tmui可用版本号')
|
|
59
|
+
.action(function(type, name){
|
|
60
|
+
viewTmuiVer.run(type,name)
|
|
61
|
+
})
|
|
62
|
+
program.command('use')
|
|
63
|
+
.description('引导式安装tmui组件!!!')
|
|
64
|
+
.action(function(type, name){
|
|
65
|
+
const { prompt,Separator} = ivk.default;
|
|
66
|
+
prompt([
|
|
67
|
+
{
|
|
68
|
+
type: 'list',
|
|
69
|
+
name: 'tmuiVerName',
|
|
70
|
+
message: '请选择你的uniApp项目的vue版本',
|
|
71
|
+
choices: [
|
|
72
|
+
'vue2',
|
|
73
|
+
'vue3'
|
|
74
|
+
],
|
|
75
|
+
}
|
|
76
|
+
])
|
|
77
|
+
.then((answers) => {
|
|
78
|
+
if(answers.tmuiVerName=="vue2"){
|
|
79
|
+
console.log("tmui2.0版本只支持uniApp HBX项目,请务必当前目录在你的项目文件夹下/或者一个空文件都可以。")
|
|
80
|
+
console.log("正在为你的项目下载/更新tmui2.0的最新版本。")
|
|
81
|
+
tm2.run()
|
|
82
|
+
}else if(answers.tmuiVerName=='vue3'){
|
|
83
|
+
|
|
84
|
+
ft.then((fah)=>{
|
|
85
|
+
const fetch = fah.default
|
|
86
|
+
fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
|
|
87
|
+
let verText = await res.text();
|
|
88
|
+
let lastVer = verText.split('\n').slice(0,10)
|
|
89
|
+
prompt([
|
|
90
|
+
{
|
|
91
|
+
type: 'list',
|
|
92
|
+
name: 'moshi',
|
|
93
|
+
message: '选择安装方式:',
|
|
94
|
+
choices: [
|
|
95
|
+
'cli',
|
|
96
|
+
'rcli',
|
|
97
|
+
'hbx',
|
|
98
|
+
'rhbx',
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: 'list',
|
|
103
|
+
name: 'ver',
|
|
104
|
+
message: '选择最近的版本号',
|
|
105
|
+
choices: lastVer,
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
])
|
|
109
|
+
.then((answers) => {
|
|
110
|
+
let ms = answers.moshi;
|
|
111
|
+
let ver = answers.ver.trim()
|
|
112
|
+
if(!ver||typeof ver=="undefined"){
|
|
113
|
+
console.log(ck.red("请正确输入版本号"))
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if(ms=="cli"){
|
|
117
|
+
create.run(null,null,ver)
|
|
118
|
+
}else if(ms=="rcli"){
|
|
119
|
+
rcli.run(null,null,ver)
|
|
120
|
+
}else if(ms=="hbx"){
|
|
121
|
+
createHbx.run(null,null,ver)
|
|
122
|
+
}else if(ms=="rhbx"){
|
|
123
|
+
rhbx.run(null,null,ver)
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
})
|
|
118
129
|
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
})
|
|
135
|
+
program.parse();
|
|
136
|
+
|
|
137
|
+
})
|
|
138
|
+
});
|
|
123
139
|
|
|
124
|
-
|
|
125
|
-
})
|
|
126
|
-
program.parse();
|
|
127
|
-
|
|
128
|
-
})
|
|
140
|
+
|
|
129
141
|
|
|
130
142
|
|
|
131
143
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_from": "tmui-cli",
|
|
3
|
-
"_id": "tmui-cli@1.0.
|
|
3
|
+
"_id": "tmui-cli@1.0.8",
|
|
4
4
|
"_inBundle": false,
|
|
5
5
|
"_integrity": "sha512-mnddgPs3eUjTuxQGv6hxlc0b98d53YXtjd0tvrlzWvrAnf0IS0qQMo4bZHi+ImwOEYqbNLX9jhd9pq1cVb9tjw==",
|
|
6
6
|
"_location": "/tmui-cli",
|
|
@@ -31,8 +31,11 @@
|
|
|
31
31
|
"bundleDependencies": false,
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"chalk": "^5.0.1",
|
|
34
|
+
"clear": "^0.1.0",
|
|
35
|
+
"clui": "^0.3.6",
|
|
34
36
|
"commander": "^9.4.0",
|
|
35
37
|
"compressing": "^1.6.2",
|
|
38
|
+
"figlet": "^1.5.2",
|
|
36
39
|
"inquirer": "^9.1.0",
|
|
37
40
|
"node-fetch": "^3.2.10"
|
|
38
41
|
},
|
|
@@ -46,5 +49,5 @@
|
|
|
46
49
|
"main": "./bin/tmui.js",
|
|
47
50
|
"name": "tmui-cli",
|
|
48
51
|
"scripts": {},
|
|
49
|
-
"version": "1.0.
|
|
52
|
+
"version": "1.0.8"
|
|
50
53
|
}
|
package/src/create.js
CHANGED
|
@@ -4,12 +4,18 @@ const fs = require("fs")
|
|
|
4
4
|
const ft = import("node-fetch")
|
|
5
5
|
const compressing = require("compressing")
|
|
6
6
|
const chilPro = require("child_process")
|
|
7
|
-
|
|
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
|
|
8
13
|
exports.run = function(type, name,vr) {
|
|
9
14
|
chalk.then(v=>{
|
|
10
15
|
const ck = new v.Chalk();
|
|
11
16
|
const nowPath = path.resolve('./');
|
|
12
|
-
|
|
17
|
+
|
|
18
|
+
countdown.message(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
13
19
|
let userInputVer = "";
|
|
14
20
|
if(vr!=null){
|
|
15
21
|
userInputVer = vr;
|
|
@@ -27,7 +33,7 @@ exports.run = function(type, name,vr) {
|
|
|
27
33
|
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
|
-
|
|
36
|
+
countdown.start()
|
|
31
37
|
// 检查是否有router目录?
|
|
32
38
|
// fs.existsSync(path.join(nowPath,'router','index.ts'))
|
|
33
39
|
ft.then((fah)=>{
|
|
@@ -40,19 +46,18 @@ exports.run = function(type, name,vr) {
|
|
|
40
46
|
}
|
|
41
47
|
let isVer = verText.includes(ver)
|
|
42
48
|
if(!isVer){
|
|
49
|
+
countdown.stop();
|
|
43
50
|
console.log(ck.red('不存在版本号:'+ver))
|
|
44
51
|
return;
|
|
45
52
|
}
|
|
46
53
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
console.log(ck.green('正在使用版本号:'+ver))
|
|
50
|
-
console.log(ck.green(`---------------------------------------------------`))
|
|
51
|
-
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
54
|
+
|
|
55
|
+
countdown.message(ck.green('正在使用版本号:'+ver))
|
|
52
56
|
fetch(`https://cdn.tmui.design/public/static/cli.zip`).then(async (rf)=>{
|
|
53
57
|
let d = await rf.buffer()
|
|
54
58
|
fs.writeFile(path.join(nowPath,'cli.zip'),d,(err)=>{
|
|
55
59
|
if(err){
|
|
60
|
+
countdown.stop();
|
|
56
61
|
console.log(ck.bgRed(err))
|
|
57
62
|
return;
|
|
58
63
|
}
|
|
@@ -62,6 +67,8 @@ exports.run = function(type, name,vr) {
|
|
|
62
67
|
let tmuipath = path.join(nowPath,'src','tmui');
|
|
63
68
|
if(!fs.existsSync(tmuipath)){
|
|
64
69
|
fs.mkdirSync(tmuipath);
|
|
70
|
+
}else{
|
|
71
|
+
delFile(tmuipath)
|
|
65
72
|
}
|
|
66
73
|
//下载tmui
|
|
67
74
|
let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
|
|
@@ -69,29 +76,38 @@ exports.run = function(type, name,vr) {
|
|
|
69
76
|
fs.writeFileSync(path.join(nowPath,'tmui.zip'),await tmuires.buffer())
|
|
70
77
|
compressing.zip.uncompress(path.join(nowPath,'tmui.zip'),tmuipath)
|
|
71
78
|
.then(comtmui=>{
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
countdown.message(ck.green('非常nice,安装成功,正在清理'))
|
|
74
80
|
if(fs.existsSync(path.join(nowPath,'tmui.zip'))){
|
|
75
81
|
fs.unlinkSync(path.join(nowPath,'tmui.zip'))
|
|
76
82
|
}
|
|
77
83
|
if(fs.existsSync(path.join(nowPath,'cli.zip'))){
|
|
78
84
|
fs.unlinkSync(path.join(nowPath,'cli.zip'))
|
|
79
85
|
}
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
countdown.message(ck.green('正在安装依赖'))
|
|
82
87
|
const installNpm = chilPro.exec('npm install',(error, stdout, stderr)=>{
|
|
83
88
|
|
|
84
89
|
if(error){
|
|
90
|
+
countdown.stop()
|
|
85
91
|
console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
|
|
86
92
|
console.log(ck.green('npm install'))
|
|
87
93
|
return
|
|
88
94
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
countdown.stop()
|
|
96
|
+
clear()
|
|
97
|
+
figlet('TMUI OK!!', function(err, data) {
|
|
98
|
+
if (err) {
|
|
99
|
+
console.log('Something went wrong...');
|
|
100
|
+
console.dir(err);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
console.log(ck.bgGreen(data))
|
|
104
|
+
console.log(ck.green(`---------------------------------------------------`))
|
|
105
|
+
console.log(ck.green(`---------------------------------------------------`))
|
|
106
|
+
console.log(ck.green('安装成功请执行uni cli命令,编译一个H5项目试:'))
|
|
107
|
+
console.log(ck.green('npm run dev:h5'))
|
|
108
|
+
console.log(ck.green('在本窗口输入上述命令,按回车键编译。'))
|
|
109
|
+
})
|
|
110
|
+
|
|
95
111
|
})
|
|
96
112
|
|
|
97
113
|
installNpm.stdout?.on("data",(msg)=>{
|
|
@@ -99,21 +115,31 @@ exports.run = function(type, name,vr) {
|
|
|
99
115
|
})
|
|
100
116
|
|
|
101
117
|
}).catch(err=>{
|
|
118
|
+
countdown.stop()
|
|
102
119
|
console.log(ck.bgRed(err))
|
|
103
120
|
})
|
|
104
121
|
})
|
|
105
122
|
.catch(e=>{
|
|
123
|
+
countdown.stop()
|
|
106
124
|
console.log(ck.bgRed(e))
|
|
107
125
|
})
|
|
108
126
|
|
|
109
127
|
}).catch(errs=>{
|
|
128
|
+
countdown.stop()
|
|
110
129
|
console.log(ck.bgRed(errs))
|
|
111
130
|
})
|
|
112
131
|
})
|
|
113
132
|
}).catch(e=>{
|
|
114
|
-
|
|
133
|
+
countdown.stop();
|
|
134
|
+
console.log(ck.red(e))
|
|
115
135
|
})
|
|
136
|
+
}).catch(e=>{
|
|
137
|
+
countdown.stop();
|
|
138
|
+
console.log(ck.red(e))
|
|
116
139
|
})
|
|
140
|
+
}).catch(e=>{
|
|
141
|
+
countdown.stop();
|
|
142
|
+
console.log(ck.red(e))
|
|
117
143
|
})
|
|
118
144
|
// fetch()tmuiVer.txt
|
|
119
145
|
})
|
package/src/createHbx.js
CHANGED
|
@@ -4,8 +4,15 @@ const fs = require("fs")
|
|
|
4
4
|
const ft = import("node-fetch")
|
|
5
5
|
const compressing = require("compressing")
|
|
6
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('请等待... ', ['/','\\','/','\\']);
|
|
7
13
|
exports.run = function(type, name,vr) {
|
|
8
14
|
chalk.then(v=>{
|
|
15
|
+
clear()
|
|
9
16
|
const ck = new v.Chalk();
|
|
10
17
|
const nowPath = path.resolve('./');
|
|
11
18
|
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
@@ -58,7 +65,10 @@ exports.run = function(type, name,vr) {
|
|
|
58
65
|
let tmuipath = path.join(nowPath,'tmui');
|
|
59
66
|
if(!fs.existsSync(tmuipath)){
|
|
60
67
|
fs.mkdirSync(tmuipath);
|
|
68
|
+
}else{
|
|
69
|
+
delFile(tmuipath)
|
|
61
70
|
}
|
|
71
|
+
countdown.start()
|
|
62
72
|
//下载tmui
|
|
63
73
|
let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
|
|
64
74
|
fetch(donloadTmui).then(async (tmuires)=>{
|
|
@@ -74,20 +84,33 @@ exports.run = function(type, name,vr) {
|
|
|
74
84
|
}
|
|
75
85
|
console.log(ck.bgGreen('清理成功,正在安装依赖时间稍长~'))
|
|
76
86
|
chilPro.exec('npm install echarts --save',error=>{
|
|
87
|
+
countdown.stop()
|
|
77
88
|
if(error){
|
|
78
89
|
console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
|
|
79
90
|
console.log(ck.green('npm install'))
|
|
80
91
|
return
|
|
81
92
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
clear()
|
|
94
|
+
figlet('TMUI OK!!', function(err, data) {
|
|
95
|
+
if (err) {
|
|
96
|
+
console.log('Something went wrong...');
|
|
97
|
+
console.dir(err);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
console.log(ck.bgGreen(data))
|
|
101
|
+
console.log(ck.green(`---------------------------------------------------`))
|
|
102
|
+
console.log(ck.red(`截止3.5.4 hbx版本号,运行到浏览器会报错,其它平台没问题。这是uni的bug。但cli模式不会有问题。`))
|
|
103
|
+
console.log(ck.bgGreen('安装成功,请使用hbx导入项目,运行本项目。'))
|
|
104
|
+
})
|
|
105
|
+
|
|
85
106
|
})
|
|
86
107
|
}).catch(err=>{
|
|
108
|
+
countdown.stop()
|
|
87
109
|
console.log(ck.bgRed(err))
|
|
88
110
|
})
|
|
89
111
|
})
|
|
90
112
|
.catch(e=>{
|
|
113
|
+
countdown.stop()
|
|
91
114
|
console.log(ck.bgRed(e))
|
|
92
115
|
})
|
|
93
116
|
|
package/src/rcli.js
CHANGED
|
@@ -4,6 +4,12 @@ const fs = require("fs")
|
|
|
4
4
|
const ft = import("node-fetch")
|
|
5
5
|
const compressing = require("compressing")
|
|
6
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
|
|
7
13
|
exports.run = function(type, name,vr) {
|
|
8
14
|
chalk.then(v=>{
|
|
9
15
|
const ck = new v.Chalk();
|
|
@@ -53,13 +59,18 @@ exports.run = function(type, name,vr) {
|
|
|
53
59
|
let tmuipath = path.join(nowPath,'src','tmui');
|
|
54
60
|
if(!fs.existsSync(tmuipath)){
|
|
55
61
|
fs.mkdirSync(tmuipath);
|
|
62
|
+
}else{
|
|
63
|
+
delFile(tmuipath)
|
|
56
64
|
}
|
|
65
|
+
|
|
66
|
+
countdown.start()
|
|
57
67
|
//下载tmui
|
|
58
68
|
let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
|
|
59
69
|
fetch(donloadTmui).then(async (tmuires)=>{
|
|
60
70
|
fs.writeFileSync(path.join(nowPath,'tmui.zip'),await tmuires.buffer())
|
|
61
71
|
compressing.zip.uncompress(path.join(nowPath,'tmui.zip'),tmuipath)
|
|
62
72
|
.then(comtmui=>{
|
|
73
|
+
|
|
63
74
|
console.log(ck.bgGreen('非常nice,安装成功,正在清理'))
|
|
64
75
|
|
|
65
76
|
if(fs.existsSync(path.join(nowPath,'tmui.zip'))){
|
|
@@ -69,24 +80,36 @@ exports.run = function(type, name,vr) {
|
|
|
69
80
|
fs.unlinkSync(path.join(nowPath,'cli.zip'))
|
|
70
81
|
}
|
|
71
82
|
console.log(ck.bgGreen('清理成功,正在安装依赖时间稍长~'))
|
|
83
|
+
clear()
|
|
72
84
|
chilPro.exec('npm install',error=>{
|
|
85
|
+
countdown.stop()
|
|
73
86
|
if(error){
|
|
74
87
|
console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
|
|
75
88
|
console.log(ck.green('npm install'))
|
|
76
89
|
return
|
|
77
90
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
91
|
+
|
|
92
|
+
figlet('TMUI OK!!', function(err, data) {
|
|
93
|
+
if (err) {
|
|
94
|
+
console.log('Something went wrong...');
|
|
95
|
+
console.dir(err);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
console.log(ck.bgGreen(data))
|
|
99
|
+
console.log(ck.green(`---------------------------------------------------`))
|
|
100
|
+
console.log(ck.green(`---------------------------------------------------`))
|
|
101
|
+
console.log(ck.green('安装成功 请执行uni cli命令,编译一个H5项目试:'))
|
|
102
|
+
console.log(ck.green('npm run dev:h5'))
|
|
103
|
+
console.log(ck.green('在本窗口输入上述命令,按回车键编译。'))
|
|
104
|
+
})
|
|
105
|
+
|
|
84
106
|
})
|
|
85
107
|
}).catch(err=>{
|
|
86
108
|
console.log(ck.bgRed(err))
|
|
87
109
|
})
|
|
88
110
|
})
|
|
89
111
|
.catch(e=>{
|
|
112
|
+
countdown.stop()
|
|
90
113
|
console.log(ck.bgRed(e))
|
|
91
114
|
})
|
|
92
115
|
})
|
package/src/rhbx.js
CHANGED
|
@@ -4,8 +4,16 @@ const fs = require("fs")
|
|
|
4
4
|
const ft = import("node-fetch")
|
|
5
5
|
const compressing = require("compressing")
|
|
6
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('请等待... ', ['/','\\','/','\\']);
|
|
7
14
|
exports.run = function(type, name,vr) {
|
|
8
15
|
chalk.then(v=>{
|
|
16
|
+
clear()
|
|
9
17
|
const ck = new v.Chalk();
|
|
10
18
|
const nowPath = path.resolve('./');
|
|
11
19
|
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
@@ -51,6 +59,8 @@ exports.run = function(type, name,vr) {
|
|
|
51
59
|
let tmuipath = path.join(nowPath,'tmui');
|
|
52
60
|
if(!fs.existsSync(tmuipath)){
|
|
53
61
|
fs.mkdirSync(tmuipath);
|
|
62
|
+
}else{
|
|
63
|
+
delFile(tmuipath)
|
|
54
64
|
}
|
|
55
65
|
|
|
56
66
|
fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
|
|
@@ -68,6 +78,7 @@ exports.run = function(type, name,vr) {
|
|
|
68
78
|
console.log(ck.green('正在使用版本号:'+ver))
|
|
69
79
|
console.log(ck.green(`---------------------------------------------------`))
|
|
70
80
|
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
81
|
+
countdown.start()
|
|
71
82
|
//下载tmui
|
|
72
83
|
let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
|
|
73
84
|
fetch(donloadTmui).then(async (tmuires)=>{
|
|
@@ -85,20 +96,33 @@ exports.run = function(type, name,vr) {
|
|
|
85
96
|
|
|
86
97
|
console.log(ck.bgGreen('清理成功,正在安装依赖时间稍长~'))
|
|
87
98
|
chilPro.exec('npm install echarts --save',error=>{
|
|
99
|
+
countdown.stop()
|
|
88
100
|
if(error){
|
|
89
101
|
console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
|
|
90
102
|
console.log(ck.green('npm install'))
|
|
91
103
|
return
|
|
92
104
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
clear();
|
|
106
|
+
figlet('TMUI OK!!', function(err, data) {
|
|
107
|
+
if (err) {
|
|
108
|
+
console.log('Something went wrong...');
|
|
109
|
+
console.dir(err);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
console.log(ck.bgGreen(data))
|
|
113
|
+
console.log(ck.green(`---------------------------------------------------`))
|
|
114
|
+
console.log(ck.red(`截止3.5.4 hbx版本号,运行到浏览器会报错,其它平台没问题。这是uni的bug。但cli模式不会有问题。`))
|
|
115
|
+
console.log(ck.bgGreen('安装成功,请使用hbx导入项目,运行本项目。'))
|
|
116
|
+
})
|
|
117
|
+
|
|
96
118
|
})
|
|
97
119
|
}).catch(err=>{
|
|
120
|
+
countdown.stop()
|
|
98
121
|
console.log(ck.bgRed(err))
|
|
99
122
|
})
|
|
100
123
|
})
|
|
101
124
|
.catch(e=>{
|
|
125
|
+
countdown.stop()
|
|
102
126
|
console.log(ck.bgRed(e))
|
|
103
127
|
})
|
|
104
128
|
})
|
package/src/util.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
exports.default= {
|
|
34
|
+
delFile
|
|
35
|
+
}
|