Documentation
¶
Overview ¶
Package install holds the Shopware installation logic shared by the interactive dev TUI (internal/tui/dev) and the non-interactive `project dev install` command. The actual installation is delegated to vendor/bin/shopware-deployment-helper, parameterized via INSTALL_* env vars.
Index ¶
- Constants
- Variables
- func FailedStep(current int) string
- func IsInstalled(ctx context.Context, exec executor.Executor) bool
- func LocaleIDs() []string
- func MatchStep(line string, from int) (int, bool)
- func PersistCredentials(cfg *shop.Config, envCfg *shop.EnvironmentConfig, projectRoot string, ...) error
- func Run(ctx context.Context, exec executor.Executor, opts Options, onLine func(string)) error
- func RunHeadless(ctx context.Context, exec executor.Executor, cfg *shop.Config, ...) error
- func ValidateAdminPassword(password string) error
- func ValidateCurrency(currency string) error
- func ValidateLocale(locale string) error
- type HeadlessOptions
- type Language
- type Options
- type Step
Constants ¶
const ( DefaultLocale = "en-GB" DefaultCurrency = "EUR" DefaultAdminUsername = "admin" DefaultAdminPassword = "shopware" )
Defaults applied when an Options field is left empty. They match the pre-selected values of the TUI install wizard.
const FailedStepSaveCredentials = "save_credentials"
FailedStepSaveCredentials is the failed_step telemetry value for an installation that succeeded but whose admin credentials could not be saved to the project config.
const MinAdminPasswordLength = 8
MinAdminPasswordLength is the minimum admin password length enforced by the Shopware core (user:create / system:install). Validating it here rejects too-short passwords up front instead of failing late during the deployment-helper run.
Variables ¶
var Currencies = []string{"EUR", "USD", "GBP", "PLN", "CHF", "SEK", "DKK", "NOK", "CZK"}
Currencies are the ISO codes offered by the install wizard.
var Languages = []Language{
{"en-GB", "English (UK)"},
{"en-US", "English (US)"},
{"de-DE", "Deutsch"},
{"cs-CZ", "Čeština"},
{"da-DK", "Dansk"},
{"es-ES", "Español"},
{"fr-FR", "Français"},
{"it-IT", "Italiano"},
{"nl-NL", "Nederlands"},
{"nn-NO", "Norsk"},
{"pl-PL", "Język polski"},
{"pt-PT", "Português"},
{"sv-SE", "Svenska"},
}
Languages are the locales offered by the install wizard, in display order. The IDs are Shopware locale codes accepted by system:install.
var Steps = []Step{
{"system:install", "Installing Shopware"},
{"user:create", "Creating admin account"},
{"messenger:setup-transports", "Setting up message transports"},
{"sales-channel:create:storefront", "Creating storefront"},
{"theme:change", "Compiling theme"},
{"plugin:refresh", "Refreshing plugins"},
}
Steps are the recognized installation phases, in execution order.
Functions ¶
func FailedStep ¶
FailedStep names the last step that had started when the install failed. Failures before the first recognized step report the first step.
func IsInstalled ¶
IsInstalled reports whether the shop is already installed.
func LocaleIDs ¶
func LocaleIDs() []string
LocaleIDs returns the locale codes of Languages, for flag completion and validation errors.
func MatchStep ¶
MatchStep reports the index of the step a deployment-helper output line starts. Progress is monotonic: only steps at or after from match, so a pattern echoed later in the output cannot move progress backwards.
func PersistCredentials ¶
func PersistCredentials(cfg *shop.Config, envCfg *shop.EnvironmentConfig, projectRoot string, opts Options) error
PersistCredentials stores the admin credentials of a fresh installation in the project config so API commands work out of the box. ResolveEnvironment can return a copy that is not stored in cfg.Environments (the deprecated top-level url/admin_api form) — credentials set on that copy would be lost on write, so they are mirrored onto the top-level config in that case.
func Run ¶
Run installs Shopware by running the deployment helper with the INSTALL_* env vars. Combined stdout/stderr is emitted line by line via onLine.
func RunHeadless ¶
func RunHeadless(ctx context.Context, exec executor.Executor, cfg *shop.Config, envCfg *shop.EnvironmentConfig, projectRoot string, opts HeadlessOptions) error
RunHeadless installs Shopware without the TUI — for the `project dev install` command and environments without a terminal. An already-installed shop is reported and skipped, so the command is idempotent for scripts and CI.
func ValidateAdminPassword ¶
ValidateAdminPassword mirrors the Shopware core password length requirement.
func ValidateCurrency ¶
ValidateCurrency checks the currency against the Currencies allow-list.
func ValidateLocale ¶
ValidateLocale checks the locale against the Languages allow-list.
Types ¶
type HeadlessOptions ¶
type HeadlessOptions struct {
// Install parameterizes the installation; empty fields get the wizard
// defaults.
Install Options
// Out receives the progress output.
Out io.Writer
}
HeadlessOptions configure a non-interactive installation run.
type Options ¶
Options parameterize a Shopware installation.
func (*Options) ApplyDefaults ¶
func (o *Options) ApplyDefaults()
ApplyDefaults fills empty fields with the wizard defaults.
func (Options) CustomCredentials ¶
CustomCredentials reports whether the admin credentials differ from the defaults. Telemetry sends only this flag, never the credentials.