@gjsify/cli 0.1.3 → 0.1.5

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.
@@ -11,8 +11,7 @@ export const checkCommand = {
11
11
  });
12
12
  },
13
13
  handler: async (args) => {
14
- const cwd = process.cwd();
15
- const results = runAllChecks(cwd);
14
+ const results = runAllChecks(process.cwd());
16
15
  const pm = detectPackageManager();
17
16
  const missing = results.filter(r => !r.found);
18
17
  if (args.json) {
@@ -1,5 +1,5 @@
1
1
  import { discoverExamples, findExample } from '../utils/discover-examples.js';
2
- import { runAllChecks, detectPackageManager, buildInstallCommand } from '../utils/check-system-deps.js';
2
+ import { runMinimalChecks, checkGwebgl, detectPackageManager, buildInstallCommand } from '../utils/check-system-deps.js';
3
3
  import { runGjsBundle } from '../utils/run-gjs.js';
4
4
  export const showcaseCommand = {
5
5
  command: 'showcase [name]',
@@ -61,8 +61,13 @@ export const showcaseCommand = {
61
61
  console.error('Run "gjsify showcase" to list available examples.');
62
62
  process.exit(1);
63
63
  }
64
- // System dependency check before running
65
- const results = runAllChecks(process.cwd());
64
+ // System dependency check before running — only check what this example needs.
65
+ // All examples need GJS; WebGL examples additionally need gwebgl prebuilds.
66
+ const results = runMinimalChecks();
67
+ const needsWebgl = example.packageName.includes('webgl') || example.packageName.includes('three');
68
+ if (needsWebgl) {
69
+ results.push(checkGwebgl(process.cwd()));
70
+ }
66
71
  const missing = results.filter(r => !r.found);
67
72
  if (missing.length > 0) {
68
73
  console.error('Missing system dependencies:\n');
@@ -9,7 +9,17 @@ export interface DepCheck {
9
9
  }
10
10
  export type PackageManager = 'apt' | 'dnf' | 'pacman' | 'zypper' | 'apk' | 'unknown';
11
11
  export declare function detectPackageManager(): PackageManager;
12
+ /**
13
+ * Run all dependency checks. Used by `gjsify check` to show full system status.
14
+ */
12
15
  export declare function runAllChecks(cwd: string): DepCheck[];
16
+ /**
17
+ * Minimal checks needed to run any GJS example (GJS binary only).
18
+ * Used by `gjsify showcase` for examples that have no native deps.
19
+ */
20
+ export declare function runMinimalChecks(): DepCheck[];
21
+ /** Check gwebgl npm package (project first, CLI fallback). */
22
+ export declare function checkGwebgl(cwd: string): DepCheck;
13
23
  /**
14
24
  * Build a suggested install command for missing dependencies.
15
25
  * gwebgl is an npm package, not a system package — handled separately.
@@ -30,15 +30,24 @@ function checkPkgConfig(id, name, libName) {
30
30
  return { id, name, found: true, version: version.split('\n')[0] };
31
31
  }
32
32
  /**
33
- * Check for an npm package by resolving it via Node.js module resolution from cwd.
34
- * Mirrors the resolution logic used by esbuild / the build command.
33
+ * Check for an npm package. Tries the user's project first (cwd), then falls
34
+ * back to the CLI's own node_modules. This way a locally installed version
35
+ * takes precedence, but npx usage still works via the CLI's own dependencies.
35
36
  */
36
37
  function checkNpmPackage(id, name, packageName, cwd) {
38
+ // 1. Try user's project
37
39
  try {
38
40
  const requireFromCwd = createRequire(pathToFileURL(join(cwd, '_check_.js')).href);
39
41
  requireFromCwd.resolve(packageName);
40
42
  return { id, name, found: true };
41
43
  }
44
+ catch { /* not in project, try CLI fallback */ }
45
+ // 2. Fallback: CLI's own node_modules
46
+ try {
47
+ const requireFromCli = createRequire(import.meta.url);
48
+ requireFromCli.resolve(packageName);
49
+ return { id, name, found: true };
50
+ }
42
51
  catch {
43
52
  return { id, name, found: false };
44
53
  }
@@ -52,12 +61,33 @@ export function detectPackageManager() {
52
61
  }
53
62
  return 'unknown';
54
63
  }
64
+ /**
65
+ * Run all dependency checks. Used by `gjsify check` to show full system status.
66
+ */
55
67
  export function runAllChecks(cwd) {
68
+ return [...runMinimalChecks(), ...runExtraChecks(cwd)];
69
+ }
70
+ /**
71
+ * Minimal checks needed to run any GJS example (GJS binary only).
72
+ * Used by `gjsify showcase` for examples that have no native deps.
73
+ */
74
+ export function runMinimalChecks() {
56
75
  const results = [];
57
76
  // Node.js — always present
58
77
  results.push({ id: 'nodejs', name: 'Node.js', found: true, version: process.version });
59
78
  // GJS
60
79
  results.push(checkBinary('gjs', 'GJS', 'gjs', ['--version'], (out) => out.replace(/^GJS\s+/i, '').split('\n')[0] ?? out));
80
+ return results;
81
+ }
82
+ /** Check gwebgl npm package (project first, CLI fallback). */
83
+ export function checkGwebgl(cwd) {
84
+ return checkNpmPackage('gwebgl', 'gwebgl (@gjsify/webgl)', '@gjsify/webgl', cwd);
85
+ }
86
+ /**
87
+ * Extra checks for development and full system audit.
88
+ */
89
+ function runExtraChecks(cwd) {
90
+ const results = [];
61
91
  // Blueprint Compiler
62
92
  results.push(checkBinary('blueprint-compiler', 'Blueprint Compiler', 'blueprint-compiler', ['--version']));
63
93
  // pkg-config (needed for library checks)
@@ -80,8 +110,8 @@ export function runAllChecks(cwd) {
80
110
  }
81
111
  // GObject Introspection
82
112
  results.push(checkPkgConfig('gobject-introspection', 'GObject Introspection', 'gobject-introspection-1.0'));
83
- // gwebgl — resolve via Node.js module resolution from cwd, same as esbuild would.
84
- results.push(checkNpmPackage('gwebgl', 'gwebgl (@gjsify/webgl)', '@gjsify/webgl', cwd));
113
+ // gwebgl — project first, CLI fallback.
114
+ results.push(checkGwebgl(cwd));
85
115
  return results;
86
116
  }
87
117
  // Per-package-manager install package names, keyed by dep id.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "CLI for Gjsify",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -23,55 +23,55 @@
23
23
  "cli"
24
24
  ],
25
25
  "dependencies": {
26
- "@gjsify/esbuild-plugin-gjsify": "^0.1.3",
27
- "@gjsify/example-dom-canvas2d-confetti": "^0.1.3",
28
- "@gjsify/example-dom-canvas2d-fireworks": "^0.1.3",
29
- "@gjsify/example-dom-canvas2d-text": "^0.1.3",
30
- "@gjsify/example-dom-iframe-basic": "^0.1.3",
31
- "@gjsify/example-dom-three-extrude-shapes": "^0.1.3",
32
- "@gjsify/example-dom-three-geometry-cube": "^0.1.3",
33
- "@gjsify/example-dom-three-geometry-shapes": "^0.1.3",
34
- "@gjsify/example-dom-three-geometry-teapot": "^0.1.3",
35
- "@gjsify/example-dom-three-loader-ldraw": "^0.1.3",
36
- "@gjsify/example-dom-three-morphtargets": "^0.1.3",
37
- "@gjsify/example-dom-three-multiple-rendertargets": "^0.1.3",
38
- "@gjsify/example-dom-three-postprocessing-pixel": "^0.1.3",
39
- "@gjsify/example-dom-webgl-demo-fade": "^0.1.3",
40
- "@gjsify/example-dom-webgl-tutorial-01": "^0.1.3",
41
- "@gjsify/example-dom-webgl-tutorial-02": "^0.1.3",
42
- "@gjsify/example-dom-webgl-tutorial-03": "^0.1.3",
43
- "@gjsify/example-dom-webgl-tutorial-04": "^0.1.3",
44
- "@gjsify/example-dom-webgl-tutorial-05": "^0.1.3",
45
- "@gjsify/example-dom-webgl-tutorial-06": "^0.1.3",
46
- "@gjsify/example-dom-webgl-tutorial-07": "^0.1.3",
47
- "@gjsify/example-node-cli-deepkit-di": "^0.1.3",
48
- "@gjsify/example-node-cli-deepkit-events": "^0.1.3",
49
- "@gjsify/example-node-cli-deepkit-types": "^0.1.3",
50
- "@gjsify/example-node-cli-deepkit-validation": "^0.1.3",
51
- "@gjsify/example-node-cli-deepkit-workflow": "^0.1.3",
52
- "@gjsify/example-node-cli-dns-lookup": "^0.1.3",
53
- "@gjsify/example-node-cli-esbuild-plugin-deepkit": "^0.1.3",
54
- "@gjsify/example-node-cli-esbuild-plugin-transform-ext": "^0.1.3",
55
- "@gjsify/example-node-cli-file-search": "^0.1.3",
56
- "@gjsify/example-node-cli-gio-cat": "^0.1.3",
57
- "@gjsify/example-node-cli-json-store": "^0.1.3",
58
- "@gjsify/example-node-cli-node-buffer": "^0.1.3",
59
- "@gjsify/example-node-cli-node-events": "^0.1.3",
60
- "@gjsify/example-node-cli-node-fs": "^0.1.3",
61
- "@gjsify/example-node-cli-node-os": "^0.1.3",
62
- "@gjsify/example-node-cli-node-path": "^0.1.3",
63
- "@gjsify/example-node-cli-node-url": "^0.1.3",
64
- "@gjsify/example-node-cli-worker-pool": "^0.1.3",
65
- "@gjsify/example-node-cli-yargs-demo": "^0.1.3",
66
- "@gjsify/example-node-gtk-http-dashboard": "^0.1.3",
67
- "@gjsify/example-node-net-express-hello": "^0.1.3",
68
- "@gjsify/example-node-net-hono-rest": "^0.1.3",
69
- "@gjsify/example-node-net-koa-blog": "^0.1.3",
70
- "@gjsify/example-node-net-sse-chat": "^0.1.3",
71
- "@gjsify/example-node-net-static-file-server": "^0.1.3",
72
- "@gjsify/example-node-net-ws-chat": "^0.1.3",
73
- "@gjsify/node-polyfills": "^0.1.3",
74
- "@gjsify/web-polyfills": "^0.1.3",
26
+ "@gjsify/esbuild-plugin-gjsify": "^0.1.5",
27
+ "@gjsify/example-dom-canvas2d-confetti": "^0.1.5",
28
+ "@gjsify/example-dom-canvas2d-fireworks": "^0.1.5",
29
+ "@gjsify/example-dom-canvas2d-text": "^0.1.5",
30
+ "@gjsify/example-dom-iframe-basic": "^0.1.5",
31
+ "@gjsify/example-dom-three-extrude-shapes": "^0.1.5",
32
+ "@gjsify/example-dom-three-geometry-cube": "^0.1.5",
33
+ "@gjsify/example-dom-three-geometry-shapes": "^0.1.5",
34
+ "@gjsify/example-dom-three-geometry-teapot": "^0.1.5",
35
+ "@gjsify/example-dom-three-loader-ldraw": "^0.1.5",
36
+ "@gjsify/example-dom-three-morphtargets": "^0.1.5",
37
+ "@gjsify/example-dom-three-multiple-rendertargets": "^0.1.5",
38
+ "@gjsify/example-dom-three-postprocessing-pixel": "^0.1.5",
39
+ "@gjsify/example-dom-webgl-demo-fade": "^0.1.5",
40
+ "@gjsify/example-dom-webgl-tutorial-01": "^0.1.5",
41
+ "@gjsify/example-dom-webgl-tutorial-02": "^0.1.5",
42
+ "@gjsify/example-dom-webgl-tutorial-03": "^0.1.5",
43
+ "@gjsify/example-dom-webgl-tutorial-04": "^0.1.5",
44
+ "@gjsify/example-dom-webgl-tutorial-05": "^0.1.5",
45
+ "@gjsify/example-dom-webgl-tutorial-06": "^0.1.5",
46
+ "@gjsify/example-dom-webgl-tutorial-07": "^0.1.5",
47
+ "@gjsify/example-node-cli-deepkit-di": "^0.1.5",
48
+ "@gjsify/example-node-cli-deepkit-events": "^0.1.5",
49
+ "@gjsify/example-node-cli-deepkit-types": "^0.1.5",
50
+ "@gjsify/example-node-cli-deepkit-validation": "^0.1.5",
51
+ "@gjsify/example-node-cli-deepkit-workflow": "^0.1.5",
52
+ "@gjsify/example-node-cli-dns-lookup": "^0.1.5",
53
+ "@gjsify/example-node-cli-esbuild-plugin-deepkit": "^0.1.5",
54
+ "@gjsify/example-node-cli-esbuild-plugin-transform-ext": "^0.1.5",
55
+ "@gjsify/example-node-cli-file-search": "^0.1.5",
56
+ "@gjsify/example-node-cli-gio-cat": "^0.1.5",
57
+ "@gjsify/example-node-cli-json-store": "^0.1.5",
58
+ "@gjsify/example-node-cli-node-buffer": "^0.1.5",
59
+ "@gjsify/example-node-cli-node-events": "^0.1.5",
60
+ "@gjsify/example-node-cli-node-fs": "^0.1.5",
61
+ "@gjsify/example-node-cli-node-os": "^0.1.5",
62
+ "@gjsify/example-node-cli-node-path": "^0.1.5",
63
+ "@gjsify/example-node-cli-node-url": "^0.1.5",
64
+ "@gjsify/example-node-cli-worker-pool": "^0.1.5",
65
+ "@gjsify/example-node-cli-yargs-demo": "^0.1.5",
66
+ "@gjsify/example-node-gtk-http-dashboard": "^0.1.5",
67
+ "@gjsify/example-node-net-express-hello": "^0.1.5",
68
+ "@gjsify/example-node-net-hono-rest": "^0.1.5",
69
+ "@gjsify/example-node-net-koa-blog": "^0.1.5",
70
+ "@gjsify/example-node-net-sse-chat": "^0.1.5",
71
+ "@gjsify/example-node-net-static-file-server": "^0.1.5",
72
+ "@gjsify/example-node-net-ws-chat": "^0.1.5",
73
+ "@gjsify/node-polyfills": "^0.1.5",
74
+ "@gjsify/web-polyfills": "^0.1.5",
75
75
  "cosmiconfig": "^9.0.1",
76
76
  "esbuild": "^0.28.0",
77
77
  "get-tsconfig": "^4.13.7",
@@ -17,8 +17,7 @@ export const checkCommand: Command<any, CheckOptions> = {
17
17
  });
18
18
  },
19
19
  handler: async (args) => {
20
- const cwd = process.cwd();
21
- const results = runAllChecks(cwd);
20
+ const results = runAllChecks(process.cwd());
22
21
  const pm = detectPackageManager();
23
22
  const missing = results.filter(r => !r.found);
24
23
 
@@ -1,6 +1,6 @@
1
1
  import type { Command } from '../types/index.js';
2
2
  import { discoverExamples, findExample } from '../utils/discover-examples.js';
3
- import { runAllChecks, detectPackageManager, buildInstallCommand } from '../utils/check-system-deps.js';
3
+ import { runMinimalChecks, checkGwebgl, detectPackageManager, buildInstallCommand } from '../utils/check-system-deps.js';
4
4
  import { runGjsBundle } from '../utils/run-gjs.js';
5
5
 
6
6
  interface ShowcaseOptions {
@@ -76,8 +76,13 @@ export const showcaseCommand: Command<any, ShowcaseOptions> = {
76
76
  process.exit(1);
77
77
  }
78
78
 
79
- // System dependency check before running
80
- const results = runAllChecks(process.cwd());
79
+ // System dependency check before running — only check what this example needs.
80
+ // All examples need GJS; WebGL examples additionally need gwebgl prebuilds.
81
+ const results = runMinimalChecks();
82
+ const needsWebgl = example.packageName.includes('webgl') || example.packageName.includes('three');
83
+ if (needsWebgl) {
84
+ results.push(checkGwebgl(process.cwd()));
85
+ }
81
86
  const missing = results.filter(r => !r.found);
82
87
  if (missing.length > 0) {
83
88
  console.error('Missing system dependencies:\n');
@@ -44,14 +44,23 @@ function checkPkgConfig(id: string, name: string, libName: string): DepCheck {
44
44
  }
45
45
 
46
46
  /**
47
- * Check for an npm package by resolving it via Node.js module resolution from cwd.
48
- * Mirrors the resolution logic used by esbuild / the build command.
47
+ * Check for an npm package. Tries the user's project first (cwd), then falls
48
+ * back to the CLI's own node_modules. This way a locally installed version
49
+ * takes precedence, but npx usage still works via the CLI's own dependencies.
49
50
  */
50
51
  function checkNpmPackage(id: string, name: string, packageName: string, cwd: string): DepCheck {
52
+ // 1. Try user's project
51
53
  try {
52
54
  const requireFromCwd = createRequire(pathToFileURL(join(cwd, '_check_.js')).href);
53
55
  requireFromCwd.resolve(packageName);
54
56
  return { id, name, found: true };
57
+ } catch { /* not in project, try CLI fallback */ }
58
+
59
+ // 2. Fallback: CLI's own node_modules
60
+ try {
61
+ const requireFromCli = createRequire(import.meta.url);
62
+ requireFromCli.resolve(packageName);
63
+ return { id, name, found: true };
55
64
  } catch {
56
65
  return { id, name, found: false };
57
66
  }
@@ -66,7 +75,18 @@ export function detectPackageManager(): PackageManager {
66
75
  return 'unknown';
67
76
  }
68
77
 
78
+ /**
79
+ * Run all dependency checks. Used by `gjsify check` to show full system status.
80
+ */
69
81
  export function runAllChecks(cwd: string): DepCheck[] {
82
+ return [...runMinimalChecks(), ...runExtraChecks(cwd)];
83
+ }
84
+
85
+ /**
86
+ * Minimal checks needed to run any GJS example (GJS binary only).
87
+ * Used by `gjsify showcase` for examples that have no native deps.
88
+ */
89
+ export function runMinimalChecks(): DepCheck[] {
70
90
  const results: DepCheck[] = [];
71
91
 
72
92
  // Node.js — always present
@@ -76,6 +96,20 @@ export function runAllChecks(cwd: string): DepCheck[] {
76
96
  results.push(checkBinary('gjs', 'GJS', 'gjs', ['--version'],
77
97
  (out) => out.replace(/^GJS\s+/i, '').split('\n')[0] ?? out));
78
98
 
99
+ return results;
100
+ }
101
+
102
+ /** Check gwebgl npm package (project first, CLI fallback). */
103
+ export function checkGwebgl(cwd: string): DepCheck {
104
+ return checkNpmPackage('gwebgl', 'gwebgl (@gjsify/webgl)', '@gjsify/webgl', cwd);
105
+ }
106
+
107
+ /**
108
+ * Extra checks for development and full system audit.
109
+ */
110
+ function runExtraChecks(cwd: string): DepCheck[] {
111
+ const results: DepCheck[] = [];
112
+
79
113
  // Blueprint Compiler
80
114
  results.push(checkBinary('blueprint-compiler', 'Blueprint Compiler',
81
115
  'blueprint-compiler', ['--version']));
@@ -106,8 +140,8 @@ export function runAllChecks(cwd: string): DepCheck[] {
106
140
  // GObject Introspection
107
141
  results.push(checkPkgConfig('gobject-introspection', 'GObject Introspection', 'gobject-introspection-1.0'));
108
142
 
109
- // gwebgl — resolve via Node.js module resolution from cwd, same as esbuild would.
110
- results.push(checkNpmPackage('gwebgl', 'gwebgl (@gjsify/webgl)', '@gjsify/webgl', cwd));
143
+ // gwebgl — project first, CLI fallback.
144
+ results.push(checkGwebgl(cwd));
111
145
 
112
146
  return results;
113
147
  }