Skip to content

Commit

Permalink
DOKY-156 Spring Mapping for front (#102)
Browse files Browse the repository at this point in the history
* DOKY-156 Spring Mapping for front

Update submodule path and url for `doky-front`

The submodule path of `doky-front` has been moved from `web-front/doky-front` to `server/doky-front`. Additionally, the URL for this submodule has been updated to point to a new GitHub repository.

Remove `web-front` module and integrate frontend into `server` module

Removed the `web-front` module and migrated its functions to the `server` module. The frontend has been successfully integrated with the server component of the project, significantly simplifying the project structure and deployment. Updated corresponding properties, configurations, and exception handling rules to accommodate these changes.

Additional configuration was added to redirect to `index.html` any request that does not have a mapping in Spring Boot configuration. It allows to refresh page in browser that have frontend routing path.

Update build configuration and base URL

The build configuration in `server/build.gradle.kts` has been simplified by removing environment-specific arguments. In `server/doky-front/src/api/config.dev.js`, the hard-coded `BASE_URL` has been replaced with `location.origin`, making it dependent on the current location which can offer more flexibility.

Remove redundant `copyFrontDist` task from build script

The `copyFrontDist` task was removed from the `build.gradle.kts` file because it was redundant and unnecessary. Now, the build process only depends on the essential `copyFrontDistSrc` task that copy dist front files under resources src folder. This change simplifies the script and ensures a more efficient and streamlined build procedure.

Remove git modules as it was decided merge front repository into current and have only one. It simplifies develop process for tasks that have changes in both parts - backend and frontend.

As git submodule was removed, all front sources are added into current repository.
  • Loading branch information
hanna-eismant authored Jun 11, 2024
1 parent 796caa6 commit 78fb556
Show file tree
Hide file tree
Showing 79 changed files with 21,510 additions and 507 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ server/out
/docker-deployment/doky-server/server.jar
/doky-*.env
/.azure
/server/src/main/resources/static/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
allprojects {
apply plugin: 'java'

repositories {
mavenCentral()
Expand Down
30 changes: 29 additions & 1 deletion server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.github.gradle.node.npm.task.NpmTask
import kotlinx.kover.gradle.plugin.dsl.AggregationType
import kotlinx.kover.gradle.plugin.dsl.MetricType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand All @@ -13,6 +14,7 @@ plugins {
id("org.jetbrains.kotlinx.kover") version "0.7.6"
id("org.jetbrains.dokka") version "1.9.20"
id("com.github.gmazzo.buildconfig") version "5.3.5"
id("com.github.node-gradle.node") version "7.0.2"
}

dependencyManagement {
Expand All @@ -21,6 +23,10 @@ dependencyManagement {
}
}

java {
sourceCompatibility = JavaVersion.VERSION_17
}

group = "org.hkurh.doky"

version = if (project.hasProperty("deployVersion")) {
Expand All @@ -37,7 +43,7 @@ buildConfig {

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}

Expand Down Expand Up @@ -214,3 +220,25 @@ koverReport {
}
}
}

node {
download = true
version = "20.12.2"
npmInstallCommand = "ci"
nodeProjectDir = file("${project.projectDir}/doky-front")
}

tasks.register<NpmTask>("npmBuild") {
dependsOn("npmInstall")
args = listOf("run", "build")
}

tasks.register<Copy>("copyFrontDistSrc") {
dependsOn("npmBuild")
from("$projectDir/doky-front/dist")
into("$projectDir/src/main/resources/static")
}

tasks.named("processResources") {
dependsOn("copyFrontDistSrc")
}
53 changes: 53 additions & 0 deletions server/doky-front/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"extends": [
"plugin:react/recommended",
"plugin:react-hooks/recommended"
],
"env": {
"es6": true,
"browser": true
},
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module"
},
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"no-debugger": 2,
"indent": [
2,
2
],
"no-trailing-spaces": 2,
"no-undef": 2,
"eqeqeq": 2,
"semi": [
2,
"always"
],
"quotes": [
2,
"single"
],
"prefer-const": 2,
"no-unused-vars": [
"error",
{
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": false
}
],
"no-return-assign": [
"error",
"always"
],
"react/react-in-jsx-scope": 0,
"react-hooks/exhaustive-deps": 2,
"react/prop-types": 0
}
}
22 changes: 22 additions & 0 deletions server/doky-front/.github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Lint'

