@ts-for-gir/cli 4.0.0-rc.15 → 4.0.0-rc.17
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/bin/ts-for-gir +169 -74
- package/bin/ts-for-gir-gjs +556 -572
- package/package.json +113 -113
- package/src/commands/create.ts +29 -8
- package/src/config/options.ts +2 -2
- package/src/start.ts +11 -1
- package/src/types/command-args.ts +1 -1
- package/dist-templates/types-locally/.ts-for-girrc.js +0 -6
- package/dist-templates/types-locally/README.md +0 -15
- package/dist-templates/types-locally/esbuild.ts +0 -10
- package/dist-templates/types-locally/main.ts +0 -21
- package/dist-templates/types-locally/package.json +0 -18
- package/dist-templates/types-locally/tsconfig.json +0 -17
- package/dist-templates/types-npm/README.md +0 -14
- package/dist-templates/types-npm/esbuild.ts +0 -10
- package/dist-templates/types-npm/main.ts +0 -19
- package/dist-templates/types-npm/package.json +0 -23
- package/dist-templates/types-npm/tsconfig.json +0 -15
- package/dist-templates/types-workspace/.ts-for-girrc.js +0 -12
- package/dist-templates/types-workspace/README.md +0 -26
- package/dist-templates/types-workspace/package.json +0 -22
- package/dist-templates/types-workspace/packages/app/esbuild.ts +0 -10
- package/dist-templates/types-workspace/packages/app/main.ts +0 -19
- package/dist-templates/types-workspace/packages/app/package.json +0 -23
- package/dist-templates/types-workspace/packages/app/tsconfig.json +0 -15
- package/dist-templates/types-workspace/tsconfig.json +0 -11
package/package.json
CHANGED
|
@@ -1,114 +1,114 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
2
|
+
"name": "@ts-for-gir/cli",
|
|
3
|
+
"version": "4.0.0-rc.17",
|
|
4
|
+
"description": "TypeScript type definition generator for GObject introspection GIR files",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"module": "src/index.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
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
|
+
"bundler": {
|
|
20
|
+
"input": "src/start.ts",
|
|
21
|
+
"output": {
|
|
22
|
+
"file": "bin/ts-for-gir-gjs"
|
|
23
|
+
},
|
|
24
|
+
"transform": {
|
|
25
|
+
"define": {
|
|
26
|
+
"__GJS_BUNDLE__": "true"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"defineFromPackageJson": {
|
|
31
|
+
"__TS_FOR_GIR_VERSION__": {
|
|
32
|
+
"field": "version"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"excludeGlobals": [
|
|
36
|
+
"XMLHttpRequest",
|
|
37
|
+
"XMLHttpRequestUpload"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"start": "node bin/ts-for-gir-dev",
|
|
45
|
+
"start:prod": "node bin/ts-for-gir",
|
|
46
|
+
"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",
|
|
47
|
+
"build:gjs": "gjsify build",
|
|
48
|
+
"build:templates": "node scripts/process-templates.mjs",
|
|
49
|
+
"prepack": "node scripts/process-templates.mjs",
|
|
50
|
+
"check:types": "tsc --noEmit",
|
|
51
|
+
"check": "gjsify run check:types"
|
|
52
|
+
},
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/gjsify/ts-for-gir.git"
|
|
56
|
+
},
|
|
57
|
+
"author": "Pascal Garber <pascal@mailfreun.de>",
|
|
58
|
+
"files": [
|
|
59
|
+
"src",
|
|
60
|
+
"bin",
|
|
61
|
+
"dist-templates"
|
|
62
|
+
],
|
|
63
|
+
"license": "Apache-2.0",
|
|
64
|
+
"bugs": {
|
|
65
|
+
"url": "https://github.com/gjsify/ts-for-gir/issues"
|
|
66
|
+
},
|
|
67
|
+
"homepage": "https://github.com/gjsify/ts-for-gir#readme",
|
|
68
|
+
"keywords": [
|
|
69
|
+
"gjs",
|
|
70
|
+
"typescript",
|
|
71
|
+
"generate",
|
|
72
|
+
"gir",
|
|
73
|
+
"gobject-introspection",
|
|
74
|
+
"gnome",
|
|
75
|
+
"gtk",
|
|
76
|
+
"glib",
|
|
77
|
+
"gobject",
|
|
78
|
+
"dts",
|
|
79
|
+
"type definitions",
|
|
80
|
+
"cli"
|
|
81
|
+
],
|
|
82
|
+
"exports": {
|
|
83
|
+
".": "./src/index.ts"
|
|
84
|
+
},
|
|
85
|
+
"devDependencies": {
|
|
86
|
+
"@gi.ts/parser": "^4.0.0-rc.17",
|
|
87
|
+
"@gjsify/cli": "^0.4.18",
|
|
88
|
+
"@ts-for-gir/generator-base": "^4.0.0-rc.17",
|
|
89
|
+
"@ts-for-gir/generator-html-doc": "^4.0.0-rc.17",
|
|
90
|
+
"@ts-for-gir/generator-json": "^4.0.0-rc.17",
|
|
91
|
+
"@ts-for-gir/generator-typescript": "^4.0.0-rc.17",
|
|
92
|
+
"@ts-for-gir/lib": "^4.0.0-rc.17",
|
|
93
|
+
"@ts-for-gir/reporter": "^4.0.0-rc.17",
|
|
94
|
+
"@ts-for-gir/tsconfig": "^4.0.0-rc.17",
|
|
95
|
+
"@types/ejs": "^3.1.5",
|
|
96
|
+
"@types/inquirer": "^9.0.9",
|
|
97
|
+
"@types/node": "^25.6.2",
|
|
98
|
+
"@types/yargs": "^17.0.35",
|
|
99
|
+
"esbuild": "^0.28.0",
|
|
100
|
+
"source-map-support": "^0.5.21",
|
|
101
|
+
"typescript": "^6.0.3"
|
|
102
|
+
},
|
|
103
|
+
"dependencies": {
|
|
104
|
+
"@inquirer/prompts": "^8.4.2",
|
|
105
|
+
"@ts-for-gir/templates": "^4.0.0-rc.17",
|
|
106
|
+
"colorette": "^2.0.20",
|
|
107
|
+
"cosmiconfig": "^9.0.1",
|
|
108
|
+
"ejs": "^5.0.2",
|
|
109
|
+
"glob": "^13.0.6",
|
|
110
|
+
"inquirer": "^13.4.2",
|
|
111
|
+
"typedoc": "^0.28.19",
|
|
112
|
+
"yargs": "^18.0.0"
|
|
113
|
+
}
|
|
114
|
+
}
|
package/src/commands/create.ts
CHANGED
|
@@ -19,7 +19,8 @@ const command = "create [name]";
|
|
|
19
19
|
const description = "Scaffold a new GJS TypeScript project from a template";
|
|
20
20
|
|
|
21
21
|
const examples: ReadonlyArray<[string, string?]> = [
|
|
22
|
-
[`${APP_NAME} create my-app --template types-
|
|
22
|
+
[`${APP_NAME} create my-app --template types-gjsify`, "Scaffold a Node-free GJS app via gjsify (recommended)"],
|
|
23
|
+
[`${APP_NAME} create my-app --template types-npm`, "Scaffold using the @girs/* NPM types + node/esbuild"],
|
|
23
24
|
[`${APP_NAME} create my-app --template types-locally`, "Scaffold and generate types into ./@types/ locally"],
|
|
24
25
|
[
|
|
25
26
|
`${APP_NAME} create my-app --template types-workspace`,
|
|
@@ -30,15 +31,20 @@ const examples: ReadonlyArray<[string, string?]> = [
|
|
|
30
31
|
|
|
31
32
|
const TEMPLATE_CHOICES: ReadonlyArray<{ value: CreateTemplateId; name: string; description: string }> = [
|
|
32
33
|
{
|
|
33
|
-
value: "types-
|
|
34
|
-
name: "types-
|
|
35
|
-
description: "
|
|
34
|
+
value: "types-gjsify",
|
|
35
|
+
name: "types-gjsify",
|
|
36
|
+
description: "Node-free: @girs/* from NPM, all dev scripts (install/build/run/format) routed through gjsify",
|
|
36
37
|
},
|
|
37
38
|
{
|
|
38
39
|
value: "types-npm",
|
|
39
40
|
name: "types-npm",
|
|
40
41
|
description: "Use pre-generated types from the @girs/* NPM packages",
|
|
41
42
|
},
|
|
43
|
+
{
|
|
44
|
+
value: "types-locally",
|
|
45
|
+
name: "types-locally",
|
|
46
|
+
description: "Generate GIR types directly into ./@types/ (no package format, no @girs/* deps)",
|
|
47
|
+
},
|
|
42
48
|
{
|
|
43
49
|
value: "types-workspace",
|
|
44
50
|
name: "types-workspace",
|
|
@@ -226,19 +232,30 @@ const handler = async (args: ConfigFlags) => {
|
|
|
226
232
|
log.success(`Scaffolded ${template} into ${targetDir}`);
|
|
227
233
|
|
|
228
234
|
if (opts.install) {
|
|
229
|
-
|
|
230
|
-
|
|
235
|
+
// types-gjsify is Node-free at runtime — bootstrap deps via `gjsify install`
|
|
236
|
+
// so the user's first impression matches the rest of the template's scripts.
|
|
237
|
+
// Other templates remain on npm (matches the prior behavior + their README).
|
|
238
|
+
const installer = template === "types-gjsify" ? "gjsify" : "npm";
|
|
239
|
+
const installerArgs = template === "types-gjsify" ? ["install"] : ["install", "--no-audit", "--no-fund"];
|
|
240
|
+
log.info(`Running ${installer} install...`);
|
|
241
|
+
const result = spawnSync(installer, installerArgs, {
|
|
231
242
|
cwd: targetDir,
|
|
232
243
|
stdio: "inherit",
|
|
233
244
|
});
|
|
234
245
|
if (result.status !== 0) {
|
|
235
|
-
log.warn(
|
|
246
|
+
log.warn(`${installer} install failed; you can re-run it manually in the project directory.`);
|
|
236
247
|
}
|
|
237
248
|
}
|
|
238
249
|
|
|
239
250
|
log.info("\nNext steps:");
|
|
240
251
|
log.white(` cd ${projectName}`);
|
|
241
|
-
if (!opts.install)
|
|
252
|
+
if (!opts.install) {
|
|
253
|
+
if (template === "types-gjsify") {
|
|
254
|
+
log.white(" gjsify install");
|
|
255
|
+
} else {
|
|
256
|
+
log.white(" npm install");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
242
259
|
switch (template) {
|
|
243
260
|
case "types-locally":
|
|
244
261
|
log.white(" npm run generate");
|
|
@@ -253,6 +270,10 @@ const handler = async (args: ConfigFlags) => {
|
|
|
253
270
|
log.white(" npm run build:types && npm install");
|
|
254
271
|
log.white(" npm run build:app && npm start");
|
|
255
272
|
break;
|
|
273
|
+
case "types-gjsify":
|
|
274
|
+
log.white(" gjsify run check");
|
|
275
|
+
log.white(" gjsify run build && gjsify run start");
|
|
276
|
+
break;
|
|
256
277
|
}
|
|
257
278
|
};
|
|
258
279
|
|
package/src/config/options.ts
CHANGED
|
@@ -257,8 +257,8 @@ export const createOptions = {
|
|
|
257
257
|
template: {
|
|
258
258
|
type: "string" as const,
|
|
259
259
|
alias: "t",
|
|
260
|
-
description: "Template to scaffold (types-locally, types-npm, types-workspace)",
|
|
261
|
-
choices: ["types-locally", "types-npm", "types-workspace"] as const,
|
|
260
|
+
description: "Template to scaffold (types-locally, types-npm, types-workspace, types-gjsify)",
|
|
261
|
+
choices: ["types-locally", "types-npm", "types-workspace", "types-gjsify"] as const,
|
|
262
262
|
},
|
|
263
263
|
install: {
|
|
264
264
|
type: "boolean" as const,
|
package/src/start.ts
CHANGED
|
@@ -5,11 +5,21 @@ import { hideBin } from "yargs/helpers";
|
|
|
5
5
|
import { analyze, copy, create, doc, generate, json, list, selfUpdate } from "./commands/index.ts";
|
|
6
6
|
|
|
7
7
|
try {
|
|
8
|
-
|
|
8
|
+
const cli = yargs(hideBin(process.argv));
|
|
9
|
+
await cli
|
|
9
10
|
.scriptName(APP_NAME)
|
|
10
11
|
.strict()
|
|
11
12
|
.usage(APP_USAGE)
|
|
12
13
|
.version(APP_VERSION)
|
|
14
|
+
// Use the full terminal width for help. yargs's default caps at 80
|
|
15
|
+
// (`Math.min(80, process.stdout.columns)`); we explicitly opt into
|
|
16
|
+
// the real terminal width so long option/description lines wrap at
|
|
17
|
+
// the actual terminal edge instead of an arbitrary 80-col limit.
|
|
18
|
+
// Under GJS, `process.stdout.columns` is backed by
|
|
19
|
+
// `@gjsify/terminal-native` (ioctl TIOCGWINSZ) when the typelib is
|
|
20
|
+
// on `GI_TYPELIB_PATH` — the install.js launcher imports those env
|
|
21
|
+
// vars from the gjsify global install when present.
|
|
22
|
+
.wrap(cli.terminalWidth())
|
|
13
23
|
// Disable yargs's internal `process.exit` and route both success
|
|
14
24
|
// and failure through `parseAsync` + an explicit `process.exit` so
|
|
15
25
|
// async command handlers complete and stdout drains before the
|
|
@@ -94,7 +94,7 @@ export interface DocCommandArgs extends GenerateCommandArgs {
|
|
|
94
94
|
/**
|
|
95
95
|
* Available scaffolding template identifiers for the create command.
|
|
96
96
|
*/
|
|
97
|
-
export type CreateTemplateId = "types-locally" | "types-npm" | "types-workspace";
|
|
97
|
+
export type CreateTemplateId = "types-locally" | "types-npm" | "types-workspace" | "types-gjsify";
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Arguments for the create command
|
|
@@ -1,15 +0,0 @@
|
|
|
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`.
|
|
@@ -1,21 +0,0 @@
|
|
|
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));
|
|
@@ -1,18 +0,0 @@
|
|
|
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.15",
|
|
15
|
-
"esbuild": "^0.28.0",
|
|
16
|
-
"typescript": "^6.0.2"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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.
|
|
@@ -1,19 +0,0 @@
|
|
|
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));
|
|
@@ -1,23 +0,0 @@
|
|
|
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.14",
|
|
18
|
-
"@girs/gio-2.0": "^2.88.0-4.0.0-rc.14",
|
|
19
|
-
"@girs/gjs": "^4.0.0-rc.14",
|
|
20
|
-
"@girs/glib-2.0": "^2.88.0-4.0.0-rc.14",
|
|
21
|
-
"@girs/gtk-4.0": "^4.23.0-4.0.0-rc.14"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
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.
|
|
@@ -1,22 +0,0 @@
|
|
|
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.15",
|
|
20
|
-
"typescript": "^6.0.2"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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));
|