SvelteKit adapter that automatically detects deployment environment and installs appropriate platform-specific adapter
Overall
score
96%
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.
The tool should detect deployment environments by checking for specific environment variables:
DEPLOY_PLATFORM environment variable that can be set to: "vercel", "netlify", "cloudflare", or "aws"CI_ENVIRONMENT variable to distinguish between local and CI buildsWhen an environment is detected:
The tool must handle several error scenarios with helpful messages:
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
Invalid Environment Value: When DEPLOY_PLATFORM is set to an unsupported value, provide an error message listing all supported platforms
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
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
The tool should:
--check flag that validates the environment without actually configuring anything--verbose flag for detailed loggingDEPLOY_PLATFORM=vercel, the tool detects Vercel and returns appropriate configuration @testDEPLOY_PLATFORM=unsupported, the tool shows an error listing valid platform options @testpnpm-lock.yaml file exists, installation guidance uses pnpm add -D commands @test@generates
/**
* 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
};Reference implementation for automatic adapter detection and error handling patterns.
Install with Tessl CLI
npx tessl i tessl/npm-sveltejs--adapter-autodocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10