@ts-for-gir/lib 4.0.0-rc.3 → 4.0.0-rc.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-for-gir/lib",
3
- "version": "4.0.0-rc.3",
3
+ "version": "4.0.0-rc.4",
4
4
  "description": "Typescript .d.ts generator from GIR for gjs",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -41,7 +41,7 @@
41
41
  "type definitions"
42
42
  ],
43
43
  "devDependencies": {
44
- "@ts-for-gir/tsconfig": "^4.0.0-rc.3",
44
+ "@ts-for-gir/tsconfig": "^4.0.0-rc.4",
45
45
  "@types/ejs": "^3.1.5",
46
46
  "@types/lodash": "^4.17.24",
47
47
  "@types/node": "^24.12.2",
@@ -49,9 +49,9 @@
49
49
  "typescript": "^6.0.2"
50
50
  },
51
51
  "dependencies": {
52
- "@gi.ts/parser": "^4.0.0-rc.3",
53
- "@ts-for-gir/reporter": "^4.0.0-rc.3",
54
- "@ts-for-gir/templates": "^4.0.0-rc.3",
52
+ "@gi.ts/parser": "^4.0.0-rc.4",
53
+ "@ts-for-gir/reporter": "^4.0.0-rc.4",
54
+ "@ts-for-gir/templates": "^4.0.0-rc.4",
55
55
  "colorette": "^2.0.20",
56
56
  "ejs": "^5.0.1",
57
57
  "glob": "^13.0.6",
@@ -147,13 +147,22 @@ export class DependencyManager {
147
147
  }
148
148
 
149
149
  createPackageJsonImport(importPath: string, libraryVersion?: LibraryVersion): string {
150
+ const pinnedVersion = libraryVersion ? `${libraryVersion.toString()}-${APP_VERSION}` : APP_VERSION;
151
+ const format = this.config.depVersionFormat ?? (this.config.workspace ? "workspace" : "exact");
150
152
  let depVersion: string;
151
- if (this.config.workspace) {
152
- depVersion = "workspace:^";
153
- } else if (libraryVersion) {
154
- depVersion = `${libraryVersion.toString()}-${APP_VERSION}`;
155
- } else {
156
- depVersion = APP_VERSION;
153
+ switch (format) {
154
+ case "workspace":
155
+ depVersion = "workspace:^";
156
+ break;
157
+ case "caret":
158
+ depVersion = `^${pinnedVersion}`;
159
+ break;
160
+ case "any":
161
+ depVersion = "*";
162
+ break;
163
+ default:
164
+ depVersion = pinnedVersion;
165
+ break;
157
166
  }
158
167
  return `"${importPath}": "${depVersion}"`;
159
168
  }
@@ -23,6 +23,8 @@ export interface OptionsGeneration extends OptionsBase {
23
23
  npmScope: string;
24
24
  /** Uses the workspace protocol for the generated packages which can be used with package managers like Yarn and PNPM */
25
25
  workspace: boolean;
26
+ /** Format used for dependency version specifiers in generated package.json files */
27
+ depVersionFormat?: "workspace" | "caret" | "any" | "exact";
26
28
  /** Disable GLib.Variant class with string parsing */
27
29
  noAdvancedVariants: boolean;
28
30
  /**
@@ -28,6 +28,16 @@ export interface UserConfig {
28
28
  npmScope: string;
29
29
  /** Uses the workspace protocol for the generated packages which can be used with package managers like Yarn and PNPM */
30
30
  workspace: boolean;
31
+ /**
32
+ * Format used for dependency version specifiers in generated package.json files.
33
+ * - `workspace`: emit `workspace:^` (yarn/pnpm; npm only when the ref matches a registered workspace)
34
+ * - `caret`: emit `^<version>` (all managers, falls back to registry for dangling refs)
35
+ * - `any`: emit `*` (all managers, most permissive)
36
+ * - `exact`: emit `<version>` (all managers, no range)
37
+ *
38
+ * If unset, defaults to `workspace` when `workspace: true`, else `caret`.
39
+ */
40
+ depVersionFormat?: "workspace" | "caret" | "any" | "exact";
31
41
  /**
32
42
  * Only use the version prefix for the ambient module exports.
33
43
  * This is useful if, for whatever reason, you want to use different library versions of the same library in your project.