Skip to content

Stratum Contexts

Some Stratum constructs reuse the same contexts as described in Details > Contexts:

Other Stratum constructs do not reuse Bingo’s existing contexts:

Block Contexts

The Context object provided to the produce object of Blocks.

addons

Any Block Addons that have been provided by other Blocks.

For example, this Gitignore Block defines an ignores Addon that other Blocks can use to add to its created .gitignore file:

import { base } from "./base";
export const blockGitignore = base.createBlock({
addons: {
ignores: z.array(z.string()).default([]),
},
produce({ addons }) {
return {
files: {
".gitignore": ["/node_modules", ...addons.ignores].join("\n"),
},
};
},
});

options

User-provided values as described by the parent Base.

Bases fill in option values before running Blocks. Each Block created by a Base will run with the same set of options.

For example, this Base defines a repository option, which the Block then prints as a package.json property:

import { createBase } from "create";
export const base = createBase({
options: {
repository: z.string(),
},
});
export const blockPackageJson = createBlock({
produce({ options }) {
return {
files: {
"package.json": JSON.stringify({ name: options.repository }),
},
};
},
});
Made with 💝 in Boston by Josh Goldberg.