tmui-cli 1.0.3 → 1.0.4

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
@@ -1,76 +1,133 @@
1
- #!/usr/bin/env node
2
-
3
- process.title = 'tmui3.0-cli';
1
+ #!/usr/bin/env node
2
+
3
+ process.title = 'tmui3.0-cli';
4
4
  const chalk = import("chalk")
5
- const { Command } = require('commander');
5
+ const { Command } = require('commander');
6
6
  const program = new Command();
7
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
11
  const viewTmuiVer = require("../src/viewTmuiVer")
12
-
12
+ const tm2 = require("../src/tmui2")
13
+ const inquirer = import('inquirer');
14
+ const ft = import("node-fetch")
13
15
  chalk.then(v=>{
14
16
  const ck = new v.Chalk();
15
- console.log(ck.green(`---------------------------------------------------`))
16
- console.log(ck.green(`---------------------------------------------------`))
17
- console.log(ck.green(`tmui3.0`))
18
- console.log(ck.green(`欢迎使用tmui3.0 cli 命令行工具`))
19
- console.log(ck.green(`将引导你创建一个tmui3.0组件框架的UNIAPP项目`))
20
- console.log(ck.green(`文档地址:https://tmui.design.com`))
21
- console.log(ck.green(`---------------------------------------------------`))
22
- console.log(ck.green(`---------------------------------------------------`))
23
- program
24
- .version(require('../package').version)
25
- program.command('cli')
26
- .description('[可选指定版本号] 创建cli uniapp tmui3.0 项目[推荐]')
27
- .action(function(type, name){
28
- create.run(type,name)
29
- })
30
- program.command('hbx')
31
- .description('[可选指定版本号] 创建hbx uniapp tmui3.0 项目[不推荐]')
32
- .action(function(type, name){
33
- createHbx.run(type,name)
34
- })
35
- program.command('rcli')
36
- .description('[可选指定版本号] 已有cli项目下载/更新tmui3.0')
37
- .action(function(type, name){
38
- rcli.run(type,name)
39
- })
40
- program.command('rhbx')
41
- .description('[可选指定版本号] 已有hbx项目下载/更新tmui3.0')
42
- .action(function(type, name){
43
- rhbx.run(type,name)
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
- })
60
-
61
- program.parse();
62
-
17
+ console.log(ck.white(`---------------------------------------------------`))
18
+ console.log(ck.white(`---------------------------------------------------`))
19
+ console.log(ck.white(`tmui3.0`))
20
+ console.log(ck.white(`欢迎使用tmui3.0 cli 命令行工具`))
21
+ console.log(ck.white(`将引导你创建一个tmui3.0组件框架的UNIAPP项目`))
22
+ console.log(ck.green(`文档地址:https://tmui.design`))
23
+ console.log(ck.white(`---------------------------------------------------`))
24
+ console.log(ck.white(`---------------------------------------------------`))
25
+ inquirer.then(ivk=>{
26
+ program
27
+ .version(require('../package').version)
28
+ program.command('cli')
29
+ .description('[可选指定版本号] 创建cli uniapp tmui3.0 项目[推荐]')
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'){
63
74
 
64
-
65
-
66
-
67
- // cm
68
- // .Option()
69
- // .version(require('../package').version)
70
- // .usage('<命令> [参数]')
71
- // .command('create', '创建一个UNIAPP cli项目')
72
- // .parse(process.argv)
75
+ ft.then((fah)=>{
76
+ const fetch = fah.default
77
+ fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
78
+ let verText = await res.text();
79
+ let lastVer = verText.split('\n').slice(0,10)
80
+ prompt([
81
+ {
82
+ type: 'list',
83
+ name: 'moshi',
84
+ message: '选择安装方式:',
85
+ choices: [
86
+ 'cli',
87
+ 'rcli',
88
+ 'hbx',
89
+ 'rhbx',
90
+ ],
91
+ },
92
+ {
93
+ type: 'list',
94
+ name: 'ver',
95
+ message: '选择最近的版本号',
96
+ choices: lastVer,
97
+ },
98
+
99
+ ])
100
+ .then((answers) => {
101
+ let ms = answers.moshi;
102
+ let ver = answers.ver.trim()
103
+ if(!ver||typeof ver=="undefined"){
104
+ console.log(ck.red("请正确输入版本号"))
105
+ return;
106
+ }
107
+ if(ms=="cli"){
108
+ create.run(null,null,ver)
109
+ }else if(ms=="rcli"){
110
+ rcli.run(null,null,ver)
111
+ }else if(ms=="hbx"){
112
+ createHbx.run(null,null,ver)
113
+ }else if(ms=="rhbx"){
114
+ rhbx.run(null,null,ver)
115
+ }
116
+ })
117
+ })
118
+
119
+ })
120
+
121
+ }
122
+ });
123
+
124
+
125
+ })
126
+ program.parse();
127
+
128
+ })
129
+
73
130
 
