Skip to content

Commit

Permalink
Upgraded Scala.js to v1.5.1 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-podzigun committed Jul 15, 2022
1 parent da74c22 commit f78271a
Show file tree
Hide file tree
Showing 29 changed files with 54 additions and 82 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -2,7 +2,7 @@
[![CI](https://github.com/scommons/scommons-client/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/scommons/scommons-client/actions/workflows/ci.yml?query=workflow%3Aci+branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/scommons/scommons-client/badge.svg?branch=master)](https://coveralls.io/github/scommons/scommons-client?branch=master)
[![scala-index](https://index.scala-lang.org/scommons/scommons-client/scommons-client-ui/latest.svg)](https://index.scala-lang.org/scommons/scommons-client/scommons-client-ui)
[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.1.0.svg)](https://www.scala-js.org)
[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.5.0.svg)](https://www.scala-js.org)

## Scala Commons Client
Common Scala.js, React.js web-client utilities and components.
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Expand Up @@ -6,7 +6,7 @@ lazy val `scommons-client` = (project in file("."))
.settings(CommonModule.settings: _*)
.settings(ClientModule.settings: _*)
.settings(
skip in publish := true,
publish / skip := true,
publish := ((): Unit),
publishLocal := ((): Unit),
publishM2 := ((): Unit)
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
@@ -1 +1 @@
sbt.version = 1.2.8
sbt.version = 1.5.2
6 changes: 3 additions & 3 deletions project/plugins.sbt
@@ -1,13 +1,13 @@
//resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"

//addSbtPlugin(("org.scommons.sbt" % "sbt-scommons-plugin" % "0.8.0-SNAPSHOT").changing())
addSbtPlugin("org.scommons.sbt" % "sbt-scommons-plugin" % "0.8.0")
addSbtPlugin(("org.scommons.sbt" % "sbt-scommons-plugin" % "0.9.0-SNAPSHOT").changing())
//addSbtPlugin("org.scommons.sbt" % "sbt-scommons-plugin" % "0.8.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.4.3")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.7.3")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
8 changes: 4 additions & 4 deletions project/src/main/scala/common/Libs.scala
Expand Up @@ -6,10 +6,10 @@ import scommons.sbtplugin.project.CommonLibs

object Libs extends CommonLibs {

val scommonsNodejsVersion = "0.8.0"
val scommonsReactVersion = "0.8.0"
private val scommonsApiVersion = "0.8.0"
private val sjsReactJsVer = "0.17.1"
val scommonsNodejsVersion = "1.0.0-SNAPSHOT"
val scommonsReactVersion = "1.0.0-SNAPSHOT"
private val scommonsApiVersion = "1.0.0-SNAPSHOT"
private val sjsReactJsVer = "1.0.0-SNAPSHOT"

lazy val scommonsApiXhr = Def.setting("org.scommons.api" %%% "scommons-api-xhr" % scommonsApiVersion)

Expand Down
2 changes: 1 addition & 1 deletion project/src/main/scala/definitions/ClientModule.scala
Expand Up @@ -25,7 +25,7 @@ object ClientModule {
//
sonatypeProfileName := "org.scommons",
publishMavenStyle := true,
publishArtifact in Test := false,
Test / publishArtifact := false,
publishTo := sonatypePublishToBundle.value,
pomExtra := {
<url>https://github.com/scommons/scommons-client</url>
Expand Down
6 changes: 3 additions & 3 deletions project/src/main/scala/definitions/ClientShowcase.scala
Expand Up @@ -16,7 +16,7 @@ object ClientShowcase extends ScalaJsModule {

override def definition: Project = super.definition
.settings(
skip in publish := true,
publish / skip := true,
publish := ((): Unit),
publishLocal := ((): Unit),
publishM2 := ((): Unit),
Expand All @@ -28,9 +28,9 @@ object ClientShowcase extends ScalaJsModule {
webpackBundlingMode := BundlingMode.LibraryOnly(),

//dev
webpackConfigFile in fastOptJS := Some(baseDirectory.value / "client.webpack.config.js"),
fastOptJS / webpackConfigFile := Some(baseDirectory.value / "client.webpack.config.js"),
//production
webpackConfigFile in fullOptJS := Some(baseDirectory.value / "client.webpack.config.js")
fullOptJS / webpackConfigFile := Some(baseDirectory.value / "client.webpack.config.js")
)

override val internalDependencies: Seq[ClasspathDep[ProjectReference]] = Seq(
Expand Down
8 changes: 2 additions & 6 deletions project/src/main/scala/definitions/ClientUi.scala
Expand Up @@ -23,16 +23,12 @@ object ClientUi extends ScalaJsModule {
";scommons.client.ui.select.raw" +
";scommons.client.ui.HTML.InnerHTML",

npmDependencies in Compile ++= Seq(
Compile / npmDependencies ++= Seq(
"react-modal" -> "3.14.3",
"react-select" -> "3.2.0"
),

npmDevDependencies in Compile ++= Seq(
"babel-loader" -> "8.0.5",
"@babel/core" -> "7.4.0",
"@babel/preset-env" -> "7.4.2",

Compile / npmDevDependencies ++= Seq(
"css-loader" -> "2.1.1",
"mini-css-extract-plugin" -> "0.12.0",
"resolve-url-loader" -> "3.1.2",
Expand Down
25 changes: 1 addition & 24 deletions project/src/main/scala/definitions/ScalaJsModule.scala
@@ -1,14 +1,12 @@
package definitions

import org.scalajs.sbtplugin.ScalaJSPlugin
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
import sbt.Keys._
import sbt._
import scalajsbundler.sbtplugin.ScalaJSBundlerPlugin
import scalajsbundler.sbtplugin.ScalaJSBundlerPlugin.autoImport._
import scommons.sbtplugin.ScommonsPlugin.autoImport._
import scommons.sbtplugin.project.CommonClientModule
import scoverage.ScoverageKeys.{coverageEnabled, coverageScalacPluginVersion}

trait ScalaJsModule extends ClientModule {

Expand All @@ -18,28 +16,7 @@ trait ScalaJsModule extends ClientModule {
.settings(CommonClientModule.settings: _*)
.settings(
scommonsRequireWebpackInTest := true,
webpackConfigFile in Test := Some(baseDirectory.value / "test.webpack.config.js"),

//TODO: remove these temporal fixes for Scala.js 1.1+ and scoverage
coverageScalacPluginVersion := {
val current = coverageScalacPluginVersion.value
if (scalaJSVersion.startsWith("0.6")) current
else "1.4.2" //the only version that supports Scala.js 1.1+
},
libraryDependencies ~= { modules =>
if (scalaJSVersion.startsWith("0.6")) modules
else modules.filter(_.organization != "org.scoverage")
},
libraryDependencies ++= {
if (coverageEnabled.value) {
if (scalaJSVersion.startsWith("0.6")) Nil
else Seq(
"org.scoverage" %% "scalac-scoverage-runtime_sjs1" % coverageScalacPluginVersion.value,
"org.scoverage" %% "scalac-scoverage-plugin" % coverageScalacPluginVersion.value % "scoveragePlugin"
)
}
else Nil
}
Test / webpackConfigFile := Some(baseDirectory.value / "test.webpack.config.js")
)
}
}
3 changes: 1 addition & 2 deletions showcase/client.webpack.config.js
Expand Up @@ -2,9 +2,8 @@ const merge = require("webpack-merge")

const generatedConfig = require('./scalajs.webpack.config')
const commonClientConfig = require("./scommons.webpack.config.js")
const commonBabelConfig = require("./sc-babel.webpack.config.js")

module.exports = merge(generatedConfig, commonClientConfig, commonBabelConfig, {
module.exports = merge(generatedConfig, commonClientConfig, {

mode: 'production'
})
2 changes: 1 addition & 1 deletion ui/src/main/scala/scommons/client/ui/ImageButton.scala
@@ -1,7 +1,7 @@
package scommons.client.ui

import io.github.shogowada.scalajs.reactjs.events.MouseSyntheticEvent
import org.scalajs.dom.raw.HTMLButtonElement
import org.scalajs.dom.HTMLButtonElement
import scommons.react._
import scommons.react.dom._
import scommons.react.hooks._
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/scala/scommons/client/ui/ImageCheckBox.scala
@@ -1,7 +1,7 @@
package scommons.client.ui

import io.github.shogowada.scalajs.reactjs.events.FormSyntheticEvent
import org.scalajs.dom.raw.HTMLInputElement
import org.scalajs.dom.HTMLInputElement
import scommons.react._
import scommons.react.dom._
import scommons.react.hooks._
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/scala/scommons/client/ui/PasswordField.scala
@@ -1,8 +1,8 @@
package scommons.client.ui

import io.github.shogowada.scalajs.reactjs.events.{FormSyntheticEvent, KeyboardSyntheticEvent}
import org.scalajs.dom.HTMLInputElement
import org.scalajs.dom.ext.KeyCode
import org.scalajs.dom.raw.HTMLInputElement
import scommons.react._
import scommons.react.dom._
import scommons.react.hooks._
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/scala/scommons/client/ui/SimpleButton.scala
@@ -1,7 +1,7 @@
package scommons.client.ui

import io.github.shogowada.scalajs.reactjs.events.MouseSyntheticEvent
import org.scalajs.dom.raw.HTMLButtonElement
import org.scalajs.dom.HTMLButtonElement
import scommons.react._
import scommons.react.dom._
import scommons.react.hooks._
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/scala/scommons/client/ui/TextField.scala
@@ -1,8 +1,8 @@
package scommons.client.ui

import io.github.shogowada.scalajs.reactjs.events.{FormSyntheticEvent, KeyboardSyntheticEvent}
import org.scalajs.dom.HTMLInputElement
import org.scalajs.dom.ext.KeyCode
import org.scalajs.dom.raw.HTMLInputElement
import scommons.react._
import scommons.react.dom._
import scommons.react.hooks._
Expand Down
@@ -1,8 +1,7 @@
package scommons.client.ui.popup

import org.scalajs.dom
import org.scalajs.dom.Event
import org.scalajs.dom.raw.HTMLElement
import org.scalajs.dom.{Event, HTMLElement}
import scommons.react._

import scala.scalajs.js
Expand Down
10 changes: 5 additions & 5 deletions ui/src/test/scala/scommons/client/app/AppBrowsePanelSpec.scala
Expand Up @@ -26,10 +26,10 @@ class AppBrowsePanelSpec extends TestSpec with TestRendererUtils {
val result = testRender(component)

//then
assertNativeComponent(result, <.div(^.className := "row-fluid")(), { case List(span4, span8) =>
assertNativeComponent(span4, <.div(^.className := "span4")(), { case List(sidebar) =>
assertNativeComponent(sidebar, <.div(^.className := "well sidebar-nav")(), { case List(sidebarBp, tree) =>
assertNativeComponent(sidebarBp, <.div(^.className := AppBrowsePanelCss.sidebarBp)(), { case List(bp) =>
assertNativeComponent(result, <.div(^.className := "row-fluid")(), inside(_) { case List(span4, span8) =>
assertNativeComponent(span4, <.div(^.className := "span4")(), inside(_) { case List(sidebar) =>
assertNativeComponent(sidebar, <.div(^.className := "well sidebar-nav")(), inside(_) { case List(sidebarBp, tree) =>
assertNativeComponent(sidebarBp, <.div(^.className := AppBrowsePanelCss.sidebarBp)(), inside(_) { case List(bp) =>
assertTestComponent(bp, ButtonsPanel) { bpProps =>
bpProps shouldBe buttonsPanelProps
}
Expand All @@ -39,7 +39,7 @@ class AppBrowsePanelSpec extends TestSpec with TestRendererUtils {
}
})
})
assertNativeComponent(span8, <.div(^.className := "span8")(), { case List(children) =>
assertNativeComponent(span8, <.div(^.className := "span8")(), inside(_) { case List(children) =>
assertNativeComponent(children, <.div()("Some child element"))
})
})
Expand Down
Expand Up @@ -92,7 +92,7 @@ class ButtonsPanelSpec extends TestSpec with TestRendererUtils {
b1: SimpleButtonData,
b2: ImageButtonData): Unit = {

assertNativeComponent(result, <.div(^.className := className)(), { case List(simpleBtn, imageBtn) =>
assertNativeComponent(result, <.div(^.className := className)(), inside(_) { case List(simpleBtn, imageBtn) =>
assertTestComponent(simpleBtn, SimpleButton) {
case SimpleButtonProps(data, _, disabled, requestFocus) =>
data shouldBe b1
Expand Down
Expand Up @@ -213,15 +213,15 @@ class PickButtonsSpec extends TestSpec with TestRendererUtils {
val btnHoriz = Map("height" -> "30px", "writingMode" -> "tb-rl")
val btnGroupHoriz = Map("margin" -> "10px 0")

assertNativeComponent(result, <.div(props.className.map(cn => ^.className := cn))(), { case List(vert, horiz) =>
assertNativeComponent(vert, <.div(^.className := "btn-group btn-group-vertical hidden-phone")(), {
assertNativeComponent(result, <.div(props.className.map(cn => ^.className := cn))(), inside(_) { case List(vert, horiz) =>
assertNativeComponent(vert, <.div(^.className := "btn-group btn-group-vertical hidden-phone")(), inside(_) {
case List(add, remove, addAll, removeAll) =>
assertNativeComponent(add, btn(btnVert, "Add", ">", props.addEnabled))
assertNativeComponent(remove, btn(btnVert, "Remove", "<", props.removeEnabled))
assertNativeComponent(addAll, btn(btnVert, "Add All", ">>", props.addAllEnabled))
assertNativeComponent(removeAll, btn(btnVert, "Remove All", "<<", props.removeAllEnabled))
})
assertNativeComponent(horiz, <.div(^.className := "btn-group visible-phone", ^.style := btnGroupHoriz)(), {
assertNativeComponent(horiz, <.div(^.className := "btn-group visible-phone", ^.style := btnGroupHoriz)(), inside(_) {
case List(add, remove, addAll, removeAll) =>
assertNativeComponent(add, btn(btnHoriz, "Add", ">", props.addEnabled))
assertNativeComponent(remove, btn(btnHoriz, "Remove", "<", props.removeEnabled))
Expand Down
Expand Up @@ -226,7 +226,7 @@ class PaginationPanelSpec extends TestSpec with TestRendererUtils {
Some(pageBtn(s"$page", page, disableable = false))
}

assertNativeComponent(result, <.div(^.className := props.alignment.style)(), { case List(ul) =>
assertNativeComponent(result, <.div(^.className := props.alignment.style)(), inside(_) { case List(ul) =>
assertNativeComponent(ul, <.ul()(
pageBtn("<<", minPage, disableable = true),
if (minPage < selectedRange.start) {
Expand Down
Expand Up @@ -14,7 +14,7 @@ class ModalBodySpec extends TestSpec with TestRendererUtils {
val result = testRender(component)

//then
assertNativeComponent(result, <.div(^.className := "modal-body")(), { case List(child) =>
assertNativeComponent(result, <.div(^.className := "modal-body")(), inside(_) { case List(child) =>
assertNativeComponent(child, <.p()("some children"))
})
}
Expand Down
Expand Up @@ -9,7 +9,9 @@ class ModalHeaderSpec extends TestSpec with TestRendererUtils {
val onClose = mockFunction[Unit]
val props = ModalHeaderProps("Test Header", onClose = onClose)
val comp = testRender(<(ModalHeader())(^.wrapped := props)())
val List(button) = findComponents(comp, <.button.name)
val button = inside(findComponents(comp, <.button.name)) {
case List(b) => b
}

//then
onClose.expects()
Expand All @@ -27,7 +29,7 @@ class ModalHeaderSpec extends TestSpec with TestRendererUtils {
val result = testRender(component)

//then
assertNativeComponent(result, <.div(^.className := "modal-header")(), { case List(closeButton, h3) =>
assertNativeComponent(result, <.div(^.className := "modal-header")(), inside(_) { case List(closeButton, h3) =>
assertNativeComponent(closeButton, <.button(
^.`type` := "button",
^.className := "close"
Expand All @@ -45,7 +47,7 @@ class ModalHeaderSpec extends TestSpec with TestRendererUtils {
val result = testRender(component)

//then
assertNativeComponent(result, <.div(^.className := "modal-header")(), { case List(h3) =>
assertNativeComponent(result, <.div(^.className := "modal-header")(), inside(_) { case List(h3) =>
assertNativeComponent(h3, <.h3()(props.header))
})
}
Expand Down
@@ -1,7 +1,6 @@
package scommons.client.ui.popup

import org.scalajs.dom.raw.HTMLElement
import org.scalajs.dom.{Event, MouseEvent}
import org.scalajs.dom.{Event, HTMLElement, MouseEvent}
import scommons.react.test._

import scala.scalajs.js
Expand Down
Expand Up @@ -167,7 +167,7 @@ class TabPanelSpec extends TestSpec with TestRendererUtils {
assertNativeComponent(content, <.div(^.className := "tab-content")(expectedItems))
}

assertNativeComponent(result, <.div(^.className := props.direction.style)(), { case List(tabs, content) =>
assertNativeComponent(result, <.div(^.className := props.direction.style)(), inside(_) { case List(tabs, content) =>
if (props.direction == TabDirection.Bottom) assertTabsAndContent(content, tabs)
else assertTabsAndContent(tabs, content)
})
Expand Down
Expand Up @@ -114,8 +114,8 @@ class TablePanelSpec extends TestSpec with TestRendererUtils {
assertNativeComponent(result, <.table(
^.className := "table table-condensed",
^("cellSpacing") := "0"
)(), { case List(thead, tbody) =>
assertNativeComponent(thead, <.thead(^("aria-hidden") := "false")(), { case List(tr) =>
)(), inside(_) { case List(thead, tbody) =>
assertNativeComponent(thead, <.thead(^("aria-hidden") := "false")(), inside(_) { case List(tr) =>
assertNativeComponent(tr, <.tr()(), { headerRow =>
headerRow.size shouldBe expectedHeader.size
headerRow.zip(expectedHeader).foreach { case (headerCell, expectedElem) =>
Expand Down
Expand Up @@ -245,16 +245,16 @@ class BrowseTreeSpec extends TestSpec with TestRendererUtils {
val result = testRender(component)

//then
assertNativeComponent(result, <.div(^.className := TreeCss.tree)(), { case List(topItemE, topNodeE) =>
assertNativeComponent(result, <.div(^.className := TreeCss.tree)(), inside(_) { case List(topItemE, topNodeE) =>
assertTestComponent(topItemE, treeNodeComp) { topItemProps =>
assertTreeNode(topItemProps, props, topItem)
}
assertTestComponent(topNodeE, treeNodeComp)({ topNodeProps =>
assertTreeNode(topNodeProps, props, topNode)
}, { case List(childNodeE) =>
}, inside(_) { case List(childNodeE) =>
assertTestComponent(childNodeE, treeNodeComp)({ childNodeProps =>
assertTreeNode(childNodeProps, props, childNode, level = 1)
}, { case List(childItemE) =>
}, inside(_) { case List(childItemE) =>
assertTestComponent(childItemE, treeNodeComp) { childItemProps =>
assertTreeNode(childItemProps, props, childItem, level = 2)
}
Expand All @@ -276,7 +276,7 @@ class BrowseTreeSpec extends TestSpec with TestRendererUtils {
val result = testRender(component)

//then
assertNativeComponent(result, <.div(^.className := TreeCss.tree)(), { case List(topItemE, topNodeE) =>
assertNativeComponent(result, <.div(^.className := TreeCss.tree)(), inside(_) { case List(topItemE, topNodeE) =>
assertTestComponent(topItemE, treeNodeComp) { topItemProps =>
assertTreeNode(topItemProps, props, topItem)
}
Expand Down

0 comments on commit f78271a

Please sign in to comment.