@libria/scaffold-core
v0.3.8
Published
Core types and utilities for @libria/scaffold
Readme
@libria/scaffold-core
Shared types and utilities used by @libria/scaffold and its template plugins.
Installation
npm install @libria/scaffold-coreAPI
Types
ScaffoldTemplatePlugin<TOpt> — Interface that every template plugin must implement:
interface ScaffoldTemplatePlugin<TOpt extends object = object> {
readonly argument: string;
getOptions(options: ScaffoldTemplatePluginOptions & Partial<ResolvedOptions<TOpt>>): Promise<Partial<{ [k in keyof TOpt]: ScaffoldTemplatePluginOption }>>;
execute(options: ExecuteOptions<TOpt>): Promise<void>;
}ScaffoldTemplatePluginOption<TValue> — Defines a single CLI option for a template:
type ScaffoldTemplatePluginOption<TValue = string | boolean | number> = {
readonly flags: string;
readonly required?: boolean;
readonly description: string;
readonly defaultValue?: TValue | TValue[];
readonly choices?: TValue[];
};ScaffoldTemplatePluginOptions — Base options passed to every template:
type ScaffoldTemplatePluginOptions = {
name: string;
dryRun?: boolean;
force?: boolean;
};SCAFFOLD_TEMPLATE_PLUGIN_TYPE — Plugin type constant ("scaffold-template").
Utilities
replacePlaceholders(targetDir, replacements) — Recursively walks a directory and replaces all occurrences of placeholder strings in .ts, .js, .json, .md, and .txt files.
await replacePlaceholders('./my-project', {
'{PACKAGE_NAME}': 'my-lib',
'{DESCRIPTION}': 'A cool library',
});License
MIT
