File tree Expand file tree Collapse file tree 8 files changed +97
-0
lines changed
js/src/main/scala/com/github/vertical_blank/sqlformatter/scala
jvm/src/main/scala/com/github/vertical_blank/sqlformatter/scala
shared/src/it/scala/com/github/vertical_blank/sqlformatter/scala Expand file tree Collapse file tree 8 files changed +97
-0
lines changed Original file line number Diff line number Diff line change 1+ * .class
2+ * .log
3+
4+ # sbt specific
5+ .cache /
6+ .history /
7+ .lib /
8+ dist /*
9+ target /
10+ lib_managed /
11+ src_managed /
12+ project /boot /
13+ project /plugins /project /
14+
15+ # Scala-IDE specific
16+ .scala_dependencies
17+ .worksheet
18+ .idea
19+
20+ .DS_Store
21+ .bloop
22+ .metals
Original file line number Diff line number Diff line change 1+ import sbtcrossproject .CrossPlugin .autoImport .{crossProject , CrossType }
2+
3+ name := " scala-sql-formatter"
4+
5+ scalaVersion in ThisBuild := " 2.12.8"
6+
7+ lazy val root =
8+ crossProject(JSPlatform , JVMPlatform ).
9+ crossType(CrossType .Full ).in(file(" ." )).
10+ settings(
11+ name := " scala-sql-formatter" ,
12+ version := " 0.1-SNAPSHOT"
13+ ).
14+ jvmSettings(
15+ libraryDependencies += " com.github.vertical-blank" % " sql-formatter" % " 1.0"
16+ ).
17+ jsSettings(
18+ jsDependencies += " org.webjars.npm" % " sql-formatter" % " 2.3.3" / " 2.3.3/dist/sql-formatter.js" commonJSName " sqlFormatter" ,
19+ scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind .CommonJSModule ) },
20+ ).
21+ configs(IntegrationTest ).
22+ settings(Defaults .itSettings: _* ).
23+ settings(libraryDependencies += " org.scalatest" %%% " scalatest" % " 3.0.8" % IntegrationTest ).
24+ settings(
25+ unmanagedSourceDirectories in IntegrationTest ++=
26+ CrossType .Full .sharedSrcDir(baseDirectory.value, " it" ).toSeq
27+ ).
28+ jsSettings(inConfig(IntegrationTest )(ScalaJSPlugin .testConfigSettings): _* )
29+
Original file line number Diff line number Diff line change 1+ package com .github .vertical_blank .sqlformatter .scala
2+
3+ import scala .scalajs .js
4+ import scala .scalajs .js .annotation .JSImport
5+
6+ @ js.native
7+ @ JSImport (" sql-formatter" , JSImport .Namespace )
8+ object Facade extends js.Object {
9+ def format (obj : js.Any ): String = js.native
10+ }
11+
12+ object SqlFormatter {
13+ def format (sql : String ): String = Facade .format(sql)
14+ }
Original file line number Diff line number Diff line change 1+ package com .github .vertical_blank .sqlformatter .scala
2+
3+ object SqlFormatter {
4+ def format (sql : String ): String = com.github.vertical_blank.sqlformatter.SqlFormatter .format(sql)
5+ }
Original file line number Diff line number Diff line change 1+ sbt.version =1.2.1
Original file line number Diff line number Diff line change 1+ addSbtPlugin(" org.scala-js" % " sbt-scalajs" % " 0.6.29" )
2+ addSbtPlugin(" org.portable-scala" % " sbt-scalajs-crossproject" % " 0.6.1" )
Original file line number Diff line number Diff line change 1+
2+ # scala-sql-formatter
3+
4+ SQL Formatter for Scala.
5+
6+ - On jvm, calls [ https://github.com/vertical-blank/sql-formatter ] ( https://github.com/vertical-blank/sql-formatter )
7+ - On js, calls [ https://github.com/zeroturnaround/sql-formatter ] ( https://github.com/zeroturnaround/sql-formatter )
8+
Original file line number Diff line number Diff line change 1+ package com .github .vertical_blank .sqlformatter .scala
2+
3+ import org .scalatest .FunSuite
4+
5+ class Test extends FunSuite {
6+
7+ test(" Call SqlFormatter" ) {
8+ val formatted = """ |SELECT
9+ | *
10+ |FROM
11+ | table1""" .stripMargin
12+
13+ assert(SqlFormatter .format(" SELECT * FROM table1" ) == formatted)
14+ }
15+
16+ }
You can’t perform that action at this time.
0 commit comments