Skip to content

Commit b619baf

Browse files
Copilotdermatz
andcommitted
#feature-request - Update documentation for static:clean command
Co-authored-by: dermatz <6103201+dermatz@users.noreply.github.com>
1 parent 607b81f commit b619baf

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Please ensure that your Magento installation meets this requirement before insta
3737
| `mageforge:theme:list` | Lists all available themes | `m:t:l` |
3838
| `mageforge:theme:build` | Builds selected themes (CSS/TailwindCSS) | `m:t:b`, `frontend:build` |
3939
| `mageforge:theme:watch` | Starts watch mode for theme development | `m:t:w`, `frontend:watch` |
40+
| `mageforge:static:clean` | Cleans static files for specific theme(s) | `m:st:c` |
4041

4142
---
4243

docs/commands.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,52 @@ bin/magento mageforge:version
130130
- Fetches the latest version from GitHub API
131131
- Displays both versions for comparison
132132

133+
---
134+
135+
### 6. CleanCommand (`mageforge:static:clean`)
136+
137+
**Purpose**: Cleans static files from `var/view_preprocessed` and `pub/static` directories for specific theme(s).
138+
139+
**File**: `/src/Console/Command/Static/CleanCommand.php`
140+
141+
**Dependencies**:
142+
- `ThemeList` - Service to retrieve theme information
143+
- `Filesystem` - Magento filesystem component for directory operations
144+
145+
**Usage**:
146+
```bash
147+
bin/magento mageforge:static:clean [<themeCodes>...]
148+
```
149+
150+
**Examples**:
151+
```bash
152+
# Clean a single theme
153+
bin/magento mageforge:static:clean Magento/luma
154+
155+
# Clean multiple themes
156+
bin/magento mageforge:static:clean Magento/luma Vendor/custom-theme
157+
158+
# Show available themes (when no theme code provided)
159+
bin/magento mageforge:static:clean
160+
```
161+
162+
**Implementation Details**:
163+
- If no theme codes are provided, displays available themes and usage information
164+
- For each specified theme:
165+
1. Validates that the theme exists
166+
2. Cleans matching directories from `var/view_preprocessed/`
167+
3. Cleans matching directories from `pub/static/`
168+
4. Uses pattern matching to find theme-specific directories (e.g., `frontend/Vendor/theme`)
169+
- Displays a summary showing which themes were successfully cleaned
170+
- Uses recursive directory removal with proper error handling
171+
- Returns success status even if some operations fail (with appropriate error messages)
172+
173+
**Use Cases**:
174+
- Clear generated static files before a fresh build
175+
- Remove old static files after theme updates
176+
- Clean up disk space by removing unnecessary cached files
177+
- Troubleshoot theme-related issues by clearing all cached assets
178+
133179
## Command Services
134180

135181
The commands rely on several services for their functionality:

0 commit comments

Comments
 (0)