74
131
  })
75
132
 
76
-
133
+
package/package.json CHANGED
@@ -1,22 +1,50 @@
1
1
  {
2
- "name": "tmui-cli",
3
- "version": "1.0.3",
4
- "description": "tmui3.0",
5
- "main": "./bin/tmui.js",
6
- "scripts": {},
7
- "bin": {
8
- "tmui": "./bin/tmui.js"
2
+ "_from": "tmui-cli",
3
+ "_id": "tmui-cli@1.0.3",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-mnddgPs3eUjTuxQGv6hxlc0b98d53YXtjd0tvrlzWvrAnf0IS0qQMo4bZHi+ImwOEYqbNLX9jhd9pq1cVb9tjw==",
6
+ "_location": "/tmui-cli",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "tag",
10
+ "registry": true,
11
+ "raw": "tmui-cli",
12
+ "name": "tmui-cli",
13
+ "escapedName": "tmui-cli",
14
+ "rawSpec": "",
15
+ "saveSpec": null,
16
+ "fetchSpec": "latest"
9
17
  },
10
- "keywords": [
11
- "tmui",
12
- "tm-vuetify"
18
+ "_requiredBy": [
19
+ "#USER"
13
20
  ],
14
- "author": "tmzdy tmui",
15
- "license": "ISC",
21
+ "_resolved": "https://registry.npmjs.org/tmui-cli/-/tmui-cli-1.0.3.tgz",
22
+ "_shasum": "162803da7d6cc696e3f4a908b223a15f0b33d245",
23
+ "_spec": "tmui-cli",
24
+ "_where": "C:\\Users\\zsylp",
25
+ "author": {
26
+ "name": "tmzdy tmui"
27
+ },
28
+ "bin": {
29
+ "tmui": "bin/tmui.js"
30
+ },
31
+ "bundleDependencies": false,
16
32
  "dependencies": {
17
33
  "chalk": "^5.0.1",
18
34
  "commander": "^9.4.0",
19
35
  "compressing": "^1.6.2",
36
+ "inquirer": "^9.1.0",
20
37
  "node-fetch": "^3.2.10"
21
- }
38
+ },
39
+ "deprecated": false,
40
+ "description": "tmui3.0",
41
+ "keywords": [
42
+ "tmui",
43
+ "tm-vuetify"
44
+ ],
45
+ "license": "ISC",
46
+ "main": "./bin/tmui.js",
47
+ "name": "tmui-cli",
48
+ "scripts": {},
49
+ "version": "1.0.4"
22
50
  }
