tmui-cli 1.0.0 → 1.0.3

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 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,34 +17,46 @@ 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.green(`文档地址:https://tmui.design.com`))
19
21
  console.log(ck.green(`---------------------------------------------------`))
20
22
  console.log(ck.green(`---------------------------------------------------`))
21
23
  program
22
- .option('-c cli','创建新的cli tmui3.0 项目[推荐]')
23
- .option('-c hbx','创建新的hbx tmui3.0 项目[不推荐]')
24
- .option('-c rcli','已有cli项目下载/更新tmui3.0')
25
- .option('-c rhbx','已有hbx项目下载/更新tmui3.0')
26
-
24
+ .version(require('../package').version)
27
25
  program.command('cli')
28
- .description('创建cli uniapp tmui3.0 项目[推荐]')
26
+ .description('[可选指定版本号] 创建cli uniapp tmui3.0 项目[推荐]')
29
27
  .action(function(type, name){
30
28
  create.run(type,name)
31
29
  })
32
30
  program.command('hbx')
33
- .description('创建hbx uniapp tmui3.0 项目[不推荐]')
31
+ .description('[可选指定版本号] 创建hbx uniapp tmui3.0 项目[不推荐]')
34
32
  .action(function(type, name){
35
33
  createHbx.run(type,name)
36
34
  })
37
35
  program.command('rcli')
38
- .description('已有cli项目下载/更新tmui3.0')
36
+ .description('[可选指定版本号] 已有cli项目下载/更新tmui3.0')
39
37
  .action(function(type, name){
40
38
  rcli.run(type,name)
41
39
  })
42
40
  program.command('rhbx')
43
- .description('已有hbx项目下载/更新tmui3.0')
41
+ .description('[可选指定版本号] 已有hbx项目下载/更新tmui3.0')
44
42
  .action(function(type, name){
45
43
  rhbx.run(type,name)
46
44
  })
45
+ program.command('ver')
46
+ .description('查看tmui可用版本号')
47
+ .action(function(type, name){
48
+ viewTmuiVer.run(type,name)
49
+ })
50
+ program.command('use')
51
+ .description('如何使用本命令行?')
52
+ .action(function(type, name){
53
+ console.log(ck.green(`全局安装本命令 npm -g install tmui-cli`))
54
+ console.log(ck.green(`在你已有/空目录下创建/更新组件。`))
55
+ console.log(ck.green(`比如在空目录下创建新的cli项目可以使用如下命令:`))
56
+ console.log(ck.bgGreen(`tmui cli`))
57
+ console.log(ck.green(`创建指定cli项目的tmui 版本号`))
58
+ console.log(ck.bgGreen(`tmui cli 3.0.78`))
59
+ })
47
60
 
48
61
  program.parse();
49
62
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmui-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "tmui3.0",
5
5
  "main": "./bin/tmui.js",
6
6
  "scripts": {},
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,10 +33,19 @@ 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
- console.log(ck.green('查询到版本号如下:'))
22
- console.log(verText)
23
- console.log(ck.green('正在使用最新的版本号:'+ver+'进行创建项目'))
46
+ console.log(ck.green(`---------------------------------------------------`))
47
+ console.log(ck.green('正在使用版本号:'+ver))
48
+ console.log(ck.green(`---------------------------------------------------`))
24
49
  console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
25
50
  fetch(`https://cdn.tmui.design/public/static/cli.zip`).then(async (rf)=>{
26
51
  let d = await rf.buffer()
package/src/createHbx.js CHANGED
@@ -9,18 +9,38 @@ 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
- // 检查是否有router目录?
13
- // fs.existsSync(path.join(nowPath,'router','index.ts'))
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
-
21
- console.log(ck.green('查询到版本号如下:'))
22
- console.log(verText)
23
- console.log(ck.green('正在使用最新的版本号:'+ver+'进行创建项目'))
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
+ }
41
+ console.log(ck.green(`---------------------------------------------------`))
42
+ console.log(ck.green('正在使用版本号:'+ver))
43
+ console.log(ck.green(`---------------------------------------------------`))
24
44
  console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
25
45
  fetch(`https://cdn.tmui.design/public/static/tmuiHBX.zip`).then(async (rf)=>{
26
46
  let d = await rf.buffer()
package/src/rcli.js CHANGED
@@ -9,18 +9,38 @@ 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
- // 检查是否有router目录?
13
- // fs.existsSync(path.join(nowPath,'router','index.ts'))
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
- console.log(ck.green('查询到版本号如下:'))
22
- console.log(verText)
23
- console.log(ck.green('正在使用最新的版本号:'+ver+'进行创建项目'))
41
+ console.log(ck.green(`---------------------------------------------------`))
42
+ console.log(ck.green('正在使用版本号:'+ver))
43
+ console.log(ck.green(`---------------------------------------------------`))
24
44
  console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
25
45
  //创建tmui目录
26
46
  if( !fs.existsSync(path.join(nowPath,'src'))){
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,10 +53,17 @@ 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
-
43
- console.log(ck.green('查询到版本号如下:'))
44
- console.log(verText)
45
- console.log(ck.green('正在使用最新的版本号:'+ver+'进行创建项目'))
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
+ }
64
+ console.log(ck.green(`---------------------------------------------------`))
65
+ console.log(ck.green('正在使用版本号:'+ver))
66
+ console.log(ck.green(`---------------------------------------------------`))
46
67
  console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
47
68
  //下载tmui
48
69
  let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
@@ -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
+ }