cx package turns a package into an archive. cx publish puts that archive into a registry, and cx yank marks a published version so new resolutions skip it.
Adjust the list with globs in [package]. * matches within a directory, ** across directories, and a plain directory name matches everything in it:
cx package --list prints the files without packaging them.
The archive is a .tar.gz with one top-level directory, <name>-<version>/. It's reproducible: entries are sorted, timestamps are 0, and owners are 0, so the same sources always give the same checksum. It is compressed with cx's own deflate encoder, whose output depends only on the input (not on a zlib version), about as small as gzip -6.
cx package (and so cx publish) unpacks the archive into target/package/<name>-<version>/ and builds it there, the way a dependent would: with its registry dependencies and without dev-dependencies. A package that only builds because of a file that isn't in the archive fails here, not on someone else's machine. --no-verify skips the build.
cx publish refuses a package that:
System dependencies are fine. They aren't listed in the index; cx reads them from the package's cx.toml.
A static registry is a directory of files (see Hosting a registry), served by any web server or used straight from disk. cx publish writes into a local copy of it:
When the default registry (or --registry) itself is a directory or file:// URL, --index isn't needed.
Dependencies of the package must come from the registry --index is a copy of: the default registry, or the one named with --registry.
A registry with an api URL in its config.toml accepts uploads over HTTP:
cx publish and cx yank send the token stored with `cx login` (or from CX_TOKEN, CX_TOKEN_<NAME> or a credential provider) as Authorization: Bearer <token>, only to the API's host.
The API, for anyone writing a registry server:
| Request | Body | Meaning |
|---|---|---|
| PUT <api>/v1/packages/<name>/<version> | the index entry, then the archive, each preceded by its length as a 32-bit little-endian number | publish |
| PUT <api>/v1/packages/<name>/<version>/yank | empty | yank |
| PUT <api>/v1/packages/<name>/<version>/unyank | empty | undo a yank |
cx-registry is a small registry server that comes with cx. It serves a static index directory and implements the API above on top of it, so a team can run a private registry with authenticated uploads:
Clients use it like any HTTP registry (registries.company = "https://cx.example.com") and publish to it with cx publish.
Before it writes anything, the server checks each upload: the token and its scope, that the checksum matches the archive, that the archive contains <name>-<version>/cx.toml with the same name and version as the URL, and that the index entry is exactly what that cx.toml produces (so a client can't publish dependencies its package doesn't have). Versions are never replaced. With --signing-key, every index file it changes is signed again.
The index directory has the same layout as a static registry, so it can also be served by any static web server, copied with rsync, or published to with cx publish --index. The server handles one request at a time: run one per directory. It has no TLS; put it behind a reverse proxy such as Caddy or nginx for https://.
A yanked version stays in the registry, so lockfiles that pin it keep working, but new resolutions don't pick it. For a static registry, cx yank edits the yanked line of that version in place (--index for a checkout). It's the one change to an index file that isn't an append.