tmui-cli 1.2.3 → 1.2.5
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/cmdTool.js +229 -229
- package/bin/createTmui.js +382 -382
- package/bin/dirTool.js +152 -152
- package/bin/hooks.js +215 -216
- package/bin/net.js +145 -144
- package/bin/selectedDir.js +28 -28
- package/bin/tmui.js +28 -23
- package/dist/tmui.js +1 -1
- package/package.json +50 -51
- package/webpack.config.js +16 -16
- package/website/index.html +20 -20
- package/website/js/app.js +996 -996
- package/website/js/chunk-vendors.js +13591 -13591
package/bin/dirTool.js
CHANGED
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
const path = require("path")
|
|
2
|
-
const fs = require("fs")
|
|
3
|
-
|
|
4
|
-
function getJsonFiles(jsonPath) {
|
|
5
|
-
let jsonFiles = [];
|
|
6
|
-
|
|
7
|
-
function findJsonFile(www) {
|
|
8
|
-
let files = fs.readdirSync(www);
|
|
9
|
-
files.forEach(function(item, index) {
|
|
10
|
-
let fPath = path.join(www, item);
|
|
11
|
-
let stat = fs.statSync(fPath);
|
|
12
|
-
if (stat.isDirectory() === true) {
|
|
13
|
-
findJsonFile(fPath);
|
|
14
|
-
}
|
|
15
|
-
if (stat.isFile() === true) {
|
|
16
|
-
jsonFiles.push(fPath);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
findJsonFile(jsonPath);
|
|
21
|
-
return jsonFiles;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function getJsonDir(basePath = './') {
|
|
25
|
-
const dirPath = basePath;
|
|
26
|
-
const root = {
|
|
27
|
-
name: '',
|
|
28
|
-
type: 'dir',
|
|
29
|
-
parent: dirPath,
|
|
30
|
-
children: []
|
|
31
|
-
};
|
|
32
|
-
const files = fs.readdirSync(dirPath);
|
|
33
|
-
|
|
34
|
-
const tree = [];
|
|
35
|
-
for (let i = 0; i < files.length; i++) {
|
|
36
|
-
const filename = files[i];
|
|
37
|
-
const filePath = path.join(dirPath, filename);
|
|
38
|
-
const suffix = path.extname(filename)
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
if (filename.lastIndexOf('.tmp') == -1 && filename.lastIndexOf('.sys') == -1&&filename[0]!='.') {
|
|
42
|
-
const stats = fs.statSync(filePath);
|
|
43
|
-
if (stats.isFile()) {
|
|
44
|
-
const fileNode = {
|
|
45
|
-
name: filename,
|
|
46
|
-
type: 'file',
|
|
47
|
-
parent: dirPath,
|
|
48
|
-
suffix
|
|
49
|
-
};
|
|
50
|
-
tree.push(fileNode);
|
|
51
|
-
} else if (stats.isDirectory()) {
|
|
52
|
-
const dirNode = {
|
|
53
|
-
name: filename,
|
|
54
|
-
type: 'dir',
|
|
55
|
-
parent: dirPath,
|
|
56
|
-
suffix:'',
|
|
57
|
-
children: []
|
|
58
|
-
};
|
|
59
|
-
tree.push(dirNode);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
} catch (error) {
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
root.children = tree;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return root;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**读取项目信息根据提供的路径。 */
|
|
75
|
-
function checkProject(obj) {
|
|
76
|
-
|
|
77
|
-
// const {id,path,type} = obj;
|
|
78
|
-
let mainsetStrPath = "";
|
|
79
|
-
// 检查是否有tmui文件。和目录。
|
|
80
|
-
let tmuiDir = ""
|
|
81
|
-
//可运行的命令行。
|
|
82
|
-
let scriptsPackagePath = ""
|
|
83
|
-
let tmuix4dir = ""
|
|
84
|
-
if (obj.type == 'cli') {
|
|
85
|
-
mainsetStrPath = path.join(obj.path, 'src', 'manifest.json')
|
|
86
|
-
tmuiDir = path.join(obj.path, 'src', 'tmui', 'package.json')
|
|
87
|
-
if(!fs.existsSync(tmuiDir)){
|
|
88
|
-
tmuiDir = path.join(obj.path, 'src', 'uni_modules', 'tm-ui', 'package.json')
|
|
89
|
-
}
|
|
90
|
-
scriptsPackagePath = path.join(obj.path, 'package.json')
|
|
91
|
-
} else {
|
|
92
|
-
mainsetStrPath = path.join(obj.path, 'manifest.json')
|
|
93
|
-
tmuiDir = path.join(obj.path, 'tmui', 'package.json')
|
|
94
|
-
if(!fs.existsSync(tmuiDir)){
|
|
95
|
-
tmuiDir = path.join(obj.path, 'uni_modules', 'tm-ui', 'package.json')
|
|
96
|
-
}
|
|
97
|
-
tmuix4dir = path.join(obj.path, 'uni_modules','tmx-ui', 'package.json')
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
let str = fs.readFileSync(mainsetStrPath).toString('utf-8');
|
|
101
|
-
|
|
102
|
-
let reg = /("([^\\\"]*(\\.)?)*")|('([^\\\']*(\\.)?)*')|(\/{2,}.*?(\r|\n|$))|(\/\*(\n|.)*?\*\/)/g;
|
|
103
|
-
|
|
104
|
-
str = str.replace(reg, function(word) {
|
|
105
|
-
// 去除注释后的文本
|
|
106
|
-
return /^\/{2,}/.test(word) || /^\/\*/.test(word) ? "" : word;
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
const d = JSON.parse(str);
|
|
110
|
-
// 是否是x项目
|
|
111
|
-
const isUniappx = d['uni-app-x']
|
|
112
|
-
let tmui = "";
|
|
113
|
-
if(isUniappx){
|
|
114
|
-
if (fs.existsSync(tmuix4dir)) {
|
|
115
|
-
let str2 = fs.readFileSync(tmuix4dir).toString('utf-8');
|
|
116
|
-
const p = JSON.parse(str2);
|
|
117
|
-
tmui = p.version
|
|
118
|
-
}
|
|
119
|
-
}else{
|
|
120
|
-
if (fs.existsSync(tmuiDir)) {
|
|
121
|
-
let str2 = fs.readFileSync(tmuiDir).toString('utf-8');
|
|
122
|
-
const p = JSON.parse(str2);
|
|
123
|
-
tmui = p.version
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
// 读取运行的命令行。
|
|
129
|
-
let scripts = ""
|
|
130
|
-
if (fs.existsSync(scriptsPackagePath)) {
|
|
131
|
-
let str2 = fs.readFileSync(scriptsPackagePath).toString('utf-8');
|
|
132
|
-
const p = JSON.parse(str2);
|
|
133
|
-
scripts = p.scripts
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return {
|
|
137
|
-
name: d.name,
|
|
138
|
-
appid: d.appid,
|
|
139
|
-
versionName: d.versionName,
|
|
140
|
-
tmui: tmui,
|
|
141
|
-
unix:isUniappx,
|
|
142
|
-
id: obj.id,
|
|
143
|
-
scripts: scripts
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
module.exports = {
|
|
149
|
-
getJsonFiles,
|
|
150
|
-
getJsonDir,
|
|
151
|
-
checkProject
|
|
152
|
-
}
|
|
1
|
+
const path = require("path")
|
|
2
|
+
const fs = require("fs")
|
|
3
|
+
|
|
4
|
+
function getJsonFiles(jsonPath) {
|
|
5
|
+
let jsonFiles = [];
|
|
6
|
+
|
|
7
|
+
function findJsonFile(www) {
|
|
8
|
+
let files = fs.readdirSync(www);
|
|
9
|
+
files.forEach(function(item, index) {
|
|
10
|
+
let fPath = path.join(www, item);
|
|
11
|
+
let stat = fs.statSync(fPath);
|
|
12
|
+
if (stat.isDirectory() === true) {
|
|
13
|
+
findJsonFile(fPath);
|
|
14
|
+
}
|
|
15
|
+
if (stat.isFile() === true) {
|
|
16
|
+
jsonFiles.push(fPath);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
findJsonFile(jsonPath);
|
|
21
|
+
return jsonFiles;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getJsonDir(basePath = './') {
|
|
25
|
+
const dirPath = basePath;
|
|
26
|
+
const root = {
|
|
27
|
+
name: '',
|
|
28
|
+
type: 'dir',
|
|
29
|
+
parent: dirPath,
|
|
30
|
+
children: []
|
|
31
|
+
};
|
|
32
|
+
const files = fs.readdirSync(dirPath);
|
|
33
|
+
|
|
34
|
+
const tree = [];
|
|
35
|
+
for (let i = 0; i < files.length; i++) {
|
|
36
|
+
const filename = files[i];
|
|
37
|
+
const filePath = path.join(dirPath, filename);
|
|
38
|
+
const suffix = path.extname(filename)
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
if (filename.lastIndexOf('.tmp') == -1 && filename.lastIndexOf('.sys') == -1&&filename[0]!='.') {
|
|
42
|
+
const stats = fs.statSync(filePath);
|
|
43
|
+
if (stats.isFile()) {
|
|
44
|
+
const fileNode = {
|
|
45
|
+
name: filename,
|
|
46
|
+
type: 'file',
|
|
47
|
+
parent: dirPath,
|
|
48
|
+
suffix
|
|
49
|
+
};
|
|
50
|
+
tree.push(fileNode);
|
|
51
|
+
} else if (stats.isDirectory()) {
|
|
52
|
+
const dirNode = {
|
|
53
|
+
name: filename,
|
|
54
|
+
type: 'dir',
|
|
55
|
+
parent: dirPath,
|
|
56
|
+
suffix:'',
|
|
57
|
+
children: []
|
|
58
|
+
};
|
|
59
|
+
tree.push(dirNode);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} catch (error) {
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
root.children = tree;
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
return root;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**读取项目信息根据提供的路径。 */
|
|
75
|
+
function checkProject(obj) {
|
|
76
|
+
|
|
77
|
+
// const {id,path,type} = obj;
|
|
78
|
+
let mainsetStrPath = "";
|
|
79
|
+
// 检查是否有tmui文件。和目录。
|
|
80
|
+
let tmuiDir = ""
|
|
81
|
+
//可运行的命令行。
|
|
82
|
+
let scriptsPackagePath = ""
|
|
83
|
+
let tmuix4dir = ""
|
|
84
|
+
if (obj.type == 'cli') {
|
|
85
|
+
mainsetStrPath = path.join(obj.path, 'src', 'manifest.json')
|
|
86
|
+
tmuiDir = path.join(obj.path, 'src', 'tmui', 'package.json')
|
|
87
|
+
if(!fs.existsSync(tmuiDir)){
|
|
88
|
+
tmuiDir = path.join(obj.path, 'src', 'uni_modules', 'tm-ui', 'package.json')
|
|
89
|
+
}
|
|
90
|
+
scriptsPackagePath = path.join(obj.path, 'package.json')
|
|
91
|
+
} else {
|
|
92
|
+
mainsetStrPath = path.join(obj.path, 'manifest.json')
|
|
93
|
+
tmuiDir = path.join(obj.path, 'tmui', 'package.json')
|
|
94
|
+
if(!fs.existsSync(tmuiDir)){
|
|
95
|
+
tmuiDir = path.join(obj.path, 'uni_modules', 'tm-ui', 'package.json')
|
|
96
|
+
}
|
|
97
|
+
tmuix4dir = path.join(obj.path, 'uni_modules','tmx-ui', 'package.json')
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let str = fs.readFileSync(mainsetStrPath).toString('utf-8');
|
|
101
|
+
|
|
102
|
+
let reg = /("([^\\\"]*(\\.)?)*")|('([^\\\']*(\\.)?)*')|(\/{2,}.*?(\r|\n|$))|(\/\*(\n|.)*?\*\/)/g;
|
|
103
|
+
|
|
104
|
+
str = str.replace(reg, function(word) {
|
|
105
|
+
// 去除注释后的文本
|
|
106
|
+
return /^\/{2,}/.test(word) || /^\/\*/.test(word) ? "" : word;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const d = JSON.parse(str);
|
|
110
|
+
// 是否是x项目
|
|
111
|
+
const isUniappx = d['uni-app-x']
|
|
112
|
+
let tmui = "";
|
|
113
|
+
if(isUniappx){
|
|
114
|
+
if (fs.existsSync(tmuix4dir)) {
|
|
115
|
+
let str2 = fs.readFileSync(tmuix4dir).toString('utf-8');
|
|
116
|
+
const p = JSON.parse(str2);
|
|
117
|
+
tmui = p.version
|
|
118
|
+
}
|
|
119
|
+
}else{
|
|
120
|
+
if (fs.existsSync(tmuiDir)) {
|
|
121
|
+
let str2 = fs.readFileSync(tmuiDir).toString('utf-8');
|
|
122
|
+
const p = JSON.parse(str2);
|
|
123
|
+
tmui = p.version
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
// 读取运行的命令行。
|
|
129
|
+
let scripts = ""
|
|
130
|
+
if (fs.existsSync(scriptsPackagePath)) {
|
|
131
|
+
let str2 = fs.readFileSync(scriptsPackagePath).toString('utf-8');
|
|
132
|
+
const p = JSON.parse(str2);
|
|
133
|
+
scripts = p.scripts
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
name: d.name,
|
|
138
|
+
appid: d.appid,
|
|
139
|
+
versionName: d.versionName,
|
|
140
|
+
tmui: tmui,
|
|
141
|
+
unix:isUniappx,
|
|
142
|
+
id: obj.id,
|
|
143
|
+
scripts: scripts
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
module.exports = {
|
|
149
|
+
getJsonFiles,
|
|
150
|
+
getJsonDir,
|
|
151
|
+
checkProject
|
|
152
|
+
}
|