@ts-for-gir/cli 4.0.0-beta.2 → 4.0.0-beta.21
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 +43 -140
- package/lib/commands/copy.d.ts +12 -0
- package/lib/commands/copy.js +78 -0
- package/lib/commands/copy.js.map +1 -0
- package/lib/commands/doc.js +1 -3
- package/lib/commands/doc.js.map +1 -1
- package/lib/commands/generate.js +4 -10
- package/lib/commands/generate.js.map +1 -1
- package/lib/commands/index.d.ts +1 -0
- package/lib/commands/index.js +1 -0
- package/lib/commands/index.js.map +1 -1
- package/lib/commands/list.js +8 -3
- package/lib/commands/list.js.map +1 -1
- package/lib/config.d.ts +23 -8
- package/lib/config.js +85 -74
- package/lib/config.js.map +1 -1
- package/lib/generation-handler.d.ts +2 -2
- package/lib/generation-handler.js +5 -5
- package/lib/generation-handler.js.map +1 -1
- package/lib/module-loader.d.ts +23 -14
- package/lib/module-loader.js +87 -101
- package/lib/module-loader.js.map +1 -1
- package/lib/start.js +2 -1
- package/lib/start.js.map +1 -1
- package/package.json +19 -18
- package/src/commands/copy.ts +94 -0
- package/src/commands/doc.ts +3 -3
- package/src/commands/generate.ts +7 -10
- package/src/commands/index.ts +1 -0
- package/src/commands/list.ts +11 -3
- package/src/config.ts +98 -81
- package/src/generation-handler.ts +7 -9
- package/src/module-loader.ts +103 -114
- package/src/start.ts +2 -1
package/README.md
CHANGED
|
@@ -18,13 +18,12 @@
|
|
|
18
18
|
|
|
19
19
|
# CLI
|
|
20
20
|
|
|
21
|
-
CLI tool to generate Typescript Type Definition files for GJS
|
|
21
|
+
CLI tool to generate Typescript Type Definition files for GJS.
|
|
22
22
|
|
|
23
23
|
## Getting started
|
|
24
24
|
|
|
25
25
|
``` bash
|
|
26
|
-
|
|
27
|
-
ts-for-gir --help
|
|
26
|
+
npx @ts-for-gir/cli --help
|
|
28
27
|
```
|
|
29
28
|
|
|
30
29
|
> Alternatively you can also add @ts-for-gir/cli to your dependencies:
|
|
@@ -32,28 +31,28 @@ ts-for-gir --help
|
|
|
32
31
|
> npm install --save-dev @ts-for-gir/cli
|
|
33
32
|
> ```
|
|
34
33
|
>
|
|
35
|
-
> Or
|
|
34
|
+
> Or globally install it:
|
|
36
35
|
> ```bash
|
|
37
|
-
>
|
|
36
|
+
> npm install -g @ts-for-gir/cli
|
|
37
|
+
> ts-for-gir --help
|
|
38
38
|
> ```
|
|
39
39
|
|
|
40
|
-
After you have installed `@ts-for-gir/cli` you can run the `ts-for-gir` command:
|
|
41
|
-
|
|
42
40
|
```bash
|
|
43
|
-
$ ts-for-gir --help
|
|
41
|
+
$ npx @ts-for-gir/cli --help
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
TypeScript type definition generator for GObject introspection GIR files
|
|
46
44
|
|
|
47
45
|
Commands:
|
|
48
|
-
ts-for-gir generate [modules..] Generates .d.ts files from GIR for GJS
|
|
49
|
-
e-gtk
|
|
46
|
+
ts-for-gir generate [modules..] Generates .d.ts files from GIR for GJS
|
|
50
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 d
|
|
49
|
+
irectory
|
|
51
50
|
ts-for-gir doc [modules..] The HTML documentation generator is not yet i
|
|
52
51
|
mplemented, but feel free to implement it 🤗
|
|
53
52
|
|
|
54
53
|
Options:
|
|
55
54
|
--version Show version number [boolean]
|
|
56
|
-
--help Show help [boolean]
|
|
55
|
+
--help Show help [boolean]
|
|
57
56
|
```
|
|
58
57
|
|
|
59
58
|
## Example
|
|
@@ -64,24 +63,16 @@ To generate the Typescript type definitions of Gtk-4.0 for GJS run:
|
|
|
64
63
|
ts-for-gir generate Gtk-4.0
|
|
65
64
|
```
|
|
66
65
|
|
|
67
|
-
To generate this types for [node-gtk](https://github.com/romgrk/node-gtk) run:
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
ts-for-gir generate Gtk-4.0 -e node
|
|
71
|
-
```
|
|
72
|
-
|
|
73
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.
|
|
74
67
|
|
|
75
68
|
## Generate .d.ts files
|
|
76
69
|
|
|
77
70
|
```bash
|
|
78
|
-
$ ts-for-gir generate --help
|
|
79
|
-
|
|
80
|
-
ts-for-gir generate [modules..]
|
|
71
|
+
$ npx @ts-for-gir/cli generate --help
|
|
81
72
|
|
|
82
73
|
ts-for-gir generate [modules..]
|
|
83
74
|
|
|
84
|
-
Generates .d.ts files from GIR for GJS
|
|
75
|
+
Generates .d.ts files from GIR for GJS
|
|
85
76
|
|
|
86
77
|
Options:
|
|
87
78
|
--version Show version number [boolean]
|
|
@@ -90,48 +81,50 @@ Options:
|
|
|
90
81
|
tiple modules [array] [default: ["*"]]
|
|
91
82
|
-g, --girDirectories GIR directories
|
|
92
83
|
[array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share
|
|
93
|
-
/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/
|
|
94
|
-
|
|
95
|
-
usr/lib/x86_64-linux-gnu/mutter-11","/usr/lib/x86_64-linux-gnu/mutter-12","/ho
|
|
96
|
-
me/jumplink/.local/share/flatpak/exports/share/gir-1.0","/var/lib/flatpak/expo
|
|
97
|
-
rts/share/gir-1.0"]]
|
|
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-*"]]
|
|
98
86
|
--root Root directory of your project
|
|
99
|
-
|
|
87
|
+
[string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
|
|
100
88
|
-o, --outdir Directory to output to
|
|
101
89
|
[string] [default: "./@types"]
|
|
102
90
|
-i, --ignore Modules that should be ignored
|
|
103
91
|
[array] [default: []]
|
|
104
92
|
-v, --verbose Switch on/off the verbose mode
|
|
105
93
|
[string] [default: false]
|
|
106
|
-
--ignoreVersionConflicts
|
|
107
|
-
|
|
94
|
+
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
95
|
+
multiple versions are detected
|
|
96
|
+
[string] [default: false]
|
|
108
97
|
-p, --print Print the output to console and create no files
|
|
109
98
|
[string] [default: false]
|
|
110
|
-
--configName
|
|
111
|
-
|
|
99
|
+
--configName Specify a custom name for the configuration file
|
|
100
|
+
[string] [default: ".ts-for-girrc.js"]
|
|
112
101
|
-d, --noNamespace Do not export all symbols for each module as a n
|
|
113
102
|
amespace [string] [default: false]
|
|
114
103
|
-n, --noComments Do not generate documentation comments
|
|
115
104
|
[string] [default: false]
|
|
116
|
-
--noDebugComments Do not generate debugging inline comments
|
|
117
|
-
[string] [default: false]
|
|
118
|
-
--fixConflicts Fix Inheritance and implementation type conflict
|
|
119
|
-
s [string] [default: true]
|
|
120
105
|
--promisify Generate promisified functions for async/finish
|
|
121
106
|
calls [string] [default: true]
|
|
122
107
|
--npmScope Scope of the generated NPM packages
|
|
123
108
|
[string] [default: "@girs"]
|
|
109
|
+
--workspace Uses the workspace protocol for the generated pa
|
|
110
|
+
ckages which can be used with package managers l
|
|
111
|
+
ike Yarn and PNPM [string] [default: false]
|
|
112
|
+
--onlyVersionPrefix Only use the version prefix for the ambient modu
|
|
113
|
+
le exports. This is useful if, for whatever reas
|
|
114
|
+
on, you want to use different library versions o
|
|
115
|
+
f the same library in your project.
|
|
116
|
+
[string] [default: false]
|
|
117
|
+
--package Generate the typescript types with package.json
|
|
118
|
+
support [string] [default: false]
|
|
124
119
|
|
|
125
120
|
Examples:
|
|
126
121
|
ts-for-gir generate Run 'ts-for-gir generate' in your gj
|
|
127
|
-
s
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
s project to generate typings for yo
|
|
123
|
+
ur project, pass the gir modules you
|
|
124
|
+
need for your project
|
|
130
125
|
ts-for-gir generate Gtk* You can also use wild cards
|
|
131
126
|
ts-for-gir generate '*' If you want to parse all of your loc
|
|
132
127
|
ally installed gir modules run
|
|
133
|
-
ts-for-gir generate '*' -e gjs Generate .d.ts. files only for gjs
|
|
134
|
-
ts-for-gir generate '*' -e node Generate .d.ts. files only for node
|
|
135
128
|
ts-for-gir generate --configName='.ts-fo Use a special config file
|
|
136
129
|
r-gir.gtk4.rc.js
|
|
137
130
|
ts-for-gir generate --ignore=Gtk-4.0 xra Generate .d.ts. files but not for Gt
|
|
@@ -141,7 +134,7 @@ Examples:
|
|
|
141
134
|
## List available GIR modules
|
|
142
135
|
|
|
143
136
|
```bash
|
|
144
|
-
$ ts-for-gir list --help
|
|
137
|
+
$ npx @ts-for-gir/cli list --help
|
|
145
138
|
|
|
146
139
|
ts-for-gir list [modules..]
|
|
147
140
|
|
|
@@ -154,13 +147,12 @@ Options:
|
|
|
154
147
|
dules [array] [default: ["*"]]
|
|
155
148
|
-g, --girDirectories GIR directories
|
|
156
149
|
[array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share
|
|
157
|
-
/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
rts/share/gir-1.0"]]
|
|
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"]
|
|
162
154
|
-i, --ignore Modules that should be ignored [array] [default: []]
|
|
163
|
-
--configName
|
|
155
|
+
--configName Specify a custom name for the configuration file
|
|
164
156
|
[string] [default: ".ts-for-girrc.js"]
|
|
165
157
|
-v, --verbose Switch on/off the verbose mode [string] [default: false]
|
|
166
158
|
|
|
@@ -175,7 +167,7 @@ Examples:
|
|
|
175
167
|
## Generate HTML documentation
|
|
176
168
|
|
|
177
169
|
```bash
|
|
178
|
-
$ ts-for-gir doc --help
|
|
170
|
+
$ npx @ts-for-gir/cli doc --help
|
|
179
171
|
|
|
180
172
|
ts-for-gir doc [modules..]
|
|
181
173
|
|
|
@@ -190,16 +182,11 @@ To do that, create a new config file called `.ts-for-girrc.js` in your project r
|
|
|
190
182
|
```js
|
|
191
183
|
// or on CommonJs: exports.default = {
|
|
192
184
|
export default {
|
|
193
|
-
print: false,
|
|
194
185
|
verbose: true,
|
|
195
|
-
environments: ['gjs', 'node'],
|
|
196
186
|
outdir: '@types',
|
|
197
187
|
girDirectories: ['/usr/share/gir-1.0'],
|
|
198
188
|
modules: ['*'],
|
|
199
189
|
ignore: [],
|
|
200
|
-
noNamespace: false,
|
|
201
|
-
buildType: 'lib',
|
|
202
|
-
moduleType: 'esm'
|
|
203
190
|
}
|
|
204
191
|
```
|
|
205
192
|
|
|
@@ -241,97 +228,23 @@ In this example, the generated TypeScript types will be saved in the `./types` d
|
|
|
241
228
|
|
|
242
229
|
It is important to note that the outdir option should be a valid directory path, and `ts-for-gir` will create the directory if it does not exist. If the specified directory already contains files, `ts-for-gir` will overwrite the existing files with the newly generated types.
|
|
243
230
|
|
|
244
|
-
### environments
|
|
245
|
-
The `environments` option allows you to specify the JavaScript environment for which you want to generate the TypeScript type definitions. The available values are `"gjs"` and `"node"`. You can also specify both environments.
|
|
246
|
-
|
|
247
|
-
The default value for this option is `"gjs"`.
|
|
248
|
-
|
|
249
|
-
To specify the environments option when running ts-for-gir, you would add the `--environments` or `-e` flag, followed by a comma-separated list of values. For example:
|
|
250
|
-
|
|
251
|
-
```bash
|
|
252
|
-
ts-for-gir generate * --environments gjs node
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
This option is useful if you want to generate type definitions for use in different JavaScript environments, such as in a `GJS` application or in a `Node.js` application using [node-gtk](https://github.com/romgrk/node-gtk). By specifying the appropriate environment, ts-for-gir can generate type definitions that are optimized for that environment, ensuring that your code will be type-checked correctly and you will receive meaningful error messages in your development environment.
|
|
256
|
-
|
|
257
231
|
### ignore
|
|
258
232
|
The `ignore` CLI option allows you to specify modules that should be ignored when generating TypeScript types. This can be useful if you have multiple versions of a library installed but only want to generate types for one of them.
|
|
259
233
|
|
|
260
234
|
To use the ignore option, pass one or more module names as arguments. For example, to ignore the `Gtk-3.0` module, you would use the following command:
|
|
261
235
|
|
|
262
236
|
```bash
|
|
263
|
-
ts-for-gir generate Gtk-* --ignore Gtk-3.0
|
|
237
|
+
ts-for-gir generate Gtk-* --ignore */Gtk-3.0
|
|
264
238
|
```
|
|
265
239
|
|
|
266
240
|
You can also ignore multiple modules:
|
|
267
241
|
|
|
268
242
|
```bash
|
|
269
|
-
ts-for-gir generate * --ignore Gtk-2.0 Gtk-3.0 Gtk-4.0
|
|
243
|
+
ts-for-gir generate * --ignore */Gtk-2.0 */Gtk-3.0 */Gtk-4.0
|
|
270
244
|
```
|
|
271
245
|
|
|
272
246
|
Note that ignoring a module will prevent ts-for-gir from generating types for that module and any submodules that it might contain.
|
|
273
247
|
|
|
274
|
-
### buildType
|
|
275
|
-
`ts-for-gir` supports two build types for generating the types: `"lib"` and `"types"`.
|
|
276
|
-
|
|
277
|
-
* If `"lib"` is specified, `.js` files are generated as well as `.d.ts`, this is useful for some bundlers that expect a `.js` file. Some bundlers are also able to generate the import of this file only once, even if it occurs multiple times in your code.
|
|
278
|
-
* If `"types"` is specified, only `.d.ts` files are generated. In this mode it is recommended to add the generated `"@types/gjs.d.ts"` and `"@types/ambient.d.ts"` under `"include"` in the `tsconfig` to make the generated types known in your project.
|
|
279
|
-
|
|
280
|
-
### moduleType
|
|
281
|
-
The `moduleType` CLI option determines the format in which the generated JavaScript files should be exported. The option takes either `"esm"` or `"cjs"` as its value, with `"esm"` being the default.
|
|
282
|
-
|
|
283
|
-
> This option is only relevant if the `buildType` is set to `"lib"`. The choice of `moduleType` may affect how the generated code is used in other parts of your project, so it's important to choose the right format that works best for your use case.
|
|
284
|
-
|
|
285
|
-
The choice of `moduleType` is also important in the context of the bundler that you plan to use in your project. For example, if you are using a bundler that only supports ESM (such as Rollup), you would need to set `moduleType` to "esm". On the other hand, if you are using a bundler that supports both ESM and CommonJS (such as Webpack), you can choose whichever format you prefer. Ultimately, the choice of `moduleType` will depend on your project requirements and the tools that you are using. For Example, if you want to build a GNOME Shell Extension, you should use `"cjs"` because `ESM` is currently not supported for GNOME Shell Extensions. For [node-gtk](https://github.com/romgrk/node-gtk) you also need to use `"cjs"`. If you want to build a regular GJS Application we recommend to use `ESM`.
|
|
286
|
-
|
|
287
|
-
When `"esm"` is set, the generated JavaScript files will use the ECMAScript module (ESM) format for imports and exports. For example, the generated code might look like this:
|
|
288
|
-
|
|
289
|
-
```ts
|
|
290
|
-
// Gtk-4.0.d.ts
|
|
291
|
-
import type GLib from './GLib-2.0.js';
|
|
292
|
-
|
|
293
|
-
namespace Gtk {
|
|
294
|
-
class Window extends Widget {
|
|
295
|
-
...
|
|
296
|
-
}
|
|
297
|
-
function builder_error_quark(): GLib.Quark
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export default Gtk;
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
```js
|
|
304
|
-
// Gtk-4.0.js
|
|
305
|
-
import Gtk from 'gi://Gtk?version=4.0';
|
|
306
|
-
export default Gtk;
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
> The `"esm"` module type is recommended for GJS applications as it makes use of the ESM import syntax, which is more modern and flexible compared to imports.gi / CommonJS imports. This allows for a more streamlined and convenient way of using the generated types in your GJS application. Support for ES modules can be activated in `gjs` with its `gjs -m` flag.
|
|
310
|
-
|
|
311
|
-
When `"cjs"` and [`noNamespace`](#nonamespace) is set, the generated JavaScript files will use the CommonJS format exports and the `imports.gi` object for imports. For example:
|
|
312
|
-
|
|
313
|
-
```ts
|
|
314
|
-
// Gtk-4.0.d.ts
|
|
315
|
-
import type * as GLib from './GLib-2.0.js';
|
|
316
|
-
|
|
317
|
-
export class Window extends Widget {
|
|
318
|
-
...
|
|
319
|
-
}
|
|
320
|
-
export function builder_error_quark(): GLib.Quark
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
```js
|
|
324
|
-
// Gtk-4.0.js
|
|
325
|
-
imports.gi.versions.Gtk = '4.0'
|
|
326
|
-
const Gtk = imports.gi.Gtk;
|
|
327
|
-
|
|
328
|
-
module.exports = { Gtk };
|
|
329
|
-
exports.default = Gtk;
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
> It is recommended to also set the [noNamespace](#nonamespace) option to true when using the `"cjs"` moduleType option. This will ensure that the generated code is fully compatible with the CommonJS format.
|
|
333
|
-
|
|
334
|
-
|
|
335
248
|
### verbose
|
|
336
249
|
The `--verbose` or `-v` option is a flag that can be used to enable verbose output in the console when running the CLI. When this option is enabled, additional warnings and information about the processing of GIR files and the generation of TypeScript definitions will be printed to the console. This information can be useful for debugging purposes or for understanding what is happening behind the scenes when generating the TypeScript definitions.
|
|
337
250
|
|
|
@@ -377,16 +290,6 @@ To use the noComments option, pass it as a command line argument to `ts-for-gir`
|
|
|
377
290
|
ts-for-gir generate * --noComments`
|
|
378
291
|
```
|
|
379
292
|
|
|
380
|
-
### noDebugComments
|
|
381
|
-
The `noDebugComments` CLI option is used to control the generation of inline comments in the generated TypeScript files. These comments are used for debugging purposes and can be useful in tracking down issues with the generated types.
|
|
382
|
-
|
|
383
|
-
By default, the `noDebugComments` option is disabled and these inline comments will be included in the generated TypeScript files. If you do not require these comments for debugging purposes, you can use the -`-noDebugComments` option to disable their generation and keep your TypeScript code more compact.
|
|
384
|
-
|
|
385
|
-
### fixConflicts
|
|
386
|
-
The `fixConflicts` CLI option is used to resolve type conflicts between the GObject Introspection descriptions in GIR XML format and TypeScript. For example, properties in the GIR XML format can be overwritten by methods, which is not allowed in TypeScript. When this option is active, `ts-for-gir` attempts to resolve these conflicts. However, it's important to note that this may result in generating types that do not exist.
|
|
387
|
-
|
|
388
|
-
> If you have found an issue with the `fixConflicts` CLI option, we encourage you to report it. Reporting issues helps improve the quality of `ts-for-gir` and makes it a better tool for everyone.
|
|
389
|
-
|
|
390
293
|
# package
|
|
391
294
|
|
|
392
295
|
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`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything you need for the `ts-for-gir copy` command is located here
|
|
3
|
+
*/
|
|
4
|
+
import { Argv } from 'yargs';
|
|
5
|
+
import type { ConfigFlags } from '@ts-for-gir/lib';
|
|
6
|
+
export declare const copy: {
|
|
7
|
+
command: string;
|
|
8
|
+
description: string;
|
|
9
|
+
builder: ((args: Argv<any>) => Argv<ConfigFlags>) | ((args: Argv<any>) => void);
|
|
10
|
+
handler: (args: ConfigFlags) => Promise<void>;
|
|
11
|
+
examples: readonly [string, (string | undefined)?][];
|
|
12
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything you need for the `ts-for-gir copy` command is located here
|
|
3
|
+
*/
|
|
4
|
+
import { copyFile, mkdir } from 'fs/promises';
|
|
5
|
+
import { basename, join } from 'path';
|
|
6
|
+
import { ModuleLoader } from '../module-loader.js';
|
|
7
|
+
import { Config } from '../config.js';
|
|
8
|
+
import { Logger, ERROR_NO_MODULES_FOUND } from '@ts-for-gir/lib';
|
|
9
|
+
const command = 'copy [modules..]';
|
|
10
|
+
const description = 'Scan for *.gir files and copy them to a new directory';
|
|
11
|
+
const builder = (yargs) => {
|
|
12
|
+
const optionNames = Object.keys(Config.copyOptions);
|
|
13
|
+
for (const optionName of optionNames) {
|
|
14
|
+
yargs = yargs.option(optionName, Config.copyOptions[optionName]);
|
|
15
|
+
}
|
|
16
|
+
return yargs.example(examples);
|
|
17
|
+
};
|
|
18
|
+
const copyGirFile = async (config, depModule) => {
|
|
19
|
+
if (!depModule.path) {
|
|
20
|
+
Logger.danger(`- ${depModule.packageName} not found`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!config.outdir) {
|
|
24
|
+
Logger.error(`outdir not found`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const filename = basename(depModule.path);
|
|
28
|
+
const dest = join(config.outdir, filename);
|
|
29
|
+
if (depModule.path === dest) {
|
|
30
|
+
Logger.yellow(`Skip ${depModule.path}`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
Logger.success(`Copy ${depModule.path}`);
|
|
34
|
+
await copyFile(depModule.path, dest);
|
|
35
|
+
};
|
|
36
|
+
const handler = async (args) => {
|
|
37
|
+
const config = await Config.load(args);
|
|
38
|
+
const generateConfig = Config.getOptionsGeneration(config);
|
|
39
|
+
const moduleLoader = new ModuleLoader(generateConfig);
|
|
40
|
+
const { grouped, failed } = await moduleLoader.getModules(config.modules, config.ignore);
|
|
41
|
+
const moduleGroups = Object.values(grouped);
|
|
42
|
+
if (Object.keys(grouped).length === 0) {
|
|
43
|
+
return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
|
|
44
|
+
}
|
|
45
|
+
if (!config.outdir) {
|
|
46
|
+
Logger.error(`outdir not found`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
await mkdir(config.outdir, { recursive: true }).catch((err) => {
|
|
50
|
+
Logger.error(`Failed to copy gir files to ${config.outdir}: ${err}`);
|
|
51
|
+
});
|
|
52
|
+
for (const module of moduleGroups) {
|
|
53
|
+
for (const mod of module.modules) {
|
|
54
|
+
await copyGirFile(config, mod);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (failed.length > 0) {
|
|
58
|
+
Logger.danger('\nDependencies not found:');
|
|
59
|
+
for (const fail of failed) {
|
|
60
|
+
Logger.white(`- ${fail}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const examples = [
|
|
65
|
+
[`${Config.appName} copy -o ./gir`, `Copy found *.gir files to ./gir`],
|
|
66
|
+
[
|
|
67
|
+
`${Config.appName} copy -g /usr/share/gir-1.0 --ignore=Gtk-3.0 xrandr-1.3 -o ./gir`,
|
|
68
|
+
'Copy all found *.gir files in /usr/share/gir-1.0 excluding Gtk-3.0 and xrandr-1.3 to ./gir',
|
|
69
|
+
],
|
|
70
|
+
];
|
|
71
|
+
export const copy = {
|
|
72
|
+
command,
|
|
73
|
+
description,
|
|
74
|
+
builder,
|
|
75
|
+
handler,
|
|
76
|
+
examples,
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.js","sourceRoot":"","sources":["../../src/commands/copy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAIhE,MAAM,OAAO,GAAG,kBAAkB,CAAA;AAElC,MAAM,WAAW,GAAG,uDAAuD,CAAA;AAG3E,MAAM,OAAO,GAAsC,CAAC,KAAgB,EAAE,EAAE;IACpE,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;IACnD,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACnC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAA;IACpE,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAsB,CAAA;AACvD,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,KAAK,EAAE,MAAkB,EAAE,SAA8B,EAAE,EAAE;IAC7E,IAAI,CAAC,SAAS,CAAC,IAAI,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
8
8
|
import { ModuleLoader } from '../module-loader.js';
|
|
9
9
|
const command = 'doc [modules..]';
|
|
10
10
|
const description = 'The HTML documentation generator is not yet implemented, but feel free to implement it 🤗';
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
11
|
const builder = (yargs) => {
|
|
13
12
|
const optionNames = Object.keys(Config.docOptions);
|
|
14
13
|
for (const optionName of optionNames) {
|
|
@@ -16,10 +15,9 @@ const builder = (yargs) => {
|
|
|
16
15
|
}
|
|
17
16
|
return yargs.example(examples);
|
|
18
17
|
};
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
18
|
const handler = async (args) => {
|
|
21
19
|
const config = await Config.load(args);
|
|
22
|
-
const generateConfig = Config.
|
|
20
|
+
const generateConfig = Config.getOptionsGeneration(config);
|
|
23
21
|
const moduleLoader = new ModuleLoader(generateConfig);
|
|
24
22
|
const { keep } = await moduleLoader.getModulesResolved(config.modules, config.ignore || [], config.ignoreVersionConflicts);
|
|
25
23
|
if (keep.length === 0) {
|
package/lib/commands/doc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc.js","sourceRoot":"","sources":["../../src/commands/doc.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAIlD,MAAM,OAAO,GAAG,iBAAiB,CAAA;AAEjC,MAAM,WAAW,GAAG,2FAA2F,CAAA;
|
|
1
|
+
{"version":3,"file":"doc.js","sourceRoot":"","sources":["../../src/commands/doc.ts"],"names":[],"mappings":"AAAA;;GAEG;AAG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,MAAM,CAAC,cAAc,CAAC,CAAC,CAAA;IACtE,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,iBAAiB,CAAC,cAAc,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC9E,MAAM,QAAQ,GAAG,YAAY,CAAC,iBAAiB,CAAA;IAE/C,MAAM,QAAQ,CAAC,KAAK,CAChB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,EACzE,QAAQ,CACX,CAAA;AACL,CAAC,CAAA;AAED,MAAM,QAAQ,GAAqC,EAAE,CAAA;AAErD,MAAM,CAAC,MAAM,GAAG,GAAG;IACf,OAAO;IACP,WAAW;IACX,OAAO;IACP,OAAO;IACP,QAAQ;CACX,CAAA"}
|
package/lib/commands/generate.js
CHANGED
|
@@ -9,8 +9,7 @@ import { ModuleLoader } from '../module-loader.js';
|
|
|
9
9
|
import prettier from 'prettier';
|
|
10
10
|
import { Formatter } from '@ts-for-gir/lib';
|
|
11
11
|
const command = 'generate [modules..]';
|
|
12
|
-
const description = 'Generates .d.ts files from GIR for GJS';
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
const description = 'Generates Typescript type definition .d.ts files from GIR for GJS';
|
|
14
13
|
const builder = (yargs) => {
|
|
15
14
|
const optionNames = Object.keys(Config.generateOptions);
|
|
16
15
|
for (const optionName of optionNames) {
|
|
@@ -18,15 +17,15 @@ const builder = (yargs) => {
|
|
|
18
17
|
}
|
|
19
18
|
return yargs.example(examples);
|
|
20
19
|
};
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
20
|
const handler = async (args) => {
|
|
23
21
|
const config = await Config.load(args);
|
|
24
|
-
const generateConfig = Config.
|
|
22
|
+
const generateConfig = Config.getOptionsGeneration(config);
|
|
25
23
|
const moduleLoader = new ModuleLoader(generateConfig);
|
|
26
24
|
const { keep } = await moduleLoader.getModulesResolved(config.modules, config.ignore || [], config.ignoreVersionConflicts);
|
|
27
25
|
if (keep.length === 0) {
|
|
28
26
|
return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
|
|
29
27
|
}
|
|
28
|
+
moduleLoader.parse(keep);
|
|
30
29
|
const tsForGir = new GenerationHandler(generateConfig, GeneratorType.TYPES);
|
|
31
30
|
const girModules = Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module);
|
|
32
31
|
moduleLoader.dependencyManager.registerFormatter('dts', new TypeScriptFormatter());
|
|
@@ -39,8 +38,6 @@ const examples = [
|
|
|
39
38
|
],
|
|
40
39
|
[`${Config.appName} generate Gtk*`, 'You can also use wild cards'],
|
|
41
40
|
[`${Config.appName} generate '*'`, 'If you want to parse all of your locally installed gir modules run'],
|
|
42
|
-
[`${Config.appName} generate '*' -e gjs`, 'Generate .d.ts. files only for gjs'],
|
|
43
|
-
[`${Config.appName} generate '*' -e node`, 'Generate .d.ts. files only for node'],
|
|
44
41
|
[`${Config.appName} generate --configName='.ts-for-gir.gtk4.rc.js`, 'Use a special config file'],
|
|
45
42
|
[
|
|
46
43
|
`${Config.appName} generate --ignore=Gtk-4.0 xrandr-1.3`,
|
|
@@ -58,11 +55,8 @@ class TypeScriptFormatter extends Formatter {
|
|
|
58
55
|
});
|
|
59
56
|
}
|
|
60
57
|
catch (error) {
|
|
58
|
+
Logger.warn('[TypeScriptFormatter] Failed to format with prettier, returning original input', error);
|
|
61
59
|
return Promise.resolve(input);
|
|
62
|
-
// TODO: Don't return invalid TypeScript, useful for debugging for now.
|
|
63
|
-
// console.error('Failed to format output...')
|
|
64
|
-
// console.error(input)
|
|
65
|
-
// throw error
|
|
66
60
|
}
|
|
67
61
|
}
|
|
68
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAA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CAAC,GAAG,MAAM,CAAC,OAAO,gBAAgB,EAAE,6BAA6B,CAAC;IAClE,CAAC,GAAG,MAAM,CAAC,OAAO,eAAe,EAAE,oEAAoE,CAAC;IACxG,CAAC,GAAG,MAAM,CAAC,OAAO,gDAAgD,EAAE,2BAA2B,CAAC;IAChG;QACI,GAAG,MAAM,CAAC,OAAO,uCAAuC;QACxD,0DAA0D;KAC7D;CACJ,CAAA;AAED,MAAM,mBAAoB,SAAQ,SAAS;IACvC,MAAM,CAAC,KAAa;QAChB,IAAI,CAAC;YACD,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE;gBAC1B,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,YAAY;gBACpB,UAAU,EAAE,GAAG;gBACf,QAAQ,EAAE,CAAC;aACd,CAAC,CAAA;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,gFAAgF,EAAE,KAAK,CAAC,CAAA;YACpG,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACjC,CAAC;IACL,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,OAAO;IACP,WAAW;IACX,OAAO;IACP,OAAO;IACP,QAAQ;CACX,CAAA"}
|
package/lib/commands/index.d.ts
CHANGED
package/lib/commands/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
|
package/lib/commands/list.js
CHANGED
|
@@ -6,7 +6,6 @@ import { Config } from '../config.js';
|
|
|
6
6
|
import { Logger, ERROR_NO_MODULES_FOUND, ResolveType } from '@ts-for-gir/lib';
|
|
7
7
|
const command = 'list [modules..]';
|
|
8
8
|
const description = 'Lists all available GIR modules';
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
9
|
const builder = (yargs) => {
|
|
11
10
|
const optionNames = Object.keys(Config.listOptions);
|
|
12
11
|
for (const optionName of optionNames) {
|
|
@@ -14,10 +13,9 @@ const builder = (yargs) => {
|
|
|
14
13
|
}
|
|
15
14
|
return yargs.example(examples);
|
|
16
15
|
};
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
16
|
const handler = async (args) => {
|
|
19
17
|
const config = await Config.load(args);
|
|
20
|
-
const generateConfig = Config.
|
|
18
|
+
const generateConfig = Config.getOptionsGeneration(config);
|
|
21
19
|
const moduleLoader = new ModuleLoader(generateConfig);
|
|
22
20
|
const { grouped, failed } = await moduleLoader.getModules(config.modules, config.ignore);
|
|
23
21
|
const moduleGroups = Object.values(grouped);
|
|
@@ -27,10 +25,15 @@ const handler = async (args) => {
|
|
|
27
25
|
const conflictModules = moduleGroups.filter((moduleGroup) => moduleGroup.hasConflict);
|
|
28
26
|
const byHandModules = moduleGroups.filter((moduleGroup) => moduleGroup.modules[0].resolvedBy === ResolveType.BY_HAND);
|
|
29
27
|
const depModules = moduleGroups.filter((moduleGroup) => moduleGroup.modules[0].resolvedBy === ResolveType.DEPENDENCE);
|
|
28
|
+
Logger.info('\nSearch for gir files in:');
|
|
29
|
+
for (const dir of config.girDirectories) {
|
|
30
|
+
Logger.white(`- ${dir}`);
|
|
31
|
+
}
|
|
30
32
|
Logger.info('\nSelected Modules:');
|
|
31
33
|
for (const moduleGroup of byHandModules) {
|
|
32
34
|
for (const depModule of moduleGroup.modules) {
|
|
33
35
|
Logger.white(`- ${depModule.packageName}`);
|
|
36
|
+
Logger.gray(` - ${depModule.path}`);
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
if (depModules.length > 0) {
|
|
@@ -38,6 +41,7 @@ const handler = async (args) => {
|
|
|
38
41
|
for (const moduleGroup of depModules) {
|
|
39
42
|
for (const depModule of moduleGroup.modules) {
|
|
40
43
|
Logger.white(`- ${depModule.packageName}`);
|
|
44
|
+
Logger.gray(`- ${depModule.path}`);
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
}
|
|
@@ -47,6 +51,7 @@ const handler = async (args) => {
|
|
|
47
51
|
Logger.white(`- ${moduleGroup.namespace}`);
|
|
48
52
|
for (const conflictModule of moduleGroup.modules) {
|
|
49
53
|
Logger.white(` - ${conflictModule.packageName}`);
|
|
54
|
+
Logger.gray(` - ${conflictModule.path}`);
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
}
|
package/lib/commands/list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAI7E,MAAM,OAAO,GAAG,kBAAkB,CAAA;AAElC,MAAM,WAAW,GAAG,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAI7E,MAAM,OAAO,GAAG,kBAAkB,CAAA;AAElC,MAAM,WAAW,GAAG,iCAAiC,CAAA;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