@knowcode/doc-builder 1.2.0 → 1.2.2

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,37 @@ 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.2] - 2025-07-19
9
+
10
+ ### Fixed
11
+ - Removed accidentally included temp-test directory from npm package
12
+ - Added .npmignore file to prevent test directories from being published
13
+
14
+ ## [1.2.1] - 2025-07-19
15
+
16
+ ### Added
17
+ - **Auto-generated README.md** - System now automatically creates a helpful placeholder README.md when missing
18
+ - Comprehensive placeholder content with getting started guide and documentation standards
19
+ - Clear instructions for users on how to customize their documentation
20
+ - Built-in Mermaid diagram example in generated README
21
+ - Documentation structure recommendations and best practices
22
+
23
+ ### Fixed
24
+ - **Eliminated ugly file listing** on index page when no README exists
25
+ - Improved first-time user experience with welcoming placeholder content
26
+ - Better guidance for documentation creation and organization
27
+
28
+ ### Changed
29
+ - Simplified deployment logic - removed complex HTML file listing generation
30
+ - Build process now checks and creates README.md before scanning files
31
+ - Deploy process simplified since README.html will always exist
32
+
33
+ ### Technical Improvements
34
+ - Added `createPlaceholderReadme()` function to core-builder.js
35
+ - Integrated README generation into main build workflow
36
+ - Enhanced build logging to show when placeholder is generated
37
+ - Exported new function for potential external usage
38
+
8
39
  ## [1.2.0] - 2025-07-19
9
40
 
10
41
  ### Added (MAJOR FEATURE RELEASE)
