@cleanslice/ranch
v0.1.9
Published
Ranch project CLI
Downloads
1,174
Maintainers
Readme
@cleanslice/ranch
Thin CLI wrapper for the Ranch monorepo. Replaces the most-used make targets with a single ranch command.
Commands
ranch dev [api|app|admin] Start dev servers (all by default)
ranch down Stop dev servers, postgres and k3d
ranch stop Alias for down
ranch db <action> start | stop | reset | studio
ranch generate Regenerate Prisma schema from slices
ranch status Show what's currently running locally
ranch where Show which Ranch root the CLI is usingRun ranch --help or ranch <cmd> --help for the full list.
Install
Install globally so the ranch command is available everywhere:
npm i -g @cleanslice/ranch
# or
bun add -g @cleanslice/ranch
pnpm add -g @cleanslice/ranch
yarn global add @cleanslice/ranchNote: the
-g(global) flag is required. Without it the package is installed only into a project's localnode_modules/.binand theranchcommand will not be on your$PATH— you'd have to invoke it withnpx ranch ….
Verify:
ranch --helpFirst run — auto-setup
The first time you run ranch <command> outside of a Ranch checkout,
the CLI offers to set one up:
- Clone
CleanSlice/ranchinto a directory of your choice and optionally runbun installthere. - Point at an existing local copy if you've already cloned it somewhere.
The chosen path is cached at:
~/.config/ranch/config.jsonon macOS / Linux%APPDATA%\ranch\config.jsonon Windows
Subsequent ranch commands work from anywhere — no need to cd into
the project. Inspect / re-discover with ranch where.
Resolution order (first match wins):
RANCH_ROOTenvironment variablepackage.json#name === "ranch"walking up from the current directory- The cached path from the config file
- Interactive setup
Local development
The CLI is intentionally not a bun workspace of the ranch monorepo —
keeping it out means turbo dev never tries to spawn it as one of the
dev tasks. Install its deps independently:
cd cli
bun install
bun run start -- --help # runs src/cli.ts directly via bunTo link your working copy as if it were globally installed:
cd cli
bun link
bun link @cleanslice/ranch # run from any other directoryStandalone binary
Bun can compile the CLI to a single self-contained executable:
cd cli
bun run compile
# produces ./dist/ranch — copy it anywhere on $PATHThe compiled binary still shells out to bun, docker, k3d, kubectl,
so those tools must be present on the host.
Publishing to npm
Releases are automated by .github/workflows/publish-cli.yaml.
One-time setup:
- The npm scope
@cleanslicealready exists and is owned bydmitriyzhuk. Add other maintainers vianpm org set cleanslice <user> developer. - Create an automation token at https://www.npmjs.com/settings//tokens (type: Automation, so it bypasses 2FA in CI).
- In the GitHub repo: Settings → Secrets and variables → Actions →
New repository secret → name
NPM_TOKEN, value = the token. - The repository must be public — npm provenance refuses to verify packages built from private GitHub Actions runs.
To cut a release:
# 1. Bump the version in cli/package.json (semver)
cd cli
npm version patch # or minor / major → edits package.json
cd ..
# 2. Commit and push the version bump
git add cli/package.json
git commit -m "chore(cli): release v$(node -p "require('./cli/package.json').version")"
git push
# 3. Tag and push — this triggers the workflow
VERSION=$(node -p "require('./cli/package.json').version")
git tag "cli-v$VERSION"
git push origin "cli-v$VERSION"The workflow will:
- check out the repo,
- install deps with bun,
- verify the tag (
cli-v0.1.0) matchescli/package.jsonversion, - run
bun run buildto producedist/ranch.mjs, npm publish --provenance --access publicfromcli/.
Manual publish (one-off, e.g. to test on the next dist-tag):
GitHub → Actions → Publish CLI → Run workflow and pick a dist-tag.
Installing the published CLI:
npm install -g @cleanslice/ranch
ranch --help