@skild/core 0.5.0 → 0.5.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/index.d.ts +2 -1
- package/dist/index.js +26 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -159,6 +159,7 @@ declare function materializeSourceToTemp(source: string): Promise<{
|
|
|
159
159
|
}>;
|
|
160
160
|
|
|
161
161
|
declare function toDegitPath(url: string): string;
|
|
162
|
+
declare function stripSourceRef(source: string): string;
|
|
162
163
|
/**
|
|
163
164
|
* Derive a child source spec from a base source and a relative path.
|
|
164
165
|
*
|
|
@@ -244,4 +245,4 @@ declare function uninstallSkill(name: string, options?: InstallOptions & {
|
|
|
244
245
|
}): void;
|
|
245
246
|
declare function updateSkill(name?: string, options?: UpdateOptions): Promise<InstallRecord[]>;
|
|
246
247
|
|
|
247
|
-
export { DEFAULT_REGISTRY_URL, type DependencySourceType, type GlobalConfig, type InstallOptions, type InstallRecord, type InstallScope, type InstalledDependency, type ListOptions, type Lockfile, PLATFORMS, type Platform, type RegistryAuth, SkildError, type SkillFrontmatter, type SkillValidationIssue, type SkillValidationResult, type UpdateOptions, assertValidAlias, canonicalNameToInstallDirName, clearRegistryAuth, deriveChildSource, downloadAndExtractTarball, fetchWithTimeout, getSkillInfo, getSkillInstallDir, getSkillsDir, initSkill, installRegistrySkill, installSkill, isValidAlias, listAllSkills, listSkills, loadOrCreateGlobalConfig, loadRegistryAuth, materializeSourceToDir, materializeSourceToTemp, normalizeAlias, parseRegistrySpecifier, resolveRegistryAlias, resolveRegistryUrl, resolveRegistryVersion, saveRegistryAuth, searchRegistrySkills, splitCanonicalName, toDegitPath, uninstallSkill, updateSkill, validateSkill, validateSkillDir };
|
|
248
|
+
export { DEFAULT_REGISTRY_URL, type DependencySourceType, type GlobalConfig, type InstallOptions, type InstallRecord, type InstallScope, type InstalledDependency, type ListOptions, type Lockfile, PLATFORMS, type Platform, type RegistryAuth, SkildError, type SkillFrontmatter, type SkillValidationIssue, type SkillValidationResult, type UpdateOptions, assertValidAlias, canonicalNameToInstallDirName, clearRegistryAuth, deriveChildSource, downloadAndExtractTarball, fetchWithTimeout, getSkillInfo, getSkillInstallDir, getSkillsDir, initSkill, installRegistrySkill, installSkill, isValidAlias, listAllSkills, listSkills, loadOrCreateGlobalConfig, loadRegistryAuth, materializeSourceToDir, materializeSourceToTemp, normalizeAlias, parseRegistrySpecifier, resolveRegistryAlias, resolveRegistryUrl, resolveRegistryVersion, saveRegistryAuth, searchRegistrySkills, splitCanonicalName, stripSourceRef, toDegitPath, uninstallSkill, updateSkill, validateSkill, validateSkillDir };
|
package/dist/index.js
CHANGED
|
@@ -433,6 +433,11 @@ function toDegitPath(url) {
|
|
|
433
433
|
if (repoMatch) return repoMatch[1].replace(/\.git$/, "");
|
|
434
434
|
return url;
|
|
435
435
|
}
|
|
436
|
+
function stripSourceRef(source) {
|
|
437
|
+
const hashIndex = source.indexOf("#");
|
|
438
|
+
if (hashIndex === -1) return source;
|
|
439
|
+
return source.slice(0, hashIndex);
|
|
440
|
+
}
|
|
436
441
|
function normalizeRelPath(relPath) {
|
|
437
442
|
return relPath.split(path6.sep).join("/").replace(/^\/+/, "").replace(/\/+$/, "");
|
|
438
443
|
}
|
|
@@ -455,6 +460,24 @@ async function cloneRemote(degitSrc, targetPath) {
|
|
|
455
460
|
const emitter = degit(degitSrc, { force: true, verbose: false });
|
|
456
461
|
await emitter.clone(targetPath);
|
|
457
462
|
}
|
|
463
|
+
function isMissingRefError(error) {
|
|
464
|
+
if (!error) return false;
|
|
465
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
466
|
+
return /could not find commit hash/i.test(message);
|
|
467
|
+
}
|
|
468
|
+
async function cloneRemoteWithFallback(degitSrc, targetPath) {
|
|
469
|
+
try {
|
|
470
|
+
await cloneRemote(degitSrc, targetPath);
|
|
471
|
+
return degitSrc;
|
|
472
|
+
} catch (error) {
|
|
473
|
+
if (!degitSrc.includes("#") || !isMissingRefError(error)) {
|
|
474
|
+
throw error;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const fallbackSrc = stripSourceRef(degitSrc);
|
|
478
|
+
await cloneRemote(fallbackSrc, targetPath);
|
|
479
|
+
return fallbackSrc;
|
|
480
|
+
}
|
|
458
481
|
async function materializeSourceToDir(input) {
|
|
459
482
|
const sourceType = classifySource(input.source);
|
|
460
483
|
const targetDir = path7.resolve(input.targetDir);
|
|
@@ -472,8 +495,8 @@ async function materializeSourceToDir(input) {
|
|
|
472
495
|
return { sourceType: "local", materializedFrom: localPath };
|
|
473
496
|
}
|
|
474
497
|
const degitPath = toDegitPath(input.source);
|
|
475
|
-
await
|
|
476
|
-
return { sourceType, materializedFrom
|
|
498
|
+
const materializedFrom = await cloneRemoteWithFallback(degitPath, targetDir);
|
|
499
|
+
return { sourceType, materializedFrom };
|
|
477
500
|
}
|
|
478
501
|
async function materializeSourceToTemp(source) {
|
|
479
502
|
const sourceType = classifySource(source);
|
|
@@ -1202,6 +1225,7 @@ export {
|
|
|
1202
1225
|
saveRegistryAuth,
|
|
1203
1226
|
searchRegistrySkills,
|
|
1204
1227
|
splitCanonicalName,
|
|
1228
|
+
stripSourceRef,
|
|
1205
1229
|
toDegitPath,
|
|
1206
1230
|
uninstallSkill,
|
|
1207
1231
|
updateSkill,
|