CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-oclif

A comprehensive CLI framework for creating command-line interfaces in Node.js and TypeScript

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

upload-deployment.mddocs/

Upload and Deployment

Upload packaged CLIs to AWS S3 and manage distribution channels for automatic updates and releases.

Capabilities

Upload Tarballs

Upload compressed tarballs to S3 for distribution and automatic updates.

oclif upload tarballs

Flags:

  • --root, -r (string) - Root directory of the CLI project (default: ".")
  • --targets, -t (string) - Comma-separated targets to upload
  • --xz (boolean) - Also upload xz compressed tarballs
  • --sha (string) - Git SHA to include in upload metadata
  • --dry-run (boolean) - Run without uploading to S3

Usage Examples:

# Upload all tarballs to S3
oclif upload tarballs

# Upload specific targets
oclif upload tarballs --targets=linux-x64,darwin-x64

# Upload with xz compression
oclif upload tarballs --xz

# Uploads tarballs from ./dist/tarballs/ to configured S3 bucket

Requirements:

  • AWS credentials configured (AWS CLI, environment variables, or IAM roles)
  • S3 bucket and configuration set in package.json
  • Tarballs must be built first using oclif pack tarballs

Upload Debian Packages

Upload .deb packages to S3 for Debian/Ubuntu distribution.

oclif upload deb

Flags:

  • --root, -r (string) - Root directory of the CLI project (default: ".")
  • --sha (string) - Git SHA to include in upload metadata
  • --dry-run (boolean) - Run without uploading to S3

Usage Examples:

# Upload Debian packages
oclif upload deb

# Upload with dry run
oclif upload deb --dry-run

# Uploads .deb files from ./dist/deb/ to S3

Upload macOS Packages

Upload macOS installer packages to S3 for distribution.

oclif upload macos

Flags:

  • --root, -r (string) - Root directory of the CLI project (default: ".")
  • --targets, -t (string) - Comma-separated targets to upload
  • --sha (string) - Git SHA to include in upload metadata
  • --dry-run (boolean) - Run without uploading to S3

Usage Examples:

# Upload macOS installers
oclif upload macos

# Upload specific targets
oclif upload macos --targets=darwin-x64,darwin-arm64

# Uploads .pkg files from ./dist/macos/ to S3

Upload Windows Packages

Upload Windows installer packages to S3 for distribution.

oclif upload win

Flags:

  • --root, -r (string) - Root directory of the CLI project (default: ".")
  • --targets (string) - Comma-separated targets to upload
  • --sha (string) - Git SHA to include in upload metadata
  • --dry-run (boolean) - Run without uploading to S3

Usage Examples:

# Upload Windows installers
oclif upload win

# Upload specific targets
oclif upload win --targets=win32-x64,win32-x86

# Uploads .exe and .msi files from ./dist/win32/ to S3

Promote Releases

Promote CLI builds to release channels for controlled distribution and staged rollouts.

oclif promote

Flags:

  • --channel (string) - Release channel (stable, beta, alpha) (default: "stable")
  • --version (string) - Semantic version to promote (required)
  • --sha (string) - 7-digit short git commit SHA to promote (required)
  • --root, -r (string) - Root directory of the CLI project (default: ".")
  • --targets, -t (string) - Comma-separated list of targets to promote
  • --deb, -d (boolean) - Promote Debian packages
  • --macos, -m (boolean) - Promote macOS packages
  • --win, -w (boolean) - Promote Windows packages
  • --xz (boolean) - Also promote xz compressed tarballs
  • --indexes (boolean) - Append promoted URLs to index files
  • --max-age, -a (string) - Cache control max-age in seconds (default: "86400")
  • --dry-run (boolean) - Preview promotion without making changes
  • --ignore-missing (boolean) - Continue promoting even if some artifacts are missing

Usage Examples:

# Promote current version to stable channel
oclif promote --channel=stable

# Promote specific version and SHA
oclif promote --version=1.2.3 --sha=abc123 --channel=beta

# Promote with dry run to preview changes
oclif promote --channel=stable --dry-run

# Promote specific platforms only
oclif promote --targets=linux-x64,darwin-x64 --macos --channel=stable

AWS S3 Integration

oclif provides comprehensive S3 integration for hosting and distributing CLI packages.

S3 Operations

interface AWSS3Operations {
  /** Upload file to S3 with progress tracking */
  uploadFile(
    localPath: string, 
    options: S3UploadOptions,
    config?: S3Config
  ): Promise<void>;

