From 36a38271433e8c09406eb5850221fc0bb4c3e56d Mon Sep 17 00:00:00 2001 From: Yon-lu Goh Date: Thu, 8 Jul 2021 14:02:59 +0800 Subject: [PATCH 1/4] add regex for play and app to codegen --- tools/src/main/scala/caliban/tools/Codegen.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/main/scala/caliban/tools/Codegen.scala b/tools/src/main/scala/caliban/tools/Codegen.scala index 8b40d98b7..1834053ab 100644 --- a/tools/src/main/scala/caliban/tools/Codegen.scala +++ b/tools/src/main/scala/caliban/tools/Codegen.scala @@ -19,7 +19,7 @@ object Codegen { arguments: Options, genType: GenType ): Task[Unit] = { - val s = ".*/scala[^/]*/(.*)/(.*).scala".r.findFirstMatchIn(arguments.toPath) + val s = ".*/(scala|play.*|app)[^/]*/(.*)/(.*).scala".r.findFirstMatchIn(arguments.toPath) val packageName = arguments.packageName.orElse(s.map(_.group(1).split("/").mkString("."))) val objectName = s.map(_.group(2)).getOrElse("Client") val abstractEffectType = arguments.abstractEffectType.getOrElse(false) From c5b92efcd258c74a01ba5229b57e5d97307d0331 Mon Sep 17 00:00:00 2001 From: Yon-lu Goh Date: Thu, 8 Jul 2021 14:30:19 +0800 Subject: [PATCH 2/4] add compile tests --- codegen-sbt/src/sbt-test/codegen/test-compile/test | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/codegen-sbt/src/sbt-test/codegen/test-compile/test b/codegen-sbt/src/sbt-test/codegen/test-compile/test index d21bf694a..df346a112 100644 --- a/codegen-sbt/src/sbt-test/codegen/test-compile/test +++ b/codegen-sbt/src/sbt-test/codegen/test-compile/test @@ -1,11 +1,24 @@ $ absent src/main/scala/client/ClientNameUniqueness.scala $ absent src/main/scala/client/ClientGitLab.scala +$ absent app/com/caliban/client/ClientPlayFramework.scala +$ absent play23/com/caliban/client/ClientPlayFramework.scala + $ mkdir src/main/scala $ mkdir src/main/scala/client +$ mkdir app/com/caliban/client +$ mkdir play23/com/caliban/client > calibanGenClient project/schema-to-check-name-uniqueness.graphql src/main/scala/client/ClientNameUniqueness.scala --packageName client $ exists src/main/scala/client/ClientNameUniqueness.scala +> calibanGenClient project/schema-to-check-name-uniqueness.graphql app/com/caliban/client/ClientPlayFramework.scala --packageName client +$ exists app/com/caliban/client/ClientPlayFramework.scala +$ exec verify.sh ClientPlayFramework ./app/com/caliban/client/ClientPlayFramework.scala + +> calibanGenClient project/schema-to-check-name-uniqueness.graphql play23/com/caliban/client/ClientPlayFramework.scala --packageName client +$ exists play23/com/caliban/client/ClientPlayFramework.scala +$ exec verify.sh ClientPlayFramework ./play23/com/caliban/client/ClientPlayFramework.scala + $ mkdir src/main/scala/genview $ mkdir src/main/scala/genview/client From d6792d74456f94d14ac46d6b60e4a16344303c29 Mon Sep 17 00:00:00 2001 From: Yon-lu Goh Date: Thu, 8 Jul 2021 14:31:14 +0800 Subject: [PATCH 3/4] fix tests --- codegen-sbt/src/sbt-test/codegen/test-compile/test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codegen-sbt/src/sbt-test/codegen/test-compile/test b/codegen-sbt/src/sbt-test/codegen/test-compile/test index df346a112..ab7c44bcb 100644 --- a/codegen-sbt/src/sbt-test/codegen/test-compile/test +++ b/codegen-sbt/src/sbt-test/codegen/test-compile/test @@ -13,11 +13,11 @@ $ exists src/main/scala/client/ClientNameUniqueness.scala > calibanGenClient project/schema-to-check-name-uniqueness.graphql app/com/caliban/client/ClientPlayFramework.scala --packageName client $ exists app/com/caliban/client/ClientPlayFramework.scala -$ exec verify.sh ClientPlayFramework ./app/com/caliban/client/ClientPlayFramework.scala +$ exec sh verify.sh ClientPlayFramework ./app/com/caliban/client/ClientPlayFramework.scala > calibanGenClient project/schema-to-check-name-uniqueness.graphql play23/com/caliban/client/ClientPlayFramework.scala --packageName client $ exists play23/com/caliban/client/ClientPlayFramework.scala -$ exec verify.sh ClientPlayFramework ./play23/com/caliban/client/ClientPlayFramework.scala +$ exec sh verify.sh ClientPlayFramework ./play23/com/caliban/client/ClientPlayFramework.scala $ mkdir src/main/scala/genview $ mkdir src/main/scala/genview/client From fae7ae55bcc416219449d3f207a017930457aa05 Mon Sep 17 00:00:00 2001 From: Yon-lu Goh Date: Thu, 8 Jul 2021 17:12:05 +0800 Subject: [PATCH 4/4] fix regex --- tools/src/main/scala/caliban/tools/Codegen.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/main/scala/caliban/tools/Codegen.scala b/tools/src/main/scala/caliban/tools/Codegen.scala index 1834053ab..b05fb0609 100644 --- a/tools/src/main/scala/caliban/tools/Codegen.scala +++ b/tools/src/main/scala/caliban/tools/Codegen.scala @@ -19,7 +19,7 @@ object Codegen { arguments: Options, genType: GenType ): Task[Unit] = { - val s = ".*/(scala|play.*|app)[^/]*/(.*)/(.*).scala".r.findFirstMatchIn(arguments.toPath) + val s = ".*/[scala|play.*|app][^/]*/(.*)/(.*).scala".r.findFirstMatchIn(arguments.toPath) val packageName = arguments.packageName.orElse(s.map(_.group(1).split("/").mkString("."))) val objectName = s.map(_.group(2)).getOrElse("Client") val abstractEffectType = arguments.abstractEffectType.getOrElse(false)