npm package: @for-the-people-initiative/deploy
Description: One-command deployment to any platform. Part of the [For The People](https://github.com/ryuforthepeople) module ecosystem.
Latest version: 0.1.0

# @for-the-people/deploy

One-command deployment to any platform. Part of the [For The People](https://github.com/ryuforthepeople) module ecosystem.

## Packages

- **`@for-the-people/deploy-core`** - Core deployment adapters and types
- **`@for-the-people/deploy-cli`** - CLI tool for deployments

## Installation

```bash
# Core library
pnpm add @for-the-people/deploy-core

# CLI tool
pnpm add -g @for-the-people/deploy-cli
```

## Quick Start

### As a Library

```typescript
import { 
  createNetlifyAdapter, 
  createDeployService 
} from '@for-the-people/deploy-core';

// Create adapter
const adapter = createNetlifyAdapter({
  token: process.env.NETLIFY_AUTH_TOKEN!,
});

// Create service
const deploy = createDeployService({ adapter });

// Deploy a directory
const result = await deploy.deploy({
  source: 'directory',
  path: './dist',
  name: 'my-app',
});

console.log(`Deployed to: ${result.url}`);
```

### Using the CLI

```bash
# Deploy current directory
ftp-deploy deploy

# Deploy with options
ftp-deploy deploy ./dist --name my-app --wait

# Check status
ftp-deploy status abc123

# View logs
ftp-deploy logs abc123 --tail 100

# Rollback
ftp-deploy rollback abc123

# List projects
ftp-deploy projects list

# Set environment variables
ftp-deploy env set PROJECT_ID MY_VAR=value API_KEY=secret
```

## Providers

### Netlify ✅

Full support for static sites and serverless functions.

```bash
export NETLIFY_AUTH_TOKEN=your_token
ftp-deploy deploy --provider netlify
```

**Capabilities:**
- ✅ Static sites
- ✅ Serverless functions
- ✅ Environment variables
- ✅ Custom domains
- ✅ SSL
- ✅ Preview deployments
- ✅ Rollback
- ✅ Build logs

### Railway 🔜

Coming soon - server deployments with WebSocket support.

### Cloudflare Pages 🔜

Coming soon - edge deployments with Workers.

## Capabilities Pattern

Query what each provider supports:

```typescript
const caps = adapter.getCapabilities();

if (caps.targets.server) {
  // Can deploy long-running servers
}

if (caps.features.streaming) {
  // Can stream logs in real-time
}

if (!caps.limits.spinDown) {
  // Won't spin down on idle (good for always-on APIs)
}
```

## API Reference

### DeployAdapter Interface

```typescript
interface DeployAdapter {
  provider: string;
  getCapabilities(): DeployCapabilities;

  // Deployment
  deploy(config: DeployConfig): Promise<DeployResult>;
  getDeployment(id: string): Promise<DeployResult | null>;
  listDeployments(projectId: string, options?): Promise<DeployResult[]>;
  rollback(deploymentId: string): Promise<DeployResult>;

  // Projects
  createProject(name: string): Promise<Project>;
  getProject(id: string): Promise<Project | null>;
  listProjects(): Promise<Project[]>;
  deleteProject(id: string): Promise<void>;

  // Environment
  setEnvVars(projectId: string, vars: Record<string, string>): Promise<void>;
  getEnvVars(projectId: string): Promise<Record<string, string>>;

  // Domains
  addDomain(projectId: string, domain: string): Promise<DomainInfo>;
  removeDomain(projectId: string, domain: string): Promise<void>;

  // Logs
  getLogs(deploymentId: string, options?): Promise<LogEntry[]>;
  streamLogs?(deploymentId: string, callback): () => void;
}
```

### DeployConfig

```typescript
interface DeployConfig {
  source: 'directory' | 'git' | 'docker';
  path?: string;           // For directory source
  gitUrl?: string;         // For git source
  dockerImage?: string;    // For docker source
  
  name: string;            // Project name
  outputDirectory?: string; // e.g., "dist"
  buildCommand?: string;   // e.g., "pnpm build"
  startCommand?: string;   // For servers
  
  envVars?: Record<string, string>;
  production?: boolean;
}
```

## Development

```bash
# Install dependencies
pnpm install

# Build all packages
pnpm build

# Type check
pnpm typecheck
```

## License

MIT © [Ryu for the People](https://github.com/ryuforthepeople)