CLI

The Zerone command line interface is provided by the @zeronejs/cliopen in new window .

npm i -g @zeronejs/cli
1

Execute zerone --help to get the following help information:

Usage: zerone <command> [options]

Options:
  -v, --version         Output the current version.
  -h, --help            Output usage information.

Commands:
  new|n [name]          Generate New Zerone application.
  build [options]       ts代码打包为js
  info|i                Display Zerone project details.
  generate|g [options]  Generate a Zerone CRUD element
  api                   Generate Swagger Api
  help [command]        display help for command
1
2
3
4
5
6
7
8
9
10
11
12
13

info

Output information about the current system and dependencies.

Use this command whenever you want to check your environment or submit an Issue.

zerone info
1

new

Create a new Zerone project.

Usage: zerone new|n [options] [name]

Generate New Zerone application.

Options:
  -h, --help  Output usage information.
1
2
3
4
5
6

generate

Typically, during development, every time we create a table, we need to create a CRUD interface or service associated with it, which is a lot of C/V operations, creating multiple File, which involves multiple operations such as renaming, is a waste of time and no technical improvement.

And when junior developers do this, they often get stuck due to low-level mistakes like copying or renaming.

generateis designed to help developers reduce rework and help you get things done over a cup of tea. And the code generated by the program is named correctly, there will be no low-level errors.

generatereads all *.entity.ts files in the current command line directory and generates CRUD associated with them, all you need to do is write a table structureopen in new window.

TIP

The generated Module class needs to be imported into the root Module.

Usage: zerone generate|g [options]

Generate a Zerone CRUD element

Options:
  -d, --delete       Delete files generated before this module.
  -p, --path <path>  Specifies the path to the "entities" folder (relative to the command line).
  -h, --help         Output usage information.
1
2
3
4
5
6
7
8

build

It compiles ts files in packaged projects, which differ from tsc in that it can copy other files such as package.json, etc.

TIP

This is helpful if you are a library developer.

But in real development, you may not need it, so use npm run build

Usage: zerone build [options]

ts is packaged as js

Options:
  -p, --path <path>  Specify the path of the folder where "tsconfig.json" is located.
  -d, --delete       Delete files specified by "outDir".
  -h, --help         Output usage information.
1
2
3
4
5
6
7
8

api

Read the documentation of swagger (v3) and generate the corresponding ts code

TIP

This is helpful if you are a front-end developer.

Usage: zerone api [options]

Generate Swagger Api

Options:
  -h, --help  Output usage information.
1
2
3
4
5
6
  • step 1: You need to add a swagger.config.json configuration file where the api is generated

  • step 2: Add your swagger documentation address to the configuration file

  • step 3: run command

zerone api
1
Configuration example
{
    "docsUrl": "http://www.example.com/v3/api-docs",
    "includeTags": [],
    "excludeTags": ["bot-callback-controller"],
    "prefix": ""
}
1
2
3
4
5
6
Parameter Description
parameterillustrate
docsUrljson document address
includeTagstags to be included (unfilled or empty array means all included)
excludeTagstags to exclude
prefixThe prefix to be added to the interface
axiosInstanceUrlaxios instance address (default:@/utils/request)