@quenty/nevermore-template-helpers
Version:
Helpers to generate Nevermore package and game templates
38 lines (26 loc) • 1.39 kB
Markdown
Shared utilities for scaffolding, building, and template substitution across Nevermore CLI tools.
| Module | Purpose |
|--------|---------|
| `scaffolding/` | `TemplateHelper` — directory template creation with Handlebars |
| `build/` | `BuildContext` + `rojoBuildAsync` — sole rojo invocation point for the entire codebase |
| `substitution/` | `substituteTemplate` — Handlebars-based `{{VAR}}` replacement with `noEscape` |
```typescript
import { BuildContext, rojoBuildAsync, resolveTemplatePath } from '@quenty/nevermore-template-helpers';
// Resolve a template file relative to the calling package's templates/ directory
const projectPath = resolveTemplatePath(import.meta.url, 'my-template/default.project.json');
// Temp directory for build output (auto-cleaned)
const ctx = await BuildContext.createAsync({ mode: 'temp', prefix: 'my-build-' });
const placePath = path.join(ctx.dir, 'output.rbxl');
await rojoBuildAsync({ projectPath, output: placePath });
await ctx.cleanupAsync();
```
```typescript
import { substituteTemplate } from '@quenty/nevermore-template-helpers';
const result = substituteTemplate('local PORT = "{{PORT}}"', { PORT: '8080' });
// → 'local PORT = "8080"'
```
Uses Handlebars with `noEscape: true` so Lua source code (`&`, `<`, etc.) is not HTML-escaped.