-
Notifications
You must be signed in to change notification settings - Fork 1
feat: check for tool updates when printing current version #25
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
ed582a5
4ea0fc2
1bfd1bf
1899741
b41d2c0
fa879d2
282e365
b8cd286
6f3ace8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --- | ||
| name: github.com/fatih/color | ||
| version: v1.18.0 | ||
| type: go | ||
| summary: Package color is an ANSI color package to output colorized or SGR defined | ||
| output to the standard output. | ||
| homepage: https://pkg.go.dev/github.com/fatih/color | ||
| license: mit | ||
| licenses: | ||
| - sources: LICENSE.md | ||
| text: | | ||
| The MIT License (MIT) | ||
|
|
||
| Copyright (c) 2013 Fatih Arslan | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| this software and associated documentation files (the "Software"), to deal in | ||
| the Software without restriction, including without limitation the rights to | ||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| the Software, and to permit persons to whom the Software is furnished to do so, | ||
| subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| - sources: README.md | ||
| text: The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md) | ||
| for more details | ||
| notices: [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| --- | ||
| name: github.com/mattn/go-colorable | ||
| version: v0.1.13 | ||
| type: go | ||
| summary: | ||
| homepage: https://pkg.go.dev/github.com/mattn/go-colorable | ||
| license: mit | ||
| licenses: | ||
| - sources: LICENSE | ||
| text: | | ||
| The MIT License (MIT) | ||
|
|
||
| Copyright (c) 2016 Yasuhiro Matsumoto | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
| - sources: README.md | ||
| text: MIT | ||
| notices: [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| name: github.com/mattn/go-isatty | ||
| version: v0.0.20 | ||
| type: go | ||
| summary: Package isatty implements interface to isatty | ||
| homepage: https://pkg.go.dev/github.com/mattn/go-isatty | ||
| license: mit | ||
| licenses: | ||
| - sources: LICENSE | ||
| text: | | ||
| Copyright (c) Yasuhiro MATSUMOTO <[email protected]> | ||
|
|
||
| MIT License (Expat) | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| - sources: README.md | ||
| text: MIT | ||
| notices: [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| --- | ||
| name: go.bug.st/relaxed-semver | ||
| version: v0.15.0 | ||
| type: go | ||
| summary: | ||
| homepage: https://pkg.go.dev/go.bug.st/relaxed-semver | ||
| license: bsd-3-clause | ||
| licenses: | ||
| - sources: LICENSE | ||
| text: |2+ | ||
|
|
||
| Copyright (c) 2018-2025, Cristian Maglie. | ||
| All rights reserved. | ||
|
|
||
| Redistribution and use in source and binary forms, with or without | ||
| modification, are permitted provided that the following conditions | ||
| are met: | ||
|
|
||
| 1. Redistributions of source code must retain the above copyright | ||
| notice, this list of conditions and the following disclaimer. | ||
|
|
||
| 2. Redistributions in binary form must reproduce the above copyright | ||
| notice, this list of conditions and the following disclaimer in | ||
| the documentation and/or other materials provided with the | ||
| distribution. | ||
|
|
||
| 3. Neither the name of the copyright holder nor the names of its | ||
| contributors may be used to endorse or promote products derived | ||
| from this software without specific prior written permission. | ||
|
|
||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
| ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| notices: [] | ||
| ... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| --- | ||
| name: gopkg.in/yaml.v3 | ||
| version: v3.0.1 | ||
| type: go | ||
| summary: Package yaml implements YAML support for the Go language. | ||
| homepage: https://pkg.go.dev/gopkg.in/yaml.v3 | ||
| license: other | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is strange; the license isn't discovered, but the CI passes anyway. We should verify that everithing works as expected
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure on how licensee works. @per1234 is this expected? |
||
| licenses: | ||
| - sources: LICENSE | ||
| text: |2 | ||
|
|
||
| This project is covered by two different licenses: MIT and Apache. | ||
|
|
||
| #### MIT License #### | ||
|
|
||
| The following files were ported to Go from C files of libyaml, and thus | ||
| are still covered by their original MIT license, with the additional | ||
| copyright staring in 2011 when the project was ported over: | ||
|
|
||
| apic.go emitterc.go parserc.go readerc.go scannerc.go | ||
| writerc.go yamlh.go yamlprivateh.go | ||
|
|
||
| Copyright (c) 2006-2010 Kirill Simonov | ||
| Copyright (c) 2006-2011 Kirill Simonov | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| this software and associated documentation files (the "Software"), to deal in | ||
| the Software without restriction, including without limitation the rights to | ||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
| of the Software, and to permit persons to whom the Software is furnished to do | ||
| so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
|
|
||
| ### Apache License ### | ||
|
|
||
| All the remaining project files are covered by the Apache license: | ||
|
|
||
| Copyright (c) 2011-2019 Canonical Ltd | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| - sources: README.md | ||
| text: |- | ||
| The yaml package is licensed under the MIT and Apache License 2.0 licenses. | ||
| Please see the LICENSE file for details. | ||
| notices: | ||
| - sources: NOTICE | ||
| text: |- | ||
| Copyright 2011-2016 Canonical Ltd. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // This file is part of arduino-flasher-cli. | ||
| // | ||
| // Copyright 2025 ARDUINO SA (http://www.arduino.cc/) | ||
| // | ||
| // This software is released under the GNU General Public License version 3, | ||
| // which covers the main part of arduino-flasher-cli. | ||
| // The terms of this license can be found at: | ||
| // https://www.gnu.org/licenses/gpl-3.0.en.html | ||
| // | ||
| // You can be released from the requirements of the above licenses by purchasing | ||
| // a commercial license. Buying such a license is mandatory if you want to | ||
| // modify or otherwise use the software for commercial activities involving the | ||
| // Arduino software without disclosing the source code of your own applications. | ||
| // To purchase a commercial license, send an email to [email protected]. | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "fmt" | ||
| "net/http" | ||
| "strings" | ||
|
|
||
| "github.com/fatih/color" | ||
| semver "go.bug.st/relaxed-semver" | ||
|
|
||
| "github.com/arduino/arduino-flasher-cli/feedback" | ||
| "github.com/arduino/arduino-flasher-cli/i18n" | ||
| "github.com/arduino/arduino-flasher-cli/updater" | ||
| ) | ||
|
|
||
| type FlasherRelease struct { | ||
MatteoPologruto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| TagName string `json:"tag_name"` | ||
| } | ||
|
|
||
| func checkForUpdates() error { | ||
| currentVersion, err := semver.Parse(Version) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| c := updater.NewClient() | ||
| req, err := http.NewRequest("GET", "https://api.github.com/repos/arduino/arduino-flasher-cli/releases/latest", nil) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| resp, err := c.HTTPClient.Do(req) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| defer resp.Body.Close() | ||
|
|
||
| var release FlasherRelease | ||
| err = json.NewDecoder(resp.Body).Decode(&release) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| release.TagName = strings.TrimPrefix(release.TagName, "v") | ||
| latestVersion, err := semver.Parse(release.TagName) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // Do nothing if the Arduino Flasher CLI is up to date | ||
| if currentVersion.GreaterThanOrEqual(latestVersion) { | ||
| return nil | ||
| } | ||
|
|
||
| msg := fmt.Sprintf("\n\n%s %s → %s\n%s", | ||
| color.YellowString(i18n.Tr("A new release of Arduino Flasher CLI is available:")), | ||
| color.CyanString(currentVersion.String()), | ||
| color.CyanString(latestVersion.String()), | ||
| color.YellowString("https://www.arduino.cc/en/software/#flasher-tool")) | ||
MatteoPologruto marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would move the string concatenation into the caller not in this function. IMHO, this function should return the |
||
| feedback.Print(msg) | ||
MatteoPologruto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return nil | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.