Generate Phase
generate runs before TypeScript build and test jobs. It prepares generated source, exports, and static assets so downstream phases see a complete project.
What generate does
Key steps:
- discover pre-build hooks from plugin dependencies
- run hooks in dependency order
- write generated source and export metadata to
.gen/ - copy configured generated assets into the project output
putnami generate .
putnami generate . --clearOptions
| Option | Use |
|---|---|
--verbose |
Show detailed generation output |
--clear |
Remove existing generated artifacts before running |
Pre-build hooks
Dependencies can expose pre-build hooks through a ./pre-build export. The runner passes:
--context <path>with the job context--result <path>where the hook writes its JSON result
Example result:
{
"exports": {
"./generated": "./.gen/main.ts"
},
"assets": [
{ "src": ".gen/schema.json", "dest": "schema.json" }
]
}Create a hook
- Export
preBuildfromsrc/pre-build/index.ts. - Provide a command and optional arguments.
- Write the result JSON to the path received in
--result. - Add the export to
package.json.
{
"exports": {
"./pre-build": "./src/pre-build/index.ts"
}
}