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
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ linters:
- gocheckcompilerdirectives
- godox
- nilnil
- perfsprint
exclusions:
rules:
- path: cmd\/*
Expand Down
6 changes: 3 additions & 3 deletions cmd/extension/extension_admin_watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var extensionAdminWatchCmd = &cobra.Command{
cfgs := extension.BuildAssetConfigFromExtensions(cmd.Context(), sources, extension.AssetBuildConfig{}).FilterByAdmin()

if len(cfgs) == 0 {
return fmt.Errorf("found nothing to compile")
return errors.New("found nothing to compile")
}

if _, err := extension.InstallNodeModulesOfConfigs(cmd.Context(), cfgs, extension.AssetBuildConfig{}); err != nil {
Expand Down Expand Up @@ -125,7 +125,7 @@ var extensionAdminWatchCmd = &cobra.Command{
listenSplit := strings.Split(adminWatchListen, ":")

if len(listenSplit) != 2 {
return fmt.Errorf("listen should contain a colon")
return errors.New("listen should contain a colon")
}

if len(adminWatchURL) == 0 {
Expand Down Expand Up @@ -184,7 +184,7 @@ var extensionAdminWatchCmd = &cobra.Command{

// Modify admin url index page to load anything from our watcher
if req.URL.Path == targetShopUrl.Path+"/admin" {
resp, err := http.Get(fmt.Sprintf("%s/admin", targetShopUrl.Scheme+schemeHostSeparator+targetShopUrl.Host))
resp, err := http.Get(targetShopUrl.Scheme + schemeHostSeparator + targetShopUrl.Host + "/admin")
if err != nil {
logging.FromContext(cmd.Context()).Errorf("proxy failed %v", err)
w.WriteHeader(http.StatusInternalServerError)
Expand Down
3 changes: 2 additions & 1 deletion cmd/extension/extension_fix.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package extension

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand All @@ -25,7 +26,7 @@ var extensionFixCmd = &cobra.Command{

if !allowNonGit {
if stat, err := os.Stat(filepath.Join(args[0], ".git")); err != nil || !stat.IsDir() {
return fmt.Errorf("provided folder is not a git repository. Use --allow-non-git flag to run anyway")
return errors.New("provided folder is not a git repository. Use --allow-non-git flag to run anyway")
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/extension/extension_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ var extensionPackageCmd = &cobra.Command{
if len(fileName) == 0 {
fileName = fmt.Sprintf("%s-%s.zip", name, tag)
if len(tag) == 0 {
fileName = fmt.Sprintf("%s.zip", name)
fileName = name + ".zip"
}
}

Expand Down Expand Up @@ -247,8 +247,8 @@ func getStringOnStringError(val string, _ error) string {

func executeHooks(ctx context.Context, ext extension.Extension, hooks []string, extDir string) error {
env := []string{
fmt.Sprintf("EXTENSION_DIR=%s", extDir),
fmt.Sprintf("ORIGINAL_EXTENSION_DIR=%s", ext.GetPath()),
"EXTENSION_DIR=" + extDir,
"ORIGINAL_EXTENSION_DIR=" + ext.GetPath(),
}

for _, hook := range hooks {
Expand Down
5 changes: 3 additions & 2 deletions cmd/project/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package project
import (
"context"
"encoding/json"
"errors"
"fmt"
"os"
"os/exec"
Expand Down Expand Up @@ -414,7 +415,7 @@ func projectCISafetyCheck(ctx context.Context, root string, force bool, getenv f
}

if dirty {
return fmt.Errorf("project ci removes source files and creates build stubs; refusing to run outside CI with a dirty git working tree. Commit, stash, or clean local changes, or pass --force if you intentionally want to run it")
return errors.New("project ci removes source files and creates build stubs; refusing to run outside CI with a dirty git working tree. Commit, stash, or clean local changes, or pass --force if you intentionally want to run it")
}

logging.FromContext(ctx).Warnf("Running project ci outside a CI environment; this command removes source files and should usually only be used in CI")
Expand Down Expand Up @@ -495,7 +496,7 @@ func executeCIHooks(ctx context.Context, sectionName string, hooks []string, roo
hookCmd.Stdout = os.Stdout
hookCmd.Stderr = os.Stderr
hookCmd.Dir = root
hookCmd.Env = append(os.Environ(), fmt.Sprintf("PROJECT_ROOT=%s", root))
hookCmd.Env = append(os.Environ(), "PROJECT_ROOT="+root)

if err := hookCmd.Run(); err != nil {
return fmt.Errorf("hook failed (%s): %w", hook, err)
Expand Down
20 changes: 10 additions & 10 deletions cmd/project/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package project

import (
"context"
"fmt"
"errors"
"os"
"path/filepath"
"slices"
Expand Down Expand Up @@ -35,8 +35,8 @@ func findClosestShopwareProject() (string, error) {

for {
files := []string{
fmt.Sprintf("%s/composer.json", currentDir),
fmt.Sprintf("%s/composer.lock", currentDir),
currentDir + "/composer.json",
currentDir + "/composer.lock",
}

for _, file := range files {
Expand All @@ -48,7 +48,7 @@ func findClosestShopwareProject() (string, error) {
contentString := string(content)

if strings.Contains(contentString, "shopware/core") {
if _, err := os.Stat(fmt.Sprintf("%s/bin/console", currentDir)); err == nil {
if _, err := os.Stat(currentDir + "/bin/console"); err == nil {
return currentDir, nil
}
}
Expand All @@ -62,7 +62,7 @@ func findClosestShopwareProject() (string, error) {
}
}

return "", fmt.Errorf("cannot find Shopware project in current directory")
return "", errors.New("cannot find Shopware project in current directory")
}

func filterAndWritePluginJson(cmd *cobra.Command, projectRoot string, shopCfg *shop.Config, cmdExecutor executor.Executor) error {
Expand Down Expand Up @@ -102,7 +102,7 @@ func filterAndGetSources(cmd *cobra.Command, projectRoot string, shopCfg *shop.C
}

if onlyExtensions != "" && skipExtensions != "" {
return nil, fmt.Errorf("only-extensions and skip-extensions cannot be used together")
return nil, errors.New("only-extensions and skip-extensions cannot be used together")
}

logger := logging.FromContext(cmd.Context())
Expand Down Expand Up @@ -178,11 +178,11 @@ func validateExtensionSelection(ctx context.Context, onlyExtensions string, sele
}

if onlyExtensions != "" {
return fmt.Errorf("only one of --only-extensions and --select-extensions can be used")
return errors.New("only one of --only-extensions and --select-extensions can be used")
}

if !system.IsInteractionEnabled(ctx) {
return fmt.Errorf("--select-extensions requires an interactive terminal; use --only-extensions with a comma-separated list instead")
return errors.New("--select-extensions requires an interactive terminal; use --only-extensions with a comma-separated list instead")
}

return nil
Expand All @@ -202,7 +202,7 @@ func selectExtensionsInteractively(cmd *cobra.Command, sources []asset.Source) (
}

if len(items) == 0 {
return "", fmt.Errorf("no extensions available to select")
return "", errors.New("no extensions available to select")
}

selected, err := tui.FilterMultiSelect(cmd.Context(),
Expand All @@ -214,7 +214,7 @@ func selectExtensionsInteractively(cmd *cobra.Command, sources []asset.Source) (
}

if len(selected) == 0 {
return "", fmt.Errorf("no extensions selected")
return "", errors.New("no extensions selected")
}

return strings.Join(selected, ","), nil
Expand Down
5 changes: 3 additions & 2 deletions cmd/project/project_admin_api.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package project

import (
"errors"
"fmt"
"net/url"
"path"
Expand All @@ -26,7 +27,7 @@ var projectAdminApiCmd = &cobra.Command{
}

if cfg.AdminApi == nil {
return fmt.Errorf("admin api is not activated in the config")
return errors.New("admin api is not activated in the config")
}

client, err := shop.NewShopClient(cobraCmd.Context(), cfg)
Expand All @@ -47,7 +48,7 @@ var projectAdminApiCmd = &cobra.Command{
}

if len(args) < 2 {
return fmt.Errorf("command needs 2 arguments")
return errors.New("command needs 2 arguments")
}

shopURL, err := url.Parse(cfg.URL)
Expand Down
2 changes: 1 addition & 1 deletion cmd/project/project_autofix_composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var projectAutofixComposerCmd = &cobra.Command{
return pluginmigrate.NewPluginMigrator(projectRoot, exec).RunHeadless(cmd.Context(), pluginmigrate.HeadlessOptions{
Token: os.Getenv("SHOPWARE_PACKAGIST_TOKEN"),
DryRun: dryRun,
Out: os.Stdout,
Out: cmd.OutOrStdout(),
})
}

Expand Down
5 changes: 3 additions & 2 deletions cmd/project/project_autofix_flex.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package project

import (
"errors"
"fmt"
"os"
"path"
Expand Down Expand Up @@ -35,11 +36,11 @@ var projectAutofixFlexCmd = &cobra.Command{
}

if !confirmed {
return fmt.Errorf("autofix cancelled")
return errors.New("autofix cancelled")
}

if _, err := os.Stat(path.Join(project, "symfony.lock")); err == nil {
return fmt.Errorf("symfony.lock already exists, is that project already migrated to Symfony Flex?")
return errors.New("symfony.lock already exists, is that project already migrated to Symfony Flex?")
}

if err := flexmigrator.MigrateComposerJson(project); err != nil {
Expand Down
3 changes: 1 addition & 2 deletions cmd/project/project_clear_cache.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package project

import (
"fmt"
"os"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -30,7 +29,7 @@ var projectClearCacheCmd = &cobra.Command{
return err
}

return os.RemoveAll(fmt.Sprintf("%s/var/cache", projectRoot))
return os.RemoveAll(projectRoot + "/var/cache")
}

logging.FromContext(cmd.Context()).Infof("Clearing cache using admin-api")
Expand Down
6 changes: 3 additions & 3 deletions cmd/project/project_config_init.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package project

import (
"fmt"
"errors"

"charm.land/huh/v2"
"github.com/spf13/cobra"
Expand All @@ -17,7 +17,7 @@ var projectConfigInitCmd = &cobra.Command{
Short: "Creates a new project config in current dir",
RunE: func(cmd *cobra.Command, _ []string) error {
if !system.IsInteractionEnabled(cmd.Context()) {
return fmt.Errorf("this command requires interaction, but interaction is disabled")
return errors.New("this command requires interaction, but interaction is disabled")
}

config := &shop.Config{
Expand Down Expand Up @@ -117,7 +117,7 @@ func init() {

func emptyValidator(s string) error {
if len(s) == 0 {
return fmt.Errorf("this cannot be empty")
return errors.New("this cannot be empty")
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion cmd/project/project_create_form.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package project

import (
"errors"
"fmt"
"os"
"slices"
Expand Down Expand Up @@ -282,7 +283,7 @@ func runCreateForm(cmd *cobra.Command, opts *createOptions, filteredVersions []*
}

if selectConfirm == "cancel" {
return fmt.Errorf("project creation cancelled")
return errors.New("project creation cancelled")
}
}
}
7 changes: 4 additions & 3 deletions cmd/project/project_create_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package project
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -140,7 +141,7 @@ func handleSecurityBlockedInstall(ctx context.Context, opts *createOptions, chos
}

if continueAnyway == tui.No {
return fmt.Errorf("project creation cancelled")
return errors.New("project creation cancelled")
}

opts.noAudit = true
Expand All @@ -165,7 +166,7 @@ func runComposerInstall(ctx context.Context, projectFolder string, useDocker boo
dockerArgs := []string{"run",
"--rm",
"--pull=always",
"-v", fmt.Sprintf("%s:/app", absProjectFolder),
"-v", absProjectFolder + ":/app",
"-w", "/app"}

dockerArgs = append(dockerArgs, system.DockerRunUserArgs(absProjectFolder)...)
Expand All @@ -175,7 +176,7 @@ func runComposerInstall(ctx context.Context, projectFolder string, useDocker boo
if err == nil {
composerDir := filepath.Join(homeDir, ".composer")
_ = os.MkdirAll(composerDir, 0o755)
dockerArgs = append(dockerArgs, "-v", fmt.Sprintf("%s:/tmp/composer/", composerDir))
dockerArgs = append(dockerArgs, "-v", composerDir+":/tmp/composer/")
}
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/project/project_create_scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package project

import (
"context"
"fmt"
"strconv"

"github.com/shopware/shopware-cli/internal/shop"
"github.com/shopware/shopware-cli/internal/system"
Expand All @@ -14,10 +14,10 @@ func scaffoldProject(ctx context.Context, opts *createOptions, chosenVersion str
tracking.TagVersion: opts.selectedVersion,
tracking.TagDeployment: opts.selectedDeployment,
tracking.TagCI: opts.selectedCI,
tracking.TagDocker: fmt.Sprintf("%v", opts.useDocker),
tracking.TagWithElasticsearch: fmt.Sprintf("%v", opts.withElasticsearch),
tracking.TagWithAMQP: fmt.Sprintf("%v", opts.withAMQP),
tracking.TagInteractive: fmt.Sprintf("%v", opts.interactive),
tracking.TagDocker: strconv.FormatBool(opts.useDocker),
tracking.TagWithElasticsearch: strconv.FormatBool(opts.withElasticsearch),
tracking.TagWithAMQP: strconv.FormatBool(opts.withAMQP),
tracking.TagInteractive: strconv.FormatBool(opts.interactive),
})

scaffold := newShopwareProjectScaffold(opts, chosenVersion)
Expand Down
9 changes: 5 additions & 4 deletions cmd/project/project_create_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package project

import (
"context"
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -90,7 +91,7 @@ func checkSecurityAdvisories(ctx context.Context, opts *createOptions, chosenVer
}

if continueAnyway == tui.No {
return fmt.Errorf("project creation cancelled")
return errors.New("project creation cancelled")
}

opts.noAudit = true
Expand All @@ -113,14 +114,14 @@ func checkIncompatibilities(ctx context.Context, opts *createOptions) error {
if err := huh.NewForm(huh.NewGroup(
tui.NewYesNo().
Title(incompatibility.Title).
Description(fmt.Sprintf("%s. Do you want to continue anyway?", incompatibility.Description)).
Description(incompatibility.Description + ". Do you want to continue anyway?").
Value(&continueAnyway),
)).Run(); err != nil {
return err
}

if continueAnyway == tui.No {
return fmt.Errorf("project creation cancelled")
return errors.New("project creation cancelled")
}
} else {
logging.FromContext(ctx).Warnf("%s. %s", incompatibility.Title, incompatibility.Description)
Expand All @@ -133,7 +134,7 @@ func checkIncompatibilities(ctx context.Context, opts *createOptions) error {
func renderSecurityAdvisories(chosenVersion string, advisories []repository.SecurityAdvisory) string {
var b strings.Builder

b.WriteString(tui.RedText.Bold(true).Render(fmt.Sprintf("Security Advisories for Shopware %s", chosenVersion)))
b.WriteString(tui.RedText.Bold(true).Render("Security Advisories for Shopware " + chosenVersion))
b.WriteString("\n\n")

warn := tui.YellowText.Render("⚠")
Expand Down
Loading
Loading