@ts-for-gir/reporter 4.0.0-beta.41 → 4.0.0-beta.43
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/package.json +3 -3
- package/src/constants.ts +12 -47
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-for-gir/reporter",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.43",
|
|
4
4
|
"description": "Problem reporting and comprehensive generation analysis for ts-for-gir",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"analysis"
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@ts-for-gir/tsconfig": "^4.0.0-beta.
|
|
40
|
+
"@ts-for-gir/tsconfig": "^4.0.0-beta.43",
|
|
41
41
|
"@types/node": "^24.12.0",
|
|
42
|
-
"typescript": "^
|
|
42
|
+
"typescript": "^6.0.2"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"colorette": "^2.0.20"
|
package/src/constants.ts
CHANGED
|
@@ -2,56 +2,21 @@ import { readFileSync } from "node:fs";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* Package information interface for package.json
|
|
7
|
-
* Each package has its own version and metadata
|
|
8
|
-
*/
|
|
9
|
-
interface Package {
|
|
10
|
-
version: string;
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
}
|
|
5
|
+
declare const __TS_FOR_GIR_VERSION__: string;
|
|
14
6
|
|
|
15
7
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* Works both in workspace and after publishing
|
|
8
|
+
* Reads the package version, using the build-time injected value when bundled
|
|
9
|
+
* or falling back to reading package.json in development mode.
|
|
19
10
|
*/
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const currentModulePath = fileURLToPath(import.meta.url);
|
|
24
|
-
const currentDir = dirname(currentModulePath);
|
|
25
|
-
|
|
26
|
-
// Go up to the package root (src/ -> package root)
|
|
27
|
-
const packageRoot = join(currentDir, "..");
|
|
28
|
-
const packageJsonPath = join(packageRoot, "package.json");
|
|
29
|
-
|
|
30
|
-
return packageJsonPath;
|
|
31
|
-
} catch (error) {
|
|
32
|
-
throw new Error(`Unable to resolve package.json path: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
11
|
+
function getPackageVersion(): string {
|
|
12
|
+
if (typeof __TS_FOR_GIR_VERSION__ !== "undefined") {
|
|
13
|
+
return __TS_FOR_GIR_VERSION__;
|
|
33
14
|
}
|
|
15
|
+
const currentModulePath = fileURLToPath(import.meta.url);
|
|
16
|
+
const currentDir = dirname(currentModulePath);
|
|
17
|
+
const packageJsonPath = join(currentDir, "..", "package.json");
|
|
18
|
+
const content = readFileSync(packageJsonPath, "utf-8");
|
|
19
|
+
return (JSON.parse(content) as { version: string }).version;
|
|
34
20
|
}
|
|
35
21
|
|
|
36
|
-
|
|
37
|
-
* Reads and parses the current package's package.json file
|
|
38
|
-
* Contains version and metadata for this specific package
|
|
39
|
-
*/
|
|
40
|
-
function readPackage(): Package {
|
|
41
|
-
try {
|
|
42
|
-
const packagePath = resolvePackageJson();
|
|
43
|
-
const content = readFileSync(packagePath, "utf-8");
|
|
44
|
-
return JSON.parse(content) as Package;
|
|
45
|
-
} catch (error) {
|
|
46
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
47
|
-
throw new Error(`Failed to read package.json: ${message}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Read package information once at module load
|
|
52
|
-
export const PACKAGE = readPackage();
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The current version of the reporter package
|
|
56
|
-
*/
|
|
57
|
-
export const PACKAGE_VERSION = PACKAGE.version;
|
|
22
|
+
export const PACKAGE_VERSION = getPackageVersion();
|