Skip to content

Commit bbd02a9

Browse files
CopilotdermatzCopilot
authored
Add mageforge:static:clean command for comprehensive cache and generated files cleanup (#56)
* Initial plan * Add mageforge:static:clean command implementation Co-authored-by: dermatz <[email protected]> * Update documentation for static:clean command Co-authored-by: dermatz <[email protected]> * Refactor: Extract theme name parsing logic to reduce duplication Co-authored-by: dermatz <[email protected]> * Remove invalid shortcode from README for static:clean command Co-authored-by: dermatz <[email protected]> * Add cleaning of var/page_cache, var/tmp and generated directories Co-authored-by: dermatz <[email protected]> * Fix cleanGenerated to track successful deletions properly Co-authored-by: dermatz <[email protected]> * ✨ feat: enhance CleanCommand with multi-theme support and dry-run option * ✨ feat: add dry-run option and aliases for static clean command * ✨ feat: add mageforge:static:clean command and multi-theme support * Update docs/commands.md Co-authored-by: Copilot <[email protected]> * Update CHANGELOG.md Co-authored-by: Copilot <[email protected]> * Update src/Console/Command/Static/CleanCommand.php Co-authored-by: Copilot <[email protected]> * Update README.md Co-authored-by: Copilot <[email protected]> * Update .github/workflows/magento-compatibility.yml Co-authored-by: Copilot <[email protected]> * Update .github/workflows/magento-compatibility.yml Co-authored-by: Copilot <[email protected]> * Update src/Console/Command/Static/CleanCommand.php Co-authored-by: Copilot <[email protected]> * Update src/Console/Command/Static/CleanCommand.php Co-authored-by: Copilot <[email protected]> * Update docs/commands.md Co-authored-by: Copilot <[email protected]> * Update src/Console/Command/Static/CleanCommand.php Co-authored-by: Copilot <[email protected]> * Fix getCachedEnvironmentVariables to use class-level static variable Co-authored-by: dermatz <[email protected]> * 🔧 fix: correct alias for MageForge Static Clean command --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: dermatz <[email protected]> Co-authored-by: Mathias Elle <[email protected]> Co-authored-by: Mathias Elle <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 7517e5c commit bbd02a9

File tree

6 files changed

+941
-2
lines changed

6 files changed

+941
-2
lines changed

.github/workflows/magento-compatibility.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ jobs:
134134
echo "Test MageForge Theme List command:"
135135
bin/magento mageforge:theme:list
136136
137+
echo "Test MageForge Static Clean command with dry-run:"
138+
bin/magento mageforge:static:clean --all --dry-run
139+
140+
echo "Test MageForge Static Clean aliases:"
141+
bin/magento mageforge:static:clean --all --dry-run
142+
echo "Test MageForge Static Clean aliases:"
143+
bin/magento m:st:c --help
144+
bin/magento frontend:clean --help
145+
137146
- name: Test Summary
138147
run: |
139148
echo "MageForge module compatibility test with Magento ${{ matrix.magento-version }} completed"
@@ -255,6 +264,13 @@ jobs:
255264
echo "Test MageForge Theme List command:"
256265
bin/magento mageforge:theme:list
257266
267+
echo "Test MageForge Static Clean command with dry-run:"
268+
bin/magento mageforge:static:clean --all --dry-run
269+
270+
echo "Test MageForge Static Clean alias:"
271+
bin/magento m:st:c --help
272+
bin/magento frontend:clean --help
273+
258274
- name: Test Summary
259275
run: |
260276
echo "MageForge module compatibility test with Magento 2.4.8 completed"

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ All notable changes to this project will be documented in this file.
66

77
## UNRELEASED
88

9+
### Added
10+
11+
- feat: add `mageforge:static:clean` command for comprehensive cache and generated files cleanup
12+
- feat: add interactive multi-theme selection for static:clean command using Laravel Prompts
13+
- feat: add `--all` option to clean all themes at once
14+
- feat: add `--dry-run` option to preview what would be cleaned without deleting
15+
- feat: add command alias `frontend:clean` for quick access
16+
- feat: add CI/CD tests for static:clean command in compatibility workflow
17+
18+
### Changed
19+
20+
- refactor: split complex executeCommand method into smaller, focused methods to reduce cyclomatic complexity
21+
- docs: update copilot-instructions.md with CI/CD integration guidelines for new commands
22+
923
## Latest Release
1024

1125
### [0.2.2] - 2025-06-05

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` | Clean static files, cache and generated files for a theme | `frontend:clean` |
4041

4142
---
4243

docs/commands.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,41 @@ bin/magento mageforge:theme:watch [--theme=THEME]
8585

8686
---
8787

88-
### 4. SystemCheckCommand (`mageforge:system:check`)
88+
### 4. CleanCommand (`mageforge:static:clean`)
89+
90+
**Purpose**: Cleans var/view_preprocessed, pub/static, var/page_cache, var/tmp and generated directories for specific theme.
91+
92+
**File**: `/src/Console/Command/Static/CleanCommand.php`
93+
94+
**Dependencies**:
95+
- `Filesystem` - Magento filesystem component for file operations
96+
- `ThemeList` - Service to retrieve theme information
97+
- `ThemePath` - Service to resolve theme paths
98+
99+
**Usage**:
100+
```bash
101+
bin/magento mageforge:static:clean [<themename>]
102+
```
103+
104+
**Implementation Details**:
105+
- If no theme name is provided:
106+
- In interactive terminals, displays an interactive prompt to select the theme to clean
107+
- In non-interactive environments, prints the list of available themes and exits, requiring an explicit theme name
108+
- Validates that the specified theme exists
109+
- Cleans the following directories for the theme:
110+
- `var/view_preprocessed/css/frontend/Vendor/theme`
111+
- `var/view_preprocessed/source/frontend/Vendor/theme`
112+
- `pub/static/frontend/Vendor/theme`
113+
- Additionally cleans these global directories:
114+
- `var/page_cache/*`
115+
- `var/tmp/*`
116+
- `generated/*`
117+
- Displays a summary of cleaned directories
118+
- Returns success status code
119+
120+
---
121+
122+
### 5. SystemCheckCommand (`mageforge:system:check`)
89123

90124
**Purpose**: Displays system information relevant to Magento development.
91125

@@ -111,7 +145,7 @@ bin/magento mageforge:system:check
111145

112146
---
113147

114-
### 5. VersionCommand (`mageforge:version`)
148+
### 6. VersionCommand (`mageforge:version`)
115149

116150
**Purpose**: Displays the current and latest version of the MageForge module.
117151

0 commit comments

Comments
 (0)