@dscodotco/theme-cli
Version:
A CLI tool for developing Shopify themes
225 lines (169 loc) • 5.07 kB
Markdown
# CLI Commands Reference
This document provides detailed information about all available Theme CLI commands.
## Global Options
These options are available for all commands:
```bash
--help # Show help information for any command
--version # Show Theme CLI version
--debug # Enable debug logging
--verbose # Enable verbose output
--config <path> # Specify a custom config file
```
## Theme Commands
### Initialize Theme
Creates a new Shopify theme project.
```bash
theme-cli init [name] [options]
Options:
--template <name> # Use a specific theme template (default: "blank")
--typescript # Initialize with TypeScript support
--force # Overwrite existing directory
```
Example:
```bash
# Create a new theme with TypeScript
theme-cli init my-theme --typescript
# Use a specific template
theme-cli init my-theme --template dawn
```
### Development Server
Start a local development server for theme preview and hot reloading.
```bash
theme-cli dev [options]
Options:
-s, --store <name> # Shopify store name (required)
-k, --api-key <key> # Shopify Admin API key (required)
-p, --password <token> # Shopify Admin API password/token (required)
-t, --theme-id <id> # Existing theme ID to use
-n, --theme-name <name># Name for development theme
-d, --theme-dir <path> # Theme directory (default: current)
--port <number> # Port for preview server (default: 3000)
--https # Enable HTTPS
--no-watch # Disable file watching
```
Example:
```bash
# Start server with existing theme
theme-cli dev -s my-store -k api_key -p shpat_token -t 123456789
# Create new development theme
theme-cli dev -s my-store -k api_key -p shpat_token -n "Dev Theme"
```
### Deploy Theme
Deploy your theme to Shopify.
```bash
theme-cli deploy [options]
Options:
-s, --store <name> # Shopify store name (required)
-k, --api-key <key> # Shopify Admin API key (required)
-p, --password <token> # Shopify Admin API password/token (required)
-t, --theme-id <id> # Target theme ID (required)
--files <pattern> # Deploy specific files (glob pattern)
--backup # Create backup before deploying
--force # Skip confirmation prompt
```
Example:
```bash
# Deploy entire theme
theme-cli deploy -s my-store -k api_key -p shpat_token -t 123456789
# Deploy specific files with backup
theme-cli deploy -s my-store -k api_key -p shpat_token -t 123456789 --files "templates/*" --backup
```
### Theme Check
Run theme linting and validation.
```bash
theme-cli check [options]
Options:
-d, --theme-dir <path> # Theme directory to check
--fix # Automatically fix issues
--output <format> # Output format (text, json)
```
Example:
```bash
# Check current theme
theme-cli check
# Auto-fix issues
theme-cli check --fix
```
### Theme Package
Package your theme for the Shopify Theme Store.
```bash
theme-cli package [options]
Options:
-d, --theme-dir <path> # Theme directory to package
-o, --output <path> # Output directory
--minify # Minify assets
--zip # Create ZIP archive
```
Example:
```bash
# Package theme with minification
theme-cli package --minify --zip
```
## Development Scripts
The Theme CLI project includes several development scripts:
### Local Theme Development
```bash
npm run theme:dev
# or
yarn theme:dev
```
This script (`scripts/local-theme-dev.sh`):
1. Builds the project
2. Tests the Shopify API connection
3. Initializes a new theme
4. Starts the development server
### Project Setup
```bash
npm run setup
# or
yarn setup
```
This script (`scripts/project-setup.sh`):
1. Installs dependencies
2. Sets up development environment
3. Links the CLI locally
### Theme Development with npm
```bash
npm run theme:dev:npm
# or
yarn theme:dev:npm
```
This script (`scripts/setup-theme-dev.sh`):
1. Uses the published npm package
2. Sets up a new theme project
3. Starts the development server
## Configuration
### Environment Variables
Required variables in your `.env` file:
```env
SHOPIFY_STORE=your-store # Store name without .myshopify.com
SHOPIFY_API_KEY=your_api_key # Admin API key
SHOPIFY_PASSWORD=your_password # Admin API password/token
SHOPIFY_THEME_ID=123456789 # Optional: Existing theme ID
```
### Theme Configuration
Create a `theme.config.js` in your theme directory:
```javascript
module.exports = {
development: {
store: process.env.SHOPIFY_STORE,
themeId: process.env.SHOPIFY_THEME_ID,
password: process.env.SHOPIFY_PASSWORD,
ignore: ['settings_data.json'],
deployIgnore: ['node_modules', '.git']
},
production: {
// Production-specific settings
}
};
```
## Troubleshooting
If you encounter issues:
1. Check your credentials in `.env`
2. Ensure you have the required API scopes
3. Try running with `--debug` flag
4. Check the [Troubleshooting Guide](./troubleshooting.md)
For more detailed information about specific commands, use:
```bash
theme-cli [command] --help
```