@xec-sh/ops
The DevOps operations library. Use it standalone in any TypeScript/JavaScript project — no CLI required.
Installation
pnpm add @xec-sh/ops
Modules
| Module | Purpose | Key Class |
|---|---|---|
| Deploy | Deployment with strategies & rollback | Deployer |
| Pipeline | CI/CD pipeline with matrix builds | Pipeline |
| Workflow | DAG-based task orchestration | Workflow |
| Health | HTTP/TCP/command health checks | HealthChecker |
| Discovery | Docker/K8s/SSH infrastructure discovery | Discovery |
| Retry | Retry policies with backoff | RetryPolicy |
| Config | Configuration management | ConfigurationManager |
| Secrets | Encrypted secret storage | SecretManager |
Quick Example
import { Deployer, HealthChecker, Pipeline } from '@xec-sh/ops';
// Deploy with health verification
const deployer = Deployer.create({
name: 'api-service',
targets: ['web-1', 'web-2', 'web-3'],
strategy: 'rolling',
maxConcurrent: 1,
hooks: {
deploy: async (ctx) => {
await ctx.exec`docker pull myapp:${ctx.version}`;
await ctx.exec`docker-compose up -d`;
},
verify: async (ctx) => ctx.healthCheck(),
rollback: async (ctx) => {
await ctx.exec`docker-compose down`;
await ctx.exec`docker pull myapp:${ctx.previousVersion}`;
await ctx.exec`docker-compose up -d`;
},
},
healthCheck: {
url: 'http://{{target}}:8080/health',
retries: 3,
},
});
const result = await deployer.deploy('v1.2.3');
if (!result.success) {
console.error('Deploy failed, rolling back...');
await deployer.rollback();
}
Design Principles
- Library-first — No CLI dependency. Import and use in any project.
- Fluent API — Chainable builders for readable configuration.
- Composable — Each module works independently.
- Type-safe — Full TypeScript with strict mode.
- Customizable — Override any default via
ConfigManagerOptions.