Skip to content

Commit

Permalink
feat: reuse existing config when pulling store info, fixes #264
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Dec 10, 2023
1 parent 4f055ce commit 21499ce
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 36 deletions.
2 changes: 1 addition & 1 deletion cmd/account/account_company_use.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var accountCompanyUseCmd = &cobra.Command{
return fmt.Errorf("cannot invalidate token cache: %w", err)
}

logging.FromContext(cmd.Context()).Infof("Successfully changed your company to %s (%d)", membership.Company.Name, membership.Company.CustomerNumber)
logging.FromContext(cmd.Context()).Infof("Successfully changed your company to %s (%s)", membership.Company.Name, membership.Company.CustomerNumber)
return nil
}
}
Expand Down
62 changes: 41 additions & 21 deletions cmd/account/account_producer_extension_info_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,18 @@ var accountCompanyProducerExtensionInfoPullCmd = &cobra.Command{
})
}

germanDescription := ""
englishDescription := ""
germanInstallationManual := ""
englishInstallationManual := ""

for _, info := range storeExt.Infos {
language := info.Locale.Name[0:2]

if language == "de" {
germanDescription = info.Description
germanInstallationManual = info.InstallationManual

for _, element := range info.Tags {
tagsDE = append(tagsDE, element.Name)
}
Expand All @@ -130,13 +138,20 @@ var accountCompanyProducerExtensionInfoPullCmd = &cobra.Command{
videosDE = append(videosDE, element.URL)
}

highlightsDE = append(highlightsDE, strings.Split(info.Highlights, "\n")...)
featuresDE = append(featuresDE, strings.Split(info.Features, "\n")...)
if info.Highlights != "" {
highlightsDE = append(highlightsDE, strings.Split(info.Highlights, "\n")...)
}
if info.Features != "" {
featuresDE = append(featuresDE, strings.Split(info.Features, "\n")...)
}

for _, element := range info.Faqs {
faqDE = append(faqDE, extension.ConfigStoreFaq{Question: element.Question, Answer: element.Answer})
}
} else {
englishDescription = info.Description
englishInstallationManual = info.InstallationManual

for _, element := range info.Tags {
tagsEN = append(tagsEN, element.Name)
}
Expand All @@ -145,8 +160,13 @@ var accountCompanyProducerExtensionInfoPullCmd = &cobra.Command{
videosEN = append(videosEN, element.URL)
}

highlightsEN = append(highlightsEN, strings.Split(info.Highlights, "\n")...)
featuresEN = append(featuresEN, strings.Split(info.Features, "\n")...)
if info.Highlights != "" {
highlightsEN = append(highlightsEN, strings.Split(info.Highlights, "\n")...)
}

if info.Features != "" {
featuresEN = append(featuresEN, strings.Split(info.Features, "\n")...)
}

for _, element := range info.Faqs {
faqEN = append(faqEN, extension.ConfigStoreFaq{Question: element.Question, Answer: element.Answer})
Expand All @@ -160,23 +180,23 @@ var accountCompanyProducerExtensionInfoPullCmd = &cobra.Command{
extType = storeExt.ProductType.Name
}

newCfg := extension.Config{Store: extension.ConfigStore{
Icon: iconConfigPath,
DefaultLocale: &storeExt.StandardLocale.Name,
Type: &extType,
AutomaticBugfixVersionCompatibility: &storeExt.AutomaticBugfixVersionCompatibility,
Availabilities: &availabilities,
Localizations: &localizations,
Description: extension.ConfigTranslated[string]{German: &storeExt.Infos[0].Description, English: &storeExt.Infos[1].Description},
InstallationManual: extension.ConfigTranslated[string]{German: &storeExt.Infos[0].InstallationManual, English: &storeExt.Infos[1].InstallationManual},
Categories: &categoryList,
Tags: extension.ConfigTranslated[[]string]{German: &tagsDE, English: &tagsEN},
Videos: extension.ConfigTranslated[[]string]{German: &videosDE, English: &videosEN},
Highlights: extension.ConfigTranslated[[]string]{German: &highlightsDE, English: &highlightsEN},
Features: extension.ConfigTranslated[[]string]{German: &featuresDE, English: &featuresEN},
Faq: extension.ConfigTranslated[[]extension.ConfigStoreFaq]{German: &faqDE, English: &faqEN},
Images: &images,
}}
newCfg := zipExt.GetExtensionConfig()

newCfg.Store.Icon = iconConfigPath
newCfg.Store.DefaultLocale = &storeExt.StandardLocale.Name
newCfg.Store.Type = &extType
newCfg.Store.AutomaticBugfixVersionCompatibility = &storeExt.AutomaticBugfixVersionCompatibility
newCfg.Store.Availabilities = &availabilities
newCfg.Store.Localizations = &localizations
newCfg.Store.Description = extension.ConfigTranslated[string]{German: &germanDescription, English: &englishDescription}
newCfg.Store.InstallationManual = extension.ConfigTranslated[string]{German: &germanInstallationManual, English: &englishInstallationManual}
newCfg.Store.Categories = &categoryList
newCfg.Store.Tags = extension.ConfigTranslated[[]string]{German: &tagsDE, English: &tagsEN}
newCfg.Store.Videos = extension.ConfigTranslated[[]string]{German: &videosDE, English: &videosEN}
newCfg.Store.Highlights = extension.ConfigTranslated[[]string]{German: &highlightsDE, English: &highlightsEN}
newCfg.Store.Features = extension.ConfigTranslated[[]string]{German: &featuresDE, English: &featuresEN}
newCfg.Store.Faq = extension.ConfigTranslated[[]extension.ConfigStoreFaq]{German: &faqDE, English: &faqEN}
newCfg.Store.Images = &images

content, err := yaml.Marshal(newCfg)
if err != nil {
Expand Down
18 changes: 9 additions & 9 deletions extension/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ import (
)

type ConfigBuild struct {
ExtraBundles []ConfigExtraBundle `yaml:"extraBundles"`
ShopwareVersionConstraint string `yaml:"shopwareVersionConstraint"`
ExtraBundles []ConfigExtraBundle `yaml:"extraBundles,omitempty"`
ShopwareVersionConstraint string `yaml:"shopwareVersionConstraint,omitempty"`
Zip struct {
Composer struct {
Enabled bool `yaml:"enabled"`
BeforeHooks []string `yaml:"before_hooks"`
AfterHooks []string `yaml:"after_hooks"`
ExcludedPackages []string `yaml:"excluded_packages"`
BeforeHooks []string `yaml:"before_hooks,omitempty"`
AfterHooks []string `yaml:"after_hooks,omitempty"`
ExcludedPackages []string `yaml:"excluded_packages,omitempty"`
} `yaml:"composer"`
Assets struct {
Enabled bool `yaml:"enabled"`
BeforeHooks []string `yaml:"before_hooks"`
AfterHooks []string `yaml:"after_hooks"`
BeforeHooks []string `yaml:"before_hooks,omitempty"`
AfterHooks []string `yaml:"after_hooks,omitempty"`
EnableESBuildForAdmin bool `yaml:"enable_es_build_for_admin"`
EnableESBuildForStorefront bool `yaml:"enable_es_build_for_storefront"`
} `yaml:"assets"`
Pack struct {
Excludes struct {
Paths []string `yaml:"paths"`
Paths []string `yaml:"paths,omitempty"`
} `yaml:"excludes"`
BeforeHooks []string `yaml:"before_hooks"`
BeforeHooks []string `yaml:"before_hooks,omitempty"`
} `yaml:"pack"`
} `yaml:"zip"`
}
Expand Down
10 changes: 5 additions & 5 deletions internal/changelog/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ var defaultChangelogTpl string

type Config struct {
Enabled bool `yaml:"enabled"`
Pattern string `yaml:"pattern"`
Template string `yaml:"template"`
Variables map[string]string `yaml:"variables"`
AiEnabled bool `yaml:"ai_enabled"`
VCSURL string
Pattern string `yaml:"pattern,omitempty"`
Template string `yaml:"template,omitempty"`
Variables map[string]string `yaml:"variables,omitempty"`
AiEnabled bool `yaml:"ai_enabled,omitempty"`
VCSURL string `yaml:"-"`
}

type Commit struct {
Expand Down

0 comments on commit 21499ce

Please sign in to comment.