jjb-cmd 2.5.8 → 2.6.0
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/package.json +1 -1
- package/src/ai-pull.js +1 -715
- package/src/auth.js +1 -71
- package/src/code-optimization.js +1 -46
- package/src/config.js +1 -122
- package/src/crypto-utils.js +1 -183
- package/src/password-input.js +1 -79
- package/src/publish.js +1 -307
- package/src/push.js +1 -417
- package/src/rm-rf.js +1 -49
- package/src/utils.js +1 -228
- package/SECURITY.md +0 -71
- package/build.js +0 -20
- package/obf.config.json +0 -3
package/src/publish.js
CHANGED
|
@@ -1,307 +1 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const os = require('os');
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const inquirer = require('inquirer');
|
|
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
|
-
const { loadAuth } = require('./crypto-utils');
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 解析组件配置信息
|
|
21
|
-
* @param {string} distContent - 构建后的文件内容
|
|
22
|
-
* @returns {Object} 解析后的配置信息
|
|
23
|
-
*/
|
|
24
|
-
function parseComponentConfig(distContent) {
|
|
25
|
-
const matches = distContent.match(/(window\[).+?(\.componentKey|.+]={)/img);
|
|
26
|
-
if (!matches || !matches.length) {
|
|
27
|
-
throw new Error('请在组件入口文件中添加"window[props.componentKey]"以暴露组件的配置信息!');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const componentConfig = {};
|
|
31
|
-
|
|
32
|
-
// 解析 info 配置
|
|
33
|
-
const infoMatches = distContent.match(/componentKey.+([{,]info:\s{0,}{)/img);
|
|
34
|
-
if (!infoMatches || !infoMatches.length) {
|
|
35
|
-
throw new Error('暴露的配置信息中缺少"info"!');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let infoStr = '{';
|
|
39
|
-
const infoStr1 = distContent.split(infoMatches[0])[1];
|
|
40
|
-
for (let i = 0; i < infoStr1.length; i++) {
|
|
41
|
-
infoStr += infoStr1[i];
|
|
42
|
-
if (infoStr1[i] === '}') {
|
|
43
|
-
try {
|
|
44
|
-
const currJson = new Function(`return ${infoStr}`)();
|
|
45
|
-
Object.assign(componentConfig, currJson);
|
|
46
|
-
componentConfig.defaultSetting = {};
|
|
47
|
-
} catch (e) {
|
|
48
|
-
// 忽略解析错误
|
|
49
|
-
}
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// 解析 settings 配置
|
|
55
|
-
const settingsMatches = distContent.match(/componentKey.+([{,]settings:\s{0,}{)/img);
|
|
56
|
-
if (!settingsMatches || !settingsMatches.length) {
|
|
57
|
-
throw new Error('暴露的配置信息中缺少"settings"!');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let settingsStr = '{';
|
|
61
|
-
const settingsStr1 = distContent.split(settingsMatches[0])[1];
|
|
62
|
-
for (let i = 0; i < settingsStr1.length; i++) {
|
|
63
|
-
settingsStr += settingsStr1[i];
|
|
64
|
-
if (settingsStr1[i] === '}') {
|
|
65
|
-
try {
|
|
66
|
-
componentConfig.defaultSetting = new Function(`return ${settingsStr}`)();
|
|
67
|
-
} catch (e) {
|
|
68
|
-
// 忽略解析错误
|
|
69
|
-
}
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return JSON.stringify(componentConfig);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 执行构建命令
|
|
79
|
-
* @param {string} rootPath - 项目根路径
|
|
80
|
-
*/
|
|
81
|
-
function executeBuild(rootPath) {
|
|
82
|
-
const yarnLockPath = path.join(rootPath, 'yarn.lock');
|
|
83
|
-
if (fileExists(yarnLockPath)) {
|
|
84
|
-
executeCommand('yarn build:production', rootPath);
|
|
85
|
-
} else {
|
|
86
|
-
executeCommand('npm run build:production', rootPath);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 验证必要的文件
|
|
92
|
-
* @param {string} rootPath - 项目根路径
|
|
93
|
-
* @returns {Object} 验证结果和文件路径
|
|
94
|
-
*/
|
|
95
|
-
function validateRequiredFiles(rootPath) {
|
|
96
|
-
const readmePath = path.join(rootPath, 'README.md');
|
|
97
|
-
const distPath = path.join(rootPath, 'dist', 'index.js');
|
|
98
|
-
const packageJsonPath = path.join(rootPath, 'package.json');
|
|
99
|
-
const thumbnailPath = path.join(rootPath, 'thumbnail.png');
|
|
100
|
-
|
|
101
|
-
if (!fileExists(packageJsonPath)) {
|
|
102
|
-
throw new Error('组件发布失败!根目录缺少\'package.json\'文件!');
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!fileExists(distPath)) {
|
|
106
|
-
throw new Error('组件发布失败!根目录缺少\'dist/index.js\'文件!');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!fileExists(readmePath)) {
|
|
110
|
-
throw new Error('请在组件根目录添加一个README.md说明文件!');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (!fileExists(thumbnailPath)) {
|
|
114
|
-
throw new Error('请在组件根目录为组件添加一个缩略图"thumbnail.png"文件!');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
readmePath,
|
|
119
|
-
distPath,
|
|
120
|
-
packageJsonPath,
|
|
121
|
-
thumbnailPath
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* 提交发布数据
|
|
127
|
-
* @param {string} message - 发布消息
|
|
128
|
-
* @param {Object} pushData - 发布数据
|
|
129
|
-
*/
|
|
130
|
-
const submitFun = function (message, pushData) {
|
|
131
|
-
pushData.message = message || 'no message';
|
|
132
|
-
axios.post(`${getApiHost()}/api/file/publish`, pushData).then(res => {
|
|
133
|
-
logSuccess(res.data.message || '组件发布成功');
|
|
134
|
-
process.exit(0);
|
|
135
|
-
}).catch(e => {
|
|
136
|
-
if (e && e.response) {
|
|
137
|
-
const status = e.response.status;
|
|
138
|
-
const serverMsg = (e.response.data && (e.response.data.message || e.response.data.msg)) || '';
|
|
139
|
-
logError(`发布失败 (${status}): ${serverMsg || e.message}`);
|
|
140
|
-
} else if (e && e.request) {
|
|
141
|
-
logError(`网络连接失败: 无法连接到服务器`);
|
|
142
|
-
} else {
|
|
143
|
-
logError(`发布失败: ${e.message || '未知错误'}`);
|
|
144
|
-
}
|
|
145
|
-
process.exit(1);
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
module.exports = version => {
|
|
150
|
-
const authPath = path.join(__dirname, '../.auth');
|
|
151
|
-
|
|
152
|
-
if (!fileExists(authPath)) {
|
|
153
|
-
logError('未检测到认证信息,请先执行登录操作');
|
|
154
|
-
process.exit(1);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// 安全读取认证信息
|
|
158
|
-
let username, password;
|
|
159
|
-
try {
|
|
160
|
-
logInfo('正在加载认证信息...');
|
|
161
|
-
const authData = loadAuth(authPath);
|
|
162
|
-
username = authData.username;
|
|
163
|
-
password = authData.password;
|
|
164
|
-
logSuccess('认证信息加载成功');
|
|
165
|
-
} catch (error) {
|
|
166
|
-
logError(`读取认证信息失败: ${error.message}`);
|
|
167
|
-
process.exit(1);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
logInfo('正在请求服务器授权...');
|
|
171
|
-
|
|
172
|
-
axios.post(`${getApiHost()}/api/auth`, {
|
|
173
|
-
username,
|
|
174
|
-
password
|
|
175
|
-
}).then(async res => {
|
|
176
|
-
if (res.data.status) {
|
|
177
|
-
logSuccess('服务器授权成功');
|
|
178
|
-
|
|
179
|
-
const rootPath = path.resolve('./');
|
|
180
|
-
|
|
181
|
-
// 执行构建
|
|
182
|
-
logInfo('正在执行项目构建...');
|
|
183
|
-
try {
|
|
184
|
-
executeBuild(rootPath);
|
|
185
|
-
logSuccess('项目构建完成');
|
|
186
|
-
} catch (error) {
|
|
187
|
-
logError(`项目构建失败: ${error.message}`);
|
|
188
|
-
process.exit(1);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// 验证必要文件
|
|
192
|
-
logInfo('正在验证发布所需文件...');
|
|
193
|
-
let filePaths;
|
|
194
|
-
try {
|
|
195
|
-
filePaths = validateRequiredFiles(rootPath);
|
|
196
|
-
logSuccess('文件验证通过');
|
|
197
|
-
} catch (error) {
|
|
198
|
-
logError(error.message);
|
|
199
|
-
process.exit(1);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// 读取包信息
|
|
203
|
-
logInfo('正在读取包信息...');
|
|
204
|
-
const packageJsonFile = JSON.parse(readFile(path.join(__dirname, '../package.json')));
|
|
205
|
-
const { version: cmdVersion } = packageJsonFile;
|
|
206
|
-
|
|
207
|
-
// 准备发布数据
|
|
208
|
-
logInfo('正在准备发布数据...');
|
|
209
|
-
const pushData = {
|
|
210
|
-
username,
|
|
211
|
-
cmd_version: cmdVersion,
|
|
212
|
-
hostname: os.hostname(),
|
|
213
|
-
platform: os.platform(),
|
|
214
|
-
package_version: version || 0,
|
|
215
|
-
package_content: readFile(filePaths.distPath),
|
|
216
|
-
readme_content: readFile(filePaths.readmePath)
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
// 解析组件配置
|
|
220
|
-
try {
|
|
221
|
-
logInfo('正在解析组件配置信息...');
|
|
222
|
-
const distContent = readFile(filePaths.distPath);
|
|
223
|
-
pushData.component_config_content = parseComponentConfig(distContent);
|
|
224
|
-
logSuccess('组件配置解析完成');
|
|
225
|
-
} catch (error) {
|
|
226
|
-
logError(error.message);
|
|
227
|
-
process.exit(1);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// 处理缩略图
|
|
231
|
-
logInfo('正在处理缩略图...');
|
|
232
|
-
const thumbnailData = readFile(filePaths.thumbnailPath, 'binary');
|
|
233
|
-
pushData.thumbnail_base64 = Buffer.from(thumbnailData, 'binary').toString('base64');
|
|
234
|
-
logSuccess('缩略图处理完成');
|
|
235
|
-
|
|
236
|
-
// 危险操作警告确认
|
|
237
|
-
logWarning('警告:您即将进行组件发布操作,此操作不可逆,请谨慎操作');
|
|
238
|
-
logWarning('发布错误可能导致线上应用产生严重生产故障,请务必确保:');
|
|
239
|
-
logWarning(' 1. 已充分测试组件各项功能');
|
|
240
|
-
logWarning(' 2. 已检查构建产物完整性');
|
|
241
|
-
logWarning(' 3. 已确认版本号和发布信息正确');
|
|
242
|
-
logWarning(' 4. 已了解发布后的影响范围');
|
|
243
|
-
logWarning(' 5. 发布成功后请立即通知相关人员进行测试和验证');
|
|
244
|
-
|
|
245
|
-
await new Promise((resolve) => {
|
|
246
|
-
let countdown = 10;
|
|
247
|
-
const interval = setInterval(() => {
|
|
248
|
-
process.stdout.write(`\r倒计时 ${countdown} 秒... `);
|
|
249
|
-
countdown--;
|
|
250
|
-
if (countdown < 0) {
|
|
251
|
-
clearInterval(interval);
|
|
252
|
-
process.stdout.write('\r\n');
|
|
253
|
-
resolve();
|
|
254
|
-
}
|
|
255
|
-
}, 1000);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
const { confirmed } = await inquirer.prompt([
|
|
259
|
-
{
|
|
260
|
-
type: 'confirm',
|
|
261
|
-
name: 'confirmed',
|
|
262
|
-
message: '我已充分了解以上可能存在的严重风险,确认继续发布操作?',
|
|
263
|
-
default: false
|
|
264
|
-
}
|
|
265
|
-
]);
|
|
266
|
-
|
|
267
|
-
if (!confirmed) {
|
|
268
|
-
logInfo('发布操作已取消');
|
|
269
|
-
process.exit(0);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// 提交发布
|
|
273
|
-
const { message } = await inquirer.prompt([
|
|
274
|
-
{
|
|
275
|
-
type: 'input',
|
|
276
|
-
name: 'message',
|
|
277
|
-
message: '请输入此次组件发布的信息:',
|
|
278
|
-
default: 'no message'
|
|
279
|
-
}
|
|
280
|
-
]);
|
|
281
|
-
|
|
282
|
-
logInfo('正在提交发布请求...');
|
|
283
|
-
submitFun(message || 'no message', pushData);
|
|
284
|
-
} else {
|
|
285
|
-
logError(`授权失败: ${res.data.message || '未知错误'}`);
|
|
286
|
-
process.exit(1);
|
|
287
|
-
}
|
|
288
|
-
}).catch(e => {
|
|
289
|
-
// 更准确的错误分类,避免误导为授权问题
|
|
290
|
-
if (e && e.response) {
|
|
291
|
-
const status = e.response.status;
|
|
292
|
-
if (status === 401 || status === 403) {
|
|
293
|
-
logError(`授权失败 (${status}): 认证信息无效或无权限`);
|
|
294
|
-
} else {
|
|
295
|
-
const serverMsg = (e.response.data && (e.response.data.message || e.response.data.msg)) || '';
|
|
296
|
-
logError(`请求失败 (${status}): ${serverMsg || e.message}`);
|
|
297
|
-
}
|
|
298
|
-
} else if (e && e.request) {
|
|
299
|
-
// 请求已发出但未收到响应,多为网络问题
|
|
300
|
-
logError(`网络连接失败: 无法连接到服务器或服务器无响应`);
|
|
301
|
-
} else {
|
|
302
|
-
// 触发请求前发生的错误
|
|
303
|
-
logError(`操作失败: ${e ? e.message : '未知错误'}`);
|
|
304
|
-
}
|
|
305
|
-
process.exit(1);
|
|
306
|
-
});
|
|
307
|
-
};
|
|
1
|
+
const a6_0xd6ef64=a6_0x48fa;(function(_0x3243c5,_0x1a9be9){const _0x588d7f=a6_0x48fa,_0x5bc8bf=_0x3243c5();while(!![]){try{const _0x21781e=parseInt(_0x588d7f(0x142))/0x1*(-parseInt(_0x588d7f(0x155))/0x2)+parseInt(_0x588d7f(0x192))/0x3*(-parseInt(_0x588d7f(0x19b))/0x4)+parseInt(_0x588d7f(0x15e))/0x5*(parseInt(_0x588d7f(0x154))/0x6)+parseInt(_0x588d7f(0x181))/0x7*(parseInt(_0x588d7f(0x17e))/0x8)+-parseInt(_0x588d7f(0x182))/0x9+parseInt(_0x588d7f(0x16c))/0xa+parseInt(_0x588d7f(0x16e))/0xb;if(_0x21781e===_0x1a9be9)break;else _0x5bc8bf['push'](_0x5bc8bf['shift']());}catch(_0x2bc42b){_0x5bc8bf['push'](_0x5bc8bf['shift']());}}}(a6_0x1ac7,0x83b4f));const path=require('path'),os=require('os'),child_process=require('child_process'),axios=require(a6_0xd6ef64(0x14b)),inquirer=require(a6_0xd6ef64(0x144)),{getApiHost}=require(a6_0xd6ef64(0x174)),{CONSTANTS,logInfo,logSuccess,logWarning,logError,executeCommand,fileExists,readFile,writeFile}=require(a6_0xd6ef64(0x16f)),{loadAuth}=require(a6_0xd6ef64(0x17d));function getGitInfo(){const _0x2eb3c1=a6_0xd6ef64;let _0x34185e=_0x2eb3c1(0x198),_0x14a338=_0x2eb3c1(0x198);try{_0x34185e=child_process['execSync']('git\x20rev-parse\x20--abbrev-ref\x20HEAD',{'cwd':process['cwd'](),'stdio':_0x2eb3c1(0x161)})['toString']()[_0x2eb3c1(0x150)]();}catch(_0x5e26d2){}try{_0x14a338=child_process[_0x2eb3c1(0x13b)]('git\x20config\x20user.name',{'cwd':process[_0x2eb3c1(0x12d)](),'stdio':_0x2eb3c1(0x161)})[_0x2eb3c1(0x176)]()[_0x2eb3c1(0x150)]();}catch(_0x49da89){}return{'branch':_0x34185e,'gitUser':_0x14a338};}function generateMetadataComment(_0x668dd5){const _0x4a20c2=a6_0xd6ef64,{branch:_0x77871f,gitUser:_0xabb62,hostname:_0x361f24,platform:_0x1836b1,publishTime:_0x20790b,version:_0x372385,cmdVersion:_0x55b3a5}=_0x668dd5;return _0x4a20c2(0x18e)+_0x77871f+_0x4a20c2(0x134)+_0x361f24+'\x20('+_0x1836b1+_0x4a20c2(0x133)+_0x20790b+_0x4a20c2(0x141)+_0xabb62+_0x4a20c2(0x12c)+_0x372385+_0x4a20c2(0x13e)+_0x55b3a5+'\x20**/\x0a';}function parseComponentConfig(_0x51a1ba){const _0x51f93d=a6_0xd6ef64,_0x406999=_0x51a1ba[_0x51f93d(0x14a)](/(window\[).+?(\.componentKey|.+]={)/img);if(!_0x406999||!_0x406999[_0x51f93d(0x13c)])throw new Error(_0x51f93d(0x147));const _0x157ae1={},_0x1ff5d9=_0x51a1ba[_0x51f93d(0x14a)](/componentKey.+([{,]info:\s{0,}{)/img);if(!_0x1ff5d9||!_0x1ff5d9['length'])throw new Error('暴露的配置信息中缺少\x22info\x22!');let _0x3dc047='{';const _0x12159d=_0x51a1ba[_0x51f93d(0x170)](_0x1ff5d9[0x0])[0x1];for(let _0x4670f3=0x0;_0x4670f3<_0x12159d[_0x51f93d(0x13c)];_0x4670f3++){_0x3dc047+=_0x12159d[_0x4670f3];if(_0x12159d[_0x4670f3]==='}'){try{const _0x35c2c2=new Function(_0x51f93d(0x124)+_0x3dc047)();Object[_0x51f93d(0x189)](_0x157ae1,_0x35c2c2),_0x157ae1['defaultSetting']={};}catch(_0x25dc15){}break;}}const _0xd1d744=_0x51a1ba[_0x51f93d(0x14a)](/componentKey.+([{,]settings:\s{0,}{)/img);if(!_0xd1d744||!_0xd1d744[_0x51f93d(0x13c)])throw new Error(_0x51f93d(0x15f));let _0x220186='{';const _0x44a40e=_0x51a1ba[_0x51f93d(0x170)](_0xd1d744[0x0])[0x1];for(let _0x3746a6=0x0;_0x3746a6<_0x44a40e['length'];_0x3746a6++){_0x220186+=_0x44a40e[_0x3746a6];if(_0x44a40e[_0x3746a6]==='}'){try{_0x157ae1[_0x51f93d(0x125)]=new Function(_0x51f93d(0x124)+_0x220186)();}catch(_0x39cb8d){}break;}}return JSON['stringify'](_0x157ae1);}function getNodeEnv(_0x55c786){const _0x4c44bc=a6_0xd6ef64;if(_0x55c786===_0x4c44bc(0x172))return'test';if(_0x55c786===_0x4c44bc(0x157))return _0x4c44bc(0x13f);return _0x4c44bc(0x162);}function executeBuild(_0x3d96bc,_0x439ecb){const _0x500dbc=a6_0xd6ef64,_0x573598=getNodeEnv(_0x439ecb);process.env.NODE_ENV=_0x573598,logInfo(_0x500dbc(0x185)+_0x573598);const _0x32ab08=path[_0x500dbc(0x186)](_0x3d96bc,'yarn.lock');fileExists(_0x32ab08)?executeCommand(_0x500dbc(0x13a)+_0x573598,_0x3d96bc):executeCommand('npm\x20run\x20build:'+_0x573598,_0x3d96bc);}function validateRequiredFiles(_0x31c097){const _0x16dfbf=a6_0xd6ef64,_0x4fdc52=path[_0x16dfbf(0x186)](_0x31c097,_0x16dfbf(0x135)),_0xc3677f=path[_0x16dfbf(0x186)](_0x31c097,'dist',_0x16dfbf(0x167)),_0x33dc75=path['join'](_0x31c097,_0x16dfbf(0x166)),_0x11b540=path[_0x16dfbf(0x186)](_0x31c097,_0x16dfbf(0x15c));if(!fileExists(_0x33dc75))throw new Error(_0x16dfbf(0x190));if(!fileExists(_0xc3677f))throw new Error(_0x16dfbf(0x177));if(!fileExists(_0x4fdc52))throw new Error(_0x16dfbf(0x158));if(!fileExists(_0x11b540))throw new Error(_0x16dfbf(0x165));return{'readmePath':_0x4fdc52,'distPath':_0xc3677f,'packageJsonPath':_0x33dc75,'thumbnailPath':_0x11b540};}function a6_0x1ac7(){const _0x36e5e7=['prompt','resolve','组件发布成功','platform','/**\x20git-branch:\x20','正在提交发布请求...','组件发布失败!根目录缺少\x27package.json\x27文件!','未检测到认证信息,请先执行登录操作','9rNmnRK','缩略图处理完成','追溯信息注入完成','gitUser','password','binary','unknown','请输入此次组件发布的信息:','parse','989724HkKmKj','return\x20','defaultSetting','thumbnail_base64','正在验证发布所需文件...','then','distPath','no\x20message','request','\x20|\x20publish-version:\x20','cwd','status','input','../.auth','):\x20','confirmed',')\x20|\x20publish-time:\x20','\x20|\x20device:\x20','README.md','component_config_content','toISOString','message','正在加载认证信息...','yarn\x20build:','execSync','length','/api/file/publish','\x20|\x20cmd-version:\x20','development','发布失败\x20(','\x20|\x20git-user:\x20','52GeRseS','发布错误可能导致线上应用产生严重生产故障,请务必确保:','inquirer','操作失败:\x20','data','请在组件入口文件中添加\x22window[props.componentKey]\x22以暴露组件的配置信息!','文件验证通过','exports','match','axios','\x20\x201.\x20已充分测试组件各项功能','我已充分了解以上可能存在的严重风险,确认继续发布操作?','读取认证信息失败:\x20','response','trim','from','username','exit','59442odqVAs','39362HgptOY','\x20\x202.\x20已检查构建产物完整性','dev','请在组件根目录添加一个README.md说明文件!','发布失败:\x20','../package.json','\x0d倒计时\x20','thumbnail.png','stdout','490lsMCva','暴露的配置信息中缺少\x22settings\x22!','confirm','pipe','production','项目构建完成','组件配置解析完成','请在组件根目录为组件添加一个缩略图\x22thumbnail.png\x22文件!','package.json','index.js','post','\x20秒...\x20\x20','catch','hostname','5548230JKwSOc','网络连接失败:\x20无法连接到服务器或服务器无响应','7564095vrzDmS','./utils','split','服务器授权成功','test','write','./config','正在请求服务器授权...','toString','组件发布失败!根目录缺少\x27dist/index.js\x27文件!','警告:您即将进行组件发布操作,此操作不可逆,请谨慎操作','\x20\x203.\x20已确认版本号和发布信息正确','正在读取包信息...','msg','正在处理缩略图...','./crypto-utils','8216wLdcUG','0.0.0','\x20\x204.\x20已了解发布后的影响范围','3171dKnOcZ','3360681bPbolC','正在注入组件追溯信息...','未知错误','NODE_ENV\x20设置为:\x20','join','正在准备发布数据...','网络连接失败:\x20无法连接到服务器','assign'];a6_0x1ac7=function(){return _0x36e5e7;};return a6_0x1ac7();}function a6_0x48fa(_0x3755be,_0x542b87){_0x3755be=_0x3755be-0x124;const _0x1ac7e3=a6_0x1ac7();let _0x48fabb=_0x1ac7e3[_0x3755be];return _0x48fabb;}const submitFun=function(_0x79c781,_0x453551){const _0x2e6cfe=a6_0xd6ef64;_0x453551[_0x2e6cfe(0x138)]=_0x79c781||_0x2e6cfe(0x12a),axios[_0x2e6cfe(0x168)](getApiHost()+_0x2e6cfe(0x13d),_0x453551)[_0x2e6cfe(0x128)](_0x24cf1c=>{const _0x4cc99c=_0x2e6cfe;logSuccess(_0x24cf1c['data'][_0x4cc99c(0x138)]||_0x4cc99c(0x18c)),process['exit'](0x0);})[_0x2e6cfe(0x16a)](_0x26fa34=>{const _0x1705da=_0x2e6cfe;if(_0x26fa34&&_0x26fa34[_0x1705da(0x14f)]){const _0x535a02=_0x26fa34['response'][_0x1705da(0x12e)],_0x1e6b01=_0x26fa34['response'][_0x1705da(0x146)]&&(_0x26fa34['response'][_0x1705da(0x146)][_0x1705da(0x138)]||_0x26fa34[_0x1705da(0x14f)][_0x1705da(0x146)][_0x1705da(0x17b)])||'';logError(_0x1705da(0x140)+_0x535a02+_0x1705da(0x131)+(_0x1e6b01||_0x26fa34[_0x1705da(0x138)]));}else _0x26fa34&&_0x26fa34['request']?logError(_0x1705da(0x188)):logError(_0x1705da(0x159)+(_0x26fa34['message']||'未知错误'));process[_0x1705da(0x153)](0x1);});};module[a6_0xd6ef64(0x149)]=_0x22aa5e=>{const _0x241a6b=a6_0xd6ef64,_0x39ac94=path[_0x241a6b(0x186)](__dirname,_0x241a6b(0x130));!fileExists(_0x39ac94)&&(logError(_0x241a6b(0x191)),process[_0x241a6b(0x153)](0x1));let _0x2eb4a4,_0x2d8eb9;try{logInfo(_0x241a6b(0x139));const _0x2092e2=loadAuth(_0x39ac94);_0x2eb4a4=_0x2092e2[_0x241a6b(0x152)],_0x2d8eb9=_0x2092e2[_0x241a6b(0x196)],logSuccess('认证信息加载成功');}catch(_0x288a74){logError(_0x241a6b(0x14e)+_0x288a74['message']),process['exit'](0x1);}logInfo(_0x241a6b(0x175)),axios['post'](getApiHost()+'/api/auth',{'username':_0x2eb4a4,'password':_0x2d8eb9})[_0x241a6b(0x128)](async _0x504f2b=>{const _0x512f21=_0x241a6b;if(_0x504f2b['data'][_0x512f21(0x12e)]){logSuccess(_0x512f21(0x171));const _0x21e783=path[_0x512f21(0x18b)]('./');logInfo('正在执行项目构建...');try{executeBuild(_0x21e783,_0x22aa5e),logSuccess(_0x512f21(0x163));}catch(_0xe2daed){logError('项目构建失败:\x20'+_0xe2daed[_0x512f21(0x138)]),process['exit'](0x1);}logInfo(_0x512f21(0x127));let _0x25831d;try{_0x25831d=validateRequiredFiles(_0x21e783),logSuccess(_0x512f21(0x148));}catch(_0x3c3622){logError(_0x3c3622['message']),process[_0x512f21(0x153)](0x1);}logInfo(_0x512f21(0x17a));const _0x5eddea=JSON[_0x512f21(0x19a)](readFile(path[_0x512f21(0x186)](__dirname,_0x512f21(0x15a)))),{version:_0x368cb3}=_0x5eddea;logInfo(_0x512f21(0x183));const _0xe851a6=getGitInfo(),_0x50b292=new Date()[_0x512f21(0x137)](),_0x56fbdf=readFile(_0x25831d[_0x512f21(0x129)]),_0xb9f81e=generateMetadataComment({'branch':_0xe851a6['branch'],'gitUser':_0xe851a6[_0x512f21(0x195)],'hostname':os[_0x512f21(0x16b)](),'platform':os[_0x512f21(0x18d)](),'publishTime':_0x50b292,'version':_0x22aa5e||_0x512f21(0x17f),'cmdVersion':_0x368cb3})+_0x56fbdf;logSuccess(_0x512f21(0x194)),logInfo(_0x512f21(0x187));const _0x1ca2bd={'username':_0x2eb4a4,'cmd_version':_0x368cb3,'hostname':os[_0x512f21(0x16b)](),'platform':os[_0x512f21(0x18d)](),'package_version':_0x22aa5e||0x0,'package_content':_0xb9f81e,'readme_content':readFile(_0x25831d['readmePath'])};try{logInfo('正在解析组件配置信息...'),_0x1ca2bd[_0x512f21(0x136)]=parseComponentConfig(_0xb9f81e),logSuccess(_0x512f21(0x164));}catch(_0x5509b6){logError(_0x5509b6['message']),process['exit'](0x1);}logInfo(_0x512f21(0x17c));const _0x5620b2=readFile(_0x25831d['thumbnailPath'],_0x512f21(0x197));_0x1ca2bd[_0x512f21(0x126)]=Buffer[_0x512f21(0x151)](_0x5620b2,_0x512f21(0x197))[_0x512f21(0x176)]('base64'),logSuccess(_0x512f21(0x193)),logWarning(_0x512f21(0x178)),logWarning(_0x512f21(0x143)),logWarning(_0x512f21(0x14c)),logWarning(_0x512f21(0x156)),logWarning(_0x512f21(0x179)),logWarning(_0x512f21(0x180)),logWarning('\x20\x205.\x20发布成功后请立即通知相关人员进行测试和验证'),await new Promise(_0x120f67=>{let _0xf2ebda=0xa;const _0x58382a=setInterval(()=>{const _0x540c61=a6_0x48fa;process[_0x540c61(0x15d)][_0x540c61(0x173)](_0x540c61(0x15b)+_0xf2ebda+_0x540c61(0x169)),_0xf2ebda--,_0xf2ebda<0x0&&(clearInterval(_0x58382a),process[_0x540c61(0x15d)][_0x540c61(0x173)]('\x0d\x0a'),_0x120f67());},0x3e8);});const {confirmed:_0x4b91e7}=await inquirer[_0x512f21(0x18a)]([{'type':_0x512f21(0x160),'name':_0x512f21(0x132),'message':_0x512f21(0x14d),'default':![]}]);!_0x4b91e7&&(logInfo('发布操作已取消'),process[_0x512f21(0x153)](0x0));const {message:_0x3b8f7f}=await inquirer[_0x512f21(0x18a)]([{'type':_0x512f21(0x12f),'name':_0x512f21(0x138),'message':_0x512f21(0x199),'default':_0x512f21(0x12a)}]);logInfo(_0x512f21(0x18f)),submitFun(_0x3b8f7f||_0x512f21(0x12a),_0x1ca2bd);}else logError('授权失败:\x20'+(_0x504f2b[_0x512f21(0x146)]['message']||_0x512f21(0x184))),process[_0x512f21(0x153)](0x1);})[_0x241a6b(0x16a)](_0x2b9352=>{const _0x5b8f54=_0x241a6b;if(_0x2b9352&&_0x2b9352[_0x5b8f54(0x14f)]){const _0x22225e=_0x2b9352['response']['status'];if(_0x22225e===0x191||_0x22225e===0x193)logError('授权失败\x20('+_0x22225e+'):\x20认证信息无效或无权限');else{const _0xa9b131=_0x2b9352[_0x5b8f54(0x14f)]['data']&&(_0x2b9352['response'][_0x5b8f54(0x146)][_0x5b8f54(0x138)]||_0x2b9352[_0x5b8f54(0x14f)]['data'][_0x5b8f54(0x17b)])||'';logError('请求失败\x20('+_0x22225e+_0x5b8f54(0x131)+(_0xa9b131||_0x2b9352[_0x5b8f54(0x138)]));}}else _0x2b9352&&_0x2b9352[_0x5b8f54(0x12b)]?logError(_0x5b8f54(0x16d)):logError(_0x5b8f54(0x145)+(_0x2b9352?_0x2b9352[_0x5b8f54(0x138)]:'未知错误'));process[_0x5b8f54(0x153)](0x1);});};
|