@ulthon/ul-opencode-event 0.1.23 → 0.1.25
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/dist/updater.js +21 -6
- package/package.json +1 -1
package/dist/updater.js
CHANGED
|
@@ -370,20 +370,24 @@ async function showToast(ctx, title, message, variant, duration) {
|
|
|
370
370
|
*/
|
|
371
371
|
export async function runAutoUpdate(ctx, autoUpdate) {
|
|
372
372
|
try {
|
|
373
|
+
logger.info(`[updater] runAutoUpdate started, directory=${ctx.directory}, autoUpdate=${autoUpdate}`);
|
|
373
374
|
// 1. Skip checks
|
|
374
375
|
if (isLocalDevMode(ctx.directory)) {
|
|
375
376
|
logger.info('[updater] Local development mode detected, skipping update check');
|
|
376
377
|
return;
|
|
377
378
|
}
|
|
378
|
-
|
|
379
|
+
const pinned = isPinnedVersion(ctx.directory);
|
|
380
|
+
logger.info(`[updater] isPinnedVersion=${pinned}`);
|
|
381
|
+
if (pinned) {
|
|
379
382
|
logger.info('[updater] Pinned version detected, skipping auto-update');
|
|
380
383
|
// Still check and notify, but don't auto-install
|
|
381
384
|
autoUpdate = false;
|
|
382
385
|
}
|
|
383
386
|
// 2. Get current version
|
|
384
387
|
const currentVersion = getCurrentVersion();
|
|
388
|
+
logger.info(`[updater] currentVersion=${currentVersion}`);
|
|
385
389
|
if (!currentVersion) {
|
|
386
|
-
logger.
|
|
390
|
+
logger.warn('[updater] Could not determine current version');
|
|
387
391
|
return;
|
|
388
392
|
}
|
|
389
393
|
// 3. Check cache first
|
|
@@ -392,23 +396,29 @@ export async function runAutoUpdate(ctx, autoUpdate) {
|
|
|
392
396
|
const cached = getCachedCheck();
|
|
393
397
|
if (cached) {
|
|
394
398
|
latestVersion = cached.latestVersion;
|
|
395
|
-
logger.
|
|
399
|
+
logger.info(`[updater] Using cached version info: ${latestVersion}`);
|
|
396
400
|
}
|
|
397
401
|
}
|
|
402
|
+
else {
|
|
403
|
+
logger.info('[updater] Cache invalid or missing');
|
|
404
|
+
}
|
|
398
405
|
// 4. Fetch latest if no valid cache
|
|
399
406
|
if (!latestVersion) {
|
|
407
|
+
logger.info('[updater] Fetching latest version from npm...');
|
|
400
408
|
latestVersion = await getLatestVersion();
|
|
409
|
+
logger.info(`[updater] getLatestVersion returned: ${latestVersion}`);
|
|
401
410
|
if (latestVersion) {
|
|
402
411
|
setCachedCheck(latestVersion);
|
|
412
|
+
logger.info(`[updater] Cache written for ${latestVersion}`);
|
|
403
413
|
}
|
|
404
414
|
}
|
|
405
415
|
if (!latestVersion) {
|
|
406
|
-
logger.
|
|
416
|
+
logger.warn('[updater] Could not fetch latest version');
|
|
407
417
|
return;
|
|
408
418
|
}
|
|
409
419
|
// 5. Compare versions (simple string equality)
|
|
410
420
|
if (currentVersion === latestVersion) {
|
|
411
|
-
logger.
|
|
421
|
+
logger.info(`[updater] Already on latest version: ${currentVersion}`);
|
|
412
422
|
return;
|
|
413
423
|
}
|
|
414
424
|
logger.info(`[updater] Update available: ${currentVersion} -> ${latestVersion}`);
|
|
@@ -418,15 +428,17 @@ export async function runAutoUpdate(ctx, autoUpdate) {
|
|
|
418
428
|
return;
|
|
419
429
|
}
|
|
420
430
|
// 7. Auto-update: sync -> invalidate -> resolve workspace -> bun install
|
|
421
|
-
// First, find plugin info for sync
|
|
422
431
|
const plugins = readPluginList(ctx.directory);
|
|
432
|
+
logger.info(`[updater] readPluginList returned: ${JSON.stringify(plugins)}`);
|
|
423
433
|
const pluginEntry = plugins.find((e) => e.includes('ul-opencode-event')) ?? PACKAGE_NAME;
|
|
424
434
|
const atIndex = pluginEntry.lastIndexOf('@');
|
|
425
435
|
const pinnedVersion = atIndex > 0 ? pluginEntry.slice(atIndex + 1) : null;
|
|
426
436
|
const isPinned = pinnedVersion !== null && EXACT_SEMVER_RE.test(pinnedVersion);
|
|
427
437
|
const pluginInfo = { entry: pluginEntry, isPinned, pinnedVersion: isPinned ? pinnedVersion : null };
|
|
438
|
+
logger.info(`[updater] pluginInfo=${JSON.stringify(pluginInfo)}`);
|
|
428
439
|
// Sync workspace package.json to intent
|
|
429
440
|
const syncResult = syncCachePackageJsonToIntent(pluginInfo);
|
|
441
|
+
logger.info(`[updater] syncResult=${JSON.stringify(syncResult)}`);
|
|
430
442
|
if (syncResult.error) {
|
|
431
443
|
logger.warn(`[updater] Sync failed: ${syncResult.error}, continuing with notification only`);
|
|
432
444
|
await showToast(ctx, `ul-opencode-event ${latestVersion}`, `Update available: v${currentVersion} -> v${latestVersion}\nSync failed, try manual update.`, 'info', 8000);
|
|
@@ -434,9 +446,12 @@ export async function runAutoUpdate(ctx, autoUpdate) {
|
|
|
434
446
|
}
|
|
435
447
|
// Invalidate old package
|
|
436
448
|
invalidatePackage();
|
|
449
|
+
logger.info('[updater] invalidatePackage done');
|
|
437
450
|
// Resolve workspace and install
|
|
438
451
|
const workspaceDir = resolveWorkspaceDir();
|
|
452
|
+
logger.info(`[updater] workspaceDir=${workspaceDir}`);
|
|
439
453
|
const success = await runBunInstall(workspaceDir);
|
|
454
|
+
logger.info(`[updater] bun install result=${success}`);
|
|
440
455
|
if (success) {
|
|
441
456
|
await showToast(ctx, 'ul-opencode-event Updated!', `v${currentVersion} -> v${latestVersion}\nRestart OpenCode to apply.`, 'success', 8000);
|
|
442
457
|
logger.info(`[updater] Update installed: ${currentVersion} -> ${latestVersion}`);
|
package/package.json
CHANGED