-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(deps): replace ora
and log-symbols
with tiny dependency yocto-spinner
#7026
base: main
Are you sure you want to change the base?
Conversation
This should reduce our package size. I also added some missing types along the way.
@@ -15,8 +15,7 @@ const preserveScripts = new Set([ | |||
'prepublishOnly', | |||
]) | |||
|
|||
let spinner = ora({ | |||
spinner: 'star', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is a CI script so I didn't bother preserving the exact styling
const DOTS_SPINNER = { | ||
interval: 80, | ||
frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'], | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the default in ora
, which we were implicitly using here.
runCommand(settings.command, { env: settings.env, spinner, cwd }) | ||
if (settings.command) { | ||
runCommand(settings.command, { env: settings.env, spinner, cwd }) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you scroll up you'll see we were already doing this in one branch but not the other. Adding some type safety uncovered this.
// @ts-expect-error TS(7006) FIXME: Parameter 'writeStream' implicitly has an 'any' ty... Remove this comment to see the full error message | ||
const pipeDataWithSpinner = (writeStream, chunk) => { | ||
if (spinner && spinner.isSpinning) { | ||
const pipeDataWithSpinner = (writeStream: NodeJS.WriteStream, chunk: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, chunk is literally typed as any
in the NodeJS types. This isn't a lazy type 😄.
if (spinner?.isSpinning) { | ||
spinner.clear() | ||
spinner.isSilent = true | ||
} | ||
writeStream.write(chunk, () => { | ||
if (spinner && spinner.isSpinning) { | ||
spinner.isSilent = false | ||
spinner.render() | ||
if (spinner?.isSpinning) { | ||
spinner.start() | ||
} | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to compare the docs for ora and yocto-spinner and double-check me here, but I think this should reproduce the behaviour. Of course I'll poke at it manually before considering merging.
Noooooooo |
@serhalp i would actually recommend using nanospinner or picospinner (if you need a little more control of rendering) particularly nanospinner has been adopted widely elsewhere so we can benefit from npm de-duplication by using it. its also generally faster/smaller (though these are all spinners so they're about as big/fast as each other...) and it uses picocolors, which again has been widely adopted as the colours library of choice, so will de-dupe well |
Summary
This should reduce our package size, which is huge. See https://github.com/sindresorhus/yocto-spinner.
I also added some missing types along the way.