diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b394e9..906b6b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 327a97e..244ec03 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -25,9 +25,9 @@ jobs: fetch-depth: 2 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: go - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/cli/cli.go b/cli/cli.go index cb20c6b..6273ef2 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -41,7 +41,6 @@ import ( "github.com/essentialkaos/ek/v12/system" "github.com/essentialkaos/ek/v12/terminal" "github.com/essentialkaos/ek/v12/terminal/tty" - "github.com/essentialkaos/ek/v12/terminal/window" "github.com/essentialkaos/ek/v12/timeutil" "github.com/essentialkaos/ek/v12/tmp" "github.com/essentialkaos/ek/v12/usage" @@ -67,7 +66,7 @@ import ( // App info const ( APP = "RBInstall" - VER = "3.2.0" + VER = "3.3.0" DESC = "Utility for installing prebuilt Ruby versions to rbenv" ) @@ -106,6 +105,7 @@ const ( RBENV_ALLOW_UNINSTALL = "rbenv:allow-uninstall" RBENV_MAKE_ALIAS = "rbenv:make-alias" GEMS_RUBYGEMS_UPDATE = "gems:rubygems-update" + GEMS_RUBYGEMS_VERSION = "gems:rubygems-version" GEMS_ALLOW_UPDATE = "gems:allow-update" GEMS_NO_DOCUMENT = "gems:no-document" GEMS_SOURCE = "gems:source" @@ -136,11 +136,6 @@ const ( ARCH_ARM = "arm" ) -// RubyGems versions used for old versions of Ruby -const ( - MIN_RUBYGEMS_VERSION_BASE = "2.7.9" -) - // ////////////////////////////////////////////////////////////////////////////////// // var optMap = options.Map{ @@ -751,8 +746,13 @@ func installVersion(rubyVersion string, reinstall bool) { if knf.GetB(GEMS_RUBYGEMS_UPDATE) && strutil.HasPrefixAny(info.Name, "1", "2", "3") { rgVersion := getAdvisableRubyGemsVersion(info.Name) + gemVersion := rgVersion - spinner.Show("Updating RubyGems to %s", rgVersion) + if gemVersion != "latest" && strings.Count(gemVersion, ".") < 2 { + gemVersion += ".x" + } + + spinner.Show("Updating RubyGems to %s", gemVersion) err = updateRubygemsTaskHandler(info.Name, rgVersion) spinner.Done(err == nil) @@ -1144,7 +1144,7 @@ func runGemCmd(rubyVersion, cmd, gem, gemVersion string) (string, error) { if gemVersion == "" { gemVersion = "latest" - } else { + } else if strings.Count(gemVersion, ".") < 2 { gemVersion += ".x" } @@ -1357,7 +1357,7 @@ func getInstallBullet(installed bool, color string) string { } // printSized render format with given size and print text with give arguments -func printSized(format string, size int, a ...interface{}) { +func printSized(format string, size int, a ...any) { fmtc.Printf(fmtc.Sprintf(format, size), a...) } @@ -1368,7 +1368,7 @@ func printRubyVersion(category, name string) { // configureCategorySizes configure column size for each category func configureCategorySizes(data map[string]index.CategoryData) { - terminalWidth := window.GetWidth() + terminalWidth := tty.GetWidth() if terminalWidth == -1 || terminalWidth > 150 { categorySize[index.CATEGORY_RUBY] = DEFAULT_CATEGORY_SIZE @@ -1477,12 +1477,7 @@ func isVersionInstalled(rubyVersion string) bool { // getVersionFromFile try to read version file and return defined version func getVersionFromFile() (string, error) { - versionFile := fsutil.ProperPath("FRS", - []string{ - ".ruby-version", - ".rbenv-version", - }, - ) + versionFile := fsutil.ProperPath("FRS", []string{".ruby-version", ".rbenv-version"}) if versionFile == "" { return "", fmtc.Errorf("Can't find proper version file") @@ -1506,14 +1501,26 @@ func getVersionFromFile() (string, error) { // getAdvisableRubyGemsVersion returns recommended RubyGems version for // given version of Ruby func getAdvisableRubyGemsVersion(rubyVersion string) string { - v, err := version.Parse(strutil.ReadField(rubyVersion, 0, false, "-")) - minVer, _ := version.Parse("2.3.0") + ver, err := version.Parse(strutil.ReadField(rubyVersion, 0, false, "-")) + + if err != nil { + return "2.3" + } + + v23, _ := version.Parse("2.3.0") + v26, _ := version.Parse("2.6.0") + v30, _ := version.Parse("3.0.0") - if err != nil || v.Less(minVer) { - return MIN_RUBYGEMS_VERSION_BASE + switch { + case ver.Less(v23): + return "2.3" + case ver.Less(v26): + return "3.3" + case ver.Less(v30): + return "3.4" } - return "latest" + return knf.GetS(GEMS_RUBYGEMS_VERSION, "latest") } // getVersionInfo finds info about given version in index @@ -1773,7 +1780,7 @@ func intSignalHandler() { } // printErrorAndExit print error message and exit with non-zero exit code -func printErrorAndExit(f string, a ...interface{}) { +func printErrorAndExit(f string, a ...any) { terminal.Error(f, a...) exit(1) } diff --git a/clone/clone.go b/clone/clone.go index d82b7c7..787e015 100644 --- a/clone/clone.go +++ b/clone/clone.go @@ -43,7 +43,7 @@ import ( // App info const ( APP = "RBInstall Clone" - VER = "3.1.0" + VER = "3.1.1" DESC = "Utility for cloning RBInstall repository" ) @@ -462,17 +462,12 @@ func getCurrentIndexUUID(dir string) string { } // printError prints error message to console -func printError(f string, a ...interface{}) { +func printError(f string, a ...any) { fmtc.Fprintf(os.Stderr, "{r}▲ "+f+"{!}\n", a...) } -// printError prints warning message to console -func printWarn(f string, a ...interface{}) { - fmtc.Fprintf(os.Stderr, "{y}▲ "+f+"{!}\n", a...) -} - // printErrorAndExit print error message and exit with non-zero exit code -func printErrorAndExit(f string, a ...interface{}) { +func printErrorAndExit(f string, a ...any) { fmtc.Fprintf(os.Stderr, "{r}▲ "+f+"{!}\n", a...) fmtc.NewLine() os.Exit(1) diff --git a/common/eol.json b/common/eol.json index 9871f22..4767976 100644 --- a/common/eol.json +++ b/common/eol.json @@ -8,6 +8,7 @@ "2.4": true, "2.5": true, "2.6": true, + "2.7": true, "jruby-1.6": true, "jruby-1.7": true, "jruby-9.0": true, diff --git a/common/rbinstall.knf b/common/rbinstall.knf index 69e09c5..5606e05 100644 --- a/common/rbinstall.knf +++ b/common/rbinstall.knf @@ -37,6 +37,9 @@ # Update rubygems gem rubygems-update: true + # Update rubygems gem to defined version + rubygems-version: latest + # Allow gems update allow-update: true diff --git a/common/rbinstall.spec b/common/rbinstall.spec index b2c7904..ae0a082 100644 --- a/common/rbinstall.spec +++ b/common/rbinstall.spec @@ -10,7 +10,7 @@ Summary: Utility for installing prebuilt Ruby to rbenv Name: rbinstall -Version: 3.2.0 +Version: 3.3.0 Release: 0%{?dist} Group: Applications/System License: Apache License, Version 2.0 @@ -38,7 +38,7 @@ Utility for installing different prebuilt versions of Ruby to rbenv. %package gen Summary: Utility for generating RBInstall index -Version: 3.2.0 +Version: 3.2.1 Release: 0%{?dist} Group: Development/Tools @@ -50,7 +50,7 @@ Utility for generating RBInstall index. %package clone Summary: Utility for cloning RBInstall repository -Version: 3.1.0 +Version: 3.1.1 Release: 0%{?dist} Group: Development/Tools @@ -118,6 +118,11 @@ rm -rf %{buildroot} ################################################################################ %changelog +* Fri Jan 12 2024 Anton Novojilov - 3.3.0-0 +- [cli] Improved rubygems gem update +- [cli|gen|clone] Code refactoring +- Dependencies update + * Wed Dec 06 2023 Anton Novojilov - 3.2.0-0 - [cli] Added '-P'/'--pager' option to use pager for long output of versions - [cli|gen|clone] Improve verbose version info diff --git a/gen/gen.go b/gen/gen.go index bdc1e46..511aa1c 100644 --- a/gen/gen.go +++ b/gen/gen.go @@ -41,7 +41,7 @@ import ( // App info const ( APP = "RBInstall Gen" - VER = "3.2.0" + VER = "3.2.1" DESC = "Utility for generating RBInstall index" ) @@ -94,8 +94,8 @@ var optMap = options.Map{ OPT_EOL: {Value: "eol.json"}, OPT_ALIAS: {Value: "alias.json"}, OPT_NO_COLOR: {Type: options.BOOL}, - OPT_HELP: {Type: options.BOOL, Alias: "u:usage"}, - OPT_VER: {Type: options.BOOL, Alias: "ver"}, + OPT_HELP: {Type: options.BOOL}, + OPT_VER: {Type: options.BOOL}, OPT_VERB_VER: {Type: options.BOOL}, OPT_COMPLETION: {}, @@ -518,17 +518,17 @@ func fmtVersionName(v string) string { } // printError prints error message to console -func printError(f string, a ...interface{}) { +func printError(f string, a ...any) { fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...) } // printError prints warning message to console -func printWarn(f string, a ...interface{}) { +func printWarn(f string, a ...any) { fmtc.Fprintf(os.Stderr, "{y}"+f+"{!}\n", a...) } // printErrorAndExit print error message and exit with non-zero exit code -func printErrorAndExit(f string, a ...interface{}) { +func printErrorAndExit(f string, a ...any) { fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...) os.Exit(1) } diff --git a/go.mod b/go.mod index 631c002..10ea326 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,13 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.90.1 - github.com/essentialkaos/npck v1.6.1 + github.com/essentialkaos/ek/v12 v12.93.0 + github.com/essentialkaos/npck v1.6.2 ) require ( github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect - github.com/klauspost/compress v1.17.1 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/sys v0.15.0 // indirect + github.com/klauspost/compress v1.17.4 // indirect + golang.org/x/crypto v0.18.0 // indirect + golang.org/x/sys v0.16.0 // indirect ) diff --git a/go.sum b/go.sum index 870524e..81e5ef5 100644 --- a/go.sum +++ b/go.sum @@ -1,18 +1,18 @@ github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI= github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= -github.com/essentialkaos/ek/v12 v12.90.1 h1:ID950cnz4xgpqqFzhleP5xaVoLnPwuiykdH3FrogD/E= -github.com/essentialkaos/ek/v12 v12.90.1/go.mod h1:9efMqo1S8EtYhmeelOSTmMQDGC2vRgPkjkKKfvUD2eU= +github.com/essentialkaos/ek/v12 v12.93.0 h1:5lwuNYgUYjQHy2h57adWt2t1w5L2MxqTPKgHjyH3h6k= +github.com/essentialkaos/ek/v12 v12.93.0/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= -github.com/essentialkaos/npck v1.6.1 h1:cFhLRRFNbl7tBXQD2+EkzTHy6y7+oxfvwsVgbhaFvUg= -github.com/essentialkaos/npck v1.6.1/go.mod h1:Leny9a2R4otIGqZdnrs8swhI9KvwO+Rmmn2zThpPoN4= -github.com/klauspost/compress v1.17.1 h1:NE3C767s2ak2bweCZo3+rdP4U/HoyVXLv/X9f2gPS5g= -github.com/klauspost/compress v1.17.1/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/essentialkaos/npck v1.6.2 h1:OqV74UfA9qoRYbFVsZ+KYH9kY//1nU6uX/HBfAltUQ4= +github.com/essentialkaos/npck v1.6.2/go.mod h1:7ziKy4mdUrSMTihDTZKAaxf6uDH2uAlOzsD3Mj2WTyI= +github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= +github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/support/support_linux.go b/support/support_linux.go index 9068a93..a15c78d 100644 --- a/support/support_linux.go +++ b/support/support_linux.go @@ -86,6 +86,7 @@ func collectEnvInfo() Pkgs { getPackageInfo("rbenv"), getPackageInfo("jemalloc"), getPackageInfo("zlib"), + getPackageInfo("gcc"), getPackageInfo( "jre8", "jre11", "jre17", "jdk8", "jdk11", "jdk17", "java-1.8.0-openjdk", "java-11-openjdk", "java-17-openjdk",