scaffold-doc-cli 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/index.js +77 -46
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -69,25 +69,25 @@ async function init() {
69
69
  -->
70
70
  # ${answers.projectName} Documentation
71
71
 
72
- ## Overview
72
+ ## Vue d'ensemble
73
73
  <!-- AI_CONTENT_START -->
74
- Documentation initialized.
74
+ Documentation initialisée.
75
75
  <!-- AI_CONTENT_END -->
76
76
 
77
- ## Quick Links
78
- - [Getting Started](./getting-started.md)
77
+ ## Liens Rapides
78
+ - [Démarrage](./getting-started.md)
79
79
  - [Architecture](./architecture.md)
80
80
  `;
81
81
  await fs.writeFile(path.join(docsDir, 'index.md'), indexContent);
82
82
 
83
83
  // getting-started.md
84
- const gettingStartedContent = `# Getting Started
84
+ const gettingStartedContent = `# Démarrage
85
85
 
86
86
  <!--
87
- INSTRUCTION: Document the installation and setup steps.
87
+ INSTRUCTION: Documentez les étapes d'installation et de configuration.
88
88
  -->
89
89
 
90
- ## Prerequisites
90
+ ## Prérequis
91
91
  <!-- AI_CONTENT_START -->
92
92
  <!-- AI_CONTENT_END -->
93
93
 
@@ -137,10 +137,10 @@ docs_dir: .docs
137
137
  theme: readthedocs
138
138
 
139
139
  nav:
140
- - Home: index.md
141
- - Getting Started: getting-started.md
140
+ - Accueil: index.md
141
+ - Démarrage: getting-started.md
142
142
  - Architecture: architecture.md
143
- - Reference:
143
+ - Référence:
144
144
  ${referenceNav}
145
145
  `;
146
146
  await fs.writeFile(path.join(process.cwd(), 'mkdocs.yml'), mkdocsContent);
@@ -189,7 +189,8 @@ jobs:
189
189
  run: node .github/scripts/doc-sync.mjs
190
190
 
191
191
  - name: Create Pull Request
192
- uses: peter-evans/create-pull-request@v5
192
+ id: cpr
193
+ uses: peter-evans/create-pull-request@v7
193
194
  with:
194
195
  token: \${{ secrets.GITHUB_TOKEN }}
195
196
  commit-message: "docs: auto-generated documentation updates"
@@ -202,6 +203,12 @@ jobs:
202
203
  base: \${{ github.head_ref || github.ref_name }}
203
204
  delete-branch: true
204
205
  add-paths: .docs
206
+
207
+ - name: Check outputs
208
+ if: \${{ steps.cpr.outputs.pull-request-number }}
209
+ run: |
210
+ echo "Pull Request Number - \${{ steps.cpr.outputs.pull-request-number }}"
211
+ echo "Pull Request URL - \${{ steps.cpr.outputs.pull-request-url }}"
205
212
  `;
206
213
  await fs.writeFile(path.join(workflowDir, 'ai-doc-sync.yml'), workflowContent);
207
214
  console.log(chalk.green('✔ .github/workflows/ai-doc-sync.yml created'));
@@ -217,13 +224,22 @@ const genAI = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
217
224
  async function main() {
218
225
  console.log("Starting AI Doc Sync...");
219
226
 
227
+ // 1. Detect Changed Files
220
228
  // 1. Detect Changed Files
221
229
  let changedFiles = [];
230
+ let forceRegenerate = false;
231
+
222
232
  try {
223
- const output = execSync('git diff --name-only HEAD~1 HEAD 2>/dev/null').toString();
224
- changedFiles = output.split('\\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
233
+ const commitMsg = execSync('git log -1 --pretty=%B').toString();
234
+ if (commitMsg.includes('regenerate-doc')) {
235
+ console.log('Trigger "regenerate-doc" détecté. Synchronisation de tous les fichiers...');
236
+ forceRegenerate = true;
237
+ }
225
238
  } catch (e) {
226
- console.warn("HEAD~1 not found (likely first commit). Syncing all tracked files...");
239
+ // Ignore error
240
+ }
241
+
242
+ if (forceRegenerate) {
227
243
  try {
228
244
  const output = execSync('git ls-tree -r HEAD --name-only').toString();
229
245
  changedFiles = output.split('\\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
@@ -231,6 +247,20 @@ async function main() {
231
247
  console.error("Failed to list files:", err.message);
232
248
  return;
233
249
  }
250
+ } else {
251
+ try {
252
+ const output = execSync('git diff --name-only HEAD~1 HEAD 2>/dev/null').toString();
253
+ changedFiles = output.split('\\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
254
+ } catch (e) {
255
+ console.warn("HEAD~1 not found (likely first commit). Syncing all tracked files...");
256
+ try {
257
+ const output = execSync('git ls-tree -r HEAD --name-only').toString();
258
+ changedFiles = output.split('\\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
259
+ } catch (err) {
260
+ console.error("Failed to list files:", err.message);
261
+ return;
262
+ }
263
+ }
234
264
  }
235
265
 
236
266
  if (changedFiles.length === 0) {
@@ -255,17 +285,18 @@ async function main() {
255
285
 
256
286
 
257
287
  const prompt = \`
258
- You are a technical documentation assistant.
259
- Analyze the following code changes and update the documentation in the .docs/ directory.
288
+ Tu es un assistant de documentation technique expert.
289
+ Analyse les modifications de code suivantes et mets à jour la documentation dans le dossier .docs/.
260
290
 
261
- Rules:
262
- 1. Output MUST be a valid JSON object where keys are file paths (relative to .docs/, e.g., "reference/controllers.md") and values are the NEW content of that file.
263
- 2. You can create new files if necessary.
264
- 3. You can update existing files (e.g., getting-started.md, architecture.md).
265
- 4. Focus on accuracy and clarity.
266
- 5. Do not include markdown code fence blocks in your response, just the raw JSON string.
267
-
268
- Code Context:
291
+ Règles:
292
+ 1. La langue de sortie DOIT être le FRANÇAIS.
293
+ 2. La sortie DOIT être un objet JSON valide où les clés sont les chemins de fichiers (relatifs à .docs/, ex: "reference/controllers.md") et les valeurs sont le NOUVEAU contenu de ce fichier.
294
+ 3. Tu peux créer de nouveaux fichiers si nécessaire.
295
+ 4. Tu peux mettre à jour les fichiers existants (ex: getting-started.md, architecture.md).
296
+ 5. Concentre-toi sur la précision et la clarté.
297
+ 6. N'inclus PAS de blocs de code markdown dans ta réponse, juste la chaîne JSON brute.
298
+
299
+ Contexte du code:
269
300
  \${context}
270
301
  \`;
271
302
 
@@ -327,9 +358,9 @@ function getStackConfig(stack) {
327
358
  if (stack.includes('Symfony')) {
328
359
  return {
329
360
  files: {
330
- 'controllers.md': () => `${commonHeader('Controllers')}# Controllers\n\n<!-- INSTRUCTION: Document all Symfony Controllers found in /src/Controller -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
331
- 'entities.md': () => `${commonHeader('Entities')}# Entities\n\n<!-- INSTRUCTION: Document all Doctrine Entities found in /src/Entity -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
332
- 'services.md': () => `${commonHeader('Services')}# Services\n\n<!-- INSTRUCTION: Document core application services found in /src/Service -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
361
+ 'controllers.md': () => `${commonHeader('Controllers')}# Contrôleurs\n\n<!-- INSTRUCTION: Documentez tous les contrôleurs Symfony trouvés dans /src/Controller -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
362
+ 'entities.md': () => `${commonHeader('Entities')}# Entités\n\n<!-- INSTRUCTION: Documentez toutes les entités Doctrine trouvées dans /src/Entity -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
363
+ 'services.md': () => `${commonHeader('Services')}# Services\n\n<!-- INSTRUCTION: Documentez les services principaux trouvés dans /src/Service -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
333
364
  }
334
365
  };
335
366
  }
@@ -338,9 +369,9 @@ function getStackConfig(stack) {
338
369
  if (stack.includes('Laravel')) {
339
370
  return {
340
371
  files: {
341
- 'controllers.md': () => `${commonHeader('Controllers')}# Controllers\n\n<!-- INSTRUCTION: Document Http Controllers found in /app/Http/Controllers -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
342
- 'models.md': () => `${commonHeader('Models')}# Models\n\n<!-- INSTRUCTION: Document Eloquent Models found in /app/Models -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
343
- 'routes.md': () => `${commonHeader('Routes')}# Routes\n\n<!-- INSTRUCTION: Document application routes found in /routes -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
372
+ 'controllers.md': () => `${commonHeader('Controllers')}# Contrôleurs\n\n<!-- INSTRUCTION: Documentez les contrôleurs Http trouvés dans /app/Http/Controllers -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
373
+ 'models.md': () => `${commonHeader('Models')}# Modèles\n\n<!-- INSTRUCTION: Documentez les modèles Eloquent trouvés dans /app/Models -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
374
+ 'routes.md': () => `${commonHeader('Routes')}# Routes\n\n<!-- INSTRUCTION: Documentez les routes trouvées dans /routes -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
344
375
  }
345
376
  };
346
377
  }
@@ -349,9 +380,9 @@ function getStackConfig(stack) {
349
380
  if (stack.includes('Nuxt')) {
350
381
  return {
351
382
  files: {
352
- 'components.md': () => `${commonHeader('Components')}# Components\n\n<!-- INSTRUCTION: Document Vue components in /components -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
353
- 'composables.md': () => `${commonHeader('Composables')}# Composables\n\n<!-- INSTRUCTION: Document auto-imported composables in /composables -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
354
- 'server-routes.md': () => `${commonHeader('Server Routes')}# Server Routes\n\n<!-- INSTRUCTION: Document Nitro server routes in /server/api -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
383
+ 'components.md': () => `${commonHeader('Components')}# Composants\n\n<!-- INSTRUCTION: Documentez les composants Vue dans /components -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
384
+ 'composables.md': () => `${commonHeader('Composables')}# Composables\n\n<!-- INSTRUCTION: Documentez les composables auto-importés dans /composables -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
385
+ 'server-routes.md': () => `${commonHeader('Server Routes')}# Routes Serveur\n\n<!-- INSTRUCTION: Documentez les routes serveur Nitro dans /server/api -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
355
386
  }
356
387
  };
357
388
  }
@@ -360,9 +391,9 @@ function getStackConfig(stack) {
360
391
  if (stack.includes('React') || stack.includes('Next') || stack.includes('Vue') || stack.includes('Angular') || stack.includes('Svelte')) {
361
392
  return {
362
393
  files: {
363
- 'components.md': () => `${commonHeader('Components')}# Components\n\n<!-- INSTRUCTION: Document UI components -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
364
- 'hooks.md': () => `${commonHeader('Hooks')}# Hooks\n\n<!-- INSTRUCTION: Document custom hooks/composables -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
365
- 'api.md': () => `${commonHeader('API')}# API Integration\n\n<!-- INSTRUCTION: Document API clients or fetch wrappers -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
394
+ 'components.md': () => `${commonHeader('Components')}# Composants\n\n<!-- INSTRUCTION: Documentez les composants UI -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
395
+ 'hooks.md': () => `${commonHeader('Hooks')}# Hooks\n\n<!-- INSTRUCTION: Documentez les hooks personnalisés -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
396
+ 'api.md': () => `${commonHeader('API')}# Intégration API\n\n<!-- INSTRUCTION: Documentez les clients API -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
366
397
  }
367
398
  };
368
399
  }
@@ -371,9 +402,9 @@ function getStackConfig(stack) {
371
402
  if (stack.includes('Django')) {
372
403
  return {
373
404
  files: {
374
- 'models.md': () => `${commonHeader('Models')}# Models\n\n<!-- INSTRUCTION: Document Django Models -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
375
- 'views.md': () => `${commonHeader('Views')}# Views\n\n<!-- INSTRUCTION: Document Django Views/ViewSets -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
376
- 'admin.md': () => `${commonHeader('Admin')}# Admin Customization\n\n<!-- INSTRUCTION: Document Admin classes -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
405
+ 'models.md': () => `${commonHeader('Models')}# Modèles\n\n<!-- INSTRUCTION: Documentez les modèles Django -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
406
+ 'views.md': () => `${commonHeader('Views')}# Vues\n\n<!-- INSTRUCTION: Documentez les Vues/ViewSets Django -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
407
+ 'admin.md': () => `${commonHeader('Admin')}# Administration\n\n<!-- INSTRUCTION: Documentez les classes d'administration -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
377
408
  }
378
409
  };
379
410
  }
@@ -382,8 +413,8 @@ function getStackConfig(stack) {
382
413
  if (stack.includes('FastAPI')) {
383
414
  return {
384
415
  files: {
385
- 'endpoints.md': () => `${commonHeader('Endpoints')}# Endpoints\n\n<!-- INSTRUCTION: Document FastAPI routes and decorators -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
386
- 'models.md': () => `${commonHeader('Models')}# Pydantic Models\n\n<!-- INSTRUCTION: Document Pydantic models -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
416
+ 'endpoints.md': () => `${commonHeader('Endpoints')}# Endpoints\n\n<!-- INSTRUCTION: Documentez les routes et décorateurs FastAPI -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
417
+ 'models.md': () => `${commonHeader('Models')}# Modèles Pydantic\n\n<!-- INSTRUCTION: Documentez les modèles Pydantic -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
387
418
  }
388
419
  };
389
420
  }
@@ -392,9 +423,9 @@ function getStackConfig(stack) {
392
423
  if (stack.includes('Spring') || stack.includes('Java')) {
393
424
  return {
394
425
  files: {
395
- 'controllers.md': () => `${commonHeader('Controllers')}# Controllers\n\n<!-- INSTRUCTION: Document REST Controllers -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
396
- 'services.md': () => `${commonHeader('Services')}# Services\n\n<!-- INSTRUCTION: Document Service beans -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
397
- 'domain.md': () => `${commonHeader('Domain')}# Domain Models\n\n<!-- INSTRUCTION: Document Entity classes -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
426
+ 'controllers.md': () => `${commonHeader('Controllers')}# Contrôleurs\n\n<!-- INSTRUCTION: Documentez les contrôleurs REST -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
427
+ 'services.md': () => `${commonHeader('Services')}# Services\n\n<!-- INSTRUCTION: Documentez les beans Service -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
428
+ 'domain.md': () => `${commonHeader('Domain')}# Modèles de Domaine\n\n<!-- INSTRUCTION: Documentez les classes d'Entité -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
398
429
  }
399
430
  };
400
431
  }
@@ -402,8 +433,8 @@ function getStackConfig(stack) {
402
433
  // --- Default Fallback ---
403
434
  return {
404
435
  files: {
405
- 'api.md': () => `${commonHeader('API')}# API Reference\n\n<!-- INSTRUCTION: Document public API endpoints -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
406
- 'modules.md': () => `${commonHeader('Modules')}# Core Modules\n\n<!-- INSTRUCTION: Document core logical modules -->\n\n## List\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
436
+ 'api.md': () => `${commonHeader('API')}# Référence API\n\n<!-- INSTRUCTION: Documentez les endpoints API publics -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
437
+ 'modules.md': () => `${commonHeader('Modules')}# Modules principaux\n\n<!-- INSTRUCTION: Documentez les modules logiques principaux -->\n\n## Liste\n<!-- AI_CONTENT_START -->\n<!-- AI_CONTENT_END -->`,
407
438
  }
408
439
  };
409
440
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scaffold-doc-cli",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "CLI tool to scaffold standardized documentation structure for projects.",
5
5
  "main": "index.js",
6
6
  "type": "module",