generate-ui-cli 1.0.0 → 2.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/README.md CHANGED
@@ -1,32 +1,248 @@
1
1
  # GenerateUI CLI
2
2
 
3
- Generate UI from OpenAPI locally. Free works offline with 1 generation per device; Dev unlocks unlimited generation, safe regeneration, and UI overrides.
3
+ Generate CRUD screens (List, Create/Edit, Delete), typed API services, and routes from your OpenAPI spec with real Angular code you can own and evolve.
4
4
 
5
- ## Install
5
+ Goal: stop rewriting repetitive CRUD and start with a functional, scalable UI foundation.
6
+
7
+ ## What GenerateUI Does
8
+
9
+ Given an `openapi.yaml` (or `.json`), GenerateUI can generate:
10
+
11
+ - `screens.json` (detected screens/endpoints)
12
+ - one folder per feature/screen
13
+ - typed API services and DTOs
14
+ - plug-and-play routes
15
+ - basic CRUD UI (list + form + delete confirmation)
16
+ - UI states (loading / empty / error)
17
+
18
+ GenerateUI is code generation, not runtime rendering.
19
+
20
+ ## Before You Start (Quick Checklist)
21
+
22
+ You will need:
23
+
24
+ - Node.js (LTS recommended)
25
+ - A valid OpenAPI v3.x file
26
+ - An Angular project (for Angular generation) > v.15
27
+ - Optional: a design system (Material, PrimeNG, internal DS)
28
+
29
+ Important:
30
+ - Incomplete OpenAPI specs (missing schemas, responses, or types) may limit what can be generated.
31
+ - Some public APIs require query params (e.g. `fields=...`). Make sure your API calls actually work.
32
+
33
+ ## Installation
34
+
35
+ ### Global install
6
36
  ```bash
7
37
  npm install -g generate-ui-cli
8
38
  ```
9
39
 
10
- ## Usage
40
+ ### Local install
11
41
  ```bash
12
- generate-ui generate --openapi /path/to/openapi.yaml
42
+ npm install -D generate-ui-cli
13
43
  ```
14
44
 
15
- Safe regeneration (Dev):
45
+ Then run:
16
46
  ```bash
17
- generate-ui regenerate --openapi /path/to/openapi.yaml
47
+ npx generate-ui --help
18
48
  ```
19
49
 
20
- Login (Dev):
50
+ ## Recommended Workflow
51
+
52
+ GenerateUI works in two main steps:
53
+
54
+ 1. Read the OpenAPI and generate `screens.json`
55
+ 2. Generate Angular code from `screens.json`
56
+
57
+ ## 1) Generate `screens.json`
58
+
59
+ ```bash
60
+ generate-ui generate --openapi openapiWeather.yaml
61
+ ```
62
+
63
+ What happens after this command:
64
+
65
+ - GenerateUI reads your OpenAPI and detects endpoints.
66
+ - It identifies CRUD-like operations (list, get by id, create, update, delete).
67
+ - It maps request/response schemas.
68
+ - A `screens.json` file is created in the output folder.
69
+ - Two JSON folders are created: `generated/` (auto-created files) and `override/` (your manual edits that should be preserved on regeneration).
70
+
71
+ What you should review now:
72
+
73
+ - Are all expected screens present?
74
+ - Are screen and route names correct?
75
+ - Are required query params represented?
76
+ - Do the detected fields match your API schemas?
77
+
78
+ Tip: this is the best moment to adjust naming and structure before generating code.
79
+
80
+ ## 2) Generate Angular code from `screens.json`
81
+
82
+ ```bash
83
+ generate-ui angular \
84
+ --schemas /Users/nicoleprevid/Downloads/generateui-playground/frontend/src/app/assets/generate-ui \
85
+ --features /Users/nicoleprevid/Downloads/generateui-playground/frontend/src/app/features
86
+ ```
87
+
88
+ What happens after this command:
89
+
90
+ - For each screen defined in `screens.json`, GenerateUI creates:
91
+ - a feature folder
92
+ - list and form components (create/edit)
93
+ - a typed API service
94
+ - DTO/types files
95
+ - route definitions
96
+
97
+ What you should review now:
98
+
99
+ - Are files generated in the correct location?
100
+ - Does the project compile?
101
+ - Are routes correctly generated and importable?
102
+ - Does the basic UI work end-to-end?
103
+
104
+ Note:
105
+ If your project uses custom routing, standalone components, or advanced layouts, you may need to adjust how routes are plugged in.
106
+
107
+ ## Login (Dev plan)
108
+
21
109
  ```bash
22
110
  generate-ui login
23
111
  ```
