tmui-cli 1.0.0 → 1.0.1
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/tmui.js +12 -5
- package/package.json +1 -1
- package/src/create.js +25 -0
- package/src/createHbx.js +23 -3
- package/src/rcli.js +22 -2
- package/src/rhbx.js +22 -1
- package/src/viewTmuiVer.js +24 -0
package/bin/tmui.js
CHANGED
|
@@ -8,6 +8,7 @@ const create = require("../src/create")
|
|
|
8
8
|
const createHbx = require("../src/createHbx")
|
|
9
9
|
const rhbx = require("../src/rhbx")
|
|
10
10
|
const rcli = require("../src/rcli")
|
|
11
|
+
const viewTmuiVer = require("../src/viewTmuiVer")
|
|
11
12
|
|
|
12
13
|
chalk.then(v=>{
|
|
13
14
|
const ck = new v.Chalk();
|
|
@@ -16,14 +17,15 @@ chalk.then(v=>{
|
|
|
16
17
|
console.log(ck.green(`tmui3.0`))
|
|
17
18
|
console.log(ck.green(`欢迎使用tmui3.0 cli 命令行工具`))
|
|
18
19
|
console.log(ck.green(`将引导你创建一个tmui3.0组件框架的UNIAPP项目`))
|
|
20
|
+
console.log(ck.bgBlue(`文档地址:https://tmui.design.com`))
|
|
19
21
|
console.log(ck.green(`---------------------------------------------------`))
|
|
20
22
|
console.log(ck.green(`---------------------------------------------------`))
|
|
21
23
|
program
|
|
22
|
-
.
|
|
23
|
-
.option('-c
|
|
24
|
-
.option('-c
|
|
25
|
-
.option('-c
|
|
26
|
-
|
|
24
|
+
.version(require('../package').version)
|
|
25
|
+
.option('-c cli','[可选指定版本号] 创建新的cli tmui3.0 项目[推荐]')
|
|
26
|
+
.option('-c hbx','[可选指定版本号] 创建新的hbx tmui3.0 项目[不推荐]')
|
|
27
|
+
.option('-c rcli','[可选指定版本号] 已有cli项目下载/更新tmui3.0')
|
|
28
|
+
.option('-c rhbx','[可选指定版本号] 已有hbx项目下载/更新tmui3.0')
|
|
27
29
|
program.command('cli')
|
|
28
30
|
.description('创建cli uniapp tmui3.0 项目[推荐]')
|
|
29
31
|
.action(function(type, name){
|
|
@@ -44,6 +46,11 @@ chalk.then(v=>{
|
|
|
44
46
|
.action(function(type, name){
|
|
45
47
|
rhbx.run(type,name)
|
|
46
48
|
})
|
|
49
|
+
program.command('ver')
|
|
50
|
+
.description('查看tmui可用版本号')
|
|
51
|
+
.action(function(type, name){
|
|
52
|
+
viewTmuiVer.run(type,name)
|
|
53
|
+
})
|
|
47
54
|
|
|
48
55
|
program.parse();
|
|
49
56
|
|
package/package.json
CHANGED
package/src/create.js
CHANGED
|
@@ -9,6 +9,22 @@ exports.run = function(type, name) {
|
|
|
9
9
|
const ck = new v.Chalk();
|
|
10
10
|
const nowPath = path.resolve('./');
|
|
11
11
|
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
12
|
+
let userInputVer = "";
|
|
13
|
+
let args = name.parent.rawArgs.filter(el=>{
|
|
14
|
+
return el
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
if(args.includes('-c')){
|
|
18
|
+
if(args.length==5){
|
|
19
|
+
userInputVer = args.pop()||""
|
|
20
|
+
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
21
|
+
}
|
|
22
|
+
}else if(args.length==4){
|
|
23
|
+
userInputVer = args.pop()||""
|
|
24
|
+
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
12
28
|
// 检查是否有router目录?
|
|
13
29
|
// fs.existsSync(path.join(nowPath,'router','index.ts'))
|
|
14
30
|
ft.then((fah)=>{
|
|
@@ -17,6 +33,15 @@ exports.run = function(type, name) {
|
|
|
17
33
|
fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
|
|
18
34
|
let verText = await res.text();
|
|
19
35
|
let ver = verText.split('\n')[0]
|
|
36
|
+
if(userInputVer){
|
|
37
|
+
ver = userInputVer;
|
|
38
|
+
}
|
|
39
|
+
let isVer = verText.includes(ver)
|
|
40
|
+
if(!isVer){
|
|
41
|
+
console.log(ck.red('不存在版本号:'+ver))
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
20
45
|
const fileName = `cli${ver}.zip`
|
|
21
46
|
console.log(ck.green('查询到版本号如下:'))
|
|
22
47
|
console.log(verText)
|
package/src/createHbx.js
CHANGED
|
@@ -9,15 +9,35 @@ exports.run = function(type, name) {
|
|
|
9
9
|
const ck = new v.Chalk();
|
|
10
10
|
const nowPath = path.resolve('./');
|
|
11
11
|
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let userInputVer = "";
|
|
13
|
+
let args = name.parent.rawArgs.filter(el=>{
|
|
14
|
+
return el
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
if(args.includes('-c')){
|
|
18
|
+
if(args.length==5){
|
|
19
|
+
userInputVer = args.pop()||""
|
|
20
|
+
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
21
|
+
}
|
|
22
|
+
}else if(args.length==4){
|
|
23
|
+
userInputVer = args.pop()||""
|
|
24
|
+
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
25
|
+
}
|
|
26
|
+
|
|
14
27
|
ft.then((fah)=>{
|
|
15
28
|
const fetch = fah.default
|
|
16
29
|
|
|
17
30
|
fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
|
|
18
31
|
let verText = await res.text();
|
|
19
32
|
let ver = verText.split('\n')[0]
|
|
20
|
-
|
|
33
|
+
if(userInputVer){
|
|
34
|
+
ver = userInputVer;
|
|
35
|
+
}
|
|
36
|
+
let isVer = verText.includes(ver)
|
|
37
|
+
if(!isVer){
|
|
38
|
+
console.log(ck.red('不存在版本号:'+ver))
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
21
41
|
console.log(ck.green('查询到版本号如下:'))
|
|
22
42
|
console.log(verText)
|
|
23
43
|
console.log(ck.green('正在使用最新的版本号:'+ver+'进行创建项目'))
|
package/src/rcli.js
CHANGED
|
@@ -9,14 +9,34 @@ exports.run = function(type, name) {
|
|
|
9
9
|
const ck = new v.Chalk();
|
|
10
10
|
const nowPath = path.resolve('./');
|
|
11
11
|
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let userInputVer = "";
|
|
13
|
+
let args = name.parent.rawArgs.filter(el=>{
|
|
14
|
+
return el
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
if(args.includes('-c')){
|
|
18
|
+
if(args.length==5){
|
|
19
|
+
userInputVer = args.pop()||""
|
|
20
|
+
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
21
|
+
}
|
|
22
|
+
}else if(args.length==4){
|
|
23
|
+
userInputVer = args.pop()||""
|
|
24
|
+
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
25
|
+
}
|
|
14
26
|
ft.then((fah)=>{
|
|
15
27
|
const fetch = fah.default
|
|
16
28
|
|
|
17
29
|
fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
|
|
18
30
|
let verText = await res.text();
|
|
19
31
|
let ver = verText.split('\n')[0]
|
|
32
|
+
if(userInputVer){
|
|
33
|
+
ver = userInputVer;
|
|
34
|
+
}
|
|
35
|
+
let isVer = verText.includes(ver)
|
|
36
|
+
if(!isVer){
|
|
37
|
+
console.log(ck.red('不存在版本号:'+ver))
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
20
40
|
const fileName = `cli${ver}.zip`
|
|
21
41
|
console.log(ck.green('查询到版本号如下:'))
|
|
22
42
|
console.log(verText)
|
package/src/rhbx.js
CHANGED
|
@@ -9,6 +9,20 @@ exports.run = function(type, name) {
|
|
|
9
9
|
const ck = new v.Chalk();
|
|
10
10
|
const nowPath = path.resolve('./');
|
|
11
11
|
console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
|
|
12
|
+
let userInputVer = "";
|
|
13
|
+
let args = name.parent.rawArgs.filter(el=>{
|
|
14
|
+
return el
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
if(args.includes('-c')){
|
|
18
|
+
if(args.length==5){
|
|
19
|
+
userInputVer = args.pop()||""
|
|
20
|
+
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
21
|
+
}
|
|
22
|
+
}else if(args.length==4){
|
|
23
|
+
userInputVer = args.pop()||""
|
|
24
|
+
userInputVer = typeof userInputVer=='undefined'?"":userInputVer
|
|
25
|
+
}
|
|
12
26
|
|
|
13
27
|
if(fs.existsSync(path.join(nowPath,'router','index.ts'))){
|
|
14
28
|
if(!fs.existsSync(path.join(nowPath,'router'))){
|
|
@@ -39,7 +53,14 @@ exports.run = function(type, name) {
|
|
|
39
53
|
fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
|
|
40
54
|
let verText = await res.text();
|
|
41
55
|
let ver = verText.split('\n')[0]
|
|
42
|
-
|
|
56
|
+
if(userInputVer){
|
|
57
|
+
ver = userInputVer;
|
|
58
|
+
}
|
|
59
|
+
let isVer = verText.includes(ver)
|
|
60
|
+
if(!isVer){
|
|
61
|
+
console.log(ck.red('不存在版本号:'+ver))
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
43
64
|
console.log(ck.green('查询到版本号如下:'))
|
|
44
65
|
console.log(verText)
|
|
45
66
|
console.log(ck.green('正在使用最新的版本号:'+ver+'进行创建项目'))
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|