shop

package
v0.18.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeploymentNone         = "none"
	DeploymentContainer    = "container"
	DeploymentDeployer     = "deployer"
	DeploymentPlatformSH   = "platformsh"
	DeploymentShopwarePaaS = "shopware-paas"
)
View Source
const (
	VersionLatest = "latest"
	// VersionTrunk is the Composer dev branch tracking Shopware's trunk on
	// GitHub. It installs like a released version, e.g.
	// `shopware-cli project create my-shop dev-trunk`.
	VersionTrunk = "dev-trunk"
)
View Source
const (
	// DefaultProjectSBOMOutput is the filename written by both `project ci` and
	// `project sbom` when --output is omitted. Keep them identical so tooling
	// that already consumes the CI artifact keeps working.
	DefaultProjectSBOMOutput = "sbom.cdx.json"

	// ProjectSBOMFormatCycloneDXJSON is the only format currently supported.
	// The flag exists so additional formats can be added without breaking the CLI.
	ProjectSBOMFormatCycloneDXJSON = "cyclonedx-json"
)
View Source
const (
	CINone   = "none"
	CIGitHub = "github"
	CIGitLab = "gitlab"
)
View Source
const (
	CompatibilityDevMode = "2026-03-01"
)

Variables

View Source
var (
	ErrNoComposerFileFound        = errors.New("could not determine Shopware version as no composer.json or composer.lock file was found")
	ErrShopwareDependencyNotFound = errors.New("could not determine Shopware version as no shopware/core dependency was found")
)
View Source
var DefaultShopURL = docker.DefaultShopURL

DefaultShopURL is the URL a dev environment is reachable at with the default ports (and no proxy), matching the web service's default host port.

View Source
var (
	ErrDevModeNotSupported = NewCompatibilityError("development mode is not supported for this compatibility date", CompatibilityDevMode)
)
View Source
var ErrNoAdminAPICredentials = errors.New("no Admin API credentials configured: set environments.<name>.admin_api in .shopware-project.yml or SHOPWARE_CLI_API_CLIENT_ID and SHOPWARE_CLI_API_CLIENT_SECRET")

ErrNoAdminAPICredentials is returned when neither the project config nor the environment provides Admin API credentials.

View Source
var SupportedPHPVersions = []string{"8.2", "8.3", "8.4", "8.5"}

SupportedPHPVersions lists the PHP versions selectable for the docker dev image, ordered from lowest to highest.

Functions

func ConfigSchema

func ConfigSchema() []byte

ConfigSchema returns the JSON schema for the .config/shopware-project.yml configuration file.

func DefaultWorkerQueues

func DefaultWorkerQueues(projectRoot string) []string

DefaultWorkerQueues returns the default queues to consume based on the Shopware version of the project.

func DumpDatabase

func DumpDatabase(ctx context.Context, sqlCfg *mysql.Config, cfg *ConfigDump, opts DumpDatabaseOptions) error

DumpDatabase dumps the database described by sqlCfg to opts.Output. cfg may be nil; Clean, Anonymize and LimitOverrides are applied to cfg in place.

func EnsureComposeProjectName

func EnsureComposeProjectName(projectRoot string) error

EnsureComposeProjectName writes COMPOSE_PROJECT_NAME into the project .env when it is not already set. Existing values are left untouched (no silent volume disconnect for established stacks). The file is created when missing.

func EnvFileContent

func EnvFileContent(useDocker bool, projectFolder string) (string, error)

EnvFileContent returns the initial host .env contents for a scaffolded project. Docker projects get a unique COMPOSE_PROJECT_NAME so Compose volumes are not reused across same-basename recreations. Non-docker projects get an empty .env.

func FilterInstallVersions

func FilterInstallVersions(releases []repository.Version) []*version.Version

FilterInstallVersions returns supported Shopware releases in descending order, excluding dev branches and releases older than Shopware 6.4.18.0.

func FindClosestShopwareProject

func FindClosestShopwareProject(allowFallback bool) (string, error)

FindClosestShopwareProject walks from the current directory towards the filesystem root until it finds a Shopware project. When allowFallback is true, it returns the current directory if no project is found.

func GenerateComposeProjectName

func GenerateComposeProjectName(projectFolder string) (string, error)

GenerateComposeProjectName builds a unique Compose project name. Format: sw-<basename>-<6 hex>. The random suffix avoids volume reuse when a directory is deleted and recreated with the same basename. The generated name is a valid Compose project name by construction.

func GenerateComposerJson

func GenerateComposerJson(ctx context.Context, opts ComposerJsonOptions) (string, error)

func IsShopwareVersion

func IsShopwareVersion(projectRoot string, requiredVersion string) (bool, error)

func LocalConfigFileName

func LocalConfigFileName(fileName string) string

LocalConfigFileName returns the path of the local override file belonging to the given project configuration file.

func NewCompatibilityError

func NewCompatibilityError(message string, date string) error

func NewShopClient

func NewShopClient(ctx context.Context, config *Config) (*adminSdk.Client, error)

func ProductionDockerfile

func ProductionDockerfile(opts ProductionDockerfileOptions) ([]byte, error)

ProductionDockerfile is shared by project scaffolding and container packaging.

func ProductionDockerignore

func ProductionDockerignore() string

func ReadComposerAuth

func ReadComposerAuth(authFile string) (*composer.Auth, error)

