@ts-for-gir/cli 3.3.0 → 4.0.0-beta.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.
@@ -28,26 +28,23 @@ const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
28
28
  const handler = async (args: ConfigFlags) => {
29
29
  const config = await Config.load(args)
30
30
 
31
- for (let i = 0; i < config.environments.length; i++) {
32
- if (config.environments[i]) {
33
- const generateConfig = Config.getGenerateConfig(config, config.environments[i])
34
- const moduleLoader = new ModuleLoader(generateConfig)
35
- const { keep, grouped } = await moduleLoader.getModulesResolved(
36
- config.modules,
37
- config.ignore || [],
38
- config.ignoreVersionConflicts,
39
- )
40
- if (keep.length === 0) {
41
- return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories))
42
- }
43
- const tsForGir = new GenerationHandler(generateConfig, GeneratorType.HTML_DOC)
44
-
45
- await tsForGir.start(
46
- Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module),
47
- Object.values(grouped),
48
- )
49
- }
31
+ const generateConfig = Config.getOptionsGeneration(config)
32
+ const moduleLoader = new ModuleLoader(generateConfig)
33
+ const { keep } = await moduleLoader.getModulesResolved(
34
+ config.modules,
35
+ config.ignore || [],
36
+ config.ignoreVersionConflicts,
37
+ )
38
+ if (keep.length === 0) {
39
+ return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories))
50
40
  }
41
+ const tsForGir = new GenerationHandler(generateConfig, GeneratorType.HTML_DOC)
42
+ const registry = moduleLoader.dependencyManager
43
+
44
+ await tsForGir.start(
45
+ Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module),
46
+ registry,
47
+ )
51
48
  }
52
49
 
53
50
  const examples: ReadonlyArray<[string, string?]> = []
@@ -8,12 +8,14 @@ import { GeneratorType } from '@ts-for-gir/generator-base'
8
8
  import { GenerationHandler } from '../generation-handler.js'
9
9
  import { Config } from '../config.js'
10
10
  import { ModuleLoader } from '../module-loader.js'
11
+ import prettier from 'prettier'
11
12
 
12
13
  import type { ConfigFlags } from '@ts-for-gir/lib'
14
+ import { Formatter } from '@ts-for-gir/lib'
13
15
 
14
16
  const command = 'generate [modules..]'
15
17
 
16
- const description = 'Generates .d.ts files from GIR for GJS or node-gtk'
18
+ const description = 'Generates Typescript type definition .d.ts files from GIR for GJS'
17
19
 
18
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
21
  const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
@@ -28,35 +30,35 @@ const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
28
30
  const handler = async (args: ConfigFlags) => {
29
31
  const config = await Config.load(args)
30
32
 
31
- for (const env of config.environments) {
32
- const generateConfig = Config.getGenerateConfig(config, env)
33
- const moduleLoader = new ModuleLoader(generateConfig)
34
- const { keep, grouped } = await moduleLoader.getModulesResolved(
35
- config.modules,
36
- config.ignore || [],
37
- config.ignoreVersionConflicts,
38
- )
39
- if (keep.length === 0) {
40
- return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories))
41
- }
42
- const tsForGir = new GenerationHandler(generateConfig, GeneratorType.TYPES)
43
-
44
- const girModules = Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module)
45
- const girModulesGrouped = Object.values(grouped)
33
+ const generateConfig = Config.getOptionsGeneration(config)
34
+ const moduleLoader = new ModuleLoader(generateConfig)
35
+ const { keep } = await moduleLoader.getModulesResolved(
36
+ config.modules,
37
+ config.ignore || [],
38
+ config.ignoreVersionConflicts,
39
+ )
46
40
 
47
- await tsForGir.start(girModules, girModulesGrouped)
41
+ if (keep.length === 0) {
42
+ return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories))
48
43
  }
