CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-netlify-cli

Netlify command line tool for deploying and managing modern web applications on the Netlify platform

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

build-system.mddocs/

Build System

Local and remote build functionality with context support, offline capabilities, and production serving for testing built applications locally.

Capabilities

Local Build

Build projects locally using Netlify Build system with full context support and plugin integration.

/**
 * Build project locally
 * Command: netlify build [options]
 */
interface BuildOptions {
  /** Deploy context for environment variables and plugins (default: production) */
  context?: 'production' | 'deploy-preview' | 'branch-deploy' | 'dev' | string;
  /** Show build instructions without executing (dry run) */
  dry?: boolean;
  /** Disable network-dependent features during build */
  offline?: boolean;
}

Usage Examples:

# Build for production context
netlify build

# Build for specific context
netlify build --context deploy-preview

# Dry run to see build commands
netlify build --dry

# Build offline (skip network features)
netlify build --offline

# Build for development context
netlify build --context dev

Production Serve

Serve built applications locally to test production builds before deployment.

/**
 * Build and serve project locally for production testing
 * Command: netlify serve [options]
 */
interface ServeOptions {
  /** Deploy context for build and serve */
  context?: 'production' | 'deploy-preview' | 'branch-deploy' | 'dev' | string;
  /** Port for local server */
  port?: number;
  /** Static files directory to serve */
  dir?: string;
  /** Functions folder */
  functions?: string;
  /** Disable network-dependent features */
  offline?: boolean;
  /** Disable edge functions */
  internalDisableEdgeFunctions?: boolean;
  /** Functions server port */
  functionsPort?: number;
  /** Geolocation mode for testing */
  geo?: 'cache' | 'mock' | 'update';
  /** Country code for geo mocking */
  country?: string;
  /** Static server port */
  staticServerPort?: number;
}

Usage Examples:

# Build and serve for production
netlify serve

# Serve on custom port
netlify serve --port 8080

# Serve with custom directory
netlify serve --dir dist

# Serve with functions
netlify serve --functions ./lambda --port 3000

# Serve for specific context
netlify serve --context deploy-preview

# Serve with geolocation mocking
netlify serve --geo mock --country US

# Serve offline
netlify serve --offline

Build Configuration

Build system configuration and integration with netlify.toml:

/**
 * Build configuration structure
 */
interface BuildConfig {
  /** Build settings */
  build: {
    /** Build command to execute */
    command?: string;
    /** Directory to publish (relative to repo root) */
    publish?: string;
    /** Functions directory */
    functions?: string;
    /** Base directory for build */
    base?: string;
    /** Environment variables for build */
    environment?: Record<string, string>;
    /** Build processing */
    processing: {
      /** CSS optimization */
      css?: {
        bundle: boolean;
        minify: boolean;
      };
      /** JavaScript optimization */
      js?: {
        bundle: boolean;
        minify: boolean;
      };
      /** HTML optimization */
      html?: {
        pretty_urls: boolean;
      };
      /** Image optimization */
      images?: {
        compress: boolean;
      };
    };
  };
  
  /** Context-specific build settings */
  context: {
    [contextName: string]: {
      command?: string;
      publish?: string;
      functions?: string;
      environment?: Record<string, string>;
    };
  };
  
  /** Branch-specific settings */
  [branchName: string]: {
    command?: string;
    publish?: string;
    functions?: string;
    environment?: Record<string, string>;
  };
}

Build Plugins

Integration with Netlify Build plugins for extended functionality:

/**
 * Build plugin configuration
 */
interface BuildPlugins {
  /** Plugin list and configuration */
  plugins: Array<{
    /** Plugin package name */
    package: string;
    /** Plugin inputs/configuration */
    inputs?: Record<string, any>;
    /** Conditions for plugin execution */
    conditions?: {
      /** Only run in specific contexts */
      context?: string[];
      /** Only run for specific branches */
      branch?: string[];
      /** Environment variable conditions */
      env?: Record<string, string>;
    };
  }>;
  
