nestgen-cli 0.2.2 → 0.2.3
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/examples/store-api/README.md +3 -3
- package/examples/store-api/nestgen.example.json +1 -1
- package/nestgen.js +63 -80
- package/package.json +4 -2
- package/readme.md +7 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Exemple Store API — NestGen CLI 0.2.
|
|
1
|
+
# Exemple Store API — NestGen CLI 0.2.3
|
|
2
2
|
|
|
3
|
-
Cette application exemple décrit une API de vente avec des clients, produits, commandes et lignes de commande. Elle est validée avec `nestgen-cli@0.2.
|
|
3
|
+
Cette application exemple décrit une API de vente avec des clients, produits, commandes et lignes de commande. Elle est validée avec `nestgen-cli@0.2.3` et TypeORM, avec le profil d’architecture `advanced`.
|
|
4
4
|
|
|
5
5
|
Les fichiers de `definitions/` sont la source de vérité. Ils restent volontairement déclaratifs : l’application est reconstruite par le CLI au lieu de conserver une copie de fichiers générés qui pourrait diverger du produit.
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ Créez un dossier de travail, installez la version exacte du CLI puis générez
|
|
|
11
11
|
```bash
|
|
12
12
|
mkdir nestgen-store-api && cd nestgen-store-api
|
|
13
13
|
npm init --yes
|
|
14
|
-
npm install nestgen-cli@0.2.
|
|
14
|
+
npm install nestgen-cli@0.2.3
|
|
15
15
|
|
|
16
16
|
./node_modules/.bin/nestgen init store-api \
|
|
17
17
|
--no-interactive \
|
package/nestgen.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { spawnSync } from 'child_process';
|
|
4
|
-
import
|
|
4
|
+
import input from '@inquirer/input';
|
|
5
|
+
import select from '@inquirer/select';
|
|
6
|
+
import confirm from '@inquirer/confirm';
|
|
5
7
|
import chalk from 'chalk';
|
|
6
8
|
import path from 'path';
|
|
7
9
|
import fs from 'fs';
|
|
@@ -241,72 +243,57 @@ export function runBashScript(scriptPath, args = [], env = {}, quiet = false) {
|
|
|
241
243
|
|
|
242
244
|
// ────── Commande : INIT
|
|
243
245
|
async function askInitQuestions() {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
default: true,
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
type: 'input',
|
|
299
|
-
name: 'modules',
|
|
300
|
-
message: '📦 Modules à générer (séparés par des espaces) :',
|
|
301
|
-
default: 'user',
|
|
302
|
-
filter: (input) =>
|
|
303
|
-
input
|
|
304
|
-
.split(' ')
|
|
305
|
-
.map((s) => s.trim())
|
|
306
|
-
.filter(Boolean),
|
|
307
|
-
validate: validatePromptValue((modules) => modules.forEach(validateModuleName)),
|
|
308
|
-
},
|
|
309
|
-
]);
|
|
246
|
+
const projectName = await input({
|
|
247
|
+
message: '📛 Nom du projet :',
|
|
248
|
+
default: 'my-app',
|
|
249
|
+
validate: validatePromptValue(validateModuleName),
|
|
250
|
+
});
|
|
251
|
+
const projectPath = await input({
|
|
252
|
+
message: '📁 Dossier cible :',
|
|
253
|
+
default: './',
|
|
254
|
+
validate: validatePromptValue(resolveProjectPath),
|
|
255
|
+
});
|
|
256
|
+
const packageManager = await select({
|
|
257
|
+
message: '📦 Package manager :',
|
|
258
|
+
choices: ['pnpm', 'yarn', 'npm'].map((value) => ({ name: value, value })),
|
|
259
|
+
default: 'pnpm',
|
|
260
|
+
});
|
|
261
|
+
const orm = await select({
|
|
262
|
+
message: '🧠 ORM :',
|
|
263
|
+
choices: ['typeorm', 'prisma'].map((value) => ({ name: value, value })),
|
|
264
|
+
default: 'typeorm',
|
|
265
|
+
});
|
|
266
|
+
const withSwagger = await confirm({ message: '📚 Activer Swagger ?', default: true });
|
|
267
|
+
const withDocker = await confirm({ message: '🐳 Activer Docker ?', default: false });
|
|
268
|
+
const withOperations = await confirm({
|
|
269
|
+
message: '🩺 Activer le socle d’exploitation (santé, logs, arrêt propre) ?',
|
|
270
|
+
default: false,
|
|
271
|
+
});
|
|
272
|
+
const withGit = await confirm({ message: '🔃 Initialiser Git ?', default: true });
|
|
273
|
+
const modulesInput = await input({
|
|
274
|
+
message: '📦 Modules à générer (séparés par des espaces) :',
|
|
275
|
+
default: 'user',
|
|
276
|
+
validate: validatePromptValue((value) => parseModulesInput(value).forEach(validateModuleName)),
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
projectName,
|
|
281
|
+
projectPath,
|
|
282
|
+
packageManager,
|
|
283
|
+
orm,
|
|
284
|
+
withSwagger,
|
|
285
|
+
withDocker,
|
|
286
|
+
withOperations,
|
|
287
|
+
withGit,
|
|
288
|
+
modules: parseModulesInput(modulesInput),
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function parseModulesInput(value) {
|
|
293
|
+
return value
|
|
294
|
+
.split(' ')
|
|
295
|
+
.map((moduleName) => moduleName.trim())
|
|
296
|
+
.filter(Boolean);
|
|
310
297
|
}
|
|
311
298
|
|
|
312
299
|
function validatePromptValue(validator) {
|
|
@@ -393,23 +380,19 @@ async function runModuleGeneration(parsed) {
|
|
|
393
380
|
orm = validateOrm(parsed.options.orm ?? config.orm);
|
|
394
381
|
} else {
|
|
395
382
|
if (parsed.options.noInteractive) throw new Error('module --no-interactive requiert un nom de module.');
|
|
396
|
-
|
|
397
|
-
{
|
|
398
|
-
type: 'input',
|
|
399
|
-
name: 'moduleName',
|
|
383
|
+
moduleName = validateModuleName(
|
|
384
|
+
await input({
|
|
400
385
|
message: '📦 Nom du module :',
|
|
401
386
|
validate: validatePromptValue(validateModuleName),
|
|
402
|
-
},
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
387
|
+
}),
|
|
388
|
+
);
|
|
389
|
+
orm = validateOrm(
|
|
390
|
+
await select({
|
|
406
391
|
message: '🧠 ORM utilisé :',
|
|
407
|
-
choices: ['typeorm', 'prisma'],
|
|
392
|
+
choices: ['typeorm', 'prisma'].map((value) => ({ name: value, value })),
|
|
408
393
|
default: 'typeorm',
|
|
409
|
-
},
|
|
410
|
-
|
|
411
|
-
moduleName = validateModuleName(answers.moduleName);
|
|
412
|
-
orm = validateOrm(answers.orm);
|
|
394
|
+
}),
|
|
395
|
+
);
|
|
413
396
|
}
|
|
414
397
|
|
|
415
398
|
if (!isNestProject()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestgen-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "NestGen CLI — Générateur modulaire NestJS (DDD, CQRS, Hexagonal)",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -52,8 +52,10 @@
|
|
|
52
52
|
},
|
|
53
53
|
"licenses": "MIT",
|
|
54
54
|
"dependencies": {
|
|
55
|
+
"@inquirer/confirm": "^6.3.3",
|
|
56
|
+
"@inquirer/input": "^5.1.7",
|
|
57
|
+
"@inquirer/select": "^5.2.6",
|
|
55
58
|
"chalk": "^5.3.0",
|
|
56
|
-
"inquirer": "^9.0.0",
|
|
57
59
|
"prettier": "^3.9.9",
|
|
58
60
|
"typescript": "^5.9.3"
|
|
59
61
|
},
|
package/readme.md
CHANGED
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
NestGen CLI generates NestJS project scaffolding and TypeORM or Prisma 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).
|
|
8
8
|
|
|
9
|
-
## Published in 0.2.
|
|
9
|
+
## Published in 0.2.3 / Disponible dans 0.2.3
|
|
10
10
|
|
|
11
11
|
| Available now / Disponible maintenant | Evidence / Preuve |
|
|
12
12
|
| ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
-
| Nest project, module and TypeORM or Prisma resource generation | The commands are shipped by `nestgen-cli@0.2.
|
|
13
|
+
| Nest project, module and TypeORM or Prisma resource generation | The commands are shipped by `nestgen-cli@0.2.3` and covered by the CLI contract tests. |
|
|
14
14
|
| Declarative resource relations, safe updates and migration plans | The generated manifest protects manual edits; migrations remain explicitly reviewed and applied by the developer. |
|
|
15
15
|
| Operational foundation and authorization metadata | Both are optional extension points; NestGen does not configure an identity provider, a global guard or an external monitoring service. |
|
|
16
16
|
| Store API example | The package ships the [version-pinned example](examples/store-api/README.md), which CI reconstructs from its resource definitions. |
|
|
17
17
|
|
|
18
18
|
## Planned (not released) / Prévu (non publié)
|
|
19
19
|
|
|
20
|
-
The [roadmap](roadmap.md) contains topics under consideration after 0.2.
|
|
20
|
+
The [roadmap](roadmap.md) contains topics under consideration after 0.2.3. They have no release date and are not part of the npm contract until they appear in a versioned guide and `CHANGELOG.md`. La roadmap recense des pistes après 0.2.3 ; elles n’ont ni date de sortie ni engagement de compatibilité avant leur publication dans un guide versionné et le changelog.
|
|
21
21
|
|
|
22
22
|
## Supported contract
|
|
23
23
|
|
|
@@ -52,11 +52,11 @@ For Prisma, run `npx prisma generate` and apply the schema with `npx prisma db p
|
|
|
52
52
|
Install the announced release and verify the exact binary before generating anything. Installez la version annoncée et vérifiez le binaire exact avant toute génération.
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
npm install --global nestgen-cli@0.2.
|
|
56
|
-
nestgen --version # 0.2.
|
|
55
|
+
npm install --global nestgen-cli@0.2.3
|
|
56
|
+
nestgen --version # 0.2.3
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Then follow the [Store API example](examples/store-api/README.md): it generates customers, products, orders and order items; starts PostgreSQL; creates an explicit migration; and runs generated tests. The versioned [guide](docs/versions/0.2.
|
|
59
|
+
Then follow the [Store API example](examples/store-api/README.md): it generates customers, products, orders and order items; starts PostgreSQL; creates an explicit migration; and runs generated tests. The versioned [guide](docs/versions/0.2.3.md) documents the commands and constraints used by the demo. Ensuite, suivez l’exemple Store API : il couvre la génération, PostgreSQL, une migration explicite, les tests générés et la documentation de la version.
|
|
60
60
|
|
|
61
61
|
The CI verifies the public commands against the announced package version, reconstructs the example and installs the npm tarball in a clean consumer. It validates reproducibility of these flows, not a production certification / pas une certification de production.
|
|
62
62
|
|
|
@@ -65,7 +65,7 @@ The CI verifies the public commands against the announced package version, recon
|
|
|
65
65
|
The following flow is the supported end-to-end TypeORM path. Prerequisites: Node.js `>=24.15.0 <27`, npm 11 and Docker with Compose. It uses Docker for PostgreSQL and creates an explicit migration.
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
npm install --global nestgen-cli@0.2.
|
|
68
|
+
npm install --global nestgen-cli@0.2.3
|
|
69
69
|
nestgen --version
|
|
70
70
|
nestgen init
|
|
71
71
|
```
|