diff --git a/build.ts b/build.ts index 78cca37..76e68d2 100644 --- a/build.ts +++ b/build.ts @@ -2,7 +2,7 @@ import isolatedDecl from 'bun-plugin-isolated-decl'; // handles building the library await Bun.build({ - entrypoints: ['./src/index.ts'], + entrypoints: ['./src/*.ts'], outdir: './dist', target: 'node', plugins: [ diff --git a/bun.lockb b/bun.lockb index 1fc25a7..8704886 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 1599848..d8e8f02 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "code-tokenizer-md", - "version": "1.1.2", + "version": "1.1.6", "type": "module", "main": "src/index.ts", "module": "src/index.ts", @@ -13,15 +13,13 @@ } }, "bin": { - "code-tokenizer-md": "./dist/code-tokenizer-md" + "code-tokenizer-md": "./dist/cli.js" }, "files": [ "dist" ], - "types": "", "scripts": { - "build": "rm -rf dist && bun ./build.ts && bun build:cli", - "build:cli": "bun build ./src/cli.ts --compile --outfile dist/code-tokenizer-md", + "build": "rm -rf dist && bun build ./src/index.ts ./src/cli.ts --outdir dist --target node && bun ./build.ts", "test": "bun test", "prepublishOnly": "bun run build", "dev": "bun run .", @@ -32,6 +30,7 @@ "fix": "bun format && bun lint:fix" }, "dependencies": { + "glob": "^11.0.0", "llama3-tokenizer-js": "^1.0.0", "micromatch": "^4.0.8" }, diff --git a/src/MarkdownGenerator.ts b/src/MarkdownGenerator.ts index 941b9fc..f969839 100644 --- a/src/MarkdownGenerator.ts +++ b/src/MarkdownGenerator.ts @@ -1,5 +1,3 @@ -// MarkdownGenerator.ts - import path from 'path'; import { execSync } from 'child_process'; import { readFile, writeFile } from 'fs/promises'; @@ -9,7 +7,7 @@ import * as micromatch from 'micromatch'; import fileTypeExclusions from './fileTypeExclusions.js'; import fileExclusions from './fileExclusions.js'; import { readFileSync } from 'node:fs'; -import { Glob } from 'bun'; +import { glob } from 'glob'; interface MarkdownGeneratorOptions { @@ -72,37 +70,19 @@ export class MarkdownGenerator { * @returns {Promise} * @throws {Error} When unable to read ignore files */ - /** - * Loads and processes .code-tokenizer-md-ignore files using ignore-walk. - * These files contain patterns for files to exclude from processing. - * @async - * @returns {Promise} - * @throws {Error} When unable to read ignore files - */ - /** - * Quickly loads patterns from .code-tokenizer-md-ignore files using Bun's native Glob. - * @async - * @returns {Promise} - */ async loadNestedIgnoreFiles(): Promise { try { if (this.verbose) { console.log('Loading ignore patterns...'); } - const ignoreGlob = new Glob("**/.code-tokenizer-md-ignore"); - const ignoreFiles: string[] = []; - - // Use Bun's native glob to find ignore files - for await (const file of ignoreGlob.scan({ + const ignoreFiles = await glob('**/.code-tokenizer-md-ignore', { cwd: this.dir, dot: true, absolute: true, - followSymlinks: false, - onlyFiles: true - })) { - ignoreFiles.push(file); - } + follow: false, + nodir: true + }); if (this.verbose) { console.log(`Found ${ignoreFiles.length} ignore files`); @@ -147,6 +127,7 @@ export class MarkdownGenerator { throw error; } } + /** * Retrieves a list of files tracked by Git, excluding those specified in fileTypeExclusions and fileExclusions. * @async diff --git a/src/fileExclusions.ts b/src/fileExclusions.ts index 779b117..895620a 100644 --- a/src/fileExclusions.ts +++ b/src/fileExclusions.ts @@ -69,4 +69,4 @@ export default [ '**/tmp/', '**/temp/', '**/*.log' -] \ No newline at end of file +] as const; \ No newline at end of file diff --git a/src/fileTypeExclusions.ts b/src/fileTypeExclusions.ts index b1d3ba0..b163138 100644 --- a/src/fileTypeExclusions.ts +++ b/src/fileTypeExclusions.ts @@ -1,4 +1,4 @@ -export default [ +const filetypeExclusions = [ // Images '.jpg', '.jpeg', @@ -57,4 +57,6 @@ export default [ '.db', '.sqlite', '.sqlite3' -] \ No newline at end of file +] as const; + +export default filetypeExclusions; \ No newline at end of file