Skip to content

Phases (TODO)

By default, blocks run in the order specified in their Preset. However, some blocks may need to refer to the Indirect Creations produced by earlier blocks.

Blocks may specify a phase property in their definition using a BlockPhase enum. Doing so indicates when that Block should be run relative to other blocks.

Those BlockPhase phases are:

  1. Default
  2. Install
  3. Source
  4. Test
  5. Build
  6. Format
  7. Lint
  8. Package
  9. Documentation
  10. Git
  11. Editor
  12. CI

For example, a .gitignore block that adds entries for all previously included metadata files:

import { BlockPhase, MetadataFileType } from "create";
import { schema } from "../schema.js";
export const blockGitignore = schema.createBlock({
about: {
name: "Gitignore",
},
phase: BlockPhase.Git,
produce({ created }) {
return {
files: {
".gitignore": formatIgnoreFile(
[
"node_modules/",
...created.metadata
.filter(
(value) =>
value.type === MetadataFileType.Built ||
value.type === MetadataFileType.Ignored,
)
.map((value) => value.glob),
].sort(),
),
},
};
},
});