@fattypanda/ngm-cli

1.1.1 • Public • Published

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

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

安装

$ npm install -g @fattypanda/ngm-cli

OR

$ yarn global add @fattypanda/ngm-cli

示例

创建项目

$ ngm create new-project

在当前目录创建项目

$ ngm create
$ ngm create .
$ ngm create ./

创建项目选择配置文件

$ 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] 的帮助信息

特别说明

$ ngm create [name] -c <url>
$ ngm add <name> <url>
$ ngm update <name> [url]

以上 url 可以是远程地址 (http|https);

配置文件 (*.json)

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[];
}

默认配置

{
  "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

Package Sidebar

Install

npm i @fattypanda/ngm-cli

Weekly Downloads

4

Version

1.1.1

License

MIT

Unpacked Size

23.9 kB

Total Files

17

Last publish

Collaborators

  • fattypanda