This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
versacommerce-cli is a Ruby gem providing a Command Line Interface tool for interacting with VersaCommerce Theme API services. The primary executable is vc-theme, which provides theme management capabilities (download, watch, upload).
Ruby Version: Requires Ruby >= 3.1.0 (upgraded from Ruby >= 2.0.0 in version 0.3.0)
bin/setupRuns bundle install and any additional automated setup.
bin/consoleOpens an interactive prompt for experimentation.
rake build # Build the gem
rake install # Install gem locally
rake release # Create git tag and push gem to RubyGemsbundle exec exe/vc-theme <command>Run the CLI directly from source without installing the gem.
ruby test/smoke_test.rbRuns basic smoke tests to verify CLI functionality.
exe/vc-theme- Executable entry point that loads and startsVersacommerce::CLI::Theme
The gem follows a simple modular architecture:
lib/versacommerce/cli.rb- Root module definitionlib/versacommerce/cli/version.rb- Version constant (update this when releasing)lib/versacommerce/cli/theme.rb- Main Thor-based CLI class with all command logiclib/versacommerce/cli/simple_logger.rb- Colorized logging utility
The Theme class inherits from Thor and implements three main commands:
- download - Downloads complete theme from Theme API to local directory
- watch - Uses Listen gem to monitor file changes and sync to Theme API in real-time
- upload - Recursively uploads directory tree to Theme API (delete then add for each file)
The CLI checks for authorization in this priority order:
--authorizationcommand line option--configexplicit config file pathconfig.ymlin current working directoryTHEME_AUTHORIZATIONenvironment variable~/.config/versacommerce/cli/config.yml(implicit global config)
This is implemented in the authorization method on lib/versacommerce/cli/theme.rb:156.
All commands follow a pattern:
- Ensure authorization exists (
ensure_authorization!) - Save config if
--save-configflag present - Validate path is a directory
- Perform operation using
versacommerce-theme_api_clientgem
The watch command uses Listen.to() with a block that handles modified/added/removed file arrays.
- thor (~> 1.3) - CLI framework for building command-line interfaces (upgraded from 0.19.1)
- listen (~> 3.9) - File system change monitoring for watch command (upgraded from ~> 2.10)
- colorize (~> 1.1) - Terminal color output for logger (upgraded from 0.7.5)
- versacommerce-theme_api_client (~> 0.1.3) - API client for VersaCommerce Theme API
Note: For local development, the Gemfile references the local versacommerce-theme_api_client gem to use the Ruby 3.1+ compatible version.
Update lib/versacommerce/cli/version.rb with new version number before releasing.
Current version: 0.3.0 (Ruby 3.1+ support, dependency updates, security fixes)
- Updated Ruby requirement from >= 2.0.0 to >= 3.1.0
- Fixed YAML.load_file security vulnerabilities (3 instances in theme.rb)
- Now uses
YAML.load_file(path, permitted_classes: [Symbol])for safe loading
- Now uses
- Modernized string interpolation from % formatting to #{} syntax
- Fixed Thor 1.x compatibility issues:
- Changed Pathname default values to strings
- Added
exit_on_failure?method
- Updated all dependencies to Ruby 3.1+ compatible versions
- Added basic smoke tests in
test/smoke_test.rb - Tests verify CLI loading, help commands, and YAML config loading