Skip to content

Commit fdb9bef

Browse files
committed
Initial version 0.1
1 parent be0e64f commit fdb9bef

File tree

10 files changed

+819
-28
lines changed

10 files changed

+819
-28
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ venv
77
.pytest_cache
88
*.egg-info
99
.DS_Store
10+
.env*
11+
components/
12+
layouts/
13+
styles/
14+
devhub.conf.json
15+
docs-examples/

README.md

Lines changed: 94 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# devhub
22

3-
[![PyPI](https://img.shields.io/pypi/v/devhub.svg)](https://pypi.org/project/devhub/)
4-
[![Changelog](https://img.shields.io/github/v/release/devhub/devhub?include_prereleases&label=changelog)](https://github.com/devhub/devhub/releases)
5-
[![Tests](https://github.com/devhub/devhub/actions/workflows/test.yml/badge.svg)](https://github.com/devhub/devhub/actions/workflows/test.yml)
6-
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/devhub/devhub/blob/master/LICENSE)
3+
[![PyPI](https://img.shields.io/pypi/v/devhub.svg)](https://pypi.org/project/devhub-cli/)
4+
[![Changelog](https://img.shields.io/github/v/release/devhub/devhub-cli?include_prereleases&label=changelog)](https://github.com/devhub/devhub-cli/releases)
5+
[![Tests](https://github.com/devhub/devhub-cli/actions/workflows/test.yml/badge.svg)](https://github.com/devhub/devhub-cli/actions/workflows/test.yml)
6+
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/devhub/devhub-cli/blob/master/LICENSE)
77

88
CLI interface to devhub
99

1010
## Installation
1111

1212
Install this tool using `pip`:
1313
```bash
14-
pip install devhub
14+
pip install devhub-cli
1515
```
1616
## Usage
1717

@@ -23,11 +23,99 @@ You can also use:
2323
```bash
2424
python -m devhub --help
2525
```
26+
27+
## Theme Commands
28+
29+
The DevHub CLI provides powerful theme management capabilities for synchronizing and managing your DevHub theme components locally.
30+
31+
### Initial Setup
32+
33+
Before using theme commands, you need to initialize your environment:
34+
35+
```bash
36+
devhub theme init
37+
```
38+
39+
This command will:
40+
- Create a `.env` file with your DevHub API credentials
41+
- Generate a `.gitignore` file with appropriate exclusions
42+
- Create a `devhub.conf.json` configuration file
43+
44+
You'll be prompted to enter:
45+
- `DEVHUB_API_KEY` - Your OAuth1 API key
46+
- `DEVHUB_API_SECRET` - Your OAuth1 API secret
47+
- `DEVHUB_BASE_URL` - Your DevHub instance URL (e.g., https://yourbrand.cloudfrontend.net)
48+
- `DEVHUB_SITE_ID` - Your site identifier
49+
50+
### Available Commands
51+
52+
#### `devhub theme list`
53+
Lists all available theme templates and components that can be synchronized.
54+
55+
```bash
56+
devhub theme list
57+
```
58+
59+
#### `devhub theme status`
60+
Shows the synchronization status of all theme components, indicating which files have changes compared to the remote version.
61+
62+
```bash
63+
devhub theme status
64+
```
65+
66+
#### `devhub theme sync`
67+
Synchronizes theme components from your DevHub instance to local files.
68+
69+
```bash
70+
# Sync all components
71+
devhub theme sync
72+
73+
# Sync specific components only
74+
devhub theme sync layouts/headers/DefaultHeader.html components/HeroSection/HeroSection.jinja
75+
```
76+
77+
The sync command will:
78+
- Download theme files (CSS, headers, footers, localization) to the `layouts/` directory
79+
- Download template components to the `components/` directory as `.jinja` files
80+
- Format templates using `djlint` with 2-space indentation
81+
- Convert component names from slug-case to PascalCase (e.g., `hero-section``HeroSection.jinja`)
82+
- Perform checksum comparison to detect conflicts between local and remote changes
83+
84+
### Project Structure
85+
86+
After initialization and synchronization, your project structure will look like:
87+
88+
```
89+
your-project/
90+
├── .env # Environment variables (not committed)
91+
├── .gitignore # Git exclusions
92+
├── devhub.conf.json # CLI configuration
93+
├── layouts/ # Theme templates (headers, footers, CSS)
94+
│ ├── headers/DefaultHeader.jinja
95+
│ ├── footers/DefaultFooter.jinja
96+
├── styles/ # CSS styles
97+
│ └── globals.css
98+
└── components/ # Template components
99+
├── HeroSection/HeroSection.jinja
100+
├── ProductCard/ProductCard.jinja
101+
└── NavigationMenu/NavigationMenu.jinja
102+
```
103+
104+
### Authentication & Environment
105+
106+
The CLI uses OAuth1 authentication to connect to your DevHub instance. All sensitive credentials are stored in the `.env` file, which should never be committed to version control.
107+
108+
Required environment variables:
109+
- `DEVHUB_API_KEY` - OAuth1 API key
110+
- `DEVHUB_API_SECRET` - OAuth1 API secret
111+
- `DEVHUB_BASE_URL` - Base URL for DevHub API
112+
- `DEVHUB_SITE_ID` - Site identifier
113+
26114
## Development
27115

28116
To contribute to this tool, first checkout the code. Then create a new virtual environment:
29117
```bash
30-
cd devhub
118+
cd devhub-cli
31119
python -m venv venv
32120
source venv/bin/activate
33121
```

devhub/cli.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import click
2+
from dotenv import load_dotenv
3+
import os
4+
5+
from .commands.theme import theme
6+
7+
if 'WORKING_DIR' not in os.environ:
8+
# auto-set the working directory
9+
os.environ['WORKING_DIR'] = os.getcwd()
10+
11+
dotenv_path = os.path.abspath(
12+
os.path.join(os.environ['WORKING_DIR'], '.env'))
13+
load_dotenv(dotenv_path=dotenv_path)
214

315

416
@click.group()
5-
@click.version_option()
17+
@click.version_option(package_name='devhub-cli', prog_name='devhub-cli')
618
def cli():
719
"CLI interface to devhub"
820

9-
10-
@cli.command(name="command")
11-
@click.argument(
12-
"example"
13-
)
14-
@click.option(
15-
"-o",
16-
"--option",
17-
help="An example option",
18-
)
19-
def first_command(example, option):
20-
"Command description goes here"
21-
click.echo("Here is some output")
21+
cli.add_command(theme)

devhub/commands/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)