Scaffolder is a command-line interface tool written in Golang designed to automate the mundane task of manually creating barebones for your project. It takes the neccesary directory structure defined in a reusable config YAML file, which is very easy to work with for both humans and parsers.
See templates for some programming languages here: Scaffold configs
- Change default config folder to a dotfile -
~/.scaffolder
-
--configdir
flag to let the user specify path to custom config folder. Fallback to default path if empty, also let user get the config from current working directory - Remember custom config directory if specified AND
--remember
is true (by default false) - Additional error handling for new features
If you are not planning to contribue OR you don't need the very last releases:
- Change your directory to home:
$ cd ~
- Create a folder for scaffolder and navigate there:
$ mkdir scaffolder
$ cd scaffolder
- Download the latest release (repeat this step to update it in future, replace stable-v1_1 with tag of latest version):
# Linux:
$ wget -q -O scaffold https://github.com/cemister/scaffolder/releases/download/stable-v1_1/scaffolder_linux
# MacOS:
$ curl -s -o scaffold https://github.com/cemister/scaffolder/releases/download/stable-v1_1/scaffolder_macos
- Turn the file into an executable:
$ chmod +x scaffold
- Add the executable to PATH:
$ echo 'export PATH="$HOME/scaffolder:$PATH"' >> ~/.bashrc
- Update bash config (Might restart the terminal as well):
$ source ~/.bashrc
- Open Command Prompt (cmd) or PowerShell and change the directory to the user's home directory:
# cmd:
cd %userprofile%
# PowerShell:
cd $env:userprofle
- Create a folder named "scaffolder" and change the current directory to it:
mkdir scaffolder
cd scaffolder
- Download latest scaffolder windows release (repeat this step to update it, replace stable-v1 with tag of latest version):
curl -s -o scaffold.exe https://github.com/cemister/scaffolder/releases/download/stable-v1_1/scaffolder_win.exe
- Add the executable to the PATH in Windows:
- Press
Win + S
to open the Windows search bar. - Search for "Environment Variables" and select "Edit the system environment variables."
- In the System Properties window, click the "Environment Variables" button.
- In the Environment Variables window, find the "Path" variable under "User variables" and click "Edit."
- Click "New," then enter the full path to the "scaffolder" folder (e.g.,
C:\Users\YourUsername\scaffolder
) and click "OK" to add it to the PATH.
Note: Make sure to replace YourUsername
with your actual Windows username.
Note that curl
in Windows can be used if you have it installed (comes pre-installed starting from Windows 10 1803), or you can use a graphical web browser to download the executable.
To build from source, make sure you have installed Golang:
- Clone the repository (Make sure you have installed Git. Pre-installed on macOS since Mavericks (10.9) and on majority of Linux distributions)
$ git clone https://github.com/cemister/scaffolde.git
- Navigate to the project directory
$ cd scaffolder
- Build the project
$ go build
# Use without angle brackets.
# Also wrap the path in quotes.
# Arguments with ? are optional.
$ scaffold --name <project name> --yaml <config name> --configdir? <path to custom folder if exists> --git? <true/false>
The config folder must be located inside your home directory: Scaffolder 1.1.5:
-
Name of config folder: scaffolder-configs -> .scaffolder. It is a dotfile, meaning it's hidden by default, so you should either manipulate it using a terminal or toggle visiblity of hidden folders. Please rename the folder for compatiblity with this version
-
--configdir
- new flag using which you can specify path to your custom config folder. Example below, it looks for the yaml config inside path specified in configdir which is .custom_configs folder in home directory (Unix)
scaffold --name test --yaml cpp --configdir "~/.custom_configs"
- If you want to get yaml in current directory, make sure it doesn't exist in .scaffolder and configdir is empty. The usage is same as normal.
Example:
$ scaffold --name example --yaml "hello"
It will create the project folder and scaffold it, based on the provided YAML file. You can also make it automatically initialize a Git repository inside the project by setting git
to true.
Here's how can the YAML file look like:
hello1: # Folder name
hello.txt: | # File name
Hello World # File content
hello1.txt: # File name (empty)
hello2.txt: # File name (empty)
hello2: # Folder name
hello22.txt: # File name (empty)
It's pretty much straightforward; hello1 is the folder, and hello.txt, hello1.txt, hello2.txt are the files inside it. The result is:
example
├── hello1
│ ├── hello.txt
│ ├── hello1.txt
│ └── hello2.txt
└── hello2
└── hello22.txt
hello.txt:
Hello World
Note that | in YAML is used for multline text
To create a file inside the parent (project's) directory, we create a "." collection:
.:
main.txt:
To create a subdirectory (folder inside a folder), we create a new collection with it's name being the name of parent folder and then the name of needed folder, separated by a slash (/):
hello1:
hello.txt:
hello1.txt:
hello2.txt:
hello2:
hello22.txt:
hello2/hello3:
hello33.txt:
Result:
example
├── hello1
│ ├── hello.txt
│ ├── hello1.txt
│ └── hello2.txt
└── hello2
├── hello22.txt
└── hello3
└── hello33.txt
To create a folder inside hello3, we do the same:
hello2/hello3:
hello33.txt:
hello2/hello3/hello4:
hello44.txt:
Result:
example
└── hello2
└── hello3
├── hello33.txt
└── hello4
└── hello44.txt
To create an empty folder, we create an empty collection without values:
helloempty:
Result:
example
└── helloempty
Here's a more advanced example (note it's pseudocode only to showcase scaffolder):
.:
webpack.json: |
// Some stuff here
modules/typescript:
a.config.ts: |
import { A } from "a";
if (A) {
console.log(1);
}
modules/colort:
colort.config.ts: |
import { A } from "a";
if (A) {
console.log(1);
}
src:
index.ts: |
let a = false;
console.log(a);
console.log("Hello!");
Result:
example
├── webpack.json
├── modules
│ ├── typescript
│ │ └── a.config.ts
│ └── colort
│ └── colort.config.ts
└── src
└── index.ts
Every file has it's corresponding contents.
If you want to contibute to Scaffolder but don't know how, refer to the official Github guide - Contributing to projects
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.