@sculptor/cli 0.1.11 → 0.1.12
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 +21 -0
- package/README.md +494 -0
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Prakhar Tripathi (imprakhartripathi)
|
|
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,494 @@
|
|
|
1
|
+
# @sculptor/cli
|
|
2
|
+
|
|
3
|
+
The SculptorTS CLI is the user-facing command line for the framework.
|
|
4
|
+
|
|
5
|
+
It handles:
|
|
6
|
+
|
|
7
|
+
- New app scaffolding
|
|
8
|
+
- Resource generation
|
|
9
|
+
- Test generation and registry syncing
|
|
10
|
+
- Dev and production startup paths
|
|
11
|
+
- Help and version output
|
|
12
|
+
|
|
13
|
+
## Quick Command Sheet
|
|
14
|
+
|
|
15
|
+
| Command | What it does |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `sc new <app>` | Creates a new app |
|
|
18
|
+
| `sc dev` | Starts the app from source |
|
|
19
|
+
| `sc start` | Starts the app in production-style mode |
|
|
20
|
+
| `sc build` | Builds the app |
|
|
21
|
+
| `sc lint` | Lints the app |
|
|
22
|
+
| `sc test` | Runs the test suite |
|
|
23
|
+
| `sc generate` / `sc g` | Generates framework resources |
|
|
24
|
+
| `sc g c user` | Generates a controller resource |
|
|
25
|
+
| `sc g c user in src/app/users` | Generates into a custom path |
|
|
26
|
+
| `sc g c in src/app/users` | Infers the name from the path and generates there |
|
|
27
|
+
| `sc g t user -e` | Generates an enum type file |
|
|
28
|
+
| `sc g t user -i` | Generates an interface type file |
|
|
29
|
+
| `sc g t user -c` | Generates a class type file |
|
|
30
|
+
| `sc v` / `sc --v` / `sc -v` | Prints version |
|
|
31
|
+
| `sc help` | Prints help |
|
|
32
|
+
|
|
33
|
+
## Entry Points
|
|
34
|
+
|
|
35
|
+
- Binary: `sc`
|
|
36
|
+
- Programmatic API: `runCli()`
|
|
37
|
+
|
|
38
|
+
## Command Reference
|
|
39
|
+
|
|
40
|
+
### `sc new <app>`
|
|
41
|
+
|
|
42
|
+
What it does:
|
|
43
|
+
- Creates a new Sculptor app in a sibling folder
|
|
44
|
+
- Writes the initial framework files
|
|
45
|
+
- Installs the package dependencies
|
|
46
|
+
|
|
47
|
+
How it is used:
|
|
48
|
+
```bash
|
|
49
|
+
sc new my-app
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Flags:
|
|
53
|
+
|
|
54
|
+
| Flag | Meaning |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| `--name <value>` | Sets the app name |
|
|
57
|
+
| `--version <value>` | Sets the scaffolded app version |
|
|
58
|
+
| `--style <decorator|functional|hybrid>` | Sets the routing mode |
|
|
59
|
+
| `--decorator` | Shortcut for decorator mode |
|
|
60
|
+
| `--functional` | Shortcut for functional mode |
|
|
61
|
+
| `--hybrid` | Shortcut for hybrid mode |
|
|
62
|
+
| `--frameworkLock <true|false>` | Sets framework lock |
|
|
63
|
+
| `--frameworklock <true|false>` | Alias for framework lock |
|
|
64
|
+
| `--framework-lock <true|false>` | Alias for framework lock |
|
|
65
|
+
| `--dev-server <tsx|nodemon>` | Selects the dev server |
|
|
66
|
+
| `--devserver <tsx|nodemon>` | Alias for dev server |
|
|
67
|
+
| `--tsx` | Shortcut for `tsx` dev server |
|
|
68
|
+
| `--nodemon` | Shortcut for `nodemon` dev server |
|
|
69
|
+
|
|
70
|
+
Examples:
|
|
71
|
+
```bash
|
|
72
|
+
sc new api
|
|
73
|
+
sc new api --style=hybrid
|
|
74
|
+
sc new api --dev-server=nodemon
|
|
75
|
+
sc new api --framework-lock=false
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
What it solves:
|
|
79
|
+
- You get a ready-to-run app with the framework defaults already wired
|
|
80
|
+
|
|
81
|
+
You will find it here:
|
|
82
|
+
- [packages/cli/src/cli.ts](src/cli.ts)
|
|
83
|
+
- [packages/cli/src/scaffold.ts](src/scaffold.ts)
|
|
84
|
+
|
|
85
|
+
### `sc dev`
|
|
86
|
+
|
|
87
|
+
What it does:
|
|
88
|
+
- Starts the app from source
|
|
89
|
+
- Prints the CLI banner
|
|
90
|
+
|
|
91
|
+
How it is used:
|
|
92
|
+
```bash
|
|
93
|
+
sc dev
|
|
94
|
+
sc dev --port=4000
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Flags:
|
|
98
|
+
|
|
99
|
+
| Flag | Meaning |
|
|
100
|
+
| --- | --- |
|
|
101
|
+
| `--port=<number>` | Sets `PORT` for the dev process |
|
|
102
|
+
|
|
103
|
+
What it solves:
|
|
104
|
+
- You can restart the app quickly while editing source files
|
|
105
|
+
|
|
106
|
+
Behavior:
|
|
107
|
+
- Uses `nodemon` when `project.devServer` is `nodemon`
|
|
108
|
+
- Uses `tsx` when `project.devServer` is `tsx`
|
|
109
|
+
- Refuses to run outside a Sculptor app root
|
|
110
|
+
- Suppresses the runtime banner by setting `SCULPTOR_SUPPRESS_BANNER=1`
|
|
111
|
+
|
|
112
|
+
### `sc start`
|
|
113
|
+
|
|
114
|
+
What it does:
|
|
115
|
+
- Starts the app in production-style mode
|
|
116
|
+
|
|
117
|
+
How it is used:
|
|
118
|
+
```bash
|
|
119
|
+
sc start
|
|
120
|
+
sc start --port=4000
|
|
121
|
+
sc start --watch
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Flags:
|
|
125
|
+
|
|
126
|
+
| Flag | Meaning |
|
|
127
|
+
| --- | --- |
|
|
128
|
+
| `--port=<number>` | Sets `PORT` for the process |
|
|
129
|
+
| `--watch` | Forces the dev path instead of the built path |
|
|
130
|
+
|
|
131
|
+
Behavior:
|
|
132
|
+
- If `dist/main.js` exists and `--watch` is not set, it runs the built app
|
|
133
|
+
- If `--watch` is set, it behaves like `sc dev`
|
|
134
|
+
- If no build output exists, it falls back to `tsx src/main.ts`
|
|
135
|
+
|
|
136
|
+
What it solves:
|
|
137
|
+
- The same command can be used for production-style startup and local fallback startup
|
|
138
|
+
|
|
139
|
+
### `sc build`
|
|
140
|
+
|
|
141
|
+
What it does:
|
|
142
|
+
- Runs TypeScript build for the current app
|
|
143
|
+
|
|
144
|
+
How it is used:
|
|
145
|
+
```bash
|
|
146
|
+
sc build
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
What it solves:
|
|
150
|
+
- Creates production JavaScript output from app source
|
|
151
|
+
|
|
152
|
+
Behavior:
|
|
153
|
+
- Only works inside a Sculptor app root
|
|
154
|
+
- Uses the app-local `tsconfig.json`
|
|
155
|
+
|
|
156
|
+
### `sc lint`
|
|
157
|
+
|
|
158
|
+
What it does:
|
|
159
|
+
- Runs ESLint from the app root
|
|
160
|
+
|
|
161
|
+
How it is used:
|
|
162
|
+
```bash
|
|
163
|
+
sc lint
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
What it solves:
|
|
167
|
+
- Gives a single framework-aligned lint command
|
|
168
|
+
|
|
169
|
+
### `sc test`
|
|
170
|
+
|
|
171
|
+
What it does:
|
|
172
|
+
- Runs the app test suite
|
|
173
|
+
|
|
174
|
+
How it is used:
|
|
175
|
+
```bash
|
|
176
|
+
sc test
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Behavior:
|
|
180
|
+
- If `src/tests/runner.ts` exists, runs `vitest run src/tests/runner.ts`
|
|
181
|
+
- If the runner does not exist, falls back to `vitest run`
|
|
182
|
+
|
|
183
|
+
What it solves:
|
|
184
|
+
- You can keep a generated test registry while still having a standard test command
|
|
185
|
+
|
|
186
|
+
### `sc generate` and `sc g`
|
|
187
|
+
|
|
188
|
+
What it does:
|
|
189
|
+
- Generates framework resources in the current app
|
|
190
|
+
|
|
191
|
+
How it is used:
|
|
192
|
+
```bash
|
|
193
|
+
sc generate controller user
|
|
194
|
+
sc g c user
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Supported kinds:
|
|
198
|
+
|
|
199
|
+
| Kind | Aliases |
|
|
200
|
+
| --- | --- |
|
|
201
|
+
| controller | `c`, `controller` |
|
|
202
|
+
| service | `s`, `service` |
|
|
203
|
+
| module | `m`, `mo`, `module` |
|
|
204
|
+
| middleware | `mw`, `middleware` |
|
|
205
|
+
| type | `t`, `type` |
|
|
206
|
+
| route | `r`, `route`, `resource` |
|
|
207
|
+
|
|
208
|
+
Behavior:
|
|
209
|
+
- Refuses to run outside a Sculptor app root
|
|
210
|
+
- Refuses route generation in decorator mode
|
|
211
|
+
- Rewrites the test registry when test generation is enabled
|
|
212
|
+
|
|
213
|
+
What it solves:
|
|
214
|
+
- Your app stays consistent as it grows
|
|
215
|
+
|
|
216
|
+
### `sc help`
|
|
217
|
+
|
|
218
|
+
What it does:
|
|
219
|
+
- Prints help text
|
|
220
|
+
|
|
221
|
+
How it is used:
|
|
222
|
+
```bash
|
|
223
|
+
sc help
|
|
224
|
+
sc help generate
|
|
225
|
+
sc help controller
|
|
226
|
+
sc help module
|
|
227
|
+
sc help middleware
|
|
228
|
+
sc help type
|
|
229
|
+
sc help route
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### `sc version`
|
|
233
|
+
|
|
234
|
+
What it does:
|
|
235
|
+
- Prints the CLI version and the banner
|
|
236
|
+
|
|
237
|
+
How it is used:
|
|
238
|
+
```bash
|
|
239
|
+
sc version
|
|
240
|
+
sc v
|
|
241
|
+
sc -v
|
|
242
|
+
sc --v
|
|
243
|
+
sc --version
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Full Flag Reference
|
|
247
|
+
|
|
248
|
+
### Global flags and aliases
|
|
249
|
+
|
|
250
|
+
| Input | Meaning |
|
|
251
|
+
| --- | --- |
|
|
252
|
+
| `-v` | Print version |
|
|
253
|
+
| `--v` | Print version |
|
|
254
|
+
| `--version` | Print version |
|
|
255
|
+
| `version` | Print version |
|
|
256
|
+
| `v` | Print version |
|
|
257
|
+
| `-h` | Print help |
|
|
258
|
+
| `--help` | Print help |
|
|
259
|
+
|
|
260
|
+
### `sc new` flags
|
|
261
|
+
|
|
262
|
+
| Flag | Meaning |
|
|
263
|
+
| --- | --- |
|
|
264
|
+
| `--name` | App name |
|
|
265
|
+
| `--version` | Scaffold version |
|
|
266
|
+
| `--style` | Routing style |
|
|
267
|
+
| `--decorator` | Decorator routing shortcut |
|
|
268
|
+
| `--functional` | Functional routing shortcut |
|
|
269
|
+
| `--hybrid` | Hybrid routing shortcut |
|
|
270
|
+
| `--frameworkLock` | Framework lock |
|
|
271
|
+
| `--frameworklock` | Framework lock |
|
|
272
|
+
| `--framework-lock` | Framework lock |
|
|
273
|
+
| `--dev-server` | Dev server selection |
|
|
274
|
+
| `--devserver` | Dev server selection |
|
|
275
|
+
| `--tsx` | Dev server shortcut |
|
|
276
|
+
| `--nodemon` | Dev server shortcut |
|
|
277
|
+
|
|
278
|
+
### `sc dev` / `sc start` flags
|
|
279
|
+
|
|
280
|
+
| Flag | Meaning |
|
|
281
|
+
| --- | --- |
|
|
282
|
+
| `--port` | Sets the process port |
|
|
283
|
+
| `--watch` | Only used by `sc start` |
|
|
284
|
+
|
|
285
|
+
### `sc generate` flags
|
|
286
|
+
|
|
287
|
+
| Flag | Meaning |
|
|
288
|
+
| --- | --- |
|
|
289
|
+
| `--functional` | Use functional routing mode |
|
|
290
|
+
| `--decorator` | Use decorator routing mode |
|
|
291
|
+
| `--hybrid` | Use hybrid routing mode |
|
|
292
|
+
| `--style` | Explicitly set routing mode |
|
|
293
|
+
| `in <path>` | Write files into a custom directory |
|
|
294
|
+
| `-i` | Type generator creates `*.interface.ts` |
|
|
295
|
+
| `-interface` | Type generator creates `*.interface.ts` |
|
|
296
|
+
| `-c` | Type generator creates `*.class.ts` |
|
|
297
|
+
| `-class` | Type generator creates `*.class.ts` |
|
|
298
|
+
| `-e` | Type generator creates `*.enum.ts` |
|
|
299
|
+
| `-enum` | Type generator creates `*.enum.ts` |
|
|
300
|
+
|
|
301
|
+
## Generator Behavior
|
|
302
|
+
|
|
303
|
+
### Controller generation
|
|
304
|
+
|
|
305
|
+
What it does:
|
|
306
|
+
- In decorator mode, writes `*.controller.ts`
|
|
307
|
+
- In functional mode, writes `*.routes.ts` and `*.handler.ts`
|
|
308
|
+
- In hybrid mode, writes both controller and functional files
|
|
309
|
+
|
|
310
|
+
Examples:
|
|
311
|
+
```bash
|
|
312
|
+
sc g c user
|
|
313
|
+
sc g c user in src/app/users
|
|
314
|
+
sc g c in src/app/users
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
If you use `in <path>`:
|
|
318
|
+
- the file location changes to that path
|
|
319
|
+
- the file name still follows the generator suffix
|
|
320
|
+
- if you do not provide a name, the CLI infers it from the last path segment
|
|
321
|
+
- the generated test file, when enabled, is written under `src/tests`
|
|
322
|
+
|
|
323
|
+
### Service generation
|
|
324
|
+
|
|
325
|
+
What it does:
|
|
326
|
+
- Writes `*.service.ts`
|
|
327
|
+
|
|
328
|
+
Examples:
|
|
329
|
+
```bash
|
|
330
|
+
sc g s user
|
|
331
|
+
sc g s user in src/app/services
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Module generation
|
|
335
|
+
|
|
336
|
+
What it does:
|
|
337
|
+
- Writes `*.module.ts`
|
|
338
|
+
|
|
339
|
+
Examples:
|
|
340
|
+
```bash
|
|
341
|
+
sc g m user
|
|
342
|
+
sc g mo user
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Middleware generation
|
|
346
|
+
|
|
347
|
+
What it does:
|
|
348
|
+
- Writes `*.middleware.ts`
|
|
349
|
+
|
|
350
|
+
Examples:
|
|
351
|
+
```bash
|
|
352
|
+
sc g mw auth
|
|
353
|
+
sc g mw auth in src/app/middlewares
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Type generation
|
|
357
|
+
|
|
358
|
+
What it does:
|
|
359
|
+
- Writes one of:
|
|
360
|
+
- `*.type.ts`
|
|
361
|
+
- `*.interface.ts`
|
|
362
|
+
- `*.class.ts`
|
|
363
|
+
- `*.enum.ts`
|
|
364
|
+
|
|
365
|
+
Examples:
|
|
366
|
+
```bash
|
|
367
|
+
sc g t user
|
|
368
|
+
sc g t
|
|
369
|
+
sc g t user -i
|
|
370
|
+
sc g t user -interface
|
|
371
|
+
sc g t user -c
|
|
372
|
+
sc g t user -class
|
|
373
|
+
sc g t user -e
|
|
374
|
+
sc g t user -enum
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
If you omit the name, the CLI falls back to `index` unless a custom output path lets it infer a name from the directory.
|
|
378
|
+
|
|
379
|
+
### Route generation
|
|
380
|
+
|
|
381
|
+
What it does:
|
|
382
|
+
- Writes `*.routes.ts` in functional or hybrid mode
|
|
383
|
+
|
|
384
|
+
Examples:
|
|
385
|
+
```bash
|
|
386
|
+
sc g r user
|
|
387
|
+
sc g r user in src/app/routes
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
Decorator mode behavior:
|
|
391
|
+
- The CLI refuses route generation
|
|
392
|
+
|
|
393
|
+
## Test Generation
|
|
394
|
+
|
|
395
|
+
Test generation is controlled by `testing.generate` in `sculptor.json`.
|
|
396
|
+
|
|
397
|
+
| Setting | Result |
|
|
398
|
+
| --- | --- |
|
|
399
|
+
| `true` | Matching `*.spec.ts` files are generated |
|
|
400
|
+
| `false` | No new spec files are generated |
|
|
401
|
+
|
|
402
|
+
Generated spec names:
|
|
403
|
+
|
|
404
|
+
- `user.controller.spec.ts`
|
|
405
|
+
- `user.service.spec.ts`
|
|
406
|
+
- `user.routes.spec.ts`
|
|
407
|
+
- `auth.middleware.spec.ts`
|
|
408
|
+
|
|
409
|
+
Default scaffold test files:
|
|
410
|
+
|
|
411
|
+
- `src/tests/main.spec.ts`
|
|
412
|
+
- `src/tests/health.controller.spec.ts`
|
|
413
|
+
- `src/tests/health.routes.spec.ts`
|
|
414
|
+
- `src/tests/registry.ts`
|
|
415
|
+
- `src/tests/runner.ts`
|
|
416
|
+
|
|
417
|
+
## Test Harness Behavior
|
|
418
|
+
|
|
419
|
+
What it does:
|
|
420
|
+
- Discovers every `*.spec.ts` file under `src/tests`
|
|
421
|
+
- Writes `src/tests/registry.ts`
|
|
422
|
+
- Writes `src/tests/runner.ts`
|
|
423
|
+
|
|
424
|
+
How it is used:
|
|
425
|
+
- `sc test` runs the registry runner when it exists
|
|
426
|
+
|
|
427
|
+
What it solves:
|
|
428
|
+
- You do not have to manually keep your test suite entrypoint updated
|
|
429
|
+
|
|
430
|
+
## App Root Rules
|
|
431
|
+
|
|
432
|
+
Only these commands work from outside a Sculptor app root:
|
|
433
|
+
|
|
434
|
+
- `sc new`
|
|
435
|
+
- `sc help`
|
|
436
|
+
- `sc version`
|
|
437
|
+
|
|
438
|
+
Everything else requires `sculptor.json` in the current directory.
|
|
439
|
+
|
|
440
|
+
If you try to run a restricted command outside an app root, the CLI stops with a clear error.
|
|
441
|
+
|
|
442
|
+
## CLI Banner Behavior
|
|
443
|
+
|
|
444
|
+
The version line in the banner is automatic.
|
|
445
|
+
|
|
446
|
+
If the package version changes, the banner version changes too.
|
|
447
|
+
|
|
448
|
+
## Programmatic Use
|
|
449
|
+
|
|
450
|
+
```ts
|
|
451
|
+
import { runCli } from "@sculptor/cli";
|
|
452
|
+
|
|
453
|
+
await runCli(["node", "sc", "help"]);
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
## Exports
|
|
457
|
+
|
|
458
|
+
`@sculptor/cli` re-exports:
|
|
459
|
+
|
|
460
|
+
- `runCli`
|
|
461
|
+
- `resolveProjectMetadata`
|
|
462
|
+
- `scaffoldProject`
|
|
463
|
+
- `generateResourceFiles`
|
|
464
|
+
- `writeGeneratedFiles`
|
|
465
|
+
- `syncTestHarness`
|
|
466
|
+
- the scaffold help strings
|
|
467
|
+
|
|
468
|
+
## Package Scripts
|
|
469
|
+
|
|
470
|
+
- `npm run cli` runs the CLI source with `tsx`
|
|
471
|
+
- `npm run build` compiles the package
|
|
472
|
+
- `npm run prepack` builds before packaging
|
|
473
|
+
|
|
474
|
+
## If You Only Remember One Thing
|
|
475
|
+
|
|
476
|
+
If you are inside a Sculptor app root, use:
|
|
477
|
+
|
|
478
|
+
```bash
|
|
479
|
+
sc dev
|
|
480
|
+
sc g c user
|
|
481
|
+
sc test
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
If you are outside an app root, only use:
|
|
485
|
+
|
|
486
|
+
```bash
|
|
487
|
+
sc new
|
|
488
|
+
sc help
|
|
489
|
+
sc version
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
## License
|
|
493
|
+
|
|
494
|
+
MIT
|