Skip to content

Commit 6fbae75

Browse files
committed
fix: Adjust the command name
1 parent 51ec0c8 commit 6fbae75

File tree

3 files changed

+23
-173
lines changed

3 files changed

+23
-173
lines changed

README.md

+11-69
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,21 @@
1-
# CLI Tsup Template
1+
# Json2Typebox CLI
22

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.
44

5-
English | [简体中文](https://github.com/hacxy/cli-tsup-template/blob/main/README_zh.md)
5+
## Installation
66

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
289
```
2910

30-
### Install Dependencies
11+
## Usage
3112

32-
```sh
33-
cd my-cli-project
34-
npm install
35-
```
13+
### Commands
3614

37-
### Development
15+
- `quick`: Convert json data in the clipboard to typebox type and save it in the clipboard
3816

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
4919
```
5020

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+
![](https://raw.githubusercontent.com/hacxy/hacxy/main/images/Kapture%202024-10-30%20at%2011.13.16.gif)

README_zh.md

-84
This file was deleted.

src/index.ts

+12-20
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,19 @@ import projectInfo from '../package.json';
77

88
const bootstrap = async () => {
99
const cli = cac('json2typebox');
10-
cli.command('tb', 'Generate typebox schemas').action(async () => {
11-
const clipboardStr = clipboard.readSync();
12-
try {
13-
const code = await json2typebox(clipboardStr, 'Root');
14-
clipboard.writeSync(code);
15-
console.log(logSymbols.success, 'Successfully converted into typebox, to clipboard!');
16-
} catch (error) {
17-
console.log(logSymbols.error, 'Failed, check whether the paste board data is json.');
18-
}
19-
});
10+
cli
11+
.command('quick', 'Read JSON from the clipboard and generate TypeBox types into the clipboard.')
12+
.action(async () => {
13+
const clipboardStr = clipboard.readSync();
14+
try {
15+
const code = await json2typebox(clipboardStr, 'Root');
16+
clipboard.writeSync(code);
17+
console.log(logSymbols.success, 'Successfully converted into typebox, to clipboard!');
18+
} catch (error) {
19+
console.log(logSymbols.error, 'Failed, check whether the paste board data is json.');
20+
}
21+
});
2022

21-
cli.command('ts', 'Generate typescript types').action(async () => {
22-
const clipboardStr = clipboard.readSync();
23-
try {
24-
const code = await json2typebox(clipboardStr, 'Root');
25-
clipboard.writeSync(code);
26-
console.log(logSymbols.success, 'Successfully converted into typescrit, to clipboard!');
27-
} catch (error) {
28-
console.log(logSymbols.error, 'Failed, check whether the paste board data is json.');
29-
}
30-
});
3123
cli.help();
3224
cli.version(projectInfo.version);
3325
cli.parse(process.argv);

0 commit comments

Comments
 (0)