@6edesign/cli
v0.1.15
Published
CLI for the 6edesign/zrpc framework
Readme
@6edesign/cli
This package provides the Command Line Interface (CLI) for the Stacker monorepo. It allows developers to interact with various aspects of the Stacker ecosystem, including deploying applications, managing workspaces, and eventually debugging and code generation.
The CLI is built with a config-driven architecture, making it highly extensible and easy to add new commands and interactive features.
Features
- Config-Driven Commands: Commands and their options are defined declaratively using Zod schemas, simplifying development and ensuring consistency.
- Interactive "Genie Mode": Automatically prompts users for missing required options, guiding them through complex operations with clear, interactive prompts.
- One-Shot Mode: Supports direct command-line arguments for experienced users and automated CI/CD workflows.
- Workspace Management: Discovers and interacts with workspaces defined in the monorepo.
- Deployment Orchestration: Integrates with
@6edesign/cicdto execute deployments using Pulumi.
Installation
The Stacker CLI is part of the Stacker monorepo. To use it, ensure you have pnpm installed and then run:
pnpm installUsage
You can execute the Stacker CLI using pnpm exec stacker.
Interactive Mode (Genie Mode)
Run the CLI without any arguments to enter interactive mode:
pnpm exec stackerThe CLI will guide you through available commands and their options using prompts.
One-Shot Mode
Specify commands and options directly on the command line:
pnpm exec stacker deploy --workspace=shop --deployable=ui --environment=devExample: Deploying an Application
To deploy an application, you can use the deploy command.
Interactive Deployment
pnpm exec stacker deployFollow the prompts to select the workspace, deployable, and environment.
One-Shot Deployment
pnpm exec stacker deploy --workspace=my-app --deployable=dockerImage --environment=prod --version=1.0.0Code Generation Commands
The CLI provides commands to quickly scaffold new projects, packages, and zRPC services, adhering to the monorepo's conventions.
New Project
To bootstrap a new monorepo project:
pnpm exec stacker new-projectFollow the prompts to configure your new project.
New Package
To create a new TypeScript package within the packages/ directory:
pnpm exec stacker new-packageFollow the prompts to define your new package.
New zRPC Service
To scaffold a new zRPC microservice within the apps/ directory:
pnpm exec stacker new-zrpc-serviceFollow the prompts to configure your new service (JavaScript or TypeScript).
Development
To add new commands or extend existing ones:
- Define your command and its options in
packages/cli/src/commands/definitions.tsusingCliCommandSchemaandCliOptionSchema. - Implement the command's logic in its associated handler function.
- The
CommandBuilderwill automatically register your new command with the CLI.
Refer to packages/cli/src/types/cli.ts for the schema definitions and packages/cli/src/utils/command-builder.ts for how commands are built and interactive prompts are handled.