24
112
 
25
- Telemetry can be disabled with:
113
+ What happens after this command:
114
+
115
+ - You authenticate your device to unlock Dev features.
116
+ - Dev features include safe regeneration, UI overrides, and unlimited generations.
117
+
118
+ ## Plugging Routes into Your App
119
+
120
+ GenerateUI usually creates route files such as:
121
+
122
+ - `generated.routes.ts`
123
+ - or per feature: `users.routes.ts`, `orders.routes.ts`
124
+
125
+ Example (Angular Router):
126
+
127
+ ```ts
128
+ import { GENERATED_ROUTES } from './app/generated/generated.routes';
129
+
130
+ export const routes = [
131
+ // ...your existing routes
132
+ ...GENERATED_ROUTES
133
+ ];
134
+ ```
135
+
136
+ Things to pay attention to:
137
+
138
+ - route prefixes (`/admin`, `/app`, etc.)
139
+ - authentication guards
140
+ - layout components (`<router-outlet>` placement)
141
+
142
+ ## Example Generated Structure
143
+
144
+ ```txt
145
+ src/app/generated/
146
+ users/
147
+ users-list.component.ts
148
+ users-form.component.ts
149
+ users.routes.ts
150
+ users.service.ts
151
+ users.types.ts
152
+ orders/
153
+ orders-list.component.ts
154
+ orders-form.component.ts
155
+ orders.routes.ts
156
+ orders.service.ts
157
+ orders.types.ts
158
+ generated.routes.ts
159
+ ```
160
+
161
+ ## After Generation: How to Customize Safely
162
+
163
+ GenerateUI gives you a working baseline. From here, you typically:
164
+
165
+ - Customize UI (design system components, masks, validators)
166
+ - Add business logic (conditional fields, permissions)
167
+ - Improve UX (pagination, filtering, empty/error states)
168
+
169
+ Rule of thumb: the generated code is yours — generate once, then evolve freely.
170
+
171
+ ## Overrides and Regeneration Behavior
172
+
173
+ You can edit files inside `override/` to customize labels, placeholders, hints, and other details. When your API changes and you regenerate, GenerateUI updates what is safe to change from the OpenAPI, but preserves what you defined in `override/` to avoid breaking your flow.
174
+
175
+ Even after the Angular TypeScript files are generated, changes you make in `override/` will be mirrored the next time you regenerate.
176
+
177
+ ## Common Issues and Fixes
178
+
179
+ ### "required option '-o, --openapi <path>' not specified"
180
+
181
+ You ran the command without passing the OpenAPI file.
182
+
183
+ Fix:
26
184
  ```bash
27
- generate-ui --no-telemetry generate --openapi /path/to/openapi.yaml
185
+ generate-ui generate --openapi /path/to/openapi.yaml
28
186
  ```
29
187
 
