diff --git a/.gitignore b/.gitignore index 712e158..e25e571 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ project/project/target yarn.lock !website/yarn.lock +.downloads + website/node_modules website/build website/i18n/* diff --git a/.scalafmt.conf b/.scalafmt.conf index 97b3068..e8c1c10 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,5 @@ -version = "3.8.4-RC1" +include ".downloads/.scalafmt.shared.conf" + runner.dialect = "scala213" # !!! TODO !!! Update styles in the generator to match scalafmt config @@ -8,167 +9,3 @@ project.excludePaths = [ "glob:**/src/main/scala/com/raquo/laminar/defs/**", "glob:**/project/VersionHelper.scala", ] - -maxColumn = 1000 - -indent.main = 2 -indent.callSite = 2 -indent.binPackCallSite = 2 -indent.ctrlSite = 2 -indent.defnSite = 2 -indent.binPackDefnSite = 2 -indent.ctorSite = 2 -indent.matchSite = 2 -indent.caseSite = 2 -indent.extendSite = 0 -indent.withSiteRelativeToExtends = 0 -indent.commaSiteRelativeToExtends = 2 # 0 is not allowed -indent.extraBeforeOpenParenDefnSite = 0 -indent.relativeToLhsLastLine = [match, infix] -indent.fewerBraces = never -indent.afterInfixSite = 2 # not sure what this is https://scalameta.org/scalafmt/docs/configuration.html#indentafterinfixsite - -# Indenting of nested calls: -# !!! #TODO !!!: https://scalameta.org/scalafmt/docs/configuration.html#indent-for-binpackcallsite -# !!! #TODO !!!: https://scalameta.org/scalafmt/docs/configuration.html#indentoperator - -align.preset = none - -# TODO: alignment can be more detailed but requires knowing Scala types -# https://scalameta.org/scalafmt/docs/configuration.html#aligntokens - -align.arrowEnumeratorGenerator = false -align.closeParenSite = false -align.openParenCallSite = false -align.openBracketCallSite = false -align.openParenCtrlSite = false -align.openParenDefnSite = false -align.openBracketDefnSite = false -align.openParenCallSite = false -align.beforeOpenParenCallSite = false # ??? https://scalameta.org/scalafmt/docs/configuration.html#alignbeforeopenparenxxxsite -align.beforeOpenParenDefnSite = false # ??? https://scalameta.org/scalafmt/docs/configuration.html#alignbeforeopenparenxxxsite -align.stripMargin = true -align.multiline = false -align.allowOverflow = true # Not sure, it's unused since alignment is disabled https://scalameta.org/scalafmt/docs/configuration.html#alignallowoverflow -align.inInterpolation = false -align.delayUntilSpace = true - -# https://scalameta.org/scalafmt/docs/configuration.html#binpacking -binPack.callSite = onelinesjs -binPack.parentConstructors = keep - -newlines.source = keep -# TODO: ??? https://scalameta.org/scalafmt/docs/configuration.html#newlinestoplevelstatementblanklines -newlines.topLevelStatementBlankLines = [] -newlines.topLevelBodyIfMinStatements = [] -newlines.beforeTemplateBodyIfBreakInParentCtors = false # TODO not sure https://scalameta.org/scalafmt/docs/configuration.html#newlinesbeforetemplatebodyifbreakinparentctors -newlines.beforeMultiline = keep # !!! TODO not sure, maybe `unfold` https://scalameta.org/scalafmt/docs/configuration.html#newlinesbeforemultiline -newlines.forceBeforeMultilineAssign = never -newlines.forceBeforeAssign = never -newlines.beforeTypeBounds = keep -newlines.alwaysBeforeElseAfterCurlyIf = false -newlines.beforeCurlyLambdaParams = never -newlines.afterCurlyLambdaParams = keep -newlines.configStyleCallSite.prefer = false # Lets us keep all method arguments on the same line, without forcing it -# newlines.implicitParamListModifierPrefer = after # TODO I want this to be before, but scalafmt does not work well with it. Also I can't set this to any value and set binpacking - not supported. -# newlines.implicitParamListModifierForce = [after] # !!! TODO not sure -newlines.afterInfix = keep -newlines.afterInfixBreakOnNested = false # ??? https://scalameta.org/scalafmt/docs/configuration.html#newlinesafterinfixbreakonnested -newlines.avoidForSimpleOverflow = [tooLong, punct, slc] -newlines.avoidInResultType = true -newlines.avoidAfterYield = false -newlines.sometimesBeforeColonInMethodReturnType = false -# newlines.beforeOpenParenDefnSite = keep # TODO not sure https://scalameta.org/scalafmt/docs/configuration.html#newlinesbeforeopenparenxxxsite -# newlines.beforeOpenParenCallSite = keep # TODO only supported for Scala 3. Also, not sure... https://scalameta.org/scalafmt/docs/configuration.html#newlinesbeforeopenparenxxxsite -newlines.selectChains = keep -newlines.inInterpolation = avoid # TODO not sure https://scalameta.org/scalafmt/docs/configuration.html#newlinesininterpolation -newlines.ignoreInSyntax = true # TODO very not sure https://scalameta.org/scalafmt/docs/configuration.html#newlinesignoreinsyntax - -optIn.annotationNewlines = true # TODO not sure https://scalameta.org/scalafmt/docs/configuration.html#optinannotationnewlines - -danglingParentheses.defnSite = true -danglingParentheses.callSite = true -danglingParentheses.bracketDefnSite = true -danglingParentheses.bracketCallSite = true -danglingParentheses.ctrlSite = true -danglingParentheses.tupleSite = true -danglingParentheses.exclude = [] # TODO not sure https://scalameta.org/scalafmt/docs/configuration.html#danglingparenthesesexclude -# !!! TODO not sure how !!! newlines.configStyleXxxSite.prefer https://scalameta.org/scalafmt/docs/configuration.html#newlinesconfigstylexxxsiteprefer - -# prefercurlyfors, redundantparens, redundantbraces, sortmodifiers, sortimports, expandimportselectors, imports, avoidinfix, asciisortimports - -rewrite.rules = [SortModifiers, PreferCurlyFors, Imports] -# rewrite.sortModifiers.preset = styleGuide # TODO consider removing (changes position of `final` keyword) https://scalameta.org/scalafmt/docs/configuration.html#sortmodifiers -rewrite.sortModifiers.order = [ # TODO maybe a custom order... - "final", "override", - "implicit", - "sealed", "abstract", - "private", "protected", - "lazy" -] -rewrite.preferCurlyFors.removeTrailingSemicolonsOnly = true # TODO not sure https://scalameta.org/scalafmt/docs/configuration.html#prefercurlyfors -rewrite.imports.expand = false -rewrite.imports.sort = scalastyle # TODO not sure - change this later https://scalameta.org/scalafmt/docs/configuration.html#imports-sort--ascii -rewrite.imports.groups = [ # TODO not sure - [".*"], # Other imports first - ["java\\..*", "scala\\..*", "scala.scalajs\\..*"] -] -rewrite.imports.contiguousGroups = only # TODO not sure -rewrite.trailingCommas.style = keep # TODO consider changing to `never` -rewrite.trailingCommas.allowFolding = true # TODO not sure https://scalameta.org/scalafmt/docs/configuration.html#rewritetrailingcommasallowfolding - -# TODO Scala 3 rewrites? https://scalameta.org/scalafmt/docs/configuration.html#scala3-rewrites - -# !!!! TODO not sure about any of this !!! Maybe disable completely? -# https://scalameta.org/scalafmt/docs/configuration.html#vertical-multiline -verticalMultiline.atDefnSite = true -verticalMultiline.arityThreshold = 10 -verticalMultiline.newlineAfterOpenParen = true - -comments.wrap = no -comments.wrapStandaloneSlcAsSlc = true // # TODO not sure because unused -comments.wrapSingleLineMlcAsSlc = false - -docstrings.style = keep # !!! TODO not sure, can also be Space, SpaceAsterisk, or AsteriskSpace https://scalameta.org/scalafmt/docs/configuration.html#docstringsstyle -docstrings.removeEmpty = true -docstrings.oneline = keep # TODO not sure. Note: Ignored if docstrings.style = keep https://scalameta.org/scalafmt/docs/configuration.html#docstringsoneline -docstrings.wrap = keep -docstrings.wrapMaxColumn = 100 # TODO change if want it to be different from maxColumn -docstrings.blankFirstLine = keep # !!! TODO not sure, try `fold` -docstrings.forceBlankLineBefore = false # TODO not sure https://scalameta.org/scalafmt/docs/configuration.html#docstringsforceblanklinebefore - -spaces.beforeContextBoundColon = never # !!! TODO not sure, Always or IfMultipleBounds may be better style https://scalameta.org/scalafmt/docs/configuration.html#spacesbeforecontextboundcolon -spaces.inImportCurlyBraces = false -spaces.inInterpolatedStringCurlyBraces = false -spaces.inParentheses = false -spaces.neverAroundInfixTypes = [] -spaces.aroundSymbolicInfixOperators.include = [".*"] -spaces.aroundSymbolicInfixOperators.exclude = [] -spaces.afterKeywordBeforeParen = true -spaces.inByNameTypes = true -spaces.afterSymbolicDefs = false -spaces.beforeApplyArgInParens = AfterSymbolic # TODO not sure https://scalameta.org/scalafmt/docs/configuration.html#spacesbeforexxxarginparens -spaces.beforeInfixArgInParens = always -spaces.afterColonInMatchPattern = always - -literals.long = Upper -literals.float = Lower -literals.double = Lower -literals.hexPrefix = Lower -literals.hexDigits = Lower # Not sure, unused https://scalameta.org/scalafmt/docs/configuration.html#literalshexdigits -literals.scientific = Lower - -xmlLiterals.assumeFormatted = false - -# !!! TODO Classic select chains !!! https://scalameta.org/scalafmt/docs/configuration.html#classic-select-chains -# - I don't think this applies to us, it's only for when newlines.source = classic, but we have `keep` - -# lineEndings = unix # TODO: Is there a difference between omitting it and setting `unix`? https://scalameta.org/scalafmt/docs/configuration.html#lineendings - -rewriteTokens = { - "⇒": "=>" - "→": "->" - "←": "<-" -} - -importSelectors = binPack # TODO Not sure, is there a `keep` option? https://scalameta.org/scalafmt/docs/configuration.html#importselectors diff --git a/build.sbt b/build.sbt index aba7dec..8056800 100644 --- a/build.sbt +++ b/build.sbt @@ -1,3 +1,4 @@ +import com.raquo.buildkit.SourceDownloader import VersionHelper.{versionFmt, fallbackVersion} // Lets me depend on Maven Central artifacts immediately without waiting @@ -21,11 +22,33 @@ ThisBuild / scalaVersion := Versions.Scala_3 ThisBuild / crossScalaVersions := Seq(Versions.Scala_2_13, Versions.Scala_3) -lazy val precompile = taskKey[Unit]("runs Laminar-specific pre-compile tasks") +lazy val preload = taskKey[Unit]("runs Laminar-specific pre-load tasks") -precompile := DomDefsGenerator.cachedGenerate() +preload := { + val projectDir = (ThisBuild / baseDirectory).value -(Compile / compile) := ((Compile / compile) dependsOn precompile).value + DomDefsGenerator.cachedGenerate() + + SourceDownloader.downloadVersionedFile( + name = "scalafmt-shared-conf", + version = "v0.1.0", + urlPattern = version => s"https://raw.githubusercontent.com/raquo/scalafmt-config/refs/tags/$version/.scalafmt.shared.conf", + versionFile = projectDir / ".downloads" / ".scalafmt.shared.conf.version", + outputFile = projectDir / ".downloads" / ".scalafmt.shared.conf", + processOutput = "#\n# DO NOT EDIT. See SourceDownloader in build.sbt\n" + _ + ) +} + +Global / onLoad := { + (Global / onLoad).value andThen { state => preload.key.label :: state } +} + +// https://github.com/JetBrains/sbt-ide-settings +SettingKey[Seq[File]]("ide-excluded-directories").withRank(KeyRanks.Invisible) := Seq( + ".downloads", ".idea", ".metals", ".bloop", ".bsp", + "target", "project/target", "project/project/target", "project/project/project/target", + "website/build", "website/target", "websiteJS/target" +).map(file) lazy val websiteJS = project .in(file("websiteJS")) diff --git a/project/DomDefsGenerator.scala b/project/DomDefsGenerator.scala index 1ccc97f..0a4b078 100644 --- a/project/DomDefsGenerator.scala +++ b/project/DomDefsGenerator.scala @@ -23,7 +23,9 @@ object DomDefsGenerator { override def scalaJsElementTypeParam: String = "Ref" } - private val cache = new CanonicalCache("project") + private val cache = new CanonicalCache("project") { + override val fileName: String = "../.downloads/domtypes.version" + } def cachedGenerate(): Unit = { cache.triggerIfCacheKeyUpdated( diff --git a/project/build.sbt b/project/build.sbt index 880b35c..6c020a3 100644 --- a/project/build.sbt +++ b/project/build.sbt @@ -12,6 +12,7 @@ lazy val root = (project in file(".")) buildInfoPackage := "metaProject", // Compile-time dependencies libraryDependencies ++= Seq( - "com.raquo" %% "domtypes" % ProjectVersions.ScalaDomTypes + "com.raquo" %% "buildkit" % ProjectVersions.BuildKit, + "com.raquo" %% "domtypes" % ProjectVersions.ScalaDomTypes, ) ) diff --git a/project/lastScalaDomTypesVersion.txt b/project/lastScalaDomTypesVersion.txt deleted file mode 100644 index d576022..0000000 --- a/project/lastScalaDomTypesVersion.txt +++ /dev/null @@ -1 +0,0 @@ -18.1.0 \ No newline at end of file diff --git a/project/project/ProjectVersions.scala b/project/project/ProjectVersions.scala index c876d80..f79ba3d 100644 --- a/project/project/ProjectVersions.scala +++ b/project/project/ProjectVersions.scala @@ -1,5 +1,7 @@ /** Versions of compile-time dependencies */ object ProjectVersions { + val BuildKit = "0.1.0" + val ScalaDomTypes = "18.1.0" }