on: [ push ]

jobs:
lint:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install npm dependencies
run: npm ci

- name: 'run eslint'
run: npm run lint
37 changes: 21 additions & 16 deletions web-front/.gitignore → server/doky-front/.gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
node_modules

HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
Expand All @@ -13,30 +14,34 @@ build/
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
/.idea/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
/.jpb/

### Gradle ###
server/.gradle

server/out

bin
/.gradle/
/docker-deployment/doky-server/server.jar

### Kotlin ###
.kotlin
/doky-front/node_modules/
/doky-front/dist/
/doky-*.env
1 change: 1 addition & 0 deletions server/doky-front/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint
102 changes: 102 additions & 0 deletions server/doky-front/.space.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import java.time.DayOfWeek
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.time.temporal.TemporalAdjusters

var deploymentKey = "azure-dev-front"

job("Tests for main branch") {
startOn {
gitPush {
anyRefMatching {
+"refs/heads/main"
}
}
}

host("Schedule Azure DEV Deployment") {
kotlinScript { api ->
val deployVersion = "Aardvark-v0.1." + api.executionNumber() + "f"
api.space().projects.automation.deployments.schedule(
project = api.projectIdentifier(),
targetIdentifier = TargetIdentifier.Key(deploymentKey),
version = deployVersion,
scheduledStart = getNextSundayDate()
)
}
}
}

job("Azure DEV Deployment") {
startOn {
// every Sunday at 11:59 pm UTC
schedule { cron("59 23 * * SUN") }
}

host("Sync deployment status") {
kotlinScript { api ->
val deployVersion = api.space().projects.automation.deployments.get(
project = api.projectIdentifier(),
targetIdentifier = TargetIdentifier.Key(deploymentKey),
deploymentIdentifier = DeploymentIdentifier.Status(DeploymentIdentifierStatus.scheduled)
).version
api.space().projects.automation.deployments.start(
project = api.projectIdentifier(),
targetIdentifier = TargetIdentifier.Key(deploymentKey),
version = deployVersion,
syncWithAutomationJob = true
)
}
}

val sharedBuildPath = "to-deploy"
val zipFile = "dist.zip"
container(displayName = "Build", image = "node:18-alpine") {
shellScript {
content = """
npm ci && npm run build
mkdir ${'$'}JB_SPACE_FILE_SHARE_PATH/$sharedBuildPath
cd dist
cp -a . ${'$'}JB_SPACE_FILE_SHARE_PATH/$sharedBuildPath
cd ${'$'}JB_SPACE_FILE_SHARE_PATH/$sharedBuildPath
ls -la
""".trimIndent()
}
}

container(displayName = "Zip dist", image = "joshkeegan/zip") {
shellScript {
content = """
cd ${'$'}JB_SPACE_FILE_SHARE_PATH/$sharedBuildPath
zip -r $zipFile *
ls -la
""".trimIndent()
}
}

container(displayName = "Deploy to azure", "mcr.microsoft.com/azure-cli") {
env["AZURE_SUBSCRIPTION"] = "{{ project:azure-subscription }}"
env["AZURE_RESOURCE_GROUP"] = "{{ project:azure-resource-group }}"
env["AZURE_APP_NAME"] = "{{ project:azure-app-name-front }}"
env["AZURE_TENANT"] = "{{ project:azure-tenant }}"
env["AZURE_CLIENT"] = "{{ project:azure-client }}"
env["AZURE_AUTH_KEY"] = "{{ project:azure-auth-key }}"

shellScript {
content = """
az login --service-principal -t ${'$'}AZURE_TENANT -u ${'$'}AZURE_CLIENT -p ${'$'}AZURE_AUTH_KEY
az webapp deployment source config-zip -g ${'$'}AZURE_RESOURCE_GROUP -n ${'$'}AZURE_APP_NAME --src ${'$'}JB_SPACE_FILE_SHARE_PATH/$sharedBuildPath/$zipFile
"""
}
}
}

fun getNextSundayDate(): Instant {
var date = ZonedDateTime.of(LocalDateTime.now(), ZoneId.of("UTC"))
// set time to 11:59 pm UTC
date = date.withHour(23).withMinute(59).withSecond(0).withNano(0)
val sunday = date.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY))
return Instant.parse(sunday.format(DateTimeFormatter.ISO_INSTANT))
}
Loading

0 comments on commit 78fb556

Please sign in to comment.