@ts-for-gir/cli 4.0.0-beta.9 → 4.0.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +335 -86
  2. package/bin/ts-for-gir +28832 -0
  3. package/bin/ts-for-gir-dev +43 -0
  4. package/bin/ts-for-gir-gjs +348955 -0
  5. package/dist-templates/types-locally/.ts-for-girrc.js +6 -0
  6. package/dist-templates/types-locally/README.md +15 -0
  7. package/dist-templates/types-locally/esbuild.ts +10 -0
  8. package/dist-templates/types-locally/main.ts +21 -0
  9. package/dist-templates/types-locally/package.json +18 -0
  10. package/dist-templates/types-locally/tsconfig.json +17 -0
  11. package/dist-templates/types-npm/README.md +14 -0
  12. package/dist-templates/types-npm/esbuild.ts +10 -0
  13. package/dist-templates/types-npm/main.ts +19 -0
  14. package/dist-templates/types-npm/package.json +23 -0
  15. package/dist-templates/types-npm/tsconfig.json +15 -0
  16. package/dist-templates/types-workspace/.ts-for-girrc.js +12 -0
  17. package/dist-templates/types-workspace/README.md +26 -0
  18. package/dist-templates/types-workspace/package.json +22 -0
  19. package/dist-templates/types-workspace/packages/app/esbuild.ts +10 -0
  20. package/dist-templates/types-workspace/packages/app/main.ts +19 -0
  21. package/dist-templates/types-workspace/packages/app/package.json +23 -0
  22. package/dist-templates/types-workspace/packages/app/tsconfig.json +15 -0
  23. package/dist-templates/types-workspace/tsconfig.json +11 -0
  24. package/package.json +60 -37
  25. package/src/commands/analyze.ts +344 -0
  26. package/src/commands/command-builder.ts +30 -0
  27. package/src/commands/copy.ts +71 -76
  28. package/src/commands/create.ts +223 -0
  29. package/src/commands/doc.ts +44 -47
  30. package/src/commands/generate.ts +35 -79
  31. package/src/commands/index.ts +8 -4
  32. package/src/commands/json.ts +43 -0
  33. package/src/commands/list.ts +71 -90
  34. package/src/commands/run-generation-command.ts +75 -0
  35. package/src/commands/self-update.ts +142 -0
  36. package/src/config/config-loader.ts +238 -0
  37. package/src/config/config-writer.ts +52 -0
  38. package/src/config/defaults.ts +68 -0
  39. package/src/config/index.ts +16 -0
  40. package/src/config/options.ts +365 -0
  41. package/src/config.ts +3 -456
  42. package/src/formatters/typescript-formatter.ts +17 -0
  43. package/src/generation-handler.ts +122 -67
  44. package/src/index.ts +4 -4
  45. package/src/module-loader/dependency-resolver.ts +100 -0
  46. package/src/module-loader/file-finder.ts +65 -0
  47. package/src/module-loader/index.ts +8 -0
  48. package/src/module-loader/module-grouper.ts +77 -0
  49. package/src/module-loader/prompt-handler.ts +111 -0
  50. package/src/module-loader.ts +321 -578
  51. package/src/start.ts +36 -15
  52. package/src/types/command-args.ts +154 -0
  53. package/src/types/command-definition.ts +17 -0
  54. package/src/types/commands.ts +30 -0
  55. package/src/types/index.ts +15 -0
  56. package/src/types/report-types.ts +34 -0
  57. package/lib/commands/copy.d.ts +0 -12
  58. package/lib/commands/copy.js +0 -80
  59. package/lib/commands/copy.js.map +0 -1
  60. package/lib/commands/doc.d.ts +0 -12
  61. package/lib/commands/doc.js +0 -40
  62. package/lib/commands/doc.js.map +0 -1
  63. package/lib/commands/generate.d.ts +0 -12
  64. package/lib/commands/generate.js +0 -71
  65. package/lib/commands/generate.js.map +0 -1
  66. package/lib/commands/index.d.ts +0 -4
  67. package/lib/commands/index.js +0 -5
  68. package/lib/commands/index.js.map +0 -1
  69. package/lib/commands/list.d.ts +0 -12
  70. package/lib/commands/list.js +0 -81
  71. package/lib/commands/list.js.map +0 -1
  72. package/lib/config.d.ts +0 -108
  73. package/lib/config.js +0 -410
  74. package/lib/config.js.map +0 -1
  75. package/lib/generation-handler.d.ts +0 -10
  76. package/lib/generation-handler.js +0 -48
  77. package/lib/generation-handler.js.map +0 -1
  78. package/lib/index.d.ts +0 -4
  79. package/lib/index.js +0 -5
  80. package/lib/index.js.map +0 -1
  81. package/lib/module-loader.d.ts +0 -148
  82. package/lib/module-loader.js +0 -468
  83. package/lib/module-loader.js.map +0 -1
  84. package/lib/start.d.ts +0 -2
  85. package/lib/start.js +0 -16
  86. package/lib/start.js.map +0 -1
