https://github.com/block/scaffolder
A general-purpose project scaffolding tool inspired by cookiecutter
https://github.com/block/scaffolder
Last synced: about 1 month ago
JSON representation
A general-purpose project scaffolding tool inspired by cookiecutter
- Host: GitHub
- URL: https://github.com/block/scaffolder
- Owner: block
- License: apache-2.0
- Created: 2023-10-25T08:35:10.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-14T17:52:14.000Z (10 months ago)
- Last Synced: 2025-01-14T19:17:06.977Z (10 months ago)
- Language: Go
- Size: 111 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# A general-purpose project scaffolding library and tool inspired by [cookiecutter](https://github.com/cookiecutter/cookiecutter)
[](https://github.com/mkenney/software-guides/blob/master/STABILITY-BADGES.md#experimental) [](https://pkg.go.dev/github.com/block/scaffolder) [](https://github.com/block/scaffolder/actions/workflows/ci.yml)
---
Scaffolder evaluates the scaffolding files at the given desScaffolder evaluates a template of directories and files into a destination using JSON context using the following
rules:
- Templates are evaluated using the Go template engine.
- Both path names and file contents are evaluated.
- If a file name ends with ".tmpl", the ".tmpl" suffix will be removed.
- If a file or directory name evalutes to the empty string it will be excluded.
- If a file named "template.js" exists in the root of the template directory,
all functions defined in this file will be available as Go template functions.
- Directory and file names in templates can be expanded multiple times
using the "push" function. This function takes two arguments, the
file/directory name and the context to use when evaluating templates within
the file/directory.
- The following functions are available as Go template functions: "snake", "screamingSnake", "camel", "lowerCamel",
"kebab", "screamingKebab", "upper", "lower", "title",
For example, given the following files and directories as the template:
template/
{{ range .modules }}{{ push .name . }}{{ end }}/
file.txt
And the context "context.json":
{
"modules": [
{"name": "module1", "path": "path1"},
{"name": "module2", "path": "path2"}
]
}
Running scaffolder with:
scaffolder --json context.json --template template --dest dest
The output "dest" directory will contain the following files and directories:
module1/
file.txt
module2/
file.txt