@ts-for-gir/cli 4.0.0-beta.25 → 4.0.0-beta.27
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 +84 -2
- package/bin/ts-for-gir-dev.js +43 -0
- package/bin/ts-for-gir.js +20046 -0
- package/package.json +34 -36
- package/src/commands/analyze.ts +344 -0
- package/src/commands/command-builder.ts +30 -0
- package/src/commands/copy.ts +71 -76
- package/src/commands/doc.ts +58 -46
- package/src/commands/generate.ts +97 -77
- package/src/commands/index.ts +6 -4
- package/src/commands/json.ts +104 -0
- package/src/commands/list.ts +81 -90
- package/src/config/config-loader.ts +203 -0
- package/src/config/config-writer.ts +52 -0
- package/src/config/defaults.ts +61 -0
- package/src/config/index.ts +8 -0
- package/src/config/options.ts +292 -0
- package/src/config.ts +3 -456
- package/src/formatters/typescript-formatter.ts +24 -0
- package/src/generation-handler.ts +122 -67
- package/src/index.ts +4 -4
- package/src/module-loader/dependency-resolver.ts +100 -0
- package/src/module-loader/file-finder.ts +58 -0
- package/src/module-loader/index.ts +8 -0
- package/src/module-loader/module-grouper.ts +77 -0
- package/src/module-loader/prompt-handler.ts +111 -0
- package/src/module-loader.ts +280 -580
- package/src/start.ts +17 -14
- package/src/types/command-args.ts +110 -0
- package/src/types/command-definition.ts +15 -0
- package/src/types/commands.ts +35 -0
- package/src/types/index.ts +15 -0
- package/src/types/report-types.ts +34 -0
- package/lib/commands/copy.d.ts +0 -12
- package/lib/commands/copy.js +0 -78
- package/lib/commands/copy.js.map +0 -1
- package/lib/commands/doc.d.ts +0 -12
- package/lib/commands/doc.js +0 -38
- package/lib/commands/doc.js.map +0 -1
- package/lib/commands/generate.d.ts +0 -12
- package/lib/commands/generate.js +0 -70
- package/lib/commands/generate.js.map +0 -1
- package/lib/commands/index.d.ts +0 -4
- package/lib/commands/index.js +0 -5
- package/lib/commands/index.js.map +0 -1
- package/lib/commands/list.d.ts +0 -12
- package/lib/commands/list.js +0 -79
- package/lib/commands/list.js.map +0 -1
- package/lib/config.d.ts +0 -108
- package/lib/config.js +0 -409
- package/lib/config.js.map +0 -1
- package/lib/generation-handler.d.ts +0 -10
- package/lib/generation-handler.js +0 -48
- package/lib/generation-handler.js.map +0 -1
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -5
- package/lib/index.js.map +0 -1
- package/lib/module-loader.d.ts +0 -154
- package/lib/module-loader.js +0 -465
- package/lib/module-loader.js.map +0 -1
- package/lib/start.d.ts +0 -2
- package/lib/start.js +0 -16
- package/lib/start.js.map +0 -1
package/src/commands/doc.ts
CHANGED
|
@@ -2,57 +2,69 @@
|
|
|
2
2
|
* Everything you need for the `ts-for-gir generate` command is located here
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
import { GeneratorType } from "@ts-for-gir/generator-base";
|
|
6
|
+
import type { ConfigFlags } from "@ts-for-gir/lib";
|
|
7
|
+
import {
|
|
8
|
+
configureConflictsReporter,
|
|
9
|
+
ERROR_NO_MODULES_FOUND,
|
|
10
|
+
type GirModule,
|
|
11
|
+
Logger,
|
|
12
|
+
NSRegistry,
|
|
13
|
+
TypeIdentifier,
|
|
14
|
+
} from "@ts-for-gir/lib";
|
|
15
|
+
import type { Argv, BuilderCallback } from "yargs";
|
|
16
|
+
import { docOptions, getOptionsGeneration, load } from "../config.ts";
|
|
17
|
+
import { GenerationHandler } from "../generation-handler.ts";
|
|
18
|
+
import { ModuleLoader } from "../module-loader.ts";
|
|
19
|
+
import type { DocCommandArgs } from "../types/index.ts";
|
|
11
20
|
|
|
12
|
-
|
|
21
|
+
const command = "doc [modules..]";
|
|
13
22
|
|
|
14
|
-
const
|
|
23
|
+
const description = "The HTML documentation generator is not yet implemented, but feel free to implement it 🤗";
|
|
15
24
|
|
|
16
|
-
const
|
|
25
|
+
const logger = new Logger(false, "DocCommand");
|
|
17
26
|
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
27
|
+
const builder: BuilderCallback<DocCommandArgs, ConfigFlags> = (yargs: Argv<DocCommandArgs>) => {
|
|
28
|
+
const optionNames = Object.keys(docOptions);
|
|
29
|
+
for (const optionName of optionNames) {
|
|
30
|
+
yargs = yargs.option(optionName, docOptions[optionName]);
|
|
31
|
+
}
|
|
32
|
+
return yargs.example(examples) as Argv<ConfigFlags>;
|
|
33
|
+
};
|
|
26
34
|
|
|
27
|
-
|
|
28
35
|
const handler = async (args: ConfigFlags) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
36
|
+
const config = await load(args);
|
|
37
|
+
|
|
38
|
+
const generateConfig = getOptionsGeneration(config);
|
|
39
|
+
const registry = new NSRegistry(); // TODO: Use singleton
|
|
40
|
+
|
|
41
|
+
// Configure reporters BEFORE parsing to capture all problems
|
|
42
|
+
if (generateConfig.reporter) {
|
|
43
|
+
TypeIdentifier.configureReporter(generateConfig.reporter, generateConfig.reporterOutput);
|
|
44
|
+
configureConflictsReporter(generateConfig.reporter, generateConfig.reporterOutput);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const moduleLoader = new ModuleLoader(generateConfig, registry);
|
|
48
|
+
const { keep } = await moduleLoader.getModulesResolved(
|
|
49
|
+
config.modules,
|
|
50
|
+
config.ignore || [],
|
|
51
|
+
config.ignoreVersionConflicts,
|
|
52
|
+
);
|
|
53
|
+
if (keep.length === 0) {
|
|
54
|
+
logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const tsForGir = new GenerationHandler(generateConfig, GeneratorType.HTML_DOC, registry);
|
|
58
|
+
|
|
59
|
+
await tsForGir.start(Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module as GirModule));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const examples: ReadonlyArray<[string, string?]> = [];
|
|
51
63
|
|
|
52
64
|
export const doc = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
65
|
+
command,
|
|
66
|
+
description,
|
|
67
|
+
builder,
|
|
68
|
+
handler,
|
|
69
|
+
examples,
|
|
70
|
+
};
|
package/src/commands/generate.ts
CHANGED
|
@@ -2,90 +2,110 @@
|
|
|
2
2
|
* Everything you need for the `ts-for-gir generate` command is located here
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
import { GeneratorType } from "@ts-for-gir/generator-base";
|
|
6
|
+
import type { ConfigFlags } from "@ts-for-gir/lib";
|
|
7
|
+
import {
|
|
8
|
+
APP_NAME,
|
|
9
|
+
configureConflictsReporter,
|
|
10
|
+
ERROR_NO_MODULES_FOUND,
|
|
11
|
+
type GirModule,
|
|
12
|
+
Logger,
|
|
13
|
+
NSRegistry,
|
|
14
|
+
ReporterService,
|
|
15
|
+
TypeIdentifier,
|
|
16
|
+
} from "@ts-for-gir/lib";
|
|
17
|
+
import { generateOptions, getOptionsGeneration, load } from "../config.ts";
|
|
18
|
+
import { TypeScriptFormatter } from "../formatters/typescript-formatter.ts";
|
|
19
|
+
import { GenerationHandler } from "../generation-handler.ts";
|
|
20
|
+
import { ModuleLoader } from "../module-loader.ts";
|
|
21
|
+
import type { GenerateCommandArgs } from "../types/index.ts";
|
|
22
|
+
import { createBuilder } from "./command-builder.ts";
|
|
23
|
+
|
|
24
|
+
const command = "generate [modules..]";
|
|
25
|
+
|
|
26
|
+
const description = "Generates Typescript type definition .d.ts files from GIR for GJS";
|
|
27
|
+
|
|
28
|
+
const logger = new Logger(false, "GenerateCommand");
|
|
29
|
+
|
|
30
|
+
const examples: ReadonlyArray<[string, string?]> = [
|
|
31
|
+
[
|
|
32
|
+
`${APP_NAME} generate`,
|
|
33
|
+
`Run '${APP_NAME} generate' in your gjs project to generate typings for your project, pass the gir modules you need for your project`,
|
|
34
|
+
],
|
|
35
|
+
[`${APP_NAME} generate Gtk*`, "You can also use wild cards"],
|
|
36
|
+
[`${APP_NAME} generate '*'`, "If you want to parse all of your locally installed gir modules run"],
|
|
37
|
+
[`${APP_NAME} generate --configName='.ts-for-gir.gtk4.rc.js`, "Use a special config file"],
|
|
38
|
+
[`${APP_NAME} generate --ignore=Gtk-4.0 xrandr-1.3`, "Generate .d.ts. files but not for Gtk-4.0 and xrandr-1.3"],
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const builder = createBuilder<GenerateCommandArgs>(generateOptions, examples);
|
|
42
|
+
|
|
30
43
|
const handler = async (args: ConfigFlags) => {
|
|
31
|
-
|
|
44
|
+
const config = await load(args);
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const { keep } = await moduleLoader.getModulesResolved(
|
|
36
|
-
config.modules,
|
|
37
|
-
config.ignore || [],
|
|
38
|
-
config.ignoreVersionConflicts,
|
|
39
|
-
)
|
|
46
|
+
const generateConfig = getOptionsGeneration(config);
|
|
47
|
+
const registry = new NSRegistry(); // TODO: Use singleton
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
49
|
+
// Register TypeScript formatter for .d.ts files
|
|
50
|
+
registry.registerFormatter("dts", new TypeScriptFormatter());
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
const moduleLoader = new ModuleLoader(generateConfig, registry);
|
|
46
53
|
|
|
47
|
-
|
|
54
|
+
// Configure reporters BEFORE parsing to capture all problems
|
|
55
|
+
if (generateConfig.reporter) {
|
|
56
|
+
TypeIdentifier.configureReporter(generateConfig.reporter, generateConfig.reporterOutput);
|
|
57
|
+
configureConflictsReporter(generateConfig.reporter, generateConfig.reporterOutput);
|
|
58
|
+
}
|
|
48
59
|
|
|
49
|
-
|
|
60
|
+
let tsForGir: GenerationHandler | null = null;
|
|
50
61
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
try {
|
|
63
|
+
const { keep } = await moduleLoader.getModulesResolved(
|
|
64
|
+
config.modules,
|
|
65
|
+
config.ignore || [],
|
|
66
|
+
config.ignoreVersionConflicts,
|
|
67
|
+
);
|
|
54
68
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
69
|
+
if (keep.length === 0) {
|
|
70
|
+
logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
moduleLoader.parse(keep);
|
|
75
|
+
|
|
76
|
+
tsForGir = new GenerationHandler(generateConfig, GeneratorType.TYPES, registry);
|
|
77
|
+
|
|
78
|
+
const girModules = Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module as GirModule);
|
|
79
|
+
|
|
80
|
+
await tsForGir.start(girModules);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
// If reporter is enabled and tsForGir was created, make sure the report is generated
|
|
83
|
+
if (generateConfig.reporter && tsForGir) {
|
|
84
|
+
const service = ReporterService.getInstance();
|
|
85
|
+
|
|
86
|
+
// Log the error to the reporter
|
|
87
|
+
if (tsForGir.log) {
|
|
88
|
+
tsForGir.log.reportGenerationFailure(
|
|
89
|
+
"Main",
|
|
90
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
91
|
+
"Generation failed",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Generate and save the report
|
|
96
|
+
await service.printComprehensiveSummary();
|
|
97
|
+
await service.saveComprehensiveReport();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Re-throw the error to maintain existing behavior
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
84
104
|
|
|
85
105
|
export const generate = {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
106
|
+
command,
|
|
107
|
+
description,
|
|
108
|
+
builder,
|
|
109
|
+
handler,
|
|
110
|
+
examples,
|
|
111
|
+
};
|
package/src/commands/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./analyze.ts";
|
|
2
|
+
export * from "./copy.ts";
|
|
3
|
+
export * from "./doc.ts";
|
|
4
|
+
export * from "./generate.ts";
|
|
5
|
+
export * from "./json.ts";
|
|
6
|
+
export * from "./list.ts";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything you need for the `ts-for-gir json` command is located here
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { GeneratorType } from "@ts-for-gir/generator-base";
|
|
6
|
+
import type { ConfigFlags } from "@ts-for-gir/lib";
|
|
7
|
+
import {
|
|
8
|
+
APP_NAME,
|
|
9
|
+
configureConflictsReporter,
|
|
10
|
+
ERROR_NO_MODULES_FOUND,
|
|
11
|
+
type GirModule,
|
|
12
|
+
Logger,
|
|
13
|
+
NSRegistry,
|
|
14
|
+
ReporterService,
|
|
15
|
+
TypeIdentifier,
|
|
16
|
+
} from "@ts-for-gir/lib";
|
|
17
|
+
import { generateOptions, getOptionsGeneration, load } from "../config.ts";
|
|
18
|
+
import { GenerationHandler } from "../generation-handler.ts";
|
|
19
|
+
import { ModuleLoader } from "../module-loader.ts";
|
|
20
|
+
import type { GenerateCommandArgs } from "../types/index.ts";
|
|
21
|
+
import { createBuilder } from "./command-builder.ts";
|
|
22
|
+
|
|
23
|
+
const command = "json [modules..]";
|
|
24
|
+
|
|
25
|
+
const description = "Generates JSON representation from GIR files for analysis and tooling";
|
|
26
|
+
|
|
27
|
+
const logger = new Logger(false, "JsonCommand");
|
|
28
|
+
|
|
29
|
+
const examples: ReadonlyArray<[string, string?]> = [
|
|
30
|
+
[`${APP_NAME} json`, `Run '${APP_NAME} json' in your gjs project to generate JSON files for your project`],
|
|
31
|
+
[`${APP_NAME} json Gtk*`, "You can also use wild cards"],
|
|
32
|
+
[`${APP_NAME} json '*'`, "If you want to parse all of your locally installed gir modules run"],
|
|
33
|
+
[`${APP_NAME} json --configName='.ts-for-gir.gtk4.rc.js`, "Use a special config file"],
|
|
34
|
+
[`${APP_NAME} json --ignore=Gtk-4.0 xrandr-1.3`, "Generate JSON files but not for Gtk-4.0 and xrandr-1.3"],
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const builder = createBuilder<GenerateCommandArgs>(generateOptions, examples);
|
|
38
|
+
|
|
39
|
+
const handler = async (args: ConfigFlags) => {
|
|
40
|
+
const config = await load(args);
|
|
41
|
+
|
|
42
|
+
const generateConfig = getOptionsGeneration(config);
|
|
43
|
+
const registry = new NSRegistry(); // TODO: Use singleton
|
|
44
|
+
|
|
45
|
+
const moduleLoader = new ModuleLoader(generateConfig, registry);
|
|
46
|
+
|
|
47
|
+
// Configure reporters BEFORE parsing to capture all problems
|
|
48
|
+
if (generateConfig.reporter) {
|
|
49
|
+
TypeIdentifier.configureReporter(generateConfig.reporter, generateConfig.reporterOutput);
|
|
50
|
+
configureConflictsReporter(generateConfig.reporter, generateConfig.reporterOutput);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let tsForGir: GenerationHandler | null = null;
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
const { keep } = await moduleLoader.getModulesResolved(
|
|
57
|
+
config.modules,
|
|
58
|
+
config.ignore || [],
|
|
59
|
+
config.ignoreVersionConflicts,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
if (keep.length === 0) {
|
|
63
|
+
logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
moduleLoader.parse(keep);
|
|
68
|
+
|
|
69
|
+
tsForGir = new GenerationHandler(generateConfig, GeneratorType.JSON, registry);
|
|
70
|
+
|
|
71
|
+
const girModules = Array.from(keep).map((girModuleResolvedBy) => girModuleResolvedBy.module as GirModule);
|
|
72
|
+
|
|
73
|
+
await tsForGir.start(girModules);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
// If reporter is enabled and tsForGir was created, make sure the report is generated
|
|
76
|
+
if (generateConfig.reporter && tsForGir) {
|
|
77
|
+
const service = ReporterService.getInstance();
|
|
78
|
+
|
|
79
|
+
// Log the error to the reporter
|
|
80
|
+
if (tsForGir.log) {
|
|
81
|
+
tsForGir.log.reportGenerationFailure(
|
|
82
|
+
"Main",
|
|
83
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
84
|
+
"JSON generation failed",
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Generate and save the report
|
|
89
|
+
await service.printComprehensiveSummary();
|
|
90
|
+
await service.saveComprehensiveReport();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Re-throw the error to maintain existing behavior
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const json = {
|
|
99
|
+
command,
|
|
100
|
+
description,
|
|
101
|
+
builder,
|
|
102
|
+
handler,
|
|
103
|
+
examples,
|
|
104
|
+
};
|
package/src/commands/list.ts
CHANGED
|
@@ -2,101 +2,92 @@
|
|
|
2
2
|
* Everything you need for the `ts-for-gir list` command is located here
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import type { ConfigFlags } from "@ts-for-gir/lib";
|
|
6
|
+
import { APP_NAME, ERROR_NO_MODULES_FOUND, Logger, NSRegistry, ResolveType } from "@ts-for-gir/lib";
|
|
7
|
+
import { getOptionsGeneration, listOptions, load } from "../config.ts";
|
|
8
|
+
import { ModuleLoader } from "../module-loader.ts";
|
|
9
|
+
import type { ListCommandArgs } from "../types/index.ts";
|
|
10
|
+
import { createBuilder } from "./command-builder.ts";
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
const command = "list [modules..]";
|
|
11
13
|
|
|
12
|
-
const
|
|
14
|
+
const description = "Lists all available GIR modules";
|
|
13
15
|
|
|
14
|
-
const
|
|
16
|
+
const logger = new Logger(false, "ListCommand");
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
18
|
+
const examples: ReadonlyArray<[string, string?]> = [
|
|
19
|
+
[`${APP_NAME} list -g ./vala-girs/gir-1.0`, "Lists all available GIR modules in ./vala-girs/gir-1.0"],
|
|
20
|
+
[
|
|
21
|
+
`${APP_NAME} list --ignore=Gtk-3.0 xrandr-1.3`,
|
|
22
|
+
"Lists all available GIR modules in /usr/share/gir-1.0 but not Gtk-3.0 and xrandr-1.3",
|
|
23
|
+
],
|
|
24
|
+
];
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
const handler = async (args: ConfigFlags) => {
|
|
27
|
-
const config = await Config.load(args)
|
|
28
|
-
const generateConfig = Config.getOptionsGeneration(config)
|
|
29
|
-
const moduleLoader = new ModuleLoader(generateConfig)
|
|
30
|
-
const { grouped, failed } = await moduleLoader.getModules(config.modules, config.ignore)
|
|
31
|
-
const moduleGroups = Object.values(grouped)
|
|
32
|
-
if (Object.keys(grouped).length === 0) {
|
|
33
|
-
return Logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories))
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const conflictModules = moduleGroups.filter((moduleGroup) => moduleGroup.hasConflict)
|
|
37
|
-
|
|
38
|
-
const byHandModules = moduleGroups.filter(
|
|
39
|
-
(moduleGroup) => moduleGroup.modules[0].resolvedBy === ResolveType.BY_HAND,
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
const depModules = moduleGroups.filter(
|
|
43
|
-
(moduleGroup) => moduleGroup.modules[0].resolvedBy === ResolveType.DEPENDENCE,
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
Logger.info('\nSearch for gir files in:')
|
|
47
|
-
for (const dir of config.girDirectories) {
|
|
48
|
-
Logger.white(`- ${dir}`)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
Logger.info('\nSelected Modules:')
|
|
52
|
-
for (const moduleGroup of byHandModules) {
|
|
53
|
-
for (const depModule of moduleGroup.modules) {
|
|
54
|
-
Logger.white(`- ${depModule.packageName}`)
|
|
55
|
-
Logger.gray(` - ${depModule.path}`)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (depModules.length > 0) {
|
|
60
|
-
Logger.yellow('\nDependencies:')
|
|
61
|
-
for (const moduleGroup of depModules) {
|
|
62
|
-
for (const depModule of moduleGroup.modules) {
|
|
63
|
-
Logger.white(`- ${depModule.packageName}`)
|
|
64
|
-
Logger.gray(`- ${depModule.path}`)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (conflictModules.length > 0) {
|
|
70
|
-
Logger.danger('\nConflicts:')
|
|
71
|
-
for (const moduleGroup of conflictModules) {
|
|
72
|
-
Logger.white(`- ${moduleGroup.namespace}`)
|
|
73
|
-
for (const conflictModule of moduleGroup.modules) {
|
|
74
|
-
Logger.white(` - ${conflictModule.packageName}`)
|
|
75
|
-
Logger.gray(` - ${conflictModule.path}`)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (failed.length > 0) {
|
|
81
|
-
Logger.danger('\nDependencies not found:')
|
|
82
|
-
for (const fail of failed) {
|
|
83
|
-
Logger.white(`- ${fail}`)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
26
|
+
const builder = createBuilder<ListCommandArgs>(listOptions, examples);
|
|
87
27
|
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
28
|
+
const handler = async (args: ConfigFlags) => {
|
|
29
|
+
const config = await load(args);
|
|
30
|
+
const generateConfig = getOptionsGeneration(config);
|
|
31
|
+
const registry = new NSRegistry(); // TODO: Use singleton
|
|
32
|
+
const moduleLoader = new ModuleLoader(generateConfig, registry);
|
|
33
|
+
const { grouped, failed } = await moduleLoader.getModules(config.modules, config.ignore);
|
|
34
|
+
const moduleGroups = Object.values(grouped);
|
|
35
|
+
if (Object.keys(grouped).length === 0) {
|
|
36
|
+
return logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const conflictModules = moduleGroups.filter((moduleGroup) => moduleGroup.hasConflict);
|
|
40
|
+
|
|
41
|
+
const byHandModules = moduleGroups.filter((moduleGroup) => moduleGroup.modules[0].resolvedBy === ResolveType.BY_HAND);
|
|
42
|
+
|
|
43
|
+
const depModules = moduleGroups.filter((moduleGroup) => moduleGroup.modules[0].resolvedBy === ResolveType.DEPENDENCE);
|
|
44
|
+
|
|
45
|
+
logger.info("\nSearch for gir files in:");
|
|
46
|
+
for (const dir of config.girDirectories) {
|
|
47
|
+
logger.white(`- ${dir}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
logger.info("\nSelected Modules:");
|
|
51
|
+
for (const moduleGroup of byHandModules) {
|
|
52
|
+
for (const depModule of moduleGroup.modules) {
|
|
53
|
+
logger.white(`- ${depModule.packageName}`);
|
|
54
|
+
logger.gray(` - ${depModule.path}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (depModules.length > 0) {
|
|
59
|
+
logger.yellow("\nDependencies:");
|
|
60
|
+
for (const moduleGroup of depModules) {
|
|
61
|
+
for (const depModule of moduleGroup.modules) {
|
|
62
|
+
logger.white(`- ${depModule.packageName}`);
|
|
63
|
+
logger.gray(`- ${depModule.path}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (conflictModules.length > 0) {
|
|
69
|
+
logger.danger("\nConflicts:");
|
|
70
|
+
for (const moduleGroup of conflictModules) {
|
|
71
|
+
logger.white(`- ${moduleGroup.namespace}`);
|
|
72
|
+
for (const conflictModule of moduleGroup.modules) {
|
|
73
|
+
logger.white(` - ${conflictModule.packageName}`);
|
|
74
|
+
logger.gray(` - ${conflictModule.path}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (failed.length > 0) {
|
|
80
|
+
logger.danger("\nDependencies not found:");
|
|
81
|
+
for (const fail of failed) {
|
|
82
|
+
logger.white(`- ${fail}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
95
86
|
|
|
96
87
|
export const list = {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
88
|
+
command,
|
|
89
|
+
description,
|
|
90
|
+
builder,
|
|
91
|
+
handler,
|
|
92
|
+
examples,
|
|
93
|
+
};
|