Giter Club home page Giter Club logo

project's Introduction

Project

Command line utility to create new project template.

CI Audit

project is a command line utility to help developers get up and running as quickly as possible with a new project leveraging other projects or pre-existing git repository as a template.

It has a very simple and intuitive commands to help you pull project locally or from a remote git repository. Templates could also be customized using templating engines such as Handlebars or Liquid. A configuration file ("template.toml") can also help developers customize how the new project is generated.

Command Line Interface (CLI)

An ASCII art depiction may help explain this better.

                      Top Level App (project)                 TOP (binary name)
                              |
           --------------------------------------------
         /       |            |       |       \        \
     init       new          git     help --verbose --quiet   LEVEL 1 (subcommands)
      |        /  \         /   \
    repo  template name  remote name                          LEVEL 2 (args)
      |                    |
--branch               --branch                               LEVEL 3 (flags)

Usage

Let's start by asking for --help and see what we get.

$ project --help
project 0.1.0
Victor I. Afolabi <[email protected]
Create a new project from existing project/template.

USAGE:
    project [FLAGS] [SUBCOMMAND]

FLAGS:
    -h, --help       Prints help information
    -q, --quiet      Supress all output. Progress is not reported to the standard error stream.
        --version    Prints version information
    -V, --verbose    Run verbosely.

SUBCOMMANDS:
    git     Initalize project from a GitHub template
    help    Prints this message or the help of the given subcommand(s)
    init    Initialize new project from current dir.
    new     Creates a new project from a local template.

You can get help messages on different subcommands provided:

$ project help new
project-new
Creates a new project from a local template.

USAGE:
    project new <template> [name]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

ARGS:
    <template>    Path to a local template directory.
    <name>        Name of the project / directory name.

A simple view to how you can invoke the subcommands:

$ project init <repo>
$ project new <template> <name>
$ project git <remote> <name> --branch master

To start a new project from a local template:

$ project new ../relative/path/to/template my-project

ProjectInfo: ProjectInfo { name: "my-project", path: "/Users/user/project/my-project" }
TemplateOptions: Local("/Users/user/hbs-template")

Done generating template into /Users/user/project/my-project
Success!
Project name: my-project
Project path: /Users/user/project/my-project
Verbose: false | quite: false

Templates

For more control of the generated project, you can create a "template.toml" file to configure how files are generated, variables that can be substituted, directories and files to include/exclude, and many more. Your template configuration file can also contain placeholders which are provided out-of-the-box. Currently supported palceholders are:

  • {{project-name}} - This is supplied by either passing the name argument to the CLI or automatically inferred from the base project directory.

  • {{author-name}} - Author's name is deteremed from your cargo or git configuration or a fallback to environment variables. You can also manually set the $NAME or $USERNAME environment variable.

  • {{author-email}} - Author's email, like author-name, it's gotten from your cargo or git configuration and a fallback to environment variables. You can also manually set $EMAIL environment variable.

Example

use project::{ProjectInfo, TemplateOptions, Template};

fn main() {
    let project = ProjectInfo::from("path/to/project");
    let options = TemplateOptions::new("path/to/template");

    let template = Template::new(&project, &options);
    match &template.generate() {
        Ok(_) => {
            println!("Finished!");
            println!("\tcd {}", &project.rel_path().display());
        }
        Err(err) => eprintln!("Error generating project. {}", err),
    }
}

A simple example of the "template.toml" configuration file.

# Available built-in placholder variables are project-name, author-name, author-email.

[variables]
project = "{{project-name}}"
author = "{{author-name}}"
author_email = "{{author-email}}"
description = "A template project"
py_version = "3.7"

# Replace these directory with the value.
# e.g  path/to/template/file is renamed to path/to/my_project/file
[rename]
template = "{{project-name}}"
bin = "scripts"

# Files or directories present in the templates can also be filtered out of the target project.
[filters]
exclude = ["venv", ".vscode", ".DS_Store"]

NOTE: Every files that ends with either ".hbs" or ".liquid" is rendered. Since it is a templating engine, logics, conditionals, loops are also evaluated and rendered. After the render, the files are saved without the template extensions. E.g. setup.cfg.hbs is rendered and saved as setup.cfg.

WARNING: For files without extensions, the template extensions are still required to treat it as a candidate for template rendering, otherwise the files are just copied over as-is into the target project.

Additionally, all filters and tags of the Handlebars and Liquid templating language are supported. For more information, checkout the Handlebars and Liquid documentation on Tags and Filters.

More [handlebars helpers] are supported in handlebars.rs and you can also add more helpers to the default ones already provided. See handlebars.rs and handlebars helpers docs for more information.

Contribution

You are very welcome to modify and use them in your own projects.

Please keep a link to the original repository. If you have made a fork with substantial modifications that you feel may be useful, then please open a new issue on GitHub with a link and short description.

License (Apache)

This project is opened under the Apache License 2.0 which allows very broad use for both private and commercial purposes.

A few of the images used for demonstration purposes may be under copyright. These images are included under the "fair usage" laws.

project's People

Contributors

victor-iyi avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

project's Issues

RUSTSEC-2020-0041: Multiple soundness issues in Chunk and InlineArray

Multiple soundness issues in Chunk and InlineArray

Details
Package sized-chunks
Version 0.6.2
URL bodil/sized-chunks#11
Date 2020-09-06

Chunk:

  • Array size is not checked when constructed with unit() and pair().
  • Array size is not checked when constructed with From&lt;InlineArray&lt;A, T&gt;&gt;.
  • Clone and insert_from are not panic-safe; A panicking iterator causes memory safety issues with them.

InlineArray:

  • Generates unaligned references for types with a large alignment requirement.

See advisory page for additional details.

RUSTSEC-2020-0146: arr! macro erases lifetimes

arr! macro erases lifetimes

Details
Package generic-array
Version 0.12.3
URL fizyk20/generic-array#98
Date 2020-04-09
Patched versions >=0.14.0
Unaffected versions <0.8.0

Affected versions of this crate allowed unsoundly extending
lifetimes using arr! macro. This may result in a variety of
memory corruption scenarios, most likely use-after-free.

See advisory page for additional details.

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.