SvelteKit adapter that automatically detects deployment environment and installs appropriate platform-specific adapter
Overall
score
96%
Build a utility module that detects which package manager is being used in a project and generates appropriate installation commands.
Your module should provide functions to:
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 pnpmyarn.lock indicates yarnpackage-lock.json indicates npmbun.lockb or bun.lock indicates bundeno.lock indicates denoGenerate 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 install -D <package>@<version>pnpm add -D <package>@<version>yarn add -D <package>@<version>bun add -D <package>@<version>deno install -D npm:<package>@<version>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
@generates
/**
* 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
}Provides multi-package manager detection and command generation functionality.
@satisfied-by
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