@gjsify/cli 0.1.7 → 0.1.9
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/actions/build.d.ts +19 -0
- package/lib/actions/build.js +80 -11
- package/lib/commands/build.js +6 -0
- package/lib/commands/check.js +41 -12
- package/lib/commands/create.d.ts +6 -0
- package/lib/commands/create.js +15 -0
- package/lib/commands/index.d.ts +1 -0
- package/lib/commands/index.js +1 -0
- package/lib/commands/showcase.js +35 -33
- package/lib/config.js +2 -0
- package/lib/index.js +2 -1
- package/lib/types/cli-build-options.d.ts +7 -0
- package/lib/types/config-data.d.ts +5 -0
- package/lib/utils/check-system-deps.d.ts +14 -2
- package/lib/utils/check-system-deps.js +214 -46
- package/lib/utils/detect-native-packages.d.ts +4 -0
- package/lib/utils/detect-native-packages.js +12 -0
- package/lib/utils/discover-showcases.d.ts +19 -0
- package/lib/utils/{discover-examples.js → discover-showcases.js} +14 -15
- package/lib/utils/run-gjs.js +9 -0
- package/package.json +10 -50
- package/src/actions/build.ts +99 -13
- package/src/commands/build.ts +6 -0
- package/src/commands/check.ts +45 -12
- package/src/commands/create.ts +21 -0
- package/src/commands/index.ts +2 -1
- package/src/commands/showcase.ts +36 -34
- package/src/config.ts +1 -0
- package/src/index.ts +2 -1
- package/src/types/cli-build-options.ts +8 -1
- package/src/types/config-data.ts +6 -1
- package/src/utils/check-system-deps.ts +264 -45
- package/src/utils/detect-native-packages.ts +12 -0
- package/src/utils/{discover-examples.ts → discover-showcases.ts} +18 -19
- package/src/utils/run-gjs.ts +11 -0
- package/lib/utils/discover-examples.d.ts +0 -19
package/lib/actions/build.d.ts
CHANGED
|
@@ -7,6 +7,25 @@ export declare class BuildAction {
|
|
|
7
7
|
getEsBuildDefaults(): BuildOptions;
|
|
8
8
|
/** Library mode */
|
|
9
9
|
buildLibrary(): Promise<BuildResult<BuildOptions>[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Parse the `--globals` value into { autoMode, extras }.
|
|
12
|
+
* - `auto` → { autoMode: true, extras: '' }
|
|
13
|
+
* - `auto,dom` → { autoMode: true, extras: 'dom' }
|
|
14
|
+
* - `auto,dom,fetch` → { autoMode: true, extras: 'dom,fetch' }
|
|
15
|
+
* - `dom,fetch` → { autoMode: false, extras: 'dom,fetch' }
|
|
16
|
+
* - `none` / `` → { autoMode: false, extras: '' }
|
|
17
|
+
* - `undefined` → { autoMode: true, extras: '' } (default)
|
|
18
|
+
*/
|
|
19
|
+
private parseGlobalsValue;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve the `--globals` CLI list into a pre-computed inject stub path
|
|
22
|
+
* that the esbuild plugin will append to its `inject` list. Only runs
|
|
23
|
+
* for `--app gjs` — Node and browser builds rely on native globals.
|
|
24
|
+
*
|
|
25
|
+
* Used only for the explicit-only path (no `auto` token in the value).
|
|
26
|
+
* The auto path is handled in `buildApp` via the two-pass build.
|
|
27
|
+
*/
|
|
28
|
+
private resolveGlobalsInject;
|
|
10
29
|
/** Application mode */
|
|
11
30
|
buildApp(app?: App): Promise<BuildResult<{
|
|
12
31
|
format: "esm" | "cjs";
|
package/lib/actions/build.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { build } from 'esbuild';
|
|
2
2
|
import { gjsifyPlugin } from '@gjsify/esbuild-plugin-gjsify';
|
|
3
|
+
import { resolveGlobalsList, writeRegisterInjectFile, detectAutoGlobals } from '@gjsify/esbuild-plugin-gjsify/globals';
|
|
3
4
|
import { dirname, extname } from 'path';
|
|
4
5
|
export class BuildAction {
|
|
5
6
|
configData;
|
|
@@ -63,31 +64,99 @@ export class BuildAction {
|
|
|
63
64
|
}
|
|
64
65
|
return results;
|
|
65
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Parse the `--globals` value into { autoMode, extras }.
|
|
69
|
+
* - `auto` → { autoMode: true, extras: '' }
|
|
70
|
+
* - `auto,dom` → { autoMode: true, extras: 'dom' }
|
|
71
|
+
* - `auto,dom,fetch` → { autoMode: true, extras: 'dom,fetch' }
|
|
72
|
+
* - `dom,fetch` → { autoMode: false, extras: 'dom,fetch' }
|
|
73
|
+
* - `none` / `` → { autoMode: false, extras: '' }
|
|
74
|
+
* - `undefined` → { autoMode: true, extras: '' } (default)
|
|
75
|
+
*/
|
|
76
|
+
parseGlobalsValue(value) {
|
|
77
|
+
if (value === undefined)
|
|
78
|
+
return { autoMode: true, extras: '' };
|
|
79
|
+
if (value === 'none' || value === '')
|
|
80
|
+
return { autoMode: false, extras: '' };
|
|
81
|
+
const tokens = value.split(',').map(t => t.trim()).filter(Boolean);
|
|
82
|
+
const hasAuto = tokens.includes('auto');
|
|
83
|
+
const extras = tokens.filter(t => t !== 'auto').join(',');
|
|
84
|
+
return { autoMode: hasAuto, extras };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Resolve the `--globals` CLI list into a pre-computed inject stub path
|
|
88
|
+
* that the esbuild plugin will append to its `inject` list. Only runs
|
|
89
|
+
* for `--app gjs` — Node and browser builds rely on native globals.
|
|
90
|
+
*
|
|
91
|
+
* Used only for the explicit-only path (no `auto` token in the value).
|
|
92
|
+
* The auto path is handled in `buildApp` via the two-pass build.
|
|
93
|
+
*/
|
|
94
|
+
async resolveGlobalsInject(app, globals, verbose) {
|
|
95
|
+
if (app !== 'gjs')
|
|
96
|
+
return undefined;
|
|
97
|
+
if (!globals)
|
|
98
|
+
return undefined;
|
|
99
|
+
const registerPaths = resolveGlobalsList(globals);
|
|
100
|
+
if (registerPaths.size === 0)
|
|
101
|
+
return undefined;
|
|
102
|
+
const injectPath = await writeRegisterInjectFile(registerPaths, process.cwd());
|
|
103
|
+
if (verbose && injectPath) {
|
|
104
|
+
console.debug(`[gjsify] globals: injected ${registerPaths.size} register module(s) from --globals ${globals}`);
|
|
105
|
+
}
|
|
106
|
+
return injectPath ?? undefined;
|
|
107
|
+
}
|
|
66
108
|
/** Application mode */
|
|
67
109
|
async buildApp(app = 'gjs') {
|
|
68
110
|
const { verbose, esbuild, typescript, exclude, library: pgk } = this.configData;
|
|
69
111
|
const format = esbuild?.format ?? (esbuild?.outfile?.endsWith('.cjs') ? 'cjs' : 'esm');
|
|
70
|
-
// Set default outfile if no outdir is set
|
|
112
|
+
// Set default outfile if no outdir is set
|
|
71
113
|
if (esbuild && !esbuild?.outfile && !esbuild?.outdir && (pgk?.main || pgk?.module)) {
|
|
72
114
|
esbuild.outfile = esbuild?.format === 'cjs' ? pgk.main || pgk.module : pgk.module || pgk.main;
|
|
73
115
|
}
|
|
74
|
-
const { consoleShim } = this.configData;
|
|
116
|
+
const { consoleShim, globals } = this.configData;
|
|
117
|
+
const pluginOpts = {
|
|
118
|
+
debug: verbose,
|
|
119
|
+
app,
|
|
120
|
+
format,
|
|
121
|
+
exclude,
|
|
122
|
+
reflection: typescript?.reflection,
|
|
123
|
+
consoleShim,
|
|
124
|
+
};
|
|
125
|
+
const { autoMode, extras } = this.parseGlobalsValue(globals);
|
|
126
|
+
// --- Auto mode (with optional extras): iterative multi-pass build ---
|
|
127
|
+
// The extras token is used for cases where the detector cannot
|
|
128
|
+
// statically see a global (e.g. Excalibur indirects globalThis via
|
|
129
|
+
// BrowserComponent.nativeComponent). Common pattern: --globals auto,dom
|
|
130
|
+
if (app === 'gjs' && autoMode) {
|
|
131
|
+
const { injectPath } = await detectAutoGlobals({ ...this.getEsBuildDefaults(), ...esbuild, format }, pluginOpts, verbose, { extraGlobalsList: extras });
|
|
132
|
+
const result = await build({
|
|
133
|
+
...this.getEsBuildDefaults(),
|
|
134
|
+
...esbuild,
|
|
135
|
+
format,
|
|
136
|
+
plugins: [
|
|
137
|
+
gjsifyPlugin({
|
|
138
|
+
...pluginOpts,
|
|
139
|
+
autoGlobalsInject: injectPath,
|
|
140
|
+
}),
|
|
141
|
+
],
|
|
142
|
+
});
|
|
143
|
+
return [result];
|
|
144
|
+
}
|
|
145
|
+
// --- Explicit list (no `auto` token) or none mode ---
|
|
146
|
+
const autoGlobalsInject = extras
|
|
147
|
+
? await this.resolveGlobalsInject(app, extras, verbose)
|
|
148
|
+
: undefined;
|
|
75
149
|
const result = await build({
|
|
76
150
|
...this.getEsBuildDefaults(),
|
|
77
151
|
...esbuild,
|
|
78
152
|
format,
|
|
79
153
|
plugins: [
|
|
80
|
-
gjsifyPlugin({
|
|
154
|
+
gjsifyPlugin({
|
|
155
|
+
...pluginOpts,
|
|
156
|
+
autoGlobalsInject,
|
|
157
|
+
}),
|
|
81
158
|
]
|
|
82
159
|
});
|
|
83
|
-
// See https://esbuild.github.io/api/#metafile
|
|
84
|
-
// TODO add cli options for this
|
|
85
|
-
// if(result.metafile) {
|
|
86
|
-
// const outFile = esbuild?.outfile ? esbuild.outfile + '.meta.json' : 'meta.json';
|
|
87
|
-
// await writeFile(outFile, JSON.stringify(result.metafile));
|
|
88
|
-
// let text = await analyzeMetafile(result.metafile)
|
|
89
|
-
// console.log(text)
|
|
90
|
-
// }
|
|
91
160
|
return [result];
|
|
92
161
|
}
|
|
93
162
|
async start(buildType = { app: 'gjs' }) {
|
package/lib/commands/build.js
CHANGED
|
@@ -85,6 +85,12 @@ export const buildCommand = {
|
|
|
85
85
|
type: 'boolean',
|
|
86
86
|
normalize: true,
|
|
87
87
|
default: true
|
|
88
|
+
})
|
|
89
|
+
.option('globals', {
|
|
90
|
+
description: "Comma-separated list of global identifiers, 'auto' (default) to detect automatically from the bundled output, or 'none' to disable. The 'auto' token may be combined with explicit identifiers/groups (e.g. 'auto,dom') for cases where the detector cannot statically see a global because it's accessed via indirection. Each identifier is mapped to the corresponding `@gjsify/<pkg>/register` module and injected into the bundle. See the CLI Reference docs for the full list of known identifiers. Only applies to GJS app builds.",
|
|
91
|
+
type: 'string',
|
|
92
|
+
normalize: true,
|
|
93
|
+
default: 'auto'
|
|
88
94
|
});
|
|
89
95
|
},
|
|
90
96
|
handler: async (args) => {
|
package/lib/commands/check.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { runAllChecks, detectPackageManager, buildInstallCommand } from '../utils/check-system-deps.js';
|
|
2
2
|
export const checkCommand = {
|
|
3
3
|
command: 'check',
|
|
4
|
-
description: 'Check that
|
|
4
|
+
description: 'Check that required system dependencies (GJS, GTK4, libsoup3, …) are installed. Optional dependencies are detected only when their @gjsify/* package is in your project.',
|
|
5
5
|
builder: (yargs) => {
|
|
6
6
|
return yargs
|
|
7
7
|
.option('json', {
|
|
@@ -13,31 +13,60 @@ export const checkCommand = {
|
|
|
13
13
|
handler: async (args) => {
|
|
14
14
|
const results = runAllChecks(process.cwd());
|
|
15
15
|
const pm = detectPackageManager();
|
|
16
|
-
const
|
|
16
|
+
const missingRequired = results.filter(r => !r.found && r.severity === 'required');
|
|
17
|
+
const missingOptional = results.filter(r => !r.found && r.severity === 'optional');
|
|
18
|
+
const allMissing = [...missingRequired, ...missingOptional];
|
|
17
19
|
if (args.json) {
|
|
18
20
|
console.log(JSON.stringify({ packageManager: pm, deps: results }, null, 2));
|
|
19
|
-
|
|
21
|
+
// Only required deps influence the exit code.
|
|
22
|
+
process.exit(missingRequired.length > 0 ? 1 : 0);
|
|
20
23
|
return;
|
|
21
24
|
}
|
|
22
25
|
console.log('System dependency check\n');
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
console.log(
|
|
26
|
+
const required = results.filter(r => r.severity === 'required');
|
|
27
|
+
const optional = results.filter(r => r.severity === 'optional');
|
|
28
|
+
if (required.length > 0) {
|
|
29
|
+
console.log('Required:');
|
|
30
|
+
for (const dep of required) {
|
|
31
|
+
const icon = dep.found ? '✓' : '✗';
|
|
32
|
+
const ver = dep.version ? ` (${dep.version})` : '';
|
|
33
|
+
console.log(` ${icon} ${dep.name}${ver}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (optional.length > 0) {
|
|
37
|
+
console.log('\nOptional:');
|
|
38
|
+
for (const dep of optional) {
|
|
39
|
+
// ⚠ for missing-but-needed-by-installed-packages, ○ for missing-but-not-needed (shouldn't appear in conditional mode)
|
|
40
|
+
const icon = dep.found ? '✓' : '⚠';
|
|
41
|
+
const ver = dep.version ? ` (${dep.version})` : '';
|
|
42
|
+
const requiredBy = dep.requiredBy && dep.requiredBy.length > 0
|
|
43
|
+
? ` — needed by ${dep.requiredBy.join(', ')}`
|
|
44
|
+
: '';
|
|
45
|
+
console.log(` ${icon} ${dep.name}${ver}${requiredBy}`);
|
|
46
|
+
}
|
|
27
47
|
}
|
|
28
48
|
console.log(`\nPackage manager: ${pm}`);
|
|
29
|
-
if (
|
|
49
|
+
if (allMissing.length === 0) {
|
|
30
50
|
console.log('\nAll dependencies found.');
|
|
31
51
|
return;
|
|
32
52
|
}
|
|
33
|
-
|
|
34
|
-
|
|
53
|
+
if (missingRequired.length > 0) {
|
|
54
|
+
console.log(`\nMissing required: ${missingRequired.map(d => d.name).join(', ')}`);
|
|
55
|
+
}
|
|
56
|
+
if (missingOptional.length > 0) {
|
|
57
|
+
console.log(`Missing optional: ${missingOptional.map(d => d.name).join(', ')}`);
|
|
58
|
+
}
|
|
59
|
+
const cmd = buildInstallCommand(pm, allMissing);
|
|
35
60
|
if (cmd) {
|
|
36
|
-
console.log(`\nTo install
|
|
61
|
+
console.log(`\nTo install:\n ${cmd}`);
|
|
37
62
|
}
|
|
38
63
|
else {
|
|
39
64
|
console.log('\nNo install command available for your package manager. Install manually.');
|
|
40
65
|
}
|
|
41
|
-
|
|
66
|
+
// Exit non-zero ONLY if a required dependency is missing.
|
|
67
|
+
// Optional deps that are missing but needed by an installed @gjsify/*
|
|
68
|
+
// package generate a warning but keep exit code 0 — the user can still
|
|
69
|
+
// build/run code paths that don't touch the optional library.
|
|
70
|
+
process.exit(missingRequired.length > 0 ? 1 : 0);
|
|
42
71
|
},
|
|
43
72
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createProject } from '@gjsify/create-app';
|
|
2
|
+
export const createCommand = {
|
|
3
|
+
command: 'create [project-name]',
|
|
4
|
+
description: 'Scaffold a new Gjsify project in a new directory.',
|
|
5
|
+
builder: (yargs) => {
|
|
6
|
+
return yargs.positional('project-name', {
|
|
7
|
+
describe: 'Name of the project directory to create',
|
|
8
|
+
type: 'string',
|
|
9
|
+
default: 'my-gjs-app',
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
handler: async (args) => {
|
|
13
|
+
await createProject(args['project-name']);
|
|
14
|
+
},
|
|
15
|
+
};
|
package/lib/commands/index.d.ts
CHANGED
package/lib/commands/index.js
CHANGED
package/lib/commands/showcase.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { discoverShowcases, findShowcase } from '../utils/discover-showcases.js';
|
|
2
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]',
|
|
6
|
-
description: 'List or run built-in gjsify
|
|
6
|
+
description: 'List or run built-in gjsify showcase applications.',
|
|
7
7
|
builder: (yargs) => {
|
|
8
8
|
return yargs
|
|
9
9
|
.positional('name', {
|
|
10
|
-
description: '
|
|
10
|
+
description: 'Showcase name to run (omit to list all)',
|
|
11
11
|
type: 'string',
|
|
12
12
|
})
|
|
13
13
|
.option('json', {
|
|
@@ -16,7 +16,7 @@ export const showcaseCommand = {
|
|
|
16
16
|
default: false,
|
|
17
17
|
})
|
|
18
18
|
.option('list', {
|
|
19
|
-
description: 'List available
|
|
19
|
+
description: 'List available showcases',
|
|
20
20
|
type: 'boolean',
|
|
21
21
|
default: false,
|
|
22
22
|
});
|
|
@@ -24,65 +24,67 @@ export const showcaseCommand = {
|
|
|
24
24
|
handler: async (args) => {
|
|
25
25
|
// List mode: no name given, or --list flag
|
|
26
26
|
if (!args.name || args.list) {
|
|
27
|
-
const
|
|
27
|
+
const showcases = discoverShowcases();
|
|
28
28
|
if (args.json) {
|
|
29
|
-
console.log(JSON.stringify(
|
|
29
|
+
console.log(JSON.stringify(showcases, null, 2));
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
if (
|
|
33
|
-
console.log('No
|
|
32
|
+
if (showcases.length === 0) {
|
|
33
|
+
console.log('No showcases found. Showcase packages may not be installed.');
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
// Group by category
|
|
37
37
|
const grouped = new Map();
|
|
38
|
-
for (const
|
|
39
|
-
const list = grouped.get(
|
|
40
|
-
list.push(
|
|
41
|
-
grouped.set(
|
|
38
|
+
for (const sc of showcases) {
|
|
39
|
+
const list = grouped.get(sc.category) ?? [];
|
|
40
|
+
list.push(sc);
|
|
41
|
+
grouped.set(sc.category, list);
|
|
42
42
|
}
|
|
43
|
-
console.log('Available gjsify
|
|
43
|
+
console.log('Available gjsify showcases:\n');
|
|
44
44
|
for (const [category, list] of grouped) {
|
|
45
45
|
console.log(` ${category.toUpperCase()}:`);
|
|
46
46
|
const maxNameLen = Math.max(...list.map(e => e.name.length));
|
|
47
|
-
for (const
|
|
48
|
-
const pad = ' '.repeat(maxNameLen -
|
|
49
|
-
const desc =
|
|
50
|
-
console.log(` ${
|
|
47
|
+
for (const sc of list) {
|
|
48
|
+
const pad = ' '.repeat(maxNameLen - sc.name.length + 2);
|
|
49
|
+
const desc = sc.description ? `${pad}${sc.description}` : '';
|
|
50
|
+
console.log(` ${sc.name}${desc}`);
|
|
51
51
|
}
|
|
52
52
|
console.log('');
|
|
53
53
|
}
|
|
54
|
-
console.log('Run
|
|
54
|
+
console.log('Run a showcase: gjsify showcase <name>');
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
// Run mode: find the
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
60
|
-
console.error(`Unknown
|
|
61
|
-
console.error('Run "gjsify showcase" to list available
|
|
57
|
+
// Run mode: find the showcase
|
|
58
|
+
const showcase = findShowcase(args.name);
|
|
59
|
+
if (!showcase) {
|
|
60
|
+
console.error(`Unknown showcase: "${args.name}"`);
|
|
61
|
+
console.error('Run "gjsify showcase" to list available showcases.');
|
|
62
62
|
process.exit(1);
|
|
63
63
|
}
|
|
64
|
-
// System dependency check before running — only check what this
|
|
65
|
-
// All
|
|
64
|
+
// System dependency check before running — only check what this showcase needs.
|
|
65
|
+
// All showcases need GJS; WebGL showcases additionally need gwebgl prebuilds.
|
|
66
66
|
const results = runMinimalChecks();
|
|
67
|
-
const needsWebgl =
|
|
67
|
+
const needsWebgl = showcase.packageName.includes('webgl') || showcase.packageName.includes('three');
|
|
68
68
|
if (needsWebgl) {
|
|
69
69
|
results.push(checkGwebgl(process.cwd()));
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
// Hard-fail only on missing REQUIRED deps (gjs, gwebgl is required if needsWebgl).
|
|
72
|
+
// For showcase, gwebgl is treated as required because the bundle won't run without it.
|
|
73
|
+
const missingHard = results.filter(r => !r.found && (r.severity === 'required' || r.id === 'gwebgl'));
|
|
74
|
+
if (missingHard.length > 0) {
|
|
73
75
|
console.error('Missing system dependencies:\n');
|
|
74
|
-
for (const dep of
|
|
76
|
+
for (const dep of missingHard) {
|
|
75
77
|
console.error(` ✗ ${dep.name}`);
|
|
76
78
|
}
|
|
77
79
|
const pm = detectPackageManager();
|
|
78
|
-
const cmd = buildInstallCommand(pm,
|
|
80
|
+
const cmd = buildInstallCommand(pm, missingHard);
|
|
79
81
|
if (cmd) {
|
|
80
82
|
console.error(`\nInstall with:\n ${cmd}`);
|
|
81
83
|
}
|
|
82
84
|
process.exit(1);
|
|
83
85
|
}
|
|
84
|
-
// Run the
|
|
85
|
-
console.log(`Running
|
|
86
|
-
await runGjsBundle(
|
|
86
|
+
// Run the showcase via shared GJS runner
|
|
87
|
+
console.log(`Running showcase: ${showcase.name}\n`);
|
|
88
|
+
await runGjsBundle(showcase.bundlePath);
|
|
87
89
|
},
|
|
88
90
|
};
|
package/lib/config.js
CHANGED
|
@@ -69,6 +69,8 @@ export class Config {
|
|
|
69
69
|
configData.exclude = cliArgs.exclude || [];
|
|
70
70
|
if (cliArgs.consoleShim !== undefined)
|
|
71
71
|
configData.consoleShim = cliArgs.consoleShim;
|
|
72
|
+
if (cliArgs.globals !== undefined)
|
|
73
|
+
configData.globals = cliArgs.globals;
|
|
72
74
|
merge(configData.library ??= {}, pkg, configData.library);
|
|
73
75
|
merge(configData.typescript ??= {}, tsConfig, configData.typescript);
|
|
74
76
|
merge(configData.esbuild ??= {}, {
|
package/lib/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import yargs from 'yargs';
|
|
3
3
|
import { hideBin } from 'yargs/helpers';
|
|
4
|
-
import { buildCommand as build, runCommand as run, infoCommand as info, checkCommand as check, showcaseCommand as showcase } from './commands/index.js';
|
|
4
|
+
import { buildCommand as build, runCommand as run, infoCommand as info, checkCommand as check, showcaseCommand as showcase, createCommand as create } from './commands/index.js';
|
|
5
5
|
import { APP_NAME } from './constants.js';
|
|
6
6
|
void yargs(hideBin(process.argv))
|
|
7
7
|
.scriptName(APP_NAME)
|
|
8
8
|
.strict()
|
|
9
9
|
// .usage(Config.usage)
|
|
10
|
+
.command(create.command, create.description, create.builder, create.handler)
|
|
10
11
|
.command(build.command, build.description, build.builder, build.handler)
|
|
11
12
|
.command(run.command, run.description, run.builder, run.handler)
|
|
12
13
|
.command(info.command, info.description, info.builder, info.handler)
|
|
@@ -47,4 +47,11 @@ export interface CliBuildOptions {
|
|
|
47
47
|
* Use --no-console-shim to disable. Only applies to GJS app builds. Default: true.
|
|
48
48
|
*/
|
|
49
49
|
consoleShim?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Comma-separated list of global identifiers your code needs (e.g.
|
|
52
|
+
* `"fetch,Buffer,process,URL,crypto"`). Each identifier is mapped to the
|
|
53
|
+
* corresponding `@gjsify/<pkg>/register` module and injected into the
|
|
54
|
+
* bundle. Only applies to GJS app builds.
|
|
55
|
+
*/
|
|
56
|
+
globals?: string;
|
|
50
57
|
}
|
|
@@ -13,4 +13,9 @@ export interface ConfigData {
|
|
|
13
13
|
* Only applies to GJS app builds. Default: true.
|
|
14
14
|
*/
|
|
15
15
|
consoleShim?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Comma-separated list of global identifiers to register in the bundle.
|
|
18
|
+
* See CliBuildOptions for format.
|
|
19
|
+
*/
|
|
20
|
+
globals?: string;
|
|
16
21
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type DepSeverity = 'required' | 'optional';
|
|
1
2
|
export interface DepCheck {
|
|
2
3
|
/** Stable key used for install command lookup, e.g. "gjs" */
|
|
3
4
|
id: string;
|
|
@@ -6,19 +7,30 @@ export interface DepCheck {
|
|
|
6
7
|
found: boolean;
|
|
7
8
|
/** Version string when found, e.g. "1.86.0" */
|
|
8
9
|
version?: string;
|
|
10
|
+
/** required = exit 1 if missing, optional = warn only */
|
|
11
|
+
severity: DepSeverity;
|
|
12
|
+
/** For optional deps: which @gjsify/* packages need this lib */
|
|
13
|
+
requiredBy?: string[];
|
|
9
14
|
}
|
|
10
15
|
export type PackageManager = 'apt' | 'dnf' | 'pacman' | 'zypper' | 'apk' | 'unknown';
|
|
11
16
|
export declare function detectPackageManager(): PackageManager;
|
|
12
17
|
/**
|
|
13
18
|
* Run all dependency checks. Used by `gjsify check` to show full system status.
|
|
19
|
+
*
|
|
20
|
+
* Required deps (gjs, gtk4, libsoup3, libadwaita, gobject-introspection,
|
|
21
|
+
* blueprint-compiler, pkg-config, meson) are always checked.
|
|
22
|
+
*
|
|
23
|
+
* Optional deps are checked conditionally based on which @gjsify/* packages
|
|
24
|
+
* the project (resolved from cwd) actually consumes. If no project context
|
|
25
|
+
* is available, all optional deps are checked.
|
|
14
26
|
*/
|
|
15
27
|
export declare function runAllChecks(cwd: string): DepCheck[];
|
|
16
28
|
/**
|
|
17
|
-
* Minimal checks needed to run any GJS example (GJS
|
|
29
|
+
* Minimal checks needed to run any GJS example (Node + GJS binaries only).
|
|
18
30
|
* Used by `gjsify showcase` for examples that have no native deps.
|
|
19
31
|
*/
|
|
20
32
|
export declare function runMinimalChecks(): DepCheck[];
|
|
21
|
-
/** Check gwebgl npm package (project first, CLI fallback). */
|
|
33
|
+
/** Check gwebgl npm package (project first, CLI fallback). Optional — only needed by @gjsify/webgl users. */
|
|
22
34
|
export declare function checkGwebgl(cwd: string): DepCheck;
|
|
23
35
|
/**
|
|
24
36
|
* Build a suggested install command for missing dependencies.
|