All-purpose web tiles library
README.md

@dasl/atile #

The command-line tool for DASL tiles: publish them to the AT Protocol, or bundle them into self-contained .tile files.

Most operations work from a tile source directory — a folder with a manifest.json and your index.html and other resources — which atile either uploads to a PDS as an ing.dasl.masl record, or packs into a CAR .tile.

Install #

npm install -g @dasl/atile
# or run without installing:
npx @dasl/atile --help

Credentials are stored with keytar, which has a native build step; npm will compile it on install.

Commands #

Usage: atile [options] [command]

Commands:
  login <handle>                 log a handle into AT so that you can post
  logout <handle>                log a specific handle out
  default-user <handle>          set the default handle to use when unspecified
  list-users                     list all logged in handles you have
  publish [options] <dir>        publish a tile to the Atmosphere
  delete [options] <dirOrATURL>  delete a tile from the Atmosphere
  bundle [options] <dir> <out>   bundle a tile into a .tile file
  help [command]                 display help for command

What goes into a tile #

Everything in a tile is public, and what has been published has to be treated as read, even if you delete it afterwards. So atile does not take everything that is in the directory. It leaves out, unless manifest.json names the path in its resources:

  • dot-files, and everything under a directory whose name starts with a dot (.env, .npmrc, .git/);
  • everything under node_modules;
  • .tile files (earlier bundles).

It never takes a symbolic link, nor the file a bundle is being written to. bundle and publish both print what goes into the tile, with sizes, and what was left out.

A file becomes the resource at its own path, written as a URL writes it: img/my file.png is /img/my%20file.png, which is what <img src="img/my file.png"> asks for. index.html at the top is /.

A directory with a .git in it is a working copy, which usually holds more than the tile (sources, notes, build scripts), so atile refuses it. Give it a directory that holds only the tile, such as the build output, or pass --force to take that one as it is. Even then, check the list: only what is listed above is left out.

Bundling (no login needed) #

Pack a source directory into a self-contained CAR .tile that any tile reader can open:

atile bundle ./my-tile ./my-tile.tile

Publishing to AT #

First log in with an app password. The handle is stored securely and becomes the default; log in with several and switch between them with --user.

atile login me.example.com     # asks for the app password
atile publish ./my-tile

atile login asks for the app password at a prompt that does not show it. It is never an argument on the command line, where it would stay in the shell history and show in the process list. Without a terminal (a script, an agent) it is read from standard input:

atile login me.example.com < app-password.txt

If the ATILE_APP_PASSWORD environment variable is set, the password is taken from it, and nothing is asked or read.

Logging in finds out which account the handle names and which PDS that account is on, checks that the password opens a session there, and stores the three together in the system keychain. From then on the password is sent to that PDS only, over https, for that account only. If the handle later resolves to another account or another PDS, or cannot be resolved at all, atile stops before sending anything; if the change is yours, run atile login again.

A login made with atile 2.1 or earlier holds the password alone. Run atile login <handle> once more to replace it.

atile publish reads ./my-tile/manifest.json, content-addresses every file, fills in the resources map (guessing media types), uploads the blobs, and writes the tile record.

Blobs are uploaded as application/octet-stream, and the record carries the reference the PDS answers with, mimeType included, as the tiles spec recommends: some PDS implementations sniff uploads, store blobs under the type they recognise, and refuse a record that names another. The content-type a resource is served with is a separate header, guessed from the file name; set it in manifest.json to override the guess.

Useful options:

  • -u, --user <handle> — publish as a specific logged-in handle.
  • -s, --stable-id — remember the tile's AT URL for this directory and update that record in place on future publishes, instead of creating a new one. (A directory last published as another account gets a new record.)
  • -t, --tid <tid> — publish under a specific record key (overrides -s).
  • -n, --dry-run — show what would be uploaded, and stop there. It needs no login and sends nothing.
  • -y, --yes — upload without asking. At a terminal atile publish shows the list of files and asks before it uploads anything. Without a terminal (a script, an agent) it never waits for an answer.
  • -f, --force — take a directory that has a .git in it (also for bundle).

Deleting #

atile delete at://did:plc:…/ing.dasl.masl/3m…
atile delete ./my-tile         # if you published it with -s

Managing handles #

atile list-users               # all logged-in handles
atile default-user me.example.com
atile logout me.example.com

Part of DASL tiles #

License #

Apache-2.0