Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,20 @@ The DevHub CLI provides powerful theme management capabilities for synchronizing
Before using theme commands, you need to initialize your environment:

```bash
# Initialize in current directory
devhub theme init

# Initialize in a new directory
devhub theme init mybrand-corporate-theme
```

This command will:
- Create a `.env` file with your DevHub API credentials
- Generate a `.gitignore` file with appropriate exclusions
- Create a `devhub.conf.json` configuration file

When specifying a directory, the command will create the directory if it doesn't exist and initialize all configuration files within it.

You'll be prompted to enter:
- `DEVHUB_API_KEY` - Your OAuth1 API key
- `DEVHUB_API_SECRET` - Your OAuth1 API secret
Expand Down
36 changes: 31 additions & 5 deletions devhub/commands/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,39 @@ def init_config():


@theme.command()
def init():
@click.argument('directory', required=False)
def init(directory):
"""Initialize theme environment configuration."""
click.echo(click.style('Initializing DevHub environment configuration...', fg='green'))
original_working_dir = os.environ.get('WORKING_DIR', os.getcwd())

if directory:
# Check if directory already exists
if os.path.exists(directory):
click.echo(click.style(f'Error: Directory "{directory}" already exists', fg='red'))
return

# Create the directory
try:
os.makedirs(directory, exist_ok=False)
click.echo(click.style(f'Created directory: {directory}', fg='green'))
except OSError as e:
click.echo(click.style(f'Error creating directory "{directory}": {e}', fg='red'))
return

# Update WORKING_DIR to the new directory
absolute_directory = os.path.abspath(directory)
os.environ['WORKING_DIR'] = absolute_directory
click.echo(click.style(f'Initializing DevHub environment configuration in {absolute_directory}...', fg='green'))
else:
click.echo(click.style('Initializing DevHub environment configuration...', fg='green'))

init_env()
init_gitignore()
init_config()
try:
init_env()
init_gitignore()
init_config()
finally:
# Restore original WORKING_DIR
os.environ['WORKING_DIR'] = original_working_dir


@theme.command()
Expand Down