  /** Copy object within S3 */
  copyObject(
    options: S3CopyOptions,
    config?: S3Config
  ): Promise<void>;

  /** Get object metadata */
  headObject(options: S3HeadOptions): Promise<S3HeadResult>;

  /** Get object content */
  getObject(options: S3GetOptions): Promise<S3GetResult>;

  /** List objects in bucket */
  listObjects(options: S3ListOptions): Promise<S3ListResult>;

  /** Delete multiple objects */
  deleteObjects(options: S3DeleteOptions): Promise<void>;
}

interface S3UploadOptions {
  bucket: string;
  key: string;
  acl?: string;
  contentType?: string;
  metadata?: Record<string, string>;
}

interface S3CopyOptions {
  sourceBucket: string;
  sourceKey: string;
  destinationBucket: string;
  destinationKey: string;
  acl?: string;
}

CloudFront Integration

interface CloudFrontOperations {
  /** Create CloudFront cache invalidation */
  createCloudfrontInvalidation(options: CloudFrontInvalidationOptions): Promise<void>;
}

interface CloudFrontInvalidationOptions {
  distributionId: string;
  paths: string[];
  callerReference?: string;
}

Update Mechanism

oclif supports automatic updates through S3-hosted version manifests and update channels.

Update Configuration

interface UpdateConfiguration {
  /** Automatic update settings */
  autoupdate?: {
    /** Rollout percentage (0-100) */
    rollout: number;
    /** Debounce time in minutes */
    debounce: number;
  };
  /** Node.js runtime version */
  node?: {
    version: string;
  };
  /** S3 hosting configuration */
  s3?: {
    bucket: string;
    /** S3 key prefix/folder */
    folder?: string;
    /** Custom host URL for downloads */
    host?: string;
    /** S3 ACL permissions */
    acl?: string;
    /** Maximum versions to keep in index */
    indexVersionLimit?: number;
    /** Use xz compression */
    xz?: boolean;
  };
}

Release Channels

oclif supports multiple release channels for staged rollouts:

  • stable: Production releases
  • beta: Pre-release testing
  • alpha: Early development builds
  • dev: Development builds

Version Indexes

Version indexes track available versions and update metadata:

interface VersionIndex {
  /** Channel name */
  channel: string;
  /** Available versions */
  versions: VersionMetadata[];
  /** Current/latest version */
  current: string;
}

interface VersionMetadata {
  version: string;
  sha: string;
  date: string;
  /** Platform-specific download URLs */
  downloads: Record<Target, DownloadInfo>;
}

interface DownloadInfo {
  url: string;
  sha256: string;
  size: number;
}

Upload Utilities

Helper functions for upload and deployment operations.

/**
 * Check if endpoint is S3-compatible
 * @param endpoint - S3 endpoint URL
 * @returns True if endpoint supports S3 API
 */
function isS3Compatible(endpoint: string): boolean;

/**
 * Get S3 checksum configuration
 * @param endpoint - S3 endpoint
 * @param envValue - Environment variable value
 * @returns S3 checksum settings
 */
function getS3ChecksumConfig(
  endpoint: string, 
  envValue?: string
): S3ChecksumConfig;

interface S3ChecksumConfig {
  algorithm: 'SHA256' | 'SHA1' | 'CRC32' | 'CRC32C';
  enabled: boolean;
}

Deployment Workflow

Typical deployment workflow for oclif CLIs:

  1. Build: oclif pack tarballs --targets=linux-x64,darwin-x64,win32-x64
  2. Upload: oclif upload tarballs
  3. Promote: oclif promote --channel=beta
  4. Test: Verify beta channel functionality
  5. Release: oclif promote --channel=stable

Environment Variables

Required environment variables for S3 operations:

# AWS credentials
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_REGION=us-east-1

# Optional: Custom S3 endpoint
AWS_S3_ENDPOINT=https://s3.custom-domain.com

# Optional: CloudFront distribution
CLOUDFRONT_DISTRIBUTION_ID=ABCDEFGHIJKLMN

Package.json S3 Configuration

{
  "oclif": {
    "update": {
      "s3": {
        "bucket": "my-cli-releases",
        "folder": "releases/mycli",
        "host": "https://releases.mycli.com",
        "acl": "public-read",
        "indexVersionLimit": 20,
        "xz": true
      },
      "autoupdate": {
        "rollout": 100,
        "debounce": 60
      }
    }
  }
}

Install with Tessl CLI

npx tessl i tessl/npm-oclif

docs

cli-management.md

code-generation.md

index.md

packaging.md

programmatic-api.md

upload-deployment.md

tile.json