All Projects → yonaskolb → Genesis

yonaskolb / Genesis

Licence: mit
Templating, scaffolding and generation tool

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Genesis

Xcodegen
A Swift command line tool for generating your Xcode project
Stars: ✭ 5,032 (+4024.59%)
Mutual labels:  cli, yaml, generator
Swaggen
OpenAPI/Swagger 3.0 Parser and Swift code generator
Stars: ✭ 385 (+215.57%)
Mutual labels:  cli, yaml, generator
Proji
A powerful cross-platform CLI project templating tool.
Stars: ✭ 156 (+27.87%)
Mutual labels:  cli, tool, templating
Carvel Ytt
YAML templating tool that works on YAML structure instead of text
Stars: ✭ 816 (+568.85%)
Mutual labels:  cli, yaml, templating
Angular Librarian
An Angular 2+ scaffolding setup for creating libraries
Stars: ✭ 92 (-24.59%)
Mutual labels:  cli, generator
Api Client Generator
Angular REST API client generator from Swagger YAML or JSON file with camel case settigs
Stars: ✭ 92 (-24.59%)
Mutual labels:  yaml, generator
Matrix Commander
simple but convenient CLI-based Matrix client app for sending and receiving
Stars: ✭ 90 (-26.23%)
Mutual labels:  cli, tool
Dart Code Metrics
Software analytics tool that helps developers analyse and improve software quality.
Stars: ✭ 96 (-21.31%)
Mutual labels:  cli, tool
Fileinfo
📄Get information on over 10,000 file extensions right from the terminal
Stars: ✭ 86 (-29.51%)
Mutual labels:  cli, tool
Swagger Merger
🔗 Merge multiple swagger files into a swagger file, support JSON/YAML.
Stars: ✭ 94 (-22.95%)
Mutual labels:  cli, yaml
Rundeck Cli
CLI tool for Rundeck
Stars: ✭ 98 (-19.67%)
Mutual labels:  cli, tool
Starred search
Fuzzy search your list of starred ★ repositories on GitHub
Stars: ✭ 89 (-27.05%)
Mutual labels:  cli, tool
Gomplate
A flexible commandline tool for template rendering. Supports lots of local and remote datasources.
Stars: ✭ 1,270 (+940.98%)
Mutual labels:  cli, templating
Git Hub
Git command line interface to GitHub
Stars: ✭ 119 (-2.46%)
Mutual labels:  cli, tool
Boilr
⚡️ boilerplate template manager that generates files or directories from template repositories
Stars: ✭ 1,268 (+939.34%)
Mutual labels:  cli, tool
Generator Ngx Rocket
🚀 Extensible Angular 11+ enterprise-grade project generator
Stars: ✭ 1,329 (+989.34%)
Mutual labels:  cli, generator
Bangajs
Bàngá is a CLI generator for scaffolding ExpressJS applications with speed and efficiency.
Stars: ✭ 102 (-16.39%)
Mutual labels:  cli, generator
Redis Cui
Simple, visual command line tool for redis
Stars: ✭ 101 (-17.21%)
Mutual labels:  cli, tool
Npm Try
🚆 Quickly try npm packages without writing boilerplate code.
Stars: ✭ 103 (-15.57%)
Mutual labels:  cli, tool
Generact
Generate React components by replicating your own
Stars: ✭ 1,471 (+1105.74%)
Mutual labels:  cli, generator

Genesis

SPM Git Version Build Status license

Genesis is a templating and scaffolding tool.

A Genesis template is a manifest of options and files written in yaml or json. Option values can be provided in various ways otherwise you will be interactively asked for inputs. Template files are written in Stencil. The list of files can make use of dynamic paths and be generated multiple times depending on the format of the input.

  • ✅ Template manifests in easy to read and write yaml or json
  • ✅ Template files written in Stencil templating language
  • ✅ Provide options via ENV, command line, file or interactively
  • ✅ Powerful command line interactivity with choices, lists and branching
  • ✅ Write dynamic file paths

The very simple example:

options:
  - name: project
    description: The name of the project
    question: What is the name of your project?
    required: true
    type: string
files:
  - template: project.stencil
    path: "{{ project }}.project"

And then run like this:

