onlyonce-cli
v1.0.2
Published
CLI tool for deploying frontend code to Only-Once
Maintainers
Readme
Only-Once CLI
Command-line tool for deploying frontend code to the Only-Once deployment service.
Installation
npm install -g onlyonce-cliOr use with npx (no installation needed):
npx onlyonce-cli deployUsage
Deploy with Auto-Detection
When no directory is provided, the CLI runs your project's build script and
auto-detects common output directories (build, dist, out, .next, public):
npx onlyonce-cli deployDeploy from Specific Directory
npx onlyonce-cli deploy ./build
npx onlyonce-cli deploy ./dist
npx onlyonce-cli deploy /path/to/your/buildOther Commands
npx onlyonce-cli device-login # Create or refresh a device session
npx onlyonce-cli --version # Show version
npx onlyonce-cli --help # Show helpConfiguration
Set the Only-Once API URL via environment variable:
export ONLY_ONCE_API_URL=http://localhost:3000
npx onlyonce-cli deployOr create a .env file:
ONLY_ONCE_API_URL=http://localhost:3000Default API URL: http://localhost:3000
Device Session Storage
The CLI stores the device token and ID in ~/.onlyonce/config.json. Running
npx onlyonce device-login refreshes this token and prepares the CLI for future
deployments.
How It Works
- Build: Runs your project's
buildscript if a directory is not provided - Auto-Detection: Finds common build directories (
build,dist,out,.next,public) - Zip: Archives the build output for upload
- Deployment: Uploads the zip to the Only-Once API
- Result: Returns the live CDN URL where your app is deployed
Examples
React App
npm run build
npx onlyonce-cli deploy ./buildNext.js App
npm run build
npx onlyonce-cli deploy ./outVite App
npm run build
npx onlyonce-cli deploy ./distCustom Build
# Build your app
npm run build
# Deploy
npx onlyonce-cli deploy ./custom-build-folderRequirements
- Node.js 18+
- Only-Once server running (see only-once)
- Built frontend project with
index.html
Troubleshooting
"Could not detect build directory"
Make sure you're in the project root and have built your project, or specify the directory manually:
npx onlyonce-cli deploy ./build"Could not connect to Only-Once API"
- Make sure the Only-Once server is running
- Check the API URL:
export ONLY_ONCE_API_URL=http://your-server:3000 - Verify network connectivity
"Directory does not contain index.html"
Make sure you're deploying the built/compiled output, not the source code. Most frameworks require a build step:
npm run build # or yarn build, etc.
npx onlyonce-cli deploy ./buildLicense
ISC
