jjb-cmd 2.2.3 → 2.2.4
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 +4 -0
- package/package.json +1 -1
- package/src/new/cmd.auth/index.js +1 -26
- package/src/new/cmd.init/index.js +1 -116
- package/src/new/cmd.install/config.js +1 -70
- package/src/new/cmd.install/index.js +1 -262
- package/src/new/cmd.install/tools.js +1 -230
- package/src/new/cmd.install.app/index.js +1 -27
- package/src/new/cmd.jenkins/index.js +1 -72
- package/src/new/cmd.publish/index.js +1 -197
- package/src/new/cmd.push/index.js +1 -76
- package/src/new/cmd.push/java.js +1 -148
- package/src/new/cmd.push-set/index.js +1 -205
- package/src/new/cmd.refresh/index.js +1 -65
- package/src/new/cmd.reglist/index.js +1 -23
- package/src/new/cmd.rm-rf/index.js +1 -58
- package/src/new/cmd.version/index.js +1 -35
- 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/build.js +0 -15
- package/obf.config.json +0 -3
- 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.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 a21_0x30bb9c=a21_0x3e4a;(function(_0x8d5e37,_0x1b4c98){const _0x2d8a9d=a21_0x3e4a,_0x4270b7=_0x8d5e37();while(!![]){try{const _0x36dd7c=parseInt(_0x2d8a9d(0x229))/0x1+parseInt(_0x2d8a9d(0x22a))/0x2+-parseInt(_0x2d8a9d(0x21f))/0x3*(-parseInt(_0x2d8a9d(0x214))/0x4)+parseInt(_0x2d8a9d(0x1da))/0x5+-parseInt(_0x2d8a9d(0x222))/0x6*(parseInt(_0x2d8a9d(0x221))/0x7)+parseInt(_0x2d8a9d(0x1e8))/0x8*(parseInt(_0x2d8a9d(0x1f3))/0x9)+-parseInt(_0x2d8a9d(0x224))/0xa;if(_0x36dd7c===_0x1b4c98)break;else _0x4270b7['push'](_0x4270b7['shift']());}catch(_0x5b0f7f){_0x4270b7['push'](_0x4270b7['shift']());}}}(a21_0x3624,0xa7211));const fs=require('fs'),os=require('os'),path=require(a21_0x30bb9c(0x200)),utils=require('./util'),request=require(a21_0x30bb9c(0x1de)),compressing=require('compressing'),GIT_HOST=a21_0x30bb9c(0x20e),GIT_TEMP_DIR=a21_0x30bb9c(0x1f6),CLOUD_PROJECT={'common':{'token':a21_0x30bb9c(0x210),'projectId':0x117,'localName':a21_0x30bb9c(0x1ef)},'react-admin-component':{'token':a21_0x30bb9c(0x219),'projectId':0x154,'localName':a21_0x30bb9c(0x218)}},COMMON_CONTENT_NOR_REPLACE=[{'path':a21_0x30bb9c(0x20a),'replace':[['components',a21_0x30bb9c(0x215)]]},{'path':a21_0x30bb9c(0x217),'replace':[[/const\srelation\s=\srequire\(`~\/application\/\${module.code}\/enumerate\/menu`\)\.default;/,a21_0x30bb9c(0x226)],[a21_0x30bb9c(0x218),'jjb-react-admin-component']]}],COMMON_CONTENT_SPA_REPLACE=[{'path':a21_0x30bb9c(0x20a),'replace':[['return\x20__planA();',a21_0x30bb9c(0x207)]]}],COMMON_CONTENT_MICRO_REPLACE=[{'path':a21_0x30bb9c(0x20a),'replace':[[a21_0x30bb9c(0x1d3),a21_0x30bb9c(0x1dc)]]}],COMPONENTS_CONTENT_REPLACE=[{'path':a21_0x30bb9c(0x1e0),'replace':[[a21_0x30bb9c(0x1e5),'jjb-common/http'],[a21_0x30bb9c(0x1f2),a21_0x30bb9c(0x227)],[a21_0x30bb9c(0x208),a21_0x30bb9c(0x1ed)]]},{'path':a21_0x30bb9c(0x225),'replace':[[a21_0x30bb9c(0x22b),a21_0x30bb9c(0x1d8)]]},{'path':'\x5cRouterMenu\x5cindex.js','replace':[[a21_0x30bb9c(0x208),a21_0x30bb9c(0x1ed)]]},{'path':a21_0x30bb9c(0x205),'replace':[[a21_0x30bb9c(0x1e5),a21_0x30bb9c(0x1e1)],['common/tools',a21_0x30bb9c(0x1ed)]]},{'path':a21_0x30bb9c(0x21c),'replace':[[a21_0x30bb9c(0x1e5),a21_0x30bb9c(0x1e1)],['common/tools',a21_0x30bb9c(0x1ed)]]},{'path':a21_0x30bb9c(0x1e4),'replace':[[a21_0x30bb9c(0x1e5),a21_0x30bb9c(0x1e1)],['common/tools',a21_0x30bb9c(0x1ed)]]},{'path':a21_0x30bb9c(0x223),'replace':[[a21_0x30bb9c(0x22b),'jjb-common/color']]},{'path':a21_0x30bb9c(0x1ce),'replace':[[a21_0x30bb9c(0x208),a21_0x30bb9c(0x1ed)]]},{'path':a21_0x30bb9c(0x1f8),'replace':[['common/website',a21_0x30bb9c(0x1f9)],[a21_0x30bb9c(0x208),'jjb-common/tools']]}];function uid(){const _0x4bab14=a21_0x30bb9c;return Math['random']()[_0x4bab14(0x1ec)]()[_0x4bab14(0x1e2)](0x2);}module[a21_0x30bb9c(0x1db)]=_0x3a3633=>{const _0xe1bbe4=a21_0x30bb9c,_0x7d4b8a=path[_0xe1bbe4(0x22e)]('./'),_0x41715e=_0xe1bbe4(0x21e)+_0x3a3633,_0x494082='1.0.0',_0x306e8b=_0x7d4b8a+'\x5csrc',_0x32fd96=_0xe1bbe4(0x1fb)+uid(),_0x36ecd0=__dirname+'\x5c'+_0x32fd96,_0x417e42=_0x7d4b8a+_0xe1bbe4(0x20b),_0x124f60=_0x7d4b8a+_0xe1bbe4(0x1d7)+_0x3a3633;try{if(fs[_0xe1bbe4(0x21b)](_0x306e8b)){const _0x4aa8d6=CLOUD_PROJECT[_0x3a3633]||undefined;if(_0x4aa8d6){const _0x4d5da9=os['tmpdir'](),_0x4f4aec=_0x4d5da9+'/'+GIT_TEMP_DIR+'/'+_0x3a3633+_0xe1bbe4(0x1eb),_0x41fef1=_0x4d5da9+'/'+GIT_TEMP_DIR+_0xe1bbe4(0x1f4);utils[_0xe1bbe4(0x22c)](_0x4d5da9+'/'+GIT_TEMP_DIR,()=>{const _0x22af75=_0xe1bbe4;fs[_0x22af75(0x1df)](_0x4d5da9+'/'+GIT_TEMP_DIR);const _0x9b2f2b=fs['createWriteStream'](_0x4f4aec);request(GIT_HOST+_0x22af75(0x20c)+_0x4aa8d6[_0x22af75(0x1ff)]+_0x22af75(0x1dd)+_0x4aa8d6['token']+_0x22af75(0x209))[_0x22af75(0x212)](_0x9b2f2b)['on'](_0x22af75(0x1d2),()=>{const _0x301615=_0x22af75;fs[_0x301615(0x1df)](_0x41fef1),compressing['zip'][_0x301615(0x211)](_0x4f4aec,_0x41fef1)[_0x301615(0x1d6)](()=>{setTimeout(()=>{const _0x3bc465=a21_0x3e4a;fs[_0x3bc465(0x1f7)](_0x41fef1)[_0x3bc465(0x21a)](_0x5ecb6b=>{const _0x3036f5=_0x3bc465;_0x5ecb6b[_0x3036f5(0x228)](_0x3036f5(0x204))!==-0x1&&utils[_0x3036f5(0x22c)](_0x306e8b+'\x5c'+_0x4aa8d6[_0x3036f5(0x1d5)],()=>{const _0x1590d7=_0x3036f5;fs[_0x1590d7(0x1df)](_0x36ecd0),utils[_0x1590d7(0x1cf)](_0x41fef1+_0x5ecb6b,_0x36ecd0),setTimeout(()=>{const _0x98d108=_0x1590d7;if(_0x3a3633===_0x98d108(0x1ef)){const _0x23e64e=fs[_0x98d108(0x21b)](_0x306e8b+_0x98d108(0x213));if(_0x23e64e)rm_rf(_0x36ecd0+_0x98d108(0x201)),fs[_0x98d108(0x202)](_0x36ecd0+_0x98d108(0x201));else{if(get_project_type(_0x417e42)==='spa')content_replace(COMMON_CONTENT_SPA_REPLACE,_0x36ecd0),fs['writeFileSync'](_0x36ecd0+'\x5cdva\x5cautomatic\x5crouter.js',fs[_0x98d108(0x1d9)](__dirname+_0x98d108(0x1d1))[_0x98d108(0x1ec)]()),fs[_0x98d108(0x1cd)](_0x36ecd0+_0x98d108(0x1fa),fs['readFileSync'](__dirname+'\x5ccli.dva.register.spa.txt')['toString']());else get_project_type(_0x417e42)===_0x98d108(0x1f0)&&(content_replace(COMMON_CONTENT_MICRO_REPLACE,_0x36ecd0),fs[_0x98d108(0x1cd)](_0x36ecd0+'\x5cdva\x5cautomatic\x5crouter.js',fs['readFileSync'](__dirname+'\x5ccli.dva.router.saas.txt')[_0x98d108(0x1ec)]()),fs[_0x98d108(0x1cd)](_0x36ecd0+_0x98d108(0x1fa),fs['readFileSync'](__dirname+_0x98d108(0x20f))[_0x98d108(0x1ec)]()));}content_replace(COMMON_CONTENT_NOR_REPLACE,_0x36ecd0);}_0x3a3633===_0x98d108(0x216)&&content_replace(COMPONENTS_CONTENT_REPLACE,_0x36ecd0),rm_rf(_0x36ecd0+_0x98d108(0x1d0)),fs[_0x98d108(0x21b)](_0x36ecd0+_0x98d108(0x1d0))&&fs[_0x98d108(0x202)](_0x36ecd0+'\x5c.idea'),fs[_0x98d108(0x21b)](_0x36ecd0+'\x5c.gitignore')&&fs[_0x98d108(0x206)](_0x36ecd0+_0x98d108(0x220)),!fs[_0x98d108(0x21b)](_0x124f60)?fs['mkdirSync'](_0x124f60):rm_rf(_0x124f60),utils[_0x98d108(0x1cf)](_0x36ecd0,_0x124f60,()=>{const _0x4efb81=_0x98d108;rm_rf(_0x36ecd0),fs[_0x4efb81(0x202)](_0x36ecd0),create_package_json(_0x124f60,_0x41715e,_0x494082),update_project_package_json(_0x417e42,_0x41715e,_0x494082),console[_0x4efb81(0x1ee)](_0x4efb81(0x1f1)+_0x41715e+'\x20v'+_0x494082);});},0x3e8);});});},0x7d0);});});});}else console['error'](_0xe1bbe4(0x1e9)+_0x3a3633);}}catch(_0x4503b7){console[_0xe1bbe4(0x1e6)](_0xe1bbe4(0x203));}};function a21_0x3e4a(_0x1952b6,_0x2936a4){const _0x362431=a21_0x3624();return a21_0x3e4a=function(_0x3e4add,_0x2717a7){_0x3e4add=_0x3e4add-0x1cd;let _0x48b994=_0x362431[_0x3e4add];return _0x48b994;},a21_0x3e4a(_0x1952b6,_0x2936a4);}function rm_rf(_0x14c37b){const _0x323778=a21_0x30bb9c;if(fs[_0x323778(0x21b)](_0x14c37b)){const _0x36d695=fs[_0x323778(0x1f7)](_0x14c37b);for(let _0x5f1ba3=0x0;_0x5f1ba3<_0x36d695[_0x323778(0x1f5)];_0x5f1ba3++){const _0x2aa34f=_0x36d695[_0x5f1ba3],_0xb580e2=_0x14c37b+'/'+_0x2aa34f;fs[_0x323778(0x1d4)](_0xb580e2)[_0x323778(0x1ea)]()?(rm_rf(_0xb580e2),fs[_0x323778(0x202)](_0xb580e2)):fs['unlinkSync'](_0xb580e2);}}}function create_package_json(_0x529078,_0x26c87b,_0x1fde8e){const _0x415b6c=a21_0x30bb9c;fs['writeFileSync'](_0x529078+'\x5cpackage.json',_0x415b6c(0x1e7)+_0x26c87b+_0x415b6c(0x1fd)+_0x1fde8e+_0x415b6c(0x21d));}function get_project_type(_0x464f2e){const _0x3028ed=a21_0x30bb9c,_0x49c9ae=JSON[_0x3028ed(0x1fe)](fs[_0x3028ed(0x1d9)](_0x464f2e)[_0x3028ed(0x1ec)]());return _0x49c9ae[_0x3028ed(0x20d)];}function a21_0x3624(){const _0x4646c2=['\x5capplication','112092hWIWjy','jjb-react-admin-component','react-admin-component','\x5cwebsite\x5cindex.js','components','FT3pKzxpRynFkmddJ9Bs','forEach','existsSync','\x5cImageCropper\x5cindex.js','\x22,\x22main\x22:\x20\x22index.js\x22}','jjb-','87lIjeyy','\x5c.gitignore','25858aHGULd','1884NmNxHN','\x5cPageHeaderBar\x5cindex.js','20690800gTmdbO','\x5cRejectText\x5cindex.js','const\x20relation\x20=\x20require(\x27~/enumerate/menu\x27).default;','jjb-common/crypto','indexOf','1231083UkLyxU','1410130bquLab','common/color','DeleteDirAllFile','stringify','resolve','writeFileSync','\x5cRouterContainer\x5cindex.js','CopyFolder','\x5c.idea','\x5ccli.dva.router.spa.txt','close','return\x20__planA();','statSync','localName','then','\x5cnode_modules\x5cjjb-','jjb-common/color','readFileSync','2272420oHGLJe','exports','return\x20process.env.app;','/repository/archive.zip?private_token=','request','mkdirSync','\x5cEditor\x5cindex.js','jjb-common/http','substr','replace','\x5cImageUploader\x5cindex.js','common/http','error','{\x22name\x22:\x22','149528hrhDyN','【Error】:\x20未获取到项目\x20','isDirectory','.zip','toString','jjb-common/tools','log','common','micro-spa','【已安装】:','common/crypto','342hzElnB','/unzip/','length','jjbAssembly','readdirSync','\x5cRouterContainer\x5ccomponents\x5cNavigationTab\x5cindex.js','jjb-common/website','\x5cdva\x5cautomatic\x5cregister.js','template_','dependencies','\x22,\x22version\x22:\x22','parse','projectId','path','\x5cdva\x5cautomatic','rmdirSync','【Error】:\x20当前目录不存在src子目录,无法完成pull操作。','-master-','\x5cFileUploader\x5cindex.js','unlinkSync','return\x20process.env;','common/tools','&ref=master','\x5ctools\x5cindex.js','\x5cpackage.json','/api/v4/projects/','projectType','http://192.168.1.242:10985','\x5ccli.dva.register.saas.txt','G4HJRsHr9D7Ssmixegw2','uncompress','pipe'];a21_0x3624=function(){return _0x4646c2;};return a21_0x3624();}function update_project_package_json(_0x454130,_0xc0c1db,_0x145e26){const _0x26423b=a21_0x30bb9c,_0x12a5b8=JSON[_0x26423b(0x1fe)](fs['readFileSync'](_0x454130)[_0x26423b(0x1ec)]());_0x12a5b8[_0x26423b(0x1fc)][_0xc0c1db]=_0x145e26,fs[_0x26423b(0x1cd)](_0x454130,JSON[_0x26423b(0x22d)](_0x12a5b8,null,0x2));}function content_replace(_0x48fc15=[],_0x20e20f){const _0x4734df=a21_0x30bb9c;_0x48fc15[_0x4734df(0x21a)](_0x2f5dae=>{const _0x368360=_0x4734df,_0x576315=_0x20e20f+_0x2f5dae['path'];if(fs[_0x368360(0x21b)](_0x576315)){let _0x5512fd=fs[_0x368360(0x1d9)](_0x576315)[_0x368360(0x1ec)]();_0x2f5dae[_0x368360(0x1e3)]['forEach'](_0x401355=>{_0x5512fd=_0x5512fd['replace'](_0x401355[0x0],_0x401355[0x1]);}),fs[_0x368360(0x1cd)](_0x576315,_0x5512fd);}});}
|
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 a22_0x41879c=a22_0xf487;(function(_0x247b28,_0x33d49f){const _0x430d99=a22_0xf487,_0x4d97b3=_0x247b28();while(!![]){try{const _0x24acd6=-parseInt(_0x430d99(0xee))/0x1*(-parseInt(_0x430d99(0xf0))/0x2)+-parseInt(_0x430d99(0xe9))/0x3*(parseInt(_0x430d99(0xf8))/0x4)+-parseInt(_0x430d99(0xf6))/0x5+parseInt(_0x430d99(0xe4))/0x6+parseInt(_0x430d99(0xf3))/0x7*(parseInt(_0x430d99(0xec))/0x8)+parseInt(_0x430d99(0xdb))/0x9*(parseInt(_0x430d99(0xed))/0xa)+-parseInt(_0x430d99(0xe5))/0xb;if(_0x24acd6===_0x33d49f)break;else _0x4d97b3['push'](_0x4d97b3['shift']());}catch(_0x35ac84){_0x4d97b3['push'](_0x4d97b3['shift']());}}}(a22_0x1b25,0xb0df6));const fs=require('fs'),path=require('path'),readline=require(a22_0x41879c(0xe2)),ProgressBar=require(a22_0x41879c(0xdf)),io=readline[a22_0x41879c(0xe3)]({'input':process[a22_0x41879c(0xf9)],'output':process[a22_0x41879c(0xf4)]}),progress=new ProgressBar(a22_0x41879c(0xf7),0x32);function a22_0xf487(_0x35a1ee,_0x20132c){const _0x1b2592=a22_0x1b25();return a22_0xf487=function(_0xf48742,_0x160cd4){_0xf48742=_0xf48742-0xd9;let _0x309bf6=_0x1b2592[_0xf48742];return _0x309bf6;},a22_0xf487(_0x35a1ee,_0x20132c);}let f_total=0x0,f_number=0x0;module[a22_0x41879c(0xdc)]=function(){const _0x1e6b1c=a22_0x41879c,_0x1dc681=path[_0x1e6b1c(0xd9)]('./');io['question']('是否确认删除?删除后不可恢复![y/n]:',function(_0x3a5a57){const _0x2fa245=_0x1e6b1c;if(_0x3a5a57[_0x2fa245(0xeb)]()==='y')console['log'](_0x2fa245(0xf5)),setTimeout(()=>{setTimeout(()=>{console['clear'](),exec(_0x1dc681),setTimeout(()=>{const _0xf05576=a22_0xf487;console[_0xf05576(0xde)](_0xf05576(0xe1)),console['clear'](),process['exit'](0x0);},0x1f4);},0x1f4);},0x1f4);else _0x3a5a57[_0x2fa245(0xeb)]()==='n'?(console[_0x2fa245(0xde)]('取消删除。'),process['exit'](0x0)):(console['log']('无效操作。'),process[_0x2fa245(0xe7)](0x0));});};function a22_0x1b25(){const _0x4e8b43=['15481873bOQVfq','readdirSync','exit','删除异常:','361887ArWHWM','unlinkSync','trim','40NCuVex','829630ugfdZF','19MMpGVg','rmdirSync','87316KGGcKQ','existsSync','statSync','1555225WEhSaX','stdout','正在计算项目数,请稍等...','5695635FalYJo','删除进度','4QweuCr','stdin','resolve','isDirectory','54rvCVEJ','exports','length','log','./progress-bar','删除文件夹:','删除完成。','readline','createInterface','5721084QXthkj'];a22_0x1b25=function(){return _0x4e8b43;};return a22_0x1b25();}function exec(_0x3215e8){const _0xa9aba7=a22_0x41879c;if(fs[_0xa9aba7(0xf1)](_0x3215e8)){const _0x5746a3=fs[_0xa9aba7(0xe6)](_0x3215e8);for(let _0x25f27c=0x0;_0x25f27c<_0x5746a3['length'];_0x25f27c++){const _0x2885c9=_0x5746a3[_0x25f27c],_0x41b010=_0x3215e8+'/'+_0x2885c9;try{fs[_0xa9aba7(0xf2)](_0x41b010)[_0xa9aba7(0xda)]()?(exec(_0x41b010),fs[_0xa9aba7(0xef)](_0x41b010,{'recursive':!![]}),console[_0xa9aba7(0xde)](_0xa9aba7(0xe0)+_0x41b010)):(fs[_0xa9aba7(0xea)](_0x41b010),console['log']('删除文件:'+_0x41b010));}catch(_0x5d6736){console[_0xa9aba7(0xde)](_0xa9aba7(0xe8)+_0x41b010);}}}}function scanner(_0x3abd8c){const _0x1f50f7=a22_0x41879c;if(fs[_0x1f50f7(0xf1)](_0x3abd8c)){const _0x109c42=fs['readdirSync'](_0x3abd8c);for(let _0x1699cd=0x0;_0x1699cd<_0x109c42[_0x1f50f7(0xdd)];_0x1699cd++){const _0x11a704=_0x109c42[_0x1699cd],_0x15697f=_0x3abd8c+'/'+_0x11a704;try{fs[_0x1f50f7(0xf2)](_0x15697f)[_0x1f50f7(0xda)]()?(scanner(_0x15697f),f_total=f_total+0x1):f_total=f_total+0x1;}catch(_0x27f371){}}}}
|
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
|
+
function a23_0x9ab1(_0x1361a3,_0x19de23){const _0x4af6ad=a23_0x4af6();return a23_0x9ab1=function(_0x9ab125,_0x2269d4){_0x9ab125=_0x9ab125-0x109;let _0x3757f2=_0x4af6ad[_0x9ab125];return _0x3757f2;},a23_0x9ab1(_0x1361a3,_0x19de23);}const a23_0x24a188=a23_0x9ab1;(function(_0x260321,_0xde954a){const _0x35eb04=a23_0x9ab1,_0x37ca74=_0x260321();while(!![]){try{const _0x47764d=-parseInt(_0x35eb04(0x119))/0x1*(parseInt(_0x35eb04(0x117))/0x2)+parseInt(_0x35eb04(0x109))/0x3*(parseInt(_0x35eb04(0x10c))/0x4)+-parseInt(_0x35eb04(0x110))/0x5*(-parseInt(_0x35eb04(0x10e))/0x6)+parseInt(_0x35eb04(0x11a))/0x7+-parseInt(_0x35eb04(0x113))/0x8+-parseInt(_0x35eb04(0x114))/0x9*(parseInt(_0x35eb04(0x10d))/0xa)+-parseInt(_0x35eb04(0x116))/0xb*(-parseInt(_0x35eb04(0x111))/0xc);if(_0x47764d===_0xde954a)break;else _0x37ca74['push'](_0x37ca74['shift']());}catch(_0x15f9a3){_0x37ca74['push'](_0x37ca74['shift']());}}}(a23_0x4af6,0x208cc));const slog=require('single-line-log')[a23_0x24a188(0x10a)];function a23_0x4af6(){const _0x64db98=['1006440LbxwXG','toFixed','1765096QZPYmY','36lJhIJX','Progress','66JUQbsJ','82JYcQis','length','6437brdTYs','530502vFNVJK','render','13563YdWuNP','stdout','total','28SSCwNY','326020MhDhsv','825798enGeiw','completed','5bZkzpS'];a23_0x4af6=function(){return _0x64db98;};return a23_0x4af6();}function ProgressBar(_0x16133c,_0x1d7f8c){const _0x20b243=a23_0x24a188;this['description']=_0x16133c||_0x20b243(0x115),this[_0x20b243(0x118)]=_0x1d7f8c||0x19,this[_0x20b243(0x11b)]=function(_0x549579){const _0x3842ef=_0x20b243;let _0x29e2ec;const _0x4677fb=(_0x549579[_0x3842ef(0x10f)]/_0x549579[_0x3842ef(0x10b)])['toFixed'](0x4),_0x201d5e=Math['floor'](_0x4677fb*this[_0x3842ef(0x118)]);let _0x122355='';for(_0x29e2ec=0x0;_0x29e2ec<_0x201d5e;_0x29e2ec++){_0x122355+='█';}let _0x4deb4c='';for(_0x29e2ec=0x0;_0x29e2ec<this[_0x3842ef(0x118)]-_0x201d5e;_0x29e2ec++){_0x4deb4c+='░';}const _0x51929c=this['description']+':\x20'+(0x64*_0x4677fb)[_0x3842ef(0x112)](0x2)+'%\x20'+_0x122355+_0x4deb4c+'\x20'+_0x549579[_0x3842ef(0x10f)]+'/'+_0x549579[_0x3842ef(0x10b)];slog(_0x51929c);};}module['exports']=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';function a24_0x2854(){const _0xa77f4f=['4SwAeVc','isDirectory','readdir','rmdirSync','unlinkSync','push','read\x20error','forEach','CopyFolder','731827zrDRGO','259kdKLVh','close','1183788ytTRfc','createWriteStream','readdirSync','12677769hRtuSd','CreatePaths','error','mkdir','DeleteDirAllFile','log','CopyFile','length','116792OUuNjy','join','DeepScanner','createReadStream','707075RQBvXQ','1092669BFbhPc','existsSync','1680822vznquY','write\x20error','statSync','mkdirSync'];a24_0x2854=function(){return _0xa77f4f;};return a24_0x2854();}const a24_0x4668f1=a24_0x137c;function a24_0x137c(_0x2ff2c2,_0x377fce){const _0x2854ef=a24_0x2854();return a24_0x137c=function(_0x137c21,_0x130ef1){_0x137c21=_0x137c21-0x10a;let _0x3c2971=_0x2854ef[_0x137c21];return _0x3c2971;},a24_0x137c(_0x2ff2c2,_0x377fce);}(function(_0xe6ad23,_0x40bf40){const _0x2cdf9a=a24_0x137c,_0x18d8eb=_0xe6ad23();while(!![]){try{const _0x153d1e=parseInt(_0x2cdf9a(0x110))/0x1+parseInt(_0x2cdf9a(0x129))/0x2*(-parseInt(_0x2cdf9a(0x123))/0x3)+-parseInt(_0x2cdf9a(0x113))/0x4+parseInt(_0x2cdf9a(0x122))/0x5+-parseInt(_0x2cdf9a(0x125))/0x6+-parseInt(_0x2cdf9a(0x111))/0x7*(parseInt(_0x2cdf9a(0x11e))/0x8)+parseInt(_0x2cdf9a(0x116))/0x9;if(_0x153d1e===_0x40bf40)break;else _0x18d8eb['push'](_0x18d8eb['shift']());}catch(_0x20b6f3){_0x18d8eb['push'](_0x18d8eb['shift']());}}}(a24_0x2854,0x6abc6));const fs=require('fs'),path=require('path');exports['DeleteDirAllFile']=(_0x42c249,_0x2f2c8b)=>{const _0x561ddc=a24_0x137c;let _0xa2ba84=[];const _0x2f7163=this;fs[_0x561ddc(0x124)](_0x42c249)?(_0xa2ba84=fs[_0x561ddc(0x115)](_0x42c249),_0xa2ba84['forEach'](function(_0x2e7fb9,_0x49facf){const _0x3bb77e=_0x561ddc;let _0x25474c=_0x42c249+'/'+_0x2e7fb9;fs['statSync'](_0x25474c)[_0x3bb77e(0x12a)]()?_0x2f7163[_0x3bb77e(0x11a)](_0x25474c):fs[_0x3bb77e(0x10b)](_0x25474c);}),fs[_0x561ddc(0x10a)](_0x42c249),_0x2f2c8b&&_0x2f2c8b()):_0x2f2c8b&&_0x2f2c8b();},exports['CopyFolder']=(_0x489787,_0x383686,_0x18388e)=>{const _0x1614ca=a24_0x137c,_0x367b97=this;fs[_0x1614ca(0x12b)](_0x489787,function(_0x3f0fbb,_0x51e1a9){const _0x14cb13=_0x1614ca;let _0x539153=0x0;const _0x27512c=function(){++_0x539153===_0x51e1a9['length']&&_0x18388e&&_0x18388e();};if(_0x3f0fbb){_0x27512c();return;}_0x51e1a9[_0x14cb13(0x10e)](function(_0x3af6de){const _0x733317=_0x14cb13,_0x1ca964=path[_0x733317(0x11f)](_0x489787,_0x3af6de),_0x4cfd26=path['join'](_0x383686,_0x3af6de);fs['stat'](_0x1ca964,function(_0x4574f1,_0x3d99f6){const _0x24c1fc=_0x733317;_0x3d99f6['isDirectory']()?fs[_0x24c1fc(0x119)](_0x4cfd26,function(_0x3cf3e5){const _0x5de930=_0x24c1fc;if(_0x3cf3e5){console[_0x5de930(0x11b)](_0x3cf3e5);return;}_0x367b97[_0x5de930(0x10f)](_0x1ca964,_0x4cfd26,_0x27512c);}):_0x367b97[_0x24c1fc(0x11c)](_0x1ca964,_0x4cfd26,_0x27512c);});}),_0x51e1a9[_0x14cb13(0x11d)]===0x0&&_0x18388e&&_0x18388e();});},exports[a24_0x4668f1(0x11c)]=(_0x3906f4,_0x3a80da,_0x3f14e4)=>{const _0x4ed70f=a24_0x4668f1,_0xeae131=fs[_0x4ed70f(0x121)](_0x3906f4);_0xeae131['on']('error',function(_0x104bf1){const _0x15a62c=_0x4ed70f;_0x104bf1&&console[_0x15a62c(0x11b)](_0x15a62c(0x10d),_0x3906f4),_0x3f14e4&&_0x3f14e4(_0x104bf1);});const _0x4cd1de=fs[_0x4ed70f(0x114)](_0x3a80da);_0x4cd1de['on'](_0x4ed70f(0x118),function(_0x148517){const _0xa427fc=_0x4ed70f;_0x148517&&console[_0xa427fc(0x11b)](_0xa427fc(0x126),_0x3a80da),_0x3f14e4&&_0x3f14e4(_0x148517);}),_0x4cd1de['on'](_0x4ed70f(0x112),function(_0x28163d){_0x3f14e4&&_0x3f14e4(_0x28163d);}),_0xeae131['pipe'](_0x4cd1de);},exports[a24_0x4668f1(0x120)]=(_0x4974fd,_0xdfd6a0)=>{const _0x3d5a83=a24_0x4668f1,_0x326b3a=this,_0x418a90=fs['readdirSync'](_0x4974fd);_0x418a90[_0x3d5a83(0x10e)](_0x497a54=>{const _0x554a8f=_0x3d5a83,_0x18ab28=_0x4974fd+'/'+_0x497a54,_0x2e6db7=fs[_0x554a8f(0x127)](_0x18ab28);_0x2e6db7[_0x554a8f(0x12a)]()?_0x326b3a[_0x554a8f(0x120)](_0x18ab28,_0xdfd6a0):_0xdfd6a0['push'](_0x18ab28);});},exports[a24_0x4668f1(0x117)]=(_0xbf3910,_0x3f35af)=>{return new Promise(_0x289c44=>{const _0x3693ca=a24_0x137c,_0x535c22=[];_0x3f35af[_0x3693ca(0x10e)]((_0x2be09f,_0x22ab0b)=>{const _0x9b1d2d=_0x3693ca,_0x1aec6c=_0xbf3910+'/'+_0x535c22[_0x9b1d2d(0x11f)]('/')+'/'+_0x2be09f;try{const _0x47f1db=fs['statSync'](_0x1aec6c);_0x47f1db[_0x9b1d2d(0x12a)]()?_0x22ab0b===_0x3f35af[_0x9b1d2d(0x11d)]-0x1&&_0x289c44():(fs[_0x9b1d2d(0x128)](_0x1aec6c),_0x22ab0b===_0x3f35af[_0x9b1d2d(0x11d)]-0x1&&_0x289c44());}catch(_0x53f76b){fs[_0x9b1d2d(0x128)](_0x1aec6c),_0x22ab0b===_0x3f35af[_0x9b1d2d(0x11d)]-0x1&&_0x289c44();}_0x535c22[_0x9b1d2d(0x10c)](_0x2be09f);});});};
|