Sites CLI (sitio.mjs)
sitio.mjs is the reference command line to publish and manage sites. It is a Node.js script with
Spanish command names. It signs with a private key file and pays in IOTA from that account.
The CLI lives in the project repository, which is not public yet. Most users should use the app, which does the same from a browser wallet.
Commands
| Command | What it does |
|---|---|
publicar <folder> | Publishes the folder as a new site. |
actualizar <folder> <site> | Updates an existing site with the folder. |
desplegar <folder> | Publishes the first time and updates afterwards, using the object_id of ws-resources.json, which it writes. |
mapa <site> | Lists the resources of a site (path, content-type, blob ID, patch), its routes and its redirects. |
convertir <0x… or base36> | Converts a Site ID to base36 and back. |
destruir <site> | Deletes the blobs, removes the resources and burns the Site. |
renovar [<site>…] --epocas N | Extends the blobs of the site without uploading anything. |
<site> can be the object ID (0x…), its base36 form or an IOTA Names name (name.iota, through
its target address).
Options
| Option | Default | Meaning |
|---|---|---|
--clave <file> | File with the private key (iotaprivkey1…) of the account that pays and owns the site. Keep it secret. | |
--epocas <N> | 1 | Epochs to store the new files, and up to which the blobs in use are renewed (current epoch + N). At most 53. |
--permanente | off | Store the files as permanent (not deletable) blobs. By default they are deletable. |
--nombre "…" | Name of the site; overrides site_name. | |
--max-quilt <bytes> | 512 MiB | Maximum size of a quilt when grouping the files (never more than the largest blob of the network). |
--red <file> | local network | JSON file that describes the network: RPC URL and the IDs of its packages and objects (see Contracts). For testnet, also set IOTA_RPC_URL=https://api.testnet.iota.cafe. |
Examples
# testnet
export IOTA_RPC_URL=https://api.testnet.iota.cafe
# publish (the first time) or update (afterwards) a folder for 5 epochs
node sitio.mjs desplegar ./my-site --red testnet.json --clave alice.key --epocas 5
# update a given site
node sitio.mjs actualizar ./my-site <site ID> --red testnet.json --clave alice.key
# list what a site contains
node sitio.mjs mapa blog.alice.iota --red testnet.json
# convert between the object ID and the subdomain
node sitio.mjs convertir <site ID> --red testnet.json
# extend the blobs of a site up to the current epoch + 30
node sitio.mjs renovar <site ID> --red testnet.json --clave alice.key --epocas 30
# destroy a site and recover its deposits
node sitio.mjs destruir <site ID> --red testnet.json --clave alice.key
When it publishes or updates, the CLI prints how many files it uploads, reuses and renews, each
quilt (blob ID, files, size, cost and end epoch), the ID of the Site, its base36 form and its URL
in the portal.
How it works
The CLI is built on the library sitios.mjs, which has no Node.js dependencies so that the app can
use it in the browser too. For each publication it:
- reads the folder and
ws-resources.json, and drops the ignored files; - computes the headers and the SHA-256 of each file;
- compares them with the published
Site, if any, to upload only what changed (see Update, renew and destroy); - groups the files to upload in quilts and stores each quilt as a blob, paying in IOTA;
- creates or updates the
Sitein as many transactions as needed; - deletes the deletable blobs that are no longer used.