feat: support offline mode with env var version pinning and cache fallback#16
Draft
fauzxan wants to merge 1 commit intoholistics:masterfrom
Draft
feat: support offline mode with env var version pinning and cache fallback#16fauzxan wants to merge 1 commit intoholistics:masterfrom
fauzxan wants to merge 1 commit intoholistics:masterfrom
Conversation
…lback When HOLISTICS_CLI_CORE_VERSION is set, skip npm registry calls entirely and use the specified version from cache. When the env var is not set and npm is unreachable, fall back to the most recent cached version instead of crashing. Closes holistics#15 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #15 — the CLI binary currently always contacts
registry.npmjs.orgto resolve the latest@holistics/cli-coreversion, even when the package is already cached locally. This makes the CLI unusable in network-restricted environments.This PR adds two mechanisms to
ensureModuleinsrc/downloader.ts:HOLISTICS_CLI_CORE_VERSIONenv var — when set, the npm registry call is skipped entirely and the specified version is loaded directly from cachegetLatestVersion()fails due to a network error, the CLI scans~/.cache/holistics/for any previously downloaded version (picking the highest) instead of crashingChanges
src/downloader.ts:findCachedVersion()— scans the cache directory for existing{pkg}@{version}entries and returns the highest version foundensureModule()— checksHOLISTICS_CLI_CORE_VERSIONenv var first, then attempts npm with fallback to cached version on network failurereaddirimport fromfs/promisesandgetCacheDirimport from./cacheUsage
Use case: Pre-baked Docker images
Test plan
holistics --versionworks normally (no env var, network available)HOLISTICS_CLI_CORE_VERSION=0.6.13 holistics --versionworks with pre-populated cache and no network🤖 Generated with Claude Code