@vegastack/design 0.8.34 → 0.8.35
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/bin/check-updates.mjs
CHANGED
|
@@ -272,7 +272,10 @@ function assertRegistryRequest(url, headers) {
|
|
|
272
272
|
parsed = new URL(url);
|
|
273
273
|
} catch {
|
|
274
274
|
// redact: an unparseable URL is still printed, and it may carry an interpolated secret.
|
|
275
|
-
|
|
275
|
+
// Never echoed: an unparseable URL may carry a password no parser can find to redact.
|
|
276
|
+
throw new Error(
|
|
277
|
+
"registry URL is invalid (not shown: it may carry credentials)",
|
|
278
|
+
);
|
|
276
279
|
}
|
|
277
280
|
if (parsed.username || parsed.password) {
|
|
278
281
|
throw new Error("registry URL must not contain embedded credentials");
|
|
@@ -960,7 +963,64 @@ export async function main(argv) {
|
|
|
960
963
|
return errors.length ? 2 : opts.failOnUpdate && updates.length ? 1 : 0;
|
|
961
964
|
}
|
|
962
965
|
|
|
963
|
-
|
|
966
|
+
/**
|
|
967
|
+
* The registry index, for another read-only command (`owned-files`): the same config precedence,
|
|
968
|
+
* `${ENV}` expansion, credential headers, trusted-origin and no-redirect rules as `check-updates`
|
|
969
|
+
* itself. Throws an Error whose message is already terminal-safe and redacted.
|
|
970
|
+
*/
|
|
971
|
+
export async function fetchRegistryIndex({
|
|
972
|
+
cwd,
|
|
973
|
+
registry = null,
|
|
974
|
+
componentsJson = null,
|
|
975
|
+
}) {
|
|
976
|
+
missingEnv.clear();
|
|
977
|
+
ENV = loadEnv(cwd);
|
|
978
|
+
const { urlTemplate, headers } = resolveRegistry(
|
|
979
|
+
{ registry },
|
|
980
|
+
componentsJson,
|
|
981
|
+
);
|
|
982
|
+
const url = indexUrl(urlTemplate);
|
|
983
|
+
// Printed without userinfo: a `user:password@` URL is refused, and must not be echoed either.
|
|
984
|
+
const shown = (() => {
|
|
985
|
+
try {
|
|
986
|
+
const u = new URL(url);
|
|
987
|
+
u.username = "";
|
|
988
|
+
u.password = "";
|
|
989
|
+
return terminalText(u.href);
|
|
990
|
+
} catch {
|
|
991
|
+
return "the configured registry URL";
|
|
992
|
+
}
|
|
993
|
+
})();
|
|
994
|
+
let res;
|
|
995
|
+
try {
|
|
996
|
+
res = await fetchRegistry(url, headers);
|
|
997
|
+
} catch (err) {
|
|
998
|
+
throw new Error(
|
|
999
|
+
`could not reach the registry at ${shown}: ${terminalText(err.message)}`,
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
if (!res.ok) {
|
|
1003
|
+
const hint = missingEnv.size
|
|
1004
|
+
? ` (these auth env vars are unset: ${[...missingEnv].join(", ")})`
|
|
1005
|
+
: "";
|
|
1006
|
+
throw new Error(
|
|
1007
|
+
`registry index fetch failed: HTTP ${res.status} ${terminalText(res.statusText)} (${shown})${hint}`,
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
let index;
|
|
1011
|
+
try {
|
|
1012
|
+
index = await res.json();
|
|
1013
|
+
} catch {
|
|
1014
|
+
// Never the parser's message: it quotes a truncated prefix of the body, which redaction of
|
|
1015
|
+
// whole secret values cannot catch.
|
|
1016
|
+
throw new Error(`registry index is not JSON (${shown})`);
|
|
1017
|
+
}
|
|
1018
|
+
if (!Array.isArray(index?.items))
|
|
1019
|
+
throw new Error("registry index has no items array");
|
|
1020
|
+
return { url: shown, items: index.items };
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
export { terminalText, PROVENANCE_RE, ITEM_NAME_RE };
|
|
964
1024
|
|
|
965
1025
|
// standalone execution (so `node check-updates.mjs` works; the dispatcher imports main() instead)
|
|
966
1026
|
if (
|