@gjsify/cli 0.3.21 → 0.4.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.
- package/dist/cli.gjs.mjs +798 -0
- package/lib/actions/build.js +4 -17
- package/lib/bundler-pick.d.ts +79 -0
- package/lib/bundler-pick.js +428 -0
- package/lib/commands/foreach.d.ts +16 -0
- package/lib/commands/foreach.js +268 -0
- package/lib/commands/index.d.ts +2 -0
- package/lib/commands/index.js +2 -0
- package/lib/commands/install.d.ts +1 -0
- package/lib/commands/install.js +222 -26
- package/lib/commands/run.d.ts +1 -1
- package/lib/commands/run.js +133 -20
- package/lib/commands/workspace.d.ts +8 -0
- package/lib/commands/workspace.js +69 -0
- package/lib/config.js +12 -1
- package/lib/index.js +11 -3
- package/lib/types/config-data.d.ts +10 -1
- package/lib/utils/install-backend-native.d.ts +5 -1
- package/lib/utils/install-backend-native.js +88 -11
- package/lib/utils/install-backend.d.ts +11 -1
- package/lib/utils/install-backend.js +4 -2
- package/lib/utils/pkg-json-edit.d.ts +47 -0
- package/lib/utils/pkg-json-edit.js +108 -0
- package/package.json +36 -12
- package/src/actions/build.ts +0 -431
- package/src/actions/index.ts +0 -1
- package/src/commands/build.ts +0 -146
- package/src/commands/check.ts +0 -87
- package/src/commands/create.ts +0 -63
- package/src/commands/dlx.ts +0 -195
- package/src/commands/flatpak/build.ts +0 -225
- package/src/commands/flatpak/ci.ts +0 -173
- package/src/commands/flatpak/deps.ts +0 -120
- package/src/commands/flatpak/index.ts +0 -53
- package/src/commands/flatpak/init.ts +0 -191
- package/src/commands/flatpak/utils.ts +0 -76
- package/src/commands/gettext.ts +0 -258
- package/src/commands/gresource.ts +0 -97
- package/src/commands/gsettings.ts +0 -87
- package/src/commands/index.ts +0 -12
- package/src/commands/info.ts +0 -70
- package/src/commands/install.ts +0 -195
- package/src/commands/run.ts +0 -33
- package/src/commands/showcase.ts +0 -149
- package/src/config.ts +0 -304
- package/src/constants.ts +0 -1
- package/src/index.ts +0 -37
- package/src/types/cli-build-options.ts +0 -100
- package/src/types/command.ts +0 -10
- package/src/types/config-data-library.ts +0 -5
- package/src/types/config-data-typescript.ts +0 -6
- package/src/types/config-data.ts +0 -225
- package/src/types/cosmiconfig-result.ts +0 -5
- package/src/types/index.ts +0 -6
- package/src/utils/check-system-deps.ts +0 -480
- package/src/utils/detect-native-packages.ts +0 -153
- package/src/utils/discover-showcases.ts +0 -75
- package/src/utils/dlx-cache.ts +0 -135
- package/src/utils/install-backend-native.ts +0 -363
- package/src/utils/install-backend.ts +0 -88
- package/src/utils/install-global.ts +0 -182
- package/src/utils/normalize-bundler-options.ts +0 -129
- package/src/utils/parse-spec.ts +0 -48
- package/src/utils/resolve-gjs-entry.ts +0 -96
- package/src/utils/resolve-plugin-by-name.ts +0 -106
- package/src/utils/run-gjs.ts +0 -90
- package/tsconfig.json +0 -16
package/src/commands/gettext.ts
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { mkdir, readFile, readdir, stat, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { join, resolve } from 'node:path';
|
|
4
|
-
import { promisify } from 'node:util';
|
|
5
|
-
import type { Command } from '../types/index.js';
|
|
6
|
-
|
|
7
|
-
const execFileAsync = promisify(execFile);
|
|
8
|
-
|
|
9
|
-
type GettextFormat = 'mo' | 'xml' | 'desktop' | 'json';
|
|
10
|
-
|
|
11
|
-
interface GettextOptions {
|
|
12
|
-
poDir: string;
|
|
13
|
-
outDir: string;
|
|
14
|
-
domain: string;
|
|
15
|
-
format?: GettextFormat;
|
|
16
|
-
metainfo?: string;
|
|
17
|
-
filename?: string;
|
|
18
|
-
removeXmlComments?: boolean;
|
|
19
|
-
verbose?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function listLanguages(poDir: string): Promise<string[]> {
|
|
23
|
-
const entries = await readdir(poDir);
|
|
24
|
-
return entries
|
|
25
|
-
.filter((name) => name.endsWith('.po') && !name.startsWith('.'))
|
|
26
|
-
.map((name) => name.slice(0, -3))
|
|
27
|
-
.sort();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function stripXmlComments(source: string): string {
|
|
31
|
-
return source.replace(/<!--[\s\S]*?-->/g, '');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async function ensureDir(path: string): Promise<void> {
|
|
35
|
-
await mkdir(path, { recursive: true });
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async function fileExists(path: string): Promise<boolean> {
|
|
39
|
-
try {
|
|
40
|
-
await stat(path);
|
|
41
|
-
return true;
|
|
42
|
-
} catch {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function compileBulkXml(opts: {
|
|
48
|
-
poDir: string;
|
|
49
|
-
outDir: string;
|
|
50
|
-
domain: string;
|
|
51
|
-
template: string;
|
|
52
|
-
filename: string;
|
|
53
|
-
removeXmlComments: boolean;
|
|
54
|
-
verbose: boolean;
|
|
55
|
-
}): Promise<void> {
|
|
56
|
-
const outputFile = join(opts.outDir, opts.filename);
|
|
57
|
-
await ensureDir(opts.outDir);
|
|
58
|
-
|
|
59
|
-
const args = [
|
|
60
|
-
`--output-file=${outputFile}`,
|
|
61
|
-
'--xml',
|
|
62
|
-
`--template=${opts.template}`,
|
|
63
|
-
'-d',
|
|
64
|
-
opts.poDir,
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
if (opts.verbose) {
|
|
68
|
-
console.log(`[gjsify gettext] msgfmt ${args.join(' ')}`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
await execFileAsync('msgfmt', args);
|
|
72
|
-
|
|
73
|
-
if (opts.removeXmlComments) {
|
|
74
|
-
const content = await readFile(outputFile, 'utf-8');
|
|
75
|
-
await writeFile(outputFile, stripXmlComments(content));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (opts.verbose) {
|
|
79
|
-
console.log(`[gjsify gettext] wrote ${outputFile}`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async function compilePerLanguage(opts: {
|
|
84
|
-
poDir: string;
|
|
85
|
-
outDir: string;
|
|
86
|
-
domain: string;
|
|
87
|
-
format: GettextFormat;
|
|
88
|
-
filename: string;
|
|
89
|
-
verbose: boolean;
|
|
90
|
-
}): Promise<void> {
|
|
91
|
-
const languages = await listLanguages(opts.poDir);
|
|
92
|
-
if (languages.length === 0) {
|
|
93
|
-
console.warn(`[gjsify gettext] no .po files found in ${opts.poDir}`);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
for (const lang of languages) {
|
|
98
|
-
const poFile = join(opts.poDir, `${lang}.po`);
|
|
99
|
-
const langDir =
|
|
100
|
-
opts.format === 'mo'
|
|
101
|
-
? join(opts.outDir, lang, 'LC_MESSAGES')
|
|
102
|
-
: join(opts.outDir, lang);
|
|
103
|
-
await ensureDir(langDir);
|
|
104
|
-
const outputFile = join(langDir, opts.filename);
|
|
105
|
-
|
|
106
|
-
// msgfmt produces the binary .mo format by default — there is no
|
|
107
|
-
// `--mo` flag (only --xml, --desktop, --properties-output, ...).
|
|
108
|
-
const args = [`--output-file=${outputFile}`];
|
|
109
|
-
if (opts.format !== 'mo') {
|
|
110
|
-
args.push(`--${opts.format}`);
|
|
111
|
-
}
|
|
112
|
-
args.push(poFile);
|
|
113
|
-
|
|
114
|
-
if (opts.verbose) {
|
|
115
|
-
console.log(`[gjsify gettext] msgfmt ${args.join(' ')}`);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
await execFileAsync('msgfmt', args);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (opts.verbose) {
|
|
122
|
-
console.log(
|
|
123
|
-
`[gjsify gettext] compiled ${languages.length} language(s) into ${opts.outDir}`,
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function defaultFilename(domain: string, format: GettextFormat, metainfoTemplate?: string): string {
|
|
129
|
-
switch (format) {
|
|
130
|
-
case 'mo':
|
|
131
|
-
return `${domain}.mo`;
|
|
132
|
-
case 'json':
|
|
133
|
-
return `${domain}.json`;
|
|
134
|
-
case 'desktop':
|
|
135
|
-
return `${domain}.desktop`;
|
|
136
|
-
case 'xml': {
|
|
137
|
-
// Mirror the template filename but without the trailing `.in` (convention for
|
|
138
|
-
// pre-processed metainfo templates: `org.foo.Bar.metainfo.xml.in`).
|
|
139
|
-
if (metainfoTemplate) {
|
|
140
|
-
const base = metainfoTemplate.replace(/\.in$/, '');
|
|
141
|
-
const slash = base.lastIndexOf('/');
|
|
142
|
-
return slash >= 0 ? base.slice(slash + 1) : base;
|
|
143
|
-
}
|
|
144
|
-
return `${domain}.xml`;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export const gettextCommand: Command<any, GettextOptions> = {
|
|
150
|
-
command: 'gettext <poDir> <outDir>',
|
|
151
|
-
description:
|
|
152
|
-
'Compile gettext .po files to .mo (per-language locale tree) or substitute a metainfo template via msgfmt --xml.',
|
|
153
|
-
builder: (yargs) => {
|
|
154
|
-
return yargs
|
|
155
|
-
.positional('poDir', {
|
|
156
|
-
description: 'Directory containing <lang>.po files',
|
|
157
|
-
type: 'string',
|
|
158
|
-
normalize: true,
|
|
159
|
-
demandOption: true,
|
|
160
|
-
})
|
|
161
|
-
.positional('outDir', {
|
|
162
|
-
description:
|
|
163
|
-
'Output directory (locale tree for --format=mo, plain dir for xml/desktop/json)',
|
|
164
|
-
type: 'string',
|
|
165
|
-
normalize: true,
|
|
166
|
-
demandOption: true,
|
|
167
|
-
})
|
|
168
|
-
.option('domain', {
|
|
169
|
-
description: 'Text domain / application ID (e.g. `org.pixelrpg.maker`)',
|
|
170
|
-
type: 'string',
|
|
171
|
-
normalize: true,
|
|
172
|
-
demandOption: true,
|
|
173
|
-
})
|
|
174
|
-
.option('format', {
|
|
175
|
-
description: 'Output format',
|
|
176
|
-
type: 'string',
|
|
177
|
-
choices: ['mo', 'xml', 'desktop', 'json'] as const,
|
|
178
|
-
default: 'mo' as const,
|
|
179
|
-
})
|
|
180
|
-
.option('metainfo', {
|
|
181
|
-
description:
|
|
182
|
-
'For --format=xml: path to the template (`.metainfo.xml.in`) used as msgfmt --template',
|
|
183
|
-
type: 'string',
|
|
184
|
-
normalize: true,
|
|
185
|
-
})
|
|
186
|
-
.option('filename', {
|
|
187
|
-
description: 'Override the output filename (defaults to <domain>.<ext>)',
|
|
188
|
-
type: 'string',
|
|
189
|
-
normalize: true,
|
|
190
|
-
})
|
|
191
|
-
.option('remove-xml-comments', {
|
|
192
|
-
description: 'For --format=xml: strip XML comments from the compiled output',
|
|
193
|
-
type: 'boolean',
|
|
194
|
-
default: true,
|
|
195
|
-
})
|
|
196
|
-
.option('verbose', {
|
|
197
|
-
description: 'Print each msgfmt invocation',
|
|
198
|
-
type: 'boolean',
|
|
199
|
-
default: false,
|
|
200
|
-
});
|
|
201
|
-
},
|
|
202
|
-
handler: async (args) => {
|
|
203
|
-
const poDir = resolve(args.poDir as string);
|
|
204
|
-
const outDir = resolve(args.outDir as string);
|
|
205
|
-
const domain = args.domain as string;
|
|
206
|
-
const format = (args.format as GettextFormat | undefined) ?? 'mo';
|
|
207
|
-
const metainfo = args.metainfo ? resolve(args.metainfo as string) : undefined;
|
|
208
|
-
const filename = args.filename ?? defaultFilename(domain, format, metainfo);
|
|
209
|
-
const verbose = !!args.verbose;
|
|
210
|
-
const removeXmlComments = !!args['remove-xml-comments'];
|
|
211
|
-
|
|
212
|
-
if (!(await fileExists(poDir))) {
|
|
213
|
-
console.error(`[gjsify gettext] PO directory does not exist: ${poDir}`);
|
|
214
|
-
process.exitCode = 1;
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
try {
|
|
219
|
-
if (format === 'xml' && metainfo) {
|
|
220
|
-
await compileBulkXml({
|
|
221
|
-
poDir,
|
|
222
|
-
outDir,
|
|
223
|
-
domain,
|
|
224
|
-
template: metainfo,
|
|
225
|
-
filename,
|
|
226
|
-
removeXmlComments,
|
|
227
|
-
verbose,
|
|
228
|
-
});
|
|
229
|
-
} else {
|
|
230
|
-
if (format === 'xml') {
|
|
231
|
-
console.warn(
|
|
232
|
-
'[gjsify gettext] --format=xml without --metainfo: falling back to per-language XML files',
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
await compilePerLanguage({
|
|
236
|
-
poDir,
|
|
237
|
-
outDir,
|
|
238
|
-
domain,
|
|
239
|
-
format,
|
|
240
|
-
filename,
|
|
241
|
-
verbose,
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
} catch (err: any) {
|
|
245
|
-
if (err?.code === 'ENOENT') {
|
|
246
|
-
console.error(
|
|
247
|
-
'[gjsify gettext] msgfmt not found. Install it via your distro (package: gettext).',
|
|
248
|
-
);
|
|
249
|
-
} else {
|
|
250
|
-
if (err?.stderr) process.stderr.write(err.stderr);
|
|
251
|
-
console.error(
|
|
252
|
-
`[gjsify gettext] msgfmt failed${err?.code !== undefined ? ` (exit ${err.code})` : ''}`,
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
process.exitCode = typeof err?.code === 'number' ? err.code : 1;
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { mkdir } from 'node:fs/promises';
|
|
3
|
-
import { basename, dirname, extname, resolve } from 'node:path';
|
|
4
|
-
import { promisify } from 'node:util';
|
|
5
|
-
import type { Command } from '../types/index.js';
|
|
6
|
-
|
|
7
|
-
const execFileAsync = promisify(execFile);
|
|
8
|
-
|
|
9
|
-
interface GResourceOptions {
|
|
10
|
-
xml: string;
|
|
11
|
-
sourcedir?: string;
|
|
12
|
-
target?: string;
|
|
13
|
-
verbose?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Derive a default `.gresource` target path from the XML descriptor.
|
|
18
|
-
* `foo.gresource.xml` → `foo.gresource` in the same directory.
|
|
19
|
-
*/
|
|
20
|
-
function defaultTargetFor(xmlPath: string): string {
|
|
21
|
-
const ext = extname(xmlPath);
|
|
22
|
-
const stem = basename(xmlPath, ext);
|
|
23
|
-
return resolve(dirname(xmlPath), stem);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const gresourceCommand: Command<any, GResourceOptions> = {
|
|
27
|
-
command: 'gresource <xml>',
|
|
28
|
-
description:
|
|
29
|
-
'Compile a GResource XML descriptor into a binary .gresource bundle (wraps `glib-compile-resources`).',
|
|
30
|
-
builder: (yargs) => {
|
|
31
|
-
return yargs
|
|
32
|
-
.positional('xml', {
|
|
33
|
-
description: 'Path to the .gresource.xml descriptor',
|
|
34
|
-
type: 'string',
|
|
35
|
-
normalize: true,
|
|
36
|
-
demandOption: true,
|
|
37
|
-
})
|
|
38
|
-
.option('sourcedir', {
|
|
39
|
-
description: 'Directory containing the resource files referenced by <xml>',
|
|
40
|
-
type: 'string',
|
|
41
|
-
normalize: true,
|
|
42
|
-
})
|
|
43
|
-
.option('target', {
|
|
44
|
-
alias: 't',
|
|
45
|
-
description: 'Output .gresource file (default: <xml-without-.xml> next to <xml>)',
|
|
46
|
-
type: 'string',
|
|
47
|
-
normalize: true,
|
|
48
|
-
})
|
|
49
|
-
.option('verbose', {
|
|
50
|
-
description: 'Print the underlying glib-compile-resources invocation',
|
|
51
|
-
type: 'boolean',
|
|
52
|
-
default: false,
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
handler: async (args) => {
|
|
56
|
-
const xmlPath = resolve(args.xml as string);
|
|
57
|
-
const target = args.target ? resolve(args.target as string) : defaultTargetFor(xmlPath);
|
|
58
|
-
const sourcedir = args.sourcedir
|
|
59
|
-
? resolve(args.sourcedir as string)
|
|
60
|
-
: dirname(xmlPath);
|
|
61
|
-
|
|
62
|
-
const cmdArgs = [
|
|
63
|
-
`--sourcedir=${sourcedir}`,
|
|
64
|
-
`--target=${target}`,
|
|
65
|
-
xmlPath,
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
if (args.verbose) {
|
|
69
|
-
console.log(`[gjsify gresource] glib-compile-resources ${cmdArgs.join(' ')}`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Ensure the target directory exists — glib-compile-resources writes
|
|
73
|
-
// a temporary file next to the target and fails with ENOENT otherwise.
|
|
74
|
-
await mkdir(dirname(target), { recursive: true });
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
const { stdout, stderr } = await execFileAsync('glib-compile-resources', cmdArgs);
|
|
78
|
-
if (stdout) process.stdout.write(stdout);
|
|
79
|
-
if (stderr) process.stderr.write(stderr);
|
|
80
|
-
if (args.verbose) {
|
|
81
|
-
console.log(`[gjsify gresource] wrote ${target}`);
|
|
82
|
-
}
|
|
83
|
-
} catch (err: any) {
|
|
84
|
-
if (err?.code === 'ENOENT') {
|
|
85
|
-
console.error(
|
|
86
|
-
'[gjsify gresource] glib-compile-resources not found. Install it via your distro (package: glib2-devel / libglib2.0-dev).',
|
|
87
|
-
);
|
|
88
|
-
} else {
|
|
89
|
-
if (err?.stderr) process.stderr.write(err.stderr);
|
|
90
|
-
console.error(
|
|
91
|
-
`[gjsify gresource] glib-compile-resources failed${err?.code !== undefined ? ` (exit ${err.code})` : ''}`,
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
process.exitCode = typeof err?.code === 'number' ? err.code : 1;
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { mkdir } from 'node:fs/promises';
|
|
3
|
-
import { resolve } from 'node:path';
|
|
4
|
-
import { promisify } from 'node:util';
|
|
5
|
-
import type { Command } from '../types/index.js';
|
|
6
|
-
|
|
7
|
-
const execFileAsync = promisify(execFile);
|
|
8
|
-
|
|
9
|
-
interface GSettingsOptions {
|
|
10
|
-
schemadir: string;
|
|
11
|
-
targetdir?: string;
|
|
12
|
-
strict?: boolean;
|
|
13
|
-
verbose?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const gsettingsCommand: Command<any, GSettingsOptions> = {
|
|
17
|
-
command: 'gsettings <schemadir>',
|
|
18
|
-
description:
|
|
19
|
-
'Compile GSettings schema XML files into a binary gschemas.compiled (wraps `glib-compile-schemas`).',
|
|
20
|
-
builder: (yargs) => {
|
|
21
|
-
return yargs
|
|
22
|
-
.positional('schemadir', {
|
|
23
|
-
description: 'Directory containing *.gschema.xml descriptors',
|
|
24
|
-
type: 'string',
|
|
25
|
-
normalize: true,
|
|
26
|
-
demandOption: true,
|
|
27
|
-
})
|
|
28
|
-
.option('targetdir', {
|
|
29
|
-
alias: 't',
|
|
30
|
-
description:
|
|
31
|
-
'Directory to write gschemas.compiled (default: <schemadir>)',
|
|
32
|
-
type: 'string',
|
|
33
|
-
normalize: true,
|
|
34
|
-
})
|
|
35
|
-
.option('strict', {
|
|
36
|
-
description:
|
|
37
|
-
'Abort on any schema warning (passes --strict to glib-compile-schemas)',
|
|
38
|
-
type: 'boolean',
|
|
39
|
-
default: true,
|
|
40
|
-
})
|
|
41
|
-
.option('verbose', {
|
|
42
|
-
description: 'Print the underlying glib-compile-schemas invocation',
|
|
43
|
-
type: 'boolean',
|
|
44
|
-
default: false,
|
|
45
|
-
});
|
|
46
|
-
},
|
|
47
|
-
handler: async (args) => {
|
|
48
|
-
const schemadir = resolve(args.schemadir as string);
|
|
49
|
-
const targetdir = args.targetdir
|
|
50
|
-
? resolve(args.targetdir as string)
|
|
51
|
-
: schemadir;
|
|
52
|
-
|
|
53
|
-
const cmdArgs: string[] = [];
|
|
54
|
-
if (args.strict) cmdArgs.push('--strict');
|
|
55
|
-
cmdArgs.push(`--targetdir=${targetdir}`);
|
|
56
|
-
cmdArgs.push(schemadir);
|
|
57
|
-
|
|
58
|
-
if (args.verbose) {
|
|
59
|
-
console.log(`[gjsify gsettings] glib-compile-schemas ${cmdArgs.join(' ')}`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// glib-compile-schemas writes a temporary file in `targetdir` before
|
|
63
|
-
// renaming to gschemas.compiled — fails with ENOENT if missing.
|
|
64
|
-
await mkdir(targetdir, { recursive: true });
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
const { stdout, stderr } = await execFileAsync('glib-compile-schemas', cmdArgs);
|
|
68
|
-
if (stdout) process.stdout.write(stdout);
|
|
69
|
-
if (stderr) process.stderr.write(stderr);
|
|
70
|
-
if (args.verbose) {
|
|
71
|
-
console.log(`[gjsify gsettings] wrote ${targetdir}/gschemas.compiled`);
|
|
72
|
-
}
|
|
73
|
-
} catch (err: any) {
|
|
74
|
-
if (err?.code === 'ENOENT') {
|
|
75
|
-
console.error(
|
|
76
|
-
'[gjsify gsettings] glib-compile-schemas not found. Install it via your distro (package: glib2-devel / libglib2.0-dev).',
|
|
77
|
-
);
|
|
78
|
-
} else {
|
|
79
|
-
if (err?.stderr) process.stderr.write(err.stderr);
|
|
80
|
-
console.error(
|
|
81
|
-
`[gjsify gsettings] glib-compile-schemas failed${err?.code !== undefined ? ` (exit ${err.code})` : ''}`,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
process.exitCode = typeof err?.code === 'number' ? err.code : 1;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
};
|
package/src/commands/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from './build.js';
|
|
2
|
-
export * from './run.js';
|
|
3
|
-
export * from './info.js';
|
|
4
|
-
export * from './check.js';
|
|
5
|
-
export * from './showcase.js';
|
|
6
|
-
export * from './create.js';
|
|
7
|
-
export * from './gresource.js';
|
|
8
|
-
export * from './gettext.js';
|
|
9
|
-
export * from './gsettings.js';
|
|
10
|
-
export { flatpakCommand } from './flatpak/index.js';
|
|
11
|
-
export * from './dlx.js';
|
|
12
|
-
export * from './install.js';
|
package/src/commands/info.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
|
-
import type { Command } from '../types/index.js';
|
|
3
|
-
import { detectNativePackages, buildNativeEnv } from '../utils/detect-native-packages.js';
|
|
4
|
-
|
|
5
|
-
interface InfoOptions {
|
|
6
|
-
export: boolean;
|
|
7
|
-
file?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const infoCommand: Command<any, InfoOptions> = {
|
|
11
|
-
command: 'info [file]',
|
|
12
|
-
description: 'Show native gjsify packages detected in node_modules and the env vars needed to run a GJS bundle directly with gjs.',
|
|
13
|
-
builder: (yargs) => {
|
|
14
|
-
return yargs
|
|
15
|
-
.positional('file', {
|
|
16
|
-
description: 'Optional: the GJS bundle path to include in the example command (e.g. dist/gjs.js)',
|
|
17
|
-
type: 'string',
|
|
18
|
-
normalize: true,
|
|
19
|
-
})
|
|
20
|
-
.option('export', {
|
|
21
|
-
description: 'Output only shell export statements suitable for eval (eval $(gjsify info --export))',
|
|
22
|
-
type: 'boolean',
|
|
23
|
-
default: false,
|
|
24
|
-
});
|
|
25
|
-
},
|
|
26
|
-
handler: async (args) => {
|
|
27
|
-
const cwd = process.cwd();
|
|
28
|
-
const file = args.file ? resolve(args.file as string) : null;
|
|
29
|
-
const nativePackages = detectNativePackages(cwd);
|
|
30
|
-
const { LD_LIBRARY_PATH, GI_TYPELIB_PATH } = buildNativeEnv(nativePackages);
|
|
31
|
-
|
|
32
|
-
if (args.export) {
|
|
33
|
-
// Machine-readable output for eval
|
|
34
|
-
console.log(`export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"`);
|
|
35
|
-
console.log(`export GI_TYPELIB_PATH="${GI_TYPELIB_PATH}"`);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Human-readable output
|
|
40
|
-
if (nativePackages.length === 0) {
|
|
41
|
-
console.log('No native gjsify packages detected in node_modules.');
|
|
42
|
-
console.log('Native packages declare "gjsify": { "prebuilds": "<dir>" } in their package.json.');
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
console.log('Native packages detected:');
|
|
47
|
-
for (const pkg of nativePackages) {
|
|
48
|
-
console.log(` ${pkg.name} → ${pkg.prebuildsDir}`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
console.log('');
|
|
52
|
-
console.log('To run your app directly with gjs, set:');
|
|
53
|
-
console.log(` export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"`);
|
|
54
|
-
console.log(` export GI_TYPELIB_PATH="${GI_TYPELIB_PATH}"`);
|
|
55
|
-
|
|
56
|
-
if (file) {
|
|
57
|
-
console.log(` gjs -m ${file}`);
|
|
58
|
-
} else {
|
|
59
|
-
console.log(' gjs -m <your-bundle.js>');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
console.log('');
|
|
63
|
-
console.log('Or use gjsify run to handle this automatically:');
|
|
64
|
-
if (file) {
|
|
65
|
-
console.log(` gjsify run ${args.file}`);
|
|
66
|
-
} else {
|
|
67
|
-
console.log(' gjsify run <your-bundle.js>');
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
};
|