@knowcode/doc-builder 1.2.8 → 1.2.9
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 +15 -0
- package/lib/core-builder.js +64 -8
- package/lib/deploy.js +56 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ 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.9] - 2025-07-19
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Comprehensive console logging for debugging index.html creation
|
|
12
|
+
- Detailed file existence checks with paths and sizes
|
|
13
|
+
- File copy verification with size comparison
|
|
14
|
+
- List of HTML files found during build and deployment
|
|
15
|
+
- Error handling with detailed error messages
|
|
16
|
+
- Final verification step to confirm index.html exists
|
|
17
|
+
|
|
18
|
+
### Improved
|
|
19
|
+
- Much more verbose output to help diagnose deployment issues
|
|
20
|
+
- Clear indication of what files are being processed
|
|
21
|
+
- Better error reporting when file operations fail
|
|
22
|
+
|
|
8
23
|
## [1.2.8] - 2025-07-19
|
|
9
24
|
|
|
10
25
|
### Changed
|
package/lib/core-builder.js
CHANGED
|
@@ -460,6 +460,14 @@ async function buildDocumentation(config) {
|
|
|
460
460
|
const files = await getAllMarkdownFiles(docsDir);
|
|
461
461
|
console.log(chalk.green(`✅ Found ${files.length} markdown files${readmeGenerated ? ' (including auto-generated README)' : ''}`));
|
|
462
462
|
|
|
463
|
+
// Log the files found
|
|
464
|
+
if (files.length > 0) {
|
|
465
|
+
console.log(chalk.gray(' Found files:'));
|
|
466
|
+
files.forEach(file => {
|
|
467
|
+
console.log(chalk.gray(` - ${file.relativePath} → ${file.urlPath}`));
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
|
|
463
471
|
console.log(chalk.blue('📝 Processing files...'));
|
|
464
472
|
for (const file of files) {
|
|
465
473
|
const outputPath = path.join(outputDir, file.urlPath);
|
|
@@ -499,23 +507,71 @@ async function buildDocumentation(config) {
|
|
|
499
507
|
const indexSourcePath = path.join(outputDir, 'index.html'); // from index.md
|
|
500
508
|
const readmePath = path.join(outputDir, 'README.html');
|
|
501
509
|
|
|
502
|
-
console.log(chalk.blue('📄 Checking for index.html creation...'));
|
|
503
|
-
console.log(chalk.gray(` -
|
|
504
|
-
console.log(chalk.gray(` -
|
|
510
|
+
console.log(chalk.blue('\n📄 Checking for index.html creation...'));
|
|
511
|
+
console.log(chalk.gray(` - Output directory: ${outputDir}`));
|
|
512
|
+
console.log(chalk.gray(` - Index path: ${indexPath}`));
|
|
513
|
+
console.log(chalk.gray(` - README path: ${readmePath}`));
|
|
514
|
+
console.log(chalk.gray(` - index.html exists: ${fs.existsSync(indexPath)}`));
|
|
515
|
+
console.log(chalk.gray(` - README.html exists: ${fs.existsSync(readmePath)}`));
|
|
516
|
+
|
|
517
|
+
// List all HTML files in output directory
|
|
518
|
+
if (fs.existsSync(outputDir)) {
|
|
519
|
+
const htmlFiles = fs.readdirSync(outputDir).filter(f => f.endsWith('.html'));
|
|
520
|
+
console.log(chalk.gray(` - HTML files in output: [${htmlFiles.join(', ')}]`));
|
|
521
|
+
} else {
|
|
522
|
+
console.log(chalk.red(` - ERROR: Output directory does not exist!`));
|
|
523
|
+
}
|
|
505
524
|
|
|
506
525
|
if (!fs.existsSync(indexPath)) {
|
|
526
|
+
console.log(chalk.yellow('⚠️ index.html does not exist, need to create it'));
|
|
527
|
+
|
|
507
528
|
if (fs.existsSync(readmePath)) {
|
|
508
|
-
|
|
509
|
-
|
|
529
|
+
console.log(chalk.blue(' → Found README.html, copying to index.html'));
|
|
530
|
+
try {
|
|
531
|
+
await fs.copy(readmePath, indexPath);
|
|
532
|
+
console.log(chalk.green('✅ Successfully created index.html from README.html'));
|
|
533
|
+
|
|
534
|
+
// Verify the copy worked
|
|
535
|
+
if (fs.existsSync(indexPath)) {
|
|
536
|
+
const stats = fs.statSync(indexPath);
|
|
537
|
+
console.log(chalk.gray(` - index.html size: ${stats.size} bytes`));
|
|
538
|
+
} else {
|
|
539
|
+
console.log(chalk.red(' - ERROR: index.html was not created!'));
|
|
540
|
+
}
|
|
541
|
+
} catch (error) {
|
|
542
|
+
console.log(chalk.red(` - ERROR copying README.html: ${error.message}`));
|
|
543
|
+
}
|
|
510
544
|
} else {
|
|
511
545
|
// No README.html, create informative default page
|
|
512
546
|
console.log(chalk.yellow('⚠️ No README.html found, creating default index.html'));
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
547
|
+
try {
|
|
548
|
+
const defaultIndex = await createDefaultIndexPage(outputDir, config, packageJson.version);
|
|
549
|
+
await fs.writeFile(indexPath, defaultIndex);
|
|
550
|
+
console.log(chalk.green('✅ Created default index.html with instructions'));
|
|
551
|
+
|
|
552
|
+
// Verify the write worked
|
|
553
|
+
if (fs.existsSync(indexPath)) {
|
|
554
|
+
const stats = fs.statSync(indexPath);
|
|
555
|
+
console.log(chalk.gray(` - index.html size: ${stats.size} bytes`));
|
|
556
|
+
} else {
|
|
557
|
+
console.log(chalk.red(' - ERROR: default index.html was not created!'));
|
|
558
|
+
}
|
|
559
|
+
} catch (error) {
|
|
560
|
+
console.log(chalk.red(` - ERROR creating default index.html: ${error.message}`));
|
|
561
|
+
}
|
|
516
562
|
}
|
|
517
563
|
} else {
|
|
518
564
|
console.log(chalk.gray('ℹ️ index.html already exists (likely from index.md)'));
|
|
565
|
+
const stats = fs.statSync(indexPath);
|
|
566
|
+
console.log(chalk.gray(` - Existing index.html size: ${stats.size} bytes`));
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// Final verification
|
|
570
|
+
console.log(chalk.blue('\n📋 Final index.html check:'));
|
|
571
|
+
if (fs.existsSync(indexPath)) {
|
|
572
|
+
console.log(chalk.green(` ✅ index.html exists at: ${indexPath}`));
|
|
573
|
+
} else {
|
|
574
|
+
console.log(chalk.red(` ❌ index.html is MISSING at: ${indexPath}`));
|
|
519
575
|
}
|
|
520
576
|
|
|
521
577
|
console.log(chalk.green('✅ Documentation build complete!'));
|
package/lib/deploy.js
CHANGED
|
@@ -346,17 +346,54 @@ async function prepareDeployment(config) {
|
|
|
346
346
|
console.log(chalk.blue(`\n📦 Preparing deployment with @knowcode/doc-builder v${packageJson.version}`));
|
|
347
347
|
|
|
348
348
|
// Create index.html from README.html if needed
|
|
349
|
+
console.log(chalk.blue('\n📁 Deployment preparation - index.html check:'));
|
|
349
350
|
const indexPath = path.join(outputDir, 'index.html');
|
|
350
|
-
|
|
351
|
+
const readmePath = path.join(outputDir, 'README.html');
|
|
352
|
+
|
|
353
|
+
console.log(chalk.gray(` - Output directory: ${outputDir}`));
|
|
354
|
+
console.log(chalk.gray(` - Output dir exists: ${fs.existsSync(outputDir)}`));
|
|
355
|
+
|
|
356
|
+
if (fs.existsSync(outputDir)) {
|
|
357
|
+
const files = fs.readdirSync(outputDir);
|
|
358
|
+
const htmlFiles = files.filter(f => f.endsWith('.html'));
|
|
359
|
+
console.log(chalk.gray(` - Total files: ${files.length}`));
|
|
360
|
+
console.log(chalk.gray(` - HTML files: [${htmlFiles.slice(0, 5).join(', ')}${htmlFiles.length > 5 ? '...' : ''}]`));
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
console.log(chalk.gray(` - Checking index.html: ${fs.existsSync(indexPath) ? 'exists' : 'missing'}`));
|
|
364
|
+
console.log(chalk.gray(` - Index path: ${indexPath}`));
|
|
351
365
|
|
|
352
366
|
if (!fs.existsSync(indexPath)) {
|
|
353
|
-
|
|
354
|
-
console.log(chalk.gray(` - Checking README.html: ${fs.existsSync(readmePath) ? 'exists' : 'missing'}
|
|
367
|
+
console.log(chalk.yellow(' ⚠️ index.html is missing, attempting to create...'));
|
|
368
|
+
console.log(chalk.gray(` - Checking README.html: ${fs.existsSync(readmePath) ? 'exists' : 'missing'}`));
|
|
369
|
+
console.log(chalk.gray(` - README path: ${readmePath}`));
|
|
355
370
|
|
|
356
371
|
if (fs.existsSync(readmePath)) {
|
|
357
372
|
// Copy README.html to index.html for proper root page
|
|
358
|
-
|
|
359
|
-
|
|
373
|
+
console.log(chalk.blue(' → Copying README.html to index.html...'));
|
|
374
|
+
try {
|
|
375
|
+
fs.copyFileSync(readmePath, indexPath);
|
|
376
|
+
console.log(chalk.green(' ✅ Successfully copied README.html to index.html'));
|
|
377
|
+
|
|
378
|
+
// Verify the copy
|
|
379
|
+
if (fs.existsSync(indexPath)) {
|
|
380
|
+
const readmeStats = fs.statSync(readmePath);
|
|
381
|
+
const indexStats = fs.statSync(indexPath);
|
|
382
|
+
console.log(chalk.gray(` - README.html size: ${readmeStats.size} bytes`));
|
|
383
|
+
console.log(chalk.gray(` - index.html size: ${indexStats.size} bytes`));
|
|
384
|
+
|
|
385
|
+
if (readmeStats.size === indexStats.size) {
|
|
386
|
+
console.log(chalk.green(' ✅ File sizes match - copy successful'));
|
|
387
|
+
} else {
|
|
388
|
+
console.log(chalk.yellow(' ⚠️ File sizes do not match!'));
|
|
389
|
+
}
|
|
390
|
+
} else {
|
|
391
|
+
console.log(chalk.red(' ❌ ERROR: index.html was not created after copy!'));
|
|
392
|
+
}
|
|
393
|
+
} catch (error) {
|
|
394
|
+
console.log(chalk.red(` ❌ ERROR copying file: ${error.message}`));
|
|
395
|
+
console.log(chalk.red(` - Error stack: ${error.stack}`));
|
|
396
|
+
}
|
|
360
397
|
} else {
|
|
361
398
|
// If no README.html, find first available HTML file or create informative page
|
|
362
399
|
console.log(chalk.yellow('⚠️ No README.html found, looking for other HTML files...'));
|
|
@@ -408,11 +445,24 @@ async function prepareDeployment(config) {
|
|
|
408
445
|
|
|
409
446
|
// Final check - log what files exist
|
|
410
447
|
console.log(chalk.blue('\n📁 Final deployment state:'));
|
|
448
|
+
|
|
449
|
+
// Double-check index.html one more time
|
|
450
|
+
const finalIndexExists = fs.existsSync(indexPath);
|
|
451
|
+
console.log(chalk[finalIndexExists ? 'green' : 'red'](` - index.html: ${finalIndexExists ? 'EXISTS' : 'MISSING'}`));
|
|
452
|
+
|
|
453
|
+
if (finalIndexExists) {
|
|
454
|
+
const stats = fs.statSync(indexPath);
|
|
455
|
+
console.log(chalk.gray(` - index.html size: ${stats.size} bytes`));
|
|
456
|
+
console.log(chalk.gray(` - index.html modified: ${stats.mtime.toISOString()}`));
|
|
457
|
+
}
|
|
458
|
+
|
|
411
459
|
const finalFiles = fs.readdirSync(outputDir)
|
|
412
460
|
.filter(file => file.endsWith('.html'))
|
|
413
461
|
.slice(0, 5); // Show first 5 HTML files
|
|
462
|
+
console.log(chalk.gray(`\n HTML files in ${outputDir}:`));
|
|
414
463
|
finalFiles.forEach(file => {
|
|
415
|
-
|
|
464
|
+
const size = fs.statSync(path.join(outputDir, file)).size;
|
|
465
|
+
console.log(chalk.gray(` - ${file} (${size} bytes)`));
|
|
416
466
|
});
|
|
417
467
|
if (fs.readdirSync(outputDir).filter(f => f.endsWith('.html')).length > 5) {
|
|
418
468
|
console.log(chalk.gray(` - ... and ${fs.readdirSync(outputDir).filter(f => f.endsWith('.html')).length - 5} more HTML files`));
|