@aiyiran/myclaw 1.0.44 → 1.0.45
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/index.js +12 -4
- package/package.json +1 -1
- package/prepare.js +26 -0
package/index.js
CHANGED
|
@@ -345,8 +345,12 @@ call npm install -g @aiyiran/myclaw@latest --prefer-online >nul 2>&1
|
|
|
345
345
|
echo [update] OK
|
|
346
346
|
echo.
|
|
347
347
|
|
|
348
|
-
REM ---- Step 4: Open browser ----
|
|
349
|
-
echo [4/
|
|
348
|
+
REM ---- Step 4: Patch + Open browser ----
|
|
349
|
+
echo [4/5] Patch...
|
|
350
|
+
wsl -d OpenClaw -- myclaw patch
|
|
351
|
+
echo [OK]
|
|
352
|
+
|
|
353
|
+
echo [5/5] Browser...
|
|
350
354
|
call myclaw open
|
|
351
355
|
echo [OK]
|
|
352
356
|
echo.
|
|
@@ -364,8 +368,12 @@ exit /b
|
|
|
364
368
|
:gateway_running
|
|
365
369
|
echo [OK] Running
|
|
366
370
|
|
|
367
|
-
REM ---- Step 4: Open browser ----
|
|
368
|
-
echo [4/
|
|
371
|
+
REM ---- Step 4: Patch + Open browser ----
|
|
372
|
+
echo [4/5] Patch...
|
|
373
|
+
wsl -d OpenClaw -- myclaw patch
|
|
374
|
+
echo [OK]
|
|
375
|
+
|
|
376
|
+
echo [5/5] Browser...
|
|
369
377
|
call myclaw open
|
|
370
378
|
echo [OK]
|
|
371
379
|
echo.
|
package/package.json
CHANGED
package/prepare.js
CHANGED
|
@@ -39,6 +39,21 @@ const BAR = '========================================';
|
|
|
39
39
|
// 检测是否在 npm postinstall 中运行(非交互模式)
|
|
40
40
|
const isPostInstall = process.env.npm_lifecycle_event === 'postinstall';
|
|
41
41
|
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// 文件日志(用于调试 postinstall 等场景)
|
|
44
|
+
// ============================================================================
|
|
45
|
+
|
|
46
|
+
const fs = require('fs');
|
|
47
|
+
const LOG_PATH = path.join(os.tmpdir(), 'myclaw-prepare.log');
|
|
48
|
+
|
|
49
|
+
function writeLog(msg) {
|
|
50
|
+
const ts = new Date().toISOString();
|
|
51
|
+
const line = '[' + ts + '] ' + msg + '\n';
|
|
52
|
+
try {
|
|
53
|
+
fs.appendFileSync(LOG_PATH, line, 'utf8');
|
|
54
|
+
} catch {}
|
|
55
|
+
}
|
|
56
|
+
|
|
42
57
|
// ============================================================================
|
|
43
58
|
// 工具:交互式问答
|
|
44
59
|
// ============================================================================
|
|
@@ -313,6 +328,8 @@ function createDesktopLauncher() {
|
|
|
313
328
|
// ============================================================================
|
|
314
329
|
|
|
315
330
|
async function run() {
|
|
331
|
+
writeLog('=== prepare start (postinstall=' + isPostInstall + ', version=' + require('./package.json').version + ')');
|
|
332
|
+
|
|
316
333
|
console.log('');
|
|
317
334
|
console.log(C.b + BAR + C.nc);
|
|
318
335
|
console.log(C.b + ' MyClaw 初始化向导' + C.nc);
|
|
@@ -322,6 +339,7 @@ async function run() {
|
|
|
322
339
|
// === Step 1: 检测环境 ===
|
|
323
340
|
const env = detectEnv();
|
|
324
341
|
log('Step 1', '检测运行环境...');
|
|
342
|
+
writeLog('Step 1: env=' + env);
|
|
325
343
|
|
|
326
344
|
const envNames = {
|
|
327
345
|
windows: 'Windows',
|
|
@@ -335,16 +353,19 @@ async function run() {
|
|
|
335
353
|
|
|
336
354
|
// === Step 2: 检测 Chrome ===
|
|
337
355
|
const hasChrome = checkChrome(env);
|
|
356
|
+
writeLog('Step 2: chrome=' + hasChrome);
|
|
338
357
|
console.log('');
|
|
339
358
|
|
|
340
359
|
// === Step 3: 检测 OpenClaw ===
|
|
341
360
|
const openclawStatus = checkOpenClaw(env);
|
|
361
|
+
writeLog('Step 3: openclaw=' + openclawStatus);
|
|
342
362
|
console.log('');
|
|
343
363
|
|
|
344
364
|
if (openclawStatus !== 'installed') {
|
|
345
365
|
// 需要安装
|
|
346
366
|
log('提示', 'OpenClaw 需要安装');
|
|
347
367
|
const installed = await installOpenClaw(env, openclawStatus);
|
|
368
|
+
writeLog('Step 3b: install result=' + installed);
|
|
348
369
|
|
|
349
370
|
if (!installed) {
|
|
350
371
|
// 安装未完成(可能需要重启/手动操作)
|
|
@@ -354,6 +375,7 @@ async function run() {
|
|
|
354
375
|
console.log(' 完成后请重新运行: ' + C.y + 'myclaw prepare' + C.nc);
|
|
355
376
|
console.log(BAR);
|
|
356
377
|
console.log('');
|
|
378
|
+
writeLog('=== prepare end (install incomplete)');
|
|
357
379
|
return;
|
|
358
380
|
}
|
|
359
381
|
|
|
@@ -362,9 +384,11 @@ async function run() {
|
|
|
362
384
|
|
|
363
385
|
// === Step 4: Patch ===
|
|
364
386
|
const { AUTO_PATCH } = require('./config');
|
|
387
|
+
writeLog('Step 4: AUTO_PATCH=' + AUTO_PATCH + ', env=' + env);
|
|
365
388
|
if (AUTO_PATCH && env !== 'windows') {
|
|
366
389
|
// Mac/Linux 直接 patch
|
|
367
390
|
runPatchStep(env);
|
|
391
|
+
writeLog('Step 4: patch executed');
|
|
368
392
|
console.log('');
|
|
369
393
|
} else if (!AUTO_PATCH) {
|
|
370
394
|
log('Step 4', 'Patch 已跳过 (AUTO_PATCH=false)');
|
|
@@ -375,6 +399,7 @@ async function run() {
|
|
|
375
399
|
// === Step 5: Windows 桌面启动器 ===
|
|
376
400
|
if (env === 'windows') {
|
|
377
401
|
createDesktopLauncher();
|
|
402
|
+
writeLog('Step 5: desktop launcher created');
|
|
378
403
|
console.log('');
|
|
379
404
|
}
|
|
380
405
|
|
|
@@ -391,6 +416,7 @@ async function run() {
|
|
|
391
416
|
console.log(' 然后打开 ' + C.y + 'http://127.0.0.1:18789' + C.nc);
|
|
392
417
|
}
|
|
393
418
|
console.log('');
|
|
419
|
+
writeLog('=== prepare end (success)');
|
|
394
420
|
}
|
|
395
421
|
|
|
396
422
|
module.exports = { run };
|