@gjsify/create-app 0.18.0 → 0.19.0

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.
@@ -16,12 +16,12 @@
16
16
  "@girs/gjs": "^4.1.0",
17
17
  "@girs/gobject-2.0": "^4.1.0",
18
18
  "@girs/gtk-4.0": "^4.1.0",
19
- "@gjsify/cli": "^0.18.0",
20
- "@gjsify/vite-plugin-blueprint": "^0.18.0",
19
+ "@gjsify/cli": "^0.19.0",
20
+ "@gjsify/vite-plugin-blueprint": "^0.19.0",
21
21
  "@types/node": "^25.9.2",
22
22
  "typescript": "^6.0.3"
23
23
  },
24
24
  "dependencies": {
25
- "@gjsify/canvas2d": "^0.18.0"
25
+ "@gjsify/canvas2d": "^0.19.0"
26
26
  }
27
27
  }
@@ -16,14 +16,14 @@
16
16
  "@girs/gjs": "^4.1.0",
17
17
  "@girs/gobject-2.0": "^4.1.0",
18
18
  "@girs/gtk-4.0": "^4.1.0",
19
- "@gjsify/canvas2d": "^0.18.0",
20
- "@gjsify/cli": "^0.18.0",
21
- "@gjsify/vite-plugin-blueprint": "^0.18.0",
19
+ "@gjsify/canvas2d": "^0.19.0",
20
+ "@gjsify/cli": "^0.19.0",
21
+ "@gjsify/vite-plugin-blueprint": "^0.19.0",
22
22
  "@types/node": "^25.9.2",
23
23
  "typescript": "^6.0.3"
24
24
  },
25
25
  "dependencies": {
26
- "@gjsify/webgl": "^0.18.0",
26
+ "@gjsify/webgl": "^0.19.0",
27
27
  "excalibur": "0.32.0"
28
28
  }
29
29
  }
@@ -16,14 +16,14 @@
16
16
  "@girs/gjs": "^4.1.0",
17
17
  "@girs/gobject-2.0": "^4.1.0",
18
18
  "@girs/gtk-4.0": "^4.1.0",
19
- "@gjsify/cli": "^0.18.0",
20
- "@gjsify/vite-plugin-blueprint": "^0.18.0",
19
+ "@gjsify/cli": "^0.19.0",
20
+ "@gjsify/vite-plugin-blueprint": "^0.19.0",
21
21
  "@types/node": "^25.9.2",
22
22
  "@types/three": "^0.185.0",
23
23
  "typescript": "^6.0.3"
24
24
  },
25
25
  "dependencies": {
26
- "@gjsify/webgl": "^0.18.0",
26
+ "@gjsify/webgl": "^0.19.0",
27
27
  "three": "0.185.1"
28
28
  }
29
29
  }
@@ -11,9 +11,9 @@
11
11
  "dev": "gjsify build src/index.ts --outfile dist/index.js && gjsify run dist/index.js"
12
12
  },
13
13
  "devDependencies": {
14
- "@gjsify/cli": "^0.18.0",
15
- "@gjsify/node-globals": "^0.18.0",
16
- "@gjsify/runtime": "^0.18.0",
14
+ "@gjsify/cli": "^0.19.0",
15
+ "@gjsify/node-globals": "^0.19.0",
16
+ "@gjsify/runtime": "^0.19.0",
17
17
  "@types/node": "^25.9.2",
18
18
  "@types/yargs": "^17.0.35",
19
19
  "typescript": "^6.0.3"
@@ -11,7 +11,7 @@
11
11
  "dev": "gjsify build src/index.ts --outfile dist/index.js && gjsify run dist/index.js"
12
12
  },
13
13
  "devDependencies": {
14
- "@gjsify/cli": "^0.18.0",
14
+ "@gjsify/cli": "^0.19.0",
15
15
  "@types/node": "^25.9.2",
16
16
  "typescript": "^6.0.3"
17
17
  },
@@ -11,9 +11,9 @@
11
11
  "dev": "gjsify build src/index.ts --outfile dist/index.js && gjsify run dist/index.js"
12
12
  },
