@ts-for-gir/cli 4.0.0-beta.9 → 4.0.0-rc.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.
- package/README.md +295 -84
- package/bin/ts-for-gir +26569 -0
- package/bin/ts-for-gir-dev +43 -0
- package/package.json +39 -38
- package/src/commands/analyze.ts +344 -0
- package/src/commands/command-builder.ts +30 -0
- package/src/commands/copy.ts +71 -76
- package/src/commands/doc.ts +44 -47
- package/src/commands/generate.ts +35 -79
- package/src/commands/index.ts +6 -4
- package/src/commands/json.ts +43 -0
- package/src/commands/list.ts +71 -90
- package/src/commands/run-generation-command.ts +70 -0
- package/src/config/config-loader.ts +190 -0
- package/src/config/config-writer.ts +52 -0
- package/src/config/defaults.ts +66 -0
- package/src/config/index.ts +8 -0
- package/src/config/options.ts +315 -0
- package/src/config.ts +3 -456
- package/src/formatters/typescript-formatter.ts +24 -0
- package/src/generation-handler.ts +122 -67
- package/src/index.ts +4 -4
- package/src/module-loader/dependency-resolver.ts +100 -0
- package/src/module-loader/file-finder.ts +65 -0
- package/src/module-loader/index.ts +8 -0
- package/src/module-loader/module-grouper.ts +77 -0
- package/src/module-loader/prompt-handler.ts +111 -0
- package/src/module-loader.ts +289 -578
- package/src/start.ts +17 -14
- package/src/types/command-args.ts +118 -0
- package/src/types/command-definition.ts +17 -0
- package/src/types/commands.ts +30 -0
- package/src/types/index.ts +15 -0
- package/src/types/report-types.ts +34 -0
- package/lib/commands/copy.d.ts +0 -12
- package/lib/commands/copy.js +0 -80
- package/lib/commands/copy.js.map +0 -1
- package/lib/commands/doc.d.ts +0 -12
- package/lib/commands/doc.js +0 -40
- package/lib/commands/doc.js.map +0 -1
- package/lib/commands/generate.d.ts +0 -12
- package/lib/commands/generate.js +0 -71
- package/lib/commands/generate.js.map +0 -1
- package/lib/commands/index.d.ts +0 -4
- package/lib/commands/index.js +0 -5
- package/lib/commands/index.js.map +0 -1
- package/lib/commands/list.d.ts +0 -12
- package/lib/commands/list.js +0 -81
- package/lib/commands/list.js.map +0 -1
- package/lib/config.d.ts +0 -108
- package/lib/config.js +0 -410
- package/lib/config.js.map +0 -1
- package/lib/generation-handler.d.ts +0 -10
- package/lib/generation-handler.js +0 -48
- package/lib/generation-handler.js.map +0 -1
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -5
- package/lib/index.js.map +0 -1
- package/lib/module-loader.d.ts +0 -148
- package/lib/module-loader.js +0 -468
- package/lib/module-loader.js.map +0 -1
- package/lib/start.d.ts +0 -2
- package/lib/start.js +0 -16
- package/lib/start.js.map +0 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
# CLI
|
|
20
20
|
|
|
21
|
-
CLI tool to generate
|
|
21
|
+
CLI tool to generate TypeScript type definitions and HTML documentation for GObject Introspection Repository (GIR) files, primarily for GJS applications.
|
|
22
22
|
|
|
23
23
|
## Getting started
|
|
24
24
|
|
|
@@ -37,18 +37,16 @@ npx @ts-for-gir/cli --help
|
|
|
37
37
|
> ts-for-gir --help
|
|
38
38
|
> ```
|
|
39
39
|
|
|
40
|
-
```
|
|
41
|
-
$ npx @ts-for-gir/cli --help
|
|
42
|
-
|
|
40
|
+
```
|
|
43
41
|
TypeScript type definition generator for GObject introspection GIR files
|
|
44
42
|
|
|
45
43
|
Commands:
|
|
46
44
|
ts-for-gir generate [modules..] Generates .d.ts files from GIR for GJS
|
|
45
|
+
ts-for-gir json [modules..] Generates JSON representation from GIR files for analysis and tooling
|
|
46
|
+
ts-for-gir doc [modules..] Generates HTML documentation from GIR files using TypeDoc
|
|
47
47
|
ts-for-gir list [modules..] Lists all available GIR modules
|
|
48
|
-
ts-for-gir copy [modules..] Scan for *.gir files and copy them to a new
|
|
49
|
-
|
|
50
|
-
ts-for-gir doc [modules..] The HTML documentation generator is not yet i
|
|
51
|
-
mplemented, but feel free to implement it 🤗
|
|
48
|
+
ts-for-gir copy [modules..] Scan for *.gir files and copy them to a new directory
|
|
49
|
+
ts-for-gir analyze Analyze report files generated by ts-for-gir reporter
|
|
52
50
|
|
|
53
51
|
Options:
|
|
54
52
|
--version Show version number [boolean]
|
|
@@ -57,19 +55,17 @@ Options:
|
|
|
57
55
|
|
|
58
56
|
## Example
|
|
59
57
|
|
|
60
|
-
To generate the
|
|
58
|
+
To generate the TypeScript type definitions of Gtk-4.0 for GJS run:
|
|
61
59
|
|
|
62
60
|
```
|
|
63
61
|
ts-for-gir generate Gtk-4.0
|
|
64
62
|
```
|
|
65
63
|
|
|
66
|
-
You can also look at the [examples](https://github.com/gjsify/ts-for-gir/tree/main/examples) to see how the types are generated there.
|
|
64
|
+
You can also look at the [examples](https://github.com/gjsify/ts-for-gir/tree/main/examples) to see how the types are generated and/or used there.
|
|
67
65
|
|
|
68
66
|
## Generate .d.ts files
|
|
69
67
|
|
|
70
|
-
```
|
|
71
|
-
$ npx @ts-for-gir/cli generate --help
|
|
72
|
-
|
|
68
|
+
```
|
|
73
69
|
ts-for-gir generate [modules..]
|
|
74
70
|
|
|
75
71
|
Generates .d.ts files from GIR for GJS
|
|
@@ -77,65 +73,169 @@ Generates .d.ts files from GIR for GJS
|
|
|
77
73
|
Options:
|
|
78
74
|
--version Show version number [boolean]
|
|
79
75
|
--help Show help [boolean]
|
|
80
|
-
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
81
|
-
|
|
82
|
-
-g, --girDirectories GIR directories
|
|
83
|
-
|
|
84
|
-
/*/gir-1.0","/usr/share/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/li
|
|
85
|
-
b64/mutter-*","/usr/lib/mutter-*","/usr/lib/x86_64-linux-gnu/mutter-*"]]
|
|
86
|
-
--root Root directory of your project
|
|
87
|
-
[string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
|
|
76
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
77
|
+
multiple modules [array] [default: ["*"]]
|
|
78
|
+
-g, --girDirectories GIR directories [array]
|
|
79
|
+
--root Root directory of your project [string]
|
|
88
80
|
-o, --outdir Directory to output to
|
|
89
81
|
[string] [default: "./@types"]
|
|
90
82
|
-i, --ignore Modules that should be ignored
|
|
91
83
|
[array] [default: []]
|
|
92
84
|
-v, --verbose Switch on/off the verbose mode
|
|
93
|
-
|
|
85
|
+
[boolean] [default: false]
|
|
94
86
|
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
95
87
|
multiple versions are detected
|
|
96
|
-
|
|
88
|
+
[boolean] [default: false]
|
|
97
89
|
-p, --print Print the output to console and create no files
|
|
98
|
-
|
|
90
|
+
[boolean] [default: false]
|
|
99
91
|
--configName Specify a custom name for the configuration file
|
|
100
92
|
[string] [default: ".ts-for-girrc.js"]
|
|
101
|
-
-d, --noNamespace Do not export all symbols for each module as a
|
|
102
|
-
|
|
93
|
+
-d, --noNamespace Do not export all symbols for each module as a
|
|
94
|
+
namespace [boolean] [default: false]
|
|
103
95
|
-n, --noComments Do not generate documentation comments
|
|
104
|
-
|
|
96
|
+
[boolean] [default: false]
|
|
105
97
|
--promisify Generate promisified functions for async/finish
|
|
106
|
-
calls
|
|
98
|
+
calls [boolean] [default: true]
|
|
107
99
|
--npmScope Scope of the generated NPM packages
|
|
108
100
|
[string] [default: "@girs"]
|
|
109
|
-
--workspace Uses the workspace protocol for the generated
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
--workspace Uses the workspace protocol for the generated
|
|
102
|
+
packages [boolean] [default: false]
|
|
103
|
+
--onlyVersionPrefix Only use the version prefix for the ambient
|
|
104
|
+
module exports [boolean] [default: false]
|
|
105
|
+
--noPrettyPrint Do not prettify the generated types
|
|
106
|
+
[boolean] [default: false]
|
|
107
|
+
--noAdvancedVariants Disable GLib.Variant class with string parsing
|
|
108
|
+
[boolean] [default: false]
|
|
117
109
|
--package Generate the typescript types with package.json
|
|
118
|
-
support
|
|
110
|
+
support [boolean] [default: false]
|
|
111
|
+
--reporter Enable generation problem reporter and create a
|
|
112
|
+
detailed report file [boolean] [default: false]
|
|
113
|
+
--reporterOutput Output file path for the reporter
|
|
114
|
+
[string] [default: "ts-for-gir-report.json"]
|
|
119
115
|
|
|
120
116
|
Examples:
|
|
121
|
-
ts-for-gir generate
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
ts-for-gir generate
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
ts-for-gir generate --
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
ndr-1.3 k-4.0 and xrandr-1.3
|
|
117
|
+
ts-for-gir generate Run 'ts-for-gir generate'
|
|
118
|
+
in your gjs project to
|
|
119
|
+
generate typings
|
|
120
|
+
ts-for-gir generate 'Gtk*' You can also use wild cards
|
|
121
|
+
ts-for-gir generate '*' Parse all locally installed
|
|
122
|
+
gir modules
|
|
123
|
+
ts-for-gir generate --configName='.rc.js' Use a special config file
|
|
124
|
+
ts-for-gir generate --ignore=Gtk-4.0 xrandr-1.3 Generate .d.ts files but
|
|
125
|
+
not for Gtk-4.0 and
|
|
126
|
+
xrandr-1.3
|
|
132
127
|
```
|
|
133
128
|
|
|
134
|
-
##
|
|
129
|
+
## Generate TypeDoc JSON
|
|
130
|
+
|
|
131
|
+
Generates TypeDoc JSON output enriched with GIR-specific metadata. This is useful as an intermediate step before generating HTML documentation (see `doc --merge`), or for custom tooling.
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
ts-for-gir json [modules..]
|
|
135
|
+
|
|
136
|
+
Generates JSON representation from GIR files for analysis and tooling
|
|
137
|
+
|
|
138
|
+
Options:
|
|
139
|
+
--version Show version number [boolean]
|
|
140
|
+
--help Show help [boolean]
|
|
141
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
142
|
+
multiple modules [array] [default: ["*"]]
|
|
143
|
+
-g, --girDirectories GIR directories [array]
|
|
144
|
+
--root Root directory of your project [string]
|
|
145
|
+
-o, --outdir Directory to output to
|
|
146
|
+
[string] [default: "./@types"]
|
|
147
|
+
-i, --ignore Modules that should be ignored
|
|
148
|
+
[array] [default: []]
|
|
149
|
+
-v, --verbose Switch on/off the verbose mode
|
|
150
|
+
[boolean] [default: false]
|
|
151
|
+
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
152
|
+
multiple versions are detected
|
|
153
|
+
[boolean] [default: false]
|
|
154
|
+
--configName Specify a custom name for the configuration file
|
|
155
|
+
[string] [default: ".ts-for-girrc.js"]
|
|
156
|
+
|
|
157
|
+
Examples:
|
|
158
|
+
ts-for-gir json Generate JSON for all modules
|
|
159
|
+
ts-for-gir json Gtk-4.0 --outdir ./json Generate JSON for Gtk-4.0 into ./json
|
|
160
|
+
ts-for-gir json '*' --outdir ./json Generate JSON for all modules
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Generate HTML documentation
|
|
164
|
+
|
|
165
|
+
Generates a browsable HTML API reference using TypeDoc. Supports two modes:
|
|
166
|
+
|
|
167
|
+
- **Direct mode**: Generates `.d.ts` files from GIR, then converts to HTML in one step.
|
|
168
|
+
- **Merge mode** (`--merge`): Reads pre-generated JSON files (from `ts-for-gir json`) and produces HTML. This uses less memory and is suitable for large module sets.
|
|
169
|
+
|
|
170
|
+
The generated documentation uses a custom theme inspired by [gi-docgen](https://gnome.pages.gitlab.gnome.org/gi-docgen/) with a 3-column layout, GIR metadata badges, and categorized module listings.
|
|
171
|
+
|
|
172
|
+
See the live documentation at [gjsify.github.io/docs](https://gjsify.github.io/docs).
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
ts-for-gir doc [modules..]
|
|
176
|
+
|
|
177
|
+
Generates HTML documentation from GIR files using TypeDoc
|
|
178
|
+
|
|
179
|
+
Options:
|
|
180
|
+
--version Show version number [boolean]
|
|
181
|
+
--help Show help [boolean]
|
|
182
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
183
|
+
multiple modules [array] [default: ["*"]]
|
|
184
|
+
-g, --girDirectories GIR directories [array]
|
|
185
|
+
--root Root directory of your project [string]
|
|
186
|
+
-o, --outdir Directory to output to
|
|
187
|
+
[string] [default: "./docs"]
|
|
188
|
+
-i, --ignore Modules that should be ignored
|
|
189
|
+
[array] [default: []]
|
|
190
|
+
-v, --verbose Switch on/off the verbose mode
|
|
191
|
+
[boolean] [default: false]
|
|
192
|
+
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
193
|
+
multiple versions are detected
|
|
194
|
+
[boolean] [default: false]
|
|
195
|
+
--configName Specify a custom name for the configuration file
|
|
196
|
+
[string] [default: ".ts-for-girrc.js"]
|
|
197
|
+
--combined Generate a single unified documentation for all
|
|
198
|
+
modules (use --no-combined for separate
|
|
199
|
+
per-module docs) [boolean] [default: true]
|
|
200
|
+
--sourceLinkTemplate URL template for source links in generated
|
|
201
|
+
documentation. Supports {path}, {line},
|
|
202
|
+
{gitRevision} placeholders [string]
|
|
203
|
+
--theme Theme for HTML documentation generation.
|
|
204
|
+
Use "default" for TypeDoc's built-in theme.
|
|
205
|
+
[string] [default: "gi-docgen"]
|
|
206
|
+
--readme Path to a README file for the documentation
|
|
207
|
+
index page. Use "none" to disable. [string]
|
|
208
|
+
--merge Use TypeDoc merge mode to generate HTML from
|
|
209
|
+
pre-generated JSON files (requires --jsonDir)
|
|
210
|
+
[boolean] [default: false]
|
|
211
|
+
--jsonDir Directory containing pre-generated TypeDoc JSON
|
|
212
|
+
files for merge mode (from 'ts-for-gir json')
|
|
213
|
+
[string]
|
|
214
|
+
|
|
215
|
+
Examples:
|
|
216
|
+
ts-for-gir doc Gtk-4.0 --outdir ./docs Generate HTML documentation
|
|
217
|
+
for Gtk-4.0
|
|
218
|
+
ts-for-gir doc '*' --outdir ./docs Generate documentation for all
|
|
219
|
+
locally installed GIR modules
|
|
220
|
+
ts-for-gir doc --merge --jsonDir ./json Generate HTML from pre-generated
|
|
221
|
+
--outdir ./docs JSON files (low memory)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Two-phase workflow
|
|
225
|
+
|
|
226
|
+
For large module sets, you can split documentation generation into two phases to reduce peak memory usage:
|
|
135
227
|
|
|
136
228
|
```bash
|
|
137
|
-
|
|
138
|
-
|
|
229
|
+
# Phase 1: Generate JSON files (one per module)
|
|
230
|
+
ts-for-gir json '*' --outdir ./json
|
|
231
|
+
|
|
232
|
+
# Phase 2: Merge JSON files into HTML documentation
|
|
233
|
+
ts-for-gir doc --merge --jsonDir ./json --outdir ./docs
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## List available GIR modules
|
|
237
|
+
|
|
238
|
+
```
|
|
139
239
|
ts-for-gir list [modules..]
|
|
140
240
|
|
|
141
241
|
Lists all available GIR modules
|
|
@@ -143,37 +243,102 @@ Lists all available GIR modules
|
|
|
143
243
|
Options:
|
|
144
244
|
--version Show version number [boolean]
|
|
145
245
|
--help Show help [boolean]
|
|
146
|
-
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
147
|
-
|
|
148
|
-
-g, --girDirectories GIR directories
|
|
149
|
-
|
|
150
|
-
/*/gir-1.0","/usr/share/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/li
|
|
151
|
-
b64/mutter-*","/usr/lib/mutter-*","/usr/lib/x86_64-linux-gnu/mutter-*"]]
|
|
152
|
-
--root Root directory of your project
|
|
153
|
-
[string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
|
|
246
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
247
|
+
multiple modules [array] [default: ["*"]]
|
|
248
|
+
-g, --girDirectories GIR directories [array]
|
|
249
|
+
--root Root directory of your project [string]
|
|
154
250
|
-i, --ignore Modules that should be ignored [array] [default: []]
|
|
155
251
|
--configName Specify a custom name for the configuration file
|
|
156
252
|
[string] [default: ".ts-for-girrc.js"]
|
|
157
|
-
-v, --verbose Switch on/off the verbose mode [
|
|
253
|
+
-v, --verbose Switch on/off the verbose mode [boolean] [default: false]
|
|
158
254
|
|
|
159
255
|
Examples:
|
|
160
|
-
ts-for-gir list -g ./vala-girs/gir-1.0
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
256
|
+
ts-for-gir list -g ./vala-girs/gir-1.0 Lists all available GIR
|
|
257
|
+
modules in
|
|
258
|
+
./vala-girs/gir-1.0
|
|
259
|
+
ts-for-gir list --ignore=Gtk-3.0 xrandr-1.3 Lists all available GIR
|
|
260
|
+
modules but not Gtk-3.0
|
|
261
|
+
and xrandr-1.3
|
|
165
262
|
```
|
|
166
263
|
|
|
167
|
-
##
|
|
264
|
+
## Copy GIR files
|
|
168
265
|
|
|
169
|
-
```
|
|
170
|
-
|
|
266
|
+
```
|
|
267
|
+
ts-for-gir copy [modules..]
|
|
171
268
|
|
|
172
|
-
|
|
269
|
+
Scan for *.gir files and copy them to a new directory
|
|
270
|
+
|
|
271
|
+
Options:
|
|
272
|
+
--version Show version number [boolean]
|
|
273
|
+
--help Show help [boolean]
|
|
274
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
275
|
+
multiple modules [array] [default: ["*"]]
|
|
276
|
+
-g, --girDirectories GIR directories [array]
|
|
277
|
+
--root Root directory of your project [string]
|
|
278
|
+
-o, --outdir Directory to output to [string] [default: "./@types"]
|
|
279
|
+
-i, --ignore Modules that should be ignored [array] [default: []]
|
|
280
|
+
--configName Specify a custom name for the configuration file
|
|
281
|
+
[string] [default: ".ts-for-girrc.js"]
|
|
282
|
+
-v, --verbose Switch on/off the verbose mode [boolean] [default: false]
|
|
283
|
+
|
|
284
|
+
Examples:
|
|
285
|
+
ts-for-gir copy -o ./gir Copy found *.gir files to
|
|
286
|
+
./gir
|
|
287
|
+
ts-for-gir copy -g /usr/share/gir-1.0 Copy all found *.gir files
|
|
288
|
+
--ignore=Gtk-3.0 xrandr-1.3 -o ./gir excluding Gtk-3.0 and
|
|
289
|
+
xrandr-1.3 to ./gir
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Analyze report files
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
ts-for-gir analyze [options]
|
|
173
296
|
|
|
174
|
-
|
|
175
|
-
|
|
297
|
+
Analyze report files generated by ts-for-gir reporter
|
|
298
|
+
|
|
299
|
+
Options:
|
|
300
|
+
--version Show version number [boolean]
|
|
301
|
+
--help Show help [boolean]
|
|
302
|
+
-f, --reportFile Path to the report file to analyze [string] [required]
|
|
303
|
+
-s, --severity Filter by problem severity
|
|
304
|
+
(debug, info, warning, error, critical) [array]
|
|
305
|
+
-c, --category Filter by problem category [array]
|
|
306
|
+
-n, --namespace Filter by namespace/module [array]
|
|
307
|
+
-t, --type Filter by specific type name [array]
|
|
308
|
+
--search Search for text in messages, details, or type names
|
|
309
|
+
[string]
|
|
310
|
+
--since Filter problems since date/time (ISO format) [string]
|
|
311
|
+
--until Filter problems until date/time (ISO format) [string]
|
|
312
|
+
--top Show top N most problematic items [number] [default: 10]
|
|
313
|
+
--format Output format (table, json, csv)
|
|
314
|
+
[string] [default: "table"]
|
|
315
|
+
-e, --export Export filtered results to file [string]
|
|
316
|
+
-d, --detailed Show detailed problem information [boolean] [default: false]
|
|
317
|
+
--summary Show summary statistics only [boolean] [default: false]
|
|
318
|
+
-v, --verbose Enable verbose output [boolean] [default: false]
|
|
319
|
+
|
|
320
|
+
Examples:
|
|
321
|
+
ts-for-gir analyze -f ./ts-for-gir-report.json
|
|
322
|
+
Show summary statistics of the report
|
|
323
|
+
ts-for-gir analyze -f ./report.json --severity error critical
|
|
324
|
+
Show only critical and error problems
|
|
325
|
+
ts-for-gir analyze -f ./report.json --category type_resolution --format table
|
|
326
|
+
Show type resolution problems
|
|
327
|
+
ts-for-gir analyze -f ./report.json --namespace Gtk --top 10
|
|
328
|
+
Show top 10 problems in Gtk namespace
|
|
329
|
+
ts-for-gir analyze -f ./report.json --search "Unable to resolve" --export errors.json
|
|
330
|
+
Export unresolved type errors to file
|
|
176
331
|
```
|
|
332
|
+
|
|
333
|
+
The `analyze` command helps debug type generation issues by providing powerful filtering and analysis capabilities for ts-for-gir report files.
|
|
334
|
+
|
|
335
|
+
**Key Features:**
|
|
336
|
+
- **Comprehensive Filtering**: Filter by severity, category, namespace, type name, or search text
|
|
337
|
+
- **Multiple Output Formats**: Table, JSON, or CSV format for different use cases
|
|
338
|
+
- **Statistical Analysis**: Show most problematic types, namespaces, and categories
|
|
339
|
+
- **Export Capabilities**: Save filtered results for further analysis
|
|
340
|
+
- **Time-based Filtering**: Analyze problems within specific time ranges
|
|
341
|
+
|
|
177
342
|
## Config
|
|
178
343
|
|
|
179
344
|
In addition to the option of passing options as a CLI flag, you can also write them in a config file.
|
|
@@ -192,12 +357,28 @@ export default {
|
|
|
192
357
|
|
|
193
358
|
The javascript config files must also be in ESM format if you are inside a ESM Package, this is the case if `"type": "module"` is defined in your package.json. Alternatively, the file can be saved in json format, then it works in both cases.
|
|
194
359
|
|
|
195
|
-
You can pass the config file name to the CLI using [configName](#
|
|
360
|
+
You can pass the config file name to the CLI using [configName](#configname).
|
|
361
|
+
|
|
362
|
+
### Doc-specific config
|
|
363
|
+
|
|
364
|
+
For documentation generation, you can configure doc-specific options in the config file:
|
|
365
|
+
|
|
366
|
+
```js
|
|
367
|
+
export default {
|
|
368
|
+
modules: ['Gtk-4.0', 'Gdk-4.0', 'Gio-2.0', 'GLib-2.0', 'GObject-2.0'],
|
|
369
|
+
outdir: './docs',
|
|
370
|
+
merge: true,
|
|
371
|
+
jsonDir: './json',
|
|
372
|
+
readme: './DOC.md',
|
|
373
|
+
verbose: true,
|
|
374
|
+
sourceLinkTemplate: 'https://github.com/user/repo/blob/main/{path}#L{line}',
|
|
375
|
+
}
|
|
376
|
+
```
|
|
196
377
|
|
|
197
378
|
## Options
|
|
198
379
|
|
|
199
380
|
### girDirectories
|
|
200
|
-
Directories in which `*.gir` files are to be searched for. Default is `["/usr/share/gir-1.0"]`. More than one can be specified. If you want to generate the types for the GNOME Shell you have to search in several folders for the corresponding types:
|
|
381
|
+
Directories in which `*.gir` files are to be searched for. Default is `["/usr/share/gir-1.0"]`. More than one can be specified. If you want to generate the types for the GNOME Shell you have to search in several folders for the corresponding types:
|
|
201
382
|
```js
|
|
202
383
|
girDirectories: [
|
|
203
384
|
// General gir files
|
|
@@ -216,7 +397,7 @@ girDirectories: [
|
|
|
216
397
|
```
|
|
217
398
|
|
|
218
399
|
### outdir
|
|
219
|
-
The `outdir` option is used to specify the name of the directory where the generated TypeScript types should be saved. The default value of the `outdir` option is `"./@types"`.
|
|
400
|
+
The `outdir` option is used to specify the name of the directory where the generated TypeScript types should be saved. The default value of the `outdir` option is `"./@types"` for `generate` and `"./docs"` for `doc`.
|
|
220
401
|
|
|
221
402
|
Here is an example of how you can use the outdir option in the CLI of `ts-for-gir`:
|
|
222
403
|
|
|
@@ -253,7 +434,7 @@ The `ignoreVersionConflicts` CLI option allows you to disable the prompt to choo
|
|
|
253
434
|
|
|
254
435
|
This option can be useful in certain scenarios where you want to generate types for all versions of a library, even if there are conflicts between the versions. Note that this may result in type conflicts and other issues, so it should be used with caution.
|
|
255
436
|
|
|
256
|
-
Another way to disable the prompt and ignore conflicting versions of `.gir` files is to use the [ignore CLI option](#ignore).
|
|
437
|
+
Another way to disable the prompt and ignore conflicting versions of `.gir` files is to use the [ignore CLI option](#ignore).
|
|
257
438
|
|
|
258
439
|
### print
|
|
259
440
|
The `print` CLI option allows you to output the generated TypeScript definitions to the console, instead of saving them to files on disk. This is useful if you want to quickly inspect the generated types without having to save them to disk and open them in an editor.
|
|
@@ -263,7 +444,7 @@ By default, the print option is disabled and the generated types will be saved t
|
|
|
263
444
|
### configName
|
|
264
445
|
The `configName` CLI option allows you to specify the name of the configuration file to be used when generating the TypeScript definitions. This option is useful if you want to use a custom configuration file instead of the default one.
|
|
265
446
|
|
|
266
|
-
By default
|
|
447
|
+
By default, `ts-for-gir` looks for a configuration file named `.ts-for-girrc.js` in the current directory. If a different configuration file name is required, the `configName` option can be used to specify the name of the configuration file.
|
|
267
448
|
|
|
268
449
|
For example, if you have a configuration file named `custom-config.js`, you can use the following command to generate TypeScript definitions using this configuration file:
|
|
269
450
|
|
|
@@ -287,10 +468,24 @@ When `noComments` is set to `true`, `ts-for-gir` will not include TSDoc comments
|
|
|
287
468
|
To use the noComments option, pass it as a command line argument to `ts-for-gir`:
|
|
288
469
|
|
|
289
470
|
```bash
|
|
290
|
-
ts-for-gir generate * --noComments
|
|
471
|
+
ts-for-gir generate * --noComments
|
|
291
472
|
```
|
|
292
473
|
|
|
293
|
-
|
|
474
|
+
### noPrettyPrint
|
|
475
|
+
The `noPrettyPrint` option controls whether the generated TypeScript definitions are formatted using Prettier. When set to `true`, the output will not be formatted, which can be useful for debugging or in cases where you want to handle formatting separately.
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
ts-for-gir generate * --noPrettyPrint
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
### noAdvancedVariants
|
|
482
|
+
The `noAdvancedVariants` option disables the advanced GLib.Variant class with string parsing capabilities. This option is enabled by default (`false`) as these advanced features can impact performance, especially with older TypeScript versions.
|
|
483
|
+
|
|
484
|
+
```bash
|
|
485
|
+
ts-for-gir generate * --noAdvancedVariants=false
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### package
|
|
294
489
|
|
|
295
490
|
The `--package` option of ts-for-gir is used to package the generated TypeScript type definitions into an NPM package. The generated package can be easily installed and used in other TypeScript projects via `npm install`.
|
|
296
491
|
|
|
@@ -298,14 +493,14 @@ The `--package` option of ts-for-gir is used to package the generated TypeScript
|
|
|
298
493
|
|
|
299
494
|
When this option is used, each GObject introspection module will be packaged into its own NPM package. The package name will be in the format of `@girs/<lower case module name>-<version>`.
|
|
300
495
|
|
|
301
|
-
For example, if the `--package` option is used to generate the TypeScript type definitions for the `Gtk-4.0` module, then the generated NPM package will have the name `@girs/gtk-
|
|
496
|
+
For example, if the `--package` option is used to generate the TypeScript type definitions for the `Gtk-4.0` module, then the generated NPM package will have the name `@girs/gtk-4.0`.
|
|
302
497
|
|
|
303
498
|
> You can change the NPM package scope name with the [`--npmScope`](#npmscope) option.
|
|
304
499
|
|
|
305
500
|
To use the generated NPM package in your TypeScript project, you can also install our pregenerated packages:
|
|
306
501
|
|
|
307
502
|
```bash
|
|
308
|
-
npm install @girs/gtk-
|
|
503
|
+
npm install @girs/gtk-4.0
|
|
309
504
|
```
|
|
310
505
|
|
|
311
506
|
Then, import the desired module in your TypeScript code:
|
|
@@ -329,10 +524,10 @@ The `--npmScope` CLI option can be used to specify a custom NPM package scope na
|
|
|
329
524
|
Here's an example command to generate NPM packages with a custom scope name:
|
|
330
525
|
|
|
331
526
|
```bash
|
|
332
|
-
ts-for-gir
|
|
527
|
+
ts-for-gir generate * --package --npmScope my-scope
|
|
333
528
|
```
|
|
334
529
|
|
|
335
|
-
This command will generate NPM packages with the scope
|
|
530
|
+
This command will generate NPM packages with the scope `@my-scope` instead of the default `@girs` scope. For `Gtk-4.0` this would generate a package with the name of `@my-scope/gtk-4.0`.
|
|
336
531
|
|
|
337
532
|
## Ambient modules
|
|
338
533
|
|
|
@@ -348,7 +543,7 @@ To use ambient modules, the `ambient.d.ts` file must be imported either in the c
|
|
|
348
543
|
```json
|
|
349
544
|
// tsconfig.json
|
|
350
545
|
{
|
|
351
|
-
"compilerOptions": {
|
|
546
|
+
"compilerOptions": {
|
|
352
547
|
"lib": ["ESNext"],
|
|
353
548
|
"types": [],
|
|
354
549
|
"target": "ESNext",
|
|
@@ -376,4 +571,20 @@ declare module "gi://Gtk" {
|
|
|
376
571
|
import Gtk from "gi://Gtk?version=4.0";
|
|
377
572
|
export default Gtk;
|
|
378
573
|
}
|
|
379
|
-
```
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
## reporter
|
|
577
|
+
|
|
578
|
+
The `--reporter` option enables the generation of a problem reporter and creates a detailed report file.
|
|
579
|
+
|
|
580
|
+
```bash
|
|
581
|
+
ts-for-gir generate * --reporter
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
## reporterOutput
|
|
585
|
+
|
|
586
|
+
The `--reporterOutput` option specifies the output file path for the reporter. The default value is `ts-for-gir-report.json`.
|
|
587
|
+
|
|
588
|
+
```bash
|
|
589
|
+
ts-for-gir generate * --reporterOutput custom-report.json
|
|
590
|
+
```
|