@lobehub/cli 0.0.1-canary.9 → 0.0.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,60 +0,0 @@
1
- #!/usr/bin/env node
2
- import "./chunk-LMMQX4CK.js";
3
-
4
- // ../../packages/file-loaders/src/loaders/text/index.ts
5
- import { readFile } from "fs/promises";
6
- import debug from "debug";
7
- var log = debug("file-loaders:text");
8
- var TextLoader = class {
9
- async loadPages(filePath) {
10
- log("Loading text file:", filePath);
11
- try {
12
- const fileContent = await readFile(filePath, "utf8");
13
- log("Text file loaded successfully, size:", fileContent.length, "bytes");
14
- const lines = fileContent.split("\n");
15
- const lineCount = lines.length;
16
- const charCount = fileContent.length;
17
- log("Text file stats:", { charCount, lineCount });
18
- const page = {
19
- charCount,
20
- lineCount,
21
- metadata: {
22
- lineNumberEnd: lineCount,
23
- lineNumberStart: 1
24
- },
25
- pageContent: fileContent
26
- };
27
- log("Text page created successfully");
28
- return [page];
29
- } catch (e) {
30
- const error = e;
31
- log("Error encountered while loading text file");
32
- console.error(`Error loading text file ${filePath}: ${error.message}`);
33
- const errorPage = {
34
- charCount: 0,
35
- lineCount: 0,
36
- metadata: {
37
- error: `Failed to load text file: ${error.message}`
38
- },
39
- pageContent: ""
40
- };
41
- log("Created error page for failed text file loading");
42
- return [errorPage];
43
- }
44
- }
45
- /**
46
- * For plain text, simply concatenate the content of all pages.
47
- * (Although TextLoader typically has only one page, this maintains interface consistency)
48
- * @param pages Array of pages
49
- * @returns Aggregated content
50
- */
51
- async aggregateContent(pages) {
52
- log("Aggregating content from", pages.length, "text pages");
53
- const result = pages.map((page) => page.pageContent).join("\n");
54
- log("Content aggregated successfully, length:", result.length);
55
- return result;
56
- }
57
- };
58
- export {
59
- TextLoader
60
- };