Skip to content

Stratum Template Settings

Recap: Bingo configurations may specify two template-specific configurations:

  • options: any type-safe options the template has declared
  • settings: any custom settings specified by the template

Options

options configurations are specified by the underlying Base. See Templates > Options for information on Stratum Template options.

The only added option is preset, which is a required string option. It is a union of the lowercased labels for the Template’s available Presets.

For example, given a Template whose Base includes a boolean bin string, this configuration explicitly sets that option to "index.js":

create-example.config.js
import { createConfig } from "bingo";
import { blockCSpell, template } from "create-typescript-app";
export default createConfig(template, {
options: {
base: "index.js",
preset: "everything",
},
});

Settings

settings configurations are general to all Stratum Templates. All Stratum Templates support the following settings in their configuration files:

addons

Any Addons to be passed to the Blocks provided by the selected Preset. These will be merged in with Addons provided by other Blocks.

For example, this configuration file adds the word "arethetypeswrong" to a CSpell Block’s Addons:

create-example.config.js
import { createConfig } from "bingo";
import { blockCSpell, template } from "create-typescript-app";
export default createConfig(template, {
options: { preset: "everything" },
settings: {
addons: [
blockCSpell({
words: ["arethetypeswrong"],
}),
],
},
});

Running npx bingo in a repository with that configuration file would merge in that words to the Addons provided to its CSpell Block.

blocks

Any customizations to the Blocks provided by the selected Preset.

add

Any Blocks to add to what the Preset provides.

For example, this configuration file adds in an “arethetypeswrong” Block alongside existing Blocks provided by create-typescript-app:

create-example.config.js
import { createConfig } from "bingo";
import { blockAreTheTypesWrong, template } from "create-typescript-app";
export default createConfig(template, {
options: { preset: "everything" },
settings: {
blocks: {
add: [blockAreTheTypesWrong],
},
},
});

Running npx bingo in a repository with that configuration file would add in the created outputs from blockAreTheTypesWrong.

exclude

Any Blocks to exclude from what the Preset provides.

For example, this configuration file omits the default “This package was templated with…” notice that comes with create-typescript-app:

create-example.config.js
import { createConfig } from "bingo";
import { blockTemplatedBy, template } from "create-typescript-app";
export default createConfig(template, {
options: { preset: "everything" },
settings: {
blocks: {
exclude: [blockTemplatedBy],
},
},
});

Running npx bingo in a repository with that configuration file would not include that Block, and so its generated README.md would not include the notice.

Custom Blocks

Configurations can use Blocks beyond those included in Template Presets. Some Templates provide Blocks that can be opted into using blocks > add.

Templates that export their Base also allow configurations to create and include their own, custom Blocks.

For example, this custom Block adds a Wallaby configuration file:

blockWallabyConfig.js
import { base, blockPackageJson } from "create-typescript-app";
export const blockWallabyConfig = base.createBlock({
about: {
name: "Wallaby Config",
},
produce() {
return {
files: {
"wallaby.js": `module.exports = function () {
return {
reportConsoleErrorAsError: true,
};
};`,
},
};
},
});
create-example.config.js
import { createConfig } from "bingo";
import { template } from "create-typescript-app";
import { blockWallabyConfig } from "./blockWallabyConfig.js";
export default createConfig(template, {
options: { preset: "everything" },
settings: {
blocks: {
add: [blockWallabyConfig],
},
},
});

Custom Blocks and Addons

Custom Blocks can provide Addons to any other Blocks, including those provided by the package. This allows your repositories to blend in seamlessly with the features provided by your Template.

For example, to add an @arethetypeswrong/cli lint task to the package.json file, a repository using the create-typescript-app Template could create and use a custom Block:

blockLintAreTheTypesWrong.js
import { base, blockPackageJson } from "create-typescript-app";
export const blockLintAreTheTypesWrong = base.createBlock({
about: {
name: "Lint Are The Types Wrong",
},
produce() {
return {
addons: [
blockPackageJson({
properties: {
devDependencies: {
"@arethetypeswrong/cli": "0.17.3",
},
scripts: {
"lint:arethetypeswrong": "attw --pack .",
},
},
}),
],
};
},
});
create-example.config.js
import { createConfig } from "bingo";
import { template } from "create-typescript-app";
import { blockLintAreTheTypesWrong } from "./blockLintAreTheTypesWrong.js";
export default createConfig(template, {
options: { preset: "everything" },
settings: {
blocks: {
add: [blockLintAreTheTypesWrong],
},
},
});
Made with 💝 in Boston by Josh Goldberg.