install

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: 10 Imported by: 0

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

View Source
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.

View Source
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.

View Source
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

View Source
var Currencies = []string{"EUR", "USD", "GBP", "PLN", "CHF", "SEK", "DKK", "NOK", "CZK"}

Currencies are the ISO codes offered by the install wizard.

View Source
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.

View Source
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

func FailedStep(current int) string

FailedStep names the last step that had started when the install failed. Failures before the first recognized step report the first step.

func IsInstalled

func IsInstalled(ctx context.Context, exec executor.Executor) bool

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

func MatchStep(line string, from int) (int, bool)

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

func Run(ctx context.Context, exec executor.Executor, opts Options, onLine func(string)) error

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

func ValidateAdminPassword(password string) error

ValidateAdminPassword mirrors the Shopware core password length requirement.

func ValidateCurrency

func ValidateCurrency(currency string) error

ValidateCurrency checks the currency against the Currencies allow-list.

func ValidateLocale

func ValidateLocale(locale string) error

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 Language

type Language struct {
	ID    string
	Label string
}

Language is a storefront locale selectable during installation.

type Options

type Options struct {
	Locale        string
	Currency      string
	AdminUsername string
	AdminPassword string
}

Options parameterize a Shopware installation.

func (*Options) ApplyDefaults

func (o *Options) ApplyDefaults()

ApplyDefaults fills empty fields with the wizard defaults.

func (Options) CustomCredentials

func (o Options) CustomCredentials() bool

CustomCredentials reports whether the admin credentials differ from the defaults. Telemetry sends only this flag, never the credentials.

func (Options) Validate

func (o Options) Validate() error

Validate checks locale, currency and password against the same rules the TUI wizard enforces.

type Step

type Step struct {
	Pattern string
	Label   string
}

Step maps a deployment-helper console command to a user-facing label. The helper prints "Start: <command> ..." lines; matching them is the only progress signal the installation offers.

Jump to

Keyboard shortcuts

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