@craftware/crafty-cli
v0.3.0
Published
Crafty Hosting CLI — deploy your frontend build to Crafty Hosting
Readme
@craftware/crafty-cli
Crafty Hosting CLI — deploy your frontend build to Crafty Hosting with a single command. The CLI talks to your Crafty CMS tenant; the underlying hosting provider is fully abstracted (you never deal with it directly).
Install
npm i -g @craftware/crafty-cliRequires Node.js 20+.
Quick start
From your frontend project (the one that already consumes the Crafty API):
crafty login # opens a browser to approve the CLI (OAuth device flow)
crafty init # writes crafty.json (site + environment + build dir)
npm run build # produce ./dist (framework-specific)
crafty deploy # zips the build, uploads it, prints the live URLThe CLI reads CRAFTY_API_URL from your project's .env to know which tenant to
talk to, so there is nothing else to configure. Hosting must be enabled for your
tenant, site and environment (in the Crafty panel) before a deploy is allowed.
Multiple tenants
The CLI keeps one session per tenant host, so you stay logged into all of
your tenants at once. Each project's CRAFTY_API_URL selects which stored
session is used — switching directories never forces a re-login. Log into a
tenant without entering its project with crafty login --host=<url>.
Commands
| Command | Description |
| --- | --- |
| crafty login [--host=<url>] | Authenticate via the OAuth 2.0 Device Authorization Grant. Without --host, the tenant comes from CRAFTY_API_URL. The token (scope deploy) is stored per host in ~/.crafty/credentials (mode 600). |
| crafty init [--site=<slug> --environment=<env> --build-dir=<dir>] | Create crafty.json in the project. |
| crafty deploy [dir] | Package and deploy a build directory (default: the buildDir from crafty.json, i.e. dist). |
| crafty status | Show the status of the project's last deployment. |
| crafty logout | Revoke and remove the session for the current project's tenant. |
| crafty update (crafty --update / -u) | Self-update the globally installed CLI to the latest version on npm. |
| crafty --version / crafty help | Print version / usage. |
crafty.json
{
"site": "acme",
"environment": "production",
"buildDir": "dist"
}Set buildDir to your framework's output: Vite/CRA/Astro dist, Next.js static
export out, Nuxt .output/public, SvelteKit (static adapter) build.
How it resolves context
CRAFTY_API_URLfrom the project.env(or the environment) → tenant base URL.crafty.json→site,environment,buildDir.~/.crafty/credentials→ the access token stored for that tenant host.
For safety, the token is only ever sent to the host it was issued for, https is
required (except localhost), and .git / .env* / node_modules / symlinks are
excluded from the uploaded build.
Deployed URL & custom domains
A successful deploy is served at a tenant-scoped subdomain
{tenant}-{site}-{environment}.pages.crafty.do (DNS + TLS set up automatically).
To use your own domain, add it in the Crafty panel under Site → Hosting; it
returns a CNAME record to create at your registrar.
Agent skill
This package ships a crafty-deploy skill (under skills/) that teaches coding
agents how to use the CLI — when to run login/init/deploy, how to set
buildDir per framework, and how to troubleshoot. Agents that load skills from
installed packages pick it up automatically.
Development
npm install
npm run build # tsc → dist
npm test # builds, then runs node:test
npm run typecheckPublishing
Published as a public, scoped package under the @craftware org. publishConfig.access
is already public and prepublishOnly rebuilds dist, so no extra flags are needed.
Prerequisites: an npm account that is a member of the craftware org with publish
rights, and your 2FA device if enabled.
# 1. authenticate
npm login
npm whoami
# 2. from this package, install exact deps and validate
cd sdk/cli
npm ci
npm test
npm run typecheck
# 3. preview the exact tarball (no upload)
npm publish --dry-run
# expect: dist/**, skills/**, LICENSE, README.md, package.json
# (never src/, tests/ or node_modules/)
# 4. publish
npm publish # add --otp=123456 if 2FA is enabled
# 5. verify
npm view @craftware/crafty-cli
npm i -g @craftware/crafty-cli && crafty --versionReleasing a new version
cd sdk/cli
npm version patch # or minor / major — creates a commit + git tag
git push --follow-tags
npm publishNotes:
- A given version can only be published once; bump the version for any change.
- Publish from a clean tree at the intended commit.
- The
craftybin isdist/bin/crafty.js(with a#!/usr/bin/env nodeshebang).
