Skip to content

Commit bc998ed

Browse files
silvanocerzaper1234cmaglie
authoredAug 31, 2021
Add ways to let users verify if new CLI released (#1416)
* Add ways to let users verify if new CLI released * Code review fixes Co-authored-by: per1234 <[email protected]> * Enhance docs Co-authored-by: per1234 <[email protected]> * Fix version check for git-snapshots and nightlies * Change method to request latest release * Remove ansi library in favor of color * Fix go mod errors * Remove useless function Co-authored-by: Cristian Maglie <[email protected]> Co-authored-by: per1234 <[email protected]> Co-authored-by: Cristian Maglie <[email protected]>
1 parent ff4eb92 commit bc998ed

File tree

11 files changed

+248
-42
lines changed

11 files changed

+248
-42
lines changed
 

‎cli/cli.go

+34-8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"github.com/arduino/arduino-cli/cli/output"
4040
"github.com/arduino/arduino-cli/cli/sketch"
4141
"github.com/arduino/arduino-cli/cli/update"
42+
"github.com/arduino/arduino-cli/cli/updater"
4243
"github.com/arduino/arduino-cli/cli/upgrade"
4344
"github.com/arduino/arduino-cli/cli/upload"
4445
"github.com/arduino/arduino-cli/cli/version"
@@ -50,12 +51,14 @@ import (
5051
"github.com/rifflock/lfshook"
5152
"github.com/sirupsen/logrus"
5253
"github.com/spf13/cobra"
54+
semver "go.bug.st/relaxed-semver"
5355
)
5456

5557
var (
56-
verbose bool
57-
outputFormat string
58-
configFile string
58+
verbose bool
59+
outputFormat string
60+
configFile string
61+
updaterMessageChan chan *semver.Version = make(chan *semver.Version)
5962
)
6063

6164
// NewCommand creates a new ArduinoCli command root
@@ -64,11 +67,12 @@ func NewCommand() *cobra.Command {
6467

6568
// ArduinoCli is the root command
6669
arduinoCli := &cobra.Command{
67-
Use: "arduino-cli",
68-
Short: tr("Arduino CLI."),
69-
Long: tr("Arduino Command Line Interface (arduino-cli)."),
70-
Example: fmt.Sprintf(" %s <%s> [%s...]", os.Args[0], tr("command"), tr("flags")),
71-
PersistentPreRun: preRun,
70+
Use: "arduino-cli",
71+
Short: tr("Arduino CLI."),
72+
Long: tr("Arduino Command Line Interface (arduino-cli)."),
73+
Example: fmt.Sprintf(" %s <%s> [%s...]", os.Args[0], tr("command"), tr("flags")),
74+
PersistentPreRun: preRun,
75+
PersistentPostRun: postRun,
7276
}
7377

7478
arduinoCli.SetUsageTemplate(usageTemplate)
@@ -151,6 +155,20 @@ func preRun(cmd *cobra.Command, args []string) {
151155
feedback.SetOut(colorable.NewColorableStdout())
152156
feedback.SetErr(colorable.NewColorableStderr())
153157

158+
updaterMessageChan = make(chan *semver.Version)
159+
go func() {
160+
if cmd.Name() == "version" {
161+
// The version command checks by itself if there's a new available version
162+
updaterMessageChan <- nil
163+
}
164+
// Starts checking for updates
165+
currentVersion, err := semver.Parse(globals.VersionInfo.VersionString)
166+
if err != nil {
167+
updaterMessageChan <- nil
168+
}
169+
updaterMessageChan <- updater.CheckForUpdate(currentVersion)
170+
}()
171+
154172
//
155173
// Prepare logging
156174
//
@@ -236,3 +254,11 @@ func preRun(cmd *cobra.Command, args []string) {
236254
})
237255
}
238256
}
257+
258+
func postRun(cmd *cobra.Command, args []string) {
259+
latestVersion := <-updaterMessageChan
260+
if latestVersion != nil {
261+
// Notify the user a new version is available
262+
updater.NotifyNewVersionIsAvailable(latestVersion.String())
263+
}
264+
}

