jjb-cmd 2.5.1 → 2.5.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/bin/command.js CHANGED
@@ -1,17 +1,15 @@
1
1
  #! /usr/bin/env node
2
2
 
3
3
  const commander = require('commander');
4
- // const readline = require('readline');
5
4
  const path = require('path');
6
5
  const fs = require('fs');
7
- // const child_process = require('child_process');
8
6
 
9
7
  commander.command('v').description('-- 查看版本').action(() => {
10
8
  const package_json_file = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json')).toString());
11
9
  const {
12
10
  version
13
11
  } = package_json_file;
14
- console.log(`当前版本 v${version}`);
12
+ console.log(`当前版本: v${version}`);
15
13
  });
16
14
 
17
15
  commander.command('help').description('-- 帮助').action(() => {
@@ -23,26 +21,18 @@ commander.command('help').description('-- 帮助').action(() => {
23
21
  console.log('jjb-cmd opti 代码优化');
24
22
  console.log('jjb-cmd v 查看版本');
25
23
  console.log('jjb-cmd publish <version> 发布云组件\n\targ1 <version> 发布版本,可设置为latest');
26
- console.log('jjb-cmd auth <username> <password> 登录授权\n\targ1 <username> 用户名\n\targ2 <password> 密码');
27
- console.log('jjb-cmd push java <env> 推送微应用到服务器\n\targ1 <env> 推送环境');
28
- });
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
- }
24
+ console.log('jjb-cmd auth 登录授权(交互式输入用户名和密码)');
25
+ console.log('jjb-cmd push java 推送微应用到服务器');
36
26
  });
37
27
 
38
28
  // 命令
