presetter bootstrap
Setup the project according to the specified preset by generating configuration files and installing dependencies.
Synopsis
presetter bootstrap [options]
Description
The bootstrap command is the core setup command that:
- Reads your preset configuration from
presetter.config.ts - Resolves the preset graph and asset templates
- Generates configuration files (tsconfig.json, eslint.config.ts, etc.)
- Skips null assets and writes generated assets to the project root
When several projects are targeted, bootstrap always attempts every project, even if an earlier one fails. Failures are collected and reported together on stderr once the run is over, and the command then exits with a non-zero status. That way a single broken package no longer leaves the rest of a monorepo un-bootstrapped.
[AggregateError] failed to bootstrap 1 of 3 projects
[Error] failed to bootstrap packages/b
[Error] failed to load the presetter configuration at /repo/packages/b/presetter.config.ts
[SyntaxError] Unexpected token
This command is typically run:
- After installing Presetter and a preset for the first time
- When updating to a new preset version
- When adding Presetter to an existing project
- From a
bootstrappackage script that you run explicitly
Options
--only <file>
Proceed only if the specified file exists. Useful for conditional bootstrapping.
# Only bootstrap if package.json exists
presetter bootstrap --only package.json
# Only bootstrap if preset config exists
presetter bootstrap --only presetter.config.ts
Use cases:
- CI/CD pipelines that should only run in certain contexts
- Monorepo setups where not all packages need bootstrapping
- Conditional setup based on project structure
-p, --projects <patterns...>
Specify glob patterns matching target project folders containing package.json.
Default: ["." (current directory)
# Bootstrap multiple packages in a monorepo
presetter bootstrap --projects "packages/*" "apps/*"
# Bootstrap all packages recursively
presetter bootstrap --projects "**/package.json"
# Bootstrap specific packages
presetter bootstrap --projects "packages/core" "packages/utils"
Pattern Examples:
"packages/*"- All direct subdirectories in packages/"apps/*/"- All app directories"."- Current directory only"**/"- All directories recursively (use with caution)
-P, --packages <patterns...>
Specify glob patterns matching target package names rather than paths, as declared by
each project's package.json name field. Within a pattern, * matches anything except
/, so @acme/* stays inside the @acme scope.
Default: [] (no package-name selection)
# Bootstrap every preset package in a scope
presetter bootstrap --packages "@presetter/preset-*"
# Combine path and name selection; both contribute to the same set of roots
presetter bootstrap --projects "packages/*" --packages "@acme/tooling"
Excluding with !
Any pattern given to --projects or --packages may be prefixed with ! to exclude
its matches.
# Every preset except presets/node
presetter bootstrap --projects "presets/*,!presets/node"
# Every @acme preset except one, by package name
presetter bootstrap --packages "@acme/preset-*,!@acme/preset-node"
# Exclusions cross flags: the path exclusion also drops a name-selected root
presetter bootstrap --packages "@acme/preset-*" --projects "!presets/legacy"
Two rules govern how exclusions behave:
- Negations never select. They only subtract, following the same convention as globby
and
.gitignore.presetter bootstrap -p '!e2e'on its own therefore selects nothing. - Exclusions apply to the whole selection, not only to the flag they were given on. A
!pattern on--projectsstill removes a root that--packagesselected, and vice versa.
Global Options
--help- Show help information--version- Show version number
Examples
Basic Project Setup
# First time setup
npm install --save-dev presetter @presetter/preset-esm
echo "export { default } from '@presetter/preset-esm';" > presetter.config.ts
presetter bootstrap
Monorepo Setup
# Bootstrap all packages in a monorepo
presetter bootstrap --projects "packages/*" "apps/*"
# Only bootstrap packages that have a presetter config
presetter bootstrap --projects "packages/*" --only presetter.config.ts
# Bootstrap the whole monorepo apart from a couple of exceptions
presetter bootstrap --projects ".,packages/*,presets/*,!presets/legacy,!packages/sandbox"
Conditional Bootstrapping
# Only bootstrap in CI if lock file exists
presetter bootstrap --only package-lock.json
# Bootstrap for production deployment only
if [ "$NODE_ENV" = "production" ]; then
presetter bootstrap
fi
Integration with Package Scripts
Add a package script so the bootstrap command is easy to run:
{
"scripts": {
"bootstrap": "presetter bootstrap"
}
}
Lifecycle hook usage:
postinstall- Runs afternpm installprepare- Runs before publishing and afternpm installprepack- Runs before creating package tarball
What Gets Generated
The bootstrap command typically generates:
Configuration Files
tsconfig.json- TypeScript compiler configurationeslint.config.ts- ESLint linting rulesvitest.config.ts- Vitest testing configuration.prettierrc.json- Prettier formatting rules.gitignore- Git ignore patternspackage.jsonscripts - Merged with preset scripts
Dependency Installation
Preset packages declare their required tools as peer dependencies. Install the preset package with your package manager, then follow that package manager's peer-dependency behavior.
Generated File Strategy
Bootstrap writes generated files directly into the target project. Keep durable changes in presetter.config.ts, then rerun presetter bootstrap to regenerate the output files.
Troubleshooting
Common Issues
Permission Errors:
# Try with elevated permissions
sudo presetter bootstrap
# Or fix npm permissions
npm config set prefix ~/.npm-global
File Conflicts:
# Existing configs will be backed up automatically
# Check .presetter-backup/ directory for originals
ls -la .presetter-backup/
Missing Dependencies:
# Ensure preset is properly installed
npm list @presetter/preset-esm
# Reinstall if needed
npm install --save-dev @presetter/preset-esm
Monorepo Issues:
# Use absolute patterns for complex structures
presetter bootstrap --projects "$(pwd)/packages/*"
# Debug with verbose output
DEBUG=presetter:* presetter bootstrap --projects "packages/*"
Verification
After running bootstrap, verify the setup:
# Check generated files
ls -la tsconfig.json eslint.config.ts vitest.config.ts
# Verify dependencies are installed
npm list typescript eslint vitest
# Test the setup
npm run test
npm run lint
npm run build
Advanced Usage
Custom Bootstrap Logic
Create a wrapper script for complex bootstrap scenarios:
// scripts/bootstrap.ts
import { bootstrap } from 'presetter/preset';
import { existsSync } from 'fs';
// Custom bootstrap logic
if (existsSync('custom.config.js')) {
console.log('Custom configuration detected');
await bootstrap('.', { customMode: true });
} else {
await bootstrap('.');
}
Integration with Build Tools
# Vite integration
echo "import { defineConfig } from 'vite'; export default defineConfig({});" > vite.config.ts
presetter bootstrap
# Webpack integration
echo "module.exports = {};" > webpack.config.js
presetter bootstrap
Environment-Specific Configs
// presetter.config.ts
export default preset('env-aware', (context) => {
const isDev = process.env.NODE_ENV === 'development';
return {
assets: {
'tsconfig.json': {
compilerOptions: {
sourceMap: isDev,
strict: !isDev
}
}
}
};
});
Related Commands
presetter run- Execute scripts generated by bootstrappresetter run-s- Run multiple scripts sequentiallypresetter run-p- Run multiple scripts in parallel
See Also
- Getting Started Guide - First time setup
- Configuration Guide - Customizing your setup
- Preset Ecosystem - Available presets