ygc-dsh-plugin-autoupdate 1.2.0 → 1.2.1

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.
Files changed (2) hide show
  1. package/lib/api.js +10 -4
  2. package/package.json +1 -1
package/lib/api.js CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  MAX_DELAY_HOURS,
10
10
  MIN_INTERVAL_MINUTES,
11
11
  delayRemainingMs,
12
+ gitOriginOf,
12
13
  humanHours,
13
14
  installedVersion,
14
15
  isNewerVersion,
@@ -61,14 +62,19 @@ function snapshot(deps) {
61
62
  const policy = policyFor(state, plugin.name);
62
63
  const pending = state.pending[plugin.name];
63
64
  const seen = cached[plugin.name];
64
- // 「最新版」以 pending 为准,退回上次检查快照
65
- const latest = (pending && pending.latest) || (seen && seen.latest) || null;
65
+ // git-local 的「最新」不必等一轮检查:识别阶段已经把上游 tag 的版本号拿到了,
66
+ // 直接比版本号就能给出结论。否则面板刚打开时会把「上游 0.43.1、本机 0.39.1」
67
+ // 显示成「已是最新」——这跟「查询失败当成最新」是同一类谎。
68
+ const origin = plugin.kind === 'git-local' ? gitOriginOf(state, plugin.name) : undefined;
69
+ const originLatest = origin && origin.latest ? origin.latest : null;
70
+ // 「最新版」以 pending 为准,退回上次检查快照,再退回识别结果(仅 git-local)
71
+ const latest = (pending && pending.latest) || (seen && seen.latest) || originLatest;
66
72
  // 是否可更新必须按版本比较:插件可能已被别处(手动/pnpm/宿主)升到最新,
67
73
  // 而 pending 里还留着旧记录。只看 pending 会把「已是最新」错标成「可更新」。
68
74
  const newer = Boolean(latest && plugin.version && isNewerVersion(plugin.version, latest));
69
75
  const active = newer ? pending : undefined;
70
76
  // git 来源没有版本号可比,可更新性直接看检查阶段算出的 updateAvailable;
71
- // git-local(本地 tgz 装、上游是 Git)同理——它的「新旧」由检查阶段按 tag 版本号判定。
77
+ // git-local 反而能自己算:本机版本 vs 上游 tag 版本,与检查阶段同一判据。
72
78
  const gitNewer =
73
79
  plugin.kind === 'git' || plugin.kind === 'git-local' ? Boolean(seen && seen.updateAvailable) : false;
74
80
  // 可卸载性:listPlugins 已经从宿主清单带过来了(plugin.canUninstall)。
@@ -90,7 +96,7 @@ function snapshot(deps) {
90
96
  npmMigration: (seen && seen.npmMigration) || plugin.npmMigration || null,
91
97
  latestError: seen && seen.error ? seen.error : '',
92
98
  updateAvailable:
93
- plugin.kind === 'git' || plugin.kind === 'git-local' ? gitNewer : newer,
99
+ plugin.kind === 'git' ? gitNewer : plugin.kind === 'git-local' ? newer || gitNewer : newer,
94
100
  waitMs: active ? delayRemainingMs(state, plugin.name, active.firstSeenAt) : 0,
95
101
  waitText: active ? humanHours(delayRemainingMs(state, plugin.name, active.firstSeenAt)) : '',
96
102
  // 面板据此决定「卸载」按钮是否可点,以及鼠标悬停时解释为什么不行
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ygc-dsh-plugin-autoupdate",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "description": "DSH 插件自动更新器:定时检查已装插件的新版本并按策略升级、装完按需重启、可回滚。只管「已装插件的新版本」,插件清单共享已移交 ygc-dsh-sync。",
6
6
  "icon": "icon.svg",