# granturismo

> generator tool

Latest version **1.14.0** (published 2018-03-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install granturismo
pnpm add granturismo
yarn add granturismo
bun add granturismo
```

Provides the command `gt`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.14.0 |
| Published | 2018-03-02 |
| First published | 2016-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 381.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | vivaxy |
| Maintainers | vivaxy |
| Keywords | granturismo, gt, generator, yo |

## Links

- npm: https://www.npmjs.com/package/granturismo
- Repository: https://github.com/vivaxy/granturismo
- Homepage: https://github.com/vivaxy/granturismo#readme
- Issues: https://github.com/vivaxy/granturismo/issues
- npm.io page: https://npm.io/package/granturismo

## Dependencies (11)

- [chalk](https://npm.io/package/chalk.md) ^2.3.1
- [execa](https://npm.io/package/execa.md) ^0.5.0
- [listr](https://npm.io/package/listr.md) ^0.8.0
- [yargs](https://npm.io/package/yargs.md) ^11.0.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^3.0.1
- [inquirer](https://npm.io/package/inquirer.md) ^1.2.3
- [columnify](https://npm.io/package/columnify.md) ^1.5.4
- [log-symbols](https://npm.io/package/log-symbols.md) ^2.2.0
- [git-user-name](https://npm.io/package/git-user-name.md) ^1.2.0
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.16.0
- [update-notifier](https://npm.io/package/update-notifier.md) ^2.1.0

## Recent versions

- 1.14.0 (latest) — 2018-03-02
- 1.6.0-0 (beta) — 2017-03-18
- 1.13.4 — 2018-01-14
- 1.13.3 — 2018-01-14
- 1.13.2 — 2018-01-14
- 1.13.1 — 2018-01-14
- 1.13.0 — 2018-01-09
- 1.12.2 — 2018-01-09
- 1.12.1 — 2018-01-09
- 1.12.0 — 2018-01-09
- 1.11.1 — 2018-01-03
- 1.11.0 — 2017-08-25
- 1.10.0 — 2017-08-25
- 1.9.1 — 2017-06-13
- 1.9.0 — 2017-06-13
- … 22 more at https://npm.io/package/granturismo/versions

## README

# Granturismo

![GT](./assets/images/gt.png)

[![Build Status][travis-image]][travis-url]
[![NPM Version][npm-version-image]][npm-url]
[![NPM Downloads][npm-downloads-image]][npm-url]
[![MIT License][license-image]][license-url]
[![Conventional Commits][conventional-commits-image]][conventional-commits-url]
[![Codecov][codecov-image]][codecov-url]

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](http://yeoman.io/).

## Scaffolds

- [vivaxy/gt-react-scaffold](https://github.com/vivaxy/gt-react-scaffold) webpack, babel, react, redux, router...
- [vivaxy/gt-front-end-scaffold](https://github.com/vivaxy/gt-front-end-scaffold) webpack, babel, eslint...
- [vivaxy/gt-node-server](https://github.com/vivaxy/gt-node-server) nodejs server
- [vivaxy/gt-npm-package](https://github.com/vivaxy/gt-npm-package) npm package

## Installation

Make sure your git version >= 2.7.0

Make sure you have installed nodejs

`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.

If `scripts/gt.js`, all files will be copied by default.

See [Scaffolds](#scaffolds) for examples.

### `gt.js`

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

```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`.

```js
// 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) => {
    
};
```

```js
// 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
            username: 'vivaxy', // git configured username
        },
    },
    scaffold: {
        folder: '/absolute/path/to/scaffold/folder', // mostly ~/.gt/scaffold-name
        name: 'scaffold-name',
        git: {
            headHash: '23c5742ac306e561554d1cfa56b1618d30d16157',
        },
    },
    presets: {
        copyFiles: async() => {},
        writeFile: async() => {},
        updateFile: async() => {},
        writeJson: async() => {},
        updateJson: async() => {},
        removeFiles: async() => {},
        addScaffoldInfo: async() => {},
    },
}
```

```js
/**
 * 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)`

- `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, content)`

- `file {String}`
- `content {String}`

Write string into file under project folder.

##### `updateFile(file, filter)`

- `file {String}`
- `filter {Function} filter(input) => output`
    - `input {String}`
    - `output {String}`

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

##### `updateFiles(files, filter)`

- `files {Array[String]}`
- `filter {Function} filter(input) => output`
    - `input {String}`
    - `output {String}`

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

##### `writeJson(file, json)`

- `file {String}`
- `json {Object}`

Same as `writeFile`, but passing json object into second parameter.

##### `updateJson(file, filter)`

- `file {String}`
- `filter {Function} filter(input) => output`
    - `input {Object}`
    - `output {Object}`

Same as `updateFile`, but passing json object into `filter`.

##### `removeFiles(fileList)`

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

Same as `copyFiles`, but remove files in project folder.

##### `addScaffoldInfo({ scaffoldCommitHash, scaffoldVersion })`

- `scaffoldCommitHash {String}` default: `'scaffoldCommitHash'`
- `scaffoldVersion {String}` default: `'scaffoldVersion'`

Update the project `package.json` file, add `scaffoldCommitHash` and `scaffoldVersion`.
Use `scaffoldCommitHash` and `scaffoldVersion` as `package.json` key.
If `scaffoldCommitHash` or `scaffoldVersion` is falsy`, it will not add this key.

### How to test a scaffold project?

- Checkout a new branch, update your `gt.js`.
- Use `gt config add test-scaffold-name git-repo#new-branch-name` to set a test registry.
- `gt init` and select `test-scaffold-name` to run `gt.js` in your new branch to test.

## Change Log

[Change Log](CHANGELOG.md)

## Contributing

[Contributing](CONTRIBUTING.md)

## Prior Art

- [yeoman](http://yeoman.io/)
- [node-scaffold-generator](https://github.com/kaelzhang/node-scaffold-generator)
- [generate](https://github.com/generate/generate)

[travis-image]: https://img.shields.io/travis/vivaxy/granturismo.svg?style=flat-square
[travis-url]: https://travis-ci.org/vivaxy/granturismo
[npm-version-image]: http://img.shields.io/npm/v/granturismo.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/granturismo
[npm-downloads-image]: https://img.shields.io/npm/dt/granturismo.svg?style=flat-square
[license-image]: https://img.shields.io/npm/l/granturismo.svg?style=flat-square
[license-url]: LICENSE
[conventional-commits-image]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square
[conventional-commits-url]: https://conventionalcommits.org
[codecov-image]: https://img.shields.io/codecov/c/github/vivaxy/granturismo.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/vivaxy/granturismo

---
_Source: https://npm.io/package/granturismo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
