@ts-for-gir/cli 4.0.0 → 4.0.1

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 (27) hide show
  1. package/bin/ts-for-gir +3 -3
  2. package/bin/ts-for-gir-gjs +3 -3
  3. package/dist-templates/types-gjsify/README.md +32 -0
  4. package/dist-templates/types-gjsify/biome.json +38 -0
  5. package/dist-templates/types-gjsify/main.ts +19 -0
  6. package/dist-templates/types-gjsify/package.json +26 -0
  7. package/dist-templates/types-gjsify/tsconfig.json +15 -0
  8. package/dist-templates/types-locally/.ts-for-girrc.js +6 -0
  9. package/dist-templates/types-locally/README.md +15 -0
  10. package/dist-templates/types-locally/esbuild.ts +10 -0
  11. package/dist-templates/types-locally/main.ts +21 -0
  12. package/dist-templates/types-locally/package.json +18 -0
  13. package/dist-templates/types-locally/tsconfig.json +17 -0
  14. package/dist-templates/types-npm/README.md +14 -0
  15. package/dist-templates/types-npm/esbuild.ts +10 -0
  16. package/dist-templates/types-npm/main.ts +19 -0
  17. package/dist-templates/types-npm/package.json +23 -0
  18. package/dist-templates/types-npm/tsconfig.json +15 -0
  19. package/dist-templates/types-workspace/.ts-for-girrc.js +12 -0
  20. package/dist-templates/types-workspace/README.md +26 -0
  21. package/dist-templates/types-workspace/package.json +22 -0
  22. package/dist-templates/types-workspace/packages/app/esbuild.ts +10 -0
  23. package/dist-templates/types-workspace/packages/app/main.ts +19 -0
  24. package/dist-templates/types-workspace/packages/app/package.json +23 -0
  25. package/dist-templates/types-workspace/packages/app/tsconfig.json +15 -0
  26. package/dist-templates/types-workspace/tsconfig.json +11 -0
  27. package/package.json +11 -11
@@ -0,0 +1,32 @@
1
+ # __PROJECT_NAME__
2
+
3
+ GJS + TypeScript starter, fully Node-free at runtime. Uses pre-generated [`@girs/*`](https://www.npmjs.com/org/girs) types and the [`gjsify` CLI](https://gjsify.github.io/gjsify/) for install, build, run, format and lint — no `npm`, no `node`, no `esbuild` ceremony.
4
+
5
+ ## Setup
6
+
7
+ ```sh
8
+ gjsify install
9
+ gjsify run build && gjsify run start
10
+ ```
11
+
12
+ That's it. `gjsify build` produces a single GJS bundle with the right `firefox*` target + `gi://*` externals; `gjsify run` launches it with `LD_LIBRARY_PATH` / `GI_TYPELIB_PATH` pre-wired for any native typelib deps.
13
+
14
+ ## Scripts
15
+
16
+ | Script | What it does |
17
+ |---|---|
18
+ | `gjsify install` | Install deps (Node-free; reads `gjsify-lock.json`) |
19
+ | `gjsify run check` | TypeScript `tsc --noEmit` |
20
+ | `gjsify run build` | Bundle `main.ts` → `dist/main.js` |
21
+ | `gjsify run start` | Launch the bundle under `gjs -m` |
22
+ | `gjsify run format` | Format via Biome |
23
+ | `gjsify run fix` | Format + safe-fix lint + organize imports |
24
+ | `gjsify run clear` | Remove `dist/` |
25
+
26
+ ## Adding GIR modules
27
+
28
+ Install the matching `@girs/<name>-<version>` package and add it to `tsconfig.json`'s `types` array. Example for GStreamer:
29
+
30
+ ```sh
31
+ gjsify install @girs/gst-1.0
32
+ ```
@@ -0,0 +1,38 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
3
+ "formatter": {
4
+ "enabled": true,
5
+ "indentStyle": "tab",
6
+ "lineWidth": 120,
7
+ "lineEnding": "lf"
8
+ },
9
+ "linter": {
10
+ "enabled": true,
11
+ "rules": {
12
+ "recommended": true,
13
+ "style": {
14
+ "useImportType": "warn",
15
+ "useNodejsImportProtocol": "error",
16
+ "noNonNullAssertion": "off"
17
+ },
18
+ "suspicious": {
19
+ "noExplicitAny": "warn",
20
+ "noConsole": "off"
21
+ },
22
+ "correctness": {
23
+ "noUnusedImports": "warn"
24
+ }
25
+ }
26
+ },
27
+ "javascript": {
28
+ "formatter": {
29
+ "quoteStyle": "double",
30
+ "semicolons": "always",
31
+ "trailingCommas": "all",
32
+ "arrowParentheses": "always"
33
+ }
34
+ },
35
+ "files": {
36
+ "includes": ["**", "!**/node_modules", "!**/dist", "!**/.cache"]
37
+ }
38
+ }
@@ -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,26 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "scripts": {
7
+ "check": "tsc --noEmit",
8
+ "build": "gjsify build main.ts --app gjs --outfile dist/main.js",
9
+ "start": "gjsify run dist/main.js",
10
+ "format": "gjsify format",
11
+ "fix": "gjsify fix",
12
+ "clear": "rm -rf dist"
13
+ },
14
+ "devDependencies": {
15
+ "@biomejs/biome": "^2.4.13",
16
+ "@gjsify/cli": "^0.4.14",
17
+ "typescript": "^6.0.2"
18
+ },
19
+ "dependencies": {
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",
24
+ "@girs/gtk-4.0": "^4.23.0-4.0.0-rc.17"
25
+ }
26
+ }
@@ -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,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.1",
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.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",
21
+ "@girs/gtk-4.0": "^4.23.0-4.0.0-rc.17"
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.1",
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-for-gir/cli",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "TypeScript type definition generator for GObject introspection GIR files",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -124,7 +124,7 @@
124
124
  "scripts": {
125
125
  "start": "node bin/ts-for-gir-dev",
126
126
  "start:prod": "node bin/ts-for-gir",
127
- "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",
127
+ "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 && node scripts/process-templates.mjs",
128
128
  "build:gjs": "gjsify build",
129
129
  "build:templates": "node scripts/process-templates.mjs",
130
130
  "prepack": "node scripts/process-templates.mjs",
@@ -164,15 +164,15 @@
164
164
  ".": "./src/index.ts"
165
165
  },
166
166
  "devDependencies": {
167
- "@gi.ts/parser": "^4.0.0",
167
+ "@gi.ts/parser": "^4.0.1",
168
168
  "@gjsify/cli": "^0.4.19",
169
- "@ts-for-gir/generator-base": "^4.0.0",
170
- "@ts-for-gir/generator-html-doc": "^4.0.0",
171
- "@ts-for-gir/generator-json": "^4.0.0",
172
- "@ts-for-gir/generator-typescript": "^4.0.0",
173
- "@ts-for-gir/lib": "^4.0.0",
174
- "@ts-for-gir/reporter": "^4.0.0",
175
- "@ts-for-gir/tsconfig": "^4.0.0",
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",
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.0",
186
+ "@ts-for-gir/templates": "^4.0.1",
187
187
  "colorette": "^2.0.20",
188
188
  "cosmiconfig": "^9.0.1",
189
189
  "ejs": "^5.0.2",