nestgen-cli 0.0.7 → 0.1.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/package.json CHANGED
@@ -1,33 +1,58 @@
1
1
  {
2
- "name": "nestgen-cli",
3
- "version": "0.0.7",
4
- "description": "NestGen CLI — Générateur modulaire NestJS (DDD, CQRS, Hexagonal)",
5
- "files": [
6
- "nestgen.js",
7
- "nestjs-generator"
8
- ],
9
- "bin": {
10
- "nestgen": "nestgen.js"
11
- },
12
- "author": "Aristide kamara bakarykamara52@gmail.com",
13
- "license": "MIT",
14
- "keywords": [
15
- "nestjs",
16
- "cli",
17
- "ddd",
18
- "cqrs",
19
- "scaffold",
20
- "generator",
21
- "hexagonal"
22
- ],
23
- "repository": {
24
- "type": "git",
25
- "url": "https://github.com/el-hack/nestgen-cli.git"
26
- },
27
- "type": "module",
28
- "licenses": "MIT",
29
- "dependencies": {
30
- "chalk": "^5.3.0",
31
- "inquirer": "^9.0.0"
32
- }
2
+ "name": "nestgen-cli",
3
+ "version": "0.1.0",
4
+ "description": "NestGen CLI — Générateur modulaire NestJS (DDD, CQRS, Hexagonal)",
5
+ "files": [
6
+ "dist",
7
+ "nestgen.js",
8
+ "nestjs-generator"
9
+ ],
10
+ "bin": {
11
+ "nestgen": "nestgen.js"
12
+ },
13
+ "author": "Aristide kamara bakarykamara52@gmail.com",
14
+ "license": "MIT",
15
+ "keywords": [
16
+ "nestjs",
17
+ "cli",
18
+ "ddd",
19
+ "cqrs",
20
+ "scaffold",
21
+ "generator",
22
+ "hexagonal"
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/el-hack/nestgen-cli.git"
27
+ },
28
+ "type": "module",
29
+ "engines": {
30
+ "node": ">=24.15.0 <27"
31
+ },
32
+ "packageManager": "npm@11.0.0",
33
+ "scripts": {
34
+ "build": "tsc -p tsconfig.json",
35
+ "check": "npm run typecheck && eslint .",
36
+ "format": "prettier --write .",
37
+ "format:check": "prettier --check .",
38
+ "prepack": "npm run build && npm run check && npm run format:check && npm test",
39
+ "test": "node --test",
40
+ "test:package": "node scripts/package-smoke.mjs",
41
+ "test:prisma": "node scripts/prisma-integration.mjs",
42
+ "test:docker": "node scripts/docker-config-integration.mjs",
43
+ "test:typeorm": "node scripts/typeorm-http-integration.mjs",
44
+ "typecheck": "tsc -p tsconfig.json --noEmit"
45
+ },
46
+ "licenses": "MIT",
47
+ "dependencies": {
48
+ "chalk": "^5.3.0",
49
+ "inquirer": "^9.0.0",
50
+ "typescript": "^5.9.3"
51
+ },
52
+ "devDependencies": {
53
+ "@eslint/js": "^9.39.5",
54
+ "@types/node": "^24.19.0",
55
+ "eslint": "^9.39.5",
56
+ "prettier": "^3.9.9"
57
+ }
33
58
  }
package/readme.md CHANGED
@@ -1,175 +1,132 @@
1
- # NestGen
1
+ # NestGen CLI
2
2
 
