Edit files during project creation

Remove demo files, update the README, and change defaults while creating a project.

Edit files during project creation

After cloning a service starter, there are often demo files to remove, a README to rewrite, defaults to change, and a demo command to delete from package.json. When the edits are the same each time, put them in a preset.

index.js

console.log('Service ready')

Create command

Bash
pnpm create preset init my-service --from ./presets/service.json

Operation order

  1. exclude skips demo.js during copying, leaving it out of the new project.
  2. write rewrites README.md, with each entry in lines becoming one line in the file.
  3. replace changes APP_LABEL=Starter to APP_LABEL=Team in .env.example.
  4. json edits package.json. Setting scripts.demo to null removes that command and keeps scripts.start.

Preview the creation plan

Save the config as presets/service.json, then add --dry-run to see the planned operations:

Bash
pnpm create preset init my-service --from ./presets/service.json --dry-run

This step does not download the repository, so it cannot check whether the original text in replace exists. After checking the plan, remove --dry-run to create the project and inspect the files.

See Preset Configs for other fields.