@gjsify/cli 0.3.17 → 0.3.19
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/lib/commands/showcase.js +36 -11
- package/package.json +10 -10
- package/src/commands/showcase.ts +35 -11
package/lib/commands/showcase.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { discoverShowcases, findShowcase } from '../utils/discover-showcases.js';
|
|
2
|
-
import { runMinimalChecks,
|
|
2
|
+
import { runMinimalChecks, detectPackageManager, buildInstallCommand, } from '../utils/check-system-deps.js';
|
|
3
3
|
import { spawn } from 'node:child_process';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
function readCliVersion() {
|
|
7
|
+
try {
|
|
8
|
+
const pkgUrl = new URL('../../package.json', import.meta.url);
|
|
9
|
+
const pkg = JSON.parse(readFileSync(pkgUrl, 'utf8'));
|
|
10
|
+
return typeof pkg.version === 'string' ? pkg.version : undefined;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
5
16
|
export const showcaseCommand = {
|
|
6
17
|
command: 'showcase [name]',
|
|
7
18
|
description: 'List or run curated gjsify showcase applications.',
|
|
@@ -58,12 +69,15 @@ export const showcaseCommand = {
|
|
|
58
69
|
console.error('Run "gjsify showcase" to list available showcases.');
|
|
59
70
|
process.exit(1);
|
|
60
71
|
}
|
|
61
|
-
// System dependency check before delegating — only
|
|
72
|
+
// System dependency check before delegating — only system libs (gjs,
|
|
73
|
+
// gtk4, …). The showcase's npm deps (incl. `@gjsify/webgl` with the
|
|
74
|
+
// gwebgl Vala prebuild) are fetched by `gjsify dlx` into the npm
|
|
75
|
+
// cache, and `runGjsBundle()` picks the prebuild up from the bundle
|
|
76
|
+
// dir via `detectNativePackages()`. Pre-flight-checking npm deps
|
|
77
|
+
// here would fail for `npx @gjsify/cli showcase` (no project
|
|
78
|
+
// node_modules, CLI doesn't dep on the showcase libs).
|
|
62
79
|
const results = runMinimalChecks();
|
|
63
|
-
|
|
64
|
-
results.push(checkGwebgl(process.cwd()));
|
|
65
|
-
}
|
|
66
|
-
const missingHard = results.filter((r) => !r.found && (r.severity === 'required' || r.id === 'gwebgl'));
|
|
80
|
+
const missingHard = results.filter((r) => !r.found && r.severity === 'required');
|
|
67
81
|
if (missingHard.length > 0) {
|
|
68
82
|
console.error('Missing system dependencies:\n');
|
|
69
83
|
for (const dep of missingHard) {
|
|
@@ -76,12 +90,23 @@ export const showcaseCommand = {
|
|
|
76
90
|
}
|
|
77
91
|
process.exit(1);
|
|
78
92
|
}
|
|
79
|
-
// Delegate to `gjsify dlx <package>` — same npm-cache,
|
|
80
|
-
// symlink-swap, same `gjsify.main` resolution. Re-spawning
|
|
81
|
-
// keeps the dlx logic in one place.
|
|
82
|
-
|
|
93
|
+
// Delegate to `gjsify dlx <package>@<cli-version>` — same npm-cache,
|
|
94
|
+
// same atomic symlink-swap, same `gjsify.main` resolution. Re-spawning
|
|
95
|
+
// the CLI keeps the dlx logic in one place.
|
|
96
|
+
//
|
|
97
|
+
// Pinning to the CLI's own version is load-bearing: showcases ship in
|
|
98
|
+
// lockstep with the CLI, so users running `npx @gjsify/cli@X showcase
|
|
99
|
+
// <name>` expect the matching `@gjsify/example-*@X`. Without the pin,
|
|
100
|
+
// dlx caches the first resolved-latest on disk; subsequent CLI
|
|
101
|
+
// releases leave that cache untouched until the 7-day TTL expires,
|
|
102
|
+
// and the user gets a stale showcase that may be missing deps the
|
|
103
|
+
// newer CLI assumes (the `@gjsify/http-soup-bridge` regression
|
|
104
|
+
// reported against `@gjsify/cli@0.3.17`).
|
|
105
|
+
const cliVersion = readCliVersion();
|
|
106
|
+
const dlxSpec = cliVersion ? `${showcase.packageName}@${cliVersion}` : showcase.packageName;
|
|
107
|
+
console.log(`Running showcase: ${showcase.name} (via gjsify dlx ${dlxSpec})\n`);
|
|
83
108
|
const cliBin = fileURLToPath(new URL('../index.js', import.meta.url));
|
|
84
|
-
const child = spawn(process.execPath, [cliBin, 'dlx',
|
|
109
|
+
const child = spawn(process.execPath, [cliBin, 'dlx', dlxSpec], {
|
|
85
110
|
stdio: 'inherit',
|
|
86
111
|
});
|
|
87
112
|
await new Promise((resolvePromise, reject) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.19",
|
|
4
4
|
"description": "CLI for Gjsify",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"cli"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@gjsify/create-app": "^0.3.
|
|
27
|
-
"@gjsify/node-polyfills": "^0.3.
|
|
28
|
-
"@gjsify/npm-registry": "^0.3.
|
|
29
|
-
"@gjsify/resolve-npm": "^0.3.
|
|
30
|
-
"@gjsify/rolldown-plugin-gjsify": "^0.3.
|
|
31
|
-
"@gjsify/rolldown-plugin-pnp": "^0.3.
|
|
32
|
-
"@gjsify/semver": "^0.3.
|
|
33
|
-
"@gjsify/tar": "^0.3.
|
|
34
|
-
"@gjsify/web-polyfills": "^0.3.
|
|
26
|
+
"@gjsify/create-app": "^0.3.19",
|
|
27
|
+
"@gjsify/node-polyfills": "^0.3.19",
|
|
28
|
+
"@gjsify/npm-registry": "^0.3.19",
|
|
29
|
+
"@gjsify/resolve-npm": "^0.3.19",
|
|
30
|
+
"@gjsify/rolldown-plugin-gjsify": "^0.3.19",
|
|
31
|
+
"@gjsify/rolldown-plugin-pnp": "^0.3.19",
|
|
32
|
+
"@gjsify/semver": "^0.3.19",
|
|
33
|
+
"@gjsify/tar": "^0.3.19",
|
|
34
|
+
"@gjsify/web-polyfills": "^0.3.19",
|
|
35
35
|
"cosmiconfig": "^9.0.1",
|
|
36
36
|
"get-tsconfig": "^4.14.0",
|
|
37
37
|
"pkg-types": "^2.3.1",
|
package/src/commands/showcase.ts
CHANGED
|
@@ -2,12 +2,22 @@ import type { Command } from '../types/index.js';
|
|
|
2
2
|
import { discoverShowcases, findShowcase } from '../utils/discover-showcases.js';
|
|
3
3
|
import {
|
|
4
4
|
runMinimalChecks,
|
|
5
|
-
checkGwebgl,
|
|
6
5
|
detectPackageManager,
|
|
7
6
|
buildInstallCommand,
|
|
8
7
|
} from '../utils/check-system-deps.js';
|
|
9
8
|
import { spawn } from 'node:child_process';
|
|
10
9
|
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
|
|
12
|
+
function readCliVersion(): string | undefined {
|
|
13
|
+
try {
|
|
14
|
+
const pkgUrl = new URL('../../package.json', import.meta.url);
|
|
15
|
+
const pkg = JSON.parse(readFileSync(pkgUrl, 'utf8')) as { version?: unknown };
|
|
16
|
+
return typeof pkg.version === 'string' ? pkg.version : undefined;
|
|
17
|
+
} catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
11
21
|
|
|
12
22
|
interface ShowcaseOptions {
|
|
13
23
|
name?: string;
|
|
@@ -79,13 +89,16 @@ export const showcaseCommand: Command<any, ShowcaseOptions> = {
|
|
|
79
89
|
process.exit(1);
|
|
80
90
|
}
|
|
81
91
|
|
|
82
|
-
// System dependency check before delegating — only
|
|
92
|
+
// System dependency check before delegating — only system libs (gjs,
|
|
93
|
+
// gtk4, …). The showcase's npm deps (incl. `@gjsify/webgl` with the
|
|
94
|
+
// gwebgl Vala prebuild) are fetched by `gjsify dlx` into the npm
|
|
95
|
+
// cache, and `runGjsBundle()` picks the prebuild up from the bundle
|
|
96
|
+
// dir via `detectNativePackages()`. Pre-flight-checking npm deps
|
|
97
|
+
// here would fail for `npx @gjsify/cli showcase` (no project
|
|
98
|
+
// node_modules, CLI doesn't dep on the showcase libs).
|
|
83
99
|
const results = runMinimalChecks();
|
|
84
|
-
if (showcase.needsWebgl) {
|
|
85
|
-
results.push(checkGwebgl(process.cwd()));
|
|
86
|
-
}
|
|
87
100
|
const missingHard = results.filter(
|
|
88
|
-
(r) => !r.found &&
|
|
101
|
+
(r) => !r.found && r.severity === 'required',
|
|
89
102
|
);
|
|
90
103
|
if (missingHard.length > 0) {
|
|
91
104
|
console.error('Missing system dependencies:\n');
|
|
@@ -100,12 +113,23 @@ export const showcaseCommand: Command<any, ShowcaseOptions> = {
|
|
|
100
113
|
process.exit(1);
|
|
101
114
|
}
|
|
102
115
|
|
|
103
|
-
// Delegate to `gjsify dlx <package>` — same npm-cache,
|
|
104
|
-
// symlink-swap, same `gjsify.main` resolution. Re-spawning
|
|
105
|
-
// keeps the dlx logic in one place.
|
|
106
|
-
|
|
116
|
+
// Delegate to `gjsify dlx <package>@<cli-version>` — same npm-cache,
|
|
117
|
+
// same atomic symlink-swap, same `gjsify.main` resolution. Re-spawning
|
|
118
|
+
// the CLI keeps the dlx logic in one place.
|
|
119
|
+
//
|
|
120
|
+
// Pinning to the CLI's own version is load-bearing: showcases ship in
|
|
121
|
+
// lockstep with the CLI, so users running `npx @gjsify/cli@X showcase
|
|
122
|
+
// <name>` expect the matching `@gjsify/example-*@X`. Without the pin,
|
|
123
|
+
// dlx caches the first resolved-latest on disk; subsequent CLI
|
|
124
|
+
// releases leave that cache untouched until the 7-day TTL expires,
|
|
125
|
+
// and the user gets a stale showcase that may be missing deps the
|
|
126
|
+
// newer CLI assumes (the `@gjsify/http-soup-bridge` regression
|
|
127
|
+
// reported against `@gjsify/cli@0.3.17`).
|
|
128
|
+
const cliVersion = readCliVersion();
|
|
129
|
+
const dlxSpec = cliVersion ? `${showcase.packageName}@${cliVersion}` : showcase.packageName;
|
|
130
|
+
console.log(`Running showcase: ${showcase.name} (via gjsify dlx ${dlxSpec})\n`);
|
|
107
131
|
const cliBin = fileURLToPath(new URL('../index.js', import.meta.url));
|
|
108
|
-
const child = spawn(process.execPath, [cliBin, 'dlx',
|
|
132
|
+
const child = spawn(process.execPath, [cliBin, 'dlx', dlxSpec], {
|
|
109
133
|
stdio: 'inherit',
|
|
110
134
|
});
|
|
111
135
|
await new Promise<void>((resolvePromise, reject) => {
|