File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7171
7272ENV SHOPWARE_CLI_TOOLS_DIR=/opt/verifier
7373
74-
7574COPY scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
7675
7776CMD ["sh"]
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ var extensionFixCmd = &cobra.Command{
1717 Use : "fix" ,
1818 Short : "Fix an extension" ,
1919 PreRunE : func (cmd * cobra.Command , args []string ) error {
20- return verifier .SetupTools (cmd .Root ().Version )
20+ return verifier .SetupTools (cmd .Context (), cmd . Root ().Version )
2121 },
2222 RunE : func (cmd * cobra.Command , args []string ) error {
2323 allowNonGit , _ := cmd .Flags ().GetBool ("allow-non-git" )
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ var extensionFormat = &cobra.Command{
1616 Use : "format" ,
1717 Short : "Format an extension" ,
1818 PreRunE : func (cmd * cobra.Command , args []string ) error {
19- return verifier .SetupTools (cmd .Root ().Version )
19+ return verifier .SetupTools (cmd .Context (), cmd . Root ().Version )
2020 },
2121 RunE : func (cmd * cobra.Command , args []string ) error {
2222 dryRun , _ := cmd .Flags ().GetBool ("dry-run" )
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
1111 "github.com/shopware/shopware-cli/extension"
1212 "github.com/shopware/shopware-cli/internal/system"
1313 "github.com/shopware/shopware-cli/internal/verifier"
14+ "github.com/shopware/shopware-cli/logging"
1415)
1516
1617var extensionValidateCmd = & cobra.Command {
@@ -49,8 +50,18 @@ var extensionValidateCmd = &cobra.Command{
4950 var toolCfg * verifier.ToolConfig
5051
5152 if stat .IsDir () {
52- if err := system .CopyFiles (args [0 ], tmpDir ); err != nil {
53- return err
53+ if isFull {
54+ if err := system .CopyFiles (args [0 ], tmpDir ); err != nil {
55+ return err
56+ }
57+
58+ defer func () {
59+ if err := os .RemoveAll (tmpDir ); err != nil {
60+ logging .FromContext (cmd .Context ()).Error ("Failed to remove temporary directory:" , err )
61+ }
62+ }()
63+ } else {
64+ tmpDir = args [0 ]
5465 }
5566
5667 ext , err := extension .GetExtensionByFolder (path )
@@ -126,6 +137,6 @@ func init() {
126137 return nil
127138 }
128139
129- return verifier .SetupTools ("latest" )
140+ return verifier .SetupTools (cmd . Context (), cmd . Root (). Version )
130141 }
131142}
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ import (
1414var projectFixCmd = & cobra.Command {
1515 Use : "fix" ,
1616 Short : "Fix project" ,
17+ PreRunE : func (cmd * cobra.Command , args []string ) error {
18+ return verifier .SetupTools (cmd .Context (), cmd .Root ().Version )
19+ },
1720 RunE : func (cmd * cobra.Command , args []string ) error {
1821 allowNonGit , _ := cmd .Flags ().GetBool ("allow-non-git" )
1922 gitPath := filepath .Join (args [0 ], ".git" )
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ import (
1313var projectFormatCmd = & cobra.Command {
1414 Use : "format" ,
1515 Short : "Format project" ,
16+ PreRunE : func (cmd * cobra.Command , args []string ) error {
17+ return verifier .SetupTools (cmd .Context (), cmd .Root ().Version )
18+ },
1619 RunE : func (cmd * cobra.Command , args []string ) error {
1720 var err error
1821 only , _ := cmd .Flags ().GetString ("only" )
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ import (
1515var projectValidateCmd = & cobra.Command {
1616 Use : "validate" ,
1717 Short : "Validate project" ,
18+ PreRunE : func (cmd * cobra.Command , args []string ) error {
19+ return verifier .SetupTools (cmd .Context (), cmd .Root ().Version )
20+ },
1821 RunE : func (cmd * cobra.Command , args []string ) error {
1922 reportingFormat , _ := cmd .Flags ().GetString ("reporter" )
2023 only , _ := cmd .Flags ().GetString ("only" )
Original file line number Diff line number Diff line change 11package verifier
22
33import (
4+ "context"
45 "embed"
56 "fmt"
67 "log"
@@ -9,14 +10,16 @@ import (
910 "path"
1011
1112 "github.com/shopware/shopware-cli/internal/system"
13+ "github.com/shopware/shopware-cli/logging"
1214)
1315
1416//go:embed php/composer.json php/composer.lock php/configs js/configs js/packages js/package*.json
1517var toolsFS embed.FS
1618
17- func SetupTools (currentVersion string ) error {
19+ func SetupTools (ctx context. Context , currentVersion string ) error {
1820 customToolDir := os .Getenv ("SHOPWARE_CLI_TOOLS_DIR" )
1921 if customToolDir != "" {
22+ logging .FromContext (ctx ).Debugf ("Using custom tool directory: %s" , customToolDir )
2023 setToolDirectory (customToolDir )
2124 return nil
2225 }
@@ -25,10 +28,12 @@ func SetupTools(currentVersion string) error {
2528 toolsDir := path .Join (cacheDir , "tools" , currentVersion )
2629
2730 if _ , err := os .Stat (toolsDir ); err == nil {
31+ logging .FromContext (ctx ).Debugf ("Using cached tool directory: %s" , toolsDir )
2832 setToolDirectory (toolsDir )
2933 return nil
3034 }
3135
36+ logging .FromContext (ctx ).Debugf ("Using tool directory: %s" , toolsDir )
3237 if err := os .MkdirAll (toolsDir , os .ModePerm ); err != nil {
3338 return fmt .Errorf ("failed to create directory %s: %w" , toolsDir , err )
3439 }
You can’t perform that action at this time.
0 commit comments