-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample-usage.ts
More file actions
70 lines (64 loc) · 1.72 KB
/
example-usage.ts
File metadata and controls
70 lines (64 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// example-usage.ts
import chalk from "chalk";
import {
FileContextBuilder,
FileCollectorConfig,
ConsoleRenderer,
JsonRenderer,
FileContextJson,
} from "./src";
export const collectorConfig: FileCollectorConfig = {
name: "Relevant Files",
showContents: true,
showMeta: true,
includeDirs: [
{
path: "./src",
include: ["**/*.ts"],
recursive: true,
},
{
path: "./__tests__",
include: ["**/*.*"],
recursive: true,
},
{
path: "./.husky",
include: ["**/*.*"],
recursive: true,
},
{
path: "./.github",
include: ["**/*.yml"],
recursive: true,
},
],
includeFiles: [
"README.md",
"LICENSE.md",
"package.json",
"tsconfig.json",
"example-usage.ts",
"jest.config.js",
".npmrc",
".gitignore",
],
};
(async () => {
const builder = new FileContextBuilder(collectorConfig);
const context = await builder.build();
// Option 1: Render as a console-friendly string
const consoleRenderer = new ConsoleRenderer();
console.log(chalk.bold.blueBright("=== ConsoleRenderer Output ==="));
console.log(consoleRenderer.render(context));
// Option 2: Render as a strongly-typed JSON object
const jsonRenderer = new JsonRenderer();
const output = jsonRenderer.renderToObject(context);
// Now you have a strongly typed JSON object.
// console.log(chalk.bold.blueBright("Summary Statistics:", JSON.stringify(output.summary.statistics, null, 2)));
// console.log(chalk.bold.cyanBright("Context:", output.fileContext.config.name));
// You can also work directly with the file context if needed.
// if (process.env.NODE_ENV !== "test") {
// console.log("Files:", output.fileContext.files);
// }
})();