Skip to main content

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.

Not public yet

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​

CommandWhat 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 NExtends 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​

OptionDefaultMeaning
--clave <file>File with the private key (iotaprivkey1…) of the account that pays and owns the site. Keep it secret.
--epocas <N>1Epochs to store the new files, and up to which the blobs in use are renewed (current epoch + N). At most 53.
--permanenteoffStore the files as permanent (not deletable) blobs. By default they are deletable.
--nombre "…"Name of the site; overrides site_name.
--max-quilt <bytes>512 MiBMaximum size of a quilt when grouping the files (never more than the largest blob of the network).
--red <file>local networkJSON 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:

  1. reads the folder and ws-resources.json, and drops the ignored files;
  2. computes the headers and the SHA-256 of each file;
  3. compares them with the published Site, if any, to upload only what changed (see Update, renew and destroy);
  4. groups the files to upload in quilts and stores each quilt as a blob, paying in IOTA;
  5. creates or updates the Site in as many transactions as needed;
  6. deletes the deletable blobs that are no longer used.