zhang-cli
v1.1.4
Published
`zhang-cli` is a command-line tool used to clone template projects from a specified GitHub or Gitee organization. It guides users through an interactive command-line interface (CLI) to select the desired platform, organization name, and project template,
Downloads
4
Readme
zhang-cli
zhang-cli
is a command-line tool used to clone template projects from a specified GitHub or Gitee organization. It guides users through an interactive command-line interface (CLI) to select the desired platform, organization name, and project template, and then clones it locally.
Features
- Supports retrieving all available templates from a GitHub or Gitee organization.
- Provides an interactive template selection interface.
- Automatically clones the selected template into the user-specified project folder.
- Saves the user's selection (platform and organization name) to a configuration file on first use, and automatically reads from the configuration file on subsequent uses to avoid repeated input.
Installation
Before using this CLI, you need to install it globally. Run the following command:
npm install -g zhang-cli
Usage
After installation, you can use the zhang
command to create a new project. Here’s how to use it:
zhang create <project-name>
This command will perform the following steps:
- If running for the first time:
- Select which platform (GitHub or Gitee) you want to retrieve templates from.
- Enter the name of the organization you want to use.
- This information will be saved in a configuration file located in the user's home directory as
.zhang-cli-config.json
.
- Retrieve a list of all available templates from the specified platform and organization.
- Prompt you to choose a template via the interactive interface.
- Clone the selected template into a local folder named
<project-name>
.
Dependencies
This CLI uses the following dependencies:
axios
: For sending HTTP requests to the GitHub or Gitee API and retrieving template information.inquirer
: For creating interactive command-line interfaces.simple-git
: For executing Git operations and cloning template projects.commander
: For parsing command-line input and defining command structures.
Example
Suppose you want to create a new project using a template from a GitHub or Gitee organization:
- Run
zhang create my-project
in the terminal. - If running for the first time, choose the platform (GitHub or Gitee) and enter the organization name.
- Choose the template you want to use.
- The tool will automatically clone the template into a local folder named
my-project
and notify you when the cloning is complete.
Configuration File
On the first run, the platform and organization name will be saved to a .zhang-cli-config.json
file in the user's home directory. On subsequent runs, the configuration will be automatically read from this file. If the file is deleted, the system will prompt the user to input the information again.
Version
Current version: 1.0.0
License
This project is licensed under the ISC License.
zhang-cli
zhang-cli
是一个命令行工具,用于从指定的 GitHub 或 Gitee 组织中克隆模板项目。它通过交互式命令行界面(CLI)引导用户选择所需的平台、组织名和项目模板,并将其克隆到本地。
功能
- 支持从 GitHub 或 Gitee 组织中获取所有可用的模板。
- 提供交互式的模板选择界面。
- 自动克隆选定的模板到用户指定的项目文件夹中。
- 第一次使用时,保存用户的选择(平台和组织名)到配置文件,下次使用时自动读取配置,避免重复输入。
安装
在使用该 CLI 之前,您需要先全局安装它。运行以下命令:
npm install -g zhang-cli
用法
安装完成后,您可以使用 zhang
命令来创建一个新的项目。以下是使用方式:
zhang create <project-name>
此命令会执行以下步骤:
- 如果是首次运行:
- 选择您要从哪个平台(GitHub 或 Gitee)获取模板。
- 输入要使用的组织名称。
- 这些信息会被保存到配置文件中,配置文件位于用户主目录下的
.zhang-cli-config.json
文件中。
- 从指定的平台和组织中获取所有可用的模板列表。
- 通过交互式界面提示您选择一个模板。
- 克隆选定的模板到以
<project-name>
命名的本地文件夹中。
依赖
该 CLI 使用了以下依赖库:
axios
: 用于向 GitHub 或 Gitee API 发送 HTTP 请求并获取模板信息。inquirer
: 用于创建交互式命令行界面。simple-git
: 用于执行 Git 操作并克隆模板项目。commander
: 用于解析命令行输入和定义命令结构。
示例
假设您想使用 GitHub 或 Gitee 组织中的一个模板创建一个新项目:
- 在终端中运行
zhang create my-project
。 - 如果是第一次运行,选择平台(GitHub 或 Gitee)并输入组织名称。
- 选择您想要使用的模板。
- 工具会自动克隆该模板到当前目录下名为
my-project
的文件夹中,并告知您克隆完成。
配置文件
首次运行时,平台和组织名称会被保存到用户主目录下的 .zhang-cli-config.json
文件中。下次运行时将自动读取该配置文件。如果该文件被删除,系统将重新提示用户输入。
版本
当前版本:1.0.0
许可证
该项目遵循 ISC 许可证。