From 9e552d2ac195c8b6ff1092a6a933d5b0addcc62f Mon Sep 17 00:00:00 2001
From: eikek <eike.kettner@posteo.de>
Date: Tue, 22 Jun 2021 23:40:42 +0200
Subject: [PATCH] Move webapp related build files into the webapp directory

---
 .github/workflows/ci.yml                                | 2 ++
 .github/workflows/release-nightly.yml                   | 2 ++
 .github/workflows/release.yml                           | 2 ++
 elm-analyse.json => modules/webapp/elm-analyse.json     | 0
 elm-package.json => modules/webapp/elm-package.json     | 0
 elm.json => modules/webapp/elm.json                     | 4 ++--
 package-lock.json => modules/webapp/package-lock.json   | 0
 package.json => modules/webapp/package.json             | 0
 postcss.config.js => modules/webapp/postcss.config.js   | 6 +++---
 tailwind.config.js => modules/webapp/tailwind.config.js | 0
 project/StylesPlugin.scala                              | 2 +-
 11 files changed, 12 insertions(+), 6 deletions(-)
 rename elm-analyse.json => modules/webapp/elm-analyse.json (100%)
 rename elm-package.json => modules/webapp/elm-package.json (100%)
 rename elm.json => modules/webapp/elm.json (94%)
 rename package-lock.json => modules/webapp/package-lock.json (100%)
 rename package.json => modules/webapp/package.json (100%)
 rename postcss.config.js => modules/webapp/postcss.config.js (79%)
 rename tailwind.config.js => modules/webapp/tailwind.config.js (100%)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 52fbcb74..45b48147 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,6 +16,8 @@ jobs:
         with:
           elm-version: 0.19.1
       - uses: bahmutov/npm-install@v1
+        with:
+          working-directory: modules/webapp
       - name: Fetch tags
         run: git fetch --depth=100 origin +refs/tags/*:refs/tags/*
       - uses: olafurpg/setup-scala@v12
diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml
index 4b9e008d..624dd949 100644
--- a/.github/workflows/release-nightly.yml
+++ b/.github/workflows/release-nightly.yml
@@ -21,6 +21,8 @@ jobs:
         with:
           elm-version: 0.19.1
       - uses: bahmutov/npm-install@v1
+        with:
+          working-directory: modules/webapp
       - name: Coursier cache
         uses: coursier/cache-action@v6
       - name: Set current version
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index aa3358b6..d606b396 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -21,6 +21,8 @@ jobs:
         with:
           elm-version: 0.19.1
       - uses: bahmutov/npm-install@v1
+        with:
+          working-directory: modules/webapp
       - name: Coursier cache
         uses: coursier/cache-action@v6
       - name: Set current version
diff --git a/elm-analyse.json b/modules/webapp/elm-analyse.json
similarity index 100%
rename from elm-analyse.json
rename to modules/webapp/elm-analyse.json
diff --git a/elm-package.json b/modules/webapp/elm-package.json
similarity index 100%
rename from elm-package.json
rename to modules/webapp/elm-package.json
diff --git a/elm.json b/modules/webapp/elm.json
similarity index 94%
rename from elm.json
rename to modules/webapp/elm.json
index 1ca54b30..047c5cda 100644
--- a/elm.json
+++ b/modules/webapp/elm.json
@@ -1,8 +1,8 @@
 {
     "type": "application",
     "source-directories": [
-        "modules/webapp/src/main/elm",
-        "modules/webapp/target/elm-src"
+        "src/main/elm",
+        "target/elm-src"
     ],
     "elm-version": "0.19.1",
     "dependencies": {
diff --git a/package-lock.json b/modules/webapp/package-lock.json
similarity index 100%
rename from package-lock.json
rename to modules/webapp/package-lock.json
diff --git a/package.json b/modules/webapp/package.json
similarity index 100%
rename from package.json
rename to modules/webapp/package.json
diff --git a/postcss.config.js b/modules/webapp/postcss.config.js
similarity index 79%
rename from postcss.config.js
rename to modules/webapp/postcss.config.js
index dc192a54..049f289e 100644
--- a/postcss.config.js
+++ b/modules/webapp/postcss.config.js
@@ -15,9 +15,9 @@ const prodPlugins =
           require("autoprefixer"),
           require("@fullhuman/postcss-purgecss")({
               content: [
-                  "./modules/webapp/src/main/elm/**/*.elm",
-                  "./modules/webapp/src/main/styles/keep.txt",
-                  "./modules/restserver/src/main/templates/*.html"
+                  "./src/main/elm/**/*.elm",
+                  "./src/main/styles/keep.txt",
+                  "../restserver/src/main/templates/*.html"
               ],
               defaultExtractor: content => content.match(/[A-Za-z0-9-_:/\.]+/g) || []
           }),
diff --git a/tailwind.config.js b/modules/webapp/tailwind.config.js
similarity index 100%
rename from tailwind.config.js
rename to modules/webapp/tailwind.config.js
diff --git a/project/StylesPlugin.scala b/project/StylesPlugin.scala
index e41af9c8..ad8671d7 100644
--- a/project/StylesPlugin.scala
+++ b/project/StylesPlugin.scala
@@ -50,7 +50,7 @@ object StylesPlugin extends AutoPlugin {
         val npm    = stylesNpmCommand.value
         val inDir  = stylesDirectory.value
         val outDir = stylesOutputDir.value
-        val wd     = (LocalRootProject / baseDirectory).value
+        val wd     = (Compile / baseDirectory).value
         val mode   = stylesMode.value
         npmInstall(npm, wd, logger)
         val files = postCss(npx, inDir, outDir, wd, mode, logger) ++