@ozanarslan/corpus-cli 0.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.
package/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+ Copyright (c) 2026 ozanArslan2424
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,196 @@
1
+ # @ozanarslan/corpus-cli
2
+
3
+ CLI for [@ozanarslan/corpus](https://github.com/ozanArslan2424/corpus) — codegen for API clients, and scaffolding for services, controllers, models, exceptions, and full resources.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ bunx @ozanarslan/corpus-cli <module> [args]
9
+ ```
10
+
11
+ Or install as a dev dependency:
12
+
13
+ ```bash
14
+ bun add -d @ozanarslan/corpus-cli
15
+ ```
16
+
17
+ ```json
18
+ {
19
+ "scripts": {
20
+ "gen:api": "corpus api",
21
+ "gen:resource": "corpus resource"
22
+ }
23
+ }
24
+ ```
25
+
26
+ ## Modules
27
+
28
+ | Module | Aliases | Description |
29
+ | ------------------- | ------- | ----------------------------------------------------------------------------- |
30
+ | `api` | — | Codegen for all routes |
31
+ | `service <name>` | `svc` | Scaffold a standalone service with stubbed CRUD methods |
32
+ | `controller <name>` | `ctrl` | Scaffold a standalone controller with stubbed CRUD routes |
33
+ | `model <name>` | `mdl` | Scaffold a standalone model with a default CRUD-shaped interface or schema |
34
+ | `exception <name>` | `exc` | Scaffold a standalone exception class with a default NotImplemented exception |
35
+ | `resource <name>` | `res` | Scaffold a new resource (model, service, controller, exception) |
36
+
37
+ Run `corpus <module> --help` for module-specific flags.
38
+
39
+ ### `corpus api`
40
+
41
+ Generates types and model interfaces for all routes, and an API client with methods for all routes (unless disabled in config).
42
+
43
+ ```bash
44
+ corpus api
45
+ ```
46
+
47
+ > Your entry file must call `.listen()` either at the top level or inside a single function.
48
+
49
+ ### `corpus service <name>` (`svc`)
50
+
51
+ Scaffolds a standalone service with stubbed CRUD methods.
52
+
53
+ ```bash
54
+ corpus service <name>
55
+ corpus svc --name <name>
56
+ ```
57
+
58
+ | Flag | Description |
59
+ | -------------- | -------------------------------------------------- |
60
+ | `<name>`, `-n` | Name of the service to generate |
61
+ | `--empty` | Generate a bare service with no default CRUD shape |
62
+
63
+ > This only generates the service file. Without a matching model, the stubbed methods will be untyped.
64
+
65
+ ### `corpus controller <name>` (`ctrl`)
66
+
67
+ Scaffolds a standalone controller with stubbed CRUD routes.
68
+
69
+ ```bash
70
+ corpus controller <name>
71
+ corpus ctrl --name <name>
72
+ ```
73
+
74
+ | Flag | Description |
75
+ | -------------- | ---------------------------------- |
76
+ | `<name>`, `-n` | Name of the controller to generate |
77
+
78
+ > This only generates the controller file. Without a matching model and service, the stubbed routes will be untyped and just throw.
79
+
80
+ ### `corpus model <name>` (`mdl`)
81
+
82
+ Scaffolds a standalone model with a default CRUD-shaped interface or schema.
83
+
84
+ ```bash
85
+ corpus model <name>
86
+ corpus mdl --name <name>
87
+ ```
88
+
89
+ | Flag | Description |
90
+ | -------------- | ------------------------------------------------ |
91
+ | `<name>`, `-n` | Name of the model to generate |
92
+ | `--empty` | Generate a bare model with no default CRUD shape |
93
+
94
+ > This only generates the model file and does not touch any other files.
95
+
96
+ ### `corpus exception <name>` (`exc`)
97
+
98
+ Scaffolds a standalone exception class with a default `NotImplemented` exception.
99
+
100
+ ```bash
101
+ corpus exception <name>
102
+ corpus exc --name <name>
103
+ ```
104
+
105
+ | Flag | Description |
106
+ | -------------- | ---------------------------------------------------------- |
107
+ | `<name>`, `-n` | Name of the exception class to generate |
108
+ | `--empty` | Generate a bare exception class with no default exceptions |
109
+
110
+ > This only generates the exception file and does not touch any other files.
111
+
112
+ ### `corpus resource <name>` (`res`)
113
+
114
+ Scaffolds a new resource: model, service, controller, and exception together.
115
+
116
+ ```bash
117
+ corpus resource <name>
118
+ corpus res --name <name>
119
+ ```
120
+
121
+ | Flag | Description |
122
+ | -------------- | ------------------------------------------------ |
123
+ | `<name>`, `-n` | Name of the resource to generate |
124
+ | `--empty` | Generate a bare model with no default CRUD shape |
125
+
126
+ ## Configuration
127
+
128
+ Define config with `defineConfig`:
129
+
130
+ ```ts
131
+ import { defineConfig } from "@ozanarslan/corpus-cli";
132
+
133
+ export default defineConfig({
134
+ main: "./src/main.ts",
135
+ validationLibrary: "arktype",
136
+ casing: "pascal",
137
+ // ...
138
+ });
139
+ ```
140
+
141
+ ### Options
142
+
143
+ | Option | Type | Default | Description |
144
+ | ----------------------- | --------------------------------------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
145
+ | `silent` | `boolean` | `false` | Suppress console logs |
146
+ | `main` | `string` | `"./src/main.ts"` | The server entrypoint file path; must contain your instances and `.listen()` call |
147
+ | `pkgPath` | `string` | `"@ozanarslan/corpus"` | The corpus package path |
148
+ | `casing` | `"pascal" \| "camel" \| "kebab"` | `"pascal"` | Casing for generated file and directory names |
149
+ | `validationLibrary` | `"arktype" \| "zod" \| "yup" \| null` | `null` | Validation library to generate models with. Append a version with `@` if needed (default versions: arktype `2.2.0`, yup `1.7.1`, zod `4.3.6`) |
150
+ | `output` | `string` | `"./src/corpus.gen.ts"` | File path where the generated API client output is written |
151
+ | `apiClient` | `ApiClientConfig` | — | API client specific configuration (see below) |
152
+ | `exportModelsNamespace` | `boolean` | `true` | Collects all models into a namespace |
153
+ | `exportArgsNamespace` | `boolean` | `true` | Collects all args (models without the response) into a namespace |
154
+ | `ignoreGlobalPrefix` | `boolean` | `true` | Generated method/type names ignore the global prefix by default |
155
+ | `defaultMethods` | `DefaultMethodsConfig` | — | Default method names for scaffolded models, services, and controllers |
156
+ | `folderStructure` | `Partial<Record<ImportableKind, \`${string}.ts\`>>` | `"{resource}/{resource}-{kind}.ts"` | Custom output path templates per file kind (see below) |
157
+
158
+ #### `apiClient`
159
+
160
+ | Option | Type | Default | Description |
161
+ | ---------------- | --------- | ------------- | -------------------------------------------------------------------------- |
162
+ | `disabled` | `boolean` | `false` | Disables API client generation. Types and models are still generated |
163
+ | `exportAs` | `string` | `"CorpusApi"` | Controls how the API client is exported. Set to `false` to skip the client |
164
+ | `useStaticClass` | `boolean` | `false` | Makes all API client methods and properties static |
165
+
166
+ #### `defaultMethods`
167
+
168
+ Maps default CRUD method names to your own, for scaffolded models/services/controllers:
169
+
170
+ ```ts
171
+ {
172
+ get: { propertyKey: "get", address: "GET /:id" },
173
+ getByParams: { propertyKey: "getByParams", address: "GET /" },
174
+ create: { propertyKey: "create", address: "POST /" },
175
+ update: { propertyKey: "update", address: "PUT /:id" },
176
+ remove: { propertyKey: "remove", address: "DELETE /:id" },
177
+ }
178
+ ```
179
+
180
+ #### `folderStructure`
181
+
182
+ Custom output path templates per file kind, letting you control your own folder structure. Each template is a relative path string supporting:
183
+
184
+ - `{resource}` — the resource name (e.g. `"user"`), cased per the `casing` option
185
+ - `{kind}` — the file kind (e.g. `"service"`, `"model"`, `"controller"`, `"route"`), cased per the `casing` option
186
+
187
+ Kinds without a matching entry fall back to the default template `"{resource}/{resource}-{kind}.ts"`. The file extension is preserved as-is and not affected by casing.
188
+
189
+ ```ts
190
+ // group files by kind instead of by resource
191
+ {
192
+ model: "models/{resource}-model.ts",
193
+ service: "services/{resource}-service.ts",
194
+ controller: "controllers/{resource}-controller.ts",
195
+ }
196
+ ```
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ export {}