@barcidev/ngx-autogen 0.1.71 β†’ 0.1.72

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