@barcidev/ngx-autogen 0.1.71 β†’ 0.1.73

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,352 +1,385 @@
1
- # ngx-autogen
1
+ <p align="center">
2
+ <img src="./logo.png" alt="ngx-autogen logo" width="120">
3
+ </p>
2
4
 
3
- [![Language: English](https://img.shields.io/badge/lang-en-blue.svg)](README.md)
4
- [![Language: Spanish](https://img.shields.io/badge/lang-es-yellow.svg)](README.es.md)
5
+ <p align="center">
6
+ <a href="README.md">πŸ‡ΊπŸ‡Έ English</a> | <a href="README_ES.md">πŸ‡ͺπŸ‡Έ EspaΓ±ol</a>
7
+ </p>
5
8
 
6
- **ngx-autogen** is a set of schematics designed to optimize and standardize the workflow in Angular projects. This library provides code generation tools that follow best practices, allowing developers to save time on repetitive tasks and architecture configuration.
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/@barcidev/ngx-autogen"><img src="https://img.shields.io/npm/v/@barcidev/ngx-autogen?style=for-the-badge&color=007acc&labelColor=010101" alt="npm version"></a>
11
+ <a href="https://github.com/jpalacio09/ngx-autogen/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@barcidev/ngx-autogen?style=for-the-badge&color=green&labelColor=010101" alt="license"></a>
12
+ <img src="https://img.shields.io/badge/Angular-17%2B-DD0031?style=for-the-badge&logo=angular&labelColor=010101" alt="Angular 17+">
13
+ <img src="https://img.shields.io/badge/NgRx%20Signals-17%2B-BA2BD2?style=for-the-badge&logo=ngrx&labelColor=010101" alt="NgRx Signals 17+">
14
+ </p>
7
15
 
8
- ## πŸš€ Features
16
+ <p align="center">
17
+ <b>⚑ Angular schematics that scaffold complete NgRx Signal Store entities, Transloco i18n scopes, and standalone components in seconds. ⚑</b>
18
+ </p>
9
19
 
10
- The project is initially launched with a focus on state management, but is designed to grow:
20
+ ---
11
21
 
12
- - **Store Schematic**: Our first available schematic. It allows you to automatically generate the entire structure needed for a store based on signals (NGRX-Signals), facilitating the quick and scalable integration of state management in your applications.
22
+ ## πŸ“– Table of Contents
13
23
 
14
- ## πŸ“… Coming Soon
24
+ - [Overview](#overview)
25
+ - [Requirements](#requirements)
26
+ - [Installation](#installation)
27
+ - [Via ng add (recommended)](#via-ng-add-recommended)
28
+ - [Via npm](#via-npm)
29
+ - [Runtime Exports](#runtime-exports)
30
+ - [Schematics Reference](#schematics-reference)
31
+ - [ng-add](#ng-add)
32
+ - [app-store](#app-store)
33
+ - [app-i18n](#app-i18n)
34
+ - [app-component](#app-component)
35
+ - [License](#license)
15
36
 
16
- **ngx-autogen** is a project in continuous evolution. New tools and schematics will be progressively added to cover more aspects of Angular development, such as:
37
+ ---
17
38
 
18
- - Generation of services and utilities.
19
- - Scaffolding for advanced components.
39
+ ## 🌟 Overview
20
40
 
21
- ## πŸ“¦ Installation
41
+ `@barcidev/ngx-autogen` is a collection of Angular schematics designed to eliminate repetitive scaffolding when building enterprise Angular applications. It generates production-ready code for three core concerns:
22
42
 
23
- You can install the package in your Angular project using Angular CLI so that the project is automatically configured with the necessary dependencies:
43
+ - **NgRx Signal Store** (`app-store`) - Full CRUD signal store with entity management, pagination state, status tracking, and an accompanying service and model layer. Built on `@ngrx/signals` and `@ngrx/signals/entities`.
44
+ - **Transloco i18n** (`app-i18n`) - Scoped translation files with typed Transloco integration via `@barcidev/typed-transloco`, automatic provider registration, and global type map updates.
45
+ - **Angular Component** (`app-component`) - Standalone component generation via `@schematics/angular` with optional automatic store and i18n wiring.
46
+
47
+ The library also ships runtime utilities under `@barcidev/ngx-autogen/entity` that provide reusable NgRx Signal Store features: `withEntityStatus`, `withPagination`, and typed model helpers.
48
+
49
+ ---
50
+
51
+ ## πŸ“‹ Requirements
52
+
53
+ | Dependency | Minimum Version |
54
+ |---|---|
55
+ | `@angular/core` | `>=17.0.0` |
56
+ | `@angular/common` | `>=17.0.0` |
57
+ | `@angular/forms` | `>=17.0.0` |
58
+ | `@ngrx/signals` | `>=17.0.0` |
59
+ | Node.js | `>=16.0.0` |
60
+
61
+ ---
62
+
63
+ ## πŸš€ Installation
64
+
65
+ ### Via ng add (recommended)
24
66
 
25
67
  ```bash
26
- ng add ngx-autogen
68
+ ng add @barcidev/ngx-autogen
27
69
  ```
28
70
 
29
- ## πŸ› οΈ Usage
71
+ This command performs the following actions automatically:
30
72
 
31
- ### Generate a Store
73
+ 1. **Moves the library to `devDependencies`** - If installed as a production dependency, it is relocated to `devDependencies` in `package.json`.
74
+ 2. **Registers the schematic collection** - Adds `@barcidev/ngx-autogen` to `cli.schematicCollections` in `angular.json`, enabling short-form aliases like `ng g app-store`.
75
+ 3. **Stores global configuration** - Saves the selected default language (`lang`) under `schematics["@barcidev/ngx-autogen:all"]` in `angular.json` so all schematics inherit it.
32
76
 
33
- #### Properties
77
+ **Prompt:**
34
78
 
35
- - `name` (required): name of the store.
36
- - `pk` (optional): name of the primary key. If not specified, the one specified during the schematic installation process will be used; otherwise, `id` will be used.
37
- - `path` (optional): path of the store. If not specified, the one specified during the schematic installation process will be used; otherwise, `src/app/core` will be used. The folder `state` will be automatically appended to the path.
38
- - `grouped` (optional): if true, the files will be grouped into subfolders `models`, `services`, and `store`.
79
+ | Prompt | Default |
80
+ |---|---|
81
+ | What is the default language for the application (en, es)? | `en` |
39
82
 
40
- #### Example
83
+ ### Via npm
41
84
 
42
85
  ```bash
43
- ng g app-store --name="user" --pk="cod"
86
+ npm install @barcidev/ngx-autogen --save-dev
44
87
  ```
45
88
 
46
- This will create the files `user.model.ts`, `user.service.ts`, `user.store.ts` within the `src/app/core/state/user` folder, and the files `entity.model.ts`, `with-entity-pagination.ts`, and `with-entity-status.ts` if they don't exist within the `src/app/shared/state` folder.
89
+ > [!NOTE]
90
+ > When installing via npm, you must manually register the collection in `angular.json` and use the fully qualified schematic name (e.g., `ng generate @barcidev/ngx-autogen:app-store`).
47
91
 
48
- ```bash
49
- src/
50
- └── app/
51
- └── shared/
52
- └── state/
53
- β”œβ”€β”€ entity.model.ts
54
- β”œβ”€β”€ with-entity-pagination.ts
55
- └── with-entity-status.ts
56
- └── state/
57
- └── index.ts
58
- └── user/
59
- β”œβ”€β”€ user.service.ts
60
- β”œβ”€β”€ user.model.ts
61
- └── user.store.ts
62
- ```
63
-
64
- The `index.ts` file will export everything necessary so that the store can be imported and used anywhere in the application.
92
+ ---
93
+
94
+ ## πŸ› οΈ Runtime Exports
95
+
96
+ The library exports reusable NgRx Signal Store features under the `@barcidev/ngx-autogen/entity` entry point:
97
+
98
+ | Export | Description |
99
+ |---|---|
100
+ | `withEntityStatus()` | Signal Store feature that adds loading, error, and selection state tracking for entities. |
101
+ | `withPagination()` | Signal Store feature that adds pagination state (page, size, total). |
102
+ | `RequestConfig<TPayload, TResponse>` | Generic type for store method configurations with `payload`, `onSuccess`, and `onError` callbacks. |
103
+ | `FormGroupType<T>` | Utility type that maps an interface to its Angular `FormGroup` control types. |
65
104
 
66
105
  ```typescript
67
- /* USER */
68
- export * from './user/user.model';
69
- export * from './user/user.service';
70
- export * from './user/user.store';
106
+ import { withEntityStatus, withPagination, RequestConfig, FormGroupType } from '@barcidev/ngx-autogen/entity';
71
107
  ```
72
108
 
73
- The `src/app/shared/state` folder contains the shared files for state management.
109
+ ---
74
110
 
75
- `entity.model.ts`:
111
+ ## πŸ“– Schematics Reference
76
112
 
77
- ```typescript
78
- import { HttpErrorResponse } from '@angular/common/http';
79
- import { FormControl } from '@angular/forms';
113
+ ### `ng-add`
80
114
 
81
- export type FormGroupType<T> = {
82
- [K in keyof T]: FormControl<T[K]>;
83
- };
115
+ **Description**: Ng add schematic for ngx-autogen. Configures the workspace for using all library schematics.
84
116
 
85
- export interface RequestConfig<T, U = unknown> {
86
- onError?: (error?: HttpErrorResponse) => void;
87
- onSuccess?: (response?: U) => void;
88
- payload: T;
89
- }
117
+ **Usage**
118
+ ```bash
119
+ ng add @barcidev/ngx-autogen
90
120
  ```
91
121
 
92
- The `user.model.ts` file contains the data model interface.
122
+ **Options**
93
123
 
94
- ```typescript
95
- import { FormGroupType } from 'src/app/shared/state/entity.model';
124
+ | Option | Type | Default | Required | Description |
125
+ |---|---|---|---|---|
126
+ | `lang` | `string` | `en` | No | The default language for the application (`en`, `es`). |
127
+
128
+ ---
96
129
 
97
- export interface AddUser {
98
- }
130
+ ### `app-store`
99
131
 
100
- export type AddUserForm = FormGroupType<AddUser>;
132
+ > Alias: `ng g app-store` (when collection is registered via `ng add`)
101
133
 
102
- export interface UserDto {
103
- cod: number;
104
- }
134
+ **Description**: Adds NgRx Store to the Angular application with signal support. Generates a complete CRUD signal store, service, and model layer for a given entity.
105
135
 
106
- export type UpdateUser = Partial<UserDto> & Pick<UserDto, 'cod'>;
136
+ **Usage**
137
+ ```bash
138
+ # Short form (requires ng add):
139
+ ng g app-store --name product
107
140
 
108
- export interface UserRequest{}
141
+ # Full form:
142
+ ng generate @barcidev/ngx-autogen:app-store --name product
109
143
  ```
110
144
 
111
- The `user.service.ts` file contains the service responsible for business logic.
145
+ **Options**
112
146
 
113
- ```typescript
114
- import { Injectable } from '@angular/core';
115
- import { Observable, of } from 'rxjs';
116
- import {
117
- AddUser,
118
- UserDto,
119
- UpdateUser
120
- } from './user.model';
147
+ | Option | Type | Default | Required | Description |
148
+ |---|---|---|---|---|
149
+ | `name` | `string` | - | **Yes** | Name of the entity. Used to derive all class names, file names, and store methods. |
150
+ | `path` | `string` | *(cwd)* | No | Destination path. Defaults to the current working directory relative to `src/`. |
151
+ | `grouped` | `boolean` | `false` | No | Whether the files should be grouped in `models/` and `services/` subfolders. |
152
+ | `pk` | `string` | `id` | No | The name of the default Primary Key (e.g., `id`, `cod`, `uuid`). |
153
+ | `lang` | `string` | *(global)* | No | The default language for the application (`en`, `es`). Inherited from `ng add` config. |
154
+ | `isProvideInRoot` | `boolean` | `false` | No | Whether the store and service should use `providedIn: 'root'`. |
155
+
156
+ **What it generates**
157
+
158
+ For a given entity name, this schematic creates:
159
+
160
+ - `<name>.store.ts` - NgRx Signal Store with full CRUD methods (`add`, `load`, `update`, `remove`, `select`), entity config, computed selectors, and `onInit` hook.
161
+ - `<name>.service.ts` - Injectable service with stub methods for `add$`, `get$` (pluralized), `update$`, and `remove$`.
162
+ - `<name>.model.ts` - TypeScript interfaces: `Add<Name>`, `<Name>Dto`, `Update<Name>`, `Add<Name>Form`, and `<Name>Request`.
163
+ - `state/index.ts` - Barrel file with re-exports (created or updated).
164
+
165
+ It also:
166
+ - Installs `@ngrx/signals` if not already present (matching Angular major version).
167
+ - Configures `@shared-state/*` path alias in `tsconfig.app.json`.
168
+ - Saves `pk` and `lang` defaults in `angular.json`.
169
+
170
+ **Examples**
171
+
172
+ **Minimal - Entity with defaults:**
173
+ ```bash
174
+ ng g app-store --name product
175
+ ```
176
+ ```
177
+ src/app/state/
178
+ index.ts
179
+ product/
180
+ product.model.ts
181
+ product.service.ts
182
+ product.store.ts
183
+ ```
184
+
185
+ **Grouped layout with custom PK:**
186
+ ```bash
187
+ ng g app-store --name invoice --grouped --pk cod
188
+ ```
189
+ ```
190
+ src/app/state/
191
+ index.ts
192
+ invoice/
193
+ models/
194
+ invoice.model.ts
195
+ services/
196
+ invoice.service.ts
197
+ invoice.store.ts
198
+ ```
199
+
200
+ **Provided in root with Spanish pluralization:**
201
+ ```bash
202
+ ng g app-store --name usuario --isProvideInRoot --lang es
203
+ ```
204
+ ```
205
+ src/app/state/
206
+ index.ts
207
+ usuario/
208
+ usuario.model.ts # interfaces with pk: id
209
+ usuario.service.ts # @Injectable({ providedIn: 'root' })
210
+ usuario.store.ts # signalStore({ providedIn: 'root' }, ...) - methods use "Usuarios" (Spanish plural)
211
+ ```
212
+
213
+ ---
121
214
 
122
- @Injectable({
123
- providedIn: 'root'
124
- })
125
- export class UserService {
215
+ ### `app-i18n`
126
216
 
127
- addUser$(entity: AddUser): Observable<number> {
128
- return of(0);
129
- }
217
+ > Alias: `ng g app-i18n` (when collection is registered via `ng add`)
130
218
 
131
- removeUser$(cod: number): Observable<boolean> {
132
- return of(true);
133
- }
219
+ **Description**: Adds Transloco to the Angular application. Generates a scoped i18n translation file and wires it into the target component.
134
220
 
135
- getUsers$(): Observable<UserDto[]> {
136
- return of([]);
137
- }
221
+ **Usage**
222
+ ```bash
223
+ # Short form:
224
+ ng g app-i18n --name dashboard
138
225
 
139
- updateUser$(entity: UpdateUser): Observable<boolean> {
140
- return of(true);
141
- }
142
- }
226
+ # Full form:
227
+ ng generate @barcidev/ngx-autogen:app-i18n --name dashboard
143
228
  ```
144
229
 
145
- The `user.store.ts` file contains the store responsible for state management.
230
+ **Options**
146
231
 
147
- ```typescript
148
- import { computed, inject } from '@angular/core';
149
- import { patchState, signalStore, type, withComputed, withHooks, withMethods, withState } from '@ngrx/signals';
150
- import {
151
- addEntity,
152
- entityConfig,
153
- removeEntity,
154
- setAllEntities,
155
- updateEntity,
156
- withEntities
157
- } from '@ngrx/signals/entities';
158
- import { rxMethod } from '@ngrx/signals/rxjs-interop';
159
- import { catchError, of, pipe, switchMap, tap } from 'rxjs';
160
-
161
- import { RequestConfig } from 'src/app/shared/state/entity.model';
162
- import { withPagination } from 'src/app/shared/state/with-entity-pagination';
163
- import { withEntityStatus } from 'src/app/shared/state/with-entity-status';
164
- import {
165
- AddUser,
166
- UserDto,
167
- UpdateUser
168
- } from './user.model';
169
- import { UserService } from './user.service';
170
-
171
- const config = entityConfig({
172
- entity: type<UserDto>(),
173
- selectId: (entity) => entity.cod,
174
- });
175
-
176
- export const UserStore = signalStore(
177
- withEntities(config),
178
- withEntityStatus(),
179
- withPagination(),
180
- withComputed(({ entities, entityMap, status: { idSelected } }) => ({
181
- users: computed(() => entities()),
182
- userSeleccionado: computed(() => {
183
- const cod = idSelected();
184
- return cod ? entityMap()[cod] : null;
185
- })
186
- })),
187
- withMethods((store, userService = inject(UserService)) => ({
188
- addUser: rxMethod<RequestConfig<AddUser, UserDto>>(
189
- pipe(
190
- tap(() => {
191
- patchState(store, (state) => ({ status: { ...state.status, addLoading: true } }));
192
- }),
193
- switchMap(({ onError, onSuccess, payload: { request } }) => {
194
- return userService.addUser$(request).pipe(
195
- tap((cod) => {
196
- const newUser: UserDto = { ...request, cod};
197
- patchState(store, addEntity(newUser, config), (state) => ({
198
- ...state,
199
- status: { ...state.status, addError: null, addLoading: false }
200
- }));
201
- if (onSuccess) {
202
- onSuccess(newUser);
203
- }
204
- }),
205
- catchError(() => {
206
- const error = new Error('');
207
- patchState(store, (state) => ({
208
- status: { ...state.status, addError: error, addLoading: false }
209
- }));
210
- if (onError) {
211
- onError();
212
- }
213
- return EMPTY;
214
- })
215
- );
216
- })
217
- )
218
- ),
219
- loadUsers: rxMethod<void>(
220
- pipe(
221
- tap(() => {
222
- patchState(store, (state) => ({ status: { ...state.status, loading: true } }));
223
- }),
224
- switchMap(() => {
225
- return userService.getUsers$().pipe(
226
- tap((response) => {
227
- patchState(store, setAllEntities(response, config), (state) => ({
228
- status: { ...state.status, error: null, loaded: true, loading: false }
229
- }));
230
- }),
231
- catchError(() => {
232
- patchState(store, (state) => ({
233
- status: { ...state.status, error: new Error('Error al cargar users'), loading: false }
234
- }));
235
- return EMPTY;
236
- })
237
- );
238
- })
239
- )
240
- ),
241
- removeUser: rxMethod<RequestConfig<number, boolean>>(
242
- pipe(
243
- tap(({ payload }) => {
244
- patchState(store, (state) => ({
245
- status: {
246
- ...state.status,
247
- _removeLoading: true,
248
- idsRemoving: [...(state.status.idsRemoving || []), payload]
249
- }
250
- }));
251
- }),
252
- switchMap(({ onError, onSuccess, payload }) => {
253
- return userService.removeUser$(payload).pipe(
254
- tap((response) => {
255
- if (response) {
256
- const idsRemoving = store.status.idsRemoving() || [];
257
- patchState(store, removeEntity(payload), (state) => ({
258
- status: {
259
- ...state.status,
260
- _removeLoading: false,
261
- error: null,
262
- idsRemoving: idsRemoving.filter((idRemoving) => idRemoving !== payload)
263
- }
264
- }));
265
- if (onSuccess) {
266
- onSuccess(response);
267
- }
268
- } else {
269
- throw new Error();
270
- }
271
- }),
272
- catchError(() => {
273
- const idsRemoving = store.status.idsRemoving() || [];
274
- patchState(store, (state) => ({
275
- status: {
276
- ...state.status,
277
- _removeLoading: false,
278
- error: new Error(),
279
- idsRemoving: idsRemoving.filter((idRemoving) => idRemoving !== payload)
280
- }
281
- }));
282
- if (onError) {
283
- onError();
284
- }
285
- return EMPTY;
286
- })
287
- );
288
- })
289
- )
290
- ),
291
- updateUser: rxMethod<RequestConfig<UpdateUser, boolean>>(
292
- pipe(
293
- tap(({ payload }) => {
294
- patchState(store, (state) => ({
295
- status: {
296
- ...state.status,
297
- _updateLoading: true,
298
- idsUpdating: [...(state.status.idsUpdating || []), payload.cod]
299
- }
300
- }));
301
- }),
302
- switchMap(({ onError, onSuccess, payload }) => {
303
- return userService.updateUser$(entity).pipe(
304
- tap((response) => {
305
- if (response) {
306
- const idsUpdating = store.status.idsUpdating() || [];
307
- patchState(store, updateEntity({ changes: payload, id: payload.cod }, config), (state) => ({
308
- status: {
309
- ...state.status,
310
- _updateLoading: false,
311
- error: null,
312
- idsUpdating: idsUpdating.filter((idUpdating) => idUpdating !== payload.cod)
313
- }
314
- }));
315
- if (onSuccess) {
316
- onSuccess(response);
317
- }
318
- } else {
319
- throw new Error('');
320
- }
321
- }),
322
- catchError(() => {
323
- const idsUpdating = store.status.idsUpdating() || [];
324
- patchState(store, (state) => ({
325
- status: {
326
- ...state.status,
327
- _updateLoading: false,
328
- error: new Error('Error al actualizar user'),
329
- idsUpdating: idsUpdating.filter((idUpdating) => idUpdating !== payload.cod)
330
- }
331
- }));
332
- if (onError) {
333
- onError();
334
- }
335
- return EMPTY;
336
- })
337
- );
338
- })
339
- )
340
- ),
341
- })),
342
- withHooks({
343
- onInit: (store) => {
344
- store.loadUsers();
345
- },
346
- })
347
- );
348
- ```
349
-
350
- ## πŸ“„ License
351
-
352
- This project is under the [MIT](LICENSE) license.
232
+ | Option | Type | Default | Required | Description |
233
+ |---|---|---|---|---|
234
+ | `name` | `string` | *(auto-detected)* | No | Name of the component. Auto-detected from the `.component.ts` file in the current directory if not provided. |
235
+ | `path` | `string` | *(cwd)* | No | Destination path. Defaults to the current working directory relative to `src/`. |
236
+ | `lang` | `string` | *(global)* | No | Language for pluralization (`en` for English, `es` for Spanish). |
237
+
238
+ **What it generates**
239
+
240
+ - `<name>.i18n.ts` - Translation scope file with `en-US` and `es-CO` objects registered via `TranslocoUtils.createScopeConfig`.
241
+
242
+ It also:
243
+ - Runs `@barcidev/typed-transloco:ng-add` if Transloco is not yet configured in the project.
244
+ - Adds `provideTranslocoScopeWrapper` to the component's `providers` array.
245
+ - Adds `AppTypedTranslocoDirective` to the component's `imports` array.
246
+ - Updates the global `app.i18n.ts` type map with the new scope.
247
+
248
+ **Examples**
249
+
250
+ **Auto-detect component in current directory:**
251
+ ```bash
252
+ cd src/app/features/dashboard
253
+ ng g app-i18n
254
+ ```
255
+ ```
256
+ src/app/features/dashboard/
257
+ dashboard.i18n.ts # new
258
+ dashboard.component.ts # updated with providers + imports
259
+ ```
260
+
261
+ **Explicit name and path:**
262
+ ```bash
263
+ ng g app-i18n --name settings --path src/app/features/settings
264
+ ```
265
+ ```
266
+ src/app/features/settings/
267
+ settings.i18n.ts
268
+ ```
269
+
270
+ **With Spanish pluralization:**
271
+ ```bash
272
+ ng g app-i18n --name usuario --lang es
273
+ ```
274
+ ```
275
+ src/app/features/usuario/
276
+ usuario.i18n.ts # scope key: "usuario", pluralization uses Spanish rules
277
+ ```
278
+
279
+ ---
280
+
281
+ ### `app-component`
282
+
283
+ > Alias: `ng g app-component` (when collection is registered via `ng add`)
284
+
285
+ **Description**: Generates an Angular component with optional i18n and NgRx support. Delegates to `@schematics/angular:component` for base generation, then optionally chains `app-store` and `app-i18n` schematics.
286
+
287
+ **Usage**
288
+ ```bash
289
+ # Short form:
290
+ ng g app-component --name product-list
291
+
292
+ # Full form:
293
+ ng generate @barcidev/ngx-autogen:app-component --name product-list
294
+ ```
295
+
296
+ **Options**
297
+
298
+ | Option | Type | Default | Required | Description |
299
+ |---|---|---|---|---|
300
+ | `name` | `string` | - | **Yes** | Name of the component. |
301
+ | `store` | `string` | - | No | Whether to create a store for the component. Enum: `Yes`, `No`. |
302
+ | `i18n` | `string` | - | No | Whether to create an i18n file for the component. Enum: `Yes`, `No`. |
303
+ | `pk` | `string` | `id` | No | The name of the default Primary Key. Only used when `store` is `Yes`. |
304
+ | `isProvideInRoot` | `boolean` | `false` | No | Whether the store and service should be provided in root. Only used when `store` is `Yes`. |
305
+ | `path` | `string` | *(cwd)* | No | Destination path. |
306
+ | `lang` | `string` | *(global)* | No | Language for pluralization (`en`, `es`). |
307
+ | `style` | `string` | `css` | No | The file extension or preprocessor to use for style files. |
308
+ | `skipTests` | `boolean` | `false` | No | Do not create `spec.ts` test files. |
309
+ | `inlineStyle` | `boolean` | `false` | No | Include styles inline in the component `.ts` file. |
310
+ | `inlineTemplate` | `boolean` | `false` | No | Include template inline in the component `.ts` file. |
311
+
312
+ **Interactive prompts** (when `store` is `Yes`):
313
+
314
+ | Prompt | Default |
315
+ |---|---|
316
+ | What is the name of the entity store to create? | *(component name)* |
317
+ | What is the name of the default Primary Key? | `id` |
318
+ | Should the store and service be provided in root? | `No` |
319
+
320
+ **What it generates**
321
+
322
+ The base component is generated by the official `@schematics/angular:component` schematic with `standalone: true`. Depending on options:
323
+
324
+ - **With `store: Yes`**: Chains `app-store` schematic inside the component directory, injects the store into the component class, adds `JsonPipe` to imports, wires `data$` computed property, and configures `providers` with `provide<Name>Store()` (unless `isProvideInRoot` is true). Also updates the `.spec.ts` with store mock providers.
325
+ - **With `i18n: Yes`**: Chains `app-i18n` schematic inside the component directory.
326
+
327
+ **Examples**
328
+
329
+ **Minimal - Component only:**
330
+ ```bash
331
+ ng g app-component --name dashboard --store No --i18n No
332
+ ```
333
+ ```
334
+ src/app/dashboard/
335
+ dashboard.component.ts
336
+ dashboard.component.html
337
+ dashboard.component.css
338
+ dashboard.component.spec.ts
339
+ ```
340
+
341
+ **Component with store and i18n:**
342
+ ```bash
343
+ ng g app-component --name product-list --store Yes --i18n Yes --style scss
344
+ ```
345
+ ```
346
+ src/app/product-list/
347
+ product-list.component.ts # injects ProductListStore, data$, JsonPipe, providers
348
+ product-list.component.html # <div *typedTransloco="let t; prefix:'productList'">
349
+ product-list.component.scss
350
+ product-list.component.spec.ts # TestBed configured with store mock
351
+ product-list.i18n.ts
352
+ state/
353
+ index.ts
354
+ product-list/
355
+ product-list.model.ts
356
+ product-list.service.ts
357
+ product-list.store.ts
358
+ ```
359
+
360
+ **Component with custom entity store name and root provider:**
361
+ ```bash
362
+ ng g app-component --name user-profile --store Yes --i18n No --pk uuid --isProvideInRoot
363
+ ```
364
+
365
+ When prompted for the entity store name, enter `user` instead of the default `user-profile`:
366
+
367
+ ```
368
+ src/app/user-profile/
369
+ user-profile.component.ts # injects UserStore (not UserProfileStore)
370
+ user-profile.component.html
371
+ user-profile.component.css
372
+ user-profile.component.spec.ts
373
+ state/
374
+ index.ts
375
+ user/
376
+ user.model.ts # pk field: uuid
377
+ user.service.ts # @Injectable({ providedIn: 'root' })
378
+ user.store.ts # signalStore({ providedIn: 'root' }, ...)
379
+ ```
380
+
381
+ ---
382
+
383
+ ## βš–οΈ License
384
+
385
+ [MIT](./LICENSE) - Jorge Palacio Barcinilla