Repository navigation
build(deps): replace ora with yocto-spinner - #369
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R1iLgtNj9JZPkuSQCZbGfR
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Cousin to electron/docs-parser#214 and we'll drop ora out of the lockfile once this repo picks up a newer release of |
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🟡
src/bin.ts— When generation fails in an interactive terminal, users may be left with a hidden cursor after the CLI exits, which does not happen on the base branch. The.catchhandler callsconsole.error(err)andprocess.exit(1)while the spinner is still running. As I recall it, yocto-spinner only restores the cursor on SIGINT/SIGTERM, not on 'exit', while ora's cli-cursor/restore-cursor did. Fix: stop the spinner before exiting, e.g.runner.error(chalk.red('Failed to generate definitions'))and thenconsole.error(err)andprocess.exit(1).Why this was flagged
I could not install yocto-spinner here to check its source, so this assumes, from my reading of yocto-spinner 1.2.2, that start() hides the cursor with '\u001B[?25l' on a TTY and that its only restore hooks are process.once('SIGINT') and process.once('SIGTERM'). The trigger is any failure in generateDefinitions, JSON.parse or writeFile, for example a malformed --api JSON file. That error goes to the
.catchat src/bin.ts:77-80, which calls process.exit(1) without stoppingrunner. Calling process.exit fires 'exit', not a signal, so with yocto-spinner the cursor stays hidden in the user's shell and the last spinner frame stays on the line in front of the error. On the base branch, ora 8 hides the cursor through cli-cursor, which registers restore-cursor's signal-exit onExit hook, so the cursor came back on process.exit(1). The two argv-error paths are not affected because runner.error() stops the spinner first.Verification: Trigger: generation fails while the CLI runs in an interactive terminal. The handler at src/bin.ts:77-80 runs
console.error(err); process.exit(1);and never callsrunner.stop()orrunner.error(). On the base branch, restore-cursor registers an onExit hook that writes\u001B[?25h, so ora's hidden cursor comes back. Nothing runs on 'exit', soprocess.exit(1)leaves the cursor hidden.
yocto-spinner only restores the hidden cursor on SIGINT/SIGTERM, not on process exit (ora did this via restore-cursor). Stop the spinner with an error mark before exiting, and attach the handler to the outer promise chain so read/parse failures of the --api file are covered too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R1iLgtNj9JZPkuSQCZbGfR
|
Confirmed the cursor-restore finding (in a pseudo-TTY, a failing run left the cursor hidden with yocto-spinner but not with ora) and fixed it in 3eceda3 by stopping the spinner with an error mark before exiting; the handler now also covers read/parse failures of the Generated by Claude Code |
|
🎉 This PR is included in version 10.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Requested by David Babenko-Sanders · Slack thread
This replaces
orawithyocto-spinnerfor the CLI spinner insrc/bin.ts, the same change as electron/docs-parser#214.yocto-spinnerhas one small dependency (yoctocolors), whileorabrings in 17 packages besideschalk, so the published package's runtime dependency tree drops by a net 15 packages. This repo'syarn.lockactually grows by 2 entries for now, because the@electron/docs-parser@^2.0.0devDependency still depends onora; the ora tree will leave the lockfile once a docs-parser release that includes #214 is picked up. The API maps directly:ora(text).start()becomesyoctoSpinner({ text }).start(),.text =stays the same,.succeed()becomes.success()and.fail()becomes.error(). The generatedelectron.d.tsis byte-identical, and the TTY output looks the same apart from spinner frames. Piped (non-TTY) output is a little different:yocto-spinnerprints each text update as its own line, so the "Generating API in directory" step now appears in CI logs, and it colors the status symbol unlessNO_COLORis set.Generated by Claude Code