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

Package Manager Detector

Build a utility module that detects which package manager is being used in a project and generates appropriate installation commands.

Requirements

Your module should provide functions to:

  1. Detect the package manager being used in a project by checking for lockfiles in the current directory or any parent directories up to the filesystem root. Check in this priority order:

    • pnpm-lock.yaml indicates pnpm
    • yarn.lock indicates yarn
    • package-lock.json indicates npm
    • bun.lockb or bun.lock indicates bun
    • deno.lock indicates deno
    • If no lockfile is found, default to npm
  2. Generate appropriate install commands for different package managers. Given a package manager name, package name, and version, construct the correct command to install it as a development dependency.

The install command formats are:

  • npm: npm install -D <package>@<version>
  • pnpm: pnpm add -D <package>@<version>
  • yarn: yarn add -D <package>@<version>
  • bun: bun add -D <package>@<version>
  • deno: deno install -D npm:<package>@<version>

Test Cases

  • When a pnpm-lock.yaml file exists in the current directory, detectLockfile() returns 'pnpm' @test

  • When a yarn.lock file exists in the current directory, detectLockfile() returns 'yarn' @test

  • When a package-lock.json file exists in the current directory, detectLockfile() returns 'npm' @test

  • When no lockfile exists in any directory up to root, detectLockfile() returns 'npm' as the default @test

  • generateInstallCommand('pnpm', 'lodash', '4.17.21') returns 'pnpm add -D lodash@4.17.21' @test

  • generateInstallCommand('deno', 'lodash', '4.17.21') returns 'deno install -D npm:lodash@4.17.21' @test

Implementation

@generates

API

/**
 * Detects which package manager is being used by searching for lockfiles
 * in the current directory and parent directories.
 * @returns {string} The detected package manager name ('npm', 'pnpm', 'yarn', 'bun', or 'deno')
 */
export function detectLockfile() {
  // implementation
}

/**
 * Generates the install command for a given package manager
 * @param {string} manager - The package manager ('npm', 'pnpm', 'yarn', 'bun', or 'deno')
 * @param {string} packageName - The name of the package to install
 * @param {string} version - The version to install
 * @returns {string} The install command string
 */
export function generateInstallCommand(manager, packageName, version) {
  // implementation
}

Dependencies { .dependencies }

@sveltejs/adapter-auto { .dependency }

Provides multi-package manager detection and command generation functionality.

@satisfied-by

Install with Tessl CLI

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

tile.json