opsos
v1.2.4
Published
Zero-config git-branch deploy CLI for MERN / Next.js / Vite projects
Downloads
2,486
Maintainers
Readme
opsos
Zero-config, incremental git-branch deploy CLI for MERN, Next.js, and Vite projects.
opsos is a lightweight command-line tool designed to build your project and deploy the output to a dedicated Git branch on your remote repository. By pushing only build artifacts to a branch (like stage or prod), your VPS/server can pull updates in seconds — completely bypassing complex Docker setups or resource-heavy CI/CD pipelines.
⚡ Key Features
- 🚀 Smart Auto-Detection: Automatically identifies Next.js (Standalone, Static Export, or Standard), Vite, Create React App, and generic frontend setups.
- ⏱️ Incremental Syncing: Only copies new or modified assets, keeping filesystem operations minimal and lightning-fast.
- 📁 File & Folder Copies: Configure custom file transfers in
deploy-config.jsonby copying entire directories or targeting individual files. - 🚫 Advanced Exclusions: Exclude specific files, extensions, or subfolders relative to your destination root.
- 🔧 Standalone Injection: Patches Next.js
server.jswith automated.envloaders and starting diagnostics upon deployment. - 💾 Git Caching: Retains a persistent
.deployGit environment locally to make subsequent deploys near-instant.
📦 Installation
Use npx to run it on-demand without installation:
npx opsos deploy prodOr install it globally / locally as a dev dependency:
# Global installation
npm install -g opsos
# As a dev dependency (recommended)
npm install -D opsos🛠️ CLI Usage
opsos deploy [branch] # Build and deploy to target branch (default: stage)
opsos init # Auto-detect project structure & generate deploy-config.json
opsos help # Show command helpRecommended package.json Scripts
Easily integrate opsos into your development workflow:
{
"scripts": {
"deploy:stage": "opsos deploy stage",
"deploy:prod": "opsos deploy prod"
}
}⚙️ Configuration (deploy-config.json)
To customize your builds, place a deploy-config.json in your project root. If not present, opsos will auto-generate one during the first run.
Default Auto-Detection Rules
| Project Type | Detection Trigger | Target Copy Source |
|---|---|---|
| Next.js Standalone | output: 'standalone' in next.config | .next/standalone |
| Next.js Static Export | output: 'export' in next.config | out/ (or customized distDir) |
| Vite | vite.config.* present | dist/ |
| Create React App | react-scripts in package.json | build/ |
| Generic | Fallback | dist/ |
Configuration Examples
1. Next.js Standalone (Default)
Optimized for production Node.js servers running Next.js standalone builds:
{
"buildCommand": "npm run build",
"copySteps": [
{
"src": ".next/standalone",
"dest": ".deploy",
"excludes": ["public", ".next/static", ".git"]
},
{ "src": ".next/static", "dest": ".deploy/.next/static" },
{ "src": "public", "dest": ".deploy/public" }
]
}2. Vite / Static Web Application
For static Single Page Applications (SPA) deploying to GitHub Pages, Netlify, or static servers:
{
"buildCommand": "npm run build",
"copySteps": [
{ "src": "dist", "dest": ".deploy" }
]
}3. Custom Assets & File Copying
You can copy specific files and apply exclusions to keep your target deployment clean:
{
"buildCommand": "npm run build",
"copySteps": [
{
"src": "dist",
"dest": ".deploy",
"excludes": [
"temp-cache.json",
"assets/ignored-file.png"
]
},
{
"src": "config/production.json",
"dest": ".deploy/config.json"
}
]
}🔄 How It Works Under the Hood
- Verify Target Branch: Checks if the target deploy branch exists on your remote
originrepository. - Version Increment: Runs
npm version patch --no-git-tag-versionto bump package version metadata cleanly. - Execute Build: Triggers the configured
buildCommand(e.g.npm run build). - Shallow Repo Setup: Clones the remote target branch into a cached
.deployfolder (using--depth 1). - Incremental Sync: Scans and pushes file updates from source directories/files into
.deploy/matching constraints and exclusions. - Deploy Server Injection: Automatically injects utility
.envloaders and port diagnostics into any deployedserver.jsfile. - Commit & Push: Commits changes as
Deploy version <x.y.z>and pushes directly to the remote Git branch.
[!TIP] Add
/.deployto your root.gitignorefile to ensure the temporary deployment directory remains out of your local development branch history.
🛡️ License
MIT © mytecsys