$ genesis generate template.yml
What is the name of your project? MyProject
Generated files:
  MyProject.project

Or you can provide the required options via arguments

$ genesis generate template.yml --options name:MyProject
Generated files:
  MyProject.project

Much more powerful templates are possible. See more complete documentation here

Installing

Make sure Xcode 9 is installed first.

Mint

$ mint install yonaskolb/genesis

Make

$ git clone https://github.com/yonaskolb/Genesis.git
$ cd Genesis
$ make

Swift Package Manager

Use CLI

$ git clone https://github.com/yonaskolb/Genesis.git
$ cd Genesis
$ swift run mint

Use as dependency

Add the following to your Package.swift file's dependencies:

.package(url: "https://github.com/yonaskolb/Genesis.git", from: "0.1.0"),

And then import GenesisKit. See GenesisKit for more information.

Usage

Run genesis help for usage instructions

Usage: genesis generate <templatePath> [options]

Options:
  -d, --destination <value>    Path to the directory where output will be generated. Defaults to the current directory
  -h, --help                   Show help information for this command
  -n, --non-interactive        Do not prompt for required options
  -o, --options <value>        Provide option overrides, in the format --options "option1: value 2, option2: value 2.
  -p, --option-path <value>    Path to a yaml or json file containing options

Providing options

Options will be passed to the template in the following order, merging along the way, with duplicate options overriding the previous ones.

1. Environment Variables

Set any environment variables before you call generate, or use already existing ones from your development environment

name="My Name" genesis generate template.yml

2. Options File

Pass a path to a json or yaml file with --option-file This can include more structures and complex data. For example:

name: MyProject
targets:
  - name: MyTarget
    type: application
  - name: MyFramework
    type: framework  

3. Options Argument

Pass specific options with --options like this

-- options "option1: value 2, option2: value 2"

4. Interactive input

Genesis will ask you for any missing options if they are required. You can turn off interactive input with --non-interactive.

5. Default value

Each option can have a default value which be used as a fallback.

Missing value

If an option is required and still hasn't received a value from anywhere, generation will fail.

Template

A genesis template is a yaml or json file that includes a list of options and files

Options

Options are structured input for the Stencil templates. They serve as documentation and allow for Genesis to interactively ask for input.

  • name: This is the name that is referenced in the template as well as the command line
  • value: This is the default value that will be used if none are provided. This can have Stencil tags in it
  • question: The question that is asked when asking for input. This can have Stencil tags in it
  • description: An extended description of the option and what it does
  • required: Whether this option is required or not for the template to generate. If it is not provided via the command line, option file, or input, generation will fail
  • type: This is the type of option. It defaults to string but can be any one of the following:
    • string a simple string
    • boolean a boolean
    • choice a string from a list of choices. Requires choices to be defined
    • array an array of other options. Requires options to be defined.

Files

  • path: This is the path the file will be generated at. It can include Stencil tags to make it dynamic. This defaults to template if present
  • contents: A file template string
  • template: A path to a file template
  • context: An optional context property path that will be passed to the template. If this resolves to an array, a file for each element will be created, using tags in path to differentiate them.
  • include: Whether the file should be written. This is a Stencil if tag without the braces. For example instead of {% if type == 'framework' %} you would write type == 'framework'

Each file can have a contents or template. If neither of those are present, the file will be copied exactly as is without any content replacement. The final path of the file will be based off path otherwise template.

Stencil Templates

Each Stencil template has all the filters available in StencilSwiftKit, and has access to all the options. See Stencil for more info about tags.

Small example:

{% if name %}
name: {{ name }}
{% endif %}

GenesisKit

The library GenesisKit can be used to easily provide generation in your own tools.

import GenesisKit

// create a context
let context: [String: Any] = ["name": "hello"]

// create a template, either from a file or programmatically
let template = try GenesisTemplate(path: "template.yml")

// Create the generator
let generator = try TemplateGenerator(template: template)

// generate the files
let generationResult = try generator.generate(context: context, interactive: false)

// write the files to disk
try generationResult.writeFiles(path: "destination")

Contributions

Pull requests and issues are welcome

License

Genesis is licensed under the MIT license. See LICENSE for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].