Templates
Templates are generated in the Stratum engine by grouping together Presets.
Templates are the highest layer in Stratum.
Stratum-generated Templates can be used as general Bingo templates: under the hood, they are created with the same createTemplate
API as any other template.
For example, this Template groups several levels of tooling from a create-typescript-app
-like generator:
import { createTemplate } from "create";
import { presetCommon } from "./presetCommon";import { presetEverything } from "./presetEverything";import { presetMinimal } from "./presetMinimal";
export const template = createTemplate({ about: { name: "TypeScript App", }, presets: [ { label: "Minimal", preset: presetMinimal }, { label: "Common", preset: presetCommon }, { label: "Everything", preset: presetEverything }, ], suggested: presetCommon,});
The preset labels are turned into a --preset
option.
Runners like Template CLIs will know to prompt for a preset if not provided:
$ npx create-typescript-app@beta
┌ ✨ create-typescript-app@2.0.0 ✨││ Learn more on: https://github.com/JoshuaKGoldberg/create-typescript-app││ Running with mode --initialize for a new repository.││ What will the --preset be?
Options
Stratum Templates source their options
from their Base.
Options declared on a Template’s Base are what may be set in a configuration’s options
.
The only added option is preset
, which is a required string option.
It is a union of the lowercased labels provided under presets
.
For example, given the earlier template
with three Presets, the preset
option would be type "common" | "everything" | "minimal"
:
import { template } from "create-typescript-app";
export default createConfig(template, { options: { preset: "everything" },});