@ts-for-gir/cli 4.0.1 → 4.0.3

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.
@@ -13,14 +13,14 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@biomejs/biome": "^2.4.13",
16
- "@gjsify/cli": "^0.4.14",
16
+ "@gjsify/cli": "^0.4.26",
17
17
  "typescript": "^6.0.2"
18
18
  },
19
19
  "dependencies": {
20
20
  "@girs/adw-1": "^1.10.0-4.0.0-rc.17",
21
- "@girs/gio-2.0": "^2.88.0-4.0.0-rc.17",
22
- "@girs/gjs": "^4.0.0-rc.17",
23
- "@girs/glib-2.0": "^2.88.0-4.0.0-rc.17",
21
+ "@girs/gio-2.0": "^2.88.0-4.0.1",
22
+ "@girs/gjs": "^4.0.1",
23
+ "@girs/glib-2.0": "^2.88.0-4.0.1",
24
24
  "@girs/gtk-4.0": "^4.23.0-4.0.0-rc.17"
25
25
  }
26
26
  }
@@ -11,7 +11,7 @@
11
11
  "clear": "rm -rf dist @types"
12
12
  },
13
13
  "devDependencies": {
14
- "@ts-for-gir/cli": "^4.0.1",
14
+ "@ts-for-gir/cli": "^4.0.3",
15
15
  "esbuild": "^0.28.0",
16
16
  "typescript": "^6.0.2"
17
17
  }
@@ -15,9 +15,9 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@girs/adw-1": "^1.10.0-4.0.0-rc.17",
18
- "@girs/gio-2.0": "^2.88.0-4.0.0-rc.17",
19
- "@girs/gjs": "^4.0.0-rc.17",
20
- "@girs/glib-2.0": "^2.88.0-4.0.0-rc.17",
18
+ "@girs/gio-2.0": "^2.88.0-4.0.1",
19
+ "@girs/gjs": "^4.0.1",
20
+ "@girs/glib-2.0": "^2.88.0-4.0.1",
21
21
  "@girs/gtk-4.0": "^4.23.0-4.0.0-rc.17"
22
22
  }
23
23
  }
@@ -16,7 +16,7 @@
16
16
  "clear": "rm -rf @girs packages/*/dist"
17
17
  },
18
18
  "devDependencies": {
19
- "@ts-for-gir/cli": "^4.0.1",
19
+ "@ts-for-gir/cli": "^4.0.3",
20
20
  "typescript": "^6.0.2"
21
21
  }
22
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-for-gir/cli",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "TypeScript type definition generator for GObject introspection GIR files",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -164,15 +164,15 @@
164
164
  ".": "./src/index.ts"
165
165
  },
166
166
  "devDependencies": {
167
- "@gi.ts/parser": "^4.0.1",
168
- "@gjsify/cli": "^0.4.19",
169
- "@ts-for-gir/generator-base": "^4.0.1",
170
- "@ts-for-gir/generator-html-doc": "^4.0.1",
171
- "@ts-for-gir/generator-json": "^4.0.1",
172
- "@ts-for-gir/generator-typescript": "^4.0.1",
173
- "@ts-for-gir/lib": "^4.0.1",
174
- "@ts-for-gir/reporter": "^4.0.1",
175
- "@ts-for-gir/tsconfig": "^4.0.1",
167
+ "@gi.ts/parser": "^4.0.3",
168
+ "@gjsify/cli": "^0.4.26",
169
+ "@ts-for-gir/generator-base": "^4.0.3",
170
+ "@ts-for-gir/generator-html-doc": "^4.0.3",
171
+ "@ts-for-gir/generator-json": "^4.0.3",
172
+ "@ts-for-gir/generator-typescript": "^4.0.3",
173
+ "@ts-for-gir/lib": "^4.0.3",
174
+ "@ts-for-gir/reporter": "^4.0.3",
175
+ "@ts-for-gir/tsconfig": "^4.0.3",
176
176
  "@types/ejs": "^3.1.5",
177
177
  "@types/inquirer": "^9.0.9",
178
178
  "@types/node": "^25.6.2",
@@ -183,7 +183,7 @@
183
183
  },
184
184
  "dependencies": {
185
185
  "@inquirer/prompts": "^8.4.2",
186
- "@ts-for-gir/templates": "^4.0.1",
186
+ "@ts-for-gir/templates": "^4.0.3",
187
187
  "colorette": "^2.0.20",
188
188
  "cosmiconfig": "^9.0.1",
189
189
  "ejs": "^5.0.2",
@@ -17,11 +17,37 @@ const GJS_ASSET_NAME = "ts-for-gir-gjs";
17
17
  function getCurrentBinaryPath(): string | null {
18
18
  const p = process.argv[1] ?? null;
19
19
  if (!p) return null;
20
- // Refuse to update in dev mode (source file or node_modules path)
21
- if (p.endsWith(".ts") || p.includes("node_modules")) return null;
20
+ // Refuse to update in dev mode — running from a source `.ts` file or
21
+ // from a project-local `node_modules/` (in which case the user should
22
+ // update via their package manager, not by replacing the binary in
23
+ // place).
24
+ if (p.endsWith(".ts")) return null;
25
+ if (p.includes("/node_modules/") && !isGjsifyGlobalLocation(p)) return null;
22
26
  return p;
23
27
  }
24
28
 
29
+ /**
30
+ * Recognise the gjsify-install global location (`~/.local/share/gjsify/global/
31
+ * node_modules/<pkg>/...`, set up by `gjsify install -g` and `install.js`).
32
+ *
33
+ * The previous broad `path.includes("node_modules")` check rejected this
34
+ * location alongside genuine project-local installs, even though the
35
+ * gjsify-global location IS the canonical install spot for `ts-for-gir
36
+ * self-update`. The fix: only refuse updates for paths that contain
37
+ * `node_modules` AND aren't under the gjsify-global root.
38
+ *
39
+ * Matches both XDG_DATA_HOME-rooted and the documented fallback
40
+ * (`$HOME/.local/share/gjsify/global/`).
41
+ */
42
+ function isGjsifyGlobalLocation(p: string): boolean {
43
+ const xdgData = process.env.XDG_DATA_HOME;
44
+ const home = process.env.HOME;
45
+ const candidates: string[] = [];
46
+ if (xdgData) candidates.push(`${xdgData}/gjsify/global/`);
47
+ if (home) candidates.push(`${home}/.local/share/gjsify/global/`);
48
+ return candidates.some((root) => p.startsWith(root));
49
+ }
50
+
25
51
  async function fetchJson(url: string): Promise<unknown> {
26
52
  const headers: Record<string, string> = {
27
53
  Accept: "application/vnd.github.v3+json",