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

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:

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

Read a package's code before you trust it with a permission like network or write.

Limits today