From 00fef1ae06b317ffc08def03bc6a156d340aa918 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Tue, 3 Feb 2026 22:58:28 +0000 Subject: [PATCH] fix(mod_update): try private registry (verdaccio.lossless.digital) first when fetching package versions; fall back to public npm; handle unknown latest versions gracefully in output --- changelog.md | 9 +++++++++ ts/00_commitinfo_data.ts | 2 +- ts/mod_update/classes.packagemanager.ts | 20 ++++++++++++++++++++ ts/mod_update/index.ts | 22 ++++++++++++---------- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/changelog.md b/changelog.md index 15f03c4..a6fa7e5 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,14 @@ # Changelog +## 2026-02-03 - 3.1.3 - fix(mod_update) +try private registry (verdaccio.lossless.digital) first when fetching package versions; fall back to public npm; handle unknown latest versions gracefully in output + +- getLatestVersion now attempts a direct API request to https://verdaccio.lossless.digital/ and parses dist-tags.latest +- Falls back to npm view when the private registry request fails +- Scoped package names are URL-encoded (replaces '/' with '%2f') before querying the private registry +- Packages with no resolvable latest version are included with latestVersion set to 'unknown' and displayed as '? Version unknown' +- needsUpdate is set to false when latest version is unknown + ## 2026-02-03 - 3.1.2 - fix(scripts) make test script output verbose by using --verbose instead of --web diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index ac93fb0..b4c6a31 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tools', - version: '3.1.2', + version: '3.1.3', description: 'A CLI tool placeholder for development utilities.' } diff --git a/ts/mod_update/classes.packagemanager.ts b/ts/mod_update/classes.packagemanager.ts index 24839a3..5754014 100644 --- a/ts/mod_update/classes.packagemanager.ts +++ b/ts/mod_update/classes.packagemanager.ts @@ -128,8 +128,28 @@ export class PackageManagerUtil { /** * Get the latest version of a package from npm registry + * Tries private registry (verdaccio.lossless.digital) first via API, then falls back to public npm */ public async getLatestVersion(packageName: string): Promise { + // URL-encode the package name for scoped packages (@scope/name -> @scope%2fname) + const encodedName = packageName.replace('/', '%2f'); + + // Try private registry first via direct API call (npm view doesn't work reliably) + try { + const result = await this.shell.execSilent( + `curl -sf "https://verdaccio.lossless.digital/${encodedName}" 2>/dev/null` + ); + if (result.exitCode === 0 && result.stdout.trim()) { + const data = JSON.parse(result.stdout.trim()); + if (data['dist-tags']?.latest) { + return data['dist-tags'].latest; + } + } + } catch { + // Continue to public registry + } + + // Fall back to public npm try { const result = await this.shell.execSilent(`npm view ${packageName} version 2>/dev/null`); if (result.exitCode === 0 && result.stdout.trim()) { diff --git a/ts/mod_update/index.ts b/ts/mod_update/index.ts index fb0f0df..6c4fbdc 100644 --- a/ts/mod_update/index.ts +++ b/ts/mod_update/index.ts @@ -46,15 +46,13 @@ export const run = async (options: IUpdateOptions = {}): Promise => { // Only include packages from our predefined list if (GITZONE_PACKAGES.includes(pkg.name)) { const latestVersion = await pmUtil.getLatestVersion(pkg.name); - if (latestVersion) { - allPackages.push({ - name: pkg.name, - currentVersion: pkg.version, - latestVersion, - packageManager: pm, - needsUpdate: pmUtil.isNewerVersion(pkg.version, latestVersion), - }); - } + allPackages.push({ + name: pkg.name, + currentVersion: pkg.version, + latestVersion: latestVersion || 'unknown', + packageManager: pm, + needsUpdate: latestVersion ? pmUtil.isNewerVersion(pkg.version, latestVersion) : false, + }); } } } @@ -74,7 +72,11 @@ export const run = async (options: IUpdateOptions = {}): Promise => { const current = pkg.currentVersion.padEnd(12); const latest = pkg.latestVersion.padEnd(12); const pm = pkg.packageManager.padEnd(8); - const status = pkg.needsUpdate ? '⬆️ Update available' : '✓ Up to date'; + const status = pkg.latestVersion === 'unknown' + ? '? Version unknown' + : pkg.needsUpdate + ? '⬆️ Update available' + : '✓ Up to date'; console.log(` ${name}${current}${latest}${pm}${status}`); }