Official CLI tool for Sealos Cloud - Manage devbox, applications, databases, and object storage
src/
├── bin/
│ └── cli.ts # CLI entry point
├── commands/ # Command modules
│ ├── auth/ # Authentication commands
│ │ ├── login.ts
│ │ ├── logout.ts
│ │ ├── whoami.ts
│ │ └── index.ts
│ ├── workspace/ # Workspace management
│ │ └── index.ts
│ ├── devbox/ # Devbox management
│ │ └── index.ts
│ ├── s3/ # S3 object storage
│ │ └── index.ts
│ ├── database/ # Database management
│ │ └── index.ts
│ ├── template/ # Template management
│ │ └── index.ts
│ ├── quota/ # Resource quotas
│ │ └── index.ts
│ ├── app/ # Application management
│ │ └── index.ts
│ └── config/ # CLI configuration
│ └── index.ts
├── lib/ # Shared libraries
│ ├── api.ts # API client
│ ├── config.ts # Configuration management
│ ├── errors.ts # Error handling
│ └── output.ts # Output formatting
├── types/ # TypeScript type definitions
│ └── index.ts
└── main.ts # Main program setup
- Manages CLI configuration at
~/.sealos/config.json - Handles multiple contexts (hosts/workspaces)
- Supports environment variables (e.g.,
KUBECONFIG)
- Axios-based HTTP client with interceptors
- Automatic token injection from current context
- Unified error handling
- Support for KUBECONFIG environment variable
- Support for multiple formats: JSON, YAML, Table
- Colored terminal output using chalk
- Loading spinners using ora
- Table formatting using table
- Typed error classes (AuthError, ConfigError, ApiError)
- Global error handler
- User-friendly error messages
npm installnpm start -- <command>
# Examples:
npm start -- --help
npm start -- login
npm start -- devbox listnpm run buildnpm test# Login with token
sealos login hzh.sealos.run --token YOUR_TOKEN
# Check current user
sealos whoami
# Logout
sealos logout# List workspaces
sealos workspace list
# Switch workspace
sealos workspace switch production
# Show current workspace
sealos workspace current# Create a devbox
sealos devbox create --name my-devbox --template nextjs --cpu 2c --memory 4g
# List devboxes
sealos devbox list
sealos devbox list --output json
# Get devbox details
sealos devbox get my-devbox
# Connect to devbox
sealos devbox connect my-devbox --ide cursor
# Start/Stop/Restart
sealos devbox start my-devbox
sealos devbox stop my-devbox
sealos devbox restart my-devbox
# Delete devbox
sealos devbox delete my-devbox --force# List all config
sealos config list
# Get config value
sealos config get currentContext
# Set config value
sealos config set key valueKUBECONFIG: Path to Kubernetes config file (automatically included in API requests)DEBUG: Enable debug mode for verbose error output
Most command implementations contain TODO comments indicating where API integration is needed. Key areas:
- Authentication: OAuth flow for browser-based login
- API Integration: Connect all commands to actual Sealos API endpoints
- S3 Operations: File upload/download with progress tracking
- Database Management: Full CRUD operations
- Interactive Prompts: Use inquirer for confirmations
- YAML Support: Add YAML output formatting
- Config Nesting: Support nested config key access
- Modular command structure
- TypeScript for type safety
- Shared utilities for common operations
- Consistent error handling
- Multiple output formats
- Environment variable support
- Configuration file management
- Loading indicators for async operations
- Color-coded terminal output
Apache-2.0