@ts-for-gir/cli 4.0.0-beta.31 → 4.0.0-beta.33
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/bin/ts-for-gir +83 -88
- package/package.json +10 -10
- package/src/commands/copy.ts +1 -1
- package/src/commands/doc.ts +1 -1
- package/src/commands/generate.ts +1 -1
- package/src/commands/json.ts +1 -1
- package/src/commands/list.ts +11 -21
- package/src/module-loader/file-finder.ts +20 -6
package/bin/ts-for-gir
CHANGED
|
@@ -3333,7 +3333,7 @@ var require_lodash = __commonJS({
|
|
|
3333
3333
|
}
|
|
3334
3334
|
return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
|
|
3335
3335
|
});
|
|
3336
|
-
function
|
|
3336
|
+
function join10(array, separator) {
|
|
3337
3337
|
return array == null ? "" : nativeJoin.call(array, separator);
|
|
3338
3338
|
}
|
|
3339
3339
|
function last(array) {
|
|
@@ -5252,7 +5252,7 @@ var require_lodash = __commonJS({
|
|
|
5252
5252
|
lodash2.isUndefined = isUndefined;
|
|
5253
5253
|
lodash2.isWeakMap = isWeakMap;
|
|
5254
5254
|
lodash2.isWeakSet = isWeakSet;
|
|
5255
|
-
lodash2.join =
|
|
5255
|
+
lodash2.join = join10;
|
|
5256
5256
|
lodash2.kebabCase = kebabCase;
|
|
5257
5257
|
lodash2.last = last;
|
|
5258
5258
|
lodash2.lastIndexOf = lastIndexOf;
|
|
@@ -5515,19 +5515,17 @@ import { blue, gray, green, red, yellow, yellowBright } from "colorette";
|
|
|
5515
5515
|
|
|
5516
5516
|
// ../reporter/src/constants.ts
|
|
5517
5517
|
import { readFileSync } from "node:fs";
|
|
5518
|
-
import {
|
|
5519
|
-
import {
|
|
5520
|
-
var require2 = createRequire(import.meta.url);
|
|
5518
|
+
import { dirname, join } from "node:path";
|
|
5519
|
+
import { fileURLToPath } from "node:url";
|
|
5521
5520
|
function resolvePackageJson() {
|
|
5522
5521
|
try {
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
}
|
|
5522
|
+
const currentModulePath = fileURLToPath(import.meta.url);
|
|
5523
|
+
const currentDir = dirname(currentModulePath);
|
|
5524
|
+
const packageRoot = join(currentDir, "..");
|
|
5525
|
+
const packageJsonPath = join(packageRoot, "package.json");
|
|
5526
|
+
return packageJsonPath;
|
|
5527
|
+
} catch (error) {
|
|
5528
|
+
throw new Error(`Unable to resolve package.json path: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
5531
5529
|
}
|
|
5532
5530
|
}
|
|
5533
5531
|
function readPackage() {
|
|
@@ -5542,8 +5540,6 @@ function readPackage() {
|
|
|
5542
5540
|
}
|
|
5543
5541
|
var PACKAGE = readPackage();
|
|
5544
5542
|
var PACKAGE_VERSION = PACKAGE.version;
|
|
5545
|
-
var PACKAGE_NAME = PACKAGE.name;
|
|
5546
|
-
var PACKAGE_DESCRIPTION = PACKAGE.description;
|
|
5547
5543
|
|
|
5548
5544
|
// ../reporter/src/types/problem.ts
|
|
5549
5545
|
var ProblemSeverity = /* @__PURE__ */ ((ProblemSeverity2) => {
|
|
@@ -6184,7 +6180,7 @@ ${"=".repeat(50)}`);
|
|
|
6184
6180
|
|
|
6185
6181
|
// ../reporter/src/reporter-service.ts
|
|
6186
6182
|
import { writeFile as writeFile2 } from "node:fs/promises";
|
|
6187
|
-
import { resolve
|
|
6183
|
+
import { resolve } from "node:path";
|
|
6188
6184
|
import { blue as blue2, green as green2, red as red2, yellow as yellow2 } from "colorette";
|
|
6189
6185
|
var ReporterService = class _ReporterService {
|
|
6190
6186
|
static instance = null;
|
|
@@ -6451,7 +6447,7 @@ var ReporterService = class _ReporterService {
|
|
|
6451
6447
|
const report = this.generateComprehensiveReport();
|
|
6452
6448
|
const filePath = outputPath || this.config.outputPath;
|
|
6453
6449
|
try {
|
|
6454
|
-
const fullPath =
|
|
6450
|
+
const fullPath = resolve(process.cwd(), filePath);
|
|
6455
6451
|
await writeFile2(fullPath, JSON.stringify(report, null, 2), "utf-8");
|
|
6456
6452
|
console.log(`\u{1F4CA} Comprehensive report saved to: ${fullPath}`);
|
|
6457
6453
|
} catch (error) {
|
|
@@ -6534,27 +6530,25 @@ ${"=".repeat(60)}`);
|
|
|
6534
6530
|
};
|
|
6535
6531
|
|
|
6536
6532
|
// ../lib/src/constants.ts
|
|
6537
|
-
import {
|
|
6538
|
-
import { dirname as dirname2,
|
|
6539
|
-
|
|
6533
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
6534
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
6535
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
6540
6536
|
var NEW_LINE_REG_EXP = /[\n\r]+/g;
|
|
6541
6537
|
function resolvePackageJson2() {
|
|
6542
6538
|
try {
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
}
|
|
6539
|
+
const currentModulePath = fileURLToPath2(import.meta.url);
|
|
6540
|
+
const currentDir = dirname2(currentModulePath);
|
|
6541
|
+
const packageRoot = join2(currentDir, "..");
|
|
6542
|
+
const packageJsonPath = join2(packageRoot, "package.json");
|
|
6543
|
+
return packageJsonPath;
|
|
6544
|
+
} catch (error) {
|
|
6545
|
+
throw new Error(`Unable to resolve package.json path: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
6551
6546
|
}
|
|
6552
6547
|
}
|
|
6553
6548
|
function readPackageSync() {
|
|
6554
6549
|
try {
|
|
6555
6550
|
const packagePath = resolvePackageJson2();
|
|
6556
|
-
const
|
|
6557
|
-
const content = readFileSync3(packagePath, "utf-8");
|
|
6551
|
+
const content = readFileSync2(packagePath, "utf-8");
|
|
6558
6552
|
return JSON.parse(content);
|
|
6559
6553
|
} catch (error) {
|
|
6560
6554
|
const message = error instanceof Error ? error.message : "Unknown error";
|
|
@@ -8175,7 +8169,7 @@ var Logger = class _Logger {
|
|
|
8175
8169
|
// ../lib/src/utils/files.ts
|
|
8176
8170
|
import { constants } from "node:fs";
|
|
8177
8171
|
import { access, readFile } from "node:fs/promises";
|
|
8178
|
-
import { join } from "node:path";
|
|
8172
|
+
import { join as join3 } from "node:path";
|
|
8179
8173
|
import { glob } from "glob";
|
|
8180
8174
|
var fileExists = async (filePath) => {
|
|
8181
8175
|
try {
|
|
@@ -8187,7 +8181,7 @@ var fileExists = async (filePath) => {
|
|
|
8187
8181
|
};
|
|
8188
8182
|
var findFilesInDirs = async (dirs, filename) => {
|
|
8189
8183
|
const filesInfo = [];
|
|
8190
|
-
const pattern = dirs.map((dir) =>
|
|
8184
|
+
const pattern = dirs.map((dir) => join3(dir, filename));
|
|
8191
8185
|
const _files = await glob(pattern);
|
|
8192
8186
|
const files = [...new Set(_files)];
|
|
8193
8187
|
for (const filePath of files) {
|
|
@@ -15945,10 +15939,10 @@ var GENERATING_TYPES_DONE = "Done.";
|
|
|
15945
15939
|
|
|
15946
15940
|
// ../lib/src/templates/template-engine.ts
|
|
15947
15941
|
import { mkdir, readdir, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
|
|
15948
|
-
import { createRequire
|
|
15949
|
-
import { dirname as dirname3, extname, join as
|
|
15942
|
+
import { createRequire } from "node:module";
|
|
15943
|
+
import { dirname as dirname3, extname, join as join4, resolve as resolve2 } from "node:path";
|
|
15950
15944
|
import ejs from "ejs";
|
|
15951
|
-
var
|
|
15945
|
+
var require2 = createRequire(import.meta.url);
|
|
15952
15946
|
var TemplateEngine = class {
|
|
15953
15947
|
log;
|
|
15954
15948
|
templateDir;
|
|
@@ -15962,9 +15956,9 @@ var TemplateEngine = class {
|
|
|
15962
15956
|
*/
|
|
15963
15957
|
resolveTemplateDirectory() {
|
|
15964
15958
|
try {
|
|
15965
|
-
return
|
|
15959
|
+
return join4(dirname3(require2.resolve("@ts-for-gir/templates/package.json")), "templates");
|
|
15966
15960
|
} catch (_error) {
|
|
15967
|
-
return
|
|
15961
|
+
return resolve2(process.cwd(), "../../templates/templates");
|
|
15968
15962
|
}
|
|
15969
15963
|
}
|
|
15970
15964
|
/**
|
|
@@ -15986,7 +15980,7 @@ var TemplateEngine = class {
|
|
|
15986
15980
|
* Checks if the template file or directory exists and returns the path if found
|
|
15987
15981
|
*/
|
|
15988
15982
|
async exists(templateFilename) {
|
|
15989
|
-
const fullTemplatePath =
|
|
15983
|
+
const fullTemplatePath = join4(this.templateDir, templateFilename);
|
|
15990
15984
|
if (await fileExists(fullTemplatePath)) {
|
|
15991
15985
|
return fullTemplatePath;
|
|
15992
15986
|
}
|
|
@@ -16026,7 +16020,7 @@ var TemplateEngine = class {
|
|
|
16026
16020
|
}
|
|
16027
16021
|
const results = {};
|
|
16028
16022
|
for (const file of files) {
|
|
16029
|
-
const content = await readFile3(
|
|
16023
|
+
const content = await readFile3(join4(path, file), "utf8");
|
|
16030
16024
|
results[file] = this.removeTypeScriptDirectives(content);
|
|
16031
16025
|
}
|
|
16032
16026
|
return results;
|
|
@@ -16397,29 +16391,29 @@ function mergeDescs(descs, comment, indentCount = 1) {
|
|
|
16397
16391
|
}
|
|
16398
16392
|
|
|
16399
16393
|
// ../lib/src/utils/path.ts
|
|
16400
|
-
import { dirname as dirname4, resolve as
|
|
16401
|
-
import { fileURLToPath } from "node:url";
|
|
16402
|
-
var __filename =
|
|
16403
|
-
var __dirname =
|
|
16394
|
+
import { dirname as dirname4, resolve as resolve3 } from "node:path";
|
|
16395
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
16396
|
+
var __filename = fileURLToPath3(import.meta.url);
|
|
16397
|
+
var __dirname = resolve3(dirname4(__filename), "../..");
|
|
16404
16398
|
|
|
16405
16399
|
// src/start.ts
|
|
16406
16400
|
import yargs from "yargs";
|
|
16407
16401
|
import { hideBin } from "yargs/helpers";
|
|
16408
16402
|
|
|
16409
16403
|
// src/commands/analyze.ts
|
|
16410
|
-
import { existsSync as existsSync2, readFileSync as
|
|
16404
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync } from "node:fs";
|
|
16411
16405
|
|
|
16412
16406
|
// src/config/config-loader.ts
|
|
16413
|
-
import { dirname as dirname5, resolve as
|
|
16407
|
+
import { dirname as dirname5, resolve as resolve4 } from "node:path";
|
|
16414
16408
|
import { cosmiconfig } from "cosmiconfig";
|
|
16415
16409
|
|
|
16416
16410
|
// src/config/config-writer.ts
|
|
16417
16411
|
import { writeFile as writeFile4 } from "node:fs/promises";
|
|
16418
|
-
import { extname as extname2, join as
|
|
16412
|
+
import { extname as extname2, join as join6 } from "node:path";
|
|
16419
16413
|
|
|
16420
16414
|
// src/config/defaults.ts
|
|
16421
16415
|
import { existsSync } from "node:fs";
|
|
16422
|
-
import { join as
|
|
16416
|
+
import { join as join5 } from "node:path";
|
|
16423
16417
|
var defaults = {
|
|
16424
16418
|
print: false,
|
|
16425
16419
|
configName: ".ts-for-girrc.js",
|
|
@@ -16455,7 +16449,7 @@ function getDefaultGirDirectories() {
|
|
|
16455
16449
|
];
|
|
16456
16450
|
const dataDirs = process.env.XDG_DATA_DIRS?.split(":") || [];
|
|
16457
16451
|
for (let dataDir of dataDirs) {
|
|
16458
|
-
dataDir =
|
|
16452
|
+
dataDir = join5(dataDir, "gir-1.0");
|
|
16459
16453
|
if (!girDirectories.includes(dataDir) && existsSync(dataDir)) {
|
|
16460
16454
|
girDirectories.push(dataDir);
|
|
16461
16455
|
}
|
|
@@ -16465,7 +16459,7 @@ function getDefaultGirDirectories() {
|
|
|
16465
16459
|
|
|
16466
16460
|
// src/config/config-writer.ts
|
|
16467
16461
|
var logger2 = new Logger(false, "ConfigWriter");
|
|
16468
|
-
var configFilePath =
|
|
16462
|
+
var configFilePath = join6(process.cwd(), defaults.configName);
|
|
16469
16463
|
function setConfigFilePath(path) {
|
|
16470
16464
|
configFilePath = path;
|
|
16471
16465
|
}
|
|
@@ -16879,12 +16873,12 @@ async function load(cliOptions) {
|
|
|
16879
16873
|
}
|
|
16880
16874
|
}
|
|
16881
16875
|
if (userConfig.outdir && !userConfig.outdir.startsWith("/")) {
|
|
16882
|
-
userConfig.outdir =
|
|
16876
|
+
userConfig.outdir = resolve4(userConfig.root, userConfig.outdir);
|
|
16883
16877
|
}
|
|
16884
16878
|
if (userConfig.girDirectories) {
|
|
16885
16879
|
userConfig.girDirectories = userConfig.girDirectories.map((dir) => {
|
|
16886
16880
|
if (!dir.startsWith("/")) {
|
|
16887
|
-
return
|
|
16881
|
+
return resolve4(userConfig.root, dir);
|
|
16888
16882
|
}
|
|
16889
16883
|
return dir;
|
|
16890
16884
|
});
|
|
@@ -16933,7 +16927,7 @@ var loadReportFile = (filePath) => {
|
|
|
16933
16927
|
throw new Error(`Report file not found: ${filePath}`);
|
|
16934
16928
|
}
|
|
16935
16929
|
try {
|
|
16936
|
-
const content =
|
|
16930
|
+
const content = readFileSync3(filePath, "utf-8");
|
|
16937
16931
|
const report = JSON.parse(content);
|
|
16938
16932
|
report.metadata.generatedAt = parseReportDate(report.metadata.generatedAt);
|
|
16939
16933
|
report.statistics.startTime = parseReportDate(report.statistics.startTime);
|
|
@@ -17160,7 +17154,7 @@ var analyze = {
|
|
|
17160
17154
|
|
|
17161
17155
|
// src/commands/copy.ts
|
|
17162
17156
|
import { copyFile, mkdir as mkdir2 } from "node:fs/promises";
|
|
17163
|
-
import { basename as basename2, join as
|
|
17157
|
+
import { basename as basename2, join as join8 } from "node:path";
|
|
17164
17158
|
|
|
17165
17159
|
// src/module-loader/dependency-resolver.ts
|
|
17166
17160
|
var DependencyResolver = class {
|
|
@@ -17238,7 +17232,7 @@ var DependencyResolver = class {
|
|
|
17238
17232
|
};
|
|
17239
17233
|
|
|
17240
17234
|
// src/module-loader/file-finder.ts
|
|
17241
|
-
import { basename, join as
|
|
17235
|
+
import { basename, join as join7 } from "node:path";
|
|
17242
17236
|
import { glob as glob2 } from "glob";
|
|
17243
17237
|
var FileFinder = class {
|
|
17244
17238
|
constructor(girDirectories, dependencyManager) {
|
|
@@ -17256,12 +17250,23 @@ var FileFinder = class {
|
|
|
17256
17250
|
if (!globPackageNames[i]) {
|
|
17257
17251
|
continue;
|
|
17258
17252
|
}
|
|
17259
|
-
|
|
17260
|
-
|
|
17261
|
-
|
|
17262
|
-
|
|
17263
|
-
|
|
17264
|
-
|
|
17253
|
+
if (globPackageNames[i] === "*") {
|
|
17254
|
+
for (const girDirectory of this.girDirectories) {
|
|
17255
|
+
const pattern = join7(girDirectory, "*.gir");
|
|
17256
|
+
const ignoreGirs = ignore.map((ignored) => join7(girDirectory, `${ignored}.gir`));
|
|
17257
|
+
const files = await glob2(pattern, { ignore: ignoreGirs });
|
|
17258
|
+
for (const file of files) {
|
|
17259
|
+
foundFiles.add(file);
|
|
17260
|
+
}
|
|
17261
|
+
}
|
|
17262
|
+
} else {
|
|
17263
|
+
const filename = `${globPackageNames[i]}.gir`;
|
|
17264
|
+
const pattern = this.girDirectories.map((girDirectory) => join7(girDirectory, filename));
|
|
17265
|
+
const ignoreGirs = ignore.map((girDirectory) => `${girDirectory}.gir`);
|
|
17266
|
+
const files = await glob2(pattern, { ignore: ignoreGirs });
|
|
17267
|
+
for (const file of files) {
|
|
17268
|
+
foundFiles.add(file);
|
|
17269
|
+
}
|
|
17265
17270
|
}
|
|
17266
17271
|
}
|
|
17267
17272
|
return foundFiles;
|
|
@@ -17641,7 +17646,7 @@ var ModuleLoader = class {
|
|
|
17641
17646
|
// src/commands/copy.ts
|
|
17642
17647
|
var command2 = "copy [modules..]";
|
|
17643
17648
|
var description2 = "Scan for *.gir files and copy them to a new directory";
|
|
17644
|
-
var logger3 = new Logger(
|
|
17649
|
+
var logger3 = new Logger(true, "CopyCommand");
|
|
17645
17650
|
var examples2 = [
|
|
17646
17651
|
[`${APP_NAME} copy -o ./gir`, "Copy found *.gir files to ./gir"],
|
|
17647
17652
|
[
|
|
@@ -17660,7 +17665,7 @@ var copyGirFile = async (config, depModule) => {
|
|
|
17660
17665
|
return;
|
|
17661
17666
|
}
|
|
17662
17667
|
const filename = basename2(depModule.path);
|
|
17663
|
-
const dest =
|
|
17668
|
+
const dest = join8(config.outdir, filename);
|
|
17664
17669
|
if (depModule.path === dest) {
|
|
17665
17670
|
logger3.yellow(`Skip ${depModule.path}`);
|
|
17666
17671
|
return;
|
|
@@ -17921,7 +17926,7 @@ var JsonDefinitionGenerator = class _JsonDefinitionGenerator {
|
|
|
17921
17926
|
};
|
|
17922
17927
|
|
|
17923
17928
|
// ../generator-typescript/src/template-processor.ts
|
|
17924
|
-
import { dirname as dirname6, join as
|
|
17929
|
+
import { dirname as dirname6, join as join9, relative } from "node:path";
|
|
17925
17930
|
var TemplateProcessor = class extends TemplateEngine {
|
|
17926
17931
|
data;
|
|
17927
17932
|
packageName;
|
|
@@ -17951,7 +17956,7 @@ var TemplateProcessor = class extends TemplateEngine {
|
|
|
17951
17956
|
dep,
|
|
17952
17957
|
deps,
|
|
17953
17958
|
typeDir,
|
|
17954
|
-
join:
|
|
17959
|
+
join: join9,
|
|
17955
17960
|
dirname: dirname6,
|
|
17956
17961
|
...this.config,
|
|
17957
17962
|
packageName: this.packageName
|
|
@@ -18022,10 +18027,10 @@ ${append}`;
|
|
|
18022
18027
|
const rendered = await this.loadAll(templateDirname, fileExtension, ejsOptions, overrideTemplateData);
|
|
18023
18028
|
const result = {};
|
|
18024
18029
|
for (const filename of Object.keys(rendered)) {
|
|
18025
|
-
const destPath =
|
|
18030
|
+
const destPath = join9(baseOutputPath, outputDirname, filename);
|
|
18026
18031
|
result[destPath] = `${rendered[filename]}
|
|
18027
18032
|
${append}`;
|
|
18028
|
-
await this.write(result[destPath], baseOutputPath,
|
|
18033
|
+
await this.write(result[destPath], baseOutputPath, join9(outputDirname, filename));
|
|
18029
18034
|
}
|
|
18030
18035
|
return result;
|
|
18031
18036
|
}
|
|
@@ -18034,8 +18039,8 @@ ${append}`;
|
|
|
18034
18039
|
* This is TypeScript-specific logic for handling package.json mode
|
|
18035
18040
|
*/
|
|
18036
18041
|
getOutputPath(baseOutputPath, outputFilename) {
|
|
18037
|
-
const filePath = this.config.package ?
|
|
18038
|
-
const outputPath =
|
|
18042
|
+
const filePath = this.config.package ? join9(this.data?.importName || this.packageName, outputFilename) : outputFilename;
|
|
18043
|
+
const outputPath = join9(baseOutputPath, filePath);
|
|
18039
18044
|
return outputPath;
|
|
18040
18045
|
}
|
|
18041
18046
|
/**
|
|
@@ -19779,7 +19784,7 @@ var GenerationHandler = class {
|
|
|
19779
19784
|
// src/commands/doc.ts
|
|
19780
19785
|
var command3 = "doc [modules..]";
|
|
19781
19786
|
var description3 = "The HTML documentation generator is not yet implemented, but feel free to implement it \u{1F917}";
|
|
19782
|
-
var logger4 = new Logger(
|
|
19787
|
+
var logger4 = new Logger(true, "DocCommand");
|
|
19783
19788
|
var builder3 = (yargs2) => {
|
|
19784
19789
|
const optionNames = Object.keys(docOptions);
|
|
19785
19790
|
for (const optionName of optionNames) {
|
|
@@ -19839,7 +19844,7 @@ var TypeScriptFormatter = class extends Formatter {
|
|
|
19839
19844
|
// src/commands/generate.ts
|
|
19840
19845
|
var command4 = "generate [modules..]";
|
|
19841
19846
|
var description4 = "Generates Typescript type definition .d.ts files from GIR for GJS";
|
|
19842
|
-
var logger6 = new Logger(
|
|
19847
|
+
var logger6 = new Logger(true, "GenerateCommand");
|
|
19843
19848
|
var examples4 = [
|
|
19844
19849
|
[
|
|
19845
19850
|
`${APP_NAME} generate`,
|
|
@@ -19903,7 +19908,7 @@ var generate = {
|
|
|
19903
19908
|
// src/commands/json.ts
|
|
19904
19909
|
var command5 = "json [modules..]";
|
|
19905
19910
|
var description5 = "Generates JSON representation from GIR files for analysis and tooling";
|
|
19906
|
-
var logger7 = new Logger(
|
|
19911
|
+
var logger7 = new Logger(true, "JsonCommand");
|
|
19907
19912
|
var examples5 = [
|
|
19908
19913
|
[`${APP_NAME} json`, `Run '${APP_NAME} json' in your gjs project to generate JSON files for your project`],
|
|
19909
19914
|
[`${APP_NAME} json Gtk*`, "You can also use wild cards"],
|
|
@@ -19963,7 +19968,7 @@ var json = {
|
|
|
19963
19968
|
// src/commands/list.ts
|
|
19964
19969
|
var command6 = "list [modules..]";
|
|
19965
19970
|
var description6 = "Lists all available GIR modules";
|
|
19966
|
-
var logger8 = new Logger(
|
|
19971
|
+
var logger8 = new Logger(true, "ListCommand");
|
|
19967
19972
|
var examples6 = [
|
|
19968
19973
|
[`${APP_NAME} list -g ./vala-girs/gir-1.0`, "Lists all available GIR modules in ./vala-girs/gir-1.0"],
|
|
19969
19974
|
[
|
|
@@ -19983,26 +19988,16 @@ var handler6 = async (args) => {
|
|
|
19983
19988
|
return logger8.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
|
|
19984
19989
|
}
|
|
19985
19990
|
const conflictModules = moduleGroups.filter((moduleGroup) => moduleGroup.hasConflict);
|
|
19986
|
-
const
|
|
19987
|
-
const depModules = moduleGroups.filter((moduleGroup) => moduleGroup.modules[0].resolvedBy === 0 /* DEPENDENCE */);
|
|
19991
|
+
const allModules = moduleGroups.filter((moduleGroup) => !moduleGroup.hasConflict);
|
|
19988
19992
|
logger8.info("\nSearch for gir files in:");
|
|
19989
19993
|
for (const dir of config.girDirectories) {
|
|
19990
19994
|
logger8.white(`- ${dir}`);
|
|
19991
19995
|
}
|
|
19992
|
-
logger8.info("\
|
|
19993
|
-
for (const moduleGroup of
|
|
19994
|
-
for (const
|
|
19995
|
-
logger8.white(`- ${
|
|
19996
|
-
logger8.gray(` - ${
|
|
19997
|
-
}
|
|
19998
|
-
}
|
|
19999
|
-
if (depModules.length > 0) {
|
|
20000
|
-
logger8.yellow("\nDependencies:");
|
|
20001
|
-
for (const moduleGroup of depModules) {
|
|
20002
|
-
for (const depModule of moduleGroup.modules) {
|
|
20003
|
-
logger8.white(`- ${depModule.packageName}`);
|
|
20004
|
-
logger8.gray(`- ${depModule.path}`);
|
|
20005
|
-
}
|
|
19996
|
+
logger8.info("\nAvailable Modules:");
|
|
19997
|
+
for (const moduleGroup of allModules) {
|
|
19998
|
+
for (const module of moduleGroup.modules) {
|
|
19999
|
+
logger8.white(`- ${module.packageName}`);
|
|
20000
|
+
logger8.gray(` - ${module.path}`);
|
|
20006
20001
|
}
|
|
20007
20002
|
}
|
|
20008
20003
|
if (conflictModules.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-for-gir/cli",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.33",
|
|
4
4
|
"description": "TypeScript type definition generator for GObject introspection GIR files",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
|
-
"ts-for-gir": "bin/ts-for-gir",
|
|
10
9
|
"cli": "bin/ts-for-gir",
|
|
10
|
+
"ts-for-gir": "bin/ts-for-gir",
|
|
11
11
|
"ts-for-gir-dev": "bin/ts-for-gir-dev"
|
|
12
12
|
},
|
|
13
13
|
"engines": {
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
".": "./src/index.ts"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@gi.ts/parser": "^4.0.0-beta.
|
|
57
|
-
"@ts-for-gir/generator-base": "^4.0.0-beta.
|
|
58
|
-
"@ts-for-gir/generator-html-doc": "^4.0.0-beta.
|
|
59
|
-
"@ts-for-gir/generator-json": "^4.0.0-beta.
|
|
60
|
-
"@ts-for-gir/generator-typescript": "^4.0.0-beta.
|
|
61
|
-
"@ts-for-gir/lib": "^4.0.0-beta.
|
|
62
|
-
"@ts-for-gir/reporter": "^4.0.0-beta.
|
|
56
|
+
"@gi.ts/parser": "^4.0.0-beta.33",
|
|
57
|
+
"@ts-for-gir/generator-base": "^4.0.0-beta.33",
|
|
58
|
+
"@ts-for-gir/generator-html-doc": "^4.0.0-beta.33",
|
|
59
|
+
"@ts-for-gir/generator-json": "^4.0.0-beta.33",
|
|
60
|
+
"@ts-for-gir/generator-typescript": "^4.0.0-beta.33",
|
|
61
|
+
"@ts-for-gir/lib": "^4.0.0-beta.33",
|
|
62
|
+
"@ts-for-gir/reporter": "^4.0.0-beta.33",
|
|
63
63
|
"@types/ejs": "^3.1.5",
|
|
64
64
|
"@types/inquirer": "^9.0.9",
|
|
65
65
|
"@types/node": "^24.2.1",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@inquirer/prompts": "^7.8.2",
|
|
73
|
-
"@ts-for-gir/templates": "^4.0.0-beta.
|
|
73
|
+
"@ts-for-gir/templates": "^4.0.0-beta.33",
|
|
74
74
|
"colorette": "^2.0.20",
|
|
75
75
|
"cosmiconfig": "^9.0.0",
|
|
76
76
|
"ejs": "^3.1.10",
|
package/src/commands/copy.ts
CHANGED
|
@@ -15,7 +15,7 @@ const command = "copy [modules..]";
|
|
|
15
15
|
|
|
16
16
|
const description = "Scan for *.gir files and copy them to a new directory";
|
|
17
17
|
|
|
18
|
-
const logger = new Logger(
|
|
18
|
+
const logger = new Logger(true, "CopyCommand");
|
|
19
19
|
|
|
20
20
|
const examples: ReadonlyArray<[string, string?]> = [
|
|
21
21
|
[`${APP_NAME} copy -o ./gir`, "Copy found *.gir files to ./gir"],
|
package/src/commands/doc.ts
CHANGED
|
@@ -22,7 +22,7 @@ const command = "doc [modules..]";
|
|
|
22
22
|
|
|
23
23
|
const description = "The HTML documentation generator is not yet implemented, but feel free to implement it 🤗";
|
|
24
24
|
|
|
25
|
-
const logger = new Logger(
|
|
25
|
+
const logger = new Logger(true, "DocCommand");
|
|
26
26
|
|
|
27
27
|
const builder: BuilderCallback<DocCommandArgs, ConfigFlags> = (yargs: Argv<DocCommandArgs>) => {
|
|
28
28
|
const optionNames = Object.keys(docOptions);
|
package/src/commands/generate.ts
CHANGED
|
@@ -25,7 +25,7 @@ const command = "generate [modules..]";
|
|
|
25
25
|
|
|
26
26
|
const description = "Generates Typescript type definition .d.ts files from GIR for GJS";
|
|
27
27
|
|
|
28
|
-
const logger = new Logger(
|
|
28
|
+
const logger = new Logger(true, "GenerateCommand");
|
|
29
29
|
|
|
30
30
|
const examples: ReadonlyArray<[string, string?]> = [
|
|
31
31
|
[
|
package/src/commands/json.ts
CHANGED
|
@@ -24,7 +24,7 @@ const command = "json [modules..]";
|
|
|
24
24
|
|
|
25
25
|
const description = "Generates JSON representation from GIR files for analysis and tooling";
|
|
26
26
|
|
|
27
|
-
const logger = new Logger(
|
|
27
|
+
const logger = new Logger(true, "JsonCommand");
|
|
28
28
|
|
|
29
29
|
const examples: ReadonlyArray<[string, string?]> = [
|
|
30
30
|
[`${APP_NAME} json`, `Run '${APP_NAME} json' in your gjs project to generate JSON files for your project`],
|
package/src/commands/list.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { ConfigFlags } from "@ts-for-gir/lib";
|
|
6
|
-
import { APP_NAME, ERROR_NO_MODULES_FOUND, Logger, NSRegistry
|
|
6
|
+
import { APP_NAME, ERROR_NO_MODULES_FOUND, Logger, NSRegistry } from "@ts-for-gir/lib";
|
|
7
7
|
import { getOptionsGeneration, listOptions, load } from "../config.ts";
|
|
8
8
|
import { ModuleLoader } from "../module-loader.ts";
|
|
9
9
|
import type { ListCommandArgs } from "../types/index.ts";
|
|
@@ -13,7 +13,7 @@ const command = "list [modules..]";
|
|
|
13
13
|
|
|
14
14
|
const description = "Lists all available GIR modules";
|
|
15
15
|
|
|
16
|
-
const logger = new Logger(
|
|
16
|
+
const logger = new Logger(true, "ListCommand");
|
|
17
17
|
|
|
18
18
|
const examples: ReadonlyArray<[string, string?]> = [
|
|
19
19
|
[`${APP_NAME} list -g ./vala-girs/gir-1.0`, "Lists all available GIR modules in ./vala-girs/gir-1.0"],
|
|
@@ -32,39 +32,29 @@ const handler = async (args: ConfigFlags) => {
|
|
|
32
32
|
const moduleLoader = new ModuleLoader(generateConfig, registry);
|
|
33
33
|
const { grouped, failed } = await moduleLoader.getModules(config.modules, config.ignore);
|
|
34
34
|
const moduleGroups = Object.values(grouped);
|
|
35
|
+
|
|
35
36
|
if (Object.keys(grouped).length === 0) {
|
|
36
37
|
return logger.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
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);
|
|
41
|
+
const allModules = moduleGroups.filter((moduleGroup) => !moduleGroup.hasConflict);
|
|
44
42
|
|
|
45
43
|
logger.info("\nSearch for gir files in:");
|
|
46
44
|
for (const dir of config.girDirectories) {
|
|
47
45
|
logger.white(`- ${dir}`);
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
logger.
|
|
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
|
-
}
|
|
48
|
+
// Show all available modules
|
|
49
|
+
logger.info("\nAvailable Modules:");
|
|
50
|
+
for (const moduleGroup of allModules) {
|
|
51
|
+
for (const module of moduleGroup.modules) {
|
|
52
|
+
logger.white(`- ${module.packageName}`);
|
|
53
|
+
logger.gray(` - ${module.path}`);
|
|
65
54
|
}
|
|
66
55
|
}
|
|
67
56
|
|
|
57
|
+
// Only show sections if there is actual content
|
|
68
58
|
if (conflictModules.length > 0) {
|
|
69
59
|
logger.danger("\nConflicts:");
|
|
70
60
|
for (const moduleGroup of conflictModules) {
|
|
@@ -26,13 +26,27 @@ export class FileFinder {
|
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
// Handle wildcard patterns
|
|
30
|
+
if (globPackageNames[i] === "*") {
|
|
31
|
+
// Special case: find all .gir files
|
|
32
|
+
for (const girDirectory of this.girDirectories) {
|
|
33
|
+
const pattern = join(girDirectory, "*.gir");
|
|
34
|
+
const ignoreGirs = ignore.map((ignored) => join(girDirectory, `${ignored}.gir`));
|
|
35
|
+
const files = await glob(pattern, { ignore: ignoreGirs });
|
|
36
|
+
for (const file of files) {
|
|
37
|
+
foundFiles.add(file);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
// Handle specific module names or patterns like "Gtk*"
|
|
42
|
+
const filename = `${globPackageNames[i]}.gir`;
|
|
43
|
+
const pattern = this.girDirectories.map((girDirectory) => join(girDirectory, filename));
|
|
44
|
+
const ignoreGirs = ignore.map((girDirectory) => `${girDirectory}.gir`);
|
|
45
|
+
const files = await glob(pattern, { ignore: ignoreGirs });
|
|
33
46
|
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
for (const file of files) {
|
|
48
|
+
foundFiles.add(file);
|
|
49
|
+
}
|
|
36
50
|
}
|
|
37
51
|
}
|
|
38
52
|
|