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.
Example note
The files below show the source, config, and expected output; no commands run here. To try it locally, replace the example repository URL and save the JSON at the path in the command.
index.js
console.log('Service ready')
Create command
Bash
pnpm create preset init my-service --from ./presets/service.jsonOperation order
excludeskipsdemo.jsduring copying, leaving it out of the new project.writerewritesREADME.md, with each entry inlinesbecoming one line in the file.replacechangesAPP_LABEL=StartertoAPP_LABEL=Teamin.env.example.jsoneditspackage.json. Settingscripts.demotonullremoves that command and keepsscripts.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-runThis 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.