jjb-cmd 2.0.9 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +2 -1
- package/src/new/cmd.init/index.js +1 -102
- package/src/new/cmd.install/config.js +1 -47
- package/src/new/cmd.install/index.js +1 -262
- package/src/new/cmd.install/tools.js +1 -230
- package/src/new/cmd.push/index.js +1 -54
- package/src/new/cmd.reglist/index.js +1 -22
- package/src/new/cmd.rm-rf/index.js +1 -58
- package/src/new/cmd.version/index.js +1 -34
- package/src/old/cli.init.js +1 -26
- package/src/old/cli.install/config.js +1 -206
- package/src/old/cli.install/index.js +1 -340
- package/src/old/cli.install/tools.js +1 -230
- package/src/old/cli.merge.js +1 -80
- package/src/old/cli.pull.js +1 -94
- package/src/old/cli.pull2.js +1 -377
- package/src/old/cli.rm-rf.js +1 -88
- package/src/old/progress-bar.js +1 -23
- package/src/old/util.js +1 -149
- package/.idea/jjb-cmd.iml +0 -12
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/src/old/cli.dva.register.saas.txt +0 -40
- package/src/old/cli.dva.register.spa.txt +0 -22
- package/src/old/cli.dva.router.saas.txt +0 -210
- package/src/old/cli.dva.router.spa.txt +0 -119
- package/src/old/cli.init/jjb.config.json +0 -40
- package/src/old/cli.init/jjb.script/build.js +0 -11
- package/src/old/cli.init/jjb.script/config.js +0 -217
- package/src/old/cli.init/jjb.script/proxy.js +0 -19
- package/src/old/cli.init/jjb.script/server.js +0 -29
- package/src/old/cli.init/jjb.script/utils.js +0 -13
- package/src/old/cli.init/package.json +0 -65
- package/src/old/cli.init/public/index.html +0 -21
- package/src/old/cli.init/src/enumerate/menu/index.js +0 -1
- package/src/old/cli.init/src/enumerate/namespace/index.js +0 -3
- package/src/old/cli.init/src/index.js +0 -24
- package/src/old/cli.init/src/models/main/index.js +0 -31
- package/src/old/cli.init/src/pages/index.js +0 -9
- package/src/old/cli.init/webstorm.config.js +0 -18
package/src/old/cli.pull2.js
CHANGED
@@ -1,377 +1 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const fs = require('fs');
|
4
|
-
const os = require('os');
|
5
|
-
const path = require('path');
|
6
|
-
const utils = require('./util');
|
7
|
-
const request = require('request');
|
8
|
-
const compressing = require('compressing');
|
9
|
-
|
10
|
-
// GIT仓库
|
11
|
-
const GIT_HOST = 'http://192.168.1.242:10985';
|
12
|
-
// 临时存放目录
|
13
|
-
const GIT_TEMP_DIR = 'jjbAssembly';
|
14
|
-
// 项目列表,后期可存库
|
15
|
-
const CLOUD_PROJECT = {
|
16
|
-
'common': {
|
17
|
-
token: 'G4HJRsHr9D7Ssmixegw2',
|
18
|
-
projectId: 279,
|
19
|
-
localName: 'common'
|
20
|
-
},
|
21
|
-
'react-admin-component': {
|
22
|
-
token: 'FT3pKzxpRynFkmddJ9Bs',
|
23
|
-
projectId: 340,
|
24
|
-
localName: 'components'
|
25
|
-
}
|
26
|
-
};
|
27
|
-
// common 需要替换的文本(常规应用)
|
28
|
-
const COMMON_CONTENT_NOR_REPLACE = [
|
29
|
-
{
|
30
|
-
path: `\\tools\\index.js`,
|
31
|
-
replace: [
|
32
|
-
[
|
33
|
-
'components',
|
34
|
-
'jjb-react-admin-component'
|
35
|
-
]
|
36
|
-
]
|
37
|
-
},
|
38
|
-
{
|
39
|
-
path: `\\website\\index.js`,
|
40
|
-
replace: [
|
41
|
-
[
|
42
|
-
/const\srelation\s=\srequire\(`~\/application\/\${module.code}\/enumerate\/menu`\)\.default;/,
|
43
|
-
'const relation = require(\'~/enumerate/menu\').default;'
|
44
|
-
],
|
45
|
-
[
|
46
|
-
'components',
|
47
|
-
'jjb-react-admin-component'
|
48
|
-
]
|
49
|
-
]
|
50
|
-
}
|
51
|
-
];
|
52
|
-
// common 需要替换的文本(单应用)
|
53
|
-
const COMMON_CONTENT_SPA_REPLACE = [
|
54
|
-
{
|
55
|
-
path: `\\tools\\index.js`,
|
56
|
-
replace: [
|
57
|
-
[
|
58
|
-
'return __planA();',
|
59
|
-
'return process.env;'
|
60
|
-
]
|
61
|
-
]
|
62
|
-
}
|
63
|
-
];
|
64
|
-
// common 需要替换的文本(微应用)
|
65
|
-
const COMMON_CONTENT_MICRO_REPLACE = [
|
66
|
-
{
|
67
|
-
path: `\\tools\\index.js`,
|
68
|
-
replace: [
|
69
|
-
[
|
70
|
-
'return __planA();',
|
71
|
-
'return process.env.app;'
|
72
|
-
]
|
73
|
-
]
|
74
|
-
}
|
75
|
-
];
|
76
|
-
// react-admin-component 需要替换的文本
|
77
|
-
const COMPONENTS_CONTENT_REPLACE = [
|
78
|
-
{
|
79
|
-
path: `\\Editor\\index.js`,
|
80
|
-
replace: [
|
81
|
-
[
|
82
|
-
'common/http',
|
83
|
-
'jjb-common/http'
|
84
|
-
],
|
85
|
-
[
|
86
|
-
'common/crypto',
|
87
|
-
'jjb-common/crypto'
|
88
|
-
],
|
89
|
-
[
|
90
|
-
'common/tools',
|
91
|
-
'jjb-common/tools'
|
92
|
-
]
|
93
|
-
]
|
94
|
-
},
|
95
|
-
{
|
96
|
-
path: `\\RejectText\\index.js`,
|
97
|
-
replace: [
|
98
|
-
[
|
99
|
-
'common/color',
|
100
|
-
'jjb-common/color'
|
101
|
-
]
|
102
|
-
]
|
103
|
-
},
|
104
|
-
{
|
105
|
-
path: `\\RouterMenu\\index.js`,
|
106
|
-
replace: [
|
107
|
-
[
|
108
|
-
'common/tools',
|
109
|
-
'jjb-common/tools'
|
110
|
-
]
|
111
|
-
]
|
112
|
-
},
|
113
|
-
{
|
114
|
-
path: `\\FileUploader\\index.js`,
|
115
|
-
replace: [
|
116
|
-
[
|
117
|
-
'common/http',
|
118
|
-
'jjb-common/http'
|
119
|
-
],
|
120
|
-
[
|
121
|
-
'common/tools',
|
122
|
-
'jjb-common/tools'
|
123
|
-
]
|
124
|
-
]
|
125
|
-
},
|
126
|
-
{
|
127
|
-
path: `\\ImageCropper\\index.js`,
|
128
|
-
replace: [
|
129
|
-
[
|
130
|
-
'common/http',
|
131
|
-
'jjb-common/http'
|
132
|
-
],
|
133
|
-
[
|
134
|
-
'common/tools',
|
135
|
-
'jjb-common/tools'
|
136
|
-
]
|
137
|
-
]
|
138
|
-
},
|
139
|
-
{
|
140
|
-
path: `\\ImageUploader\\index.js`,
|
141
|
-
replace: [
|
142
|
-
[
|
143
|
-
'common/http',
|
144
|
-
'jjb-common/http'
|
145
|
-
],
|
146
|
-
[
|
147
|
-
'common/tools',
|
148
|
-
'jjb-common/tools'
|
149
|
-
]
|
150
|
-
]
|
151
|
-
},
|
152
|
-
{
|
153
|
-
path: `\\PageHeaderBar\\index.js`,
|
154
|
-
replace: [
|
155
|
-
[
|
156
|
-
'common/color',
|
157
|
-
'jjb-common/color'
|
158
|
-
]
|
159
|
-
]
|
160
|
-
},
|
161
|
-
{
|
162
|
-
path: `\\RouterContainer\\index.js`,
|
163
|
-
replace: [
|
164
|
-
[
|
165
|
-
'common/tools',
|
166
|
-
'jjb-common/tools'
|
167
|
-
]
|
168
|
-
]
|
169
|
-
},
|
170
|
-
{
|
171
|
-
path: `\\RouterContainer\\components\\NavigationTab\\index.js`,
|
172
|
-
replace: [
|
173
|
-
[
|
174
|
-
'common/website',
|
175
|
-
'jjb-common/website'
|
176
|
-
],
|
177
|
-
[
|
178
|
-
'common/tools',
|
179
|
-
'jjb-common/tools'
|
180
|
-
]
|
181
|
-
]
|
182
|
-
}
|
183
|
-
];
|
184
|
-
|
185
|
-
/**
|
186
|
-
* @description 生成UID
|
187
|
-
* @returns {string}
|
188
|
-
*/
|
189
|
-
function uid () {
|
190
|
-
return Math.random().toString().substr(2);
|
191
|
-
}
|
192
|
-
|
193
|
-
module.exports = input => {
|
194
|
-
/* 下发项目路径 */
|
195
|
-
const root = path.resolve('./');
|
196
|
-
/* 下发包名 */
|
197
|
-
const packageName = `jjb-${input}`;
|
198
|
-
/* 下发包版本 */
|
199
|
-
const packageVerson = '1.0.0';
|
200
|
-
/* 下发项目src路径 */
|
201
|
-
const srcFolderPath = `${root}\\src`;
|
202
|
-
/* 临时文件名称 */
|
203
|
-
const templateFolderName = `template_${uid()}`;
|
204
|
-
/* 临时文件路径 */
|
205
|
-
const templateFolderPath = `${__dirname}\\${templateFolderName}`;
|
206
|
-
/* 下发安装包package.json */
|
207
|
-
const rootPackageJsonPath = `${root}\\package.json`;
|
208
|
-
/* 安装包路径 */
|
209
|
-
const rootNodeModulesPackagePath = `${root}\\node_modules\\jjb-${input}`;
|
210
|
-
try {
|
211
|
-
if (fs.existsSync(srcFolderPath)) {
|
212
|
-
const cloudObj = CLOUD_PROJECT[ input ] || undefined;
|
213
|
-
if (cloudObj) {
|
214
|
-
const tmpDir = os.tmpdir();
|
215
|
-
const zipPath = `${tmpDir}/${GIT_TEMP_DIR}/${input}.zip`;
|
216
|
-
const zipFolder = `${tmpDir}/${GIT_TEMP_DIR}/unzip/`;
|
217
|
-
utils.DeleteDirAllFile(`${tmpDir}/${GIT_TEMP_DIR}`, () => {
|
218
|
-
fs.mkdirSync(`${tmpDir}/${GIT_TEMP_DIR}`);
|
219
|
-
const stream = fs.createWriteStream(zipPath);
|
220
|
-
request(`${GIT_HOST}/api/v4/projects/${cloudObj.projectId}/repository/archive.zip?private_token=${cloudObj.token}&ref=master`)
|
221
|
-
.pipe(stream)
|
222
|
-
.on('close', () => {
|
223
|
-
fs.mkdirSync(zipFolder);
|
224
|
-
compressing.zip.uncompress(zipPath, zipFolder)
|
225
|
-
.then(() => {
|
226
|
-
setTimeout(() => {
|
227
|
-
fs.readdirSync(zipFolder).forEach(dirName => {
|
228
|
-
if (dirName.indexOf('-master-') !== -1) {
|
229
|
-
/* 删除下载的文件 */
|
230
|
-
utils.DeleteDirAllFile(`${srcFolderPath}\\${cloudObj.localName}`, () => {
|
231
|
-
/* 创建临时文件夹 */
|
232
|
-
fs.mkdirSync(templateFolderPath);
|
233
|
-
/* 拷贝解压后的文件到临时文件夹 */
|
234
|
-
utils.CopyFolder(zipFolder + dirName, templateFolderPath);
|
235
|
-
setTimeout(() => {
|
236
|
-
/* 如果输入文件名是common */
|
237
|
-
if (input === 'common') {
|
238
|
-
/* 判断是否为多应用 */
|
239
|
-
const isMutilate = fs.existsSync(`${srcFolderPath}\\application`);
|
240
|
-
if (isMutilate) {
|
241
|
-
/* 多应用模式下需要删除automatic文件夹 */
|
242
|
-
rm_rf(`${templateFolderPath}\\dva\\automatic`);
|
243
|
-
fs.rmdirSync(`${templateFolderPath}\\dva\\automatic`);
|
244
|
-
} else {
|
245
|
-
if (get_project_type(rootPackageJsonPath) === 'spa') {
|
246
|
-
/* 替换操作 */
|
247
|
-
content_replace(COMMON_CONTENT_SPA_REPLACE, templateFolderPath);
|
248
|
-
fs.writeFileSync(`${templateFolderPath}\\dva\\automatic\\router.js`, fs.readFileSync(`${__dirname}\\cli.dva.router.spa.txt`).toString());
|
249
|
-
fs.writeFileSync(`${templateFolderPath}\\dva\\automatic\\register.js`, fs.readFileSync(`${__dirname}\\cli.dva.register.spa.txt`).toString());
|
250
|
-
} else if (get_project_type(rootPackageJsonPath) === 'micro-spa') {
|
251
|
-
content_replace(COMMON_CONTENT_MICRO_REPLACE, templateFolderPath);
|
252
|
-
fs.writeFileSync(`${templateFolderPath}\\dva\\automatic\\router.js`, fs.readFileSync(`${__dirname}\\cli.dva.router.saas.txt`).toString());
|
253
|
-
fs.writeFileSync(`${templateFolderPath}\\dva\\automatic\\register.js`, fs.readFileSync(`${__dirname}\\cli.dva.register.saas.txt`).toString());
|
254
|
-
}
|
255
|
-
}
|
256
|
-
/* 替换操作 */
|
257
|
-
content_replace(COMMON_CONTENT_NOR_REPLACE, templateFolderPath);
|
258
|
-
}
|
259
|
-
/* 如果输入文件名是react-admin-component */
|
260
|
-
if (input === 'react-admin-component') {
|
261
|
-
/* 替换操作 */
|
262
|
-
content_replace(COMPONENTS_CONTENT_REPLACE, templateFolderPath);
|
263
|
-
}
|
264
|
-
rm_rf(`${templateFolderPath}\\.idea`);
|
265
|
-
if (fs.existsSync(`${templateFolderPath}\\.idea`)) {
|
266
|
-
fs.rmdirSync(`${templateFolderPath}\\.idea`);
|
267
|
-
}
|
268
|
-
if (fs.existsSync(`${templateFolderPath}\\.gitignore`)) {
|
269
|
-
fs.unlinkSync(`${templateFolderPath}\\.gitignore`);
|
270
|
-
}
|
271
|
-
/* 如果文件夹不存在 */
|
272
|
-
if (!fs.existsSync(rootNodeModulesPackagePath)) {
|
273
|
-
// 创建文件夹
|
274
|
-
fs.mkdirSync(rootNodeModulesPackagePath);
|
275
|
-
} else {
|
276
|
-
// 删除旧文件
|
277
|
-
rm_rf(rootNodeModulesPackagePath);
|
278
|
-
}
|
279
|
-
/* 复制文件到下发项目node_modules */
|
280
|
-
utils.CopyFolder(templateFolderPath, rootNodeModulesPackagePath, () => {
|
281
|
-
/* 删除所有临时文件 */
|
282
|
-
rm_rf(templateFolderPath);
|
283
|
-
/* 删除临时文件夹 */
|
284
|
-
fs.rmdirSync(templateFolderPath);
|
285
|
-
/* 创建下发包package.json */
|
286
|
-
create_package_json(rootNodeModulesPackagePath, packageName, packageVerson);
|
287
|
-
/* 下发完成更新下发项目package.json */
|
288
|
-
update_project_package_json(rootPackageJsonPath, packageName, packageVerson);
|
289
|
-
/* 完成操作 */
|
290
|
-
console.log(`【已安装】:${packageName} v${packageVerson}`);
|
291
|
-
});
|
292
|
-
}, 1000);
|
293
|
-
});
|
294
|
-
}
|
295
|
-
});
|
296
|
-
}, 2000);
|
297
|
-
});
|
298
|
-
});
|
299
|
-
});
|
300
|
-
} else {
|
301
|
-
console.error(`【Error】: 未获取到项目 ${input}`);
|
302
|
-
}
|
303
|
-
}
|
304
|
-
} catch (e) {
|
305
|
-
console.error('【Error】: 当前目录不存在src子目录,无法完成pull操作。');
|
306
|
-
}
|
307
|
-
};
|
308
|
-
|
309
|
-
/**
|
310
|
-
* @description 删除全部
|
311
|
-
* @param path
|
312
|
-
*/
|
313
|
-
function rm_rf (path) {
|
314
|
-
if (fs.existsSync(path)) {
|
315
|
-
const list = fs.readdirSync(path);
|
316
|
-
for (let i = 0; i < list.length; i++) {
|
317
|
-
const item = list[ i ];
|
318
|
-
const vPath = `${path}/${item}`;
|
319
|
-
if (fs.statSync(vPath).isDirectory()) {
|
320
|
-
rm_rf(vPath);
|
321
|
-
fs.rmdirSync(vPath);
|
322
|
-
} else {
|
323
|
-
fs.unlinkSync(vPath);
|
324
|
-
}
|
325
|
-
}
|
326
|
-
}
|
327
|
-
}
|
328
|
-
|
329
|
-
/**
|
330
|
-
* @description 创建package.json
|
331
|
-
* @param path {string} 路径
|
332
|
-
* @param name {string} 包名
|
333
|
-
* @param version {string} 版本
|
334
|
-
*/
|
335
|
-
function create_package_json (path, name, version) {
|
336
|
-
fs.writeFileSync(`${path}\\package.json`, `{"name":"${name}","version":"${version}","main": "index.js"}`);
|
337
|
-
}
|
338
|
-
|
339
|
-
/**
|
340
|
-
* @description 获取项目类型
|
341
|
-
* @param path {string} 路径
|
342
|
-
* @returns {string}
|
343
|
-
*/
|
344
|
-
function get_project_type (path) {
|
345
|
-
const packageJSONFile = JSON.parse(fs.readFileSync(path).toString());
|
346
|
-
return packageJSONFile.projectType;
|
347
|
-
}
|
348
|
-
|
349
|
-
/**
|
350
|
-
* @description 更新项目package.json文件
|
351
|
-
* @param path {string} 路径
|
352
|
-
* @param name {string} 包名
|
353
|
-
* @param version {string} 版本
|
354
|
-
*/
|
355
|
-
function update_project_package_json (path, name, version) {
|
356
|
-
const packageJSONFile = JSON.parse(fs.readFileSync(path).toString());
|
357
|
-
packageJSONFile.dependencies[ name ] = version;
|
358
|
-
fs.writeFileSync(path, JSON.stringify(packageJSONFile, null, 2));
|
359
|
-
}
|
360
|
-
|
361
|
-
/**
|
362
|
-
* @description 替换文件操作
|
363
|
-
* @param source {[]} 替换源
|
364
|
-
* @param root {string} 路径
|
365
|
-
*/
|
366
|
-
function content_replace (source = [], root) {
|
367
|
-
source.forEach(item => {
|
368
|
-
const path = root + item.path;
|
369
|
-
if (fs.existsSync(path)) {
|
370
|
-
let content = fs.readFileSync(path).toString();
|
371
|
-
item.replace.forEach(rep => {
|
372
|
-
content = content.replace(rep[ 0 ], rep[ 1 ]);
|
373
|
-
});
|
374
|
-
fs.writeFileSync(path, content);
|
375
|
-
}
|
376
|
-
});
|
377
|
-
}
|
1
|
+
'use strict';const a14_0x3e622b=a14_0x396e;(function(_0x5ec32e,_0x4cc799){const _0x16b1f8=a14_0x396e,_0x285475=_0x5ec32e();while(!![]){try{const _0x2e7553=parseInt(_0x16b1f8(0x1bb))/0x1*(parseInt(_0x16b1f8(0x19f))/0x2)+-parseInt(_0x16b1f8(0x1a7))/0x3*(-parseInt(_0x16b1f8(0x1c9))/0x4)+-parseInt(_0x16b1f8(0x18c))/0x5+-parseInt(_0x16b1f8(0x172))/0x6*(parseInt(_0x16b1f8(0x1b7))/0x7)+-parseInt(_0x16b1f8(0x19e))/0x8*(parseInt(_0x16b1f8(0x1aa))/0x9)+parseInt(_0x16b1f8(0x17b))/0xa+parseInt(_0x16b1f8(0x187))/0xb;if(_0x2e7553===_0x4cc799)break;else _0x285475['push'](_0x285475['shift']());}catch(_0x3b27e2){_0x285475['push'](_0x285475['shift']());}}}(a14_0xde9c,0xc15cf));function a14_0x396e(_0x4446aa,_0xe28455){const _0xde9cc=a14_0xde9c();return a14_0x396e=function(_0x396e8d,_0x1ad213){_0x396e8d=_0x396e8d-0x171;let _0x3b7dad=_0xde9cc[_0x396e8d];return _0x3b7dad;},a14_0x396e(_0x4446aa,_0xe28455);}const fs=require('fs'),os=require('os'),path=require(a14_0x3e622b(0x1ce)),utils=require(a14_0x3e622b(0x1b3)),request=require(a14_0x3e622b(0x188)),compressing=require(a14_0x3e622b(0x1c4)),GIT_HOST='http://192.168.1.242:10985',GIT_TEMP_DIR=a14_0x3e622b(0x181),CLOUD_PROJECT={'common':{'token':a14_0x3e622b(0x17d),'projectId':0x117,'localName':a14_0x3e622b(0x190)},'react-admin-component':{'token':'FT3pKzxpRynFkmddJ9Bs','projectId':0x154,'localName':a14_0x3e622b(0x1a4)}},COMMON_CONTENT_NOR_REPLACE=[{'path':'\x5ctools\x5cindex.js','replace':[[a14_0x3e622b(0x1a4),a14_0x3e622b(0x1b4)]]},{'path':a14_0x3e622b(0x177),'replace':[[/const\srelation\s=\srequire\(`~\/application\/\${module.code}\/enumerate\/menu`\)\.default;/,a14_0x3e622b(0x1b8)],['components','jjb-react-admin-component']]}],COMMON_CONTENT_SPA_REPLACE=[{'path':a14_0x3e622b(0x175),'replace':[[a14_0x3e622b(0x18e),'return\x20process.env;']]}],COMMON_CONTENT_MICRO_REPLACE=[{'path':'\x5ctools\x5cindex.js','replace':[[a14_0x3e622b(0x18e),a14_0x3e622b(0x1ad)]]}],COMPONENTS_CONTENT_REPLACE=[{'path':a14_0x3e622b(0x193),'replace':[['common/http',a14_0x3e622b(0x1b2)],[a14_0x3e622b(0x178),a14_0x3e622b(0x1cd)],[a14_0x3e622b(0x1bc),a14_0x3e622b(0x1c3)]]},{'path':'\x5cRejectText\x5cindex.js','replace':[[a14_0x3e622b(0x1c1),a14_0x3e622b(0x194)]]},{'path':a14_0x3e622b(0x199),'replace':[['common/tools',a14_0x3e622b(0x1c3)]]},{'path':a14_0x3e622b(0x176),'replace':[[a14_0x3e622b(0x19d),'jjb-common/http'],[a14_0x3e622b(0x1bc),a14_0x3e622b(0x1c3)]]},{'path':'\x5cImageCropper\x5cindex.js','replace':[['common/http','jjb-common/http'],['common/tools',a14_0x3e622b(0x1c3)]]},{'path':a14_0x3e622b(0x185),'replace':[['common/http',a14_0x3e622b(0x1b2)],[a14_0x3e622b(0x1bc),'jjb-common/tools']]},{'path':a14_0x3e622b(0x1b9),'replace':[[a14_0x3e622b(0x1c1),a14_0x3e622b(0x194)]]},{'path':a14_0x3e622b(0x18d),'replace':[['common/tools',a14_0x3e622b(0x1c3)]]},{'path':a14_0x3e622b(0x173),'replace':[['common/website',a14_0x3e622b(0x1bd)],['common/tools',a14_0x3e622b(0x1c3)]]}];function a14_0xde9c(){const _0x35c52f=['\x5ccli.dva.router.saas.txt','length','template_','jjb-common/crypto','path','random','60ZHVFZr','\x5cRouterContainer\x5ccomponents\x5cNavigationTab\x5cindex.js','.zip','\x5ctools\x5cindex.js','\x5cFileUploader\x5cindex.js','\x5cwebsite\x5cindex.js','common/crypto','\x5cdva\x5cautomatic\x5crouter.js','zip','6179540BRFYQE','createWriteStream','G4HJRsHr9D7Ssmixegw2','isDirectory','pipe','substr','jjbAssembly','react-admin-component','mkdirSync','existsSync','\x5cImageUploader\x5cindex.js','【Error】:\x20当前目录不存在src子目录,无法完成pull操作。','11983180ZtGXhq','request','exports','stringify','/unzip/','2416070tRwIjN','\x5cRouterContainer\x5cindex.js','return\x20__planA();','token','common','\x5cdva\x5cautomatic','replace','\x5cEditor\x5cindex.js','jjb-common/color','readFileSync','error','statSync','1.0.0','\x5cRouterMenu\x5cindex.js','【Error】:\x20未获取到项目\x20','jjb-','\x5cpackage.json','common/http','4450968CbbRDd','70VBgUzR','toString','\x5cdva\x5cautomatic\x5cregister.js','/repository/archive.zip?private_token=','log','components','projectId','\x5capplication','5847dDQSkd','rmdirSync','uncompress','9SBlpLd','parse','micro-spa','return\x20process.env.app;','unlinkSync','\x5cnode_modules\x5cjjb-','readdirSync','projectType','jjb-common/http','./util','jjb-react-admin-component','dependencies','\x5ccli.dva.router.spa.txt','137557GLgcMj','const\x20relation\x20=\x20require(\x27~/enumerate/menu\x27).default;','\x5cPageHeaderBar\x5cindex.js','&ref=master','8107WcrozE','common/tools','jjb-common/website','【已安装】:','DeleteDirAllFile','writeFileSync','common/color','\x5c.idea','jjb-common/tools','compressing','-master-','\x22,\x22main\x22:\x20\x22index.js\x22}','\x5ccli.dva.register.spa.txt','forEach','76tIiXei'];a14_0xde9c=function(){return _0x35c52f;};return a14_0xde9c();}function uid(){const _0x6f30f9=a14_0x3e622b;return Math[_0x6f30f9(0x171)]()[_0x6f30f9(0x1a0)]()[_0x6f30f9(0x180)](0x2);}module[a14_0x3e622b(0x189)]=_0x31ce8f=>{const _0x9b4d6a=a14_0x3e622b,_0x211249=path['resolve']('./'),_0x5df094=_0x9b4d6a(0x19b)+_0x31ce8f,_0x6bb277=_0x9b4d6a(0x198),_0x539df8=_0x211249+'\x5csrc',_0x2f7cd2=_0x9b4d6a(0x1cc)+uid(),_0x405f95=__dirname+'\x5c'+_0x2f7cd2,_0x2b88e4=_0x211249+'\x5cpackage.json',_0x5b93d2=_0x211249+_0x9b4d6a(0x1af)+_0x31ce8f;try{if(fs['existsSync'](_0x539df8)){const _0x307ffe=CLOUD_PROJECT[_0x31ce8f]||undefined;if(_0x307ffe){const _0x17b92b=os['tmpdir'](),_0xf518ac=_0x17b92b+'/'+GIT_TEMP_DIR+'/'+_0x31ce8f+_0x9b4d6a(0x174),_0x1cfef5=_0x17b92b+'/'+GIT_TEMP_DIR+_0x9b4d6a(0x18b);utils[_0x9b4d6a(0x1bf)](_0x17b92b+'/'+GIT_TEMP_DIR,()=>{const _0x21c8a2=_0x9b4d6a;fs[_0x21c8a2(0x183)](_0x17b92b+'/'+GIT_TEMP_DIR);const _0x33b33c=fs[_0x21c8a2(0x17c)](_0xf518ac);request(GIT_HOST+'/api/v4/projects/'+_0x307ffe[_0x21c8a2(0x1a5)]+_0x21c8a2(0x1a2)+_0x307ffe[_0x21c8a2(0x18f)]+_0x21c8a2(0x1ba))[_0x21c8a2(0x17f)](_0x33b33c)['on']('close',()=>{const _0xc98d45=_0x21c8a2;fs[_0xc98d45(0x183)](_0x1cfef5),compressing[_0xc98d45(0x17a)][_0xc98d45(0x1a9)](_0xf518ac,_0x1cfef5)['then'](()=>{setTimeout(()=>{const _0x2c50b5=a14_0x396e;fs[_0x2c50b5(0x1b0)](_0x1cfef5)[_0x2c50b5(0x1c8)](_0x3d5a27=>{const _0x43ce22=_0x2c50b5;_0x3d5a27['indexOf'](_0x43ce22(0x1c5))!==-0x1&&utils[_0x43ce22(0x1bf)](_0x539df8+'\x5c'+_0x307ffe['localName'],()=>{const _0x4f2629=_0x43ce22;fs[_0x4f2629(0x183)](_0x405f95),utils['CopyFolder'](_0x1cfef5+_0x3d5a27,_0x405f95),setTimeout(()=>{const _0x32976b=_0x4f2629;if(_0x31ce8f===_0x32976b(0x190)){const _0xfe2701=fs['existsSync'](_0x539df8+_0x32976b(0x1a6));if(_0xfe2701)rm_rf(_0x405f95+_0x32976b(0x191)),fs[_0x32976b(0x1a8)](_0x405f95+_0x32976b(0x191));else{if(get_project_type(_0x2b88e4)==='spa')content_replace(COMMON_CONTENT_SPA_REPLACE,_0x405f95),fs[_0x32976b(0x1c0)](_0x405f95+_0x32976b(0x179),fs[_0x32976b(0x195)](__dirname+_0x32976b(0x1b6))['toString']()),fs[_0x32976b(0x1c0)](_0x405f95+_0x32976b(0x1a1),fs[_0x32976b(0x195)](__dirname+_0x32976b(0x1c7))[_0x32976b(0x1a0)]());else get_project_type(_0x2b88e4)===_0x32976b(0x1ac)&&(content_replace(COMMON_CONTENT_MICRO_REPLACE,_0x405f95),fs[_0x32976b(0x1c0)](_0x405f95+_0x32976b(0x179),fs[_0x32976b(0x195)](__dirname+_0x32976b(0x1ca))['toString']()),fs[_0x32976b(0x1c0)](_0x405f95+_0x32976b(0x1a1),fs[_0x32976b(0x195)](__dirname+'\x5ccli.dva.register.saas.txt')['toString']()));}content_replace(COMMON_CONTENT_NOR_REPLACE,_0x405f95);}_0x31ce8f===_0x32976b(0x182)&&content_replace(COMPONENTS_CONTENT_REPLACE,_0x405f95),rm_rf(_0x405f95+_0x32976b(0x1c2)),fs[_0x32976b(0x184)](_0x405f95+_0x32976b(0x1c2))&&fs[_0x32976b(0x1a8)](_0x405f95+_0x32976b(0x1c2)),fs[_0x32976b(0x184)](_0x405f95+'\x5c.gitignore')&&fs[_0x32976b(0x1ae)](_0x405f95+'\x5c.gitignore'),!fs[_0x32976b(0x184)](_0x5b93d2)?fs[_0x32976b(0x183)](_0x5b93d2):rm_rf(_0x5b93d2),utils['CopyFolder'](_0x405f95,_0x5b93d2,()=>{const _0x1a652a=_0x32976b;rm_rf(_0x405f95),fs[_0x1a652a(0x1a8)](_0x405f95),create_package_json(_0x5b93d2,_0x5df094,_0x6bb277),update_project_package_json(_0x2b88e4,_0x5df094,_0x6bb277),console[_0x1a652a(0x1a3)](_0x1a652a(0x1be)+_0x5df094+'\x20v'+_0x6bb277);});},0x3e8);});});},0x7d0);});});});}else console['error'](_0x9b4d6a(0x19a)+_0x31ce8f);}}catch(_0x5afe51){console[_0x9b4d6a(0x196)](_0x9b4d6a(0x186));}};function rm_rf(_0x5d30fe){const _0x152d17=a14_0x3e622b;if(fs[_0x152d17(0x184)](_0x5d30fe)){const _0x5d2278=fs[_0x152d17(0x1b0)](_0x5d30fe);for(let _0x4e880c=0x0;_0x4e880c<_0x5d2278[_0x152d17(0x1cb)];_0x4e880c++){const _0x1da215=_0x5d2278[_0x4e880c],_0x237a5c=_0x5d30fe+'/'+_0x1da215;fs[_0x152d17(0x197)](_0x237a5c)[_0x152d17(0x17e)]()?(rm_rf(_0x237a5c),fs[_0x152d17(0x1a8)](_0x237a5c)):fs[_0x152d17(0x1ae)](_0x237a5c);}}}function create_package_json(_0x589cc8,_0xc70e67,_0x45ba45){const _0x2c1bbe=a14_0x3e622b;fs[_0x2c1bbe(0x1c0)](_0x589cc8+_0x2c1bbe(0x19c),'{\x22name\x22:\x22'+_0xc70e67+'\x22,\x22version\x22:\x22'+_0x45ba45+_0x2c1bbe(0x1c6));}function get_project_type(_0x2edba3){const _0x29c58c=a14_0x3e622b,_0x34c254=JSON[_0x29c58c(0x1ab)](fs[_0x29c58c(0x195)](_0x2edba3)[_0x29c58c(0x1a0)]());return _0x34c254[_0x29c58c(0x1b1)];}function update_project_package_json(_0x3563da,_0x25c752,_0x23c9bf){const _0x4d34bb=a14_0x3e622b,_0x2771d7=JSON[_0x4d34bb(0x1ab)](fs['readFileSync'](_0x3563da)[_0x4d34bb(0x1a0)]());_0x2771d7[_0x4d34bb(0x1b5)][_0x25c752]=_0x23c9bf,fs[_0x4d34bb(0x1c0)](_0x3563da,JSON[_0x4d34bb(0x18a)](_0x2771d7,null,0x2));}function content_replace(_0x2bb0ce=[],_0x446c8e){const _0x4ac73c=a14_0x3e622b;_0x2bb0ce[_0x4ac73c(0x1c8)](_0x40fae2=>{const _0x259236=_0x4ac73c,_0x248926=_0x446c8e+_0x40fae2['path'];if(fs['existsSync'](_0x248926)){let _0x4ac61e=fs['readFileSync'](_0x248926)[_0x259236(0x1a0)]();_0x40fae2[_0x259236(0x192)][_0x259236(0x1c8)](_0x3302ac=>{const _0xab3cee=_0x259236;_0x4ac61e=_0x4ac61e[_0xab3cee(0x192)](_0x3302ac[0x0],_0x3302ac[0x1]);}),fs[_0x259236(0x1c0)](_0x248926,_0x4ac61e);}});}
|
package/src/old/cli.rm-rf.js
CHANGED
@@ -1,88 +1 @@
|
|
1
|
-
const
|
2
|
-
const path = require('path');
|
3
|
-
const readline = require('readline');
|
4
|
-
const ProgressBar = require('./progress-bar');
|
5
|
-
const io = readline.createInterface({
|
6
|
-
input: process.stdin,
|
7
|
-
output: process.stdout
|
8
|
-
});
|
9
|
-
const progress = new ProgressBar('删除进度', 50);
|
10
|
-
|
11
|
-
let f_total = 0;
|
12
|
-
let f_number = 0;
|
13
|
-
|
14
|
-
module.exports = function () {
|
15
|
-
const root_path = path.resolve('./');
|
16
|
-
|
17
|
-
io.question('是否确认删除?删除后不可恢复![y/n]:', function (answer) {
|
18
|
-
if (answer.trim() === 'y') {
|
19
|
-
console.log('正在计算项目数,请稍等...');
|
20
|
-
setTimeout(() => {
|
21
|
-
// scanner(root_path);
|
22
|
-
// console.log(`计算完成共计[${f_total}]项目。`);
|
23
|
-
setTimeout(() => {
|
24
|
-
console.clear();
|
25
|
-
exec(root_path);
|
26
|
-
setTimeout(() => {
|
27
|
-
console.log('删除完成。');
|
28
|
-
console.clear();
|
29
|
-
process.exit(0);
|
30
|
-
}, 500);
|
31
|
-
}, 500);
|
32
|
-
}, 500);
|
33
|
-
} else if (answer.trim() === 'n') {
|
34
|
-
console.log('取消删除。');
|
35
|
-
process.exit(0);
|
36
|
-
} else {
|
37
|
-
console.log('无效操作。');
|
38
|
-
process.exit(0);
|
39
|
-
}
|
40
|
-
});
|
41
|
-
};
|
42
|
-
|
43
|
-
function exec (path) {
|
44
|
-
if (fs.existsSync(path)) {
|
45
|
-
const list = fs.readdirSync(path);
|
46
|
-
for (let i = 0; i < list.length; i++) {
|
47
|
-
const item = list[ i ];
|
48
|
-
const vPath = `${path}/${item}`;
|
49
|
-
try {
|
50
|
-
if (fs.statSync(vPath).isDirectory()) {
|
51
|
-
exec(vPath);
|
52
|
-
fs.rmdirSync(vPath, { recursive: true });
|
53
|
-
// f_number = f_number + 1;
|
54
|
-
console.log('删除文件夹:' + vPath);
|
55
|
-
} else {
|
56
|
-
fs.unlinkSync(vPath);
|
57
|
-
// f_number = f_number + 1;
|
58
|
-
console.log('删除文件:' + vPath);
|
59
|
-
}
|
60
|
-
// progress.render({
|
61
|
-
// completed: f_number,
|
62
|
-
// total: f_total
|
63
|
-
// });
|
64
|
-
} catch (e) {
|
65
|
-
console.log('删除异常:' + vPath);
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
function scanner (path) {
|
72
|
-
if (fs.existsSync(path)) {
|
73
|
-
const list = fs.readdirSync(path);
|
74
|
-
for (let i = 0; i < list.length; i++) {
|
75
|
-
const item = list[ i ];
|
76
|
-
const vPath = `${path}/${item}`;
|
77
|
-
try {
|
78
|
-
if (fs.statSync(vPath).isDirectory()) {
|
79
|
-
scanner(vPath);
|
80
|
-
f_total = f_total + 1;
|
81
|
-
} else {
|
82
|
-
f_total = f_total + 1;
|
83
|
-
}
|
84
|
-
} catch (e) {
|
85
|
-
}
|
86
|
-
}
|
87
|
-
}
|
88
|
-
}
|
1
|
+
const a15_0x27a5eb=a15_0x2e5e;(function(_0x2fc1d5,_0xb468a8){const _0x282de3=a15_0x2e5e,_0x3b0262=_0x2fc1d5();while(!![]){try{const _0x4cf028=parseInt(_0x282de3(0x1d8))/0x1*(-parseInt(_0x282de3(0x1b4))/0x2)+parseInt(_0x282de3(0x1c4))/0x3*(-parseInt(_0x282de3(0x1d3))/0x4)+parseInt(_0x282de3(0x1b7))/0x5+parseInt(_0x282de3(0x1da))/0x6*(-parseInt(_0x282de3(0x1c3))/0x7)+parseInt(_0x282de3(0x1ca))/0x8*(-parseInt(_0x282de3(0x1c1))/0x9)+parseInt(_0x282de3(0x1c6))/0xa*(parseInt(_0x282de3(0x1d6))/0xb)+-parseInt(_0x282de3(0x1cc))/0xc*(-parseInt(_0x282de3(0x1d4))/0xd);if(_0x4cf028===_0xb468a8)break;else _0x3b0262['push'](_0x3b0262['shift']());}catch(_0xd5368f){_0x3b0262['push'](_0x3b0262['shift']());}}}(a15_0x4ee6,0x8bfb4));const fs=require('fs'),path=require(a15_0x27a5eb(0x1cd)),readline=require(a15_0x27a5eb(0x1d9)),ProgressBar=require(a15_0x27a5eb(0x1cb)),io=readline[a15_0x27a5eb(0x1c8)]({'input':process[a15_0x27a5eb(0x1b5)],'output':process[a15_0x27a5eb(0x1d5)]}),progress=new ProgressBar(a15_0x27a5eb(0x1bb),0x32);let f_total=0x0,f_number=0x0;function a15_0x4ee6(){const _0x32fa94=['path','exports','删除文件:','是否确认删除?删除后不可恢复![y/n]:','取消删除。','statSync','8Ggjyuj','13403VxrDIW','stdout','8371ThIFZi','existsSync','1KHDuxO','readline','438yOzGFx','clear','263078NyEJmH','stdin','trim','2422190DmgZxX','exit','question','length','删除进度','log','删除文件夹:','resolve','readdirSync','删除完成。','9imMQub','isDirectory','39781jzIomI','1600083tKuIMq','正在计算项目数,请稍等...','14540KoCXRQ','无效操作。','createInterface','rmdirSync','5578576eqikCP','./progress-bar','15048FuZVBB'];a15_0x4ee6=function(){return _0x32fa94;};return a15_0x4ee6();}module[a15_0x27a5eb(0x1ce)]=function(){const _0x3c1d5c=a15_0x27a5eb,_0x291f99=path[_0x3c1d5c(0x1be)]('./');io[_0x3c1d5c(0x1b9)](_0x3c1d5c(0x1d0),function(_0x4b76f8){const _0x379d48=_0x3c1d5c;if(_0x4b76f8[_0x379d48(0x1b6)]()==='y')console['log'](_0x379d48(0x1c5)),setTimeout(()=>{setTimeout(()=>{const _0x523e29=a15_0x2e5e;console[_0x523e29(0x1b3)](),exec(_0x291f99),setTimeout(()=>{const _0x1edebf=_0x523e29;console[_0x1edebf(0x1bc)](_0x1edebf(0x1c0)),console[_0x1edebf(0x1b3)](),process[_0x1edebf(0x1b8)](0x0);},0x1f4);},0x1f4);},0x1f4);else _0x4b76f8['trim']()==='n'?(console[_0x379d48(0x1bc)](_0x379d48(0x1d1)),process[_0x379d48(0x1b8)](0x0)):(console[_0x379d48(0x1bc)](_0x379d48(0x1c7)),process[_0x379d48(0x1b8)](0x0));});};function a15_0x2e5e(_0x56323d,_0x36fa49){const _0x4ee6fb=a15_0x4ee6();return a15_0x2e5e=function(_0x2e5e60,_0x4c089e){_0x2e5e60=_0x2e5e60-0x1b3;let _0x5ab45f=_0x4ee6fb[_0x2e5e60];return _0x5ab45f;},a15_0x2e5e(_0x56323d,_0x36fa49);}function exec(_0x5a53d2){const _0x2a16b9=a15_0x27a5eb;if(fs[_0x2a16b9(0x1d7)](_0x5a53d2)){const _0x5aa889=fs[_0x2a16b9(0x1bf)](_0x5a53d2);for(let _0x274f7a=0x0;_0x274f7a<_0x5aa889[_0x2a16b9(0x1ba)];_0x274f7a++){const _0x5d6547=_0x5aa889[_0x274f7a],_0x2a176b=_0x5a53d2+'/'+_0x5d6547;try{fs[_0x2a16b9(0x1d2)](_0x2a176b)[_0x2a16b9(0x1c2)]()?(exec(_0x2a176b),fs[_0x2a16b9(0x1c9)](_0x2a176b,{'recursive':!![]}),console[_0x2a16b9(0x1bc)](_0x2a16b9(0x1bd)+_0x2a176b)):(fs['unlinkSync'](_0x2a176b),console[_0x2a16b9(0x1bc)](_0x2a16b9(0x1cf)+_0x2a176b));}catch(_0x2711dd){console['log']('删除异常:'+_0x2a176b);}}}}function scanner(_0x3cd5b7){const _0x5703cd=a15_0x27a5eb;if(fs[_0x5703cd(0x1d7)](_0x3cd5b7)){const _0x5930da=fs[_0x5703cd(0x1bf)](_0x3cd5b7);for(let _0x446cf5=0x0;_0x446cf5<_0x5930da[_0x5703cd(0x1ba)];_0x446cf5++){const _0x4b0bc7=_0x5930da[_0x446cf5],_0x2341f9=_0x3cd5b7+'/'+_0x4b0bc7;try{fs[_0x5703cd(0x1d2)](_0x2341f9)[_0x5703cd(0x1c2)]()?(scanner(_0x2341f9),f_total=f_total+0x1):f_total=f_total+0x1;}catch(_0x2be2c5){}}}}
|
package/src/old/progress-bar.js
CHANGED
@@ -1,23 +1 @@
|
|
1
|
-
const
|
2
|
-
|
3
|
-
function ProgressBar (description, bar_length) {
|
4
|
-
this.description = description || 'Progress';
|
5
|
-
this.length = bar_length || 25;
|
6
|
-
this.render = function (opts) {
|
7
|
-
let i;
|
8
|
-
const percent = (opts.completed / opts.total).toFixed(4);
|
9
|
-
const cell_num = Math.floor(percent * this.length);
|
10
|
-
let cell = '';
|
11
|
-
for (i = 0; i < cell_num; i++) {
|
12
|
-
cell += '█';
|
13
|
-
}
|
14
|
-
let empty = '';
|
15
|
-
for (i = 0; i < this.length - cell_num; i++) {
|
16
|
-
empty += '░';
|
17
|
-
}
|
18
|
-
const cmdText = this.description + ': ' + (100 * percent).toFixed(2) + '% ' + cell + empty + ' ' + opts.completed + '/' + opts.total;
|
19
|
-
slog(cmdText);
|
20
|
-
};
|
21
|
-
}
|
22
|
-
|
23
|
-
module.exports = ProgressBar;
|
1
|
+
const a16_0x150805=a16_0x5cc5;(function(_0x4e5943,_0x5a6a63){const _0x30b9ed=a16_0x5cc5,_0x3570ac=_0x4e5943();while(!![]){try{const _0x14b772=parseInt(_0x30b9ed(0x80))/0x1+-parseInt(_0x30b9ed(0x79))/0x2+parseInt(_0x30b9ed(0x78))/0x3+parseInt(_0x30b9ed(0x7a))/0x4+parseInt(_0x30b9ed(0x89))/0x5*(-parseInt(_0x30b9ed(0x8a))/0x6)+parseInt(_0x30b9ed(0x86))/0x7*(parseInt(_0x30b9ed(0x83))/0x8)+parseInt(_0x30b9ed(0x7d))/0x9;if(_0x14b772===_0x5a6a63)break;else _0x3570ac['push'](_0x3570ac['shift']());}catch(_0x46e2cc){_0x3570ac['push'](_0x3570ac['shift']());}}}(a16_0x12c9,0xadeeb));const slog=require(a16_0x150805(0x7c))[a16_0x150805(0x81)];function ProgressBar(_0x5b92b7,_0x14ac86){const _0x4f91f3=a16_0x150805;this[_0x4f91f3(0x7e)]=_0x5b92b7||_0x4f91f3(0x88),this['length']=_0x14ac86||0x19,this[_0x4f91f3(0x7b)]=function(_0x2b506c){const _0xf99a3b=_0x4f91f3;let _0x4c0042;const _0x12aac8=(_0x2b506c[_0xf99a3b(0x82)]/_0x2b506c[_0xf99a3b(0x85)])[_0xf99a3b(0x7f)](0x4),_0x5228a7=Math['floor'](_0x12aac8*this[_0xf99a3b(0x84)]);let _0x121612='';for(_0x4c0042=0x0;_0x4c0042<_0x5228a7;_0x4c0042++){_0x121612+='█';}let _0xf29cd9='';for(_0x4c0042=0x0;_0x4c0042<this[_0xf99a3b(0x84)]-_0x5228a7;_0x4c0042++){_0xf29cd9+='░';}const _0x163886=this[_0xf99a3b(0x7e)]+':\x20'+(0x64*_0x12aac8)[_0xf99a3b(0x7f)](0x2)+'%\x20'+_0x121612+_0xf29cd9+'\x20'+_0x2b506c[_0xf99a3b(0x82)]+'/'+_0x2b506c['total'];slog(_0x163886);};}function a16_0x5cc5(_0x5d1f8e,_0xfe5dcc){const _0x12c95d=a16_0x12c9();return a16_0x5cc5=function(_0x5cc557,_0x9f2c04){_0x5cc557=_0x5cc557-0x78;let _0x363bfc=_0x12c95d[_0x5cc557];return _0x363bfc;},a16_0x5cc5(_0x5d1f8e,_0xfe5dcc);}function a16_0x12c9(){const _0x21e72e=['exports','Progress','5450395riUyiw','6SucXhY','2243388JdBsae','2425834ZHAykq','4174476FVexvp','render','single-line-log','4261230HGsDKa','description','toFixed','537538btsnnO','stdout','completed','1704000RwDtvG','length','total','7eDywjk'];a16_0x12c9=function(){return _0x21e72e;};return a16_0x12c9();}module[a16_0x150805(0x87)]=ProgressBar;
|
package/src/old/util.js
CHANGED
@@ -1,149 +1 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const fs = require('fs');
|
4
|
-
const path = require('path');
|
5
|
-
|
6
|
-
/**
|
7
|
-
* @description 清空当前目录
|
8
|
-
* @param filePath
|
9
|
-
* @param callback
|
10
|
-
* @constructor
|
11
|
-
*/
|
12
|
-
exports.DeleteDirAllFile = (filePath, callback) => {
|
13
|
-
let files = [];
|
14
|
-
const that = this;
|
15
|
-
if(fs.existsSync(filePath)) {
|
16
|
-
files = fs.readdirSync(filePath);
|
17
|
-
files.forEach(function(file, index) {
|
18
|
-
let curPath = filePath + "/" + file;
|
19
|
-
if(fs.statSync(curPath).isDirectory()) {
|
20
|
-
that.DeleteDirAllFile(curPath);
|
21
|
-
} else {
|
22
|
-
fs.unlinkSync(curPath);
|
23
|
-
}
|
24
|
-
});
|
25
|
-
fs.rmdirSync(filePath);
|
26
|
-
callback && callback();
|
27
|
-
} else {
|
28
|
-
callback && callback();
|
29
|
-
}
|
30
|
-
};
|
31
|
-
|
32
|
-
/**
|
33
|
-
* @description 复制文件夹及子目录文件
|
34
|
-
* @param srcDir
|
35
|
-
* @param tarDir
|
36
|
-
* @param cb
|
37
|
-
*/
|
38
|
-
exports.CopyFolder = (srcDir, tarDir, cb) => {
|
39
|
-
const that = this;
|
40
|
-
fs.readdir(srcDir, function(err, files) {
|
41
|
-
|
42
|
-
let count = 0
|
43
|
-
const checkEnd = function() {
|
44
|
-
++count === files.length && cb && cb()
|
45
|
-
}
|
46
|
-
|
47
|
-
if (err) {
|
48
|
-
checkEnd()
|
49
|
-
return
|
50
|
-
}
|
51
|
-
|
52
|
-
files.forEach(function(file) {
|
53
|
-
const srcPath = path.join(srcDir, file)
|
54
|
-
const tarPath = path.join(tarDir, file)
|
55
|
-
|
56
|
-
fs.stat(srcPath, function(err, stats) {
|
57
|
-
if (stats.isDirectory()) {
|
58
|
-
fs.mkdir(tarPath, function(err) {
|
59
|
-
if (err) {
|
60
|
-
console.log(err)
|
61
|
-
return
|
62
|
-
}
|
63
|
-
|
64
|
-
that.CopyFolder(srcPath, tarPath, checkEnd)
|
65
|
-
})
|
66
|
-
} else {
|
67
|
-
that.CopyFile(srcPath, tarPath, checkEnd)
|
68
|
-
}
|
69
|
-
})
|
70
|
-
})
|
71
|
-
//为空时直接回调
|
72
|
-
files.length === 0 && cb && cb()
|
73
|
-
})
|
74
|
-
}
|
75
|
-
|
76
|
-
/**
|
77
|
-
* @description 复制文件
|
78
|
-
* @param srcPath
|
79
|
-
* @param tarPath
|
80
|
-
* @param cb
|
81
|
-
*/
|
82
|
-
exports.CopyFile = (srcPath, tarPath, cb) => {
|
83
|
-
const rs = fs.createReadStream(srcPath)
|
84
|
-
rs.on('error', function(err) {
|
85
|
-
if (err) {
|
86
|
-
console.log('read error', srcPath)
|
87
|
-
}
|
88
|
-
cb && cb(err)
|
89
|
-
})
|
90
|
-
|
91
|
-
const ws = fs.createWriteStream(tarPath)
|
92
|
-
ws.on('error', function(err) {
|
93
|
-
if (err) {
|
94
|
-
console.log('write error', tarPath)
|
95
|
-
}
|
96
|
-
cb && cb(err)
|
97
|
-
})
|
98
|
-
ws.on('close', function(ex) {
|
99
|
-
cb && cb(ex)
|
100
|
-
})
|
101
|
-
|
102
|
-
rs.pipe(ws)
|
103
|
-
};
|
104
|
-
|
105
|
-
/**
|
106
|
-
* 深度获取目录路径
|
107
|
-
* @param path
|
108
|
-
* @param pathChildren
|
109
|
-
* @constructor
|
110
|
-
*/
|
111
|
-
exports.DeepScanner = (path, pathChildren) => {
|
112
|
-
const that = this;
|
113
|
-
const itemList = fs.readdirSync(path);
|
114
|
-
itemList.forEach(item => {
|
115
|
-
const childPath = `${path}/${item}`;
|
116
|
-
const stat = fs.statSync(childPath);
|
117
|
-
if (stat.isDirectory()) {
|
118
|
-
that.DeepScanner(childPath, pathChildren);
|
119
|
-
} else {
|
120
|
-
pathChildren.push(childPath);
|
121
|
-
}
|
122
|
-
});
|
123
|
-
};
|
124
|
-
|
125
|
-
/**
|
126
|
-
* 创建目录路径
|
127
|
-
* @param pathArr
|
128
|
-
*/
|
129
|
-
exports.CreatePaths = (rootPath, pathArr) => {
|
130
|
-
return new Promise(resolve => {
|
131
|
-
const linkStr = [];
|
132
|
-
pathArr.forEach((item, index) => {
|
133
|
-
const dirPath = rootPath + '/' + linkStr.join('/') + '/' + item;
|
134
|
-
try {
|
135
|
-
const stat = fs.statSync(dirPath);
|
136
|
-
if (stat.isDirectory()) {
|
137
|
-
index === pathArr.length - 1 && resolve();
|
138
|
-
} else {
|
139
|
-
fs.mkdirSync(dirPath);
|
140
|
-
index === pathArr.length - 1 && resolve();
|
141
|
-
}
|
142
|
-
} catch (e) {
|
143
|
-
fs.mkdirSync(dirPath);
|
144
|
-
index === pathArr.length - 1 && resolve();
|
145
|
-
}
|
146
|
-
linkStr.push(item);
|
147
|
-
});
|
148
|
-
});
|
149
|
-
};
|
1
|
+
'use strict';const a17_0x778af5=a17_0x5e93;(function(_0x590913,_0x2ee0c3){const _0xc03aca=a17_0x5e93,_0x546018=_0x590913();while(!![]){try{const _0x2be17c=parseInt(_0xc03aca(0x16f))/0x1+-parseInt(_0xc03aca(0x153))/0x2+-parseInt(_0xc03aca(0x15b))/0x3*(parseInt(_0xc03aca(0x162))/0x4)+-parseInt(_0xc03aca(0x14d))/0x5*(-parseInt(_0xc03aca(0x16e))/0x6)+-parseInt(_0xc03aca(0x155))/0x7*(parseInt(_0xc03aca(0x15f))/0x8)+parseInt(_0xc03aca(0x15c))/0x9*(-parseInt(_0xc03aca(0x14e))/0xa)+-parseInt(_0xc03aca(0x16a))/0xb*(-parseInt(_0xc03aca(0x15a))/0xc);if(_0x2be17c===_0x2ee0c3)break;else _0x546018['push'](_0x546018['shift']());}catch(_0x4f4375){_0x546018['push'](_0x546018['shift']());}}}(a17_0x1725,0x6c1e6));function a17_0x5e93(_0x1a1304,_0x25b1a7){const _0x1725c6=a17_0x1725();return a17_0x5e93=function(_0x5e93c9,_0x2aa582){_0x5e93c9=_0x5e93c9-0x14c;let _0x434690=_0x1725c6[_0x5e93c9];return _0x434690;},a17_0x5e93(_0x1a1304,_0x25b1a7);}const fs=require('fs'),path=require(a17_0x778af5(0x15e));exports[a17_0x778af5(0x160)]=(_0x23475f,_0x44c08e)=>{const _0x546ef8=a17_0x778af5;let _0x5bb9f7=[];const _0x374ed1=this;fs[_0x546ef8(0x16c)](_0x23475f)?(_0x5bb9f7=fs['readdirSync'](_0x23475f),_0x5bb9f7[_0x546ef8(0x169)](function(_0x3324b9,_0x20b0d3){const _0x1bbde7=_0x546ef8;let _0x871fb4=_0x23475f+'/'+_0x3324b9;fs['statSync'](_0x871fb4)[_0x1bbde7(0x159)]()?_0x374ed1[_0x1bbde7(0x160)](_0x871fb4):fs['unlinkSync'](_0x871fb4);}),fs['rmdirSync'](_0x23475f),_0x44c08e&&_0x44c08e()):_0x44c08e&&_0x44c08e();},exports['CopyFolder']=(_0xaa3dbc,_0x2ca0f3,_0x5bd4bb)=>{const _0x5b21c6=a17_0x778af5,_0x481500=this;fs[_0x5b21c6(0x15d)](_0xaa3dbc,function(_0x10243f,_0x2e92eb){const _0x28537e=_0x5b21c6;let _0x3eafa5=0x0;const _0x48d7d7=function(){const _0x23e9d6=a17_0x5e93;++_0x3eafa5===_0x2e92eb[_0x23e9d6(0x166)]&&_0x5bd4bb&&_0x5bd4bb();};if(_0x10243f){_0x48d7d7();return;}_0x2e92eb[_0x28537e(0x169)](function(_0x1270fd){const _0x1ccbcf=_0x28537e,_0x16e53c=path[_0x1ccbcf(0x154)](_0xaa3dbc,_0x1270fd),_0x3a69c3=path['join'](_0x2ca0f3,_0x1270fd);fs[_0x1ccbcf(0x152)](_0x16e53c,function(_0x5c28e8,_0x367763){const _0x1fbe7b=_0x1ccbcf;_0x367763[_0x1fbe7b(0x159)]()?fs[_0x1fbe7b(0x168)](_0x3a69c3,function(_0x34385d){const _0x175cd9=_0x1fbe7b;if(_0x34385d){console[_0x175cd9(0x151)](_0x34385d);return;}_0x481500[_0x175cd9(0x157)](_0x16e53c,_0x3a69c3,_0x48d7d7);}):_0x481500[_0x1fbe7b(0x158)](_0x16e53c,_0x3a69c3,_0x48d7d7);});}),_0x2e92eb[_0x28537e(0x166)]===0x0&&_0x5bd4bb&&_0x5bd4bb();});},exports[a17_0x778af5(0x158)]=(_0x4cfb40,_0x343b19,_0x72c5b4)=>{const _0x361d31=a17_0x778af5,_0x1a4c0e=fs[_0x361d31(0x170)](_0x4cfb40);_0x1a4c0e['on'](_0x361d31(0x14c),function(_0x5efda9){const _0x59f848=_0x361d31;_0x5efda9&&console[_0x59f848(0x151)](_0x59f848(0x165),_0x4cfb40),_0x72c5b4&&_0x72c5b4(_0x5efda9);});const _0x1da2aa=fs[_0x361d31(0x16d)](_0x343b19);_0x1da2aa['on'](_0x361d31(0x14c),function(_0x179652){const _0x595d3a=_0x361d31;_0x179652&&console['log'](_0x595d3a(0x14f),_0x343b19),_0x72c5b4&&_0x72c5b4(_0x179652);}),_0x1da2aa['on'](_0x361d31(0x161),function(_0x31fec7){_0x72c5b4&&_0x72c5b4(_0x31fec7);}),_0x1a4c0e[_0x361d31(0x16b)](_0x1da2aa);},exports[a17_0x778af5(0x163)]=(_0x1db090,_0x1416f3)=>{const _0xb8e664=a17_0x778af5,_0x1bc70b=this,_0x518dba=fs['readdirSync'](_0x1db090);_0x518dba[_0xb8e664(0x169)](_0x921a87=>{const _0x2c4af7=_0xb8e664,_0x5dc0b6=_0x1db090+'/'+_0x921a87,_0x89e242=fs[_0x2c4af7(0x156)](_0x5dc0b6);_0x89e242['isDirectory']()?_0x1bc70b[_0x2c4af7(0x163)](_0x5dc0b6,_0x1416f3):_0x1416f3[_0x2c4af7(0x164)](_0x5dc0b6);});},exports[a17_0x778af5(0x167)]=(_0x2ae4e8,_0x5d5e72)=>{return new Promise(_0x3efc5f=>{const _0x284df9=[];_0x5d5e72['forEach']((_0x1c22bd,_0x37a756)=>{const _0x5d5777=a17_0x5e93,_0x42c506=_0x2ae4e8+'/'+_0x284df9[_0x5d5777(0x154)]('/')+'/'+_0x1c22bd;try{const _0x30227e=fs[_0x5d5777(0x156)](_0x42c506);_0x30227e[_0x5d5777(0x159)]()?_0x37a756===_0x5d5e72[_0x5d5777(0x166)]-0x1&&_0x3efc5f():(fs[_0x5d5777(0x150)](_0x42c506),_0x37a756===_0x5d5e72[_0x5d5777(0x166)]-0x1&&_0x3efc5f());}catch(_0x381ad1){fs[_0x5d5777(0x150)](_0x42c506),_0x37a756===_0x5d5e72['length']-0x1&&_0x3efc5f();}_0x284df9['push'](_0x1c22bd);});});};function a17_0x1725(){const _0x24be93=['error','86300YZkGGr','30PZrZJv','write\x20error','mkdirSync','log','stat','9202XKyiAD','join','221627FsieuN','statSync','CopyFolder','CopyFile','isDirectory','7932aHlqJj','573xNOkmp','1186803orzwXy','readdir','path','24nbrrbQ','DeleteDirAllFile','close','4912iOGtYE','DeepScanner','push','read\x20error','length','CreatePaths','mkdir','forEach','4554QLkprs','pipe','existsSync','createWriteStream','6EEfbXP','881673ocFlGI','createReadStream'];a17_0x1725=function(){return _0x24be93;};return a17_0x1725();}
|