CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-sveltejs--adapter-auto

SvelteKit adapter that automatically detects deployment environment and installs appropriate platform-specific adapter

Overall
score

96%

Overview
Eval results
Files

task.mdevals/scenario-1/

Build Environment Adapter Selector

Build a command-line tool that automatically selects and configures build adapters based on detected environment variables. The tool should detect various deployment platforms, handle missing dependencies gracefully, and provide clear guidance when problems occur.

Requirements

Environment Detection

The tool should detect deployment environments by checking for specific environment variables:

  • Check for DEPLOY_PLATFORM environment variable that can be set to: "vercel", "netlify", "cloudflare", or "aws"
  • Check for CI_ENVIRONMENT variable to distinguish between local and CI builds

Adapter Configuration

When an environment is detected:

  • Log which environment was detected
  • Return an appropriate configuration object with platform-specific settings
  • If the environment is "local" (no platform detected), provide a warning message with guidance on setting environment variables

Error Handling and Guidance

The tool must handle several error scenarios with helpful messages:

  1. Missing Configuration File: When a required config file is missing, provide a clear error message that explains which file is needed and where it should be located

  2. Invalid Environment Value: When DEPLOY_PLATFORM is set to an unsupported value, provide an error message listing all supported platforms

  3. Conflicting Settings: When both DEPLOY_PLATFORM and a platform-specific environment variable (e.g., VERCEL_ENV) are set but don't match, provide a warning about the conflict and explain which one will be used

  4. Installation Guidance: When suggesting installation of dependencies, detect whether the project uses npm, pnpm, or yarn by checking for lockfiles (package-lock.json, pnpm-lock.yaml, yarn.lock) and provide the appropriate install command

Command-Line Interface

The tool should:

  • Accept a --check flag that validates the environment without actually configuring anything
  • Accept a --verbose flag for detailed logging
  • Exit with appropriate status codes (0 for success, 1 for errors, 2 for warnings)

Test Cases

  • When DEPLOY_PLATFORM=vercel, the tool detects Vercel and returns appropriate configuration @test
  • When no platform environment variables are set, the tool provides a helpful warning with setup instructions @test
  • When DEPLOY_PLATFORM=unsupported, the tool shows an error listing valid platform options @test
  • When a pnpm-lock.yaml file exists, installation guidance uses pnpm add -D commands @test

@generates

API

/**
 * Detects the deployment environment and returns appropriate configuration
 * @param {Object} options - Configuration options
 * @param {boolean} options.verbose - Enable verbose logging
 * @param {boolean} options.checkOnly - Only validate without configuring
 * @returns {Object} Configuration object with platform settings and any warnings/errors
 */
function detectEnvironment(options = {}) {
  // Implementation
}

/**
 * Provides installation guidance based on the project's package manager
 * @param {string} packageName - The package to install
 * @returns {string} The appropriate install command
 */
function getInstallCommand(packageName) {
  // Implementation
}

/**
 * Validates that environment settings are consistent and supported
 * @returns {Object} Validation result with any errors or warnings
 */
function validateEnvironment() {
  // Implementation
}

module.exports = {
  detectEnvironment,
  getInstallCommand,
  validateEnvironment
};

Dependencies { .dependencies }

@sveltejs/adapter-auto { .dependency }

Reference implementation for automatic adapter detection and error handling patterns.

Install with Tessl CLI

npx tessl i tessl/npm-sveltejs--adapter-auto

tile.json