UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

98 lines (97 loc) 3.62 kB
import { type PackageDownloader } from '../package-downloader.js'; import { ShellRunner } from '../shell-runner.js'; /** * Base class for dependency managers that download and manage CLI tools * Common functionality for downloading, checking versions, and managing executables */ export declare abstract class BaseDependencyManager extends ShellRunner { protected readonly downloader: PackageDownloader; protected readonly installationDirectory: string; protected readonly requiredVersion: string; protected readonly downloadBaseUrl: string; protected readonly osArch: string; protected localExecutableWithPath: string; protected globalExecutablePath: string; protected readonly artifactName: string; protected readonly downloadURL: string; protected readonly checksumURL: string; protected readonly executableName: string; protected constructor(downloader: PackageDownloader, installationDirectory: string, osArch: string, requiredVersion: string, dependencyName: string, downloadBaseUrl: string); protected getArch(): string; /** * Child classes must implement this to generate the correct artifact name * based on version, platform, and architecture */ protected abstract getArtifactName(): string; /** * Get the download URL for the executable */ protected abstract getDownloadURL(): string; /** * Get the checksum URL for the executable */ protected abstract getChecksumURL(): string; abstract getVersion(executablePath: string): Promise<string>; /** * Handle any post-download processing before copying to destination * Child classes can override this for custom extraction or processing */ protected abstract processDownloadedPackage(packageFilePath: string, temporaryDirectory: string): Promise<string[]>; /** * Get the executable to run */ getExecutable(): Promise<string>; /** * Find the global executable by scanning PATH directories directly in Node.js. * This avoids spawning a shell subprocess (which, command -v, where) whose * behaviour varies across shells and CI runner environments. */ private getGlobalExecutableWithPath; /** * Check if the given installation meets version requirements */ installationMeetsRequirements(executableWithPath: string): Promise<boolean>; /** * Check if the tool is installed globally and meets requirements */ private isInstalledGloballyAndMeetsRequirements; /** * Check if the tool is installed locally and meets requirements */ private isInstalledLocallyAndMeetsRequirements; /** * Check if the tool is installed locally */ isInstalledLocally(): boolean; /** * Uninstall the local version */ uninstallLocal(): void; /** * Hook for any pre-installation steps */ protected preInstall(): Promise<void>; /** * Hook to determine if installation should proceed * Child classes can override this for custom logic */ shouldInstall(): Promise<boolean>; /** * Determine if checksum verification should be performed * Child classes can override this if needed */ getVerifyChecksum(): boolean; /** * Install the tool */ install(temporaryDirectory?: string): Promise<boolean>; /** * Get the tool's required version */ getRequiredVersion(): string; /** * Hook for setting up any configuration after installation * Child classes can override this if needed */ setupConfig(): void; }