Commit edb87d6
authored
feat(upgrade): progress bars for delta-patch apply and full download (#1281)
## What
`sentry upgrade` gives no feedback during its slow phases. This adds two
byte-driven progress bars.
- **Apply phase** (the slow part of a delta upgrade): a determinate bar
— `Applying 3 patch(es) [███████░░░░░░░░░] 22.1 MB / 45.0 MB`. Total is
the **final binary size** (the last patch's declared `newSize`), i.e.
the real output the user gets — not the sum of intermediate hop writes.
Progress is byte-driven across the whole chain, so it advances smoothly
rather than stalling per hop.
- **Full-binary download**: an indeterminate byte counter — `Downloading
38.0 MB`. The decompressed size isn't known ahead of time
(`Content-Length` covers only the compressed stream), so it shows an
honest live byte count, not a fake fraction.
Both bars are gated on interactive output via the existing
`isPlainOutput()`, so they self-suppress under `NO_COLOR`, piped stdout,
and CI.
## How
- New `src/lib/progress.ts` — `makeByteProgress(label, totalBytes)`.
Reuses the existing `formatBytes` (`formatters/numbers`) and
`isPlainOutput` (`formatters/plain-detect`) helpers. Cosmetic-only: a
render failure never aborts the upgrade, and **both** `onProgress` and
`done()` are guarded against throwing streams.
- An optional `onBytes` callback is threaded through
`applyReaderToMemory` / `applyReaderToFile` → `applyPatchChainInMemory`
→ `applyPatchChain`, reporting bytes-written per output chunk. Purely
additive — no behavior change to the apply/verify logic.
- Apply bar created in `applyChainAndReturn`; download bar in
`streamDecompressToFile`.
## Tests
`test/lib/progress.test.ts` (7): determinate/indeterminate rendering,
plain-output and non-TTY header-only behavior, byte accumulation,
full-bar clamping, and the never-throws contract —
**mutation-verified**: an unguarded `done()` turns the never-throws test
RED.
## Verification
- 22/22 (`progress` + `bspatch`) pass, `tsc --noEmit` clean, `biome
check` clean.
- Independent of #1279 (`MAX_OUTPUT_SIZE`) and #1280 (SWAR) — separate
file regions, no overlap.1 parent 9b0e23b commit edb87d6
7 files changed
Lines changed: 388 additions & 37 deletions
File tree
- src
- commands/cli
- lib
- test/lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
561 | | - | |
| 561 | + | |
| 562 | + | |
562 | 563 | | |
563 | 564 | | |
564 | 565 | | |
| |||
629 | 630 | | |
630 | 631 | | |
631 | 632 | | |
632 | | - | |
| 633 | + | |
| 634 | + | |
633 | 635 | | |
634 | 636 | | |
635 | 637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
684 | | - | |
| 684 | + | |
| 685 | + | |
685 | 686 | | |
686 | 687 | | |
687 | 688 | | |
| |||
703 | 704 | | |
704 | 705 | | |
705 | 706 | | |
| 707 | + | |
706 | 708 | | |
707 | 709 | | |
708 | 710 | | |
| |||
735 | 737 | | |
736 | 738 | | |
737 | 739 | | |
738 | | - | |
| 740 | + | |
| 741 | + | |
739 | 742 | | |
740 | 743 | | |
741 | 744 | | |
| |||
746 | 749 | | |
747 | 750 | | |
748 | 751 | | |
| 752 | + | |
749 | 753 | | |
750 | 754 | | |
751 | 755 | | |
| |||
794 | 798 | | |
795 | 799 | | |
796 | 800 | | |
797 | | - | |
| 801 | + | |
| 802 | + | |
798 | 803 | | |
799 | 804 | | |
800 | 805 | | |
| |||
812 | 817 | | |
813 | 818 | | |
814 | 819 | | |
815 | | - | |
| 820 | + | |
816 | 821 | | |
817 | 822 | | |
818 | 823 | | |
| |||
822 | 827 | | |
823 | 828 | | |
824 | 829 | | |
825 | | - | |
| 830 | + | |
826 | 831 | | |
827 | 832 | | |
828 | 833 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
835 | 836 | | |
836 | 837 | | |
837 | 838 | | |
| 839 | + | |
838 | 840 | | |
839 | 841 | | |
840 | 842 | | |
841 | 843 | | |
842 | | - | |
| 844 | + | |
| 845 | + | |
843 | 846 | | |
844 | 847 | | |
845 | 848 | | |
| |||
865 | 868 | | |
866 | 869 | | |
867 | 870 | | |
868 | | - | |
| 871 | + | |
| 872 | + | |
869 | 873 | | |
870 | 874 | | |
871 | 875 | | |
872 | 876 | | |
873 | 877 | | |
874 | | - | |
| 878 | + | |
| 879 | + | |
875 | 880 | | |
876 | 881 | | |
877 | 882 | | |
| |||
977 | 982 | | |
978 | 983 | | |
979 | 984 | | |
980 | | - | |
| 985 | + | |
| 986 | + | |
981 | 987 | | |
982 | | - | |
983 | | - | |
984 | | - | |
985 | | - | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
986 | 1009 | | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
987 | 1020 | | |
988 | 1021 | | |
989 | 1022 | | |
| |||
1002 | 1035 | | |
1003 | 1036 | | |
1004 | 1037 | | |
| 1038 | + | |
| 1039 | + | |
1005 | 1040 | | |
1006 | 1041 | | |
1007 | 1042 | | |
| |||
1021 | 1056 | | |
1022 | 1057 | | |
1023 | 1058 | | |
| 1059 | + | |
1024 | 1060 | | |
1025 | 1061 | | |
1026 | 1062 | | |
| |||
1029 | 1065 | | |
1030 | 1066 | | |
1031 | 1067 | | |
1032 | | - | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
1033 | 1074 | | |
1034 | 1075 | | |
1035 | 1076 | | |
| |||
1051 | 1092 | | |
1052 | 1093 | | |
1053 | 1094 | | |
1054 | | - | |
| 1095 | + | |
1055 | 1096 | | |
1056 | 1097 | | |
1057 | 1098 | | |
| |||
1062 | 1103 | | |
1063 | 1104 | | |
1064 | 1105 | | |
| 1106 | + | |
1065 | 1107 | | |
1066 | 1108 | | |
1067 | 1109 | | |
1068 | 1110 | | |
1069 | | - | |
| 1111 | + | |
| 1112 | + | |
1070 | 1113 | | |
1071 | 1114 | | |
1072 | 1115 | | |
| |||
1078 | 1121 | | |
1079 | 1122 | | |
1080 | 1123 | | |
| 1124 | + | |
1081 | 1125 | | |
1082 | 1126 | | |
1083 | 1127 | | |
| |||
1089 | 1133 | | |
1090 | 1134 | | |
1091 | 1135 | | |
| 1136 | + | |
1092 | 1137 | | |
1093 | 1138 | | |
1094 | 1139 | | |
1095 | 1140 | | |
1096 | | - | |
| 1141 | + | |
| 1142 | + | |
1097 | 1143 | | |
1098 | 1144 | | |
1099 | 1145 | | |
| |||
1102 | 1148 | | |
1103 | 1149 | | |
1104 | 1150 | | |
| 1151 | + | |
1105 | 1152 | | |
1106 | 1153 | | |
1107 | 1154 | | |
| |||
1178 | 1225 | | |
1179 | 1226 | | |
1180 | 1227 | | |
1181 | | - | |
| 1228 | + | |
| 1229 | + | |
1182 | 1230 | | |
1183 | 1231 | | |
1184 | 1232 | | |
| |||
1197 | 1245 | | |
1198 | 1246 | | |
1199 | 1247 | | |
1200 | | - | |
| 1248 | + | |
| 1249 | + | |
1201 | 1250 | | |
1202 | 1251 | | |
1203 | 1252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
0 commit comments