‎cli/config/validate.go

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var validMap = map[string]reflect.Kind{
3636
"network.proxy": reflect.String,
3737
"network.user_agent_ext": reflect.String,
3838
"output.no_color": reflect.Bool,
39+
"updater.enable_notification": reflect.Bool,
3940
}
4041

4142
func typeOf(key string) (reflect.Kind, error) {

‎cli/updater/updater.go

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
4+
//
5+
// This software is released under the GNU General Public License version 3,
6+
// which covers the main part of arduino-cli.
7+
// The terms of this license can be found at:
8+
// https://www.gnu.org/licenses/gpl-3.0.en.html
9+
//
10+
// You can be released from the requirements of the above licenses by purchasing
11+
// a commercial license. Buying such a license is mandatory if you want to
12+
// modify or otherwise use the software for commercial activities involving the
13+
// Arduino software without disclosing the source code of your own applications.
14+
// To purchase a commercial license, send an email to license@arduino.cc.
15+
16+
package updater
17+
18+
import (
19+
"os"
20+
"strings"
21+
"time"
22+
23+
"github.com/arduino/arduino-cli/cli/feedback"
24+
"github.com/arduino/arduino-cli/cli/globals"
25+
"github.com/arduino/arduino-cli/configuration"
26+
"github.com/arduino/arduino-cli/httpclient"
27+
"github.com/arduino/arduino-cli/i18n"
28+
"github.com/arduino/arduino-cli/inventory"
29+
"github.com/fatih/color"
30+
semver "go.bug.st/relaxed-semver"
31+
)
32+
33+
var tr = i18n.Tr
34+
35+
// CheckForUpdate returns the latest available version if greater than
36+
// the one running and it makes sense to check for an update, nil in all other cases
37+
func CheckForUpdate(currentVersion *semver.Version) *semver.Version {
38+
if !shouldCheckForUpdate(currentVersion) {
39+
return nil
40+
}
41+
42+
return ForceCheckForUpdate(currentVersion)
43+
}
44+
45+
// ForceCheckForUpdate always returns the latest available version if greater than
46+
// the one running, nil in all other cases
47+
func ForceCheckForUpdate(currentVersion *semver.Version) *semver.Version {
48+
defer func() {
49+
// Always save the last time we checked for updates at the end
50+
inventory.Store.Set("updater.last_check_time", time.Now())
51+
inventory.WriteStore()
52+
}()
53+
54+
latestVersion, err := semver.Parse(getLatestRelease())
55+
if err != nil {
56+
return nil
57+
}
58+
59+
if currentVersion.GreaterThanOrEqual(latestVersion) {
60+
// Current version is already good enough
61+
return nil
62+
}
63+
64+
return latestVersion
65+
}
66+
67+
// NotifyNewVersionIsAvailable prints information about the new latestVersion
68+
func NotifyNewVersionIsAvailable(latestVersion string) {
69+
feedback.Errorf("\n\n%s %s → %s\n%s",
70+
color.YellowString(tr("A new release of Arduino CLI is available:")),
71+
color.CyanString(globals.VersionInfo.VersionString),
72+
color.CyanString(latestVersion),
73+
color.YellowString("https://arduino.github.io/arduino-cli/latest/installation/#latest-packages"))
74+
}
75+
76+
// shouldCheckForUpdate return true if it actually makes sense to check for new updates,
77+
// false in all other cases.
78+
func shouldCheckForUpdate(currentVersion *semver.Version) bool {
79+
if strings.Contains(currentVersion.String(), "git-snapshot") || strings.Contains(currentVersion.String(), "nightly") {
80+
// This is a dev build, no need to check for updates
81+
return false
82+
}
83+
84+
if !configuration.Settings.GetBool("updater.enable_notification") {
85+
// Don't check if the user disabled the notification
86+
return false
87+
}
88+
89+
if inventory.Store.IsSet("updater.last_check_time") && time.Since(inventory.Store.GetTime("updater.last_check_time")).Hours() < 24 {
90+
// Checked less than 24 hours ago, let's wait
91+
return false
92+
}
93+
94+
// Don't check when running on CI or on non interactive consoles
95+
return !isCI() && configuration.IsInteractive && configuration.HasConsole
96+
}
97+
98+
// based on https://github.com/watson/ci-info/blob/HEAD/index.js
99+
func isCI() bool {
100+
return os.Getenv("CI") != "" || // GitHub Actions, Travis CI, CircleCI, Cirrus CI, GitLab CI, AppVeyor, CodeShip, dsari
101+
os.Getenv("BUILD_NUMBER") != "" || // Jenkins, TeamCity
102+
os.Getenv("RUN_ID") != "" // TaskCluster, dsari
103+
}
104+
105+
// getLatestRelease queries the official Arduino download server for the latest release,
106+
// if there are no errors or issues a version string is returned, in all other case an empty string.
107+
func getLatestRelease() string {
108+
client, err := httpclient.New()
109+
if err != nil {
110+
return ""
111+
}
112+
113+
// We just use this URL to check if there's a new release available and
114+
// never show it to the user, so it's fine to use the Linux one for all OSs.
115+
URL := "https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_64bit.tar.gz"
116+
res, err := client.Head(URL)
117+
if err != nil {
118+
// Yes, we ignore it
119+
return ""
120+
}
121+
122+
// Get redirected URL
123+
location := res.Request.URL.String()
124+
125+
// The location header points to the the latest release of the CLI, it's supposed to be formatted like this:
126+
// https://downloads.arduino.cc/arduino-cli/arduino-cli_0.18.3_Linux_64bit.tar.gz
127+
// so we split it to get the version, if there are not enough splits something must have gone wrong.
128+
split := strings.Split(location, "_")
129+
if len(split) < 2 {
130+
return ""
131+
}
132+
133+
return split[1]
134+
}

‎cli/version/version.go

+29-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ package version
1717

1818
import (
1919
"os"
20+
"strings"
2021

22+
"github.com/arduino/arduino-cli/cli/errorcodes"
2123
"github.com/arduino/arduino-cli/cli/feedback"
2224
"github.com/arduino/arduino-cli/cli/globals"
25+
"github.com/arduino/arduino-cli/cli/updater"
2326
"github.com/arduino/arduino-cli/i18n"
2427
"github.com/spf13/cobra"
28+
semver "go.bug.st/relaxed-semver"
2529
)
2630

2731
var tr = i18n.Tr
@@ -39,5 +43,29 @@ func NewCommand() *cobra.Command {
3943
}
4044

4145
func run(cmd *cobra.Command, args []string) {
42-
feedback.Print(globals.VersionInfo)
46+
if strings.Contains(globals.VersionInfo.VersionString, "git-snapshot") || strings.Contains(globals.VersionInfo.VersionString, "nightly") {
47+
// We're using a development version, no need to check if there's a
48+
// new release available
49+
feedback.Print(globals.VersionInfo)
50+
return
51+
}
52+
53+
currentVersion, err := semver.Parse(globals.VersionInfo.VersionString)
54+
if err != nil {
55+
feedback.Errorf("Error parsing current version: %s", err)
56+
os.Exit(errorcodes.ErrGeneric)
57+
}
58+
latestVersion := updater.ForceCheckForUpdate(currentVersion)
59+
60+
versionInfo := globals.VersionInfo
61+
if feedback.GetFormat() == feedback.JSON && latestVersion != nil {
62+
// Set this only we managed to get the latest version
63+
versionInfo.LatestVersion = latestVersion.String()
64+
}
65+
66+
feedback.Print(versionInfo)
67+
68+
if feedback.GetFormat() == feedback.Text && latestVersion != nil {
69+
updater.NotifyNewVersionIsAvailable(latestVersion.String())
70+
}
4371
}

‎configuration/defaults.go

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ func SetDefaults(settings *viper.Viper) {
5252
// output settings
5353
settings.SetDefault("output.no_color", false)
5454

55+
// updater settings
56+
settings.SetDefault("updater.enable_notification", true)
57+
5558
// Bind env vars
5659
settings.SetEnvPrefix("ARDUINO")
5760
settings.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))

