type-flash 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  <div align="center">
2
2
 
3
- # type-gen
3
+ # type-flash
4
4
 
5
5
  **JSON 智能生成 TypeScript 类型定义**
6
6
 
7
- [![npm version](https://img.shields.io/npm/v/type-gen.svg?style=flat-square)](https://www.npmjs.com/package/type-gen)
7
+ [![npm version](https://img.shields.io/npm/v/type-flash.svg?style=flat-square)](https://www.npmjs.com/package/type-flash)
8
8
  [![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
9
9
 
10
10
  > **One line of code, types generated instantly.**
@@ -50,19 +50,19 @@
50
50
 
51
51
  ```bash
52
52
  # npm
53
- npm install type-gen --save-dev
53
+ npm install type-flash --save-dev
54
54
 
55
55
  # yarn
56
- yarn add type-gen -D
56
+ yarn add type-flash -D
57
57
 
58
58
  # pnpm
59
- pnpm add type-gen -D
59
+ pnpm add type-flash -D
60
60
  ```
61
61
 
62
62
  ### 一行代码上手
63
63
 
64
64
  ```typescript
65
- import { generate } from 'type-gen';
65
+ import { generate } from 'type-flash';
66
66
 
67
67
  const jsonData = {
68
68
  id: 1,
@@ -83,7 +83,7 @@ console.log(result.code);
83
83
 
84
84
  ```typescript
85
85
  /**
86
- * Generated by type-gen
86
+ * Generated by type-flash
87
87
  * Root type: User
88
88
  */
89
89
 
@@ -110,7 +110,7 @@ export interface UserProfile {
110
110
  #### 基础用法
111
111
 
112
112
  ```typescript
113
- import { generate, generateFromString } from 'type-gen';
113
+ import { generate, generateFromString } from 'type-flash';
114
114
 
115
115
  // 从 JS 对象生成
116
116
  const result1 = generate({ name: 'foo', age: 25 }, { rootName: 'User' });
@@ -128,7 +128,7 @@ console.log(result1.types);
128
128
  #### 分页接口示例
129
129
 
130
130
  ```typescript
131
- import { generate } from 'type-gen';
131
+ import { generate } from 'type-flash';
132
132
 
133
133
  const apiResponse = {
134
134
  code: 0,
@@ -187,35 +187,35 @@ export enum StatusEnum {
187
187
 
188
188
  ```bash
189
189
  # 从文件生成,输出到控制台
190
- type-gen user.json
190
+ type-flash user.json
191
191
 
192
192
  # 指定输出文件
193
- type-gen user.json -o user.types.ts
193
+ type-flash user.json -o user.types.ts
194
194
 
195
195
  # 自定义根类型名
196
- type-gen user.json -n User
196
+ type-flash user.json -n User
197
197
 
198
198
  # 使用 type 风格输出
199
- type-gen data.json --style type
199
+ type-flash data.json --style type
200
200
  ```
201
201
 
202
202
  #### 高级用法
203
203
 
204
204
  ```bash
205
205
  # 从标准输入读取(管道)
206
- curl https://api.example.com/users | type-gen -n UserList
206
+ curl https://api.example.com/users | type-flash -n UserList
207
207
 
208
208
  # 生成带注释的类型定义
209
- type-gen api.json --comments -o api-types.ts
209
+ type-flash api.json --comments -o api-types.ts
210
210
 
211
211
  # 严格空值模式
212
- type-gen data.json --strict-null
212
+ type-flash data.json --strict-null
213
213
 
214
214
  # 添加类型前缀
215
- type-gen response.json --prefix I -o interfaces.ts
215
+ type-flash response.json --prefix I -o interfaces.ts
216
216
 
217
217
  # 不生成 export
218
- type-gen types.json --no-export
218
+ type-flash types.json --no-export
219
219
  ```
220
220
 
221
221
  #### 所有 CLI 选项
@@ -301,7 +301,7 @@ interface GenerateOptions {
301
301
  #### 企业级 DTO 配置
302
302
 
303
303
  ```typescript
304
- import { generate } from 'type-gen';
304
+ import { generate } from 'type-flash';
305
305
 
306
306
  const result = generate(jsonData, {
307
307
  rootName: 'UserDTO',
@@ -338,7 +338,7 @@ const result = generate(jsonData, {
338
338
 
339
339
  ### 与其他方案对比
340
340
 
341
- | 特性 | type-gen | json-schema-to-typescript | 在线转换工具 | quicktype |
341
+ | 特性 | type-flash | json-schema-to-typescript | 在线转换工具 | quicktype |
342
342
  |------|--------|---------------------------|--------------|-----------|
343
343
  | **直接输入 JSON** | ✅ | ❌ 需要 JSON Schema | ✅ | ✅ |
344
344
  | **嵌套对象自动命名** | ✅ 智能命名 | ✅ | ⚠️ 简单命名 | ✅ |
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * type-gen CLI - 命令行工具
3
+ * type-flash CLI - 命令行工具
4
4
  *
5
5
  * 用法:
6
- * type-gen <input.json> [options]
7
- * type-gen -i input.json -o output.ts
8
- * cat data.json | type-gen
6
+ * type-flash <input.json> [options]
7
+ * type-flash -i input.json -o output.ts
8
+ * cat data.json | type-flash
9
9
  *
10
10
  * 示例:
11
- * type-gen user.json -n User
12
- * type-gen api.json --style type --no-export
13
- * curl https://api.example.com/users | type-gen -n UserList
11
+ * type-flash user.json -n User
12
+ * type-flash api.json --style type --no-export
13
+ * curl https://api.example.com/users | type-flash -n UserList
14
14
  */
15
15
 
16
16
  'use strict';
@@ -142,12 +142,12 @@ function parseArgs(argv) {
142
142
  // 显示帮助信息
143
143
  function showHelp() {
144
144
  console.log(`
145
- type-gen - JSON 智能生成 TypeScript 类型定义
145
+ type-flash - JSON 智能生成 TypeScript 类型定义
146
146
 
147
147
  用法:
148
- type-gen <input.json> [options]
149
- type-gen -i input.json -o output.ts
150
- cat data.json | type-gen
148
+ type-flash <input.json> [options]
149
+ type-flash -i input.json -o output.ts
150
+ cat data.json | type-flash
151
151
 
152
152
  选项:
153
153
  -i, --input <file> 输入 JSON 文件路径
@@ -171,16 +171,16 @@ type-gen - JSON 智能生成 TypeScript 类型定义
171
171
 
172
172
  示例:
173
173
  # 从文件生成
174
- type-gen user.json -n User -o user.ts
174
+ type-flash user.json -n User -o user.ts
175
175
 
176
176
  # 使用 type 风格输出
177
- type-gen data.json --style type
177
+ type-flash data.json --style type
178
178
 
179
179
  # 从标准输入读取
180
- curl https://api.example.com/data | type-gen -n ApiResponse
180
+ curl https://api.example.com/data | type-flash -n ApiResponse
181
181
 
182
182
  # 带前缀和注释
183
- type-gen api.json --prefix Api --comments -o api-types.ts
183
+ type-flash api.json --prefix Api --comments -o api-types.ts
184
184
  `);
185
185
  }
186
186
 
@@ -189,9 +189,9 @@ function showVersion() {
189
189
  try {
190
190
  const pkgPath = path.join(__dirname, '..', 'package.json');
191
191
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
192
- console.log(`type-gen v${pkg.version}`);
192
+ console.log(`type-flash v${pkg.version}`);
193
193
  } catch (e) {
194
- console.log('type-gen (unknown version)');
194
+ console.log('type-flash (unknown version)');
195
195
  }
196
196
  }
197
197
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-flash",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "JSON 智能生成 TypeScript 类型定义 - 一键从 JSON 数据生成 Interface / Type 定义",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",