diff --git a/cmd/project/ci.go b/cmd/project/ci.go index 6d58986..d56e77d 100644 --- a/cmd/project/ci.go +++ b/cmd/project/ci.go @@ -12,6 +12,7 @@ import ( "dario.cat/mergo" "github.com/FriendsOfShopware/shopware-cli/extension" + "github.com/FriendsOfShopware/shopware-cli/internal/phpexec" "github.com/FriendsOfShopware/shopware-cli/logging" "github.com/FriendsOfShopware/shopware-cli/shop" "github.com/spf13/cobra" @@ -55,7 +56,7 @@ var projectCI = &cobra.Command{ logging.FromContext(cmd.Context()).Infof("Installing dependencies using Composer") - composer := exec.CommandContext(cmd.Context(), "composer", "install", "--no-dev", "--no-interaction", "--no-progress", "--optimize-autoloader", "--classmap-authoritative") + composer := phpexec.ComposerCommand(cmd.Context(), "install", "--no-dev", "--no-interaction", "--no-progress", "--optimize-autoloader", "--classmap-authoritative") composer.Dir = args[0] composer.Stdin = os.Stdin composer.Stdout = os.Stdout @@ -107,7 +108,7 @@ var projectCI = &cobra.Command{ logging.FromContext(cmd.Context()).Infof("Warmup container cache") - if err := runTransparentCommand(exec.CommandContext(cmd.Context(), "php", path.Join(args[0], "bin", "ci"), "--version")); err != nil { //nolint: gosec + if err := runTransparentCommand(phpexec.PHPCommand(cmd.Context(), path.Join(args[0], "bin", "ci"), "--version")); err != nil { //nolint: gosec return fmt.Errorf("failed to warmup container cache (php bin/ci --version): %w", err) } @@ -122,7 +123,7 @@ var projectCI = &cobra.Command{ } } - if err := runTransparentCommand(exec.CommandContext(cmd.Context(), "php", path.Join(args[0], "bin", "ci"), "asset:install")); err != nil { //nolint: gosec + if err := runTransparentCommand(phpexec.PHPCommand(cmd.Context(), path.Join(args[0], "bin", "ci"), "asset:install")); err != nil { //nolint: gosec return fmt.Errorf("failed to install assets (php bin/ci asset:install): %w", err) } } diff --git a/cmd/project/project_admin_build.go b/cmd/project/project_admin_build.go index 6a03a03..624403a 100644 --- a/cmd/project/project_admin_build.go +++ b/cmd/project/project_admin_build.go @@ -1,8 +1,8 @@ package project import ( + "github.com/FriendsOfShopware/shopware-cli/internal/phpexec" "github.com/FriendsOfShopware/shopware-cli/shop" - "os/exec" "github.com/FriendsOfShopware/shopware-cli/extension" "github.com/FriendsOfShopware/shopware-cli/logging" @@ -49,7 +49,7 @@ var projectAdminBuildCmd = &cobra.Command{ return nil } - return runTransparentCommand(commandWithRoot(exec.CommandContext(cmd.Context(), "php", "bin/console", "assets:install"), projectRoot)) + return runTransparentCommand(commandWithRoot(phpexec.ConsoleCommand(cmd.Context(), "assets:install"), projectRoot)) }, } diff --git a/cmd/project/project_admin_watch.go b/cmd/project/project_admin_watch.go index 0c96d19..c8d5d1a 100644 --- a/cmd/project/project_admin_watch.go +++ b/cmd/project/project_admin_watch.go @@ -1,12 +1,14 @@ package project import ( - "github.com/FriendsOfShopware/shopware-cli/extension" - "github.com/FriendsOfShopware/shopware-cli/shop" - "github.com/spf13/cobra" "os" "os/exec" "path" + + "github.com/FriendsOfShopware/shopware-cli/extension" + "github.com/FriendsOfShopware/shopware-cli/internal/phpexec" + "github.com/FriendsOfShopware/shopware-cli/shop" + "github.com/spf13/cobra" ) var projectAdminWatchCmd = &cobra.Command{ @@ -35,7 +37,7 @@ var projectAdminWatchCmd = &cobra.Command{ return err } - if err := runTransparentCommand(commandWithRoot(exec.CommandContext(cmd.Context(), "php", "bin/console", "feature:dump"), projectRoot)); err != nil { + if err := runTransparentCommand(commandWithRoot(phpexec.ConsoleCommand(cmd.Context(), "feature:dump"), projectRoot)); err != nil { return err } @@ -59,7 +61,7 @@ var projectAdminWatchCmd = &cobra.Command{ } } - if err := runTransparentCommand(commandWithRoot(exec.CommandContext(cmd.Context(), "php", "bin/console", "-eprod", "framework:schema", "-s", "entity-schema", path.Join(mockDirectory, "entity-schema.json")), projectRoot)); err != nil { + if err := runTransparentCommand(commandWithRoot(phpexec.ConsoleCommand(cmd.Context(), "-eprod", "framework:schema", "-s", "entity-schema", path.Join(mockDirectory, "entity-schema.json")), projectRoot)); err != nil { return err } diff --git a/cmd/project/project_storefront_build.go b/cmd/project/project_storefront_build.go index 7043b9c..15c3331 100644 --- a/cmd/project/project_storefront_build.go +++ b/cmd/project/project_storefront_build.go @@ -1,8 +1,8 @@ package project import ( + "github.com/FriendsOfShopware/shopware-cli/internal/phpexec" "github.com/FriendsOfShopware/shopware-cli/shop" - "os/exec" "github.com/FriendsOfShopware/shopware-cli/extension" "github.com/FriendsOfShopware/shopware-cli/logging" @@ -49,7 +49,7 @@ var projectStorefrontBuildCmd = &cobra.Command{ return nil } - return runTransparentCommand(commandWithRoot(exec.CommandContext(cmd.Context(), "php", "bin/console", "theme:compile"), projectRoot)) + return runTransparentCommand(commandWithRoot(phpexec.ConsoleCommand(cmd.Context(), "theme:compile"), projectRoot)) }, } diff --git a/cmd/project/project_storefront_watch.go b/cmd/project/project_storefront_watch.go index f5e3a01..6fc18de 100644 --- a/cmd/project/project_storefront_watch.go +++ b/cmd/project/project_storefront_watch.go @@ -1,12 +1,14 @@ package project import ( - "github.com/FriendsOfShopware/shopware-cli/extension" - "github.com/FriendsOfShopware/shopware-cli/shop" - "github.com/spf13/cobra" "os" "os/exec" "strings" + + "github.com/FriendsOfShopware/shopware-cli/extension" + "github.com/FriendsOfShopware/shopware-cli/internal/phpexec" + "github.com/FriendsOfShopware/shopware-cli/shop" + "github.com/spf13/cobra" ) var projectStorefrontWatchCmd = &cobra.Command{ @@ -35,7 +37,7 @@ var projectStorefrontWatchCmd = &cobra.Command{ return err } - if err := runTransparentCommand(commandWithRoot(exec.CommandContext(cmd.Context(), "php", "bin/console", "feature:dump"), projectRoot)); err != nil { + if err := runTransparentCommand(commandWithRoot(phpexec.ConsoleCommand(cmd.Context(), "feature:dump"), projectRoot)); err != nil { return err } @@ -45,11 +47,11 @@ var projectStorefrontWatchCmd = &cobra.Command{ activeOnly = "-v" } - if err := runTransparentCommand(commandWithRoot(exec.CommandContext(cmd.Context(), "php", "bin/console", "theme:compile", activeOnly), projectRoot)); err != nil { + if err := runTransparentCommand(commandWithRoot(phpexec.ConsoleCommand(cmd.Context(), "theme:compile", activeOnly), projectRoot)); err != nil { return err } - if err := runTransparentCommand(commandWithRoot(exec.CommandContext(cmd.Context(), "php", "bin/console", "theme:dump"), projectRoot)); err != nil { + if err := runTransparentCommand(commandWithRoot(phpexec.ConsoleCommand(cmd.Context(), "theme:dump"), projectRoot)); err != nil { return err } diff --git a/cmd/project/project_worker.go b/cmd/project/project_worker.go index bdbff38..263e58f 100644 --- a/cmd/project/project_worker.go +++ b/cmd/project/project_worker.go @@ -4,13 +4,13 @@ import ( "context" "fmt" "os" - "os/exec" "os/signal" "strconv" "strings" "sync" "syscall" + "github.com/FriendsOfShopware/shopware-cli/internal/phpexec" "github.com/FriendsOfShopware/shopware-cli/shop" "github.com/spf13/cobra" @@ -54,7 +54,7 @@ var projectWorkerCmd = &cobra.Command{ cancelCtx, cancel := context.WithCancel(cobraCmd.Context()) cancelOnTermination(cancelCtx, cancel) - consumeArgs := []string{"bin/console", "messenger:consume", fmt.Sprintf("--memory-limit=%s", memoryLimit), fmt.Sprintf("--time-limit=%s", timeLimit)} + consumeArgs := []string{"messenger:consume", fmt.Sprintf("--memory-limit=%s", memoryLimit), fmt.Sprintf("--time-limit=%s", timeLimit)} if queuesToConsume == "" { if is, _ := shop.IsShopwareVersion(projectRoot, ">=6.5"); is { @@ -73,7 +73,7 @@ var projectWorkerCmd = &cobra.Command{ wg.Add(1) go func(ctx context.Context) { for { - cmd := exec.CommandContext(cancelCtx, "php", consumeArgs...) + cmd := phpexec.ConsoleCommand(cancelCtx, consumeArgs...) cmd.Dir = projectRoot cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr