Skip to content

Commit

Permalink
feat: support latest as version in project creation
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 22, 2025
1 parent d1f25e3 commit 4c31edc
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions cmd/project/project_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ var projectCreateCmd = &cobra.Command{
return fmt.Errorf("the folder %s exists already", projectFolder)
}

if err := os.Mkdir(projectFolder, os.ModePerm); err != nil {
return err
}

logging.FromContext(cmd.Context()).Infof("Using Symfony Flex to create a new Shopware 6 project")

filteredVersions, err := getFilteredInstallVersions(cmd.Context())
Expand All @@ -77,18 +73,25 @@ var projectCreateCmd = &cobra.Command{

chooseVersion := ""

for _, release := range filteredVersions {
if release.String() == result {
chooseVersion = release.String()
break
if result == "latest" {
chooseVersion = filteredVersions[0].String()
} else {
for _, release := range filteredVersions {
if release.String() == result {
chooseVersion = release.String()
break
}
}
}

if chooseVersion == "" {
_ = os.RemoveAll(projectFolder)
return fmt.Errorf("cannot find version %s", result)
}

if err := os.Mkdir(projectFolder, os.ModePerm); err != nil {
return err
}

logging.FromContext(cmd.Context()).Infof("Setting up Shopware %s", chooseVersion)

composerJson, err := generateComposerJson(chooseVersion, strings.Contains(chooseVersion, "rc"))
Expand Down Expand Up @@ -123,7 +126,6 @@ var projectCreateCmd = &cobra.Command{
logging.FromContext(cmd.Context()).Infof("Installing dependencies")

composerBinary, err := exec.LookPath("composer")

if err != nil {
return err
}
Expand Down Expand Up @@ -284,7 +286,6 @@ func generateComposerJson(version string, rc bool) (string, error) {
Version: version,
RC: rc,
})

if err != nil {
return "", err
}
Expand Down

0 comments on commit 4c31edc

Please sign in to comment.