1 Star 0 Fork 0

ngm-cli / ngm-cli

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

@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

MIT License Copyright (c) 2021 fattypanda Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
JavaScript 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/ngm-cli/ngm-cli.git
git@gitee.com:ngm-cli/ngm-cli.git
ngm-cli
ngm-cli
ngm-cli
master

搜索帮助