The kamakiri CLI

kamakiri is the command-line client for Kamakiri Pages, and the whole interface to the service.

Install

Run the install script, in a terminal on Linux and macOS or in PowerShell on Windows.

$ curl -fsSL https://get.kamakiri-labs.jp/install.sh | sh
PS> irm https://get.kamakiri-labs.jp/install.ps1 | iex

The script verifies the download against the checksum published with the release, then installs it to ~/.local/bin/kamakiri, or to %USERPROFILE%\.local\bin on Windows. To install somewhere else, set KAMAKIRI_INSTALL_DIR to a directory you own: kamakiri upgrade replaces the binary in place without administrator rights, so it cannot update a copy in a directory owned by root.

On macOS and Linux the script edits no shell profile. If the install directory is not on your PATH, the run ends by printing the line to add and the file to add it to. On Windows the script adds the directory to your user PATH and to the current session, so kamakiri version works straight away.

The client is also published on npm and Homebrew:

The binary for each platform is linked from get.kamakiri-labs.jp.

Update

Run the install command again, or kamakiri upgrade. A copy installed with npm or Homebrew updates through that package manager. When a newer release is out, a command that succeeded on a terminal ends with one line on stderr saying so, at most once a day. When the server stops supporting your version, every command that talks to it is refused with a line telling you to run kamakiri upgrade.

Uninstall

Run the uninstall script.

$ curl -fsSL https://get.kamakiri-labs.jp/uninstall.sh | sh
Removed ~/.local/bin/kamakiri.
Removed the config directory ~/.config/kamakiri.
It held your saved API key. Only this copy is gone: the key itself stays valid on your account, and nothing here revokes it.
kamakiri is uninstalled.
If you added ~/.local/bin to your PATH for kamakiri alone, that line in ~/.bashrc can come out now.
PS> irm https://get.kamakiri-labs.jp/uninstall.ps1 | iex
Removed C:\Users\you\.local\bin\kamakiri.exe.
Removed the config directory C:\Users\you\.config\kamakiri.
It held your saved API key. Only this copy is gone: the key itself stays valid on your account, and nothing here revokes it.
Removed C:\Users\you\.local\bin from your user PATH.
kamakiri is uninstalled.

The script removes the binary and the whole config directory, including your saved API key and settings. If you installed with KAMAKIRI_INSTALL_DIR, set it again for the uninstall. A copy from npm or Homebrew is removed with npm uninstall -g kamakiri or brew uninstall kamakiri.

The usage message

kamakiri with no command prints this to stderr and exits 1. There is no help command and no --help flag.

$ kamakiri
Usage: kamakiri <command>

Commands:
  login       Log in with your email
  status      Show current status (--verbose shows DNS records inline; --recheck asks the server to check DNS now)
  init        Create a new site
  deploy      Deploy a directory or archive
  deploys     List recent deploys
  rollback    Roll back to a previous deploy
  teardown    Delete the linked site
  cdn         Manage CDN (cloudflare/webaccel/none/cleanup/verify/credentials/status/purge)
  domain      Manage custom domains (register/unregister/verify/set/unset/add/remove/list)
  subdomain   Get or set the site subdomain
  version     Print the CLI version (--version, -v)
  language    Show or set the CLI language (en/ja)
  upgrade     Update the CLI to the latest release

Environment variables:
  KAMAKIRI_API_KEY
    The API key every command that needs a credential uses, for CI runners
    with no credentials file. While it is set, the credentials file is not
    read. Take the key from the file `kamakiri login` saves on your machine.

  KAMAKIRI_CDN_TOKEN, KAMAKIRI_CDN_SECRET
    WebAccel API credentials for `kamakiri cdn webaccel`. Prefer these
    over --token/--secret flags in CI: command-line arguments are visible
    in `ps`, while env vars are not.
$ kamakiri
使い方: kamakiri <command>

コマンド:
  login       メールアドレスでログインします
  status      現在の状態を表示します(--verbose はDNSレコードも表示し、--recheck はサーバーにDNSの再確認を要求します)
  init        新しいサイトを作成します
  deploy      ディレクトリまたはアーカイブをデプロイします
  deploys     最近のデプロイを一覧表示します
  rollback    以前のデプロイにロールバックします
  teardown    リンクされているサイトを削除します
  cdn         CDNを管理します (cloudflare/webaccel/none/cleanup/verify/credentials/status/purge)
  domain      カスタムドメインを管理します (register/unregister/verify/set/unset/add/remove/list)
  subdomain   サイトのサブドメインを表示・設定します
  version     CLIのバージョンを表示します (--version, -v)
  language    CLIの言語を表示・設定します (en/ja)
  upgrade     CLIを最新リリースに更新します

環境変数:
  KAMAKIRI_API_KEY
    認証情報が必要なすべてのコマンドが使うAPIキーです。認証情報ファイルの
    ないCIランナー向けで、設定されている間はそのファイルを読みません。
    キーは、手元のマシンで `kamakiri login` が保存したファイルにあります。

  KAMAKIRI_CDN_TOKEN, KAMAKIRI_CDN_SECRET
    `kamakiri cdn webaccel` で使う WebAccel API の認証情報です。CIでは
    --token/--secret フラグより環境変数を推奨します。コマンドライン
    引数は `ps` から見えますが、環境変数は見えません。

Files

The config directory is $XDG_CONFIG_HOME/kamakiri when that variable is set, and ~/.config/kamakiri otherwise, on every platform. On Windows that is %USERPROFILE%\.config\kamakiri. It holds:

Your project holds .kamakiri/config.json, written by kamakiri init. It holds the id of the linked site and nothing secret. Commit it, so a collaborator or a CI job deploys the same site.

Authentication

kamakiri login saves an API key in credentials.json, in the config directory. Every command that talks to the API uses it.

While KAMAKIRI_API_KEY holds a value that is not blank, commands use it and do not read the credentials file. Deploy covers setting it up in CI.

A command that finds no credential prints not logged in and exits 1. A key the server rejects prints invalid API key: log in again, or, when the key came from KAMAKIRI_API_KEY, check the value the variable holds.

What a command waits for

A command that starts work on the service returns when the result is true for a visitor to your site, not when the request is accepted. kamakiri deploy, kamakiri rollback and kamakiri cdn purge return once a visitor gets the current deploy, through the CDN as well when one is configured.

Language

The CLI speaks English and Japanese, chosen from KAMAKIRI_LANG, then the preference saved with kamakiri language, then your locale. Text from the server is always English, so a Japanese transcript can carry an English line.

The commands