update
This commit is contained in:
171
ts/smartupdate.interfaces.ts
Normal file
171
ts/smartupdate.interfaces.ts
Normal file
@@ -0,0 +1,171 @@
|
||||
import type { TLogLevel } from './smartupdate.constants.js';
|
||||
import type * as smartnpm from '@push.rocks/smartnpm';
|
||||
|
||||
/**
|
||||
* Cache status stored for each package
|
||||
*/
|
||||
export interface ICacheStatus {
|
||||
lastCheck: number;
|
||||
latestVersion: string;
|
||||
performedUpgrade: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for configuring the SmartUpdate instance
|
||||
*/
|
||||
export interface ISmartUpdateOptions {
|
||||
/**
|
||||
* Options for the npm registry connection
|
||||
*/
|
||||
npmRegistryOptions?: smartnpm.INpmRegistryConstructorOptions;
|
||||
|
||||
/**
|
||||
* Cache duration configuration
|
||||
* @default { hours: 1 }
|
||||
*/
|
||||
cacheDuration?: {
|
||||
hours?: number;
|
||||
minutes?: number;
|
||||
seconds?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Logging level
|
||||
* @default 'INFO'
|
||||
*/
|
||||
logLevel?: TLogLevel;
|
||||
|
||||
/**
|
||||
* Custom logger function
|
||||
* If provided, this will be used instead of console output
|
||||
*/
|
||||
customLogger?: (level: TLogLevel, message: string) => void;
|
||||
|
||||
/**
|
||||
* Disable colored output
|
||||
* @default false
|
||||
*/
|
||||
noColor?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for checking for updates
|
||||
*/
|
||||
export interface IUpdateCheckOptions {
|
||||
/**
|
||||
* The npm package name to check
|
||||
*/
|
||||
packageName: string;
|
||||
|
||||
/**
|
||||
* The current version to compare against
|
||||
*/
|
||||
currentVersion: string;
|
||||
|
||||
/**
|
||||
* Optional URL to the changelog
|
||||
* If provided and an update is available, the changelog will be opened
|
||||
*/
|
||||
changelogUrl?: string;
|
||||
|
||||
/**
|
||||
* Whether to open the changelog URL automatically
|
||||
* Only applies if running in a non-CI environment
|
||||
* @default true
|
||||
*/
|
||||
openChangelog?: boolean;
|
||||
|
||||
/**
|
||||
* Cache strategy for this check
|
||||
* - 'always': Always check cache first (default for CLI)
|
||||
* - 'never': Always check registry, bypass cache
|
||||
* - 'time-based': Check based on cache duration
|
||||
* @default 'time-based'
|
||||
*/
|
||||
cacheStrategy?: 'always' | 'never' | 'time-based';
|
||||
}
|
||||
|
||||
/**
|
||||
* Result of an update check
|
||||
*/
|
||||
export interface IUpdateCheckResult {
|
||||
/**
|
||||
* Status of the update check
|
||||
*/
|
||||
status: 'up-to-date' | 'update-available' | 'check-skipped' | 'error';
|
||||
|
||||
/**
|
||||
* The current version being checked
|
||||
*/
|
||||
currentVersion: string;
|
||||
|
||||
/**
|
||||
* The latest version available (if found)
|
||||
*/
|
||||
latestVersion?: string;
|
||||
|
||||
/**
|
||||
* The package name that was checked
|
||||
*/
|
||||
packageName: string;
|
||||
|
||||
/**
|
||||
* Time when the check was performed
|
||||
*/
|
||||
checkTime: Date;
|
||||
|
||||
/**
|
||||
* Whether this result came from cache
|
||||
*/
|
||||
cacheHit: boolean;
|
||||
|
||||
/**
|
||||
* When the next check can be performed (if check was skipped due to rate limiting)
|
||||
*/
|
||||
nextCheckTime?: Date;
|
||||
|
||||
/**
|
||||
* Error details if status is 'error'
|
||||
*/
|
||||
error?: Error;
|
||||
|
||||
/**
|
||||
* Reason for the result (human-readable explanation)
|
||||
*/
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for the cache manager
|
||||
*/
|
||||
export interface ICacheOptions {
|
||||
/**
|
||||
* Cache duration in milliseconds
|
||||
*/
|
||||
durationMs: number;
|
||||
|
||||
/**
|
||||
* Identifier for the key-value store
|
||||
*/
|
||||
storeIdentifier?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for the notifier
|
||||
*/
|
||||
export interface INotificationOptions {
|
||||
/**
|
||||
* Log level for notifications
|
||||
*/
|
||||
logLevel: TLogLevel;
|
||||
|
||||
/**
|
||||
* Whether to use colors in output
|
||||
*/
|
||||
useColors: boolean;
|
||||
|
||||
/**
|
||||
* Custom logger function
|
||||
*/
|
||||
customLogger?: (level: TLogLevel, message: string) => void;
|
||||
}
|
||||
Reference in New Issue
Block a user