Skip to content

About

Provides the ability to quickly create preset projects.

Resources

Stars

46 stars

Watchers

1 watching

Forks

Repository files navigation

create-preset

create-preset

Create projects with official generators and declarative JSON presets.

npm version npm downloads documentation GitHub stars

English | 简体中文

Quick start

Node.js and a package manager are required for official generators. Git is required for presets that clone a repository.

Run the interactive flow through npm's package runner:

npm create preset

The flow asks for a project directory, technology stack, and starter. The selected official CLI owns the remaining prompts and generated files.

For repeated use, install the package globally:

npm install --global create-preset
preset

Common commands

# List available starter IDs
preset --list

# Select a starter interactively
preset

# Create from a registered official or private preset
preset init my-app --from vite

# Create from a local or remote preset.json
preset init my-docs --from ./preset.json
preset init my-docs --from https://example.com/preset.json

# Choose the package manager used by an official generator
preset init my-app --from vue --package-manager pnpm

# Preview a generator or JSON preset without creating a project
preset init my-app --from vite --dry-run
preset init my-docs --from ./preset.json --dry-run

# Explicitly allow replacing an existing directory in a script
preset init my-app --from vite --yes

# Inspect or change the private preset manifest
preset config get
preset config set /path/to/private-presets.json
preset config remove

# Update a global installation
preset upgrade

--from accepts an official generator ID, a private preset name, or a .json config path or URL. The --package-manager option accepts npm, yarn, pnpm, and bun. Without that option, Create Preset detects the package manager from the current npm user agent and falls back to npm. An unknown explicit --from value exits with an error; it never switches to interactive selection. Run preset --list to see registered IDs.

--dry-run prints a JSON creation plan without cloning repositories, running generators, resolving npm versions, or changing project files. Remote config URLs are still fetched and validated. --yes skips only the confirmation for replacing existing target files; official generators keep their own prompts.

Private presets are generated in a temporary directory before replacing the target. Original target files are backed up while an official generator runs and restored if it fails or exits without creating a project.

Official generators

Official generators remain responsible for their own prompts, dependencies, and output. Create Preset currently exposes these IDs:

Technology IDs
Vue vue, nuxt
React next-app, react-router, expo-app
Vite vite
Astro astro
Svelte svelte (SvelteKit)

Direct selection is useful for scripts and documentation examples:

preset init demo --from next-app --package-manager npm

Private presets

Private presets add repository starters or declarative configs to the interactive catalog. Bind one manifest file globally:

preset config set /path/to/private-presets.json
preset init company-service

Private entries appear before built-in generators in the same technology stack, and custom technology IDs are supported. The manifest can use a simple array or a versioned object when a custom label or color is needed. See Private presets.

Hosted preset configs

A project can publish a preset.json without maintaining another CLI. The config describes a repository source and the transformations needed to turn a starter into a new project:

preset init my-docs --from https://example.com/preset.json

Supported operations include selecting a monorepo directory, excluding files, writing files, replacing text, merging JSON, and resolving workspace: dependencies. See Preset configs and the published schema.

Locale

The CLI follows the system locale and includes English, Simplified Chinese, Traditional Chinese, and Japanese. Set PRESET_LANG to override detection:

PRESET_LANG=ja-JP preset init demo

Supported values are en-US, zh-CN, zh-HK, and ja-JP; common locale variants map to the same four translations. After delegation, the official generator controls its own locale.

Migration to v1

Version 1 builds the official generator catalog into the binary. The remote tech, official, and community lists are no longer downloaded.

The legacy --template option remains available only to print a migration notice. Replace it with --from:

preset init old-demo --from vue

The preset proxy command and the config --tech, localTech, and mirror settings were removed. Official generators use the selected package manager's registry configuration. Private presets should point to a repo or config source that is reachable from the execution environment.

Documentation

Feedback and contributions

Choose an issue form to report a bug, submit a showcase, suggest a feature, improve documentation, or ask a usage question. English and Chinese submissions are welcome.

License

MIT License © 2022 chengpeiquan

About

Provides the ability to quickly create preset projects.

Resources

Stars

46 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages