Skip to content

Commit 1c59d9b

Browse files
committed
feat: add comprehensive documentation for MageForge commands and custom ThemeBuilders
1 parent 753685a commit 1c59d9b

File tree

3 files changed

+553
-49
lines changed

3 files changed

+553
-49
lines changed

docs/commands.md

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# MageForge Commands Documentation
2+
3+
This document provides a comprehensive overview of all commands available in the MageForge module. It's designed to help developers understand the structure and functionality of each command.
4+
5+
## Command Architecture
6+
7+
All commands in MageForge follow a consistent structure based on Symfony's Console Component. They extend the `Symfony\Component\Console\Command\Command` class and implement:
8+
9+
- A constructor that injects dependencies
10+
- A `configure()` method that sets the command name, description, and arguments/options
11+
- An `execute()` method that handles the command logic
12+
13+
## Available Commands
14+
15+
### 1. ListThemeCommand (`mageforge:theme:list`)
16+
17+
**Purpose**: Lists all available Magento themes in the installation.
18+
19+
**File**: `/src/Console/Command/ListThemeCommand.php`
20+
21+
**Dependencies**:
22+
- `ThemeList` - Service to retrieve theme information
23+
24+
**Usage**:
25+
```bash
26+
bin/magento mageforge:theme:list
27+
```
28+
29+
**Implementation Details**:
30+
- Retrieves all themes from the `ThemeList` service
31+
- Displays a formatted table with theme information (code, title, path)
32+
- Returns success status code
33+
34+
---
35+
36+
### 2. BuildThemeCommand (`mageforge:theme:build`)
37+
38+
**Purpose**: Builds specified Magento themes by compiling assets and deploying static content.
39+
40+
**File**: `/src/Console/Command/BuildThemeCommand.php`
41+
42+
**Dependencies**:
43+
- `ThemePath` - Service to resolve theme paths
44+
- `ThemeList` - Service to retrieve theme information
45+
- `BuilderPool` - Service to get appropriate builders for themes
46+
47+
**Usage**:
48+
```bash
49+
bin/magento mageforge:theme:build [<themeCodes>...]
50+
```
51+
52+
**Implementation Details**:
53+
- If no theme codes are provided, displays an interactive prompt to select themes
54+
- For each selected theme:
55+
1. Resolves the theme path
56+
2. Determines the appropriate builder for the theme type
57+
3. Executes the build process
58+
- Displays a summary of built themes and execution time
59+
- Has an alias: `frontend:build`
60+
61+
---
62+
63+
### 3. ThemeWatchCommand (`mageforge:theme:watch`)
64+
65+
**Purpose**: Watches theme files for changes and automatically rebuilds when changes are detected.
66+
67+
**File**: `/src/Console/Command/ThemeWatchCommand.php`
68+
69+
**Dependencies**:
70+
- `BuilderPool` - Service to get appropriate builders for themes
71+
- `ThemeList` - Service to retrieve theme information
72+
- `ThemePath` - Service to resolve theme paths
73+
74+
**Usage**:
75+
```bash
76+
bin/magento mageforge:theme:watch [--theme=THEME]
77+
```
78+
79+
**Implementation Details**:
80+
- If no theme code is provided, displays an interactive prompt to select a theme
81+
- Resolves the theme path
82+
- Determines the appropriate builder for the theme type
83+
- Starts a watch process that monitors for file changes
84+
- Has an alias: `frontend:watch`
85+
86+
---
87+
88+
### 4. SystemCheckCommand (`mageforge:system:check`)
89+
90+
**Purpose**: Displays system information relevant to Magento development.
91+
92+
**File**: `/src/Console/Command/SystemCheckCommand.php`
93+
94+
**Dependencies**:
95+
- `ProductMetadataInterface` - For retrieving Magento version
96+
- `Escaper` - For HTML escaping output
97+
98+
**Usage**:
99+
```bash
100+
bin/magento mageforge:system:check
101+
```
102+
103+
**Implementation Details**:
104+
- Retrieves and displays:
105+
- PHP version
106+
- Node.js version (with comparison to latest LTS)
107+
- MySQL version
108+
- Operating System information
109+
- Magento version
110+
- Utilizes Symfony's table component for formatted output
111+
112+
---
113+
114+
### 5. VersionCommand (`mageforge:version`)
115+
116+
**Purpose**: Displays the current and latest version of the MageForge module.
117+
118+
**File**: `/src/Console/Command/VersionCommand.php`
119+
120+
**Dependencies**:
121+
- `File` - Filesystem driver for reading files
122+
123+
**Usage**:
124+
```bash
125+
bin/magento mageforge:version
126+
```
127+
128+
**Implementation Details**:
129+
- Reads the current module version from `composer.lock`
130+
- Fetches the latest version from GitHub API
131+
- Displays both versions for comparison
132+
133+
## Command Services
134+
135+
The commands rely on several services for their functionality:
136+
137+
### Builder Services
138+
- `BuilderPool`: Manages theme builders and selects appropriate builders for themes
139+
- `BuilderInterface`: Implemented by all theme builders
140+
- `MagentoStandard\Builder`: Processes standard Magento LESS-based themes
141+
- Various other builders for different theme types
142+
143+
### Theme Services
144+
- `ThemeList`: Retrieves all installed themes
145+
- `ThemePath`: Resolves theme codes to filesystem paths
146+
- `StaticContentDeployer`: Handles static content deployment
147+
- `CacheCleaner`: Manages cache cleaning after theme builds
148+
149+
### Utility Services
150+
- `DependencyChecker`: Verifies required dependencies for theme building
151+
- `GruntTaskRunner`: Executes Grunt tasks for theme compilation
152+
153+
## Command Execution Flow
154+
155+
1. The command is executed via the Magento CLI framework
156+
2. Dependencies are injected via constructor
157+
3. Arguments and options are processed
158+
4. Interactive prompts are shown if required
159+
5. The appropriate services are called to perform the command's task
160+
6. Formatted output is displayed to the user
161+
7. A status code is returned (success or failure)
162+
163+
## Error Handling
164+
165+
All commands implement error handling via try-catch blocks and return appropriate error messages and status codes when failures occur. Interactive commands also provide suggestions for resolving issues.

0 commit comments

Comments
 (0)