  /** Popular build plugins */
  common: {
    /** Essential plugins */
    essential: [
      '@netlify/plugin-essential-next',
      '@netlify/plugin-gatsby',
      '@netlify/plugin-nuxt'
    ];
    /** Optimization plugins */
    optimization: [
      'netlify-plugin-minify-html',
      'netlify-plugin-image-optim',
      'netlify-plugin-inline-critical-css'
    ];
    /** SEO and analytics */
    seo: [
      'netlify-plugin-sitemap',
      'netlify-plugin-lighthouse',
      '@netlify/plugin-google-analytics'
    ];
    /** Security plugins */
    security: [
      'netlify-plugin-csp-generator',
      'netlify-plugin-security-txt'
    ];
  };
}

Build Process and Lifecycle

Build process stages and lifecycle hooks:

/**
 * Build lifecycle stages
 */
interface BuildLifecycle {
  /** Pre-build stage */
  preBuild: {
    /** Install dependencies */
    install: boolean;
    /** Run pre-build commands */
    commands: string[];
    /** Plugin pre-build hooks */
    pluginHooks: string[];
  };
  
  /** Build stage */
  build: {
    /** Main build command */
    command: string;
    /** Build timeout */
    timeout: number; // seconds
    /** Environment variables */
    environment: Record<string, string>;
    /** Working directory */
    workingDirectory: string;
  };
  
  /** Post-build stage */
  postBuild: {
    /** Post-build commands */
    commands: string[];
    /** Plugin post-build hooks */
    pluginHooks: string[];
    /** Asset processing */
    assetProcessing: boolean;
  };
  
  /** Pre-deploy stage */
  preDeploy: {
    /** Pre-deploy commands */
    commands: string[];
    /** File transformations */
    transformations: string[];
    /** Security scans */
    securityScans: boolean;
  };
}

Framework Detection and Integration

Automatic framework detection and configuration:

/**
 * Framework detection system
 */
interface FrameworkDetection {
  /** Detected framework information */
  detected: {
    /** Framework name */
    name: 'gatsby' | 'next' | 'react' | 'vue' | 'angular' | 'hugo' | 'jekyll' | 'eleventy' | 'svelte' | 'nuxt' | 'vite' | 'remix' | 'astro';
    /** Framework version */
    version: string;
    /** Detection confidence */
    confidence: number; // 0-1
    /** Detection method */
    detectedBy: 'package.json' | 'config-file' | 'file-structure';
  };
  
  /** Framework-specific settings */
  settings: {
    /** Default build command */
    buildCommand: string;
    /** Default publish directory */
    publishDir: string;
    /** Default functions directory */
    functionsDir?: string;
    /** Framework-specific environment variables */
    environment: Record<string, string>;
    /** Required plugins */
    plugins: string[];
    /** Development server settings */
    devCommand: string;
    devPort: number;
  };
  
  /** Framework overrides */
  overrides: {
    /** Custom build command */
    buildCommand?: string;
    /** Custom publish directory */
    publishDir?: string;
    /** Custom environment variables */
    environment?: Record<string, string>;
    /** Additional plugins */
    additionalPlugins?: string[];
  };
}

Build Environment

Build environment configuration and variables:

/**
 * Build environment configuration
 */
interface BuildEnvironment {
  /** System environment */
  system: {
    /** Operating system */
    os: 'ubuntu-20.04' | 'ubuntu-22.04';
    /** Node.js version */
    nodeVersion: string;
    /** npm version */
    npmVersion: string;
    /** yarn version */
    yarnVersion?: string;
    /** Python version */
    pythonVersion?: string;
    /** Ruby version */
    rubyVersion?: string;
    /** Go version */
    goVersion?: string;
    /** Available memory */
    memory: number; // MB
    /** Available disk space */
    diskSpace: number; // GB
  };
  
  /** Build-specific variables */
  buildVars: {
    /** Netlify build variables */
    netlify: {
      BUILD_ID: string;
      DEPLOY_ID: string;
      CONTEXT: string;
      BRANCH: string;
      HEAD: string;
      COMMIT_REF: string;
      REPOSITORY_URL: string;
      URL: string;
      DEPLOY_URL: string;
      DEPLOY_PRIME_URL: string;
      SITE_ID: string;
      SITE_NAME: string;
      NETLIFY: 'true';
      NETLIFY_BUILD_BASE: string;
      NETLIFY_BUILD_LIFECYCLE_TRIAL: string;
    };
    
    /** User-defined variables */
    user: Record<string, string>;
    
    /** Context-specific variables */
    context: Record<string, string>;
  };
  
