jjb-cmd 2.2.1 → 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,14 @@
1
1
  <h1>重庆市建教帮科技有限公司-前端脚手架</h1>
2
2
  <h3>更新日志:</h3>
3
3
  <ul>
4
+ <li>
5
+ <p>2.2.3</p>
6
+ <div>修复已知问题</div>
7
+ </li>
8
+ <li>
9
+ <p>2.2.2</p>
10
+ <div>修复已知问题</div>
11
+ </li>
4
12
  <li>
5
13
  <p>2.2.1</p>
6
14
  <div>push java增加--force参数,强制拉取新项目</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.1",
5
+ "version": "2.2.3",
6
6
  "description": "jjb脚手架工具",
7
7
  "main": "index.js",
8
8
  "scripts": {
@@ -1 +1,26 @@
1
- const a0_0x21d9a8=a0_0x1414;function a0_0x1414(_0x13a648,_0x4a40f7){const _0x10a8c3=a0_0x10a8();return a0_0x1414=function(_0x141459,_0x5c50f6){_0x141459=_0x141459-0x112;let _0x14e0ce=_0x10a8c3[_0x141459];return _0x14e0ce;},a0_0x1414(_0x13a648,_0x4a40f7);}function a0_0x10a8(){const _0x45ea09=['../../../.auth','8956qTYoGk','249WfYYjC','888354NEnsXP','4JNzAwK','Auth\x20Fail!','data','exports','unlinkSync','1050696oDitwT','Auth\x20NetWork\x20Fail!','2856715KTJEqK','axios','77bMypQe','Auth\x20Success!','/api/auth','12NwJQtb','status','log','1774206RXtfuR','../cmd.install/config','then','270vzBmbJ','210630ZsguWY','17356823YqvKYq','post','writeFileSync','existsSync'];a0_0x10a8=function(){return _0x45ea09;};return a0_0x10a8();}(function(_0x1d68dc,_0x284820){const _0x500f09=a0_0x1414,_0x5ba533=_0x1d68dc();while(!![]){try{const _0x149c9d=parseInt(_0x500f09(0x126))/0x1+parseInt(_0x500f09(0x124))/0x2*(parseInt(_0x500f09(0x125))/0x3)+parseInt(_0x500f09(0x127))/0x4*(-parseInt(_0x500f09(0x112))/0x5)+-parseInt(_0x500f09(0x11a))/0x6+-parseInt(_0x500f09(0x114))/0x7*(-parseInt(_0x500f09(0x12c))/0x8)+-parseInt(_0x500f09(0x11d))/0x9*(-parseInt(_0x500f09(0x11e))/0xa)+parseInt(_0x500f09(0x11f))/0xb*(-parseInt(_0x500f09(0x117))/0xc);if(_0x149c9d===_0x284820)break;else _0x5ba533['push'](_0x5ba533['shift']());}catch(_0x47e1cc){_0x5ba533['push'](_0x5ba533['shift']());}}}(a0_0x10a8,0xd9b28));const axios=require(a0_0x21d9a8(0x113)),fs=require('fs'),path=require('path'),{getApiHost}=require(a0_0x21d9a8(0x11b));module[a0_0x21d9a8(0x12a)]=_0x49b564=>{const _0x43a4a1=a0_0x21d9a8;console[_0x43a4a1(0x119)](_0x49b564);const [_0x4a44d4,_0x2a7f3e]=_0x49b564;axios[_0x43a4a1(0x120)](getApiHost()+_0x43a4a1(0x116),{'username':_0x4a44d4,'password':_0x2a7f3e})[_0x43a4a1(0x11c)](_0x5d1452=>{const _0x140e97=_0x43a4a1,_0x1fe086=path['join'](__dirname,_0x140e97(0x123));_0x5d1452[_0x140e97(0x129)][_0x140e97(0x118)]?(console['log'](_0x140e97(0x115)),fs[_0x140e97(0x121)](_0x1fe086,_0x4a44d4+'/'+_0x2a7f3e)):(console[_0x140e97(0x119)](_0x140e97(0x128)),fs[_0x140e97(0x122)](_0x1fe086)&&fs[_0x140e97(0x12b)](_0x1fe086));})['catch'](_0x252334=>{const _0x43eaa6=_0x43a4a1;console[_0x43eaa6(0x119)](_0x43eaa6(0x12d));});};
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_0x325e4e=a1_0x9ad3;function a1_0x9ad3(_0x2bd927,_0x2ba020){const _0xf5620d=a1_0xf562();return a1_0x9ad3=function(_0x9ad346,_0x9b0743){_0x9ad346=_0x9ad346-0x6e;let _0x3795d2=_0xf5620d[_0x9ad346];return _0x3795d2;},a1_0x9ad3(_0x2bd927,_0x2ba020);}(function(_0x3336dc,_0x31a761){const _0x219742=a1_0x9ad3,_0x511d4c=_0x3336dc();while(!![]){try{const _0x9e0113=-parseInt(_0x219742(0x93))/0x1*(parseInt(_0x219742(0x76))/0x2)+parseInt(_0x219742(0x6f))/0x3+-parseInt(_0x219742(0x86))/0x4*(-parseInt(_0x219742(0x82))/0x5)+-parseInt(_0x219742(0x7a))/0x6*(parseInt(_0x219742(0x8f))/0x7)+-parseInt(_0x219742(0x72))/0x8+parseInt(_0x219742(0x7b))/0x9+parseInt(_0x219742(0x83))/0xa;if(_0x9e0113===_0x31a761)break;else _0x511d4c['push'](_0x511d4c['shift']());}catch(_0x406a61){_0x511d4c['push'](_0x511d4c['shift']());}}}(a1_0xf562,0xdba69));const fs=require('fs'),os=require('os'),path=require(a1_0x325e4e(0x88)),request=require(a1_0x325e4e(0x8b)),utils=require(a1_0x325e4e(0x89)),compressing=require('compressing'),readline=require(a1_0x325e4e(0x75)),io=readline['createInterface']({'input':process[a1_0x325e4e(0x87)],'output':process[a1_0x325e4e(0x8a)]}),child_process=require('child_process'),{CLOUD_PROJECT,GIT_TEMP_DIR,GIT_HOST}=require('../cmd.install/config');function a1_0xf562(){const _0x197ea7=['indexOf','jjb-cmd\x20install.app\x20','不存在。','237625pJqArC','/repository/archive.zip?private_token=','then','tmpdir','exports','2805492nZEMaj','/api/v4/projects/','pipe','11239832XLustP','projectId','token','readline','10JRVMyq','close','zip','初始化完成!请自行使用jjb-cmd\x20install.app\x20yarn/npm安装项目!','6cvWLZC','2673981pmPpLt','uncompress','trim','execSync','-master-','DeleteDirAllFile','/unzip/','178745XuYoEI','22229600hFZuad','yarn','npm','68getteO','stdin','path','../../old/util','stdout','request','createWriteStream','mkdirSync','log','3991211vhgYCz'];a1_0xf562=function(){return _0x197ea7;};return a1_0xf562();}module[a1_0x325e4e(0x6e)]=_0x2c2a04=>{const _0x24c767=a1_0x325e4e,_0x3d437d=path['resolve']('./'),_0x1b117d=CLOUD_PROJECT[_0x2c2a04]||undefined;if(_0x1b117d){const _0x2f8ad6=os[_0x24c767(0x96)](),_0x28c740=_0x2f8ad6+'/'+GIT_TEMP_DIR+'/'+_0x2c2a04+'.zip',_0x610c2f=_0x2f8ad6+'/'+GIT_TEMP_DIR+_0x24c767(0x81);utils[_0x24c767(0x80)](_0x2f8ad6+'/'+GIT_TEMP_DIR,()=>{const _0x108a87=_0x24c767;fs['mkdirSync'](_0x2f8ad6+'/'+GIT_TEMP_DIR);let _0x171128=fs[_0x108a87(0x8c)](_0x28c740);request(GIT_HOST+_0x108a87(0x70)+_0x1b117d[_0x108a87(0x73)]+_0x108a87(0x94)+_0x1b117d[_0x108a87(0x74)]+'&ref=master')[_0x108a87(0x71)](_0x171128)['on'](_0x108a87(0x77),()=>{const _0x14da90=_0x108a87;fs[_0x14da90(0x8d)](_0x610c2f),compressing[_0x14da90(0x78)][_0x14da90(0x7c)](_0x28c740,_0x610c2f)[_0x14da90(0x95)](()=>{setTimeout(()=>{fs['readdirSync'](_0x610c2f)['forEach'](_0x22d2e6=>{const _0x2c9f41=a1_0x9ad3;_0x22d2e6[_0x2c9f41(0x90)](_0x2c9f41(0x7f))!==-0x1&&utils['CopyFolder'](_0x610c2f+_0x22d2e6,_0x3d437d,()=>{io['question']('初始化完成?请选择安装方式![yarn/npm]:',function(_0x48ada7){const _0x3a4267=a1_0x9ad3;[_0x3a4267(0x84),_0x3a4267(0x85)]['includes'](_0x48ada7[_0x3a4267(0x7d)]())?(console[_0x3a4267(0x8e)]('安装中,请耐心等待...'),child_process[_0x3a4267(0x7e)](_0x3a4267(0x91)+_0x48ada7['trim'](),{'cwd':_0x3d437d}),console['log']('安装完成,祝您愉快编码!'),process['exit'](0x0)):(console[_0x3a4267(0x8e)](_0x3a4267(0x79)),process['exit'](0x0));});});});},0x7d0);});});});}else console[_0x24c767(0x8e)]('【Error】:初始化失败,'+_0x2c2a04+_0x24c767(0x92));};
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_0x4d31bc=a2_0x5c8a;function a2_0x48e1(){const _0x15efbe=['CONFIG_FILE_HOST','1560735bXrOIc','GIT_HOST','API_HOST_TEST','CLOUD_PROJECT','jjb-assembly-','tmpdir','jjb-assembly-java','http://120.26.210.58:8089','../../../package.json','dev','5oBjlfS','TEMPLATE_FOLDER','test','parse','gPSit8aJsLVmNzuQ5Cy4','ywPtT3xCG6b_vAxp6sTj','env','join','6720190PhQdbs','88ptJcZw','http://120.26.210.58:8088','hLqARY89CN6fUD3yg4NL','http://192.168.1.242:10985','snBxJ2i5kYarGGcsojhY','GIT_TEMP_JAVA','getApiHost','API_HOST','81781MBEqRG','e9njpBd1nS_LREN8GFpR','1063312wVWivr','1939948WLCHtN','9lMoqsR','prod','GIT_JAVA_ENV_JSON','1264UGbBmh','G4HJRsHr9D7Ssmixegw2','path','readFileSync','https://cdn.cqjjb.cn/jjb-cloud-config','FT3pKzxpRynFkmddJ9Bs','4920576yKulbL','4809wMLVAR','toString'];a2_0x48e1=function(){return _0x15efbe;};return a2_0x48e1();}(function(_0x98729d,_0x503474){const _0x88d59=a2_0x5c8a,_0x6693ed=_0x98729d();while(!![]){try{const _0x4c3db9=-parseInt(_0x88d59(0x1eb))/0x1+parseInt(_0x88d59(0x1ec))/0x2+-parseInt(_0x88d59(0x1f7))/0x3*(-parseInt(_0x88d59(0x1f0))/0x4)+-parseInt(_0x88d59(0x204))/0x5*(parseInt(_0x88d59(0x1f6))/0x6)+-parseInt(_0x88d59(0x215))/0x7*(-parseInt(_0x88d59(0x20d))/0x8)+parseInt(_0x88d59(0x1ed))/0x9*(parseInt(_0x88d59(0x20c))/0xa)+parseInt(_0x88d59(0x1fa))/0xb;if(_0x4c3db9===_0x503474)break;else _0x6693ed['push'](_0x6693ed['shift']());}catch(_0x23d804){_0x6693ed['push'](_0x6693ed['shift']());}}}(a2_0x48e1,0x82beb));function a2_0x5c8a(_0x3a6dcd,_0x36d60f){const _0x48e19a=a2_0x48e1();return a2_0x5c8a=function(_0x5c8af9,_0x28fbe3){_0x5c8af9=_0x5c8af9-0x1ea;let _0x5688d8=_0x48e19a[_0x5c8af9];return _0x5688d8;},a2_0x5c8a(_0x3a6dcd,_0x36d60f);}const os=require('os'),path=require(a2_0x4d31bc(0x1f2)),fs=require('fs'),API_HOST=a2_0x4d31bc(0x20e),API_HOST_TEST=a2_0x4d31bc(0x201);exports[a2_0x4d31bc(0x1f9)]=a2_0x4d31bc(0x1f4),exports[a2_0x4d31bc(0x214)]=API_HOST,exports[a2_0x4d31bc(0x1fc)]=API_HOST_TEST,exports[a2_0x4d31bc(0x1fb)]=a2_0x4d31bc(0x210),exports['GIT_TEMP_DIR']=a2_0x4d31bc(0x1fe)+Date['now'](),exports[a2_0x4d31bc(0x212)]=a2_0x4d31bc(0x200),exports[a2_0x4d31bc(0x1ef)]={'development':a2_0x4d31bc(0x203),'production':a2_0x4d31bc(0x1ee),'test':'test'},exports[a2_0x4d31bc(0x1fd)]={'common':{'token':a2_0x4d31bc(0x1f1),'projectId':0x117},'react-admin-component':{'token':a2_0x4d31bc(0x1f5),'projectId':0x154},'jjb-dva-runtime':{'token':a2_0x4d31bc(0x20f),'projectId':0x23b},'jjb-common-lib':{'token':a2_0x4d31bc(0x1ea),'projectId':0x23c},'jjb-common-decorator':{'token':a2_0x4d31bc(0x208),'projectId':0x23e},'vue-unisass-component':{'token':'d4wQ7dzEjYPsgVbKnYei','projectId':0x153},'react-component':{'token':a2_0x4d31bc(0x211),'projectId':0x33f},'micro-app-ts':{'token':'7V-YUxhmh51Mdhgx4rq4','projectId':0x33e},'micro-app':{'token':'FqNrmFAgrxasMrbbjvq9','projectId':0x33d},'lib':{'token':a2_0x4d31bc(0x209),'projectId':0x33c}},exports[a2_0x4d31bc(0x205)]=os[a2_0x4d31bc(0x1ff)]()+'\x5c'+exports['GIT_TEMP_DIR'],exports[a2_0x4d31bc(0x213)]=()=>{const _0x4322d1=a2_0x4d31bc,_0x34d139=JSON[_0x4322d1(0x207)](fs[_0x4322d1(0x1f3)](path[_0x4322d1(0x20b)](__dirname,_0x4322d1(0x202)))[_0x4322d1(0x1f8)]());return _0x34d139[_0x4322d1(0x20a)]===_0x4322d1(0x206)?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
- function a3_0x4120(_0x336260,_0x12ab1a){const _0x42a4d4=a3_0x42a4();return a3_0x4120=function(_0x4120b5,_0x2296db){_0x4120b5=_0x4120b5-0xab;let _0x8e1ae0=_0x42a4d4[_0x4120b5];return _0x8e1ae0;},a3_0x4120(_0x336260,_0x12ab1a);}function a3_0x42a4(){const _0x34d1c5=['index.js','pipe','uncompress','map','request','includes','installTarget','jjb-common-lib','find','exports','importList','./tools','_zip','setting.json','createWriteStream','336609nlJmnN','repository','length','1260264VIDEPp','【Error】:安装失败,src目录不存在。','.idea','close','readdirSync','existsSync','3247344Uffzbp','filter','934122YHFZyN','.gitignore','mkdirSync','1080GEutlJ','pure_name','forEach','1191876yGhptE','package.json','import_list','10ZpLuhA','1627521zAuUVC','installResources','rmdirSync','log','【Warning】:若安装在node_modules中,请确保projectType\x20=\x20micro-spa,并关闭webpack.config.js\x20rules限制。','【Error】:执行失败,在您的项目根目录,需要一个jjb.config.json文件。','join','【jjb-cmd】:install命令执行完成,用时','9821532qNwuSX','1.0.0','path','exit','resolve','./config','now','node_modules','\x5ctypes'];a3_0x42a4=function(){return _0x34d1c5;};return a3_0x42a4();}const a3_0x297f60=a3_0x4120;(function(_0x50b4b4,_0x2742da){const _0x39953b=a3_0x4120,_0xae79f2=_0x50b4b4();while(!![]){try{const _0x346abf=-parseInt(_0x39953b(0xac))/0x1+-parseInt(_0x39953b(0xdf))/0x2+parseInt(_0x39953b(0xb2))/0x3+parseInt(_0x39953b(0xd9))/0x4*(-parseInt(_0x39953b(0xb5))/0x5)+-parseInt(_0x39953b(0xbe))/0x6+parseInt(_0x39953b(0xb6))/0x7+parseInt(_0x39953b(0xaf))/0x8*(parseInt(_0x39953b(0xd6))/0x9);if(_0x346abf===_0x2742da)break;else _0xae79f2['push'](_0xae79f2['shift']());}catch(_0x2183eb){_0xae79f2['push'](_0xae79f2['shift']());}}}(a3_0x42a4,0xd0842));const fs=require('fs'),path=require('path'),request=require(a3_0x297f60(0xcb)),compressing=require('compressing'),{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_0x297f60(0xd2)),{TEMPLATE_FOLDER}=require(a3_0x297f60(0xc3)),start_time=Date[a3_0x297f60(0xc4)]();module[a3_0x297f60(0xd0)]=()=>{const _0x42dcd3=a3_0x297f60,_0x29f753=path[_0x42dcd3(0xc2)]('./'),_0x2118e8=[_0x29f753,'src\x5c'][_0x42dcd3(0xbc)]('\x5c'),_0x25eec4=[_0x29f753,'node_modules'][_0x42dcd3(0xbc)]('\x5c'),_0x2271f3=[_0x29f753,_0x42dcd3(0xb3)][_0x42dcd3(0xbc)]('\x5c');if(f_scan_jjb_config_json(_0x29f753)){const _0x1babb0=f_scan_jjb_config_json_rules(_0x29f753);_0x1babb0[_0x42dcd3(0xcd)]===_0x42dcd3(0xc5)?!fs[_0x42dcd3(0xde)](_0x25eec4)?(console['log']('【Error】:安装失败,node_modules目录不存在。'),process[_0x42dcd3(0xc1)](0x0)):console[_0x42dcd3(0xb9)](_0x42dcd3(0xba)):!fs['existsSync'](_0x2118e8)&&(console[_0x42dcd3(0xb9)](_0x42dcd3(0xda)),process[_0x42dcd3(0xc1)](0x0));fs['mkdirSync'](TEMPLATE_FOLDER),f_pull_git_repository(_0x1babb0[_0x42dcd3(0xb7)])[_0x42dcd3(0xca)](_0x4749ae=>{const _0x564b97=_0x42dcd3,_0x5a387d=fs[_0x564b97(0xd5)](_0x4749ae[_0x564b97(0xc0)]);request(_0x4749ae[_0x564b97(0xd7)])[_0x564b97(0xc8)](_0x5a387d)['on'](_0x564b97(0xdc),()=>{const _0x5a2aa7=_0x564b97;fs[_0x5a2aa7(0xae)](_0x4749ae['compress']),compressing['zip'][_0x5a2aa7(0xc9)](_0x4749ae[_0x5a2aa7(0xc0)],_0x4749ae['compress']);});});const _0x5b61e7=setInterval(()=>{const _0x43726f=_0x42dcd3,_0x3e2a8d=fs[_0x43726f(0xdd)](TEMPLATE_FOLDER),_0x54ae41=_0x3e2a8d[_0x43726f(0xab)](_0x41666b=>_0x1babb0[_0x43726f(0xb7)][_0x43726f(0xca)](_0x329784=>_0x329784['name']+_0x43726f(0xd3))[_0x43726f(0xcc)](_0x41666b));if(_0x54ae41['length']===_0x1babb0[_0x43726f(0xb7)][_0x43726f(0xd8)]){clearInterval(_0x5b61e7);const _0x35a463=[];_0x54ae41[_0x43726f(0xb1)](_0x45af99=>{const _0x5d9fe8=_0x43726f,_0x5bbeb7=[TEMPLATE_FOLDER,_0x45af99][_0x5d9fe8(0xbc)]('\x5c');fs['readdirSync'](_0x5bbeb7)[_0x5d9fe8(0xb1)](_0x2b1084=>_0x35a463['push']({'name':_0x45af99,'path':[_0x5bbeb7,_0x2b1084]['join']('\x5c'),'pure_name':_0x45af99['replace'](/_zip$/,''),'import_list':_0x1babb0[_0x5d9fe8(0xb7)][_0x5d9fe8(0xcf)](_0x3ad5c9=>_0x3ad5c9['name']+'_zip'===_0x45af99)[_0x5d9fe8(0xd1)]}));}),_0x35a463[_0x43726f(0xb1)](_0x120bff=>{const _0x305203=_0x43726f,_0x2fc758=_0x120bff[_0x305203(0xb0)],_0x5b978e=_0x120bff[_0x305203(0xb4)],_0x313355=[_0x120bff['path'],_0x305203(0xdb)]['join']('//'),_0x390b59=[_0x120bff[_0x305203(0xc0)],_0x305203(0xad)][_0x305203(0xbc)]('//');fs[_0x305203(0xde)](_0x313355)&&(f_rm_rf(_0x313355),fs[_0x305203(0xb8)](_0x313355));fs[_0x305203(0xde)](_0x390b59)&&fs['unlinkSync'](_0x390b59);_0x5b978e[_0x305203(0xd8)]&&fs[_0x305203(0xdd)](_0x120bff['path'])[_0x305203(0xab)](_0x5b5fdf=>!_0x5b978e[_0x305203(0xcc)](_0x5b5fdf)&&_0x5b5fdf!==_0x305203(0xc7)&&_0x5b5fdf!==_0x305203(0xd4))[_0x305203(0xb1)](_0x382552=>{const _0x3e795c=_0x305203,_0x1ddc69=_0x120bff['path']+'\x5c'+_0x382552;f_rm_rf(_0x1ddc69),fs[_0x3e795c(0xb8)](_0x1ddc69);});if(_0x1babb0['installTarget']===_0x305203(0xc5)){const _0x40f06a=_0x2fc758;fs[_0x305203(0xde)](_0x25eec4+'\x5c'+_0x40f06a)?f_rm_rf(_0x25eec4+'\x5c'+_0x40f06a):fs[_0x305203(0xae)](_0x25eec4+'\x5c'+_0x40f06a),_0x40f06a!==_0x305203(0xce)?(f_file_copy(_0x120bff[_0x305203(0xc0)],_0x25eec4+'\x5c'+_0x40f06a),f_create_package_json(_0x25eec4+'\x5c'+_0x40f06a,_0x40f06a,_0x305203(0xbf))):f_file_copy(_0x120bff[_0x305203(0xc0)]+_0x305203(0xc6),_0x25eec4+'\x5c'+_0x40f06a),f_update_project_package_json(_0x2271f3,_0x40f06a,'1.0.0');}else _0x1babb0[_0x305203(0xcd)]==='src'&&(fs[_0x305203(0xde)](_0x2118e8+_0x2fc758)?f_rm_rf(_0x2118e8+_0x2fc758):fs[_0x305203(0xae)](_0x2118e8+_0x2fc758),f_file_copy(_0x120bff['path'],_0x2118e8+_0x2fc758));}),setTimeout(()=>{const _0x5bf149=_0x43726f;f_rm_rf(TEMPLATE_FOLDER),fs[_0x5bf149(0xb8)](TEMPLATE_FOLDER);const _0x54256f=Date[_0x5bf149(0xc4)]();console[_0x5bf149(0xb9)](_0x5bf149(0xbd)+(_0x54256f-start_time)/0x3e8+'s');},0x5dc);}},0x3e8);}else console['log'](_0x42dcd3(0xbb));};
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
+