Skip to content

[WebProfilerBundle] Inline flowchart-only Mermaid version #54424

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

MatTheCat
Copy link
Contributor

@MatTheCat MatTheCat commented Mar 27, 2024

Q A
Branch? 7.1
Bug fix? no
New feature? no
Deprecations? no
Issues Fix #54416
License MIT

From mermaid-js/mermaid#2920 (comment) there is no official way to generate a diagram-specific script, but it is possible by patching the packages/mermaid/src/diagram-api/diagram-orchestration.ts file before building.

This PR comes with a Makefile whose default recipe does so, and the mermaid-flowchart-v2.min.js file it generated from v10.9.0.

Bumping the script’s version will require to update the Makefile’s tag variable to the corresponding mermaid-js/mermaid’s (from https://github.com/mermaid-js/mermaid/tags) and running make. The recipe depends on cURL, GNU tar, and pnpm.

@stof
Copy link
Member

stof commented Mar 27, 2024

I suggest putting a text file in the repo near the mermaid file mentioning the version of mermaid being included as well as how to build it. Otherwise, updating mermaid will be a pain.

@stof
Copy link
Member

stof commented Mar 27, 2024

or even better, a script (in a location excluded from the composer archive) that actually generates the file, so that updating mermaid is a matter of updating the version in the script and running it.

@MatTheCat
Copy link
Contributor Author

@stof are you thinking of something like Intl’s compile script? It’s the only precedent I’m aware of but it comes with the component and require a specific Docker image.

@stof
Copy link
Member

stof commented Mar 27, 2024

@MatTheCat no, it is not include in the archives:

/Resources/bin/compile export-ignore

@stof
Copy link
Member

stof commented Mar 27, 2024

regarding requiring a Docker image, this script was implemented this way to simplify things as it requires being run with a specific version of icu to achieve its purpose.
https://github.com/symfony/symfony/tree/e70dcb124ef9d01f3ef5d221e23a5d313a57b4e2/src/Symfony/Component/Emoji/Resources/bin is not relying on Docker.

@MatTheCat
Copy link
Contributor Author

Okay, added a Makefile to generate mermaid-flowchart-v2.min.js for a given tag.

endef

.PHONY: mermaid-flowchart-v2.min.js
mermaid-flowchart-v2.min.js: | mermaid-$(if $(tag),$(tag),$(error missing “tag” variable))/node_modules
Copy link
Member

Choose a reason for hiding this comment

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

Where is the value of the tag provided ? It looks like it is passed as argument, but it would be better to have the version defined in the script itself so that we track which version is embedded in the repo (instead of having to know which version was used by the last update by asking the dev to remember it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tag would have to be provided when calling make: make tag=v10.9.0 e.g.

Will set its default value to v10.9.0.

Copy link
Member

Choose a reason for hiding this comment

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

instead of a default value, I would prefer a hardcoded value in the makefile. When wanting to update to a new version, you update the hardcoded version, you run the script, and you commit both changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forced tag value in cb041e3

pnpm -C $(@D) install --ignore-scripts

mermaid-%:
curl -fL https://github.com/mermaid-js/mermaid/archive/refs/tags/$*.tar.gz | tar -xz --strip-components=1 --one-top-level=$@
Copy link
Member

Choose a reason for hiding this comment

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

this looks like it will create a folder containing the mermaid source code. This should have a gitignore rule to avoid committing it by mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, was not sure if I was supposed to add a clean rule. Will update .gitignore.

Copy link
Member

Choose a reason for hiding this comment

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

we can also have a clean command, but that does not remove the need for a gitignore to prevent mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a clean rule too in de90cc6

MatTheCat added a commit to MatTheCat/symfony that referenced this pull request Mar 28, 2024
MatTheCat added a commit to MatTheCat/symfony that referenced this pull request Mar 29, 2024
@fabpot fabpot added the ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" label Apr 5, 2024
@fabpot
Copy link
Member

fabpot commented Apr 8, 2024

Thank you @MatTheCat.

@fabpot fabpot merged commit 44e4699 into symfony:7.1 Apr 8, 2024
6 of 10 checks passed
@MatTheCat MatTheCat deleted the ticket_54416 branch April 8, 2024 12:44
@MatTheCat
Copy link
Contributor Author

MatTheCat commented Aug 28, 2024

Gave a shot at mermaid v11; some changes are needed in the compilation script and the resulting file is > 100 KB heavier. Not sure if a PR is needed 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" Status: Reviewed WebProfilerBundle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[WebProfilerBundle] Don't load external JS dependencies in Workflow profiler
4 participants