-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit a7ec8af
committed
feature #59464 [AssetMapper] Add
This PR was merged into the 7.3 branch.
Discussion
----------
[AssetMapper] Add `--dry-run` option on `importmap:require` command
| Q | A
| ------------- | ---
| Branch? | 7.3
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| License | MIT
We are working with `@smnandre` on several ideas to **improve AssetMapper DX**, focusing here on the `importmap:require` command.
Currently, there is no way to know in advance which dependent packages will be downloaded too, and the final output display lacks clarity.
This PR aims to solve both issues by adding a new `--dry-run` flag and reworking the command output (with `-v` verbosity)
<img width="845" alt="1" src="https://github.com/user-attachments/assets/26616802-f6f1-413f-9535-7a1a5205d277" />
<details><summary>Console output</summary>
```console
php bin/console importmap:require bootstrap --dry-run -v
[DRY-RUN] No changes will apply to the importmap configuration.
-------------------------------------- --------- ----------------------------------------------------
Package Version Path
-------------------------------------- --------- ----------------------------------------------------
bootstrap 5.3.3 assets/vendor/bootstrap/bootstrap.index.js
`@popperjs`/core 2.11.8 assets/vendor/`@popperjs`/core/core.index.js
bootstrap/dist/css/bootstrap.min.css 5.3.3 assets/vendor/bootstrap/dist/css/bootstrap.min.css
-------------------------------------- --------- ----------------------------------------------------
[OK] 3 new items (bootstrap, `@popperjs`/core, bootstrap/dist/css/bootstrap.min.css) added to the importmap.php!
[DRY-RUN] No changes applied to the importmap configuration.
```
</details>
## New `--dry-run` option
This flag allows developers to simulate the installation process, without any alteration:
- no modification of `importmap.php` file;
- no file added or updated in the `assets` and `public` directories.
The `--dry-run` flag allows developers to:
- **check** commands for **mistakes** (e.g., typing `bootrap` instead of `bootstrap`, or `jquery`);
- **list** dependent **packages** that will be installed (e.g., requiring `bootstrap` will also install ``@popperjs`/core`);
- **test** for potential issues while **downloading**[^1] files.
The console will display a line at start and end of execution to signal the dry-run mode.
<img width="845" alt="2" src="https://github.com/user-attachments/assets/4df6abc0-6205-410e-9039-8c4b37a41055" />
<details><summary>Console output</summary>
```bash
php bin/console importmap:require bootstrap --dry-run
[DRY-RUN] No changes will apply to the importmap configuration.
[OK] 3 new items (bootstrap, `@popperjs`/core, bootstrap/dist/css/bootstrap.min.css) added to the importmap.php!
[DRY-RUN] No changes applied to the importmap configuration.
```
</details>
## New `-v` verbose output
This PR also reworks the output for the `-v` (verbose) flag to provide more clarity when running the command with additional verbosity.
<img width="845" alt="3" src="https://github.com/user-attachments/assets/46ff8d22-887c-4900-b778-36d9aaac1512" />
---
All feedback welcome!
[^1]: AssetMapper recursively extracts the dependencies of JavaScript modules. Even with the `--dry-run` option, the `importmap:require` command requires a working `HttpClient` to download metadata and JavaScript files from various registries/repositories (mainly JSDelivr for now).
Commits
-------
337c4655f3f [AssetMapper] Add `--dry-run` option on `importmap:require` command--dry-run
option on importmap:require
command (chadyred)File tree
Expand file treeCollapse file tree
1 file changed
+1
-0
lines changedFilter options
- Resources/config
Expand file treeCollapse file tree
1 file changed
+1
-0
lines changedResources/config/asset_mapper.php
Copy file name to clipboardExpand all lines: Resources/config/asset_mapper.php+1Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
232 | 232 |
| |
233 | 233 |
| |
234 | 234 |
| |
| 235 | + | |
235 | 236 |
| |
236 | 237 |
| |
237 | 238 |
| |
|
0 commit comments