@gjsify/cli 0.4.28 → 0.4.30
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 +132 -132
- package/lib/actions/barrels-generate.js +1 -5
- package/lib/actions/build.d.ts +3 -3
- package/lib/actions/build.js +56 -64
- package/lib/bundler-pick.d.ts +3 -3
- package/lib/bundler-pick.js +5 -6
- package/lib/commands/build.d.ts +1 -1
- package/lib/commands/build.js +37 -31
- package/lib/commands/check.js +3 -3
- package/lib/commands/create.d.ts +1 -1
- package/lib/commands/dlx.d.ts +1 -1
- package/lib/commands/fix.js +33 -23
- package/lib/commands/flatpak/build.js +6 -2
- package/lib/commands/flatpak/check.js +9 -3
- package/lib/commands/flatpak/ci.js +1 -2
- package/lib/commands/flatpak/deps.js +1 -2
- package/lib/commands/flatpak/diff.js +2 -6
- package/lib/commands/flatpak/init.js +19 -19
- package/lib/commands/flatpak/release.js +2 -2
- package/lib/commands/flatpak/scaffold.js +3 -11
- package/lib/commands/flatpak/sync-flathub.js +5 -9
- package/lib/commands/flatpak/utils.js +1 -6
- package/lib/commands/foreach.d.ts +1 -1
- package/lib/commands/foreach.js +5 -14
- package/lib/commands/format.js +54 -41
- package/lib/commands/generate-installer.d.ts +1 -1
- package/lib/commands/gettext.d.ts +1 -1
- package/lib/commands/gettext.js +8 -15
- package/lib/commands/gresource.d.ts +1 -1
- package/lib/commands/gresource.js +8 -13
- package/lib/commands/gsettings.d.ts +1 -1
- package/lib/commands/gsettings.js +7 -8
- package/lib/commands/info.d.ts +1 -1
- package/lib/commands/install.d.ts +1 -1
- package/lib/commands/install.js +45 -13
- package/lib/commands/lint.d.ts +1 -1
- package/lib/commands/lint.js +22 -22
- package/lib/commands/pack.d.ts +1 -1
- package/lib/commands/pack.js +29 -17
- package/lib/commands/publish.d.ts +1 -1
- package/lib/commands/publish.js +17 -18
- package/lib/commands/run.d.ts +1 -1
- package/lib/commands/run.js +2 -6
- package/lib/commands/self-update.d.ts +1 -1
- package/lib/commands/self-update.js +1 -3
- package/lib/commands/showcase.d.ts +1 -1
- package/lib/commands/showcase.js +1 -1
- package/lib/commands/system-check.d.ts +1 -1
- package/lib/commands/system-check.js +8 -11
- package/lib/commands/test.js +12 -8
- package/lib/commands/uninstall.d.ts +1 -1
- package/lib/commands/uninstall.js +1 -3
- package/lib/commands/upgrade.d.ts +1 -1
- package/lib/commands/upgrade.js +109 -120
- package/lib/commands/workspace.d.ts +1 -1
- package/lib/commands/workspace.js +1 -3
- package/lib/config.js +18 -13
- package/lib/index.js +3 -1
- package/lib/templates/install.mjs.tmpl +20 -14
- package/lib/templates/oxfmtrc.tmpl +54 -0
- package/lib/templates/oxlintrc.json.tmpl +35 -0
- package/lib/types/command.d.ts +1 -1
- package/lib/types/config-data.d.ts +23 -13
- package/lib/types/cosmiconfig-result.d.ts +1 -1
- package/lib/utils/check-system-deps.js +10 -4
- package/lib/utils/detect-native-packages.js +1 -1
- package/lib/utils/dlx-cache.js +2 -7
- package/lib/utils/install-backend-native.d.ts +2 -2
- package/lib/utils/install-backend-native.js +112 -58
- package/lib/utils/install-backend.js +2 -1
- package/lib/utils/install-global.js +1 -3
- package/lib/utils/normalize-bundler-options.js +52 -17
- package/lib/utils/oxc-resolve.d.ts +63 -0
- package/lib/utils/oxc-resolve.js +264 -0
- package/lib/utils/pkg-json-edit.js +1 -6
- package/lib/utils/run-gjs.js +1 -4
- package/lib/utils/run-lifecycle-script.js +3 -7
- package/lib/utils/workspace-root.js +3 -1
- package/package.json +17 -17
- package/lib/templates/biome.json.tmpl +0 -79
- package/lib/utils/biome-resolve.d.ts +0 -47
- package/lib/utils/biome-resolve.js +0 -204
|
@@ -15,11 +15,7 @@
|
|
|
15
15
|
import { readdir, readFile, writeFile } from 'node:fs/promises';
|
|
16
16
|
import { basename, extname, join, resolve } from 'node:path';
|
|
17
17
|
export const DEFAULT_BARRELS_HEADER = '// Auto-generated by `gjsify barrels` — do not edit by hand.';
|
|
18
|
-
export const DEFAULT_BARRELS_EXCLUDES = [
|
|
19
|
-
'\\.test\\.',
|
|
20
|
-
'\\.spec\\.',
|
|
21
|
-
'\\.test-data\\.',
|
|
22
|
-
];
|
|
18
|
+
export const DEFAULT_BARRELS_EXCLUDES = ['\\.test\\.', '\\.spec\\.', '\\.test-data\\.'];
|
|
23
19
|
const SOURCE_FILE_RE = /\.(ts|tsx|mts|cts)$/;
|
|
24
20
|
/**
|
|
25
21
|
* Regenerate `index.ts` in every directory in `args.paths`.
|
package/lib/actions/build.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ConfigData } from
|
|
2
|
-
import type { App } from
|
|
3
|
-
import type { RolldownOutput } from
|
|
1
|
+
import type { ConfigData } from '../types/index.js';
|
|
2
|
+
import type { App } from '@gjsify/rolldown-plugin-gjsify';
|
|
3
|
+
import type { RolldownOutput } from 'rolldown';
|
|
4
4
|
export declare class BuildAction {
|
|
5
5
|
readonly configData: ConfigData;
|
|
6
6
|
constructor(configData?: ConfigData);
|
package/lib/actions/build.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { runBundle, runWatch, bundleToChunks } from
|
|
2
|
-
import { gjsifyPlugin, textLoaderPlugin, resolveShebangLine, NODE_SHEBANG } from
|
|
3
|
-
import { resolveUserPlugins } from
|
|
4
|
-
import { resolveGlobalsList, writeRegisterInjectFile, detectAutoGlobals
|
|
5
|
-
import { pnpPlugin } from
|
|
6
|
-
import { dirname, extname } from
|
|
7
|
-
import { chmod, readFile, writeFile } from
|
|
8
|
-
import { normalizeBundlerOptions, mergeBundlerOptions } from
|
|
9
|
-
const DEFAULT_GJS_SHEBANG =
|
|
1
|
+
import { runBundle, runWatch, bundleToChunks } from '../bundler-pick.js';
|
|
2
|
+
import { gjsifyPlugin, textLoaderPlugin, resolveShebangLine, NODE_SHEBANG } from '@gjsify/rolldown-plugin-gjsify';
|
|
3
|
+
import { resolveUserPlugins } from '../utils/resolve-plugin-by-name.js';
|
|
4
|
+
import { resolveGlobalsList, writeRegisterInjectFile, detectAutoGlobals } from '@gjsify/rolldown-plugin-gjsify/globals';
|
|
5
|
+
import { pnpPlugin } from '@gjsify/rolldown-plugin-pnp';
|
|
6
|
+
import { dirname, extname } from 'node:path';
|
|
7
|
+
import { chmod, readFile, writeFile } from 'node:fs/promises';
|
|
8
|
+
import { normalizeBundlerOptions, mergeBundlerOptions } from '../utils/normalize-bundler-options.js';
|
|
9
|
+
const DEFAULT_GJS_SHEBANG = '#!/usr/bin/env -S gjs -m';
|
|
10
10
|
/**
|
|
11
11
|
* `true` when `path` points at a location that's unsafe to use as a build
|
|
12
12
|
* outfile (would overwrite source). Currently catches:
|
|
@@ -16,7 +16,7 @@ const DEFAULT_GJS_SHEBANG = "#!/usr/bin/env -S gjs -m";
|
|
|
16
16
|
function isUnsafeDefaultOutput(path) {
|
|
17
17
|
if (/\.[cm]?tsx?$/i.test(path))
|
|
18
18
|
return true;
|
|
19
|
-
const norm = path.replace(/\\/g,
|
|
19
|
+
const norm = path.replace(/\\/g, '/');
|
|
20
20
|
if (/(?:^|\/)src\//.test(norm))
|
|
21
21
|
return true;
|
|
22
22
|
return false;
|
|
@@ -46,16 +46,14 @@ export class BuildAction {
|
|
|
46
46
|
const userBundler = normalizeBundlerOptions(this.configData);
|
|
47
47
|
const moduleOutdir = lib.module ? dirname(lib.module) : undefined;
|
|
48
48
|
const mainOutdir = lib.main ? dirname(lib.main) : undefined;
|
|
49
|
-
const moduleOutExt = lib.module ? extname(lib.module) :
|
|
50
|
-
const mainOutExt = lib.main ? extname(lib.main) :
|
|
49
|
+
const moduleOutExt = lib.module ? extname(lib.module) : '.js';
|
|
50
|
+
const mainOutExt = lib.main ? extname(lib.main) : '.js';
|
|
51
51
|
const multipleBuilds = moduleOutdir && mainOutdir && moduleOutdir !== mainOutdir;
|
|
52
52
|
const pnp = await buildPnpPlugin();
|
|
53
53
|
const pnpPlugins = pnp ? [pnp] : [];
|
|
54
54
|
const results = [];
|
|
55
55
|
if (multipleBuilds) {
|
|
56
|
-
const moduleFormat = moduleOutdir.includes(
|
|
57
|
-
? "cjs"
|
|
58
|
-
: "esm";
|
|
56
|
+
const moduleFormat = moduleOutdir.includes('/cjs') || moduleOutExt === '.cjs' ? 'cjs' : 'esm';
|
|
59
57
|
results.push(await runOneLibraryBuild({
|
|
60
58
|
pluginOpts: {
|
|
61
59
|
debug: verbose,
|
|
@@ -69,7 +67,7 @@ export class BuildAction {
|
|
|
69
67
|
userAliases: aliases,
|
|
70
68
|
pnpPlugins,
|
|
71
69
|
}));
|
|
72
|
-
const mainFormat = mainOutdir.includes(
|
|
70
|
+
const mainFormat = mainOutdir.includes('/cjs') || mainOutExt === '.cjs' ? 'cjs' : 'esm';
|
|
73
71
|
results.push(await runOneLibraryBuild({
|
|
74
72
|
pluginOpts: {
|
|
75
73
|
debug: verbose,
|
|
@@ -86,10 +84,10 @@ export class BuildAction {
|
|
|
86
84
|
}
|
|
87
85
|
else {
|
|
88
86
|
const outfilePath = userBundler.output?.file ?? lib.module ?? lib.main;
|
|
89
|
-
const outExt = outfilePath ? extname(outfilePath) :
|
|
87
|
+
const outExt = outfilePath ? extname(outfilePath) : '.js';
|
|
90
88
|
const outdir = userBundler.output?.dir ?? (outfilePath ? dirname(outfilePath) : undefined);
|
|
91
89
|
const format = userBundler.output?.format ??
|
|
92
|
-
(outdir?.includes(
|
|
90
|
+
(outdir?.includes('/cjs') || outExt === '.cjs' ? 'cjs' : 'esm');
|
|
93
91
|
results.push(await runOneLibraryBuild({
|
|
94
92
|
pluginOpts: {
|
|
95
93
|
debug: verbose,
|
|
@@ -117,15 +115,15 @@ export class BuildAction {
|
|
|
117
115
|
*/
|
|
118
116
|
parseGlobalsValue(value) {
|
|
119
117
|
if (value === undefined)
|
|
120
|
-
return { autoMode: true, extras:
|
|
121
|
-
if (value ===
|
|
122
|
-
return { autoMode: false, extras:
|
|
118
|
+
return { autoMode: true, extras: '' };
|
|
119
|
+
if (value === 'none' || value === '')
|
|
120
|
+
return { autoMode: false, extras: '' };
|
|
123
121
|
const tokens = value
|
|
124
|
-
.split(
|
|
122
|
+
.split(',')
|
|
125
123
|
.map((t) => t.trim())
|
|
126
124
|
.filter(Boolean);
|
|
127
|
-
const hasAuto = tokens.includes(
|
|
128
|
-
const extras = tokens.filter((t) => t !==
|
|
125
|
+
const hasAuto = tokens.includes('auto');
|
|
126
|
+
const extras = tokens.filter((t) => t !== 'auto').join(',');
|
|
129
127
|
return { autoMode: hasAuto, extras };
|
|
130
128
|
}
|
|
131
129
|
/**
|
|
@@ -137,7 +135,7 @@ export class BuildAction {
|
|
|
137
135
|
* The auto path is handled in `buildApp` via the iterative multi-pass build.
|
|
138
136
|
*/
|
|
139
137
|
async resolveGlobalsInject(app, globals, verbose) {
|
|
140
|
-
if (app !==
|
|
138
|
+
if (app !== 'gjs')
|
|
141
139
|
return undefined;
|
|
142
140
|
if (!globals)
|
|
143
141
|
return undefined;
|
|
@@ -164,39 +162,37 @@ export class BuildAction {
|
|
|
164
162
|
async applyShebang(app, outfile, verbose) {
|
|
165
163
|
if (!outfile) {
|
|
166
164
|
if (verbose)
|
|
167
|
-
console.warn(
|
|
165
|
+
console.warn('[gjsify] --shebang skipped: no single outfile (use --outfile for executables)');
|
|
168
166
|
return;
|
|
169
167
|
}
|
|
170
|
-
const defaultLine = app ===
|
|
168
|
+
const defaultLine = app === 'node' ? NODE_SHEBANG : DEFAULT_GJS_SHEBANG;
|
|
171
169
|
const line = resolveShebangLine(this.configData.shebang, defaultLine) ?? defaultLine;
|
|
172
|
-
const content = await readFile(outfile,
|
|
173
|
-
if (content.startsWith(
|
|
170
|
+
const content = await readFile(outfile, 'utf-8');
|
|
171
|
+
if (content.startsWith('#!')) {
|
|
174
172
|
if (verbose)
|
|
175
173
|
console.debug(`[gjsify] --shebang skipped: ${outfile} already starts with a shebang`);
|
|
176
174
|
}
|
|
177
175
|
else {
|
|
178
|
-
await writeFile(outfile, line +
|
|
176
|
+
await writeFile(outfile, line + '\n' + content);
|
|
179
177
|
}
|
|
180
178
|
await chmod(outfile, 0o755);
|
|
181
179
|
if (verbose)
|
|
182
180
|
console.debug(`[gjsify] --shebang: wrote ${line} + chmod 0o755 to ${outfile}`);
|
|
183
181
|
}
|
|
184
182
|
/** Application mode */
|
|
185
|
-
async buildApp(app =
|
|
186
|
-
const { verbose, typescript, exclude, library: pkg, aliases, excludeGlobals
|
|
183
|
+
async buildApp(app = 'gjs', opts = {}) {
|
|
184
|
+
const { verbose, typescript, exclude, library: pkg, aliases, excludeGlobals } = this.configData;
|
|
187
185
|
const userBundler = normalizeBundlerOptions(this.configData);
|
|
188
186
|
const formatRaw = userBundler.output?.format ??
|
|
189
|
-
(userBundler.output?.file?.endsWith(
|
|
187
|
+
(userBundler.output?.file?.endsWith('.cjs') ? 'cjs' : 'esm');
|
|
190
188
|
// The orchestrator only handles esm/cjs (iife is not a GJS / Node /
|
|
191
189
|
// browser-bundle target we support). Coerce.
|
|
192
|
-
const format = formatRaw ===
|
|
190
|
+
const format = formatRaw === 'iife' ? 'esm' : formatRaw;
|
|
193
191
|
// Set default outfile if no outdir is set
|
|
194
192
|
let outfile = userBundler.output?.file;
|
|
195
193
|
let outdir = userBundler.output?.dir;
|
|
196
194
|
if (!outfile && !outdir && (pkg?.main || pkg?.module)) {
|
|
197
|
-
const candidate = format ===
|
|
198
|
-
? pkg.main ?? pkg.module
|
|
199
|
-
: pkg.module ?? pkg.main;
|
|
195
|
+
const candidate = format === 'cjs' ? (pkg.main ?? pkg.module) : (pkg.module ?? pkg.main);
|
|
200
196
|
if (candidate && isUnsafeDefaultOutput(candidate)) {
|
|
201
197
|
throw new Error(`gjsify build: refusing to default --outfile to ${candidate} ` +
|
|
202
198
|
`(would overwrite a TypeScript source file). Pass --outfile/--outdir ` +
|
|
@@ -205,12 +201,8 @@ export class BuildAction {
|
|
|
205
201
|
outfile = candidate;
|
|
206
202
|
}
|
|
207
203
|
const { consoleShim, globals } = this.configData;
|
|
208
|
-
const userExternal = Array.isArray(userBundler.external)
|
|
209
|
-
|
|
210
|
-
: undefined;
|
|
211
|
-
const userBanner = typeof userBundler.output?.banner === "string"
|
|
212
|
-
? userBundler.output.banner
|
|
213
|
-
: undefined;
|
|
204
|
+
const userExternal = Array.isArray(userBundler.external) ? userBundler.external : undefined;
|
|
205
|
+
const userBanner = typeof userBundler.output?.banner === 'string' ? userBundler.output.banner : undefined;
|
|
214
206
|
const pluginOpts = {
|
|
215
207
|
debug: verbose,
|
|
216
208
|
app,
|
|
@@ -242,7 +234,7 @@ export class BuildAction {
|
|
|
242
234
|
userPlugins.push(...resolved);
|
|
243
235
|
}
|
|
244
236
|
// --- Auto mode (with optional extras): iterative multi-pass build ---
|
|
245
|
-
if (app ===
|
|
237
|
+
if (app === 'gjs' && autoMode) {
|
|
246
238
|
// Return the full orchestrator config (options + plugins) so
|
|
247
239
|
// auto-globals can reuse the per-app `resolve.conditionNames` /
|
|
248
240
|
// `mainFields` / `external` / `treeshake` for the in-memory
|
|
@@ -297,7 +289,7 @@ export class BuildAction {
|
|
|
297
289
|
return [];
|
|
298
290
|
}
|
|
299
291
|
const writeResult = await runBundle(finalOpts);
|
|
300
|
-
if ((app ===
|
|
292
|
+
if ((app === 'gjs' || app === 'node') && this.configData.shebang) {
|
|
301
293
|
await this.applyShebang(app, outfile, verbose);
|
|
302
294
|
}
|
|
303
295
|
return [writeResult];
|
|
@@ -311,36 +303,36 @@ export class BuildAction {
|
|
|
311
303
|
async runWatchLoop(finalOpts, app, outfile, verbose) {
|
|
312
304
|
const watcher = await runWatch(finalOpts);
|
|
313
305
|
const closed = new Promise((resolve) => {
|
|
314
|
-
watcher.on(
|
|
306
|
+
watcher.on('close', () => resolve());
|
|
315
307
|
});
|
|
316
308
|
let closing = false;
|
|
317
309
|
const shutdown = async () => {
|
|
318
310
|
if (closing)
|
|
319
311
|
return;
|
|
320
312
|
closing = true;
|
|
321
|
-
console.log(
|
|
313
|
+
console.log('\n[gjsify build --watch] stopping watcher…');
|
|
322
314
|
try {
|
|
323
315
|
await watcher.close();
|
|
324
316
|
}
|
|
325
317
|
catch (err) {
|
|
326
|
-
console.error(
|
|
318
|
+
console.error('[gjsify build --watch] watcher close error:', err);
|
|
327
319
|
}
|
|
328
320
|
};
|
|
329
|
-
process.on(
|
|
330
|
-
process.on(
|
|
331
|
-
watcher.on(
|
|
321
|
+
process.on('SIGINT', shutdown);
|
|
322
|
+
process.on('SIGTERM', shutdown);
|
|
323
|
+
watcher.on('event', async (event) => {
|
|
332
324
|
switch (event.code) {
|
|
333
|
-
case
|
|
325
|
+
case 'START':
|
|
334
326
|
if (verbose)
|
|
335
|
-
console.log(
|
|
327
|
+
console.log('[gjsify build --watch] rebuild start');
|
|
336
328
|
break;
|
|
337
|
-
case
|
|
338
|
-
console.log(
|
|
329
|
+
case 'BUNDLE_START':
|
|
330
|
+
console.log('[gjsify build --watch] building…');
|
|
339
331
|
break;
|
|
340
|
-
case
|
|
332
|
+
case 'BUNDLE_END':
|
|
341
333
|
console.log(`[gjsify build --watch] built in ${event.duration}ms`);
|
|
342
334
|
try {
|
|
343
|
-
if ((app ===
|
|
335
|
+
if ((app === 'gjs' || app === 'node') && this.configData.shebang) {
|
|
344
336
|
await this.applyShebang(app, outfile, verbose);
|
|
345
337
|
}
|
|
346
338
|
}
|
|
@@ -348,11 +340,11 @@ export class BuildAction {
|
|
|
348
340
|
await event.result.close();
|
|
349
341
|
}
|
|
350
342
|
break;
|
|
351
|
-
case
|
|
352
|
-
console.log(
|
|
343
|
+
case 'END':
|
|
344
|
+
console.log('[gjsify build --watch] waiting for changes…');
|
|
353
345
|
break;
|
|
354
|
-
case
|
|
355
|
-
console.error(
|
|
346
|
+
case 'ERROR':
|
|
347
|
+
console.error('[gjsify build --watch] build failed:', event.error?.message ?? event.error);
|
|
356
348
|
if (verbose && event.error?.stack)
|
|
357
349
|
console.error(event.error.stack);
|
|
358
350
|
try {
|
|
@@ -365,16 +357,16 @@ export class BuildAction {
|
|
|
365
357
|
}
|
|
366
358
|
});
|
|
367
359
|
if (verbose) {
|
|
368
|
-
watcher.on(
|
|
360
|
+
watcher.on('change', (id, change) => {
|
|
369
361
|
console.log(`[gjsify build --watch] ${change.event}: ${id}`);
|
|
370
362
|
});
|
|
371
363
|
}
|
|
372
364
|
await closed;
|
|
373
365
|
}
|
|
374
|
-
async start(buildType = { app:
|
|
366
|
+
async start(buildType = { app: 'gjs' }) {
|
|
375
367
|
if (buildType.library) {
|
|
376
368
|
if (buildType.watch) {
|
|
377
|
-
throw new Error(
|
|
369
|
+
throw new Error('gjsify build: --watch is not supported with --library (library mode would emit watcher rebuilds for every produced format; use --app gjs|node|browser instead).');
|
|
378
370
|
}
|
|
379
371
|
return await this.buildLibrary();
|
|
380
372
|
}
|
package/lib/bundler-pick.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RolldownOutput } from 'rolldown';
|
|
1
|
+
import type { RolldownOutput, InputOptions, RolldownWatcher } from 'rolldown';
|
|
2
2
|
import type { BundlerOptions } from './types/index.js';
|
|
3
3
|
export interface NativePluginContext {
|
|
4
4
|
resolve(specifier: string, importer?: string, opts?: {
|
|
@@ -62,7 +62,7 @@ export interface NativePlugin {
|
|
|
62
62
|
* the GJS-bundled CLI doesn't try to load the unloadable npm crate.
|
|
63
63
|
*/
|
|
64
64
|
export declare function bundleToChunks(input: {
|
|
65
|
-
rolldownInput:
|
|
65
|
+
rolldownInput: InputOptions;
|
|
66
66
|
format: 'esm' | 'cjs' | 'iife';
|
|
67
67
|
}): Promise<string[]>;
|
|
68
68
|
/**
|
|
@@ -71,7 +71,7 @@ export declare function bundleToChunks(input: {
|
|
|
71
71
|
* Returns the watcher; the caller registers `event` / `close` listeners
|
|
72
72
|
* and is responsible for invoking `watcher.close()` on shutdown.
|
|
73
73
|
*/
|
|
74
|
-
export declare function runWatch(finalOpts: BundlerOptions): Promise<
|
|
74
|
+
export declare function runWatch(finalOpts: BundlerOptions): Promise<RolldownWatcher>;
|
|
75
75
|
/**
|
|
76
76
|
* Run a bundle with the picked engine. Drop-in replacement for the
|
|
77
77
|
* `rolldown(opts).write(opts.output)` flow used directly in build.ts.
|
package/lib/bundler-pick.js
CHANGED
|
@@ -206,10 +206,11 @@ async function runNativeBundle(finalOpts) {
|
|
|
206
206
|
void _droppedPlugins;
|
|
207
207
|
const bundlerOpts = liftTransformExtras(stripUnserializable({
|
|
208
208
|
...rest,
|
|
209
|
-
...
|
|
209
|
+
...outputOpts,
|
|
210
210
|
input: normalizeInputForNative(finalOpts.input),
|
|
211
211
|
}));
|
|
212
|
-
if (globalThis.process?.env
|
|
212
|
+
if (globalThis.process?.env
|
|
213
|
+
?.GJSIFY_DEBUG_NATIVE_OPTS) {
|
|
213
214
|
// Debug switch to inspect the shape we ship to the native facade —
|
|
214
215
|
// mismatches surface as Rust serde parse errors that point at column
|
|
215
216
|
// numbers in this JSON.
|
|
@@ -225,9 +226,7 @@ async function runNativeBundle(finalOpts) {
|
|
|
225
226
|
await fs.mkdir(outDir, { recursive: true });
|
|
226
227
|
for (const item of result.output) {
|
|
227
228
|
if (item.type === 'chunk') {
|
|
228
|
-
const target = outputCfg.file && result.output.length === 1
|
|
229
|
-
? outputCfg.file
|
|
230
|
-
: path.join(outDir, item.fileName);
|
|
229
|
+
const target = outputCfg.file && result.output.length === 1 ? outputCfg.file : path.join(outDir, item.fileName);
|
|
231
230
|
await fs.writeFile(target, item.code, 'utf8');
|
|
232
231
|
}
|
|
233
232
|
}
|
|
@@ -316,7 +315,7 @@ function normalizeInputForNative(input) {
|
|
|
316
315
|
if (typeof input === 'string')
|
|
317
316
|
return [{ import: input }];
|
|
318
317
|
if (Array.isArray(input)) {
|
|
319
|
-
return input.map((v) => typeof v === 'string' ? { import: v } : v);
|
|
318
|
+
return input.map((v) => (typeof v === 'string' ? { import: v } : v));
|
|
320
319
|
}
|
|
321
320
|
return Object.entries(input).map(([name, file]) => ({ name, import: file }));
|
|
322
321
|
}
|
package/lib/commands/build.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Command, CliBuildOptions } from '../types/index.js';
|
|
2
|
-
export declare const buildCommand: Command<
|
|
2
|
+
export declare const buildCommand: Command<unknown, CliBuildOptions>;
|
package/lib/commands/build.js
CHANGED
|
@@ -6,7 +6,7 @@ export const buildCommand = {
|
|
|
6
6
|
builder: (yargs) => {
|
|
7
7
|
return yargs
|
|
8
8
|
.option('entry-points', {
|
|
9
|
-
description:
|
|
9
|
+
description: 'The entry points you want to bundle. Defaults to bundler.input from package.json#gjsify or .gjsifyrc.js, falling back to src/index.ts when neither is set.',
|
|
10
10
|
array: true,
|
|
11
11
|
type: 'string',
|
|
12
12
|
normalize: true,
|
|
@@ -19,59 +19,59 @@ export const buildCommand = {
|
|
|
19
19
|
// and producing a bundle from the wrong entry point. The
|
|
20
20
|
// fallback to src/index.ts is applied in config.ts AFTER
|
|
21
21
|
// merging with the cosmiconfig data.
|
|
22
|
-
defaultDescription:
|
|
22
|
+
defaultDescription: 'src/index.ts (fallback)',
|
|
23
23
|
coerce: (arg) => {
|
|
24
24
|
// Removes duplicates
|
|
25
25
|
return [...new Set(arg)];
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
27
|
})
|
|
28
28
|
.option('exclude', {
|
|
29
|
-
description:
|
|
29
|
+
description: 'An array of glob patterns to exclude entry-points and aliases',
|
|
30
30
|
array: true,
|
|
31
31
|
type: 'string',
|
|
32
32
|
normalize: true,
|
|
33
|
-
default: []
|
|
33
|
+
default: [],
|
|
34
34
|
})
|
|
35
35
|
.option('verbose', {
|
|
36
|
-
description:
|
|
36
|
+
description: 'Switch on the verbose mode',
|
|
37
37
|
type: 'boolean',
|
|
38
38
|
normalize: true,
|
|
39
|
-
default: false
|
|
39
|
+
default: false,
|
|
40
40
|
})
|
|
41
41
|
.option('app', {
|
|
42
|
-
description:
|
|
42
|
+
description: 'Use this if you want to build an application, the platform node is usually only used for tests',
|
|
43
43
|
type: 'string',
|
|
44
44
|
choices: ['gjs', 'node', 'browser'],
|
|
45
45
|
normalize: true,
|
|
46
|
-
default: 'gjs'
|
|
46
|
+
default: 'gjs',
|
|
47
47
|
})
|
|
48
48
|
.option('format', {
|
|
49
|
-
description:
|
|
49
|
+
description: 'Override the default output format',
|
|
50
50
|
type: 'string',
|
|
51
51
|
choices: ['iife', 'esm', 'cjs'],
|
|
52
52
|
normalize: true,
|
|
53
53
|
})
|
|
54
54
|
.option('minify', {
|
|
55
|
-
description:
|
|
55
|
+
description: 'Minify the bundled output. Defaults to true; use --no-minify to emit pretty-printed code (e.g. for debugging or readable bundle review).',
|
|
56
56
|
type: 'boolean',
|
|
57
57
|
normalize: true,
|
|
58
58
|
defaultDescription: 'true',
|
|
59
59
|
})
|
|
60
60
|
.option('library', {
|
|
61
|
-
description:
|
|
61
|
+
description: 'Use this if you want to build a library for Gjsify',
|
|
62
62
|
type: 'boolean',
|
|
63
63
|
normalize: true,
|
|
64
|
-
default: false
|
|
64
|
+
default: false,
|
|
65
65
|
})
|
|
66
66
|
.option('outfile', {
|
|
67
67
|
alias: 'o',
|
|
68
|
-
description:
|
|
68
|
+
description: 'Sets the output file name for the build operation. If no outfile is specified, the outfile will be parsed from the package.json. Only used if application mode is active',
|
|
69
69
|
type: 'string',
|
|
70
70
|
normalize: true,
|
|
71
71
|
})
|
|
72
72
|
.option('outdir', {
|
|
73
73
|
alias: 'd',
|
|
74
|
-
description:
|
|
74
|
+
description: 'Sets the output directory for the build operation. If no outdir is specified, the outdir will be parsed from the package.json. Only used if library mode is active',
|
|
75
75
|
type: 'string',
|
|
76
76
|
normalize: true,
|
|
77
77
|
})
|
|
@@ -80,60 +80,66 @@ export const buildCommand = {
|
|
|
80
80
|
description: "Enables TypeScript types on runtime using Deepkit's type compiler",
|
|
81
81
|
type: 'boolean',
|
|
82
82
|
normalize: true,
|
|
83
|
-
default: false
|
|
83
|
+
default: false,
|
|
84
84
|
})
|
|
85
85
|
.option('log-level', {
|
|
86
|
-
description:
|
|
86
|
+
description: 'The log level can be changed to prevent esbuild from printing warning and/or error messages to the terminal',
|
|
87
87
|
type: 'string',
|
|
88
88
|
choices: ['silent', 'error', 'warning', 'info', 'debug', 'verbose'],
|
|
89
89
|
normalize: true,
|
|
90
|
-
default: 'warning'
|
|
90
|
+
default: 'warning',
|
|
91
91
|
})
|
|
92
92
|
.option('console-shim', {
|
|
93
|
-
description:
|
|
93
|
+
description: 'Inject a console shim into GJS builds for clean output without the GLib prefix and with working ANSI colors. Use --no-console-shim to disable. Only applies to GJS app builds.',
|
|
94
94
|
type: 'boolean',
|
|
95
95
|
normalize: true,
|
|
96
|
-
default: true
|
|
96
|
+
default: true,
|
|
97
97
|
})
|
|
98
98
|
.option('globals', {
|
|
99
99
|
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.",
|
|
100
100
|
type: 'string',
|
|
101
101
|
normalize: true,
|
|
102
|
-
default: 'auto'
|
|
102
|
+
default: 'auto',
|
|
103
103
|
})
|
|
104
104
|
.option('shebang', {
|
|
105
|
-
description:
|
|
105
|
+
description: 'Prepend a target-appropriate shebang to the output and mark it executable (chmod 755): `#!/usr/bin/env -S gjs -m` for --app gjs, `#!/usr/bin/env node` for --app node. Applies to GJS and Node app builds with a single --outfile. Default: false (use --shebang to enable, or set `shebang: true` in `.gjsifyrc.js`).',
|
|
106
106
|
type: 'boolean',
|
|
107
|
-
normalize: true
|
|
107
|
+
normalize: true,
|
|
108
108
|
})
|
|
109
109
|
.option('external', {
|
|
110
|
-
description:
|
|
110
|
+
description: 'Module names that should NOT be bundled. Repeat the flag or pass a comma-separated list (e.g. --external typedoc,prettier). Globs are forwarded to esbuild as-is. See https://esbuild.github.io/api/#external',
|
|
111
111
|
array: true,
|
|
112
112
|
type: 'string',
|
|
113
113
|
default: [],
|
|
114
|
-
coerce: (arg) => arg.flatMap((v) => v
|
|
114
|
+
coerce: (arg) => arg.flatMap((v) => v
|
|
115
|
+
.split(',')
|
|
116
|
+
.map((s) => s.trim())
|
|
117
|
+
.filter(Boolean)),
|
|
115
118
|
})
|
|
116
119
|
.option('define', {
|
|
117
|
-
description:
|
|
120
|
+
description: 'Substitute compile-time constants. Each entry is KEY=VALUE where VALUE is a JS expression (string literals must be quoted: --define VERSION=\'"1.2.3"\'). Repeat the flag or pass comma-separated. See https://esbuild.github.io/api/#define',
|
|
118
121
|
array: true,
|
|
119
122
|
type: 'string',
|
|
120
123
|
default: [],
|
|
121
124
|
})
|
|
122
125
|
.option('alias', {
|
|
123
|
-
description:
|
|
126
|
+
description: 'Map module specifiers at bundle time. Each entry is FROM=TO (e.g. --alias typedoc=@gjsify/empty). Layered on top of the built-in alias map. Useful for stubbing heavy deps the test scenario never executes.',
|
|
124
127
|
array: true,
|
|
125
128
|
type: 'string',
|
|
126
129
|
default: [],
|
|
127
|
-
coerce: (arg) => arg.flatMap((v) => v
|
|
130
|
+
coerce: (arg) => arg.flatMap((v) => v
|
|
131
|
+
.split(',')
|
|
132
|
+
.map((s) => s.trim())
|
|
133
|
+
.filter(Boolean)),
|
|
128
134
|
})
|
|
129
135
|
.option('exclude-globals', {
|
|
130
|
-
description:
|
|
136
|
+
description: 'Comma-separated global identifiers to remove from auto-detection results. Use for false positives from dead browser-compat code whose polyfills require unavailable native libraries (e.g. --exclude-globals fetch,XMLHttpRequest).',
|
|
131
137
|
type: 'string',
|
|
132
138
|
normalize: true,
|
|
133
139
|
})
|
|
134
140
|
.option('watch', {
|
|
135
141
|
alias: 'w',
|
|
136
|
-
description:
|
|
142
|
+
description: 'Watch source files and rebuild on change. Logs each rebuild with duration; clean SIGINT shutdown. Only valid with --app gjs|node|browser (rejected with --library). Requires the npm `rolldown` engine — run under Node, not the GJS-bundled CLI.',
|
|
137
143
|
type: 'boolean',
|
|
138
144
|
normalize: true,
|
|
139
145
|
default: false,
|
|
@@ -148,5 +154,5 @@ export const buildCommand = {
|
|
|
148
154
|
app: args.app,
|
|
149
155
|
watch: args.watch,
|
|
150
156
|
});
|
|
151
|
-
}
|
|
157
|
+
},
|
|
152
158
|
};
|
package/lib/commands/check.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// In a single package (or anywhere a `package.json` with a `check` script
|
|
8
8
|
// is reachable from cwd): runs the local `check` script directly. This is
|
|
9
9
|
// the natural "tsc --noEmit on the current scope" invocation, analogous to
|
|
10
|
-
// `gjsify format` / `lint` / `fix` (which all wrap
|
|
10
|
+
// `gjsify format` / `lint` / `fix` (which all wrap oxc workspace-wide).
|
|
11
11
|
//
|
|
12
12
|
// The legacy system-dep-check shape lives under `gjsify system-check` after
|
|
13
13
|
// PR #254. The `check` alias on `system-check` stays valid for one release
|
|
@@ -18,7 +18,7 @@ import { spawn, spawnSync } from 'node:child_process';
|
|
|
18
18
|
import { existsSync, readFileSync } from 'node:fs';
|
|
19
19
|
import { join } from 'node:path';
|
|
20
20
|
import { cpus } from 'node:os';
|
|
21
|
-
import { discoverWorkspaces, filterWorkspaces
|
|
21
|
+
import { discoverWorkspaces, filterWorkspaces } from '@gjsify/workspace';
|
|
22
22
|
import { findWorkspaceRoot } from '../utils/workspace-root.js';
|
|
23
23
|
function readPackageJson(dir) {
|
|
24
24
|
const path = join(dir, 'package.json');
|
|
@@ -147,7 +147,7 @@ export const checkCommand = {
|
|
|
147
147
|
firstFail = code;
|
|
148
148
|
}
|
|
149
149
|
if (firstFail !== 0)
|
|
150
|
-
console.error(`gjsify check: failures in ${targets.filter(async (ws) => await runCheck(ws, null) !== 0).length}+ workspaces`);
|
|
150
|
+
console.error(`gjsify check: failures in ${targets.filter(async (ws) => (await runCheck(ws, null)) !== 0).length}+ workspaces`);
|
|
151
151
|
process.exit(firstFail);
|
|
152
152
|
}
|
|
153
153
|
// ---- Parallel mode (default) ----
|
package/lib/commands/create.d.ts
CHANGED
package/lib/commands/dlx.d.ts
CHANGED