tutuca 0.9.16 → 0.9.18

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
@@ -59,6 +59,74 @@ Zero-dependency batteries included SPA framework.
59
59
  </html>
60
60
  ```
61
61
 
62
+ ## CLI
63
+
64
+ Tutuca ships a single-file CLI (`dist/tutuca-cli.js`) for inspecting, linting,
65
+ documenting, and rendering components defined in an ES module. The module just
66
+ needs to export `getComponents()` and, for render-time commands, `getExamples()`
67
+ in the storybook shape `{ title, description?, groups?, items: [{ title, description?, value, view? }] }`.
68
+
69
+ ### Setup
70
+
71
+ ```sh
72
+ npm install --save-dev tutuca jsdom
73
+ # prettier is optional, only needed for --pretty
74
+ npm install --save-dev prettier
75
+ ```
76
+
77
+ The package exposes `tutuca` via `bin`, so `npx tutuca` (or a global `npm i -g tutuca jsdom`) just works. `jsdom` is a peer dep because it's only needed for `render`, `lint`, and `doctor`.
78
+
79
+ ### Commands
80
+
81
+ ```
82
+ tutuca <module-path> <command> [args] [flags]
83
+ tutuca help [command]
84
+ ```
85
+
86
+ | Command | What it does |
87
+ |---|---|
88
+ | `info` | Export inventory and counts for the module |
89
+ | `list` | List components and their fields/views |
90
+ | `examples` | List the examples defined in the module's section |
91
+ | `docs [name]` | Component API docs — all, or one by name |
92
+ | `lint [name]` | Run lint checks — all, or one by name (exit 2 on errors) |
93
+ | `render [name] [--title t] [--view v]` | Render examples to HTML |
94
+ | `doctor` | Lint + render smoke test over the whole module |
95
+
96
+ Global flags: `-f, --format <cli\|md\|json\|html>`, `-o, --output <file>`, `--pretty`, `-h, --help`.
97
+ Exit codes: `0` ok, `1` usage, `2` lint errors, `3` render crash.
98
+
99
+ ### Usage examples
100
+
101
+ ```sh
102
+ # Summary of what the module exports
103
+ npx tutuca ./src/components.js info
104
+
105
+ # API docs for one component, as markdown
106
+ npx tutuca ./src/components.js docs Button --format md -o docs/button.md
107
+
108
+ # Render every example to HTML, pretty-printed
109
+ npx tutuca ./src/components.js render --format html --pretty -o dist/examples.html
110
+
111
+ # Render a single named example
112
+ npx tutuca ./src/components.js render Button --title "Disabled state"
113
+
114
+ # Lint just one component (exit 2 if findings)
115
+ npx tutuca ./src/components.js lint Button
116
+
117
+ # CI smoke test — lints and renders everything
118
+ npx tutuca ./src/components.js doctor
119
+ ```
120
+
121
+ ### Wrapping
122
+
123
+ The invocation stays short even without wrapping, but common patterns:
124
+
125
+ - **`package.json` scripts** — `"docs": "tutuca ./src/components.js docs"`
126
+ - **Shell alias** — `tut() { npx tutuca ./src/components.js "$@"; }`, then `tut render Button`
127
+ - **`justfile` / `Makefile`** — one recipe per subcommand, passing through positionals
128
+ - **Programmatic** — `import "tutuca/cli"` (the bundled entry) for custom build integration
129
+
62
130
  ## License
63
131
 
64
132
  MIT