tmui-cli 1.0.0

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/READE.md ADDED
File without changes
package/bin/tmui.js ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+
3
+ process.title = 'tmui3.0-cli';
4
+ const chalk = import("chalk")
5
+ const { Command } = require('commander');
6
+ const program = new Command();
7
+ const create = require("../src/create")
8
+ const createHbx = require("../src/createHbx")
9
+ const rhbx = require("../src/rhbx")
10
+ const rcli = require("../src/rcli")
11
+
12
+ chalk.then(v=>{
13
+ const ck = new v.Chalk();
14
+ console.log(ck.green(`---------------------------------------------------`))
15
+ console.log(ck.green(`---------------------------------------------------`))
16
+ console.log(ck.green(`tmui3.0`))
17
+ console.log(ck.green(`欢迎使用tmui3.0 cli 命令行工具`))
18
+ console.log(ck.green(`将引导你创建一个tmui3.0组件框架的UNIAPP项目`))
19
+ console.log(ck.green(`---------------------------------------------------`))
20
+ console.log(ck.green(`---------------------------------------------------`))
21
+ 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
+
27
+ program.command('cli')
28
+ .description('创建cli uniapp tmui3.0 项目[推荐]')
29
+ .action(function(type, name){
30
+ create.run(type,name)
31
+ })
32
+ program.command('hbx')
33
+ .description('创建hbx uniapp tmui3.0 项目[不推荐]')
34
+ .action(function(type, name){
35
+ createHbx.run(type,name)
36
+ })
37
+ program.command('rcli')
38
+ .description('已有cli项目下载/更新tmui3.0')
39
+ .action(function(type, name){
40
+ rcli.run(type,name)
41
+ })
42
+ program.command('rhbx')
43
+ .description('已有hbx项目下载/更新tmui3.0')
44
+ .action(function(type, name){
45
+ rhbx.run(type,name)
46
+ })
47
+
48
+ program.parse();
49
+
50
+
51
+
52
+
53
+
54
+ // cm
55
+ // .Option()
56
+ // .version(require('../package').version)
57
+ // .usage('<命令> [参数]')
58
+ // .command('create', '创建一个UNIAPP cli项目')
59
+ // .parse(process.argv)
60
+
61
+ })
62
+
63
+
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "tmui-cli",
3
+ "version": "1.0.0",
4
+ "description": "tmui3.0",
5
+ "main": "./bin/tmui.js",
6
+ "scripts": {},
7
+ "bin": {
8
+ "tmui": "./bin/tmui.js"
9
+ },
10
+ "keywords": [
11
+ "tmui",
12
+ "tm-vuetify"
13
+ ],
14
+ "author": "tmzdy tmui",
15
+ "license": "ISC",
16
+ "dependencies": {
17
+ "chalk": "^5.0.1",
18
+ "commander": "^9.4.0",
19
+ "compressing": "^1.6.2",
20
+ "node-fetch": "^3.2.10"
21
+ }
22
+ }
package/src/create.js ADDED
@@ -0,0 +1,86 @@
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
+ console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
12
+ // 检查是否有router目录?
13
+ // fs.existsSync(path.join(nowPath,'router','index.ts'))
14
+ ft.then((fah)=>{
15
+ const fetch = fah.default
16
+
17
+ fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
18
+ let verText = await res.text();
19
+ let ver = verText.split('\n')[0]
20
+ const fileName = `cli${ver}.zip`
21
+ console.log(ck.green('查询到版本号如下:'))
22
+ console.log(verText)
23
+ console.log(ck.green('正在使用最新的版本号:'+ver+'进行创建项目'))
24
+ console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
25
+ fetch(`https://cdn.tmui.design/public/static/cli.zip`).then(async (rf)=>{
26
+ let d = await rf.buffer()
27
+ fs.writeFile(path.join(nowPath,'cli.zip'),d,(err)=>{
28
+ if(err){
29
+ console.log(ck.bgRed(err))
30
+ return;
31
+ }
32
+ compressing.zip.uncompress(path.join(nowPath,'cli.zip'),path.join(nowPath))
33
+ .then(revalue=>{
34
+ //创建tmui目录
35
+ let tmuipath = path.join(nowPath,'src','tmui');
36
+ if(!fs.existsSync(tmuipath)){
37
+ fs.mkdirSync(tmuipath);
38
+ }
39
+ //下载tmui
40
+ let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
41
+ fetch(donloadTmui).then(async (tmuires)=>{
42
+ fs.writeFileSync(path.join(nowPath,'tmui.zip'),await tmuires.buffer())
43
+ compressing.zip.uncompress(path.join(nowPath,'tmui.zip'),tmuipath)
44
+ .then(comtmui=>{
45
+ console.log(ck.bgGreen('非常nice,安装成功,正在清理'))
46
+
47
+ if(fs.existsSync(path.join(nowPath,'tmui.zip'))){
48
+ fs.unlinkSync(path.join(nowPath,'tmui.zip'))
49
+ }
50
+ if(fs.existsSync(path.join(nowPath,'cli.zip'))){
51
+ fs.unlinkSync(path.join(nowPath,'cli.zip'))
52
+ }
53
+ console.log(ck.bgGreen('清理成功,正在安装依赖时间稍长~'))
54
+ chilPro.exec('npm install',error=>{
55
+ if(error){
56
+ console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
57
+ console.log(ck.green('npm install'))
58
+ return
59
+ }
60
+ console.log(ck.bgGreen('安装成功'))
61
+ console.log(ck.green(`---------------------------------------------------`))
62
+ console.log(ck.green(`---------------------------------------------------`))
63
+ console.log(ck.green('请执行uni cli命令,编译一个H5项目试:'))
64
+ console.log(ck.green('npm run dev:h5'))
65
+ console.log(ck.green('在本窗口输入上述命令,按回车键编译。'))
66
+ })
67
+ }).catch(err=>{
68
+ console.log(ck.bgRed(err))
69
+ })
70
+ })
71
+ .catch(e=>{
72
+ console.log(ck.bgRed(e))
73
+ })
74
+
75
+ }).catch(errs=>{
76
+ console.log(ck.bgRed(errs))
77
+ })
78
+ })
79
+ }).catch(e=>{
80
+ console.log(ck.bgRed(e))
81
+ })
82
+ })
83
+ })
84
+ // fetch()tmuiVer.txt
85
+ })
86
+ }
@@ -0,0 +1,82 @@
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
+ console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
12
+ // 检查是否有router目录?
13
+ // fs.existsSync(path.join(nowPath,'router','index.ts'))
14
+ ft.then((fah)=>{
15
+ const fetch = fah.default
16
+
17
+ fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
18
+ let verText = await res.text();
19
+ let ver = verText.split('\n')[0]
20
+
21
+ console.log(ck.green('查询到版本号如下:'))
22
+ console.log(verText)
23
+ console.log(ck.green('正在使用最新的版本号:'+ver+'进行创建项目'))
24
+ console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
25
+ fetch(`https://cdn.tmui.design/public/static/tmuiHBX.zip`).then(async (rf)=>{
26
+ let d = await rf.buffer()
27
+ fs.writeFile(path.join(nowPath,'tmuiHBX.zip'),d,(err)=>{
28
+ if(err){
29
+ console.log(ck.bgRed(err))
30
+ return;
31
+ }
32
+ compressing.zip.uncompress(path.join(nowPath,'tmuiHBX.zip'),path.join(nowPath))
33
+ .then(revalue=>{
34
+ //创建tmui目录
35
+ let tmuipath = path.join(nowPath,'tmui');
36
+ if(!fs.existsSync(tmuipath)){
37
+ fs.mkdirSync(tmuipath);
38
+ }
39
+ //下载tmui
40
+ let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
41
+ fetch(donloadTmui).then(async (tmuires)=>{
42
+ fs.writeFileSync(path.join(nowPath,'tmui.zip'),await tmuires.buffer())
43
+ compressing.zip.uncompress(path.join(nowPath,'tmui.zip'),tmuipath)
44
+ .then(comtmui=>{
45
+ console.log(ck.bgGreen('非常nice,安装成功,正在清理'))
46
+ if(fs.existsSync(path.join(nowPath,'tmui.zip'))){
47
+ fs.unlinkSync(path.join(nowPath,'tmui.zip'))
48
+ }
49
+ if(fs.existsSync(path.join(nowPath,'tmuiHBX.zip'))){
50
+ fs.unlinkSync(path.join(nowPath,'tmuiHBX.zip'))
51
+ }
52
+ console.log(ck.bgGreen('清理成功,正在安装依赖时间稍长~'))
53
+ chilPro.exec('npm install echarts --save',error=>{
54
+ if(error){
55
+ console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
56
+ console.log(ck.green('npm install'))
57
+ return
58
+ }
59
+ console.log(ck.green(`---------------------------------------------------`))
60
+ console.log(ck.red(`截止3.5.4 hbx版本号,运行到浏览器会报错,其它平台没问题。这是uni的bug。但cli模式不会有问题。`))
61
+ console.log(ck.bgGreen('安装成功,请使用hbx导入项目,运行本项目。'))
62
+ })
63
+ }).catch(err=>{
64
+ console.log(ck.bgRed(err))
65
+ })
66
+ })
67
+ .catch(e=>{
68
+ console.log(ck.bgRed(e))
69
+ })
70
+
71
+ }).catch(errs=>{
72
+ console.log(ck.bgRed(errs))
73
+ })
74
+ })
75
+ }).catch(e=>{
76
+ console.log(ck.bgRed(e))
77
+ })
78
+ })
79
+ })
80
+ // fetch()tmuiVer.txt
81
+ })
82
+ }
package/src/rcli.js ADDED
@@ -0,0 +1,73 @@
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
+ console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
12
+ // 检查是否有router目录?
13
+ // fs.existsSync(path.join(nowPath,'router','index.ts'))
14
+ ft.then((fah)=>{
15
+ const fetch = fah.default
16
+
17
+ fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
18
+ let verText = await res.text();
19
+ let ver = verText.split('\n')[0]
20
+ const fileName = `cli${ver}.zip`
21
+ console.log(ck.green('查询到版本号如下:'))
22
+ console.log(verText)
23
+ console.log(ck.green('正在使用最新的版本号:'+ver+'进行创建项目'))
24
+ console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
25
+ //创建tmui目录
26
+ if( !fs.existsSync(path.join(nowPath,'src'))){
27
+ console.log(ck.bgRed('非cli项目,请使用rhbx项目'))
28
+ return
29
+ }
30
+ let tmuipath = path.join(nowPath,'src','tmui');
31
+ if(!fs.existsSync(tmuipath)){
32
+ fs.mkdirSync(tmuipath);
33
+ }
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
+ console.log(ck.bgGreen('非常nice,安装成功,正在清理'))
41
+
42
+ if(fs.existsSync(path.join(nowPath,'tmui.zip'))){
43
+ fs.unlinkSync(path.join(nowPath,'tmui.zip'))
44
+ }
45
+ if(fs.existsSync(path.join(nowPath,'cli.zip'))){
46
+ fs.unlinkSync(path.join(nowPath,'cli.zip'))
47
+ }
48
+ console.log(ck.bgGreen('清理成功,正在安装依赖时间稍长~'))
49
+ chilPro.exec('npm install',error=>{
50
+ if(error){
51
+ console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
52
+ console.log(ck.green('npm install'))
53
+ return
54
+ }
55
+ console.log(ck.bgGreen('安装成功'))
56
+ console.log(ck.green(`---------------------------------------------------`))
57
+ console.log(ck.green(`---------------------------------------------------`))
58
+ console.log(ck.green('请执行uni cli命令,编译一个H5项目试:'))
59
+ console.log(ck.green('npm run dev:h5'))
60
+ console.log(ck.green('在本窗口输入上述命令,按回车键编译。'))
61
+ })
62
+ }).catch(err=>{
63
+ console.log(ck.bgRed(err))
64
+ })
65
+ })
66
+ .catch(e=>{
67
+ console.log(ck.bgRed(e))
68
+ })
69
+ })
70
+ })
71
+ // fetch()tmuiVer.txt
72
+ })
73
+ }
package/src/rhbx.js ADDED
@@ -0,0 +1,86 @@
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
+ console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
12
+
13
+ if(fs.existsSync(path.join(nowPath,'router','index.ts'))){
14
+ if(!fs.existsSync(path.join(nowPath,'router'))){
15
+ fs.mkdirSync(path.join(nowPath,'router'));
16
+ }
17
+ let txt = require('./router').txt;
18
+ fs.writeFileSync(path.join(nowPath,'router','index.ts'),txt)
19
+ }
20
+ if(fs.existsSync(path.join(nowPath,'theme','index.ts'))){
21
+ if(!fs.existsSync(path.join(nowPath,'theme'))){
22
+ fs.mkdirSync(path.join(nowPath,'theme'));
23
+ }
24
+ let txt = require('./router').txt;
25
+ fs.writeFileSync(path.join(nowPath,'theme','index.ts'),txt)
26
+ }
27
+
28
+
29
+ // 检查是否有router目录?
30
+ // fs.existsSync(path.join(nowPath,'router','index.ts'))
31
+ ft.then((fah)=>{
32
+ const fetch = fah.default
33
+ //创建tmui目录
34
+ let tmuipath = path.join(nowPath,'tmui');
35
+ if(!fs.existsSync(tmuipath)){
36
+ fs.mkdirSync(tmuipath);
37
+ }
38
+
39
+ fetch('https://cdn.tmui.design/tmuiVer.txt').then(async (res)=>{
40
+ let verText = await res.text();
41
+ let ver = verText.split('\n')[0]
42
+
43
+ console.log(ck.green('查询到版本号如下:'))
44
+ console.log(verText)
45
+ console.log(ck.green('正在使用最新的版本号:'+ver+'进行创建项目'))
46
+ console.log(ck.bgBlue('不 要 关闭窗体,正在创建中....'))
47
+ //下载tmui
48
+ let donloadTmui = `https://cdn.tmui.design/public/static/tmui${ver}.zip`
49
+ fetch(donloadTmui).then(async (tmuires)=>{
50
+ fs.writeFileSync(path.join(nowPath,'tmui.zip'),await tmuires.buffer())
51
+ compressing.zip.uncompress(path.join(nowPath,'tmui.zip'),tmuipath)
52
+ .then(comtmui=>{
53
+ console.log(ck.bgGreen('非常nice,安装成功,正在清理'))
54
+
55
+ if(fs.existsSync(path.join(nowPath,'tmui.zip'))){
56
+ fs.unlinkSync(path.join(nowPath,'tmui.zip'))
57
+ }
58
+ if(fs.existsSync(path.join(nowPath,'tmuiHBX.zip'))){
59
+ fs.unlinkSync(path.join(nowPath,'tmuiHBX.zip'))
60
+ }
61
+
62
+ console.log(ck.bgGreen('清理成功,正在安装依赖时间稍长~'))
63
+ chilPro.exec('npm install echarts --save',error=>{
64
+ if(error){
65
+ console.log('安装失败,请在当前目录手动安装依赖文件执行:',ck.bgRed(error))
66
+ console.log(ck.green('npm install'))
67
+ return
68
+ }
69
+ console.log(ck.green(`---------------------------------------------------`))
70
+ console.log(ck.red(`截止3.5.4 hbx版本号,运行到浏览器会报错,其它平台没问题。这是uni的bug。但cli模式不会有问题。`))
71
+ console.log(ck.bgGreen('安装成功,请使用hbx导入项目,运行本项目。'))
72
+ })
73
+ }).catch(err=>{
74
+ console.log(ck.bgRed(err))
75
+ })
76
+ })
77
+ .catch(e=>{
78
+ console.log(ck.bgRed(e))
79
+ })
80
+ })
81
+
82
+
83
+ })
84
+ // fetch()tmuiVer.txt
85
+ })
86
+ }
package/src/router.js ADDED
@@ -0,0 +1,28 @@
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 ADDED
@@ -0,0 +1,8 @@
1
+ exports.txt=`
2
+ export const theme = {
3
+ // 这里输入你定义的主题主色
4
+ //比如:"primary": "#FF0000"
5
+ //名称如果与自带主题相同,将会覆盖。
6
+
7
+ }
8
+ `