ts-pkgx
Version:
A library & CLI for managing packages
88 lines • 3.79 kB
TypeScript
import type { ProjectFolder } from './types';
/**
* Saves GitHub API rate limit information to a file
* @param headers Response headers from a GitHub API request
*/
export declare function saveRateLimitInfo(headers: Headers): void;
/**
* Checks if we should proceed with a GitHub API request based on rate limit
* and adds delays when necessary to avoid hitting limits
* @returns boolean indicating if the request should proceed
*/
export declare function shouldProceedWithGitHubRequest(): boolean;
/**
* Gets cached GitHub package list if it exists and is still valid
* @returns Array of package paths from cache, or null if cache invalid
*/
export declare function getGitHubPackageCache(): string[] | null;
/**
* Saves GitHub package list to cache
* @param packages Array of package paths to cache
*/
export declare function saveGitHubPackageCache(packages: string[]): void;
/**
* Fetches a list of packages from GitHub API using nested directory approach
* @param limit Maximum number of packages to return (0 for all)
* @param singlePackage Optional specific package to return (skips fetching others)
* @returns Array of package paths
*/
export declare function fetchPackageListFromGitHub(limit?: number, singlePackage?: string): Promise<string[]>;
/**
* Demo function to show how to use fetchPkgxProjects
* @returns Promise resolving to array of projects or empty array on error
*/
export declare function logPkgxProjects(): Promise<ProjectFolder[]>;
/**
* Formats an object as a string without quotes around property names
* Used for generating TypeScript files with clean object syntax
*
* @param obj The object to format
* @param indent The indentation level
* @returns A formatted string representation of the object
*/
export declare function formatObjectWithoutQuotedKeys(obj: any, indent?: any): string;
/**
* Utility functions for handling package domains and nested paths
* These utilities help standardize the naming conventions for TypeScript files
*/
/**
* Converts a domain name to a safe TypeScript variable name
* @param domain Domain name (e.g., 'bun.sh', 'agwa.name/git-crypt')
* @returns Safe TypeScript variable name (e.g., 'bunsh', 'agwanamegitcrypt')
*/
export declare function convertDomainToVarName(domain: string): string;
/**
* Converts a domain name to a standard format for file names
* @param domain Domain name or path
* @returns Filename-safe version (e.g., 'bun.sh' -> 'bunsh', 'agwa.name/git-crypt' -> 'agwaname-gitcrypt')
*/
export declare function convertDomainToFileName(domain: string): string;
/**
* Attempts to guess a domain name from a filename
* @param fileName The filename (without extension)
* @returns Best guess at the original domain
*/
export declare function guessOriginalDomain(fileName: string): string;
/**
* Resolves a package name to its full domain name using the PACKAGE_ALIASES mapping
* @param packageName The package name to resolve (e.g., 'node', 'python', 'nodejs.org')
* @returns The resolved domain name (e.g., 'nodejs.org', 'python.org')
*/
export declare function resolvePackageDomain(packageName: string): string;
/**
* Gets all available package aliases
* @returns Record of alias to domain mappings
*/
export declare function getPackageAliases(): Record<string, string>;
/**
* Checks if a package name is a known alias
* @param packageName The package name to check
* @returns True if the package name is a known alias
*/
export declare function isKnownAlias(packageName: string): boolean;
/**
* Gets the canonical domain name for a package, whether it's an alias or already a domain
* @param packageName The package name or domain to canonicalize
* @returns The canonical domain name
*/
export declare function getCanonicalDomain(packageName: string): string;