https://github.com/iaseth/tsj-cli
https://github.com/iaseth/tsj-cli
cli interface json node types typescript
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/iaseth/tsj-cli
- Owner: iaseth
- License: mit
- Created: 2025-04-06T15:37:27.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2025-04-06T16:24:02.000Z (6 months ago)
- Last Synced: 2025-04-06T16:36:13.455Z (6 months ago)
- Topics: cli, interface, json, node, types, typescript
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/tsj-cli
- Size: 0 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# tsj-cli
**tsj-cli** is a lightweight CLI tool that generates TypeScript interfaces or type aliases from a JSON file.
๐ฆ NPM: [`tsj-cli`](https://www.npmjs.com/package/tsj-cli)
๐ป GitHub: [iaseth/tsj-cli](https://github.com/iaseth/tsj-cli)## โจ Features
- Generates TypeScript `interface` or `type` from JSON
- Supports custom indentation: 2 spaces (default), 4 spaces, or tabs
- Simple command-line usage
- Minimal and dependency-free output## ๐ Installation
```bash
npm i -g tsj-cli@latest
```## ๐ Usage
```bash
tsj [--type | --interface] [--tabs | --spaces]
```### Examples
```bash
tsj user.json # default: interface, 2 spaces
tsj user.json --type # generates a type alias
tsj user.json --spaces # uses 4 spaces for indentation
tsj user.json --tabs # uses tabs instead
tsj user.json --type --tabs # type alias with tab indentation
```### Input (`user.json`)
```json
{
"id": 1,
"name": "Alice",
"isAdmin": false,
"tags": ["dev", "ts"],
"profile": {
"age": 30,
"location": "Earth"
}
}
```### Output (`interface`)
```ts
interface User {
id: number;
name: string;
isAdmin: boolean;
tags: string[];
profile: {
age: number;
location: string;
};
}
```## ๐ Project Structure
```bash
tsj-cli/
โโโ src/ # Source code (written in TypeScript)
โโโ dist/ # Transpiled JavaScript output
โโโ package.json
โโโ tsconfig.json
โโโ .gitignore
โโโ .npmignore
โโโ README.md
```## ๐งช Development
```bash
# Install dependencies
npm install# Build
npm run build# Test locally
ts-node src/index.ts data.json --type --tabs# Link globally for local use
npm link
tsj data.json --interface
```## ๐ License
MIT ยฉ [iaseth](https://github.com/iaseth)