Socket
Book a DemoInstallSign in
Socket

typebox-cli

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typebox-cli - npm Package Compare versions

Comparing version

to
1.0.3-dev

2

dist/index.js
import process from "node:process";
import { program } from "commander";
import { program } from "./program.js";
export default function main(argv = process.argv) {

@@ -4,0 +4,0 @@ return program.parse(argv);

{
"name": "typebox-cli",
"version": "1.0.2-dev",
"version": "1.0.3-dev",
"description": "CLI tool for various TypeBox and JSON Schema operations",
"repository": {
"type": "git",
"url": "https://github.com/gsuess/typebox-cli"
},
"main": "dist/index.js",

@@ -6,0 +10,0 @@ "bin": {

@@ -17,11 +17,74 @@ # TypeBox CLI

Convert TypeScript Types to TypeBox schema:
#### Convert TypeScript types to TypeBox Schema
Input file (i.e. `types.ts`):
```ts
export type T = "test";
```
Run TypeBox Codegen:
```bash
typebox codegen TypeBox --source types.ts > typebox.ts
typebox codegen TypeBox --source types.ts
```
Outputs:
```ts
import { Type, Static } from '@sinclair/typebox'
export type T = Static<typeof T>
export const T = Type.String()
```
#### Convert TypeBox Schema into JSON schema
Input file (i.e. `typebox.ts`):
```ts
import { Type } from "@sinclair/typebox";
export const T = Type.String();
```
Run JSON Schema extraction:
```bash
typebox extract json --module typebox.ts -e T
```
Outputs:
```json
{
"$id": "T",
"type": "string"
}
```
## Reference
### Commands
```bash
# Extract - Extract JSON schema from exported TypeBox variables:
typebox extract json --module <module path>
# Codegen -- Generate Schema from either TypeScript types (using --source) or TypeBox schema (using --module):
typebox codegen <model-name> --source <source file> # Generate from TypeScript Types.
typebox codegen <model-name> --module <module path> # Generate from exported TypeBox Schema values.
# List available Codegen models:
typebox list
# Misc
typebox --version # Display current typebox version.
typebox --help # Help
```
### Dependencies
`typebox-cli` is based on these packages:
- [TypeBox](https://github.com/sinclairzx81/typebox) - Json Schema Type Builder with Static Type Resolution for TypeScript
- [TypeBox Codegen](https://github.com/sinclairzx81/typebox-codegen) - Code Generation Tools for TypeBox
- [jiti](https://github.com/unjs/jiti) - Module Loading
- [Commander](https://github.com/tj/commander.js) - CLI Interface
## License
[MIT](LICENSE)

Sorry, the diff of this file is not supported yet