Skip to content

Commit b974bc7

Browse files
committed
fix: add parsing progress for sync
1 parent 91233df commit b974bc7

File tree

1 file changed

+38
-15
lines changed
  • packages/clawdhub/src/cli/commands

1 file changed

+38
-15
lines changed

packages/clawdhub/src/cli/commands/sync.ts

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ type Candidate = SkillFolder & {
3434
latestVersion: string | null
3535
}
3636

37+
type LocalSkill = SkillFolder & {
38+
fingerprint: string
39+
fileCount: number
40+
}
41+
3742
export async function cmdSync(opts: GlobalOpts, options: SyncOptions, inputAllowed: boolean) {
3843
const allowPrompt = isInteractive() && inputAllowed !== false
3944
intro('ClawdHub sync')
@@ -61,14 +66,36 @@ export async function cmdSync(opts: GlobalOpts, options: SyncOptions, inputAllow
6166
spinner.stop()
6267
}
6368
const skills = scan.skills
64-
const candidatesSpinner = createSpinner('Checking registry sync state')
65-
const candidates: Candidate[] = []
66-
let supportsResolve: boolean | null = null
69+
const parsingSpinner = createSpinner('Parsing local skills')
70+
const locals: LocalSkill[] = []
6771
try {
72+
let index = 0
6873
for (const skill of skills) {
74+
index += 1
75+
parsingSpinner.text = `Parsing local skills ${index}/${skills.length}`
6976
const filesOnDisk = await listTextFiles(skill.folder)
7077
const hashed = hashSkillFiles(filesOnDisk)
71-
const fingerprint = hashed.fingerprint
78+
locals.push({
79+
...skill,
80+
fingerprint: hashed.fingerprint,
81+
fileCount: filesOnDisk.length,
82+
})
83+
}
84+
} catch (error) {
85+
parsingSpinner.fail(formatError(error))
86+
throw error
87+
} finally {
88+
parsingSpinner.stop()
89+
}
90+
91+
const candidatesSpinner = createSpinner('Checking registry sync state')
92+
const candidates: Candidate[] = []
93+
let supportsResolve: boolean | null = null
94+
try {
95+
let index = 0
96+
for (const skill of locals) {
97+
index += 1
98+
candidatesSpinner.text = `Checking registry sync state ${index}/${locals.length}`
7299

73100
const meta = await apiRequest(
74101
registry,
@@ -80,8 +107,6 @@ export async function cmdSync(opts: GlobalOpts, options: SyncOptions, inputAllow
80107
if (!latestVersion) {
81108
candidates.push({
82109
...skill,
83-
fingerprint,
84-
fileCount: filesOnDisk.length,
85110
status: 'new',
86111
matchVersion: null,
87112
latestVersion: null,
@@ -120,15 +145,13 @@ export async function cmdSync(opts: GlobalOpts, options: SyncOptions, inputAllow
120145
matchVersion = remote === fingerprint ? latestVersion : null
121146
}
122147

123-
candidates.push({
124-
...skill,
125-
fingerprint,
126-
fileCount: filesOnDisk.length,
127-
status: matchVersion ? 'synced' : 'update',
128-
matchVersion,
129-
latestVersion,
130-
})
131-
}
148+
candidates.push({
149+
...skill,
150+
status: matchVersion ? 'synced' : 'update',
151+
matchVersion,
152+
latestVersion,
153+
})
154+
}
132155
} catch (error) {
133156
candidatesSpinner.fail(formatError(error))
134157
throw error

0 commit comments

Comments
 (0)