@efebia/yaml-to-ts 0.0.4 → 0.0.5

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.
Files changed (2) hide show
  1. package/README.md +81 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # @efebia/yaml-to-ts
2
+
3
+ CLI tool that generates a TypeScript interface declaration from a YAML file.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install --save-dev @efebia/yaml-to-ts
9
+ # or globally
10
+ npm install -g @efebia/yaml-to-ts
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ yaml-to-ts <input-file> [options]
17
+ ```
18
+
19
+ ### Example
20
+
21
+ Given `config.yaml`:
22
+
23
+ ```yaml
24
+ server:
25
+ host: localhost
26
+ port: 3000
27
+ features:
28
+ - name: darkMode
29
+ enabled: true
30
+ ```
31
+
32
+ Running:
33
+
34
+ ```bash
35
+ yaml-to-ts config.yaml --interface-name Config --out-file config.d.ts
36
+ ```
37
+
38
+ Produces `config.d.ts`:
39
+
40
+ ```ts
41
+ export interface Config {
42
+ server: {
43
+ host: string;
44
+ port: number;
45
+ };
46
+ features: {
47
+ name: string;
48
+ enabled: boolean;
49
+ }[];
50
+ }
51
+ ```
52
+
53
+ ### Dry run (print to stdout)
54
+
55
+ ```bash
56
+ yaml-to-ts config.yaml --dry-run
57
+ ```
58
+
59
+ ## Options
60
+
61
+ | Flag | Alias | Type | Default | Description |
62
+ |------|-------|------|---------|-------------|
63
+ | `<input-file>` | `-i` | `string` | — | **Required.** Path to the input YAML file |
64
+ | `--out-file` | `-o` | `string` | `./declaration.d.ts` | Output file path |
65
+ | `--interface-name` | `--int` | `string` | `Declaration` | Name of the generated TypeScript interface |
66
+ | `--prettier-file` | `-p` | `string` | — | Path to a Prettier config file for formatting the output |
67
+ | `--dry-run` | `-d` | `boolean` | `false` | Print the generated declaration to stdout instead of writing to disk |
68
+
69
+ ## Type inference
70
+
71
+ Types are inferred from the YAML values:
72
+
73
+ - Strings → `string`
74
+ - Numbers → `number`
75
+ - Booleans → `boolean`
76
+ - Arrays → element type with `[]` suffix (inferred from the first element)
77
+ - Nested objects → nested interface shape
78
+
79
+ ## License
80
+
81
+ ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efebia/yaml-to-ts",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Build TS interface declaration from yml file",
5
5
  "main": "lib/yaml-to-ts.js",
6
6
  "scripts": {