package/src/create.js CHANGED
@@ -4,32 +4,34 @@ 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
- exports.run = function(type, name) {
7
+
8
+ exports.run = function(type, name,vr) {
8
9
  chalk.then(v=>{
9
10
  const ck = new v.Chalk();
10
11
  const nowPath = path.resolve('./');
11
12
  console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
12
13
  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){
14
+ if(vr!=null){
15
+ userInputVer = vr;
16
+ }else{
17
+ let args = name.parent.rawArgs.filter(el=>{
18
+ return el
19
+ })
20
+ if(args.includes('-c')){
21
+ if(args.length==5){
22
+ userInputVer = args.pop()||""
23
+ userInputVer = typeof userInputVer=='undefined'?"":userInputVer
24
+ }
25
+ }else if(args.length==4){
19
26
  userInputVer = args.pop()||""
20
27
  userInputVer = typeof userInputVer=='undefined'?"":userInputVer
21
28
  }
22
- }else if(args.length==4){
23
- userInputVer = args.pop()||""
24
- userInputVer = typeof userInputVer=='undefined'?"":userInputVer
25
29
  }
26
30
 
27
-
28
31
  // 检查是否有router目录?
29
32
  // fs.existsSync(path.join(nowPath,'router','index.ts'))
30
33
  ft.then((fah)=>{
31
34
  const fetch = fah.default
32
-
33
35
  fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
34
36
  let verText = await res.text();
35
37
  let ver = verText.split('\n')[0]
@@ -76,7 +78,9 @@ exports.run = function(type, name) {
76
78
  fs.unlinkSync(path.join(nowPath,'cli.zip'))
77
79
  }
78
80
  console.log(ck.bgGreen('清理成功,正在安装依赖时间稍长~'))
79
- chilPro.exec('npm install',error=>{
81
+
82
+ const installNpm = chilPro.exec('npm install',(error, stdout, stderr)=>{
83
+
80
84
  if(error){
81
85
  console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
82
86
  console.log(ck.green('npm install'))
@@ -89,6 +93,11 @@ exports.run = function(type, name) {
89
93
  console.log(ck.green('npm run dev:h5'))
90
94
  console.log(ck.green('在本窗口输入上述命令,按回车键编译。'))
91
95
  })
96
+
97
+ installNpm.stdout?.on("data",(msg)=>{
98
+ console.log(msg.toString('utf8'))
99
+ })
100
+
92
101
  }).catch(err=>{
93
102
  console.log(ck.bgRed(err))
94
103
  })
package/src/createHbx.js CHANGED
@@ -4,24 +4,27 @@ 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
- exports.run = function(type, name) {
7
+ exports.run = function(type, name,vr) {
8
8
  chalk.then(v=>{
9
9
  const ck = new v.Chalk();
10
10
  const nowPath = path.resolve('./');
11
11
  console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
12
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){
13
+ if(vr!=null){
14
+ userInputVer = vr;
15
+ }else{
16
+ let args = name.parent.rawArgs.filter(el=>{
17
+ return el
18
+ })
19
+ if(args.includes('-c')){
20
+ if(args.length==5){
21
+ userInputVer = args.pop()||""
22
+ userInputVer = typeof userInputVer=='undefined'?"":userInputVer
23
+ }
24
+ }else if(args.length==4){
19
25
  userInputVer = args.pop()||""
20
26
  userInputVer = typeof userInputVer=='undefined'?"":userInputVer
21
27
  }
22
- }else if(args.length==4){
23
- userInputVer = args.pop()||""
24
- userInputVer = typeof userInputVer=='undefined'?"":userInputVer
25
28
  }
26
29
 
27
30
  ft.then((fah)=>{
package/src/rcli.js CHANGED
@@ -4,24 +4,27 @@ 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
- exports.run = function(type, name) {
7
+ exports.run = function(type, name,vr) {
8
8
  chalk.then(v=>{
9
9
  const ck = new v.Chalk();
10
10
  const nowPath = path.resolve('./');
11
11
  console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
12
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){
13
+ if(vr!=null){
14
+ userInputVer = vr;
15
+ }else{
16
+ let args = name.parent.rawArgs.filter(el=>{
17
+ return el
18
+ })
19
+ if(args.includes('-c')){
20
+ if(args.length==5){
21
+ userInputVer = args.pop()||""
22
+ userInputVer = typeof userInputVer=='undefined'?"":userInputVer
23
+ }
24
+ }else if(args.length==4){
19
25
  userInputVer = args.pop()||""
20
26
  userInputVer = typeof userInputVer=='undefined'?"":userInputVer
21
27
  }
22
- }else if(args.length==4){
23
- userInputVer = args.pop()||""
24
- userInputVer = typeof userInputVer=='undefined'?"":userInputVer
25
28
  }
26
29
  ft.then((fah)=>{
27
30
  const fetch = fah.default
package/src/rhbx.js CHANGED
@@ -4,24 +4,27 @@ 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
- exports.run = function(type, name) {
7
+ exports.run = function(type, name,vr) {
8
8
  chalk.then(v=>{
9
9
  const ck = new v.Chalk();
10
10
  const nowPath = path.resolve('./');
11
11
  console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
12
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){
13
+ if(vr!=null){
14
+ userInputVer = vr;
15
+ }else{
16
+ let args = name.parent.rawArgs.filter(el=>{
17
+ return el
18
+ })
19
+ if(args.includes('-c')){
20
+ if(args.length==5){
21
+ userInputVer = args.pop()||""
22
+ userInputVer = typeof userInputVer=='undefined'?"":userInputVer
23
+ }
24
+ }else if(args.length==4){
19
25
  userInputVer = args.pop()||""
20
26
  userInputVer = typeof userInputVer=='undefined'?"":userInputVer
21
27
  }
22
- }else if(args.length==4){
23
- userInputVer = args.pop()||""
24
- userInputVer = typeof userInputVer=='undefined'?"":userInputVer
25
28
  }
26
29
 
27
30
  if(fs.existsSync(path.join(nowPath,'router','index.ts'))){
package/src/tmui2.js ADDED
@@ -0,0 +1,60 @@
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
+ }