package/src/start.ts CHANGED
@@ -1,17 +1,38 @@
1
- #!/usr/bin/env node
2
- import yargs from 'yargs'
3
- import { hideBin } from 'yargs/helpers'
1
+ import { APP_NAME, APP_USAGE, APP_VERSION } from "@ts-for-gir/lib";
2
+ import yargs, { type CommandModule } from "yargs";
3
+ import { hideBin } from "yargs/helpers";
4
4
 
5
- import { generate, list, doc, copy } from './commands/index.js'
6
- import { Config } from './config.js'
5
+ import { analyze, copy, create, doc, generate, json, list, selfUpdate } from "./commands/index.ts";
7
6
 
8
- void yargs(hideBin(process.argv))
9
- .scriptName(Config.appName)
10
- .strict()
11
- .usage(Config.usage)
12
- .command(generate.command, generate.description, generate.builder, generate.handler)
13
- .command(list.command, list.description, list.builder, list.handler)
14
- .command(copy.command, copy.description, copy.builder, copy.handler)
15
- .command(doc.command, doc.description, doc.builder, doc.handler)
16
- .demandCommand(1)
17
- .help().argv
7
+ try {
8
+ await yargs(hideBin(process.argv))
9
+ .scriptName(APP_NAME)
10
+ .strict()
11
+ .usage(APP_USAGE)
12
+ .version(APP_VERSION)
13
+ // Disable yargs's internal `process.exit` and route both success
14
+ // and failure through `parseAsync` + an explicit `process.exit` so
15
+ // async command handlers complete and stdout drains before the
16
+ // runtime (Node or the gjsify Node-compat loader on GJS, which
17
+ // keeps a GLib main loop alive that would otherwise prevent the
18
+ // process from exiting after main() returns) tears down.
19
+ .exitProcess(false)
20
+ .fail(false)
21
+ // TODO: Fix this
22
+ .command(analyze as unknown as CommandModule)
23
+ .command(create as unknown as CommandModule)
24
+ .command(generate as unknown as CommandModule)
25
+ .command(json as unknown as CommandModule)
26
+ .command(list as unknown as CommandModule)
27
+ .command(copy as unknown as CommandModule)
28
+ .command(doc as unknown as CommandModule)
29
+ .command(selfUpdate as unknown as CommandModule)
30
+ .demandCommand(1)
31
+ .help()
32
+ .parseAsync();
33
+ process.exit(0);
34
+ } catch (err) {
35
+ const message = err instanceof Error ? err.message : String(err);
36
+ process.stderr.write(`${message}\n`);
37
+ process.exit(1);
38
+ }
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Base interface for all command arguments extending ConfigFlags
3
+ */
4
+ export interface BaseCommandArgs {
5
+ /** GIR modules to load, e.g. 'Gio-2.0'. Accepts multiple modules */
6
+ modules: string[];
7
+ /** GIR directories */
8
+ girDirectories: string[];
9
+ /** Root directory of your project */
10
+ root: string;
11
+ /** Modules that should be ignored */
12
+ ignore: string[];
13
+ /** Specify a custom name for the configuration file */
14
+ configName: string;
15
+ /** Switch on/off the verbose mode */
16
+ verbose: boolean;
17
+ }
18
+
19
+ /**
20
+ * Arguments for the generate command
21
+ */
22
+ export interface GenerateCommandArgs extends BaseCommandArgs {
23
+ /** Directory to output to */
24
+ outdir: string | null;
25
+ /** Skip prompts for library version selection when multiple versions are detected */
26
+ ignoreVersionConflicts: boolean;
27
+ /** Print the output to console and create no files */
28
+ print: boolean;
29
+ /** Do not export all symbols for each module as a namespace */
30
+ noNamespace: boolean;
31
+ /** Do not generate documentation comments */
32
+ noComments: boolean;
33
+ /** Generate promisified functions for async/finish calls */
34
+ promisify: boolean;
35
+ /** Scope of the generated NPM packages */
36
+ npmScope: string;
37
+ /** Uses the workspace protocol for the generated packages which can be used with package managers like Yarn and PNPM */
38
+ workspace: boolean;
39
+ /** Dependency version spec format in generated package.json files */
40
+ depVersionFormat?: "workspace" | "caret" | "any" | "exact";
41
+ /** Only use the version prefix for the ambient module exports */
42
+ onlyVersionPrefix: boolean;
43
+ /** Do not prettify the generated types */
44
+ noPrettyPrint: boolean;
45
+ /** Disable GLib.Variant class with string parsing */
46
+ noAdvancedVariants: boolean;
47
+ /** Generate the typescript types with package.json support */
48
+ package: boolean;
49
+ /** Enable generation problem reporter and create a detailed report file */
50
+ reporter: boolean;
51
+ /** Output file path for the reporter */
52
+ reporterOutput: string;
53
+ /** Emit imports from installed @girs/* npm packages instead of regenerating dep types */
54
+ externalDeps: boolean;
55
+ /** Allow externalDeps generation when transitive dep GIRs are missing (degraded type quality) */
56
+ allowMissingDeps: boolean;
57
+ /** Override default namespace→npm package mapping. Repeatable. Format: `Namespace=@girs/pkg` */
58
+ externalPackage?: string[];
59
+ }
60
+
61
+ /**
62
+ * Arguments for the list command
63
+ */
64
+ export interface ListCommandArgs extends BaseCommandArgs {
65
+ // List command only uses base arguments
66
+ }
67
+
68
+ /**
69
+ * Arguments for the copy command
70
+ */
71
+ export interface CopyCommandArgs extends BaseCommandArgs {
72
+ /** Directory to output to */
73
+ outdir: string | null;
74
+ }
75
+
76
+ /**
77
+ * Arguments for the doc command
78
+ */
79
+ export interface DocCommandArgs extends GenerateCommandArgs {
80
+ /** Generate a single unified documentation for all modules (use --no-combined for separate per-module docs) */
81
+ combined: boolean;
82
+ /** URL template for source links in generated documentation. Supports {path}, {line}, {gitRevision} placeholders */
83
+ sourceLinkTemplate?: string;
84
+ /** Theme for HTML documentation generation (default: "gi-docgen") */
85
+ theme?: string;
86
+ /** Path to a README file to use as the documentation index page (default: "none") */
87
+ readme?: string;
88
+ /** Use TypeDoc merge mode to generate HTML from pre-generated JSON files */
89
+ merge?: boolean;
90
+ /** Directory containing pre-generated TypeDoc JSON files for merge mode */
91
+ jsonDir?: string;
92
+ }
93
+
94
+ /**
95
+ * Available scaffolding template identifiers for the create command.
96
+ */
97
+ export type CreateTemplateId = "types-locally" | "types-npm" | "types-workspace";
98
+
99
+ /**
100
+ * Arguments for the create command
101
+ */
102
+ export interface CreateCommandArgs {
103
+ /** Project name and target directory (positional) */
104
+ name?: string;
105
+ /** Template identifier */
106
+ template?: CreateTemplateId;
107
+ /** Run npm install after scaffolding (use --no-install to skip) */
108
+ install: boolean;
109
+ /** Allow scaffolding into a non-empty target directory */
110
+ force: boolean;
111
+ /** Switch on/off the verbose mode */
112
+ verbose: boolean;
113
+ }
114
+
115
+ /**
116
+ * Arguments for the analyze command
117
+ */
118
+ export interface AnalyzeCommandArgs {
119
+ /** Path to the report file to analyze */
120
+ reportFile: string;
121
+ /** Filter by problem severity (debug, info, warning, error, critical) */
122
+ severity?: string[];
123
+ /** Filter by problem category */
124
+ category?: string[];
125
+ /** Filter by namespace/module */
126
+ namespace?: string[];
127
+ /** Filter by specific type name */
128
+ type?: string[];
129
+ /** Show top N most problematic items */
130
+ top?: number;
131
+ /** Export filtered results to file */
132
+ export?: string;
133
+ /** Output format (json, csv, table) */
134
+ format?: string;
135
+ /** Show detailed problem information */
136
+ detailed?: boolean;
137
+ /** Show summary statistics only */
138
+ summary?: boolean;
139
+ /** Search for problems containing specific text */
140
+ search?: string;
141
+ /** Show problems from a specific time range (ISO date) */
142
+ since?: string;
143
+ /** Show problems until a specific time (ISO date) */
144
+ until?: string;
145
+ /** Switch on/off the verbose mode */
146
+ verbose?: boolean;
147
+ }
148
+
149
+ export interface SelfUpdateCommandArgs {
150
+ /** Only check for a newer version, do not install */
151
+ check: boolean;
152
+ /** Force reinstall even if already on the latest version */
153
+ force: boolean;
154
+ }
@@ -0,0 +1,17 @@
1
+ import type { ConfigFlags } from "@ts-for-gir/lib";
2
+ import type { BuilderCallback } from "yargs";
3
+ /**
4
+ * Base interface for command definition structure
5
+ */
6
+ export interface CommandDefinition<TArgs> {
7
+ /** Command name and parameters */
8
+ command: string;
9
+ /** Command description */
10
+ description: string;
11
+ /** Builder function for yargs configuration */
12
+ builder: BuilderCallback<TArgs, ConfigFlags>;
13
+ /** Handler function for command execution */
14
+ handler: (args: ConfigFlags) => Promise<void>;
15
+ /** Example usage array */
16
+ examples: ReadonlyArray<[string, string?]>;
17
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Type definitions for command structure and exports
3
+ */
4
+ import type { CopyCommandArgs, DocCommandArgs, GenerateCommandArgs, ListCommandArgs } from "./command-args.ts";
5
+ import type { CommandDefinition } from "./command-definition.ts";
6
+
7
+ /**
8
+ * Generate command definition type
9
+ */
10
+ export type GenerateCommand = CommandDefinition<GenerateCommandArgs>;
11
+
12
+ /**
13
+ * List command definition type
14
+ */
15
+ export type ListCommand = CommandDefinition<ListCommandArgs>;
16
+
17
+ /**
18
+ * Copy command definition type
19
+ */
20
+ export type CopyCommand = CommandDefinition<CopyCommandArgs>;
21
+
22
+ /**
23
+ * Doc command definition type
24
+ */
25
+ export type DocCommand = CommandDefinition<DocCommandArgs>;
26
+
27
+ /**
28
+ * Union type for all command types
29
+ */
30
+ export type AnyCommand = GenerateCommand | ListCommand | CopyCommand | DocCommand;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Export all types from the CLI types module
3
+ */
4
+
5
+ // Command argument interfaces
6
+ export * from "./command-args.ts";
7
+
8
+ // Command definition interfaces
9
+ export * from "./command-definition.ts";
10
+
11
+ // Command type definitions
12
+ export * from "./commands.ts";
13
+
14
+ // Report analysis types
15
+ export * from "./report-types.ts";
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Type definitions for report analysis functionality
3
+ */
4
+
5
+ import type { ProblemEntry } from "@ts-for-gir/reporter";
6
+
7
+ export interface TypeStatistics {
8
+ commonUnresolvedTypes: Array<{ type: string; count: number; namespaces: string[] }>;
9
+ commonTypeConflicts: Array<{ conflictType: string; count: number; examples: string[] }>;
10
+ problematicNamespaces: Array<{ namespace: string; problems: number; types: string[] }>;
11
+ }
12
+
13
+ export interface ReportStatistics {
14
+ bySeverity: Record<string, number>;
15
+ byCategory: Record<string, number>;
16
+ byModule: Record<string, number>;
17
+ totalProblems: number;
18
+ mostProblematicModules: Array<{ module: string; count: number }>;
19
+ typeStatistics: TypeStatistics;
20
+ startTime: string | Date;
21
+ endTime?: string | Date;
22
+ durationMs?: number;
23
+ }
24
+
25
+ export interface ReportMetadata {
26
+ version: string;
27
+ generatedAt: string | Date;
28
+ }
29
+
30
+ export interface ReportData {
31
+ metadata: ReportMetadata;
32
+ statistics: ReportStatistics;
33
+ problems: ProblemEntry[];
34
+ }
@@ -1,12 +0,0 @@
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
- };
@@ -1,80 +0,0 @@
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
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
- const builder = (yargs) => {
13
- const optionNames = Object.keys(Config.copyOptions);
14
- for (const optionName of optionNames) {
15
- yargs = yargs.option(optionName, Config.copyOptions[optionName]);
16
- }
17
- return yargs.example(examples);
18
- };
19
- const copyGirFile = async (config, depModule) => {
20
- if (!depModule.path) {
21
- Logger.danger(`- ${depModule.packageName} not found`);
22
- return;
23
- }
24
- if (!config.outdir) {
25
- Logger.error(`outdir not found`);
26
- return;
27
- }
28
- const filename = basename(depModule.path);
29
- const dest = join(config.outdir, filename);
30
- if (depModule.path === dest) {
31
- Logger.yellow(`Skip ${depModule.path}`);
32
- return;
33
- }
34
- Logger.success(`Copy ${depModule.path}`);
35
- await copyFile(depModule.path, dest);
36
- };
37
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
- const handler = async (args) => {
39
- const config = await Config.load(args);
40
- const generateConfig = Config.getOptionsGeneration(config);
41
- const moduleLoader = new ModuleLoader(generateConfig);
42
- const { grouped, failed } = await moduleLoader.getModules(config.modules, config.ignore);
43
- const moduleGroups = Object.values(grouped);
44
- if (Object.keys(grouped).length === 0) {
45
- return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
46
- }
47
- if (!config.outdir) {
48
- Logger.error(`outdir not found`);
49
- return;
50
- }
51
- await mkdir(config.outdir, { recursive: true }).catch((err) => {
52
- Logger.error(`Failed to copy gir files to ${config.outdir}: ${err}`);
53
- });
54
- for (const module of moduleGroups) {
55
- for (const mod of module.modules) {
56
- await copyGirFile(config, mod);
57
- }
58
- }
59
- if (failed.length > 0) {
60
- Logger.danger('\nDependencies not found:');
61
- for (const fail of failed) {
62
- Logger.white(`- ${fail}`);
63
- }
64
- }
65
- };
66
- const examples = [
67
- [`${Config.appName} copy -o ./gir`, `Copy found *.gir files to ./gir`],
68
- [
69
- `${Config.appName} copy -g /usr/share/gir-1.0 --ignore=Gtk-3.0 xrandr-1.3 -o ./gir`,
70
- 'Copy all found *.gir files in /usr/share/gir-1.0 excluding Gtk-3.0 and xrandr-1.3 to ./gir',
71
- ],
72
- ];
73
- export const copy = {
74
- command,
75
- description,
76
- builder,
77
- handler,
78
- examples,
79
- };
80
- //# sourceMappingURL=copy.js.map
@@ -1 +0,0 @@
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;AAE3E,8DAA8D;AAC9D,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,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,GAAqC;IAC/C,CAAC,GAAG,MAAM,CAAC,OAAO,gBAAgB,EAAE,iCAAiC,CAAC;IACtE;QACI,GAAG,MAAM,CAAC,OAAO,kEAAkE;QACnF,4FAA4F;KAC/F;CACJ,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAG;IAChB,OAAO;IACP,WAAW;IACX,OAAO;IACP,OAAO;IACP,QAAQ;CACX,CAAA"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Everything you need for the `ts-for-gir generate` command is located here
3
- */
4
- import { Argv } from 'yargs';
5
- import type { ConfigFlags } from '@ts-for-gir/lib';
6
- export declare const doc: {
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
- };
@@ -1,40 +0,0 @@
1
- /**
2
- * Everything you need for the `ts-for-gir generate` command is located here
3
- */
4
- import { Logger, ERROR_NO_MODULES_FOUND } from '@ts-for-gir/lib';
5
- import { GeneratorType } from '@ts-for-gir/generator-base';
6
- import { GenerationHandler } from '../generation-handler.js';
7
- import { Config } from '../config.js';
8
- import { ModuleLoader } from '../module-loader.js';
9
- const command = 'doc [modules..]';
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
- const builder = (yargs) => {
13
- const optionNames = Object.keys(Config.docOptions);
14
- for (const optionName of optionNames) {
15
- yargs = yargs.option(optionName, Config.docOptions[optionName]);
16
- }
17
- return yargs.example(examples);
18
- };
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- const handler = async (args) => {
21
- const config = await Config.load(args);
22
- const generateConfig = Config.getOptionsGeneration(config);
23
- const moduleLoader = new ModuleLoader(generateConfig);
24
- const { keep } = await moduleLoader.getModulesResolved(config.modules, config.ignore || [], config.ignoreVersionConflicts);
25
- if (keep.length === 0) {
26
- return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
27
- }
28
- const tsForGir = new GenerationHandler(generateConfig, GeneratorType.HTML_DOC);
29
- const registry = moduleLoader.dependencyManager;
30
- await tsForGir.start(Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module), registry);
31
- };
32
- const examples = [];
33
- export const doc = {
34
- command,
35
- description,
36
- builder,
37
- handler,
38
- examples,
39
- };
40
- //# sourceMappingURL=doc.js.map
@@ -1 +0,0 @@
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;AAE/G,8DAA8D;AAC9D,MAAM,OAAO,GAAsC,CAAC,KAAgB,EAAE,EAAE;IACpE,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IAClD,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACnC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAA;IACnE,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAsB,CAAA;AACvD,CAAC,CAAA;AAED,8DAA8D;AAC9D,MAAM,OAAO,GAAG,KAAK,EAAE,IAAiB,EAAE,EAAE;IACxC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEtC,MAAM,cAAc,GAAG,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAA;IAC1D,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,cAAc,CAAC,CAAA;IACrD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,YAAY,CAAC,kBAAkB,CAClD,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,MAAM,IAAI,EAAE,EACnB,MAAM,CAAC,sBAAsB,CAChC,CAAA;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,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"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Everything you need for the `ts-for-gir generate` command is located here
3
- */
4
- import { Argv } from 'yargs';
5
- import type { ConfigFlags } from '@ts-for-gir/lib';
6
- export declare const generate: {
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
- };
@@ -1,71 +0,0 @@
1
- /**
2
- * Everything you need for the `ts-for-gir generate` command is located here
3
- */
4
- import { ERROR_NO_MODULES_FOUND, Logger } from '@ts-for-gir/lib';
5
- import { GeneratorType } from '@ts-for-gir/generator-base';
6
- import { GenerationHandler } from '../generation-handler.js';
7
- import { Config } from '../config.js';
8
- import { ModuleLoader } from '../module-loader.js';
9
- import prettier from 'prettier';
10
- import { Formatter } from '@ts-for-gir/lib';
11
- const command = 'generate [modules..]';
12
- const description = 'Generates Typescript type definition .d.ts files from GIR for GJS';
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- const builder = (yargs) => {
15
- const optionNames = Object.keys(Config.generateOptions);
16
- for (const optionName of optionNames) {
17
- yargs = yargs.option(optionName, Config.generateOptions[optionName]);
18
- }
19
- return yargs.example(examples);
20
- };
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- const handler = async (args) => {
23
- const config = await Config.load(args);
24
- const generateConfig = Config.getOptionsGeneration(config);
25
- const moduleLoader = new ModuleLoader(generateConfig);
26
- const { keep } = await moduleLoader.getModulesResolved(config.modules, config.ignore || [], config.ignoreVersionConflicts);
27
- if (keep.length === 0) {
28
- return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
29
- }
30
- moduleLoader.parse(keep);
31
- const tsForGir = new GenerationHandler(generateConfig, GeneratorType.TYPES);
32
- const girModules = Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module);
33
- moduleLoader.dependencyManager.registerFormatter('dts', new TypeScriptFormatter());
34
- await tsForGir.start(girModules, moduleLoader.dependencyManager);
35
- };
36
- const examples = [
37
- [
38
- `${Config.appName} generate`,
39
- `Run '${Config.appName} generate' in your gjs project to generate typings for your project, pass the gir modules you need for your project`,
40
- ],
41
- [`${Config.appName} generate Gtk*`, 'You can also use wild cards'],
42
- [`${Config.appName} generate '*'`, 'If you want to parse all of your locally installed gir modules run'],
43
- [`${Config.appName} generate --configName='.ts-for-gir.gtk4.rc.js`, 'Use a special config file'],
44
- [
45
- `${Config.appName} generate --ignore=Gtk-4.0 xrandr-1.3`,
46
- 'Generate .d.ts. files but not for Gtk-4.0 and xrandr-1.3',
47
- ],
48
- ];
49
- class TypeScriptFormatter extends Formatter {
50
- format(input) {
51
- try {
52
- return prettier.format(input, {
53
- singleQuote: true,
54
- parser: 'typescript',
55
- printWidth: 120,
56
- tabWidth: 4,
57
- });
58
- }
59
- catch (error) {
60
- return Promise.resolve(input);
61
- }
62
- }
63
- }
64
- export const generate = {
65
- command,
66
- description,
67
- builder,
68
- handler,
69
- examples,
70
- };
71
- //# sourceMappingURL=generate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,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;AAClD,OAAO,QAAQ,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,MAAM,OAAO,GAAG,sBAAsB,CAAA;AAEtC,MAAM,WAAW,GAAG,mEAAmE,CAAA;AAEvF,8DAA8D;AAC9D,MAAM,OAAO,GAAsC,CAAC,KAAgB,EAAE,EAAE;IACpE,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAA;IACvD,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACnC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAA;IACxE,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CA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AAM,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,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"}
@@ -1,4 +0,0 @@
1
- export * from './copy.js';
2
- export * from './doc.js';
3
- export * from './generate.js';
4
- export * from './list.js';
@@ -1,5 +0,0 @@
1
- export * from './copy.js';
2
- export * from './doc.js';
3
- export * from './generate.js';
4
- export * from './list.js';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Everything you need for the `ts-for-gir list` command is located here
3
- */
4
- import { Argv } from 'yargs';
5
- import type { ConfigFlags } from '@ts-for-gir/lib';
6
- export declare const list: {
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
- };