@gjsify/cli 0.35.0 → 0.37.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 +136 -126
- package/lib/actions/build.d.ts +19 -0
- package/lib/actions/build.js +2 -2
- package/lib/bundler-pick.js +72 -98
- package/lib/cli-fail.d.ts +4 -7
- package/lib/cli-fail.js +29 -55
- package/lib/commands/affected.js +161 -286
- package/lib/commands/install.d.ts +63 -66
- package/lib/commands/install.js +372 -536
- package/lib/commands/run.d.ts +1 -0
- package/lib/commands/run.js +37 -0
- package/lib/templates/install.mjs.tmpl +38 -68
- package/lib/types/cli-build-options.d.ts +33 -67
- package/lib/types/command.d.ts +9 -12
- package/lib/types/config-data.d.ts +125 -221
- package/lib/utils/auth-npmrc.d.ts +5 -10
- package/lib/utils/auth-npmrc.js +11 -21
- package/lib/utils/check-system-deps.d.ts +16 -0
- package/lib/utils/check-system-deps.js +49 -0
- package/lib/utils/clear-targets.d.ts +8 -11
- package/lib/utils/clear-targets.js +22 -29
- package/lib/utils/copy-targets.d.ts +13 -19
- package/lib/utils/copy-targets.js +31 -44
- package/lib/utils/dep-aggregation.d.ts +7 -15
- package/lib/utils/dep-aggregation.js +9 -22
- package/lib/utils/detect-native-packages.d.ts +83 -116
- package/lib/utils/detect-native-packages.js +111 -149
- package/lib/utils/dir-link.d.ts +29 -48
- package/lib/utils/dir-link.js +33 -56
- package/lib/utils/discover-showcases.d.ts +6 -7
- package/lib/utils/discover-showcases.js +11 -15
- package/lib/utils/dlx-cache.d.ts +29 -38
- package/lib/utils/dlx-cache.js +53 -63
- package/lib/utils/force-exit.d.ts +0 -3
- package/lib/utils/force-exit.js +13 -24
- package/lib/utils/gi-search-path.d.ts +16 -24
- package/lib/utils/gi-search-path.js +54 -82
- package/lib/utils/gjs-bundle-guard.d.ts +5 -13
- package/lib/utils/gjs-bundle-guard.js +35 -57
- package/lib/utils/gjs-source-escape.d.ts +2 -2
- package/lib/utils/gjs-source-escape.js +21 -39
- package/lib/utils/gjsify-shim.d.ts +26 -8
- package/lib/utils/gjsify-shim.js +128 -80
- package/lib/utils/html-entry.d.ts +8 -12
- package/lib/utils/html-entry.js +19 -28
- package/lib/utils/install-backend-native.d.ts +123 -161
- package/lib/utils/install-backend-native.js +536 -737
- package/lib/utils/install-backend.d.ts +42 -57
- package/lib/utils/install-backend.js +16 -21
- package/lib/utils/install-cache-fs.d.ts +10 -15
- package/lib/utils/install-cache-fs.js +18 -26
- package/lib/utils/install-lock.d.ts +5 -6
- package/lib/utils/install-lock.js +46 -65
- package/lib/utils/install-packument-cache.d.ts +27 -33
- package/lib/utils/install-packument-cache.js +44 -57
- package/lib/utils/install-progress.d.ts +2 -9
- package/lib/utils/install-progress.js +14 -39
- package/lib/utils/install-tarball-cache.d.ts +14 -20
- package/lib/utils/install-tarball-cache.js +41 -59
- package/lib/utils/library-output.d.ts +9 -22
- package/lib/utils/library-output.js +19 -37
- package/lib/utils/load-npmrc.d.ts +5 -6
- package/lib/utils/load-npmrc.js +18 -27
- package/lib/utils/node-bundle-guard.d.ts +4 -8
- package/lib/utils/node-bundle-guard.js +21 -35
- package/lib/utils/node-script.d.ts +12 -0
- package/lib/utils/node-script.js +95 -0
- package/lib/utils/node-version.d.ts +5 -14
- package/lib/utils/node-version.js +15 -24
- package/lib/utils/normalize-bundler-options.d.ts +7 -11
- package/lib/utils/normalize-bundler-options.js +24 -42
- package/lib/utils/npm-oidc.d.ts +23 -37
- package/lib/utils/npm-oidc.js +28 -53
- package/lib/utils/npm-otp-cache.d.ts +4 -4
- package/lib/utils/npm-otp-cache.js +20 -25
- package/lib/utils/npm-otp.d.ts +20 -30
- package/lib/utils/npm-otp.js +32 -51
- package/lib/utils/onboard-probe.d.ts +7 -13
- package/lib/utils/onboard-probe.js +16 -27
- package/lib/utils/parse-spec.d.ts +3 -3
- package/lib/utils/parse-spec.js +4 -5
- package/lib/utils/pkg-json-edit.d.ts +7 -12
- package/lib/utils/pkg-json-edit.js +13 -26
- package/lib/utils/pkg-json.d.ts +11 -18
- package/lib/utils/pkg-json.js +19 -28
- package/lib/utils/prefixed-output.d.ts +3 -4
- package/lib/utils/prefixed-output.js +13 -19
- package/lib/utils/prompt.d.ts +3 -4
- package/lib/utils/prompt.js +14 -18
- package/lib/utils/publish-diagnose.d.ts +11 -16
- package/lib/utils/publish-diagnose.js +15 -28
- package/lib/utils/publish-headers.d.ts +7 -11
- package/lib/utils/publish-headers.js +36 -65
- package/lib/utils/publishable-packages.d.ts +4 -6
- package/lib/utils/publishable-packages.js +14 -18
- package/lib/utils/resolve-gjs-entry.d.ts +5 -8
- package/lib/utils/resolve-gjs-entry.js +10 -27
- package/lib/utils/resolve-npm-package.d.ts +6 -11
- package/lib/utils/resolve-npm-package.js +29 -63
- package/lib/utils/resolve-plugin-by-name.d.ts +11 -19
- package/lib/utils/resolve-plugin-by-name.js +9 -14
- package/lib/utils/run-gjs.d.ts +19 -17
- package/lib/utils/run-gjs.js +37 -51
- package/lib/utils/run-lifecycle-script.d.ts +5 -9
- package/lib/utils/run-lifecycle-script.js +23 -42
- package/lib/utils/run-node.d.ts +23 -33
- package/lib/utils/run-node.js +56 -60
- package/lib/utils/runtimes.d.ts +25 -35
- package/lib/utils/runtimes.js +34 -46
- package/lib/utils/spawn.d.ts +32 -48
- package/lib/utils/spawn.js +51 -84
- package/lib/utils/stdin.d.ts +2 -2
- package/lib/utils/stdin.js +10 -25
- package/lib/utils/suggest.d.ts +6 -7
- package/lib/utils/suggest.js +8 -10
- package/lib/utils/system-gi.d.ts +18 -27
- package/lib/utils/system-gi.js +60 -114
- package/lib/utils/trust-registry.d.ts +4 -8
- package/lib/utils/trust-registry.js +7 -15
- package/lib/utils/win32-command.d.ts +8 -14
- package/lib/utils/win32-command.js +29 -43
- package/lib/utils/workspace-root.js +7 -12
- package/package.json +18 -17
- package/showcases.json +6 -0
package/lib/commands/run.d.ts
CHANGED
package/lib/commands/run.js
CHANGED
|
@@ -19,6 +19,8 @@ import { spawn } from 'node:child_process';
|
|
|
19
19
|
import { runGjsBundle } from '../utils/run-gjs.js';
|
|
20
20
|
import { runRuntimeBundle } from '../utils/run-node.js';
|
|
21
21
|
import { readPackageJson } from '../utils/pkg-json-edit.js';
|
|
22
|
+
import { runNodeScript } from '../utils/node-script.js';
|
|
23
|
+
import { nodeShimDir } from '../utils/gjsify-shim.js';
|
|
22
24
|
import { findWorkspaceRoot } from '../utils/workspace-root.js';
|
|
23
25
|
import { discoverWorkspaces } from '@gjsify/workspace';
|
|
24
26
|
import { isGjs, hostRuntime } from '@gjsify/rolldown-plugin-gjsify/runtime';
|
|
@@ -47,6 +49,16 @@ export const runCommand = {
|
|
|
47
49
|
alias: 'w',
|
|
48
50
|
type: 'string',
|
|
49
51
|
description: 'Run <target> as a script in the named workspace (by name or path), like `npm run <script> -w <name>`.',
|
|
52
|
+
})
|
|
53
|
+
.option('node-script', {
|
|
54
|
+
// Run an UNBUNDLED `.mjs` that imports `node:*` builtins on the
|
|
55
|
+
// host runtime — bundling it for GJS first when that is the host.
|
|
56
|
+
// Declared here so yargs captures it instead of forwarding it to
|
|
57
|
+
// the target (this command routes unknown flags to the child).
|
|
58
|
+
// Forces file mode, like --runtime.
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
default: false,
|
|
61
|
+
description: 'Treat <target> as an unbundled Node-style script (imports `node:` builtins) and run it on the host runtime. Under GJS the file is bundled `--app gjs` on the fly first, which is what makes a repo script runnable on a host that has no Node.',
|
|
50
62
|
})
|
|
51
63
|
.option('runtime', {
|
|
52
64
|
// Runtime selector for a BUNDLE FILE. `gjs` (default) launches
|
|
@@ -99,6 +111,22 @@ export const runCommand = {
|
|
|
99
111
|
const positionalArgs = args.args ?? [];
|
|
100
112
|
const doubleDashArgs = (args['--'] ?? []).filter((v) => typeof v === 'string');
|
|
101
113
|
const extraArgs = [...positionalArgs, ...doubleDashArgs];
|
|
114
|
+
// `--node-script` (explicit) → run an UNBUNDLED Node-style script on the
|
|
115
|
+
// host runtime; under GJS it is bundled `--app gjs` on the fly first.
|
|
116
|
+
// Checked before `--runtime` and `--workspace`: it is a file mode, and
|
|
117
|
+
// combining it with either is a caller error rather than a precedence
|
|
118
|
+
// question (`--runtime` picks a launcher for a PREBUILT bundle,
|
|
119
|
+
// `--workspace` names a package.json script).
|
|
120
|
+
if (args.nodeScript === true) {
|
|
121
|
+
const isSet = (v) => typeof v === 'string' && v.length > 0;
|
|
122
|
+
const clash = isSet(args.runtime) ? '--runtime' : isSet(args.workspace) ? '--workspace' : null;
|
|
123
|
+
if (clash) {
|
|
124
|
+
console.error(`gjsify run: --node-script cannot be combined with ${clash}.`);
|
|
125
|
+
return process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
await runNodeScript(target, extraArgs, { exitOnSuccess: true });
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
102
130
|
// `--runtime <gjs|node|bun|deno>` (explicit) → run a BUNDLE FILE on the
|
|
103
131
|
// chosen runtime. This FORCES file mode: the runtime selector only makes
|
|
104
132
|
// sense for a prebuilt bundle, and it must beat the script-name lookup.
|
|
@@ -308,6 +336,15 @@ async function runScript(script, extraArgs, cwd = process.cwd()) {
|
|
|
308
336
|
if (process.env.GJSIFY_SHIM_DIR) {
|
|
309
337
|
binDirs.unshift(process.env.GJSIFY_SHIM_DIR);
|
|
310
338
|
}
|
|
339
|
+
// The `node` shim (see `nodeShimDir`) reaches PACKAGE SCRIPTS and nothing
|
|
340
|
+
// else. A script saying `node scripts/x.mjs` means "run this script", which
|
|
341
|
+
// gjsify can serve on a host with no Node; the CLI's own internals asking for
|
|
342
|
+
// `node` mean "I need a real Node", and answering those turned
|
|
343
|
+
// `gjsify tsc`'s honest "not on PATH" diagnosis into a bundling error two
|
|
344
|
+
// layers down (tests/e2e/tsc-node-fallback caught exactly that).
|
|
345
|
+
const nodeShim = nodeShimDir();
|
|
346
|
+
if (nodeShim)
|
|
347
|
+
binDirs.unshift(nodeShim);
|
|
311
348
|
// Default FORCE_COLOR=1 when not already set, matching yarn / npm
|
|
312
349
|
// script-runner behaviour. Without this, tools that check
|
|
313
350
|
// `process.stdout.isTTY` (chalk, picocolors, biome, …) disable colors
|
|
@@ -1,40 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env -S gjs -m
|
|
2
2
|
/**
|
|
3
|
-
* gjsify universal installer — bootstraps `@gjsify/cli` (or any GJS app
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* gjsify universal installer — bootstraps `@gjsify/cli` (or any GJS app on npm)
|
|
4
|
+
* on a system that has only `gjs` and libsoup: no Node, no npm. Decision and
|
|
5
|
+
* history: docs/adr/0002-bootstrap-bundle-minimization.md.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* gjs -m install.mjs --help
|
|
7
|
+
* Two stages: download a self-contained GJS bundle of `@gjsify/cli`
|
|
8
|
+
* (`cli.gjs.mjs`) from this repo's GitHub releases and verify its SHA-256, then
|
|
9
|
+
* spawn it as `gjs -m <bundle> install -g <target>@<tag>`. Dependency
|
|
10
|
+
* resolution, native prebuilds, lockfiles and the `~/.local/bin` launchers all
|
|
11
|
+
* live in that bundle — this bootstrapper re-implements none of it on purpose.
|
|
13
12
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* (`cli.gjs.mjs`) from this repo's GitHub releases. Verify SHA-256.
|
|
17
|
-
* 2. Spawn that bundle: `gjs -m <bundle> install -g <target>@<tag>`. The
|
|
18
|
-
* bundle handles transitive dependency resolution, native prebuilds,
|
|
19
|
-
* lockfiles, and the `~/.local/bin` launchers — all the things this
|
|
20
|
-
* thin bootstrapper deliberately does NOT re-implement.
|
|
13
|
+
* `gjsify generate-installer` re-emits this file for end-user GJS apps with the
|
|
14
|
+
* marked constants substituted.
|
|
21
15
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Test hooks (set by tests/e2e/install-script/run.mjs):
|
|
27
|
-
* GJSIFY_INSTALL_BOOTSTRAP_URL override the cli.gjs.mjs download origin
|
|
28
|
-
* (accepts file:// for offline tests)
|
|
29
|
-
* GJSIFY_INSTALL_BOOTSTRAP_SHA256_URL override the .sha256 companion URL.
|
|
30
|
-
* An EMPTY string is the only way to install
|
|
31
|
-
* without verification, and it warns loudly; a
|
|
32
|
-
* digest URL that is set but unreachable is a
|
|
33
|
-
* hard failure, never a silent downgrade.
|
|
34
|
-
* GJSIFY_GLOBAL_PREFIX override install prefix (forwarded to cli)
|
|
35
|
-
* GJSIFY_GLOBAL_BIN_DIR override bin dir (forwarded to cli)
|
|
36
|
-
* GJSIFY_INSTALL_REGISTRY override npm registry (forwarded as npm_config_registry)
|
|
37
|
-
* GJSIFY_INSTALL_BOOTSTRAP_CACHE override the bootstrap cache dir
|
|
16
|
+
* `--help` documents the user-facing flags and env vars. Two more exist only for
|
|
17
|
+
* tests/e2e/install-script/run.mjs: GJSIFY_INSTALL_BOOTSTRAP_SHA256_URL and
|
|
18
|
+
* GJSIFY_INSTALL_BOOTSTRAP_CACHE.
|
|
38
19
|
*/
|
|
39
20
|
|
|
40
21
|
import GLib from 'gi://GLib';
|
|
@@ -53,17 +34,16 @@ const DEFAULT_BOOTSTRAP_SHA256_URL = `${DEFAULT_BOOTSTRAP_URL}.sha256`;
|
|
|
53
34
|
|
|
54
35
|
const USER_AGENT = 'gjsify-installer/1.0';
|
|
55
36
|
|
|
56
|
-
//
|
|
57
|
-
//
|
|
37
|
+
// Content-addressed cache: `cli-<sha256>.gjs.mjs`. Why the digest and not a
|
|
38
|
+
// fixed name keys it: `resolveBootstrap()`.
|
|
58
39
|
const CACHE_PREFIX = 'cli-';
|
|
59
40
|
const CACHE_SUFFIX = '.gjs.mjs';
|
|
60
41
|
|
|
61
42
|
/**
|
|
62
|
-
* Under `--fetch-only`
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* surfaces as a confusing "file not found" rather than as bad output.
|
|
43
|
+
* Under `--fetch-only` stdout carries nothing but the bundle path, so progress
|
|
44
|
+
* goes to stderr. A caller does `BOOTSTRAP=$(gjs -m install.mjs --fetch-only)`,
|
|
45
|
+
* where one stray `info()` line glues a log message to the front of the path and
|
|
46
|
+
* surfaces later as a confusing "file not found".
|
|
67
47
|
*/
|
|
68
48
|
let logToStderr = false;
|
|
69
49
|
|
|
@@ -139,7 +119,7 @@ Examples:
|
|
|
139
119
|
}
|
|
140
120
|
|
|
141
121
|
function checkGjsVersion() {
|
|
142
|
-
//
|
|
122
|
+
// `system.version` is packed: major*10000 + minor*100 + micro
|
|
143
123
|
const v = system?.version;
|
|
144
124
|
if (typeof v !== 'number') return;
|
|
145
125
|
const major = Math.floor(v / 10000);
|
|
@@ -197,18 +177,17 @@ function readBytesOrNull(path) {
|
|
|
197
177
|
const [, bytes] = Gio.File.new_for_path(path).load_contents(null);
|
|
198
178
|
return bytes;
|
|
199
179
|
} catch {
|
|
200
|
-
// An absent
|
|
201
|
-
//
|
|
202
|
-
//
|
|
180
|
+
// An absent or unreadable entry (truncated by a killed earlier run) is a
|
|
181
|
+
// MISS, not an error. `load_contents` is `throws="1"`, so this catch has
|
|
182
|
+
// a genuine throw path.
|
|
203
183
|
return null;
|
|
204
184
|
}
|
|
205
185
|
}
|
|
206
186
|
|
|
207
187
|
/**
|
|
208
|
-
* Drop every other cached bootstrap
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
* can never be warm" for "the cache grows forever".
|
|
188
|
+
* Drop every other cached bootstrap. Each entry is a ~6.6 MB bundle and the
|
|
189
|
+
* digest changes every release, so without pruning, content-addressing would
|
|
190
|
+
* trade "the cache can never be warm" for "the cache grows forever".
|
|
212
191
|
*/
|
|
213
192
|
function pruneCache(dir, keepBasename) {
|
|
214
193
|
const children = Gio.File.new_for_path(dir).enumerate_children('standard::name', Gio.FileQueryInfoFlags.NONE, null);
|
|
@@ -224,21 +203,15 @@ function pruneCache(dir, keepBasename) {
|
|
|
224
203
|
/**
|
|
225
204
|
* Resolve a VERIFIED bootstrap bundle and return its path.
|
|
226
205
|
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* a 404, or a captive portal silently downgraded the install to no
|
|
235
|
-
* verification at all. Fetching the digest first makes that impossible:
|
|
236
|
-
* no digest, no install.
|
|
237
|
-
* 2. The cache could never be warm. It wrote a fixed `cli.gjs.mjs` and never
|
|
238
|
-
* read it back, so every run re-downloaded ~6.6 MB. A content-addressed
|
|
239
|
-
* name lets a matching entry short-circuit the download entirely.
|
|
206
|
+
* Fetching the digest BEFORE the bundle, and keying the cache by it, is the
|
|
207
|
+
* mechanism rather than an optimisation; the reverse order cost two defects.
|
|
208
|
+
* Verifying after downloading made verification skippable by anyone who could
|
|
209
|
+
* break ONE request — a failed `.sha256` fetch logged "skipping verification"
|
|
210
|
+
* and carried on, so a proxy, a 404 or a captive portal silently downgraded the
|
|
211
|
+
* install. And a fixed `cli.gjs.mjs` name that was never read back meant every
|
|
212
|
+
* run re-downloaded ~6.6 MB; a content-addressed name short-circuits that.
|
|
240
213
|
*
|
|
241
|
-
* Skipping verification
|
|
214
|
+
* Skipping verification remains possible only as an EXPLICIT act
|
|
242
215
|
* (`GJSIFY_INSTALL_BOOTSTRAP_SHA256_URL=''`), and it says so on stderr.
|
|
243
216
|
*/
|
|
244
217
|
async function resolveBootstrap(session, bootstrapUrl, sha256Url) {
|
|
@@ -313,14 +286,12 @@ function buildSpec(target, tag) {
|
|
|
313
286
|
}
|
|
314
287
|
|
|
315
288
|
async function runInstall(bundlePath, spec) {
|
|
316
|
-
// `gjsify install -g <spec>`
|
|
317
|
-
//
|
|
318
|
-
// installer's own `--force` is satisfied by the fact that we always
|
|
319
|
-
// re-download the bootstrap and re-invoke the CLI.
|
|
289
|
+
// `gjsify install -g <spec>` rewrites the tree unconditionally, so there is
|
|
290
|
+
// no force flag to forward and `--force` needs nothing here.
|
|
320
291
|
info(`Running: gjs -m <bootstrap> install -g ${spec}`);
|
|
321
292
|
const argv = ['gjs', '-m', bundlePath, 'install', '-g', spec];
|
|
322
|
-
//
|
|
323
|
-
// reach the spawned CLI.
|
|
293
|
+
// No `envp`: the launcher inherits ours, so override env vars set by tests
|
|
294
|
+
// and power-users reach the spawned CLI.
|
|
324
295
|
const launcher = new Gio.SubprocessLauncher({
|
|
325
296
|
flags: Gio.SubprocessFlags.NONE,
|
|
326
297
|
});
|
|
@@ -349,7 +320,6 @@ async function main() {
|
|
|
349
320
|
}
|
|
350
321
|
|
|
351
322
|
if (opts.fetchOnly) {
|
|
352
|
-
// The one thing on stdout. Everything above went to stderr.
|
|
353
323
|
print(bundlePath);
|
|
354
324
|
exit(0);
|
|
355
325
|
}
|
|
@@ -1,106 +1,72 @@
|
|
|
1
1
|
import type { App } from '@gjsify/rolldown-plugin-gjsify';
|
|
2
2
|
export interface CliBuildOptions {
|
|
3
|
-
/**
|
|
4
|
-
* This is an array of files that each serve as an input to the bundling algorithm.
|
|
5
|
-
* @see https://esbuild.github.io/api/#entry-points
|
|
6
|
-
*/
|
|
3
|
+
/** Input files to the bundling algorithm. */
|
|
7
4
|
entryPoints?: string[];
|
|
8
|
-
/** Switch on the verbose mode */
|
|
9
5
|
verbose?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* When enabled, the generated code will be minified instead of pretty-printed.
|
|
12
|
-
* @see https://esbuild.github.io/api/#minify
|
|
13
|
-
*/
|
|
6
|
+
/** Minify the generated code instead of pretty-printing it. */
|
|
14
7
|
minify?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Override the default output format.
|
|
17
|
-
* @see https://esbuild.github.io/api/#format
|
|
18
|
-
*/
|
|
8
|
+
/** Override the default output format. */
|
|
19
9
|
format?: 'iife' | 'esm' | 'cjs';
|
|
20
|
-
/**
|
|
10
|
+
/** Build an application or test. `node` is mostly internal, for gjsify's tests. */
|
|
21
11
|
app?: App;
|
|
22
|
-
/**
|
|
12
|
+
/** Build a library rather than an application. */
|
|
23
13
|
library?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* This option sets the output file name for the build operation.
|
|
26
|
-
* This is only applicable if there is a single entry point.
|
|
27
|
-
* If there are multiple entry points, you must use the outdir option instead to specify an output directory.
|
|
28
|
-
* @see https://esbuild.github.io/api/#outfile
|
|
29
|
-
*/
|
|
14
|
+
/** Output file name. Single entry point only — otherwise use `outdir`. */
|
|
30
15
|
outfile?: string;
|
|
31
|
-
/**
|
|
32
|
-
* This option sets the output directory for the build operation.
|
|
33
|
-
* @see https://esbuild.github.io/api/#outdir
|
|
34
|
-
*/
|
|
35
16
|
outdir?: string;
|
|
36
|
-
/** Enables TypeScript types
|
|
17
|
+
/** Enables TypeScript types at runtime using Deepkit's type compiler. */
|
|
37
18
|
reflection?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* The log level can be changed to prevent esbuild from printing warning and/or error messages to the terminal
|
|
40
|
-
* @see https://esbuild.github.io/api/#log-level
|
|
41
|
-
*/
|
|
19
|
+
/** How much the bundler prints to the terminal. */
|
|
42
20
|
logLevel: 'silent' | 'error' | 'warning' | 'info' | 'debug' | 'verbose';
|
|
43
|
-
/**
|
|
21
|
+
/** Glob patterns excluding matches and aliases. */
|
|
44
22
|
exclude?: string[];
|
|
45
23
|
/**
|
|
46
|
-
* Inject a console shim into GJS builds for clean output (no GLib prefix,
|
|
47
|
-
*
|
|
24
|
+
* Inject a console shim into GJS app builds for clean output (no GLib prefix,
|
|
25
|
+
* working ANSI colors). Disable with `--no-console-shim`. Default: true.
|
|
48
26
|
*/
|
|
49
27
|
consoleShim?: boolean;
|
|
50
28
|
/**
|
|
51
|
-
* Comma-separated
|
|
52
|
-
* `"fetch,Buffer,process,URL,crypto"
|
|
53
|
-
*
|
|
54
|
-
* bundle. Only applies to GJS app builds.
|
|
29
|
+
* Comma-separated global identifiers the code needs, e.g.
|
|
30
|
+
* `"fetch,Buffer,process,URL,crypto"`. Each maps to the corresponding
|
|
31
|
+
* `@gjsify/<pkg>/register` module, injected into the bundle. GJS app builds only.
|
|
55
32
|
*/
|
|
56
33
|
globals?: string;
|
|
57
34
|
/**
|
|
58
|
-
* Prepend a `#!/usr/bin/env -S gjs -m` shebang
|
|
59
|
-
*
|
|
60
|
-
* `--outfile`. Default: false.
|
|
35
|
+
* Prepend a `#!/usr/bin/env -S gjs -m` shebang and chmod 755. GJS app builds with
|
|
36
|
+
* a single `--outfile` only. Default: false.
|
|
61
37
|
*/
|
|
62
38
|
shebang?: boolean;
|
|
63
39
|
/**
|
|
64
|
-
* Module names that
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* `--external typedoc,prettier --external typescript`. Glob-style wildcards
|
|
70
|
-
* (`@inquirer/*`, `lodash-*`) are forwarded as-is to esbuild.
|
|
71
|
-
*
|
|
72
|
-
* @see https://esbuild.github.io/api/#external
|
|
40
|
+
* Module names that must NOT be bundled: each stays a literal `import`/`require`
|
|
41
|
+
* in the output, resolved by the runtime at execution time. Repeat the flag or
|
|
42
|
+
* pass a comma-separated value (`--external typedoc,prettier --external
|
|
43
|
+
* typescript`); glob-style wildcards (`@inquirer/*`, `lodash-*`) pass through to
|
|
44
|
+
* the bundler unchanged.
|
|
73
45
|
*/
|
|
74
46
|
external?: string[];
|
|
75
47
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* upstream packages that read a build-time constant via
|
|
48
|
+
* Compile-time constants as `KEY=VALUE`, where `VALUE` is an arbitrary JS
|
|
49
|
+
* expression — string literals must be quoted (`--define VERSION='"1.2.3"'`).
|
|
50
|
+
* For upstream packages reading a build-time constant via
|
|
80
51
|
* `typeof __FOO__ !== 'undefined'`.
|
|
81
|
-
*
|
|
82
|
-
* @see https://esbuild.github.io/api/#define
|
|
83
52
|
*/
|
|
84
53
|
define?: string[];
|
|
85
54
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* scenario never executes). Layered on top of the built-in alias map.
|
|
55
|
+
* Remap module specifiers at bundle time as `FROM=TO`, typically to
|
|
56
|
+
* `@gjsify/empty` to drop a heavy dep the scenario never executes. Layered on top
|
|
57
|
+
* of the built-in alias map.
|
|
90
58
|
*/
|
|
91
59
|
alias?: string[];
|
|
92
60
|
/**
|
|
93
|
-
* Comma-separated global identifiers to
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* Example: `--exclude-globals fetch,XMLHttpRequest`
|
|
61
|
+
* Comma-separated global identifiers to drop from the auto-detected set — for
|
|
62
|
+
* false positives from dead browser-compat code in npm deps whose polyfills need
|
|
63
|
+
* unavailable native libraries. Example: `--exclude-globals fetch,XMLHttpRequest`.
|
|
97
64
|
*/
|
|
98
65
|
excludeGlobals?: string[];
|
|
99
66
|
/**
|
|
100
|
-
* Watch
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* npm `rolldown` engine — run under Node.
|
|
67
|
+
* Watch and rebuild on change; SIGINT/SIGTERM closes the watcher cleanly. Valid
|
|
68
|
+
* only with `--app gjs|node|browser`, rejected with `--library`, and requires the
|
|
69
|
+
* npm `rolldown` engine — so run it under Node.
|
|
104
70
|
*/
|
|
105
71
|
watch?: boolean;
|
|
106
72
|
}
|
package/lib/types/command.d.ts
CHANGED
|
@@ -8,19 +8,16 @@ export interface Command<T = unknown, U = T> {
|
|
|
8
8
|
deprecated?: boolean | string;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* A command that definitely runs something —
|
|
12
|
-
*
|
|
11
|
+
* A command that definitely runs something — every command except the
|
|
12
|
+
* builder-only parents. Annotate any command a standalone entry invokes directly.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* to the import closure of `src/index.ts`. Annotate a command that a standalone
|
|
22
|
-
* entry invokes directly with this type, and the guarantee is in the type
|
|
23
|
-
* instead of in a cast.
|
|
14
|
+
* `Command.handler` must stay optional for parent commands, but that optionality
|
|
15
|
+
* then lands on every CALL site, including those outside `cli-app.ts`'s yargs
|
|
16
|
+
* registration, where a missing handler is a silent no-op rather than a type
|
|
17
|
+
* error. `src/affected-entry.ts` — the entry `dist/affected.gjs.mjs` is built
|
|
18
|
+
* from — invoked `affectedCommand.handler(...)` through a cast that suppressed
|
|
19
|
+
* exactly that, unnoticed for as long as the tsconfig scoped the compile to the
|
|
20
|
+
* import closure of `src/index.ts`. This puts the guarantee in the type instead.
|
|
24
21
|
*/
|
|
25
22
|
export type LeafCommand<T = unknown, U = T> = Command<T, U> & {
|
|
26
23
|
handler: NonNullable<Command<T, U>['handler']>;
|