feat(mosaic): migrate install wizard from v0 to v1
Complete port of the ~2000 LOC mosaic install wizard from v0. Migrates all 27 source files across the prompter, config, platform, template, runtime, skills, and stages subsystems to v1 ESM/NodeNext conventions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
23
packages/mosaic/src/template/engine.ts
Normal file
23
packages/mosaic/src/template/engine.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
export interface TemplateVars {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces {{PLACEHOLDER}} tokens with provided values.
|
||||
* Does NOT expand ${ENV_VAR} syntax — those pass through for shell resolution.
|
||||
*/
|
||||
export function renderTemplate(
|
||||
template: string,
|
||||
vars: TemplateVars,
|
||||
options: { strict?: boolean } = {},
|
||||
): string {
|
||||
return template.replace(/\{\{([A-Z_][A-Z0-9_]*)\}\}/g, (match, varName: string) => {
|
||||
if (varName in vars) {
|
||||
return vars[varName] ?? '';
|
||||
}
|
||||
if (options.strict) {
|
||||
throw new Error(`Template variable not provided: {{${varName}}}`);
|
||||
}
|
||||
return '';
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user