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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "jjb-cmd",
|
3
|
-
"version": "2.0
|
3
|
+
"version": "2.1.0",
|
4
4
|
"description": "jjb脚手架工具",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -16,6 +16,7 @@
|
|
16
16
|
"axios": "^1.1.3",
|
17
17
|
"commander": "^1.3.2",
|
18
18
|
"compressing": "^1.5.1",
|
19
|
+
"javascript-obfuscator": "^4.0.2",
|
19
20
|
"request": "2.88.2",
|
20
21
|
"single-line-log": "1.1.2"
|
21
22
|
}
|
@@ -1,102 +1 @@
|
|
1
|
-
const
|
2
|
-
const { f_file_copy } = require('../cmd.install/tools');
|
3
|
-
const { CLOUD_PROJECT, GIT_TEMP_DIR, GIT_HOST } = require('../cmd.install/config');
|
4
|
-
const fs = require('fs');
|
5
|
-
const os = require("os");
|
6
|
-
const utils = require("../../old/util");
|
7
|
-
const request = require("request");
|
8
|
-
const compressing = require("compressing");
|
9
|
-
|
10
|
-
module.exports = stdin => {
|
11
|
-
/**
|
12
|
-
* 下发数据根路径
|
13
|
-
* @type {string}
|
14
|
-
*/
|
15
|
-
const root_path = path.resolve('./');
|
16
|
-
|
17
|
-
const cloudObj = CLOUD_PROJECT[ stdin ] || undefined;
|
18
|
-
if (cloudObj) {
|
19
|
-
const tmpDir = os.tmpdir();
|
20
|
-
const zipPath = `${tmpDir}/${GIT_TEMP_DIR}/${stdin}.zip`;
|
21
|
-
const zipFolder = `${tmpDir}/${GIT_TEMP_DIR}/unzip/`;
|
22
|
-
utils.DeleteDirAllFile(`${tmpDir}/${GIT_TEMP_DIR}`, () => {
|
23
|
-
fs.mkdirSync(`${tmpDir}/${GIT_TEMP_DIR}`);
|
24
|
-
let stream = fs.createWriteStream(zipPath);
|
25
|
-
request(`${GIT_HOST}/api/v4/projects/${cloudObj.projectId}/repository/archive.zip?private_token=${cloudObj.token}&ref=master`).pipe(stream)
|
26
|
-
.on('close', () => {
|
27
|
-
fs.mkdirSync(zipFolder);
|
28
|
-
compressing.zip.uncompress(zipPath, zipFolder)
|
29
|
-
.then(() => {
|
30
|
-
setTimeout(() => {
|
31
|
-
fs.readdirSync(zipFolder).forEach(dirName => {
|
32
|
-
if (dirName.indexOf('-master-') !== -1) {
|
33
|
-
utils.CopyFolder(zipFolder + dirName, root_path, () => {
|
34
|
-
console.log('初始化完成!');
|
35
|
-
process.exit(0);
|
36
|
-
});
|
37
|
-
}
|
38
|
-
})
|
39
|
-
}, 2000);
|
40
|
-
})
|
41
|
-
});
|
42
|
-
});
|
43
|
-
} else {
|
44
|
-
console.log('【Error】:初始化失败,'+ stdin +'不存在。');
|
45
|
-
}
|
46
|
-
|
47
|
-
// if (stdin === 'micro-app') {
|
48
|
-
// if (
|
49
|
-
// !fs.existsSync(`${root_path}\\jjb.script`) &&
|
50
|
-
// !fs.existsSync(`${root_path}\\public`) &&
|
51
|
-
// !fs.existsSync(`${root_path}\\src`) &&
|
52
|
-
// !fs.existsSync(`${root_path}\\.gitignore`) &&
|
53
|
-
// !fs.existsSync(`${root_path}\\jjb.config.json`) &&
|
54
|
-
// !fs.existsSync(`${root_path}\\package.json`) &&
|
55
|
-
// !fs.existsSync(`${root_path}\\webstorm.config.js`)
|
56
|
-
// ) {
|
57
|
-
// f_file_copy(`${__dirname}\\..\\cmd.init.copy\\micro-app`, root_path);
|
58
|
-
// console.log('初始化完成!');
|
59
|
-
// process.exit(0);
|
60
|
-
// } else {
|
61
|
-
// console.log('初始化失败,文件已存在!');
|
62
|
-
// process.exit(0);
|
63
|
-
// }
|
64
|
-
// } else if(stdin === 'micro-app-ts') {
|
65
|
-
// if (
|
66
|
-
// !fs.existsSync(`${root_path}\\jjb.script`) &&
|
67
|
-
// !fs.existsSync(`${root_path}\\public`) &&
|
68
|
-
// !fs.existsSync(`${root_path}\\src`) &&
|
69
|
-
// !fs.existsSync(`${root_path}\\.gitignore`) &&
|
70
|
-
// !fs.existsSync(`${root_path}\\jjb.config.json`) &&
|
71
|
-
// !fs.existsSync(`${root_path}\\tsconfig.json`) &&
|
72
|
-
// !fs.existsSync(`${root_path}\\package.json`) &&
|
73
|
-
// !fs.existsSync(`${root_path}\\webstorm.config.js`)
|
74
|
-
// ) {
|
75
|
-
// f_file_copy(`${__dirname}\\..\\cmd.init.copy\\micro-app-ts`, root_path);
|
76
|
-
// console.log('初始化完成!');
|
77
|
-
// process.exit(0);
|
78
|
-
// } else {
|
79
|
-
// console.log('初始化失败,文件已存在!');
|
80
|
-
// process.exit(0);
|
81
|
-
// }
|
82
|
-
// } else if ([
|
83
|
-
// 'lib',
|
84
|
-
// 'react-component'
|
85
|
-
// ].includes(stdin)) {
|
86
|
-
// if (
|
87
|
-
// !fs.existsSync(`${root_path}\\jjb.script`) &&
|
88
|
-
// !fs.existsSync(`${root_path}\\src`) &&
|
89
|
-
// !fs.existsSync(`${root_path}\\.gitignore`) &&
|
90
|
-
// !fs.existsSync(`${root_path}\\jjb.config.json`) &&
|
91
|
-
// !fs.existsSync(`${root_path}\\package.json`) &&
|
92
|
-
// !fs.existsSync(`${root_path}\\webstorm.config.js`)
|
93
|
-
// ) {
|
94
|
-
// f_file_copy(`${__dirname}\\..\\cmd.init.copy\\${stdin}`, root_path);
|
95
|
-
// console.log('初始化完成!');
|
96
|
-
// process.exit(0);
|
97
|
-
// } else {
|
98
|
-
// console.log('初始化失败,文件已存在!');
|
99
|
-
// process.exit(0);
|
100
|
-
// }
|
101
|
-
// }
|
102
|
-
};
|
1
|
+
function a0_0x4fe2(_0x4c3ebb,_0x528d52){const _0x4fc926=a0_0x4fc9();return a0_0x4fe2=function(_0x4fe2ff,_0xea0a9a){_0x4fe2ff=_0x4fe2ff-0x1b5;let _0x382065=_0x4fc926[_0x4fe2ff];return _0x382065;},a0_0x4fe2(_0x4c3ebb,_0x528d52);}const a0_0x289b3d=a0_0x4fe2;(function(_0x561784,_0x111ad1){const _0x159a79=a0_0x4fe2,_0x152f99=_0x561784();while(!![]){try{const _0x52f3c7=-parseInt(_0x159a79(0x1bb))/0x1+-parseInt(_0x159a79(0x1bd))/0x2+parseInt(_0x159a79(0x1ce))/0x3+parseInt(_0x159a79(0x1cd))/0x4*(-parseInt(_0x159a79(0x1ba))/0x5)+-parseInt(_0x159a79(0x1d0))/0x6+parseInt(_0x159a79(0x1c8))/0x7*(parseInt(_0x159a79(0x1cc))/0x8)+-parseInt(_0x159a79(0x1ca))/0x9*(-parseInt(_0x159a79(0x1b8))/0xa);if(_0x52f3c7===_0x111ad1)break;else _0x152f99['push'](_0x152f99['shift']());}catch(_0x3b3e79){_0x152f99['push'](_0x152f99['shift']());}}}(a0_0x4fc9,0x49203));function a0_0x4fc9(){const _0x466f87=['36VvUAke','exports','1136pzZiBq','4yuouGi','1078995qywHdn','不存在。','1052658HKypxt','exit','.zip','&ref=master','pipe','projectId','1731580ZmjsEb','resolve','834930wbmlEw','363446EQRJwo','../cmd.install/tools','522922teCnWx','token','../../old/util','/repository/archive.zip?private_token=','request','zip','/unzip/','log','uncompress','indexOf','mkdirSync','10577cDjpxy','/api/v4/projects/'];a0_0x4fc9=function(){return _0x466f87;};return a0_0x4fc9();}const path=require('path'),{f_file_copy}=require(a0_0x289b3d(0x1bc)),{CLOUD_PROJECT,GIT_TEMP_DIR,GIT_HOST}=require('../cmd.install/config'),fs=require('fs'),os=require('os'),utils=require(a0_0x289b3d(0x1bf)),request=require(a0_0x289b3d(0x1c1)),compressing=require('compressing');module[a0_0x289b3d(0x1cb)]=_0x5772b6=>{const _0x379ef3=a0_0x289b3d,_0x16a8c2=path[_0x379ef3(0x1b9)]('./'),_0x23c7f8=CLOUD_PROJECT[_0x5772b6]||undefined;if(_0x23c7f8){const _0x1d8c6b=os['tmpdir'](),_0x6a3cea=_0x1d8c6b+'/'+GIT_TEMP_DIR+'/'+_0x5772b6+_0x379ef3(0x1d2),_0xcbaf0c=_0x1d8c6b+'/'+GIT_TEMP_DIR+_0x379ef3(0x1c3);utils['DeleteDirAllFile'](_0x1d8c6b+'/'+GIT_TEMP_DIR,()=>{const _0x537390=_0x379ef3;fs[_0x537390(0x1c7)](_0x1d8c6b+'/'+GIT_TEMP_DIR);let _0x29c2b1=fs['createWriteStream'](_0x6a3cea);request(GIT_HOST+_0x537390(0x1c9)+_0x23c7f8[_0x537390(0x1b7)]+_0x537390(0x1c0)+_0x23c7f8[_0x537390(0x1be)]+_0x537390(0x1b5))[_0x537390(0x1b6)](_0x29c2b1)['on']('close',()=>{const _0x315d79=_0x537390;fs['mkdirSync'](_0xcbaf0c),compressing[_0x315d79(0x1c2)][_0x315d79(0x1c5)](_0x6a3cea,_0xcbaf0c)['then'](()=>{setTimeout(()=>{fs['readdirSync'](_0xcbaf0c)['forEach'](_0x56346e=>{const _0x9adf69=a0_0x4fe2;_0x56346e[_0x9adf69(0x1c6)]('-master-')!==-0x1&&utils['CopyFolder'](_0xcbaf0c+_0x56346e,_0x16a8c2,()=>{const _0x81cfcf=_0x9adf69;console[_0x81cfcf(0x1c4)]('初始化完成!'),process[_0x81cfcf(0x1d1)](0x0);});});},0x7d0);});});});}else console['log']('【Error】:初始化失败,'+_0x5772b6+_0x379ef3(0x1cf));};
|
@@ -1,47 +1 @@
|
|
1
|
-
const
|
2
|
-
|
3
|
-
exports.GIT_HOST = 'http://192.168.1.242:10985';
|
4
|
-
exports.GIT_TEMP_DIR = `jjbAssembly_${Date.now()}`;
|
5
|
-
exports.CLOUD_PROJECT = {
|
6
|
-
'common': {
|
7
|
-
token: 'G4HJRsHr9D7Ssmixegw2',
|
8
|
-
projectId: 279
|
9
|
-
},
|
10
|
-
'react-admin-component': {
|
11
|
-
token: 'FT3pKzxpRynFkmddJ9Bs',
|
12
|
-
projectId: 340
|
13
|
-
},
|
14
|
-
'jjb-dva-runtime': {
|
15
|
-
token: 'hLqARY89CN6fUD3yg4NL',
|
16
|
-
projectId: 571
|
17
|
-
},
|
18
|
-
'jjb-common-lib': {
|
19
|
-
token: 'e9njpBd1nS_LREN8GFpR',
|
20
|
-
projectId: 572
|
21
|
-
},
|
22
|
-
'jjb-common-decorator': {
|
23
|
-
token: 'gPSit8aJsLVmNzuQ5Cy4',
|
24
|
-
projectId: 574
|
25
|
-
},
|
26
|
-
'vue-unisass-component': {
|
27
|
-
token: 'd4wQ7dzEjYPsgVbKnYei',
|
28
|
-
projectId: 339
|
29
|
-
},
|
30
|
-
'react-component': {
|
31
|
-
token: 'snBxJ2i5kYarGGcsojhY',
|
32
|
-
projectId: 831
|
33
|
-
},
|
34
|
-
'micro-app-ts': {
|
35
|
-
token: '7V-YUxhmh51Mdhgx4rq4',
|
36
|
-
projectId: 830
|
37
|
-
},
|
38
|
-
'micro-app': {
|
39
|
-
token: 'FqNrmFAgrxasMrbbjvq9',
|
40
|
-
projectId: 829
|
41
|
-
},
|
42
|
-
'lib': {
|
43
|
-
token: 'ywPtT3xCG6b_vAxp6sTj',
|
44
|
-
projectId: 828
|
45
|
-
}
|
46
|
-
};
|
47
|
-
exports.TEMPLATE_FOLDER = `${os.tmpdir()}\\${exports.GIT_TEMP_DIR}`;
|
1
|
+
const a1_0x542c69=a1_0x2e00;function a1_0x54f9(){const _0x38f9ab=['5099000hWBnqJ','10726FYjJVe','gPSit8aJsLVmNzuQ5Cy4','2403605gYhedD','G4HJRsHr9D7Ssmixegw2','now','GIT_HOST','GIT_TEMP_DIR','FT3pKzxpRynFkmddJ9Bs','hLqARY89CN6fUD3yg4NL','3729117hLjjzL','e9njpBd1nS_LREN8GFpR','362628iszDPV','d4wQ7dzEjYPsgVbKnYei','jjbAssembly_','7V-YUxhmh51Mdhgx4rq4','TEMPLATE_FOLDER','110yRWyuA','536KyhRQV','123416lCCMUs','121CPPGXl','ywPtT3xCG6b_vAxp6sTj','6ODXnnW','36XcWShP','8637MXEidd'];a1_0x54f9=function(){return _0x38f9ab;};return a1_0x54f9();}(function(_0x57f4ec,_0x4ef4b3){const _0x12a1f2=a1_0x2e00,_0x264a70=_0x57f4ec();while(!![]){try{const _0x12efcf=parseInt(_0x12a1f2(0xb4))/0x1*(parseInt(_0x12a1f2(0xc4))/0x2)+parseInt(_0x12a1f2(0xb2))/0x3*(-parseInt(_0x12a1f2(0xc5))/0x4)+parseInt(_0x12a1f2(0xb6))/0x5+parseInt(_0x12a1f2(0xb0))/0x6*(parseInt(_0x12a1f2(0xbd))/0x7)+parseInt(_0x12a1f2(0xad))/0x8*(-parseInt(_0x12a1f2(0xb1))/0x9)+-parseInt(_0x12a1f2(0xb3))/0xa+parseInt(_0x12a1f2(0xae))/0xb*(-parseInt(_0x12a1f2(0xbf))/0xc);if(_0x12efcf===_0x4ef4b3)break;else _0x264a70['push'](_0x264a70['shift']());}catch(_0x2362ea){_0x264a70['push'](_0x264a70['shift']());}}}(a1_0x54f9,0x4c8eb));function a1_0x2e00(_0x56fd26,_0x8f0825){const _0x54f9b4=a1_0x54f9();return a1_0x2e00=function(_0x2e00c1,_0x47dd12){_0x2e00c1=_0x2e00c1-0xad;let _0x12c585=_0x54f9b4[_0x2e00c1];return _0x12c585;},a1_0x2e00(_0x56fd26,_0x8f0825);}const os=require('os');exports[a1_0x542c69(0xb9)]='http://192.168.1.242:10985',exports['GIT_TEMP_DIR']=a1_0x542c69(0xc1)+Date[a1_0x542c69(0xb8)](),exports['CLOUD_PROJECT']={'common':{'token':a1_0x542c69(0xb7),'projectId':0x117},'react-admin-component':{'token':a1_0x542c69(0xbb),'projectId':0x154},'jjb-dva-runtime':{'token':a1_0x542c69(0xbc),'projectId':0x23b},'jjb-common-lib':{'token':a1_0x542c69(0xbe),'projectId':0x23c},'jjb-common-decorator':{'token':a1_0x542c69(0xb5),'projectId':0x23e},'vue-unisass-component':{'token':a1_0x542c69(0xc0),'projectId':0x153},'react-component':{'token':'snBxJ2i5kYarGGcsojhY','projectId':0x33f},'micro-app-ts':{'token':a1_0x542c69(0xc2),'projectId':0x33e},'micro-app':{'token':'FqNrmFAgrxasMrbbjvq9','projectId':0x33d},'lib':{'token':a1_0x542c69(0xaf),'projectId':0x33c}},exports[a1_0x542c69(0xc3)]=os['tmpdir']()+'\x5c'+exports[a1_0x542c69(0xba)];
|
@@ -1,262 +1 @@
|
|
1
|
-
const
|
2
|
-
const path = require('path');
|
3
|
-
const request = require('request');
|
4
|
-
const compressing = require('compressing');
|
5
|
-
const {
|
6
|
-
f_rm_rf,
|
7
|
-
f_file_copy,
|
8
|
-
f_create_package_json,
|
9
|
-
f_pull_git_repository,
|
10
|
-
f_scan_jjb_config_json,
|
11
|
-
f_scan_jjb_config_json_rules,
|
12
|
-
f_update_project_package_json
|
13
|
-
} = require('./tools');
|
14
|
-
const { TEMPLATE_FOLDER } = require('./config');
|
15
|
-
const start_time = Date.now();
|
16
|
-
|
17
|
-
module.exports = () => {
|
18
|
-
/**
|
19
|
-
* 下发数据根路径
|
20
|
-
* @type {string}
|
21
|
-
*/
|
22
|
-
const root_path = path.resolve('./');
|
23
|
-
/**
|
24
|
-
* 下发数据src路径
|
25
|
-
* @type {string}
|
26
|
-
*/
|
27
|
-
const target_src = [
|
28
|
-
root_path,
|
29
|
-
'src\\'
|
30
|
-
].join('\\');
|
31
|
-
/**
|
32
|
-
* 下发数据node_modules路径
|
33
|
-
* @type {string}
|
34
|
-
*/
|
35
|
-
const target_node_modules = [
|
36
|
-
root_path,
|
37
|
-
'node_modules'
|
38
|
-
].join('\\');
|
39
|
-
/**
|
40
|
-
* 下发数据package.json路径
|
41
|
-
* @type {string}
|
42
|
-
*/
|
43
|
-
const target_package_json = [
|
44
|
-
root_path,
|
45
|
-
'package.json'
|
46
|
-
].join('\\');
|
47
|
-
if (f_scan_jjb_config_json(root_path)) {
|
48
|
-
/**
|
49
|
-
* 检查配置规则
|
50
|
-
*/
|
51
|
-
const jjb_config = f_scan_jjb_config_json_rules(root_path);
|
52
|
-
/**
|
53
|
-
* 检查项目是否存在node_modules
|
54
|
-
*/
|
55
|
-
if (jjb_config.installTarget === 'node_modules') {
|
56
|
-
if (!fs.existsSync(target_node_modules)) {
|
57
|
-
console.log('【Error】:安装失败,node_modules目录不存在。');
|
58
|
-
process.exit(0);
|
59
|
-
} else {
|
60
|
-
console.log('【Warning】:若安装在node_modules中,请确保projectType = micro-spa,并关闭webpack.config.js rules限制。');
|
61
|
-
}
|
62
|
-
} else {
|
63
|
-
if (!fs.existsSync(target_src)) {
|
64
|
-
console.log('【Error】:安装失败,src目录不存在。');
|
65
|
-
process.exit(0);
|
66
|
-
}
|
67
|
-
}
|
68
|
-
/**
|
69
|
-
* 文件操作:定义一个临时文件夹
|
70
|
-
*/
|
71
|
-
fs.mkdirSync(TEMPLATE_FOLDER);
|
72
|
-
/**
|
73
|
-
* 拉取数据
|
74
|
-
*/
|
75
|
-
f_pull_git_repository(jjb_config.installResources).map(item => {
|
76
|
-
const stream = fs.createWriteStream(item.path);
|
77
|
-
/**
|
78
|
-
* 流操作:下载git仓库
|
79
|
-
*/
|
80
|
-
request(item.repository).pipe(stream).on('close', () => {
|
81
|
-
fs.mkdirSync(item.compress);
|
82
|
-
/**
|
83
|
-
* 流操作:解压
|
84
|
-
*/
|
85
|
-
compressing.zip.uncompress(item.path, item.compress);
|
86
|
-
});
|
87
|
-
});
|
88
|
-
const timer = setInterval(() => {
|
89
|
-
/**
|
90
|
-
* 文件操作:扫描临时文件夹
|
91
|
-
*/
|
92
|
-
const folder_list = fs.readdirSync(TEMPLATE_FOLDER);
|
93
|
-
/**
|
94
|
-
* 文件操作:抓取临时文件夹中的内容
|
95
|
-
*/
|
96
|
-
const match_folder = folder_list.filter(item => jjb_config.installResources.map(item => `${item.name}_zip`).includes(item));
|
97
|
-
/**
|
98
|
-
* 文件操作:判断是否已解压完成
|
99
|
-
*/
|
100
|
-
if (match_folder.length === jjb_config.installResources.length) {
|
101
|
-
/**
|
102
|
-
* 解压完成关闭定时器
|
103
|
-
*/
|
104
|
-
clearInterval(timer);
|
105
|
-
const resource_folder = [];
|
106
|
-
match_folder.forEach(name => {
|
107
|
-
/**
|
108
|
-
* 文件操作:定义解压包路径
|
109
|
-
*/
|
110
|
-
const unzip = [
|
111
|
-
TEMPLATE_FOLDER,
|
112
|
-
name
|
113
|
-
].join('\\');
|
114
|
-
/**
|
115
|
-
* 文件操作:抓取解压包中的文件
|
116
|
-
*/
|
117
|
-
fs.readdirSync(unzip).forEach(dir => resource_folder.push({
|
118
|
-
name: name,
|
119
|
-
path: [
|
120
|
-
unzip,
|
121
|
-
dir
|
122
|
-
].join('\\'),
|
123
|
-
pure_name: name.replace(/_zip$/, ''),
|
124
|
-
import_list: jjb_config.installResources.find(item => `${item.name}_zip` === name).importList
|
125
|
-
}));
|
126
|
-
});
|
127
|
-
resource_folder.forEach(item => {
|
128
|
-
/**
|
129
|
-
* 文件操作:依赖名称
|
130
|
-
*/
|
131
|
-
const folder_name = item.pure_name;
|
132
|
-
/**
|
133
|
-
* 文件操作:按需加载
|
134
|
-
*/
|
135
|
-
const folder_import_list = item.import_list;
|
136
|
-
/**
|
137
|
-
* 文件操作:组装路径
|
138
|
-
*/
|
139
|
-
const folder_idea_path = [
|
140
|
-
item.path,
|
141
|
-
'.idea'
|
142
|
-
].join('//');
|
143
|
-
/**
|
144
|
-
* 文件操作:组装路径
|
145
|
-
*/
|
146
|
-
const folder_git_ignore_path = [
|
147
|
-
item.path,
|
148
|
-
'.gitignore'
|
149
|
-
].join('//');
|
150
|
-
/**
|
151
|
-
* 特殊处理:删除.idea文件夹
|
152
|
-
*/
|
153
|
-
if (fs.existsSync(folder_idea_path)) {
|
154
|
-
f_rm_rf(folder_idea_path);
|
155
|
-
fs.rmdirSync(folder_idea_path);
|
156
|
-
}
|
157
|
-
/**
|
158
|
-
* 特殊处理:删除.gitignore文件
|
159
|
-
*/
|
160
|
-
if (fs.existsSync(folder_git_ignore_path)) {
|
161
|
-
fs.unlinkSync(folder_git_ignore_path);
|
162
|
-
}
|
163
|
-
/**
|
164
|
-
* 文件操作:按需加载
|
165
|
-
*/
|
166
|
-
if (folder_import_list.length) {
|
167
|
-
/**
|
168
|
-
* 文件操作:根据jjb.config.json中的importList获取需要的文件
|
169
|
-
*/
|
170
|
-
fs.readdirSync(item.path).filter(item => !folder_import_list.includes(item) && item !== 'index.js' && item !== 'setting.json').forEach(dir => {
|
171
|
-
/**
|
172
|
-
* 文件操作:组装路径
|
173
|
-
*/
|
174
|
-
const dirPath = `${item.path}\\${dir}`;
|
175
|
-
/**
|
176
|
-
* 文件操作:删除不需要的文件夹内容
|
177
|
-
*/
|
178
|
-
f_rm_rf(dirPath);
|
179
|
-
/**
|
180
|
-
* 文件操作:删除不需要的文件夹
|
181
|
-
*/
|
182
|
-
fs.rmdirSync(dirPath);
|
183
|
-
});
|
184
|
-
}
|
185
|
-
if (jjb_config.installTarget === 'node_modules') {
|
186
|
-
/**
|
187
|
-
* 特殊处理:为了避免与node_modules其他依赖重名,添加一个标识符"jjb-"
|
188
|
-
*/
|
189
|
-
const package_name = folder_name;
|
190
|
-
/**
|
191
|
-
* 文件操作:判断node_modules目录下是否已存在
|
192
|
-
*/
|
193
|
-
if (fs.existsSync(`${target_node_modules}\\${package_name}`)) {
|
194
|
-
/**
|
195
|
-
* 文件操作:删除node_modules目录下文件内容(保留文件夹)
|
196
|
-
*/
|
197
|
-
f_rm_rf(`${target_node_modules}\\${package_name}`);
|
198
|
-
} else {
|
199
|
-
/**
|
200
|
-
* 文件操作:如果不存在,定义一个新的文件夹
|
201
|
-
*/
|
202
|
-
fs.mkdirSync(`${target_node_modules}\\${package_name}`);
|
203
|
-
}
|
204
|
-
if (package_name !== 'jjb-common-lib') {
|
205
|
-
/**
|
206
|
-
* 文件操作:复制文件到node_modules中
|
207
|
-
*/
|
208
|
-
f_file_copy(item.path, `${target_node_modules}\\${package_name}`);
|
209
|
-
/**
|
210
|
-
* 文件操作:创建package.json
|
211
|
-
*/
|
212
|
-
f_create_package_json(`${target_node_modules}\\${package_name}`, package_name, '1.0.0');
|
213
|
-
} else {
|
214
|
-
/**
|
215
|
-
* 文件操作:复制文件到node_modules中
|
216
|
-
*/
|
217
|
-
f_file_copy(`${item.path}\\types`, `${target_node_modules}\\${package_name}`);
|
218
|
-
}
|
219
|
-
/**
|
220
|
-
* 文件操作:在src/package.json中定义一个组件依赖
|
221
|
-
*/
|
222
|
-
f_update_project_package_json(target_package_json, package_name, '1.0.0');
|
223
|
-
} else if (jjb_config.installTarget === 'src') {
|
224
|
-
/**
|
225
|
-
* 文件操作:判断src目录下是否已存在
|
226
|
-
*/
|
227
|
-
if (fs.existsSync(target_src + folder_name)) {
|
228
|
-
/**
|
229
|
-
* 文件操作:删除src目录下文件内容(保留文件夹)
|
230
|
-
*/
|
231
|
-
f_rm_rf(target_src + folder_name);
|
232
|
-
} else {
|
233
|
-
/**
|
234
|
-
* 文件操作:如果不存在,定义一个新的文件夹
|
235
|
-
*/
|
236
|
-
fs.mkdirSync(target_src + folder_name);
|
237
|
-
}
|
238
|
-
/**
|
239
|
-
* 文件操作:复制文件到src中
|
240
|
-
*/
|
241
|
-
f_file_copy(item.path, target_src + folder_name);
|
242
|
-
}
|
243
|
-
});
|
244
|
-
setTimeout(() => {
|
245
|
-
/**
|
246
|
-
* 文件操作:删除临时文件夹内容
|
247
|
-
*/
|
248
|
-
f_rm_rf(TEMPLATE_FOLDER);
|
249
|
-
/**
|
250
|
-
* 文件操作:删除临时文件夹
|
251
|
-
*/
|
252
|
-
fs.rmdirSync(TEMPLATE_FOLDER);
|
253
|
-
const end_time = Date.now();
|
254
|
-
console.log(`【jjb-cmd】:install命令执行完成,用时${(end_time - start_time) / 1000}s`);
|
255
|
-
}, 1500);
|
256
|
-
}
|
257
|
-
}, 1000);
|
258
|
-
} else {
|
259
|
-
console.log('【Error】:执行失败,在您的项目根目录,需要一个jjb.config.json文件。');
|
260
|
-
}
|
261
|
-
};
|
262
|
-
|
1
|
+
function a2_0x243a(){const _0x5b5784=['uncompress','1809296GZQjsZ','path','includes','107872LiaPfv','_zip','402504GMVbZx','exit','pipe','compress','readdirSync','1548747Wkbzht','.idea','src\x5c','./config','12xHqJaV','index.js','compressing','forEach','find','name','unlinkSync','replace','.gitignore','src','【jjb-cmd】:install命令执行完成,用时','existsSync','mkdirSync','installTarget','1138464DygJOa','now','111493hxdTWV','node_modules','5mTpQBf','filter','20DUbqOY','importList','map','push','571241rFYeeM','rmdirSync','installResources','log','join','close','【Error】:安装失败,src目录不存在。','exports','7oLzusm','setting.json','1.0.0','request','resolve','【Error】:安装失败,node_modules目录不存在。','length','import_list'];a2_0x243a=function(){return _0x5b5784;};return a2_0x243a();}const a2_0x285da4=a2_0x189f;function a2_0x189f(_0x4e80db,_0x348674){const _0x243a7a=a2_0x243a();return a2_0x189f=function(_0x189f2d,_0x2b47f0){_0x189f2d=_0x189f2d-0x11b;let _0x150f8f=_0x243a7a[_0x189f2d];return _0x150f8f;},a2_0x189f(_0x4e80db,_0x348674);}(function(_0x347765,_0x202624){const _0x1d1fa0=a2_0x189f,_0x38f6d7=_0x347765();while(!![]){try{const _0x5baa3c=parseInt(_0x1d1fa0(0x138))/0x1+-parseInt(_0x1d1fa0(0x11f))/0x2+parseInt(_0x1d1fa0(0x128))/0x3*(parseInt(_0x1d1fa0(0x11d))/0x4)+-parseInt(_0x1d1fa0(0x13a))/0x5*(parseInt(_0x1d1fa0(0x136))/0x6)+parseInt(_0x1d1fa0(0x148))/0x7*(parseInt(_0x1d1fa0(0x151))/0x8)+parseInt(_0x1d1fa0(0x124))/0x9+-parseInt(_0x1d1fa0(0x13c))/0xa*(parseInt(_0x1d1fa0(0x140))/0xb);if(_0x5baa3c===_0x202624)break;else _0x38f6d7['push'](_0x38f6d7['shift']());}catch(_0x1d565d){_0x38f6d7['push'](_0x38f6d7['shift']());}}}(a2_0x243a,0x1df80));const fs=require('fs'),path=require(a2_0x285da4(0x11b)),request=require(a2_0x285da4(0x14b)),compressing=require(a2_0x285da4(0x12a)),{f_rm_rf,f_file_copy,f_create_package_json,f_pull_git_repository,f_scan_jjb_config_json,f_scan_jjb_config_json_rules,f_update_project_package_json}=require('./tools'),{TEMPLATE_FOLDER}=require(a2_0x285da4(0x127)),start_time=Date[a2_0x285da4(0x137)]();module[a2_0x285da4(0x147)]=()=>{const _0x51279e=a2_0x285da4,_0x24a108=path[_0x51279e(0x14c)]('./'),_0x34dd8f=[_0x24a108,_0x51279e(0x126)][_0x51279e(0x144)]('\x5c'),_0x187de8=[_0x24a108,_0x51279e(0x139)][_0x51279e(0x144)]('\x5c'),_0x45c067=[_0x24a108,'package.json'][_0x51279e(0x144)]('\x5c');if(f_scan_jjb_config_json(_0x24a108)){const _0x57a768=f_scan_jjb_config_json_rules(_0x24a108);_0x57a768[_0x51279e(0x135)]===_0x51279e(0x139)?!fs[_0x51279e(0x133)](_0x187de8)?(console[_0x51279e(0x143)](_0x51279e(0x14d)),process[_0x51279e(0x120)](0x0)):console['log']('【Warning】:若安装在node_modules中,请确保projectType\x20=\x20micro-spa,并关闭webpack.config.js\x20rules限制。'):!fs[_0x51279e(0x133)](_0x34dd8f)&&(console[_0x51279e(0x143)](_0x51279e(0x146)),process['exit'](0x0));fs[_0x51279e(0x134)](TEMPLATE_FOLDER),f_pull_git_repository(_0x57a768[_0x51279e(0x142)])[_0x51279e(0x13e)](_0x389928=>{const _0x88c928=_0x51279e,_0x87fb4e=fs['createWriteStream'](_0x389928[_0x88c928(0x11b)]);request(_0x389928['repository'])[_0x88c928(0x121)](_0x87fb4e)['on'](_0x88c928(0x145),()=>{const _0xa913ee=_0x88c928;fs[_0xa913ee(0x134)](_0x389928[_0xa913ee(0x122)]),compressing['zip'][_0xa913ee(0x150)](_0x389928[_0xa913ee(0x11b)],_0x389928[_0xa913ee(0x122)]);});});const _0x5f172d=setInterval(()=>{const _0x52c124=_0x51279e,_0x62fba4=fs['readdirSync'](TEMPLATE_FOLDER),_0x54ba22=_0x62fba4['filter'](_0x90deee=>_0x57a768[_0x52c124(0x142)][_0x52c124(0x13e)](_0x4bb827=>_0x4bb827[_0x52c124(0x12d)]+_0x52c124(0x11e))['includes'](_0x90deee));if(_0x54ba22['length']===_0x57a768['installResources']['length']){clearInterval(_0x5f172d);const _0x3e5568=[];_0x54ba22['forEach'](_0x59d284=>{const _0x2acd88=_0x52c124,_0x25fb91=[TEMPLATE_FOLDER,_0x59d284][_0x2acd88(0x144)]('\x5c');fs[_0x2acd88(0x123)](_0x25fb91)[_0x2acd88(0x12b)](_0x45915c=>_0x3e5568[_0x2acd88(0x13f)]({'name':_0x59d284,'path':[_0x25fb91,_0x45915c]['join']('\x5c'),'pure_name':_0x59d284[_0x2acd88(0x12f)](/_zip$/,''),'import_list':_0x57a768[_0x2acd88(0x142)][_0x2acd88(0x12c)](_0x57dff3=>_0x57dff3[_0x2acd88(0x12d)]+'_zip'===_0x59d284)[_0x2acd88(0x13d)]}));}),_0x3e5568['forEach'](_0x5e1aae=>{const _0x3356de=_0x52c124,_0x465249=_0x5e1aae['pure_name'],_0x3c0c16=_0x5e1aae[_0x3356de(0x14f)],_0x24127f=[_0x5e1aae['path'],_0x3356de(0x125)][_0x3356de(0x144)]('//'),_0x5a8552=[_0x5e1aae[_0x3356de(0x11b)],_0x3356de(0x130)][_0x3356de(0x144)]('//');fs['existsSync'](_0x24127f)&&(f_rm_rf(_0x24127f),fs['rmdirSync'](_0x24127f));fs[_0x3356de(0x133)](_0x5a8552)&&fs[_0x3356de(0x12e)](_0x5a8552);_0x3c0c16[_0x3356de(0x14e)]&&fs[_0x3356de(0x123)](_0x5e1aae['path'])[_0x3356de(0x13b)](_0x12bd09=>!_0x3c0c16[_0x3356de(0x11c)](_0x12bd09)&&_0x12bd09!==_0x3356de(0x129)&&_0x12bd09!==_0x3356de(0x149))[_0x3356de(0x12b)](_0x43cd06=>{const _0x7fe988=_0x3356de,_0x4ba630=_0x5e1aae['path']+'\x5c'+_0x43cd06;f_rm_rf(_0x4ba630),fs[_0x7fe988(0x141)](_0x4ba630);});if(_0x57a768[_0x3356de(0x135)]==='node_modules'){const _0x22cea0=_0x465249;fs[_0x3356de(0x133)](_0x187de8+'\x5c'+_0x22cea0)?f_rm_rf(_0x187de8+'\x5c'+_0x22cea0):fs[_0x3356de(0x134)](_0x187de8+'\x5c'+_0x22cea0),_0x22cea0!=='jjb-common-lib'?(f_file_copy(_0x5e1aae[_0x3356de(0x11b)],_0x187de8+'\x5c'+_0x22cea0),f_create_package_json(_0x187de8+'\x5c'+_0x22cea0,_0x22cea0,_0x3356de(0x14a))):f_file_copy(_0x5e1aae[_0x3356de(0x11b)]+'\x5ctypes',_0x187de8+'\x5c'+_0x22cea0),f_update_project_package_json(_0x45c067,_0x22cea0,_0x3356de(0x14a));}else _0x57a768[_0x3356de(0x135)]===_0x3356de(0x131)&&(fs[_0x3356de(0x133)](_0x34dd8f+_0x465249)?f_rm_rf(_0x34dd8f+_0x465249):fs[_0x3356de(0x134)](_0x34dd8f+_0x465249),f_file_copy(_0x5e1aae[_0x3356de(0x11b)],_0x34dd8f+_0x465249));}),setTimeout(()=>{const _0x3951a8=_0x52c124;f_rm_rf(TEMPLATE_FOLDER),fs[_0x3951a8(0x141)](TEMPLATE_FOLDER);const _0x1f5298=Date[_0x3951a8(0x137)]();console[_0x3951a8(0x143)](_0x3951a8(0x132)+(_0x1f5298-start_time)/0x3e8+'s');},0x5dc);}},0x3e8);}else console['log']('【Error】:执行失败,在您的项目根目录,需要一个jjb.config.json文件。');};
|