Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[AssetMapper] Adding debug:assetmap command + normalize paths#50219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:6.3fromweaverryan:asset-mapper-debug-command
May 5, 2023

Conversation

@weaverryan
Copy link
Member

@weaverryanweaverryan commentedMay 2, 2023
edited
Loading

QA
Branch?6.3
Bug fix?no
New feature?yes
Deprecations?no
TicketsNone
LicenseMIT
Doc PRDocs are TODO already for the component

For UX, those packages will add their own namespaced paths to the "asset mapper" to make their Stimulus controllers available. So, between your own paths and automatically-added paths, having a way to visualize everything seems helpful.

Screenshot 2023-05-02 at 4 15 49 PM

ALSO

This PR normalizes the paths in asset mapper in 2 ways:

A) Use/ always for logical path - e.g. you would useasset('images/foo.png') everywhere... you wouldn't sayasset('images\\foo.png') on Windows
B) All absolute paths are converted withrealpath internally. We do some "directory comparisons" (e.g. is/var/foo inside of/var/foo/bar) so having real paths consistently everywhere keeps this working.

Tests added for all of these changes

Cheers!


$pathRows = [];
foreach ($this->assetMapperRepository->allDirectories()as$path =>$namespace) {
$path =$this->relativizePath($path);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We could makeAssetMapperRepository::getRepositories() able to return the relative paths with some bool argument or even a new method. No big deal though, fine as is

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That's true - we already have the projectRootDir there. I don't feel too strongly either way :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

if only the debug command needs that, I would keep it in the bug command for now

$file =rtrim($path,'/').'/'.$localLogicalPath;
if (file_exists($file)) {
return$file;
returnrealpath($file);
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Usingrealpath everywhere now in this file so that all paths use the "real" path. That's just "nice" because you'll get back full paths - instead of potentially getting back file paths like/var/something/else/../other-path/app.js - and is important especially forfindLogicalPath() where we pass in a$filesystemPath and then do some matching by the filesystem path.

@weaverryan
Copy link
MemberAuthor

.. checking on one other edge case bug fix for the repository...

@weaverryanweaverryan changed the title[AssetMapper] Adding debug:assetmap command[AssetMapper] Adding debug:assetmap command + normalize pathsMay 3, 2023
@weaverryan
Copy link
MemberAuthor

Ok, this is ready - test failures are unrelated.

Copy link
Member

@fabpotfabpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Some small suggestions.

@weaverryanweaverryanforce-pushed theasset-mapper-debug-command branch from4807b8b toe990cd1CompareMay 5, 2023 09:59
@weaverryan
Copy link
MemberAuthor

This is ready for merge - 2 test failures are unrelated. Thanks for the feedback!

@fabpotfabpotforce-pushed theasset-mapper-debug-command branch frome990cd1 to7f48565CompareMay 5, 2023 10:34
@fabpot
Copy link
Member

Thank you@weaverryan.

@fabpotfabpot merged commit4cc4973 intosymfony:6.3May 5, 2023
@weaverryanweaverryan deleted the asset-mapper-debug-command branchMay 5, 2023 16:45
nicolas-grekas added a commit that referenced this pull requestMay 5, 2023
… and importmaps (weaverryan)This PR was squashed before being merged into the 6.3 branch.Discussion----------[AssetMapper] Fixing 2 bugs related to the compile command and importmaps| Q             | A| ------------- | ---| Branch?       | 6.3| Bug fix?      | yes| New feature?  | no| Deprecations? | none| Tickets       | none| License       | MIT| Doc PR        | not neededFixes 2 bugs:A) Running `assetmap:compile` gives you a `public/assets/importmap.json` for fast importmap dumping on production. But, running `assetmap:compile` again later would re-use the `importmap.json` info to create the new `importmap.json`... meaning it would never update after the first compile.B) The importmap process generates 2 pieces of information: (A) the importmap and (B) which files from the importmap should be preloaded. When we use `assetmap:compile`, we need to dump both pieces of info. So, we now also dump an `importmap.preload.json` file. These are TWO files (and not just one) because we avoid parsing `importmap.json` at runtime: we read the file and dump it straight out. We DO need to parse the "preload" file. So, I've kept them separate.Blocked by#50219, which has some changes that will fix the tests here.Cheers!Commits-------f9f7274 [AssetMapper] Fixing 2 bugs related to the compile command and importmaps
@fabpotfabpot mentioned this pull requestMay 7, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof approved these changes

@chalasrchalasrchalasr left review comments

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.3

Development

Successfully merging this pull request may close these issues.

5 participants

@weaverryan@fabpot@stof@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp