diff --git a/.codebeatsettings b/.codebeatsettings deleted file mode 100644 index 259c6b4..0000000 --- a/.codebeatsettings +++ /dev/null @@ -1,9 +0,0 @@ -{ - "GOLANG": { - "ABC": [25, 50, 75, 100], - "CYCLO": [25, 50, 75, 100], - "TOO_MANY_IVARS": [12, 16, 20, 24], - "TOO_MANY_FUNCTIONS": [50, 70, 90, 120], - "TOTAL_LOC": [500, 750, 1000, 2000] - } -} diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index cfdc63e..0000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,55 +0,0 @@ -_Before opening an issue, search for similar bug reports or feature requests on GitHub Issues. If yes, please add a_ πŸ‘ _reaction to the existing issue. If no similar issue can be found, fill out either the "Bug Report" or the "Feature Request" section below. Erase the other section and everything on and above this line._ - -### Bug report - -**System info:** - -* **Version used:** -* **OS (e.g. from `/etc/*-release`):** -* **Kernel (`uname -a`):** -* **Go version (`go version`):** -* **p7zip version (`7za | head -3`):** -* **Install tools:** - -**Steps to reproduce:** - -1. [First Step] -2. [Second Step] -3. [and so on...] - -**Expected behavior:** - -[What you expected to happen] - -**Actual behavior:** - -[What actually happened] - -**Additional info:** - -[Include gist of relevant config, logs, etc.] - -Please run those if possible and link them from a [gist](http://gist.github.com). - ---- - -### Feature Request - -Opening a feature request kicks off a discussion. Requests may be closed if we're not actively planning to work on them. - -**Proposal:** - -[Description of the feature] - -**Current behavior:** - -[What currently happens] - -**Desired behavior:** - -[What you would like to happen] - -**Use case:** - -[Why is this important (helps with prioritizing requests)] - diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..a33f390 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,51 @@ +name: ❗ Bug Report +description: File a bug report +title: "[Bug]: " +labels: ["issue β€’ bug"] +assignees: + - andyone + +body: + - type: markdown + attributes: + value: | + > [!IMPORTANT] + > Before you open an issue, search GitHub Issues for a similar bug reports. If so, please add a πŸ‘ reaction to the existing issue. + + - type: textarea + attributes: + label: Module version info + description: Output of `grep 'github.com/essentialkaos/zip7' go.sum` command + render: shell + validations: + required: true + + - type: textarea + attributes: + label: Steps to reproduce + description: Short guide on how to reproduce this problem on our site + placeholder: | + 1. [First Step] + 2. [Second Step] + 3. [and so on...] + validations: + required: true + + - type: textarea + attributes: + label: Expected behavior + description: What you expected to happen + validations: + required: true + + - type: textarea + attributes: + label: Actual behavior + description: What actually happened + validations: + required: true + + - type: textarea + attributes: + label: Additional info + description: Include gist of relevant config, logs, etc. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..185cc9a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,14 @@ +blank_issues_enabled: false + +contact_links: + - name: Security Policies and Procedures + url: https://github.com/essentialkaos/.github/blob/master/SECURITY.md + about: Security procedures and general policies for all ESSENTIAL KAOS projects. + + - name: Contributing Guidelines + url: https://github.com/essentialkaos/contributing-guidelines/blob/master/CONTRIBUTING.md + about: Contributing Guidelines for all ESSENTIAL KAOS projects + + - name: Go Version Support Policy + url: https://github.com/essentialkaos/.github/blob/master/GO-VERSION-SUPPORT.md + about: Information about supported Go versions diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 0000000..d161e0c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,28 @@ +name: ❓ Question +description: Question about application, configuration or code +title: "[Question]: " +labels: ["issue β€’ question"] +assignees: + - andyone + +body: + - type: markdown + attributes: + value: | + > [!IMPORTANT] + > Before you open an issue, search GitHub Issues for a similar question. If so, please add a πŸ‘ reaction to the existing issue. + + - type: textarea + attributes: + label: Question + description: Detailed question + validations: + required: true + + - type: textarea + attributes: + label: Module version info + description: Output of `grep 'github.com/essentialkaos/zip7' go.sum` command + render: shell + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/suggestion.yml b/.github/ISSUE_TEMPLATE/suggestion.yml new file mode 100644 index 0000000..39c69e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/suggestion.yml @@ -0,0 +1,43 @@ +name: βž• Suggestion +description: Suggest new feature or improvement +title: "[Suggestion]: " +labels: ["issue β€’ suggestion"] +assignees: + - andyone + +body: + - type: markdown + attributes: + value: | + > [!IMPORTANT] + > Before you open an issue, search GitHub Issues for a similar feature requests. If so, please add a πŸ‘ reaction to the existing issue. + > + > Opening a feature request kicks off a discussion. Requests may be closed if we're not actively planning to work on them. + + - type: textarea + attributes: + label: Proposal + description: Description of the feature + validations: + required: true + + - type: textarea + attributes: + label: Current behavior + description: What currently happens + validations: + required: true + + - type: textarea + attributes: + label: Desired behavior + description: What you would like to happen + validations: + required: true + + - type: textarea + attributes: + label: Use case + description: Why is this important (helps with prioritizing requests) + validations: + required: true diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d0ad1de..605744a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,7 +6,7 @@ updates: target-branch: "develop" schedule: interval: "daily" - timezone: "Europe/London" + timezone: "Etc/UTC" time: "03:00" labels: - "PR β€’ MAINTENANCE" @@ -26,8 +26,8 @@ updates: target-branch: "develop" schedule: interval: "daily" - timezone: "Europe/London" - time: "04:00" + timezone: "Etc/UTC" + time: "03:00" labels: - "PR β€’ MAINTENANCE" assignees: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d042b5..be4d58b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: - go: [ '1.21.x', '1.22.x' ] + go: [ '1.22.x', '1.23.x' ] steps: - name: Install 7zip @@ -88,7 +88,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.21.x' + go-version: '1.22.x' - name: Check Golang sources with Aligo uses: essentialkaos/aligo-action@v2 diff --git a/Makefile b/Makefile index 55a61b9..5dab5f7 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ################################################################################ -# This Makefile generated by GoMakeGen 3.0.2 using next command: +# This Makefile generated by GoMakeGen 3.2.1 using next command: # gomakegen --mod . # # More info: https://kaos.sh/gomakegen @@ -11,7 +11,16 @@ ifdef VERBOSE ## Print verbose information (Flag) VERBOSE_FLAG = -v endif -COMPAT ?= 1.19 +ifdef PROXY ## Force proxy usage for downloading dependencies (Flag) +export GOPROXY=https://proxy.golang.org/cached-only,direct +endif + +ifdef CGO ## Enable CGO usage (Flag) +export CGO_ENABLED=1 +else +export CGO_ENABLED=0 +endif + MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD) @@ -33,7 +42,7 @@ vendor: mod-vendor ## Make vendored copy of dependencies test: ## Run tests @echo "Starting tests…" ifdef COVERAGE_FILE ## Save coverage data into file (String) - @go test $(VERBOSE_FLAG) -covermode=count -coverprofile=$(COVERAGE_FILE) . + @go test $(VERBOSE_FLAG) -covermode=count -coverprofile=$(COVERAGE_FILE) ./. else @go test $(VERBOSE_FLAG) -covermode=count . endif @@ -97,8 +106,9 @@ help: ## Show this info @echo -e '\n\033[1mVariables:\033[0m\n' @grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \ | sed 's/ifdef //' \ + | sort -h \ | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-13s\033[0m %s\n", $$1, $$2}' @echo -e '' - @echo -e '\033[90mGenerated by GoMakeGen 3.0.2\033[0m\n' + @echo -e '\033[90mGenerated by GoMakeGen 3.2.1\033[0m\n' ################################################################################ diff --git a/README.md b/README.md index 69fe7ed..1dc36e3 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,8 @@

