jjb-cmd 2.2.2 → 2.2.3

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 CHANGED
@@ -1,6 +1,10 @@
1
1
  <h1>重庆市建教帮科技有限公司-前端脚手架</h1>
2
2
  <h3>更新日志:</h3>
3
3
  <ul>
4
+ <li>
5
+ <p>2.2.3</p>
6
+ <div>修复已知问题</div>
7
+ </li>
4
8
  <li>
5
9
  <p>2.2.2</p>
6
10
  <div>修复已知问题</div>
package/build.js ADDED
@@ -0,0 +1,15 @@
1
+ const child_process = require('child_process');
2
+ const utils = require("./src/old/util");
3
+
4
+ child_process.execSync(`npx javascript-obfuscator src --output publish/src --config obf.config.json`, (error, stdout) => {});
5
+ console.log("obf Done!");
6
+ utils.CopyFolder('./bin', './publish/bin', () => {
7
+ console.log("bin Folder Done!");
8
+ utils.CopyFile('./package.json', './publish/package.json', () => {
9
+ utils.CopyFile('./README.md', './publish/README.md', () => {
10
+ utils.CopyFile('./LICENSE', './publish/LICENSE', () => {
11
+ console.log("ALL Done !");
12
+ });
13
+ });
14
+ });
15
+ })
@@ -0,0 +1,3 @@
1
+ {
2
+ "compact": true
3
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "jjb-cmd",
3
3
  "use": "no",
4
4
  "env": "prod",
5
- "version": "2.2.2",
5
+ "version": "2.2.3",
6
6
  "description": "jjb脚手架工具",
7
7
  "main": "index.js",
8
8
  "scripts": {
@@ -1 +1,26 @@
1
- function a0_0x4cee(_0x5eb69b,_0x2cabda){const _0x5c6c81=a0_0x5c6c();return a0_0x4cee=function(_0x4ceed3,_0x24936f){_0x4ceed3=_0x4ceed3-0xe7;let _0x3edfe9=_0x5c6c81[_0x4ceed3];return _0x3edfe9;},a0_0x4cee(_0x5eb69b,_0x2cabda);}const a0_0x50409a=a0_0x4cee;(function(_0x442acf,_0x4a4202){const _0xd0bd4b=a0_0x4cee,_0x30184c=_0x442acf();while(!![]){try{const _0x580584=parseInt(_0xd0bd4b(0xfd))/0x1*(parseInt(_0xd0bd4b(0xff))/0x2)+-parseInt(_0xd0bd4b(0x103))/0x3*(-parseInt(_0xd0bd4b(0xfa))/0x4)+-parseInt(_0xd0bd4b(0xf1))/0x5+-parseInt(_0xd0bd4b(0xf8))/0x6*(parseInt(_0xd0bd4b(0x101))/0x7)+parseInt(_0xd0bd4b(0xe8))/0x8*(parseInt(_0xd0bd4b(0xf3))/0x9)+parseInt(_0xd0bd4b(0x100))/0xa*(parseInt(_0xd0bd4b(0xf2))/0xb)+-parseInt(_0xd0bd4b(0xfb))/0xc*(parseInt(_0xd0bd4b(0xe7))/0xd);if(_0x580584===_0x4a4202)break;else _0x30184c['push'](_0x30184c['shift']());}catch(_0x37b9be){_0x30184c['push'](_0x30184c['shift']());}}}(a0_0x5c6c,0x9c272));const axios=require(a0_0x50409a(0xf5)),fs=require('fs'),path=require(a0_0x50409a(0xed)),{getApiHost}=require(a0_0x50409a(0xf7));function a0_0x5c6c(){const _0x5b789c=['2ZKEcBI','20yaaIal','55111TGsAsh','log','841473znCODk','3915808PSuVOK','48fSYLjS','then','post','Auth\x20NetWork\x20Fail!','unlinkSync','path','data','Auth\x20Fail!','writeFileSync','1779460FmXdOm','3422309SiSBNl','1357578RITbWS','existsSync','axios','join','../cmd.install/config','444xinjdn','Auth\x20Success!','4xuJzcA','24VGEtFx','../../../.auth','372747ErztYa','/api/auth'];a0_0x5c6c=function(){return _0x5b789c;};return a0_0x5c6c();}module['exports']=_0x5e7d6d=>{const _0x4ad1bf=a0_0x50409a;console[_0x4ad1bf(0x102)](_0x5e7d6d);const [_0x39f5d1,_0x3fe364]=_0x5e7d6d;axios[_0x4ad1bf(0xea)](getApiHost()+_0x4ad1bf(0xfe),{'username':_0x39f5d1,'password':_0x3fe364})[_0x4ad1bf(0xe9)](_0x410417=>{const _0x1ab5a8=_0x4ad1bf,_0xfeb8a0=path[_0x1ab5a8(0xf6)](__dirname,_0x1ab5a8(0xfc));_0x410417[_0x1ab5a8(0xee)]['status']?(console['log'](_0x1ab5a8(0xf9)),fs[_0x1ab5a8(0xf0)](_0xfeb8a0,_0x39f5d1+'/'+_0x3fe364)):(console[_0x1ab5a8(0x102)](_0x1ab5a8(0xef)),fs[_0x1ab5a8(0xf4)](_0xfeb8a0)&&fs[_0x1ab5a8(0xec)](_0xfeb8a0));})['catch'](_0x28e268=>{const _0x3a0c48=_0x4ad1bf;console['log'](_0x3a0c48(0xeb));});};
1
+ const axios = require("axios");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const { getApiHost } = require("../cmd.install/config");
5
+
6
+ module.exports = args => {
7
+ console.log(args)
8
+ const [username, password] = args;
9
+ axios.post(`${getApiHost()}/api/auth`, {
10
+ username,
11
+ password
12
+ }).then(res => {
13
+ const authPath = path.join(__dirname, '../../../.auth');
14
+ if (res.data.status) {
15
+ console.log('Auth Success!');
16
+ fs.writeFileSync(authPath, `${username}/${password}`);
17
+ } else {
18
+ console.log('Auth Fail!');
19
+ if (fs.existsSync(authPath)) {
20
+ fs.unlinkSync(authPath);
21
+ }
22
+ }
23
+ }).catch(e => {
24
+ console.log('Auth NetWork Fail!');
25
+ });
26
+ };
@@ -1 +1,116 @@
1
- const a1_0x143cf7=a1_0x22fb;(function(_0x2afc5,_0x2e4874){const _0x3c670f=a1_0x22fb,_0x262399=_0x2afc5();while(!![]){try{const _0x3a2cf5=parseInt(_0x3c670f(0x19f))/0x1*(parseInt(_0x3c670f(0x193))/0x2)+-parseInt(_0x3c670f(0x1b0))/0x3+parseInt(_0x3c670f(0x18d))/0x4+parseInt(_0x3c670f(0x186))/0x5*(-parseInt(_0x3c670f(0x1a2))/0x6)+-parseInt(_0x3c670f(0x18f))/0x7+parseInt(_0x3c670f(0x1a7))/0x8+parseInt(_0x3c670f(0x185))/0x9*(parseInt(_0x3c670f(0x18e))/0xa);if(_0x3a2cf5===_0x2e4874)break;else _0x262399['push'](_0x262399['shift']());}catch(_0x3c4255){_0x262399['push'](_0x262399['shift']());}}}(a1_0x59ea,0x4dae7));const fs=require('fs'),os=require('os'),path=require('path'),request=require(a1_0x143cf7(0x19c)),utils=require(a1_0x143cf7(0x192)),compressing=require(a1_0x143cf7(0x19e)),readline=require('readline'),io=readline[a1_0x143cf7(0x19d)]({'input':process['stdin'],'output':process[a1_0x143cf7(0x18c)]}),child_process=require(a1_0x143cf7(0x198)),{CLOUD_PROJECT,GIT_TEMP_DIR,GIT_HOST}=require(a1_0x143cf7(0x184));function a1_0x22fb(_0x351ba4,_0x5b58ab){const _0x59ead7=a1_0x59ea();return a1_0x22fb=function(_0x22fba8,_0x521428){_0x22fba8=_0x22fba8-0x184;let _0x18fe3d=_0x59ead7[_0x22fba8];return _0x18fe3d;},a1_0x22fb(_0x351ba4,_0x5b58ab);}function a1_0x59ea(){const _0x195da0=['30bqKqQo','初始化完成?请选择安装方式![yarn/npm]:','安装完成,祝您愉快编码!','yarn','tmpdir','1391256oobnns','npm','CopyFolder','question','.zip','close','DeleteDirAllFile','jjb-cmd\x20install.app\x20','mkdirSync','735747aeLtbH','安装中,请耐心等待...','-master-','不存在。','zip','../cmd.install/config','6142887uzuwHq','309635HRwfaq','trim','includes','resolve','exit','pipe','stdout','1068132WjEiat','10vfqrdW','3100034toXuMf','/repository/archive.zip?private_token=','readdirSync','../../old/util','2aeZzgE','/api/v4/projects/','初始化完成!请自行使用jjb-cmd\x20install.app\x20yarn/npm安装项目!','exports','【Error】:初始化失败,','child_process','indexOf','&ref=master','log','request','createInterface','compressing','192446iwTIDy','execSync','projectId'];a1_0x59ea=function(){return _0x195da0;};return a1_0x59ea();}module[a1_0x143cf7(0x196)]=_0x3131c7=>{const _0x1abedd=a1_0x143cf7,_0x29f61f=path[_0x1abedd(0x189)]('./'),_0x2a2ac5=CLOUD_PROJECT[_0x3131c7]||undefined;if(_0x2a2ac5){const _0xf50b13=os[_0x1abedd(0x1a6)](),_0x533d24=_0xf50b13+'/'+GIT_TEMP_DIR+'/'+_0x3131c7+_0x1abedd(0x1ab),_0xe0ce3a=_0xf50b13+'/'+GIT_TEMP_DIR+'/unzip/';utils[_0x1abedd(0x1ad)](_0xf50b13+'/'+GIT_TEMP_DIR,()=>{const _0x5df157=_0x1abedd;fs[_0x5df157(0x1af)](_0xf50b13+'/'+GIT_TEMP_DIR);let _0x34d4d4=fs['createWriteStream'](_0x533d24);request(GIT_HOST+_0x5df157(0x194)+_0x2a2ac5[_0x5df157(0x1a1)]+_0x5df157(0x190)+_0x2a2ac5['token']+_0x5df157(0x19a))[_0x5df157(0x18b)](_0x34d4d4)['on'](_0x5df157(0x1ac),()=>{const _0xbd8906=_0x5df157;fs['mkdirSync'](_0xe0ce3a),compressing[_0xbd8906(0x1b4)]['uncompress'](_0x533d24,_0xe0ce3a)['then'](()=>{setTimeout(()=>{const _0x184891=a1_0x22fb;fs[_0x184891(0x191)](_0xe0ce3a)['forEach'](_0x58ede8=>{const _0x220f4f=_0x184891;_0x58ede8[_0x220f4f(0x199)](_0x220f4f(0x1b2))!==-0x1&&utils[_0x220f4f(0x1a9)](_0xe0ce3a+_0x58ede8,_0x29f61f,()=>{const _0x44f6a6=_0x220f4f;io[_0x44f6a6(0x1aa)](_0x44f6a6(0x1a3),function(_0x5b3782){const _0x13fb0b=_0x44f6a6;[_0x13fb0b(0x1a5),_0x13fb0b(0x1a8)][_0x13fb0b(0x188)](_0x5b3782[_0x13fb0b(0x187)]())?(console['log'](_0x13fb0b(0x1b1)),child_process[_0x13fb0b(0x1a0)](_0x13fb0b(0x1ae)+_0x5b3782['trim'](),{'cwd':_0x29f61f}),console[_0x13fb0b(0x19b)](_0x13fb0b(0x1a4)),process[_0x13fb0b(0x18a)](0x0)):(console[_0x13fb0b(0x19b)](_0x13fb0b(0x195)),process[_0x13fb0b(0x18a)](0x0));});});});},0x7d0);});});});}else console[_0x1abedd(0x19b)](_0x1abedd(0x197)+_0x3131c7+_0x1abedd(0x1b3));};
1
+ const fs = require('fs');
2
+ const os = require("os");
3
+ const path = require('path');
4
+ const request = require("request");
5
+ const utils = require("../../old/util");
6
+ const compressing = require("compressing");
7
+ const readline = require('readline');
8
+ const io = readline.createInterface({
9
+ input: process.stdin,
10
+ output: process.stdout
11
+ });
12
+ const child_process = require('child_process');
13
+ const { CLOUD_PROJECT, GIT_TEMP_DIR, GIT_HOST } = require('../cmd.install/config');
14
+
15
+ module.exports = stdin => {
16
+ /**
17
+ * 下发数据根路径
18
+ * @type {string}
19
+ */
20
+ const root_path = path.resolve('./');
21
+
22
+ const cloudObj = CLOUD_PROJECT[ stdin ] || undefined;
23
+ if (cloudObj) {
24
+ const tmpDir = os.tmpdir();
25
+ const zipPath = `${tmpDir}/${GIT_TEMP_DIR}/${stdin}.zip`;
26
+ const zipFolder = `${tmpDir}/${GIT_TEMP_DIR}/unzip/`;
27
+ utils.DeleteDirAllFile(`${tmpDir}/${GIT_TEMP_DIR}`, () => {
28
+ fs.mkdirSync(`${tmpDir}/${GIT_TEMP_DIR}`);
29
+ let stream = fs.createWriteStream(zipPath);
30
+ request(`${GIT_HOST}/api/v4/projects/${cloudObj.projectId}/repository/archive.zip?private_token=${cloudObj.token}&ref=master`).pipe(stream)
31
+ .on('close', () => {
32
+ fs.mkdirSync(zipFolder);
33
+ compressing.zip.uncompress(zipPath, zipFolder)
34
+ .then(() => {
35
+ setTimeout(() => {
36
+ fs.readdirSync(zipFolder).forEach(dirName => {
37
+ if (dirName.indexOf('-master-') !== -1) {
38
+ utils.CopyFolder(zipFolder + dirName, root_path, () => {
39
+ io.question('初始化完成?请选择安装方式![yarn/npm]:', function (answer) {
40
+ if (['yarn', 'npm'].includes(answer.trim())) {
41
+ console.log('安装中,请耐心等待...');
42
+ child_process.execSync(`jjb-cmd install.app ${answer.trim()}`, { cwd: root_path });
43
+ console.log('安装完成,祝您愉快编码!');
44
+ process.exit(0);
45
+ } else {
46
+ console.log('初始化完成!请自行使用jjb-cmd install.app yarn/npm安装项目!');
47
+ process.exit(0);
48
+ }
49
+ });
50
+ });
51
+ }
52
+ })
53
+ }, 2000);
54
+ })
55
+ });
56
+ });
57
+ } else {
58
+ console.log('【Error】:初始化失败,'+ stdin +'不存在。');
59
+ }
60
+
61
+ // if (stdin === 'micro-app') {
62
+ // if (
63
+ // !fs.existsSync(`${root_path}\\jjb.script`) &&
64
+ // !fs.existsSync(`${root_path}\\public`) &&
65
+ // !fs.existsSync(`${root_path}\\src`) &&
66
+ // !fs.existsSync(`${root_path}\\.gitignore`) &&
67
+ // !fs.existsSync(`${root_path}\\jjb.config.json`) &&
68
+ // !fs.existsSync(`${root_path}\\package.json`) &&
69
+ // !fs.existsSync(`${root_path}\\webstorm.config.js`)
70
+ // ) {
71
+ // f_file_copy(`${__dirname}\\..\\cmd.init.copy\\micro-app`, root_path);
72
+ // console.log('初始化完成!');
73
+ // process.exit(0);
74
+ // } else {
75
+ // console.log('初始化失败,文件已存在!');
76
+ // process.exit(0);
77
+ // }
78
+ // } else if(stdin === 'micro-app-ts') {
79
+ // if (
80
+ // !fs.existsSync(`${root_path}\\jjb.script`) &&
81
+ // !fs.existsSync(`${root_path}\\public`) &&
82
+ // !fs.existsSync(`${root_path}\\src`) &&
83
+ // !fs.existsSync(`${root_path}\\.gitignore`) &&
84
+ // !fs.existsSync(`${root_path}\\jjb.config.json`) &&
85
+ // !fs.existsSync(`${root_path}\\tsconfig.json`) &&
86
+ // !fs.existsSync(`${root_path}\\package.json`) &&
87
+ // !fs.existsSync(`${root_path}\\webstorm.config.js`)
88
+ // ) {
89
+ // f_file_copy(`${__dirname}\\..\\cmd.init.copy\\micro-app-ts`, root_path);
90
+ // console.log('初始化完成!');
91
+ // process.exit(0);
92
+ // } else {
93
+ // console.log('初始化失败,文件已存在!');
94
+ // process.exit(0);
95
+ // }
96
+ // } else if ([
97
+ // 'lib',
98
+ // 'react-component'
99
+ // ].includes(stdin)) {
100
+ // if (
101
+ // !fs.existsSync(`${root_path}\\jjb.script`) &&
102
+ // !fs.existsSync(`${root_path}\\src`) &&
103
+ // !fs.existsSync(`${root_path}\\.gitignore`) &&
104
+ // !fs.existsSync(`${root_path}\\jjb.config.json`) &&
105
+ // !fs.existsSync(`${root_path}\\package.json`) &&
106
+ // !fs.existsSync(`${root_path}\\webstorm.config.js`)
107
+ // ) {
108
+ // f_file_copy(`${__dirname}\\..\\cmd.init.copy\\${stdin}`, root_path);
109
+ // console.log('初始化完成!');
110
+ // process.exit(0);
111
+ // } else {
112
+ // console.log('初始化失败,文件已存在!');
113
+ // process.exit(0);
114
+ // }
115
+ // }
116
+ };
@@ -1 +1,70 @@
1
- const a2_0x4d7f13=a2_0x46db;(function(_0x3979bf,_0x4429e1){const _0x26a43f=a2_0x46db,_0x359734=_0x3979bf();while(!![]){try{const _0x4b4fea=-parseInt(_0x26a43f(0x115))/0x1*(-parseInt(_0x26a43f(0x12d))/0x2)+-parseInt(_0x26a43f(0x135))/0x3*(parseInt(_0x26a43f(0x123))/0x4)+parseInt(_0x26a43f(0x129))/0x5*(-parseInt(_0x26a43f(0x113))/0x6)+parseInt(_0x26a43f(0x128))/0x7*(-parseInt(_0x26a43f(0x136))/0x8)+parseInt(_0x26a43f(0x132))/0x9*(parseInt(_0x26a43f(0x124))/0xa)+parseInt(_0x26a43f(0x126))/0xb*(parseInt(_0x26a43f(0x13b))/0xc)+-parseInt(_0x26a43f(0x112))/0xd*(-parseInt(_0x26a43f(0x134))/0xe);if(_0x4b4fea===_0x4429e1)break;else _0x359734['push'](_0x359734['shift']());}catch(_0xd653be){_0x359734['push'](_0x359734['shift']());}}}(a2_0x5b1d,0xa75b3));function a2_0x5b1d(){const _0x1782e6=['tmpdir','../../../package.json','getApiHost','1457865RBGuxL','http://120.26.210.58:8089','434NSKdiA','240RGnYet','8WVpmUh','env','parse','GIT_TEMP_JAVA','ywPtT3xCG6b_vAxp6sTj','836760JPuTEn','GIT_TEMP_DIR','path','jjb-assembly-','620542vTdhzp','993138JVzGlz','GIT_JAVA_ENV_JSON','714MqfTck','readFileSync','d4wQ7dzEjYPsgVbKnYei','G4HJRsHr9D7Ssmixegw2','API_HOST_TEST','test','http://192.168.1.242:10985','GIT_HOST','API_HOST','https://cdn.cqjjb.cn/jjb-cloud-config','join','snBxJ2i5kYarGGcsojhY','CONFIG_FILE_HOST','prod','5124IuUEYS','40sCIBHN','7V-YUxhmh51Mdhgx4rq4','33xvIycU','CLOUD_PROJECT','3707249IQmvhV','40FOrNnf','toString','jjb-assembly-java','FqNrmFAgrxasMrbbjvq9','854iOxKhW','now'];a2_0x5b1d=function(){return _0x1782e6;};return a2_0x5b1d();}function a2_0x46db(_0x33934e,_0x52e0c5){const _0x5b1d38=a2_0x5b1d();return a2_0x46db=function(_0x46db7d,_0x4b2fac){_0x46db7d=_0x46db7d-0x112;let _0x2e8a95=_0x5b1d38[_0x46db7d];return _0x2e8a95;},a2_0x46db(_0x33934e,_0x52e0c5);}const os=require('os'),path=require(a2_0x4d7f13(0x13d)),fs=require('fs'),API_HOST='http://120.26.210.58:8088',API_HOST_TEST=a2_0x4d7f13(0x133);exports[a2_0x4d7f13(0x121)]=a2_0x4d7f13(0x11e),exports[a2_0x4d7f13(0x11d)]=API_HOST,exports[a2_0x4d7f13(0x119)]=API_HOST_TEST,exports[a2_0x4d7f13(0x11c)]=a2_0x4d7f13(0x11b),exports[a2_0x4d7f13(0x13c)]=a2_0x4d7f13(0x13e)+Date[a2_0x4d7f13(0x12e)](),exports[a2_0x4d7f13(0x139)]=a2_0x4d7f13(0x12b),exports[a2_0x4d7f13(0x114)]={'development':'dev','production':a2_0x4d7f13(0x122),'test':a2_0x4d7f13(0x11a)},exports[a2_0x4d7f13(0x127)]={'common':{'token':a2_0x4d7f13(0x118),'projectId':0x117},'react-admin-component':{'token':'FT3pKzxpRynFkmddJ9Bs','projectId':0x154},'jjb-dva-runtime':{'token':'hLqARY89CN6fUD3yg4NL','projectId':0x23b},'jjb-common-lib':{'token':'e9njpBd1nS_LREN8GFpR','projectId':0x23c},'jjb-common-decorator':{'token':'gPSit8aJsLVmNzuQ5Cy4','projectId':0x23e},'vue-unisass-component':{'token':a2_0x4d7f13(0x117),'projectId':0x153},'react-component':{'token':a2_0x4d7f13(0x120),'projectId':0x33f},'micro-app-ts':{'token':a2_0x4d7f13(0x125),'projectId':0x33e},'micro-app':{'token':a2_0x4d7f13(0x12c),'projectId':0x33d},'lib':{'token':a2_0x4d7f13(0x13a),'projectId':0x33c}},exports['TEMPLATE_FOLDER']=os[a2_0x4d7f13(0x12f)]()+'\x5c'+exports[a2_0x4d7f13(0x13c)],exports[a2_0x4d7f13(0x131)]=()=>{const _0x15423b=a2_0x4d7f13,_0x4f55f5=JSON[_0x15423b(0x138)](fs[_0x15423b(0x116)](path[_0x15423b(0x11f)](__dirname,_0x15423b(0x130)))[_0x15423b(0x12a)]());return _0x4f55f5[_0x15423b(0x137)]==='test'?API_HOST_TEST:API_HOST;};
1
+ const os = require('os');
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
5
+ const API_HOST = 'http://120.26.210.58:8088';
6
+ const API_HOST_TEST = 'http://120.26.210.58:8089';
7
+
8
+ exports.CONFIG_FILE_HOST = 'https://cdn.cqjjb.cn/jjb-cloud-config';
9
+ exports.API_HOST = API_HOST;
10
+ exports.API_HOST_TEST = API_HOST_TEST;
11
+ exports.GIT_HOST = 'http://192.168.1.242:10985';
12
+ exports.GIT_TEMP_DIR = `jjb-assembly-${Date.now()}`;
13
+ exports.GIT_TEMP_JAVA = `jjb-assembly-java`;
14
+ exports.GIT_JAVA_ENV_JSON = {
15
+ "development": "dev",
16
+ "production": "prod",
17
+ "test": "test"
18
+ };
19
+ exports.CLOUD_PROJECT = {
20
+ 'common': {
21
+ token: 'G4HJRsHr9D7Ssmixegw2',
22
+ projectId: 279
23
+ },
24
+ 'react-admin-component': {
25
+ token: 'FT3pKzxpRynFkmddJ9Bs',
26
+ projectId: 340
27
+ },
28
+ 'jjb-dva-runtime': {
29
+ token: 'hLqARY89CN6fUD3yg4NL',
30
+ projectId: 571
31
+ },
32
+ 'jjb-common-lib': {
33
+ token: 'e9njpBd1nS_LREN8GFpR',
34
+ projectId: 572
35
+ },
36
+ 'jjb-common-decorator': {
37
+ token: 'gPSit8aJsLVmNzuQ5Cy4',
38
+ projectId: 574
39
+ },
40
+ 'vue-unisass-component': {
41
+ token: 'd4wQ7dzEjYPsgVbKnYei',
42
+ projectId: 339
43
+ },
44
+ 'react-component': {
45
+ token: 'snBxJ2i5kYarGGcsojhY',
46
+ projectId: 831
47
+ },
48
+ 'micro-app-ts': {
49
+ token: '7V-YUxhmh51Mdhgx4rq4',
50
+ projectId: 830
51
+ },
52
+ 'micro-app': {
53
+ token: 'FqNrmFAgrxasMrbbjvq9',
54
+ projectId: 829
55
+ },
56
+ 'lib': {
57
+ token: 'ywPtT3xCG6b_vAxp6sTj',
58
+ projectId: 828
59
+ }
60
+ };
61
+ exports.TEMPLATE_FOLDER = `${os.tmpdir()}\\${exports.GIT_TEMP_DIR}`;
62
+
63
+ exports.getApiHost = () => {
64
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../../package.json')).toString());
65
+ if (packageJson.env === 'test') {
66
+ return API_HOST_TEST;
67
+ } else {
68
+ return API_HOST;
69
+ }
70
+ };
@@ -1 +1,262 @@
1
- const a3_0x1617e2=a3_0x88fc;function a3_0x471a(){const _0x4549b2=['pipe','4tiLACe','package.json','node_modules','_zip','.idea','request','rmdirSync','770232YpKPJS','compressing','push','【Error】:安装失败,node_modules目录不存在。','importList','11GHVtDs','22774776PqQzeI','compress','9639CZqWND','exit','1831030XTLSja','1.0.0','uncompress','installTarget','now','【Warning】:若安装在node_modules中,请确保projectType\x20=\x20micro-spa,并关闭webpack.config.js\x20rules限制。','4242USSZvs','forEach','7938WHKcHz','9590zkparv','import_list','includes','unlinkSync','【Error】:执行失败,在您的项目根目录,需要一个jjb.config.json文件。','readdirSync','installResources','existsSync','map','createWriteStream','find','join','filter','3115116zyZiQG','exports','resolve','.gitignore','index.js','2460GhtSZM','zip','./tools','pure_name','mkdirSync','path','length','log','【Error】:安装失败,src目录不存在。','./config','7496goqbBn','\x5ctypes'];a3_0x471a=function(){return _0x4549b2;};return a3_0x471a();}(function(_0x588092,_0x9d16e1){const _0x59f9eb=a3_0x88fc,_0x2df78d=_0x588092();while(!![]){try{const _0x8e6278=-parseInt(_0x59f9eb(0x104))/0x1+parseInt(_0x59f9eb(0x10e))/0x2+parseInt(_0x59f9eb(0xeb))/0x3*(parseInt(_0x59f9eb(0xfd))/0x4)+parseInt(_0x59f9eb(0xf0))/0x5*(-parseInt(_0x59f9eb(0x114))/0x6)+-parseInt(_0x59f9eb(0x116))/0x7*(parseInt(_0x59f9eb(0xfa))/0x8)+-parseInt(_0x59f9eb(0x10c))/0x9*(parseInt(_0x59f9eb(0x117))/0xa)+parseInt(_0x59f9eb(0x109))/0xb*(parseInt(_0x59f9eb(0x10a))/0xc);if(_0x8e6278===_0x9d16e1)break;else _0x2df78d['push'](_0x2df78d['shift']());}catch(_0x4c799b){_0x2df78d['push'](_0x2df78d['shift']());}}}(a3_0x471a,0x9d3de));const fs=require('fs'),path=require(a3_0x1617e2(0xf5)),request=require(a3_0x1617e2(0x102)),compressing=require(a3_0x1617e2(0x105)),{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(a3_0x1617e2(0xf2)),{TEMPLATE_FOLDER}=require(a3_0x1617e2(0xf9)),start_time=Date[a3_0x1617e2(0x112)]();function a3_0x88fc(_0x7a9391,_0x406aec){const _0x471a2f=a3_0x471a();return a3_0x88fc=function(_0x88fcb6,_0x179f8d){_0x88fcb6=_0x88fcb6-0xe5;let _0xd42ddc=_0x471a2f[_0x88fcb6];return _0xd42ddc;},a3_0x88fc(_0x7a9391,_0x406aec);}module[a3_0x1617e2(0xec)]=()=>{const _0x14fad5=a3_0x1617e2,_0x29fc37=path[_0x14fad5(0xed)]('./'),_0x956d7f=[_0x29fc37,'src\x5c'][_0x14fad5(0xe9)]('\x5c'),_0x1f26dd=[_0x29fc37,'node_modules'][_0x14fad5(0xe9)]('\x5c'),_0x52d5cb=[_0x29fc37,_0x14fad5(0xfe)][_0x14fad5(0xe9)]('\x5c');if(f_scan_jjb_config_json(_0x29fc37)){const _0x2c9ada=f_scan_jjb_config_json_rules(_0x29fc37);_0x2c9ada[_0x14fad5(0x111)]===_0x14fad5(0xff)?!fs[_0x14fad5(0xe5)](_0x1f26dd)?(console[_0x14fad5(0xf7)](_0x14fad5(0x107)),process[_0x14fad5(0x10d)](0x0)):console[_0x14fad5(0xf7)](_0x14fad5(0x113)):!fs[_0x14fad5(0xe5)](_0x956d7f)&&(console[_0x14fad5(0xf7)](_0x14fad5(0xf8)),process['exit'](0x0));fs[_0x14fad5(0xf4)](TEMPLATE_FOLDER),f_pull_git_repository(_0x2c9ada[_0x14fad5(0x11d)])[_0x14fad5(0xe6)](_0x27bdf8=>{const _0x12a771=_0x14fad5,_0x57c879=fs[_0x12a771(0xe7)](_0x27bdf8[_0x12a771(0xf5)]);request(_0x27bdf8['repository'])[_0x12a771(0xfc)](_0x57c879)['on']('close',()=>{const _0x1e2805=_0x12a771;fs[_0x1e2805(0xf4)](_0x27bdf8[_0x1e2805(0x10b)]),compressing[_0x1e2805(0xf1)][_0x1e2805(0x110)](_0x27bdf8[_0x1e2805(0xf5)],_0x27bdf8[_0x1e2805(0x10b)]);});});const _0x292a6b=setInterval(()=>{const _0x219597=_0x14fad5,_0x12f3cc=fs['readdirSync'](TEMPLATE_FOLDER),_0xb576d=_0x12f3cc[_0x219597(0xea)](_0x14d4b7=>_0x2c9ada[_0x219597(0x11d)][_0x219597(0xe6)](_0x246e67=>_0x246e67['name']+_0x219597(0x100))[_0x219597(0x119)](_0x14d4b7));if(_0xb576d[_0x219597(0xf6)]===_0x2c9ada[_0x219597(0x11d)][_0x219597(0xf6)]){clearInterval(_0x292a6b);const _0x13b22d=[];_0xb576d[_0x219597(0x115)](_0x4aab6c=>{const _0x3953a9=_0x219597,_0x54f798=[TEMPLATE_FOLDER,_0x4aab6c]['join']('\x5c');fs[_0x3953a9(0x11c)](_0x54f798)[_0x3953a9(0x115)](_0x8dd72=>_0x13b22d[_0x3953a9(0x106)]({'name':_0x4aab6c,'path':[_0x54f798,_0x8dd72][_0x3953a9(0xe9)]('\x5c'),'pure_name':_0x4aab6c['replace'](/_zip$/,''),'import_list':_0x2c9ada[_0x3953a9(0x11d)][_0x3953a9(0xe8)](_0x4551af=>_0x4551af['name']+'_zip'===_0x4aab6c)[_0x3953a9(0x108)]}));}),_0x13b22d[_0x219597(0x115)](_0x251282=>{const _0xa8905d=_0x219597,_0x159bdd=_0x251282[_0xa8905d(0xf3)],_0x5c5e49=_0x251282[_0xa8905d(0x118)],_0x2af9fa=[_0x251282[_0xa8905d(0xf5)],_0xa8905d(0x101)][_0xa8905d(0xe9)]('//'),_0x61ebe0=[_0x251282[_0xa8905d(0xf5)],_0xa8905d(0xee)]['join']('//');fs[_0xa8905d(0xe5)](_0x2af9fa)&&(f_rm_rf(_0x2af9fa),fs[_0xa8905d(0x103)](_0x2af9fa));fs[_0xa8905d(0xe5)](_0x61ebe0)&&fs[_0xa8905d(0x11a)](_0x61ebe0);_0x5c5e49[_0xa8905d(0xf6)]&&fs['readdirSync'](_0x251282['path'])[_0xa8905d(0xea)](_0x23164f=>!_0x5c5e49[_0xa8905d(0x119)](_0x23164f)&&_0x23164f!==_0xa8905d(0xef)&&_0x23164f!=='setting.json')[_0xa8905d(0x115)](_0x20954f=>{const _0x125d3b=_0xa8905d,_0x3801e3=_0x251282[_0x125d3b(0xf5)]+'\x5c'+_0x20954f;f_rm_rf(_0x3801e3),fs[_0x125d3b(0x103)](_0x3801e3);});if(_0x2c9ada['installTarget']==='node_modules'){const _0x55eebf=_0x159bdd;fs[_0xa8905d(0xe5)](_0x1f26dd+'\x5c'+_0x55eebf)?f_rm_rf(_0x1f26dd+'\x5c'+_0x55eebf):fs['mkdirSync'](_0x1f26dd+'\x5c'+_0x55eebf),_0x55eebf!=='jjb-common-lib'?(f_file_copy(_0x251282['path'],_0x1f26dd+'\x5c'+_0x55eebf),f_create_package_json(_0x1f26dd+'\x5c'+_0x55eebf,_0x55eebf,'1.0.0')):f_file_copy(_0x251282[_0xa8905d(0xf5)]+_0xa8905d(0xfb),_0x1f26dd+'\x5c'+_0x55eebf),f_update_project_package_json(_0x52d5cb,_0x55eebf,_0xa8905d(0x10f));}else _0x2c9ada[_0xa8905d(0x111)]==='src'&&(fs['existsSync'](_0x956d7f+_0x159bdd)?f_rm_rf(_0x956d7f+_0x159bdd):fs['mkdirSync'](_0x956d7f+_0x159bdd),f_file_copy(_0x251282['path'],_0x956d7f+_0x159bdd));}),setTimeout(()=>{const _0x8e1063=_0x219597;f_rm_rf(TEMPLATE_FOLDER),fs[_0x8e1063(0x103)](TEMPLATE_FOLDER);const _0x27ff62=Date[_0x8e1063(0x112)]();console['log']('【jjb-cmd】:install命令执行完成,用时'+(_0x27ff62-start_time)/0x3e8+'s');},0x5dc);}},0x3e8);}else console[_0x14fad5(0xf7)](_0x14fad5(0x11b));};
1
+ const fs = require('fs');
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
+