|
1 |
| -# CLI Tsup Template |
| 1 | +# Json2Typebox CLI |
2 | 2 |
|
3 |
| -This is a Nodejs CLI application development template that uses TypeScript as the development language and tsup as the build tool. |
| 3 | +This is the command line tool for [json2typebox](https://github.com/hacxy/json2typebox), used to convert json files to typebox type definitions. |
4 | 4 |
|
5 |
| -English | [简体中文](https://github.com/hacxy/cli-tsup-template/blob/main/README_zh.md) |
| 5 | +## Installation |
6 | 6 |
|
7 |
| -## Prerequisites |
8 |
| - |
9 |
| -Requires Node.js version 18+ or 20+. |
10 |
| - |
11 |
| -## Using the Template |
12 |
| - |
13 |
| -### Create the Template Locally |
14 |
| - |
15 |
| -- You can quickly create a project locally using [create-ts-frame](https://github.com/hacxy/create-ts-frame). |
16 |
| - |
17 |
| -When executing the creation command, you can specify the project name and template name through options. |
18 |
| - |
19 |
| -```sh |
20 |
| -# npm 7+, requires additional double dashes: |
21 |
| -npm create ts-frame@latest my-cli-app -- --template cli-tsup |
22 |
| -# yarn |
23 |
| -yarn create ts-frame my-cli-app --template cli-tsup |
24 |
| -# pnpm |
25 |
| -pnpm create ts-frame my-cli-app --template cli-tsup |
26 |
| -# bun |
27 |
| -bun create ts-frame my-cli-app --template cli-tsup |
| 7 | +```bash |
| 8 | +npm install -g json2typebox |
28 | 9 | ```
|
29 | 10 |
|
30 |
| -### Install Dependencies |
| 11 | +## Usage |
31 | 12 |
|
32 |
| -```sh |
33 |
| -cd my-cli-project |
34 |
| -npm install |
35 |
| -``` |
| 13 | +### Commands |
36 | 14 |
|
37 |
| -### Development |
| 15 | +- `quick`: Convert json data in the clipboard to typebox type and save it in the clipboard |
38 | 16 |
|
39 |
| -- Development mode: This will enable `watch` mode to rebuild code and output `sourcemap` files for debugging. |
40 |
| - |
41 |
| -```sh |
42 |
| -npm run dev |
43 |
| -``` |
44 |
| - |
45 |
| -- Build production environment code: |
46 |
| - |
47 |
| -```sh |
48 |
| -npm run build |
| 17 | +```bash |
| 18 | +json2typebox quick |
49 | 19 | ```
|
50 | 20 |
|
51 |
| -- Type check: |
52 |
| - |
53 |
| -```sh |
54 |
| -npm run typecheck |
55 |
| -``` |
56 |
| - |
57 |
| -## Debugging Program Execution |
58 |
| - |
59 |
| -As I use `vscode` to develop CLI applications, corresponding debug configuration file `.vscode/launch.json` is provided. When you need to debug this project, first add breakpoints, then press `F5` key to start Debugger mode. The Debugger mode will automatically exit when your CLI application execution ends. |
60 |
| - |
61 |
| -### Global Link Package |
62 |
| - |
63 |
| -You can also establish a global link for this package so that you can test or debug code with real environments easily: |
64 |
| - |
65 |
| -```sh |
66 |
| -npm link |
67 |
| -``` |
68 |
| - |
69 |
| -Afterwards, you can execute command "hello-cli" at any path under all terminals of your operating system. This command corresponds to value of option "bin" in file `package.json`. |
70 |
| - |
71 |
| -When you no longer need this global link, you can manually remove it by executing in root directory of your project: |
72 |
| - |
73 |
| -```sh |
74 |
| -npm unlink -g |
75 |
| -``` |
76 |
| - |
77 |
| -### Dependency Description |
78 |
| - |
79 |
| -If your third-party library is installed with DevDependencies during development time,executing `npm run build` will pack these dependencies into production environment codes.If program works abnormally after installing via this method,you should try installing them as production environment dependencies(Dependencies). When they are installed as production environment dependencies ,they won't be packed into production environment codes . |
| 21 | + |
0 commit comments