@gjsify/cli 0.37.0 → 0.38.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 +168 -168
- package/lib/actions/build.d.ts +7 -0
- package/lib/actions/build.js +18 -3
- package/lib/commands/showcase.js +9 -8
- package/lib/config.d.ts +14 -0
- package/lib/config.js +18 -1
- package/lib/templates/install.mjs.tmpl +188 -8
- package/lib/types/config-data.d.ts +12 -0
- package/lib/utils/bin-shim.d.ts +40 -25
- package/lib/utils/bin-shim.js +51 -26
- package/lib/utils/detect-native-packages.d.ts +6 -6
- package/lib/utils/detect-native-packages.js +8 -20
- package/lib/utils/node-script.js +9 -1
- package/lib/utils/publish-headers.d.ts +1 -0
- package/lib/utils/publish-headers.js +6 -1
- package/lib/utils/system-gi.d.ts +18 -0
- package/lib/utils/system-gi.js +25 -0
- package/package.json +18 -18
package/lib/utils/node-script.js
CHANGED
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
// injects the globals the script reads, and resolves bare
|
|
18
18
|
// specifiers), then run the bundle.
|
|
19
19
|
//
|
|
20
|
+
// "the globals the script reads" is auto-detection: a syntactic answer to a runtime question,
|
|
21
|
+
// blind to a dead branch. The script's own package overrides it through `gjsify.nodeScript` /
|
|
22
|
+
// `gjsify.globals` (`Config.forNodeScript`) — the shim path has no command line for a flag.
|
|
23
|
+
//
|
|
20
24
|
// `import.meta.url` is the whole trick: the bundle does not live where the source lives, and
|
|
21
25
|
// a script's own location is how it finds what it operates on — all four scripts this was
|
|
22
26
|
// built for derive their package root from `dirname(fileURLToPath(import.meta.url))`. Left
|
|
@@ -29,6 +33,7 @@ import { existsSync, statSync } from 'node:fs';
|
|
|
29
33
|
import { basename, resolve } from 'node:path';
|
|
30
34
|
import { pathToFileURL } from 'node:url';
|
|
31
35
|
import { hostRuntime } from '@gjsify/rolldown-plugin-gjsify/runtime';
|
|
36
|
+
import { Config } from '../config.js';
|
|
32
37
|
import { runGjsBundle } from './run-gjs.js';
|
|
33
38
|
import { runRuntimeBundle } from './run-node.js';
|
|
34
39
|
/**
|
|
@@ -73,6 +78,7 @@ export async function runNodeScript(file, extraArgs = [], options = {}) {
|
|
|
73
78
|
// Dynamic import keeps the bundler machinery out of the eager module graph
|
|
74
79
|
// of every `gjsify run`, matching how config.ts pulls it.
|
|
75
80
|
const { BuildAction } = await import('../actions/build.js');
|
|
81
|
+
const { globals, excludeGlobals } = await new Config().forNodeScript(scriptPath);
|
|
76
82
|
let bundlePath;
|
|
77
83
|
try {
|
|
78
84
|
bundlePath = await BuildAction.bundleFileForGjsCached(scriptPath, {
|
|
@@ -82,6 +88,8 @@ export async function runNodeScript(file, extraArgs = [], options = {}) {
|
|
|
82
88
|
// A script is executed, never imported — no default export to preserve.
|
|
83
89
|
preserveDefaultExport: false,
|
|
84
90
|
define: { 'import.meta.url': JSON.stringify(pathToFileURL(scriptPath).href) },
|
|
91
|
+
globals,
|
|
92
|
+
excludeGlobals,
|
|
85
93
|
});
|
|
86
94
|
}
|
|
87
95
|
catch (err) {
|
|
@@ -90,6 +98,6 @@ export async function runNodeScript(file, extraArgs = [], options = {}) {
|
|
|
90
98
|
`workspace packages, pure-JS npm deps). (${err.message})`);
|
|
91
99
|
}
|
|
92
100
|
// Quiet for the same reason as the node path above; the bundle's location is
|
|
93
|
-
// deterministic (`node_modules/.cache/gjsify/node-scripts/<name>-<hash>.mjs`).
|
|
101
|
+
// deterministic (`node_modules/.cache/gjsify/node-scripts/<name>-<hash>/<name>.mjs`).
|
|
94
102
|
await runGjsBundle(bundlePath, extraArgs, { exitOnSuccess: options.exitOnSuccess, quiet: true });
|
|
95
103
|
}
|
|
@@ -82,9 +82,14 @@ export function buildPublishHeaders(url, opts) {
|
|
|
82
82
|
* `lib/`, `dist/` and an installed `node_modules/@gjsify/cli/**` alike.
|
|
83
83
|
*
|
|
84
84
|
* `GJSIFY_CLI_PACKAGE_JSON` overrides both, matching `self-update.ts`.
|
|
85
|
+
*
|
|
86
|
+
* Exported because `showcase` needs the SAME answer rather than a fourth
|
|
87
|
+
* resolver: it PINS the showcase package to this version, so a version it cannot
|
|
88
|
+
* read is a showcase left unpinned and `dlx` serves a stale cached one
|
|
89
|
+
* (`docs/code-anti-patterns.md`). Returns `'unknown'`, never `undefined`.
|
|
85
90
|
*/
|
|
86
91
|
let cachedCliVersion;
|
|
87
|
-
function cliVersion() {
|
|
92
|
+
export function cliVersion() {
|
|
88
93
|
if (cachedCliVersion !== undefined)
|
|
89
94
|
return cachedCliVersion;
|
|
90
95
|
cachedCliVersion =
|
package/lib/utils/system-gi.d.ts
CHANGED
|
@@ -60,3 +60,21 @@ export declare function systemGiLibraryDirs({ platform, env, existsDir, searchDi
|
|
|
60
60
|
* pins both.
|
|
61
61
|
*/
|
|
62
62
|
export declare function pathCovers(wanted: readonly string[], current: readonly string[]): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* dyld's OWN default fallback list, verbatim from `dyld(1)`. Setting
|
|
65
|
+
* `DYLD_FALLBACK_LIBRARY_PATH` REPLACES it, so anything composed for that
|
|
66
|
+
* variable must carry it as a tail. The incident that bought this rule is in the
|
|
67
|
+
* ORIGINAL (`packages/node-gi/node-gi/system-gi.js`); the mirror does not
|
|
68
|
+
* restate it.
|
|
69
|
+
*/
|
|
70
|
+
export declare function dyldDefaultFallbackDirs(env?: Record<string, string | undefined>): string[];
|
|
71
|
+
/**
|
|
72
|
+
* Compose a `DYLD_FALLBACK_LIBRARY_PATH` value: `wanted`, then the launching
|
|
73
|
+
* environment's own value, then {@link dyldDefaultFallbackDirs} —
|
|
74
|
+
* unconditionally, so a child launched through gjsify never searches LESS than
|
|
75
|
+
* one launched without it. Deduplicated: `systemGiLibraryDirs()` can legitimately
|
|
76
|
+
* yield a directory the tail also names, and a repeated entry costs the loader a
|
|
77
|
+
* second stat on every miss. First occurrence wins everywhere, so dropping later
|
|
78
|
+
* repeats is behaviour-preserving.
|
|
79
|
+
*/
|
|
80
|
+
export declare function composeDyldFallback(wanted: readonly string[], env?: Record<string, string | undefined>): string;
|
package/lib/utils/system-gi.js
CHANGED
|
@@ -174,3 +174,28 @@ export function systemGiLibraryDirs({ platform = process.platform, env = process
|
|
|
174
174
|
export function pathCovers(wanted, current) {
|
|
175
175
|
return wanted.every((dir) => current.includes(dir));
|
|
176
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* dyld's OWN default fallback list, verbatim from `dyld(1)`. Setting
|
|
179
|
+
* `DYLD_FALLBACK_LIBRARY_PATH` REPLACES it, so anything composed for that
|
|
180
|
+
* variable must carry it as a tail. The incident that bought this rule is in the
|
|
181
|
+
* ORIGINAL (`packages/node-gi/node-gi/system-gi.js`); the mirror does not
|
|
182
|
+
* restate it.
|
|
183
|
+
*/
|
|
184
|
+
export function dyldDefaultFallbackDirs(env = process.env) {
|
|
185
|
+
const home = env['HOME'];
|
|
186
|
+
return [...(home ? [`${home}/lib`] : []), '/usr/local/lib', '/lib', '/usr/lib'];
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Compose a `DYLD_FALLBACK_LIBRARY_PATH` value: `wanted`, then the launching
|
|
190
|
+
* environment's own value, then {@link dyldDefaultFallbackDirs} —
|
|
191
|
+
* unconditionally, so a child launched through gjsify never searches LESS than
|
|
192
|
+
* one launched without it. Deduplicated: `systemGiLibraryDirs()` can legitimately
|
|
193
|
+
* yield a directory the tail also names, and a repeated entry costs the loader a
|
|
194
|
+
* second stat on every miss. First occurrence wins everywhere, so dropping later
|
|
195
|
+
* repeats is behaviour-preserving.
|
|
196
|
+
*/
|
|
197
|
+
export function composeDyldFallback(wanted, env = process.env) {
|
|
198
|
+
return [
|
|
199
|
+
...new Set([...wanted, ...splitSearchPath(env['DYLD_FALLBACK_LIBRARY_PATH']), ...dyldDefaultFallbackDirs(env)]),
|
|
200
|
+
].join(':');
|
|
201
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.1",
|
|
4
4
|
"description": "CLI for Gjsify",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -134,20 +134,20 @@
|
|
|
134
134
|
"cli"
|
|
135
135
|
],
|
|
136
136
|
"dependencies": {
|
|
137
|
-
"@gjsify/buffer": "^0.
|
|
138
|
-
"@gjsify/create-app": "^0.
|
|
139
|
-
"@gjsify/node-globals": "^0.
|
|
140
|
-
"@gjsify/node-polyfills": "^0.
|
|
141
|
-
"@gjsify/npm-registry": "^0.
|
|
142
|
-
"@gjsify/resolve-npm": "^0.
|
|
143
|
-
"@gjsify/rolldown-plugin-gjsify": "^0.
|
|
144
|
-
"@gjsify/vite-plugin-blueprint": "^0.
|
|
145
|
-
"@gjsify/rolldown-plugin-pnp": "^0.
|
|
146
|
-
"@gjsify/semver": "^0.
|
|
147
|
-
"@gjsify/tar": "^0.
|
|
148
|
-
"@gjsify/tsc": "^0.
|
|
149
|
-
"@gjsify/web-polyfills": "^0.
|
|
150
|
-
"@gjsify/workspace": "^0.
|
|
137
|
+
"@gjsify/buffer": "^0.38.1",
|
|
138
|
+
"@gjsify/create-app": "^0.38.1",
|
|
139
|
+
"@gjsify/node-globals": "^0.38.1",
|
|
140
|
+
"@gjsify/node-polyfills": "^0.38.1",
|
|
141
|
+
"@gjsify/npm-registry": "^0.38.1",
|
|
142
|
+
"@gjsify/resolve-npm": "^0.38.1",
|
|
143
|
+
"@gjsify/rolldown-plugin-gjsify": "^0.38.1",
|
|
144
|
+
"@gjsify/vite-plugin-blueprint": "^0.38.1",
|
|
145
|
+
"@gjsify/rolldown-plugin-pnp": "^0.38.1",
|
|
146
|
+
"@gjsify/semver": "^0.38.1",
|
|
147
|
+
"@gjsify/tar": "^0.38.1",
|
|
148
|
+
"@gjsify/tsc": "^0.38.1",
|
|
149
|
+
"@gjsify/web-polyfills": "^0.38.1",
|
|
150
|
+
"@gjsify/workspace": "^0.38.1",
|
|
151
151
|
"cosmiconfig": "^9.0.2",
|
|
152
152
|
"get-tsconfig": "^4.14.0",
|
|
153
153
|
"pkg-types": "^2.3.1",
|
|
@@ -155,13 +155,13 @@
|
|
|
155
155
|
"yargs": "^18.0.0"
|
|
156
156
|
},
|
|
157
157
|
"devDependencies": {
|
|
158
|
-
"@gjsify/unit": "^0.
|
|
158
|
+
"@gjsify/unit": "^0.38.1",
|
|
159
159
|
"@types/yargs": "^17.0.35",
|
|
160
160
|
"typescript": "^6.0.3"
|
|
161
161
|
},
|
|
162
162
|
"peerDependencies": {
|
|
163
|
-
"@gjsify/oxfmt-native": "^0.
|
|
164
|
-
"@gjsify/rolldown-native": "^0.
|
|
163
|
+
"@gjsify/oxfmt-native": "^0.38.1",
|
|
164
|
+
"@gjsify/rolldown-native": "^0.38.1"
|
|
165
165
|
},
|
|
166
166
|
"peerDependenciesMeta": {
|
|
167
167
|
"@gjsify/oxfmt-native": {
|