Skip to content

Commit

Permalink
0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Aug 22, 2018
1 parent f3fe134 commit dfe179d
Show file tree
Hide file tree
Showing 26 changed files with 111 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ matrix:
jdk: oraclejdk8

script:
- curl -L -o ~/bin/mill https://github.com/lihaoyi/mill/releases/download/0.2.6/0.2.6-11-1287d7 && chmod +x ~/bin/mill
- curl -L -o ~/bin/mill https://github.com/lihaoyi/mill/releases/download/0.2.6/0.2.6-19-807e47 && chmod +x ~/bin/mill
- export PATH=~/bin/mill:$PATH
- "$CI_SCRIPT"

Expand Down
7 changes: 5 additions & 2 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import $file.example.staticFiles.build
import $file.example.todo.build
import $file.example.todoApi.build
import $file.example.todoDb.build
import $file.example.twirl.build
import $file.example.variableRoutes.build
import $file.example.websockets.build

Expand Down Expand Up @@ -50,7 +51,7 @@ object cask extends ScalaModule with PublishModule {
def testFrameworks = Seq("utest.runner.Framework")
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
ivy"org.xerial:sqlite-jdbc:3.18.0",
ivy"io.getquill::quill-jdbc:2.5.4"
)
Expand Down Expand Up @@ -80,6 +81,7 @@ object example extends Module{
object todo extends $file.example.todo.build.AppModule with LocalModule
object todoApi extends $file.example.todoApi.build.AppModule with LocalModule
object todoDb extends $file.example.todoDb.build.AppModule with LocalModule
object twirl extends $file.example.twirl.build.AppModule with LocalModule
object variableRoutes extends $file.example.variableRoutes.build.AppModule with LocalModule
object websockets extends $file.example.websockets.build.AppModule with LocalModule
}
Expand Down Expand Up @@ -122,6 +124,7 @@ def uploadToGithub(authKey: String) = T.command{
$file.example.todo.build.millSourcePath,
$file.example.todoApi.build.millSourcePath,
$file.example.todoDb.build.millSourcePath,
$file.example.twirl.build.millSourcePath,
$file.example.variableRoutes.build.millSourcePath,
$file.example.websockets.build.millSourcePath,
)
Expand All @@ -136,7 +139,7 @@ def uploadToGithub(authKey: String) = T.command{
|if [ ! -f out/mill-cask ]; then
| echo "Initializing Cask/Mill build tool for the first time"
| mkdir -p out &&
| (echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/mill/releases/download/0.2.6/0.2.6-13-b9b133) > out/mill-cask
| (echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/mill/releases/download/0.2.6/0.2.6-19-807e47) > out/mill-cask
|fi
|
|chmod +x out/mill-cask
Expand Down
21 changes: 18 additions & 3 deletions docs/pages/1 - Cask: a Scala HTTP micro-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ via the following coordinates:
```scala
// Mill
ivy"com.lihaoyi::cask:0.1.1"
ivy"com.lihaoyi::cask:0.1.3"
// SBT
"com.lihaoyi" %% "cask" % "0.1.1"
"com.lihaoyi" %% "cask" % "0.1.3"
```
The `./cask` command is just a wrapper around the
Expand Down Expand Up @@ -222,7 +222,22 @@ adding the relevant `ivy"com.lihaoyi::scalatags:0.6.7"` dependency to your
$$$scalatags
If you prefer to use the
[Twirl](https://www.playframework.com/documentation/2.6.x/ScalaTemplates)
templating engine, you can use that too:
$$$twirl
With the following `app/views/hello.scala.html`:
```html
@(titleTxt: String)
<html>
<body>
<h1>@titleTxt</h1>
<p>I am cow</p>
</body>
</html>
```
## Extending Endpoints with Decorators
Expand Down
2 changes: 1 addition & 1 deletion example/compress/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/compress2/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/compress3/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/cookies/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/decorated/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/decorated2/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/endpoints/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/formJsonPost/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/httpMethods/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/minimalApplication/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/minimalApplication2/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/redirectAbort/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/scalatags/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/staticFiles/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)

def forkWorkingDir = build.millSourcePath
Expand Down
2 changes: 1 addition & 1 deletion example/todo/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/todoApi/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/todoDb/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
9 changes: 9 additions & 0 deletions example/twirl/app/src/Twirl.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package app
object Twirl extends cask.MainRoutes{
@cask.get("/")
def hello() = {
"<!doctype html>" + html.hello("Hello World")
}

initialize()
}
29 changes: 29 additions & 0 deletions example/twirl/app/test/src/ExampleTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package app
import io.undertow.Undertow

import utest._

object ExampleTests extends TestSuite{
def test[T](example: cask.main.BaseMain)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
.build
server.start()
val res =
try f("http://localhost:8080")
finally server.stop()
res
}

val tests = Tests {
'Twirl - test(Twirl) { host =>
val body = requests.get(host).text()

assert(
body.contains("<h1>Hello World</h1>"),
body.contains("<p>I am cow</p>"),
)
}
}
}
7 changes: 7 additions & 0 deletions example/twirl/app/views/hello.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@(titleTxt: String)
<html>
<body>
<h1>@titleTxt</h1>
<p>I am cow</p>
</body>
</html>
23 changes: 23 additions & 0 deletions example/twirl/build.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import mill._, scalalib._
import $ivy.`com.lihaoyi::mill-contrib-twirllib:0.2.6-18-b29c13`

trait AppModule extends ScalaModule with mill.twirllib.TwirlModule{
def scalaVersion = "2.12.6"
def twirlVersion = "1.3.15"

def generatedSources = T{ Seq(compileTwirl().classes) }
def ivyDeps = Agg(
ivy"com.lihaoyi::cask:0.1.1",
ivy"com.lihaoyi::scalatags:0.6.7",
ivy"com.typesafe.play::twirl-api:${twirlVersion()}",
)

object test extends Tests{
def testFrameworks = Seq("utest.runner.Framework")

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/variableRoutes/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
)
}
}
2 changes: 1 addition & 1 deletion example/websockets/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
ivy"com.lihaoyi::requests::0.1.2",
ivy"com.lihaoyi::requests::0.1.3",
ivy"org.asynchttpclient:async-http-client:2.5.2"
)
}
Expand Down

0 comments on commit dfe179d

Please sign in to comment.