diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 03d9f60..ecb8811 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -33,7 +33,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.24.x - name: Check out code uses: actions/checkout@v3 diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index e8919d4..1663754 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -18,7 +18,7 @@ jobs: - name: "Set up Go" uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.24.x check-latest: true cache: true diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml index 3cc2909..5a9c968 100644 --- a/.github/workflows/release-test.yml +++ b/.github/workflows/release-test.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.24.x - name: release test uses: goreleaser/goreleaser-action@v4 diff --git a/.github/workflows/setup-test.yaml b/.github/workflows/setup-test.yaml index 0b62a6e..6fb89a9 100644 --- a/.github/workflows/setup-test.yaml +++ b/.github/workflows/setup-test.yaml @@ -21,7 +21,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.24.x - name: Check out code uses: actions/checkout@v3 diff --git a/Dockerfile b/Dockerfile index 224027c..e3803ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20.6-alpine AS builder +FROM golang:1.24.2-alpine AS builder RUN apk add --no-cache git RUN go install -v github.com/projectdiscovery/pdtm/cmd/pdtm@latest diff --git a/README.md b/README.md index 6e0fa5a..b8ff343 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ ## Installation -**`pdtm`** requires **go1.19** to install successfully. Run the following command to install the latest version: +**`pdtm`** requires **go1.24.2** to install successfully. Run the following command to install the latest version: 1. Install using go install - diff --git a/internal/runner/banner.go b/internal/runner/banner.go index 721266f..075cd93 100644 --- a/internal/runner/banner.go +++ b/internal/runner/banner.go @@ -5,7 +5,7 @@ import ( updateutils "github.com/projectdiscovery/utils/update" ) -const version = "v0.0.9" +const version = "v0.0.10" var banner = ` ____ diff --git a/pkg/path/unix.go b/pkg/path/unix.go index 403141b..f7b154f 100644 --- a/pkg/path/unix.go +++ b/pkg/path/unix.go @@ -24,6 +24,10 @@ var confList = []*Config{ shellName: "zsh", rcFile: ".zshrc", }, + { + shellName: "fish", + rcFile: ".config/fish/config.fish", + }, } func (c *Config) GetRCFilePath() (string, error) { @@ -32,6 +36,17 @@ func (c *Config) GetRCFilePath() (string, error) { return "", err } rcFilePath := filepath.Join(home, c.rcFile) + + // For fish, ensure the directory exists + if c.shellName == "fish" { + configDir := filepath.Dir(rcFilePath) + if !fileutil.FolderExists(configDir) { + if err := os.MkdirAll(configDir, os.ModePerm); err != nil { + return "", fmt.Errorf("failed to create fish config directory %v got %v", configDir, err) + } + } + } + if fileutil.FileExists(rcFilePath) { return rcFilePath, nil } @@ -79,7 +94,13 @@ func add(path string) (bool, error) { return false, errorutil.NewWithErr(err).Msgf("add %s to $PATH env", path) } - script := fmt.Sprintf("export PATH=$PATH:%s\n\n", path) + var script string + if conf.shellName == "fish" { + script = fmt.Sprintf("fish_add_path %s\n\n", path) + } else { + script = fmt.Sprintf("export PATH=$PATH:%s\n\n", path) + } + return exportToConfig(conf, path, script) } @@ -93,8 +114,15 @@ func remove(path string) (bool, error) { if err != nil { return false, errorutil.NewWithErr(err).Msgf("remove %s from $PATH env", path) } - pathVars = sliceutil.PruneEqual(pathVars, path) - script := fmt.Sprintf("export PATH=%s\n\n", strings.Join(pathVars, ":")) + + var script string + if conf.shellName == "fish" { + script = fmt.Sprintf("set --erase fish_user_paths[contains $fish_user_paths %s]\n\n", path) + } else { + pathVars = sliceutil.PruneEqual(pathVars, path) + script = fmt.Sprintf("export PATH=%s\n\n", strings.Join(pathVars, ":")) + } + return exportToConfig(conf, path, script) } @@ -115,7 +143,11 @@ func exportToConfig(config *Config, path, script string) (bool, error) { lines := strings.Split(strings.TrimSpace(string(b)), "\n") for _, line := range lines { if strings.EqualFold(line, strings.TrimSpace(script)) { - gologger.Info().Msgf("Run `source ~/%s` to add %s to $PATH ", config.rcFile, path) + if config.shellName == "fish" { + gologger.Info().Msgf("Run `source %s` to add %s to $PATH ", rcFilePath, path) + } else { + gologger.Info().Msgf("Run `source ~/%s` to add %s to $PATH ", config.rcFile, path) + } return true, nil } } @@ -123,6 +155,7 @@ func exportToConfig(config *Config, path, script string) (bool, error) { if err != nil { return false, err } + script = fmt.Sprintf("\n\n# Generated for pdtm. Do not edit.\n%s", script) if _, err := f.Write([]byte(script)); err != nil { return false, err @@ -130,6 +163,11 @@ func exportToConfig(config *Config, path, script string) (bool, error) { if err := f.Close(); err != nil { return false, err } - gologger.Info().Label("WRN").Msgf("Run `source ~/%s` to add $PATH (%s)", config.rcFile, path) + + if config.shellName == "fish" { + gologger.Info().Label("WRN").Msgf("Run `source %s` to add $PATH (%s)", rcFilePath, path) + } else { + gologger.Info().Label("WRN").Msgf("Run `source ~/%s` to add $PATH (%s)", config.rcFile, path) + } return true, nil }