@noego/stitch 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +110 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noego/stitch",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
package/readme.md CHANGED
@@ -2,6 +2,113 @@
2
2
 
3
3
  Stitch merges multiple YAML files into a single, validated artifact. It’s ideal for modular OpenAPI specs and other structured YAML, with CLI, Node, and browser support — plus VSCode schema integration for real‑time validation.
4
4
 
5
+ > Note: OpenAPI is used throughout as a familiar example, but Stitch is schema‑agnostic and works with any YAML configuration.
6
+
7
+ ## Core Features
8
+
9
+ - Deterministic ordering: Globs expand to files sorted alphabetically; the order in `stitch.yaml` decides precedence (later wins).
10
+ - Deep merge for objects: Keys are joined recursively; later files override earlier values for the same key.
11
+ - Arrays replace, not concatenate: When a key maps to an array, the array from the later file fully replaces the earlier one.
12
+ - Flexible validation: Lightweight OpenAPI shape checks or full JSON Schema validation via AJV.
13
+ - Multi-environment: Same engine for CLI/Node, plus browser helpers for Vite.
14
+ - Watch + output: Rebuild on changes; write YAML/JSON to file with a generated-file header.
15
+
16
+ ### How merging works (keys and arrays)
17
+
18
+ Given two files merged in order: `base.yaml`, then `override.yaml`.
19
+
20
+ Objects (keys are joined, later overrides):
21
+
22
+ ```yaml
23
+ # base.yaml
24
+ info:
25
+ title: My API
26
+ version: 1.0.0
27
+ contact:
28
+ name: Team A
29
+
30
+ # override.yaml
31
+ info:
32
+ version: 1.1.0
33
+ contact:
34
+ email: team@example.com
35
+ ```
36
+
37
+ Result:
38
+
39
+ ```yaml
40
+ info:
41
+ title: My API # from base
42
+ version: 1.1.0 # overridden by override
43
+ contact:
44
+ name: Team A # preserved from base
45
+ email: team@example.com
46
+ ```
47
+
48
+ Arrays (later replaces earlier, no concat):
49
+
50
+ ```yaml
51
+ # base.yaml
52
+ servers:
53
+ - url: https://api.example.com
54
+ - url: https://staging.example.com
55
+
56
+ # override.yaml
57
+ servers:
58
+ - url: http://localhost:3000
59
+ ```
60
+
61
+ Result:
62
+
63
+ ```yaml
64
+ servers:
65
+ - url: http://localhost:3000
66
+ ```
67
+
68
+ Primitives (later replaces earlier):
69
+
70
+ ```yaml
71
+ # base.yaml
72
+ openapi: 3.0.3
73
+
74
+ # override.yaml
75
+ openapi: 3.1.0
76
+ ```
77
+
78
+ Result: `openapi: 3.1.0`
79
+
80
+ ### Works With Any YAML
81
+
82
+ - Schema‑agnostic: Stitch performs generic YAML deep merges; it is not tied to OpenAPI.
83
+ - Validation choices: For non‑OpenAPI configs, either skip `--validate` or provide your own JSON Schema path.
84
+
85
+ ## Config File (stitch.yaml)
86
+
87
+ Stitch expects a YAML config whose top-level key is `stitch`, an array of file paths and/or glob patterns. Paths are resolved relative to the config file’s directory. Files are merged in the order listed; glob matches are sorted alphabetically.
88
+
89
+ Minimal example:
90
+
91
+ ```yaml
92
+ # stitch.yaml
93
+ stitch:
94
+ - openapi/base.yaml
95
+ - openapi/components/**/*.yaml
96
+ - openapi/paths/**/*.yaml
97
+ - overrides/*.yaml
98
+ ```
99
+
100
+ Notes
101
+ - Required key: `stitch` must be an array.
102
+ - Relative base: paths/globs are resolved relative to the config file location.
103
+ - Ordering: list order decides precedence; later files override earlier ones.
104
+ - Globs: `*`, `**`, `?`, and character classes are supported.
105
+ - JSON is fine too: JSON is a subset of YAML, so a `.json` config with the same shape works.
106
+ - OpenAPI is just an example here: use any YAML file layout and names for your domain.
107
+
108
+ Using a different config file
109
+ - CLI: pass the config file as a positional argument, e.g. `stitch build my-config.yaml` or `stitch watch my-config.yaml`.
110
+ - Programmatic: `stitch.build({ input: 'my-config.yaml', ... })` or `engine.build('my-config.yaml', ...)`.
111
+
5
112
  ## Why Stitch
6
113
 
7
114
  - Modularize YAML: Keep specs split across files and folders without losing clarity.
@@ -102,8 +209,8 @@ const result = stitchFromContent([
102
209
 
103
210
  ## Validation
104
211
 
105
- - Basic: `--validate` enables lightweight OpenAPI shape checks (`openapi`, `info`).
106
- - JSON Schema: `--validate schemas/schema.json` enables full AJV validation against your schema.
212
+ - Basic: `--validate` enables lightweight OpenAPI shape checks (`openapi`, `info`). If your content is not OpenAPI, skip this flag.
213
+ - JSON Schema: `--validate schemas/schema.json` enables full AJV validation against your schema (works for any YAML domain).
107
214
 
108
215
  ## VSCode Integration
109
216
 
@@ -124,9 +231,7 @@ Manual configuration example (`.vscode/settings.json`):
124
231
  }
125
232
  ```
126
233
 
127
- Alternative paths
128
- - "@noego/forge/schema.json" – Package export (if supported by VSCode)
129
- - "node_modules/@noego/forge/schema.json" – Direct node_modules path (most reliable)
234
+
130
235
 
131
236
  ## Example Project Structure
132
237
 
@@ -156,4 +261,3 @@ stitch install @noego/dinner/schema.json --target "**/*.yaml"
156
261
  ## License
157
262
 
158
263
  MIT
159
-