/** * CLI version detection with environment-aware caching. * * This module provides cached CLI version detection optimized for different * environments: * - Docker/CSB: Reads from SUPERBLOCKS_CLI_VERSION env var (instant, ~0ms) * - Local: Caches subprocess result (6s first call, 0ms subsequent calls) * * The caching strategy eliminates duplicate subprocess executions that previously * caused ~12s delays during dev server startup. */ /** * Package version information returned by version detection. */ interface PackageVersionInfo { /** Semantic version string (e.g., "2.0.0-next.1") */ version: string; /** Optional package alias for ephemeral builds (e.g., "@superblocksteam/cli-ephemeral") */ alias?: string; } /** * Gets the current CLI version with caching. * * Detection strategy (in order): * 1. Return cached value if available (only successful detections are cached) * 2. Docker/CSB: Read from SUPERBLOCKS_CLI_VERSION env var (~0ms) * 3. Local: Execute subprocess and cache result (~6s first call, ~0ms subsequent) * * The cache is shared across all callers, eliminating duplicate subprocess * executions. This reduces dev server startup from ~12s to ~6s (local) or * ~0s (Docker). * * Note: Failures are NOT cached, allowing recovery from transient issues * (network glitches, filesystem races) without requiring a dev server restart. * * @returns PackageVersionInfo if CLI version can be detected, undefined otherwise * * @example * // First call in Docker - instant * const version = await getCurrentCliVersion(); * // Returns: { version: "2.0.0-next.1" } * * @example * // First call locally - slow (~6s) * const version1 = await getCurrentCliVersion(); * // Second call - instant (cached) * const version2 = await getCurrentCliVersion(); */ export declare function getCurrentCliVersion(): Promise; /** * Clears the cached CLI version, optionally setting it to a known value. * * This is used after CLI upgrades to update the cache with the newly installed * version, avoiding the need for subprocess detection. If a version is provided, * the cache is set to that version; otherwise, the cache is cleared and the next * call to getCurrentCliVersion() will re-detect. * * @param newVersion - Optional version info to set the cache to (e.g., after upgrade) * * @example * // After upgrading CLI to a known version * clearCliVersionCache({ version: "2.0.0-next.2" }); * const version = await getCurrentCliVersion(); // Returns cached version instantly * * @example * // Clear cache completely (for tests) * clearCliVersionCache(); * const version = await getCurrentCliVersion(); // Will re-detect */ export declare function clearCliVersionCache(newVersion?: PackageVersionInfo): void; export {}; //# sourceMappingURL=version-detection.d.ts.map