typst / typst

A new markup-based typesetting system that is powerful and easy to learn.
https://typst.app
Apache License 2.0
35.37k stars 942 forks source link

Fetch a package using the CLI #4752

Open emilyyyylime opened 3 months ago

emilyyyylime commented 3 months ago

Description

Being able to explore the amazing Typst Universe from the CLI would be really great, seeing as the compiler is really also a package manager. I'm envisioning at the very least a search (by name, author, tags, version...) and a fetch operation, for if I know I want to use a package later but only have access to internet right now. Not sure if it would look like typst universe search or typst package fetch or typst install/typst search etc., but I certainly think it'll be a good addition overall

emilyyyylime commented 3 months ago

If anyone wants a quick way to do it now is typst c - /dev/null -f png <<< '#import "@preview/PACKAGE:VERSION"', but it does require you to already know which package/version you're looking for

Athishpranav2003 commented 3 months ago

I guess i can work on this. My idea is that https://github.com/typst/packages repo is used to store all the published packages (available in typst universe). It would be nice if we host the metadata of these packages in some kind of public endpoint then we can fetch the information and use it correctly. Currently we could only do this by web scraping the github repo or the website itself.

Athishpranav2003 commented 3 months ago

@laurmaedje How would this need to be designed?

laurmaedje commented 3 months ago

Currently we could only do this by web scraping the github repo or the website itself.

https://packages.typst.org/preview/index.json is available for use. We don't give any stability guarantees, but it's reasonably stable since the compiler uses it.

How would this need to be designed?

UX-wise this seems like a larger design task. Unfortunately, I don't have the time to think about it much at the moment.

Athishpranav2003 commented 3 months ago

@laurmaedje yah i agree. Maybe later sometime if we could work together on this it would be great

Thumuss commented 3 months ago

I need to add something! I'm developing a package manager called utpm. I already have developed some features like clone as it's the same to your suggestions but with less possibilities. I'll try this week to add the possibility to search into the registry like you said.

In the future when it will be stable with all functionalities that a package manager needs, I'll take my chance to merge it into typst.

I think you should take a look at it. Do you think, with a bit of more development, it satisfy your demand?

emilyyyylime commented 2 months ago

@Thumuss utpm looks really cool! But as of now, it's still an unofficial alternative to the core Typst, and I think with the current directions of the Typst ecosystem many of the features implemented in utpm should sooner or later make it to the official Typst CLI, so I think this issue is still warranted

Thumuss commented 2 months ago

@emilyyyylime first of all, thank you!

And yes for now I've made it unofficial because my knowledge at the time of what is a package manager, and rust in general was miserable. I didn't want to integrate something that wasn't ideal for typst.

So I made this project! In the future, as you said, I want to move this project to typst directly. I will try it at the end of the year when this project will be more mature!

Any contribution is greatly appreciated!

Edit: I didn't reply directly to this message but yes this issue is still warranted and I think it's a great start for the package manager of Typst