claudepluginhub 0.5.0 → 0.6.0
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/download.js +20 -12
- package/dist/output.d.ts +1 -0
- package/dist/output.js +3 -0
- package/package.json +1 -1
package/dist/download.js
CHANGED
|
@@ -2,7 +2,7 @@ import { writeFileSync, mkdirSync, readFileSync, existsSync } from 'node:fs';
|
|
|
2
2
|
import { dirname, join, resolve, sep } from 'node:path';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { fetchDefaultBranch, fetchTree, downloadFile, findTreeSha, findBlobSha, listFilesUnder, } from './github.js';
|
|
5
|
-
import { printError } from './output.js';
|
|
5
|
+
import { printError, printProgress } from './output.js';
|
|
6
6
|
function getBaseDir(scope) {
|
|
7
7
|
if (scope === 'user') {
|
|
8
8
|
return join(homedir(), '.claude');
|
|
@@ -63,18 +63,26 @@ export async function downloadSkill(component, scope) {
|
|
|
63
63
|
printError(`Skipping unsafe skill name: ${componentName}`);
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
printProgress(`${componentName} (skill) — downloading ${files.length} file(s)...`);
|
|
67
|
+
const BATCH_SIZE = 5;
|
|
68
|
+
for (let i = 0; i < files.length; i += BATCH_SIZE) {
|
|
69
|
+
const batch = files.slice(i, i + BATCH_SIZE);
|
|
70
|
+
const results = await Promise.all(batch.map(async (file) => {
|
|
71
|
+
const relativePath = file.path.slice(dirPath.length + 1);
|
|
72
|
+
const destPath = join(installDir, relativePath);
|
|
73
|
+
if (!isSafePath(destPath, installDir)) {
|
|
74
|
+
printError(`Skipping unsafe path: ${file.path}`);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
const content = await downloadFile(source, branch, file.path);
|
|
78
|
+
if (content === null)
|
|
79
|
+
return false;
|
|
80
|
+
ensureDir(destPath);
|
|
81
|
+
writeFileSync(destPath, content);
|
|
82
|
+
return true;
|
|
83
|
+
}));
|
|
84
|
+
if (results.includes(false))
|
|
75
85
|
return null;
|
|
76
|
-
ensureDir(destPath);
|
|
77
|
-
writeFileSync(destPath, content);
|
|
78
86
|
}
|
|
79
87
|
const hash = findTreeSha(tree, dirPath) ?? 'unknown';
|
|
80
88
|
return {
|
package/dist/output.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare function printBanner(): void;
|
|
|
16
16
|
export declare function printWarning(message: string): void;
|
|
17
17
|
export declare function printStep(label: string): void;
|
|
18
18
|
export declare function printSuccess(label: string): void;
|
|
19
|
+
export declare function printProgress(label: string): void;
|
|
19
20
|
export declare function printFail(label: string, error?: string): void;
|
|
20
21
|
export declare function printSummary(results: {
|
|
21
22
|
name: string;
|
package/dist/output.js
CHANGED
|
@@ -28,6 +28,9 @@ export function printStep(label) {
|
|
|
28
28
|
export function printSuccess(label) {
|
|
29
29
|
print(` ${GREEN}ok${RESET} ${label}`);
|
|
30
30
|
}
|
|
31
|
+
export function printProgress(label) {
|
|
32
|
+
print(` ${DIM}↓${RESET} ${label}`);
|
|
33
|
+
}
|
|
31
34
|
export function printFail(label, error) {
|
|
32
35
|
print(` ${RED}fail${RESET} ${label}${error ? ` ${DIM}(${error})${RESET}` : ''}`);
|
|
33
36
|
}
|