This repository was archived by the owner on May 20, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathcmd_fix.go
More file actions
73 lines (60 loc) · 1.96 KB
/
Copy pathcmd_fix.go
File metadata and controls
73 lines (60 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"fmt"
"os"
"path/filepath"
"time"
"github.com/charmbracelet/log"
"github.com/shopware/extension-verifier/internal/tool"
"github.com/shopware/shopware-cli/logging"
"github.com/spf13/cobra"
"golang.org/x/sync/errgroup"
)
var (
allowNonGit bool
fixCommand = &cobra.Command{
Use: "fix [path]",
Args: cobra.ExactArgs(1),
Short: "Fixes known issues in a Shopware extension",
RunE: func(cmd *cobra.Command, args []string) error {
log.Error("Extension Verifier project have been moved into shopware-cli itself")
log.Error("The new command is: docker run --rm -v $(pwd):/ext shopware/shopware-cli extension fix /ext")
log.Error("For projects you can use: docker run --rm -v $(pwd):/ext shopware/shopware-cli project fix /ext")
log.Error("Sleeping for 30 seconds before running the old command")
time.Sleep(30 * time.Second)
gitPath := filepath.Join(args[0], ".git")
if !allowNonGit {
if stat, err := os.Stat(gitPath); err != nil || !stat.IsDir() {
return fmt.Errorf("provided folder is not a git repository. Use --allow-non-git flag to run anyway")
}
}
toolCfg, err := getToolConfig(args[0])
if err != nil {
return err
}
logging.FromContext(cmd.Context()).Debugf("Running fixes for Shopware version: %s", toolCfg.MinShopwareVersion)
var gr errgroup.Group
tools := tool.GetTools()
only, _ := cmd.Flags().GetString("only")
tools, err = filterTools(tools, only)
if err != nil {
return err
}
for _, tool := range tools {
tool := tool
gr.Go(func() error {
return tool.Fix(cmd.Context(), *toolCfg)
})
}
if err := gr.Wait(); err != nil {
return err
}
return nil
},
}
)
func init() {
fixCommand.Flags().BoolVar(&allowNonGit, "allow-non-git", false, "Allow running the fix command on non-git repositories")
fixCommand.Flags().String("only", "", "Run only specific tools by name (comma-separated, e.g. phpstan,eslint)")
rootCmd.AddCommand(fixCommand)
}