Creations
A Creation object is what’s returned by each Block’s produce()
method.
It may contain any of the following properties:
- “Direct” creations that always cause changes to the repository:
- “Indirect” creations only made to be used by later blocks:
addons
: Composed Addons to merge in for other Blocks, if they exist
For example, a Block that adds pnpm package deduplication might choose to both run a command (commands
) used in a GitHub Actions job in addon Addons to another Block:
Direct Creations
These Creation properties always cause changes to the output repository.
commands
Terminal commands to run after setup.
This can be useful when commands are necessary to initialize a repository after files are written.
For example, an AllContributors block that runs a hydration command:
files
Files to create or modify on disk.
This is the primary, most common output from blocks.
Each object under files
describes a folder of files.
Properties whose values are strings are written as files on disk.
Properties whose values are objects represent a directory.
For example, this Block that generates a .github/CODE_OF_CONDUCT.md
file:
That would instruct the create
engine to create a .github/
directory if it doesn’t exist yet, then create a .github/CODE_OF_CONDUCT.md
file.
File Creations
Each property in a files
object may be one of the following:
false
orundefined
: Ignoredobject
: A directory, whose properties recursively are file creationsstring
: A file to be created[string, CreatedFileOptions]
: A file to be created withfsPromises.writeFile
options:mode
: Integer mode, such as0o777
to make executable
For example, this Block generates an executable .husky/pre-commit
file:
Indirect Creations
These Creation properties produce information meant to be used by subsequent Blocks.
See Context for how Blocks can read context from previous Blocks.
addons
Additional Addons to merge in for other Blocks, if those Blocks exist.
Blocks may specify additions to other, “downstream” Blocks. If the downstream Block is included in the running Preset, then the augmenting Addons will be merged into what that downstream Block receives.
For example, this blockESLintJSDoc
Block tells blockESLint
about using the ESLint plugin for JSONC files:
If blockESLint
is run in the same Preset, then it will receive those additional Addons.