‎docs/configuration.md

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
- `sketch` - configuration options relating to [Arduino sketches][sketch specification].
2525
- `always_export_binaries` - set to `true` to make [`arduino-cli compile`][arduino-cli compile] always save binaries
2626
to the sketch folder. This is the equivalent of using the [`--export-binaries`][arduino-cli compile options] flag.
27+
- `updater` - configuration options related to Arduino CLI updates
28+
- `enable_notification` - set to `false` to disable notifications of new Arduino CLI releases, defaults to `true`
2729

2830
## Configuration methods
2931

‎docs/installation.md

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ as a parameter like this:
4040
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s 0.9.0
4141
```
4242

43+
Arduino CLI checks for new releases every 24 hours. If you don't like this behaviour you can disable it by setting the
44+
[`updater.enable_notification` config](configuration.md#configuration-keys) or the
45+
[env var `ARDUINO_UPDATER_ENABLE_NOTIFICATION`](configuration.md#environment-variables) to `false`.
46+
4347
### Download
4448

4549
Pre-built binaries for all the supported platforms are available for download from the links below.

‎i18n/data/en.po

+28-24
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ msgstr " Not used: {0}"
1313
msgid " Used: {0}"
1414
msgstr " Used: {0}"
1515

16-
#: version/version.go:54
16+
#: version/version.go:55
1717
msgid "%[1]s %[2]s Version: %[3]s Commit: %[4]s Date: %[5]s"
1818
msgstr "%[1]s %[2]s Version: %[3]s Commit: %[4]s Date: %[5]s"
1919

@@ -111,6 +111,10 @@ msgstr "--git-url and --zip-path are disabled by default, for more information s
111111
msgid "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk."
112112
msgstr "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk."
113113

114+
#: cli/updater/updater.go:70
115+
msgid "A new release of Arduino CLI is available:"
116+
msgstr "A new release of Arduino CLI is available:"
117+
114118
#: commands/errors.go:181
115119
msgid "A programmer is required to upload"
116120
msgstr "A programmer is required to upload"
@@ -169,11 +173,11 @@ msgstr "Archiving built core (caching) in: {0}"
169173
msgid "Arduino CLI sketch commands."
170174
msgstr "Arduino CLI sketch commands."
171175

172-
#: cli/cli.go:68
176+
#: cli/cli.go:71
173177
msgid "Arduino CLI."
174178
msgstr "Arduino CLI."
175179

176-
#: cli/cli.go:69
180+
#: cli/cli.go:72
177181
msgid "Arduino Command Line Interface (arduino-cli)."
178182
msgstr "Arduino Command Line Interface (arduino-cli)."
179183

@@ -389,7 +393,7 @@ msgstr "Checksum:"
389393
msgid "Clean caches."
390394
msgstr "Clean caches."
391395

392-
#: cli/cli.go:107
396+
#: cli/cli.go:111
393397
msgid "Comma-separated list of additional URLs for the Boards Manager."
394398
msgstr "Comma-separated list of additional URLs for the Boards Manager."
395399

@@ -1203,7 +1207,7 @@ msgstr "Internal error in cache"
12031207
msgid "Invalid '%[1]s' property: %[2]s"
12041208
msgstr "Invalid '%[1]s' property: %[2]s"
12051209

1206-
#: cli/cli.go:234
1210+
#: cli/cli.go:252
12071211
msgid "Invalid Call : should show Help, but it is available only in TEXT mode."
12081212
msgstr "Invalid Call : should show Help, but it is available only in TEXT mode."
12091213

@@ -1260,11 +1264,11 @@ msgstr "Invalid library"
12601264
msgid "Invalid network.proxy '%[1]s': %[2]s"
12611265
msgstr "Invalid network.proxy '%[1]s': %[2]s"
12621266

1263-
#: cli/cli.go:195
1267+
#: cli/cli.go:213
12641268
msgid "Invalid option for --log-level: %s"
12651269
msgstr "Invalid option for --log-level: %s"
12661270

1267-
#: cli/cli.go:212
1271+
#: cli/cli.go:230
12681272
msgid "Invalid output format: %s"
12691273
msgstr "Invalid output format: %s"
12701274

@@ -1429,7 +1433,7 @@ msgstr "Maintainer: %s"
14291433
msgid "Max time to wait for port discovery, e.g.: 30s, 1m"
14301434
msgstr "Max time to wait for port discovery, e.g.: 30s, 1m"
14311435

1432-
#: cli/cli.go:102
1436+
#: cli/cli.go:106
14331437
msgid "Messages with this level and above will be logged. Valid levels are: %s, %s, %s, %s, %s, %s, %s"
14341438
msgstr "Messages with this level and above will be logged. Valid levels are: %s, %s, %s, %s, %s, %s, %s"
14351439

@@ -1627,7 +1631,7 @@ msgstr "Package website:"
16271631
msgid "Paragraph: %s"
16281632
msgstr "Paragraph: %s"
16291633

1630-
#: cli/cli.go:103
1634+
#: cli/cli.go:107
16311635
msgid "Path to the file where logs will be written."
16321636
msgstr "Path to the file where logs will be written."
16331637

@@ -1713,7 +1717,7 @@ msgstr "Print details about a board."
17131717
msgid "Print preprocessed code to stdout instead of compiling."
17141718
msgstr "Print preprocessed code to stdout instead of compiling."
17151719

1716-
#: cli/cli.go:101
1720+
#: cli/cli.go:105
17171721
msgid "Print the logs on the standard output."
17181722
msgstr "Print the logs on the standard output."
17191723

@@ -1838,7 +1842,7 @@ msgid "Setting build path to {0}"
18381842
msgstr "Setting build path to {0}"
18391843

18401844
#: cli/config/delete.go:57
1841-
#: cli/config/validate.go:44
1845+
#: cli/config/validate.go:45
18421846
msgid "Settings key doesn't exist"
18431847
msgstr "Settings key doesn't exist"
18441848

@@ -1913,11 +1917,11 @@ msgstr "Shows the list of the examples for libraries."
19131917
msgid "Shows the list of the examples for libraries. A name may be given as argument to search a specific library."
19141918
msgstr "Shows the list of the examples for libraries. A name may be given as argument to search a specific library."
19151919

1916-
#: cli/version/version.go:34
1920+
#: cli/version/version.go:38
19171921
msgid "Shows the version number of Arduino CLI which is installed on your system."
19181922
msgstr "Shows the version number of Arduino CLI which is installed on your system."
19191923

1920-
#: cli/version/version.go:33
1924+
#: cli/version/version.go:37
19211925
msgid "Shows version number of Arduino CLI."
19221926
msgstr "Shows version number of Arduino CLI."
19231927

@@ -1995,7 +1999,7 @@ msgstr "The connected devices search timeout, raise it if your board doesn't sho
19951999
msgid "The connected devices search timeout, raise it if your board doesn't show up e.g.: 10s"
19962000
msgstr "The connected devices search timeout, raise it if your board doesn't show up e.g.: 10s"
19972001

1998-
#: cli/cli.go:106
2002+
#: cli/cli.go:110
19992003
msgid "The custom config file (if not specified the default will be used)."
20002004
msgstr "The custom config file (if not specified the default will be used)."
20012005

@@ -2015,11 +2019,11 @@ msgid "The key '%[1]v' is not a list of items, can't remove from it.\n"
20152019
msgstr "The key '%[1]v' is not a list of items, can't remove from it.\n"
20162020
"Maybe use '%[2]s'?"
20172021

2018-
#: cli/cli.go:104
2022+
#: cli/cli.go:108
20192023
msgid "The output format for the logs, can be {%s|%s}."
20202024
msgstr "The output format for the logs, can be {%s|%s}."
20212025

2022-
#: cli/cli.go:105
2026+
#: cli/cli.go:109
20232027
msgid "The output format, can be {%s|%s}."
20242028
msgstr "The output format, can be {%s|%s}."
20252029

@@ -2109,7 +2113,7 @@ msgstr "Unable to get Local App Data Folder: %v"
21092113
msgid "Unable to get user home dir: %v"
21102114
msgstr "Unable to get user home dir: %v"
21112115

2112-
#: cli/cli.go:181
2116+
#: cli/cli.go:199
21132117
msgid "Unable to open file for logging: %s"
21142118
msgstr "Unable to open file for logging: %s"
21152119

@@ -2469,7 +2473,7 @@ msgstr "checking local archive integrity"
24692473
msgid "cleaning build path"
24702474
msgstr "cleaning build path"
24712475

2472-
#: cli/cli.go:70
2476+
#: cli/cli.go:73
24732477
msgid "command"
24742478
msgstr "command"
24752479

@@ -2639,7 +2643,7 @@ msgstr "find abs path: %s"
26392643
msgid "first message must contain monitor configuration, not data"
26402644
msgstr "first message must contain monitor configuration, not data"
26412645

2642-
#: cli/cli.go:70
2646+
#: cli/cli.go:73
26432647
msgid "flags"
26442648
msgstr "flags"
26452649

@@ -2666,11 +2670,11 @@ msgstr "for the latest version."
26662670
msgid "for the specific version."
26672671
msgstr "for the specific version."
26682672

2669-
#: inventory/inventory.go:67
2673+
#: inventory/inventory.go:68
26702674
msgid "generating installation.id: %w"
26712675
msgstr "generating installation.id: %w"
26722676

2673-
#: inventory/inventory.go:73
2677+
#: inventory/inventory.go:74
26742678
msgid "generating installation.secret: %w"
26752679
msgstr "generating installation.secret: %w"
26762680

@@ -2803,11 +2807,11 @@ msgstr "invalid library location: %s"
28032807
msgid "invalid option '%s'"
28042808
msgstr "invalid option '%s'"
28052809

2806-
#: inventory/inventory.go:85
2810+
#: inventory/inventory.go:88
28072811
msgid "invalid path creating config dir: %[1]s error: %[2]w"
28082812
msgstr "invalid path creating config dir: %[1]s error: %[2]w"
28092813

2810-
#: inventory/inventory.go:91
2814+
#: inventory/inventory.go:94
28112815
msgid "invalid path writing inventory file: %[1]s error: %[2]w"
28122816
msgstr "invalid path writing inventory file: %[1]s error: %[2]w"
28132817

@@ -3095,7 +3099,7 @@ msgstr "reading file %[1]s: %[2]s"
30953099
msgid "reading files: %v"
30963100
msgstr "reading files: %v"
30973101

3098-
#: inventory/inventory.go:57
3102+
#: inventory/inventory.go:58
30993103
msgid "reading inventory file: %w"
31003104
msgstr "reading inventory file: %w"
31013105

‎i18n/rice-box.go

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎inventory/inventory.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ var (
3232
// Type is the inventory file type
3333
Type = "yaml"
3434
// Name is the inventory file Name with Type as extension
35-
Name = "inventory" + "." + Type
36-
tr = i18n.Tr
35+
Name = "inventory" + "." + Type
36+
tr = i18n.Tr
37+
configFilePath string
3738
)
3839

3940
// Init configures the Read Only config storage
4041
func Init(configPath string) error {
41-
configFilePath := filepath.Join(configPath, Name)
42+
configFilePath = filepath.Join(configPath, Name)
4243
Store.SetConfigName(Name)
4344
Store.SetConfigType(Type)
4445
Store.AddConfigPath(configPath)
@@ -50,7 +51,7 @@ func Init(configPath string) error {
5051
if err := generateInstallationData(); err != nil {
5152
return err
5253
}
53-
if err := writeStore(configFilePath); err != nil {
54+
if err := WriteStore(); err != nil {
5455
return err
5556
}
5657
} else {
@@ -76,7 +77,9 @@ func generateInstallationData() error {
7677
return nil
7778
}
7879

79-
func writeStore(configFilePath string) error {
80+
// WriteStore writes the current information from Store to configFilePath.
81+
// Returns err if it fails.
82+
func WriteStore() error {
8083
configPath := filepath.Dir(configFilePath)
8184

8285
// Create config dir if not present,

‎version/version.go

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var (
3434
type Info struct {
3535
Application string `json:"Application"`
3636
VersionString string `json:"VersionString"`
37+
LatestVersion string `json:"LatestVersion,omitempty"`
3738
Commit string `json:"Commit"`
3839
Status string `json:"Status"`
3940
Date string `json:"Date"`

0 commit comments

Comments
 (0)
Please sign in to comment.