39
- commander.command('auth [args]').description('-- 授权').action(args => {
40
- require('../src/auth.js')(process.argv.splice(3));
29
+ commander.command('auth').description('-- 授权').action(async () => {
30
+ await require('../src/auth.js')([]);
41
31
  });
42
32
 
43
33
  // 优化
44
- commander.command('opti').description('-- 代码优化').action(args => {
45
- require('../src/code-optimization')();
34
+ commander.command('opti').description('-- 代码优化').action(async args => {
35
+ await require('../src/code-optimization')();
46
36
  });
47
37
 
48
38
  // 发包
@@ -54,20 +44,20 @@ commander.command('publish [args]').description('-- 发布包').action(args => {
54
44
  commander.command('push [args]').description('-- 发布包').action(args => {
55
45
  if (args) {
56
46
  if ([ 'java' ].includes(args)) {
57
- require('../src/push.js')(process.argv.splice(3));
47
+ require('../src/push.js')([]);
58
48
  } else {
59
- console.log(`无效的选项‘${args}’。`);
49
+ console.log(`无效的选项: ${args}`);
60
50
  process.exit(0);
61
51
  }
62
52
  } else {
63
- console.log(`无效的选项‘${args}’。`);
53
+ console.log(`缺少必要参数,请使用 'jjb-cmd push java'`);
64
54
  process.exit(0);
65
55
  }
66
56
  });
67
57
 
68
58
  // rm-rf 命令
69
- commander.command('rm-rf').description('-- 删除全部').action(() => {
70
- require('../src/rm-rf.js')();
59
+ commander.command('rm-rf').description('-- 删除全部').action(async () => {
60
+ await require('../src/rm-rf.js')();
71
61
  });
72
62
 
73
63
  commander.parse(process.argv);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "env": "prod",
5
5
  "httpMethod": "http",
6
6
  "pushMessage": "yes",
7
- "version": "2.5.1",
7
+ "version": "2.5.3",
8
8
  "description": "jjb-cmd命令行工具",
9
9
  "main": "index.js",
10
10
  "scripts": {
@@ -17,20 +17,21 @@
17
17
  "author": "jiaoxiwei",
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
- "@cqsjjb/react-code-optimization": "^0.0.2",
21
- "chalk": "2.4.0",
22
- "prettier": "^3.3.3",
23
- "@babel/traverse": "^7.25.9",
20
+ "@babel/core": "^7.19.3",
24
21
  "@babel/generator": "^7.26.0",
25
22
  "@babel/parser": "^7.26.1",
26
23
  "@babel/preset-env": "^7.23.2",
27
- "@babel/preset-typescript": "^7.23.2",
28
- "@babel/core": "^7.19.3",
29
24
  "@babel/preset-react": "^7.18.6",
25
+ "@babel/preset-typescript": "^7.23.2",
26
+ "@babel/traverse": "^7.25.9",
27
+ "@cqsjjb/react-code-optimization": "^0.0.2",
30
28
  "axios": "^1.1.3",
29
+ "chalk": "2.4.0",
31
30
  "commander": "^1.3.2",
32
31
  "compressing": "^1.5.1",
32
+ "inquirer": "^8.2.7",
33
33
  "jenkins": "^1.0.2",
34
+ "prettier": "^3.3.3",
34
35
  "request": "2.88.2",
35
36
  "single-line-log": "1.1.2"
36
37
  }
package/src/auth.js CHANGED
@@ -1,47 +1 @@
1
- const axios = require('axios');
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_0x2449d7=a0_0x16b9;function a0_0x16b9(_0x3e863c,_0x119508){const _0x42156b=a0_0x4215();return a0_0x16b9=function(_0x16b945,_0x2fcb1a){_0x16b945=_0x16b945-0x1ca;let _0x1a0111=_0x42156b[_0x16b945];return _0x1a0111;},a0_0x16b9(_0x3e863c,_0x119508);}(function(_0x1984c7,_0x8b3371){const _0xa43fa=a0_0x16b9,_0x5e5763=_0x1984c7();while(!![]){try{const _0x53ddbe=-parseInt(_0xa43fa(0x1eb))/0x1*(parseInt(_0xa43fa(0x1f1))/0x2)+parseInt(_0xa43fa(0x1e3))/0x3+-parseInt(_0xa43fa(0x1e7))/0x4*(parseInt(_0xa43fa(0x1d5))/0x5)+parseInt(_0xa43fa(0x1ca))/0x6+-parseInt(_0xa43fa(0x1de))/0x7*(-parseInt(_0xa43fa(0x1ed))/0x8)+-parseInt(_0xa43fa(0x1d0))/0x9+-parseInt(_0xa43fa(0x1ea))/0xa;if(_0x53ddbe===_0x8b3371)break;else _0x5e5763['push'](_0x5e5763['shift']());}catch(_0xa3f569){_0x5e5763['push'](_0x5e5763['shift']());}}}(a0_0x4215,0x1e1a1));const axios=require(a0_0x2449d7(0x1e4)),path=require(a0_0x2449d7(0x1e2)),{getApiHost}=require(a0_0x2449d7(0x1da)),{logInfo,logSuccess,logError,fileExists,deleteFile}=require(a0_0x2449d7(0x1e8)),{saveAuth,deleteAuth}=require(a0_0x2449d7(0x1ef)),{getCredentials,interactiveAuth}=require(a0_0x2449d7(0x1d8));function a0_0x4215(){const _0x457cfb=['用户认证成功','认证失败:\x20','39046ckWjmM','认证失败\x20(','join','网络连接失败:\x20无法连接到服务器','path','420963JNAtFk','axios','用户取消输入','已清理无效的认证信息','124MUuOgo','./utils','../.auth','144370mbVPOS','1811VDCenU','includes','200byNqLq','request','./crypto-utils','data','50eYPCBM','899820HeQtQS','认证信息已安全加密存储','status','正在验证用户凭证...','):\x20用户名或密码错误','username','1382193eXJEYN','请求失败\x20(','message','response','password','15025KZNGVy','):\x20','exports','./password-input','exit','./config','/api/auth'];a0_0x4215=function(){return _0x457cfb;};return a0_0x4215();}module[a0_0x2449d7(0x1d7)]=async _0x30e405=>{const _0x141099=a0_0x2449d7,_0x215bce=path[_0x141099(0x1e0)](__dirname,_0x141099(0x1e9));try{logInfo('启动交互式登录流程');const _0x5b6f59=await interactiveAuth(),_0x17f817=_0x5b6f59[_0x141099(0x1cf)],_0x3608a1=_0x5b6f59[_0x141099(0x1d4)];logInfo(_0x141099(0x1cd));const _0x1e41fa=await axios['post'](getApiHost()+_0x141099(0x1db),{'username':_0x17f817,'password':_0x3608a1});if(_0x1e41fa['data'][_0x141099(0x1cc)]){logSuccess(_0x141099(0x1dc));try{saveAuth(_0x17f817,_0x3608a1,_0x215bce),logSuccess(_0x141099(0x1cb));}catch(_0x234f0c){logError('保存认证信息失败:\x20'+_0x234f0c[_0x141099(0x1d2)]),process[_0x141099(0x1d9)](0x1);}}else logError(_0x141099(0x1dd)+(_0x1e41fa[_0x141099(0x1f0)][_0x141099(0x1d2)]||'未知错误')),fileExists(_0x215bce)&&(deleteAuth(_0x215bce),logInfo(_0x141099(0x1e6))),process[_0x141099(0x1d9)](0x1);}catch(_0xebae84){if(_0xebae84[_0x141099(0x1d2)][_0x141099(0x1ec)](_0x141099(0x1e5)))logError('用户取消登录操作');else{if(_0xebae84['response']){const _0x171726=_0xebae84[_0x141099(0x1d3)]['status'],_0xe17855=_0xebae84[_0x141099(0x1d3)][_0x141099(0x1f0)]?.[_0x141099(0x1d2)]||_0xebae84[_0x141099(0x1d2)];_0x171726===0x191||_0x171726===0x193?logError(_0x141099(0x1df)+_0x171726+_0x141099(0x1ce)):logError(_0x141099(0x1d1)+_0x171726+_0x141099(0x1d6)+_0xe17855);}else _0xebae84[_0x141099(0x1ee)]?logError(_0x141099(0x1e1)):logError('登录失败:\x20'+_0xebae84[_0x141099(0x1d2)]);}process[_0x141099(0x1d9)](0x1);}};
@@ -1,49 +1 @@
1
- const path = require('path');
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_0x5a6c3c=a1_0x2c45;(function(_0x53e8db,_0x237484){const _0x454069=a1_0x2c45,_0x31b5cb=_0x53e8db();while(!![]){try{const _0x3a534a=parseInt(_0x454069(0xc1))/0x1+parseInt(_0x454069(0xc4))/0x2+parseInt(_0x454069(0xc3))/0x3+parseInt(_0x454069(0xb7))/0x4+parseInt(_0x454069(0xc9))/0x5+parseInt(_0x454069(0xca))/0x6+-parseInt(_0x454069(0xc2))/0x7;if(_0x3a534a===_0x237484)break;else _0x31b5cb['push'](_0x31b5cb['shift']());}catch(_0x58c2e2){_0x31b5cb['push'](_0x31b5cb['shift']());}}}(a1_0x5326,0x1cd36));const path=require(a1_0x5a6c3c(0xbe)),inquirer=require(a1_0x5a6c3c(0xc0)),{bootstrap}=require(a1_0x5a6c3c(0xb8)),{logInfo,logSuccess,logError,logWarning}=require(a1_0x5a6c3c(0xba));function a1_0x2c45(_0x21c699,_0x12f726){const _0x532634=a1_0x5326();return a1_0x2c45=function(_0x2c4586,_0x297b08){_0x2c4586=_0x2c4586-0xb6;let _0x27cf7c=_0x532634[_0x2c4586];return _0x27cf7c;},a1_0x2c45(_0x21c699,_0x12f726);}module[a1_0x5a6c3c(0xbd)]=async function(){const _0x5d6085=a1_0x5a6c3c,_0x271d1b=path['resolve']('./');logInfo(_0x5d6085(0xb9)),logWarning('此操作将优化当前目录下的代码,请确保已备份重要文件');const {confirmed:_0x5aeb48}=await inquirer[_0x5d6085(0xc8)]([{'type':'confirm','name':_0x5d6085(0xc6),'message':'是否确认优化代码?','default':![]}]);if(_0x5aeb48){logInfo(_0x5d6085(0xc7));try{bootstrap(_0x271d1b,0x64,()=>{const _0x340f69=_0x5d6085;logSuccess(_0x340f69(0xbf)),process['exit'](0x0);});}catch(_0x5ed75e){logError(_0x5d6085(0xbb)+_0x5ed75e[_0x5d6085(0xbc)]),process[_0x5d6085(0xb6)](0x1);}}else logInfo(_0x5d6085(0xc5)),process[_0x5d6085(0xb6)](0x0);};function a1_0x5326(){const _0x2ef530=['942696acAurL','exit','10236iJENuM','@cqsjjb/react-code-optimization','代码优化工具已启动','./utils','代码优化失败:\x20','message','exports','path','代码优化已完成','inquirer','71818Rngnrs','2584365CTfNsj','317634lNXwfo','48406CYOwMw','操作已取消','confirmed','正在分析代码结构...','prompt','628455YPEjjd'];a1_0x5326=function(){return _0x2ef530;};return a1_0x5326();}
package/src/config.js CHANGED
@@ -1,122 +1 @@
1
- const os = require('os');
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_0x1239(){const _0x5bc4e2=['6677867VEEKFr','96310kmEMkY','GIT_TEMP_JAVA','150fUoTWG','FqNrmFAgrxasMrbbjvq9','4558740lebucg','GIT_JAVA_ENV_JSON','CONFIG_FILE_HOST','http://192.168.1.242:10985','join','GIT_HOST','../package.json','http','hLqARY89CN6fUD3yg4NL','46502416wDmeFq','test','1793734WKZmEa','jjb-assembly-','d4wQ7dzEjYPsgVbKnYei','GIT_TEMP_DIR','gPSit8aJsLVmNzuQ5Cy4','3505460tuCMWL','now','http://120.26.210.58:8089','API_HOST_TEST','https://jcloud.cqjjb.cn','ywPtT3xCG6b_vAxp6sTj','https://cdn.cqjjb.cn/jjb-cloud-config','toString','httpMethod','2772748eZgDan','readFileSync','http://120.26.210.58:8088','7V-YUxhmh51Mdhgx4rq4','dev','CLOUD_PROJECT','path','getApiHost'];a2_0x1239=function(){return _0x5bc4e2;};return a2_0x1239();}const a2_0x202e9b=a2_0x2342;(function(_0x22dd3e,_0xea39fe){const _0x3789d1=a2_0x2342,_0x25a298=_0x22dd3e();while(!![]){try{const _0x48b683=-parseInt(_0x3789d1(0xb5))/0x1+-parseInt(_0x3789d1(0x94))/0x2+-parseInt(_0x3789d1(0xaa))/0x3+parseInt(_0x3789d1(0x9d))/0x4+-parseInt(_0x3789d1(0xa6))/0x5*(-parseInt(_0x3789d1(0xa8))/0x6)+-parseInt(_0x3789d1(0xa5))/0x7+parseInt(_0x3789d1(0xb3))/0x8;if(_0x48b683===_0xea39fe)break;else _0x25a298['push'](_0x25a298['shift']());}catch(_0x3d9430){_0x25a298['push'](_0x25a298['shift']());}}}(a2_0x1239,0xec35a));function a2_0x2342(_0x558a9a,_0x2a5a74){const _0x1239df=a2_0x1239();return a2_0x2342=function(_0x2342c3,_0x1d9339){_0x2342c3=_0x2342c3-0x90;let _0x18698e=_0x1239df[_0x2342c3];return _0x18698e;},a2_0x2342(_0x558a9a,_0x2a5a74);}const os=require('os'),path=require(a2_0x202e9b(0xa3)),fs=require('fs'),API_HOST=a2_0x202e9b(0x9f),API_HOST_HTTPS=a2_0x202e9b(0x98),API_HOST_TEST=a2_0x202e9b(0x96);exports[a2_0x202e9b(0xac)]=a2_0x202e9b(0x9a),exports['API_HOST']=API_HOST,exports[a2_0x202e9b(0x97)]=API_HOST_TEST,exports[a2_0x202e9b(0xaf)]=a2_0x202e9b(0xad),exports['GIT_TEMP_DIR']=a2_0x202e9b(0x90)+Date[a2_0x202e9b(0x95)](),exports[a2_0x202e9b(0xa7)]='jjb-assembly-java',exports[a2_0x202e9b(0xab)]={'development':a2_0x202e9b(0xa1),'production':'prod','test':a2_0x202e9b(0xb4)},exports[a2_0x202e9b(0xa2)]={'common':{'token':'G4HJRsHr9D7Ssmixegw2','projectId':0x117},'react-admin-component':{'token':'FT3pKzxpRynFkmddJ9Bs','projectId':0x154},'jjb-dva-runtime':{'token':a2_0x202e9b(0xb2),'projectId':0x23b},'jjb-common-lib':{'token':'e9njpBd1nS_LREN8GFpR','projectId':0x23c},'jjb-common-decorator':{'token':a2_0x202e9b(0x93),'projectId':0x23e},'vue-unisass-component':{'token':a2_0x202e9b(0x91),'projectId':0x153},'react-component':{'token':'snBxJ2i5kYarGGcsojhY','projectId':0x33f},'micro-app-ts':{'token':a2_0x202e9b(0xa0),'projectId':0x33e},'micro-app':{'token':a2_0x202e9b(0xa9),'projectId':0x33d},'lib':{'token':a2_0x202e9b(0x99),'projectId':0x33c}},exports['TEMPLATE_FOLDER']=path['join'](os['tmpdir'](),exports[a2_0x202e9b(0x92)]),exports[a2_0x202e9b(0xa4)]=()=>{const _0x23790a=a2_0x202e9b;try{const _0x2a1cdf=JSON['parse'](fs[_0x23790a(0x9e)](path[_0x23790a(0xae)](__dirname,_0x23790a(0xb0)))[_0x23790a(0x9b)]());return _0x2a1cdf['env']==='test'?API_HOST_TEST:_0x2a1cdf[_0x23790a(0x9c)]===_0x23790a(0xb1)?API_HOST:API_HOST_HTTPS;}catch(_0x53047e){return API_HOST_HTTPS;}};
@@ -0,0 +1 @@
1
+ const a3_0x3f74e1=a3_0x20f1;function a3_0x20f1(_0x1237d0,_0x17b56e){const _0x1cdc72=a3_0x1cdc();return a3_0x20f1=function(_0x20f172,_0x44606a){_0x20f172=_0x20f172-0xaf;let _0x460260=_0x1cdc72[_0x20f172];return _0x460260;},a3_0x20f1(_0x1237d0,_0x17b56e);}function a3_0x1cdc(){const _0x57e1da=['algorithm','1969638lIkWxz','utf8','认证文件不存在','sha256','split','认证数据格式错误','2uMItDj','解密失败:\x20','slice','1153110fYEhRw','8201952AEpniZ','createDecipheriv','hex','435741XeuDzT','keyLength','existsSync','342546UXApSA','digest','createCipheriv','concat','unknown','readFileSync','username','final','createHash','1372742VMGEcX','保存认证信息失败:\x20','base64','toString','读取认证信息失败:\x20','exports','aes-256-cbc','path','unlinkSync','加密失败:\x20','update','176424Tayopa','join','saltLength','randomBytes','arch','from','platform','message','ivLength','删除认证文件失败:\x20'];a3_0x1cdc=function(){return _0x57e1da;};return a3_0x1cdc();}(function(_0x37f16c,_0x4f64e2){const _0x46f46f=a3_0x20f1,_0x3061fd=_0x37f16c();while(!![]){try{const _0x256e1c=parseInt(_0x46f46f(0xd9))/0x1+-parseInt(_0x46f46f(0xcf))/0x2*(-parseInt(_0x46f46f(0xd6))/0x3)+-parseInt(_0x46f46f(0xbe))/0x4+parseInt(_0x46f46f(0xd2))/0x5+parseInt(_0x46f46f(0xc9))/0x6+parseInt(_0x46f46f(0xb3))/0x7+-parseInt(_0x46f46f(0xd3))/0x8;if(_0x256e1c===_0x4f64e2)break;else _0x3061fd['push'](_0x3061fd['shift']());}catch(_0x7bb94d){_0x3061fd['push'](_0x3061fd['shift']());}}}(a3_0x1cdc,0x2a584));const crypto=require('crypto'),fs=require('fs'),path=require(a3_0x3f74e1(0xba)),CRYPTO_CONFIG={'algorithm':a3_0x3f74e1(0xb9),'keyLength':0x20,'ivLength':0x10,'saltLength':0x20};function deriveKey(_0x1c9303,_0x6bfe14){const _0x52e199=a3_0x3f74e1;return crypto['pbkdf2Sync'](_0x1c9303,_0x6bfe14,0x186a0,CRYPTO_CONFIG[_0x52e199(0xd7)],'sha512');}function generateSalt(){const _0x45ee46=a3_0x3f74e1;return crypto[_0x45ee46(0xc1)](CRYPTO_CONFIG['saltLength']);}function generateIV(){const _0x669a9d=a3_0x3f74e1;return crypto[_0x669a9d(0xc1)](CRYPTO_CONFIG[_0x669a9d(0xc6)]);}function encrypt(_0x5a90fd,_0x4594b8){const _0x1e330e=a3_0x3f74e1;try{const _0x49bf9c=generateSalt(),_0x193b24=generateIV(),_0x1e7762=deriveKey(_0x4594b8,_0x49bf9c),_0x10c7a1=crypto[_0x1e330e(0xdb)](CRYPTO_CONFIG['algorithm'],_0x1e7762,_0x193b24);_0x10c7a1['setAutoPadding'](!![]);let _0x5dbbc7=_0x10c7a1['update'](_0x5a90fd,'utf8',_0x1e330e(0xd5));_0x5dbbc7+=_0x10c7a1[_0x1e330e(0xb1)]('hex');const _0x42e1c8=Buffer[_0x1e330e(0xdc)]([_0x49bf9c,_0x193b24,Buffer[_0x1e330e(0xc3)](_0x5dbbc7,_0x1e330e(0xd5))]);return _0x42e1c8[_0x1e330e(0xb6)](_0x1e330e(0xb5));}catch(_0x52c36b){throw new Error(_0x1e330e(0xbc)+_0x52c36b[_0x1e330e(0xc5)]);}}function decrypt(_0x538efa,_0x3ab1c3){const _0x31b8c3=a3_0x3f74e1;try{const _0x532bdb=Buffer[_0x31b8c3(0xc3)](_0x538efa,'base64'),_0x2e5170=_0x532bdb[_0x31b8c3(0xd1)](0x0,CRYPTO_CONFIG[_0x31b8c3(0xc0)]),_0x3389a1=_0x532bdb[_0x31b8c3(0xd1)](CRYPTO_CONFIG['saltLength'],CRYPTO_CONFIG[_0x31b8c3(0xc0)]+CRYPTO_CONFIG[_0x31b8c3(0xc6)]),_0x3e9b01=_0x532bdb[_0x31b8c3(0xd1)](CRYPTO_CONFIG[_0x31b8c3(0xc0)]+CRYPTO_CONFIG[_0x31b8c3(0xc6)]),_0x41a493=deriveKey(_0x3ab1c3,_0x2e5170),_0x4d4f16=crypto[_0x31b8c3(0xd4)](CRYPTO_CONFIG[_0x31b8c3(0xc8)],_0x41a493,_0x3389a1);_0x4d4f16['setAutoPadding'](!![]);let _0x168c11=_0x4d4f16[_0x31b8c3(0xbd)](_0x3e9b01,null,'utf8');return _0x168c11+=_0x4d4f16[_0x31b8c3(0xb1)](_0x31b8c3(0xca)),_0x168c11;}catch(_0x52b8b5){throw new Error(_0x31b8c3(0xd0)+_0x52b8b5[_0x31b8c3(0xc5)]);}}function generateDeviceKey(){const _0x390dd9=a3_0x3f74e1,_0x33d0ab=require('os'),_0x56773e=[_0x33d0ab[_0x390dd9(0xc4)](),_0x33d0ab[_0x390dd9(0xc2)](),_0x33d0ab['hostname'](),_0x33d0ab['userInfo']()[_0x390dd9(0xb0)]||_0x390dd9(0xdd)][_0x390dd9(0xbf)]('|');return crypto[_0x390dd9(0xb2)](_0x390dd9(0xcc))[_0x390dd9(0xbd)](_0x56773e)[_0x390dd9(0xda)](_0x390dd9(0xd5));}function saveAuth(_0x570706,_0x353aa9,_0x41cbbb){const _0x564b25=a3_0x3f74e1;try{const _0x2966e5=generateDeviceKey(),_0x21089c=_0x570706+'/'+_0x353aa9,_0x55468c=encrypt(_0x21089c,_0x2966e5);return fs['writeFileSync'](_0x41cbbb,_0x55468c,{'mode':0x180}),!![];}catch(_0x1fab8b){throw new Error(_0x564b25(0xb4)+_0x1fab8b[_0x564b25(0xc5)]);}}function loadAuth(_0xf27fff){const _0xe49f2=a3_0x3f74e1;try{if(!fs[_0xe49f2(0xd8)](_0xf27fff))throw new Error(_0xe49f2(0xcb));const _0x5b8b23=generateDeviceKey(),_0x535322=fs[_0xe49f2(0xaf)](_0xf27fff,'utf8'),_0x322e71=decrypt(_0x535322,_0x5b8b23),[_0x5e20d3,_0x49178e]=_0x322e71[_0xe49f2(0xcd)]('/');if(!_0x5e20d3||!_0x49178e)throw new Error(_0xe49f2(0xce));return{'username':_0x5e20d3,'password':_0x49178e};}catch(_0x54a425){throw new Error(_0xe49f2(0xb7)+_0x54a425[_0xe49f2(0xc5)]);}}function deleteAuth(_0x2b353a){const _0x4a35a2=a3_0x3f74e1;try{fs[_0x4a35a2(0xd8)](_0x2b353a)&&fs[_0x4a35a2(0xbb)](_0x2b353a);}catch(_0x373378){throw new Error(_0x4a35a2(0xc7)+_0x373378['message']);}}module[a3_0x3f74e1(0xb8)]={'encrypt':encrypt,'decrypt':decrypt,'saveAuth':saveAuth,'loadAuth':loadAuth,'deleteAuth':deleteAuth,'generateDeviceKey':generateDeviceKey};
@@ -0,0 +1 @@
1
+ function a4_0x2713(_0x3a7204,_0x3527db){const _0x48063e=a4_0x4806();return a4_0x2713=function(_0x2713b0,_0x415d9a){_0x2713b0=_0x2713b0-0xe5;let _0x4fc99a=_0x48063e[_0x2713b0];return _0x4fc99a;},a4_0x2713(_0x3a7204,_0x3527db);}function a4_0x4806(){const _0x32bc12=['请输入账号:','2516136QJTfXj','请输入密码:','trim','./utils','密码不能为空','730000EBfYEP','2470875bvaZEP','账号不能为空','获取认证信息失败:\x20','240657RxxNqF','6220eezBhG','input','username','push','prompt','exports','3BtbWGG','7vkckDi','2180880udhFDf','1458488akJTtO','isTtyError','password','message'];a4_0x4806=function(){return _0x32bc12;};return a4_0x4806();}const a4_0xcb6d08=a4_0x2713;(function(_0x500358,_0x49f955){const _0x3eaf71=a4_0x2713,_0x2adf1c=_0x500358();while(!![]){try{const _0x3658c2=parseInt(_0x3eaf71(0xeb))/0x1+parseInt(_0x3eaf71(0xe7))/0x2*(parseInt(_0x3eaf71(0xf2))/0x3)+-parseInt(_0x3eaf71(0xec))/0x4+parseInt(_0x3eaf71(0xe8))/0x5+-parseInt(_0x3eaf71(0xfa))/0x6+-parseInt(_0x3eaf71(0xf3))/0x7*(parseInt(_0x3eaf71(0xf5))/0x8)+-parseInt(_0x3eaf71(0xf4))/0x9;if(_0x3658c2===_0x49f955)break;else _0x2adf1c['push'](_0x2adf1c['shift']());}catch(_0x561f4c){_0x2adf1c['push'](_0x2adf1c['shift']());}}}(a4_0x4806,0x3e152));const inquirer=require('inquirer'),{logError}=require(a4_0xcb6d08(0xe5));async function getCredentials(_0x50542b=null){const _0x42ebcf=a4_0xcb6d08;try{let _0x5b89e2=_0x50542b;const _0x5ddabd=[];!_0x5b89e2&&_0x5ddabd['push']({'type':_0x42ebcf(0xed),'name':_0x42ebcf(0xee),'message':_0x42ebcf(0xf9),'validate':_0x31b75a=>{const _0x3a7ebb=_0x42ebcf;if(!_0x31b75a||!_0x31b75a[_0x3a7ebb(0xfc)]())return _0x3a7ebb(0xe9);return!![];}});_0x5ddabd[_0x42ebcf(0xef)]({'type':_0x42ebcf(0xf7),'name':_0x42ebcf(0xf7),'message':_0x42ebcf(0xfb),'mask':'*','validate':_0x1cc089=>{const _0x4f24e2=_0x42ebcf;if(!_0x1cc089||!_0x1cc089[_0x4f24e2(0xfc)]())return _0x4f24e2(0xe6);return!![];}});const _0x182c76=await inquirer[_0x42ebcf(0xf0)](_0x5ddabd);_0x5b89e2=_0x5b89e2||_0x182c76[_0x42ebcf(0xee)][_0x42ebcf(0xfc)]();const _0x305853=_0x182c76['password'];return{'username':_0x5b89e2,'password':_0x305853};}catch(_0x994d80){_0x994d80[_0x42ebcf(0xf6)]?logError('获取认证信息失败:\x20当前环境不支持交互式输入'):logError(_0x42ebcf(0xea)+_0x994d80[_0x42ebcf(0xf8)]);throw _0x994d80;}}async function interactiveAuth(){return await getCredentials();}module[a4_0xcb6d08(0xf1)]={'getCredentials':getCredentials,'interactiveAuth':interactiveAuth};
package/src/publish.js CHANGED
@@ -1,222 +1 @@
1
- const path = require('path');
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
+ function a5_0xb4a2(){const _0x273e46=['platform','stringify','thumbnailPath','28088522XhjyCA','\x20\x201.\x20已充分测试组件各项功能','暴露的配置信息中缺少\x22settings\x22!','input','组件发布失败!根目录缺少\x27package.json\x27文件!','110BNJpaC','项目构建完成','8QsJlvQ','username','发布失败\x20(','2xHaQpx','post','):\x20','path','catch','未检测到认证信息,请先执行登录操作','网络连接失败:\x20无法连接到服务器或服务器无响应','组件配置解析完成','no\x20message','182421btxDzs','request','发布错误可能导致线上应用产生严重生产故障,请务必确保:','\x20秒...\x20\x20','正在提交发布请求...','dist','message','readmePath','base64','parse','prompt','status','9783872zoWFYS','\x20\x205.\x20发布成功后请立即通知相关人员进行测试和验证','exit','yarn.lock','join','defaultSetting','exports','发布操作已取消','文件验证通过','正在处理缩略图...','未知错误','):\x20认证信息无效或无权限','data','length','../package.json','请在组件根目录添加一个README.md说明文件!','then','match','项目构建失败:\x20','暴露的配置信息中缺少\x22info\x22!','我已充分了解以上可能存在的严重风险,确认继续发布操作?','./config','1626159Zfsneg','assign','836559fxolCg','发布失败:\x20','toString','index.js','组件发布成功','response','distPath','return\x20','请输入此次组件发布的信息:','2718272mJlRdC','inquirer','confirmed','confirm','resolve','认证信息加载成功','服务器授权成功','请求失败\x20(','stdout','write','2589738NEVwWk','\x0d倒计时\x20','网络连接失败:\x20无法连接到服务器','正在验证发布所需文件...','5sfyAHb','thumbnail_base64','组件发布失败!根目录缺少\x27dist/index.js\x27文件!','/api/auth','binary','msg','正在准备发布数据...','password','README.md','thumbnail.png','正在加载认证信息...','正在请求服务器授权...','./utils'];a5_0xb4a2=function(){return _0x273e46;};return a5_0xb4a2();}const a5_0x24e10c=a5_0x213b;(function(_0x1b07d5,_0x135ab1){const _0x36fed0=a5_0x213b,_0x18927f=_0x1b07d5();while(!![]){try{const _0x2dd07a=parseInt(_0x36fed0(0x1c4))/0x1*(-parseInt(_0x36fed0(0x197))/0x2)+parseInt(_0x36fed0(0x1c2))/0x3*(parseInt(_0x36fed0(0x194))/0x4)+-parseInt(_0x36fed0(0x1db))/0x5*(parseInt(_0x36fed0(0x1d7))/0x6)+-parseInt(_0x36fed0(0x1ac))/0x7+-parseInt(_0x36fed0(0x1cd))/0x8+parseInt(_0x36fed0(0x1a0))/0x9*(parseInt(_0x36fed0(0x192))/0xa)+parseInt(_0x36fed0(0x18d))/0xb;if(_0x2dd07a===_0x135ab1)break;else _0x18927f['push'](_0x18927f['shift']());}catch(_0x45a2e0){_0x18927f['push'](_0x18927f['shift']());}}}(a5_0xb4a2,0xd0b79));function a5_0x213b(_0x2409ad,_0x574ae7){const _0xb4a293=a5_0xb4a2();return a5_0x213b=function(_0x213b74,_0x54c4ea){_0x213b74=_0x213b74-0x17f;let _0x40d82a=_0xb4a293[_0x213b74];return _0x40d82a;},a5_0x213b(_0x2409ad,_0x574ae7);}const path=require(a5_0x24e10c(0x19a)),os=require('os'),axios=require('axios'),inquirer=require(a5_0x24e10c(0x1ce)),{getApiHost}=require(a5_0x24e10c(0x1c1)),{CONSTANTS,logInfo,logSuccess,logWarning,logError,executeCommand,fileExists,readFile,writeFile}=require(a5_0x24e10c(0x189)),{loadAuth}=require('./crypto-utils');function parseComponentConfig(_0x4060ac){const _0x40e7b3=a5_0x24e10c,_0x3515aa=_0x4060ac['match'](/(window\[).+?(\.componentKey|.+]={)/img);if(!_0x3515aa||!_0x3515aa[_0x40e7b3(0x1b9)])throw new Error('请在组件入口文件中添加\x22window[props.componentKey]\x22以暴露组件的配置信息!');const _0x5474a6={},_0x4f3a5e=_0x4060ac[_0x40e7b3(0x1bd)](/componentKey.+([{,]info:\s{0,}{)/img);if(!_0x4f3a5e||!_0x4f3a5e[_0x40e7b3(0x1b9)])throw new Error(_0x40e7b3(0x1bf));let _0x352f97='{';const _0x3417df=_0x4060ac['split'](_0x4f3a5e[0x0])[0x1];for(let _0x97525b=0x0;_0x97525b<_0x3417df[_0x40e7b3(0x1b9)];_0x97525b++){_0x352f97+=_0x3417df[_0x97525b];if(_0x3417df[_0x97525b]==='}'){try{const _0x3a8a=new Function('return\x20'+_0x352f97)();Object[_0x40e7b3(0x1c3)](_0x5474a6,_0x3a8a),_0x5474a6['defaultSetting']={};}catch(_0x574ff5){}break;}}const _0x4bc1e0=_0x4060ac[_0x40e7b3(0x1bd)](/componentKey.+([{,]settings:\s{0,}{)/img);if(!_0x4bc1e0||!_0x4bc1e0[_0x40e7b3(0x1b9)])throw new Error(_0x40e7b3(0x18f));let _0x5ef49d='{';const _0x499aa6=_0x4060ac['split'](_0x4bc1e0[0x0])[0x1];for(let _0x474f46=0x0;_0x474f46<_0x499aa6[_0x40e7b3(0x1b9)];_0x474f46++){_0x5ef49d+=_0x499aa6[_0x474f46];if(_0x499aa6[_0x474f46]==='}'){try{_0x5474a6[_0x40e7b3(0x1b1)]=new Function(_0x40e7b3(0x1cb)+_0x5ef49d)();}catch(_0x33dd25){}break;}}return JSON[_0x40e7b3(0x18b)](_0x5474a6);}function executeBuild(_0x25ae93){const _0x4924b8=a5_0x24e10c,_0x1e9689=path[_0x4924b8(0x1b0)](_0x25ae93,_0x4924b8(0x1af));fileExists(_0x1e9689)?executeCommand('yarn\x20build:production',_0x25ae93):executeCommand('npm\x20run\x20build:production',_0x25ae93);}function validateRequiredFiles(_0x345598){const _0x55f8dd=a5_0x24e10c,_0x486931=path[_0x55f8dd(0x1b0)](_0x345598,_0x55f8dd(0x185)),_0x335b6c=path[_0x55f8dd(0x1b0)](_0x345598,_0x55f8dd(0x1a5),_0x55f8dd(0x1c7)),_0x35fe46=path[_0x55f8dd(0x1b0)](_0x345598,'package.json'),_0x3023b3=path[_0x55f8dd(0x1b0)](_0x345598,_0x55f8dd(0x186));if(!fileExists(_0x35fe46))throw new Error(_0x55f8dd(0x191));if(!fileExists(_0x335b6c))throw new Error(_0x55f8dd(0x17f));if(!fileExists(_0x486931))throw new Error(_0x55f8dd(0x1bb));if(!fileExists(_0x3023b3))throw new Error('请在组件根目录为组件添加一个缩略图\x22thumbnail.png\x22文件!');return{'readmePath':_0x486931,'distPath':_0x335b6c,'packageJsonPath':_0x35fe46,'thumbnailPath':_0x3023b3};}const submitFun=function(_0x569bac,_0x17c09e){const _0x1fa526=a5_0x24e10c;_0x17c09e[_0x1fa526(0x1a6)]=_0x569bac||_0x1fa526(0x19f),axios[_0x1fa526(0x198)](getApiHost()+'/api/file/publish',_0x17c09e)[_0x1fa526(0x1bc)](_0x4d83d3=>{const _0x27a104=_0x1fa526;logSuccess(_0x4d83d3['data'][_0x27a104(0x1a6)]||_0x27a104(0x1c8)),process[_0x27a104(0x1ae)](0x0);})[_0x1fa526(0x19b)](_0x2722b5=>{const _0x56fe94=_0x1fa526;if(_0x2722b5&&_0x2722b5['response']){const _0x5a51e9=_0x2722b5['response'][_0x56fe94(0x1ab)],_0x47fefb=_0x2722b5[_0x56fe94(0x1c9)][_0x56fe94(0x1b8)]&&(_0x2722b5[_0x56fe94(0x1c9)][_0x56fe94(0x1b8)][_0x56fe94(0x1a6)]||_0x2722b5[_0x56fe94(0x1c9)][_0x56fe94(0x1b8)][_0x56fe94(0x182)])||'';logError(_0x56fe94(0x196)+_0x5a51e9+_0x56fe94(0x199)+(_0x47fefb||_0x2722b5[_0x56fe94(0x1a6)]));}else _0x2722b5&&_0x2722b5[_0x56fe94(0x1a1)]?logError(_0x56fe94(0x1d9)):logError(_0x56fe94(0x1c5)+(_0x2722b5[_0x56fe94(0x1a6)]||'未知错误'));process[_0x56fe94(0x1ae)](0x1);});};module[a5_0x24e10c(0x1b2)]=_0x5eafb0=>{const _0x3d55bf=a5_0x24e10c,_0x277976=path['join'](__dirname,'../.auth');!fileExists(_0x277976)&&(logError(_0x3d55bf(0x19c)),process[_0x3d55bf(0x1ae)](0x1));let _0x49a14d,_0x3d45db;try{logInfo(_0x3d55bf(0x187));const _0x3a8d8f=loadAuth(_0x277976);_0x49a14d=_0x3a8d8f[_0x3d55bf(0x195)],_0x3d45db=_0x3a8d8f[_0x3d55bf(0x184)],logSuccess(_0x3d55bf(0x1d2));}catch(_0x4e6e9f){logError('读取认证信息失败:\x20'+_0x4e6e9f[_0x3d55bf(0x1a6)]),process[_0x3d55bf(0x1ae)](0x1);}logInfo(_0x3d55bf(0x188)),axios[_0x3d55bf(0x198)](getApiHost()+_0x3d55bf(0x180),{'username':_0x49a14d,'password':_0x3d45db})[_0x3d55bf(0x1bc)](async _0x446d37=>{const _0x36b2c1=_0x3d55bf;if(_0x446d37[_0x36b2c1(0x1b8)]['status']){logSuccess(_0x36b2c1(0x1d3));const _0xe1269a=path[_0x36b2c1(0x1d1)]('./');logInfo('正在执行项目构建...');try{executeBuild(_0xe1269a),logSuccess(_0x36b2c1(0x193));}catch(_0x554b72){logError(_0x36b2c1(0x1be)+_0x554b72[_0x36b2c1(0x1a6)]),process[_0x36b2c1(0x1ae)](0x1);}logInfo(_0x36b2c1(0x1da));let _0x105cae;try{_0x105cae=validateRequiredFiles(_0xe1269a),logSuccess(_0x36b2c1(0x1b4));}catch(_0x2a15b4){logError(_0x2a15b4[_0x36b2c1(0x1a6)]),process[_0x36b2c1(0x1ae)](0x1);}logInfo('正在读取包信息...');const _0x54259c=JSON[_0x36b2c1(0x1a9)](readFile(path[_0x36b2c1(0x1b0)](__dirname,_0x36b2c1(0x1ba)))),{version:_0x189ab6}=_0x54259c;logInfo(_0x36b2c1(0x183));const _0x37a147={'username':_0x49a14d,'cmd_version':_0x189ab6,'hostname':os['hostname'](),'platform':os[_0x36b2c1(0x18a)](),'package_version':_0x5eafb0||0x0,'package_content':readFile(_0x105cae[_0x36b2c1(0x1ca)]),'readme_content':readFile(_0x105cae[_0x36b2c1(0x1a7)])};try{logInfo('正在解析组件配置信息...');const _0x31ae41=readFile(_0x105cae[_0x36b2c1(0x1ca)]);_0x37a147['component_config_content']=parseComponentConfig(_0x31ae41),logSuccess(_0x36b2c1(0x19e));}catch(_0x157dcb){logError(_0x157dcb['message']),process['exit'](0x1);}logInfo(_0x36b2c1(0x1b5));const _0x4897ef=readFile(_0x105cae[_0x36b2c1(0x18c)],_0x36b2c1(0x181));_0x37a147[_0x36b2c1(0x1dc)]=Buffer['from'](_0x4897ef,_0x36b2c1(0x181))[_0x36b2c1(0x1c6)](_0x36b2c1(0x1a8)),logSuccess('缩略图处理完成'),logWarning('警告:您即将进行组件发布操作,此操作不可逆,请谨慎操作'),logWarning(_0x36b2c1(0x1a2)),logWarning(_0x36b2c1(0x18e)),logWarning('\x20\x202.\x20已检查构建产物完整性'),logWarning('\x20\x203.\x20已确认版本号和发布信息正确'),logWarning('\x20\x204.\x20已了解发布后的影响范围'),logWarning(_0x36b2c1(0x1ad)),await new Promise(_0x3d62ae=>{let _0x3251d3=0xa;const _0x436c80=setInterval(()=>{const _0x4ad1ab=a5_0x213b;process[_0x4ad1ab(0x1d5)][_0x4ad1ab(0x1d6)](_0x4ad1ab(0x1d8)+_0x3251d3+_0x4ad1ab(0x1a3)),_0x3251d3--,_0x3251d3<0x0&&(clearInterval(_0x436c80),process['stdout'][_0x4ad1ab(0x1d6)]('\x0d\x0a'),_0x3d62ae());},0x3e8);});const {confirmed:_0x33a235}=await inquirer[_0x36b2c1(0x1aa)]([{'type':_0x36b2c1(0x1d0),'name':_0x36b2c1(0x1cf),'message':_0x36b2c1(0x1c0),'default':![]}]);!_0x33a235&&(logInfo(_0x36b2c1(0x1b3)),process[_0x36b2c1(0x1ae)](0x0));const {message:_0x5a62e8}=await inquirer[_0x36b2c1(0x1aa)]([{'type':_0x36b2c1(0x190),'name':_0x36b2c1(0x1a6),'message':_0x36b2c1(0x1cc),'default':_0x36b2c1(0x19f)}]);logInfo(_0x36b2c1(0x1a4)),submitFun(_0x5a62e8||_0x36b2c1(0x19f),_0x37a147);}else logError('授权失败:\x20'+(_0x446d37[_0x36b2c1(0x1b8)][_0x36b2c1(0x1a6)]||_0x36b2c1(0x1b6))),process[_0x36b2c1(0x1ae)](0x1);})[_0x3d55bf(0x19b)](_0x16c4b7=>{const _0x86db5c=_0x3d55bf;if(_0x16c4b7&&_0x16c4b7[_0x86db5c(0x1c9)]){const _0x1eb3e6=_0x16c4b7[_0x86db5c(0x1c9)][_0x86db5c(0x1ab)];if(_0x1eb3e6===0x191||_0x1eb3e6===0x193)logError('授权失败\x20('+_0x1eb3e6+_0x86db5c(0x1b7));else{const _0x207642=_0x16c4b7[_0x86db5c(0x1c9)]['data']&&(_0x16c4b7[_0x86db5c(0x1c9)]['data'][_0x86db5c(0x1a6)]||_0x16c4b7[_0x86db5c(0x1c9)][_0x86db5c(0x1b8)][_0x86db5c(0x182)])||'';logError(_0x86db5c(0x1d4)+_0x1eb3e6+_0x86db5c(0x199)+(_0x207642||_0x16c4b7['message']));}}else _0x16c4b7&&_0x16c4b7[_0x86db5c(0x1a1)]?logError(_0x86db5c(0x19d)):logError('操作失败:\x20'+(_0x16c4b7?_0x16c4b7['message']:_0x86db5c(0x1b6)));process[_0x86db5c(0x1ae)](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_0x271645=a6_0x2c3a;(function(_0x2232d0,_0x3f82cd){const _0x5cd49e=a6_0x2c3a,_0x5863cf=_0x2232d0();while(!![]){try{const _0xf9e4a4=-parseInt(_0x5cd49e(0x150))/0x1*(-parseInt(_0x5cd49e(0xfc))/0x2)+parseInt(_0x5cd49e(0x154))/0x3*(parseInt(_0x5cd49e(0x11e))/0x4)+-parseInt(_0x5cd49e(0x13a))/0x5*(-parseInt(_0x5cd49e(0x12e))/0x6)+parseInt(_0x5cd49e(0x157))/0x7*(-parseInt(_0x5cd49e(0x137))/0x8)+-parseInt(_0x5cd49e(0x167))/0x9+-parseInt(_0x5cd49e(0x17b))/0xa*(parseInt(_0x5cd49e(0x12c))/0xb)+parseInt(_0x5cd49e(0x15e))/0xc;if(_0xf9e4a4===_0x3f82cd)break;else _0x5863cf['push'](_0x5863cf['shift']());}catch(_0x433a6e){_0x5863cf['push'](_0x5863cf['shift']());}}}(a6_0x1784,0x5aba1));function a6_0x2c3a(_0x18d8fb,_0x5a83d8){const _0x178479=a6_0x1784();return a6_0x2c3a=function(_0x2c3a5b,_0x28c877){_0x2c3a5b=_0x2c3a5b-0xfc;let _0x1c541b=_0x178479[_0x2c3a5b];return _0x1c541b;},a6_0x2c3a(_0x18d8fb,_0x5a83d8);}function a6_0x1784(){const _0x1e09e8=['10daJhrQ','26212laMeUx','认证信息加载成功','then','请选择环境:','uncaughtException','join','split','yarn\x20run\x20','git\x20checkout\x20','node_modules','appIdentifier','清理临时目录失败:\x20','正在准备临时工作目录...','javaGit','selectedScript','username','exit','项目依赖安装完成','./utils','toLowerCase','DEFAULT_BRANCH','.html','正在加载认证信息...','environment\x20配置为空,将使用默认分支','构建产物复制完成','读取认证信息失败:\x20','package.json','临时工作目录已创建','prompt','request','default','代码提交跳过:\x20没有需要提交的变更','javaGitName','\x22\x20--no-verify','16OxmMvI','正在处理构建产物...','代码推送完成','正在检查项目配置文件...','项目依赖检查通过','正在推送代码到远程仓库...','MAX_BUFFER_SIZE','data','scripts','input','代码提交成功','random','正在请求服务器授权...','response','5648236ouOFhH','keys','107892NkRsTV','password','构建产物目录不存在,请检查构建输出配置','yarn','build','tmpdir','./config','已生成\x20','index.html','24gVfxDq','git\x20clone\x20','正在切换到目标分支:\x20','90FuBJxB','length','git\x20commit\x20-m\x20\x22','未知错误','服务器授权成功','substr','已选择环境:\x20','正在添加文件变更...','catch','package.json\x20读取成功','utf8','commitMessage','正在清理目标目录...','已选择打包命令:\x20','now','exports','检测到已存在的仓库,正在强制清理...','未找到\x20jjb.config.json\x20文件','message','/api/auth','list','请求失败\x20(','27aORxiZ','git\x20push','envType','Git\x20仓库克隆完成','151818caUZYu','已生成\x20index.html\x20文件','临时工作目录已清理:\x20','416339kzcooW','未找到\x20environment\x20配置,将使用默认分支','检测到未安装项目依赖','正在安装项目依赖,请稍候...','no\x20message','readFileSync','includes','2947212VEIlwk','trim','解析\x20jjb.config.json\x20失败:\x20','配置文件中缺少必要字段:\x20','inquirer','javaGitBranch','object','some','.html\x20文件','558351GEhcDZ','__esModule','分支切换完成','CONFIG_FILE_NAME','git\x20pull','resolve','force','../.auth','请输入提交信息:','isValid','未找到打包相关的命令,请检查\x20package.json\x20中的\x20scripts\x20配置','TEMPLATES_PATH','正在提交代码变更...','项目构建完成','正在同步\x20Git\x20仓库最新代码...','environment','toString','SYNC_DELAY','正在克隆\x20Git\x20仓库...','missingFields'];a6_0x1784=function(){return _0x1e09e8;};return a6_0x1784();}const os=require('os'),path=require('path'),fs=require('fs'),inquirer=require(a6_0x271645(0x162)),{CopyFolder,DeleteDirAllFile}=require(a6_0x271645(0x10e)),{GIT_TEMP_JAVA,getApiHost}=require(a6_0x271645(0x134)),axios=require('axios'),{CONSTANTS,logInfo,logSuccess,logWarning,logError,executeCommand,deleteFolderRecursive,fileExists,readFile,writeFile,createDir,isViteProject,validateConfig}=require(a6_0x271645(0x10e)),{loadAuth}=require('./crypto-utils');module[a6_0x271645(0x149)]=async arguments=>{const _0x352baa=a6_0x271645;let _0x18febf=null;const _0x2d2c90=path[_0x352baa(0x101)](__dirname,_0x352baa(0x16e));!fileExists(_0x2d2c90)&&(logError('未检测到认证信息,请先执行登录操作'),process[_0x352baa(0x10c)](0x1));let _0x5126af,_0x38aaec;try{logInfo(_0x352baa(0x112));const _0x5b82fc=loadAuth(_0x2d2c90);_0x5126af=_0x5b82fc[_0x352baa(0x10b)],_0x38aaec=_0x5b82fc[_0x352baa(0x12f)],logSuccess(_0x352baa(0xfd));}catch(_0x5f5a9e){logError(_0x352baa(0x115)+_0x5f5a9e[_0x352baa(0x14c)]),process['exit'](0x1);}const _0x3bc4cd=arguments[0x1]?arguments[0x1][_0x352baa(0x102)]('-'):[],_0x521eb5=path[_0x352baa(0x16c)]('./'),_0x33dd88=path[_0x352baa(0x101)](_0x521eb5,_0x352baa(0x116)),_0x3067a4=path[_0x352baa(0x101)](_0x521eb5,CONSTANTS[_0x352baa(0x16a)]),_0x2e28b8=path[_0x352baa(0x101)](_0x521eb5,CONSTANTS['BUILD_OUTPUT_DIR']),_0xff2cb6=os['tmpdir']();logInfo(_0x352baa(0x121));!fileExists(_0x33dd88)&&(logError('未找到\x20package.json\x20文件'),process['exit'](0x1));let _0x1ddc26;try{_0x1ddc26=JSON['parse'](fs[_0x352baa(0x15c)](_0x33dd88,_0x352baa(0x144))),logSuccess(_0x352baa(0x143));}catch(_0x1f2291){logError('解析\x20package.json\x20失败:\x20'+_0x1f2291[_0x352baa(0x14c)]),process[_0x352baa(0x10c)](0x1);}const _0x4f3425=_0x1ddc26[_0x352baa(0x126)]||{},_0xfd5261=[_0x352baa(0x132)],_0xa68502=Object[_0x352baa(0x12d)](_0x4f3425)['filter'](_0x295d95=>{const _0x4da627=_0x352baa;return _0xfd5261[_0x4da627(0x165)](_0x938756=>_0x295d95[_0x4da627(0x10f)]()[_0x4da627(0x15d)](_0x938756));});_0xa68502[_0x352baa(0x13b)]===0x0&&(logError(_0x352baa(0x171)),process[_0x352baa(0x10c)](0x1));const {selectedScript:_0x4ce257}=await inquirer[_0x352baa(0x118)]([{'type':'list','name':_0x352baa(0x10a),'message':'请选择要执行的打包命令:','choices':_0xa68502['map'](_0x3b541c=>({'name':_0x3b541c+'\x20('+_0x4f3425[_0x3b541c]+')','value':_0x3b541c}))}]);logInfo(_0x352baa(0x147)+_0x4ce257),logInfo(_0x352baa(0x121));!fileExists(_0x3067a4)&&(logError(_0x352baa(0x14b)),process['exit'](0x1));let _0x29fda4;try{_0x29fda4=require(_0x3067a4),_0x29fda4=_0x29fda4[_0x352baa(0x168)]?_0x29fda4[_0x352baa(0x11a)]:_0x29fda4,logSuccess('jjb.config.json\x20读取成功');}catch(_0x52cc40){logError(_0x352baa(0x160)+_0x52cc40[_0x352baa(0x14c)]),process[_0x352baa(0x10c)](0x1);}const _0x54ac90=['javaGit',_0x352baa(0x11c),_0x352baa(0x106)],_0x468d1b=validateConfig(_0x29fda4,_0x54ac90);!_0x468d1b[_0x352baa(0x170)]&&(logError(_0x352baa(0x161)+_0x468d1b[_0x352baa(0x17a)][_0x352baa(0x101)](',\x20')),process[_0x352baa(0x10c)](0x1));let _0x1c799e=null;if(_0x29fda4[_0x352baa(0x176)]&&typeof _0x29fda4[_0x352baa(0x176)]===_0x352baa(0x164)){const _0xa250d0=Object[_0x352baa(0x12d)](_0x29fda4[_0x352baa(0x176)]);if(_0xa250d0[_0x352baa(0x13b)]>0x0){const {envType:_0x480205}=await inquirer[_0x352baa(0x118)]([{'type':_0x352baa(0x14e),'name':_0x352baa(0x152),'message':_0x352baa(0xff),'choices':_0xa250d0['map'](_0x38121e=>({'name':_0x38121e,'value':_0x38121e}))}]);_0x1c799e=_0x480205,logInfo(_0x352baa(0x140)+_0x1c799e);}else logWarning(_0x352baa(0x113));}else logWarning(_0x352baa(0x158));logInfo(_0x352baa(0x12a)),axios['post'](getApiHost()+_0x352baa(0x14d),{'username':_0x5126af,'password':_0x38aaec})[_0x352baa(0xfe)](async _0x47d9cf=>{const _0x7c9e79=_0x352baa;if(_0x47d9cf['data']['status']){logSuccess(_0x7c9e79(0x13e));const _0x61a451=GIT_TEMP_JAVA+'-'+Date[_0x7c9e79(0x148)]()+'-'+Math[_0x7c9e79(0x129)]()[_0x7c9e79(0x177)](0x24)[_0x7c9e79(0x13f)](0x2,0x9);_0x18febf=_0x61a451;const _0x4ae37c=path[_0x7c9e79(0x101)](_0xff2cb6,_0x61a451);logInfo(_0x7c9e79(0x108));fileExists(_0x4ae37c)&&deleteFolderRecursive(_0x4ae37c);createDir(_0x4ae37c),logSuccess(_0x7c9e79(0x117));const _0x32b713=path[_0x7c9e79(0x101)](_0x4ae37c,_0x29fda4[_0x7c9e79(0x11c)]);logInfo(_0x7c9e79(0x179)),fileExists(_0x32b713)?_0x3bc4cd['includes'](_0x7c9e79(0x16d))?(logInfo(_0x7c9e79(0x14a)),DeleteDirAllFile(_0x32b713,()=>{const _0x498c78=_0x7c9e79;executeCommand(_0x498c78(0x138)+_0x29fda4[_0x498c78(0x109)],_0x4ae37c),logSuccess('Git\x20仓库克隆完成');})):(executeCommand(_0x7c9e79(0x138)+_0x29fda4['javaGit'],_0x4ae37c),logSuccess(_0x7c9e79(0x153))):(executeCommand('git\x20clone\x20'+_0x29fda4[_0x7c9e79(0x109)],_0x4ae37c),logSuccess(_0x7c9e79(0x153))),_0x4c8a98(_0x4ae37c,_0x29fda4,_0x61a451,_0x4ce257,_0x1c799e);}else logError('授权失败:\x20'+(_0x47d9cf[_0x7c9e79(0x125)][_0x7c9e79(0x14c)]||_0x7c9e79(0x13d))),process[_0x7c9e79(0x10c)](0x1);})[_0x352baa(0x142)](_0x411571=>{const _0x3dd791=_0x352baa;if(_0x411571&&_0x411571[_0x3dd791(0x12b)]){const _0x2caafb=_0x411571[_0x3dd791(0x12b)]['status'];_0x2caafb===0x191||_0x2caafb===0x193?logError('授权失败\x20('+_0x2caafb+'):\x20认证信息无效或无权限'):logError(_0x3dd791(0x14f)+_0x2caafb+'):\x20'+(_0x411571[_0x3dd791(0x12b)][_0x3dd791(0x125)]?.[_0x3dd791(0x14c)]||_0x411571[_0x3dd791(0x14c)]));}else _0x411571&&_0x411571[_0x3dd791(0x119)]?logError('网络连接失败:\x20无法连接到服务器'):logError('操作失败:\x20'+(_0x411571[_0x3dd791(0x14c)]||'未知错误'));process[_0x3dd791(0x10c)](0x1);}),process['on'](_0x352baa(0x10c),()=>{const _0x83f3e9=_0x352baa;if(_0x18febf){const _0x2f8126=path[_0x83f3e9(0x101)](os[_0x83f3e9(0x133)](),_0x18febf);if(fileExists(_0x2f8126))try{deleteFolderRecursive(_0x2f8126);}catch(_0x2c39b9){}}}),process['on'](_0x352baa(0x100),_0x927da=>{const _0x34748f=_0x352baa;if(_0x18febf){const _0x57226e=path[_0x34748f(0x101)](os[_0x34748f(0x133)](),_0x18febf);if(fileExists(_0x57226e))try{deleteFolderRecursive(_0x57226e);}catch(_0x2c2a6d){}}throw _0x927da;});function _0x4c8a98(_0x47d43a,_0x1558d7,_0x38be31,_0x4db1c1,_0x483a48){const _0x568e63=_0x352baa,_0x1e918f=path[_0x568e63(0x101)](_0x47d43a,_0x1558d7[_0x568e63(0x11c)]);logInfo(_0x568e63(0x175)),executeCommand(_0x568e63(0x16b),_0x1e918f),logSuccess('代码同步完成');!fileExists(path[_0x568e63(0x101)](_0x521eb5,_0x568e63(0x105)))?(logWarning(_0x568e63(0x159)),logInfo(_0x568e63(0x15a)),executeCommand(_0x568e63(0x131),_0x521eb5),logSuccess(_0x568e63(0x10d))):logInfo(_0x568e63(0x122));try{logInfo('正在执行构建命令:\x20yarn\x20run\x20'+_0x4db1c1),executeCommand(_0x568e63(0x103)+_0x4db1c1,_0x521eb5,{'maxBuffer':CONSTANTS[_0x568e63(0x124)]}),logSuccess(_0x568e63(0x174));}catch(_0x39232d){logError('项目构建失败:\x20'+_0x39232d[_0x568e63(0x14c)]);const _0x24859a=path[_0x568e63(0x101)](os['tmpdir'](),_0x38be31);if(fileExists(_0x24859a))try{deleteFolderRecursive(_0x24859a),logInfo('临时工作目录已清理:\x20'+_0x38be31);}catch(_0x25b765){logWarning(_0x568e63(0x107)+_0x25b765[_0x568e63(0x14c)]);}process['exit'](0x1);}if(fileExists(_0x2e28b8)){logInfo(_0x568e63(0x11f));const _0x43057c=_0x1558d7['appIdentifier'],_0x516074=readFile(path[_0x568e63(0x101)](_0x2e28b8,_0x568e63(0x136)));_0x3bc4cd[_0x568e63(0x15d)]('index')?(writeFile(path[_0x568e63(0x101)](_0x2e28b8,_0x568e63(0x136)),_0x516074),logInfo(_0x568e63(0x155))):(writeFile(path['join'](_0x2e28b8,_0x43057c+'.html'),_0x516074),logInfo(_0x568e63(0x135)+_0x43057c+_0x568e63(0x166)));const _0x39fccc=path[_0x568e63(0x101)](_0x1e918f,CONSTANTS[_0x568e63(0x172)]);logInfo('正在创建模板目录...'),createDir(_0x39fccc);const _0x427e90=_0x483a48&&_0x1558d7[_0x568e63(0x176)]&&_0x1558d7['environment'][_0x483a48]&&_0x1558d7[_0x568e63(0x176)][_0x483a48]['javaGitBranch']?_0x1558d7['environment'][_0x483a48][_0x568e63(0x163)]:CONSTANTS[_0x568e63(0x110)];logInfo(_0x568e63(0x139)+_0x427e90),executeCommand(_0x568e63(0x104)+_0x427e90,_0x1e918f),logSuccess(_0x568e63(0x169));const _0x5f0502=path[_0x568e63(0x101)](_0x39fccc,_0x1558d7[_0x568e63(0x106)]);logInfo(_0x568e63(0x146)),DeleteDirAllFile(_0x5f0502,()=>{const _0x1fefdc=_0x568e63;createDir(_0x5f0502),logInfo('正在复制构建产物到目标目录...'),writeFile(path[_0x1fefdc(0x101)](_0x39fccc,_0x43057c+_0x1fefdc(0x111)),_0x516074),CopyFolder(path[_0x1fefdc(0x101)](_0x2e28b8,_0x1558d7[_0x1fefdc(0x106)]),_0x5f0502,async()=>{const _0x3a0744=_0x1fefdc;logSuccess(_0x3a0744(0x114)),setTimeout(async()=>{const _0x205b92=_0x3a0744;logInfo('正在同步远程仓库...'),executeCommand(_0x205b92(0x16b),_0x1e918f),logInfo(_0x205b92(0x141)),executeCommand('git\x20add\x20.',_0x1e918f);const {commitMessage:_0x276690}=await inquirer[_0x205b92(0x118)]([{'type':_0x205b92(0x127),'name':_0x205b92(0x145),'message':_0x205b92(0x16f),'default':_0x205b92(0x15b)}]),_0xd63afc=_0x276690[_0x205b92(0x15f)]()||_0x205b92(0x15b);try{logInfo(_0x205b92(0x173)),executeCommand(_0x205b92(0x13c)+_0xd63afc+_0x205b92(0x11d),_0x1e918f),logSuccess(_0x205b92(0x128));}catch(_0x24db03){logWarning(_0x205b92(0x11b));}logInfo(_0x205b92(0x123)),executeCommand(_0x205b92(0x151),_0x1e918f),logSuccess(_0x205b92(0x120)),setTimeout(()=>{const _0x49fcb3=_0x205b92;logInfo('正在清理临时工作目录...');const _0x1fe90f=path[_0x49fcb3(0x101)](os['tmpdir'](),_0x38be31);if(fileExists(_0x1fe90f))try{deleteFolderRecursive(_0x1fe90f),logSuccess(_0x49fcb3(0x156)+_0x38be31);}catch(_0x5b5fc0){logWarning(_0x49fcb3(0x107)+_0x5b5fc0[_0x49fcb3(0x14c)]);}},CONSTANTS['SYNC_DELAY']*0x2);},CONSTANTS[_0x3a0744(0x178)]);});});}else{logError(_0x568e63(0x130));const _0x4b4b14=path[_0x568e63(0x101)](os[_0x568e63(0x133)](),_0x38be31);if(fileExists(_0x4b4b14))try{deleteFolderRecursive(_0x4b4b14),logInfo(_0x568e63(0x156)+_0x38be31);}catch(_0x12818d){logWarning(_0x568e63(0x107)+_0x12818d['message']);}process[_0x568e63(0x10c)](0x1);}}};
package/src/rm-rf.js CHANGED
@@ -1,52 +1 @@
1
- const path = require('path');
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
+ function a7_0x569d(_0x23e6bb,_0x57c9a3){const _0x45c37d=a7_0x45c3();return a7_0x569d=function(_0x569d9f,_0x3473ff){_0x569d9f=_0x569d9f-0x168;let _0x17df1d=_0x45c37d[_0x569d9f];return _0x17df1d;},a7_0x569d(_0x23e6bb,_0x57c9a3);}const a7_0x45a700=a7_0x569d;function a7_0x45c3(){const _0x3f440e=['message','7mdadJc','是否确认删除?删除后不可恢复!','1355772xiNVEZ','操作已取消','删除操作失败:\x20','4jIJVqe','resolve','1369018XIcnAV','confirm','所有文件已成功删除','2590495rMmjOh','10757120HXhOAv','2180799QtYFuY','path','开始执行删除操作...','3274893GZylfZ','删除后不可恢复,请谨慎操作','./utils','16tmTgXf','exit','prompt','1211606DyOCbI','exports'];a7_0x45c3=function(){return _0x3f440e;};return a7_0x45c3();}(function(_0x2df3bf,_0x1c8868){const _0x7357e8=a7_0x569d,_0x476192=_0x2df3bf();while(!![]){try{const _0x73479c=-parseInt(_0x7357e8(0x179))/0x1+parseInt(_0x7357e8(0x16b))/0x2+parseInt(_0x7357e8(0x170))/0x3*(parseInt(_0x7357e8(0x169))/0x4)+parseInt(_0x7357e8(0x16e))/0x5+parseInt(_0x7357e8(0x17e))/0x6*(-parseInt(_0x7357e8(0x17c))/0x7)+parseInt(_0x7357e8(0x176))/0x8*(-parseInt(_0x7357e8(0x173))/0x9)+parseInt(_0x7357e8(0x16f))/0xa;if(_0x73479c===_0x1c8868)break;else _0x476192['push'](_0x476192['shift']());}catch(_0x2f7e1e){_0x476192['push'](_0x476192['shift']());}}}(a7_0x45c3,0xcd0fb));const path=require(a7_0x45a700(0x171)),inquirer=require('inquirer'),{logInfo,logSuccess,logError,logWarning,deleteFolderRecursive}=require(a7_0x45a700(0x175));module[a7_0x45a700(0x17a)]=async function(){const _0x5a9255=a7_0x45a700,_0x5e4e83=path[_0x5a9255(0x16a)]('./');logWarning('危险操作:此命令将删除当前目录下的所有文件和文件夹'),logWarning(_0x5a9255(0x174));const {confirm:_0x29dacd}=await inquirer[_0x5a9255(0x178)]([{'type':_0x5a9255(0x16c),'name':_0x5a9255(0x16c),'message':_0x5a9255(0x17d),'default':![]}]);_0x29dacd?(logInfo('正在扫描目录结构...'),setTimeout(()=>{const _0x2b0ef0=_0x5a9255;try{logInfo(_0x2b0ef0(0x172)),deleteFolderRecursive(_0x5e4e83),logSuccess(_0x2b0ef0(0x16d)),process[_0x2b0ef0(0x177)](0x0);}catch(_0x59c6d5){logError(_0x2b0ef0(0x168)+_0x59c6d5[_0x2b0ef0(0x17b)]),process[_0x2b0ef0(0x177)](0x1);}},0x3e8)):(logInfo(_0x5a9255(0x17f)),process[_0x5a9255(0x177)](0x0));};
package/src/utils.js CHANGED
@@ -1,226 +1 @@
1
- const fs = require('fs');
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_0x5d5f15=a8_0x4429;(function(_0x46cc26,_0x20c2c2){const _0x4869f3=a8_0x4429,_0xacbaee=_0x46cc26();while(!![]){try{const _0x2cb3de=-parseInt(_0x4869f3(0x133))/0x1*(-parseInt(_0x4869f3(0x122))/0x2)+-parseInt(_0x4869f3(0x126))/0x3+parseInt(_0x4869f3(0x139))/0x4*(-parseInt(_0x4869f3(0x127))/0x5)+parseInt(_0x4869f3(0x10e))/0x6*(-parseInt(_0x4869f3(0x10b))/0x7)+parseInt(_0x4869f3(0x11d))/0x8+parseInt(_0x4869f3(0x121))/0x9*(parseInt(_0x4869f3(0x135))/0xa)+-parseInt(_0x4869f3(0x10c))/0xb*(-parseInt(_0x4869f3(0x12e))/0xc);if(_0x2cb3de===_0x20c2c2)break;else _0xacbaee['push'](_0xacbaee['shift']());}catch(_0x3e5c07){_0xacbaee['push'](_0xacbaee['shift']());}}}(a8_0x5026,0xb0404));const fs=require('fs'),path=require(a8_0x5d5f15(0x111)),child_process=require('child_process'),chalk=require(a8_0x5d5f15(0x11c)),CONSTANTS={'MAX_BUFFER_SIZE':0x3b9aca00,'SYNC_DELAY':0x3e8,'DEFAULT_BRANCH':a8_0x5d5f15(0x11b),'CONFIG_FILE_NAME':a8_0x5d5f15(0x112),'BUILD_OUTPUT_DIR':a8_0x5d5f15(0x120),'TEMPLATES_PATH':a8_0x5d5f15(0x10d)};function a8_0x5026(){const _0x342991=['join','readdir','yellow','execSync','filter','master','chalk','7778912QslLym','createWriteStream','lstatSync','dist','37431DFnubB','1204646TztbZi','existsSync','log','dirname','54810yPuYhX','5632885okuURi','error','writeFileSync','文件复制失败:\x20','environment','vite.config.ts','mkdir','3036dszPKF','unlinkSync','vite.config.mjs','rmdirSync','[工作目录:\x20','1ZYmqxa','pipe','790ljbsbV','创建目录失败:\x20','执行命令:\x20','exports','4JSxjYE','createReadStream','readdirSync','statSync','green','utf8','6579580lUviIU','39281JXTTeW','start/src/main/resources/templates','6cXCAUo','message','isDirectory','path','jjb.config.js','forEach','vite.config.js','length'];a8_0x5026=function(){return _0x342991;};return a8_0x5026();}function logInfo(_0x3f3bc1,_0x238df8=''){const _0x2a7457=a8_0x5d5f15,_0x3ef952=chalk['blue']('ℹ'),_0x17dca8=_0x238df8?_0x3ef952+'\x20'+_0x3f3bc1+'\x20'+_0x238df8:_0x3ef952+'\x20'+_0x3f3bc1;console[_0x2a7457(0x124)](_0x17dca8);}function logSuccess(_0x23ef68){const _0x4dad1c=a8_0x5d5f15;console[_0x4dad1c(0x124)](chalk[_0x4dad1c(0x109)]('✓\x20'+_0x23ef68));}function logWarning(_0x24a7f8){const _0xc91599=a8_0x5d5f15;console[_0xc91599(0x124)](chalk[_0xc91599(0x118)]('⚠\x20'+_0x24a7f8));}function logError(_0x1bb3f2){const _0x26d1bf=a8_0x5d5f15;console[_0x26d1bf(0x124)](chalk['red']('✗\x20'+_0x1bb3f2));}function executeCommand(_0x592801,_0x496e49,_0x2b502b={}){const _0x302e27=a8_0x5d5f15;return logInfo(_0x302e27(0x137)+_0x592801,_0x496e49?_0x302e27(0x132)+_0x496e49+']':''),child_process[_0x302e27(0x119)](_0x592801,{'cwd':_0x496e49,..._0x2b502b});}function deleteFolderRecursive(_0x440e96){const _0x4b1351=a8_0x5d5f15;fs[_0x4b1351(0x123)](_0x440e96)&&(fs[_0x4b1351(0x13b)](_0x440e96)[_0x4b1351(0x113)](_0x386144=>{const _0x4d876b=_0x4b1351,_0xe640c9=path[_0x4d876b(0x116)](_0x440e96,_0x386144);fs[_0x4d876b(0x11f)](_0xe640c9)[_0x4d876b(0x110)]()?deleteFolderRecursive(_0xe640c9):fs[_0x4d876b(0x12f)](_0xe640c9);}),fs[_0x4b1351(0x131)](_0x440e96));}function a8_0x4429(_0x46e3eb,_0x434574){const _0x5026c0=a8_0x5026();return a8_0x4429=function(_0x442941,_0x1967a9){_0x442941=_0x442941-0x108;let _0x324e5b=_0x5026c0[_0x442941];return _0x324e5b;},a8_0x4429(_0x46e3eb,_0x434574);}function fileExists(_0x4af3ee){const _0x38e33d=a8_0x5d5f15;return fs[_0x38e33d(0x123)](_0x4af3ee);}function readFile(_0x43a414,_0x4d5fbf=a8_0x5d5f15(0x10a)){return fs['readFileSync'](_0x43a414,_0x4d5fbf);}function writeFile(_0x44e262,_0x37077e,_0x125ab2=a8_0x5d5f15(0x10a)){const _0xa401cd=a8_0x5d5f15;fs[_0xa401cd(0x129)](_0x44e262,_0x37077e,_0x125ab2);}function createDir(_0x157a1c){const _0x4c6d5=a8_0x5d5f15;!fs[_0x4c6d5(0x123)](_0x157a1c)&&fs['mkdirSync'](_0x157a1c,{'recursive':!![]});}function isViteProject(_0x3bb374){const _0x1fa21f=a8_0x5d5f15;return fileExists(path[_0x1fa21f(0x116)](_0x3bb374,_0x1fa21f(0x114)))||fileExists(path[_0x1fa21f(0x116)](_0x3bb374,_0x1fa21f(0x12c)))||fileExists(path[_0x1fa21f(0x116)](_0x3bb374,_0x1fa21f(0x130)));}function validateConfig(_0x319c5c,_0x479d76){const _0x9e4945=a8_0x5d5f15,_0x29fc52=_0x479d76[_0x9e4945(0x11a)](_0x1057ff=>!_0x319c5c[_0x1057ff]);return{'isValid':_0x29fc52[_0x9e4945(0x115)]===0x0,'missingFields':_0x29fc52};}function validateEnvironment(_0x74590,_0x5511ff){const _0x37c251=a8_0x5d5f15;return _0x74590[_0x37c251(0x12b)]&&_0x74590[_0x37c251(0x12b)][_0x5511ff];}function DeleteDirAllFile(_0x56522a,_0x435828){const _0x39448b=a8_0x5d5f15;let _0x335ca0=[];fs[_0x39448b(0x123)](_0x56522a)?(_0x335ca0=fs[_0x39448b(0x13b)](_0x56522a),_0x335ca0[_0x39448b(0x113)](function(_0x489db1,_0x3c959a){const _0xf6d3=_0x39448b;let _0x2fbb3c=path['join'](_0x56522a,_0x489db1);fs[_0xf6d3(0x108)](_0x2fbb3c)[_0xf6d3(0x110)]()?DeleteDirAllFile(_0x2fbb3c):fs[_0xf6d3(0x12f)](_0x2fbb3c);}),fs['rmdirSync'](_0x56522a),_0x435828&&_0x435828()):_0x435828&&_0x435828();}function CopyFile(_0x2cd9f8,_0x26def6,_0x2569f5){const _0x18ecd5=a8_0x5d5f15,_0x41a589=path[_0x18ecd5(0x125)](_0x26def6);!fs[_0x18ecd5(0x123)](_0x41a589)&&fs['mkdirSync'](_0x41a589,{'recursive':!![]});const _0x4e05ff=fs['createReadStream'](_0x2cd9f8),_0x2aaf22=fs[_0x18ecd5(0x11e)](_0x26def6);_0x4e05ff[_0x18ecd5(0x134)](_0x2aaf22),_0x2aaf22['on']('close',function(){_0x2569f5&&_0x2569f5();}),_0x2aaf22['on'](_0x18ecd5(0x128),function(_0x439ae4){const _0x4dc80d=_0x18ecd5;logError(_0x4dc80d(0x12a)+_0x439ae4[_0x4dc80d(0x10f)]),_0x2569f5&&_0x2569f5();});}function CopyFolder(_0x224049,_0xd0c07c,_0x4b033f){const _0x481bfe=a8_0x5d5f15;!fs[_0x481bfe(0x123)](_0xd0c07c)&&fs['mkdirSync'](_0xd0c07c,{'recursive':!![]}),fs[_0x481bfe(0x117)](_0x224049,function(_0x120640,_0x4f552e){const _0x284d23=_0x481bfe;let _0x3e350c=0x0;const _0x526a29=function(){++_0x3e350c===_0x4f552e['length']&&_0x4b033f&&_0x4b033f();};if(_0x120640){_0x526a29();return;}_0x4f552e[_0x284d23(0x113)](function(_0x40f000){const _0x28081a=_0x284d23,_0x2511d3=path[_0x28081a(0x116)](_0x224049,_0x40f000),_0x2e4ee9=path[_0x28081a(0x116)](_0xd0c07c,_0x40f000);fs['stat'](_0x2511d3,function(_0x1bacff,_0x40058f){const _0x20bd8e=_0x28081a;if(_0x40058f[_0x20bd8e(0x110)]())fs[_0x20bd8e(0x12d)](_0x2e4ee9,{'recursive':!![]},function(_0x1a585a){const _0x59c213=_0x20bd8e;if(_0x1a585a){logError(_0x59c213(0x136)+_0x1a585a[_0x59c213(0x10f)]);return;}CopyFolder(_0x2511d3,_0x2e4ee9,_0x526a29);});else{const _0x7337da=fs[_0x20bd8e(0x13a)](_0x2511d3),_0x225be5=fs[_0x20bd8e(0x11e)](_0x2e4ee9);_0x7337da[_0x20bd8e(0x134)](_0x225be5),_0x225be5['on']('close',_0x526a29),_0x225be5['on'](_0x20bd8e(0x128),_0x526a29);}});}),_0x4f552e['length']===0x0&&_0x4b033f&&_0x4b033f();});}module[a8_0x5d5f15(0x138)]={'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
@@ -1,3 +0,0 @@
1
- {
2
- "compact": true
3
- }