@ts-for-gir/cli 4.0.0-beta.9 → 4.0.0-rc.10

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.
Files changed (86) hide show
  1. package/README.md +335 -86
  2. package/bin/ts-for-gir +28832 -0
  3. package/bin/ts-for-gir-dev +43 -0
  4. package/bin/ts-for-gir-gjs +348955 -0
  5. package/dist-templates/types-locally/.ts-for-girrc.js +6 -0
  6. package/dist-templates/types-locally/README.md +15 -0
  7. package/dist-templates/types-locally/esbuild.ts +10 -0
  8. package/dist-templates/types-locally/main.ts +21 -0
  9. package/dist-templates/types-locally/package.json +18 -0
  10. package/dist-templates/types-locally/tsconfig.json +17 -0
  11. package/dist-templates/types-npm/README.md +14 -0
  12. package/dist-templates/types-npm/esbuild.ts +10 -0
  13. package/dist-templates/types-npm/main.ts +19 -0
  14. package/dist-templates/types-npm/package.json +23 -0
  15. package/dist-templates/types-npm/tsconfig.json +15 -0
  16. package/dist-templates/types-workspace/.ts-for-girrc.js +12 -0
  17. package/dist-templates/types-workspace/README.md +26 -0
  18. package/dist-templates/types-workspace/package.json +22 -0
  19. package/dist-templates/types-workspace/packages/app/esbuild.ts +10 -0
  20. package/dist-templates/types-workspace/packages/app/main.ts +19 -0
  21. package/dist-templates/types-workspace/packages/app/package.json +23 -0
  22. package/dist-templates/types-workspace/packages/app/tsconfig.json +15 -0
  23. package/dist-templates/types-workspace/tsconfig.json +11 -0
  24. package/package.json +60 -37
  25. package/src/commands/analyze.ts +344 -0
  26. package/src/commands/command-builder.ts +30 -0
  27. package/src/commands/copy.ts +71 -76
  28. package/src/commands/create.ts +223 -0
  29. package/src/commands/doc.ts +44 -47
  30. package/src/commands/generate.ts +35 -79
  31. package/src/commands/index.ts +8 -4
  32. package/src/commands/json.ts +43 -0
  33. package/src/commands/list.ts +71 -90
  34. package/src/commands/run-generation-command.ts +75 -0
  35. package/src/commands/self-update.ts +142 -0
  36. package/src/config/config-loader.ts +238 -0
  37. package/src/config/config-writer.ts +52 -0
  38. package/src/config/defaults.ts +68 -0
  39. package/src/config/index.ts +16 -0
  40. package/src/config/options.ts +365 -0
  41. package/src/config.ts +3 -456
  42. package/src/formatters/typescript-formatter.ts +17 -0
  43. package/src/generation-handler.ts +122 -67
  44. package/src/index.ts +4 -4
  45. package/src/module-loader/dependency-resolver.ts +100 -0
  46. package/src/module-loader/file-finder.ts +65 -0
  47. package/src/module-loader/index.ts +8 -0
  48. package/src/module-loader/module-grouper.ts +77 -0
  49. package/src/module-loader/prompt-handler.ts +111 -0
  50. package/src/module-loader.ts +321 -578
  51. package/src/start.ts +36 -15
  52. package/src/types/command-args.ts +154 -0
  53. package/src/types/command-definition.ts +17 -0
  54. package/src/types/commands.ts +30 -0
  55. package/src/types/index.ts +15 -0
  56. package/src/types/report-types.ts +34 -0
  57. package/lib/commands/copy.d.ts +0 -12
  58. package/lib/commands/copy.js +0 -80
  59. package/lib/commands/copy.js.map +0 -1
  60. package/lib/commands/doc.d.ts +0 -12
  61. package/lib/commands/doc.js +0 -40
  62. package/lib/commands/doc.js.map +0 -1
  63. package/lib/commands/generate.d.ts +0 -12
  64. package/lib/commands/generate.js +0 -71
  65. package/lib/commands/generate.js.map +0 -1
  66. package/lib/commands/index.d.ts +0 -4
  67. package/lib/commands/index.js +0 -5
  68. package/lib/commands/index.js.map +0 -1
  69. package/lib/commands/list.d.ts +0 -12
  70. package/lib/commands/list.js +0 -81
  71. package/lib/commands/list.js.map +0 -1
  72. package/lib/config.d.ts +0 -108
  73. package/lib/config.js +0 -410
  74. package/lib/config.js.map +0 -1
  75. package/lib/generation-handler.d.ts +0 -10
  76. package/lib/generation-handler.js +0 -48
  77. package/lib/generation-handler.js.map +0 -1
  78. package/lib/index.d.ts +0 -4
  79. package/lib/index.js +0 -5
  80. package/lib/index.js.map +0 -1
  81. package/lib/module-loader.d.ts +0 -148
  82. package/lib/module-loader.js +0 -468
  83. package/lib/module-loader.js.map +0 -1
  84. package/lib/start.d.ts +0 -2
  85. package/lib/start.js +0 -16
  86. package/lib/start.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ export default {
2
+ modules: ["Adw-1", "Gtk-4.0"],
3
+ outdir: "./@types",
4
+ package: false,
5
+ ignoreVersionConflicts: true,
6
+ };
@@ -0,0 +1,15 @@
1
+ # __PROJECT_NAME__
2
+
3
+ GJS + TypeScript starter that generates GObject Introspection types **locally** into `./@types/`, without using the `@girs/*` NPM packages.
4
+
5
+ ## Setup
6
+
7
+ ```sh
8
+ npm install
9
+ npm run generate # writes types into ./@types/
10
+ npm run check:types # tsc --noEmit
11
+ npm run build # bundles main.ts to dist/ via esbuild
12
+ npm start # runs dist/main.js with gjs
13
+ ```
14
+
15
+ `@types/index.d.ts` is regenerated each time you run `npm run generate`. Add or remove modules in `.ts-for-girrc.js`.
@@ -0,0 +1,10 @@
1
+ import { build } from "esbuild";
2
+
3
+ await build({
4
+ entryPoints: ["main.ts"],
5
+ outdir: "dist",
6
+ bundle: true,
7
+ target: "firefox128",
8
+ format: "esm",
9
+ external: ["gi://*", "resource://*", "gettext", "system", "cairo"],
10
+ });
@@ -0,0 +1,21 @@
1
+ /// <reference path="./@types/index.d.ts" />
2
+
3
+ import Adw from "gi://Adw?version=1";
4
+ import Gio from "gi://Gio?version=2.0";
5
+ import Gtk from "gi://Gtk?version=4.0";
6
+
7
+ const app = new Adw.Application({
8
+ applicationId: "com.example.__PROJECT_NAME__",
9
+ flags: Gio.ApplicationFlags.FLAGS_NONE,
10
+ });
11
+
12
+ app.connect("activate", (app: Adw.Application) => {
13
+ const label = new Gtk.Label({ label: "Hello from __PROJECT_NAME__" });
14
+ const window = new Gtk.ApplicationWindow({ application: app });
15
+ window.set_title("__PROJECT_NAME__");
16
+ window.set_default_size(320, 120);
17
+ window.set_child(label);
18
+ window.present();
19
+ });
20
+
21
+ app.run([imports.system.programInvocationName].concat(ARGV));
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "scripts": {
7
+ "generate": "ts-for-gir generate",
8
+ "check:types": "tsc --noEmit",
9
+ "build": "node --experimental-strip-types --experimental-transform-types --no-warnings esbuild.ts",
10
+ "start": "gjs -m dist/main.js",
11
+ "clear": "rm -rf dist @types"
12
+ },
13
+ "devDependencies": {
14
+ "@ts-for-gir/cli": "^4.0.0-rc.10",
15
+ "esbuild": "^0.28.0",
16
+ "typescript": "^6.0.2"
17
+ }
18
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "lib": ["ESNext"],
6
+ "moduleResolution": "bundler",
7
+ "skipLibCheck": false,
8
+ "types": [],
9
+ "strict": true,
10
+ "noImplicitAny": true,
11
+ "strictNullChecks": true,
12
+ "noImplicitThis": true,
13
+ "alwaysStrict": true
14
+ },
15
+ "include": ["main.ts", "@types/index.d.ts"],
16
+ "exclude": []
17
+ }
@@ -0,0 +1,14 @@
1
+ # __PROJECT_NAME__
2
+
3
+ GJS + TypeScript starter that consumes pre-generated GObject Introspection types from the [`@girs/*`](https://www.npmjs.com/org/girs) NPM packages.
4
+
5
+ ## Setup
6
+
7
+ ```sh
8
+ npm install
9
+ npm run check # tsc --noEmit
10
+ npm run build # bundles main.ts to dist/ via esbuild
11
+ npm start # runs dist/main.js with gjs
12
+ ```
13
+
14
+ To add another GIR module, install the matching `@girs/<name>-<version>` package and add it to `tsconfig.json`'s `types` array.
@@ -0,0 +1,10 @@
1
+ import { build } from "esbuild";
2
+
3
+ await build({
4
+ entryPoints: ["main.ts"],
5
+ outdir: "dist",
6
+ bundle: true,
7
+ target: "firefox128",
8
+ format: "esm",
9
+ external: ["gi://*", "resource://*", "gettext", "system", "cairo"],
10
+ });
@@ -0,0 +1,19 @@
1
+ import Adw from "gi://Adw?version=1";
2
+ import Gio from "gi://Gio?version=2.0";
3
+ import Gtk from "gi://Gtk?version=4.0";
4
+
5
+ const app = new Adw.Application({
6
+ applicationId: "com.example.__PROJECT_NAME__",
7
+ flags: Gio.ApplicationFlags.FLAGS_NONE,
8
+ });
9
+
10
+ app.connect("activate", (app: Adw.Application) => {
11
+ const label = new Gtk.Label({ label: "Hello from __PROJECT_NAME__" });
12
+ const window = new Gtk.ApplicationWindow({ application: app });
13
+ window.set_title("__PROJECT_NAME__");
14
+ window.set_default_size(320, 120);
15
+ window.set_child(label);
16
+ window.present();
17
+ });
18
+
19
+ app.run([imports.system.programInvocationName].concat(ARGV));
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "scripts": {
7
+ "check": "tsc --noEmit",
8
+ "build": "node --experimental-strip-types --experimental-transform-types --no-warnings esbuild.ts",
9
+ "start": "gjs -m dist/main.js",
10
+ "clear": "rm -rf dist"
11
+ },
12
+ "devDependencies": {
13
+ "esbuild": "^0.28.0",
14
+ "typescript": "^6.0.2"
15
+ },
16
+ "dependencies": {
17
+ "@girs/adw-1": "^1.10.0-4.0.0-rc.9",
18
+ "@girs/gio-2.0": "^2.88.0-4.0.0-rc.9",
19
+ "@girs/gjs": "^4.0.0-rc.9",
20
+ "@girs/glib-2.0": "^2.88.0-4.0.0-rc.9",
21
+ "@girs/gtk-4.0": "^4.23.0-4.0.0-rc.9"
22
+ }
23
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ESNext"],
4
+ "types": ["@girs/gjs", "@girs/adw-1"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleResolution": "bundler",
8
+ "strict": true,
9
+ "noImplicitAny": true,
10
+ "strictNullChecks": true,
11
+ "noImplicitThis": true,
12
+ "alwaysStrict": true
13
+ },
14
+ "files": ["main.ts"]
15
+ }
@@ -0,0 +1,12 @@
1
+ export default {
2
+ modules: ["Adw-1", "Gtk-4.0"],
3
+ outdir: "./@girs",
4
+ package: true,
5
+ // npm does not support the workspace: protocol. `caret` emits ^<version>
6
+ // which npm, yarn and pnpm all resolve to the local workspace when the ref
7
+ // matches, falling back to the registry otherwise — the most portable
8
+ // default for a generated monorepo. Falls back to "exact" on CLI versions
9
+ // that predate this option, which is also npm-compatible.
10
+ depVersionFormat: "caret",
11
+ ignoreVersionConflicts: true,
12
+ };
@@ -0,0 +1,26 @@
1
+ # __PROJECT_NAME__
2
+
3
+ GJS + TypeScript starter that uses an **npm workspace** with the `@girs/*` types generated locally as workspace packages. Useful when you want pinned, hermetic types under version control without depending on the published `@girs/*` packages on NPM.
4
+
5
+ ## Setup
6
+
7
+ ```sh
8
+ npm install
9
+ npm run build:types # generates @girs/* packages into ./@girs/
10
+ npm install # picks up the freshly generated @girs/* workspace packages
11
+ npm run build:app
12
+ npm start
13
+ ```
14
+
15
+ Or shorthand: `npm run build` runs all three steps in order.
16
+
17
+ The application lives in [`packages/app/`](./packages/app/). Its dependencies on `@girs/*` are written as `"*"` which works across all three package managers — npm, yarn, pnpm all resolve to the locally generated workspace packages in `./@girs/`.
18
+
19
+ ### About the dependency version format
20
+
21
+ Two deliberate choices keep the template portable:
22
+
23
+ 1. **Generated `@girs/*` packages** reference each other via `^<version>` (not `workspace:^`). Controlled by `depVersionFormat: "caret"` in [`.ts-for-girrc.js`](./.ts-for-girrc.js). npm and yarn/pnpm all prefer the local workspace match; the registry serves as fallback for transitive GIR packages outside your `modules` set.
24
+ 2. **Sub-package deps** (`packages/app/package.json`) use `"*"`. Same reasoning — all managers resolve to the local workspace.
25
+
26
+ If you run yarn or pnpm exclusively and want strict workspace-only resolution, switch both: add `workspace: true` and `depVersionFormat: "workspace"` in `.ts-for-girrc.js`, plus `"workspace:^"` specs in `packages/app/package.json`. npm does **not** support the `workspace:` protocol.
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "workspaces": [
7
+ "packages/*",
8
+ "@girs/*"
9
+ ],
10
+ "scripts": {
11
+ "build:types": "ts-for-gir generate --package --outdir=./@girs",
12
+ "build:app": "npm run --workspace=@__PROJECT_NAME__/app build",
13
+ "build": "npm run build:types && npm install && npm run build:app",
14
+ "check": "npm run --workspaces --if-present check",
15
+ "start": "npm run --workspace=@__PROJECT_NAME__/app start",
16
+ "clear": "rm -rf @girs packages/*/dist"
17
+ },
18
+ "devDependencies": {
19
+ "@ts-for-gir/cli": "^4.0.0-rc.10",
20
+ "typescript": "^6.0.2"
21
+ }
22
+ }
@@ -0,0 +1,10 @@
1
+ import { build } from "esbuild";
2
+
3
+ await build({
4
+ entryPoints: ["main.ts"],
5
+ outdir: "dist",
6
+ bundle: true,
7
+ target: "firefox128",
8
+ format: "esm",
9
+ external: ["gi://*", "resource://*", "gettext", "system", "cairo"],
10
+ });
@@ -0,0 +1,19 @@
1
+ import Adw from "gi://Adw?version=1";
2
+ import Gio from "gi://Gio?version=2.0";
3
+ import Gtk from "gi://Gtk?version=4.0";
4
+
5
+ const app = new Adw.Application({
6
+ applicationId: "com.example.__PROJECT_NAME__",
7
+ flags: Gio.ApplicationFlags.FLAGS_NONE,
8
+ });
9
+
10
+ app.connect("activate", (app: Adw.Application) => {
11
+ const label = new Gtk.Label({ label: "Hello from __PROJECT_NAME__" });
12
+ const window = new Gtk.ApplicationWindow({ application: app });
13
+ window.set_title("__PROJECT_NAME__");
14
+ window.set_default_size(320, 120);
15
+ window.set_child(label);
16
+ window.present();
17
+ });
18
+
19
+ app.run([imports.system.programInvocationName].concat(ARGV));
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@__PROJECT_NAME__/app",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "scripts": {
7
+ "check": "tsc --noEmit",
8
+ "build": "node --experimental-strip-types --experimental-transform-types --no-warnings esbuild.ts",
9
+ "start": "gjs -m dist/main.js",
10
+ "clear": "rm -rf dist"
11
+ },
12
+ "devDependencies": {
13
+ "esbuild": "^0.28.0",
14
+ "typescript": "^6.0.2"
15
+ },
16
+ "dependencies": {
17
+ "@girs/adw-1": "*",
18
+ "@girs/gio-2.0": "*",
19
+ "@girs/gjs": "*",
20
+ "@girs/glib-2.0": "*",
21
+ "@girs/gtk-4.0": "*"
22
+ }
23
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ESNext"],
4
+ "types": ["@girs/gjs", "@girs/adw-1"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleResolution": "bundler",
8
+ "strict": true,
9
+ "noImplicitAny": true,
10
+ "strictNullChecks": true,
11
+ "noImplicitThis": true,
12
+ "alwaysStrict": true
13
+ },
14
+ "files": ["main.ts"]
15
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ESNext"],
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "strict": true,
8
+ "noEmit": true
9
+ },
10
+ "references": [{ "path": "./packages/app" }]
11
+ }
package/package.json CHANGED
@@ -1,37 +1,55 @@
1
1
  {
2
2
  "name": "@ts-for-gir/cli",
3
- "version": "4.0.0-beta.9",
3
+ "version": "4.0.0-rc.10",
4
4
  "description": "TypeScript type definition generator for GObject introspection GIR files",
5
- "module": "lib/index.js",
6
- "main": "lib/index.js",
5
+ "main": "src/index.ts",
6
+ "module": "src/index.ts",
7
7
  "type": "module",
8
8
  "bin": {
9
- "ts-for-gir": "./lib/start.js"
9
+ "cli": "bin/ts-for-gir",
10
+ "ts-for-gir": "bin/ts-for-gir",
11
+ "ts-for-gir-dev": "bin/ts-for-gir-dev",
12
+ "ts-for-gir-gjs": "bin/ts-for-gir-gjs"
13
+ },
14
+ "gjsify": {
15
+ "bin": {
16
+ "ts-for-gir": "bin/ts-for-gir-gjs"
17
+ },
18
+ "shebang": true,
19
+ "esbuild": {
20
+ "outfile": "bin/ts-for-gir-gjs"
21
+ },
22
+ "excludeGlobals": [
23
+ "fetch",
24
+ "Headers",
25
+ "Request",
26
+ "Response",
27
+ "XMLHttpRequest",
28
+ "XMLHttpRequestUpload"
29
+ ]
10
30
  },
11
31
  "engines": {
12
32
  "node": ">=18"
13
33
  },
14
34
  "scripts": {
15
- "start": "yarn node --max_old_space_size=9216 lib/start.js",
16
- "start:dev": "yarn node --max_old_space_size=9216 --loader ts-node/esm src/start.ts",
17
- "build": "yarn lint && yarn build:ts && yarn chmod",
18
- "chmod": "chmod +x ./lib/start.js",
19
- "build:ts": "tsc",
20
- "clear": "yarn clear:build",
21
- "clear:build": "rimraf ./lib",
22
- "watch": "yarn build:ts --watch",
23
- "lint": "eslint . --ext .ts,.tsx --fix"
35
+ "start": "node bin/ts-for-gir-dev",
36
+ "start:prod": "node bin/ts-for-gir",
37
+ "build": "node --experimental-specifier-resolution=node --experimental-strip-types --experimental-transform-types --no-warnings esbuild.ts && chmod +x bin/ts-for-gir-dev && chmod +x bin/ts-for-gir",
38
+ "build:gjs": "node scripts/build-gjs.mjs",
39
+ "build:templates": "node scripts/process-templates.mjs",
40
+ "prepack": "node scripts/process-templates.mjs",
41
+ "check:types": "tsc --noEmit",
42
+ "check": "yarn check:types"
24
43
  },
25
44
  "repository": {
26
45
  "type": "git",
27
46
  "url": "git+https://github.com/gjsify/ts-for-gir.git"
28
47
  },
29
- "author": "Pascal Garber <pascal@artandcode.studio>",
48
+ "author": "Pascal Garber <pascal@mailfreun.de>",
30
49
  "files": [
31
50
  "src",
32
51
  "bin",
33
- "lib",
34
- "templates"
52
+ "dist-templates"
35
53
  ],
36
54
  "license": "Apache-2.0",
37
55
  "bugs": {
@@ -52,30 +70,35 @@
52
70
  "type definitions",
53
71
  "cli"
54
72
  ],
73
+ "exports": {
74
+ ".": "./src/index.ts"
75
+ },
55
76
  "devDependencies": {
56
- "@types/inquirer": "^9.0.7",
57
- "@types/node": "^20.14.11",
58
- "@types/yargs": "^17.0.32",
59
- "@typescript-eslint/eslint-plugin": "^7.16.1",
60
- "@typescript-eslint/parser": "^7.16.1",
61
- "eslint": "^8.57.0",
62
- "eslint-config-prettier": "^9.1.0",
63
- "eslint-plugin-prettier": "^5.2.1",
64
- "rimraf": "^6.0.1",
65
- "ts-node": "^10.9.2",
66
- "typescript": "^5.5.3"
77
+ "@gi.ts/parser": "^4.0.0-rc.10",
78
+ "@gjsify/cli": "^0.3.13",
79
+ "@ts-for-gir/generator-base": "^4.0.0-rc.10",
80
+ "@ts-for-gir/generator-html-doc": "^4.0.0-rc.10",
81
+ "@ts-for-gir/generator-json": "^4.0.0-rc.10",
82
+ "@ts-for-gir/generator-typescript": "^4.0.0-rc.10",
83
+ "@ts-for-gir/lib": "^4.0.0-rc.10",
84
+ "@ts-for-gir/reporter": "^4.0.0-rc.10",
85
+ "@ts-for-gir/tsconfig": "^4.0.0-rc.10",
86
+ "@types/ejs": "^3.1.5",
87
+ "@types/inquirer": "^9.0.9",
88
+ "@types/node": "^25.6.0",
89
+ "@types/yargs": "^17.0.35",
90
+ "esbuild": "^0.28.0",
91
+ "typescript": "^6.0.3"
67
92
  },
68
93
  "dependencies": {
69
- "@gi.ts/parser": "^2.0.0",
70
- "@ts-for-gir/generator-base": "^4.0.0-beta.9",
71
- "@ts-for-gir/generator-html-doc": "^4.0.0-beta.9",
72
- "@ts-for-gir/generator-typescript": "^4.0.0-beta.9",
73
- "@ts-for-gir/lib": "^4.0.0-beta.9",
94
+ "@inquirer/prompts": "^8.4.2",
95
+ "@ts-for-gir/templates": "^4.0.0-rc.10",
74
96
  "colorette": "^2.0.20",
75
- "cosmiconfig": "^9.0.0",
76
- "glob": "^11.0.0",
77
- "inquirer": "^9.3.5",
78
- "prettier": "^3.3.3",
79
- "yargs": "^17.7.2"
97
+ "cosmiconfig": "^9.0.1",
98
+ "ejs": "^5.0.2",
99
+ "glob": "^13.0.6",
100
+ "inquirer": "^13.4.2",
101
+ "typedoc": "^0.28.19",
102
+ "yargs": "^18.0.0"
80
103
  }
81
104
  }