@skild/core 0.10.3 → 0.10.17
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 +29 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -456,8 +456,12 @@ function ensureInstallableDir(sourcePath) {
|
|
|
456
456
|
throw new SkildError("NOT_A_DIRECTORY", `Source path is not a directory: ${sourcePath}`, { sourcePath });
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
|
-
|
|
460
|
-
|
|
459
|
+
function resetTargetDir(targetPath) {
|
|
460
|
+
removeDir(targetPath);
|
|
461
|
+
fs6.mkdirSync(targetPath, { recursive: true });
|
|
462
|
+
}
|
|
463
|
+
async function cloneRemote(degitSrc, targetPath, mode) {
|
|
464
|
+
const emitter = degit(degitSrc, { force: true, verbose: false, mode });
|
|
461
465
|
await emitter.clone(targetPath);
|
|
462
466
|
}
|
|
463
467
|
function isMissingRefError(error) {
|
|
@@ -466,17 +470,31 @@ function isMissingRefError(error) {
|
|
|
466
470
|
return /could not find commit hash/i.test(message);
|
|
467
471
|
}
|
|
468
472
|
async function cloneRemoteWithFallback(degitSrc, targetPath) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
473
|
+
const fallbackSrc = degitSrc.includes("#") ? stripSourceRef(degitSrc) : degitSrc;
|
|
474
|
+
const candidates = [
|
|
475
|
+
{ src: degitSrc, mode: "git" }
|
|
476
|
+
];
|
|
477
|
+
if (fallbackSrc !== degitSrc) {
|
|
478
|
+
candidates.push({ src: fallbackSrc, mode: "git" });
|
|
479
|
+
}
|
|
480
|
+
candidates.push({ src: degitSrc, mode: "tar" });
|
|
481
|
+
if (fallbackSrc !== degitSrc) {
|
|
482
|
+
candidates.push({ src: fallbackSrc, mode: "tar" });
|
|
483
|
+
}
|
|
484
|
+
let lastError;
|
|
485
|
+
for (const candidate of candidates) {
|
|
486
|
+
try {
|
|
487
|
+
resetTargetDir(targetPath);
|
|
488
|
+
await cloneRemote(candidate.src, targetPath, candidate.mode);
|
|
489
|
+
return candidate.src;
|
|
490
|
+
} catch (error) {
|
|
491
|
+
lastError = error;
|
|
492
|
+
if (candidate.src === degitSrc && isMissingRefError(error)) {
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
475
495
|
}
|
|
476
496
|
}
|
|
477
|
-
|
|
478
|
-
await cloneRemote(fallbackSrc, targetPath);
|
|
479
|
-
return fallbackSrc;
|
|
497
|
+
throw lastError;
|
|
480
498
|
}
|
|
481
499
|
async function materializeSourceToDir(input) {
|
|
482
500
|
const sourceType = classifySource(input.source);
|