- GitHub Actions CI Status GoReportCard - Codebeat badge + GitHub Actions CI Status GitHub Actions CodeQL Status

diff --git a/example_test.go b/example_test.go index 7f5645a..6b97d87 100644 --- a/example_test.go +++ b/example_test.go @@ -2,7 +2,7 @@ package zip7 // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2022 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/go.mod b/go.mod index 88a60c5..1adc9f1 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,15 @@ module github.com/essentialkaos/zip7 -go 1.18 +go 1.22.7 require ( github.com/essentialkaos/check v1.4.0 - github.com/essentialkaos/ek/v12 v12.127.0 + github.com/essentialkaos/ek/v13 v13.5.1 ) require ( github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect - golang.org/x/sys v0.21.0 // indirect + golang.org/x/sys v0.25.0 // indirect ) diff --git a/go.sum b/go.sum index ea2d4d2..c6505b3 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/check v1.4.0/go.mod h1:LMKPZ2H+9PXe7Y2gEoKyVAwUqXVgx7KtgibfsHJPus0= -github.com/essentialkaos/ek/v12 v12.127.0 h1:fU5A+QbIZ7NTq1K5jGVwAWwuLtBUhsIKuRWYT78hE+Q= -github.com/essentialkaos/ek/v12 v12.127.0/go.mod h1:71IJ7m82hgjrvWnhL+z0vIhguxz47/rfVma5/CeI5Fw= +github.com/essentialkaos/ek/v13 v13.5.1 h1:xkr3d5uAzs69AqI0oKHjjZIsowKdR117AMBv+Dop4Fk= +github.com/essentialkaos/ek/v13 v13.5.1/go.mod h1:KBOtJlrIC2etc/EXvMdbz1JeKmtkuVdK6uRW/ap0OPM= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -11,5 +11,5 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/zip7.go b/zip7.go index 66d6a8a..f87ee6c 100644 --- a/zip7.go +++ b/zip7.go @@ -3,7 +3,7 @@ package zip7 // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2022 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // @@ -201,7 +201,7 @@ func Check(props Props) (bool, error) { if line == _TEST_OK_VALUE { return true, nil } else if line == _TEST_ERROR_VALUE { - return false, fmt.Errorf(outData[index+1]) + return false, errors.New(outData[index+1]) } } @@ -227,19 +227,17 @@ func Delete(props Props, files ...string) (string, error) { // Validate validates properties values func (p Props) Validate(checkFile bool) error { - if checkFile && !isExist(p.File) { + switch { + case checkFile && !isExist(p.File): return fmt.Errorf("File %s does not exist", p.File) - } - if p.IncludeFile != "" && !isExist(p.IncludeFile) { + case p.IncludeFile != "" && !isExist(p.IncludeFile): return fmt.Errorf("Included file %s does not exist", p.IncludeFile) - } - if p.ExcludeFile != "" && !isExist(p.ExcludeFile) { + case p.ExcludeFile != "" && !isExist(p.ExcludeFile): return fmt.Errorf("Included file %s does not exist", p.ExcludeFile) - } - if p.OutputDir != "" && !isExist(p.OutputDir) { + case p.OutputDir != "" && !isExist(p.OutputDir): return fmt.Errorf("Directory %s does not exist", p.OutputDir) } @@ -250,7 +248,8 @@ func (p Props) Validate(checkFile bool) error { func (p Props) ToArgs(command string) []string { var args = []string{p.File, "", "-y", "-bd"} - if command == _COMMAND_ADD { + switch command { + case _COMMAND_ADD: var compression int if p.Compression == 0 { @@ -277,12 +276,11 @@ func (p Props) ToArgs(command string) []string { if p.IncludeFile != "" { args = append(args, "-ir@"+p.IncludeFile) } - - } else if command == _COMMAND_EXTRACT { + case _COMMAND_EXTRACT: if p.OutputDir != "" { args = append(args, "-o"+p.OutputDir) } - } else if command == _COMMAND_LIST { + case _COMMAND_LIST: args = append(args, "-slt") } diff --git a/zip7_test.go b/zip7_test.go index 00f7eb0..a63de1b 100644 --- a/zip7_test.go +++ b/zip7_test.go @@ -2,7 +2,7 @@ package zip7 // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2022 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // @@ -10,7 +10,7 @@ package zip7 import ( "testing" - "github.com/essentialkaos/ek/v12/fsutil" + "github.com/essentialkaos/ek/v13/fsutil" check "github.com/essentialkaos/check" )