Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.16
go-version: "1.22"
- name: Docker Login
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: txservices
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -56,7 +56,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -69,4 +69,4 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
16 changes: 7 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ on:
name: Test
jobs:
test:
env:
GO111MODULE: "on"
strategy:
matrix:
go-version: [1.16.x]
go-version: [1.22.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build
run: make local-build
- name: Test
Expand All @@ -38,12 +36,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: "1.17.x"
go-version: "1.22.x"
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@2022.1
run: go install honnef.co/go/tools/cmd/staticcheck@2024.1.1
- name: Run staticcheck
run: staticcheck ./...
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cli-build:
DOCKER_BUILDKIT=1 docker build -f ./build/Dockerfile --platform ${PLATFORM} -t go-cli:devel .

cli-tests:
docker-compose run --rm cli-test
docker compose run --rm cli-test

docker-build:
DOCKER_BUILDKIT=1 docker build -f ./build/Dockerfile-bin --output bin/ --platform ${PLATFORM} --target bin .
Expand Down
43 changes: 39 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/transifex/cli

go 1.16
go 1.22

require (
github.com/blang/semver v3.5.1+incompatible
Expand All @@ -11,10 +11,45 @@ require (
github.com/manifoldco/promptui v0.8.0
github.com/mattn/go-isatty v0.0.14
github.com/rhysd/go-github-selfupdate v1.2.3
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d
gopkg.in/ini.v1 v1.62.0
)

require (
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.1.0 // indirect
github.com/golang/protobuf v1.3.2 // indirect
github.com/google/go-github/v30 v30.1.0 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/tcnksm/go-gitconfig v0.1.2 // indirect
github.com/ulikunitz/xz v0.5.9 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
google.golang.org/appengine v1.3.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
4 changes: 2 additions & 2 deletions internal/txlib/add_remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package txlib

import (
"fmt"
"io/ioutil"
"io"
"net/url"
"os"
"reflect"
Expand Down Expand Up @@ -147,7 +147,7 @@ func TestAddRemoteInvalidFileFormat(t *testing.T) {
// Restore stdout
w.Close()
os.Stdout = oldStdout
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
r.Close()

testSimpleGet(t, mockData, projectUrl)
Expand Down
2 changes: 1 addition & 1 deletion internal/txlib/config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The local configuration has a 'host' field in its 'main' section. That host
points to a section in the root configuration. We return the rest_hostname of
that section. The fallback value is `https://rest.api.transifex.com` */
func (cfg *Config) GetActiveHost() *Host {
if cfg.Root.Hosts == nil || len(cfg.Root.Hosts) == 0 ||
if len(cfg.Root.Hosts) == 0 ||
cfg.Local == nil {
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions internal/txlib/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ func deleteResource(
return err
}
if remoteStatAttributes.TranslatedStrings > 0 {
msg := fmt.Sprintf("Aborting due to translations in %s",
return fmt.Errorf("aborting due to translations in %s",
cfgResource.ResourceSlug)
return fmt.Errorf(msg)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/txlib/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package txlib

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -34,7 +34,7 @@ func MigrateLegacyConfigFile(
// Backup previous file before doing anything

//Read all the contents of the original config file
bytesRead, err := ioutil.ReadFile(cfg.Local.Path)
bytesRead, err := os.ReadFile(cfg.Local.Path)
if err != nil {
return "", fmt.Errorf("aborting, could not create backup file %w", err)
}
Expand All @@ -45,7 +45,7 @@ func MigrateLegacyConfigFile(
backUpFilePath := filepath.Join(filepath.Dir(cfg.Local.Path),
"config_"+currentTime.Format("20060102150405")+".bak")

err = ioutil.WriteFile(backUpFilePath, bytesRead, 0755)
err = os.WriteFile(backUpFilePath, bytesRead, 0755)

if err != nil {
return "", fmt.Errorf("aborting, could not create backup file %w", err)
Expand Down
14 changes: 7 additions & 7 deletions internal/txlib/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package txlib

import (
"fmt"
"io/ioutil"
"io"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -435,7 +435,7 @@ func TestNeedsTokenInRootConfig(t *testing.T) {
_, _ = MigrateLegacyConfigFile(&cfg, api)

w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout

assert.True(t, strings.Contains(string(out), "API token not found."))
Expand Down Expand Up @@ -507,7 +507,7 @@ func TestNoTransifexRcFile(t *testing.T) {
_, _ = MigrateLegacyConfigFile(&cfg, api)

w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout

assert.True(t, strings.Contains(string(out), "Please provide an API token to continue."))
Expand Down Expand Up @@ -668,12 +668,12 @@ func TestResourceMigrationFailed(t *testing.T) {
}

w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout
assert.True(t, strings.Contains(
string(out), "Could not migrate resource `ares`"))

content, err := ioutil.ReadFile(filepath.Join(tmpDir, "config"))
content, err := os.ReadFile(filepath.Join(tmpDir, "config"))
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -798,11 +798,11 @@ func TestBackUpFileCreated(t *testing.T) {

backupFilePath, _ := MigrateLegacyConfigFile(&cfg, api)

newContent, err := ioutil.ReadFile(filepath.Join(tmpDir, "config"))
newContent, err := os.ReadFile(filepath.Join(tmpDir, "config"))
if err != nil {
t.Error(err)
}
buContent, err := ioutil.ReadFile(filepath.Join(backupFilePath))
buContent, err := os.ReadFile(filepath.Join(backupFilePath))
if err != nil {
t.Error(err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/txlib/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package txlib

import (
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -684,7 +683,7 @@ func TestKeepNewFilesSourceOnlyWithDisableOverride(t *testing.T) {
testSimpleGet(t, mockData, sourceDownloadUrl)

assertFileContent(t, "aaa.json", "New source")
_, err = ioutil.ReadFile("aaa.json.new")
_, err = os.ReadFile("aaa.json.new")
if err == nil {
t.Error("File not exist because DisableOverwrite is not true")
}
Expand Down
8 changes: 4 additions & 4 deletions internal/txlib/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package txlib

import (
"fmt"
"io/ioutil"
"io"
"log"
"os"
"strings"
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestStatusWithNoResourcesAsParameters(t *testing.T) {
)

w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout

result := string(out)
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestStatusWithOverrides(t *testing.T) {
)

w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout

result := string(out)
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestStatusWithResourceAsParameter(t *testing.T) {
)

w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout

result := string(out)
Expand Down
14 changes: 7 additions & 7 deletions internal/txlib/update_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package txlib

import (
"io/ioutil"
"io"
"os"
"strings"
"testing"
Expand All @@ -20,7 +20,7 @@ func TestUpdateCommandVersionLessThanProduction(t *testing.T) {
os.Stdout = w
_ = UpdateCommand(arguments)
w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout

result := string(out)
Expand All @@ -38,7 +38,7 @@ func TestUpdateCommandCheckGreaterThanProduction(t *testing.T) {
os.Stdout = w
_ = UpdateCommand(arguments)
w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout

result := string(out)
Expand All @@ -60,7 +60,7 @@ func TestUpdateCommandCheckEQtoProduction(t *testing.T) {
os.Stdout = w
_ = UpdateCommand(arguments)
w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout

result := string(out)
Expand All @@ -77,7 +77,7 @@ func TestUpdateCommandCheckLessThanProduction(t *testing.T) {
os.Stdout = w
_ = UpdateCommand(arguments)
w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout

result := string(out)
Expand All @@ -98,7 +98,7 @@ func TestUpdateCommandGreaterThanProduction(t *testing.T) {
os.Stdout = w
_ = UpdateCommand(arguments)
w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout

result := string(out)
Expand All @@ -119,7 +119,7 @@ func TestUpdateCommandEQtoProduction(t *testing.T) {
os.Stdout = w
_ = UpdateCommand(arguments)
w.Close()
out, _ := ioutil.ReadAll(r)
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout

result := string(out)
Expand Down
Loading