@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/src/commands/generate.ts
CHANGED
|
@@ -15,9 +15,9 @@ import { Formatter } from '@ts-for-gir/lib'
|
|
|
15
15
|
|
|
16
16
|
const command = 'generate [modules..]'
|
|
17
17
|
|
|
18
|
-
const description = 'Generates .d.ts files from GIR for GJS'
|
|
18
|
+
const description = 'Generates Typescript type definition .d.ts files from GIR for GJS'
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
|
|
22
22
|
const optionNames = Object.keys(Config.generateOptions)
|
|
23
23
|
for (const optionName of optionNames) {
|
|
@@ -26,11 +26,11 @@ const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
|
|
|
26
26
|
return yargs.example(examples) as Argv<ConfigFlags>
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
const handler = async (args: ConfigFlags) => {
|
|
31
31
|
const config = await Config.load(args)
|
|
32
32
|
|
|
33
|
-
const generateConfig = Config.
|
|
33
|
+
const generateConfig = Config.getOptionsGeneration(config)
|
|
34
34
|
const moduleLoader = new ModuleLoader(generateConfig)
|
|
35
35
|
const { keep } = await moduleLoader.getModulesResolved(
|
|
36
36
|
config.modules,
|
|
@@ -42,6 +42,8 @@ const handler = async (args: ConfigFlags) => {
|
|
|
42
42
|
return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories))
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
moduleLoader.parse(keep)
|
|
46
|
+
|
|
45
47
|
const tsForGir = new GenerationHandler(generateConfig, GeneratorType.TYPES)
|
|
46
48
|
|
|
47
49
|
const girModules = Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module)
|
|
@@ -57,8 +59,6 @@ const examples: ReadonlyArray<[string, string?]> = [
|
|
|
57
59
|
],
|
|
58
60
|
[`${Config.appName} generate Gtk*`, 'You can also use wild cards'],
|
|
59
61
|
[`${Config.appName} generate '*'`, 'If you want to parse all of your locally installed gir modules run'],
|
|
60
|
-
[`${Config.appName} generate '*' -e gjs`, 'Generate .d.ts. files only for gjs'],
|
|
61
|
-
[`${Config.appName} generate '*' -e node`, 'Generate .d.ts. files only for node'],
|
|
62
62
|
[`${Config.appName} generate --configName='.ts-for-gir.gtk4.rc.js`, 'Use a special config file'],
|
|
63
63
|
[
|
|
64
64
|
`${Config.appName} generate --ignore=Gtk-4.0 xrandr-1.3`,
|
|
@@ -76,11 +76,8 @@ class TypeScriptFormatter extends Formatter {
|
|
|
76
76
|
tabWidth: 4,
|
|
77
77
|
})
|
|
78
78
|
} catch (error) {
|
|
79
|
+
Logger.warn('[TypeScriptFormatter] Failed to format with prettier, returning original input', error)
|
|
79
80
|
return Promise.resolve(input)
|
|
80
|
-
// TODO: Don't return invalid TypeScript, useful for debugging for now.
|
|
81
|
-
// console.error('Failed to format output...')
|
|
82
|
-
// console.error(input)
|
|
83
|
-
// throw error
|
|
84
81
|
}
|
|
85
82
|
}
|
|
86
83
|
}
|
package/src/commands/index.ts
CHANGED
package/src/commands/list.ts
CHANGED
|
@@ -13,7 +13,7 @@ const command = 'list [modules..]'
|
|
|
13
13
|
|
|
14
14
|
const description = 'Lists all available GIR modules'
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
|
|
18
18
|
const optionNames = Object.keys(Config.listOptions)
|
|
19
19
|
for (const optionName of optionNames) {
|
|
@@ -22,10 +22,10 @@ const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
|
|
|
22
22
|
return yargs.example(examples) as Argv<ConfigFlags>
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
const handler = async (args: ConfigFlags) => {
|
|
27
27
|
const config = await Config.load(args)
|
|
28
|
-
const generateConfig = Config.
|
|
28
|
+
const generateConfig = Config.getOptionsGeneration(config)
|
|
29
29
|
const moduleLoader = new ModuleLoader(generateConfig)
|
|
30
30
|
const { grouped, failed } = await moduleLoader.getModules(config.modules, config.ignore)
|
|
31
31
|
const moduleGroups = Object.values(grouped)
|
|
@@ -43,10 +43,16 @@ const handler = async (args: ConfigFlags) => {
|
|
|
43
43
|
(moduleGroup) => moduleGroup.modules[0].resolvedBy === ResolveType.DEPENDENCE,
|
|
44
44
|
)
|
|
45
45
|
|
|
46
|
+
Logger.info('\nSearch for gir files in:')
|
|
47
|
+
for (const dir of config.girDirectories) {
|
|
48
|
+
Logger.white(`- ${dir}`)
|
|
49
|
+
}
|
|
50
|
+
|
|
46
51
|
Logger.info('\nSelected Modules:')
|
|
47
52
|
for (const moduleGroup of byHandModules) {
|
|
48
53
|
for (const depModule of moduleGroup.modules) {
|
|
49
54
|
Logger.white(`- ${depModule.packageName}`)
|
|
55
|
+
Logger.gray(` - ${depModule.path}`)
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
58
|
|
|
@@ -55,6 +61,7 @@ const handler = async (args: ConfigFlags) => {
|
|
|
55
61
|
for (const moduleGroup of depModules) {
|
|
56
62
|
for (const depModule of moduleGroup.modules) {
|
|
57
63
|
Logger.white(`- ${depModule.packageName}`)
|
|
64
|
+
Logger.gray(`- ${depModule.path}`)
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
}
|
|
@@ -65,6 +72,7 @@ const handler = async (args: ConfigFlags) => {
|
|
|
65
72
|
Logger.white(`- ${moduleGroup.namespace}`)
|
|
66
73
|
for (const conflictModule of moduleGroup.modules) {
|
|
67
74
|
Logger.white(` - ${conflictModule.packageName}`)
|
|
75
|
+
Logger.gray(` - ${conflictModule.path}`)
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
78
|
}
|
package/src/config.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
/**
|
|
3
3
|
* Default values, parse the config file and handle CLI flags
|
|
4
4
|
*/
|
|
@@ -6,9 +6,10 @@ import { Options } from 'yargs'
|
|
|
6
6
|
import { cosmiconfig, Options as ConfigSearchOptions } from 'cosmiconfig'
|
|
7
7
|
import { join, extname, dirname, resolve } from 'path'
|
|
8
8
|
import { writeFile } from 'fs/promises'
|
|
9
|
+
import { existsSync } from 'fs'
|
|
9
10
|
import { merge, isEqual, Logger, APP_NAME, APP_USAGE, ERROR_CONFIG_EXTENSION_UNSUPPORTED } from '@ts-for-gir/lib'
|
|
10
11
|
|
|
11
|
-
import type { UserConfig, ConfigFlags, UserConfigLoadResult,
|
|
12
|
+
import type { UserConfig, ConfigFlags, UserConfigLoadResult, OptionsGeneration } from '@ts-for-gir/lib'
|
|
12
13
|
|
|
13
14
|
export class Config {
|
|
14
15
|
static appName = APP_NAME
|
|
@@ -30,11 +31,16 @@ export class Config {
|
|
|
30
31
|
ignoreVersionConflicts: false,
|
|
31
32
|
noNamespace: false,
|
|
32
33
|
noComments: false,
|
|
33
|
-
noDebugComments: false,
|
|
34
|
-
fixConflicts: true,
|
|
35
34
|
promisify: true,
|
|
36
35
|
npmScope: '@girs',
|
|
37
|
-
|
|
36
|
+
workspace: false,
|
|
37
|
+
onlyVersionPrefix: false,
|
|
38
|
+
noPrettyPrint: false,
|
|
39
|
+
// Disabled by default because advanced variants are complicated,
|
|
40
|
+
// it does impact performance (especially on older typescript versions)
|
|
41
|
+
// and we'd need to test it works with the updated bindings
|
|
42
|
+
noAdvancedVariants: true,
|
|
43
|
+
package: false,
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
static configFilePath = join(process.cwd(), Config.defaults.configName)
|
|
@@ -87,7 +93,7 @@ export class Config {
|
|
|
87
93
|
},
|
|
88
94
|
ignoreVersionConflicts: {
|
|
89
95
|
type: 'boolean',
|
|
90
|
-
description: '
|
|
96
|
+
description: 'Skip prompts for library version selection when multiple versions are detected',
|
|
91
97
|
default: Config.defaults.ignoreVersionConflicts,
|
|
92
98
|
normalize: true,
|
|
93
99
|
},
|
|
@@ -100,7 +106,7 @@ export class Config {
|
|
|
100
106
|
},
|
|
101
107
|
configName: {
|
|
102
108
|
type: 'string',
|
|
103
|
-
description: '
|
|
109
|
+
description: 'Specify a custom name for the configuration file',
|
|
104
110
|
default: Config.defaults.configName,
|
|
105
111
|
normalize: true,
|
|
106
112
|
},
|
|
@@ -118,18 +124,6 @@ export class Config {
|
|
|
118
124
|
default: Config.defaults.noComments,
|
|
119
125
|
normalize: true,
|
|
120
126
|
},
|
|
121
|
-
noDebugComments: {
|
|
122
|
-
type: 'boolean',
|
|
123
|
-
description: 'Do not generate debugging inline comments',
|
|
124
|
-
default: Config.defaults.noDebugComments,
|
|
125
|
-
normalize: true,
|
|
126
|
-
},
|
|
127
|
-
fixConflicts: {
|
|
128
|
-
type: 'boolean',
|
|
129
|
-
description: 'Fix Inheritance and implementation type conflicts',
|
|
130
|
-
default: Config.defaults.fixConflicts,
|
|
131
|
-
normalize: true,
|
|
132
|
-
},
|
|
133
127
|
promisify: {
|
|
134
128
|
type: 'boolean',
|
|
135
129
|
description: 'Generate promisified functions for async/finish calls',
|
|
@@ -142,10 +136,36 @@ export class Config {
|
|
|
142
136
|
default: Config.defaults.npmScope,
|
|
143
137
|
normalize: true,
|
|
144
138
|
},
|
|
145
|
-
|
|
139
|
+
workspace: {
|
|
140
|
+
type: 'boolean',
|
|
141
|
+
description:
|
|
142
|
+
'Uses the workspace protocol for the generated packages which can be used with package managers like Yarn and PNPM',
|
|
143
|
+
default: Config.defaults.workspace,
|
|
144
|
+
normalize: true,
|
|
145
|
+
},
|
|
146
|
+
onlyVersionPrefix: {
|
|
147
|
+
type: 'boolean',
|
|
148
|
+
description:
|
|
149
|
+
'Only use the version prefix for the ambient module exports. This is useful if, for whatever reason, you want to use different library versions of the same library in your project.',
|
|
150
|
+
default: Config.defaults.onlyVersionPrefix,
|
|
151
|
+
normalize: true,
|
|
152
|
+
},
|
|
153
|
+
noPrettyPrint: {
|
|
146
154
|
type: 'boolean',
|
|
147
|
-
description: '
|
|
148
|
-
default: Config.defaults.
|
|
155
|
+
description: 'Do not prettify the generated types',
|
|
156
|
+
default: Config.defaults.noPrettyPrint,
|
|
157
|
+
normalize: true,
|
|
158
|
+
},
|
|
159
|
+
noAdvancedVariants: {
|
|
160
|
+
type: 'boolean',
|
|
161
|
+
description: 'Disable GLib.Variant class with string parsing',
|
|
162
|
+
default: Config.defaults.noAdvancedVariants,
|
|
163
|
+
normalize: true,
|
|
164
|
+
},
|
|
165
|
+
package: {
|
|
166
|
+
type: 'boolean',
|
|
167
|
+
description: 'Generate the typescript types with package.json support',
|
|
168
|
+
default: Config.defaults.package,
|
|
149
169
|
normalize: true,
|
|
150
170
|
},
|
|
151
171
|
}
|
|
@@ -165,16 +185,29 @@ export class Config {
|
|
|
165
185
|
configName: this.options.configName,
|
|
166
186
|
noNamespace: this.options.noNamespace,
|
|
167
187
|
noComments: this.options.noComments,
|
|
168
|
-
noDebugComments: this.options.noDebugComments,
|
|
169
|
-
fixConflicts: this.options.fixConflicts,
|
|
170
188
|
promisify: this.options.promisify,
|
|
171
189
|
npmScope: this.options.npmScope,
|
|
172
|
-
|
|
190
|
+
workspace: this.options.workspace,
|
|
191
|
+
onlyVersionPrefix: this.options.onlyVersionPrefix,
|
|
192
|
+
noPrettyPrint: this.options.noPrettyPrint,
|
|
193
|
+
noAdvancedVariants: this.options.noAdvancedVariants,
|
|
194
|
+
package: this.options.package,
|
|
173
195
|
}
|
|
174
196
|
|
|
175
197
|
static listOptions = {
|
|
176
198
|
modules: this.options.modules,
|
|
177
199
|
girDirectories: Config.options.girDirectories,
|
|
200
|
+
root: this.options.root,
|
|
201
|
+
ignore: Config.options.ignore,
|
|
202
|
+
configName: Config.options.configName,
|
|
203
|
+
verbose: Config.options.verbose,
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
static copyOptions = {
|
|
207
|
+
modules: this.options.modules,
|
|
208
|
+
girDirectories: Config.options.girDirectories,
|
|
209
|
+
root: this.options.root,
|
|
210
|
+
outdir: Config.options.outdir,
|
|
178
211
|
ignore: Config.options.ignore,
|
|
179
212
|
configName: Config.options.configName,
|
|
180
213
|
verbose: Config.options.verbose,
|
|
@@ -183,6 +216,7 @@ export class Config {
|
|
|
183
216
|
static docOptions = {
|
|
184
217
|
modules: this.options.modules,
|
|
185
218
|
girDirectories: Config.options.girDirectories,
|
|
219
|
+
root: this.options.root,
|
|
186
220
|
outdir: Config.options.outdir,
|
|
187
221
|
ignore: Config.options.ignore,
|
|
188
222
|
verbose: Config.options.verbose,
|
|
@@ -227,7 +261,7 @@ export class Config {
|
|
|
227
261
|
loaders: {
|
|
228
262
|
// ESM loader
|
|
229
263
|
'.js': async (filepath) => {
|
|
230
|
-
|
|
264
|
+
|
|
231
265
|
const file = await import(filepath)
|
|
232
266
|
|
|
233
267
|
// Files with `exports.default = { ... }`
|
|
@@ -254,21 +288,9 @@ export class Config {
|
|
|
254
288
|
return configFile
|
|
255
289
|
}
|
|
256
290
|
|
|
257
|
-
public static
|
|
258
|
-
const generateConfig:
|
|
259
|
-
|
|
260
|
-
root: config.root,
|
|
261
|
-
outdir: config.outdir,
|
|
262
|
-
verbose: config.verbose,
|
|
263
|
-
noNamespace: config.noNamespace,
|
|
264
|
-
noComments: config.noComments,
|
|
265
|
-
noDebugComments: config.noDebugComments,
|
|
266
|
-
fixConflicts: config.fixConflicts,
|
|
267
|
-
promisify: config.promisify,
|
|
268
|
-
npmScope: config.npmScope,
|
|
269
|
-
packageYarn: config.packageYarn,
|
|
270
|
-
noPrettyPrint: false,
|
|
271
|
-
noAdvancedVariants: true,
|
|
291
|
+
public static getOptionsGeneration(config: UserConfig): OptionsGeneration {
|
|
292
|
+
const generateConfig: OptionsGeneration = {
|
|
293
|
+
...config,
|
|
272
294
|
}
|
|
273
295
|
return generateConfig
|
|
274
296
|
}
|
|
@@ -287,21 +309,7 @@ export class Config {
|
|
|
287
309
|
const configFileData = configFile?.config || {}
|
|
288
310
|
|
|
289
311
|
const config: UserConfig = {
|
|
290
|
-
|
|
291
|
-
ignoreVersionConflicts: options.ignoreVersionConflicts,
|
|
292
|
-
print: options.print,
|
|
293
|
-
root: options.root,
|
|
294
|
-
outdir: options.outdir,
|
|
295
|
-
girDirectories: options.girDirectories,
|
|
296
|
-
ignore: options.ignore,
|
|
297
|
-
modules: options.modules,
|
|
298
|
-
noNamespace: options.noNamespace,
|
|
299
|
-
noComments: options.noComments,
|
|
300
|
-
noDebugComments: options.noDebugComments,
|
|
301
|
-
fixConflicts: options.fixConflicts,
|
|
302
|
-
promisify: options.promisify,
|
|
303
|
-
npmScope: options.npmScope,
|
|
304
|
-
packageYarn: options.packageYarn,
|
|
312
|
+
...options,
|
|
305
313
|
}
|
|
306
314
|
|
|
307
315
|
if (configFileData) {
|
|
@@ -363,20 +371,6 @@ export class Config {
|
|
|
363
371
|
) {
|
|
364
372
|
config.noComments = configFileData.noComments
|
|
365
373
|
}
|
|
366
|
-
// noDebugComments
|
|
367
|
-
if (
|
|
368
|
-
config.noDebugComments === Config.options.noDebugComments.default &&
|
|
369
|
-
typeof configFileData.noDebugComments === 'boolean'
|
|
370
|
-
) {
|
|
371
|
-
config.noDebugComments = configFileData.noDebugComments
|
|
372
|
-
}
|
|
373
|
-
// fixConflicts
|
|
374
|
-
if (
|
|
375
|
-
config.fixConflicts === Config.options.fixConflicts.default &&
|
|
376
|
-
typeof configFileData.fixConflicts === 'boolean'
|
|
377
|
-
) {
|
|
378
|
-
config.fixConflicts = configFileData.fixConflicts
|
|
379
|
-
}
|
|
380
374
|
// promisify
|
|
381
375
|
if (
|
|
382
376
|
config.promisify === Config.options.promisify.default &&
|
|
@@ -388,12 +382,37 @@ export class Config {
|
|
|
388
382
|
if (config.npmScope === Config.options.npmScope.default && configFileData.npmScope) {
|
|
389
383
|
config.npmScope = configFileData.npmScope
|
|
390
384
|
}
|
|
391
|
-
//
|
|
385
|
+
// workspace
|
|
386
|
+
if (
|
|
387
|
+
config.workspace === Config.options.workspace.default &&
|
|
388
|
+
typeof configFileData.workspace === 'boolean'
|
|
389
|
+
) {
|
|
390
|
+
config.workspace = configFileData.workspace
|
|
391
|
+
}
|
|
392
|
+
// onlyVersionPrefix
|
|
392
393
|
if (
|
|
393
|
-
config.
|
|
394
|
-
typeof configFileData.
|
|
394
|
+
config.onlyVersionPrefix === Config.options.onlyVersionPrefix.default &&
|
|
395
|
+
typeof configFileData.onlyVersionPrefix === 'boolean'
|
|
395
396
|
) {
|
|
396
|
-
config.
|
|
397
|
+
config.onlyVersionPrefix = configFileData.onlyVersionPrefix
|
|
398
|
+
}
|
|
399
|
+
// noPrettyPrint
|
|
400
|
+
if (
|
|
401
|
+
config.noPrettyPrint === Config.options.noPrettyPrint.default &&
|
|
402
|
+
typeof configFileData.noPrettyPrint === 'boolean'
|
|
403
|
+
) {
|
|
404
|
+
config.noPrettyPrint = configFileData.noPrettyPrint
|
|
405
|
+
}
|
|
406
|
+
// noAdvancedVariants
|
|
407
|
+
if (
|
|
408
|
+
config.noAdvancedVariants === Config.options.noAdvancedVariants.default &&
|
|
409
|
+
typeof configFileData.noAdvancedVariants === 'boolean'
|
|
410
|
+
) {
|
|
411
|
+
config.noAdvancedVariants = configFileData.noAdvancedVariants
|
|
412
|
+
}
|
|
413
|
+
// package
|
|
414
|
+
if (config.package === Config.options.package.default && typeof configFileData.package === 'boolean') {
|
|
415
|
+
config.package = configFileData.package
|
|
397
416
|
}
|
|
398
417
|
}
|
|
399
418
|
|
|
@@ -420,14 +439,12 @@ function getDefaultGirDirectories(): string[] {
|
|
|
420
439
|
const girDirectories = [
|
|
421
440
|
'/usr/local/share/gir-1.0',
|
|
422
441
|
'/usr/share/gir-1.0',
|
|
442
|
+
'/usr/share/*/gir-1.0',
|
|
423
443
|
'/usr/share/gnome-shell',
|
|
424
444
|
'/usr/share/gnome-shell/gir-1.0',
|
|
425
|
-
'/usr/lib64/mutter
|
|
426
|
-
'/usr/
|
|
427
|
-
'/usr/
|
|
428
|
-
'/usr/lib/x86_64-linux-gnu/mutter-10',
|
|
429
|
-
'/usr/lib/x86_64-linux-gnu/mutter-11',
|
|
430
|
-
'/usr/lib/x86_64-linux-gnu/mutter-12',
|
|
445
|
+
'/usr/lib64/mutter-*',
|
|
446
|
+
'/usr/lib/mutter-*',
|
|
447
|
+
'/usr/lib/x86_64-linux-gnu/mutter-*',
|
|
431
448
|
]
|
|
432
449
|
// NixOS and other distributions does not have a /usr/local/share directory.
|
|
433
450
|
// Instead, the nix store paths with Gir files are set as XDG_DATA_DIRS.
|
|
@@ -435,7 +452,7 @@ function getDefaultGirDirectories(): string[] {
|
|
|
435
452
|
const dataDirs = process.env['XDG_DATA_DIRS']?.split(':') || []
|
|
436
453
|
for (let dataDir of dataDirs) {
|
|
437
454
|
dataDir = join(dataDir, 'gir-1.0')
|
|
438
|
-
if (!girDirectories.includes(dataDir)) {
|
|
455
|
+
if (!girDirectories.includes(dataDir) && existsSync(dataDir)) {
|
|
439
456
|
girDirectories.push(dataDir)
|
|
440
457
|
}
|
|
441
458
|
}
|
|
@@ -10,16 +10,16 @@ import {
|
|
|
10
10
|
} from '@ts-for-gir/lib'
|
|
11
11
|
import { GeneratorType, Generator } from '@ts-for-gir/generator-base'
|
|
12
12
|
import { TypeDefinitionGenerator } from '@ts-for-gir/generator-typescript'
|
|
13
|
-
|
|
13
|
+
import { HtmlDocGenerator } from '@ts-for-gir/generator-html-doc'
|
|
14
14
|
|
|
15
|
-
import type {
|
|
15
|
+
import type { OptionsGeneration, NSRegistry } from '@ts-for-gir/lib'
|
|
16
16
|
|
|
17
17
|
export class GenerationHandler {
|
|
18
18
|
log: Logger
|
|
19
19
|
generator: Generator
|
|
20
20
|
|
|
21
21
|
constructor(
|
|
22
|
-
private readonly config:
|
|
22
|
+
private readonly config: OptionsGeneration,
|
|
23
23
|
type: GeneratorType,
|
|
24
24
|
) {
|
|
25
25
|
this.log = new Logger(config.verbose, 'GenerationHandler')
|
|
@@ -28,9 +28,9 @@ export class GenerationHandler {
|
|
|
28
28
|
case GeneratorType.TYPES:
|
|
29
29
|
this.generator = new TypeDefinitionGenerator(config)
|
|
30
30
|
break
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
case GeneratorType.HTML_DOC:
|
|
32
|
+
this.generator = new HtmlDocGenerator(config)
|
|
33
|
+
break
|
|
34
34
|
default:
|
|
35
35
|
throw new Error('Unknown Generator')
|
|
36
36
|
}
|
|
@@ -61,12 +61,10 @@ export class GenerationHandler {
|
|
|
61
61
|
|
|
62
62
|
for (const girModule of girModules) {
|
|
63
63
|
this.log.log(` - ${girModule.packageName} ...`)
|
|
64
|
-
girModule.start(girModules)
|
|
65
|
-
|
|
66
64
|
await this.generator.generate(registry, girModule)
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
await this.generator.finish(registry)
|
|
67
|
+
await this.generator.finish(registry, girModules)
|
|
70
68
|
|
|
71
69
|
this.log.success(GENERATING_TYPES_DONE)
|
|
72
70
|
}
|