@knowcode/doc-builder 1.2.9 → 1.2.10

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/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to @knowcode/doc-builder will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.2.10] - 2025-07-19
9
+
10
+ ### Fixed
11
+ - **Critical fix**: Now properly replaces old directory listing index.html files
12
+ - Detects and replaces index.html if it's under 3KB (likely a directory listing)
13
+ - Detects and replaces index.html if it doesn't contain doc-builder markers
14
+ - Fixes the issue where gasworld.vercel.app showed a directory listing instead of documentation
15
+
16
+ ### Added
17
+ - Smart detection of outdated or non-doc-builder index.html files
18
+ - Automatic replacement of directory listing pages with proper documentation
19
+ - Clear logging when replacing an existing index.html file
20
+
8
21
  ## [1.2.9] - 2025-07-19
9
22
 
10
23
  ### Added
@@ -522,9 +522,28 @@ async function buildDocumentation(config) {
522
522
  console.log(chalk.red(` - ERROR: Output directory does not exist!`));
523
523
  }
524
524
 
525
+ // Check if we need to create/replace index.html
526
+ let shouldCreateIndex = false;
527
+
525
528
  if (!fs.existsSync(indexPath)) {
526
529
  console.log(chalk.yellow('⚠️ index.html does not exist, need to create it'));
527
-
530
+ shouldCreateIndex = true;
531
+ } else {
532
+ // Check if existing index.html is likely a directory listing or outdated
533
+ const indexStats = fs.statSync(indexPath);
534
+ const indexContent = fs.readFileSync(indexPath, 'utf8');
535
+
536
+ // Check if it's a small file (likely directory listing) or contains directory listing markers
537
+ if (indexStats.size < 3000 || indexContent.includes('<title>Documentation</title>') && indexContent.includes('<ul>') && !indexContent.includes('class="navigation"')) {
538
+ console.log(chalk.yellow('⚠️ Existing index.html appears to be a directory listing (size: ' + indexStats.size + ' bytes), will replace it'));
539
+ shouldCreateIndex = true;
540
+ } else if (!indexContent.includes('@knowcode/doc-builder')) {
541
+ console.log(chalk.yellow('⚠️ Existing index.html was not created by doc-builder, will replace it'));
542
+ shouldCreateIndex = true;
543
+ }
544
+ }
545
+
546
+ if (shouldCreateIndex) {
528
547
  if (fs.existsSync(readmePath)) {
529
548
  console.log(chalk.blue(' → Found README.html, copying to index.html'));
530
549
  try {
@@ -561,9 +580,10 @@ async function buildDocumentation(config) {
561
580
  }
562
581
  }
563
582
  } else {
564
- console.log(chalk.gray('ℹ️ index.html already exists (likely from index.md)'));
583
+ console.log(chalk.gray('ℹ️ index.html already exists and appears valid'));
565
584
  const stats = fs.statSync(indexPath);
566
585
  console.log(chalk.gray(` - Existing index.html size: ${stats.size} bytes`));
586
+ console.log(chalk.gray(` - Keeping existing index.html (likely from index.md or custom page)`));
567
587
  }
568
588
 
569
589
  // Final verification
package/lib/deploy.js CHANGED
@@ -363,8 +363,27 @@ async function prepareDeployment(config) {
363
363
  console.log(chalk.gray(` - Checking index.html: ${fs.existsSync(indexPath) ? 'exists' : 'missing'}`));
364
364
  console.log(chalk.gray(` - Index path: ${indexPath}`));
365
365
 
366
+ // Check if we need to create/replace index.html
367
+ let shouldCreateIndex = false;
368
+
366
369
  if (!fs.existsSync(indexPath)) {
367
370
  console.log(chalk.yellow(' ⚠️ index.html is missing, attempting to create...'));
371
+ shouldCreateIndex = true;
372
+ } else {
373
+ // Check if existing index.html needs replacement
374
+ const indexStats = fs.statSync(indexPath);
375
+ const indexContent = fs.readFileSync(indexPath, 'utf8');
376
+
377
+ if (indexStats.size < 3000 || (indexContent.includes('<title>Documentation</title>') && indexContent.includes('<ul>') && !indexContent.includes('class="navigation"'))) {
378
+ console.log(chalk.yellow(` ⚠️ Existing index.html appears to be a directory listing (${indexStats.size} bytes), will replace`));
379
+ shouldCreateIndex = true;
380
+ } else if (!indexContent.includes('@knowcode/doc-builder')) {
381
+ console.log(chalk.yellow(' ⚠️ Existing index.html was not created by doc-builder, will replace'));
382
+ shouldCreateIndex = true;
383
+ }
384
+ }
385
+
386
+ if (shouldCreateIndex) {
368
387
  console.log(chalk.gray(` - Checking README.html: ${fs.existsSync(readmePath) ? 'exists' : 'missing'}`));
369
388
  console.log(chalk.gray(` - README path: ${readmePath}`));
370
389
 
@@ -440,7 +459,9 @@ async function prepareDeployment(config) {
440
459
  }
441
460
  }
442
461
  } else {
443
- console.log(chalk.gray(' ✓ index.html already exists'));
462
+ console.log(chalk.gray(' ✓ index.html already exists and appears valid'));
463
+ const stats = fs.statSync(indexPath);
464
+ console.log(chalk.gray(` - Keeping existing index.html (${stats.size} bytes)`));
444
465
  }
445
466
 
446
467
  // Final check - log what files exist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.2.9",
3
+ "version": "1.2.10",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {