@gjsify/cli 0.26.1 → 0.27.1
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 +188 -183
- package/lib/bundler-pick.js +12 -4
- package/lib/cli-app.js +3 -1
- package/lib/commands/affected.js +1 -1
- package/lib/commands/build.js +21 -14
- package/lib/commands/check.js +40 -4
- package/lib/commands/clear.d.ts +8 -0
- package/lib/commands/clear.js +90 -0
- package/lib/commands/copy.d.ts +8 -0
- package/lib/commands/copy.js +87 -0
- package/lib/commands/dlx.js +8 -1
- package/lib/commands/index.d.ts +2 -0
- package/lib/commands/index.js +2 -0
- package/lib/commands/install.d.ts +4 -0
- package/lib/commands/install.js +164 -15
- package/lib/commands/onboard.js +17 -14
- package/lib/commands/pack.d.ts +32 -0
- package/lib/commands/pack.js +11 -2
- package/lib/commands/publish.js +18 -4
- package/lib/commands/storybook.js +5 -1
- package/lib/commands/test.js +29 -2
- package/lib/commands/uninstall.js +44 -2
- package/lib/commands/upgrade.js +1 -4
- package/lib/templates/install.mjs.tmpl +110 -19
- package/lib/utils/bin-shim.d.ts +73 -0
- package/lib/utils/bin-shim.js +97 -2
- package/lib/utils/build-cache.d.ts +7 -27
- package/lib/utils/build-cache.js +27 -2
- package/lib/utils/check-system-deps.d.ts +15 -1
- package/lib/utils/check-system-deps.js +126 -2
- package/lib/utils/clear-targets.d.ts +30 -0
- package/lib/utils/clear-targets.js +114 -0
- package/lib/utils/copy-targets.d.ts +41 -0
- package/lib/utils/copy-targets.js +145 -0
- package/lib/utils/detect-native-packages.d.ts +160 -5
- package/lib/utils/detect-native-packages.js +326 -50
- package/lib/utils/dir-link.d.ts +34 -6
- package/lib/utils/dir-link.js +23 -9
- package/lib/utils/install-backend-native.d.ts +109 -1
- package/lib/utils/install-backend-native.js +622 -59
- package/lib/utils/install-backend.js +17 -15
- package/lib/utils/install-global.js +6 -34
- package/lib/utils/install-lock.js +1 -1
- package/lib/utils/install-packument-cache.d.ts +36 -17
- package/lib/utils/install-packument-cache.js +59 -31
- package/lib/utils/oxc-resolve.d.ts +27 -1
- package/lib/utils/oxc-resolve.js +53 -26
- package/lib/utils/pkg-json.d.ts +24 -0
- package/lib/utils/pkg-json.js +27 -1
- package/lib/utils/platform-check.d.ts +215 -0
- package/lib/utils/platform-check.js +377 -0
- package/lib/utils/resolve-npm-package.js +9 -2
- package/lib/utils/run-gjs.d.ts +1 -1
- package/lib/utils/run-gjs.js +19 -3
- package/lib/utils/spawn.js +50 -2
- package/lib/utils/win32-command.d.ts +54 -0
- package/lib/utils/win32-command.js +140 -0
- package/package.json +19 -20
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Packument } from '@gjsify/npm-registry';
|
|
2
2
|
import type { InstallOptions } from './install-backend.ts';
|
|
3
|
+
import { type PlatformDeclaration, type PlatformTarget } from './platform-check.js';
|
|
3
4
|
interface ParsedSpec {
|
|
4
5
|
name: string;
|
|
5
6
|
range: string;
|
|
@@ -19,12 +20,105 @@ interface ResolvedNode {
|
|
|
19
20
|
/** `optionalDependencies` field from the packument. */
|
|
20
21
|
optionalDependencies: Record<string, string>;
|
|
21
22
|
bin?: string | Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* The version's `os`/`cpu`/`libc` declaration, as published. Recorded on the
|
|
25
|
+
* node (and in the lockfile) so the compatibility VERDICT can be recomputed
|
|
26
|
+
* for whichever host runs the install — see the header note on portability.
|
|
27
|
+
*
|
|
28
|
+
* Read from the FULL packument, which is the only document that carries
|
|
29
|
+
* `libc`. That is not an optimisation detail leaking into a comment: the
|
|
30
|
+
* abbreviated document can never PROVE the absence of a `libc` restriction,
|
|
31
|
+
* so a declaration built from it would be silently incomplete for exactly
|
|
32
|
+
* the packages the field exists for (this repo publishes nine of them —
|
|
33
|
+
* `@gjsify/{rolldown,lightningcss,oxfmt}-native`, `webgl`, `napi`,
|
|
34
|
+
* `sab-native`, `terminal-native`, `http2-native`, `http-soup-bridge` all
|
|
35
|
+
* declare `libc: ["glibc"]` and NO `os`/`cpu`).
|
|
36
|
+
*/
|
|
37
|
+
platform?: PlatformDeclaration;
|
|
38
|
+
/**
|
|
39
|
+
* Is this node reachable ONLY through optionalDependency edges? Decides what
|
|
40
|
+
* an incompatible platform means: skip silently (optional) vs. fail the
|
|
41
|
+
* install (required). npm calls the same set `optionalSet`.
|
|
42
|
+
*
|
|
43
|
+
* DERIVED, not an input — {@link computeOptionalFlags} recomputes it as a
|
|
44
|
+
* fixpoint over the placed graph before anything reads it, on the fresh-
|
|
45
|
+
* resolve AND the lockfile path. The value the BFS assigns at placement time
|
|
46
|
+
* is a forward guess used only to decide whether a resolve FAILURE under this
|
|
47
|
+
* node is tolerated; it is edge-order-dependent and must never be the final
|
|
48
|
+
* answer (header note, invariant 2).
|
|
49
|
+
*
|
|
50
|
+
* OPTIONAL FIELD, and absent must read as `false` (= required): nodes are
|
|
51
|
+
* also built structurally by callers that only care about name/installPath,
|
|
52
|
+
* and the safe default for an unknown edge kind is the loud one — a required
|
|
53
|
+
* incompatible dependency fails the install instead of being silently
|
|
54
|
+
* dropped from the tree.
|
|
55
|
+
*/
|
|
56
|
+
optional?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Set by {@link applyPlatformFilter}: this node cannot run on the install
|
|
59
|
+
* target, so it is not downloaded or extracted. Never persisted — it is a
|
|
60
|
+
* per-host verdict, not a property of the resolution.
|
|
61
|
+
*/
|
|
62
|
+
inert?: boolean;
|
|
22
63
|
}
|
|
23
64
|
export interface InstalledTopLevel {
|
|
24
65
|
name: string;
|
|
25
66
|
version: string;
|
|
26
67
|
}
|
|
27
|
-
|
|
68
|
+
/**
|
|
69
|
+
* {@link InstallOptions} plus what only the NATIVE backend can use.
|
|
70
|
+
*
|
|
71
|
+
* `optionalSpecs` exists because a spec is a flat `"<name>@<range>"` string by
|
|
72
|
+
* the time it reaches here — `projectSpecsFromPackageJson` flattens
|
|
73
|
+
* `dependencies`, `devDependencies` and `optionalDependencies` into one list —
|
|
74
|
+
* yet the KIND decides what an incompatible `os`/`cpu`/`libc` means: an optional
|
|
75
|
+
* dependency is skipped, a required one fails the install. The shape that makes
|
|
76
|
+
* this concrete is `optionalDependencies: { fsevents }` in a project's own
|
|
77
|
+
* manifest: on Linux npm leaves fsevents out and installs fine, so treating
|
|
78
|
+
* every top-level spec as required would turn that into a hard EBADPLATFORM for
|
|
79
|
+
* a package nothing on the host would ever load.
|
|
80
|
+
*
|
|
81
|
+
* It rides the SAME options object `install-backend.ts` forwards wholesale to
|
|
82
|
+
* this function. If that forwarding is ever changed to destructure, this field
|
|
83
|
+
* must be forwarded with it — otherwise top-level optional deps quietly become
|
|
84
|
+
* required again (and the `install-platform-filter` e2e goes red, which is where
|
|
85
|
+
* that assumption is pinned).
|
|
86
|
+
*/
|
|
87
|
+
export interface NativeInstallOptions extends InstallOptions {
|
|
88
|
+
/**
|
|
89
|
+
* Names (not spec strings — the range differs per requester) of top-level
|
|
90
|
+
* specs declared as `optionalDependencies`. Absent ⇒ every top-level spec is
|
|
91
|
+
* required, the pre-platform-filter behaviour.
|
|
92
|
+
*/
|
|
93
|
+
optionalSpecs?: Set<string>;
|
|
94
|
+
}
|
|
95
|
+
export declare function installPackagesNative(opts: NativeInstallOptions): Promise<InstalledTopLevel[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Split a resolved tree into what THIS target can install, marking the rest
|
|
98
|
+
* inert. Mirrors arborist's post-resolve platform pass
|
|
99
|
+
* (`refs/npm-cli/workspaces/arborist/lib/arborist/build-ideal-tree.js`, the
|
|
100
|
+
* `checkPlatform` loop around line 210) rather than filtering during the walk,
|
|
101
|
+
* for two reasons: the verdict must be identical whether the tree came from a
|
|
102
|
+
* fresh resolve or from `gjsify-lock.json`, and a node's optionality is only
|
|
103
|
+
* final once every edge that could reach it has been visited.
|
|
104
|
+
*
|
|
105
|
+
* The two outcomes are npm's, including the asymmetry around `force`:
|
|
106
|
+
* - REQUIRED + incompatible → EBADPLATFORM. A required dependency the host
|
|
107
|
+
* cannot run is a broken install, not a smaller one; failing loudly with
|
|
108
|
+
* `pkgid`/`current`/`required` is the only honest answer. `--force`
|
|
109
|
+
* suppresses it (the user is asserting something about their own machine).
|
|
110
|
+
* - OPTIONAL + incompatible → inert: not downloaded, not extracted, still in
|
|
111
|
+
* the lockfile. `--force` does NOT lift this — npm says so in as many words
|
|
112
|
+
* ("We ignore the --force and --engine-strict flags") and it is right:
|
|
113
|
+
* forcing an optional binary that cannot load buys a download and nothing
|
|
114
|
+
* else.
|
|
115
|
+
*
|
|
116
|
+
* The skip line goes through the debug logger with npm's `current`/`required`
|
|
117
|
+
* payload, so `--verbose` recovers exactly WHY a package is absent. Silence
|
|
118
|
+
* here is what made the original defect invisible in the other direction: 3.67
|
|
119
|
+
* GB arrived with no line saying it should not have.
|
|
120
|
+
*/
|
|
121
|
+
export declare function applyPlatformFilter(nodes: ResolvedNode[], target: PlatformTarget, force: boolean, log: Logger): ResolvedNode[];
|
|
28
122
|
/**
|
|
29
123
|
* Warn about a native package that installed WITHOUT a usable binary.
|
|
30
124
|
*
|
|
@@ -64,6 +158,20 @@ export declare function writeBinEntry(opts: {
|
|
|
64
158
|
binName: string;
|
|
65
159
|
targetAbs: string;
|
|
66
160
|
platform?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Set when this entry is the package's GJS-runnable artifact (declared via
|
|
163
|
+
* `gjsify.bin`). Then the entry is a GENERATED launcher rather than a link
|
|
164
|
+
* to a file with a shebang — see {@link buildShLauncher} for why, and
|
|
165
|
+
* {@link pickBinMap} for why `gjsify.bin` has to win here at all.
|
|
166
|
+
*
|
|
167
|
+
* The preamble is what exports `GI_TYPELIB_PATH` / the loader path before
|
|
168
|
+
* `gjs` starts. It cannot be done from inside the bundle: GI resolves the
|
|
169
|
+
* typelib while the runtime boots, before the first line runs.
|
|
170
|
+
*/
|
|
171
|
+
gjs?: {
|
|
172
|
+
envPreamble: string;
|
|
173
|
+
prebuildDirs: readonly string[];
|
|
174
|
+
};
|
|
67
175
|
}): void;
|
|
68
176
|
type Logger = (fmt: string, ...args: unknown[]) => void;
|
|
69
177
|
export {};
|