44
+
45
+ moduleLoader.parse(keep)
46
+
47
+ const tsForGir = new GenerationHandler(generateConfig, GeneratorType.TYPES)
48
+
49
+ const girModules = Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module)
50
+
51
+ moduleLoader.dependencyManager.registerFormatter('dts', new TypeScriptFormatter())
52
+ await tsForGir.start(girModules, moduleLoader.dependencyManager)
49
53
  }
50
54
 
51
55
  const examples: ReadonlyArray<[string, string?]> = [
52
56
  [
53
57
  `${Config.appName} generate`,
54
- `Run '${Config.appName} generate' in your gjs or node-gtk project to generate typings for your project, pass the gir modules you need for your project`,
58
+ `Run '${Config.appName} generate' in your gjs project to generate typings for your project, pass the gir modules you need for your project`,
55
59
  ],
56
60
  [`${Config.appName} generate Gtk*`, 'You can also use wild cards'],
57
61
  [`${Config.appName} generate '*'`, 'If you want to parse all of your locally installed gir modules run'],
58
- [`${Config.appName} generate '*' -e gjs`, 'Generate .d.ts. files only for gjs'],
59
- [`${Config.appName} generate '*' -e node`, 'Generate .d.ts. files only for node'],
60
62
  [`${Config.appName} generate --configName='.ts-for-gir.gtk4.rc.js`, 'Use a special config file'],
61
63
  [
62
64
  `${Config.appName} generate --ignore=Gtk-4.0 xrandr-1.3`,
@@ -64,6 +66,21 @@ const examples: ReadonlyArray<[string, string?]> = [
64
66
  ],
65
67
  ]
66
68
 
69
+ class TypeScriptFormatter extends Formatter {
70
+ format(input: string): Promise<string> {
71
+ try {
72
+ return prettier.format(input, {
73
+ singleQuote: true,
74
+ parser: 'typescript',
75
+ printWidth: 120,
76
+ tabWidth: 4,
77
+ })
78
+ } catch (error) {
79
+ return Promise.resolve(input)
80
+ }
81
+ }
82
+ }
83
+
67
84
  export const generate = {
68
85
  command,
69
86
  description,
@@ -1,3 +1,4 @@
1
+ export * from './copy.js'
1
2
  export * from './doc.js'
2
3
  export * from './generate.js'
3
4
  export * from './list.js'
@@ -25,7 +25,7 @@ const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
25
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
26
  const handler = async (args: ConfigFlags) => {
27
27
  const config = await Config.load(args)
28
- const generateConfig = Config.getGenerateConfig(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
@@ -6,18 +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 {
10
- merge,
11
- isEqual,
12
- Logger,
13
- APP_NAME,
14
- APP_USAGE,
15
- ERROR_CONFIG_EXTENSION_UNSUPPORTED,
16
- WARN_USE_ESM_FOR_ALIAS,
17
- WARN_USE_GJS_FOR_ALIAS,
18
- } from '@ts-for-gir/lib'
9
+ import { existsSync } from 'fs'
10
+ import { merge, isEqual, Logger, APP_NAME, APP_USAGE, ERROR_CONFIG_EXTENSION_UNSUPPORTED } from '@ts-for-gir/lib'
19
11
 
20
- import type { Environment, UserConfig, ConfigFlags, UserConfigLoadResult, GenerateConfig } from '@ts-for-gir/lib'
12
+ import type { UserConfig, ConfigFlags, UserConfigLoadResult, OptionsGeneration } from '@ts-for-gir/lib'
21
13
 
22
14
  export class Config {
23
15
  static appName = APP_NAME
@@ -28,7 +20,6 @@ export class Config {
28
20
  * Default cli flag and argument values
29
21
  */
30
22
  static defaults = {
31
- environments: ['gjs'],
32
23
  print: false,
33
24
  configName: '.ts-for-girrc.js',
34
25
  root: process.cwd(),
@@ -39,16 +30,17 @@ export class Config {
39
30
  verbose: false,
40
31
  ignoreVersionConflicts: false,
41
32
  noNamespace: false,
42
- buildType: 'lib',
43
- moduleType: 'esm',
44
33
  noComments: false,
45
- noDebugComments: false,
46
- fixConflicts: true,
47
- generateAlias: false,
48
34
  promisify: true,
49
35
  npmScope: '@girs',
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,
50
43
  package: false,
51
- packageYarn: false,
52
44
  }
53
45
 
54
46
  static configFilePath = join(process.cwd(), Config.defaults.configName)
@@ -84,15 +76,6 @@ export class Config {
84
76
  default: Config.defaults.outdir,
85
77
  normalize: true,
86
78
  },
87
- environments: {
88
- type: 'string',
89
- alias: 'e',
90
- description: 'Javascript environment',
91
- array: true,
92
- choices: ['gjs', 'node'],
93
- default: Config.defaults.environments,
94
- normalize: true,
95
- },
96
79
  ignore: {
97
80
  type: 'string',
98
81
  alias: 'i',
@@ -101,23 +84,6 @@ export class Config {
101
84
  default: Config.defaults.ignore,
102
85
  normalize: true,
103
86
  },
104
- buildType: {
105
- type: 'string',
106
- alias: 'b',
107
- description: 'Definitions generation type',
108
- array: false,
109
- choices: ['lib', 'types'],
110
- default: Config.defaults.buildType,
111
- normalize: true,
112
- },
113
- moduleType: {
114
- type: 'string',
115
- alias: 't',
116
- description: 'Specify what module code is generated.',
117
- choices: ['esm', 'commonjs', 'cjs'],
118
- default: Config.defaults.moduleType,
119
- normalize: true,
120
- },
121
87
  verbose: {
122
88
  type: 'boolean',
123
89
  alias: 'v',
@@ -127,7 +93,7 @@ export class Config {
127
93
  },
128
94
  ignoreVersionConflicts: {
129
95
  type: 'boolean',
130
- description: 'Do not ask for package versions if multiple versions are found',
96
+ description: 'Skip prompts for library version selection when multiple versions are detected',
131
97
  default: Config.defaults.ignoreVersionConflicts,
132
98
  normalize: true,
133
99
  },
@@ -140,7 +106,7 @@ export class Config {
140
106
  },
141
107
  configName: {
142
108
  type: 'string',
143
- description: 'Name of the config if you want to use a different name',
109
+ description: 'Specify a custom name for the configuration file',
144
110
  default: Config.defaults.configName,
145
111
  normalize: true,
146
112
  },
@@ -158,47 +124,48 @@ export class Config {
158
124
  default: Config.defaults.noComments,
159
125
  normalize: true,
160
126
  },
161
- noDebugComments: {
127
+ promisify: {
162
128
  type: 'boolean',
163
- description: 'Do not generate debugging inline comments',
164
- default: Config.defaults.noDebugComments,
129
+ description: 'Generate promisified functions for async/finish calls',
130
+ default: Config.defaults.promisify,
165
131
  normalize: true,
166
132
  },
167
- fixConflicts: {
168
- type: 'boolean',
169
- description: 'Fix Inheritance and implementation type conflicts',
170
- default: Config.defaults.fixConflicts,
133
+ npmScope: {
134
+ type: 'string',
135
+ description: 'Scope of the generated NPM packages',
136
+ default: Config.defaults.npmScope,
171
137
  normalize: true,
172
138
  },
173
- generateAlias: {
139
+ workspace: {
174
140
  type: 'boolean',
175
- alias: 'a',
176
- description: 'Generate an alias tsconfig file to support GJS ESM module imports',
177
- default: Config.defaults.generateAlias,
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,
178
144
  normalize: true,
179
145
  },
180
- promisify: {
146
+ onlyVersionPrefix: {
181
147
  type: 'boolean',
182
- description: 'Generate promisified functions for async/finish calls',
183
- default: Config.defaults.promisify,
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,
184
151
  normalize: true,
185
152
  },
186
- npmScope: {
187
- type: 'string',
188
- description: 'Scope of the generated NPM packages',
189
- default: Config.defaults.npmScope,
153
+ noPrettyPrint: {
154
+ type: 'boolean',
155
+ description: 'Do not prettify the generated types',
156
+ default: Config.defaults.noPrettyPrint,
190
157
  normalize: true,
191
158
  },
192
- package: {
159
+ noAdvancedVariants: {
193
160
  type: 'boolean',
194
- description: 'Generates an NPM compatible packages for each GIR module',
195
- default: Config.defaults.package,
161
+ description: 'Disable GLib.Variant class with string parsing',
162
+ default: Config.defaults.noAdvancedVariants,
196
163
  normalize: true,
197
164
  },
198
- packageYarn: {
165
+ package: {
199
166
  type: 'boolean',
200
- description: 'Adds Yarn workspace support to the NPM packages',
201
- default: Config.defaults.packageYarn,
167
+ description: 'Generate the typescript types with package.json support',
168
+ default: Config.defaults.package,
202
169
  normalize: true,
203
170
  },
204
171
  }
@@ -211,28 +178,36 @@ export class Config {
211
178
  girDirectories: this.options.girDirectories,
212
179
  root: this.options.root,
213
180
  outdir: this.options.outdir,
214
- environments: this.options.environments,
215
181
  ignore: this.options.ignore,
216
- buildType: this.options.buildType,
217
- moduleType: this.options.moduleType,
218
182
  verbose: this.options.verbose,
219
183
  ignoreVersionConflicts: this.options.ignoreVersionConflicts,
220
184
  print: this.options.print,
221
185
  configName: this.options.configName,
222
186
  noNamespace: this.options.noNamespace,
223
187
  noComments: this.options.noComments,
224
- noDebugComments: this.options.noDebugComments,
225
- fixConflicts: this.options.fixConflicts,
226
- generateAlias: this.options.generateAlias,
227
188
  promisify: this.options.promisify,
228
189
  npmScope: this.options.npmScope,
190
+ workspace: this.options.workspace,
191
+ onlyVersionPrefix: this.options.onlyVersionPrefix,
192
+ noPrettyPrint: this.options.noPrettyPrint,
193
+ noAdvancedVariants: this.options.noAdvancedVariants,
229
194
  package: this.options.package,
230
- packageYarn: this.options.packageYarn,
231
195
  }
232
196
 
233
197
  static listOptions = {
234
198
  modules: this.options.modules,
235
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,
236
211
  ignore: Config.options.ignore,
237
212
  configName: Config.options.configName,
238
213
  verbose: Config.options.verbose,
@@ -241,8 +216,8 @@ export class Config {
241
216
  static docOptions = {
242
217
  modules: this.options.modules,
243
218
  girDirectories: Config.options.girDirectories,
219
+ root: this.options.root,
244
220
  outdir: Config.options.outdir,
245
- environments: Config.options.environments,
246
221
  ignore: Config.options.ignore,
247
222
  verbose: Config.options.verbose,
248
223
  ignoreVersionConflicts: Config.options.ignoreVersionConflicts,
@@ -313,40 +288,14 @@ export class Config {
313
288
  return configFile
314
289
  }
315
290
 
316
- public static getGenerateConfig(config: UserConfig, environment: Environment = 'gjs'): GenerateConfig {
317
- const generateConfig: GenerateConfig = {
318
- environment: environment,
319
- girDirectories: config.girDirectories,
320
- root: config.root,
321
- outdir: config.outdir,
322
- verbose: config.verbose,
323
- buildType: config.buildType,
324
- moduleType: config.moduleType,
325
- noNamespace: config.noNamespace,
326
- noComments: config.noComments,
327
- noDebugComments: config.noDebugComments,
328
- fixConflicts: config.fixConflicts,
329
- generateAlias: config.generateAlias,
330
- promisify: config.promisify,
331
- npmScope: config.npmScope,
332
- package: config.package,
333
- packageYarn: config.packageYarn,
291
+ public static getOptionsGeneration(config: UserConfig): OptionsGeneration {
292
+ const generateConfig: OptionsGeneration = {
293
+ ...config,
334
294
  }
335
295
  return generateConfig
336
296
  }
337
297
 
338
298
  public static validate(config: UserConfig): UserConfig {
339
- if (config.generateAlias) {
340
- if (!config.environments.includes('gjs')) {
341
- Logger.warn(WARN_USE_GJS_FOR_ALIAS)
342
- config.environments.push('gjs')
343
- }
344
- if (config.moduleType !== 'esm') {
345
- Logger.warn(WARN_USE_ESM_FOR_ALIAS)
346
- config.moduleType = 'esm'
347
- }
348
- }
349
-
350
299
  return config
351
300
  }
352
301
 
@@ -360,41 +309,10 @@ export class Config {
360
309
  const configFileData = configFile?.config || {}
361
310
 
362
311
  const config: UserConfig = {
363
- environments: options.environments,
364
- buildType: options.buildType,
365
- moduleType: options.moduleType,
366
- verbose: options.verbose,
367
- ignoreVersionConflicts: options.ignoreVersionConflicts,
368
- print: options.print,
369
- root: options.root,
370
- outdir: options.outdir,
371
- girDirectories: options.girDirectories,
372
- ignore: options.ignore,
373
- modules: options.modules,
374
- noNamespace: options.noNamespace,
375
- noComments: options.noComments,
376
- noDebugComments: options.noDebugComments,
377
- fixConflicts: options.fixConflicts,
378
- generateAlias: options.generateAlias,
379
- promisify: options.promisify,
380
- npmScope: options.npmScope,
381
- package: options.package,
382
- packageYarn: options.packageYarn,
312
+ ...options,
383
313
  }
384
314
 
385
315
  if (configFileData) {
386
- // environments
387
- if (isEqual(config.environments, Config.defaults.environments) && configFileData.environments) {
388
- config.environments = configFileData.environments
389
- }
390
- // buildType
391
- if (config.buildType === Config.options.buildType.default && configFileData.buildType) {
392
- config.buildType = configFileData.buildType
393
- }
394
- // moduleType
395
- if (config.moduleType === Config.options.moduleType.default && configFileData.moduleType) {
396
- config.moduleType = configFileData.moduleType
397
- }
398
316
  // verbose
399
317
  if (config.verbose === Config.options.verbose.default && typeof configFileData.verbose === 'boolean') {
400
318
  config.verbose = configFileData.verbose
@@ -453,53 +371,49 @@ export class Config {
453
371
  ) {
454
372
  config.noComments = configFileData.noComments
455
373
  }
456
- // noDebugComments
374
+ // promisify
457
375
  if (
458
- config.noDebugComments === Config.options.noDebugComments.default &&
459
- typeof configFileData.noDebugComments === 'boolean'
376
+ config.promisify === Config.options.promisify.default &&
377
+ typeof configFileData.promisify === 'boolean'
460
378
  ) {
461
- config.noDebugComments = configFileData.noDebugComments
379
+ config.promisify = configFileData.promisify
462
380
  }
463
- // fixConflicts
381
+ // npmScope
382
+ if (config.npmScope === Config.options.npmScope.default && configFileData.npmScope) {
383
+ config.npmScope = configFileData.npmScope
384
+ }
385
+ // workspace
464
386
  if (
465
- config.fixConflicts === Config.options.fixConflicts.default &&
466
- typeof configFileData.fixConflicts === 'boolean'
387
+ config.workspace === Config.options.workspace.default &&
388
+ typeof configFileData.workspace === 'boolean'
467
389
  ) {
468
- config.fixConflicts = configFileData.fixConflicts
390
+ config.workspace = configFileData.workspace
469
391
  }
470
- // generateAlias
392
+ // onlyVersionPrefix
471
393
  if (
472
- config.generateAlias === Config.options.generateAlias.default &&
473
- typeof configFileData.generateAlias === 'boolean'
394
+ config.onlyVersionPrefix === Config.options.onlyVersionPrefix.default &&
395
+ typeof configFileData.onlyVersionPrefix === 'boolean'
474
396
  ) {
475
- config.generateAlias = configFileData.generateAlias
397
+ config.onlyVersionPrefix = configFileData.onlyVersionPrefix
476
398
  }
477
- // promisify
399
+ // noPrettyPrint
478
400
  if (
479
- config.promisify === Config.options.promisify.default &&
480
- typeof configFileData.promisify === 'boolean'
401
+ config.noPrettyPrint === Config.options.noPrettyPrint.default &&
402
+ typeof configFileData.noPrettyPrint === 'boolean'
481
403
  ) {
482
- config.promisify = configFileData.promisify
404
+ config.noPrettyPrint = configFileData.noPrettyPrint
483
405
  }
484
- // npmScope
485
- if (config.npmScope === Config.options.npmScope.default && configFileData.npmScope) {
486
- config.npmScope = configFileData.npmScope
406
+ // noAdvancedVariants
407
+ if (
408
+ config.noAdvancedVariants === Config.options.noAdvancedVariants.default &&
409
+ typeof configFileData.noAdvancedVariants === 'boolean'
410
+ ) {
411
+ config.noAdvancedVariants = configFileData.noAdvancedVariants
487
412
  }
488
413
  // package
489
414
  if (config.package === Config.options.package.default && typeof configFileData.package === 'boolean') {
490
415
  config.package = configFileData.package
491
416
  }
492
- // packageYarn
493
- if (
494
- config.packageYarn === Config.options.packageYarn.default &&
495
- typeof configFileData.packageYarn === 'boolean'
496
- ) {
497
- config.packageYarn = configFileData.packageYarn
498
- }
499
- }
500
-
501
- if ((config.moduleType as string) === 'commonjs') {
502
- config.moduleType = 'cjs'
503
417
  }
504
418
 
505
419
  // If outdir is not absolute, make it absolute to the root path
@@ -525,14 +439,12 @@ function getDefaultGirDirectories(): string[] {
525
439
  const girDirectories = [
526
440
  '/usr/local/share/gir-1.0',
527
441
  '/usr/share/gir-1.0',
442
+ '/usr/share/*/gir-1.0',
528
443
  '/usr/share/gnome-shell',
529
444
  '/usr/share/gnome-shell/gir-1.0',
530
- '/usr/lib64/mutter-10',
531
- '/usr/lib64/mutter-11',
532
- '/usr/lib64/mutter-12',
533
- '/usr/lib/x86_64-linux-gnu/mutter-10',
534
- '/usr/lib/x86_64-linux-gnu/mutter-11',
535
- '/usr/lib/x86_64-linux-gnu/mutter-12',
445
+ '/usr/lib64/mutter-*',
446
+ '/usr/lib/mutter-*',
447
+ '/usr/lib/x86_64-linux-gnu/mutter-*',
536
448
  ]
537
449
  // NixOS and other distributions does not have a /usr/local/share directory.
538
450
  // Instead, the nix store paths with Gir files are set as XDG_DATA_DIRS.
@@ -540,7 +452,7 @@ function getDefaultGirDirectories(): string[] {
540
452
  const dataDirs = process.env['XDG_DATA_DIRS']?.split(':') || []
541
453
  for (let dataDir of dataDirs) {
542
454
  dataDir = join(dataDir, 'gir-1.0')
543
- if (!girDirectories.includes(dataDir)) {
455
+ if (!girDirectories.includes(dataDir) && existsSync(dataDir)) {
544
456
  girDirectories.push(dataDir)
545
457
  }
546
458
  }