Skip to content

Bases

A Base defines an object of option types and default values that will be used to scaffold a repository. Bases are used to generate Blocks and Presets that rely on user-specified values for those options.

Options

Each Base is associated with a set of Options represented by Zod schemas. Each property of those Options represents a configurable value that can be provided by a user. Those Options carry through to Blocks and Presets associated with the base.

For example, a minimal Base that stores only a name string could look like:

import { createBase } from "create";
import { z } from "zod";
export const base = createBase({
options: {
name: z.string(),
},
});

Blocks and Presets made with that base will have access to the name Option of type string.

Production

Bases can optionally define a produce() function that provides default fallback values for options. Those fallback values will be used if the user doesn’t provide their own values during creation.

For example, this Base defaults its value Option to "default" if not provided:

import { createBase, createBase } from "create";
import { z } from "zod";
export const base = createBase({
options: {
value: z.string().optional(),
},
produce() {
return {
value: "default",
};
},
});

Options generated by produce() are typically used to update a repository that was previously set up with the same Preset. Doing so can allow a Base’s creations to be re-run in an existing repository without manually providing all of the same Options again.

APIs