Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[expo cli] improve spinners #3654

Merged
merged 6 commits into from
Jul 13, 2021

Conversation

EvanBacon
Copy link
Contributor

@EvanBacon EvanBacon commented Jul 12, 2021

Why

Spinners seem to not work most of the time and it's hard to catch and fix, so I'm doing it all at once.

How

  • Disable spinners in EXPO_DEBUG mode, this just tends to work better because the spinners don't disappear, giving a slightly better debug log.

  • Fix spinner respect logic for progress bars and spinners -- the spinner/bar is pushed down while the log is printed above it, the default behavior is to copy the bar or spinner (undesired).

  • Make more spinners use the respect logic by default.

  • Fix unmounting logic.

  • When we resume a spinner, it should continue animating and not freeze when moved down.

  • When we respect spinners we shouldn't accidentally unpause them.

  • Fixed loader/spinner when downloading and installing the Expo Go apps

  • Removed an extra usage of expo/simple-spinner

  • Fixed server error / spinner style after cancelling during an adb process

Test Plan

I tried rolling some unit tests, but we disable the logs in a few places, so I found it easiest to just write some logging logic in expo start:

       let timeout;
        const bar = ora('name').start();
        Log.log('-- start');
        await new Promise<void>(res => {
          let i = 0;
          function tick() {
            timeout = setTimeout(() => {
              i++;
              // Log.log(`--- tick: ${i}`);
              if (i > 10) {
                res();
                bar.stopAndPersist();
                return;
              }
              tick();
            }, 50);
          }
          tick();
        });

        Log.log('-- end');

And for progress bars:

        let timeout;

        const bar = new ProgressBar('Building JavaScript bundle [:bar] :percent', {
          width: 64,
          total: 100,
          clear: true,
          complete: '=',
          incomplete: ' ',
        });
        Log.setBundleProgressBar(bar);

        Log.log('-- start');
        await new Promise<void>(res => {
          function tick() {
            timeout = setTimeout(() => {
              const percent = 50;

              const ticks = percent - bar.curr;
              Log.log(`--- tick: ${ticks}`);
              ticks > 0 && bar.tick(ticks);
              bar.tick();
              if (!bar || bar.complete) {
                res();
                return;
              }
              tick();
            }, 50);
          }
          tick();
        });

        Log.log('-- end');
@EvanBacon EvanBacon self-assigned this Jul 13, 2021
@EvanBacon EvanBacon marked this pull request as ready for review July 13, 2021 19:41
@EvanBacon EvanBacon merged commit 72f11c3 into master Jul 13, 2021
@EvanBacon EvanBacon deleted the @evanbacon/expo-cli/improve-debug-spinners branch July 13, 2021 20:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
1 participant