13
13
  "devDependencies": {
14
- "@gjsify/cli": "^0.18.0",
15
- "@gjsify/node-globals": "^0.18.0",
16
- "@gjsify/runtime": "^0.18.0",
14
+ "@gjsify/cli": "^0.19.0",
15
+ "@gjsify/node-globals": "^0.19.0",
16
+ "@gjsify/runtime": "^0.19.0",
17
17
  "@types/express": "^5.0.6",
18
18
  "@types/node": "^25.9.2",
19
19
  "typescript": "^6.0.3"
@@ -11,9 +11,9 @@
11
11
  "dev": "gjsify build src/index.ts --outfile dist/index.js && gjsify run dist/index.js"
12
12
  },
13
13
  "devDependencies": {
14
- "@gjsify/cli": "^0.18.0",
15
- "@gjsify/node-globals": "^0.18.0",
16
- "@gjsify/runtime": "^0.18.0",
14
+ "@gjsify/cli": "^0.19.0",
15
+ "@gjsify/node-globals": "^0.19.0",
16
+ "@gjsify/runtime": "^0.19.0",
17
17
  "@types/node": "^25.9.2",
18
18
  "typescript": "^6.0.3"
19
19
  },
@@ -1,6 +1,46 @@
1
1
  import { readdirSync, readFileSync, existsSync, statSync } from 'node:fs';
2
+ import { createRequire } from 'node:module';
2
3
  import { dirname, join } from 'node:path';
3
4
  import { fileURLToPath } from 'node:url';
5
+ /**
6
+ * Locate the shipped `dist-templates/` directory across the three shapes this
7
+ * module runs in:
8
+ *
9
+ * 1. **`lib/` layout** (Node/Bun/Deno via `@gjsify/create-app/lib`): the
10
+ * templates sit next to the package as `../dist-templates` relative to
11
+ * this file. This is the common case.
12
+ * 2. **Bundled into the CLI** (`gjsify create` under the committed
13
+ * `dist/cli.gjs.mjs` GJS bundle, or a `--app node` CLI bundle): here
14
+ * `import.meta.url` points at the CLI bundle, NOT this package, so the
15
+ * `../dist-templates` sibling does not exist. Resolve the real
16
+ * `@gjsify/create-app` package via `createRequire` (works under GJS via
17
+ * `@gjsify/module`'s node_modules walker, the same anchor `showcase`
18
+ * uses) and read its `dist-templates`.
19
+ * 3. **Co-located with a standalone bundle**: a self-contained install may
20
+ * ship `dist-templates/` next to the bundle — probe `<dir>/dist-templates`.
21
+ *
22
+ * Returns the first existing candidate, or `undefined` when none is found.
23
+ */
24
+ function resolveTemplatesRoot() {
25
+ const here = dirname(fileURLToPath(import.meta.url));
26
+ const candidates = [
27
+ // 1. lib/ layout — templates are a sibling of lib/.
28
+ join(here, '..', 'dist-templates'),
29
+ // 3. co-located next to a standalone bundle.
30
+ join(here, 'dist-templates'),
31
+ ];
32
+ // 2. Bundled: resolve the create-app package itself and read its templates.
33
+ try {
34
+ const require = createRequire(import.meta.url);
35
+ const pkgJson = require.resolve('@gjsify/create-app/package.json');
36
+ candidates.splice(1, 0, join(dirname(pkgJson), 'dist-templates'));
37
+ }
38
+ catch {
39
+ // Not resolvable as a package (e.g. fully self-contained install with
40
+ // no node_modules) — the co-located candidate above still applies.
41
+ }
42
+ return candidates.find((c) => existsSync(c));
43
+ }
4
44
  const FALLBACK_DESCRIPTIONS = {
5
45
  'gtk-minimal': 'Minimal GTK4 app — Gtk.Window + Gtk.Label (no Adwaita, no Blueprint).',
6
46
  cli: 'Command-line tool using yargs (Node.js + GJS).',
@@ -15,9 +55,8 @@ const FALLBACK_DESCRIPTIONS = {
15
55
  * Returns templates sorted alphabetically by name.
16
56
  */
17
57
  export function discoverTemplates() {
18
- const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
19
- const templatesRoot = join(pkgRoot, 'dist-templates');
20
- if (!existsSync(templatesRoot))
58
+ const templatesRoot = resolveTemplatesRoot();
59
+ if (!templatesRoot)
21
60
  return [];
22
61
  const templates = [];
23
62
  for (const name of readdirSync(templatesRoot)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/create-app",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Create a new Gjsify project",
5
5
  "type": "module",
6
6
  "main": "lib/create.js",