@yanzc/claude-pro 0.11.0 → 0.12.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/src/updater.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Manual update support for `npm i -g claude-pro`: the interactive session checks npm and installs a release only
2
- // when `/update` asks for it (App.updateFromNpm). Installation is serialized by a lock file and the session loads
2
+ // when `/update` or the web console's update button asks for it. Installation is serialized by a lock file and the session loads
3
3
  // the new package with a restart (the conversation carries over). A git checkout (the development copy) is never
4
4
  // touched.
5
5
 
@@ -100,19 +100,20 @@ function runNpm(args, { timeoutMs = 300_000 } = {}) {
100
100
 
101
101
  // Look for a newer version on npm. Resolves with {status: 'dev'|'current'|'available'|'installed', version}:
102
102
  // 'available' to be installed (installUpdate), 'installed' when it is on disk already (another session installed
103
- // it: a restart loads it). (The background checks every few minutes, with their state file and switches, are gone:
104
- // /update is the only caller.)
103
+ // it: a restart loads it). Checking does not install anything.
105
104
  export async function checkForUpdate() {
106
105
  if (!installedByNpm()) return { status: 'dev' };
106
+ const disk = installedVersion();
107
+ if (isNewer(disk, VERSION)) return { status: 'installed', version: disk };
107
108
  const latest = await latestVersion();
108
109
  if (!isNewer(latest, VERSION)) return { status: 'current', version: latest };
109
- if (!isNewer(latest, installedVersion())) return { status: 'installed', version: installedVersion() };
110
110
  return { status: 'available', version: latest };
111
111
  }
112
112
 
113
113
  // Install `version` with npm. Resolves with {status: 'updated'|'installed'|'locked'|'failed', version, error}:
114
114
  // 'locked' while another session of the machine is installing.
115
115
  export async function installUpdate(version) {
116
+ if (!/^\d+\.\d+\.\d+$/.test(String(version))) return { status: 'failed', error: 'invalid npm version' };
116
117
  if (!takeLock()) return { status: 'locked', version };
117
118
  try {
118
119
  if (!isNewer(version, installedVersion())) return { status: 'installed', version: installedVersion() };