@@ -448,9 +448,13 @@ async function buildDocumentation(config) {
448
448
  const docsDir = path.join(process.cwd(), config.docsDir);
449
449
  const outputDir = path.join(process.cwd(), config.outputDir);
450
450
 
451
+ // Check and create placeholder README.md if missing
452
+ console.log(chalk.blue('📋 Checking documentation structure...'));
453
+ const readmeGenerated = await createPlaceholderReadme(docsDir, config);
454
+
451
455
  console.log(chalk.blue('📄 Scanning for markdown files...'));
452
456
  const files = await getAllMarkdownFiles(docsDir);
453
- console.log(chalk.green(`✅ Found ${files.length} markdown files`));
457
+ console.log(chalk.green(`✅ Found ${files.length} markdown files${readmeGenerated ? ' (including auto-generated README)' : ''}`));
454
458
 
455
459
  console.log(chalk.blue('📝 Processing files...'));
456
460
  for (const file of files) {
@@ -489,6 +493,99 @@ async function buildDocumentation(config) {
489
493
  console.log(chalk.green('✅ Documentation build complete!'));
490
494
  }
491
495
 
496
+ // Create placeholder README.md if missing
497
+ async function createPlaceholderReadme(docsDir, config) {
498
+ const readmePath = path.join(docsDir, 'README.md');
499
+
500
+ // Check if README.md already exists
501
+ if (fs.existsSync(readmePath)) {
502
+ return false; // README already exists, no need to create
503
+ }
504
+
505
+ const siteName = config.siteName || 'Documentation';
506
+ const currentDate = new Date().toISOString().split('T')[0];
507
+
508
+ const placeholderContent = `# Welcome to ${siteName}
509
+
510
+ **Generated**: ${currentDate} UTC
511
+ **Status**: Placeholder - Ready for customization
512
+ **Verified**: ❓ (Auto-generated content)
513
+
514
+ ## Overview
515
+
516
+ This documentation site was built with @knowcode/doc-builder. This is an auto-generated placeholder to help you get started.
517
+
518
+ ## Getting Started
519
+
520
+ 1. **Replace this file**: Edit \`docs/README.md\` with your project's actual documentation
521
+ 2. **Add content**: Create additional markdown files in the \`docs/\` directory
522
+ 3. **Organize with folders**: Use subfolders to structure your documentation
523
+ 4. **Rebuild**: Run \`npx @knowcode/doc-builder build\` to regenerate the site
524
+
525
+ ## Documentation Structure
526
+
527
+ Your documentation can include:
528
+
529
+ - **Overview**: Main project description (this file)
530
+ - **Guides**: Step-by-step tutorials
531
+ - **API Reference**: Technical documentation
532
+ - **Examples**: Code samples and usage
533
+ - **Architecture**: System design and technical details
534
+
535
+ ## Next Steps
536
+
537
+ 1. Edit this README.md file with your project information
538
+ 2. Create additional markdown files for your content
539
+ 3. Organize files into logical folders
540
+ 4. Use Mermaid diagrams for visual explanations
541
+ 5. Deploy with \`npx @knowcode/doc-builder deploy\`
542
+
543
+ ## Documentation Standards
544
+
545
+ This project follows structured documentation conventions:
546
+
547
+ ### File Organization
548
+ - Use descriptive filenames with hyphens (e.g., \`user-guide.md\`)
549
+ - Organize related content in folders
550
+ - Include a README.md in each major folder
551
+
552
+ ### Content Format
553
+ - Start each document with metadata (Generated date, Status, Verified status)
554
+ - Use clear headings and consistent structure
555
+ - Include diagrams where helpful to explain concepts
556
+ - Mark information as verified (✅) or speculated (❓)
557
+
558
+ ### Mermaid Diagrams
559
+ Include visual diagrams to explain complex concepts:
560
+
561
+ \`\`\`mermaid
562
+ graph TD
563
+ A[Start Documentation] --> B{Have Content?}
564
+ B -->|Yes| C[Edit README.md]
565
+ B -->|No| D[Create Content Files]
566
+ C --> E[Build & Deploy]
567
+ D --> E
568
+ E --> F[Share Documentation]
569
+ \`\`\`
570
+
571
+ ## Support
572
+
573
+ For help with @knowcode/doc-builder:
574
+ - Check the documentation at your package source
575
+ - Use \`npx @knowcode/doc-builder --help\` for CLI options
576
+ - Review the generated configuration guide if available
577
+ `;
578
+
579
+ try {
580
+ await fs.writeFile(readmePath, placeholderContent);
581
+ console.log(chalk.yellow('📄 Auto-generated placeholder README.md - please customize it!'));
582
+ return true; // Successfully created placeholder
583
+ } catch (error) {
584
+ console.warn(chalk.yellow(`Warning: Could not create placeholder README.md: ${error.message}`));
585
+ return false;
586
+ }
587
+ }
588
+
492
589
  // Create login/logout pages
493
590
  async function createAuthPages(outputDir, config) {
494
591
  // Login page
@@ -570,5 +667,6 @@ async function createAuthPages(outputDir, config) {
570
667
  module.exports = {
571
668
  buildDocumentation,
572
669
  processMarkdownContent,
573
- generateHTML
670
+ generateHTML,
671
+ createPlaceholderReadme
574
672
  };
package/lib/deploy.js CHANGED
@@ -365,72 +365,29 @@ async function prepareDeployment(config) {
365
365
  fs.writeFileSync(indexPath, redirectHtml);
366
366
  console.log(chalk.green('✅ Created index.html redirect to README.html'));
367
367
  } else {
368
- // If no README.html, create a basic index listing all HTML files
369
- const htmlFiles = fs.readdirSync(outputDir)
370
- .filter(file => file.endsWith('.html') && file !== 'index.html')
371
- .sort();
372
-
373
- if (htmlFiles.length > 0) {
374
- const indexHtml = `<!DOCTYPE html>
368
+ // If no README.html, create a simple redirect to home
369
+ // This should rarely happen since build process now auto-generates README.md
370
+ const simpleIndex = `<!DOCTYPE html>
375
371
  <html>
376
372
  <head>
377
373
  <meta charset="UTF-8">
378
374
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
379
- <title>Documentation</title>
380
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
375
+ <meta http-equiv="refresh" content="0; url=./">
376
+ <title>${config.siteName || 'Documentation'}</title>
381
377
  <link rel="stylesheet" href="/css/style.css">
382
378
  <link rel="stylesheet" href="/css/notion-style.css">
383
379
  </head>
384
380
  <body>
385
- <div class="navigation">
386
- <div class="nav-header">
387
- <h2>${config.siteName || 'Documentation'}</h2>
388
- </div>
389
- <nav>
390
- <ul>
391
- ${htmlFiles.map(file => {
392
- const name = file.replace('.html', '').replace(/-/g, ' ');
393
- const capitalizedName = name.split(' ').map(word =>
394
- word.charAt(0).toUpperCase() + word.slice(1)
395
- ).join(' ');
396
- return `<li><a href="${file}"><i class="fas fa-file"></i> ${capitalizedName}</a></li>`;
397
- }).join('\n ')}
398
- </ul>
399
- </nav>
400
- </div>
401
- <div class="content">
402
- <div class="header">
403
- <h1 style="text-align: center; margin: 50px 0;">📚 Documentation</h1>
404
- </div>
405
- <div class="main-content">
406
- <div class="doc-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; padding: 20px;">
407
- ${htmlFiles.map(file => {
408
- const name = file.replace('.html', '').replace(/-/g, ' ');
409
- const capitalizedName = name.split(' ').map(word =>
410
- word.charAt(0).toUpperCase() + word.slice(1)
411
- ).join(' ');
412
- return `
413
- <a href="${file}" class="doc-card" style="display: block; padding: 20px; border: 1px solid #e1e4e8; border-radius: 8px; text-decoration: none; color: inherit; transition: all 0.2s;">
414
- <h3 style="margin: 0 0 10px 0; color: #0366d6;"><i class="fas fa-file-alt"></i> ${capitalizedName}</h3>
415
- <p style="margin: 0; color: #586069; font-size: 14px;">Click to view this documentation</p>
416
- </a>`;
417
- }).join('')}
418
- </div>
419
- </div>
381
+ <div style="text-align: center; margin-top: 50px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
382
+ <h1>📚 ${config.siteName || 'Documentation'}</h1>
383
+ <p>Loading documentation...</p>
384
+ <p><a href="./" style="color: #0366d6;">Click here if not redirected automatically</a></p>
420
385
  </div>
421
- <script src="/js/main.js"></script>
422
- <style>
423
- .doc-card:hover {
424
- box-shadow: 0 4px 12px rgba(0,0,0,0.1);
425
- transform: translateY(-2px);
426
- }
427
- </style>
428
386
  </body>
429
387
  </html>`;
430
- fs.writeFileSync(indexPath, indexHtml);
431
- console.log(chalk.green('✅ Created index.html with file listing'));
432
- console.log(chalk.yellow('📌 Remember to rebuild before deploying to see styling!'));
433
- }
388
+ fs.writeFileSync(indexPath, simpleIndex);
389
+ console.log(chalk.green('✅ Created index.html redirect'));
390
+ console.log(chalk.yellow('📌 Note: Consider running build to ensure README.md exists'));
434
391
  }
435
392
  }
436
393
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {