@ts-for-gir/cli 4.0.0-beta.21 → 4.0.0-beta.22
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 +83 -57
- package/package.json +14 -14
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 for GObject Introspection Repository (GIR) files, primarily for GJS applications.
|
|
22
22
|
|
|
23
23
|
## Getting started
|
|
24
24
|
|
|
@@ -45,10 +45,8 @@ TypeScript type definition generator for GObject introspection GIR files
|
|
|
45
45
|
Commands:
|
|
46
46
|
ts-for-gir generate [modules..] Generates .d.ts files from GIR for GJS
|
|
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 doc [modules..] The HTML documentation generator is not yet implemented, but feel free to implement it 🤗
|
|
52
50
|
|
|
53
51
|
Options:
|
|
54
52
|
--version Show version number [boolean]
|
|
@@ -57,13 +55,13 @@ 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
|
|
|
@@ -77,12 +75,9 @@ Generates .d.ts files from GIR for GJS
|
|
|
77
75
|
Options:
|
|
78
76
|
--version Show version number [boolean]
|
|
79
77
|
--help Show help [boolean]
|
|
80
|
-
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
81
|
-
tiple modules [array] [default: ["*"]]
|
|
78
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts multiple modules [array] [default: ["*"]]
|
|
82
79
|
-g, --girDirectories GIR directories
|
|
83
|
-
[array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share
|
|
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-*"]]
|
|
80
|
+
[array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share/*/gir-1.0","/usr/share/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/lib64/mutter-*","/usr/lib/mutter-*","/usr/lib/x86_64-linux-gnu/mutter-*"]]
|
|
86
81
|
--root Root directory of your project
|
|
87
82
|
[string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
|
|
88
83
|
-o, --outdir Directory to output to
|
|
@@ -90,45 +85,46 @@ Options:
|
|
|
90
85
|
-i, --ignore Modules that should be ignored
|
|
91
86
|
[array] [default: []]
|
|
92
87
|
-v, --verbose Switch on/off the verbose mode
|
|
93
|
-
|
|
88
|
+
[boolean] [default: false]
|
|
94
89
|
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
95
90
|
multiple versions are detected
|
|
96
|
-
|
|
91
|
+
[boolean] [default: false]
|
|
97
92
|
-p, --print Print the output to console and create no files
|
|
98
|
-
|
|
93
|
+
[boolean] [default: false]
|
|
99
94
|
--configName Specify a custom name for the configuration file
|
|
100
95
|
[string] [default: ".ts-for-girrc.js"]
|
|
101
|
-
-d, --noNamespace Do not export all symbols for each module as a
|
|
102
|
-
|
|
96
|
+
-d, --noNamespace Do not export all symbols for each module as a namespace
|
|
97
|
+
[boolean] [default: false]
|
|
103
98
|
-n, --noComments Do not generate documentation comments
|
|
104
|
-
|
|
99
|
+
[boolean] [default: false]
|
|
105
100
|
--promisify Generate promisified functions for async/finish
|
|
106
|
-
calls
|
|
101
|
+
calls [boolean] [default: true]
|
|
107
102
|
--npmScope Scope of the generated NPM packages
|
|
108
103
|
[string] [default: "@girs"]
|
|
109
|
-
--workspace Uses the workspace protocol for the generated
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
--onlyVersionPrefix Only use the version prefix for the ambient
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
104
|
+
--workspace Uses the workspace protocol for the generated packages
|
|
105
|
+
which can be used with package managers like
|
|
106
|
+
Yarn and PNPM [boolean] [default: false]
|
|
107
|
+
--onlyVersionPrefix Only use the version prefix for the ambient module
|
|
108
|
+
exports. This is useful if you want to use different
|
|
109
|
+
library versions of the same library in your project.
|
|
110
|
+
[boolean] [default: false]
|
|
111
|
+
--noPrettyPrint Do not prettify the generated types
|
|
112
|
+
[boolean] [default: false]
|
|
113
|
+
--noAdvancedVariants Disable GLib.Variant class with string parsing
|
|
114
|
+
[boolean] [default: true]
|
|
117
115
|
--package Generate the typescript types with package.json
|
|
118
|
-
support
|
|
116
|
+
support [boolean] [default: false]
|
|
119
117
|
|
|
120
118
|
Examples:
|
|
121
|
-
ts-for-gir generate Run 'ts-for-gir generate' in your
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
need for your project
|
|
119
|
+
ts-for-gir generate Run 'ts-for-gir generate' in your gjs
|
|
120
|
+
project to generate typings for your
|
|
121
|
+
project, pass the gir modules you need
|
|
125
122
|
ts-for-gir generate Gtk* You can also use wild cards
|
|
126
|
-
ts-for-gir generate '*' If you want to parse all of your
|
|
127
|
-
|
|
128
|
-
ts-for-gir generate --configName='.ts-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
ndr-1.3 k-4.0 and xrandr-1.3
|
|
123
|
+
ts-for-gir generate '*' If you want to parse all of your locally
|
|
124
|
+
installed gir modules run
|
|
125
|
+
ts-for-gir generate --configName='.ts-for-gir.gtk4.rc.js' Use a special config file
|
|
126
|
+
ts-for-gir generate --ignore=Gtk-4.0 xrandr-1.3 Generate .d.ts files but not for
|
|
127
|
+
Gtk-4.0 and xrandr-1.3
|
|
132
128
|
```
|
|
133
129
|
|
|
134
130
|
## List available GIR modules
|
|
@@ -143,25 +139,20 @@ Lists all available GIR modules
|
|
|
143
139
|
Options:
|
|
144
140
|
--version Show version number [boolean]
|
|
145
141
|
--help Show help [boolean]
|
|
146
|
-
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts multiple
|
|
147
|
-
|
|
142
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts multiple modules
|
|
143
|
+
[array] [default: ["*"]]
|
|
148
144
|
-g, --girDirectories GIR directories
|
|
149
|
-
[array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share
|
|
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-*"]]
|
|
145
|
+
[array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share/*/gir-1.0","/usr/share/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/lib64/mutter-*","/usr/lib/mutter-*","/usr/lib/x86_64-linux-gnu/mutter-*"]]
|
|
152
146
|
--root Root directory of your project
|
|
153
147
|
[string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
|
|
154
148
|
-i, --ignore Modules that should be ignored [array] [default: []]
|
|
155
149
|
--configName Specify a custom name for the configuration file
|
|
156
150
|
[string] [default: ".ts-for-girrc.js"]
|
|
157
|
-
-v, --verbose Switch on/off the verbose mode [
|
|
151
|
+
-v, --verbose Switch on/off the verbose mode [boolean] [default: false]
|
|
158
152
|
|
|
159
153
|
Examples:
|
|
160
|
-
ts-for-gir list -g ./vala-girs/gir-1.0 Lists all available GIR modules in .
|
|
161
|
-
|
|
162
|
-
ts-for-gir list --ignore=Gtk-3.0 xrandr- Lists all available GIR modules in /
|
|
163
|
-
1.3 usr/share/gir-1.0 but not Gtk-3.0 an
|
|
164
|
-
d xrandr-1.3
|
|
154
|
+
ts-for-gir list -g ./vala-girs/gir-1.0 Lists all available GIR modules in ./vala-girs/gir-1.0
|
|
155
|
+
ts-for-gir list --ignore=Gtk-3.0 xrandr-1.3 Lists all available GIR modules but not Gtk-3.0 and xrandr-1.3
|
|
165
156
|
```
|
|
166
157
|
|
|
167
158
|
## Generate HTML documentation
|
|
@@ -171,9 +162,30 @@ $ npx @ts-for-gir/cli doc --help
|
|
|
171
162
|
|
|
172
163
|
ts-for-gir doc [modules..]
|
|
173
164
|
|
|
174
|
-
The HTML documentation generator is not yet implemented, but feel free to
|
|
175
|
-
|
|
165
|
+
The HTML documentation generator is not yet implemented, but feel free to implement it 🤗
|
|
166
|
+
|
|
167
|
+
Options:
|
|
168
|
+
--version Show version number [boolean]
|
|
169
|
+
--help Show help [boolean]
|
|
170
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts multiple modules
|
|
171
|
+
[array] [default: ["*"]]
|
|
172
|
+
-g, --girDirectories GIR directories
|
|
173
|
+
[array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share/*/gir-1.0","/usr/share/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/lib64/mutter-*","/usr/lib/mutter-*","/usr/lib/x86_64-linux-gnu/mutter-*"]]
|
|
174
|
+
--root Root directory of your project
|
|
175
|
+
[string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
|
|
176
|
+
-o, --outdir Directory to output to
|
|
177
|
+
[string] [default: "./@types"]
|
|
178
|
+
-i, --ignore Modules that should be ignored
|
|
179
|
+
[array] [default: []]
|
|
180
|
+
-v, --verbose Switch on/off the verbose mode
|
|
181
|
+
[boolean] [default: false]
|
|
182
|
+
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
183
|
+
multiple versions are detected
|
|
184
|
+
[boolean] [default: false]
|
|
185
|
+
--configName Specify a custom name for the configuration file
|
|
186
|
+
[string] [default: ".ts-for-girrc.js"]
|
|
176
187
|
```
|
|
188
|
+
|
|
177
189
|
## Config
|
|
178
190
|
|
|
179
191
|
In addition to the option of passing options as a CLI flag, you can also write them in a config file.
|
|
@@ -287,10 +299,24 @@ When `noComments` is set to `true`, `ts-for-gir` will not include TSDoc comments
|
|
|
287
299
|
To use the noComments option, pass it as a command line argument to `ts-for-gir`:
|
|
288
300
|
|
|
289
301
|
```bash
|
|
290
|
-
ts-for-gir generate * --noComments
|
|
302
|
+
ts-for-gir generate * --noComments
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### noPrettyPrint
|
|
306
|
+
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.
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
ts-for-gir generate * --noPrettyPrint
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### noAdvancedVariants
|
|
313
|
+
The `noAdvancedVariants` option disables the advanced GLib.Variant class with string parsing capabilities. This option is enabled by default (`true`) as these advanced features can impact performance, especially with older TypeScript versions.
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
ts-for-gir generate * --noAdvancedVariants=false
|
|
291
317
|
```
|
|
292
318
|
|
|
293
|
-
|
|
319
|
+
### package
|
|
294
320
|
|
|
295
321
|
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
322
|
|
|
@@ -298,14 +324,14 @@ The `--package` option of ts-for-gir is used to package the generated TypeScript
|
|
|
298
324
|
|
|
299
325
|
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
326
|
|
|
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-
|
|
327
|
+
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
328
|
|
|
303
329
|
> You can change the NPM package scope name with the [`--npmScope`](#npmscope) option.
|
|
304
330
|
|
|
305
331
|
To use the generated NPM package in your TypeScript project, you can also install our pregenerated packages:
|
|
306
332
|
|
|
307
333
|
```bash
|
|
308
|
-
npm install @girs/gtk-
|
|
334
|
+
npm install @girs/gtk-4.0
|
|
309
335
|
```
|
|
310
336
|
|
|
311
337
|
Then, import the desired module in your TypeScript code:
|
|
@@ -329,10 +355,10 @@ The `--npmScope` CLI option can be used to specify a custom NPM package scope na
|
|
|
329
355
|
Here's an example command to generate NPM packages with a custom scope name:
|
|
330
356
|
|
|
331
357
|
```bash
|
|
332
|
-
ts-for-gir
|
|
358
|
+
ts-for-gir generate * --package --npmScope my-scope
|
|
333
359
|
```
|
|
334
360
|
|
|
335
|
-
This command will generate NPM packages with the scope
|
|
361
|
+
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
362
|
|
|
337
363
|
## Ambient modules
|
|
338
364
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-for-gir/cli",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.22",
|
|
4
4
|
"description": "TypeScript type definition generator for GObject introspection GIR files",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -54,29 +54,29 @@
|
|
|
54
54
|
],
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/inquirer": "^9.0.7",
|
|
57
|
-
"@types/node": "^22.13.
|
|
57
|
+
"@types/node": "^22.13.11",
|
|
58
58
|
"@types/yargs": "^17.0.33",
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
60
|
-
"@typescript-eslint/parser": "^8.
|
|
61
|
-
"eslint": "^9.
|
|
62
|
-
"eslint-config-prettier": "^10.
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^8.27.0",
|
|
60
|
+
"@typescript-eslint/parser": "^8.27.0",
|
|
61
|
+
"eslint": "^9.22.0",
|
|
62
|
+
"eslint-config-prettier": "^10.1.1",
|
|
63
63
|
"eslint-plugin-prettier": "^5.2.3",
|
|
64
64
|
"rimraf": "^6.0.1",
|
|
65
65
|
"ts-node": "^10.9.2",
|
|
66
|
-
"typescript": "^5.
|
|
66
|
+
"typescript": "^5.8.2"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@gi.ts/parser": "^2.0.0",
|
|
70
|
-
"@inquirer/prompts": "^7.
|
|
71
|
-
"@ts-for-gir/generator-base": "^4.0.0-beta.
|
|
72
|
-
"@ts-for-gir/generator-html-doc": "^4.0.0-beta.
|
|
73
|
-
"@ts-for-gir/generator-typescript": "^4.0.0-beta.
|
|
74
|
-
"@ts-for-gir/lib": "^4.0.0-beta.
|
|
70
|
+
"@inquirer/prompts": "^7.4.0",
|
|
71
|
+
"@ts-for-gir/generator-base": "^4.0.0-beta.22",
|
|
72
|
+
"@ts-for-gir/generator-html-doc": "^4.0.0-beta.22",
|
|
73
|
+
"@ts-for-gir/generator-typescript": "^4.0.0-beta.22",
|
|
74
|
+
"@ts-for-gir/lib": "^4.0.0-beta.22",
|
|
75
75
|
"colorette": "^2.0.20",
|
|
76
76
|
"cosmiconfig": "^9.0.0",
|
|
77
77
|
"glob": "^11.0.1",
|
|
78
|
-
"inquirer": "^12.
|
|
79
|
-
"prettier": "^3.5.
|
|
78
|
+
"inquirer": "^12.5.0",
|
|
79
|
+
"prettier": "^3.5.3",
|
|
80
80
|
"yargs": "^17.7.2"
|
|
81
81
|
}
|
|
82
82
|
}
|