fix(version): read current version from deno.json and latest version from Gitea API
Some checks failed
CI / Type Check & Lint (push) Successful in 5s
CI / Build Test (Current Platform) (push) Successful in 5s
Publish to npm / npm-publish (push) Failing after 27s
Release / build-and-release (push) Successful in 54s
CI / Build All Platforms (push) Successful in 1m8s
Some checks failed
CI / Type Check & Lint (push) Successful in 5s
CI / Build Test (Current Platform) (push) Successful in 5s
Publish to npm / npm-publish (push) Failing after 27s
Release / build-and-release (push) Successful in 54s
CI / Build All Platforms (push) Successful in 1m8s
- Replace static commitinfo with dynamic deno.json import - Change version check from npm registry to Gitea releases API - Delete obsolete ts/00_commitinfo_data.ts - Ensures version consistency across updates
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@serve.zone/nupst',
|
||||
version: '5.1.2',
|
||||
description: 'Network UPS Shutdown Tool - Monitor SNMP-enabled UPS devices and orchestrate graceful system shutdowns during power emergencies'
|
||||
}
|
||||
18
ts/nupst.ts
18
ts/nupst.ts
@@ -1,7 +1,7 @@
|
||||
import { NupstSnmp } from './snmp/manager.ts';
|
||||
import { NupstDaemon } from './daemon.ts';
|
||||
import { NupstSystemd } from './systemd.ts';
|
||||
import { commitinfo } from './00_commitinfo_data.ts';
|
||||
import denoConfig from '../deno.json' with { type: 'json' };
|
||||
import { logger } from './logger.ts';
|
||||
import { UpsHandler } from './cli/ups-handler.ts';
|
||||
import { GroupHandler } from './cli/group-handler.ts';
|
||||
@@ -105,7 +105,7 @@ export class Nupst {
|
||||
* @returns The current version string
|
||||
*/
|
||||
public getVersion(): string {
|
||||
return commitinfo.version;
|
||||
return denoConfig.version;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,8 +153,8 @@ export class Nupst {
|
||||
private getLatestVersion(): Promise<string> {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
const options = {
|
||||
hostname: 'registry.npmjs.org',
|
||||
path: '/@serve.zone/nupst',
|
||||
hostname: 'code.foss.global',
|
||||
path: '/api/v1/repos/serve.zone/nupst/releases/latest',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
@@ -172,10 +172,14 @@ export class Nupst {
|
||||
res.on('end', () => {
|
||||
try {
|
||||
const response = JSON.parse(data);
|
||||
if (response['dist-tags'] && response['dist-tags'].latest) {
|
||||
resolve(response['dist-tags'].latest);
|
||||
if (response.tag_name) {
|
||||
// Strip 'v' prefix from tag name (e.g., "v5.1.7" -> "5.1.7")
|
||||
const version = response.tag_name.startsWith('v')
|
||||
? response.tag_name.substring(1)
|
||||
: response.tag_name;
|
||||
resolve(version);
|
||||
} else {
|
||||
reject(new Error('Failed to parse version from npm registry response'));
|
||||
reject(new Error('Failed to parse version from Gitea API response'));
|
||||
}
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
|
||||
Reference in New Issue
Block a user