1.2.0 • Published 3 years ago

project-template-cli v1.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

project-template-cli

A simple cli to create project from template

template-cli

Features

  • Created according to different project template types
  • Can be created using local templates or remote templates
  • Support GitHub and GitLab
  • Support download single template folder without git clone whole project
  • Rich custom configuration items

Install

npm i -g project-template-cli

Usage

template
Usage: template [options] [command]

Options:
  -v,--version                   output the version number
  -h, --help                     display help for command

Commands:
  init [options] [projectName]   init project from template
  list [options] [templateType]  list template types or names
  config [options]               operating config
  help [command]                 display help for command

Templates folder format

Whether it is a local templates or a remote templates, the first level in the folder is the template type, and the second level is the actual template

├── Electron
│   └── electron-quick-start
├── React
│   ├── create-next-app
│   └── create-react-app
└── Vue
    ├── create-nuxt-app
    └── vue-cli

Config

The configuration file is stored in the user root directory by default

# show in explorer
template config -s
# open config
template config -o
# reset config
template config -r

default config

{
  "githubToken": "",
  "gitlabToken": "",
  "localTemplates": [],
  "remoteTemplates": [
    {
      "owner": "njzydark",
      "repo": "templates",
      "path": "",
      "type": "github"
    }
  ],
  "npmDependeniesInstall": {
    "auto": true,
    "silent": false,
    "manager": "npm"
  },
  "git": {
    "init": true,
    "firstCommit": ""
  },
  "editorOpen": {
    "name": "vscode",
    "command": "code",
    "enable": false
  }
}

local templates

add path item to localTemplates, the path must be absolute path

"localTemplates": [
  {
    "path": "/Users/njzy/Projects/PersonalProjects/templates"
  }
],

remote templates

The following is the built-in remote template, you can remove and custom your own remote templates repo

GitHub

the owner repo path is the part of Github Api

the type must currently be github

"remoteTemplates": [
  {
    "owner": "njzydark",
    "repo": "templates",
    "path": "",
    "type": "github"
  }
],

GitLab

the type must currently be gitlab

"remoteTemplates": [
  {
    "baseUrl": "https://gitlab.com/api/v4",
    "owner": "",
    "repo": "",
    "branch": "master",
    "path": "",
    "type": "gitlab"
  }
]