TypeBox CLI

Description
CLI tool for various TypeBox and JSON Schema operations.
Install
npm install -g typebox-cli
Usage
Convert TypeScript types to TypeBox Schema
Input file (i.e. types.ts
):
export type T = "test";
Run TypeBox Codegen:
typebox codegen TypeBox --source types.ts
Outputs:
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
):
import { Type } from "@sinclair/typebox";
export const T = Type.String();
Run JSON Schema extraction:
typebox extract json --module typebox.ts -e T
Outputs:
{
"$id": "T",
"type": "string"
}
Reference
Commands
typebox extract json --module <module path>
typebox codegen <model-name> --source <source file>
typebox codegen <model-name> --module <module path>
typebox list
typebox --version
typebox --help
Dependencies
typebox-cli
is based on these packages:
- TypeBox - Json Schema Type Builder with Static Type Resolution for TypeScript
- TypeBox Codegen - Code Generation Tools for TypeBox
- jiti - Module Loading
- Commander - CLI Interface
License
MIT