npm package: @fattypanda/ngm-cli
Description: node git template manage cli
Author: fattypanda
Latest version: 1.1.1

@fattypanda/ngm-cli -- 使用 node 进行 git 模板管理
===

[npm-image]: http://img.shields.io/npm/v/@fattypanda/ngm-cli.svg?style=flat-square
[npm-url]: http://npmjs.org/package/@fattypanda/ngm-cli
[download-image]: https://img.shields.io/npm/dm/@fattypanda/ngm-cli.svg?style=flat-square
[download-url]: https://npmjs.org/package/@fattypanda/ngm-cli

`ngm` 会按照一定的规则，使用预设的 `git` 模板创建到指定项目。

## 安装

```shell script
$ npm install -g @fattypanda/ngm-cli
```

OR

```shell script
$ yarn global add @fattypanda/ngm-cli
```

## 示例
#### 创建项目
```shell script
$ ngm create new-project
```
#### 在当前目录创建项目
```shell script
$ ngm create
$ ngm create .
$ ngm create ./
```
#### 创建项目选择配置文件
```shell script
$ ngm create new-project -c ./config.json
$ ngm create new-project -u default
```

## 使用说明
```
Usage: ngm create [name] [options]

Options:
  -v,--version                  查看版本信息
  -h,--help                     查看帮助信息

Commands:
  create [options] [name]       创建新项目（[name]=[ |.|./] 在当前目录创建项目）
    -i,--install                模板下载完成后自动安装依赖
    -u,--use <config-name>      选择使用的配置名称
    -c,--config <config-path>   选择使用的配置文件
  add <name> <url>              添加配置
  del <name>                    删除配置
  update <name> [url]           更新配置
  use [name]                    使用配置
  help [command]                查看 [command] 的帮助信息
```

## 特别说明
```shell script
$ ngm create [name] -c <url>
$ ngm add <name> <url>
$ ngm update <name> [url]
```
以上 `url` 可以是远程地址 `(http|https)`;

## 配置文件 （*.json）
```typescript
export interface When {
    name: string;
    includes?: string[];
}

export interface Prompt {
    name: string;
    type: 'list' | 'checkbox';
    message: string;
    choices: string[];
    default: string[];
    whens?: When[];
}

export interface Template {
    whens: When[];
    repo: string;
}

export interface Config {
    name: string;
    url?: string;
    prompts: Prompt[];
    templates: Template[];
}
```

## 默认配置
```json
{
  "name": "默认",
  "prompts": [
    {
      "name": "framework",
      "type": "list",
      "message": "请选择架构",
      "choices": [
        "umi"
      ],
      "default": [
        "umi"
      ]
    },
    {
      "name": "template",
      "type": "list",
      "message": "请选择模板",
      "choices": [
        "公共模板"
      ],
      "default": [
        "公共模板"
      ],
      "whens": [
        {
          "name": "framework",
          "includes": [
            "umi"
          ]
        }
      ]
    },
    {
      "name": "packages",
      "type": "checkbox",
      "message": "请选择需要使用第三方包",
      "choices": [
        "ahooks",
        "react-use",
        "classnames",
        "unstated-next",
        "antd",
        "@ant-design/icon"
      ],
      "default": [
        "ahooks",
        "react-use",
        "classnames",
        "unstated-next",
        "antd",
        "@ant-design/icon"
      ],
      "whens": [
        {
          "name": "framework",
          "includes": [
            "umi"
          ]
        }
      ]
    }
  ],
  "templates": [
    {
      "whens": [
        {
          "name": "framework",
          "includes": [
            "umi"
          ]
        },
        {
          "name": "template",
          "includes": [
            "公共模板"
          ]
        }
      ],
      "repo": "https://gitee.com/ngm-cli/umi-default-template.git"
    }
  ]
}
```

## LICENSE
MIT