| author | Tomas Zeman <tomas@functionals.cz> |
| Thu, 24 Oct 2019 08:52:17 +0200 | |
| changeset 30 | 8933b942e89f |
| parent 29 | bf5bf2dd51db |
| child 32 | 7cc486dc94cd |
| permissions | -rw-r--r-- |
| 20 | 1 |
import ammonite.ops._ |
2 |
import mill._ |
|
|
27
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
3 |
import mill.api.Loose |
| 20 | 4 |
import mill.define.{Input, Sources, Target}
|
5 |
import mill.scalajslib._ |
|
6 |
import mill.scalalib._ |
|
7 |
import mill.scalalib.publish._ |
|
|
27
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
8 |
import $ivy.`de.tototec::de.tobiasroeser.mill.publishM2:0.1.0` |
|
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
9 |
import de.tobiasroeser.mill.publishM2._ |
| 20 | 10 |
|
|
25
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
11 |
import scala.language.postfixOps |
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
12 |
|
| 20 | 13 |
object V {
|
|
30
8933b942e89f
fatags: 0.5-SNAPSHOT -> 0.5
Tomas Zeman <tomas@functionals.cz>
parents:
29
diff
changeset
|
14 |
val fatags = "0.5" |
|
29
bf5bf2dd51db
Scala version bump -> 2.12.10, scalajs -> 0.6.29
Tomas Zeman <tomas@functionals.cz>
parents:
28
diff
changeset
|
15 |
val scalaJs = "0.6.29" |
| 20 | 16 |
val scala211 = "2.11.12" |
|
29
bf5bf2dd51db
Scala version bump -> 2.12.10, scalajs -> 0.6.29
Tomas Zeman <tomas@functionals.cz>
parents:
28
diff
changeset
|
17 |
val scala212 = "2.12.10" |
| 20 | 18 |
} |
19 |
||
20 |
object D {
|
|
21 |
val scalatags = ivy"com.lihaoyi::scalatags::0.6.7" |
|
22 |
} |
|
23 |
||
|
25
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
24 |
def camelCase(s: String): String = {
|
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
25 |
def inner(l: List[Char]): List[Char] = l match {
|
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
26 |
case '-' :: '-' :: c :: rest => c.toUpper :: inner(rest) |
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
27 |
case '-' :: c :: rest => c.toUpper :: inner(rest) |
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
28 |
case c :: rest => c :: inner(rest) |
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
29 |
case Nil => Nil |
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
30 |
} |
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
31 |
inner(s toList) mkString "" |
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
32 |
} |
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
33 |
|
|
27
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
34 |
trait Common extends CrossSbtModule with PublishM2Module {
|
| 20 | 35 |
|
| 26 | 36 |
override def artifactName = "fatags" |
37 |
||
| 20 | 38 |
def publishVersion: Target[String] = V.fatags |
39 |
||
40 |
def pomSettings = PomSettings( |
|
41 |
description = "FontAwesome Scala DSL (tags)", |
|
42 |
organization = "net.tz", |
|
|
27
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
43 |
url = "https://hg.functionals.cz/fatags", |
| 20 | 44 |
licenses = Seq(License.`Apache-2.0`), |
45 |
versionControl = VersionControl(developerConnection = Some( |
|
|
27
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
46 |
"ssh://tzeman@hg.functionals.cz/repos/public/fatags")), |
| 20 | 47 |
developers = Seq( |
48 |
Developer("tzeman", "Tomas Zeman", "")
|
|
49 |
) |
|
50 |
) |
|
51 |
||
52 |
override def scalacOptions = T{Seq(
|
|
53 |
"-deprecation", // Emit warning and location for usages of deprecated APIs. |
|
54 |
"-encoding", "utf-8", // Specify character encoding used by source files. |
|
55 |
"-explaintypes", // Explain type errors in more detail. |
|
56 |
"-feature", // Emit warning and location for usages of features that should be imported explicitly. |
|
57 |
"-language:higherKinds", // Allow higher-kinded types |
|
58 |
"-language:implicitConversions", // Allow definition of implicit functions called views |
|
59 |
"-language:reflectiveCalls", |
|
60 |
"-language:postfixOps", |
|
61 |
"-unchecked", // Enable additional warnings where generated code depends on assumptions. |
|
62 |
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. |
|
63 |
"-Xfuture", // Turn on future language features. |
|
64 |
"-target:jvm-1.8", |
|
65 |
)} |
|
66 |
||
67 |
def hgId: Input[String] = T.input {
|
|
68 |
os.proc("hg", "id", "-i").call().out.string.trim
|
|
69 |
} |
|
70 |
||
71 |
def hgNum: Input[String] = T.input {
|
|
72 |
os.proc("hg", "id", "-n").call().out.string.trim
|
|
73 |
} |
|
74 |
||
75 |
def hgTag: Input[Option[String]] = T.input {
|
|
76 |
os.proc("hg", "id", "-t").call().out.string.trim.split(' ').headOption
|
|
77 |
} |
|
78 |
||
79 |
override def ivyDeps: Target[Loose.Agg[Dep]] = Agg(D.scalatags) |
|
80 |
||
81 |
override def sources: Sources = T.sources{
|
|
82 |
super.sources() :+ PathRef(millSourcePath / 'shared / 'src / 'main / 'scala) |
|
83 |
} |
|
84 |
||
|
28
5fe465ab9150
FontAwesome upgrade -> 5.11.2
Tomas Zeman <tomas@functionals.cz>
parents:
27
diff
changeset
|
85 |
// https://github.com/FortAwesome/Font-Awesome/raw/5.11.2/metadata/icons.json |
|
21
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
86 |
type IcoDef = (String, Set[String]) |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
87 |
def parseIcons: Target[List[IcoDef]] = T{
|
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
88 |
ujson.read(os.read! pwd / "icons.json").obj.map(e => (e._1, e._2.obj("styles").arr.map(_.str).toSet)).toList
|
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
89 |
} |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
90 |
|
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
91 |
private def tpl(d: IcoDef): String = {
|
|
25
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
92 |
val sym = d._1 |
|
21
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
93 |
d._2.map {
|
|
25
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
94 |
case "brands" => s""" val ${camelCase(s"fab-$sym")}: T = fab("$sym")\n"""
|
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
95 |
case "solid" => s""" val ${camelCase(s"fas-$sym")}: T = fas("$sym")\n"""
|
|
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
96 |
case "regular" => s""" val ${camelCase(s"far-$sym")}: T = far("$sym")\n"""
|
|
21
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
97 |
}.mkString |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
98 |
} |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
99 |
|
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
100 |
override def generatedSources: Sources = T.sources{
|
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
101 |
val d = T.ctx().dest |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
102 |
val icons = parseIcons() |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
103 |
write(d / "generated.scala", |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
104 |
s""" |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
105 |
| package fontawesome.generic |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
106 |
| import scalatags.generic._ |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
107 |
| class GenericFA[Builder, Output <: FragT, FragT]( |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
108 |
| val bun: Bundle[Builder, Output, FragT]) {
|
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
109 |
| |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
110 |
| import bun.all._ |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
111 |
| |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
112 |
| type T = FA[Builder, Output, FragT] |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
113 |
| |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
114 |
| val faStack: Modifier = cls := "fa-stack fa-lg" |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
115 |
| |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
116 |
| implicit val bundle: Bundle[Builder, Output, FragT] = bun |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
117 |
| implicit def fa2tag(x: T): TypedTag[Builder, Output, FragT] = x() |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
118 |
| |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
119 |
| private def fab(w: String): T = FA(FaStyle.Brands, w) |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
120 |
| private def far(w: String): T = FA(FaStyle.Regular, w) |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
121 |
| private def fas(w: String): T = FA(FaStyle.Solid, w) |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
122 |
| |
|
25
950431e16cb4
Restored CamelCase for icon idents/names
Tomas Zeman <tzeman@volny.cz>
parents:
24
diff
changeset
|
123 |
| ${icons map tpl mkString}
|
|
21
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
124 |
| |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
125 |
| } |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
126 |
""".stripMargin) |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
127 |
d |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
128 |
} |
| 20 | 129 |
} |
130 |
||
131 |
class JvmModule(val crossScalaVersion: String) extends Common |
|
132 |
class JsModule(val crossScalaVersion: String) extends ScalaJSModule |
|
133 |
with Common {
|
|
134 |
override def scalaJSVersion: Target[String] = V.scalaJs |
|
135 |
} |
|
136 |
||
137 |
object jvm extends Cross[JvmModule](V.scala211, V.scala212) |
|
138 |
object js extends Cross[JsModule](V.scala211, V.scala212) |
|
139 |
||
140 |
def publishLocal(): define.Command[Unit] = T.command{
|
|
141 |
jvm(V.scala212).publishLocal()() |
|
142 |
js(V.scala212).publishLocal()() |
|
143 |
jvm(V.scala211).publishLocal()() |
|
144 |
js(V.scala211).publishLocal()() |
|
145 |
} |
|
146 |
||
|
27
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
147 |
def publishM2Local(p: os.Path): define.Command[Unit] = T.command{
|
|
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
148 |
jvm(V.scala212).publishM2Local(p)() |
|
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
149 |
js(V.scala212).publishM2Local(p)() |
|
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
150 |
jvm(V.scala211).publishM2Local(p)() |
|
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
151 |
js(V.scala211).publishM2Local(p)() |
|
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
152 |
() |
|
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
153 |
} |
|
c4534300acdc
Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
26
diff
changeset
|
154 |
|
| 20 | 155 |
object example extends ScalaModule with ScalaJSModule {
|
156 |
override def scalaVersion: Target[String] = T{V.scala212}
|
|
157 |
override def scalaJSVersion: Target[String] = V.scalaJs |
|
|
21
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
158 |
|
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
159 |
|
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
160 |
/* Ugly hack to prevent |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
161 |
* "Referring to non-existent method fontawesome.generic.FA... error" |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
162 |
*/ |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
163 |
//override def moduleDeps: Seq[PublishModule] = Seq(js(V.scala212)) |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
164 |
override def ivyDeps: Target[Loose.Agg[Dep]] = Agg(D.scalatags) |
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
165 |
override def sources: Sources = T.sources{super.sources() ++ js(V.scala212).sources()}
|
|
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
166 |
override def generatedSources = T{js(V.scala212).generatedSources()}
|
| 20 | 167 |
} |
168 |
||
|
21
175e7d7ce5b3
Font-Awesome upgrade 4.7 -> 5.6.3
Tomas Zeman <tzeman@volny.cz>
parents:
20
diff
changeset
|
169 |
|
| 20 | 170 |
// vim: et ts=2 sw=2 syn=scala |