npm package: @nugas/forge-devkit
Description: Angular code generation library for scaffolding features with CRUD pages, NgRx store, facade, and adapters. No scripts required—run generators directly with `npx`.
Latest version: 1.0.2

# Forge Devkit

Angular code generation library for scaffolding features with CRUD pages, NgRx store, facade, and adapters. No scripts required—run generators directly with `npx`.

## Requirements

- Angular 16+
- Node.js 18+

## Installation

### From npm (when published)

```bash
npm install forge-devkit
```

### From a .tgz file (local distribution)

```bash
npm install /path/to/forge-devkit-0.0.1.tgz
```

Or after packing:

```bash
# In the forge-devkit workspace
npm run pack:lib
# Then in your project
npm install ./path/to/forge-devkit-0.0.1.tgz
```

### From local build

```bash
npm install /path/to/codegen-workspace/dist/forge-devkit
```

## Usage

Run from your Angular project root. **No scripts to add**—just use `npx`:

```bash
npx forge-devkit
```

This opens an interactive menu. Or run a specific generator:

```bash
npx forge-devkit feature   # Full feature (pages, store, facade, adapters)
npx forge-devkit page      # Individual page
npx forge-devkit store     # NgRx store only
npx forge-devkit core      # Core layer (store models, configs, services, tokens, adapters, interceptors)
```

### Generated output

Files are written to your project's `src/app` (standalone app) or `projects/<app-name>/src/app` (Angular workspace). The generator detects your project structure via `angular.json`.

### Feature generator

Creates a full feature module with:

| Component        | Description                               |
|------------------|-------------------------------------------|
| Pages            | List, Create, Edit, View (CRUD)           |
| Store            | NGXS actions, states (list/detail/create/edit), selectors, models |
| Facade           | Service coordinating store and navigation |
| Adapters         | Request converter & response mapper       |
| Routes           | Feature routing setup                     |

You can choose which parts to include during generation.

### Core generator

Generates the core layer scaffold under `src/app/core` (or `projects/<app>/src/app/core`):

| Component     | Description                                                  |
|---------------|--------------------------------------------------------------|
| Store models  | `PostStateModel`, `PagedStateModel`, `ApiResponse`, `PaginatedResponse`, `Request`, `DetailRequest` |
| Base state    | `BaseApiState` with `requestGet` / `requestPost` helpers      |
| Configs       | `ApiConfig` for API path generation                          |
| Services      | `StorageService`, `AuthTokenService`                         |
| Tokens        | `API_CONFIG` injection token                                 |
| Adapters      | Abstract `RequestConverter`, `ResponseMapper` base classes    |
| Interceptors  | `httpRequestInterceptor` (Bearer token)                      |
| Guards        | Empty index (placeholder)                                    |

### Store generator

Generates NGXS store matching the demo-app structure:

| Path | Description |
|------|-------------|
| `actions/` | Get all, Get detail, Create, Edit actions |
| `state/` | List state, detail state, create state, edit state (edit uses POST) |
| `models/request/` | Entity DTO, get query, create DTO, edit DTO |
| `models/response/` | Paginated list response, detail response |
| `models/state/` | State models and default factories |
| `selectors/` | Selectors for list, detail, create, edit |
| `entity-endpoints.const.ts` | API endpoint constants (LIST, DETAIL, EDIT) |

Requires `@core/store` (run `forge-devkit core` first) and `@ngxs/store`.

## Building the library (contributors)

```bash
# Build
npm run build:lib

# Create distributable .tgz
npm run pack:lib
```

Output: `dist/forge-devkit/` and `dist/forge-devkit/forge-devkit-0.0.1.tgz`

## License

Private / MIT (as per your project)