Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Play framework-related regex to codegen tool #956

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions codegen-sbt/src/sbt-test/codegen/test-compile/test
Original file line number Diff line number Diff line change
@@ -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 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 sh verify.sh ClientPlayFramework ./play23/com/caliban/client/ClientPlayFramework.scala

$ mkdir src/main/scala/genview
$ mkdir src/main/scala/genview/client

Expand Down
2 changes: 1 addition & 1 deletion tools/src/main/scala/caliban/tools/Codegen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down