Commit c591211
authored
Add uninstall Mix task and its tests (#464)
* Add Mishka UI uninstall Mix task and tests
Introduces the `mix mishka.ui.uninstall` Mix task for removing Mishka Chelekom components from a Phoenix project, including smart JavaScript hook management, module prefix support, and optional CSS/config cleanup. Also adds comprehensive ExUnit tests covering argument validation, file removal, JS hook handling, dry-run mode, option aliases, and completion notices.
Add tests for --include-css and --include-config options
Extended the uninstall task tests to cover the new --include-css and --include-config options, ensuring CSS and config files are removed only when these flags are provided. Also added tests for -a/--all, -V/--verbose, and component dependency scenarios.
Update mishka.ui.uninstall.ex
* Add documentation for mix mishka.ui.uninstall task
Introduces detailed usage instructions, options, and examples for the new mix mishka.ui.uninstall task, including handling of JavaScript hooks, module prefix support, and full cleanup scenarios.
* Update mishka.ui.uninstall.ex
* Update mishka.ui.uninstall.ex
* Refactor mishka.ui.uninstall for clarity and modularity
Refactored the Mix.Tasks.Mishka.Ui.Uninstall module to improve code clarity, modularity, and maintainability. Extracted logic into smaller helper functions, reduced code duplication, and improved option handling. Enhanced the uninstall plan building, file removal, and output formatting. No changes to core uninstall logic or test coverage.
* Update mishka.ui.uninstall.ex
* Refactor JS module removal logic in uninstall task
Consolidated JS import and hook removal into a single helper function, streamlining the process of removing modules from JS content. Introduced a utility to handle JsParser results and updated usages to improve code clarity and maintainability.
* Update mishka.ui.uninstall.ex
* Refactor Mishka UI uninstall task for clarity and modularity
Streamlines the uninstall logic by consolidating option handling, reducing argument passing, and improving assignment of state via Igniter.assign. Refactors component and file removal flows for better readability and maintainability, and updates help text and output messages for clarity. This change also modularizes plan building, file operations, and output, making the codebase easier to extend and debug.
* Update mishka.ui.uninstall.ex
* Add --force flag to uninstall task for dependency override
Introduces a --force (-f) option to the mishka.ui.uninstall Mix task, allowing forced removal of components even if other components depend on them. Updates dependency handling logic to block removal with --yes unless --force is specified, and adds interactive prompts for cascading removal. Test coverage and documentation are updated to reflect the new behavior.
* Refactor component discovery and improve UX in uninstall task
Refactored the logic for finding installed components to use file-based discovery instead of module introspection, improving reliability. Enhanced the user experience for handling dependent components by integrating Owl.IO for interactive selection. Simplified confirmation logic and improved output formatting for removal plans and warnings.
* Refine uninstall logic and update usage docs
Improves conditional logic for CSS and config removal in the uninstall task, ensuring options are respected and notices are accurate. Updates documentation to clarify that --all is sufficient for full removal, removing redundant flags.
* Refactor uninstall task to improve dependency handling
Refactored Mix.Tasks.Mishka.Ui.Uninstall to simplify component config loading and dependency analysis. Removed unused code, consolidated config reading logic, and updated dependency warning checks to use preloaded configs. Added comprehensive tests for multiple and nested component dependencies in the uninstall process.
* Refactor uninstall choice handling and add tests
Extracted the uninstall choice logic into a new apply_cascade_choice/3 function for improved clarity and testability. Added comprehensive tests for all choice branches (:continue, :cancel, :cascade) to ensure correct behavior.
* Refactor import removal in do_update_import_macro
Updated do_update_import_macro to remove component imports by manipulating the AST instead of string replacement. This change improves reliability by directly editing the quote block in the __using__ macro, ensuring imports are accurately removed for specified modules.
* Improve MishkaComponents removal logic and add tests
Refines the filter logic to correctly identify and remove 'use MishkaComponents' statements by checking the last part of the module path. Adds comprehensive tests to ensure 'use MishkaComponents' is only removed from html_helpers when all related components are deleted, and remains when other components still exist.
* Refactor app.js cleanup in uninstall task for global --all
Update the uninstall task to explicitly remove MishkaComponents import and hook from app.js when all related components are removed. Add tests to verify correct cleanup and ensure app.js remains unchanged when other components still exist.
* Remove Mishka CSS imports and @theme blocks on uninstall
Enhanced the uninstall task to remove both the @import for mishka_chelekom.css and any @theme blocks from app.css. Added tests to verify that these blocks are removed, including multiline @theme blocks, while preserving other CSS content.
* Update deps and add CHANGELOG - 0.0.9-alpha.61 parent 65a1322 commit c591211
File tree
6 files changed
+1972
-6
lines changed- lib/mix/tasks
- test/mix/tasks
- usage-rules
6 files changed
+1972
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
0 commit comments