@tasteee/snooks
v0.0.124
Published
Markdown-based scaffolding.
Downloads
207
Maintainers
Readme
snooks
Markdown-based scaffolding.
Write markdown templates in .snooks/. Run snooks make. Get files.
npm i -g @tasteee/snooks
# After you make a few templates, you
# can scaffold them similar to this:
snooks make component Button
snooks make package my-pkg type=module
snooks make library my-lib whatever=42First template
Create .snooks/component.md:
---
output: src/components
---
# Component Template
````tsx $$name/index.tsx
export const $$name = () => {
return <div>$$name</div>
}
```
```css $$name/index.css
.$$name {
display: flex;
}
```
````Run it:
snooks make component ButtonOutput:
src/components/Button/index.tsx
src/components/Button/index.cssThat's it.
CLI
snooks make # pick template interactively
snooks make component # pick a name interactively
snooks make component <name> # template + name
snooks make component <name> --at src/ui # override output path
snooks make component <name> color=blue # pass extra valuesJavaScript API
import { snooks } from "@tasteee/snooks";
await snooks.scaffold({
// looks for .snooks/component.md from your package root
template: "component",
name: "Button",
});Templates
A template is a markdown file in .snooks/. Any code block with a file name / path becomes a file.
# Package Template
````json $$name/package.json
{ "version": "$$version" }
```
```json $$name/tsconfig.json
{ "compilerOptions": { "strict": true } }
```
````Frontmatter
Markdown templates can have "frontmatter" for metadata and configuration. Basically, it's a YAML block at the top of the file.
---
name: library
output: src/components
---
# Library Template
```json $$name/package.json
{ "version": "$$version" }
```
```ts $$name/tsdown.config.ts
export default {
entry: ['./src/index.ts']
dts: true,
clean: true,
}
```
```ts $$name/src/index.ts
export const $$name = {};
```| Field | Description |
| -------- | --------------------------------- |
| name | Friendly name shown in the picker |
| output | Default output directory |
Variables
$$name
Simple variable injection from arguments. The name argument is always set from the value that follows the make command and the template argument.
snooks make <template> <name>
snooks make component Button
# template → <template>
# name → <name>Flags
Any additional arguments passed as key=value pairs become variables:
snooks make component Button color=blue
# $$name → Button
# $$color → blueExamples
See the examples/ folder for ready-to-use templates.
License
MIT
