presetter use
Adopt one or more preset packages in the project containing the nearest package.json.
npx presetter use @presetter/preset-esm @presetter/preset-strict
Preset arguments accept names, versions, ranges, or tags, such as @presetter/preset-esm@^9.
What It Does
- Install Presetter and requested presets as development dependencies.
- Write
presetter.config.tswith the requested stack and the project's package name. - Resolve
setupthrough the stack'sextendsgraph and finaloverride.setuppass. - Install missing
dependencies,devDependencies, andpeerDependencies, and add declared package script delegates. - Bootstrap the tool configuration assets.
Only use applies setup. bootstrap regenerates assets from an existing config without installing packages or changing package scripts.
Package Manager Selection
Selection follows this order:
package.json#packageManager.- Exactly one lockfile family in the project root: npm (
package-lock.jsonornpm-shrinkwrap.json), pnpm (pnpm-lock.yaml), or Bun (bun.lockorbun.lockb). --package-manager=npm|pnpm|bun.- An interactive prompt.
# Choose a fallback for a fresh project
npx presetter use @presetter/preset-esm --package-manager=npm
pnpm dlx presetter use @presetter/preset-esm --package-manager=pnpm
bunx presetter use @presetter/preset-esm --package-manager=bun
The flag does not override a detected manager. Missing or conflicting lockfiles fall back to the flag or prompt. Non-interactive use without a selection fails. An unsupported packageManager value (including Yarn) fails before the fallback is considered; yarn.lock does not select a manager. The selected binary runs from PATH; Presetter does not enforce its version.
Existing Configs and Reruns
An identical generated presetter.config.ts can be reused. A differing .ts config or any .mts, .mjs, or .js config stops adoption before installation or file writes. For an existing custom config, edit it and run bootstrap; use the manual installation route for setup packages and scripts.
Already declared packages keep their dependency sections and specifications. Runtime setup skips packages present in any dependency section; development setup skips existing runtime or development dependencies. Peer setup skips existing runtime and peer declarations when preserving them, and adds peers directly when a development dependency already exists. A differing specification is reported and preserved unless you pass --force:
npx presetter use @presetter/preset-esm --force
--force replaces conflicting package specifications; it does not overwrite custom config files or existing script commands. Matching scripts succeed, while differing local scripts are logged as skipped.
Dependency Build Approval
If the package manager blocks dependency install scripts, use lists the pending builds and asks for approval. Declining, empty input, or EOF still writes the config and scripts, but skips bootstrap and prints the approval command. Run that command, then presetter bootstrap to finish setup.
Declaring Setup in a Preset
import { preset } from 'presetter';
export default preset('@acme/preset', {
setup: {
devDependencies: { vitest: '^5.0.0' },
scripts: { test: 'run test --' },
},
scripts: { test: 'vitest run' },
});
Setup commands are literal: inline or generator-returned strings do not substitute {variable} placeholders. Use scripts for runtime templates and setup.scripts for package.json delegates.