@plasosdk/plaso-electron-sdk 1.2.16 → 1.2.17-dev
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/scripts/downloadPrebuild.js +1 -1
- package/publish.js +0 -312
package/package.json
CHANGED
|
@@ -56,7 +56,7 @@ const electron_sdk_plugins_dir = 'https://wwwr.plaso.cn/static/cdn/electron-sdk-
|
|
|
56
56
|
const getPluginsZipName = () => {
|
|
57
57
|
let flameshotZipName = 'flameshot_win.zip';
|
|
58
58
|
let lameZipName = 'lame_win.zip';
|
|
59
|
-
const plasoALDZipName = '
|
|
59
|
+
const plasoALDZipName = 'PlasoALD_2.0.zip';
|
|
60
60
|
if (platform === PLATFORM_TYPE.DARWIN) {
|
|
61
61
|
lameZipName = 'lame_mac_x64.zip';
|
|
62
62
|
if (arch.includes('arm')) {
|
package/publish.js
DELETED
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Plaso SDK 发布脚本
|
|
5
|
-
*
|
|
6
|
-
* 功能:
|
|
7
|
-
* - 自动升级版本号(major/minor/patch)
|
|
8
|
-
* - 检查登录状态
|
|
9
|
-
* - 发布包
|
|
10
|
-
*
|
|
11
|
-
* 使用方法:
|
|
12
|
-
* - 基本用法: npm run release
|
|
13
|
-
* (无参数时会进入交互模式,询问是否跳过版本升级)
|
|
14
|
-
* - 跳过版本升级(推荐): npm run release-skip
|
|
15
|
-
* - 跳过版本升级(手动传参): npm run release -- --skip-version-upgrade
|
|
16
|
-
* - 跳过版本升级(简写): npm run release -- -s
|
|
17
|
-
*
|
|
18
|
-
* 注意:
|
|
19
|
-
* - 使用跳过版本选项时,会检查当前版本是否已发布,如已发布会提示确认
|
|
20
|
-
* - 如果您手动修改了版本号,建议使用跳过版本升级选项
|
|
21
|
-
* - 此脚本假设您已经手动设置了正确的npm源,不会自动切换源
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
const { execSync } = require('child_process');
|
|
25
|
-
const readline = require('readline');
|
|
26
|
-
const fs = require('fs');
|
|
27
|
-
const path = require('path');
|
|
28
|
-
|
|
29
|
-
// 创建readline接口
|
|
30
|
-
const rl = readline.createInterface({
|
|
31
|
-
input: process.stdin,
|
|
32
|
-
output: process.stdout
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// 添加跨平台休眠函数
|
|
36
|
-
function sleep(seconds) {
|
|
37
|
-
// 根据操作系统选择合适的休眠方法
|
|
38
|
-
const isWindows = process.platform === 'win32';
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
if (isWindows) {
|
|
42
|
-
// Windows 使用 timeout 命令
|
|
43
|
-
execSync(`timeout /t ${seconds}`, { stdio: 'ignore' });
|
|
44
|
-
} else {
|
|
45
|
-
// Unix 系统使用 sleep 命令
|
|
46
|
-
execSync(`sleep ${seconds}`, { stdio: 'ignore' });
|
|
47
|
-
}
|
|
48
|
-
} catch (error) {
|
|
49
|
-
// 如果命令执行失败,使用JavaScript的setTimeout作为备选
|
|
50
|
-
console.log(`系统休眠命令失败,使用JavaScript休眠 ${seconds} 秒`);
|
|
51
|
-
const start = Date.now();
|
|
52
|
-
while (Date.now() - start < seconds * 1000) {
|
|
53
|
-
// 空循环等待
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 执行命令的函数
|
|
59
|
-
function executeCommand(command) {
|
|
60
|
-
try {
|
|
61
|
-
execSync(command, { stdio: 'inherit' });
|
|
62
|
-
return true;
|
|
63
|
-
} catch (error) {
|
|
64
|
-
// 检查是否是版本已存在的错误
|
|
65
|
-
if (error.message.includes('You cannot publish over the previously published versions')) {
|
|
66
|
-
console.log('\n该版本已经发布过了,无需重复发布');
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
console.error(`执行命令失败: ${command}`);
|
|
70
|
-
console.error(error.message);
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// 检查npm登录状态
|
|
76
|
-
function checkNpmLoginStatus() {
|
|
77
|
-
try {
|
|
78
|
-
// 直接使用npm命令而不是npx
|
|
79
|
-
const output = execSync('npm whoami', { encoding: 'utf8' });
|
|
80
|
-
const username = output.trim();
|
|
81
|
-
if (username.length > 0) {
|
|
82
|
-
console.log(`当前登录用户: ${username}`);
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.log('npm登录状态检查失败,您可能尚未登录');
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// 确保npm登录
|
|
93
|
-
async function ensureNpmLogin() {
|
|
94
|
-
console.log('\n检查npm登录状态...');
|
|
95
|
-
|
|
96
|
-
// 检查登录状态
|
|
97
|
-
const isLoggedIn = checkNpmLoginStatus();
|
|
98
|
-
if (!isLoggedIn) {
|
|
99
|
-
console.log('未登录,开始登录流程...');
|
|
100
|
-
|
|
101
|
-
// 登录命令
|
|
102
|
-
const loginCmd = 'npm login';
|
|
103
|
-
if (!executeCommand(loginCmd)) {
|
|
104
|
-
throw new Error('npm登录失败');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// 再次检查登录状态
|
|
108
|
-
if (!checkNpmLoginStatus()) {
|
|
109
|
-
throw new Error('登录失败,请重试');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
console.log('登录成功!');
|
|
113
|
-
return true;
|
|
114
|
-
} else {
|
|
115
|
-
console.log('已经登录,跳过登录步骤');
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// 提示用户输入
|
|
121
|
-
function prompt(question) {
|
|
122
|
-
return new Promise((resolve) => {
|
|
123
|
-
rl.question(question, (answer) => {
|
|
124
|
-
resolve(answer);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// 读取package.json文件
|
|
130
|
-
function readPackageJson() {
|
|
131
|
-
const packagePath = path.join(process.cwd(), 'package.json');
|
|
132
|
-
const packageContent = fs.readFileSync(packagePath, 'utf8');
|
|
133
|
-
return JSON.parse(packageContent);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// 写入package.json文件
|
|
137
|
-
function writePackageJson(packageJson) {
|
|
138
|
-
const packagePath = path.join(process.cwd(), 'package.json');
|
|
139
|
-
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// 升级版本号
|
|
143
|
-
function upgradeVersion(currentVersion, type) {
|
|
144
|
-
const [major, minor, patch] = currentVersion.split('.').map(Number);
|
|
145
|
-
|
|
146
|
-
switch (type) {
|
|
147
|
-
case 'major':
|
|
148
|
-
return `${major + 1}.0.0`;
|
|
149
|
-
case 'minor':
|
|
150
|
-
return `${major}.${minor + 1}.0`;
|
|
151
|
-
case 'patch':
|
|
152
|
-
default:
|
|
153
|
-
return `${major}.${minor}.${patch + 1}`;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// 检查版本是否已发布
|
|
158
|
-
async function checkVersionExists(packageName, version) {
|
|
159
|
-
try {
|
|
160
|
-
console.log(`检查版本 ${packageName}@${version} 是否已发布...`);
|
|
161
|
-
const cmd = `npx npm view ${packageName}@${version} version --json`;
|
|
162
|
-
|
|
163
|
-
try {
|
|
164
|
-
execSync(cmd, { stdio: 'ignore' });
|
|
165
|
-
console.log(`版本 ${version} 已存在于npm仓库`);
|
|
166
|
-
return true;
|
|
167
|
-
} catch (e) {
|
|
168
|
-
// 如果命令执行失败,通常意味着版本不存在
|
|
169
|
-
console.log(`版本 ${version} 不存在于npm仓库,可以发布`);
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
} catch (error) {
|
|
173
|
-
console.error('检查版本失败:', error.message);
|
|
174
|
-
// 发生错误时,默认允许继续(让npm publish时再判断)
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// 解析命令行参数
|
|
180
|
-
function parseArgs() {
|
|
181
|
-
const args = process.argv.slice(2);
|
|
182
|
-
const options = {
|
|
183
|
-
skipVersionUpgrade: false,
|
|
184
|
-
interactive: args.length === 0 // 如果没有传入参数,则启用交互模式
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
for (let i = 0; i < args.length; i++) {
|
|
188
|
-
const arg = args[i];
|
|
189
|
-
if (arg === '--skip-version-upgrade' || arg === '-s') {
|
|
190
|
-
options.skipVersionUpgrade = true;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return options;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
async function main() {
|
|
198
|
-
// 解析命令行参数
|
|
199
|
-
const options = parseArgs();
|
|
200
|
-
|
|
201
|
-
try {
|
|
202
|
-
console.log('开始发布SDK...');
|
|
203
|
-
|
|
204
|
-
// 交互模式:如果没有传入命令行参数,则询问是否要跳过版本升级
|
|
205
|
-
if (options.interactive) {
|
|
206
|
-
const skipVersionAnswer = await prompt('是否跳过版本升级? (y/n): ');
|
|
207
|
-
if (skipVersionAnswer.toLowerCase() === 'y') {
|
|
208
|
-
options.skipVersionUpgrade = true;
|
|
209
|
-
console.log('已选择跳过版本升级');
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// 0. 升级版本号
|
|
214
|
-
console.log('\n0. 升级版本号...');
|
|
215
|
-
const packageJson = readPackageJson();
|
|
216
|
-
const currentVersion = packageJson.version;
|
|
217
|
-
let newVersion;
|
|
218
|
-
|
|
219
|
-
// 如果命令行参数指定跳过版本升级
|
|
220
|
-
if (options.skipVersionUpgrade) {
|
|
221
|
-
console.log('检测到--skip-version-upgrade参数,跳过版本升级');
|
|
222
|
-
newVersion = currentVersion;
|
|
223
|
-
} else {
|
|
224
|
-
console.log(`当前版本: ${currentVersion}`);
|
|
225
|
-
console.log('请选择版本升级类型:');
|
|
226
|
-
console.log('1. major - 主版本号升级 (不兼容的API变更)');
|
|
227
|
-
console.log('2. minor - 次版本号升级 (向后兼容的功能性新增)');
|
|
228
|
-
console.log('3. patch - 修订号升级 (向后兼容的问题修正)');
|
|
229
|
-
console.log('4. skip - 跳过版本升级,保持当前版本');
|
|
230
|
-
|
|
231
|
-
const versionType = await prompt('请输入选项 (1/2/3/4,默认为3): ');
|
|
232
|
-
let type;
|
|
233
|
-
|
|
234
|
-
switch (versionType.trim()) {
|
|
235
|
-
case '1':
|
|
236
|
-
type = 'major';
|
|
237
|
-
newVersion = upgradeVersion(currentVersion, type);
|
|
238
|
-
break;
|
|
239
|
-
case '2':
|
|
240
|
-
type = 'minor';
|
|
241
|
-
newVersion = upgradeVersion(currentVersion, type);
|
|
242
|
-
break;
|
|
243
|
-
case '4':
|
|
244
|
-
console.log('已选择跳过版本升级');
|
|
245
|
-
newVersion = currentVersion;
|
|
246
|
-
break;
|
|
247
|
-
case '3':
|
|
248
|
-
default:
|
|
249
|
-
type = 'patch';
|
|
250
|
-
newVersion = upgradeVersion(currentVersion, type);
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
console.log(`版本: ${newVersion}`);
|
|
256
|
-
|
|
257
|
-
// 如果版本没有变化,直接询问是否确认发布
|
|
258
|
-
const confirmMessage = newVersion === currentVersion
|
|
259
|
-
? `确认发布当前版本 ${currentVersion}? (y/n): `
|
|
260
|
-
: `确认将版本从 ${currentVersion} 升级到 ${newVersion}? (y/n): `;
|
|
261
|
-
|
|
262
|
-
const confirm = await prompt(confirmMessage);
|
|
263
|
-
if (confirm.toLowerCase() !== 'y') {
|
|
264
|
-
console.log('已取消发布');
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// 只有当版本变化时才写入package.json
|
|
269
|
-
if (newVersion !== currentVersion) {
|
|
270
|
-
packageJson.version = newVersion;
|
|
271
|
-
writePackageJson(packageJson);
|
|
272
|
-
console.log(`版本已更新为 ${newVersion}`);
|
|
273
|
-
} else {
|
|
274
|
-
console.log(`继续使用当前版本 ${currentVersion}`);
|
|
275
|
-
|
|
276
|
-
// 当用户选择继续使用当前版本时,检查该版本是否已发布
|
|
277
|
-
const versionExists = await checkVersionExists(packageJson.name, currentVersion);
|
|
278
|
-
if (versionExists) {
|
|
279
|
-
console.log(`\n警告: 版本 ${currentVersion} 已经发布,继续操作会失败。`);
|
|
280
|
-
const forceContinue = await prompt('是否仍要继续? (y/n): ');
|
|
281
|
-
if (forceContinue.toLowerCase() !== 'y') {
|
|
282
|
-
console.log('已取消发布');
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
console.log('用户选择强制继续,可能会在发布时报错');
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// 1. 确保登录
|
|
290
|
-
console.log('\n1. 检查登录状态...');
|
|
291
|
-
if (!await ensureNpmLogin()) {
|
|
292
|
-
throw new Error('登录失败');
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// 2. 发布包
|
|
296
|
-
console.log('\n2. 开始发布包...');
|
|
297
|
-
const publishCmd = 'npm publish --ignore-scripts';
|
|
298
|
-
if (!executeCommand(publishCmd)) {
|
|
299
|
-
throw new Error('发布包失败');
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
console.log(`\n恭喜!${packageJson.name}@${newVersion} 已成功发布到npm!`);
|
|
303
|
-
|
|
304
|
-
} catch (error) {
|
|
305
|
-
console.error('\n发布失败:', error.message);
|
|
306
|
-
process.exit(1);
|
|
307
|
-
} finally {
|
|
308
|
-
rl.close();
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
main();
|