Skip to content

Cli#339

Merged
calvinbrewer merged 3 commits intomainfrom
cli
Apr 9, 2026
Merged

Cli#339
calvinbrewer merged 3 commits intomainfrom
cli

Conversation

@calvinbrewer
Copy link
Copy Markdown
Contributor

@calvinbrewer calvinbrewer commented Apr 9, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Resolved peer dependency configuration by marking @cipherstash/stack as optional and implementing lazy loading for dependent commands. Users will now receive clear error instructions if attempting to use features requiring this optional dependency without it installed.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

🦋 Changeset detected

Latest commit: 4d0dfc5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cipherstash/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This pull request adds lazy loading for commands that depend on @cipherstash/stack by declaring it as an optional peer dependency. Commands that require this dependency (db push, db validate, schema build, secrets) now dynamically import their modules at runtime instead of eagerly loading them, with fallback error handling for missing modules.

Changes

Cohort / File(s) Summary
Changesets Metadata
.changeset/four-wolves-greet.md
Added changeset entry documenting the minor version bump for @cipherstash/cli and lazy loading implementation.
Dependency Configuration
packages/cli/package.json
Declared @cipherstash/stack as an optional peer dependency (version >=0.6.0) via peerDependencies and peerDependenciesMeta.
Command Dispatch Logic
packages/cli/src/bin/stash.ts
Replaced eager imports with lazy dynamic imports for stack-dependent commands. Added isModuleNotFound and requireStack helpers to handle missing module errors and provide user guidance.
Command Exports
packages/cli/src/commands/index.ts
Removed re-exports of stack-dependent commands (pushCommand, validateCommand, validateEncryptConfig, reportIssues, builderCommand, secretsCommand).

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as CLI Entry Point
    participant ModuleLoader as Module System
    participant CommandModule as Command Module
    
    User->>CLI: Execute command (db push/validate, schema build, secrets)
    CLI->>CLI: Check command type
    alt Stack-dependent command
        CLI->>ModuleLoader: Dynamic import with requireStack()
        ModuleLoader->>ModuleLoader: Attempt module load
        alt Module found
            ModuleLoader-->>CommandModule: Module loaded
            CommandModule-->>CLI: Return command function
            CLI->>CommandModule: Execute command
            CommandModule-->>User: Command output
        else Module not found (ERR_MODULE_NOT_FOUND)
            ModuleLoader-->>CLI: Error caught
            CLI->>CLI: Log installation guidance
            CLI->>User: Exit with error status 1
        end
    else Other command
        CLI->>CommandModule: Execute normally
        CommandModule-->>User: Command output
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • coderdan

Poem

🐰 With lazy paws, we load with care,
Stack commands now load everywhere,
Only when needed, oh what grace,
Dependencies find their proper place!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Cli' is extremely vague and generic, providing no meaningful information about the specific changes in the pull request. Use a descriptive title that summarizes the main change, such as 'Make @cipherstash/stack peer dependency optional with lazy loading' or 'Lazily load stack-dependent CLI commands to fix peer dependency issue'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cli

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@calvinbrewer calvinbrewer merged commit f159ea5 into main Apr 9, 2026
4 of 6 checks passed
@calvinbrewer calvinbrewer deleted the cli branch April 9, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant