jjb-cmd 2.5.1 → 2.5.2
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/bin/command.js +3 -11
- package/package.json +1 -1
- package/src/auth.js +1 -47
- package/src/code-optimization.js +1 -49
- package/src/config.js +1 -122
- package/src/crypto-utils.js +1 -0
- package/src/password-input.js +1 -0
- package/src/publish.js +1 -222
- package/src/push.js +1 -283
- package/src/rm-rf.js +1 -52
- package/src/utils.js +1 -226
- package/build.js +0 -20
- package/obf.config.json +0 -3
package/bin/command.js
CHANGED
|
@@ -23,21 +23,13 @@ commander.command('help').description('-- 帮助').action(() => {
|
|
|
23
23
|
console.log('jjb-cmd opti 代码优化');
|
|
24
24
|
console.log('jjb-cmd v 查看版本');
|
|
25
25
|
console.log('jjb-cmd publish <version> 发布云组件\n\targ1 <version> 发布版本,可设置为latest');
|
|
26
|
-
console.log('jjb-cmd auth
|
|
26
|
+
console.log('jjb-cmd auth 登录授权(交互式输入用户名和密码)');
|
|
27
27
|
console.log('jjb-cmd push java <env> 推送微应用到服务器\n\targ1 <env> 推送环境');
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
commander.command('pushMessage [args]').description('-- 设置publish提交时是否需要提交信息').action(args => {
|
|
31
|
-
const package_json_file = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json')).toString());
|
|
32
|
-
if ([ 'yes', 'no' ].includes(args)) {
|
|
33
|
-
package_json_file.pushMessage = args;
|
|
34
|
-
fs.writeFileSync(path.join(__dirname, '../package.json'), JSON.stringify(package_json_file));
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
30
|
// 命令
|
|
39
|
-
commander.command('auth
|
|
40
|
-
require('../src/auth.js')(
|
|
31
|
+
commander.command('auth').description('-- 授权').action(async () => {
|
|
32
|
+
await require('../src/auth.js')([]);
|
|
41
33
|
});
|
|
42
34
|
|
|
43
35
|
// 优化
|
package/package.json
CHANGED
package/src/auth.js
CHANGED
|
@@ -1,47 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { getApiHost } = require('./config');
|
|
4
|
-
const {
|
|
5
|
-
logInfo,
|
|
6
|
-
logSuccess,
|
|
7
|
-
logError,
|
|
8
|
-
writeFile,
|
|
9
|
-
fileExists,
|
|
10
|
-
deleteFile
|
|
11
|
-
} = require('./utils');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 用户认证模块
|
|
15
|
-
* @param {string[]} args - 命令行参数 [username, password]
|
|
16
|
-
*/
|
|
17
|
-
module.exports = args => {
|
|
18
|
-
// 参数验证
|
|
19
|
-
if (!args || args.length < 2) {
|
|
20
|
-
logError('用户名和密码参数不能为空!');
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const [ username, password ] = args;
|
|
25
|
-
logInfo('Auth: 授权登录!');
|
|
26
|
-
|
|
27
|
-
const authPath = path.join(__dirname, '../.auth');
|
|
28
|
-
|
|
29
|
-
axios.post(`${getApiHost()}/api/auth`, {
|
|
30
|
-
username,
|
|
31
|
-
password
|
|
32
|
-
}).then(res => {
|
|
33
|
-
if (res.data.status) {
|
|
34
|
-
logSuccess('Auth: 登录成功,已缓存登录状态!');
|
|
35
|
-
writeFile(authPath, `${username}/${password}`);
|
|
36
|
-
} else {
|
|
37
|
-
logError(`Auth: ${res.data.message}`);
|
|
38
|
-
if (fileExists(authPath)) {
|
|
39
|
-
deleteFile(authPath);
|
|
40
|
-
}
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
}).catch(e => {
|
|
44
|
-
logError(`Auth: 登录失败!${e.message}`);
|
|
45
|
-
process.exit(1);
|
|
46
|
-
});
|
|
47
|
-
};
|
|
1
|
+
const a0_0x11da1c=a0_0x1af2;function a0_0x3ab3(){const _0x3b6715=['2916970Vqzbfn','用户取消输入','Auth:\x20登录失败!','./password-input','9SFAFya','1666976huHKwW','response','56ZqOWnO','data','Auth:\x20认证信息已安全加密存储!','password','2770158MyMKlA','post','/api/auth','Auth:\x20用户取消登录','exit','status','13941968UiSxra','385VZZOTf','30110uYtwEL','exports','includes','5LuoaBh','314690SxhIEa','../.auth','146865Cqlbmu','message'];a0_0x3ab3=function(){return _0x3b6715;};return a0_0x3ab3();}function a0_0x1af2(_0x18dc20,_0x4fa981){const _0x3ab3ea=a0_0x3ab3();return a0_0x1af2=function(_0x1af228,_0x10daf6){_0x1af228=_0x1af228-0x1e1;let _0x1cc1ef=_0x3ab3ea[_0x1af228];return _0x1cc1ef;},a0_0x1af2(_0x18dc20,_0x4fa981);}(function(_0x2fe2d7,_0x185d01){const _0x586f5a=a0_0x1af2,_0x581715=_0x2fe2d7();while(!![]){try{const _0x533b70=-parseInt(_0x586f5a(0x1f1))/0x1+parseInt(_0x586f5a(0x1e4))/0x2+-parseInt(_0x586f5a(0x1ea))/0x3*(-parseInt(_0x586f5a(0x1f3))/0x4)+parseInt(_0x586f5a(0x1e7))/0x5*(-parseInt(_0x586f5a(0x1f7))/0x6)+-parseInt(_0x586f5a(0x1ec))/0x7+-parseInt(_0x586f5a(0x1e2))/0x8*(-parseInt(_0x586f5a(0x1f0))/0x9)+-parseInt(_0x586f5a(0x1e8))/0xa*(-parseInt(_0x586f5a(0x1e3))/0xb);if(_0x533b70===_0x185d01)break;else _0x581715['push'](_0x581715['shift']());}catch(_0x302836){_0x581715['push'](_0x581715['shift']());}}}(a0_0x3ab3,0xf3f27));const axios=require('axios'),path=require('path'),{getApiHost}=require('./config'),{logInfo,logSuccess,logError,fileExists,deleteFile}=require('./utils'),{saveAuth,deleteAuth}=require('./crypto-utils'),{getCredentials,interactiveAuth}=require(a0_0x11da1c(0x1ef));module[a0_0x11da1c(0x1e5)]=async _0x2821cc=>{const _0x38874c=a0_0x11da1c,_0x85cb40=path['join'](__dirname,_0x38874c(0x1e9));try{logInfo('Auth:\x20交互式登录模式');const _0x163d9b=await interactiveAuth(),_0x3da3d3=_0x163d9b['username'],_0x1bcafc=_0x163d9b[_0x38874c(0x1f6)];logInfo('Auth:\x20正在验证登录信息...');const _0x6e63e6=await axios[_0x38874c(0x1f8)](getApiHost()+_0x38874c(0x1f9),{'username':_0x3da3d3,'password':_0x1bcafc});if(_0x6e63e6[_0x38874c(0x1f4)][_0x38874c(0x1e1)]){logSuccess('Auth:\x20登录成功,已缓存登录状态!');try{saveAuth(_0x3da3d3,_0x1bcafc,_0x85cb40),logSuccess(_0x38874c(0x1f5));}catch(_0x2a4cae){logError('Auth:\x20保存认证信息失败!'+_0x2a4cae['message']),process[_0x38874c(0x1fb)](0x1);}}else logError('Auth:\x20'+_0x6e63e6[_0x38874c(0x1f4)][_0x38874c(0x1eb)]),fileExists(_0x85cb40)&&deleteAuth(_0x85cb40),process[_0x38874c(0x1fb)](0x1);}catch(_0x35e568){if(_0x35e568['message'][_0x38874c(0x1e6)](_0x38874c(0x1ed)))logError(_0x38874c(0x1fa));else _0x35e568[_0x38874c(0x1f2)]?logError(_0x38874c(0x1ee)+(_0x35e568[_0x38874c(0x1f2)][_0x38874c(0x1f4)]?.[_0x38874c(0x1eb)]||_0x35e568[_0x38874c(0x1eb)])):logError('Auth:\x20登录失败!'+_0x35e568[_0x38874c(0x1eb)]);process[_0x38874c(0x1fb)](0x1);}};
|
package/src/code-optimization.js
CHANGED
|
@@ -1,49 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const readline = require('readline');
|
|
3
|
-
const { bootstrap } = require('@cqsjjb/react-code-optimization');
|
|
4
|
-
const {
|
|
5
|
-
logInfo,
|
|
6
|
-
logSuccess,
|
|
7
|
-
logError,
|
|
8
|
-
logWarning
|
|
9
|
-
} = require('./utils');
|
|
10
|
-
|
|
11
|
-
const io = readline.createInterface({
|
|
12
|
-
input: process.stdin,
|
|
13
|
-
output: process.stdout
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 代码优化模块
|
|
18
|
-
* 使用 @cqsjjb/react-code-optimization 进行代码优化
|
|
19
|
-
*/
|
|
20
|
-
module.exports = function () {
|
|
21
|
-
const rootPath = path.resolve('./');
|
|
22
|
-
|
|
23
|
-
logInfo('代码优化工具');
|
|
24
|
-
logWarning('此操作将优化当前目录下的代码,请确保已备份重要文件!');
|
|
25
|
-
|
|
26
|
-
io.question('是否确认优化代码?[y/n]:', function (answer) {
|
|
27
|
-
const trimmedAnswer = answer.trim().toLowerCase();
|
|
28
|
-
|
|
29
|
-
if (trimmedAnswer === 'y' || trimmedAnswer === 'yes') {
|
|
30
|
-
logInfo('开始代码优化...');
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
bootstrap(rootPath, 100, () => {
|
|
34
|
-
logSuccess('优化完成。');
|
|
35
|
-
process.exit(0);
|
|
36
|
-
});
|
|
37
|
-
} catch (error) {
|
|
38
|
-
logError(`代码优化过程中发生错误:${error.message}`);
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
} else if (trimmedAnswer === 'n' || trimmedAnswer === 'no') {
|
|
42
|
-
logInfo('取消优化。');
|
|
43
|
-
process.exit(0);
|
|
44
|
-
} else {
|
|
45
|
-
logError('无效操作,请输入 y 或 n。');
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
};
|
|
1
|
+
const a1_0x1b5a1f=a1_0x35af;(function(_0x32c30e,_0x5e0b13){const _0x50540d=a1_0x35af,_0x5a79f8=_0x32c30e();while(!![]){try{const _0x1f46bc=-parseInt(_0x50540d(0x17d))/0x1*(parseInt(_0x50540d(0x170))/0x2)+parseInt(_0x50540d(0x174))/0x3*(parseInt(_0x50540d(0x186))/0x4)+parseInt(_0x50540d(0x178))/0x5*(parseInt(_0x50540d(0x184))/0x6)+parseInt(_0x50540d(0x181))/0x7+-parseInt(_0x50540d(0x172))/0x8*(parseInt(_0x50540d(0x182))/0x9)+parseInt(_0x50540d(0x188))/0xa+-parseInt(_0x50540d(0x183))/0xb*(parseInt(_0x50540d(0x187))/0xc);if(_0x1f46bc===_0x5e0b13)break;else _0x5a79f8['push'](_0x5a79f8['shift']());}catch(_0x342804){_0x5a79f8['push'](_0x5a79f8['shift']());}}}(a1_0x4443,0x85318));function a1_0x35af(_0x569949,_0x3893eb){const _0x4443ce=a1_0x4443();return a1_0x35af=function(_0x35afc9,_0x57f92f){_0x35afc9=_0x35afc9-0x16d;let _0x514a8c=_0x4443ce[_0x35afc9];return _0x514a8c;},a1_0x35af(_0x569949,_0x3893eb);}const path=require(a1_0x1b5a1f(0x175)),readline=require(a1_0x1b5a1f(0x17b)),{bootstrap}=require('@cqsjjb/react-code-optimization'),{logInfo,logSuccess,logError,logWarning}=require('./utils'),io=readline['createInterface']({'input':process[a1_0x1b5a1f(0x180)],'output':process['stdout']});function a1_0x4443(){const _0xbca454=['readline','开始代码优化...','51317LJxRoq','yes','question','stdin','4855039dlEbwb','242226YPZMAX','11lExIBQ','6xLADLs','代码优化过程中发生错误:','4hQBpVd','11785356XDGeAp','6838550hqblxm','代码优化工具','取消优化。','trim','4fKSLou','exit','208TSaDoE','此操作将优化当前目录下的代码,请确保已备份重要文件!','2856165ovvoTo','path','是否确认优化代码?[y/n]:','toLowerCase','2920DYDIfY','message','resolve'];a1_0x4443=function(){return _0xbca454;};return a1_0x4443();}module['exports']=function(){const _0x508d06=a1_0x1b5a1f,_0x2e8aa1=path[_0x508d06(0x17a)]('./');logInfo(_0x508d06(0x16d)),logWarning(_0x508d06(0x173)),io[_0x508d06(0x17f)](_0x508d06(0x176),function(_0x1f404b){const _0x1f631b=_0x508d06,_0x46aec0=_0x1f404b[_0x1f631b(0x16f)]()[_0x1f631b(0x177)]();if(_0x46aec0==='y'||_0x46aec0===_0x1f631b(0x17e)){logInfo(_0x1f631b(0x17c));try{bootstrap(_0x2e8aa1,0x64,()=>{logSuccess('优化完成。'),process['exit'](0x0);});}catch(_0x57f267){logError(_0x1f631b(0x185)+_0x57f267[_0x1f631b(0x179)]),process[_0x1f631b(0x171)](0x1);}}else _0x46aec0==='n'||_0x46aec0==='no'?(logInfo(_0x1f631b(0x16e)),process[_0x1f631b(0x171)](0x0)):(logError('无效操作,请输入\x20y\x20或\x20n。'),process[_0x1f631b(0x171)](0x1));});};
|
package/src/config.js
CHANGED
|
@@ -1,122 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* API 主机配置
|
|
7
|
-
*/
|
|
8
|
-
const API_HOST = 'http://120.26.210.58:8088';
|
|
9
|
-
const API_HOST_HTTPS = 'https://jcloud.cqjjb.cn';
|
|
10
|
-
const API_HOST_TEST = 'http://120.26.210.58:8089';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 配置文件主机地址
|
|
14
|
-
*/
|
|
15
|
-
exports.CONFIG_FILE_HOST = 'https://cdn.cqjjb.cn/jjb-cloud-config';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* API 主机地址
|
|
19
|
-
*/
|
|
20
|
-
exports.API_HOST = API_HOST;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 测试环境 API 主机地址
|
|
24
|
-
*/
|
|
25
|
-
exports.API_HOST_TEST = API_HOST_TEST;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Git 主机地址
|
|
29
|
-
*/
|
|
30
|
-
exports.GIT_HOST = 'http://192.168.1.242:10985';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 临时目录名称
|
|
34
|
-
*/
|
|
35
|
-
exports.GIT_TEMP_DIR = `jjb-assembly-${Date.now()}`;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Java 临时目录名称
|
|
39
|
-
*/
|
|
40
|
-
exports.GIT_TEMP_JAVA = `jjb-assembly-java`;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Java 环境映射
|
|
44
|
-
*/
|
|
45
|
-
exports.GIT_JAVA_ENV_JSON = {
|
|
46
|
-
development: 'dev',
|
|
47
|
-
production: 'prod',
|
|
48
|
-
test: 'test'
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* 云项目配置
|
|
52
|
-
* 包含各个项目的 token 和 projectId
|
|
53
|
-
*/
|
|
54
|
-
exports.CLOUD_PROJECT = {
|
|
55
|
-
common: {
|
|
56
|
-
token: 'G4HJRsHr9D7Ssmixegw2',
|
|
57
|
-
projectId: 279
|
|
58
|
-
},
|
|
59
|
-
'react-admin-component': {
|
|
60
|
-
token: 'FT3pKzxpRynFkmddJ9Bs',
|
|
61
|
-
projectId: 340
|
|
62
|
-
},
|
|
63
|
-
'jjb-dva-runtime': {
|
|
64
|
-
token: 'hLqARY89CN6fUD3yg4NL',
|
|
65
|
-
projectId: 571
|
|
66
|
-
},
|
|
67
|
-
'jjb-common-lib': {
|
|
68
|
-
token: 'e9njpBd1nS_LREN8GFpR',
|
|
69
|
-
projectId: 572
|
|
70
|
-
},
|
|
71
|
-
'jjb-common-decorator': {
|
|
72
|
-
token: 'gPSit8aJsLVmNzuQ5Cy4',
|
|
73
|
-
projectId: 574
|
|
74
|
-
},
|
|
75
|
-
'vue-unisass-component': {
|
|
76
|
-
token: 'd4wQ7dzEjYPsgVbKnYei',
|
|
77
|
-
projectId: 339
|
|
78
|
-
},
|
|
79
|
-
'react-component': {
|
|
80
|
-
token: 'snBxJ2i5kYarGGcsojhY',
|
|
81
|
-
projectId: 831
|
|
82
|
-
},
|
|
83
|
-
'micro-app-ts': {
|
|
84
|
-
token: '7V-YUxhmh51Mdhgx4rq4',
|
|
85
|
-
projectId: 830
|
|
86
|
-
},
|
|
87
|
-
'micro-app': {
|
|
88
|
-
token: 'FqNrmFAgrxasMrbbjvq9',
|
|
89
|
-
projectId: 829
|
|
90
|
-
},
|
|
91
|
-
lib: {
|
|
92
|
-
token: 'ywPtT3xCG6b_vAxp6sTj',
|
|
93
|
-
projectId: 828
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* 模板文件夹路径
|
|
99
|
-
*/
|
|
100
|
-
exports.TEMPLATE_FOLDER = path.join(os.tmpdir(), exports.GIT_TEMP_DIR);
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 获取 API 主机地址
|
|
104
|
-
* 根据 package.json 中的配置决定使用哪个 API 主机
|
|
105
|
-
* @returns {string} API 主机地址
|
|
106
|
-
*/
|
|
107
|
-
exports.getApiHost = () => {
|
|
108
|
-
try {
|
|
109
|
-
const packageJson = JSON.parse(
|
|
110
|
-
fs.readFileSync(path.join(__dirname, '../package.json')).toString()
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
if (packageJson.env === 'test') {
|
|
114
|
-
return API_HOST_TEST;
|
|
115
|
-
} else {
|
|
116
|
-
return packageJson.httpMethod === 'http' ? API_HOST : API_HOST_HTTPS;
|
|
117
|
-
}
|
|
118
|
-
} catch (error) {
|
|
119
|
-
// 如果读取 package.json 失败,默认返回 HTTPS 地址
|
|
120
|
-
return API_HOST_HTTPS;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
1
|
+
function a2_0x297a(_0x35221e,_0x27599b){const _0x14f15a=a2_0x14f1();return a2_0x297a=function(_0x297a8f,_0x1f7841){_0x297a8f=_0x297a8f-0x116;let _0x3ba734=_0x14f15a[_0x297a8f];return _0x3ba734;},a2_0x297a(_0x35221e,_0x27599b);}const a2_0x4edf64=a2_0x297a;function a2_0x14f1(){const _0x1e0db2=['tmpdir','snBxJ2i5kYarGGcsojhY','https://jcloud.cqjjb.cn','CLOUD_PROJECT','path','10YOuMMH','G4HJRsHr9D7Ssmixegw2','465788UCZzrp','GIT_JAVA_ENV_JSON','e9njpBd1nS_LREN8GFpR','731367ywWtvv','jjb-assembly-','gPSit8aJsLVmNzuQ5Cy4','http://120.26.210.58:8088','d4wQ7dzEjYPsgVbKnYei','API_HOST','ywPtT3xCG6b_vAxp6sTj','GIT_TEMP_JAVA','https://cdn.cqjjb.cn/jjb-cloud-config','API_HOST_TEST','toString','873ZOvCnG','1264956TWQCOH','http','getApiHost','readFileSync','7V-YUxhmh51Mdhgx4rq4','../package.json','parse','443016OVyMiP','5068JAlKCq','jjb-assembly-java','now','5jeiydO','GIT_TEMP_DIR','join','dev','GIT_HOST','test','FT3pKzxpRynFkmddJ9Bs','232jJDXMp','http://192.168.1.242:10985','2974829yhceUf','1134rhBbTK','hLqARY89CN6fUD3yg4NL','httpMethod'];a2_0x14f1=function(){return _0x1e0db2;};return a2_0x14f1();}(function(_0x166725,_0x34ed0c){const _0x20a729=a2_0x297a,_0x5ecbf6=_0x166725();while(!![]){try{const _0x4bf665=-parseInt(_0x20a729(0x122))/0x1*(parseInt(_0x20a729(0x138))/0x2)+parseInt(_0x20a729(0x123))/0x3+parseInt(_0x20a729(0x142))/0x4*(parseInt(_0x20a729(0x12e))/0x5)+parseInt(_0x20a729(0x12a))/0x6+-parseInt(_0x20a729(0x12b))/0x7*(parseInt(_0x20a729(0x135))/0x8)+-parseInt(_0x20a729(0x117))/0x9*(parseInt(_0x20a729(0x140))/0xa)+parseInt(_0x20a729(0x137))/0xb;if(_0x4bf665===_0x34ed0c)break;else _0x5ecbf6['push'](_0x5ecbf6['shift']());}catch(_0x52e2ec){_0x5ecbf6['push'](_0x5ecbf6['shift']());}}}(a2_0x14f1,0x459c4));const os=require('os'),path=require(a2_0x4edf64(0x13f)),fs=require('fs'),API_HOST=a2_0x4edf64(0x11a),API_HOST_HTTPS=a2_0x4edf64(0x13d),API_HOST_TEST='http://120.26.210.58:8089';exports['CONFIG_FILE_HOST']=a2_0x4edf64(0x11f),exports[a2_0x4edf64(0x11c)]=API_HOST,exports[a2_0x4edf64(0x120)]=API_HOST_TEST,exports[a2_0x4edf64(0x132)]=a2_0x4edf64(0x136),exports['GIT_TEMP_DIR']=a2_0x4edf64(0x118)+Date[a2_0x4edf64(0x12d)](),exports[a2_0x4edf64(0x11e)]=a2_0x4edf64(0x12c),exports[a2_0x4edf64(0x143)]={'development':a2_0x4edf64(0x131),'production':'prod','test':a2_0x4edf64(0x133)},exports[a2_0x4edf64(0x13e)]={'common':{'token':a2_0x4edf64(0x141),'projectId':0x117},'react-admin-component':{'token':a2_0x4edf64(0x134),'projectId':0x154},'jjb-dva-runtime':{'token':a2_0x4edf64(0x139),'projectId':0x23b},'jjb-common-lib':{'token':a2_0x4edf64(0x116),'projectId':0x23c},'jjb-common-decorator':{'token':a2_0x4edf64(0x119),'projectId':0x23e},'vue-unisass-component':{'token':a2_0x4edf64(0x11b),'projectId':0x153},'react-component':{'token':a2_0x4edf64(0x13c),'projectId':0x33f},'micro-app-ts':{'token':a2_0x4edf64(0x127),'projectId':0x33e},'micro-app':{'token':'FqNrmFAgrxasMrbbjvq9','projectId':0x33d},'lib':{'token':a2_0x4edf64(0x11d),'projectId':0x33c}},exports['TEMPLATE_FOLDER']=path[a2_0x4edf64(0x130)](os[a2_0x4edf64(0x13b)](),exports[a2_0x4edf64(0x12f)]),exports[a2_0x4edf64(0x125)]=()=>{const _0x109ed6=a2_0x4edf64;try{const _0x375dc1=JSON[_0x109ed6(0x129)](fs[_0x109ed6(0x126)](path[_0x109ed6(0x130)](__dirname,_0x109ed6(0x128)))[_0x109ed6(0x121)]());return _0x375dc1['env']===_0x109ed6(0x133)?API_HOST_TEST:_0x375dc1[_0x109ed6(0x13a)]===_0x109ed6(0x124)?API_HOST:API_HOST_HTTPS;}catch(_0x39d9f9){return API_HOST_HTTPS;}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function a3_0x21b3(){const _0x58e67e=['base64','message','crypto','readFileSync','concat','4ExKOKn','userInfo','aes-256-cbc','setAutoPadding','unlinkSync','path','randomBytes','arch','createHash','加密失败:\x20','认证文件不存在','existsSync','from','writeFileSync','algorithm','username','platform','sha256','unknown','1149486XhLbiw','读取认证信息失败:\x20','7542324nvIfoY','join','toString','saltLength','ivLength','11709648ZynNqj','hex','createDecipheriv','保存认证信息失败:\x20','2523123UQZsQx','解密失败:\x20','slice','keyLength','删除认证文件失败:\x20','sha512','update','12EtpQBL','2151285UNUzIX','926621NPDzek','2024176TZQomG','utf8','createCipheriv','final'];a3_0x21b3=function(){return _0x58e67e;};return a3_0x21b3();}const a3_0x41422f=a3_0x1cc9;(function(_0x4bf3f8,_0x1f8a97){const _0x588632=a3_0x1cc9,_0x464ec4=_0x4bf3f8();while(!![]){try{const _0x2886e9=-parseInt(_0x588632(0x16b))/0x1+-parseInt(_0x588632(0x175))/0x2*(-parseInt(_0x588632(0x188))/0x3)+-parseInt(_0x588632(0x169))/0x4*(-parseInt(_0x588632(0x16a))/0x5)+-parseInt(_0x588632(0x18a))/0x6+-parseInt(_0x588632(0x16c))/0x7+parseInt(_0x588632(0x18f))/0x8+-parseInt(_0x588632(0x162))/0x9;if(_0x2886e9===_0x1f8a97)break;else _0x464ec4['push'](_0x464ec4['shift']());}catch(_0x5d0399){_0x464ec4['push'](_0x464ec4['shift']());}}}(a3_0x21b3,0xbb67b));const crypto=require(a3_0x41422f(0x172)),fs=require('fs'),path=require(a3_0x41422f(0x17a)),CRYPTO_CONFIG={'algorithm':a3_0x41422f(0x177),'keyLength':0x20,'ivLength':0x10,'saltLength':0x20};function deriveKey(_0x24204c,_0x2ed4f1){const _0x3fa1ee=a3_0x41422f;return crypto['pbkdf2Sync'](_0x24204c,_0x2ed4f1,0x186a0,CRYPTO_CONFIG[_0x3fa1ee(0x165)],_0x3fa1ee(0x167));}function a3_0x1cc9(_0x3a8343,_0x58aac5){const _0x21b36d=a3_0x21b3();return a3_0x1cc9=function(_0x1cc9d8,_0xd01d55){_0x1cc9d8=_0x1cc9d8-0x15f;let _0x26942a=_0x21b36d[_0x1cc9d8];return _0x26942a;},a3_0x1cc9(_0x3a8343,_0x58aac5);}function generateSalt(){const _0x4cced2=a3_0x41422f;return crypto[_0x4cced2(0x17b)](CRYPTO_CONFIG[_0x4cced2(0x18d)]);}function generateIV(){const _0x2af246=a3_0x41422f;return crypto[_0x2af246(0x17b)](CRYPTO_CONFIG[_0x2af246(0x18e)]);}function encrypt(_0x1bdbc2,_0x390d23){const _0x2f5d41=a3_0x41422f;try{const _0x5ce49e=generateSalt(),_0x4eeeef=generateIV(),_0x3f1902=deriveKey(_0x390d23,_0x5ce49e),_0x48c59d=crypto[_0x2f5d41(0x16e)](CRYPTO_CONFIG[_0x2f5d41(0x183)],_0x3f1902,_0x4eeeef);_0x48c59d[_0x2f5d41(0x178)](!![]);let _0x5946d2=_0x48c59d['update'](_0x1bdbc2,'utf8','hex');_0x5946d2+=_0x48c59d[_0x2f5d41(0x16f)](_0x2f5d41(0x15f));const _0x4e1883=Buffer[_0x2f5d41(0x174)]([_0x5ce49e,_0x4eeeef,Buffer[_0x2f5d41(0x181)](_0x5946d2,'hex')]);return _0x4e1883[_0x2f5d41(0x18c)](_0x2f5d41(0x170));}catch(_0xdb6010){throw new Error(_0x2f5d41(0x17e)+_0xdb6010[_0x2f5d41(0x171)]);}}function decrypt(_0x578ec1,_0x48f331){const _0x4a0482=a3_0x41422f;try{const _0x136245=Buffer[_0x4a0482(0x181)](_0x578ec1,_0x4a0482(0x170)),_0x1b213c=_0x136245[_0x4a0482(0x164)](0x0,CRYPTO_CONFIG[_0x4a0482(0x18d)]),_0x269743=_0x136245[_0x4a0482(0x164)](CRYPTO_CONFIG[_0x4a0482(0x18d)],CRYPTO_CONFIG[_0x4a0482(0x18d)]+CRYPTO_CONFIG[_0x4a0482(0x18e)]),_0x2c7ff2=_0x136245[_0x4a0482(0x164)](CRYPTO_CONFIG[_0x4a0482(0x18d)]+CRYPTO_CONFIG[_0x4a0482(0x18e)]),_0x5cd02b=deriveKey(_0x48f331,_0x1b213c),_0x5b0716=crypto[_0x4a0482(0x160)](CRYPTO_CONFIG['algorithm'],_0x5cd02b,_0x269743);_0x5b0716['setAutoPadding'](!![]);let _0x435b1d=_0x5b0716[_0x4a0482(0x168)](_0x2c7ff2,null,_0x4a0482(0x16d));return _0x435b1d+=_0x5b0716[_0x4a0482(0x16f)](_0x4a0482(0x16d)),_0x435b1d;}catch(_0x56072e){throw new Error(_0x4a0482(0x163)+_0x56072e[_0x4a0482(0x171)]);}}function generateDeviceKey(){const _0x3a9a62=a3_0x41422f,_0x509f6b=require('os'),_0x3184d3=[_0x509f6b[_0x3a9a62(0x185)](),_0x509f6b[_0x3a9a62(0x17c)](),_0x509f6b['hostname'](),_0x509f6b[_0x3a9a62(0x176)]()[_0x3a9a62(0x184)]||_0x3a9a62(0x187)][_0x3a9a62(0x18b)]('|');return crypto[_0x3a9a62(0x17d)](_0x3a9a62(0x186))[_0x3a9a62(0x168)](_0x3184d3)['digest'](_0x3a9a62(0x15f));}function saveAuth(_0x4fd486,_0x49440b,_0xff3367){const _0x446c33=a3_0x41422f;try{const _0x130131=generateDeviceKey(),_0x24e702=_0x4fd486+'/'+_0x49440b,_0x468412=encrypt(_0x24e702,_0x130131);return fs[_0x446c33(0x182)](_0xff3367,_0x468412,{'mode':0x180}),!![];}catch(_0x259da0){throw new Error(_0x446c33(0x161)+_0x259da0[_0x446c33(0x171)]);}}function loadAuth(_0x5da67e){const _0x57ee4d=a3_0x41422f;try{if(!fs[_0x57ee4d(0x180)](_0x5da67e))throw new Error(_0x57ee4d(0x17f));const _0x40eaeb=generateDeviceKey(),_0x307a83=fs[_0x57ee4d(0x173)](_0x5da67e,_0x57ee4d(0x16d)),_0xde7446=decrypt(_0x307a83,_0x40eaeb),[_0x15de71,_0x309cf5]=_0xde7446['split']('/');if(!_0x15de71||!_0x309cf5)throw new Error('认证数据格式错误');return{'username':_0x15de71,'password':_0x309cf5};}catch(_0x45673a){throw new Error(_0x57ee4d(0x189)+_0x45673a['message']);}}function deleteAuth(_0xcbe020){const _0x38e3ce=a3_0x41422f;try{fs[_0x38e3ce(0x180)](_0xcbe020)&&fs[_0x38e3ce(0x179)](_0xcbe020);}catch(_0x2d962c){throw new Error(_0x38e3ce(0x166)+_0x2d962c['message']);}}module['exports']={'encrypt':encrypt,'decrypt':decrypt,'saveAuth':saveAuth,'loadAuth':loadAuth,'deleteAuth':deleteAuth,'generateDeviceKey':generateDeviceKey};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a4_0x32b18a=a4_0x1c03;(function(_0xd66141,_0x50d3fa){const _0x441ff1=a4_0x1c03,_0x1f3b58=_0xd66141();while(!![]){try{const _0x28fcb9=-parseInt(_0x441ff1(0xfd))/0x1+parseInt(_0x441ff1(0x10f))/0x2+-parseInt(_0x441ff1(0x113))/0x3+-parseInt(_0x441ff1(0xf8))/0x4*(parseInt(_0x441ff1(0x110))/0x5)+parseInt(_0x441ff1(0x10e))/0x6*(-parseInt(_0x441ff1(0xfa))/0x7)+-parseInt(_0x441ff1(0x10b))/0x8*(-parseInt(_0x441ff1(0xfc))/0x9)+parseInt(_0x441ff1(0xf4))/0xa*(parseInt(_0x441ff1(0x100))/0xb);if(_0x28fcb9===_0x50d3fa)break;else _0x1f3b58['push'](_0x1f3b58['shift']());}catch(_0x48ac75){_0x1f3b58['push'](_0x1f3b58['shift']());}}}(a4_0x2df2,0xf1d8a));function a4_0x2df2(){const _0xa95aa8=['用户名不能为空','write','获取认证信息失败:\x20','resume','stdin','3472eNVtwJ','./utils','data','2226108LJbRYe','1027826MoTayb','10QgjCWG','trim','slice','4327383yDRHXZ','请输入用户名:\x20','30lTUFwY','length','setEncoding','setRawMode','798852FPsgWw','exports','7jLUpfO','\x08\x20\x08','30087NFiExx','163627ummUAM','question','createInterface','5141983nRdWtI','用户取消输入','removeAllListeners','pause','请输入密码:\x20','stdout'];a4_0x2df2=function(){return _0xa95aa8;};return a4_0x2df2();}const readline=require('readline'),{logInfo,logError}=require(a4_0x32b18a(0x10c));function getHiddenPassword(_0x355bae=a4_0x32b18a(0x104)){return new Promise((_0x4e7cd6,_0x1e2ea2)=>{const _0x2d4c21=a4_0x1c03;process[_0x2d4c21(0x10a)][_0x2d4c21(0xf7)](!![]),process['stdin'][_0x2d4c21(0x109)](),process[_0x2d4c21(0x10a)][_0x2d4c21(0xf6)]('utf8');let _0x37dc90='';process['stdout']['write'](_0x355bae),process[_0x2d4c21(0x10a)]['on'](_0x2d4c21(0x10d),function(_0x1e6fe9){const _0x18b7af=_0x2d4c21;_0x1e6fe9=_0x1e6fe9+'';switch(_0x1e6fe9){case'\x0a':case'\x0d':case'\x04':process[_0x18b7af(0x10a)][_0x18b7af(0xf7)](![]),process[_0x18b7af(0x10a)][_0x18b7af(0x103)](),process[_0x18b7af(0x10a)][_0x18b7af(0x102)](_0x18b7af(0x10d)),process[_0x18b7af(0x105)]['write']('\x0a'),_0x4e7cd6(_0x37dc90);break;case'\x03':process[_0x18b7af(0x10a)][_0x18b7af(0xf7)](![]),process['stdin'][_0x18b7af(0x103)](),process[_0x18b7af(0x10a)][_0x18b7af(0x102)](_0x18b7af(0x10d)),process['stdout']['write']('\x0a'),_0x1e2ea2(new Error(_0x18b7af(0x101)));break;case'\x7f':case'\x08':_0x37dc90[_0x18b7af(0xf5)]>0x0&&(_0x37dc90=_0x37dc90[_0x18b7af(0x112)](0x0,-0x1),process['stdout'][_0x18b7af(0x107)](_0x18b7af(0xfb)));break;default:_0x1e6fe9['length']===0x1&&_0x1e6fe9>='\x20'&&(_0x37dc90+=_0x1e6fe9,process['stdout'][_0x18b7af(0x107)]('*'));break;}});});}async function getCredentials(_0x249fcd=null){const _0x4ffa59=a4_0x32b18a;try{let _0xd5da07=_0x249fcd;if(!_0xd5da07){const _0x4673bc=readline[_0x4ffa59(0xff)]({'input':process[_0x4ffa59(0x10a)],'output':process[_0x4ffa59(0x105)]});_0xd5da07=await new Promise(_0x710b85=>{const _0x31bd28=_0x4ffa59;_0x4673bc[_0x31bd28(0xfe)](_0x31bd28(0x114),_0x59861d=>{const _0x26e22d=_0x31bd28;_0x4673bc['close'](),_0x710b85(_0x59861d[_0x26e22d(0x111)]());});});if(!_0xd5da07)throw new Error(_0x4ffa59(0x106));}const _0x3f0bc6=await getHiddenPassword(_0x4ffa59(0x104));if(!_0x3f0bc6)throw new Error('密码不能为空');return{'username':_0xd5da07,'password':_0x3f0bc6};}catch(_0x32cd30){logError(_0x4ffa59(0x108)+_0x32cd30['message']);throw _0x32cd30;}}function a4_0x1c03(_0x168271,_0x2abfb5){const _0x2df2ab=a4_0x2df2();return a4_0x1c03=function(_0x1c0312,_0x597afb){_0x1c0312=_0x1c0312-0xf4;let _0x39a6e7=_0x2df2ab[_0x1c0312];return _0x39a6e7;},a4_0x1c03(_0x168271,_0x2abfb5);}async function interactiveAuth(){return await getCredentials();}module[a4_0x32b18a(0xf9)]={'getHiddenPassword':getHiddenPassword,'getCredentials':getCredentials,'interactiveAuth':interactiveAuth};
|
package/src/publish.js
CHANGED
|
@@ -1,222 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const os = require('os');
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const readline = require('readline');
|
|
5
|
-
const { getApiHost } = require('./config');
|
|
6
|
-
const {
|
|
7
|
-
CONSTANTS,
|
|
8
|
-
logInfo,
|
|
9
|
-
logSuccess,
|
|
10
|
-
logWarning,
|
|
11
|
-
logError,
|
|
12
|
-
executeCommand,
|
|
13
|
-
fileExists,
|
|
14
|
-
readFile,
|
|
15
|
-
writeFile
|
|
16
|
-
} = require('./utils');
|
|
17
|
-
|
|
18
|
-
const io = readline.createInterface({
|
|
19
|
-
input: process.stdin,
|
|
20
|
-
output: process.stdout
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 解析组件配置信息
|
|
25
|
-
* @param {string} distContent - 构建后的文件内容
|
|
26
|
-
* @returns {Object} 解析后的配置信息
|
|
27
|
-
*/
|
|
28
|
-
function parseComponentConfig(distContent) {
|
|
29
|
-
const matches = distContent.match(/(window\[).+?(\.componentKey|.+]={)/img);
|
|
30
|
-
if (!matches || !matches.length) {
|
|
31
|
-
throw new Error('请在组件入口文件中添加"window[props.componentKey]"以暴露组件的配置信息!');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const componentConfig = {};
|
|
35
|
-
|
|
36
|
-
// 解析 info 配置
|
|
37
|
-
const infoMatches = distContent.match(/componentKey.+([{,]info:\s{0,}{)/img);
|
|
38
|
-
if (!infoMatches || !infoMatches.length) {
|
|
39
|
-
throw new Error('暴露的配置信息中缺少"info"!');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let infoStr = '{';
|
|
43
|
-
const infoStr1 = distContent.split(infoMatches[0])[1];
|
|
44
|
-
for (let i = 0; i < infoStr1.length; i++) {
|
|
45
|
-
infoStr += infoStr1[i];
|
|
46
|
-
if (infoStr1[i] === '}') {
|
|
47
|
-
try {
|
|
48
|
-
const currJson = new Function(`return ${infoStr}`)();
|
|
49
|
-
Object.assign(componentConfig, currJson);
|
|
50
|
-
componentConfig.defaultSetting = {};
|
|
51
|
-
} catch (e) {
|
|
52
|
-
// 忽略解析错误
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 解析 settings 配置
|
|
59
|
-
const settingsMatches = distContent.match(/componentKey.+([{,]settings:\s{0,}{)/img);
|
|
60
|
-
if (!settingsMatches || !settingsMatches.length) {
|
|
61
|
-
throw new Error('暴露的配置信息中缺少"settings"!');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let settingsStr = '{';
|
|
65
|
-
const settingsStr1 = distContent.split(settingsMatches[0])[1];
|
|
66
|
-
for (let i = 0; i < settingsStr1.length; i++) {
|
|
67
|
-
settingsStr += settingsStr1[i];
|
|
68
|
-
if (settingsStr1[i] === '}') {
|
|
69
|
-
try {
|
|
70
|
-
componentConfig.defaultSetting = new Function(`return ${settingsStr}`)();
|
|
71
|
-
} catch (e) {
|
|
72
|
-
// 忽略解析错误
|
|
73
|
-
}
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return JSON.stringify(componentConfig);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* 执行构建命令
|
|
83
|
-
* @param {string} rootPath - 项目根路径
|
|
84
|
-
*/
|
|
85
|
-
function executeBuild(rootPath) {
|
|
86
|
-
const yarnLockPath = path.join(rootPath, 'yarn.lock');
|
|
87
|
-
if (fileExists(yarnLockPath)) {
|
|
88
|
-
executeCommand('yarn build:production', rootPath);
|
|
89
|
-
} else {
|
|
90
|
-
executeCommand('npm run build:production', rootPath);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* 验证必要的文件
|
|
96
|
-
* @param {string} rootPath - 项目根路径
|
|
97
|
-
* @returns {Object} 验证结果和文件路径
|
|
98
|
-
*/
|
|
99
|
-
function validateRequiredFiles(rootPath) {
|
|
100
|
-
const readmePath = path.join(rootPath, 'README.md');
|
|
101
|
-
const distPath = path.join(rootPath, 'dist', 'index.js');
|
|
102
|
-
const packageJsonPath = path.join(rootPath, 'package.json');
|
|
103
|
-
const thumbnailPath = path.join(rootPath, 'thumbnail.png');
|
|
104
|
-
|
|
105
|
-
if (!fileExists(packageJsonPath)) {
|
|
106
|
-
throw new Error('组件发布失败!根目录缺少\'package.json\'文件!');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!fileExists(distPath)) {
|
|
110
|
-
throw new Error('组件发布失败!根目录缺少\'dist/index.js\'文件!');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (!fileExists(readmePath)) {
|
|
114
|
-
throw new Error('请在组件根目录添加一个README.md说明文件!');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (!fileExists(thumbnailPath)) {
|
|
118
|
-
throw new Error('请在组件根目录为组件添加一个缩略图"thumbnail.png"文件!');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
readmePath,
|
|
123
|
-
distPath,
|
|
124
|
-
packageJsonPath,
|
|
125
|
-
thumbnailPath
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* 提交发布数据
|
|
131
|
-
* @param {string} message - 发布消息
|
|
132
|
-
* @param {Object} pushData - 发布数据
|
|
133
|
-
*/
|
|
134
|
-
const submitFun = function (message, pushData) {
|
|
135
|
-
pushData.message = message || 'no message';
|
|
136
|
-
axios.post(`${getApiHost()}/api/file/publish`, pushData).then(res => {
|
|
137
|
-
logSuccess(res.data.message);
|
|
138
|
-
process.exit(0);
|
|
139
|
-
}).catch(e => {
|
|
140
|
-
logError(`组件发布失败!${e.message}`);
|
|
141
|
-
process.exit(1);
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
module.exports = version => {
|
|
146
|
-
const authPath = path.join(__dirname, '../.auth');
|
|
147
|
-
|
|
148
|
-
if (!fileExists(authPath)) {
|
|
149
|
-
logError('请先登录!');
|
|
150
|
-
process.exit(1);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const [ username, password ] = readFile(authPath).split('/');
|
|
154
|
-
logInfo('Auth: 正在获取授权!');
|
|
155
|
-
|
|
156
|
-
axios.post(`${getApiHost()}/api/auth`, {
|
|
157
|
-
username,
|
|
158
|
-
password
|
|
159
|
-
}).then(res => {
|
|
160
|
-
if (res.data.status) {
|
|
161
|
-
logSuccess('Auth: 授权成功!');
|
|
162
|
-
|
|
163
|
-
const rootPath = path.resolve('./');
|
|
164
|
-
logInfo('Please wait, build ...', rootPath);
|
|
165
|
-
|
|
166
|
-
// 执行构建
|
|
167
|
-
executeBuild(rootPath);
|
|
168
|
-
|
|
169
|
-
// 验证必要文件
|
|
170
|
-
let filePaths;
|
|
171
|
-
try {
|
|
172
|
-
filePaths = validateRequiredFiles(rootPath);
|
|
173
|
-
} catch (error) {
|
|
174
|
-
logError(error.message);
|
|
175
|
-
process.exit(1);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// 读取包信息
|
|
179
|
-
const packageJsonFile = JSON.parse(readFile(path.join(__dirname, '../package.json')));
|
|
180
|
-
const { version: cmdVersion } = packageJsonFile;
|
|
181
|
-
|
|
182
|
-
// 准备发布数据
|
|
183
|
-
const pushData = {
|
|
184
|
-
username,
|
|
185
|
-
cmd_version: cmdVersion,
|
|
186
|
-
hostname: os.hostname(),
|
|
187
|
-
platform: os.platform(),
|
|
188
|
-
package_version: version || 0,
|
|
189
|
-
package_content: readFile(filePaths.distPath),
|
|
190
|
-
readme_content: readFile(filePaths.readmePath)
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
// 解析组件配置
|
|
194
|
-
try {
|
|
195
|
-
const distContent = readFile(filePaths.distPath);
|
|
196
|
-
pushData.component_config_content = parseComponentConfig(distContent);
|
|
197
|
-
} catch (error) {
|
|
198
|
-
logError(error.message);
|
|
199
|
-
process.exit(1);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// 处理缩略图
|
|
203
|
-
const thumbnailData = readFile(filePaths.thumbnailPath, 'binary');
|
|
204
|
-
pushData.thumbnail_base64 = Buffer.from(thumbnailData, 'binary').toString('base64');
|
|
205
|
-
|
|
206
|
-
// 提交发布
|
|
207
|
-
if (packageJsonFile.pushMessage === 'no') {
|
|
208
|
-
submitFun(null, pushData);
|
|
209
|
-
} else {
|
|
210
|
-
io.question('请输入此次组件发布的信息,按Enter确认:', function (message) {
|
|
211
|
-
submitFun(message, pushData);
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
} else {
|
|
215
|
-
logError('授权失败!');
|
|
216
|
-
process.exit(1);
|
|
217
|
-
}
|
|
218
|
-
}).catch(e => {
|
|
219
|
-
logError(`授权失败,未知错误!${e.message}`);
|
|
220
|
-
process.exit(1);
|
|
221
|
-
});
|
|
222
|
-
};
|
|
1
|
+
const a5_0xd34164=a5_0x24a0;(function(_0x90738,_0x40cee3){const _0x413ecb=a5_0x24a0,_0x87869f=_0x90738();while(!![]){try{const _0x4ad5b9=parseInt(_0x413ecb(0x150))/0x1+-parseInt(_0x413ecb(0x113))/0x2*(parseInt(_0x413ecb(0x119))/0x3)+parseInt(_0x413ecb(0x129))/0x4*(parseInt(_0x413ecb(0x11d))/0x5)+parseInt(_0x413ecb(0x135))/0x6*(parseInt(_0x413ecb(0x128))/0x7)+-parseInt(_0x413ecb(0x134))/0x8*(-parseInt(_0x413ecb(0x122))/0x9)+-parseInt(_0x413ecb(0x11e))/0xa*(parseInt(_0x413ecb(0x12c))/0xb)+-parseInt(_0x413ecb(0x11b))/0xc;if(_0x4ad5b9===_0x40cee3)break;else _0x87869f['push'](_0x87869f['shift']());}catch(_0x2186ef){_0x87869f['push'](_0x87869f['shift']());}}}(a5_0x3f50,0x28ed3));const path=require('path'),os=require('os'),axios=require(a5_0xd34164(0x130)),readline=require(a5_0xd34164(0x112)),{getApiHost}=require(a5_0xd34164(0x139)),{CONSTANTS,logInfo,logSuccess,logWarning,logError,executeCommand,fileExists,readFile,writeFile}=require(a5_0xd34164(0x13c)),{loadAuth}=require(a5_0xd34164(0x118)),io=readline[a5_0xd34164(0x114)]({'input':process['stdin'],'output':process['stdout']});function a5_0x24a0(_0x4b889a,_0x58f18f){const _0x3f507d=a5_0x3f50();return a5_0x24a0=function(_0x24a08b,_0x2d8a45){_0x24a08b=_0x24a08b-0x110;let _0x4cc136=_0x3f507d[_0x24a08b];return _0x4cc136;},a5_0x24a0(_0x4b889a,_0x58f18f);}function a5_0x3f50(){const _0x4c5caa=['dist','pushMessage','暴露的配置信息中缺少\x22info\x22!','暴露的配置信息中缺少\x22settings\x22!','toString','thumbnail_base64','status','README.md','318203xJaLyg','no\x20message','question','resolve','hostname','yarn\x20build:production','readline','67166rJQYTN','createInterface','请在组件根目录添加一个README.md说明文件!','length','match','./crypto-utils','3SsFNgK','assign','5092296eYFQFY','data','875uKygsX','32390vjUoQR','Please\x20wait,\x20build\x20...','catch','from','63TRLdvi','split','join','message','return\x20','../.auth','7jKTRon','1116esPKNN','stringify','/api/file/publish','374HnqDHP','exit','请在组件根目录为组件添加一个缩略图\x22thumbnail.png\x22文件!','distPath','axios','读取认证信息失败!','post','readmePath','284248RAesnS','719742lFPgPZ','index.js','/api/auth','thumbnailPath','./config','thumbnail.png','platform','./utils','yarn.lock','授权失败!','请在组件入口文件中添加\x22window[props.componentKey]\x22以暴露组件的配置信息!','请输入此次组件发布的信息,按Enter确认:','npm\x20run\x20build:production','component_config_content','binary','defaultSetting','then','组件发布失败!根目录缺少\x27package.json\x27文件!','组件发布失败!'];a5_0x3f50=function(){return _0x4c5caa;};return a5_0x3f50();}function parseComponentConfig(_0x5c4d14){const _0x2f0e72=a5_0xd34164,_0x2aa30d=_0x5c4d14[_0x2f0e72(0x117)](/(window\[).+?(\.componentKey|.+]={)/img);if(!_0x2aa30d||!_0x2aa30d[_0x2f0e72(0x116)])throw new Error(_0x2f0e72(0x13f));const _0x18c8ad={},_0x23d579=_0x5c4d14[_0x2f0e72(0x117)](/componentKey.+([{,]info:\s{0,}{)/img);if(!_0x23d579||!_0x23d579[_0x2f0e72(0x116)])throw new Error(_0x2f0e72(0x14a));let _0x40a28c='{';const _0x552e3e=_0x5c4d14[_0x2f0e72(0x123)](_0x23d579[0x0])[0x1];for(let _0x551931=0x0;_0x551931<_0x552e3e[_0x2f0e72(0x116)];_0x551931++){_0x40a28c+=_0x552e3e[_0x551931];if(_0x552e3e[_0x551931]==='}'){try{const _0x19d827=new Function(_0x2f0e72(0x126)+_0x40a28c)();Object[_0x2f0e72(0x11a)](_0x18c8ad,_0x19d827),_0x18c8ad[_0x2f0e72(0x144)]={};}catch(_0x186993){}break;}}const _0x3c32b2=_0x5c4d14['match'](/componentKey.+([{,]settings:\s{0,}{)/img);if(!_0x3c32b2||!_0x3c32b2[_0x2f0e72(0x116)])throw new Error(_0x2f0e72(0x14b));let _0x54bf01='{';const _0xe2dd60=_0x5c4d14[_0x2f0e72(0x123)](_0x3c32b2[0x0])[0x1];for(let _0x34cb0a=0x0;_0x34cb0a<_0xe2dd60['length'];_0x34cb0a++){_0x54bf01+=_0xe2dd60[_0x34cb0a];if(_0xe2dd60[_0x34cb0a]==='}'){try{_0x18c8ad['defaultSetting']=new Function(_0x2f0e72(0x126)+_0x54bf01)();}catch(_0x1a8785){}break;}}return JSON[_0x2f0e72(0x12a)](_0x18c8ad);}function executeBuild(_0x137477){const _0x35974f=a5_0xd34164,_0x150291=path[_0x35974f(0x124)](_0x137477,_0x35974f(0x13d));fileExists(_0x150291)?executeCommand(_0x35974f(0x111),_0x137477):executeCommand(_0x35974f(0x141),_0x137477);}function validateRequiredFiles(_0x156ee6){const _0x512ffc=a5_0xd34164,_0x58ca63=path[_0x512ffc(0x124)](_0x156ee6,_0x512ffc(0x14f)),_0x412a63=path[_0x512ffc(0x124)](_0x156ee6,_0x512ffc(0x148),_0x512ffc(0x136)),_0x4a7309=path[_0x512ffc(0x124)](_0x156ee6,'package.json'),_0x3f14cc=path[_0x512ffc(0x124)](_0x156ee6,_0x512ffc(0x13a));if(!fileExists(_0x4a7309))throw new Error(_0x512ffc(0x146));if(!fileExists(_0x412a63))throw new Error('组件发布失败!根目录缺少\x27dist/index.js\x27文件!');if(!fileExists(_0x58ca63))throw new Error(_0x512ffc(0x115));if(!fileExists(_0x3f14cc))throw new Error(_0x512ffc(0x12e));return{'readmePath':_0x58ca63,'distPath':_0x412a63,'packageJsonPath':_0x4a7309,'thumbnailPath':_0x3f14cc};}const submitFun=function(_0x521ca3,_0x192309){const _0x14e178=a5_0xd34164;_0x192309[_0x14e178(0x125)]=_0x521ca3||_0x14e178(0x151),axios[_0x14e178(0x132)](getApiHost()+_0x14e178(0x12b),_0x192309)['then'](_0x230826=>{const _0x53f9cf=_0x14e178;logSuccess(_0x230826[_0x53f9cf(0x11c)][_0x53f9cf(0x125)]),process['exit'](0x0);})[_0x14e178(0x120)](_0x477504=>{const _0x2c8a47=_0x14e178;logError(_0x2c8a47(0x147)+_0x477504['message']),process[_0x2c8a47(0x12d)](0x1);});};module['exports']=_0x16e3ca=>{const _0x219cb2=a5_0xd34164,_0x17a536=path[_0x219cb2(0x124)](__dirname,_0x219cb2(0x127));!fileExists(_0x17a536)&&(logError('请先登录!'),process['exit'](0x1));let _0x203e11,_0x4f57a7;try{const _0x3617ee=loadAuth(_0x17a536);_0x203e11=_0x3617ee['username'],_0x4f57a7=_0x3617ee['password'];}catch(_0x8e244){logError(_0x219cb2(0x131)+_0x8e244[_0x219cb2(0x125)]),process['exit'](0x1);}logInfo('Auth:\x20正在获取授权!'),axios[_0x219cb2(0x132)](getApiHost()+_0x219cb2(0x137),{'username':_0x203e11,'password':_0x4f57a7})[_0x219cb2(0x145)](_0x5ebc99=>{const _0x108dbf=_0x219cb2;if(_0x5ebc99[_0x108dbf(0x11c)][_0x108dbf(0x14e)]){logSuccess('Auth:\x20授权成功!');const _0x2cef76=path[_0x108dbf(0x153)]('./');logInfo(_0x108dbf(0x11f),_0x2cef76),executeBuild(_0x2cef76);let _0x4cf77d;try{_0x4cf77d=validateRequiredFiles(_0x2cef76);}catch(_0x43999c){logError(_0x43999c[_0x108dbf(0x125)]),process['exit'](0x1);}const _0x30b203=JSON['parse'](readFile(path[_0x108dbf(0x124)](__dirname,'../package.json'))),{version:_0x49fb9b}=_0x30b203,_0x3ad7b9={'username':_0x203e11,'cmd_version':_0x49fb9b,'hostname':os[_0x108dbf(0x110)](),'platform':os[_0x108dbf(0x13b)](),'package_version':_0x16e3ca||0x0,'package_content':readFile(_0x4cf77d['distPath']),'readme_content':readFile(_0x4cf77d[_0x108dbf(0x133)])};try{const _0x168385=readFile(_0x4cf77d[_0x108dbf(0x12f)]);_0x3ad7b9[_0x108dbf(0x142)]=parseComponentConfig(_0x168385);}catch(_0x4979e8){logError(_0x4979e8[_0x108dbf(0x125)]),process[_0x108dbf(0x12d)](0x1);}const _0x27b64d=readFile(_0x4cf77d[_0x108dbf(0x138)],'binary');_0x3ad7b9[_0x108dbf(0x14d)]=Buffer[_0x108dbf(0x121)](_0x27b64d,_0x108dbf(0x143))[_0x108dbf(0x14c)]('base64'),_0x30b203[_0x108dbf(0x149)]==='no'?submitFun(null,_0x3ad7b9):io[_0x108dbf(0x152)](_0x108dbf(0x140),function(_0x9c6586){submitFun(_0x9c6586,_0x3ad7b9);});}else logError(_0x108dbf(0x13e)),process[_0x108dbf(0x12d)](0x1);})[_0x219cb2(0x120)](_0x4d9213=>{const _0x541923=_0x219cb2;logError('授权失败,未知错误!'+_0x4d9213[_0x541923(0x125)]),process[_0x541923(0x12d)](0x1);});};
|
package/src/push.js
CHANGED
|
@@ -1,283 +1 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const {
|
|
4
|
-
CopyFolder,
|
|
5
|
-
DeleteDirAllFile
|
|
6
|
-
} = require('./utils');
|
|
7
|
-
const {
|
|
8
|
-
GIT_TEMP_JAVA,
|
|
9
|
-
getApiHost
|
|
10
|
-
} = require('./config');
|
|
11
|
-
const axios = require('axios');
|
|
12
|
-
const {
|
|
13
|
-
CONSTANTS,
|
|
14
|
-
logInfo,
|
|
15
|
-
logSuccess,
|
|
16
|
-
logWarning,
|
|
17
|
-
logError,
|
|
18
|
-
executeCommand,
|
|
19
|
-
deleteFolderRecursive,
|
|
20
|
-
fileExists,
|
|
21
|
-
readFile,
|
|
22
|
-
writeFile,
|
|
23
|
-
createDir,
|
|
24
|
-
isViteProject,
|
|
25
|
-
validateConfig,
|
|
26
|
-
validateEnvironment
|
|
27
|
-
} = require('./utils');
|
|
28
|
-
|
|
29
|
-
module.exports = arguments => {
|
|
30
|
-
// 参数验证
|
|
31
|
-
if (arguments.length < 2) {
|
|
32
|
-
logError('命令参数传递错误!');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// 存储当前任务的临时文件夹名称,用于进程退出时清理
|
|
37
|
-
let currentTempDir = null;
|
|
38
|
-
|
|
39
|
-
const authPath = path.join(__dirname, '../.auth');
|
|
40
|
-
|
|
41
|
-
if (!fileExists(authPath)) {
|
|
42
|
-
logError('请先登录!');
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 环境
|
|
48
|
-
*/
|
|
49
|
-
const environment = arguments[ 1 ];
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 描述
|
|
53
|
-
*/
|
|
54
|
-
const describe = arguments[ 2 ] || '"no message"';
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 更多参数
|
|
58
|
-
* @type {*|*[]}
|
|
59
|
-
*/
|
|
60
|
-
const parameter = arguments[ 3 ]
|
|
61
|
-
? arguments[ 3 ].split('-')
|
|
62
|
-
: [];
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* 当前根路径
|
|
66
|
-
* @type {Promise<void> | Promise<string>}
|
|
67
|
-
*/
|
|
68
|
-
const root_path = path.resolve('./');
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* jjb配置文件路径
|
|
72
|
-
* @type {string}
|
|
73
|
-
*/
|
|
74
|
-
const config_json_path = path.join(root_path, CONSTANTS.CONFIG_FILE_NAME);
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 打包输出目录
|
|
78
|
-
* @type {string}
|
|
79
|
-
*/
|
|
80
|
-
const build_output_dir = path.join(root_path, CONSTANTS.BUILD_OUTPUT_DIR);
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 临时目录
|
|
84
|
-
*/
|
|
85
|
-
const tmpdir = os.tmpdir();
|
|
86
|
-
|
|
87
|
-
const [ username, password ] = readFile(authPath).split('/');
|
|
88
|
-
logInfo('Auth: 正在获取授权!');
|
|
89
|
-
axios.post(`${getApiHost()}/api/auth`, {
|
|
90
|
-
username,
|
|
91
|
-
password
|
|
92
|
-
}).then(async res => {
|
|
93
|
-
if (res.data.status) {
|
|
94
|
-
logSuccess('Auth: 授权成功!');
|
|
95
|
-
if (!fileExists(config_json_path)) {
|
|
96
|
-
logError('当前应用中不存在"jjb.config.json"文件!');
|
|
97
|
-
process.exit(1);
|
|
98
|
-
} else {
|
|
99
|
-
// 支持 ESM 和 CJS 模块导入
|
|
100
|
-
let jjbConfig;
|
|
101
|
-
// 如果 ESM 导入失败,回退到 require
|
|
102
|
-
jjbConfig = require(config_json_path);
|
|
103
|
-
jjbConfig = jjbConfig.__esModule ? jjbConfig.default : jjbConfig;
|
|
104
|
-
// 验证必要的配置字段
|
|
105
|
-
const requiredFields = ['javaGit', 'javaGitName', 'appIdentifier'];
|
|
106
|
-
const configValidation = validateConfig(jjbConfig, requiredFields);
|
|
107
|
-
|
|
108
|
-
if (!configValidation.isValid) {
|
|
109
|
-
logError(`"jjb.config.json"中缺少必要字段: ${configValidation.missingFields.join(', ')}`);
|
|
110
|
-
process.exit(1);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// 验证环境配置
|
|
114
|
-
if (!validateEnvironment(jjbConfig, environment)) {
|
|
115
|
-
logError(`未找到环境配置 [${environment}]!`);
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// 为每个打包任务创建唯一的临时文件夹
|
|
120
|
-
const uniqueTempDir = `${GIT_TEMP_JAVA}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
121
|
-
currentTempDir = uniqueTempDir; // 存储当前临时文件夹名称
|
|
122
|
-
const tempGit = path.join(tmpdir, uniqueTempDir);
|
|
123
|
-
|
|
124
|
-
if (fileExists(tempGit)) {
|
|
125
|
-
deleteFolderRecursive(tempGit);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
createDir(tempGit);
|
|
129
|
-
|
|
130
|
-
const projectDir = path.join(tempGit, jjbConfig.javaGitName);
|
|
131
|
-
|
|
132
|
-
if (fileExists(projectDir)) {
|
|
133
|
-
if (parameter.includes('force')) {
|
|
134
|
-
DeleteDirAllFile(projectDir, () => {
|
|
135
|
-
executeCommand(`git clone ${jjbConfig.javaGit}`, tempGit);
|
|
136
|
-
});
|
|
137
|
-
} else {
|
|
138
|
-
executeCommand(`git clone ${jjbConfig.javaGit}`, tempGit);
|
|
139
|
-
}
|
|
140
|
-
} else {
|
|
141
|
-
executeCommand(`git clone ${jjbConfig.javaGit}`, tempGit);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
project_sync(tempGit, jjbConfig, uniqueTempDir);
|
|
145
|
-
}
|
|
146
|
-
} else {
|
|
147
|
-
logError('授权失败!');
|
|
148
|
-
process.exit(1);
|
|
149
|
-
}
|
|
150
|
-
}).catch(e => {
|
|
151
|
-
logError(`未知错误!${e.message}`);
|
|
152
|
-
process.exit(1);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// 进程退出时清理临时文件夹
|
|
156
|
-
process.on('exit', () => {
|
|
157
|
-
if (currentTempDir) {
|
|
158
|
-
const tempDirToClean = path.join(os.tmpdir(), currentTempDir);
|
|
159
|
-
if (fileExists(tempDirToClean)) {
|
|
160
|
-
try {
|
|
161
|
-
deleteFolderRecursive(tempDirToClean);
|
|
162
|
-
} catch (e) {
|
|
163
|
-
// 静默处理清理失败的情况
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// 处理未捕获的异常
|
|
170
|
-
process.on('uncaughtException', (error) => {
|
|
171
|
-
if (currentTempDir) {
|
|
172
|
-
const tempDirToClean = path.join(os.tmpdir(), currentTempDir);
|
|
173
|
-
if (fileExists(tempDirToClean)) {
|
|
174
|
-
try {
|
|
175
|
-
deleteFolderRecursive(tempDirToClean);
|
|
176
|
-
} catch (e) {
|
|
177
|
-
// 静默处理清理失败的情况
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
throw error;
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* 应用git同步
|
|
186
|
-
*/
|
|
187
|
-
function project_sync(tempGit, jjbConfig, uniqueTempDir) {
|
|
188
|
-
const envData = jjbConfig.environment[ environment ];
|
|
189
|
-
const projectDir = path.join(tempGit, jjbConfig.javaGitName);
|
|
190
|
-
|
|
191
|
-
if (!envData.javaGitBranch) {
|
|
192
|
-
logWarning(`当前打包 [Env#${environment}] 未配置"javaGitBranch",将使用默认分支"master"!`);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
executeCommand(`git pull`, projectDir);
|
|
196
|
-
|
|
197
|
-
if (!fileExists(path.join(root_path, 'node_modules'))) {
|
|
198
|
-
logWarning('当前应用未安装依赖!即将执行依赖安装命令,请稍等!');
|
|
199
|
-
executeCommand(`yarn`, root_path);
|
|
200
|
-
logSuccess('应用依赖安装完成!');
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// 检查是否为 Vite 项目
|
|
204
|
-
const isVite = isViteProject(root_path);
|
|
205
|
-
|
|
206
|
-
if (isVite) {
|
|
207
|
-
logInfo("项目为Vite项目,即将执行yarn run build命令");
|
|
208
|
-
executeCommand(`yarn run build`, root_path, { maxBuffer: CONSTANTS.MAX_BUFFER_SIZE });
|
|
209
|
-
} else {
|
|
210
|
-
logInfo(`项目为Webpack项目,即将进行应用打包 [Env#${environment}] 请稍等!`);
|
|
211
|
-
executeCommand(`yarn build:${environment}`, root_path, { maxBuffer: CONSTANTS.MAX_BUFFER_SIZE });
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
logSuccess('应用打包完成!');
|
|
215
|
-
|
|
216
|
-
if (fileExists(build_output_dir)) {
|
|
217
|
-
const appIdentifier = jjbConfig.appIdentifier;
|
|
218
|
-
const indexContent = readFile(path.join(build_output_dir, 'index.html'));
|
|
219
|
-
|
|
220
|
-
if (parameter.includes('index')) {
|
|
221
|
-
writeFile(path.join(build_output_dir, 'index.html'), indexContent);
|
|
222
|
-
} else {
|
|
223
|
-
writeFile(path.join(build_output_dir, `${appIdentifier}.html`), indexContent);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const tempJavaPath = path.join(projectDir, CONSTANTS.TEMPLATES_PATH);
|
|
227
|
-
|
|
228
|
-
createDir(tempJavaPath);
|
|
229
|
-
|
|
230
|
-
const javaGitBranch = envData.javaGitBranch
|
|
231
|
-
? envData.javaGitBranch
|
|
232
|
-
: CONSTANTS.DEFAULT_BRANCH;
|
|
233
|
-
|
|
234
|
-
executeCommand(`git checkout ${javaGitBranch}`, projectDir);
|
|
235
|
-
|
|
236
|
-
const projectJavaPath = path.join(tempJavaPath, jjbConfig.appIdentifier);
|
|
237
|
-
|
|
238
|
-
DeleteDirAllFile(projectJavaPath, () => {
|
|
239
|
-
createDir(projectJavaPath);
|
|
240
|
-
writeFile(path.join(projectJavaPath, '.html'), indexContent);
|
|
241
|
-
|
|
242
|
-
CopyFolder(path.join(build_output_dir, jjbConfig.appIdentifier), projectJavaPath, () => {
|
|
243
|
-
setTimeout(() => {
|
|
244
|
-
executeCommand(`git pull`, projectDir);
|
|
245
|
-
executeCommand(`git add .`, projectDir);
|
|
246
|
-
try {
|
|
247
|
-
executeCommand(`git commit -m ${describe} --no-verify`, projectDir);
|
|
248
|
-
} catch (e) {
|
|
249
|
-
logWarning(`Git commit 失败,可能没有变更需要提交: ${e.message}`);
|
|
250
|
-
}
|
|
251
|
-
executeCommand(`git push`, projectDir);
|
|
252
|
-
|
|
253
|
-
// 清理临时文件夹
|
|
254
|
-
setTimeout(() => {
|
|
255
|
-
const tempDirToClean = path.join(os.tmpdir(), uniqueTempDir);
|
|
256
|
-
if (fileExists(tempDirToClean)) {
|
|
257
|
-
try {
|
|
258
|
-
deleteFolderRecursive(tempDirToClean);
|
|
259
|
-
logInfo(`临时文件夹已清理: ${uniqueTempDir}`);
|
|
260
|
-
} catch (e) {
|
|
261
|
-
logWarning(`清理临时文件夹失败: ${e.message}`);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}, CONSTANTS.SYNC_DELAY * 2); // 延迟清理,确保git操作完成
|
|
265
|
-
}, CONSTANTS.SYNC_DELAY);
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
} else {
|
|
269
|
-
logError('未知错误,未找到"dist"目录!');
|
|
270
|
-
// 清理临时文件夹
|
|
271
|
-
const tempDirToClean = path.join(os.tmpdir(), uniqueTempDir);
|
|
272
|
-
if (fileExists(tempDirToClean)) {
|
|
273
|
-
try {
|
|
274
|
-
deleteFolderRecursive(tempDirToClean);
|
|
275
|
-
logInfo(`临时文件夹已清理: ${uniqueTempDir}`);
|
|
276
|
-
} catch (e) {
|
|
277
|
-
logWarning(`清理临时文件夹失败: ${e.message}`);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
process.exit(1);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
};
|
|
1
|
+
const a6_0x553c7d=a6_0x403c;function a6_0x403c(_0x50af48,_0x5bf631){const _0x1a3f99=a6_0x1a3f();return a6_0x403c=function(_0x403c0f,_0x493a7f){_0x403c0f=_0x403c0f-0x12b;let _0xe0dcf0=_0x1a3f99[_0x403c0f];return _0xe0dcf0;},a6_0x403c(_0x50af48,_0x5bf631);}(function(_0x3cb185,_0x335ea3){const _0x230384=a6_0x403c,_0x1ccef0=_0x3cb185();while(!![]){try{const _0xcd18ee=parseInt(_0x230384(0x171))/0x1+-parseInt(_0x230384(0x167))/0x2+-parseInt(_0x230384(0x146))/0x3*(parseInt(_0x230384(0x13a))/0x4)+-parseInt(_0x230384(0x13c))/0x5*(parseInt(_0x230384(0x130))/0x6)+parseInt(_0x230384(0x158))/0x7*(parseInt(_0x230384(0x154))/0x8)+-parseInt(_0x230384(0x13e))/0x9+parseInt(_0x230384(0x14a))/0xa;if(_0xcd18ee===_0x335ea3)break;else _0x1ccef0['push'](_0x1ccef0['shift']());}catch(_0x4848bd){_0x1ccef0['push'](_0x1ccef0['shift']());}}}(a6_0x1a3f,0xb3dbc));const os=require('os'),path=require(a6_0x553c7d(0x141)),{CopyFolder,DeleteDirAllFile}=require('./utils'),{GIT_TEMP_JAVA,getApiHost}=require('./config'),axios=require(a6_0x553c7d(0x16c)),{CONSTANTS,logInfo,logSuccess,logWarning,logError,executeCommand,deleteFolderRecursive,fileExists,readFile,writeFile,createDir,isViteProject,validateConfig,validateEnvironment}=require(a6_0x553c7d(0x132)),{loadAuth}=require(a6_0x553c7d(0x15c));module[a6_0x553c7d(0x13b)]=arguments=>{const _0x3f3f89=a6_0x553c7d;arguments[_0x3f3f89(0x138)]<0x2&&(logError(_0x3f3f89(0x139)),process[_0x3f3f89(0x165)](0x1));let _0x3fb7a6=null;const _0x156cde=path[_0x3f3f89(0x144)](__dirname,_0x3f3f89(0x152));!fileExists(_0x156cde)&&(logError(_0x3f3f89(0x162)),process['exit'](0x1));let _0x5b2dda,_0x3d2695;try{const _0x3a803f=loadAuth(_0x156cde);_0x5b2dda=_0x3a803f[_0x3f3f89(0x14f)],_0x3d2695=_0x3a803f[_0x3f3f89(0x145)];}catch(_0xe6d7f2){logError(_0x3f3f89(0x16d)+_0xe6d7f2[_0x3f3f89(0x163)]),process['exit'](0x1);}const _0x474606=arguments[0x1],_0x527981=arguments[0x2]||_0x3f3f89(0x131),_0x44a917=arguments[0x3]?arguments[0x3][_0x3f3f89(0x137)]('-'):[],_0x37572d=path[_0x3f3f89(0x136)]('./'),_0x4a5d9a=path[_0x3f3f89(0x144)](_0x37572d,CONSTANTS[_0x3f3f89(0x13d)]),_0x217702=path[_0x3f3f89(0x144)](_0x37572d,CONSTANTS[_0x3f3f89(0x161)]),_0x284113=os[_0x3f3f89(0x160)]();logInfo(_0x3f3f89(0x153)),axios[_0x3f3f89(0x13f)](getApiHost()+_0x3f3f89(0x16a),{'username':_0x5b2dda,'password':_0x3d2695})[_0x3f3f89(0x15b)](async _0x25099c=>{const _0x300d00=_0x3f3f89;if(_0x25099c[_0x300d00(0x12c)][_0x300d00(0x15f)]){logSuccess(_0x300d00(0x142));if(!fileExists(_0x4a5d9a))logError('当前应用中不存在\x22jjb.config.json\x22文件!'),process[_0x300d00(0x165)](0x1);else{let _0x290896;_0x290896=require(_0x4a5d9a),_0x290896=_0x290896[_0x300d00(0x12d)]?_0x290896['default']:_0x290896;const _0x3e2067=[_0x300d00(0x14c),_0x300d00(0x14b),'appIdentifier'],_0x11838a=validateConfig(_0x290896,_0x3e2067);!_0x11838a[_0x300d00(0x12e)]&&(logError(_0x300d00(0x169)+_0x11838a['missingFields']['join'](',\x20')),process[_0x300d00(0x165)](0x1));!validateEnvironment(_0x290896,_0x474606)&&(logError(_0x300d00(0x164)+_0x474606+']!'),process[_0x300d00(0x165)](0x1));const _0x553301=GIT_TEMP_JAVA+'-'+Date[_0x300d00(0x15e)]()+'-'+Math[_0x300d00(0x12b)]()['toString'](0x24)[_0x300d00(0x143)](0x2,0x9);_0x3fb7a6=_0x553301;const _0x3f3cce=path['join'](_0x284113,_0x553301);fileExists(_0x3f3cce)&&deleteFolderRecursive(_0x3f3cce);createDir(_0x3f3cce);const _0x336431=path[_0x300d00(0x144)](_0x3f3cce,_0x290896[_0x300d00(0x14b)]);fileExists(_0x336431)?_0x44a917[_0x300d00(0x16f)](_0x300d00(0x14e))?DeleteDirAllFile(_0x336431,()=>{const _0x4f847e=_0x300d00;executeCommand(_0x4f847e(0x174)+_0x290896[_0x4f847e(0x14c)],_0x3f3cce);}):executeCommand(_0x300d00(0x174)+_0x290896[_0x300d00(0x14c)],_0x3f3cce):executeCommand(_0x300d00(0x174)+_0x290896[_0x300d00(0x14c)],_0x3f3cce),_0x5bddae(_0x3f3cce,_0x290896,_0x553301);}}else logError(_0x300d00(0x149)),process[_0x300d00(0x165)](0x1);})[_0x3f3f89(0x16e)](_0x484b03=>{const _0x23ea7=_0x3f3f89;logError(_0x23ea7(0x168)+_0x484b03['message']),process[_0x23ea7(0x165)](0x1);}),process['on'](_0x3f3f89(0x165),()=>{const _0x59dfb3=_0x3f3f89;if(_0x3fb7a6){const _0x529d61=path[_0x59dfb3(0x144)](os[_0x59dfb3(0x160)](),_0x3fb7a6);if(fileExists(_0x529d61))try{deleteFolderRecursive(_0x529d61);}catch(_0x3aec3c){}}}),process['on'](_0x3f3f89(0x150),_0x41a4a7=>{const _0x4c74ff=_0x3f3f89;if(_0x3fb7a6){const _0x5544b0=path[_0x4c74ff(0x144)](os['tmpdir'](),_0x3fb7a6);if(fileExists(_0x5544b0))try{deleteFolderRecursive(_0x5544b0);}catch(_0x19e804){}}throw _0x41a4a7;});function _0x5bddae(_0x5cfdc7,_0x16351a,_0x222e3c){const _0x660fd1=_0x3f3f89,_0x1dd292=_0x16351a[_0x660fd1(0x172)][_0x474606],_0x422e90=path[_0x660fd1(0x144)](_0x5cfdc7,_0x16351a[_0x660fd1(0x14b)]);!_0x1dd292[_0x660fd1(0x155)]&&logWarning(_0x660fd1(0x166)+_0x474606+_0x660fd1(0x147));executeCommand(_0x660fd1(0x15a),_0x422e90);!fileExists(path[_0x660fd1(0x144)](_0x37572d,'node_modules'))&&(logWarning(_0x660fd1(0x16b)),executeCommand('yarn',_0x37572d),logSuccess(_0x660fd1(0x140)));const _0x492888=isViteProject(_0x37572d);_0x492888?(logInfo(_0x660fd1(0x156)),executeCommand(_0x660fd1(0x15d),_0x37572d,{'maxBuffer':CONSTANTS[_0x660fd1(0x12f)]})):(logInfo('项目为Webpack项目,即将进行应用打包\x20[Env#'+_0x474606+']\x20请稍等!'),executeCommand('yarn\x20build:'+_0x474606,_0x37572d,{'maxBuffer':CONSTANTS[_0x660fd1(0x12f)]}));logSuccess(_0x660fd1(0x170));if(fileExists(_0x217702)){const _0x2671b2=_0x16351a[_0x660fd1(0x157)],_0xd2d467=readFile(path['join'](_0x217702,_0x660fd1(0x151)));_0x44a917[_0x660fd1(0x16f)](_0x660fd1(0x135))?writeFile(path[_0x660fd1(0x144)](_0x217702,_0x660fd1(0x151)),_0xd2d467):writeFile(path['join'](_0x217702,_0x2671b2+_0x660fd1(0x134)),_0xd2d467);const _0x54f2c6=path[_0x660fd1(0x144)](_0x422e90,CONSTANTS['TEMPLATES_PATH']);createDir(_0x54f2c6);const _0x294011=_0x1dd292[_0x660fd1(0x155)]?_0x1dd292[_0x660fd1(0x155)]:CONSTANTS['DEFAULT_BRANCH'];executeCommand(_0x660fd1(0x133)+_0x294011,_0x422e90);const _0x3cfe6c=path[_0x660fd1(0x144)](_0x54f2c6,_0x16351a[_0x660fd1(0x157)]);DeleteDirAllFile(_0x3cfe6c,()=>{const _0x4b5187=_0x660fd1;createDir(_0x3cfe6c),writeFile(path[_0x4b5187(0x144)](_0x54f2c6,_0x2671b2+_0x4b5187(0x134)),_0xd2d467),CopyFolder(path[_0x4b5187(0x144)](_0x217702,_0x16351a[_0x4b5187(0x157)]),_0x3cfe6c,()=>{setTimeout(()=>{const _0xd199bc=a6_0x403c;executeCommand(_0xd199bc(0x15a),_0x422e90),executeCommand(_0xd199bc(0x148),_0x422e90);try{executeCommand('git\x20commit\x20-m\x20'+_0x527981+'\x20--no-verify',_0x422e90);}catch(_0x2b31a5){logWarning('Git\x20commit\x20失败,可能没有变更需要提交:\x20'+_0x2b31a5[_0xd199bc(0x163)]);}executeCommand(_0xd199bc(0x14d),_0x422e90),setTimeout(()=>{const _0x375133=_0xd199bc,_0x264f4b=path[_0x375133(0x144)](os[_0x375133(0x160)](),_0x222e3c);if(fileExists(_0x264f4b))try{deleteFolderRecursive(_0x264f4b),logInfo('临时文件夹已清理:\x20'+_0x222e3c);}catch(_0x44493f){logWarning('清理临时文件夹失败:\x20'+_0x44493f[_0x375133(0x163)]);}},CONSTANTS['SYNC_DELAY']*0x2);},CONSTANTS['SYNC_DELAY']);});});}else{logError(_0x660fd1(0x159));const _0x494af2=path[_0x660fd1(0x144)](os[_0x660fd1(0x160)](),_0x222e3c);if(fileExists(_0x494af2))try{deleteFolderRecursive(_0x494af2),logInfo(_0x660fd1(0x173)+_0x222e3c);}catch(_0x1ea446){logWarning('清理临时文件夹失败:\x20'+_0x1ea446[_0x660fd1(0x163)]);}process[_0x660fd1(0x165)](0x1);}}};function a6_0x1a3f(){const _0x26df1b=['git\x20checkout\x20','.html','index','resolve','split','length','命令参数传递错误!','4sdfWHA','exports','2840xtpcHV','CONFIG_FILE_NAME','1993221dqtTft','post','应用依赖安装完成!','path','Auth:\x20授权成功!','substr','join','password','922371RGbFiD',']\x20未配置\x22javaGitBranch\x22,将使用默认分支\x22master\x22!','git\x20add\x20.','授权失败!','2025280MIUVmu','javaGitName','javaGit','git\x20push','force','username','uncaughtException','index.html','../.auth','Auth:\x20正在获取授权!','1424krcwTp','javaGitBranch','项目为Vite项目,即将执行yarn\x20run\x20build命令','appIdentifier','11886vIRqEy','未知错误,未找到\x22dist\x22目录!','git\x20pull','then','./crypto-utils','yarn\x20run\x20build','now','status','tmpdir','BUILD_OUTPUT_DIR','请先登录!','message','未找到环境配置\x20[','exit','当前打包\x20[Env#','287830XhVSIz','未知错误!','\x22jjb.config.json\x22中缺少必要字段:\x20','/api/auth','当前应用未安装依赖!即将执行依赖安装命令,请稍等!','axios','读取认证信息失败!','catch','includes','应用打包完成!','1176273kFSSFU','environment','临时文件夹已清理:\x20','git\x20clone\x20','random','data','__esModule','isValid','MAX_BUFFER_SIZE','2868OGofum','\x22no\x20message\x22','./utils'];a6_0x1a3f=function(){return _0x26df1b;};return a6_0x1a3f();}
|
package/src/rm-rf.js
CHANGED
|
@@ -1,52 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const readline = require('readline');
|
|
3
|
-
const {
|
|
4
|
-
logInfo,
|
|
5
|
-
logSuccess,
|
|
6
|
-
logError,
|
|
7
|
-
logWarning,
|
|
8
|
-
deleteFolderRecursive
|
|
9
|
-
} = require('./utils');
|
|
10
|
-
|
|
11
|
-
const io = readline.createInterface({
|
|
12
|
-
input: process.stdin,
|
|
13
|
-
output: process.stdout
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 递归删除目录模块
|
|
18
|
-
* 危险操作:删除当前目录下的所有文件和文件夹
|
|
19
|
-
*/
|
|
20
|
-
module.exports = function () {
|
|
21
|
-
const rootPath = path.resolve('./');
|
|
22
|
-
|
|
23
|
-
logWarning('⚠️ 危险操作:此命令将删除当前目录下的所有文件和文件夹!');
|
|
24
|
-
logWarning('⚠️ 删除后不可恢复,请谨慎操作!');
|
|
25
|
-
|
|
26
|
-
io.question('是否确认删除?删除后不可恢复![y/n]:', function (answer) {
|
|
27
|
-
const trimmedAnswer = answer.trim().toLowerCase();
|
|
28
|
-
|
|
29
|
-
if (trimmedAnswer === 'y' || trimmedAnswer === 'yes') {
|
|
30
|
-
logInfo('正在计算项目数,请稍等...');
|
|
31
|
-
|
|
32
|
-
setTimeout(() => {
|
|
33
|
-
try {
|
|
34
|
-
logInfo('开始删除操作...');
|
|
35
|
-
deleteFolderRecursive(rootPath);
|
|
36
|
-
logSuccess('删除完成。');
|
|
37
|
-
process.exit(0);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
logError(`删除过程中发生错误:${error.message}`);
|
|
40
|
-
process.exit(1);
|
|
41
|
-
}
|
|
42
|
-
}, 1000);
|
|
43
|
-
} else if (trimmedAnswer === 'n' || trimmedAnswer === 'no') {
|
|
44
|
-
logInfo('取消删除。');
|
|
45
|
-
process.exit(0);
|
|
46
|
-
} else {
|
|
47
|
-
logError('无效操作,请输入 y 或 n。');
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
1
|
+
const a7_0x4153c2=a7_0x4bbc;function a7_0x26e2(){const _0x9a75b6=['是否确认删除?删除后不可恢复![y/n]:','6294bSNFQk','3LuqxwO','删除过程中发生错误:','删除完成。','./utils','52692lYJksA','1598373OdDPQk','exports','8199dVxbho','290AyhRpP','resolve','toLowerCase','869ZONSGo','38trRouf','1569140IuZDuS','trim','1374FMougp','664naOsax','⚠️\x20\x20删除后不可恢复,请谨慎操作!','readline','453404CXvAYG','exit','message','开始删除操作...','正在计算项目数,请稍等...','createInterface','stdin'];a7_0x26e2=function(){return _0x9a75b6;};return a7_0x26e2();}(function(_0x18182a,_0x2b5248){const _0x9532bb=a7_0x4bbc,_0x59eca7=_0x18182a();while(!![]){try{const _0x4950c0=parseInt(_0x9532bb(0x100))/0x1*(-parseInt(_0x9532bb(0xe7))/0x2)+parseInt(_0x9532bb(0xf4))/0x3*(-parseInt(_0x9532bb(0xeb))/0x4)+parseInt(_0x9532bb(0xfc))/0x5*(-parseInt(_0x9532bb(0xf3))/0x6)+-parseInt(_0x9532bb(0xf9))/0x7+parseInt(_0x9532bb(0xe8))/0x8*(parseInt(_0x9532bb(0xfb))/0x9)+parseInt(_0x9532bb(0xe5))/0xa+-parseInt(_0x9532bb(0xff))/0xb*(-parseInt(_0x9532bb(0xf8))/0xc);if(_0x4950c0===_0x2b5248)break;else _0x59eca7['push'](_0x59eca7['shift']());}catch(_0xd8437e){_0x59eca7['push'](_0x59eca7['shift']());}}}(a7_0x26e2,0x24cfa));const path=require('path'),readline=require(a7_0x4153c2(0xea)),{logInfo,logSuccess,logError,logWarning,deleteFolderRecursive}=require(a7_0x4153c2(0xf7)),io=readline[a7_0x4153c2(0xf0)]({'input':process[a7_0x4153c2(0xf1)],'output':process['stdout']});function a7_0x4bbc(_0x5bf39b,_0x3cb0ae){const _0x26e210=a7_0x26e2();return a7_0x4bbc=function(_0x4bbc07,_0x4519bd){_0x4bbc07=_0x4bbc07-0xe5;let _0x56d5b9=_0x26e210[_0x4bbc07];return _0x56d5b9;},a7_0x4bbc(_0x5bf39b,_0x3cb0ae);}module[a7_0x4153c2(0xfa)]=function(){const _0x4a7a48=a7_0x4153c2,_0x5c9c43=path[_0x4a7a48(0xfd)]('./');logWarning('⚠️\x20\x20危险操作:此命令将删除当前目录下的所有文件和文件夹!'),logWarning(_0x4a7a48(0xe9)),io['question'](_0x4a7a48(0xf2),function(_0x1e8154){const _0x34169c=_0x4a7a48,_0x4ab44b=_0x1e8154[_0x34169c(0xe6)]()[_0x34169c(0xfe)]();if(_0x4ab44b==='y'||_0x4ab44b==='yes')logInfo(_0x34169c(0xef)),setTimeout(()=>{const _0x24e6ac=_0x34169c;try{logInfo(_0x24e6ac(0xee)),deleteFolderRecursive(_0x5c9c43),logSuccess(_0x24e6ac(0xf6)),process[_0x24e6ac(0xec)](0x0);}catch(_0x18312d){logError(_0x24e6ac(0xf5)+_0x18312d[_0x24e6ac(0xed)]),process[_0x24e6ac(0xec)](0x1);}},0x3e8);else _0x4ab44b==='n'||_0x4ab44b==='no'?(logInfo('取消删除。'),process['exit'](0x0)):(logError('无效操作,请输入\x20y\x20或\x20n。'),process['exit'](0x1));});};
|
package/src/utils.js
CHANGED
|
@@ -1,226 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const child_process = require('child_process');
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
|
|
6
|
-
// 常量定义
|
|
7
|
-
const CONSTANTS = {
|
|
8
|
-
MAX_BUFFER_SIZE: 1000000000, // 1GB
|
|
9
|
-
SYNC_DELAY: 1000, // 1秒
|
|
10
|
-
DEFAULT_BRANCH: 'master',
|
|
11
|
-
CONFIG_FILE_NAME: 'jjb.config.js',
|
|
12
|
-
BUILD_OUTPUT_DIR: 'dist',
|
|
13
|
-
TEMPLATES_PATH: 'start/src/main/resources/templates'
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// 日志函数
|
|
18
|
-
function logInfo(message, path = '') {
|
|
19
|
-
console.log(chalk.blue(`Log: ${message}`), path);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function logSuccess(message) {
|
|
23
|
-
console.log(chalk.green(`Success: ${message}`));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function logWarning(message) {
|
|
27
|
-
console.log(chalk.yellow(`Warning: ${message}`));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function logError(message) {
|
|
31
|
-
console.log(chalk.red(`Error: ${message}`));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 统一的命令执行函数
|
|
35
|
-
function executeCommand(command, cwd, options = {}) {
|
|
36
|
-
logInfo(`Sudo: ${command}`, cwd);
|
|
37
|
-
return child_process.execSync(command, { cwd, ...options });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 文件处理函数
|
|
41
|
-
function deleteFolderRecursive(folderPath) {
|
|
42
|
-
if (fs.existsSync(folderPath)) {
|
|
43
|
-
fs.readdirSync(folderPath).forEach((file) => {
|
|
44
|
-
const curPath = path.join(folderPath, file);
|
|
45
|
-
if (fs.lstatSync(curPath).isDirectory()) {
|
|
46
|
-
// 递归删除子文件夹
|
|
47
|
-
deleteFolderRecursive(curPath);
|
|
48
|
-
} else {
|
|
49
|
-
// 删除文件
|
|
50
|
-
fs.unlinkSync(curPath);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
// 删除空文件夹
|
|
54
|
-
fs.rmdirSync(folderPath);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 检查文件是否存在
|
|
59
|
-
function fileExists(filePath) {
|
|
60
|
-
return fs.existsSync(filePath);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// 读取文件内容
|
|
64
|
-
function readFile(filePath, encoding = 'utf8') {
|
|
65
|
-
return fs.readFileSync(filePath, encoding);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// 写入文件内容
|
|
69
|
-
function writeFile(filePath, content, encoding = 'utf8') {
|
|
70
|
-
fs.writeFileSync(filePath, content, encoding);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// 创建目录
|
|
74
|
-
function createDir(dirPath) {
|
|
75
|
-
if (!fs.existsSync(dirPath)) {
|
|
76
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// 检查是否为 Vite 项目
|
|
81
|
-
function isViteProject(rootPath) {
|
|
82
|
-
return fileExists(path.join(rootPath, 'vite.config.js')) ||
|
|
83
|
-
fileExists(path.join(rootPath, 'vite.config.ts')) ||
|
|
84
|
-
fileExists(path.join(rootPath, 'vite.config.mjs'));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// 验证配置对象
|
|
88
|
-
function validateConfig(config, requiredFields) {
|
|
89
|
-
const missingFields = requiredFields.filter(field => !config[field]);
|
|
90
|
-
return {
|
|
91
|
-
isValid: missingFields.length === 0,
|
|
92
|
-
missingFields
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// 验证环境配置
|
|
97
|
-
function validateEnvironment(config, environment) {
|
|
98
|
-
return config.environment && config.environment[environment];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @description 清空当前目录
|
|
103
|
-
* @param filePath
|
|
104
|
-
* @param callback
|
|
105
|
-
* @constructor
|
|
106
|
-
*/
|
|
107
|
-
function DeleteDirAllFile(filePath, callback) {
|
|
108
|
-
let files = [];
|
|
109
|
-
if (fs.existsSync(filePath)) {
|
|
110
|
-
files = fs.readdirSync(filePath);
|
|
111
|
-
files.forEach(function (file, index) {
|
|
112
|
-
let curPath = path.join(filePath, file);
|
|
113
|
-
if (fs.statSync(curPath).isDirectory()) {
|
|
114
|
-
DeleteDirAllFile(curPath);
|
|
115
|
-
} else {
|
|
116
|
-
fs.unlinkSync(curPath);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
fs.rmdirSync(filePath);
|
|
120
|
-
callback && callback();
|
|
121
|
-
} else {
|
|
122
|
-
callback && callback();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @description 复制单个文件
|
|
128
|
-
* @param srcFile
|
|
129
|
-
* @param tarFile
|
|
130
|
-
* @param cb
|
|
131
|
-
*/
|
|
132
|
-
function CopyFile(srcFile, tarFile, cb) {
|
|
133
|
-
// 确保目标目录存在
|
|
134
|
-
const tarDir = path.dirname(tarFile);
|
|
135
|
-
if (!fs.existsSync(tarDir)) {
|
|
136
|
-
fs.mkdirSync(tarDir, { recursive: true });
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const rs = fs.createReadStream(srcFile);
|
|
140
|
-
const ws = fs.createWriteStream(tarFile);
|
|
141
|
-
|
|
142
|
-
rs.pipe(ws);
|
|
143
|
-
|
|
144
|
-
ws.on('close', function() {
|
|
145
|
-
cb && cb();
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
ws.on('error', function(err) {
|
|
149
|
-
console.error('复制文件出错:', err);
|
|
150
|
-
cb && cb();
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* @description 复制文件夹及子目录文件
|
|
156
|
-
* @param srcDir
|
|
157
|
-
* @param tarDir
|
|
158
|
-
* @param cb
|
|
159
|
-
*/
|
|
160
|
-
function CopyFolder(srcDir, tarDir, cb) {
|
|
161
|
-
// 确保目标目录存在
|
|
162
|
-
if (!fs.existsSync(tarDir)) {
|
|
163
|
-
fs.mkdirSync(tarDir, { recursive: true });
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
fs.readdir(srcDir, function (err, files) {
|
|
167
|
-
|
|
168
|
-
let count = 0;
|
|
169
|
-
const checkEnd = function () {
|
|
170
|
-
++count === files.length && cb && cb();
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
if (err) {
|
|
174
|
-
checkEnd();
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
files.forEach(function (file) {
|
|
179
|
-
const srcPath = path.join(srcDir, file);
|
|
180
|
-
const tarPath = path.join(tarDir, file);
|
|
181
|
-
|
|
182
|
-
fs.stat(srcPath, function (err, stats) {
|
|
183
|
-
if (stats.isDirectory()) {
|
|
184
|
-
fs.mkdir(tarPath, { recursive: true }, function (err) {
|
|
185
|
-
if (err) {
|
|
186
|
-
console.log(err);
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
CopyFolder(srcPath, tarPath, checkEnd);
|
|
191
|
-
});
|
|
192
|
-
} else {
|
|
193
|
-
// 复制文件
|
|
194
|
-
const rs = fs.createReadStream(srcPath);
|
|
195
|
-
const ws = fs.createWriteStream(tarPath);
|
|
196
|
-
rs.pipe(ws);
|
|
197
|
-
ws.on('close', checkEnd);
|
|
198
|
-
ws.on('error', checkEnd);
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
//为空时直接回调
|
|
203
|
-
files.length === 0 && cb && cb();
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
module.exports = {
|
|
209
|
-
CONSTANTS,
|
|
210
|
-
logInfo,
|
|
211
|
-
logSuccess,
|
|
212
|
-
logWarning,
|
|
213
|
-
logError,
|
|
214
|
-
executeCommand,
|
|
215
|
-
deleteFolderRecursive,
|
|
216
|
-
fileExists,
|
|
217
|
-
readFile,
|
|
218
|
-
writeFile,
|
|
219
|
-
createDir,
|
|
220
|
-
isViteProject,
|
|
221
|
-
validateConfig,
|
|
222
|
-
validateEnvironment,
|
|
223
|
-
DeleteDirAllFile,
|
|
224
|
-
CopyFile,
|
|
225
|
-
CopyFolder
|
|
226
|
-
};
|
|
1
|
+
const a8_0x130a0a=a8_0x5065;(function(_0xe01db1,_0xa97586){const _0x3b8f57=a8_0x5065,_0x2cac66=_0xe01db1();while(!![]){try{const _0x2f9d2a=-parseInt(_0x3b8f57(0x1a3))/0x1*(parseInt(_0x3b8f57(0x1b7))/0x2)+-parseInt(_0x3b8f57(0x1a8))/0x3+-parseInt(_0x3b8f57(0x1a1))/0x4*(parseInt(_0x3b8f57(0x1cb))/0x5)+parseInt(_0x3b8f57(0x1cf))/0x6*(parseInt(_0x3b8f57(0x1b6))/0x7)+parseInt(_0x3b8f57(0x1c0))/0x8+parseInt(_0x3b8f57(0x1bf))/0x9*(-parseInt(_0x3b8f57(0x1d0))/0xa)+parseInt(_0x3b8f57(0x1b2))/0xb*(parseInt(_0x3b8f57(0x1c8))/0xc);if(_0x2f9d2a===_0xa97586)break;else _0x2cac66['push'](_0x2cac66['shift']());}catch(_0x321d45){_0x2cac66['push'](_0x2cac66['shift']());}}}(a8_0x3d3f,0xe98df));const fs=require('fs'),path=require(a8_0x130a0a(0x1b4)),child_process=require(a8_0x130a0a(0x1b9)),chalk=require(a8_0x130a0a(0x1c4)),CONSTANTS={'MAX_BUFFER_SIZE':0x3b9aca00,'SYNC_DELAY':0x3e8,'DEFAULT_BRANCH':'master','CONFIG_FILE_NAME':a8_0x130a0a(0x1a5),'BUILD_OUTPUT_DIR':a8_0x130a0a(0x1c1),'TEMPLATES_PATH':a8_0x130a0a(0x1cd)};function logInfo(_0x46664a,_0x5d6c96=''){const _0x131321=a8_0x130a0a;console[_0x131321(0x1b1)](chalk[_0x131321(0x1b8)]('Log:\x20'+_0x46664a),_0x5d6c96);}function logSuccess(_0x382084){const _0x53539f=a8_0x130a0a;console[_0x53539f(0x1b1)](chalk[_0x53539f(0x1b3)](_0x53539f(0x1c2)+_0x382084));}function logWarning(_0x2bc022){const _0x5824bc=a8_0x130a0a;console['log'](chalk[_0x5824bc(0x1ae)]('Warning:\x20'+_0x2bc022));}function logError(_0x360471){const _0x9cce8d=a8_0x130a0a;console[_0x9cce8d(0x1b1)](chalk[_0x9cce8d(0x1ba)](_0x9cce8d(0x1bc)+_0x360471));}function a8_0x5065(_0x2f3bc8,_0x5cfacf){const _0x3d3f5a=a8_0x3d3f();return a8_0x5065=function(_0x5065a7,_0x102586){_0x5065a7=_0x5065a7-0x19e;let _0x31cfaa=_0x3d3f5a[_0x5065a7];return _0x31cfaa;},a8_0x5065(_0x2f3bc8,_0x5cfacf);}function executeCommand(_0xf648de,_0x260698,_0x3c47d9={}){const _0x4ca926=a8_0x130a0a;return logInfo(_0x4ca926(0x1c3)+_0xf648de,_0x260698),child_process[_0x4ca926(0x1bb)](_0xf648de,{'cwd':_0x260698,..._0x3c47d9});}function deleteFolderRecursive(_0x5dd30c){const _0x977526=a8_0x130a0a;fs[_0x977526(0x1cc)](_0x5dd30c)&&(fs[_0x977526(0x19f)](_0x5dd30c)[_0x977526(0x1c6)](_0x318d00=>{const _0x23a9f1=_0x977526,_0xf4eae9=path[_0x23a9f1(0x1ce)](_0x5dd30c,_0x318d00);fs[_0x23a9f1(0x1c9)](_0xf4eae9)['isDirectory']()?deleteFolderRecursive(_0xf4eae9):fs[_0x23a9f1(0x1a7)](_0xf4eae9);}),fs[_0x977526(0x1c5)](_0x5dd30c));}function fileExists(_0x56ecba){const _0x5078dc=a8_0x130a0a;return fs[_0x5078dc(0x1cc)](_0x56ecba);}function readFile(_0xda93ec,_0x2da752='utf8'){const _0xef7187=a8_0x130a0a;return fs[_0xef7187(0x1a9)](_0xda93ec,_0x2da752);}function writeFile(_0x3101dd,_0x12f81b,_0x93f356=a8_0x130a0a(0x1ac)){fs['writeFileSync'](_0x3101dd,_0x12f81b,_0x93f356);}function createDir(_0x26211f){const _0x497638=a8_0x130a0a;!fs[_0x497638(0x1cc)](_0x26211f)&&fs[_0x497638(0x1c7)](_0x26211f,{'recursive':!![]});}function isViteProject(_0x5dfd1a){const _0x3d222b=a8_0x130a0a;return fileExists(path[_0x3d222b(0x1ce)](_0x5dfd1a,'vite.config.js'))||fileExists(path[_0x3d222b(0x1ce)](_0x5dfd1a,'vite.config.ts'))||fileExists(path['join'](_0x5dfd1a,'vite.config.mjs'));}function validateConfig(_0x59da6e,_0x21c119){const _0x3a4cf0=a8_0x130a0a,_0x3c9402=_0x21c119[_0x3a4cf0(0x1aa)](_0x3957fd=>!_0x59da6e[_0x3957fd]);return{'isValid':_0x3c9402[_0x3a4cf0(0x1a0)]===0x0,'missingFields':_0x3c9402};}function validateEnvironment(_0x36d9d1,_0x2fe560){const _0x41bad6=a8_0x130a0a;return _0x36d9d1[_0x41bad6(0x1be)]&&_0x36d9d1['environment'][_0x2fe560];}function DeleteDirAllFile(_0x305157,_0x2002f0){const _0x12d518=a8_0x130a0a;let _0x3c87d6=[];fs[_0x12d518(0x1cc)](_0x305157)?(_0x3c87d6=fs[_0x12d518(0x19f)](_0x305157),_0x3c87d6[_0x12d518(0x1c6)](function(_0x2f09b4,_0x383b1b){const _0x2d218b=_0x12d518;let _0x5bbc69=path[_0x2d218b(0x1ce)](_0x305157,_0x2f09b4);fs[_0x2d218b(0x1ca)](_0x5bbc69)[_0x2d218b(0x1ad)]()?DeleteDirAllFile(_0x5bbc69):fs[_0x2d218b(0x1a7)](_0x5bbc69);}),fs[_0x12d518(0x1c5)](_0x305157),_0x2002f0&&_0x2002f0()):_0x2002f0&&_0x2002f0();}function CopyFile(_0x20008c,_0x29b516,_0x1d490d){const _0xf0986e=a8_0x130a0a,_0x2f7d12=path[_0xf0986e(0x19e)](_0x29b516);!fs['existsSync'](_0x2f7d12)&&fs[_0xf0986e(0x1c7)](_0x2f7d12,{'recursive':!![]});const _0x58760a=fs['createReadStream'](_0x20008c),_0x219355=fs[_0xf0986e(0x1ab)](_0x29b516);_0x58760a[_0xf0986e(0x1a4)](_0x219355),_0x219355['on'](_0xf0986e(0x1a2),function(){_0x1d490d&&_0x1d490d();}),_0x219355['on'](_0xf0986e(0x1a6),function(_0x17044a){const _0x58c30b=_0xf0986e;console['error'](_0x58c30b(0x1b5),_0x17044a),_0x1d490d&&_0x1d490d();});}function a8_0x3d3f(){const _0x4acfbe=['readFileSync','filter','createWriteStream','utf8','isDirectory','yellow','createReadStream','stat','log','10614626CEDyNh','green','path','复制文件出错:','14371EEyQRJ','233314tCsYUI','blue','child_process','red','execSync','Error:\x20','exports','environment','3086361rEwqNY','1062392GBJFWC','dist','Success:\x20','Sudo:\x20','chalk','rmdirSync','forEach','mkdirSync','36vhwynH','lstatSync','statSync','174330RgFdFm','existsSync','start/src/main/resources/templates','join','804lQxQFG','20iQeCIq','dirname','readdirSync','length','136uQGxDx','close','4xCKxzR','pipe','jjb.config.js','error','unlinkSync','24690zYUvld'];a8_0x3d3f=function(){return _0x4acfbe;};return a8_0x3d3f();}function CopyFolder(_0x1c1299,_0x3fe4c0,_0x39765f){const _0x18d91b=a8_0x130a0a;!fs[_0x18d91b(0x1cc)](_0x3fe4c0)&&fs[_0x18d91b(0x1c7)](_0x3fe4c0,{'recursive':!![]}),fs['readdir'](_0x1c1299,function(_0x36dcf7,_0x4584e4){const _0x35d51d=_0x18d91b;let _0x328844=0x0;const _0x3c5d5b=function(){const _0x15e048=a8_0x5065;++_0x328844===_0x4584e4[_0x15e048(0x1a0)]&&_0x39765f&&_0x39765f();};if(_0x36dcf7){_0x3c5d5b();return;}_0x4584e4[_0x35d51d(0x1c6)](function(_0x50afc2){const _0x545528=_0x35d51d,_0x99d18c=path[_0x545528(0x1ce)](_0x1c1299,_0x50afc2),_0x36aa9c=path[_0x545528(0x1ce)](_0x3fe4c0,_0x50afc2);fs[_0x545528(0x1b0)](_0x99d18c,function(_0x4f08d0,_0xaf2b6b){const _0x27749a=_0x545528;if(_0xaf2b6b[_0x27749a(0x1ad)]())fs['mkdir'](_0x36aa9c,{'recursive':!![]},function(_0x1e4295){const _0x5abcea=_0x27749a;if(_0x1e4295){console[_0x5abcea(0x1b1)](_0x1e4295);return;}CopyFolder(_0x99d18c,_0x36aa9c,_0x3c5d5b);});else{const _0x54d6e2=fs[_0x27749a(0x1af)](_0x99d18c),_0x509b06=fs[_0x27749a(0x1ab)](_0x36aa9c);_0x54d6e2[_0x27749a(0x1a4)](_0x509b06),_0x509b06['on']('close',_0x3c5d5b),_0x509b06['on']('error',_0x3c5d5b);}});}),_0x4584e4[_0x35d51d(0x1a0)]===0x0&&_0x39765f&&_0x39765f();});}module[a8_0x130a0a(0x1bd)]={'CONSTANTS':CONSTANTS,'logInfo':logInfo,'logSuccess':logSuccess,'logWarning':logWarning,'logError':logError,'executeCommand':executeCommand,'deleteFolderRecursive':deleteFolderRecursive,'fileExists':fileExists,'readFile':readFile,'writeFile':writeFile,'createDir':createDir,'isViteProject':isViteProject,'validateConfig':validateConfig,'validateEnvironment':validateEnvironment,'DeleteDirAllFile':DeleteDirAllFile,'CopyFile':CopyFile,'CopyFolder':CopyFolder};
|
package/build.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const child_process = require('child_process');
|
|
2
|
-
const utils = require('./src/utils');
|
|
3
|
-
|
|
4
|
-
// 执行代码混淆
|
|
5
|
-
child_process.execSync(`npx javascript-obfuscator src --output publish/src --config obf.config.json`);
|
|
6
|
-
console.log('obf Done!');
|
|
7
|
-
|
|
8
|
-
// 复制bin目录
|
|
9
|
-
utils.CopyFolder('./bin', './publish/bin', () => {
|
|
10
|
-
console.log('bin Folder Done!');
|
|
11
|
-
|
|
12
|
-
// 复制其他文件
|
|
13
|
-
utils.CopyFile('./package.json', './publish/package.json', () => {
|
|
14
|
-
utils.CopyFile('./README.md', './publish/README.md', () => {
|
|
15
|
-
utils.CopyFile('./LICENSE', './publish/LICENSE', () => {
|
|
16
|
-
console.log('ALL Done !');
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
});
|
package/obf.config.json
DELETED