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/dist/engine/architecture-profile.js +10 -0
- package/dist/engine/module-generator.js +142 -0
- package/dist/engine/project-config.js +39 -0
- package/dist/engine/resource-generator.js +117 -0
- package/dist/engine/resource-spec.js +44 -0
- package/nestgen.js +318 -83
- package/nestjs-generator/features/add_module.sh +68 -24
- package/nestjs-generator/features/configure_bootstrap.mjs +39 -0
- package/nestjs-generator/features/docker.sh +169 -36
- package/nestjs-generator/features/git.sh +4 -2
- package/nestjs-generator/features/inject_module_to_app.sh +22 -69
- package/nestjs-generator/features/preflight.mjs +55 -0
- package/nestjs-generator/features/prisma.sh +48 -8
- package/nestjs-generator/features/resource_name.mjs +57 -0
- package/nestjs-generator/features/swagger.sh +7 -20
- package/nestjs-generator/features/typeorm.sh +68 -7
- package/nestjs-generator/features/update_app_module.mjs +146 -0
- package/nestjs-generator/features/utils.sh +52 -14
- package/nestjs-generator/generate_project.sh +41 -71
- package/package.json +56 -31
- package/readme.md +90 -133
package/package.json
CHANGED
|
@@ -1,33 +1,58 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<p>Architecture DDD • CQRS • Hexagonal • Prisma/TypeORM • Docker/Swagger</p>
|
|
3
|
+
[](https://www.npmjs.com/package/nestgen-cli)
|
|
4
|
+
[](https://github.com/el-hack/nestgen-cli/actions/workflows/ci.yml)
|
|
5
|
+
[](LICENSE)
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-

|
|
10
|
-

|
|
11
|
-

|
|
12
|
-

|
|
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
|
-
##
|
|
9
|
+
## Supported contract
|
|
16
10
|
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
+
## Quickstart — TypeORM resource
|
|
30
20
|
|
|
31
|
-
|
|
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
|
|
24
|
+
npm install --global nestgen-cli
|
|
25
|
+
nestgen --version
|
|
26
|
+
nestgen init
|
|
48
27
|
```
|
|
49
28
|
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
79
|
-
```bash
|
|
80
|
-
nestgen module user --orm=typeorm
|
|
81
|
-
nestgen module transaction --orm=prisma --crud
|
|
82
|
-
```
|
|
62
|
+
### English quickstart
|
|
83
63
|
|
|
84
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
86
|
+
Use `nestgen --help` for the complete accepted option set. Do not rely on undocumented options such as `--crud` or `--path`.
|
|
125
87
|
|
|
126
|
-
|
|
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
|
-
|
|
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
|
-
|
|
143
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
108
|
+
Use development with `docker compose up`. Build the deployable image independently:
|
|
157
109
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
115
|
+
## Development
|
|
165
116
|
|
|
166
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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).
|