Giter VIP home page Giter VIP logo

granturismo's Introduction

granturismo

GT

Build Status NPM Version NPM Downloads MIT License Standard Version Codecov

Generator Tool

Workflow tool for scaffolding projects.

The streaming scaffold system.

It is easy to learn and easy to use, more efficient.

If you want to use a scaffold, the scaffold should be adapted to gt, but it is much more simpler than yeoman.

Scaffolds

Installation

Make sure your git version >= 2.7.0

Make sure you have installed nodejs

sudo npm i -g granturismo

Usage

gt

gt help

gt init

gt config list

gt config add scaffold-name git-repo

gt config remove scaffold-name

How to Scaffold Using GT?

Implement scripts/gt.js, adding project info into user config.

See gt-react-scaffold and gt-front-end-scaffold for examples.

gt.js

If you want to use es6 in gt.js, please use babel-register or babel-built js.

// using `babel-register`
if (!global._babelPolyfill) {
    require('babel-polyfill');
}
require('babel-register');
module.exports = require('./gt/index');

GT cli invokes methods in scaffold/scripts/gt.js, and passing options into init.

// gt.js
/**
 * `ask` will be invoked first
 * prompt questions
 * `config` returned will be passed into `init` and `after` by `options.config`
 */, 
export const ask = async(options) => {
    return config;
};
export const init = async(options) => {
    
};
export const after = async(options) => {
    
};
// options
{
    project: {
        folder: '/absolute/path/to/project/folder',
        name: 'project-name', // same as project folder name
        git: {
            repositoryURL: 'git://git-url', // mainly used for package.json repository.url
        },
    },
    scaffold: {
        folder: '/absolute/path/to/scaffold/folder', // mostly ~/.gt/scaffold-name
        name: 'scaffold-name',
    },
    presets: {
        copyFiles: async() => {},
        writeFile: async() => {},
        updateFile: async() => {},
        writeJson: async() => {},
        updateJson: async() => {},
        removeFiles: async() => {},
    },
}
/**
 * listr context
 * do not modify existing attributes
 * if you want to passing variables in listr context, add a new attribute
 */
{
    selectedScaffoldName,
    selectedScaffoldRepo,
    selectedScaffoldFolder,
    projectGT: {}, // js object required from `./scripts/gt.js`
    GTInfo: {}, // options
}

presets

copyFiles(fileList {Array[String]})

fileList Array[String] is an array containing filename your want to copy

eg.

const copyFiles = async() => {

    const {
        presets,
    } = options;

    const files = [
        `docs`,
        `mock-server`,
        `source`,
        `.babelrc`,
        `.editorconfig`,
        `.gitignore`,
        `LICENSE`,
        `webpack.config.js`,
    ];

    await presets.copyFiles(files);
};
writeFile(file {String}, content {String})

Write string into file under project folder

updateFile(file {String}, filter {Function})

filter {Function} filter(input {String}) => output {String}

Read file from scaffold, passing into filter, write filter result into file under project folder

updateFiles(files {Array[String]}, filter {Function})

filter {Function} filter(input {String}) => output {String}

Read file from scaffold, passing into filter, write filter result into file under project folder

writeJson(file {String}, json {Object})

Same as writeFile, but passing json object into second parameter

updateJson(file {String}, filter {Function})

filter {Function} filter(input {Object}) => output {Object}

Same as updateFile, but passing json object into filter

removeFiles(fileList {Array[String]})

fileList Array[String] is an array containing filename your want to copy

Same as copyFiles, but remove files in project folder

Change Log

Change Log

Contribute

make sure you have submitted your changes

npm run release

Prior Art

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.