Coder Social home page Coder Social logo

dl-tg / scaffolder Goto Github PK

View Code? Open in Web Editor NEW
123.0 5.0 6.0 1.84 MB

CLI tool to instantly generate skeleton project structure with boilerplate code, that's taken from configurable YAML file, to quickly kick-start your project

License: MIT License

Go 100.00%
directory-utilities folder-tooling go go-cli golang golang-cli yaml yaml-files yaml-parser

scaffolder's Introduction

Scaffolder

Scaffolder is a powerful command-line interface tool written in Golang designed to automate the tedious task of creating barebones for your projects. It allows you to define the necessary directory structure in a reusable config YAML file, making it easy for both humans and parsers to work with.

TODO

  • Specify default variables in YAML like $var: 1

Features

  • Automate project scaffolding with a YAML config file
  • Supports creating folders and files with custom content using simple YAML syntax
  • Define and use variables in the YAML file for flexible project generation
  • Remembers custom config directories using the --remember flag for added convenience

Quick Example

Suppose we have the following YAML config file named test.yaml:

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)

We can scaffold a project named "hello" using this config:

$ scaffold --name hello --yaml test

The resulting directory structure will be:

hello
├── hello1
│   ├── hello.txt
│   ├── hello1.txt
│   └── hello2.txt
└── hello2
    └── hello22.txt

The content of hello.txt will be:

Hello World

Installation

Linux / MacOS

  1. Change your directory to the home directory:
$ cd ~
  1. Create a folder for Scaffolder and navigate there:
$ mkdir scaffolder
$ cd scaffolder
  1. Download the latest release:
# Linux:
$ wget -q -O scaffold https://github.com/cemister/scaffolder/releases/download/v1.1.9/scaffolder_linux
# MacOS:
$ curl -s -o scaffold https://github.com/cemister/scaffolder/releases/download/v1.1.9/scaffolder_macos
  1. Make the file executable:
$ chmod +x scaffold
  1. Add the executable to your PATH:
$ echo 'export PATH="$HOME/scaffolder:$PATH"' >> ~/.bashrc
$ source ~/.bashrc

Windows

  1. Open Command Prompt (cmd) or PowerShell and change the directory to the user's home directory:
# cmd:
cd %userprofile%

# PowerShell:
cd $env:userprofile
  1. Create a folder named "scaffolder" and change the current directory to it:
mkdir scaffolder
cd scaffolder
  1. Download the latest Scaffolder Windows release:
curl -s -o scaffold.exe https://github.com/cemister/scaffolder/releases/download/v1.1.9/scaffolder_win.exe

Add the executable to the PATH in Windows:

  1. Press Win + S to open the Windows search bar
  2. Search for "Environment Variables" and select "Edit the system environment variables"
  3. In the System Properties window, click the "Environment Variables" button
  4. In the Environment Variables window, find the "Path" variable under "User variables" and click "Edit"
  5. 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.

Building from Source

To build Scaffolder from source, ensure you have Golang installed:

  1. Clone the repository (Git should be installed):
$ git clone https://github.com/dl-tg/scaffolder.git
  1. Navigate to the project directory:
$ cd scaffolder
  1. Build the project:
$ go build

Usage

Use the following command to scaffold a project:

$ scaffold --name? <project_name> --yaml <config_name> --configdir? <path_to_custom_config_folder_if_exists> --git? <true/false> --remember? <true/false> --variables? <k:v>

Note: remember flag specifies whether to remember custom path specified in configdir, avoiding the need to specify it each time On 1.1.9 version and above, name flag is optional now and if not specified, it will scaffold in current directory.

YAML Config Syntax

To create a file inside the parent (project's) directory, use a "." collection:

.:
  main.txt:

To create a subdirectory (folder inside a folder), create a new collection with its name as the name of the parent folder, followed by the name of the needed folder separated by a slash (/):

hello1:
  hello.txt:
  hello1.txt:
  hello2.txt:
hello2:
  hello22.txt:
hello2/hello3:
  hello33.txt:

To create an empty folder, create an empty collection without values:

helloempty:

Variables

Variables were added in 1.1.7. Here's how to use them:

Assume we have the following YAML config named cpp.yaml:

src:
  main.cpp: |
    #include <iostream>

    int main() {
        std::cout << "Hello, {name}!" << std::endl;
        return 0;
    }

In this example, we've defined a variable {name} within the main.cpp file, which will be replaced with the actual value when we scaffold the project.

Now, let's scaffold a C++ project named "hello-cpp" using this config and provide a value for the {name} variable:

$ scaffold --name hello-cpp --yaml cpp --variables name:John

The resulting directory structure will be:

hello-cpp
└── src
    └── main.cpp

The content of main.cpp will be:

#include <iostream>

int main() {
    std::cout << "Hello, John!" << std::endl;
    return 0;
}

As you can see, the {name} variable was replaced with "John" in the final project files. This allows you to customize the generated code or any other content based on the values you provide during scaffolding.

As of 1.1.8, support for variables in folder or file names was added. Just wrap it in double quotes like "{var}": ... if using in folder/filenames.

Contributing

If you want to contribute but are unsure how, refer to the official GitHub guide on Contributing to projects.

License

This project is licensed under the MIT license. See the LICENSE file for details.

scaffolder's People

Contributors

atoo35 avatar dl-tg avatar fjborquez avatar gwali-1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

scaffolder's Issues

Release 1.1.6 provides unexpected Architecture ARM64

I just downloaded scaffolder_linux from Release 1.1.6 & expected an amd64 compatible binary, but it turned out to be of the arm64 architecture.

I suppose, this is a mistake in the deployment configuration, if there are automated builds or you accidentally built for the wrong target. 😄

I would also advise to just generally attach the architecture etc. information in the name, to avoid any mixup, whatsoever. 🙂

First Try Review

Greetings! 👋

Thank you for this piece of software.

I'll summarise thoughts & issues I discovered, when using this project's product for the first time.

  • Templating folder & file names.
    src:
      {nimpackage.nim}: |
        echo "yes"
    
  • Accept configurations files named either *.yaml or *.yml.
  • Make --name optional, if you want to scaffold into the current directory, rather than creating a new one.
  • Optionally read variables from some variables.yml or something.
  • Allow creating files without extensions by using something like myfile.FILE to create the file myfile.

You tell me, whether I should create separate issues or what we otherwise could do with these suggestions. 😄

yaml variables that can set using a flag

Hello there,
I wanted to send in a contribution cause i find this project very cool.
I started working on the new todo as a contribution towards the project.
Problem is i seem to have a little confusion on what it means exactly.
Does it mean you want a feature where users can set various variables as key pair values using a flag eg --flags name:john, age:45 ? and where exactly is the variable supposed to be parsed and used?
See i started working on it thinking you just wanted a way to replace file or directory names with a set yaml variable using a flag like the example above(and i seem to have that working) but now i'm not so sure . Would be helpful if you help clarify what you mean exactly. Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.