ReadComposerAuth reads a Composer auth.json (via go-composer), then merges Shopware-specific environment configuration on top: the COMPOSER_AUTH env var (handled by go-composer's MergeEnv) and the SHOPWARE_PACKAGES_TOKEN convenience variable, which registers a bearer token for packages.shopware.com.

A missing auth.json is not an error; an empty, env-populated Auth is returned.

func ResolveInstallVersion

func ResolveInstallVersion(selectedVersion string, filteredVersions []*version.Version) (string, error)

ResolveInstallVersion resolves "latest", exact releases, and dev branches to the version passed to Composer.

func ResolveProjectSBOMOutputPath

func ResolveProjectSBOMOutputPath(root, output string) (string, error)

ResolveProjectSBOMOutputPath returns the absolute path to write the SBOM to. Empty output uses DefaultProjectSBOMOutput under root; absolute paths are kept; relative paths resolve against the process working directory.

func RestoreComposeProjectName

func RestoreComposeProjectName(projectRoot, name string) error

RestoreComposeProjectName re-adds a known COMPOSE_PROJECT_NAME to the project .env when the key was lost — e.g. after `composer recipes:install --force --reset` replaced .env with the recipe template. A present value is left untouched, an empty name is a no-op, and the file is created when missing.

func RestoreProjectURL

func RestoreProjectURL(configPath, envName string, prev ConfigURLState) error

RestoreProjectURL restores the url values captured in prev; previously absent keys are removed again.

func RunWorkers

func RunWorkers(ctx context.Context, jobs []WorkerJob, start StartWorkerFunc) error

RunWorkers supervises one restart-loop goroutine per job. Crashed consumers are restarted, throttled by a per-job rate limiter of one start per 10 seconds. It blocks until the context is cancelled and all consumers have stopped.

func SearchConfigPath

func SearchConfigPath(ctx context.Context, projectRoot string, inputPath string) string

SearchConfigPath either returns the inputPath if not empty or searches for the config file in projectRoot based on documented priority. It logs warnings if further config files exists that aren't used

func SetProjectURL

func SetProjectURL(configPath, envName, url string) error

SetProjectURL points the project config's environment (or top-level) url at url in place, preserving comments, ordering and unknown keys.

func UpdateLocalDockerPHP

func UpdateLocalDockerPHP(configPath string, php *ConfigDockerPHP) error

UpdateLocalDockerPHP writes the profiler credential fields into docker.php of the local override file, preserving all other content. Empty fields remove the corresponding key, and a nil php config clears every credential key, so rotated secrets do not survive on disk.

func UpdateLocalDockerPorts

func UpdateLocalDockerPorts(configPath string, overrides []docker.PortOverride) error

UpdateLocalDockerPorts merges the given host-port overrides into docker.services.<service>.ports of the local override file, preserving all other content.

func ValidateCISystem

func ValidateCISystem(ciSystem string) error

ValidateCISystem reports whether a CI system is supported by the project scaffold.

func ValidateDeploymentMethod

func ValidateDeploymentMethod(deploymentMethod string) error

ValidateDeploymentMethod reports whether a deployment method is supported by the project scaffold.

func ValidatePHPVersion

func ValidatePHPVersion(phpVersion string) error

ValidatePHPVersion checks that a user-supplied PHP version is a supported major.minor series. Requiring the series (rather than a patch level) keeps the value usable as both a Docker image tag and a portable config pin.

func ValidateProjectFolder

func ValidateProjectFolder(projectFolder string) error

ValidateProjectFolder ensures that an existing target is an empty directory.

func ValidateProjectSBOMFormat

func ValidateProjectSBOMFormat(format string) error

ValidateProjectSBOMFormat returns an error when format is not supported.

func WriteConfig

func WriteConfig(cfg *Config, dir string) error

WriteConfig Writes config in specified project dir under either its original location where it was read from (stored in `Config.storageLocation`), or the default recommended location.

func WriteProjectSBOM

func WriteProjectSBOM(ctx context.Context, root string, opts ProjectSBOMOptions) error

WriteProjectSBOM reads composer.lock from root and writes a CycloneDX SBOM. Shared by `project ci` and `project sbom` so both emit the same document.

Types

type CompatibilityError

type CompatibilityError struct {
	Message string
	// contains filtered or unexported fields
}

func (*CompatibilityError) Error

func (e *CompatibilityError) Error() string

type ComposerJsonOptions

type ComposerJsonOptions struct {
	Version          string
	DependingVersion string
	RC               bool
	UseElasticsearch bool
	UseAMQP          bool
	NoAudit          bool
	DeploymentMethod string
}

func (ComposerJsonOptions) IsDeployer

func (o ComposerJsonOptions) IsDeployer() bool

func (ComposerJsonOptions) IsPlatformSH

func (o ComposerJsonOptions) IsPlatformSH() bool

func (ComposerJsonOptions) IsShopwarePaaS

func (o ComposerJsonOptions) IsShopwarePaaS() bool

type ComposerScript

type ComposerScript struct {
	Name        string
	Description string
	Aliases     []string
}

func FindComposerScript

func FindComposerScript(scripts []ComposerScript, name string) (ComposerScript, bool)

func GetComposerScripts

func GetComposerScripts(projectRoot string) ([]ComposerScript, error)

type Config

type Config struct {
	AdditionalConfigs []string `yaml:"include,omitempty"`
	// Shop URL. Prefer environments.local.url or another named environment; the top-level url key is used only when environments.local is absent.
	URL string `yaml:"url,omitempty" jsonschema:"deprecated=true"`
	// Controls date-based compatibility behavior, formatted as YYYY-MM-DD.
	CompatibilityDate string `yaml:"compatibility_date,omitempty" jsonschema:"format=date"`
	// PHP version (e.g. "8.3") used for local PHP and Composer commands of this project. Written by "project create" for non-Docker projects. The matching PHP is looked up on the machine running the command, so the value stays portable across machines; it takes precedence over the php found in PATH, while the PHP_BINARY environment variable overrides it.
	PHPVersion string       `yaml:"php_version,omitempty"`
	Build      *ConfigBuild `yaml:"build,omitempty"`
	// Admin API credentials. Prefer environments.local.admin_api or another named environment; the top-level admin_api key is used only when environments.local is absent.
	AdminApi         *ConfigAdminApi   `yaml:"admin_api,omitempty" jsonschema:"deprecated=true"`
	ConfigDump       *ConfigDump       `yaml:"dump,omitempty"`
	ConfigDeployment *ConfigDeployment `yaml:"deployment,omitempty"`
	Validation       *ConfigValidation `yaml:"validation,omitempty"`
	ImageProxy       *ConfigImageProxy `yaml:"image_proxy,omitempty"`
	// Docker dev environment configuration
	Docker *ConfigDocker `yaml:"docker,omitempty"`
	// Named shop targets. Empty -e selects environments.local. Store url and admin_api here rather than at the top level.
	Environments map[string]*EnvironmentConfig `yaml:"environments,omitempty"`
	// When enabled, composer scripts will be disabled during CI builds
	DisableComposerScripts bool `yaml:"disable_composer_scripts,omitempty"`
	// When enabled, composer install will be skipped during CI builds
	DisableComposerInstall bool `yaml:"disable_composer_install,omitempty"`
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig() *Config

func ReadConfig

func ReadConfig(ctx context.Context, fileName string, allowFallback bool) (*Config, error)

func (*Config) DockerOptions

func (c *Config) DockerOptions() docker.Options

DockerOptions maps the configuration onto the dev environment's options: PHP settings and per-service settings. The lock features, user and worker are resolved by docker.NewEnvironment, the proxy mode by proxy.NewEnvironment. Nil-safe for a nil config.

func (*Config) DockerPorts

func (c *Config) DockerPorts(service string) docker.Ports

DockerPorts returns the host-port overrides of a service, nil when none are configured. Nil-safe for a nil config.

func (*Config) DockerServices

func (c *Config) DockerServices() ConfigDockerServices

DockerServices returns the configured per-service settings, nil when none are set. Nil-safe for a nil config.

func (*Config) EffectiveURL

func (c *Config) EffectiveURL() string

EffectiveURL returns the URL of the default environment: environments.local.url, falling back to the deprecated top-level url.

func (*Config) GetStorageLocation

func (c *Config) GetStorageLocation() string

GetStorageLocation will return the actual file path where the config either was loaded from or will be persisted to.

func (*Config) HasCompatibilityDate

func (c *Config) HasCompatibilityDate() bool

func (*Config) HasDeprecatedTopLevelShop

func (c *Config) HasDeprecatedTopLevelShop() bool

HasDeprecatedTopLevelShop reports whether the config still stores a shop target at the top-level url or admin_api keys.

func (*Config) IsAdminAPIConfigured

func (c *Config) IsAdminAPIConfigured() bool

func (*Config) IsCompatibilityDateAtLeast

func (c *Config) IsCompatibilityDateAtLeast(requiredDate string) (bool, error)

func (*Config) IsCompatibilityDateBefore

func (c *Config) IsCompatibilityDateBefore(requiredDate string) bool

func (Config) IsFallback

func (c Config) IsFallback() bool

func (*Config) ResolveEnvironment

func (c *Config) ResolveEnvironment(name string) (*EnvironmentConfig, error)

ResolveEnvironment returns the named environment, or for an empty name environments.local with the deprecated top-level url/admin_api as fallback.

func (*Config) SetLocalShop

func (c *Config) SetLocalShop(url string, adminApi *ConfigAdminApi)

SetLocalShop stores the shop URL and optional Admin API credentials on environments.local. It does not set top-level url or admin_api.

func (*Config) WithDockerPortOverrides

func (c *Config) WithDockerPortOverrides(overrides []docker.PortOverride) *Config

WithDockerPortOverrides returns a copy of the config with the host-port overrides merged into docker.services. The receiver and its docker section are left untouched, so a caller can build the new config off the update thread and adopt it once every dependent write succeeded. An empty override set returns the receiver itself.

func (*Config) WithEnvironment

func (c *Config) WithEnvironment(name string) (*Config, error)

WithEnvironment returns a copy of the config with URL and Admin API credentials from ResolveEnvironment, keeping base values the environment does not override.

type ConfigAdminApi

type ConfigAdminApi struct {
	// Client ID of integration
	ClientId string `yaml:"client_id,omitempty"`
	// Client Secret of integration
	ClientSecret string `yaml:"client_secret,omitempty"`
	// Username of admin user
	Username string `yaml:"username,omitempty"`
	// Password of admin user
	Password string `yaml:"password,omitempty"`
	// Disable SSL certificate check
	DisableSSLCheck bool `yaml:"disable_ssl_check,omitempty"`
}

type ConfigBuild

type ConfigBuild struct {
	// When enabled, the assets will not be copied to the public folder
	DisableAssetCopy bool `yaml:"disable_asset_copy,omitempty"`
	// When enabled, the assets of extensions will be removed from the extension public folder. (Requires Shopware 6.5.2.0)
	RemoveExtensionAssets bool `yaml:"remove_extension_assets,omitempty"`
	// When enabled, the extensions source code will be keep in the final build
	KeepExtensionSource bool `yaml:"keep_extension_source,omitempty"`
	// When enabled, the source maps will not be removed from the final build
	KeepSourceMaps bool `yaml:"keep_source_maps,omitempty"`
	// Paths to delete for the final build
	CleanupPaths []string `yaml:"cleanup_paths,omitempty"`
	// Browserslist configuration for the Storefront build
	Browserslist string `yaml:"browserslist,omitempty"`
	// Extensions to exclude from the build
	ExcludeExtensions []string `yaml:"exclude_extensions,omitempty"`
	// When enabled, the storefront build will be skipped
	DisableStorefrontBuild bool `yaml:"disable_storefront_build,omitempty"`
	// When enabled, the checksum.json generation for extensions will be skipped
	DisableChecksums bool `yaml:"disable_checksums,omitempty"`
	// When enabled, an already existing checksum.json in an extension will be kept instead of being overwritten
	KeepExistingChecksums bool `yaml:"keep_existing_checksums,omitempty"`
	// Extensions to force build for, even if they have compiled files
	ForceExtensionBuild []ConfigBuildExtension `yaml:"force_extension_build,omitempty"`
	// When enabled, the shopware admin will be built
	ForceAdminBuild bool `yaml:"force_admin_build,omitempty"`
	// Keep following node_modules in the final build
	KeepNodeModules []string `yaml:"keep_node_modules,omitempty"`
	// MJML email template compilation configuration
	MJML *ConfigBuildMJML `yaml:"mjml,omitempty"`
	// When enabled, built assets are cached and restored on subsequent builds when sources haven't changed
	AssetCaching bool `yaml:"asset_caching,omitempty"`
	// Hooks to run at specific points during CI builds
	Hooks *ConfigBuildHooks `yaml:"hooks,omitempty"`
	// Shopware bundles to include in builds (alternative to composer.json extra.shopware-bundles)
	Bundles []ConfigProjectBundle `yaml:"bundles,omitempty"`
}

func (ConfigBuild) IsMjmlEnabled

func (c ConfigBuild) IsMjmlEnabled() bool

type ConfigBuildExtension

type ConfigBuildExtension struct {
	// Name of the extension
	Name string `yaml:"name" jsonschema:"required"`
}

ConfigBuildExtension defines the configuration for forcing extension builds.

type ConfigBuildHooks

type ConfigBuildHooks struct {
	// Commands to run before anything runs
	Pre []string `yaml:"pre,omitempty"`
	// Commands to run after everything completes
	Post []string `yaml:"post,omitempty"`
	// Commands to run before composer install
	PreComposer []string `yaml:"pre-composer,omitempty"`
	// Commands to run after composer install
	PostComposer []string `yaml:"post-composer,omitempty"`
	// Commands to run before asset build
	PreAssets []string `yaml:"pre-assets,omitempty"`
	// Commands to run after asset build
	PostAssets []string `yaml:"post-assets,omitempty"`
}

ConfigBuildHooks defines hooks to run at specific points during CI builds.

type ConfigBuildMJML

type ConfigBuildMJML struct {
	// Whether to enable MJML compilation
	Enabled bool `yaml:"enabled,omitempty"`
	// Directories to search for MJML files
	SearchPaths []string `yaml:"search_paths,omitempty"`
	// When enabled, mj-include directives in MJML templates are processed.
	// MJML 5 ignores mj-include by default for security reasons; set this to
	// true to opt back in. Each search_path is automatically added to the
	// mj-include allowlist for files compiled inside it, so templates can
	// include siblings under the same search_path (e.g. a shared _includes/
	// folder) without further configuration.
	AllowIncludes bool `yaml:"allow_includes,omitempty"`
	// Extra directories outside any search_path that mj-include is allowed to
	// read from. Relative paths are resolved against the project root.
	// Absolute paths are used as-is. Most projects do not need this — set it
	// only when partials live outside the search_path tree. Implies
	// allow_includes.
	IncludePaths []string `yaml:"include_paths,omitempty"`
}

ConfigBuildMJML defines the configuration for MJML email template compilation.

func (ConfigBuildMJML) GetPaths

func (c ConfigBuildMJML) GetPaths(projectRoot string) []string

func (ConfigBuildMJML) ResolveIncludePaths

func (c ConfigBuildMJML) ResolveIncludePaths(projectRoot string) []string

ResolveIncludePaths returns IncludePaths as absolute paths. Relative entries are resolved against projectRoot; absolute entries are returned unchanged. Returns nil when no paths are configured.

type ConfigDeployment

type ConfigDeployment struct {
	Hooks struct {
		// The pre hook will be executed before the deployment
		Pre ConfigDeploymentHook `yaml:"pre"`
		// The post hook will be executed after the deployment
		Post ConfigDeploymentHook `yaml:"post"`
		// The pre-install hook will be executed before the installation
		PreInstall ConfigDeploymentHook `yaml:"pre-install"`
		// The post-install hook will be executed after the installation
		PostInstall ConfigDeploymentHook `yaml:"post-install"`
		// The post-extension-on-project-install hook will be executed after project extensions are installed
		PostExtensionOnProjectInstall ConfigDeploymentHook `yaml:"post-extension-on-project-install"`
		// The pre-update hook will be executed before the update
		PreUpdate ConfigDeploymentHook `yaml:"pre-update"`
		// The post-update hook will be executed after the update
		PostUpdate ConfigDeploymentHook `yaml:"post-update"`
	} `yaml:"hooks"`

	Store struct {
		LicenseDomain string `yaml:"license-domain"`
	} `yaml:"store"`

	Cache struct {
		AlwaysClear bool `yaml:"always_clear"`
	} `yaml:"cache"`

	// The extension management of the deployment
	ExtensionManagement struct {
		// When enabled, the extensions will be installed, updated, and removed
		Enabled bool `yaml:"enabled"`
		// Which extensions should not be managed
		Exclude []string `yaml:"exclude"`

		Overrides ConfigDeploymentOverrides `yaml:"overrides"`

		// DEPRECATED, On these extensions, it will be always called plugin:update
		ForceUpdatesDeprecated []string `yaml:"force_updates,omitempty" jsonschema:"deprecated=true"`
		// On these extensions, it will be always called plugin:update
		ForceUpdate []string `yaml:"force-update,omitempty"`
	} `yaml:"extension-management"`

	OneTimeTasks []struct {
		Id     string `yaml:"id" jsonschema:"required"`
		Script string `yaml:"script" jsonschema:"required"`
	} `yaml:"one-time-tasks"`

	// Staging mode configuration for the deployment
	Staging *ConfigDeploymentStaging `yaml:"staging,omitempty"`

	// OpenSearch configuration for the deployment.
	OpenSearch *ConfigDeploymentOpenSearch `yaml:"opensearch,omitempty"`
}

type ConfigDeploymentHook

type ConfigDeploymentHook struct {
	Steps []ConfigDeploymentHookStep
}

ConfigDeploymentHook is a deployment hook. It can either be a single script (string) or a list of steps that are executed individually. Each step can be a plain script string or an object with a "title" and a "script".

func (ConfigDeploymentHook) JSONSchema

func (ConfigDeploymentHook) JSONSchema() *jsonschema.Schema

func (ConfigDeploymentHook) MarshalYAML

func (h ConfigDeploymentHook) MarshalYAML() (any, error)

MarshalYAML preserves the public hook format when packaging resolved config. The internal Steps wrapper is not accepted by UnmarshalYAML.

func (*ConfigDeploymentHook) UnmarshalYAML

func (h *ConfigDeploymentHook) UnmarshalYAML(value *yaml.Node) error

type ConfigDeploymentHookStep

type ConfigDeploymentHookStep struct {
	// An optional title shown in the deployment output for this step
	Title string `yaml:"title,omitempty"`
	// The script that is executed for this step
	Script string `yaml:"script"`
}

ConfigDeploymentHookStep is a single titled step of a deployment hook.

type ConfigDeploymentOpenSearch

type ConfigDeploymentOpenSearch struct {
	// When enabled, OpenSearch indexes are created after a fresh installation.
	IndexOnInstall bool `yaml:"index-on-install,omitempty"`
}

ConfigDeploymentOpenSearch defines OpenSearch actions during deployment.

type ConfigDeploymentOverrides

type ConfigDeploymentOverrides map[string]struct {
	State string `yaml:"state"`
}

func (ConfigDeploymentOverrides) JSONSchema

type ConfigDeploymentStaging

type ConfigDeploymentStaging struct {
	// When enabled, staging setup commands will be executed during installation and upgrade
	Enabled bool `yaml:"enabled,omitempty"`
}

ConfigDeploymentStaging defines staging mode configuration.

type ConfigDocker

type ConfigDocker struct {
	// PHP configuration for the Docker dev image
	PHP *ConfigDockerPHP `yaml:"php,omitempty"`
	// Per-service settings for the Docker dev environment: host port overrides and implementation variants.
	Services ConfigDockerServices `yaml:"services,omitempty"`
}

type ConfigDockerPHP

type ConfigDockerPHP struct {
	// PHP version (e.g. "8.3", "8.2"). Defaults to "8.3".
	Version string `yaml:"version,omitempty"`
	// Profiler to enable. Possible values: xdebug, blackfire, tideways, pcov, spx.
	Profiler string `yaml:"profiler,omitempty" jsonschema:"enum=xdebug,enum=blackfire,enum=tideways,enum=pcov,enum=spx"`
	// Blackfire server ID from your Blackfire account. Required when profiler is "blackfire".
	BlackfireServerID string `yaml:"blackfire_server_id,omitempty"`
	// Blackfire server token from your Blackfire account. Required when profiler is "blackfire".
	BlackfireServerToken string `yaml:"blackfire_server_token,omitempty"`
	// Tideways API key from your Tideways account. Required when profiler is "tideways".
	TidewaysAPIKey string `yaml:"tideways_api_key,omitempty"`
}

func (ConfigDockerPHP) JSONSchema

func (ConfigDockerPHP) JSONSchema() *jsonschema.Schema

type ConfigDockerService

type ConfigDockerService = docker.ServiceSettings

ConfigDockerService configures one compose service of the dev environment; it is the catalog's settings type so the generator reads it directly.

type ConfigDockerServices

type ConfigDockerServices map[string]*ConfigDockerService

ConfigDockerServices holds the per-service settings of the Docker dev environment, keyed by compose service name. Valid names and keys are defined by the service catalog in internal/docker.

func (ConfigDockerServices) JSONSchemaExtend

func (ConfigDockerServices) JSONSchemaExtend(s *jsonschema.Schema)

JSONSchemaExtend replaces the generic map schema with one property per configurable catalog service, each allowing only the keys that apply to it.

func (ConfigDockerServices) Ports

func (s ConfigDockerServices) Ports(name string) docker.Ports

Ports returns the host-port overrides of a service, nil when none are configured. Nil-safe.

type ConfigDump

type ConfigDump struct {
	// Allows to rewrite single columns, perfect for GDPR compliance
	Rewrite map[string]map[string]string `yaml:"rewrite,omitempty"`
	// Only export the schema of these tables, supports glob wildcards (e.g. "customer*")
	NoData []string `yaml:"nodata,omitempty"`
	// Ignore these tables from export, supports glob wildcards (e.g. "customer*")
	Ignore []string `yaml:"ignore,omitempty"`
	// Add an where condition to that table, schema is table name as key, and where statement as value
	Where map[string]string `yaml:"where,omitempty"`
	// Limit the amount of exported rows of a table, schema is table name as key. All tables referencing the limited table via foreign keys (also transitively) are filtered automatically, so they only contain rows belonging to the kept rows. A second limit on a table that is already filtered this way is rejected. When the limited table references itself (e.g. product.parent_id), the ancestors of the kept rows are exported too, so the dump stays importable. Requires the CREATE and DROP privileges to freeze the kept rows into staging tables
	Limit map[string]mysqldump.TableLimit `yaml:"limit,omitempty"`
}

func (*ConfigDump) EnableAnonymization

func (c *ConfigDump) EnableAnonymization()

EnableAnonymization adds default column rewrites for anonymizing customer data

func (*ConfigDump) EnableClean

func (c *ConfigDump) EnableClean()

EnableClean adds default tables that should be excluded from data dump in clean mode

func (*ConfigDump) NormalizeFakerExpressions

func (c *ConfigDump) NormalizeFakerExpressions()

NormalizeFakerExpressions wraps bare faker expressions with {{- -}} delimiters so they can be properly evaluated by the mysqldump faker processor.

type ConfigImageProxy

type ConfigImageProxy struct {
	// The URL of the upstream server to proxy requests to when files are not found locally
	URL string `yaml:"url,omitempty"`
}

type ConfigProjectBundle

type ConfigProjectBundle struct {
	// Relative path from project root to the bundle directory
	Path string `yaml:"path" jsonschema:"required"`
	// Optional override for the bundle name; defaults to the directory basename
	Name string `yaml:"name,omitempty"`
}

ConfigProjectBundle defines a project-level Shopware bundle.

type ConfigURLState

type ConfigURLState struct {
	// HasFile is false when the project has no config file; registration
	// then leaves the project config alone entirely.
	HasFile bool `json:"-"`
	// RootURL is the top-level url value. HasRoot false = key was absent.
	RootURL string `json:"root_url,omitempty"`
	HasRoot bool   `json:"had_root_url,omitempty"`
	// EnvURL is environments.<env>.url, which overrides the top-level url
	// in the dev TUI and the admin API client. HasEnv false = key absent.
	EnvURL string `json:"env_url,omitempty"`
	HasEnv bool   `json:"had_env_url,omitempty"`
}

ConfigURLState captures the url values of a project config file (.config/shopware-project.yml) before proxy registration, so deregistration can restore them exactly. The rest of the CLI (dev TUI, admin API client) resolves the shop URL from these keys, which is why registration points them at the proxy hostname.

func ReadProjectURLState

func ReadProjectURLState(configPath, envName string) (ConfigURLState, error)

ReadProjectURLState reads the current url values straight from the project config file (not the merged Config), tracking whether each key is present so a later restore can be exact. A missing file is not an error; it yields HasFile=false.

type ConfigValidation

type ConfigValidation struct {
	// Ignore items from the validation.
	Ignore []ConfigValidationIgnoreItem `yaml:"ignore,omitempty"`

	IgnoreExtensions []ConfigValidationIgnoreExtension `yaml:"ignore_extensions,omitempty"`

	// PhpVersion overrides the PHP version used for linting (e.g. "8.4").
	// When set, this takes precedence over the version derived from composer.json or the static Shopware-to-PHP mapping.
	PhpVersion string `yaml:"php_version,omitempty"`
}

ConfigValidation is used to configure the project validation.

type ConfigValidationIgnoreExtension

type ConfigValidationIgnoreExtension struct {
	// The name of the extension to ignore.
	Name string `yaml:"name"`
}

type ConfigValidationIgnoreItem

type ConfigValidationIgnoreItem struct {
	// The identifier of the item to ignore.
	Identifier string `yaml:"identifier"`
	// The path of the item to ignore.
	Path string `yaml:"path,omitempty"`
	// The message of the item to ignore.
	Message string `yaml:"message,omitempty"`
}

ConfigValidationIgnoreItem is used to ignore items from the validation.

type ConsoleCommandFunc

type ConsoleCommandFunc func(ctx context.Context, args ...string) *exec.Cmd

ConsoleCommandFunc avoids a circular dependency between shop and executor packages.

type ConsoleResponse

type ConsoleResponse struct {
	Commands []struct {
		Name        string `json:"name"`
		Description string `json:"description"`
		Hidden      bool   `json:"hidden"`
		Definition  struct {
			Arguments interface{} `json:"arguments"`
			Options   map[string]struct {
				Shortcut string `json:"shortcut"`
			} `json:"options"`
		} `json:"definition"`
	} `json:"commands"`
}

func GetComposerCompletion

func GetComposerCompletion(ctx context.Context, projectRoot string, composerCommand ConsoleCommandFunc) (*ConsoleResponse, error)

func GetConsoleCompletion

func GetConsoleCompletion(ctx context.Context, projectRoot string, consoleCommand ConsoleCommandFunc) (*ConsoleResponse, error)

func ReadCachedComposerCompletion

func ReadCachedComposerCompletion(projectRoot string) (*ConsoleResponse, error)

func ReadCachedConsoleCompletion

func ReadCachedConsoleCompletion(projectRoot string) (*ConsoleResponse, error)

func (ConsoleResponse) GetCommandOptions

func (c ConsoleResponse) GetCommandOptions(name string) []string

func (ConsoleResponse) HasCommand

func (c ConsoleResponse) HasCommand(name string) bool

type DumpDatabaseOptions

type DumpDatabaseOptions struct {
	// Output is the destination file path, or "-" for stdout
	Output string
	// Compression compresses the dump output, parsed via mysqldump.ParseCompression
	Compression mysqldump.Compression
	// Clean excludes volatile tables (cart, messenger_messages, ...) from the data dump
	Clean bool
	// Anonymize rewrites customer related columns with faker data
	Anonymize bool
	// SkipLockTables disables locking the tables during the dump
	SkipLockTables bool
	// Quick enables the mysqldump quick mode
	Quick bool
	// Parallel controls how many tables are dumped concurrently (0 = disabled)
	Parallel int
	// InsertIntoLimit caps the rows per INSERT statement (0 = auto, takes priority over Quick when set)
	InsertIntoLimit int
	// LimitOverrides contains "table=rows" entries limiting the dumped rows per table
	LimitOverrides []string
}

DumpDatabaseOptions configures DumpDatabase. CLI concerns such as resolving the database credentials and prompting for passwords intentionally live outside this type.

type EnvironmentConfig

type EnvironmentConfig struct {
	Type string `yaml:"type" jsonschema:"enum=local,enum=docker,enum=ssh"`
	// Shop URL for this named environment
	URL string `yaml:"url,omitempty"`
	// Admin API credentials for this named environment
	AdminApi *ConfigAdminApi `yaml:"admin_api,omitempty"`
	// SSH target of this named environment (type "ssh"): a Shopware project on a remote host reachable over SSH. Commands run through a multiplexed SSH connection, and the database is tunneled through it automatically.
	SSH *EnvironmentSSHConfig `yaml:"ssh,omitempty"`
}

type EnvironmentSSHConfig

type EnvironmentSSHConfig struct {
	// SSH host name or IP address
	Host string `yaml:"host" jsonschema:"required"`
	// SSH user. Defaults to the user configured in ~/.ssh/config or the current user
	User string `yaml:"user,omitempty"`
	// SSH port. Defaults to 22
	Port int `yaml:"port,omitempty"`
	// Absolute path of the Shopware project root on the remote host
	Directory string `yaml:"directory" jsonschema:"required"`
	// Path to the SSH private key file. Defaults to the ssh agent or the default key files
	IdentityFile string `yaml:"identity_file,omitempty"`
	// PHP binary used for PHP and console commands on the remote host (e.g. "/usr/bin/php8.3"). Defaults to "php"
	PHPBinary string `yaml:"php_binary,omitempty"`
}

type PHPConstraint

type PHPConstraint struct {
	// contains filtered or unexported fields
}

PHPConstraint represents one or more composer-style `php` constraints (e.g. "^8.2" or "~8.2.0 || ~8.3.0"). A nil receiver is treated as "no constraint" and matches any supported PHP version.

func GetPHPConstraintForShopwareVersion

func GetPHPConstraintForShopwareVersion(ctx context.Context, chosenVersion string) (*PHPConstraint, error)

GetPHPConstraintForShopwareVersion fetches shopware/core's metadata from packagist and returns the `require.php` constraint declared for the given version. nil is returned when the version cannot be found or has no PHP requirement.

func NewPHPConstraint

func NewPHPConstraint(constraints ...string) *PHPConstraint

NewPHPConstraint constructs a PHPConstraint from one or more composer-style constraint strings. Empty strings are accepted and treated as "no constraint".

func PHPConstraintForShopwareVersion

func PHPConstraintForShopwareVersion(releases []repository.Version, chosenVersion string) *PHPConstraint

PHPConstraintForShopwareVersion returns the `require.php` constraint declared for the given version in the provided release list. Dev branches (e.g. dev-trunk) are looked up like any other version: the repository client fetches Packagist's dev metadata, so their constraint is usually known. nil is returned when the version cannot be found or has no PHP requirement.

func ShopwarePHPConstraint

func ShopwarePHPConstraint(lock *composer.Lock) *PHPConstraint

ShopwarePHPConstraint returns the `require.php` constraint declared by the project's installed Shopware package (shopware/core, falling back to shopware/platform) in the given composer.lock. Returns nil when no Shopware package is present or it declares no PHP requirement.

func (*PHPConstraint) Check

func (c *PHPConstraint) Check(phpVersion string) bool

Check reports whether the given PHP version (e.g. "8.3.7") satisfies every constraint. A nil receiver always returns true. An unparseable version returns false.

func (*PHPConstraint) HighestSupported

func (c *PHPConstraint) HighestSupported() string

HighestSupported returns the highest entry from SupportedPHPVersions that satisfies every constraint. Invalid or empty constraints are ignored. A nil receiver returns the highest supported version. If no version satisfies all constraints, the highest supported version is returned as a best-effort default.

func (*PHPConstraint) String

func (c *PHPConstraint) String() string

String returns the raw composer-style constraint strings joined by ", " for display purposes. Empty constraints are omitted. A nil receiver returns an empty string.

func (*PHPConstraint) SupportedVersions

func (c *PHPConstraint) SupportedVersions() []string

SupportedVersions returns the entries from SupportedPHPVersions that satisfy every constraint. Invalid or empty constraints are ignored. A nil receiver returns all supported versions. If no version satisfies the constraints, the full list is returned as a best-effort default.

type ProductionDockerfileOptions

type ProductionDockerfileOptions struct {
	PHPVersion          string
	WithDevDependencies bool
}

type ProjectSBOMOptions

type ProjectSBOMOptions struct {
	// OutputPath is the destination file. Empty means
	// filepath.Join(root, DefaultProjectSBOMOutput). Relative paths are resolved
	// against the process working directory (same as other CLI --output flags).
	OutputPath string

	// SkipMissingLock, when true, returns nil without writing a file if
	// composer.lock is absent. Used by `project ci` so a lock-less tree does not
	// fail the build. The standalone command leaves this false so a missing lock
	// is a hard error.
	SkipMissingLock bool

	// IncludeDevDependencies controls whether packages-dev from composer.lock are
	// included. Defaults to false to match `project ci`.
	IncludeDevDependencies bool

	// ToolVersion is reported in the SBOM metadata tools entry (shopware-cli version).
	ToolVersion string
}

ProjectSBOMOptions configures WriteProjectSBOM.

type ShopwareProjectScaffold

type ShopwareProjectScaffold struct {
	ProjectFolder       string
	Version             string
	DeploymentMethod    string
	CISystem            string
	PHPVersion          string
	UseDocker           bool
	UseElasticsearch    bool
	UseAMQP             bool
	NoAudit             bool
	SymfonyCLIInstalled bool
}

ShopwareProjectScaffold describes the files and directories of a new Shopware project. CLI concerns such as prompting, tracking, and detecting local tools intentionally live outside this type.

func (*ShopwareProjectScaffold) Normalize

func (s *ShopwareProjectScaffold) Normalize()

Normalize applies project defaults and deployment-specific requirements.

func (*ShopwareProjectScaffold) Scaffold

func (s *ShopwareProjectScaffold) Scaffold(ctx context.Context) error

Scaffold creates the initial project structure without installing its Composer dependencies.

func (ShopwareProjectScaffold) Validate

func (s ShopwareProjectScaffold) Validate() error

Validate ensures the scaffold options and target folder are safe to use.

func (*ShopwareProjectScaffold) WriteComposerJson

func (s *ShopwareProjectScaffold) WriteComposerJson(ctx context.Context) error

WriteComposerJson (re)generates the project's composer.json from the scaffold options, e.g. to disable composer's audit blocking after the initial scaffold has been written.

type StartWorkerFunc

type StartWorkerFunc func(ctx context.Context, job WorkerJob) (*exec.Cmd, error)

StartWorkerFunc creates and fully configures the consumer process for a job (stdout, env, graceful stop). It must not start it.

type WorkerConfig

type WorkerConfig struct {
	MemoryLimit   string
	TimeLimit     string
	FailureLimit  uint
	MessagesLimit uint
	Verbose       bool
}

WorkerConfig holds the shared messenger:consume options for all workers.

func (WorkerConfig) ConsumeArgs

func (c WorkerConfig) ConsumeArgs(queues []string) []string

ConsumeArgs builds the messenger:consume arguments for the given queues.

type WorkerJob

type WorkerJob struct {
	Queues       []string
	ConsumerName string
}

WorkerJob is a single consumer process to be supervised.

func PlanWorkers

func PlanWorkers(spec string, amount int, defaultQueues []string) ([]WorkerJob, error)

PlanWorkers expands either a worker spec ("async:5,mail:5") or the legacy worker amount into concrete worker jobs.

type WorkerQueue

type WorkerQueue struct {
	Name  string
	Count int
}

WorkerQueue is a single entry of a worker spec like "async:5".

func ParseWorkerSpec

func ParseWorkerSpec(spec string) ([]WorkerQueue, error)

ParseWorkerSpec parses a spec like "async:5,mail:5" into worker queues. The count is optional and defaults to 1, so "mail" equals "mail:1".

Directories

Path Synopsis
Package install holds the Shopware installation logic shared by the interactive dev TUI (internal/tui/dev) and the non-interactive `project dev install` command.
Package install holds the Shopware installation logic shared by the interactive dev TUI (internal/tui/dev) and the non-interactive `project dev install` command.
Package pluginmigrate moves extensions living in custom/ under Composer management: Shopware Store plugins are required from the Store packagist (and their local copy removed), everything else is registered as a Composer path repository.
Package pluginmigrate moves extensions living in custom/ under Composer management: Shopware Store plugins are required from the Store packagist (and their local copy removed), everything else is registered as a Composer path repository.
Package upgrade implements the backend for the interactive Shopware upgrade wizard (`shopware-cli project upgrade`): project readiness checks, the upgrade version catalog, extension compatibility classification, and the execution engine that applies the upgrade locally.
Package upgrade implements the backend for the interactive Shopware upgrade wizard (`shopware-cli project upgrade`): project readiness checks, the upgrade version catalog, extension compatibility classification, and the execution engine that applies the upgrade locally.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL