@streetui/cli 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 StreetUI contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,262 @@
1
+ # @streetui/cli
2
+
3
+ The StreetUI command-line tool. It scaffolds new projects and drives the full
4
+ application lifecycle — development, production build, and serving — on top of
5
+ the existing StreetUI pipeline (`DSL → Compiler → Graph → Runtime → Renderer`).
6
+ The CLI only *orchestrates* that pipeline; it is not a framework layer of its
7
+ own.
8
+
9
+ ```
10
+ streetui create <dir> Scaffold a new StreetUI project
11
+ streetui dev Start the dev server with live reload
12
+ streetui build Produce a production build (dist/client, dist/server)
13
+ streetui start Serve the production build
14
+ ```
15
+
16
+ ---
17
+
18
+ ## Installation
19
+
20
+ The CLI ships two binaries:
21
+
22
+ - `streetui` — the project command (`dev` / `build` / `start` / `create`)
23
+ - `create-streetui` — the `npm create` entry point
24
+
25
+ ```bash
26
+ # scaffold a new app
27
+ npm create streetui@latest my-app
28
+
29
+ # …or, if the CLI is installed in a project, run commands directly
30
+ npx streetui dev
31
+ ```
32
+
33
+ > **Note on this monorepo.** The `@streetui/*` packages are not yet published to
34
+ > npm. Inside this repository the generated app resolves them through the
35
+ > workspace (see *Project structure* below). `npm create streetui@latest` is the
36
+ > intended public entry point once the packages are published.
37
+
38
+ ---
39
+
40
+ ## Creating an app
41
+
42
+ ```bash
43
+ npm create streetui@latest my-app
44
+ cd my-app
45
+ npm install
46
+ npm run dev
47
+ ```
48
+
49
+ `create` scaffolds a real, working StreetUI application — no placeholder code,
50
+ no fake APIs, no React, no JSX. Two templates are available:
51
+
52
+ | Template | `--template` | What you get |
53
+ | -------- | ------------ | ------------ |
54
+ | SSR (default) | `ssr` | Server-rendered app with two views (Home / About), a counter signal, conditional rendering, a form, and client hydration. |
55
+ | Basic | `basic` | A single server-rendered page with a counter and a toggle — the smallest complete app. |
56
+
57
+ ```bash
58
+ npm create streetui@latest my-app -- --template basic
59
+ ```
60
+
61
+ Both templates are server-rendered and hydrate on the client, so `dev`,
62
+ `build`, and `start` all follow one uniform pipeline.
63
+
64
+ <!-- APPEND-HERE -->
65
+
66
+ ---
67
+
68
+ ## Development — `streetui dev`
69
+
70
+ ```bash
71
+ npm run dev # → streetui dev
72
+ streetui dev --port 4000 --host 0.0.0.0
73
+ ```
74
+
75
+ `dev` builds the project once, then watches your source with esbuild's
76
+ incremental rebuild — only what changed is recompiled, not the whole project on
77
+ every keystroke. On each successful rebuild, connected browsers reload
78
+ automatically (a small live-reload script is injected into the served HTML).
79
+ Build errors are printed with real source positions and never crash the server:
80
+
81
+ ```
82
+ streetui Client rebuild failed:
83
+ StreetUI build error (1 error)
84
+
85
+ src/app.ts:42:17
86
+ Expected ";" but found "const"
87
+ | const total = count()
88
+ ```
89
+
90
+ The dev server prints the URL it is listening on once it is actually ready.
91
+
92
+ ## Production build — `streetui build`
93
+
94
+ ```bash
95
+ npm run build # → streetui build
96
+ ```
97
+
98
+ `build` runs two esbuild passes over your real entries and writes to the output
99
+ directory (default `dist/`):
100
+
101
+ ```
102
+ dist/
103
+ client/ Browser bundle (main.js) + your public assets
104
+ server/ Node SSR bundle (server.js)
105
+ ```
106
+
107
+ The client bundle is what the browser downloads to hydrate; the server bundle
108
+ exports the `render(request)` function used for SSR. A build fails (non-zero
109
+ exit) only on real errors — third-party warnings never break the build. When
110
+ the project has no server entry, the server pass is skipped and you get a
111
+ client-only build.
112
+
113
+ ## Production server — `streetui start`
114
+
115
+ ```bash
116
+ npm run start # → streetui start
117
+ streetui start --port 8080
118
+ ```
119
+
120
+ `start` serves the production build using Node's standard `node:http` server —
121
+ no Express, no third-party server. Static assets under `dist/client/` are served
122
+ directly; every other request is server-rendered through your `server.js`
123
+ bundle and returned as full HTML, ready to hydrate. If no build exists yet,
124
+ `start` builds first.
125
+
126
+ ---
127
+
128
+ ## Configuration — `streetui.config.ts`
129
+
130
+ Configuration is optional: every field has a sensible default, so an app with no
131
+ config file still builds and runs. When you need to override something, author a
132
+ `streetui.config.ts`:
133
+
134
+ ```ts
135
+ import { defineConfig } from '@streetui/cli';
136
+
137
+ export default defineConfig({
138
+ port: 3000, // dev/start port
139
+ host: 'localhost', // host to bind
140
+ clientEntry: 'src/main.ts', // browser entry (hydration)
141
+ serverEntry: 'src/server.ts', // SSR entry (exports render())
142
+ outDir: 'dist', // build output directory
143
+ publicDir: 'public', // static assets copied verbatim
144
+ });
145
+ ```
146
+
147
+ The config is TypeScript and is compiled on the fly with esbuild, so you do not
148
+ need a TypeScript loader registered in Node. All defaults:
149
+
150
+ | Field | Default | Purpose |
151
+ | ----- | ------- | ------- |
152
+ | `port` | `3000` | Port for `dev` / `start` |
153
+ | `host` | `localhost` | Host to bind |
154
+ | `clientEntry` | `src/main.ts` | Browser/hydration entry |
155
+ | `serverEntry` | `src/server.ts` | SSR entry exporting `render(request)` |
156
+ | `outDir` | `dist` | Build output directory |
157
+ | `publicDir` | `public` | Static assets directory |
158
+
159
+ Command-line `--port` and `--host` override the config for a single run.
160
+
161
+ ---
162
+
163
+ ## Environment variables
164
+
165
+ StreetUI is safe by default: **only variables whose names begin with
166
+ `STREETUI_PUBLIC_` are exposed to the browser bundle.** Everything else stays on
167
+ the server, so secrets in the process environment cannot leak into client-side
168
+ JavaScript.
169
+
170
+ ```bash
171
+ # Reaches the browser (inlined at build time):
172
+ STREETUI_PUBLIC_API_URL=https://api.example.com
173
+
174
+ # Server-only — never inlined into the client bundle:
175
+ DATABASE_URL=postgres://…
176
+ SESSION_SECRET=…
177
+ ```
178
+
179
+ In code, read them as compile-time constants:
180
+
181
+ ```ts
182
+ const apiUrl = process.env.STREETUI_PUBLIC_API_URL;
183
+ ```
184
+
185
+ `NODE_ENV` is always defined as the build mode (`development` or `production`),
186
+ so you can branch on it.
187
+
188
+ ---
189
+
190
+ ## SSR & hydration
191
+
192
+ Both templates render on the server and hydrate on the client:
193
+
194
+ 1. **Server** — `server.ts` exports `render(request)`. It compiles the app,
195
+ calls `renderToString(compiled)` (pure — no DOM globals), serializes the
196
+ initial signal state into a `<script data-streetui-state>` island, and
197
+ returns a full HTML document that links `/main.js`.
198
+ 2. **Browser** — `main.ts` reads the state island, seeds the signals with the
199
+ exact server values, recompiles the same app, and calls
200
+ `renderer.hydrate(compiled, appContainer)`. Because the client starts from
201
+ the same state, the server markup is adopted rather than thrown away, and
202
+ events + signals become live.
203
+
204
+ The starter templates switch views with a signal (`when(...)`) rather than the
205
+ router, which keeps SSR + hydration identity robust for the common case. The
206
+ router remains available for apps that need URL-driven routing.
207
+
208
+ ---
209
+
210
+ ## Project structure
211
+
212
+ A generated project looks like this:
213
+
214
+ ```
215
+ my-app/
216
+ package.json scripts: dev / build / start / typecheck
217
+ tsconfig.json strict TypeScript, bundler resolution
218
+ streetui.config.ts optional configuration
219
+ public/ static assets (styles.css, favicon.svg)
220
+ src/
221
+ app.ts the StreetUI app: signals + DSL + views
222
+ server.ts SSR entry — exports render(request)
223
+ main.ts browser entry — hydrates the app
224
+ README.md
225
+ ```
226
+
227
+ Inside this monorepo the generated `node_modules/@streetui/*` are linked to the
228
+ workspace packages; once the framework is published, `npm install` resolves them
229
+ from the registry.
230
+
231
+ ---
232
+
233
+ ## CLI reference
234
+
235
+ ```
236
+ streetui <command> [options]
237
+
238
+ Commands:
239
+ create <dir> Scaffold a new StreetUI project
240
+ dev Start the development server with live reload
241
+ build Produce a production build (dist/client, dist/server)
242
+ start Serve the production build
243
+
244
+ Options:
245
+ -h, --help Show help
246
+ -v, --version Show the CLI version
247
+ -p, --port <n> Port for dev/start (default 3000)
248
+ --host <host> Host for dev/start (default localhost)
249
+ --template <t> Template for create (basic | ssr)
250
+ --dir <path> Project directory (default current directory)
251
+ ```
252
+
253
+ Unknown options are rejected with a message rather than silently ignored, so a
254
+ typo never changes behaviour quietly.
255
+
256
+ ### Project validation
257
+
258
+ The CLI fails with a clear, stack-trace-free message when it is run outside a
259
+ StreetUI project — for example, a missing `package.json`, a `package.json` with
260
+ no `@streetui/*` dependency, an invalid config file, or a missing build entry.
261
+
262
+