Scaflo is a flexible CLI tool for scaffolding project files from structured JSON files, supporting both local and remote JSON sources. It simplifies setting up project files, managing templates, and automating file creation with customizable content.
- 🗂️ Supports remote (URL) and local JSON files.
- 📝 Create, append, or modify files based on predefined JSON templates.
- 📂 Supports grouped files with base directories.
- 🔄 Automatic handling of nested dependencies (other JSON files).
- ✅ File overwrite, rename, and append options.
- 🔐 Supports GitHub token authentication
- (for fetching files from private repositories)
- (⚡Recommended for all tasks).
- 📁 Supports dynamic placeholders like
%SRC%
,%COMPONENTS%
, and user prompts<-ask->
.
npm install -g scaflo
Direct use
scaflo <jsonPath>
without global installation
pnpm dlx scaflo@latest <jsonPath>
<jsonPath>
- URL or local path to the JSON file defining your files and templates.
Option | Short | Description |
---|---|---|
--dir |
-d |
Set working directory before processing files |
--force |
-f |
Force overwrite files without prompt |
--extend-path |
-e |
Extend file paths from a base directory |
Example:
scaflo https://example.com/template.json --dir my-project --extend-path src/components
The JSON file should follow this schema:
"w"
: Write (default)."a"
: Append.- Object: Key-value pair for replacing content in existing files.
- File content can be:
- Inline text.
- URL (remote).
- Absolute path (local).
You can use special placeholders in file paths:
Placeholder | Description |
---|---|
%SRC% |
Replaced with src directory if it exists |
%COMPONENTS% |
Points to src/components |
<-ask-> or <-ask|withDefaultName-> |
in file or folder names, prompting the user to enter names dynamically. |
Example:
{
"files": [
{
"name": "<-ask->",
"content": "https://example.com/example.txt",
},
{
"name": "<-ask | defaultName.ts->",
"content": "https://example.com/example.txt",
},
{
"name": "<-ask|components->/button.tsx",
"content": "https://example.com/example.txt",
},
{
"name": "%components%/<-ask|button->.tsx",
"content": "https://example.com/example.txt",
},
],
}
-
set
Config Value- Example:
scaflo set githubToken ghp_abcdef123456
- Example:
-
get
Config Value- scaflo get githubToken
✅ valid properties
// key: value-type
{ githubToken: string }
scaflo https://raw.githubusercontent.com/your-repo/template.json -d my-project
- This fetches
template.json
, processes the files inside, and places them inmy-project
. - If files already exist, you can choose to overwrite, rename, or skip.
- Prompts appear if any filenames use
<-ask->
.
To access private GitHub files (e.g., raw URLs from private repos), set your GitHub token:
scaflo set githubToken <your_personal_access_token>
- Support partial file updates with
<-ask->
in file content. - Enhanced support for nested templates and complex dependency trees.
MIT License.
Contributions are welcome! Feel free to open issues or pull requests on GitHub.