tmui-cli 1.2.9 → 2.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/package.json CHANGED
@@ -1,50 +1,48 @@
1
- {
2
- "name": "tmui-cli",
3
- "version": "1.2.9",
4
- "description": "tmui2.0,3.0,4.0x,3.2",
5
- "main": "./bin/tmui.js",
6
- "scripts": {
7
- "dev": "node ./bin/tmui.js",
8
- "test": "node ./dist/tmui.js",
9
- "build": "webpack --mode production"
10
- },
11
- "keywords": [
12
- "tmui"
13
- ],
14
- "author": {
15
- "name": "tmzdy"
16
- },
17
- "bin": {
18
- "tmui": "bin/tmui.js"
19
- },
20
- "license": "MIT",
21
- "dependencies": {
22
- "@babel/runtime": "^7.25.7",
23
- "babel-polyfill": "^6.26.0",
24
- "body-parser": "^1.20.3",
25
- "bufferhelper": "^0.2.1",
26
- "chalk": "^5.3.0",
27
- "codecs": "^3.1.0",
28
- "compressing": "^1.10.1",
29
- "express": "^4.21.1",
30
- "figlet": "^1.8.0",
31
- "global-dirs": "^4.0.0",
32
- "inquirer": "^12.0.0",
33
- "node-fetch": "^3.3.2",
34
- "node-os-utils": "^1.3.7",
35
- "open": "^10.1.0",
36
- "ps-tree": "^1.2.0",
37
- "ws": "^8.18.0"
38
- },
39
- "devDependencies": {
40
- "@babel/core": "^7.25.8",
41
- "@babel/plugin-transform-modules-commonjs": "^7.25.7",
42
- "@babel/plugin-transform-runtime": "^7.25.7",
43
- "@babel/preset-env": "^7.25.8",
44
- "babel-core": "^6.26.3",
45
- "babel-loader": "^9.2.1",
46
- "webpack": "^5.95.0",
47
- "webpack-cli": "^5.1.4",
48
- "webpack-node-externals": "^3.0.0"
49
- }
50
- }
1
+ {
2
+ "name": "tmui-cli",
3
+ "version": "2.0.0",
4
+ "description": "TMUI DESIGN 终端 CLI:创建与升级 uniapp CLI / HBX 项目",
5
+ "type": "module",
6
+ "main": "./dist/main.mjs",
7
+ "bin": {
8
+ "tmui": "dist/main.mjs"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "dev": "vite",
15
+ "check:type": "vue-tsc --build",
16
+ "build": "vite build && node ./scripts/add-shebang.mjs",
17
+ "preview": "npm run build && node dist/main.mjs",
18
+ "prepublishOnly": "npm run build"
19
+ },
20
+ "keywords": [
21
+ "tmui",
22
+ "uniapp",
23
+ "cli"
24
+ ],
25
+ "author": {
26
+ "name": "tmzdy"
27
+ },
28
+ "license": "MIT",
29
+ "engines": {
30
+ "node": ">=22.18.0"
31
+ },
32
+ "dependencies": {
33
+ "@vue-tui/components": "^0.3.0",
34
+ "@vue-tui/runtime": "0.3.0",
35
+ "compressing": "^1.10.1",
36
+ "vue": "^3.5.0"
37
+ },
38
+ "devDependencies": {
39
+ "@tsconfig/node22": "^22.0.5",
40
+ "@types/node": "^22.18.0",
41
+ "@vue-tui/vite": "0.3.1",
42
+ "@vue/tsconfig": "^0.9.1",
43
+ "typescript": "~5.9.0",
44
+ "unplugin-vue": "7.2.0",
45
+ "vite": "8.2.1",
46
+ "vue-tsc": "3.3.4"
47
+ }
48
+ }
package/bin/cmdTool.js DELETED
@@ -1,229 +0,0 @@
1
-
2
- const path = require("path")
3
- const fs = require("fs")
4
- const {spawn,exec} = require("child_process")
5
- const process = require("process")
6
- const codecs = require("codecs")
7
- const psTree = require("ps-tree")
8
-
9
-
10
-
11
-
12
- function detectEncoding(str) {
13
- const buffer = Buffer.from(str);
14
- if (buffer[0] < 128) {
15
- return 'ascii';
16
- } else if (buffer[0] < 224) {
17
- return 'utf8';
18
- } else if (buffer[0] < 240) {
19
- return 'utf16le';
20
- } else {
21
- return 'utf32le';
22
- }
23
- }
24
-
25
-
26
- function send(ws, arg) {
27
- ws.forEach(function(el){
28
- el.send(arg)
29
- })
30
- }
31
-
32
- function execCmd(cb, end, command) {
33
- try {
34
- // const npmPath = path.join(process.env.APPDATA, 'npm', 'npm.cmd');
35
- const spawnObj = exec(command, {
36
- encoding: 'binary'
37
- })
38
- // const spawnObj = spawn("npm.cmd",["run","dev:h5"],{detached:true})
39
-
40
- spawnObj.stdout?.on('data', function(chunk) {
41
- // Buffer.from(chunk,'binary').toString('utf-8')
42
- // var str = iconv.decode(, 'cp936');
43
- if (cb) {
44
- let str = Buffer.from(chunk, 'binary').toString("utf8")
45
-
46
- var codecsDecode = codecs(detectEncoding(chunk))
47
- let strii = codecsDecode.decode(Buffer.from(chunk, 'binary')).toString('utf-8');
48
- // 去除控制符
49
- const cleanStr = strii.replace(
50
- /[\u001B\u009B][[\]()#;?]*(?:(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[A-PR-Za-z~])/g, '');
51
- cb(cleanStr, spawnObj.pid || 0)
52
- }
53
- });
54
- spawnObj.addListener('error', function(err) {
55
- if (end) {
56
- cb(err)
57
- end('error')
58
- }
59
- })
60
- spawnObj.on('close', function(code) {
61
- // console.log('close code : ' + code);
62
- if (end) {
63
- end('end')
64
- }
65
- })
66
- spawnObj.on('exit', function(code){
67
- // console.log('exit code : ' + code);
68
- if (end) {
69
- end('end')
70
- }
71
- });
72
-
73
- return spawnObj;
74
- } catch (error) {
75
- if (end) {
76
- cb(error)
77
- end('end')
78
- }
79
- return null;
80
- }
81
- }
82
- // 杀死子进程及其所有子孙进程
83
- function killChildAndGrandChildren(pid) {
84
-
85
- if (process.platform === 'win32') {
86
- // 在 Windows 系统上执行的代码
87
- const command = `taskkill /T /F /PID ${pid}`;
88
- exec(command, function(err, stdout, stderr){
89
- if (err) {
90
- console.error(`服务进程退出失败!不要担心,当你关闭主进程时,未退出的子进程会一并关闭哦`);
91
- }
92
- // console.log(`stdout: ${stdout}`);
93
- // console.error(`stderr: ${stderr}`);
94
- });
95
- } else {
96
- // 在 Linux/Unix/Mac 系统上执行的代码
97
- psTree(pid, function(err, children){
98
- // 使用 kill 命令杀死所有子孙进程
99
- console.log(5555)
100
- exec(`kill -TERM ${pid} ${children.map(function(c) {return c.PID}).join(' ')}`);
101
- });
102
- }
103
-
104
- }
105
-
106
- function devRunApp(ws, obj) {
107
-
108
- const nowcd = process.cwd();
109
- process.chdir(path.normalize(obj.data.path));
110
-
111
- const childreProcess = execCmd(function(msg, pid) {
112
- send(ws, JSON.stringify({
113
- event: 'info',
114
- data: msg
115
- }))
116
- const reg_1 = /http:\/\/localhost(:\d+)?(\/[^\s]*)?/g;
117
- const reg_2 = /http:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d+)?(\/[^\s]*)?/g;
118
-
119
-
120
- if (reg_1.test(msg)) {
121
- send(ws, JSON.stringify({
122
- event: '1',
123
- data: {
124
- id: obj.data.id,
125
- msg: msg.match(reg_1)[0],
126
- pid: pid
127
- }
128
- }))
129
- }
130
- if (reg_2.test(msg)) {
131
- send(ws, JSON.stringify({
132
- event: '1',
133
- data: {
134
- id: obj.data.id,
135
- msg: msg.match(reg_2)[0],
136
- pid: pid
137
- }
138
- }))
139
- }
140
- if (msg.indexOf('ready') > -1) {
141
- send(ws, JSON.stringify({
142
- event: 'ready',
143
- data: {
144
- id: obj.data.id,
145
- pid: pid
146
- },
147
- }))
148
- }
149
- }, function(type) {
150
-
151
-
152
- if (type == 'end') {
153
- send(ws, JSON.stringify({
154
- event: 'end',
155
- data: {
156
- id: obj.data.id
157
- },
158
- }))
159
- } else {
160
- send(ws, JSON.stringify({
161
- event: 'error',
162
- data: {
163
- id: obj.data.id
164
- },
165
- }))
166
-
167
- }
168
-
169
- }, obj.command)
170
-
171
- return childreProcess;
172
- }
173
-
174
- function buildApp(ws, obj, end) {
175
-
176
- const nowcd = process.cwd();
177
- process.chdir(path.normalize(obj.data.path));
178
-
179
- const childreProcess = execCmd(function(msg, pid) {
180
- send(ws, JSON.stringify({
181
- event: 'info',
182
- data: msg
183
- }))
184
- if (msg.indexOf('DONE') > -1) {
185
- send(ws, JSON.stringify({
186
- event: 'buildSucess',
187
- data: {
188
- id: obj.data.id,
189
- pid: pid
190
- },
191
- }))
192
- }
193
- }, function(type) {
194
-
195
-
196
- if (type == 'end') {
197
- send(ws, JSON.stringify({
198
- event: 'end',
199
- data: {
200
- id: obj.data.id
201
- },
202
- }))
203
-
204
- console.log('编译完成')
205
- } else {
206
- send(ws, JSON.stringify({
207
- event: 'error',
208
- data: {
209
- id: obj.data.id
210
- },
211
- }))
212
- }
213
- if (end) {
214
- end()
215
- }
216
-
217
- }, obj.command)
218
-
219
- return childreProcess;
220
- }
221
-
222
- module.exports = {
223
- execCmd,
224
- killChildAndGrandChildren,
225
- devRunApp,
226
- buildApp
227
- }
228
-
229
-