@@ -44,9 +44,24 @@ import (
4444)
4545
4646type CloudService struct {
47- Name string
48- Type string
49- Version string
47+ Name string
48+ Type string
49+ Endpoint string
50+ Version string
51+ }
52+
53+ // SetEndpoint validates and sets the endpoint based on the service type.
54+ // It handles special type mappings (e.g., redis-persistent -> redis, oracle-mysql -> mysql)
55+ // and defaults to using the type as the endpoint for standard services.
56+ func (s * CloudService )SetEndpoint () {
57+ switch s .Type {
58+ case "redis-persistent" :
59+ s .Endpoint = "redis"
60+ case "oracle-mysql" :
61+ s .Endpoint = "mysql"
62+ default :
63+ s .Endpoint = s .Type
64+ }
5065}
5166
5267var localNewCmd = & console.Command {
@@ -62,6 +77,7 @@ var localNewCmd = &console.Command{
6277},
6378& console.BoolFlag {Name :"full" ,Usage :"Use github.com/symfony/website-skeleton (deprecated, use --webapp instead)" },
6479& console.BoolFlag {Name :"demo" ,Usage :"Use github.com/symfony/demo" },
80+ & console.StringFlag {Name :"skeleton" ,Usage :"Skeleton to use (symfony, sulu, or a custom package name)" ,DefaultValue :"symfony" },
6581& console.BoolFlag {Name :"webapp" ,Usage :"Add the webapp pack to get a fully configured web project" },
6682& console.BoolFlag {Name :"api" ,Usage :"Add the api pack to get a fully configured api project" },
6783& console.BoolFlag {Name :"book" ,Usage :"Clone the Symfony: The Fast Track book project" },
@@ -136,6 +152,9 @@ var localNewCmd = &console.Command{
136152if symfonyVersion != "" && c .Bool ("demo" ) {
137153return console .Exit ("The --version flag is not supported for the Symfony Demo" ,1 )
138154}
155+ if c .Bool ("demo" )&& c .String ("skeleton" )!= "symfony" {
156+ return console .Exit ("The --demo flag cannot be used with --skeleton" ,1 )
157+ }
139158if c .Bool ("webapp" )&& c .Bool ("api" ) {
140159return console .Exit ("The --api flag cannot be used with --webapp" ,1 )
141160}
@@ -280,14 +299,22 @@ func parseCLIServices(services []string) ([]*CloudService, error) {
280299parts := strings .Split (config ,":" )
281300if len (parts )== 1 {
282301// service == name
283- service = & CloudService {Name :parts [0 ],Type :parts [0 ],Version :upsun .ServiceLastVersion (parts [1 ])}
302+ service = & CloudService {Name :parts [0 ],Type :parts [0 ],Version :upsun .ServiceLastVersion (parts [0 ])}
284303}else if len (parts )== 2 {
285304service = & CloudService {Name :parts [0 ],Type :parts [1 ],Version :upsun .ServiceLastVersion (parts [1 ])}
286305}else if len (parts )== 3 {
287306service = & CloudService {Name :parts [0 ],Type :parts [1 ],Version :parts [2 ]}
288307}else {
289308return nil ,errors .Errorf ("unable to parse service\" %s\" " ,config )
290309}
310+
311+ service .SetEndpoint ()
312+
313+ // For redis-persistent, update version based on the endpoint
314+ if service .Type == "redis-persistent" {
315+ service .Version = upsun .ServiceLastVersion (service .Endpoint )
316+ }
317+
291318cloudServices = append (cloudServices ,service )
292319}
293320return cloudServices ,nil
@@ -311,7 +338,15 @@ func parseDockerComposeServices(dir string) []*CloudService {
311338var s * CloudService
312339switch port .Target {
313340case 3306 :
314- s = & CloudService {Type :"mysql" }
341+ // Distinguish between MySQL and MariaDB based on image name
342+ dbType := "mysql"
343+ if strings .Contains (strings .ToLower (service .Image ),"mariadb" ) {
344+ dbType = "mariadb"
345+ }else if strings .Contains (strings .ToLower (service .Image ),"mysql" ) {
346+ dbType = "oracle-mysql"
347+ }
348+
349+ s = & CloudService {Type :dbType }
315350case 5432 :
316351s = & CloudService {Type :"postgresql" }
317352case 6379 :
@@ -331,6 +366,9 @@ func parseDockerComposeServices(dir string) []*CloudService {
331366if s != nil && ! done {
332367seen [service .Name ]= true
333368s .Name = service .Name
369+
370+ s .SetEndpoint ()
371+
334372parts := strings .Split (service .Image ,":" )
335373s .Version = regexp .MustCompile (`\d+(\.\d+)?` ).FindString (parts [len (parts )- 1 ])
336374serviceLastVersion := upsun .ServiceLastVersion (s .Type )
@@ -364,30 +402,60 @@ func initProjectGit(c *console.Context, dir string) error {
364402}
365403
366404func createProjectWithComposer (c * console.Context ,dir ,version string )error {
405+ // Determine the repository and project type
406+ repo := "symfony/skeleton"
407+ projectType := "Symfony"
408+
409+ if r := os .Getenv ("SYMFONY_REPO" );r != "" {
410+ repo = r
411+ }else if c .Bool ("full" ) {
412+ terminal .SymfonyStyle (terminal .Stdout ,terminal .Stdin ).Warning ("The --full flag is deprecated, use --webapp instead." )
413+ repo = "symfony/website-skeleton"
414+ }else if c .Bool ("demo" ) {
415+ repo = "symfony/symfony-demo"
416+ }else if c .String ("skeleton" )!= "" {
417+ // Handle skeleton flag
418+ skeleton := c .String ("skeleton" )
419+ switch skeleton {
420+ case "symfony" :
421+ repo = "symfony/skeleton"
422+ projectType = "Symfony"
423+ case "sulu" :
424+ repo = "sulu/skeleton"
425+ projectType = "Sulu"
426+ case "demo" :
427+ repo = "symfony/symfony-demo"
428+ projectType = "Symfony Demo"
429+ default :
430+ // Use custom Composer package directly
431+ repo = skeleton
432+
433+ // Use the package name as the project type
434+ parts := strings .Split (skeleton ,"/" )
435+ if len (parts )> 1 {
436+ projectType = parts [1 ]
437+ }else {
438+ projectType = skeleton
439+ }
440+ }
441+ }
442+
443+ // Display appropriate message based on project type
367444if c .Bool ("demo" ) {
368445terminal .Println ("* Creating a new Symfony Demo project with Composer" )
369446}else if version != "" {
370- if version == "lts" || version == "previous" || version == "stable" || version == "next" || version == "dev" {
447+ // Only handle special versions for Symfony projects
448+ if projectType == "Symfony" && (version == "lts" || version == "previous" || version == "stable" || version == "next" || version == "dev" ) {
371449var err error
372450version ,err = getSpecialVersion (version )
373451if err != nil {
374452return err
375453}
376454}
377455
378- terminal .Printfln ("* Creating a newSymfony %s project with Composer" ,version )
456+ terminal .Printfln ("* Creating a new%s %s project with Composer" , projectType ,version )
379457}else {
380- terminal .Println ("* Creating a new Symfony project with Composer" )
381- }
382-
383- repo := "symfony/skeleton"
384- if r := os .Getenv ("SYMFONY_REPO" );r != "" {
385- repo = r
386- }else if c .Bool ("full" ) {
387- terminal .SymfonyStyle (terminal .Stdout ,terminal .Stdin ).Warning ("The --full flag is deprecated, use --webapp instead." )
388- repo = "symfony/website-skeleton"
389- }else if c .Bool ("demo" ) {
390- repo = "symfony/symfony-demo"
458+ terminal .Printfln ("* Creating a new %s project with Composer" ,projectType )
391459}
392460
393461if ok ,_ := regexp .MatchString ("^\\ d+\\ .\\ d+$" ,version );ok {