@ts-for-gir/reporter 4.0.0-beta.26

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/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # @ts-for-gir/reporter
2
+
3
+ <p align="center">
4
+ <img src="https://img.shields.io/npm/v/@ts-for-gir/reporter" />
5
+ <img src="https://img.shields.io/npm/dw/@ts-for-gir/reporter" />
6
+ </p>
7
+
8
+ Comprehensive reporting system for the ts-for-gir project that provides structured problem tracking, statistics generation, and flexible output formatting with dependency injection pattern.
9
+
10
+ ## Features
11
+
12
+ - **🔧 Dependency Injection**: Abstract base class with configurable reporter implementations
13
+ - **📊 Problem Tracking**: Structured tracking of type resolution issues, conflicts, and generation problems
14
+ - **📈 Statistics**: Comprehensive statistics collection and reporting
15
+ - **🎨 Flexible Output**: Multiple output formats (console, files) with colorized output
16
+ - **🔍 Categorization**: Problems are categorized by severity and type for better analysis
17
+ - **💾 Export Capabilities**: Export reports to JSON, text, or custom formats
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install @ts-for-gir/reporter
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### Basic Console Reporting
28
+
29
+ ```typescript
30
+ import { ConsoleReporter } from '@ts-for-gir/reporter';
31
+
32
+ // Create a console reporter with basic configuration
33
+ const reporter = new ConsoleReporter(
34
+ true, // verbose mode
35
+ "MyModule", // module name
36
+ true, // enable reporting
37
+ "./reports" // output directory (optional)
38
+ );
39
+
40
+ // Report a problem
41
+ reporter.reportProblem({
42
+ severity: ProblemSeverity.WARNING,
43
+ category: ProblemCategory.TYPE_RESOLUTION,
44
+ message: "Unable to resolve type 'SomeType'",
45
+ context: {
46
+ file: "MyModule.gir",
47
+ line: 123,
48
+ element: "SomeType"
49
+ }
50
+ });
51
+
52
+ // Generate final report
53
+ const report = reporter.generateReport();
54
+ console.log(`Total problems: ${report.statistics.totalProblems}`);
55
+ ```
56
+
57
+ ### Advanced Usage with Custom Configuration
58
+
59
+ ```typescript
60
+ import { ConsoleReporter, ReporterConfig } from '@ts-for-gir/reporter';
61
+
62
+ const config: ReporterConfig = {
63
+ enableConsoleOutput: true,
64
+ enableFileOutput: true,
65
+ outputDirectory: "./custom-reports",
66
+ colorizeOutput: true,
67
+ includeStackTrace: false,
68
+ maxProblemsPerCategory: 100
69
+ };
70
+
71
+ const reporter = new ConsoleReporter(
72
+ true,
73
+ "AdvancedModule",
74
+ true,
75
+ "./reports",
76
+ config
77
+ );
78
+ ```
79
+
80
+ ### Using ReporterService for Multiple Reporters
81
+
82
+ ```typescript
83
+ import { ReporterService, ConsoleReporter } from '@ts-for-gir/reporter';
84
+
85
+ const service = new ReporterService();
86
+
87
+ // Register multiple reporters
88
+ service.registerReporter('console', new ConsoleReporter(true, "Main", true));
89
+ service.registerReporter('file', new FileReporter(true, "Main", true, "./logs"));
90
+
91
+ // Report to all registered reporters
92
+ service.reportToAll({
93
+ severity: ProblemSeverity.ERROR,
94
+ category: ProblemCategory.TYPE_CONFLICT,
95
+ message: "Type conflict detected",
96
+ context: { file: "test.gir" }
97
+ });
98
+
99
+ // Generate consolidated report
100
+ const consolidatedReport = service.generateConsolidatedReport();
101
+ ```
102
+
103
+ ## Problem Categories
104
+
105
+ The reporter system categorizes problems into the following types:
106
+
107
+ - **TYPE_RESOLUTION**: Issues with resolving types from GIR data
108
+ - **TYPE_CONFLICT**: Conflicts between different type definitions
109
+ - **GENERATION_ERROR**: Errors during TypeScript generation
110
+ - **VALIDATION_WARNING**: Validation warnings for generated code
111
+ - **DEPENDENCY_ISSUE**: Problems with dependency resolution
112
+ - **DOCUMENTATION_MISSING**: Missing or incomplete documentation
113
+
114
+ ## Problem Severities
115
+
116
+ - **ERROR**: Critical issues that prevent successful generation
117
+ - **WARNING**: Issues that may affect quality but don't block generation
118
+ - **INFO**: Informational messages for debugging and analysis
119
+
120
+ ## API Reference
121
+
122
+ ### ConsoleReporter
123
+
124
+ The main reporter implementation with console and file output capabilities.
125
+
126
+ #### Constructor
127
+
128
+ ```typescript
129
+ constructor(
130
+ verbose: boolean,
131
+ buildType: string,
132
+ reporter: boolean,
133
+ reporterOutput?: string,
134
+ config?: ReporterConfig
135
+ )
136
+ ```
137
+
138
+ #### Methods
139
+
140
+ - `reportProblem(problem: ProblemEntry): void` - Report a single problem
141
+ - `reportProblems(problems: ProblemEntry[]): void` - Report multiple problems
142
+ - `generateReport(): GenerationReport` - Generate comprehensive report
143
+ - `exportToFile(filename: string): Promise<void>` - Export report to file
144
+
145
+ ### ReporterBase
146
+
147
+ Abstract base class for implementing custom reporters.
148
+
149
+ ```typescript
150
+ abstract class ReporterBase {
151
+ abstract reportProblem(problem: ProblemEntry): void;
152
+ abstract generateReport(): GenerationReport;
153
+ // ... other abstract methods
154
+ }
155
+ ```
156
+
157
+ ### ReporterService
158
+
159
+ Service for managing multiple reporter instances.
160
+
161
+ - `registerReporter(name: string, reporter: ReporterBase): void`
162
+ - `reportToAll(problem: ProblemEntry): void`
163
+ - `generateConsolidatedReport(): GenerationReport`
164
+
165
+ ## Integration with ts-for-gir
166
+
167
+ This package is designed to integrate seamlessly with the ts-for-gir generator system:
168
+
169
+ ```typescript
170
+ import { ConsoleReporter } from '@ts-for-gir/reporter';
171
+ import { GirModule } from '@ts-for-gir/lib';
172
+
173
+ const reporter = new ConsoleReporter(true, "Gtk-4.0", true);
174
+ const girModule = new GirModule(options, reporter);
175
+ ```
176
+
177
+ ## Development
178
+
179
+ This package is part of the ts-for-gir monorepo and follows the same development patterns:
180
+
181
+ ```bash
182
+ # Type checking
183
+ yarn check
184
+
185
+ # Run tests
186
+ yarn test
187
+
188
+ # Format code
189
+ yarn format
190
+ ```
191
+
192
+ ## License
193
+
194
+ Apache-2.0 - see the [LICENSE](../../LICENSE) file for details.
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@ts-for-gir/reporter",
3
+ "version": "4.0.0-beta.26",
4
+ "description": "Problem reporting and comprehensive generation analysis for ts-for-gir",
5
+ "main": "src/index.ts",
6
+ "module": "src/index.ts",
7
+ "type": "module",
8
+ "engines": {
9
+ "node": ">=18"
10
+ },
11
+ "exports": {
12
+ ".": "./src/index.ts"
13
+ },
14
+ "scripts": {
15
+ "check": "tsc --noEmit"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/gjsify/ts-for-gir.git"
20
+ },
21
+ "author": "Pascal Garber <pascal@artandcode.studio>",
22
+ "files": [
23
+ "src"
24
+ ],
25
+ "license": "Apache-2.0",
26
+ "bugs": {
27
+ "url": "https://github.com/gjsify/ts-for-gir/issues"
28
+ },
29
+ "homepage": "https://github.com/gjsify/ts-for-gir#readme",
30
+ "keywords": [
31
+ "gjs",
32
+ "typescript",
33
+ "generate",
34
+ "gir",
35
+ "gobject-introspection",
36
+ "reporter",
37
+ "analysis"
38
+ ],
39
+ "devDependencies": {
40
+ "@types/node": "^24.2.1",
41
+ "typescript": "^5.9.2"
42
+ },
43
+ "dependencies": {
44
+ "colorette": "^2.0.20"
45
+ }
46
+ }