Mirror of https://gitlab.com/est/cargo-local-serve | Serve a local, offline, clone of crates.io.
APACHE-2.0 License
Serve a local, offline, clone of crates.io
.
DISCLAIMER: this is alpha software. Many features don't work yet or are only prototyped.
Uses the crates you have cached locally to display a clone of the crates.io
interface to users.
A second (and later) goal of this project is to extend with writeability, aka enabling a local crates.io like service for companies, mars colonists, etc where you can push your crates to, similar to how crates.io
is working.
The crates.io
team has publicly stated that the only goal of the codebase is to drive the site itself and no local clones of it. That's where this project comes in : it is tailored for that use case precisely. Aka, less setup but also only a subset of the features.
Some little demo for usage:
cargo run -p cargo-local-serve
inside the repohttp://localhost:3000/crate/winapi
or http://localhost:3000/crate/futures
The visual design has been heavily lended from the design
of the main crates.io
website. It is a very beautiful design and well known to the Rust developer community.
The project is guided by the following principles:
I definitely encourage crates.io
maintainers to take a look at my codebase and maybe draw inspiration for some improvements inside their own frontend. This is an open source project, everything is up for the grabs! But the main focus of this project is not to write a new frontend that covers the whole set of features that crates.io
does.
Ember is being used by many quite renown companies. If it were bad, they wouldn't be using it. In fact, this project itself is using the handlebars
technology that has a deep relationship to ember.
I'm not the maintainer of crates.io
so I don't want to tell them what to do. But for my project, I have chosen to not adopt ember or any other single page applications (SPA) based approach.
The basic idea of designing web sites as single page applications (SPAs) is to save on bandwidth by just transporting a small json file over the wire. However, for crates I've tested, the json file that ember-powered crates.io
sends over the network is larger than the entire HTML that my frontend sends over the wire. The second thing that SPA is about is having dynamic pages with content that changes over time either from itself (watching a live chat) or through interaction with the user (participating in a live chat). Now this project is about a mostly static site, so we'd get little gain here as well.
The third reason is a more security oriented one: if your entire interface with the application state is via json, it can be reasoned about by security tools in a much easier fashion. Also, any exploit in the rendering code would not allow you to escalate to a breach.
The first point is covered here by using handlebars: as handlebars uses json, there is already a json based interface. It is just inside the server! The second point is being approached by using memory-safe Rust everywhere. This obviously doesn't help with exploitable libraries, however they should mostly consist of safe Rust as well.
crates.io
would probably see huge improvements in performance by using ember-fastboot. However, this project targets to be even leaner than that.
I'm in fact a big fan of the rocket framework:
I would really love to use Rocket, but this service isn't just meant to be compiled once by some server inside the cloud (an environment very much under my control). It is meant to be installed by a wide audience, on local machines, etc. Therefore, I don't want to require nightly, and I can't use Rocket as a consequence.
The iron web framework is mature and well established, compared to e.g. gotham. That is why I chose it!
The logo, under site/static/package-logo.svg
has been adapted from
a MIT licensed GitHub artwork.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.