30
- ## Local files
188
+ ### "An endpoint exists but no screen was generated"
189
+
190
+ This may happen if:
191
+
192
+ - `operationId` is missing
193
+ - request/response schemas are empty
194
+ - required response codes (`200`, `201`) are missing
195
+
196
+ Recommendation:
197
+
198
+ - always define `operationId`
199
+ - include schemas in responses
200
+
201
+ ### "Routes were generated but navigation does not work"
202
+
203
+ Usually a routing integration issue.
204
+
205
+ Check:
206
+
207
+ - if `GENERATED_ROUTES` is imported/spread
208
+ - if route prefixes match your menu
209
+ - if there is a `<router-outlet>` in your layout
210
+
211
+ ## Team Workflow Recommendation
212
+
213
+ 1. Update OpenAPI
214
+ 2. Generate `screens.json`
215
+ 3. Review `screens.json`
216
+ 4. Generate Angular code
217
+ 5. Customize UI and business rules
218
+ 6. Commit
219
+
220
+ ## Tips for Better Results
221
+
222
+ - Use consistent `operationId`s (`users_list`, `users_create`, etc.)
223
+ - Define complete schemas (types, required, enums)
224
+ - Standardize responses (`200`, `201`, `204`)
225
+ - Document important query params (pagination, filters)
226
+ - If your API requires `fields=...`, reflect it in `screens.json`
227
+
228
+ ## Roadmap (Example)
229
+
230
+ - [ ] Layout presets (minimal / enterprise / dashboard)
231
+ - [ ] Design system adapters (Material / PrimeNG / custom)
232
+ - [ ] Filters and real pagination
233
+ - [ ] UI schema overrides (visual control without touching OpenAPI)
234
+ - [ ] React support
235
+
236
+ ## Contributing
237
+
238
+ Issues and PRs are welcome.
239
+ If you use GenerateUI in a company or real project, let us know — it helps guide the roadmap.
240
+
241
+ ## License
242
+
243
+ MIT
244
+
245
+ ## Local Files
246
+
31
247
  - `~/.generateui/device.json`
32
248
  - `~/.generateui/token.json`
@@ -11,7 +11,6 @@ const screen_generator_1 = require("../generators/screen.generator");
11
11
  const screen_merge_1 = require("../generators/screen.merge");
12
12
  const permissions_1 = require("../license/permissions");
13
13
  const device_1 = require("../license/device");
14
- const guard_1 = require("../license/guard");
15
14
  const telemetry_1 = require("../telemetry");
16
15
  async function generate(options) {
17
16
  /**
@@ -38,10 +37,7 @@ async function generate(options) {
38
37
  const usedOperationIds = new Set();
39
38
  const permissions = await (0, permissions_1.getPermissions)();
40
39
  const device = (0, device_1.loadDeviceIdentity)();
41
- await (0, telemetry_1.sendTelemetry)(options.telemetryCommand, options.telemetryEnabled);
42
- if (options.requireSafeRegeneration) {
43
- (0, guard_1.requireFeature)(permissions.features, 'safeRegeneration', 'Regeneration requires safe regeneration.');
44
- }
40
+ await (0, telemetry_1.sendTelemetry)('generate', options.telemetryEnabled);
45
41
  if (permissions.features.maxGenerations > -1 &&
46
42
  device.freeGenerationsUsed >= permissions.features.maxGenerations) {
47
43
  throw new Error('🔒 Você já utilizou sua geração gratuita.\n' +
package/dist/index.js CHANGED
@@ -26,8 +26,7 @@ program
26
26
  await (0, generate_1.generate)({
27
27
  openapi: options.openapi,
28
28
  debug: options.debug,
29
- telemetryEnabled: telemetry,
30
- telemetryCommand: 'generate'
29
+ telemetryEnabled: telemetry
31
30
  });
32
31
  }
33
32
  catch (error) {
@@ -70,29 +69,6 @@ program
70
69
  handleCliError(error);
71
70
  }
72
71
  });
73
- /**
74
- * 4️⃣ Regenerate with safe merge
75
- */
76
- program
77
- .command('regenerate')
78
- .description('Regenerate screen schemas with safe merge')
79
- .requiredOption('-o, --openapi <path>', 'OpenAPI file')
80
- .option('-d, --debug', 'Explain merge decisions')
81
- .action(async (options) => {
82
- const { telemetry } = program.opts();
83
- try {
84
- await (0, generate_1.generate)({
85
- openapi: options.openapi,
86
- debug: options.debug,
87
- telemetryEnabled: telemetry,
88
- telemetryCommand: 'regenerate',
89
- requireSafeRegeneration: true
90
- });
91
- }
92
- catch (error) {
93
- handleCliError(error);
94
- }
95
- });
96
72
  function handleCliError(error) {
97
73
  if (error instanceof Error) {
98
74
  console.error(error.message.replace(/\\n/g, '\n'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generate-ui-cli",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "Generate UI from OpenAPI locally with optional Dev unlocks.",
5
5
  "license": "MIT",
6
6
  "repository": {