@ts-for-gir/cli 4.0.0-beta.9 → 4.0.0-rc.10
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 +335 -86
- package/bin/ts-for-gir +28832 -0
- package/bin/ts-for-gir-dev +43 -0
- package/bin/ts-for-gir-gjs +348955 -0
- package/dist-templates/types-locally/.ts-for-girrc.js +6 -0
- package/dist-templates/types-locally/README.md +15 -0
- package/dist-templates/types-locally/esbuild.ts +10 -0
- package/dist-templates/types-locally/main.ts +21 -0
- package/dist-templates/types-locally/package.json +18 -0
- package/dist-templates/types-locally/tsconfig.json +17 -0
- package/dist-templates/types-npm/README.md +14 -0
- package/dist-templates/types-npm/esbuild.ts +10 -0
- package/dist-templates/types-npm/main.ts +19 -0
- package/dist-templates/types-npm/package.json +23 -0
- package/dist-templates/types-npm/tsconfig.json +15 -0
- package/dist-templates/types-workspace/.ts-for-girrc.js +12 -0
- package/dist-templates/types-workspace/README.md +26 -0
- package/dist-templates/types-workspace/package.json +22 -0
- package/dist-templates/types-workspace/packages/app/esbuild.ts +10 -0
- package/dist-templates/types-workspace/packages/app/main.ts +19 -0
- package/dist-templates/types-workspace/packages/app/package.json +23 -0
- package/dist-templates/types-workspace/packages/app/tsconfig.json +15 -0
- package/dist-templates/types-workspace/tsconfig.json +11 -0
- package/package.json +60 -37
- 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/create.ts +223 -0
- package/src/commands/doc.ts +44 -47
- package/src/commands/generate.ts +35 -79
- package/src/commands/index.ts +8 -4
- package/src/commands/json.ts +43 -0
- package/src/commands/list.ts +71 -90
- package/src/commands/run-generation-command.ts +75 -0
- package/src/commands/self-update.ts +142 -0
- package/src/config/config-loader.ts +238 -0
- package/src/config/config-writer.ts +52 -0
- package/src/config/defaults.ts +68 -0
- package/src/config/index.ts +16 -0
- package/src/config/options.ts +365 -0
- package/src/config.ts +3 -456
- package/src/formatters/typescript-formatter.ts +17 -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 +321 -578
- package/src/start.ts +36 -15
- package/src/types/command-args.ts +154 -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,37 +18,73 @@
|
|
|
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
|
|
|
25
|
-
|
|
25
|
+
### Install (GJS — no Node.js required)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
gjs -m https://raw.githubusercontent.com/gjsify/ts-for-gir/main/install.js
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Installs `ts-for-gir` to `~/.local/bin/ts-for-gir`. Update later with:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
ts-for-gir self-update
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Install (Node.js)
|
|
38
|
+
|
|
39
|
+
```bash
|
|
26
40
|
npx @ts-for-gir/cli --help
|
|
27
41
|
```
|
|
28
42
|
|
|
29
|
-
> Alternatively
|
|
43
|
+
> Alternatively add `@ts-for-gir/cli` to your dependencies:
|
|
30
44
|
> ```bash
|
|
31
45
|
> npm install --save-dev @ts-for-gir/cli
|
|
32
46
|
> ```
|
|
33
47
|
>
|
|
34
|
-
> Or
|
|
48
|
+
> Or install globally:
|
|
35
49
|
> ```bash
|
|
36
50
|
> npm install -g @ts-for-gir/cli
|
|
37
51
|
> ts-for-gir --help
|
|
38
52
|
> ```
|
|
39
53
|
|
|
40
|
-
|
|
41
|
-
|
|
54
|
+
### GJS bundle
|
|
55
|
+
|
|
56
|
+
The GJS bundle (`ts-for-gir-gjs`) supports the full TypeScript /
|
|
57
|
+
TypeDoc pipeline thanks to gjsify's runtime-relative `import.meta.url`
|
|
58
|
+
rewrite. All non-interactive commands run natively on GJS:
|
|
59
|
+
|
|
60
|
+
- `ts-for-gir generate` — `.d.ts` generation
|
|
61
|
+
- `ts-for-gir json` — TypeDoc-backed JSON export
|
|
62
|
+
- `ts-for-gir doc` — HTML documentation. TypeDoc's shiki highlighter
|
|
63
|
+
loads the [oniguruma](https://github.com/kkos/oniguruma) regex
|
|
64
|
+
engine via `WebAssembly.compile(...)`. GJS 1.88 (SpiderMonkey 140)
|
|
65
|
+
exposes the synchronous `WebAssembly.{Module,Instance}` constructors
|
|
66
|
+
but ships the Promise APIs as stubs that throw on first call;
|
|
67
|
+
[`@gjsify/webassembly`](https://www.npmjs.com/package/@gjsify/webassembly)
|
|
68
|
+
(gjsify v0.3.6+) wraps the synchronous constructors with
|
|
69
|
+
`Promise.{resolve,reject}` so `compile`/`instantiate` resolve
|
|
70
|
+
natively in the GJS bundle.
|
|
71
|
+
- `ts-for-gir list` / `copy` / `analyze` / `self-update`
|
|
72
|
+
|
|
73
|
+
The only command still gated on Node.js is `create` — its
|
|
74
|
+
[`inquirer`](https://www.npmjs.com/package/inquirer)-based interactive
|
|
75
|
+
prompt cannot run on GJS without a TTY-aware port. Use
|
|
76
|
+
`npx @ts-for-gir/cli create ...` from a Node install for now.
|
|
42
77
|
|
|
78
|
+
```
|
|
43
79
|
TypeScript type definition generator for GObject introspection GIR files
|
|
44
80
|
|
|
45
81
|
Commands:
|
|
46
82
|
ts-for-gir generate [modules..] Generates .d.ts files from GIR for GJS
|
|
83
|
+
ts-for-gir json [modules..] Generates JSON representation from GIR files for analysis and tooling
|
|
84
|
+
ts-for-gir doc [modules..] Generates HTML documentation from GIR files using TypeDoc
|
|
47
85
|
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 🤗
|
|
86
|
+
ts-for-gir copy [modules..] Scan for *.gir files and copy them to a new directory
|
|
87
|
+
ts-for-gir analyze Analyze report files generated by ts-for-gir reporter
|
|
52
88
|
|
|
53
89
|
Options:
|
|
54
90
|
--version Show version number [boolean]
|
|
@@ -57,19 +93,17 @@ Options:
|
|
|
57
93
|
|
|
58
94
|
## Example
|
|
59
95
|
|
|
60
|
-
To generate the
|
|
96
|
+
To generate the TypeScript type definitions of Gtk-4.0 for GJS run:
|
|
61
97
|
|
|
62
98
|
```
|
|
63
99
|
ts-for-gir generate Gtk-4.0
|
|
64
100
|
```
|
|
65
101
|
|
|
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.
|
|
102
|
+
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
103
|
|
|
68
104
|
## Generate .d.ts files
|
|
69
105
|
|
|
70
|
-
```
|
|
71
|
-
$ npx @ts-for-gir/cli generate --help
|
|
72
|
-
|
|
106
|
+
```
|
|
73
107
|
ts-for-gir generate [modules..]
|
|
74
108
|
|
|
75
109
|
Generates .d.ts files from GIR for GJS
|
|
@@ -77,65 +111,169 @@ Generates .d.ts files from GIR for GJS
|
|
|
77
111
|
Options:
|
|
78
112
|
--version Show version number [boolean]
|
|
79
113
|
--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"]
|
|
114
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
115
|
+
multiple modules [array] [default: ["*"]]
|
|
116
|
+
-g, --girDirectories GIR directories [array]
|
|
117
|
+
--root Root directory of your project [string]
|
|
88
118
|
-o, --outdir Directory to output to
|
|
89
119
|
[string] [default: "./@types"]
|
|
90
120
|
-i, --ignore Modules that should be ignored
|
|
91
121
|
[array] [default: []]
|
|
92
122
|
-v, --verbose Switch on/off the verbose mode
|
|
93
|
-
|
|
123
|
+
[boolean] [default: false]
|
|
94
124
|
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
95
125
|
multiple versions are detected
|
|
96
|
-
|
|
126
|
+
[boolean] [default: false]
|
|
97
127
|
-p, --print Print the output to console and create no files
|
|
98
|
-
|
|
128
|
+
[boolean] [default: false]
|
|
99
129
|
--configName Specify a custom name for the configuration file
|
|
100
130
|
[string] [default: ".ts-for-girrc.js"]
|
|
101
|
-
-d, --noNamespace Do not export all symbols for each module as a
|
|
102
|
-
|
|
131
|
+
-d, --noNamespace Do not export all symbols for each module as a
|
|
132
|
+
namespace [boolean] [default: false]
|
|
103
133
|
-n, --noComments Do not generate documentation comments
|
|
104
|
-
|
|
134
|
+
[boolean] [default: false]
|
|
105
135
|
--promisify Generate promisified functions for async/finish
|
|
106
|
-
calls
|
|
136
|
+
calls [boolean] [default: true]
|
|
107
137
|
--npmScope Scope of the generated NPM packages
|
|
108
138
|
[string] [default: "@girs"]
|
|
109
|
-
--workspace Uses the workspace protocol for the generated
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
139
|
+
--workspace Uses the workspace protocol for the generated
|
|
140
|
+
packages [boolean] [default: false]
|
|
141
|
+
--onlyVersionPrefix Only use the version prefix for the ambient
|
|
142
|
+
module exports [boolean] [default: false]
|
|
143
|
+
--noPrettyPrint Do not prettify the generated types
|
|
144
|
+
[boolean] [default: false]
|
|
145
|
+
--noAdvancedVariants Disable GLib.Variant class with string parsing
|
|
146
|
+
[boolean] [default: false]
|
|
117
147
|
--package Generate the typescript types with package.json
|
|
118
|
-
support
|
|
148
|
+
support [boolean] [default: false]
|
|
149
|
+
--reporter Enable generation problem reporter and create a
|
|
150
|
+
detailed report file [boolean] [default: false]
|
|
151
|
+
--reporterOutput Output file path for the reporter
|
|
152
|
+
[string] [default: "ts-for-gir-report.json"]
|
|
119
153
|
|
|
120
154
|
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
|
|
155
|
+
ts-for-gir generate Run 'ts-for-gir generate'
|
|
156
|
+
in your gjs project to
|
|
157
|
+
generate typings
|
|
158
|
+
ts-for-gir generate 'Gtk*' You can also use wild cards
|
|
159
|
+
ts-for-gir generate '*' Parse all locally installed
|
|
160
|
+
gir modules
|
|
161
|
+
ts-for-gir generate --configName='.rc.js' Use a special config file
|
|
162
|
+
ts-for-gir generate --ignore=Gtk-4.0 xrandr-1.3 Generate .d.ts files but
|
|
163
|
+
not for Gtk-4.0 and
|
|
164
|
+
xrandr-1.3
|
|
132
165
|
```
|
|
133
166
|
|
|
134
|
-
##
|
|
167
|
+
## Generate TypeDoc JSON
|
|
168
|
+
|
|
169
|
+
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.
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
ts-for-gir json [modules..]
|
|
173
|
+
|
|
174
|
+
Generates JSON representation from GIR files for analysis and tooling
|
|
175
|
+
|
|
176
|
+
Options:
|
|
177
|
+
--version Show version number [boolean]
|
|
178
|
+
--help Show help [boolean]
|
|
179
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
180
|
+
multiple modules [array] [default: ["*"]]
|
|
181
|
+
-g, --girDirectories GIR directories [array]
|
|
182
|
+
--root Root directory of your project [string]
|
|
183
|
+
-o, --outdir Directory to output to
|
|
184
|
+
[string] [default: "./@types"]
|
|
185
|
+
-i, --ignore Modules that should be ignored
|
|
186
|
+
[array] [default: []]
|
|
187
|
+
-v, --verbose Switch on/off the verbose mode
|
|
188
|
+
[boolean] [default: false]
|
|
189
|
+
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
190
|
+
multiple versions are detected
|
|
191
|
+
[boolean] [default: false]
|
|
192
|
+
--configName Specify a custom name for the configuration file
|
|
193
|
+
[string] [default: ".ts-for-girrc.js"]
|
|
194
|
+
|
|
195
|
+
Examples:
|
|
196
|
+
ts-for-gir json Generate JSON for all modules
|
|
197
|
+
ts-for-gir json Gtk-4.0 --outdir ./json Generate JSON for Gtk-4.0 into ./json
|
|
198
|
+
ts-for-gir json '*' --outdir ./json Generate JSON for all modules
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Generate HTML documentation
|
|
202
|
+
|
|
203
|
+
Generates a browsable HTML API reference using TypeDoc. Supports two modes:
|
|
204
|
+
|
|
205
|
+
- **Direct mode**: Generates `.d.ts` files from GIR, then converts to HTML in one step.
|
|
206
|
+
- **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.
|
|
207
|
+
|
|
208
|
+
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.
|
|
209
|
+
|
|
210
|
+
See the live documentation at [gjsify.github.io/docs](https://gjsify.github.io/docs).
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
ts-for-gir doc [modules..]
|
|
214
|
+
|
|
215
|
+
Generates HTML documentation from GIR files using TypeDoc
|
|
216
|
+
|
|
217
|
+
Options:
|
|
218
|
+
--version Show version number [boolean]
|
|
219
|
+
--help Show help [boolean]
|
|
220
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
221
|
+
multiple modules [array] [default: ["*"]]
|
|
222
|
+
-g, --girDirectories GIR directories [array]
|
|
223
|
+
--root Root directory of your project [string]
|
|
224
|
+
-o, --outdir Directory to output to
|
|
225
|
+
[string] [default: "./docs"]
|
|
226
|
+
-i, --ignore Modules that should be ignored
|
|
227
|
+
[array] [default: []]
|
|
228
|
+
-v, --verbose Switch on/off the verbose mode
|
|
229
|
+
[boolean] [default: false]
|
|
230
|
+
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
231
|
+
multiple versions are detected
|
|
232
|
+
[boolean] [default: false]
|
|
233
|
+
--configName Specify a custom name for the configuration file
|
|
234
|
+
[string] [default: ".ts-for-girrc.js"]
|
|
235
|
+
--combined Generate a single unified documentation for all
|
|
236
|
+
modules (use --no-combined for separate
|
|
237
|
+
per-module docs) [boolean] [default: true]
|
|
238
|
+
--sourceLinkTemplate URL template for source links in generated
|
|
239
|
+
documentation. Supports {path}, {line},
|
|
240
|
+
{gitRevision} placeholders [string]
|
|
241
|
+
--theme Theme for HTML documentation generation.
|
|
242
|
+
Use "default" for TypeDoc's built-in theme.
|
|
243
|
+
[string] [default: "gi-docgen"]
|
|
244
|
+
--readme Path to a README file for the documentation
|
|
245
|
+
index page. Use "none" to disable. [string]
|
|
246
|
+
--merge Use TypeDoc merge mode to generate HTML from
|
|
247
|
+
pre-generated JSON files (requires --jsonDir)
|
|
248
|
+
[boolean] [default: false]
|
|
249
|
+
--jsonDir Directory containing pre-generated TypeDoc JSON
|
|
250
|
+
files for merge mode (from 'ts-for-gir json')
|
|
251
|
+
[string]
|
|
252
|
+
|
|
253
|
+
Examples:
|
|
254
|
+
ts-for-gir doc Gtk-4.0 --outdir ./docs Generate HTML documentation
|
|
255
|
+
for Gtk-4.0
|
|
256
|
+
ts-for-gir doc '*' --outdir ./docs Generate documentation for all
|
|
257
|
+
locally installed GIR modules
|
|
258
|
+
ts-for-gir doc --merge --jsonDir ./json Generate HTML from pre-generated
|
|
259
|
+
--outdir ./docs JSON files (low memory)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Two-phase workflow
|
|
263
|
+
|
|
264
|
+
For large module sets, you can split documentation generation into two phases to reduce peak memory usage:
|
|
135
265
|
|
|
136
266
|
```bash
|
|
137
|
-
|
|
138
|
-
|
|
267
|
+
# Phase 1: Generate JSON files (one per module)
|
|
268
|
+
ts-for-gir json '*' --outdir ./json
|
|
269
|
+
|
|
270
|
+
# Phase 2: Merge JSON files into HTML documentation
|
|
271
|
+
ts-for-gir doc --merge --jsonDir ./json --outdir ./docs
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## List available GIR modules
|
|
275
|
+
|
|
276
|
+
```
|
|
139
277
|
ts-for-gir list [modules..]
|
|
140
278
|
|
|
141
279
|
Lists all available GIR modules
|
|
@@ -143,37 +281,102 @@ Lists all available GIR modules
|
|
|
143
281
|
Options:
|
|
144
282
|
--version Show version number [boolean]
|
|
145
283
|
--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"]
|
|
284
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
285
|
+
multiple modules [array] [default: ["*"]]
|
|
286
|
+
-g, --girDirectories GIR directories [array]
|
|
287
|
+
--root Root directory of your project [string]
|
|
154
288
|
-i, --ignore Modules that should be ignored [array] [default: []]
|
|
155
289
|
--configName Specify a custom name for the configuration file
|
|
156
290
|
[string] [default: ".ts-for-girrc.js"]
|
|
157
|
-
-v, --verbose Switch on/off the verbose mode [
|
|
291
|
+
-v, --verbose Switch on/off the verbose mode [boolean] [default: false]
|
|
158
292
|
|
|
159
293
|
Examples:
|
|
160
|
-
ts-for-gir list -g ./vala-girs/gir-1.0
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
294
|
+
ts-for-gir list -g ./vala-girs/gir-1.0 Lists all available GIR
|
|
295
|
+
modules in
|
|
296
|
+
./vala-girs/gir-1.0
|
|
297
|
+
ts-for-gir list --ignore=Gtk-3.0 xrandr-1.3 Lists all available GIR
|
|
298
|
+
modules but not Gtk-3.0
|
|
299
|
+
and xrandr-1.3
|
|
165
300
|
```
|
|
166
301
|
|
|
167
|
-
##
|
|
302
|
+
## Copy GIR files
|
|
168
303
|
|
|
169
|
-
```
|
|
170
|
-
|
|
304
|
+
```
|
|
305
|
+
ts-for-gir copy [modules..]
|
|
171
306
|
|
|
172
|
-
|
|
307
|
+
Scan for *.gir files and copy them to a new directory
|
|
308
|
+
|
|
309
|
+
Options:
|
|
310
|
+
--version Show version number [boolean]
|
|
311
|
+
--help Show help [boolean]
|
|
312
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
313
|
+
multiple modules [array] [default: ["*"]]
|
|
314
|
+
-g, --girDirectories GIR directories [array]
|
|
315
|
+
--root Root directory of your project [string]
|
|
316
|
+
-o, --outdir Directory to output to [string] [default: "./@types"]
|
|
317
|
+
-i, --ignore Modules that should be ignored [array] [default: []]
|
|
318
|
+
--configName Specify a custom name for the configuration file
|
|
319
|
+
[string] [default: ".ts-for-girrc.js"]
|
|
320
|
+
-v, --verbose Switch on/off the verbose mode [boolean] [default: false]
|
|
321
|
+
|
|
322
|
+
Examples:
|
|
323
|
+
ts-for-gir copy -o ./gir Copy found *.gir files to
|
|
324
|
+
./gir
|
|
325
|
+
ts-for-gir copy -g /usr/share/gir-1.0 Copy all found *.gir files
|
|
326
|
+
--ignore=Gtk-3.0 xrandr-1.3 -o ./gir excluding Gtk-3.0 and
|
|
327
|
+
xrandr-1.3 to ./gir
|
|
328
|
+
```
|
|
173
329
|
|
|
174
|
-
|
|
175
|
-
|
|
330
|
+
## Analyze report files
|
|
331
|
+
|
|
332
|
+
```
|
|
333
|
+
ts-for-gir analyze [options]
|
|
334
|
+
|
|
335
|
+
Analyze report files generated by ts-for-gir reporter
|
|
336
|
+
|
|
337
|
+
Options:
|
|
338
|
+
--version Show version number [boolean]
|
|
339
|
+
--help Show help [boolean]
|
|
340
|
+
-f, --reportFile Path to the report file to analyze [string] [required]
|
|
341
|
+
-s, --severity Filter by problem severity
|
|
342
|
+
(debug, info, warning, error, critical) [array]
|
|
343
|
+
-c, --category Filter by problem category [array]
|
|
344
|
+
-n, --namespace Filter by namespace/module [array]
|
|
345
|
+
-t, --type Filter by specific type name [array]
|
|
346
|
+
--search Search for text in messages, details, or type names
|
|
347
|
+
[string]
|
|
348
|
+
--since Filter problems since date/time (ISO format) [string]
|
|
349
|
+
--until Filter problems until date/time (ISO format) [string]
|
|
350
|
+
--top Show top N most problematic items [number] [default: 10]
|
|
351
|
+
--format Output format (table, json, csv)
|
|
352
|
+
[string] [default: "table"]
|
|
353
|
+
-e, --export Export filtered results to file [string]
|
|
354
|
+
-d, --detailed Show detailed problem information [boolean] [default: false]
|
|
355
|
+
--summary Show summary statistics only [boolean] [default: false]
|
|
356
|
+
-v, --verbose Enable verbose output [boolean] [default: false]
|
|
357
|
+
|
|
358
|
+
Examples:
|
|
359
|
+
ts-for-gir analyze -f ./ts-for-gir-report.json
|
|
360
|
+
Show summary statistics of the report
|
|
361
|
+
ts-for-gir analyze -f ./report.json --severity error critical
|
|
362
|
+
Show only critical and error problems
|
|
363
|
+
ts-for-gir analyze -f ./report.json --category type_resolution --format table
|
|
364
|
+
Show type resolution problems
|
|
365
|
+
ts-for-gir analyze -f ./report.json --namespace Gtk --top 10
|
|
366
|
+
Show top 10 problems in Gtk namespace
|
|
367
|
+
ts-for-gir analyze -f ./report.json --search "Unable to resolve" --export errors.json
|
|
368
|
+
Export unresolved type errors to file
|
|
176
369
|
```
|
|
370
|
+
|
|
371
|
+
The `analyze` command helps debug type generation issues by providing powerful filtering and analysis capabilities for ts-for-gir report files.
|
|
372
|
+
|
|
373
|
+
**Key Features:**
|
|
374
|
+
- **Comprehensive Filtering**: Filter by severity, category, namespace, type name, or search text
|
|
375
|
+
- **Multiple Output Formats**: Table, JSON, or CSV format for different use cases
|
|
376
|
+
- **Statistical Analysis**: Show most problematic types, namespaces, and categories
|
|
377
|
+
- **Export Capabilities**: Save filtered results for further analysis
|
|
378
|
+
- **Time-based Filtering**: Analyze problems within specific time ranges
|
|
379
|
+
|
|
177
380
|
## Config
|
|
178
381
|
|
|
179
382
|
In addition to the option of passing options as a CLI flag, you can also write them in a config file.
|
|
@@ -192,12 +395,28 @@ export default {
|
|
|
192
395
|
|
|
193
396
|
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
397
|
|
|
195
|
-
You can pass the config file name to the CLI using [configName](#
|
|
398
|
+
You can pass the config file name to the CLI using [configName](#configname).
|
|
399
|
+
|
|
400
|
+
### Doc-specific config
|
|
401
|
+
|
|
402
|
+
For documentation generation, you can configure doc-specific options in the config file:
|
|
403
|
+
|
|
404
|
+
```js
|
|
405
|
+
export default {
|
|
406
|
+
modules: ['Gtk-4.0', 'Gdk-4.0', 'Gio-2.0', 'GLib-2.0', 'GObject-2.0'],
|
|
407
|
+
outdir: './docs',
|
|
408
|
+
merge: true,
|
|
409
|
+
jsonDir: './json',
|
|
410
|
+
readme: './DOC.md',
|
|
411
|
+
verbose: true,
|
|
412
|
+
sourceLinkTemplate: 'https://github.com/user/repo/blob/main/{path}#L{line}',
|
|
413
|
+
}
|
|
414
|
+
```
|
|
196
415
|
|
|
197
416
|
## Options
|
|
198
417
|
|
|
199
418
|
### 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:
|
|
419
|
+
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
420
|
```js
|
|
202
421
|
girDirectories: [
|
|
203
422
|
// General gir files
|
|
@@ -216,7 +435,7 @@ girDirectories: [
|
|
|
216
435
|
```
|
|
217
436
|
|
|
218
437
|
### 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"`.
|
|
438
|
+
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
439
|
|
|
221
440
|
Here is an example of how you can use the outdir option in the CLI of `ts-for-gir`:
|
|
222
441
|
|
|
@@ -253,7 +472,7 @@ The `ignoreVersionConflicts` CLI option allows you to disable the prompt to choo
|
|
|
253
472
|
|
|
254
473
|
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
474
|
|
|
256
|
-
Another way to disable the prompt and ignore conflicting versions of `.gir` files is to use the [ignore CLI option](#ignore).
|
|
475
|
+
Another way to disable the prompt and ignore conflicting versions of `.gir` files is to use the [ignore CLI option](#ignore).
|
|
257
476
|
|
|
258
477
|
### print
|
|
259
478
|
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 +482,7 @@ By default, the print option is disabled and the generated types will be saved t
|
|
|
263
482
|
### configName
|
|
264
483
|
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
484
|
|
|
266
|
-
By default
|
|
485
|
+
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
486
|
|
|
268
487
|
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
488
|
|
|
@@ -287,10 +506,24 @@ When `noComments` is set to `true`, `ts-for-gir` will not include TSDoc comments
|
|
|
287
506
|
To use the noComments option, pass it as a command line argument to `ts-for-gir`:
|
|
288
507
|
|
|
289
508
|
```bash
|
|
290
|
-
ts-for-gir generate * --noComments
|
|
509
|
+
ts-for-gir generate * --noComments
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
### noPrettyPrint
|
|
513
|
+
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.
|
|
514
|
+
|
|
515
|
+
```bash
|
|
516
|
+
ts-for-gir generate * --noPrettyPrint
|
|
291
517
|
```
|
|
292
518
|
|
|
293
|
-
|
|
519
|
+
### noAdvancedVariants
|
|
520
|
+
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.
|
|
521
|
+
|
|
522
|
+
```bash
|
|
523
|
+
ts-for-gir generate * --noAdvancedVariants=false
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
### package
|
|
294
527
|
|
|
295
528
|
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
529
|
|
|
@@ -298,14 +531,14 @@ The `--package` option of ts-for-gir is used to package the generated TypeScript
|
|
|
298
531
|
|
|
299
532
|
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
533
|
|
|
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-
|
|
534
|
+
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
535
|
|
|
303
536
|
> You can change the NPM package scope name with the [`--npmScope`](#npmscope) option.
|
|
304
537
|
|
|
305
538
|
To use the generated NPM package in your TypeScript project, you can also install our pregenerated packages:
|
|
306
539
|
|
|
307
540
|
```bash
|
|
308
|
-
npm install @girs/gtk-
|
|
541
|
+
npm install @girs/gtk-4.0
|
|
309
542
|
```
|
|
310
543
|
|
|
311
544
|
Then, import the desired module in your TypeScript code:
|
|
@@ -329,10 +562,10 @@ The `--npmScope` CLI option can be used to specify a custom NPM package scope na
|
|
|
329
562
|
Here's an example command to generate NPM packages with a custom scope name:
|
|
330
563
|
|
|
331
564
|
```bash
|
|
332
|
-
ts-for-gir
|
|
565
|
+
ts-for-gir generate * --package --npmScope my-scope
|
|
333
566
|
```
|
|
334
567
|
|
|
335
|
-
This command will generate NPM packages with the scope
|
|
568
|
+
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
569
|
|
|
337
570
|
## Ambient modules
|
|
338
571
|
|
|
@@ -348,7 +581,7 @@ To use ambient modules, the `ambient.d.ts` file must be imported either in the c
|
|
|
348
581
|
```json
|
|
349
582
|
// tsconfig.json
|
|
350
583
|
{
|
|
351
|
-
"compilerOptions": {
|
|
584
|
+
"compilerOptions": {
|
|
352
585
|
"lib": ["ESNext"],
|
|
353
586
|
"types": [],
|
|
354
587
|
"target": "ESNext",
|
|
@@ -376,4 +609,20 @@ declare module "gi://Gtk" {
|
|
|
376
609
|
import Gtk from "gi://Gtk?version=4.0";
|
|
377
610
|
export default Gtk;
|
|
378
611
|
}
|
|
379
|
-
```
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
## reporter
|
|
615
|
+
|
|
616
|
+
The `--reporter` option enables the generation of a problem reporter and creates a detailed report file.
|
|
617
|
+
|
|
618
|
+
```bash
|
|
619
|
+
ts-for-gir generate * --reporter
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
## reporterOutput
|
|
623
|
+
|
|
624
|
+
The `--reporterOutput` option specifies the output file path for the reporter. The default value is `ts-for-gir-report.json`.
|
|
625
|
+
|
|
626
|
+
```bash
|
|
627
|
+
ts-for-gir generate * --reporterOutput custom-report.json
|
|
628
|
+
```
|