  /** Cache configuration */
  cache: {
    /** Build cache directory */
    directory: string;
    /** Cache key */
    key: string;
    /** Cache dependencies */
    dependencies: string[];
    /** Cache max age */
    maxAge: number; // seconds
  };
}

Build Output and Artifacts

Build output handling and artifact management:

/**
 * Build output configuration
 */
interface BuildOutput {
  /** Output directories */
  directories: {
    /** Main publish directory */
    publish: string;
    /** Functions output directory */
    functions?: string;
    /** Edge functions directory */
    edgeFunctions?: string;
    /** Static assets directory */
    assets?: string;
  };
  
  /** File processing */
  processing: {
    /** Files to include in deploy */
    include: string[];
    /** Files to exclude from deploy */
    exclude: string[];
    /** File transformations */
    transforms: Array<{
      from: string;
      to: string;
      transform: 'minify' | 'compress' | 'optimize' | 'rename';
    }>;
  };
  
  /** Build artifacts */
  artifacts: {
    /** Build logs */
    logs: {
      path: string;
      level: 'error' | 'warn' | 'info' | 'debug';
      format: 'text' | 'json';
    };
    /** Test results */
    tests?: {
      path: string;
      format: 'junit' | 'tap' | 'json';
    };
    /** Coverage reports */
    coverage?: {
      path: string;
      format: 'lcov' | 'json' | 'html';
    };
    /** Bundle analysis */
    bundleAnalysis?: {
      path: string;
      format: 'json' | 'html';
    };
  };
}

Build Performance and Optimization

Build performance monitoring and optimization features:

/**
 * Build performance configuration
 */
interface BuildPerformance {
  /** Performance monitoring */
  monitoring: {
    /** Build time tracking */
    timing: {
      enabled: boolean;
      breakdown: boolean; // per-stage timing
    };
    /** Resource usage tracking */
    resources: {
      memory: boolean;
      cpu: boolean;
      disk: boolean;
    };
  };
  
  /** Optimization settings */
  optimization: {
    /** Parallel processing */
    parallel: {
      enabled: boolean;
      maxWorkers: number;
    };
    /** Incremental builds */
    incremental: {
      enabled: boolean;
      cacheStrategy: 'aggressive' | 'conservative';
    };
    /** Dependency optimization */
    dependencies: {
      /** Dependency caching */
      cache: boolean;
      /** Install optimization */
      optimizeInstall: boolean;
    };
  };
  
  /** Build limits */
  limits: {
    /** Maximum build time */
    timeout: number; // minutes
    /** Maximum log size */
    maxLogSize: number; // MB
    /** Maximum output size */
    maxOutputSize: number; // MB
  };
}

Error Handling and Debugging

Build error handling and debugging capabilities:

/**
 * Build error handling configuration
 */
interface BuildErrorHandling {
  /** Error detection */
  detection: {
    /** Exit code monitoring */
    exitCodes: boolean;
    /** Log pattern matching */
    logPatterns: string[];
    /** Timeout detection */
    timeouts: boolean;
  };
  
  /** Error reporting */
  reporting: {
    /** Error categorization */
    categorize: boolean;
    /** Stack trace capture */
    stackTraces: boolean;
    /** Context information */
    contextInfo: boolean;
  };
  
  /** Recovery options */
  recovery: {
    /** Automatic retry */
    autoRetry: {
      enabled: boolean;
      maxAttempts: number;
      backoffStrategy: 'linear' | 'exponential';
    };
    /** Fallback builds */
    fallback: {
      enabled: boolean;
      strategy: 'previous-successful' | 'minimal';
    };
  };
  
  /** Debug features */
  debug: {
    /** Debug mode */
    enabled: boolean;
    /** Verbose logging */
    verbose: boolean;
    /** Build shell access */
    shellAccess: boolean;
    /** Environment inspection */
    envInspection: boolean;
  };
}

docs

authentication-teams.md

blobs-storage.md

build-system.md

deployment.md

environment-variables.md

functions.md

index.md

local-development.md

site-management.md

tile.json