• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

UiPath / uipathcli / 13967189571

20 Mar 2025 10:30AM UTC coverage: 90.475% (+0.004%) from 90.471%
13967189571

Pull #167

github

thschmitt
Add support for authenticated library feeds

Use the provided auth token from the configured identity client
to authenticate with the connected Orchestrator when restoring packages
so that library packages can be retrieved from authenticated feeds.

Extended the `uipath studio package pack` and `uipath studio test run`
commands to use the existing auth token for authentication with the
Orchestrator feeds.

Implementation details:

- Using the latest uipcli which supports JWT bearer tokens and passing
  the short-lived token to the uipcli.

- Reduced the boilerplate in the studio plugin tests.

Issue: https://github.com/UiPath/uipathcli/issues/149
Pull Request #167: Add support for authenticated library feeds

54 of 60 new or added lines in 3 files covered. (90.0%)

2 existing lines in 1 file now uncovered.

5946 of 6572 relevant lines covered (90.47%)

1.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.48
/utils/visualization/progress_bar.go
1
package visualization
2

3
import (
4
        "fmt"
5
        "math"
6
        "strings"
7
        "unicode/utf8"
8

9
        "github.com/UiPath/uipathcli/log"
10
)
11

12
// The ProgressBar helps rendering a text-based progress indicator on the command-line.
13
// It uses the standard error output interface of the logger for writing progress.
14
type ProgressBar struct {
15
        logger         log.Logger
16
        renderedLength int
17
}
18

19
func (b *ProgressBar) UpdateSteps(text string, current int, total int) {
1✔
20
        b.logger.LogError("\r")
1✔
21
        percent := 0.1
1✔
22
        if total > 0 {
2✔
23
                percent = float64(current) / float64(total) * 100
1✔
24
        }
1✔
25
        steps := fmt.Sprintf(" (%d/%d)", current, total)
1✔
26
        length := b.renderTick(text, percent, steps)
1✔
27
        left := b.renderedLength - length
1✔
28
        if left > 0 {
1✔
29
                b.logger.LogError(strings.Repeat(" ", left))
×
30
        }
×
31
        b.renderedLength = length
1✔
32
}
33

34
func (b *ProgressBar) UpdatePercentage(text string, percent float64) {
1✔
35
        b.logger.LogError("\r")
1✔
36
        length := b.renderTick(text, percent, "")
1✔
37
        left := b.renderedLength - length
1✔
38
        if left > 0 {
2✔
39
                b.logger.LogError(strings.Repeat(" ", left))
1✔
40
        }
1✔
41
        b.renderedLength = length
1✔
42
}
43

44
func (b *ProgressBar) UpdateProgress(text string, current int64, total int64, bytesPerSecond int64) {
1✔
45
        b.logger.LogError("\r")
1✔
46
        length := b.renderProgress(text, current, total, bytesPerSecond)
1✔
47
        left := b.renderedLength - length
1✔
48
        if left > 0 {
2✔
49
                b.logger.LogError(strings.Repeat(" ", left))
1✔
50
        }
1✔
51
        b.renderedLength = length
1✔
52
}
53

54
func (b *ProgressBar) Remove() {
1✔
55
        if b.renderedLength > 0 {
2✔
56
                clear := fmt.Sprintf("\r%s\r", strings.Repeat(" ", b.renderedLength))
1✔
57
                b.logger.LogError(clear)
1✔
58
        }
1✔
59
}
60

61
func (b ProgressBar) renderTick(text string, percent float64, info string) int {
1✔
62
        bar := b.createBar(percent)
1✔
63
        output := fmt.Sprintf("%s      |%s|%s",
1✔
64
                text,
1✔
65
                bar,
1✔
66
                info)
1✔
67
        b.logger.LogError(output)
1✔
68
        return utf8.RuneCountInString(output)
1✔
69
}
1✔
70

71
func (b ProgressBar) renderProgress(text string, currentBytes int64, totalBytes int64, bytesPerSecond int64) int {
1✔
72
        percent := math.Min(float64(currentBytes)/float64(totalBytes)*100.0, 100.0)
1✔
73
        bar := b.createBar(percent)
1✔
74
        totalBytesFormatted, unit := b.formatBytes(totalBytes)
1✔
75
        currentBytesFormatted, unit := b.formatBytesInUnit(currentBytes, unit)
1✔
76
        bytesPerSecondFormatted, bytesPerSecondUnit := b.formatBytes(bytesPerSecond)
1✔
77
        output := fmt.Sprintf("%s %3d%% |%s| (%s/%s %s, %s %s/s)",
1✔
78
                text,
1✔
79
                int(percent),
1✔
80
                bar,
1✔
81
                currentBytesFormatted,
1✔
82
                totalBytesFormatted,
1✔
83
                unit,
1✔
84
                bytesPerSecondFormatted,
1✔
85
                bytesPerSecondUnit)
1✔
86
        b.logger.LogError(output)
1✔
87
        return utf8.RuneCountInString(output)
1✔
88
}
1✔
89

90
func (b ProgressBar) createBar(percent float64) string {
1✔
91
        barCount := int(percent / 5.0)
1✔
92
        if barCount > 20 {
1✔
93
                barCount = 20
×
94
        }
×
95
        return strings.Repeat("█", barCount) + strings.Repeat(" ", 20-barCount)
1✔
96
}
97

98
func (b ProgressBar) formatBytes(count int64) (string, string) {
1✔
99
        if count < 1000 {
2✔
100
                return b.formatBytesInUnit(count, "B")
1✔
101
        }
1✔
102
        if count < 1000*1000 {
2✔
103
                return b.formatBytesInUnit(count, "kB")
1✔
104
        }
1✔
105
        if count < 1000*1000*1000 {
2✔
106
                return b.formatBytesInUnit(count, "MB")
1✔
107
        }
1✔
UNCOV
108
        return b.formatBytesInUnit(count, "GB")
×
109
}
110

111
func (b ProgressBar) formatBytesInUnit(count int64, unit string) (string, string) {
1✔
112
        if unit == "B" {
2✔
113
                return fmt.Sprintf("%d", count), unit
1✔
114
        }
1✔
115
        if unit == "kB" {
2✔
116
                return fmt.Sprintf("%0.1f", float64(count)/1_000), unit
1✔
117
        }
1✔
118
        if unit == "MB" {
2✔
119
                return fmt.Sprintf("%0.1f", float64(count)/1_000_000), unit
1✔
120
        }
1✔
UNCOV
121
        return fmt.Sprintf("%0.1f", float64(count)/1_000_000_000), unit
×
122
}
123

124
func NewProgressBar(logger log.Logger) *ProgressBar {
1✔
125
        return &ProgressBar{logger, 0}
1✔
126
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc