diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2671fd1..dbaf028 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,9 +22,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - SRC_DIR: src/github.com/${{ github.repository }} - jobs: Go: name: Go @@ -32,25 +29,21 @@ jobs: strategy: matrix: - go: [ '1.19.x', '1.20.x' ] + go: [ '1.21.x', '1.22.x' ] steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} - - name: Checkout - uses: actions/checkout@v3 - with: - path: ${{env.SRC_DIR}} - - name: Download dependencies - working-directory: ${{env.SRC_DIR}} run: make deps - name: Build binaries - working-directory: ${{env.SRC_DIR}} run: make all Aligo: @@ -60,24 +53,20 @@ jobs: needs: Go steps: - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: '1.19.x' - - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 with: - path: ${{env.SRC_DIR}} + go-version: '1.21.x' - name: Download dependencies - working-directory: ${{env.SRC_DIR}} run: make deps - name: Check Golang sources with Aligo - uses: essentialkaos/aligo-action@v1 + uses: essentialkaos/aligo-action@v2 with: - path: ${{env.SRC_DIR}} files: ./... Perfecto: @@ -88,10 +77,10 @@ jobs: steps: - name: Code checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -101,3 +90,16 @@ jobs: uses: essentialkaos/perfecto-action@v2 with: files: common/init-exporter-converter.spec + + Typos: + name: Typos + runs-on: ubuntu-latest + + needs: Go + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check spelling + uses: crate-ci/typos@master diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 3444662..d4d4ec8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -15,14 +15,14 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 2 - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v3 with: languages: go - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v3 diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 0000000..55aead8 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,2 @@ +[files] +extend-exclude = ["go.sum"] diff --git a/common/init-exporter-converter.spec b/common/init-exporter-converter.spec index fadf5cc..a8f9f62 100644 --- a/common/init-exporter-converter.spec +++ b/common/init-exporter-converter.spec @@ -6,7 +6,7 @@ Summary: Utility for converting init-exporter procfiles from v1 to v2 format Name: init-exporter-converter -Version: 0.12.0 +Version: 0.12.1 Release: 0%{?dist} Group: Development/Tools License: MIT @@ -16,7 +16,7 @@ Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: golang >= 1.19 +BuildRequires: golang >= 1.20 Provides: %{name} = %{version}-%{release} @@ -60,6 +60,10 @@ rm -rf %{buildroot} ################################################################################ %changelog +* Wed Mar 06 2024 Anton Novojilov - 0.12.1-0 +- Dependencies update +- Code refactoring + * Fri Mar 10 2023 Anton Novojilov - 0.12.0-0 - Added verbose version output - Dependencies update diff --git a/go.mod b/go.mod index 5e6cc7e..a61ab9b 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,12 @@ module github.com/funbox/init-exporter-converter go 1.18 require ( - github.com/essentialkaos/ek/v12 v12.62.0 + github.com/essentialkaos/ek/v12 v12.102.0 github.com/essentialkaos/go-simpleyaml/v2 v2.1.4 - github.com/funbox/init-exporter v0.24.1 + github.com/funbox/init-exporter v0.25.1 ) require ( - golang.org/x/sys v0.6.0 // indirect + golang.org/x/sys v0.18.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 485028d..edd2a19 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,15 @@ github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= -github.com/essentialkaos/ek/v12 v12.62.0 h1:A+pnMGbSz2apjEjlHU3EQ6Uqam85GTryVPhzcLfY8o4= -github.com/essentialkaos/ek/v12 v12.62.0/go.mod h1:9MlSuHpewu7OZ9tM9dLFHvoA8dflBIUPCA0Ctt97wRs= +github.com/essentialkaos/ek/v12 v12.102.0 h1:frHp1+iElQUg4CoscVQWuVFY1QZvU0fIqAaV2RtmeP0= +github.com/essentialkaos/ek/v12 v12.102.0/go.mod h1:T5RaDwmg6aso4vPfMp9OSk0R5YAjGtkinlxj2kDXUbo= github.com/essentialkaos/go-simpleyaml/v2 v2.1.4 h1:B2bXdGWaQ6Xy3HTsO2DLBoNV7cbMW3KDmeeOKYLo9z0= github.com/essentialkaos/go-simpleyaml/v2 v2.1.4/go.mod h1:pVQTleUBC8xBI9+HnTF38xWBZqANNrmMAzwmUemblJg= -github.com/funbox/init-exporter v0.24.1 h1:nQXX4nEq6oh+6Ok7nSRoP2WP97DU5vf84+ASEw3qg+8= -github.com/funbox/init-exporter v0.24.1/go.mod h1:/VrrNrdCYKcKZjoIPx6u0yra/M51tFPZ5v8GKV8eCz4= +github.com/funbox/init-exporter v0.25.1 h1:xmvgrPFUPInBsZRSSB8+mMciUtw78HFN0fCeMZuRyKo= +github.com/funbox/init-exporter v0.25.1/go.mod h1:r1uzN8W6j8P5awNYmWkQNA+EpIGEKdYrGA8IGVBleN4= 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.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/init-exporter-converter.go b/init-exporter-converter.go index ae41d23..b102d4d 100644 --- a/init-exporter-converter.go +++ b/init-exporter-converter.go @@ -8,15 +8,13 @@ package main import ( "fmt" - "io/ioutil" "os" "runtime" - "strings" "github.com/essentialkaos/ek/v12/fmtc" - "github.com/essentialkaos/ek/v12/fsutil" "github.com/essentialkaos/ek/v12/knf" "github.com/essentialkaos/ek/v12/options" + "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/usage" "github.com/essentialkaos/ek/v12/usage/completion/bash" "github.com/essentialkaos/ek/v12/usage/completion/fish" @@ -34,7 +32,7 @@ import ( // App props const ( APP = "init-exporter-converter" - VER = "0.12.0" + VER = "0.12.1" DESC = "Utility for converting procfiles from v1 to v2 format" ) @@ -52,7 +50,7 @@ const ( OPT_GENERATE_MAN = "generate-man" ) -// Config properies +// Config properties const ( MAIN_PREFIX = "main:prefix" PATHS_WORKING_DIR = "paths:working-dir" @@ -130,24 +128,7 @@ func main() { // preConfigureUI preconfigures UI based on information about user terminal func preConfigureUI() { - term := os.Getenv("TERM") - - fmtc.DisableColors = true - - if term != "" { - switch { - case strings.Contains(term, "xterm"), - strings.Contains(term, "color"), - term == "screen": - fmtc.DisableColors = false - } - } - - if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" { - fmtc.DisableColors = true - } - - if os.Getenv("NO_COLOR") != "" { + if !tty.IsTTY() { fmtc.DisableColors = true } } @@ -237,7 +218,7 @@ func convert(file string) error { } if !options.GetB(OPT_IN_PLACE) { - fmt.Printf(yamlData) + fmt.Print(yamlData) return nil } @@ -349,7 +330,7 @@ func validateYaml(data string) error { // writeData writes procfile data to file func writeData(file, data string) error { - return ioutil.WriteFile(file, []byte(data), 0644) + return os.WriteFile(file, []byte(data), 0644) } // printError prints error message to console @@ -357,12 +338,7 @@ func printError(f string, a ...interface{}) { 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 mesage and exit with exit code 1 +// printErrorAndExit print error message and exit with exit code 1 func printErrorAndExit(f string, a ...interface{}) { printError(f, a...) os.Exit(1) @@ -376,11 +352,11 @@ func printCompletion() int { switch options.GetS(OPT_COMPLETION) { case "bash": - fmt.Printf(bash.Generate(info, "init-exporter-converter")) + fmt.Print(bash.Generate(info, "init-exporter-converter")) case "fish": - fmt.Printf(fish.Generate(info, "init-exporter-converter")) + fmt.Print(fish.Generate(info, "init-exporter-converter")) case "zsh": - fmt.Printf(zsh.Generate(info, optMap, "init-exporter-converter")) + fmt.Print(zsh.Generate(info, optMap, "init-exporter-converter")) default: return 1 } @@ -390,12 +366,7 @@ func printCompletion() int { // printMan prints man page func printMan() { - fmt.Println( - man.Generate( - genUsage(), - genAbout(""), - ), - ) + fmt.Println(man.Generate(genUsage(), genAbout(""))) } // genUsage generates usage info @@ -426,16 +397,13 @@ func genUsage() *usage.Info { // genAbout generates info about version func genAbout(gitRev string) *usage.About { about := &usage.About{ - App: APP, - Version: VER, - Desc: DESC, - Year: 2006, - Owner: "FunBox", - License: "MIT License", - UpdateChecker: usage.UpdateChecker{ - "funbox/init-exporter-converter", - update.GitHubChecker, - }, + App: APP, + Version: VER, + Desc: DESC, + Year: 2006, + Owner: "FunBox", + License: "MIT License", + UpdateChecker: usage.UpdateChecker{"funbox/init-exporter-converter", update.GitHubChecker}, AppNameColorTag: "{*}" + colorTagApp, VersionColorTag: colorTagVer,