<commit_before>import com.lihaoyi.workbench.Plugin._
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
import sbt.Keys._
import sbt._
import spray.revolver.RevolverPlugin._

object ApplicationBuild extends Build {
  // root project aggregating the JS and JVM projects
  lazy val root = project.in(file(".")).
    aggregate(js, jvm).
    settings(
      publish := {},
      publishLocal := {}
    )

  val sharedSrcDir = "shared"

  // a special crossProject for configuring a JS/JVM/shared structure
  lazy val sharedProject = crossProject.in(file(".")).
    settings(
      name         := "scalajs-spa",
      version      := "0.1.3",
      scalaVersion := "2.11.5",
      scalacOptions ++= Seq(
        "-Xlint",
        "-unchecked",
        "-deprecation",
        "-feature"
      ),
    
      libraryDependencies ++= Seq(
        // these dependencies are shared between JS and JVM projects
        // the special %%% function selects the correct version for each project
        "com.lihaoyi"   %%% "autowire"  % "0.2.4",
        "com.lihaoyi"   %%% "upickle"   % "0.2.6"
      )
    ).
    
    // set up settings specific to the JVM project
    jvmSettings(Revolver.settings: _*).
    jvmSettings(
      libraryDependencies ++= Seq(
        // dependencies only used by the JVM project
        "io.spray"          %% "spray-can"      % "1.3.2",
        "io.spray"          %% "spray-routing"  % "1.3.2",
        "com.typesafe.akka" %% "akka-actor"     % "2.3.6"
      ),
      // copy resources from the "shared" project
      unmanagedResourceDirectories in Compile += file(".") / sharedSrcDir / "src" / "main" / "resources",
      unmanagedResourceDirectories in Test    += file(".") / sharedSrcDir / "src" / "test" / "resources",
      
      // set some basic options when running the project with Revolver
      javaOptions in Revolver.reStart ++= Seq("-Xmx1G"),
      
      // configure a specific port for debugging, so you can easily debug multiple projects at the same time if necessary
      Revolver.enableDebugging(port = 5111, suspend = false)
    ).
    // set up settings specific to the JS project
    jsSettings(workbenchSettings: _*).
    jsSettings(
      libraryDependencies ++= Seq(
        // dependencies only used by the JS project (note the use of %%% instead of %%)
        "org.scala-js"                      %%% "scalajs-dom" % "0.8.0",
        "com.github.japgolly.scalajs-react" %%% "core"        % "0.8.0",
        "com.github.japgolly.scalajs-react" %%% "extra"       % "0.8.0",
        "com.lihaoyi"                       %%% "scalarx"     % "0.2.7",
        "com.lihaoyi"                       %%% "utest"       % "0.3.0"
      ),
      // copy resources from the "shared" project
      unmanagedResourceDirectories in Compile += file(".") / sharedSrcDir / "src" / "main" / "resources",
      unmanagedResourceDirectories in Test    += file(".") / sharedSrcDir / "src" / "test" / "resources",
      
      // use uTest framework for tests
      testFrameworks += new TestFramework("utest.runner.Framework"),
      
      // define where the JS-only application will be hosted by the Workbench plugin
      localUrl        :=("localhost", 13131),
      refreshBrowsers <<= refreshBrowsers.triggeredBy(fastOptJS in Compile),
      bootSnippet     := "SPAMain().main();"
    )

  // configure a specific directory for scalajs output
  val scalajsOutputDir = Def.settingKey[File]("directory for javascript files output by scalajs")

  // make all JS builds use the output dir defined later
  lazy val js2jvmSettings = Seq(packageScalaJSLauncher, fastOptJS, fullOptJS) map { packageJSKey =>
    crossTarget in(js, Compile, packageJSKey) := scalajsOutputDir.value
  }

