Package registry
A registry is a place that holds packages by name and version. In Cresset it is just a folder (or a web address serving that folder), so you can run your own for a team with nothing but a file server.
The point of Cresset's registry is the same as the rest of the language: you see what a package may do before you use it.
Installing a package
node cresset.js install textutil --registry ./my-registry
installed textutil 1.10.0 -> cresset_packages/textutil.crs permissions it needs: nothing (it is pure) use it with: use textutil from "cresset_packages/textutil.crs" then pin it: cresset lock <your file>
For a package that needs permissions, the output tells you exactly what to grant:
installed files 0.1.0 -> cresset_packages/files.crs permissions it needs: read use it with: use files from "cresset_packages/files.crs" allow read
textutilinstalls the newest version (by real version order, so 1.10.0 is newer than 1.9.0).textutil@1.2.0installs that exact version.- The file is copied into
cresset_packages/(change it with--dir). A different version of an installed package is refused unless you add--force. - The registry's index records a SHA-256 hash for every version. If the file doesn't match, nothing is installed.
- Installing from a web address works the same:
--registry https://packages.example.org. - Set
CRESSET_REGISTRYonce and you can leave--registryoff.
An installed package is an ordinary package: import it with a use line, grant it only what it needs, and pin it with cresset lock.
Finding packages
node cresset.js search --registry ./my-registry node cresset.js search util --registry ./my-registry
Each line shows the name, the newest version, and every version available.
Publishing
node cresset.js publish lib/textutil.crs --name textutil --version 1.0.0 --registry ./my-registry
Cresset checks that the package compiles by itself, copies it into the registry, records its hash, and prints the permissions it needs. A few rules keep a registry trustworthy:
- Versions never change. Publishing a version that already exists is refused. Publish a new number instead.
- Names are lowercase letters, digits and
_, starting with a letter. - Versions look like
1.0.0. - A package may import other registry packages, but only as
use x from "x.crs"(see below). - You can publish only into a registry folder. To share it, serve that folder.
Packages that use packages
A package can build on other packages from the same registry. Import them by plain name, with the file beside it:
use base from "base.crs" use reader from "reader.crs" allow read
When you publish, Cresset checks that every import is already in the registry, pins the newest version of each into this release, and compiles the package against exactly the files an installer would get. That compile also checks your allow lines: if reader needs read and you gave it nothing, the publish is refused, just as a run would be.
Installing fetches the dependencies first, each one hash-checked, and prints them before the package itself:
(dependency) installed base 1.0.0 -> pk/base.crs permissions it needs: nothing (it is pure) (dependency) installed reader 1.0.0 -> pk/reader.crs permissions it needs: read installed mid 2.0.0 -> pk/mid.crs it depends on: base 1.0.0, reader 1.0.0
Each dependency is an ordinary package file in your folder, so the lock file pins it like any other. Two rules keep this simple and safe: one install can hold only one version of a package (a clash is refused when publishing, not left for you to find), and a package cannot import itself or form a circle.
What a registry looks like
my-registry/
index.json
packages/
textutil/
1.0.0.crs
1.10.0.crs
index.json lists each package, its versions, the file for each, and each file's hash. Any web server that serves the folder as plain files is a registry.
What this does and doesn't protect
- The hash proves the file you got is the file that was published. It catches damage and tampering after publishing.
- It does not prove the package is safe. Someone can publish a package that does something you don't want. That is what Cresset's permissions are for: a package can only use what you grant it, and
installshows you the list first. - The lock file makes sure a package you reviewed can't change underneath you later.
Read a package's code before you trust it with a permission like network or write.
Limits today
- There is no shared public registry; you run your own.
- There are no accounts or access control; whoever can write to the folder can publish.
- A package depends on exact versions, pinned when it was published. There is no version solving: two packages that need different versions of a third cannot be installed together.