UNPKG

ts-pkgx

Version:

A library & CLI for managing packages

96 lines 3.98 kB
import { aliases } from './packages/aliases'; import type { Packages } from './packages'; // Type guards export declare function isPackageAlias(name: string): name is PackageAlias; export declare function isPackageDomain(name: string): name is PackageDomain; export declare function isValidPackageName(name: string): name is PackageName; export declare function isSupportedPlatform(platform: string): platform is SupportedPlatform; export declare function isSupportedArchitecture(arch: string): arch is SupportedArchitecture; // Utility functions export declare function getAllPackageAliases(): PackageAlias[]; export declare function getAllPackageDomains(): PackageDomain[]; export declare function resolvePackageName(name: string): PackageResolution; export declare function parsePackageSpec(spec: string): ParsedPackageSpec; export declare function formatPackageSpec(name: PackageName, version?: string): PackageSpec; export declare function detectPlatform(): PlatformInfo; export declare function createInstallationContext(packageName: PackageName, version?: string, platformInfo?: PlatformInfo): InstallationContext; // Helper to get packages by category export declare function getPackagesByCategory(category: keyof typeof PACKAGE_CATEGORIES): readonly string[]; // Helper to check if a package is in a specific category export declare function isPackageInCategory(packageName: string, category: keyof typeof PACKAGE_CATEGORIES): boolean; // Constants for common version specifications export declare const VERSION_SPECS: { LATEST: 'latest'; ANY: '*' }; // Constants for common package categories export declare const PACKAGE_CATEGORIES: { RUNTIME: readonly ['nodejs.org', 'python.org', 'go.dev', 'rust-lang.org']; BUILD_TOOLS: readonly ['cmake.org', 'ninja-build.org', 'gradle.org', 'maven.apache.org']; DATABASES: readonly ['postgresql.org', 'mysql.com', 'redis.io', 'mongodb.com']; EDITORS: readonly ['neovim.io', 'vim.org', 'code.visualstudio.com']; CLI_TOOLS: readonly ['cli.github.com', 'curl.se', 'wget.gnu.org', 'jq.dev'] }; // Package information interface export declare interface PackageInfo { name: string domain: string description: string latestVersion: string totalVersions: number programs: string[] dependencies: string[] companions: string[] versions: string[] } // Package resolution result export declare interface PackageResolution { originalName: string resolvedDomain: string isAlias: boolean version?: string } // Package specification parsing result export declare interface ParsedPackageSpec { name: string version?: string versionSpec?: VersionSpec } // Platform detection result export declare interface PlatformInfo { platform: SupportedPlatform architecture: SupportedArchitecture isSupported: boolean } // Package installation context export declare interface InstallationContext { packageName: PackageName version: string platform: SupportedPlatform architecture: SupportedArchitecture format: SupportedFormat } // Extract all package alias names from ts-pkgx export type PackageAlias = keyof typeof aliases // Extract all package domain names from ts-pkgx packages export type PackageDomain = keyof Packages // Union type of all valid package identifiers (aliases + domains) export type PackageName = PackageAlias | PackageDomain // Type for package with optional version specification export type PackageSpec = `${PackageName}` | `${PackageName}@${string}` // Supported distribution formats export type SupportedFormat = 'tar.xz' | 'tar.gz' | 'zip' | 'dmg' | 'pkg' | 'msi' | 'deb' | 'rpm' // Supported platforms export type SupportedPlatform = 'darwin' | 'linux' | 'windows' // Supported architectures export type SupportedArchitecture = 'x86_64' | 'aarch64' | 'armv7l' | 'i686' // Version specification types export type VersionSpec = | 'latest' | `^${string}` | `~${string}` | `>=${string}` | `<=${string}` | `>${string}` | `<${string}` | `=${string}` | string