-
Notifications
You must be signed in to change notification settings - Fork 269
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
Making a single-file mermaid-cli.exe
for Windows
#467
Comments
It is an awkward setup for anyone who doesn't use node.js day-to-day. You need to :
And finally it should generate diagrams. |
We could set up a GitHub Action that runs automatically and uploads the The only hard part bit that might be complicated is puppeteer, which automatically downloads a ~350 MiB chromium instance at run time. Unfortunately, I don't have a Windows machine so it would be difficult for me to test the actual
@MindaugasLaganeckas, if somebody made a PR that implemented the above, would you be happy for it to be added? (if so, feel free to add the |
Thank you for a good discussion. I have limited access to Windows as well, but fortunately Github provides windows based build agents. Yes, I would accepts such PR given that some e2e/integration tasks come with the PR. |
Hi guys, I would have an interest in having a mermaid-cli agent available on Windows systems, and would be potentially interested in taking this one over, but my experience with building npm is unexistent. (the github action stuff i guess I can learn it on the fly). In order to develop this, I guess I'll create a fork of the project, and would be able to test things like uploading the CI artifact and the release asset. For me to actually be able to do this, I would really need to have the detailed steps of what I need to do, and in what order. Also, I would recommend we only build the arrtifacts on successfull pull requests, instead of every commit. That would become quite messy otherwise ;) TasksRegarding this
buildI currently don't know how to do this. Could someone maybe provide that to me? (@MindaugasLaganeckas / @aloisklink maybe ?) I can than integrate it in a github action. testsThere are two ways to go forward with this: I would prefer option b, as it make sense to me to reuse as much as possible. Artifact uploadI only have a few doubts on how to test this as I have no rights on this current project. I assume that I would be able to try this out want once I fork this project, right? I do have some difficulties to see the difference between the artifact upload, and the release upload. They look identical to me tbh.. Let me know if you guys are for this :) |
Thank you for reaching out ❤️ I would suggest to start with local testing (on your computer). And reuse as much as possible. I think option C is the one to go for:
What do you think? |
I've never done anything like this before, but I think there's two approaches that might work:
The only problem I see with both of them is that they currently only work with CommonJS JavaScript libraries. Since Otherwise, there might be another tool somewhere that can work with ESM code directly! In that case, I'd imagine it would something like:
I know this stuff is pretty JavaScript specific, so if you need help with this bit, let me know! I think I can probably get an executable working on Linux at least, and then hopefully you'll be able to modify the commands to get it working on Windows!
Agree with @MindaugasLaganeckas :) I think as long as it works with a single diagram, we can count it as a success! You can use actions/upload-artifact in GitHub Actions to upload the generated image, so something like: - run: |
my-mermaid-file.exe -i input.mmd -o output.png
- uses: actions/upload-artifact@v3
with:
name: windows-exe-output.png
path: output.png
Build artifacts are uploaded using GitHub Actions with the actions/upload-artifact action, and you can test it in your own GitHub fork :) They upload to the Github Actions run UI, e.g. https://github.com/mermaid-js/mermaid-cli/actions/runs/4785247117. These are useful for debugging, or for power users that want to test the latest version of a program (old artifacts are even auto-deleted). Release assets are uploaded using the GitHub API (maybe using a GitHub Action?). You can view these at https://github.com/mermaid-js/mermaid-cli/releases/tag/10.1.0. These are the versions we expect most people to download. I'd imagine you'd have two GitHub Actions:
|
Hey guys I finaly found some time to look at this. In a nutshell, this is what I am doing (based on the above suggestions).
When executing the
It still creates a set of 3 files
but, if I launch the creation of mermaid file, I get the following result
using SO.... I am not Javascript savy, so when I read this error message, I feel like an elderly person using a computer for the first time, and trying to understand the difference between the right and the left click. :D aloisklink, would your offer for help still stand? I think I could need some ;) |
It sounds like you're running into the following issue:
Basically, Everybody is slowly moving away from the old CommonJS standard (we had to move away because our dependencies moved to ESM). However, a bunch of older tools still don't support it. I've tried using My feeling is that if we want to use It might be possible to do this currently with electron, but I think it will be a lot of work, so it's probably better to wait for |
mermaid-cli.exe
for Windows
Thanks @aloisklink for the quick explanation 👍
I believe that that would be the wise solution, indeed. But on another side, I am a bit afraid that this might be a long wait. I'ill wait for that pkg issue to be fixed, or hope that another person can come up with a solution on how to do that. Once that is done, I believe I have figured out how to automate the process on every new release and attach it as a release. |
There is an experimental Node.JS single-executable application API (see https://nodejs.org/api/single-executable-applications.html#single-executable-applications) that seems like it will help, but it also currently only supports CommonJS and hasn't yet added ESM support (plus, the API is designed for libraries like |
Apparently both Bun and Deno support creating a single-file executable with ESM support
I've got no idea if |
Thanks for the hints @aloisklink I have looked at both options. Bun currently only offers limited support on Windows. Since we are trying to build a binary for Windows I will skip this one. I have looked a bit at deno. I have tried to compile it as this deno compile .\@mermaid-js\ but i get the following error:
I quickly googled it, and it mentions some missing .ts references. Not sure which direction to go from here... |
Sorry, I've never used Deno or Bun before, so I don't know. I don't even know if the You might find it a bit easier to try building the A good first step might be to make confirm that |
I would actually be ok in generating the .exe on linux, and than 'cross-compile' it. Ultimatley, the end goal is to have a working CLI solution working on Windows. We don't really care where / how we create that exe. As long that it works... ^^, I am not familar with that. Would you know I would go to do that?. |
I also asked ChatGPT, it mentionned tools I we have not address here yet (but maybe you guys ruled them out for obvious reasons which I don't know about ?)
It also mentionned nexeI quickly had a lookd a nexe and it looks like you have to convert a node-packer (nodec)The node-packer github project sounds promising. I specifically like this table where it compares the solution to other tools. It works on Windows directly apparently, although this might not necessarly be needed since It also seems it could be a solution for do you @aloisklink or anyone else has experience with this? What you guys think of this potential approche? |
It depends on which program you are using.
nexe doesn't support ESM yet: nexe/nexe#815 However, you might have luck using aloisklink@ed0880c, which is my WIP commit that creates a single-file
The fact that Potential alternatives:
Footnotes
|
Any progress on this? |
Hey @aloisklink I am reactivting this threat. As mentionned, I am not a Javascript guru, so I don't know what happened in the last year or so in that field, but I can imagine that 'some stuff' has changed, right? Do you know if the ecosystem has evolved in a way where we would have a technical solution to potential implement this one ? (I would still be happy to implement it - just need some guidance ... ;) ) |
Unfortunately, I think in the Node.JS eco-system, it might have become worse 😢
But, I think Deno has really improved support with Node.JS packages, so maybe that's an option? It could be worth a try to see if Deno can run |
Is your feature request related to a problem? Please describe.
I have a few diagrams in md file and would like to convert all of them at once to svg.
Describe the solution you'd like
I would like to have something like pandoc app I can install with exe on Windows 7 and then use with command line to convert md file with mermaid code to new md file with linked svg images of diagrams. I don't want to install npm etc, for existing mermaid CLI because I'm not a programmer.
Describe alternatives you've considered
Now I convert every diagram manually in online Live Editor. It's very inconvenient.
The text was updated successfully, but these errors were encountered: