botdocs 0.1.0 → 0.1.1

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.
@@ -1,8 +1,7 @@
1
1
  import { defaultConfig } from '../types/config.js';
2
2
  import { SiteGenerator } from './site-generator.js';
3
3
  import { VectorDBBuilder } from './vector-db-builder.js';
4
- import { existsSync, readFileSync, writeFileSync, copyFileSync } from 'fs';
5
- import fs from 'fs-extra';
4
+ import { existsSync, readFileSync, writeFileSync, copyFileSync, mkdirSync, cpSync } from 'fs';
6
5
  import { join, dirname, resolve } from 'path';
7
6
  import { fileURLToPath } from 'url';
8
7
  import { exec } from 'child_process';
@@ -30,7 +29,7 @@ export async function build(options) {
30
29
  console.log('Configuration:', JSON.stringify(config, null, 2));
31
30
  }
32
31
  // Prepare output directory
33
- fs.ensureDirSync(outputDir);
32
+ mkdirSync(outputDir, { recursive: true });
34
33
  if (verbose) {
35
34
  console.log(`Cleaning output directory: ${outputDir}`);
36
35
  }
@@ -40,8 +39,8 @@ export async function build(options) {
40
39
  const documents = await generator.generate(inputDir, outputDir, config);
41
40
  // Create assets directories
42
41
  const assetsDir = join(outputDir, 'assets');
43
- fs.ensureDirSync(join(assetsDir, 'css'));
44
- fs.ensureDirSync(join(assetsDir, 'js'));
42
+ mkdirSync(join(assetsDir, 'css'), { recursive: true });
43
+ mkdirSync(join(assetsDir, 'js'), { recursive: true });
45
44
  if (verbose) {
46
45
  console.log(`Processed ${documents.length} documents`);
47
46
  }
@@ -85,7 +84,7 @@ export async function build(options) {
85
84
  const distAssetsDir = join(distClientDir, 'assets');
86
85
  if (existsSync(distAssetsDir)) {
87
86
  const outputAssetsDir = join(jsOutputDir, 'assets');
88
- fs.copySync(distAssetsDir, outputAssetsDir);
87
+ cpSync(distAssetsDir, outputAssetsDir, { recursive: true });
89
88
  if (verbose) {
90
89
  console.log('Copied code-split chunks');
91
90
  }
@@ -1,6 +1,4 @@
1
- import { glob } from 'glob';
2
- import { readFileSync, writeFileSync } from 'fs';
3
- import fs from 'fs-extra';
1
+ import { readFileSync, writeFileSync, readdirSync, mkdirSync, cpSync } from 'fs';
4
2
  import { join, dirname, resolve } from 'path';
5
3
  import { MarkdownProcessor } from './markdown-processor.js';
6
4
  import { TemplateEngine } from './template-engine.js';
@@ -20,12 +18,16 @@ export class SiteGenerator {
20
18
  */
21
19
  async generate(inputDir, outputDir, config) {
22
20
  console.log('Processing markdown files...');
23
- // Find all markdown files
24
- const markdownFiles = await glob('**/*.md', {
25
- cwd: inputDir,
26
- absolute: true,
27
- ignore: ['node_modules/**', '**/node_modules/**'],
21
+ // Find all markdown files using native Node.js readdir
22
+ const allFiles = readdirSync(inputDir, {
23
+ recursive: true,
24
+ withFileTypes: true
28
25
  });
26
+ const markdownFiles = allFiles
27
+ .filter(dirent => dirent.isFile() &&
28
+ dirent.name.endsWith('.md') &&
29
+ !dirent.parentPath.includes('node_modules'))
30
+ .map(dirent => join(dirent.parentPath || dirent.path, dirent.name));
29
31
  if (markdownFiles.length === 0) {
30
32
  throw new Error(`No markdown files found in ${inputDir}`);
31
33
  }
@@ -93,7 +95,7 @@ export class SiteGenerator {
93
95
  });
94
96
  // Write HTML file
95
97
  const outputPath = join(outputDir, doc.relativePath.replace(/\.md$/, '.html'));
96
- fs.ensureDirSync(dirname(outputPath));
98
+ mkdirSync(dirname(outputPath), { recursive: true });
97
99
  writeFileSync(outputPath, html, 'utf-8');
98
100
  }
99
101
  // Copy index.html if README.md exists
@@ -102,7 +104,7 @@ export class SiteGenerator {
102
104
  const readmePath = join(outputDir, readmeDoc.relativePath.replace(/\.md$/, '.html'));
103
105
  const indexPath = join(outputDir, 'index.html');
104
106
  if (readmePath !== indexPath) {
105
- fs.copySync(readmePath, indexPath);
107
+ cpSync(readmePath, indexPath);
106
108
  }
107
109
  }
108
110
  console.log(`Generated ${this.documents.length} HTML pages`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botdocs",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "An npm CLI tool that converts markdown documentation into a static website with an optional client-side AI chatbot",
5
5
  "author": "usr-wwelsh <https://wwel.sh>",
6
6
  "license": "MIT",
@@ -38,8 +38,6 @@
38
38
  "@shikijs/markdown-it": "^1.0.0",
39
39
  "@xenova/transformers": "^2.17.0",
40
40
  "commander": "^12.0.0",
41
- "fs-extra": "^11.2.0",
42
- "glob": "^11.0.0",
43
41
  "gray-matter": "^4.0.3",
44
42
  "markdown-it": "^14.0.0",
45
43
  "markdown-it-anchor": "^9.0.0",
@@ -53,8 +51,7 @@
53
51
  "shiki": "^1.0.0"
54
52
  },
55
53
  "devDependencies": {
56
- "@types/fs-extra": "^11.0.4",
57
- "@types/markdown-it": "^13.0.0",
54
+ "@types/markdown-it": "^14.0.0",
58
55
  "@types/node": "^20.11.0",
59
56
  "terser": "^5.36.0",
60
57
  "typescript": "^5.3.0",