@skild/core 0.5.1 → 0.5.2
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/index.js +12 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -634,13 +634,22 @@ async function resolveRegistryAlias(registryUrl, alias) {
|
|
|
634
634
|
throw new SkildError("REGISTRY_RESOLVE_FAILED", `Failed to resolve alias "${a}" (${res.status}). ${text}`.trim());
|
|
635
635
|
}
|
|
636
636
|
const json = await res.json();
|
|
637
|
-
|
|
637
|
+
const normalizedSpec = normalizeResolvedSpec(json?.spec);
|
|
638
|
+
if (!json?.ok || !json.type || !normalizedSpec) {
|
|
638
639
|
throw new SkildError("REGISTRY_RESOLVE_FAILED", `Invalid registry response for alias "${a}".`);
|
|
639
640
|
}
|
|
640
|
-
if (json.type === "registry") return { type: "registry", spec:
|
|
641
|
-
if (json.type === "linked") return { type: "linked", spec:
|
|
641
|
+
if (json.type === "registry") return { type: "registry", spec: normalizedSpec };
|
|
642
|
+
if (json.type === "linked") return { type: "linked", spec: normalizedSpec };
|
|
642
643
|
throw new SkildError("REGISTRY_RESOLVE_FAILED", `Unsupported alias target type "${json.type}".`);
|
|
643
644
|
}
|
|
645
|
+
function normalizeResolvedSpec(spec) {
|
|
646
|
+
if (typeof spec !== "string") return "";
|
|
647
|
+
let normalized = spec.trim();
|
|
648
|
+
while (normalized.length >= 2 && (normalized.startsWith('"') && normalized.endsWith('"') || normalized.startsWith("'") && normalized.endsWith("'"))) {
|
|
649
|
+
normalized = normalized.slice(1, -1).trim();
|
|
650
|
+
}
|
|
651
|
+
return normalized;
|
|
652
|
+
}
|
|
644
653
|
async function downloadAndExtractTarball(resolved, tempRoot, stagingDir) {
|
|
645
654
|
const res = await fetchWithTimeout(resolved.tarballUrl, {}, 3e4);
|
|
646
655
|
if (!res.ok) {
|