  // instantiate the JS project for SBT with some additional settings
  lazy val js: Project = sharedProject.js.settings(
    fastOptJS in Compile := {
      // make a copy of the produced JS-file (and source maps) under the js project as well,
      // because the original goes under the jvm project
      // NOTE: this is only done for fastOptJS, not for fullOptJS<commit_msg>Refactor settings into their own object to make it easier to see what needs to be changed for a new project.<commit_after>import com.lihaoyi.workbench.Plugin._
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
import sbt.Keys._
import sbt._
import spray.revolver.RevolverPlugin._

/**
 * Application settings. Configure the build for your application here.
 * You normally don't have to touch the actual build definition after this.
 */
object Settings {
  /** The name of your application */
  val name = "scalajs-spa"
  
  /** The version of your application */
  val version = "0.1.3"

  /** Options for the scala compiler */
  val scalacOptions = Seq(
    "-Xlint",
    "-unchecked",
    "-deprecation",
    "-feature"
  )

  /** Set some basic options when running the project with Revolver */
  val jvmRuntimeOptions = Seq(
    "-Xmx1G"
  )

  /** Declare global dependency versions here to avoid mismatches in multi part dependencies */
  object versions {
    val scala        = "2.11.5"
    val scalajsReact = "0.8.0"
  }

  /**
   * These dependencies are shared between JS and JVM projects
   * the special %%% function selects the correct version for each project
   */
  val sharedDependencies = Def.setting(Seq(
    "com.lihaoyi"   %%% "autowire"  % "0.2.4",
    "com.lihaoyi"   %%% "upickle"   % "0.2.6"
  ))

  /** Dependencies only used by the JVM project */
  val jvmDependencies = Def.setting(Seq(
    "io.spray"          %% "spray-can"      % "1.3.2",
    "io.spray"          %% "spray-routing"  % "1.3.2",
    "com.typesafe.akka" %% "akka-actor"     % "2.3.6"
  ))

  /** Dependencies only used by the JS project (note the use of %%% instead of %%) */
  val scalajsDependencies = Def.setting(Seq(
    "com.github.japgolly.scalajs-react" %%% "core"        % versions.scalajsReact,
    "com.github.japgolly.scalajs-react" %%% "extra"       % versions.scalajsReact,
    "com.lihaoyi"                       %%% "scalarx"     % "0.2.7",
    "com.lihaoyi"                       %%% "utest"       % "0.3.0"
  ))
}

object ApplicationBuild extends Build {
  // root project aggregating the JS and JVM projects
  lazy val root = project.in(file(".")).
    aggregate(js, jvm).
    settings(
      publish := {},
      publishLocal := {}
    )

  val sharedSrcDir = "shared"

  // a special crossProject for configuring a JS/JVM/shared structure
  lazy val sharedProject = crossProject.in(file("."))
    .settings(
      name                  :=  Settings.name,
      version               :=  Settings.version,
      scalaVersion          :=  Settings.versions.scala,
      scalacOptions         ++= Settings.scalacOptions,
      libraryDependencies   ++= Settings.sharedDependencies.value
    )
    
    // set up settings specific to the JVM project
    .jvmSettings(Revolver.settings: _*)
    .jvmSettings(
      libraryDependencies ++= Settings.jvmDependencies.value,
      
      // copy resources from the "shared" project
      unmanagedResourceDirectories in Compile += file(".") / sharedSrcDir / "src" / "main" / "resources",
      unmanagedResourceDirectories in Test    += file(".") / sharedSrcDir / "src" / "test" / "resources",
      
      javaOptions in Revolver.reStart ++= Settings.jvmRuntimeOptions,
      
      // configure a specific port for debugging, so you can easily debug multiple projects at the same time if necessary
      Revolver.enableDebugging(port = 5111, suspend = false)
    )
    
    // set up settings specific to the JS project
    .jsSettings(workbenchSettings: _*)
    .jsSettings(
      libraryDependencies ++= Settings.scalajsDependencies.value,
      
      // copy resources from the "shared" project
      unmanagedResourceDirectories in Compile += file(".") / sharedSrcDir / "src" / "main" / "resources",
      unmanagedResourceDirectories in Test    += file(".") / sharedSrcDir / "src" / "test" / "resources",
      
      // use uTest framework for tests
      testFrameworks += new TestFramework("utest.runner.Framework"),
      
      // define where the JS-only application will be hosted by the Workbench plugin
      localUrl         := ("localhost", 13131),
      refreshBrowsers <<= refreshBrowsers.triggeredBy(fastOptJS in Compile),
      bootSnippet      := "SPAMain().main();"
    )

  // configure a specific directory for scalajs output
  val scalajsOutputDir = Def.settingKey[File]("directory for javascript files output by scalajs")

  // make all JS builds use the output dir defined later
  lazy val js2jvmSettings = Seq(packageScalaJSLauncher, fastOptJS, fullOptJS) map { packageJSKey =>
    crossTarget in(js, Compile, packageJSKey) := scalajsOutputDir.value
  }

  // instantiate the JS project for SBT with some additional settings
  lazy val js: Project = sharedProject.js.settings(
    fastOptJS in Compile := {
      // make a copy of the produced JS-file (and source maps) under the js project as well,
      // because the original goes under the jvm project
      // NOTE: this is only done for fastOptJS, not for fullOptJS
{'fraction_non_alphanumeric': 0.11589113257243196, 'fraction_numerical': 0.009877085162423178, 'mean_word_length': 2.502305918524212, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '467999', 'n_tokens_mistral': 2761, 'n_tokens_neox': 2694, 'n_words': 806}