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-7/

SvelteKit Multi-Environment Project Scaffold

Build a Node.js CLI tool that scaffolds SvelteKit projects configured for multiple deployment environments. The tool should support both development and production configurations, leveraging automatic platform detection for deployments.

Requirements

Your tool should initialize a SvelteKit project structure with configuration files ready for multiple deployment scenarios.

Command Interface

The tool accepts the following command-line arguments:

  • --name <project-name>: Name of the project (required)
  • --adapter <type>: Adapter type - either auto for automatic detection or static for static site generation (default: auto)

Generated Structure

The tool must create:

  1. A project directory with the specified name
  2. A svelte.config.js file configured with the appropriate adapter
  3. A package.json file with necessary dependencies
  4. A .env.example file documenting supported deployment platforms (Vercel, Netlify, Cloudflare Pages)

Adapter Configuration

  • When --adapter auto is specified (or by default), configure the project to use automatic platform detection
  • When --adapter static is specified, configure the project for static site generation
  • The configuration should properly instantiate the adapter (calling it as a function)

Test Cases

  • Running the tool with --name my-app creates a directory structure with svelte.config.js configured for automatic adapter detection @test

  • Running the tool with --name my-app --adapter static creates a configuration using the static adapter @test

  • The generated package.json includes the correct adapter package as a dependency based on the selected type @test

Implementation

@generates

API

/**
 * Parses command line arguments
 *
 * @param {string[]} args - Command line arguments
 * @returns {object} Parsed options with name and adapter properties
 */
function parseArgs(args) {
  // Implementation here
}

/**
 * Generates svelte.config.js content for the specified adapter type
 *
 * @param {string} adapterType - Type of adapter ('auto' or 'static')
 * @returns {string} The svelte.config.js file content
 */
function generateSvelteConfig(adapterType) {
  // Implementation here
}

/**
 * Generates package.json content with correct adapter dependency
 *
 * @param {string} projectName - Name of the project
 * @param {string} adapterType - Type of adapter ('auto' or 'static')
 * @returns {string} The package.json file content
 */
function generatePackageJson(projectName, adapterType) {
  // Implementation here
}

/**
 * Creates the project directory structure and files
 *
 * @param {string} projectName - Name of the project
 * @param {string} adapterType - Type of adapter ('auto' or 'static')
 * @returns {Promise<void>}
 */
async function scaffoldProject(projectName, adapterType) {
  // Implementation here
}

module.exports = {
  parseArgs,
  generateSvelteConfig,
  generatePackageJson,
  scaffoldProject
};

Dependencies { .dependencies }

@sveltejs/adapter-auto { .dependency }

Provides automatic adapter detection and installation functionality for SvelteKit projects. The scaffolded projects will use this adapter by default.

@satisfied-by

Install with Tessl CLI

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

tile.json