3
- <div align="center">
4
- <img src="https://raw.githubusercontent.com/outis25/nestgen-js/main/assets/logo.png" alt="NestGen Logo" width="200" />
5
- <h3>Générateur modulaire autonome pour projets NestJS</h3>
6
- <p>Architecture DDD • CQRS • Hexagonal • Prisma/TypeORM • Docker/Swagger</p>
3
+ [![npm](https://img.shields.io/npm/v/nestgen-cli?label=npm)](https://www.npmjs.com/package/nestgen-cli)
4
+ [![CI](https://github.com/el-hack/nestgen-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/el-hack/nestgen-cli/actions/workflows/ci.yml)
5
+ [![license](https://img.shields.io/npm/l/nestgen-cli)](LICENSE)
7
6
 
8
- ![npm](https://img.shields.io/npm/v/@outis25/nestgen?color=crimson&style=for-the-badge)
9
- ![nestjs](https://img.shields.io/badge/NestJS-Scaffolded-red?style=for-the-badge&logo=nestjs)
10
- ![standalone](https://img.shields.io/badge/100%25-Autonome-brightgreen?style=for-the-badge)
11
- ![license](https://img.shields.io/npm/l/@outis25/nestgen?color=blue&style=for-the-badge)
12
- ![downloads](https://img.shields.io/npm/dm/@outis25/nestgen?color=green&style=for-the-badge)
13
- </div>
7
+ NestGen CLI generates NestJS project scaffolding and TypeORM resources. The canonical package is [`nestgen-cli`](https://www.npmjs.com/package/nestgen-cli); the canonical repository is [`el-hack/nestgen-cli`](https://github.com/el-hack/nestgen-cli).
14
8
 
15
- ## 📋 Table des matières
9
+ ## Supported contract
16
10
 
17
- - [Introduction](#-introduction)
18
- - [Fonctionnalités](#-fonctionnalités)
19
- - [Installation](#-installation)
20
- - [Guide d'utilisation](#-guide-dutilisation)
21
- - [Architecture générée](#-architecture-générée)
22
- - [Roadmap](#-roadmap)
23
- - [FAQ](#-faq)
24
- - [Contribuer](#-contribuer)
25
- - [Licence](#-licence)
11
+ - Node.js `>=24.15.0 <27`, npm 11, pnpm or Yarn.
12
+ - `init` creates a NestJS project interactively with TypeORM or Prisma.
13
+ - `module <name>` adds the advanced module layout for TypeORM or Prisma.
14
+ - `resource <name>` currently generates a **TypeORM** REST CRUD: entity, DTOs, repository, controller, validation, pagination, `404` and unique-constraint `409`.
15
+ - `doctor`, `--dry-run`, `--help`, `--version`, `--no-interactive` and `--quiet` are scriptable CLI features.
26
16
 
27
- ## 🚀 Introduction
17
+ The repository CI validates linting, formatting, generator contracts, a Prisma integration, a TypeORM HTTP/PostgreSQL integration, generated Docker configurations, and the npm tarball. It does not publish releases or deploy applications.
28
18
 
29
- **NestGen** est un générateur de code 100% autonome pour NestJS qui vous permet de créer rapidement des projets et des modules respectant les principes d'architecture avancés. Ce package n'a aucune dépendance externe et embarque tous les templates nécessaires pour générer des applications NestJS suivant les modèles Domain-Driven Design (DDD), Command Query Responsibility Segregation (CQRS) et l'architecture hexagonale.
19
+ ## Quickstart — TypeORM resource
30
20
 
31
- Idéal pour les développeurs qui souhaitent maintenir une architecture propre et évolutive, NestGen accélère la phase de setup et garantit la cohérence structurelle de votre application, le tout sans nécessiter d'installation ou de configuration supplémentaire.
32
-
33
- ## ✨ Fonctionnalités
34
-
35
- - **100% autonome** - Aucune dépendance externe, tout est intégré
36
- - **Zéro configuration** - Fonctionne immédiatement après installation
37
- - **Génération complète** - Projets et modules prêts à l'emploi en quelques secondes
38
- - **Architecture avancée** - Support intégré pour DDD, CQRS et architecture hexagonale
39
- - **Templates embarqués** - Tous les templates sont inclus dans le package
40
- - **Support multiple d'ORM** - TypeORM et Prisma intégrés nativement
41
- - **DevOps ready** - Configurations Docker, Swagger et CI/CD incluses
42
- - **Mode interactif** - Interface CLI intuitive avec prompts pour une configuration guidée
43
-
44
- ## 📦 Installation
21
+ The following flow is the supported end-to-end TypeORM path. It uses Docker for PostgreSQL and creates an explicit migration.
45
22
 
46
23
  ```bash
47
- npm install -g @outis25/nestgen
24
+ npm install --global nestgen-cli
25
+ nestgen --version
26
+ nestgen init
48
27
  ```
49
28
 
50
- C'est tout! Aucune configuration supplémentaire n'est nécessaire. Tous les templates et dépendances sont embarqués dans le package.
51
-
52
- ## 🔧 Guide d'utilisation
53
-
54
- ### Initialiser un nouveau projet
29
+ In the interactive prompts, choose `npm`, `typeorm`, Docker enabled, then name the project `store-api`. Continue in the generated project:
55
30
 
56
31
  ```bash
57
- nestgen init
32
+ cd store-api
33
+ nestgen doctor
34
+ nestgen resource product \
35
+ --orm typeorm \
36
+ --fields sku:string!,price:number,published:boolean \
37
+ --route catalog/products \
38
+ --table catalog_products
39
+
40
+ cp .env.example .env
41
+ docker compose up --detach postgres
42
+ npx typeorm-ts-node-commonjs migration:generate \
43
+ src/database/migrations/CreateProducts \
44
+ --dataSource src/database/data-source.ts
45
+ npx typeorm-ts-node-commonjs migration:run \
46
+ --dataSource src/database/data-source.ts
47
+ npm run start:dev
58
48
  ```
59
49
 
60
- Cette commande lance un assistant interactif qui vous guidera à travers les étapes de configuration :
61
- - Nom du projet
62
- - Répertoire d'installation
63
- - Sélection de l'ORM (TypeORM ou Prisma)
64
- - Modules à générer automatiquement
65
- - Options additionnelles (Git, Swagger, Docker, etc.)
66
-
67
- ### Générer un nouveau module
50
+ In another terminal, verify the generated endpoint:
68
51
 
69
52
  ```bash
70
- nestgen module <nom-du-module> [options]
53
+ curl --request POST http://localhost:3000/catalog/products \
54
+ --header 'content-type: application/json' \
55
+ --data '{"sku":"sku-001","price":19.9,"published":true}'
56
+
57
+ curl 'http://localhost:3000/catalog/products?page=1&limit=20'
71
58
  ```
72
59
 
73
- Options disponibles :
74
- - `--orm=<typeorm|prisma>` - Spécifie l'ORM à utiliser pour ce module
75
- - `--crud` - Génère les opérations CRUD de base
76
- - `--path=<chemin>` - Définit un chemin personnalisé pour le module
60
+ A duplicate `sku` returns HTTP `409`; a malformed `price` returns HTTP `400`; an unknown identifier returns HTTP `404`. Run the generated project tests with `npm test` and stop the local database with `docker compose down`.
77
61
 
78
- Exemples :
79
- ```bash
80
- nestgen module user --orm=typeorm
81
- nestgen module transaction --orm=prisma --crud
82
- ```
62
+ ### English quickstart
83
63
 
84
- ### Vérifier l'installation
64
+ Install `nestgen-cli`, run `nestgen init`, choose **npm**, **typeorm** and Docker, then run the same commands above. `resource product --fields sku:string!,price:number,published:boolean` creates the TypeORM CRUD. Start PostgreSQL with `docker compose up -d postgres`, generate and run the migration through `typeorm-ts-node-commonjs`, start NestJS, then use the two `curl` commands to verify create and list operations.
85
65
 
86
- ```bash
66
+ ## Commands
67
+
68
+ ```text
69
+ nestgen init
70
+ nestgen module <name> [--orm typeorm|prisma] [--dry-run]
71
+ nestgen resource <name> --fields name:type[,name:type] [--route route] [--table table] [--profile simple|advanced]
72
+ nestgen config init [--orm typeorm|prisma] [--profile simple|advanced] [--package-manager npm|pnpm|yarn]
73
+ nestgen config show
87
74
  nestgen doctor
88
75
  ```
89
76
 
90
- Cette commande vérifie que :
91
- - Le package est correctement installé
92
- - Tous les templates embarqués sont disponibles
93
- - Aucune dépendance n'est manquante
94
-
95
- ## 📁 Architecture générée
96
-
97
- NestGen génère une structure de projet suivant les meilleures pratiques d'architecture :
77
+ Fields accepted by `resource` are `string`, `number`, `boolean`, `date` and `uuid`. Add `?` for a nullable field and `!` for a unique field:
98
78
 
79
+ ```bash
80
+ nestgen resource invoice \
81
+ --fields number:string!,amount:number,paid:boolean,dueAt:date? \
82
+ --route billing/invoices \
83
+ --table billing_invoices
99
84
  ```
100
- src/app/<module>/
101
- ├── core/ # Cœur du domaine métier
102
- │ ├── application/ # Cas d'utilisation
103
- │ │ ├── commands/ # Commandes CQRS
104
- │ │ ├── events/ # Événements domaine
105
- │ │ └── queries/ # Requêtes CQRS
106
- │ └── domain/ # Modèle du domaine
107
- │ ├── entities/ # Entités métier
108
- │ └── ports/ # Interfaces pour l'hexagonal
109
- ├── infrastructure/ # Implémentations techniques
110
- │ ├── adapters/ # Adaptateurs pour l'hexagonal
111
- │ └── persistences/ # Couche de persistance
112
- │ └── repositories/ # Implémentations des repos
113
- └── interfaces/ # Points d'entrée de l'app
114
- ├── controllers/ # Contrôleurs REST
115
- └── dtos/ # Objets de transfert
116
- ```
117
-
118
- Cette structure facilite :
119
- - La séparation des préoccupations
120
- - Les tests unitaires et d'intégration
121
- - L'évolutivité du code
122
- - Le remplacement des composants techniques
123
85
 
124
- ## 🔮 Roadmap
86
+ Use `nestgen --help` for the complete accepted option set. Do not rely on undocumented options such as `--crud` or `--path`.
125
87
 
126
- - ✅ Génération de projet complet
127
- - ✅ Génération de module modulaire (DDD, CQRS, Repo)
128
- - ✅ Support Prisma et TypeORM
129
- - ✅ Mode interactif
130
- - ✅ Docker, Swagger, Git
131
- - ✅ Templates intégrés
132
- - ✅ Package 100% autonome
133
- - ⬜ `nestgen resource <name>` (CRUD complet)
134
- - ⬜ `nestgen destroy module <name>`
135
- - ⬜ `nestgen preset ecommerce` (Templates d'applications)
136
- - ⬜ `nestgen --interactive` (menu CLI avancé)
137
- - ⬜ Support pour MongoDB et Mongoose
138
- - ⬜ Génération de tests unitaires et d'intégration
88
+ ## Project configuration and profiles
139
89
 
140
- ## ❓ FAQ
90
+ `nestgen config init` writes a versioned `nestgen.config.json` in the current project. Its ORM, architecture profile and package-manager defaults apply to subsequent resource generation; explicit resource flags take precedence.
141
91
 
142
- **Q: NestGen nécessite-t-il des dépendances externes ?**
143
- R: Non, NestGen est 100% autonome. Tous les templates et outils nécessaires sont embarqués dans le package.
92
+ ```bash
93
+ nestgen config init --orm typeorm --profile advanced --package-manager npm
94
+ nestgen config show
95
+ nestgen resource order --fields reference:string!,total:number
96
+ ```
144
97
 
145
- **Q: Puis-je utiliser NestGen avec un projet NestJS existant ?**
146
- R: Oui, vous pouvez ajouter des modules générés par NestGen à un projet existant. La structure générée s'intègre parfaitement aux projets NestJS standards.
98
+ The `simple` profile generates a direct CRUD. The `advanced` profile adds an explicit repository port and Nest injection token between the application service and TypeORM adapter.
147
99
 
148
- **Q: Comment puis-je personnaliser les templates générés ?**
149
- R: Par défaut, NestGen utilise ses templates intégrés. Leurs structures sont optimisées pour les meilleures pratiques et ne nécessitent généralement pas de modifications.
100
+ ## Docker generated by `init`
150
101
 
151
- **Q: NestGen supporte-t-il les microservices ?**
152
- R: Pas encore nativement, mais c'est prévu dans les prochaines versions. En attendant, vous pouvez adapter manuellement la structure générée.
102
+ When Docker is enabled, NestGen writes:
153
103
 
154
- ## 👥 Contribuer
104
+ - `compose.yaml` for local development, with PostgreSQL 16, a healthcheck and a code mount;
105
+ - `Dockerfile` with a `development` target and a separate minimal `production` target;
106
+ - `.dockerignore` and `.env.example` without overwriting existing environment examples.
155
107
 
156
- Les contributions sont les bienvenues ! Pour contribuer :
108
+ Use development with `docker compose up`. Build the deployable image independently:
157
109
 
158
- 1. Forkez le dépôt
159
- 2. Créez une branche pour votre fonctionnalité (`git checkout -b feature/amazing-feature`)
160
- 3. Commitez vos changements (`git commit -m 'feat: add amazing feature'`)
161
- 4. Poussez vers la branche (`git push origin feature/amazing-feature`)
162
- 5. Ouvrez une Pull Request
110
+ ```bash
111
+ docker build --target production --tag store-api:local .
112
+ docker run --rm --env-file .env --publish 3000:3000 store-api:local
113
+ ```
163
114
 
164
- <!-- Veuillez consulter le fichier `CONTRIBUTING.md` pour plus de détails. -->
115
+ ## Development
165
116
 
166
- ## 📄 Licence
117
+ ```bash
118
+ npm ci
119
+ npm run check
120
+ npm run format:check
121
+ npm test
122
+ npm run test:docker
123
+ npm run test:prisma
124
+ npm run test:typeorm
125
+ npm run test:package
126
+ ```
167
127
 
168
- NestGen est distribué sous licence MIT. Voir le fichier `LICENSE` pour plus d'informations.
128
+ See [COMPATIBILITY.md](COMPATIBILITY.md) for supported versions and [ARCHITECTURE.md](ARCHITECTURE.md) for generator design decisions.
169
129
 
170
- ---
130
+ ## Licence
171
131
 
172
- <div align="center">
173
- <p>Développé avec ❤️ par <a href="https://github.com/el-hack">@el-hack</a></p>
174
- <p>Si vous trouvez ce projet utile, n'hésitez pas à lui donner une ⭐️ sur GitHub !</p>
175
- </div>
132
+ MIT. See [LICENSE](LICENSE).