jjb-cmd 2.5.7 → 2.5.9

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/src/push.js CHANGED
@@ -1,417 +1 @@
1
- const os = require('os');
2
- const path = require('path');
3
- const fs = require('fs');
4
- const inquirer = require('inquirer');
5
- const {
6
- CopyFolder,
7
- DeleteDirAllFile
8
- } = require('./utils');
9
- const {
10
- GIT_TEMP_JAVA,
11
- getApiHost
12
- } = require('./config');
13
- const axios = require('axios');
14
- const {
15
- CONSTANTS,
16
- logInfo,
17
- logSuccess,
18
- logWarning,
19
- logError,
20
- executeCommand,
21
- deleteFolderRecursive,
22
- fileExists,
23
- readFile,
24
- writeFile,
25
- createDir,
26
- isViteProject,
27
- validateConfig
28
- } = require('./utils');
29
- const { loadAuth } = require('./crypto-utils');
30
-
31
- module.exports = async arguments => {
32
-
33
- // 存储当前任务的临时文件夹名称,用于进程退出时清理
34
- let currentTempDir = null;
35
-
36
- const authPath = path.join(__dirname, '../.auth');
37
-
38
- if (!fileExists(authPath)) {
39
- logError('未检测到认证信息,请先执行登录操作');
40
- process.exit(1);
41
- }
42
-
43
- // 安全读取认证信息
44
- let username, password;
45
- try {
46
- logInfo('正在加载认证信息...');
47
- const authData = loadAuth(authPath);
48
- username = authData.username;
49
- password = authData.password;
50
- logSuccess('认证信息加载成功');
51
- } catch (error) {
52
- logError(`读取认证信息失败: ${error.message}`);
53
- process.exit(1);
54
- }
55
-
56
- /**
57
- * 更多参数
58
- * @type {*|*[]}
59
- */
60
- const parameter = arguments[ 1 ]
61
- ? arguments[ 1 ].split('-')
62
- : [];
63
-
64
- /**
65
- * 当前根路径
66
- * @type {Promise<void> | Promise<string>}
67
- */
68
- const root_path = path.resolve('./');
69
-
70
- /**
71
- * package.json 路径
72
- * @type {string}
73
- */
74
- const package_json_path = path.join(root_path, 'package.json');
75
-
76
- /**
77
- * jjb配置文件路径
78
- * @type {string}
79
- */
80
- const config_json_path = path.join(root_path, CONSTANTS.CONFIG_FILE_NAME);
81
-
82
- /**
83
- * 打包输出目录
84
- * @type {string}
85
- */
86
- const build_output_dir = path.join(root_path, CONSTANTS.BUILD_OUTPUT_DIR);
87
-
88
- /**
89
- * 临时目录
90
- */
91
- const tmpdir = os.tmpdir();
92
-
93
- // 读取 package.json 并筛选打包命令
94
- logInfo('正在检查项目配置文件...');
95
- if (!fileExists(package_json_path)) {
96
- logError('未找到 package.json 文件');
97
- process.exit(1);
98
- }
99
-
100
- let packageJson;
101
- try {
102
- packageJson = JSON.parse(fs.readFileSync(package_json_path, 'utf8'));
103
- logSuccess('package.json 读取成功');
104
- } catch (error) {
105
- logError(`解析 package.json 失败: ${error.message}`);
106
- process.exit(1);
107
- }
108
-
109
- const scripts = packageJson.scripts || {};
110
-
111
- // 筛选打包相关的命令(只判断键名,包含 build、compile、打包等关键字)
112
- const buildKeywords = ['build'];
113
- const buildScripts = Object.keys(scripts).filter(key => {
114
- return buildKeywords.some(keyword =>
115
- key.toLowerCase().includes(keyword)
116
- );
117
- });
118
-
119
- if (buildScripts.length === 0) {
120
- logError('未找到打包相关的命令,请检查 package.json 中的 scripts 配置');
121
- process.exit(1);
122
- }
123
-
124
- // 使用 inquirer 让用户选择打包命令
125
- const { selectedScript } = await inquirer.prompt([
126
- {
127
- type: 'list',
128
- name: 'selectedScript',
129
- message: '请选择要执行的打包命令:',
130
- choices: buildScripts.map(script => ({
131
- name: `${script} (${scripts[script]})`,
132
- value: script
133
- }))
134
- }
135
- ]);
136
-
137
- logInfo(`已选择打包命令: ${selectedScript}`);
138
-
139
- // 读取 jjb.config.json 以获取 environment 配置
140
- logInfo('正在检查项目配置文件...');
141
- if (!fileExists(config_json_path)) {
142
- logError('未找到 jjb.config.json 文件');
143
- process.exit(1);
144
- }
145
-
146
- // 支持 ESM 和 CJS 模块导入
147
- let jjbConfig;
148
- try {
149
- // 如果 ESM 导入失败,回退到 require
150
- jjbConfig = require(config_json_path);
151
- jjbConfig = jjbConfig.__esModule ? jjbConfig.default : jjbConfig;
152
- logSuccess('jjb.config.json 读取成功');
153
- } catch (error) {
154
- logError(`解析 jjb.config.json 失败: ${error.message}`);
155
- process.exit(1);
156
- }
157
-
158
- // 验证必要的配置字段
159
- const requiredFields = ['javaGit', 'javaGitName', 'appIdentifier'];
160
- const configValidation = validateConfig(jjbConfig, requiredFields);
161
-
162
- if (!configValidation.isValid) {
163
- logError(`配置文件中缺少必要字段: ${configValidation.missingFields.join(', ')}`);
164
- process.exit(1);
165
- }
166
-
167
- // 选择 environment
168
- let selectedEnvType = null;
169
- if (jjbConfig.environment && typeof jjbConfig.environment === 'object') {
170
- const envKeys = Object.keys(jjbConfig.environment);
171
- if (envKeys.length > 0) {
172
- const { envType } = await inquirer.prompt([
173
- {
174
- type: 'list',
175
- name: 'envType',
176
- message: '请选择环境:',
177
- choices: envKeys.map(key => ({
178
- name: key,
179
- value: key
180
- }))
181
- }
182
- ]);
183
- selectedEnvType = envType;
184
- logInfo(`已选择环境: ${selectedEnvType}`);
185
- } else {
186
- logWarning('environment 配置为空,将使用默认分支');
187
- }
188
- } else {
189
- logWarning('未找到 environment 配置,将使用默认分支');
190
- }
191
-
192
- logInfo('正在请求服务器授权...');
193
- axios.post(`${getApiHost()}/api/auth`, {
194
- username,
195
- password
196
- }).then(async res => {
197
- if (res.data.status) {
198
- logSuccess('服务器授权成功');
199
-
200
- // 为每个打包任务创建唯一的临时文件夹
201
- const uniqueTempDir = `${GIT_TEMP_JAVA}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
202
- currentTempDir = uniqueTempDir; // 存储当前临时文件夹名称
203
- const tempGit = path.join(tmpdir, uniqueTempDir);
204
-
205
- logInfo('正在准备临时工作目录...');
206
- if (fileExists(tempGit)) {
207
- deleteFolderRecursive(tempGit);
208
- }
209
-
210
- createDir(tempGit);
211
- logSuccess('临时工作目录已创建');
212
-
213
- const projectDir = path.join(tempGit, jjbConfig.javaGitName);
214
-
215
- logInfo('正在克隆 Git 仓库...');
216
- if (fileExists(projectDir)) {
217
- if (parameter.includes('force')) {
218
- logInfo('检测到已存在的仓库,正在强制清理...');
219
- DeleteDirAllFile(projectDir, () => {
220
- executeCommand(`git clone ${jjbConfig.javaGit}`, tempGit);
221
- logSuccess('Git 仓库克隆完成');
222
- });
223
- } else {
224
- executeCommand(`git clone ${jjbConfig.javaGit}`, tempGit);
225
- logSuccess('Git 仓库克隆完成');
226
- }
227
- } else {
228
- executeCommand(`git clone ${jjbConfig.javaGit}`, tempGit);
229
- logSuccess('Git 仓库克隆完成');
230
- }
231
-
232
- project_sync(tempGit, jjbConfig, uniqueTempDir, selectedScript, selectedEnvType);
233
- } else {
234
- logError(`授权失败: ${res.data.message || '未知错误'}`);
235
- process.exit(1);
236
- }
237
- }).catch(e => {
238
- if (e && e.response) {
239
- const status = e.response.status;
240
- if (status === 401 || status === 403) {
241
- logError(`授权失败 (${status}): 认证信息无效或无权限`);
242
- } else {
243
- logError(`请求失败 (${status}): ${e.response.data?.message || e.message}`);
244
- }
245
- } else if (e && e.request) {
246
- logError(`网络连接失败: 无法连接到服务器`);
247
- } else {
248
- logError(`操作失败: ${e.message || '未知错误'}`);
249
- }
250
- process.exit(1);
251
- });
252
-
253
- // 进程退出时清理临时文件夹
254
- process.on('exit', () => {
255
- if (currentTempDir) {
256
- const tempDirToClean = path.join(os.tmpdir(), currentTempDir);
257
- if (fileExists(tempDirToClean)) {
258
- try {
259
- deleteFolderRecursive(tempDirToClean);
260
- } catch (e) {
261
- // 静默处理清理失败的情况
262
- }
263
- }
264
- }
265
- });
266
-
267
- // 处理未捕获的异常
268
- process.on('uncaughtException', (error) => {
269
- if (currentTempDir) {
270
- const tempDirToClean = path.join(os.tmpdir(), currentTempDir);
271
- if (fileExists(tempDirToClean)) {
272
- try {
273
- deleteFolderRecursive(tempDirToClean);
274
- } catch (e) {
275
- // 静默处理清理失败的情况
276
- }
277
- }
278
- }
279
- throw error;
280
- });
281
-
282
- /**
283
- * 应用git同步
284
- */
285
- function project_sync(tempGit, jjbConfig, uniqueTempDir, buildScript, envType) {
286
- const projectDir = path.join(tempGit, jjbConfig.javaGitName);
287
-
288
- logInfo('正在同步 Git 仓库最新代码...');
289
- executeCommand(`git pull`, projectDir);
290
- logSuccess('代码同步完成');
291
-
292
- if (!fileExists(path.join(root_path, 'node_modules'))) {
293
- logWarning('检测到未安装项目依赖');
294
- logInfo('正在安装项目依赖,请稍候...');
295
- executeCommand(`yarn`, root_path);
296
- logSuccess('项目依赖安装完成');
297
- } else {
298
- logInfo('项目依赖检查通过');
299
- }
300
-
301
- try {
302
- logInfo(`正在执行构建命令: yarn run ${buildScript}`);
303
- executeCommand(`yarn run ${buildScript}`, root_path, { maxBuffer: CONSTANTS.MAX_BUFFER_SIZE });
304
- logSuccess('项目构建完成');
305
- } catch (e) {
306
- logError(`项目构建失败: ${e.message}`);
307
- // 清理临时文件夹
308
- const tempDirToClean = path.join(os.tmpdir(), uniqueTempDir);
309
- if (fileExists(tempDirToClean)) {
310
- try {
311
- deleteFolderRecursive(tempDirToClean);
312
- logInfo(`临时工作目录已清理: ${uniqueTempDir}`);
313
- } catch (err) {
314
- logWarning(`清理临时目录失败: ${err.message}`);
315
- }
316
- }
317
- process.exit(1);
318
- }
319
-
320
- if (fileExists(build_output_dir)) {
321
- logInfo('正在处理构建产物...');
322
- const appIdentifier = jjbConfig.appIdentifier;
323
- const indexContent = readFile(path.join(build_output_dir, 'index.html'));
324
-
325
- if (parameter.includes('index')) {
326
- writeFile(path.join(build_output_dir, 'index.html'), indexContent);
327
- logInfo('已生成 index.html 文件');
328
- } else {
329
- writeFile(path.join(build_output_dir, `${appIdentifier}.html`), indexContent);
330
- logInfo(`已生成 ${appIdentifier}.html 文件`);
331
- }
332
-
333
- const tempJavaPath = path.join(projectDir, CONSTANTS.TEMPLATES_PATH);
334
-
335
- logInfo('正在创建模板目录...');
336
- createDir(tempJavaPath);
337
-
338
- // 从选择的 environment 中获取分支,如果没有则使用默认分支
339
- const javaGitBranch = (envType && jjbConfig.environment && jjbConfig.environment[envType] && jjbConfig.environment[envType].javaGitBranch)
340
- ? jjbConfig.environment[envType].javaGitBranch
341
- : CONSTANTS.DEFAULT_BRANCH;
342
-
343
- logInfo(`正在切换到目标分支: ${javaGitBranch}`);
344
- executeCommand(`git checkout ${javaGitBranch}`, projectDir);
345
- logSuccess('分支切换完成');
346
-
347
- const projectJavaPath = path.join(tempJavaPath, jjbConfig.appIdentifier);
348
-
349
- logInfo('正在清理目标目录...');
350
- DeleteDirAllFile(projectJavaPath, () => {
351
- createDir(projectJavaPath);
352
- logInfo('正在复制构建产物到目标目录...');
353
- writeFile(path.join(tempJavaPath, `${appIdentifier}.html`), indexContent);
354
-
355
- CopyFolder(path.join(build_output_dir, jjbConfig.appIdentifier), projectJavaPath, async () => {
356
- logSuccess('构建产物复制完成');
357
- setTimeout(async () => {
358
- logInfo('正在同步远程仓库...');
359
- executeCommand(`git pull`, projectDir);
360
- logInfo('正在添加文件变更...');
361
- executeCommand(`git add .`, projectDir);
362
-
363
- // 提示用户输入提交信息
364
- const { commitMessage: inputMessage } = await inquirer.prompt([
365
- {
366
- type: 'input',
367
- name: 'commitMessage',
368
- message: '请输入提交信息:',
369
- default: 'no message'
370
- }
371
- ]);
372
- const commitMessage = inputMessage.trim() || 'no message';
373
-
374
- try {
375
- logInfo('正在提交代码变更...');
376
- executeCommand(`git commit -m "${commitMessage}" --no-verify`, projectDir);
377
- logSuccess('代码提交成功');
378
- } catch (e) {
379
- logWarning(`代码提交跳过: 没有需要提交的变更`);
380
- }
381
-
382
- logInfo('正在推送代码到远程仓库...');
383
- executeCommand(`git push`, projectDir);
384
- logSuccess('代码推送完成');
385
-
386
- // 清理临时文件夹
387
- setTimeout(() => {
388
- logInfo('正在清理临时工作目录...');
389
- const tempDirToClean = path.join(os.tmpdir(), uniqueTempDir);
390
- if (fileExists(tempDirToClean)) {
391
- try {
392
- deleteFolderRecursive(tempDirToClean);
393
- logSuccess(`临时工作目录已清理: ${uniqueTempDir}`);
394
- } catch (e) {
395
- logWarning(`清理临时目录失败: ${e.message}`);
396
- }
397
- }
398
- }, CONSTANTS.SYNC_DELAY * 2); // 延迟清理,确保git操作完成
399
- }, CONSTANTS.SYNC_DELAY);
400
- });
401
- });
402
- } else {
403
- logError('构建产物目录不存在,请检查构建输出配置');
404
- // 清理临时文件夹
405
- const tempDirToClean = path.join(os.tmpdir(), uniqueTempDir);
406
- if (fileExists(tempDirToClean)) {
407
- try {
408
- deleteFolderRecursive(tempDirToClean);
409
- logInfo(`临时工作目录已清理: ${uniqueTempDir}`);
410
- } catch (e) {
411
- logWarning(`清理临时目录失败: ${e.message}`);
412
- }
413
- }
414
- process.exit(1);
415
- }
416
- }
417
- };
1
+ const a7_0x522780=a7_0x321c;function a7_0x321c(_0x29e3ad,_0x2efde6){_0x29e3ad=_0x29e3ad-0x15a;const _0x1776f7=a7_0x1776();let _0x321cc7=_0x1776f7[_0x29e3ad];return _0x321cc7;}(function(_0x596161,_0x3f01b5){const _0x426d0c=a7_0x321c,_0x31be72=_0x596161();while(!![]){try{const _0x215dc6=parseInt(_0x426d0c(0x1dd))/0x1+-parseInt(_0x426d0c(0x1cb))/0x2+parseInt(_0x426d0c(0x16c))/0x3*(-parseInt(_0x426d0c(0x1d6))/0x4)+parseInt(_0x426d0c(0x189))/0x5+-parseInt(_0x426d0c(0x180))/0x6*(-parseInt(_0x426d0c(0x15a))/0x7)+parseInt(_0x426d0c(0x1a9))/0x8*(parseInt(_0x426d0c(0x1c1))/0x9)+-parseInt(_0x426d0c(0x164))/0xa*(parseInt(_0x426d0c(0x1af))/0xb);if(_0x215dc6===_0x3f01b5)break;else _0x31be72['push'](_0x31be72['shift']());}catch(_0x39d10d){_0x31be72['push'](_0x31be72['shift']());}}}(a7_0x1776,0x9396f));const os=require('os'),path=require(a7_0x522780(0x1db)),fs=require('fs'),inquirer=require(a7_0x522780(0x1c4)),{CopyFolder,DeleteDirAllFile}=require(a7_0x522780(0x1d0)),{GIT_TEMP_JAVA,getApiHost}=require('./config'),axios=require(a7_0x522780(0x19c)),{CONSTANTS,logInfo,logSuccess,logWarning,logError,executeCommand,deleteFolderRecursive,fileExists,readFile,writeFile,createDir,isViteProject,validateConfig}=require(a7_0x522780(0x1d0)),{loadAuth}=require(a7_0x522780(0x182));function a7_0x1776(){const _0x4979d4=['4dFxxJP','data','临时工作目录已清理:\x20','username','appIdentifier','path','MAX_BUFFER_SIZE','151512dzYvAk','response','21ictERl','已生成\x20index.html\x20文件','exports','请选择要执行的打包命令:','split','代码提交跳过:\x20没有需要提交的变更','已生成\x20','SYNC_DELAY','uncaughtException','代码同步完成','792460jYGjrM','未知错误','正在创建模板目录...','scripts','未找到\x20environment\x20配置,将使用默认分支','代码提交成功','正在请求服务器授权...','status','650409PoncJt','includes','prompt','正在清理临时工作目录...','请选择环境:','正在提交代码变更...','git\x20add\x20.','selectedScript','清理临时目录失败:\x20','index','正在准备临时工作目录...','password','isValid','/api/auth','构建产物目录不存在,请检查构建输出配置','项目构建失败:\x20','授权失败\x20(','keys','npm\x20install','jjb.config.json\x20读取成功','1386402mVhOkk','正在复制构建产物到目标目录...','./crypto-utils','git\x20pull','代码推送完成','正在克隆\x20Git\x20仓库...','message','missingFields','git\x20push','1607760Zhiqac','package.json\x20读取成功','tmpdir','environment','git\x20commit\x20-m\x20\x22','force','javaGit','then','node_modules','已选择打包命令:\x20','正在清理目标目录...','join','javaGitName','index.html','request','package.json','请输入提交信息:','../.auth','配置文件中缺少必要字段:\x20','axios','no\x20message','length','DEFAULT_BRANCH','filter','exit','正在推送代码到远程仓库...','map','object','yarn.lock','正在添加文件变更...','git\x20checkout\x20','.html','248728sDrRIA','检测到已存在的仓库,正在强制清理...','list','git\x20clone\x20','未找到\x20package.json\x20文件','trim','66QhLVSO','操作失败:\x20','读取认证信息失败:\x20','npm','envType','正在同步\x20Git\x20仓库最新代码...','检测到未安装项目依赖','npm\x20run\x20','toString','正在检查项目配置文件...','),请稍候...','解析\x20jjb.config.json\x20失败:\x20','未找到打包相关的命令,请检查\x20package.json\x20中的\x20scripts\x20配置','正在同步远程仓库...','javaGitBranch','TEMPLATES_PATH','readFileSync','请求失败\x20(','342NQrXbZ','项目依赖安装完成','catch','inquirer','分支切换完成','some','已选择环境:\x20','input','post','now','2101834lETmKy','Git\x20仓库克隆完成','正在安装项目依赖\x20(','parse','解析\x20package.json\x20失败:\x20','./utils','BUILD_OUTPUT_DIR','项目构建完成','yarn','正在切换到目标分支:\x20','):\x20'];a7_0x1776=function(){return _0x4979d4;};return a7_0x1776();}module[a7_0x522780(0x15c)]=async arguments=>{const _0x47c4e0=a7_0x522780;let _0x1c480e=null;const _0x26d234=path[_0x47c4e0(0x194)](__dirname,_0x47c4e0(0x19a));!fileExists(_0x26d234)&&(logError('未检测到认证信息,请先执行登录操作'),process[_0x47c4e0(0x1a1)](0x1));let _0x286801,_0x441a2e;try{logInfo('正在加载认证信息...');const _0x52ece0=loadAuth(_0x26d234);_0x286801=_0x52ece0[_0x47c4e0(0x1d9)],_0x441a2e=_0x52ece0[_0x47c4e0(0x177)],logSuccess('认证信息加载成功');}catch(_0xeaa7ca){logError(_0x47c4e0(0x1b1)+_0xeaa7ca[_0x47c4e0(0x186)]),process[_0x47c4e0(0x1a1)](0x1);}const _0x1184b8=arguments[0x1]?arguments[0x1][_0x47c4e0(0x15e)]('-'):[],_0x2d9012=path['resolve']('./'),_0x3f26f9=path[_0x47c4e0(0x194)](_0x2d9012,_0x47c4e0(0x198)),_0x21772c=path[_0x47c4e0(0x194)](_0x2d9012,CONSTANTS['CONFIG_FILE_NAME']),_0x421a2b=path[_0x47c4e0(0x194)](_0x2d9012,CONSTANTS[_0x47c4e0(0x1d1)]),_0x3fcdf9=os[_0x47c4e0(0x18b)](),_0x2de06a=fileExists(path[_0x47c4e0(0x194)](_0x2d9012,_0x47c4e0(0x1a5)))?_0x47c4e0(0x1d3):_0x47c4e0(0x1b2),_0x58ff7b=_0x2de06a===_0x47c4e0(0x1d3)?_0x47c4e0(0x1d3):_0x47c4e0(0x17e),_0x3c7ae8=_0xb3d4e6=>_0x2de06a===_0x47c4e0(0x1d3)?'yarn\x20run\x20'+_0xb3d4e6:_0x47c4e0(0x1b6)+_0xb3d4e6;logInfo(_0x47c4e0(0x1b8));!fileExists(_0x3f26f9)&&(logError(_0x47c4e0(0x1ad)),process[_0x47c4e0(0x1a1)](0x1));let _0x413e50;try{_0x413e50=JSON[_0x47c4e0(0x1ce)](fs[_0x47c4e0(0x1bf)](_0x3f26f9,'utf8')),logSuccess(_0x47c4e0(0x18a));}catch(_0x93f36a){logError(_0x47c4e0(0x1cf)+_0x93f36a[_0x47c4e0(0x186)]),process[_0x47c4e0(0x1a1)](0x1);}const _0xf57365=_0x413e50[_0x47c4e0(0x167)]||{},_0x575c18=['build'],_0x203053=Object[_0x47c4e0(0x17d)](_0xf57365)[_0x47c4e0(0x1a0)](_0x30e52c=>{const _0x2e3868=_0x47c4e0;return _0x575c18[_0x2e3868(0x1c6)](_0x227149=>_0x30e52c['toLowerCase']()[_0x2e3868(0x16d)](_0x227149));});_0x203053[_0x47c4e0(0x19e)]===0x0&&(logError(_0x47c4e0(0x1bb)),process[_0x47c4e0(0x1a1)](0x1));const {selectedScript:_0x528fdd}=await inquirer[_0x47c4e0(0x16e)]([{'type':_0x47c4e0(0x1ab),'name':_0x47c4e0(0x173),'message':_0x47c4e0(0x15d),'choices':_0x203053[_0x47c4e0(0x1a3)](_0x2f7b16=>({'name':_0x2f7b16+'\x20('+_0xf57365[_0x2f7b16]+')','value':_0x2f7b16}))}]);logInfo(_0x47c4e0(0x192)+_0x528fdd),logInfo(_0x47c4e0(0x1b8));!fileExists(_0x21772c)&&(logError('未找到\x20jjb.config.json\x20文件'),process[_0x47c4e0(0x1a1)](0x1));let _0x24bee9;try{_0x24bee9=require(_0x21772c),_0x24bee9=_0x24bee9['__esModule']?_0x24bee9['default']:_0x24bee9,logSuccess(_0x47c4e0(0x17f));}catch(_0xdb7ec5){logError(_0x47c4e0(0x1ba)+_0xdb7ec5[_0x47c4e0(0x186)]),process[_0x47c4e0(0x1a1)](0x1);}const _0x180eed=[_0x47c4e0(0x18f),_0x47c4e0(0x195),_0x47c4e0(0x1da)],_0x5168a8=validateConfig(_0x24bee9,_0x180eed);!_0x5168a8[_0x47c4e0(0x178)]&&(logError(_0x47c4e0(0x19b)+_0x5168a8[_0x47c4e0(0x187)]['join'](',\x20')),process['exit'](0x1));let _0x33e671=null;if(_0x24bee9[_0x47c4e0(0x18c)]&&typeof _0x24bee9[_0x47c4e0(0x18c)]===_0x47c4e0(0x1a4)){const _0x1ea4ef=Object[_0x47c4e0(0x17d)](_0x24bee9[_0x47c4e0(0x18c)]);if(_0x1ea4ef[_0x47c4e0(0x19e)]>0x0){const {envType:_0x5af6e8}=await inquirer[_0x47c4e0(0x16e)]([{'type':_0x47c4e0(0x1ab),'name':_0x47c4e0(0x1b3),'message':_0x47c4e0(0x170),'choices':_0x1ea4ef['map'](_0x5a1f28=>({'name':_0x5a1f28,'value':_0x5a1f28}))}]);_0x33e671=_0x5af6e8,logInfo(_0x47c4e0(0x1c7)+_0x33e671);}else logWarning('environment\x20配置为空,将使用默认分支');}else logWarning(_0x47c4e0(0x168));logInfo(_0x47c4e0(0x16a)),axios[_0x47c4e0(0x1c9)](getApiHost()+_0x47c4e0(0x179),{'username':_0x286801,'password':_0x441a2e})[_0x47c4e0(0x190)](async _0x11a2e1=>{const _0x52dda5=_0x47c4e0;if(_0x11a2e1[_0x52dda5(0x1d7)][_0x52dda5(0x16b)]){logSuccess('服务器授权成功');const _0x5c5cb0=GIT_TEMP_JAVA+'-'+Date[_0x52dda5(0x1ca)]()+'-'+Math['random']()[_0x52dda5(0x1b7)](0x24)['substr'](0x2,0x9);_0x1c480e=_0x5c5cb0;const _0x1968e0=path[_0x52dda5(0x194)](_0x3fcdf9,_0x5c5cb0);logInfo(_0x52dda5(0x176));fileExists(_0x1968e0)&&deleteFolderRecursive(_0x1968e0);createDir(_0x1968e0),logSuccess('临时工作目录已创建');const _0x1ca735=path['join'](_0x1968e0,_0x24bee9[_0x52dda5(0x195)]);logInfo(_0x52dda5(0x185)),fileExists(_0x1ca735)?_0x1184b8[_0x52dda5(0x16d)](_0x52dda5(0x18e))?(logInfo(_0x52dda5(0x1aa)),DeleteDirAllFile(_0x1ca735,()=>{const _0x14760f=_0x52dda5;executeCommand(_0x14760f(0x1ac)+_0x24bee9[_0x14760f(0x18f)],_0x1968e0),logSuccess('Git\x20仓库克隆完成');})):(executeCommand(_0x52dda5(0x1ac)+_0x24bee9[_0x52dda5(0x18f)],_0x1968e0),logSuccess(_0x52dda5(0x1cc))):(executeCommand(_0x52dda5(0x1ac)+_0x24bee9[_0x52dda5(0x18f)],_0x1968e0),logSuccess(_0x52dda5(0x1cc))),_0x181d73(_0x1968e0,_0x24bee9,_0x5c5cb0,_0x528fdd,_0x33e671);}else logError('授权失败:\x20'+(_0x11a2e1[_0x52dda5(0x1d7)]['message']||_0x52dda5(0x165))),process[_0x52dda5(0x1a1)](0x1);})[_0x47c4e0(0x1c3)](_0x128467=>{const _0x4336c8=_0x47c4e0;if(_0x128467&&_0x128467['response']){const _0x279621=_0x128467[_0x4336c8(0x1de)][_0x4336c8(0x16b)];_0x279621===0x191||_0x279621===0x193?logError(_0x4336c8(0x17c)+_0x279621+'):\x20认证信息无效或无权限'):logError(_0x4336c8(0x1c0)+_0x279621+_0x4336c8(0x1d5)+(_0x128467['response'][_0x4336c8(0x1d7)]?.[_0x4336c8(0x186)]||_0x128467[_0x4336c8(0x186)]));}else _0x128467&&_0x128467[_0x4336c8(0x197)]?logError('网络连接失败:\x20无法连接到服务器'):logError(_0x4336c8(0x1b0)+(_0x128467[_0x4336c8(0x186)]||_0x4336c8(0x165)));process['exit'](0x1);}),process['on']('exit',()=>{const _0x523070=_0x47c4e0;if(_0x1c480e){const _0x113bb8=path[_0x523070(0x194)](os['tmpdir'](),_0x1c480e);if(fileExists(_0x113bb8))try{deleteFolderRecursive(_0x113bb8);}catch(_0x449d19){}}}),process['on'](_0x47c4e0(0x162),_0x430b17=>{const _0x1f21b5=_0x47c4e0;if(_0x1c480e){const _0x22dc2c=path[_0x1f21b5(0x194)](os[_0x1f21b5(0x18b)](),_0x1c480e);if(fileExists(_0x22dc2c))try{deleteFolderRecursive(_0x22dc2c);}catch(_0x16e4a3){}}throw _0x430b17;});function _0x181d73(_0x844f72,_0x28cd98,_0x474dfd,_0x4dd761,_0x4f01c1){const _0x14e9e1=_0x47c4e0,_0x4cb580=path[_0x14e9e1(0x194)](_0x844f72,_0x28cd98['javaGitName']);logInfo(_0x14e9e1(0x1b4)),executeCommand(_0x14e9e1(0x183),_0x4cb580),logSuccess(_0x14e9e1(0x163));!fileExists(path['join'](_0x2d9012,_0x14e9e1(0x191)))?(logWarning(_0x14e9e1(0x1b5)),logInfo(_0x14e9e1(0x1cd)+_0x2de06a+_0x14e9e1(0x1b9)),executeCommand(_0x58ff7b,_0x2d9012),logSuccess(_0x14e9e1(0x1c2))):logInfo('项目依赖检查通过');try{logInfo('正在执行构建命令:\x20'+_0x3c7ae8(_0x4dd761)),executeCommand(_0x3c7ae8(_0x4dd761),_0x2d9012,{'maxBuffer':CONSTANTS[_0x14e9e1(0x1dc)]}),logSuccess(_0x14e9e1(0x1d2));}catch(_0x823862){logError(_0x14e9e1(0x17b)+_0x823862['message']);const _0x17123e=path[_0x14e9e1(0x194)](os[_0x14e9e1(0x18b)](),_0x474dfd);if(fileExists(_0x17123e))try{deleteFolderRecursive(_0x17123e),logInfo(_0x14e9e1(0x1d8)+_0x474dfd);}catch(_0x3c5c80){logWarning(_0x14e9e1(0x174)+_0x3c5c80[_0x14e9e1(0x186)]);}process[_0x14e9e1(0x1a1)](0x1);}if(fileExists(_0x421a2b)){logInfo('正在处理构建产物...');const _0x25dd0c=_0x28cd98[_0x14e9e1(0x1da)],_0x2e75dc=readFile(path[_0x14e9e1(0x194)](_0x421a2b,_0x14e9e1(0x196)));_0x1184b8[_0x14e9e1(0x16d)](_0x14e9e1(0x175))?(writeFile(path[_0x14e9e1(0x194)](_0x421a2b,_0x14e9e1(0x196)),_0x2e75dc),logInfo(_0x14e9e1(0x15b))):(writeFile(path['join'](_0x421a2b,_0x25dd0c+_0x14e9e1(0x1a8)),_0x2e75dc),logInfo(_0x14e9e1(0x160)+_0x25dd0c+'.html\x20文件'));const _0x37c5cd=path[_0x14e9e1(0x194)](_0x4cb580,CONSTANTS[_0x14e9e1(0x1be)]);logInfo(_0x14e9e1(0x166)),createDir(_0x37c5cd);const _0x1a244a=_0x4f01c1&&_0x28cd98[_0x14e9e1(0x18c)]&&_0x28cd98[_0x14e9e1(0x18c)][_0x4f01c1]&&_0x28cd98[_0x14e9e1(0x18c)][_0x4f01c1][_0x14e9e1(0x1bd)]?_0x28cd98[_0x14e9e1(0x18c)][_0x4f01c1][_0x14e9e1(0x1bd)]:CONSTANTS[_0x14e9e1(0x19f)];logInfo(_0x14e9e1(0x1d4)+_0x1a244a),executeCommand(_0x14e9e1(0x1a7)+_0x1a244a,_0x4cb580),logSuccess(_0x14e9e1(0x1c5));const _0x27c4a5=path[_0x14e9e1(0x194)](_0x37c5cd,_0x28cd98[_0x14e9e1(0x1da)]);logInfo(_0x14e9e1(0x193)),DeleteDirAllFile(_0x27c4a5,()=>{const _0x1dee76=_0x14e9e1;createDir(_0x27c4a5),logInfo(_0x1dee76(0x181)),writeFile(path['join'](_0x37c5cd,_0x25dd0c+_0x1dee76(0x1a8)),_0x2e75dc),CopyFolder(path[_0x1dee76(0x194)](_0x421a2b,_0x28cd98['appIdentifier']),_0x27c4a5,async()=>{logSuccess('构建产物复制完成'),setTimeout(async()=>{const _0x17bbac=a7_0x321c;logInfo(_0x17bbac(0x1bc)),executeCommand(_0x17bbac(0x183),_0x4cb580),logInfo(_0x17bbac(0x1a6)),executeCommand(_0x17bbac(0x172),_0x4cb580);const {commitMessage:_0x5ece9d}=await inquirer[_0x17bbac(0x16e)]([{'type':_0x17bbac(0x1c8),'name':'commitMessage','message':_0x17bbac(0x199),'default':_0x17bbac(0x19d)}]),_0x5cc93d=_0x5ece9d[_0x17bbac(0x1ae)]()||_0x17bbac(0x19d);try{logInfo(_0x17bbac(0x171)),executeCommand(_0x17bbac(0x18d)+_0x5cc93d+'\x22\x20--no-verify',_0x4cb580),logSuccess(_0x17bbac(0x169));}catch(_0x5f15ba){logWarning(_0x17bbac(0x15f));}logInfo(_0x17bbac(0x1a2)),executeCommand(_0x17bbac(0x188),_0x4cb580),logSuccess(_0x17bbac(0x184)),setTimeout(()=>{const _0x2c9cb2=_0x17bbac;logInfo(_0x2c9cb2(0x16f));const _0x4d2a47=path[_0x2c9cb2(0x194)](os['tmpdir'](),_0x474dfd);if(fileExists(_0x4d2a47))try{deleteFolderRecursive(_0x4d2a47),logSuccess(_0x2c9cb2(0x1d8)+_0x474dfd);}catch(_0x925b88){logWarning(_0x2c9cb2(0x174)+_0x925b88[_0x2c9cb2(0x186)]);}},CONSTANTS[_0x17bbac(0x161)]*0x2);},CONSTANTS['SYNC_DELAY']);});});}else{logError(_0x14e9e1(0x17a));const _0x595c60=path[_0x14e9e1(0x194)](os['tmpdir'](),_0x474dfd);if(fileExists(_0x595c60))try{deleteFolderRecursive(_0x595c60),logInfo(_0x14e9e1(0x1d8)+_0x474dfd);}catch(_0x21c601){logWarning(_0x14e9e1(0x174)+_0x21c601[_0x14e9e1(0x186)]);}process['exit'](0x1);}}};
package/src/rm-rf.js CHANGED
@@ -1,49 +1 @@
1
- const path = require('path');
2
- const inquirer = require('inquirer');
3
- const {
4
- logInfo,
5
- logSuccess,
6
- logError,
7
- logWarning,
8
- deleteFolderRecursive
9
- } = require('./utils');
10
-
11
- /**
12
- * 递归删除目录模块
13
- * 危险操作:删除当前目录下的所有文件和文件夹
14
- */
15
- module.exports = async function () {
16
- const rootPath = path.resolve('./');
17
-
18
- logWarning('危险操作:此命令将删除当前目录下的所有文件和文件夹');
19
- logWarning('删除后不可恢复,请谨慎操作');
20
-
21
- const { confirm } = await inquirer.prompt([
22
- {
23
- type: 'confirm',
24
- name: 'confirm',
25
- message: '是否确认删除?删除后不可恢复!',
26
- default: false
27
- }
28
- ]);
29
-
30
- if (confirm) {
31
- logInfo('正在扫描目录结构...');
32
-
33
- setTimeout(() => {
34
- try {
35
- logInfo('开始执行删除操作...');
36
- deleteFolderRecursive(rootPath);
37
- logSuccess('所有文件已成功删除');
38
- process.exit(0);
39
- } catch (error) {
40
- logError(`删除操作失败: ${error.message}`);
41
- process.exit(1);
42
- }
43
- }, 1000);
44
- } else {
45
- logInfo('操作已取消');
46
- process.exit(0);
47
- }
48
- };
49
-
1
+ const a8_0xc34111=a8_0x4366;(function(_0x163153,_0x7936f7){const _0x443b6f=a8_0x4366,_0x2c130e=_0x163153();while(!![]){try{const _0x4b71d0=parseInt(_0x443b6f(0x1d3))/0x1*(parseInt(_0x443b6f(0x1cb))/0x2)+parseInt(_0x443b6f(0x1de))/0x3+parseInt(_0x443b6f(0x1dc))/0x4*(-parseInt(_0x443b6f(0x1da))/0x5)+-parseInt(_0x443b6f(0x1d0))/0x6+-parseInt(_0x443b6f(0x1db))/0x7*(parseInt(_0x443b6f(0x1cf))/0x8)+parseInt(_0x443b6f(0x1dd))/0x9+-parseInt(_0x443b6f(0x1cd))/0xa*(-parseInt(_0x443b6f(0x1d5))/0xb);if(_0x4b71d0===_0x7936f7)break;else _0x2c130e['push'](_0x2c130e['shift']());}catch(_0x3f2565){_0x2c130e['push'](_0x2c130e['shift']());}}}(a8_0x3a66,0x3e2cc));const path=require('path'),inquirer=require(a8_0xc34111(0x1d2)),{logInfo,logSuccess,logError,logWarning,deleteFolderRecursive}=require('./utils');module['exports']=async function(){const _0xb9e6=a8_0xc34111,_0x42c1bf=path[_0xb9e6(0x1d1)]('./');logWarning(_0xb9e6(0x1cc)),logWarning(_0xb9e6(0x1d6));const {confirm:_0x419370}=await inquirer['prompt']([{'type':_0xb9e6(0x1d4),'name':_0xb9e6(0x1d4),'message':_0xb9e6(0x1ca),'default':![]}]);_0x419370?(logInfo('正在扫描目录结构...'),setTimeout(()=>{const _0x2dca32=_0xb9e6;try{logInfo('开始执行删除操作...'),deleteFolderRecursive(_0x42c1bf),logSuccess(_0x2dca32(0x1d8)),process[_0x2dca32(0x1d9)](0x0);}catch(_0x119994){logError(_0x2dca32(0x1ce)+_0x119994['message']),process[_0x2dca32(0x1d9)](0x1);}},0x3e8)):(logInfo(_0xb9e6(0x1d7)),process['exit'](0x0));};function a8_0x4366(_0x437271,_0x1c6079){_0x437271=_0x437271-0x1ca;const _0x3a660a=a8_0x3a66();let _0x4366fb=_0x3a660a[_0x437271];return _0x4366fb;}function a8_0x3a66(){const _0x1b73e6=['resolve','inquirer','18329qQVAkO','confirm','385lnKizK','删除后不可恢复,请谨慎操作','操作已取消','所有文件已成功删除','exit','921470QKKTcz','14NLFfJD','8RgxwER','4204782cYGlgL','836952lbtpXa','是否确认删除?删除后不可恢复!','10BsciVa','危险操作:此命令将删除当前目录下的所有文件和文件夹','5290hSFddF','删除操作失败:\x20','479344etuUPi','679500UDhmtk'];a8_0x3a66=function(){return _0x1b73e6;};return a8_0x3a66();}