Skip to content

Commit

Permalink
0.6.0: Update frameworks and add Fomantic UI (Semantic UI fork)
Browse files Browse the repository at this point in the history
 * Add a script to quickly check all the latest versions
 * Refactor build to separate version strings from the rest
   to make updating easier
 * Handle a possible null safely
  • Loading branch information
nafg committed Jan 7, 2020
1 parent cca8a37 commit b871495
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
27 changes: 22 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ThisBuild / organization := "io.github.nafg.css-dsl"
ThisBuild / version := "0.5.0"
ThisBuild / version := "0.6.0"

ThisBuild / crossScalaVersions := Seq("2.12.10", "2.13.1")
ThisBuild / scalaVersion := (ThisBuild / crossScalaVersions).value.last
Expand All @@ -25,28 +25,40 @@ val bootstrap3Config =
CssDslConfig(
"bootstrap3",
Set(None, Some("bs"), Some("bs3")),
new URL("https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css")
"3.4.1",
"https://maxcdn.bootstrapcdn.com/bootstrap/" + _ + "/css/bootstrap.min.css"
)

val bootstrap4Config =
CssDslConfig(
"bootstrap4",
Set(None, Some("bs"), Some("bs4")),
new URL("https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css")
"4.4.1",
"https://maxcdn.bootstrapcdn.com/bootstrap/" + _ + "/css/bootstrap.min.css"
)

val bulmaConfig =
CssDslConfig(
"bulma",
Set(None, Some("b")),
new URL("https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.css")
"0.8.0",
"https://cdnjs.cloudflare.com/ajax/libs/bulma/" + _ + "/css/bulma.css"
)

val semanticUiConfig =
CssDslConfig(
"semanticui",
Set(Some("s")),
new URL("https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css")
"2.4.2",
"https://cdn.jsdelivr.net/npm/semantic-ui@" + _ + "/dist/semantic.min.css"
)

val fomanticUiConfig =
CssDslConfig(
"fomanticui",
Set(Some("f")),
"2.8.3",
"https://cdn.jsdelivr.net/npm/fomantic-ui@" + _ + "/dist/semantic.min.css"
)

lazy val bootstrap3_scalajsreact =
Expand All @@ -68,3 +80,8 @@ lazy val semanticui_scalajsreact =
project.enablePlugins(ScalaJSPlugin, GeneratorPlugin).settings(scalaJsReactSettings(semanticUiConfig))
lazy val semanticui_scalatags =
project.enablePlugins(GeneratorPlugin).settings(scalatagsSettings(semanticUiConfig))

lazy val fomanticui_scalajsreact =
project.enablePlugins(ScalaJSPlugin, GeneratorPlugin).settings(scalaJsReactSettings(fomanticUiConfig))
lazy val fomanticui_scalatags =
project.enablePlugins(GeneratorPlugin).settings(scalatagsSettings(fomanticUiConfig))
16 changes: 16 additions & 0 deletions latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

echo Latest bootstrap
npm view bootstrap dist-tags.latest

echo Previous bootstrap
npm view bootstrap dist-tags.previous

echo Latest Bulma
npm view bulma dist-tags.latest

echo Latest Semantic UI
npm view semantic-ui dist-tags.latest

echo Latest Fomantic UI
npm view fomantic-ui dist-tags.latest
8 changes: 6 additions & 2 deletions project/CssExtractor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ object CssExtractor {
case n: CSSSelectorMemberNot => getClassesFromSelectors(n.getAllSelectors)
case s: CSSSelectorSimpleMember if s.isClass => Iterator(unescape(s.getValue.stripPrefix(".")))
case a: CSSSelectorAttribute if a.getAttrName == "class" =>
val v = unquote(a.getAttrValue)
if (v.endsWith("-")) Iterator.empty else Iterator(v)
val attrValue = a.getAttrValue
if (attrValue == null) Iterator.empty
else {
val v = unquote(attrValue)
if (v.endsWith("-")) Iterator.empty else Iterator(v)
}
case _ => Iterator.empty
}

Expand Down
7 changes: 5 additions & 2 deletions project/GeneratorPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import sbt._

object GeneratorPlugin extends AutoPlugin {
object autoImport {
case class CssDslConfig(packageName: String, prefixes: Set[Option[String]], url: URL)
case class CssDslConfig(packageName: String,
prefixes: Set[Option[String]],
version: String,
versionedUrl: String => String)
val cssDslConfig = settingKey[CssDslConfig]("The settings for generating the CSS DSL")
val cssVariant = settingKey[TargetImpl]("The target")
val cssGen = taskKey[Seq[File]]("Generate the DSL")
Expand All @@ -18,7 +21,7 @@ object GeneratorPlugin extends AutoPlugin {
val cfg = cssDslConfig.value
val variant = cssVariant.value
val outputDir = (Compile / sourceManaged).value
val classes = CssExtractor.getClassesFromURL(cfg.url)
val classes = CssExtractor.getClassesFromURL(new URL(cfg.versionedUrl(cfg.version)))
for (prefix <- cfg.prefixes.toSeq) yield {
val name = prefix.getOrElse("").capitalize + "Dsl"
val generator = new Generator(cfg.packageName, name, prefix, classes, variant)
Expand Down

0 comments on commit b871495

Please sign in to comment.