tmui-cli 1.1.9 → 1.2.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/README.md +1 -1
- package/bin/cmdTool.js +6 -6
- package/bin/createTmui.js +13 -11
- package/bin/hooks.js +14 -14
- package/bin/net.js +9 -7
- package/bin/selectedDir.js +4 -4
- package/bin/tmui.js +23 -14
- package/dist/tmui.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/cmdTool.js
CHANGED
|
@@ -24,7 +24,7 @@ function detectEncoding(str) {
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
function send(ws, arg) {
|
|
27
|
-
ws.forEach(el
|
|
27
|
+
ws.forEach(function(el){
|
|
28
28
|
el.send(arg)
|
|
29
29
|
})
|
|
30
30
|
}
|
|
@@ -51,7 +51,7 @@ function execCmd(cb, end, command) {
|
|
|
51
51
|
cb(cleanStr, spawnObj.pid || 0)
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
spawnObj.addListener('error', (err)
|
|
54
|
+
spawnObj.addListener('error', function(err) {
|
|
55
55
|
if (end) {
|
|
56
56
|
cb(err)
|
|
57
57
|
end('error')
|
|
@@ -63,7 +63,7 @@ function execCmd(cb, end, command) {
|
|
|
63
63
|
end('end')
|
|
64
64
|
}
|
|
65
65
|
})
|
|
66
|
-
spawnObj.on('exit', (code)
|
|
66
|
+
spawnObj.on('exit', function(code){
|
|
67
67
|
// console.log('exit code : ' + code);
|
|
68
68
|
if (end) {
|
|
69
69
|
end('end')
|
|
@@ -85,7 +85,7 @@ function killChildAndGrandChildren(pid) {
|
|
|
85
85
|
if (process.platform === 'win32') {
|
|
86
86
|
// 在 Windows 系统上执行的代码
|
|
87
87
|
const command = `taskkill /T /F /PID ${pid}`;
|
|
88
|
-
exec(command, (err, stdout, stderr)
|
|
88
|
+
exec(command, function(err, stdout, stderr){
|
|
89
89
|
if (err) {
|
|
90
90
|
console.error(`服务进程退出失败!不要担心,当你关闭主进程时,未退出的子进程会一并关闭哦`);
|
|
91
91
|
}
|
|
@@ -94,10 +94,10 @@ function killChildAndGrandChildren(pid) {
|
|
|
94
94
|
});
|
|
95
95
|
} else {
|
|
96
96
|
// 在 Linux/Unix/Mac 系统上执行的代码
|
|
97
|
-
psTree(pid, (err, children)
|
|
97
|
+
psTree(pid, function(err, children){
|
|
98
98
|
// 使用 kill 命令杀死所有子孙进程
|
|
99
99
|
console.log(5555)
|
|
100
|
-
exec(`kill -TERM ${pid} ${children.map(c
|
|
100
|
+
exec(`kill -TERM ${pid} ${children.map(function(c) {return c.PID}).join(' ')}`);
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
|
package/bin/createTmui.js
CHANGED
|
@@ -3,6 +3,7 @@ const path = require("path")
|
|
|
3
3
|
const {execCmd} = require("./cmdTool.js")
|
|
4
4
|
const fs = require("fs")
|
|
5
5
|
const compressing = require("compressing")
|
|
6
|
+
const Fetch = import("node-fetch")
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
const uniappDevListVer = [
|
|
@@ -75,10 +76,10 @@ function writePackageJson(filepath, str) {
|
|
|
75
76
|
/**
|
|
76
77
|
* 更新项目.
|
|
77
78
|
* @param {{path,type,uvue,tmui,uniappver}} arg
|
|
78
|
-
* @param {(str)=>{}} call
|
|
79
|
-
* @param {()=>{}} end
|
|
80
79
|
*/
|
|
81
80
|
async function UpdateTmui(arg, call, end) {
|
|
81
|
+
const fetch = (await Fetch).default;
|
|
82
|
+
|
|
82
83
|
let rootdir = path.normalize(arg.path)
|
|
83
84
|
call('检测目录...')
|
|
84
85
|
if (!fs.existsSync(rootdir)) {
|
|
@@ -170,7 +171,7 @@ async function UpdateTmui(arg, call, end) {
|
|
|
170
171
|
let initjson = readPackageJson(packjsonDir)
|
|
171
172
|
if (initjson['dependencies']['@dcloudio/uni-app'] != arg.uniappver) {
|
|
172
173
|
call(`检测到cli版本与你选中的不一样,正在设置你选中的版本号`)
|
|
173
|
-
uniappDevListVer.forEach(el
|
|
174
|
+
uniappDevListVer.forEach( function(el) {
|
|
174
175
|
if (initjson['dependencies'][el]) {
|
|
175
176
|
initjson['dependencies'][el] = arg.uniappver
|
|
176
177
|
}
|
|
@@ -182,9 +183,9 @@ async function UpdateTmui(arg, call, end) {
|
|
|
182
183
|
|
|
183
184
|
writePackageJson(packjsonDir, JSON.stringify(initjson, null, 4))
|
|
184
185
|
|
|
185
|
-
execCmd((datastr)
|
|
186
|
+
execCmd(function (datastr){
|
|
186
187
|
call(datastr)
|
|
187
|
-
}, ()
|
|
188
|
+
}, function () {
|
|
188
189
|
end()
|
|
189
190
|
}, 'npm install --save --registry=https://registry.npmmirror.com/')
|
|
190
191
|
|
|
@@ -202,10 +203,10 @@ async function UpdateTmui(arg, call, end) {
|
|
|
202
203
|
/**
|
|
203
204
|
*
|
|
204
205
|
* @param {{name,rootDir,type,ver,uniappver,uniappBuildType,machine}} arg
|
|
205
|
-
* @param {(str)=>{}} call
|
|
206
|
-
* @param {(str?:string)=>{}} end
|
|
207
206
|
*/
|
|
208
207
|
async function createTmui(arg, call, end) {
|
|
208
|
+
const fetch = (await Fetch).default;
|
|
209
|
+
|
|
209
210
|
let rootdir = path.normalize(arg.rootDir)
|
|
210
211
|
call('检测目录...')
|
|
211
212
|
if (!fs.existsSync(rootdir)) {
|
|
@@ -342,7 +343,7 @@ async function createTmui(arg, call, end) {
|
|
|
342
343
|
let initjson = readPackageJson(packjsonDir)
|
|
343
344
|
|
|
344
345
|
|
|
345
|
-
uniappDevListVer.forEach(el
|
|
346
|
+
uniappDevListVer.forEach(function (el) {
|
|
346
347
|
if (initjson['dependencies'][el]) {
|
|
347
348
|
initjson['dependencies'][el] = arg.uniappver
|
|
348
349
|
}
|
|
@@ -360,9 +361,9 @@ async function createTmui(arg, call, end) {
|
|
|
360
361
|
|
|
361
362
|
writePackageJson(packjsonDir, JSON.stringify(initjson, null, 4))
|
|
362
363
|
|
|
363
|
-
execCmd((datastr)
|
|
364
|
+
execCmd(function (datastr) {
|
|
364
365
|
call(datastr)
|
|
365
|
-
}, ()
|
|
366
|
+
}, function () {
|
|
366
367
|
end(rootdir)
|
|
367
368
|
}, 'npm install --save --registry=https://registry.npmmirror.com/')
|
|
368
369
|
|
|
@@ -377,5 +378,6 @@ async function createTmui(arg, call, end) {
|
|
|
377
378
|
|
|
378
379
|
module.exports = {
|
|
379
380
|
createTmui,
|
|
380
|
-
UpdateTmui
|
|
381
|
+
UpdateTmui,
|
|
382
|
+
delFile
|
|
381
383
|
}
|
package/bin/hooks.js
CHANGED
|
@@ -46,13 +46,13 @@ function uuid(len = 24, radix) {
|
|
|
46
46
|
return uuid.join('');
|
|
47
47
|
}
|
|
48
48
|
function removeWs(id) {
|
|
49
|
-
const index = wslist.findIndex(el
|
|
49
|
+
const index = wslist.findIndex(function(el) {return el.uuid == id})
|
|
50
50
|
if (index > -1) {
|
|
51
51
|
wslist.splice(index, 1)
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
function send(arg) {
|
|
55
|
-
wslist.forEach(el
|
|
55
|
+
wslist.forEach(function(el) {
|
|
56
56
|
el.send(arg)
|
|
57
57
|
})
|
|
58
58
|
}
|
|
@@ -101,7 +101,7 @@ wss.on('connection', async function connection(ws) {
|
|
|
101
101
|
// 查询目录项目的信息
|
|
102
102
|
} else if (obj.event == '17') {
|
|
103
103
|
let result = checkProject(obj.command)
|
|
104
|
-
let runfl = runAppInfoList.filter(el
|
|
104
|
+
let runfl = runAppInfoList.filter(function(el){ return el.id == result.id})
|
|
105
105
|
send(JSON.stringify({
|
|
106
106
|
event: '17',
|
|
107
107
|
data: result,
|
|
@@ -127,12 +127,12 @@ wss.on('connection', async function connection(ws) {
|
|
|
127
127
|
if (!obj.command) return;
|
|
128
128
|
// process.kill(Number(obj.command||0))
|
|
129
129
|
const pid = Number(obj.command || 0);
|
|
130
|
-
const index = processList.findIndex(el
|
|
130
|
+
const index = processList.findIndex(function(el){ return el.pid == pid})
|
|
131
131
|
if (index > -1) {
|
|
132
132
|
// process.kill(sflit[0].pid)
|
|
133
133
|
killChildAndGrandChildren(processList[index].pid)
|
|
134
134
|
processList.splice(index, 1)
|
|
135
|
-
const index2 = runAppInfoList.findIndex(el
|
|
135
|
+
const index2 = runAppInfoList.findIndex(function(el){ return el.pid == pid})
|
|
136
136
|
runAppInfoList.splice(index2, 1)
|
|
137
137
|
}
|
|
138
138
|
} catch (error) {
|
|
@@ -141,8 +141,8 @@ wss.on('connection', async function connection(ws) {
|
|
|
141
141
|
/**编译应用build:xx */
|
|
142
142
|
} else if (obj.event == '3') {
|
|
143
143
|
const id = obj.command.data.id;
|
|
144
|
-
const childrenProcess = buildApp(wslist, obj.command, ()
|
|
145
|
-
const index2 = runAppInfoList.findIndex(el
|
|
144
|
+
const childrenProcess = buildApp(wslist, obj.command, function() {
|
|
145
|
+
const index2 = runAppInfoList.findIndex(function(el){ return el.id == id})
|
|
146
146
|
console.log("编译结束")
|
|
147
147
|
if (index2 > -1) {
|
|
148
148
|
runAppInfoList.splice(index2, 1)
|
|
@@ -150,7 +150,7 @@ wss.on('connection', async function connection(ws) {
|
|
|
150
150
|
})
|
|
151
151
|
/**保存当前运行的用户信息。 */
|
|
152
152
|
} else if (obj.event == 'saveRunInfo') {
|
|
153
|
-
const index2 = runAppInfoList.findIndex(el
|
|
153
|
+
const index2 = runAppInfoList.findIndex(function(el){return el.id == obj.command.id})
|
|
154
154
|
if (index2 > -1) {
|
|
155
155
|
runAppInfoList.splice(index2, 1, obj.command)
|
|
156
156
|
} else {
|
|
@@ -160,7 +160,7 @@ wss.on('connection', async function connection(ws) {
|
|
|
160
160
|
} else if (obj.event == 'getCpu') {
|
|
161
161
|
|
|
162
162
|
Promise.all([osUtils.mem.info(),osUtils.cpu.usage()])
|
|
163
|
-
.then(arg
|
|
163
|
+
.then(function(arg){
|
|
164
164
|
send(JSON.stringify({
|
|
165
165
|
event: 'getCpu',
|
|
166
166
|
data: {
|
|
@@ -171,13 +171,13 @@ wss.on('connection', async function connection(ws) {
|
|
|
171
171
|
})
|
|
172
172
|
}else if(obj.event=='21'){
|
|
173
173
|
// npm view @dcloudio/uni-app versions --json
|
|
174
|
-
UpdateTmui(obj.command,(str)
|
|
174
|
+
UpdateTmui(obj.command,function(str){
|
|
175
175
|
send(JSON.stringify({
|
|
176
176
|
event: 'info',
|
|
177
177
|
flag:'',
|
|
178
178
|
data: str
|
|
179
179
|
}))
|
|
180
|
-
},()
|
|
180
|
+
},function(){
|
|
181
181
|
send(JSON.stringify({
|
|
182
182
|
event: '21',
|
|
183
183
|
flag:'end',
|
|
@@ -187,13 +187,13 @@ wss.on('connection', async function connection(ws) {
|
|
|
187
187
|
// 创建项目.
|
|
188
188
|
}else if(obj.event=='22'){
|
|
189
189
|
// npm view @dcloudio/uni-app versions --json
|
|
190
|
-
createTmui(obj.command,(str)
|
|
190
|
+
createTmui(obj.command,function(str){
|
|
191
191
|
send(JSON.stringify({
|
|
192
192
|
event: 'info',
|
|
193
193
|
flag:'',
|
|
194
194
|
data: str
|
|
195
195
|
}))
|
|
196
|
-
},(prejectdir)
|
|
196
|
+
},function(prejectdir){
|
|
197
197
|
send(JSON.stringify({
|
|
198
198
|
event: '22',
|
|
199
199
|
flag:'end',
|
|
@@ -208,7 +208,7 @@ wss.on('connection', async function connection(ws) {
|
|
|
208
208
|
console.log(chalk.red(error))
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
|
-
ws.on('close', ()
|
|
211
|
+
ws.on('close', function() {
|
|
212
212
|
removeWs(ws.uuid)
|
|
213
213
|
})
|
|
214
214
|
send('something');
|
package/bin/net.js
CHANGED
|
@@ -19,7 +19,7 @@ function setResHeader(res){
|
|
|
19
19
|
app.use(express.static('website'))
|
|
20
20
|
app.use('/store', express.static('websitemod'))
|
|
21
21
|
|
|
22
|
-
app.all("/api/dirlist",(req,res)
|
|
22
|
+
app.all("/api/dirlist",function (req,res){
|
|
23
23
|
setResHeader(res)
|
|
24
24
|
// const ls = getJsonFiles( __dirname )
|
|
25
25
|
// res.json(ls)
|
|
@@ -27,7 +27,7 @@ app.all("/api/dirlist",(req,res)=>{
|
|
|
27
27
|
res.json({'code':0})
|
|
28
28
|
})
|
|
29
29
|
//获取tmui版本
|
|
30
|
-
app.post("/api/cehckTmuiVer",async (req,res)
|
|
30
|
+
app.post("/api/cehckTmuiVer",async function (req,res){
|
|
31
31
|
const fetch = (await Fetch).default;
|
|
32
32
|
|
|
33
33
|
setResHeader(res)
|
|
@@ -40,7 +40,7 @@ app.post("/api/cehckTmuiVer",async (req,res)=>{
|
|
|
40
40
|
|
|
41
41
|
})
|
|
42
42
|
|
|
43
|
-
app.post("/api/checkUniappVer",async (req,res)
|
|
43
|
+
app.post("/api/checkUniappVer",async function (req,res){
|
|
44
44
|
const fetch = (await Fetch).default;
|
|
45
45
|
|
|
46
46
|
setResHeader(res)
|
|
@@ -65,7 +65,7 @@ app.post("/api/checkUniappVer",async (req,res)=>{
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
lis = lis.slice(0,40)
|
|
68
|
-
lis = lis.filter(el
|
|
68
|
+
lis = lis.filter(function(el){ return el[0]!='2'})
|
|
69
69
|
obj.versions = lis
|
|
70
70
|
res.json({'code':0,'data':obj})
|
|
71
71
|
|
|
@@ -75,11 +75,13 @@ app.post("/api/checkUniappVer",async (req,res)=>{
|
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
function createNet (){
|
|
79
|
+
|
|
80
80
|
|
|
81
|
-
app.listen(6170,()
|
|
81
|
+
app.listen(6170,async function (){
|
|
82
|
+
const open = (await Open).default;
|
|
82
83
|
open('http://localhost:6170')
|
|
84
|
+
|
|
83
85
|
})
|
|
84
86
|
}
|
|
85
87
|
|
package/bin/selectedDir.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const path
|
|
2
|
-
const globalDirectories
|
|
3
|
-
const {getJsonDir} = require("./dirTool.js")
|
|
1
|
+
const path = require("path")
|
|
2
|
+
const globalDirectories = require("global-dirs")
|
|
3
|
+
const { getJsonDir } = require("./dirTool.js")
|
|
4
4
|
|
|
5
5
|
/**读取项目目录 */
|
|
6
|
-
|
|
6
|
+
function selectedDir(cb, end, pathStr) {
|
|
7
7
|
try {
|
|
8
8
|
let dirpath = globalDirectories.npm.prefix
|
|
9
9
|
if (pathStr) {
|
package/bin/tmui.js
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
const figlet = require("figlet")
|
|
2
2
|
const chalks = import("chalk")
|
|
3
|
-
const {createNet} = require("./net.js")
|
|
3
|
+
const { createNet } = require("./net.js")
|
|
4
|
+
const { Command } = require('commander');
|
|
5
|
+
const program = new Command();
|
|
6
|
+
|
|
4
7
|
require("./hooks.js")
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
const chalk = (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if(err){
|
|
9
|
+
chalks.then(v => {
|
|
10
|
+
const chalk = new v.Chalk()
|
|
11
|
+
figlet('TMUI for UniApp', function (err, d) {
|
|
12
|
+
if (err) {
|
|
11
13
|
console.log(chalk.red(err))
|
|
12
14
|
console.dir(err)
|
|
13
15
|
return
|
|
14
16
|
}
|
|
15
|
-
console.log(chalk.green(
|
|
16
|
-
console.log(chalk.yellow('请注意浏览器打开状态,如果打开失败'))
|
|
17
|
-
console.log(chalk.yellow('请访问:http://localhost:6170'))
|
|
18
|
-
createNet()
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
main();
|
|
17
|
+
console.log(chalk.green('请输入tmui dev'))
|
|
23
18
|
|
|
19
|
+
program.version(require('../package.json').version)
|
|
20
|
+
|
|
21
|
+
program.command('dev')
|
|
22
|
+
.description('可视化创建TMUI UniApp项目')
|
|
23
|
+
.action(function (type, name) {
|
|
24
|
+
console.log(chalk.green(d))
|
|
25
|
+
console.log(chalk.yellow('请注意浏览器打开状态,如果打开失败'))
|
|
26
|
+
console.log(chalk.yellow('请访问:http://localhost:6170'))
|
|
27
|
+
createNet()
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
program.parse(process.argv)
|
|
31
|
+
})
|
|
32
|
+
})
|
package/dist/tmui.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var e,t,o={895:e=>{"use strict";e.exports=require("chalk")},679:e=>{"use strict";e.exports=require("figlet")}},r={};function n(e){var t=r[e];if(void 0!==t)return t.exports;var l=r[e]={exports:{}};return o[e](l,l.exports,n),l.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(o,r){if(1&r&&(o=this(o)),8&r)return o;if("object"==typeof o&&o){if(4&r&&o.__esModule)return o;if(16&r&&"function"==typeof o.then)return o}var l=Object.create(null);n.r(l);var i={};e=e||[null,t({}),t([]),t(t)];for(var c=2&r&&o;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((e=>i[e]=()=>o[e]));return i.default=()=>o,n.d(l,i),l},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};const l=n(679);Promise.resolve().then(n.t.bind(n,895,23)).then((e=>{const t=new e.Chalk;l("TMUI for UniApp",(function(e,o){if(e)return console.log(t.red(e)),void console.dir(e);console.log(t.green(o)),console.log(t.yellow("请注意浏览器打开状态,如果打开失败")),console.log(t.yellow("请访问:http://localhost:6170"))}))}))})();
|