diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e8927471..f2b1d0e9f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,11 +2,10 @@ name: "Build" on: push: pull_request: - schedule: - - cron: "37 13 * * *" jobs: check: if: ${{ github.event_name == 'pull_request' }} + name: "Validating yarn cache integrity" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -15,26 +14,29 @@ jobs: node-version: 22.x - run: yarn install --check-cache working-directory: app-frontend - build: - name: "Build on JDK 21 and Node.JS 22.x" + + kotlin-build: + name: "Build backend" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: "Compiled Scripts Cache" - uses: actions/cache@v4 - with: - path: ~/.cache/awesome-kotlin - key: kotlin-scripts-cache - uses: actions/setup-java@v4 with: java-version: "21" distribution: "liberica" - uses: gradle/actions/setup-gradle@v4 - run: ./gradlew check installDist - - name: "Generate data for frontend" - run: ./build/install/awesome-kotlin/bin/awesome-kotlin - env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} + - uses: actions/upload-artifact@v4 + with: + name: "Backend Application" + path: "app-backend/build/install/" + retention-days: 1 + + react-build: + name: "Build frontend" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22.x @@ -47,26 +49,21 @@ jobs: name: "Frontend Application" path: "app-frontend/dist/" retention-days: 1 - - uses: actions/upload-artifact@v4 - with: - name: "Readme" - path: "readme/" - retention-days: 1 + build-and-push-image: - if: ${{ github.ref == 'refs/heads/main' }} + name: "Build and push docker image" runs-on: ubuntu-latest - needs: build + needs: [kotlin-build, react-build] steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: - name: "Frontend Application" - path: "app-frontend/dist/" + name: "Backend Application" + path: "app-backend/build/install/" - uses: actions/download-artifact@v4 with: - name: "Readme" - path: "readme/" - - run: ls -laR + name: "Frontend Application" + path: "app-frontend/dist/" - name: "Set up Docker Buildx" uses: docker/setup-buildx-action@v3 - name: "Login to GHCR" @@ -80,11 +77,5 @@ jobs: with: platforms: linux/amd64,linux/arm64 push: true - context: app-frontend + context: . tags: ghcr.io/heapy/awesome-kotlin:main - - name: "Deploy Readme" - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./readme - publish_branch: readme diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..d4c768b66 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM bellsoft/liberica-openjre-alpine:21.0.5 +RUN apk --no-cache add curl +COPY /app-backend/build/install/awesome /app/backend/ +COPY /app-frontend/dist /app/frontend/ +RUN chmod u+x /app/backend/bin/awesome +ENTRYPOINT /app/backend/bin/awesome diff --git a/app-backend-dataops/build.gradle.kts b/app-backend-dataops/build.gradle.kts index 45c503642..a3136682f 100644 --- a/app-backend-dataops/build.gradle.kts +++ b/app-backend-dataops/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - kotlin("jvm") + alias(libs.plugins.kotlin.jvm) } repositories { @@ -7,8 +7,8 @@ repositories { } dependencies { - implementation("org.jooq:jooq-codegen:3.19.16") - implementation("org.flywaydb:flyway-database-postgresql:11.1.0") - implementation("org.postgresql:postgresql:42.7.4") - implementation("ch.qos.logback:logback-classic:1.5.16") + implementation(libs.jooq.codegen) + implementation(libs.flyway.database.postgresql) + implementation(libs.postgresql) + implementation(libs.logback) } diff --git a/app-backend/build.gradle.kts b/app-backend/build.gradle.kts index 61a4efa46..1a30287e6 100644 --- a/app-backend/build.gradle.kts +++ b/app-backend/build.gradle.kts @@ -1,7 +1,7 @@ plugins { application - kotlin("jvm") - kotlin("plugin.serialization") + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kotlin.serialization) } application { @@ -29,45 +29,49 @@ tasks.test { dependencies { implementation(kotlin("stdlib-jdk8")) implementation(kotlin("reflect")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.10.1") + implementation(libs.kotlinx.coroutines.jdk8) - implementation("org.jetbrains.kotlinx:kotlinx-serialization-hocon:1.7.3") - implementation("com.charleskorn.kaml:kaml:0.67.0") + implementation(libs.kotlinx.serialization.json) + implementation(libs.kotlinx.serialization.hocon) + implementation(libs.kaml) - implementation("org.flywaydb:flyway-database-postgresql:11.1.0") - implementation("org.jooq:jooq:3.19.16") - implementation("org.postgresql:postgresql:42.7.4") - implementation("com.zaxxer:HikariCP:6.2.1") + implementation(libs.flyway.database.postgresql) + implementation(libs.jooq.core) + implementation(libs.postgresql) + implementation(libs.hikari) implementation("at.favre.lib:bcrypt:0.10.2") - implementation("io.heapy.komok:komok-tech-to-been-injected:1.0.7") + implementation(libs.komok.tech.to.be.injected) + implementation(libs.komok.tech.dotenv) + implementation(libs.komok.tech.logging) - implementation("io.ktor:ktor-serialization-kotlinx-json:3.0.3") - implementation("io.ktor:ktor-client-cio:3.0.3") - implementation("io.ktor:ktor-server-content-negotiation:3.0.3") - implementation("io.ktor:ktor-server-cio:3.0.3") - implementation("io.ktor:ktor-server-resources:3.0.3") - implementation("io.ktor:ktor-server-websockets:3.0.3") - implementation("io.ktor:ktor-client-content-negotiation:3.0.3") - implementation("io.ktor:ktor-server-auth-jwt:3.0.3") - implementation("io.ktor:ktor-server-metrics-micrometer:3.0.3") - implementation("io.micrometer:micrometer-registry-prometheus:1.14.2") - implementation("io.ktor:ktor-server-call-logging:3.0.3") - implementation("io.ktor:ktor-server-default-headers:3.0.3") - implementation("io.ktor:ktor-server-caching-headers:3.0.3") - implementation("io.ktor:ktor-server-status-pages:3.0.3") + implementation(libs.ktor.serialization.kotlinx.json) + implementation(libs.ktor.client.cio) + implementation(libs.ktor.server.content.negotiation) + implementation(libs.ktor.server.cio) + implementation(libs.ktor.server.resources) + implementation(libs.ktor.server.websockets) + implementation(libs.ktor.client.content.negotiation) + implementation(libs.ktor.server.auth.jwt) + implementation(libs.ktor.server.metrics.micrometer) + implementation(libs.micrometer.registry.prometheus) + implementation(libs.ktor.server.call.logging) + implementation(libs.ktor.server.default.headers) + implementation(libs.ktor.server.caching.headers) + implementation(libs.ktor.server.status.pages) implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.18.2") - implementation("ch.qos.logback:logback-classic:1.5.16") + implementation(libs.logback) - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") - testImplementation("io.mockk:mockk:1.13.14") - testImplementation("org.junit.jupiter:junit-jupiter:5.11.4") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") + testImplementation(libs.ktor.server.test.host) + testImplementation(libs.kotlinx.coroutines.test) + testImplementation(libs.mockk) + testImplementation(libs.junit.jupiter) + testRuntimeOnly(libs.junit.platform.launcher) } tasks.distZip { diff --git a/app-frontend/Dockerfile b/app-frontend/Dockerfile deleted file mode 100644 index 45bf91c8a..000000000 --- a/app-frontend/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM nginx:stable-alpine - -COPY /dist /usr/share/nginx/html -COPY default.conf /etc/nginx/conf.d/default.conf diff --git a/build.gradle.kts b/build.gradle.kts index 0fca73645..fac7de7d8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,8 @@ plugins { application - kotlin("jvm").version("2.1.0") - kotlin("plugin.serialization").version("2.1.0") + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kotlin.serialization) + alias(libs.plugins.ksp) } application { @@ -12,6 +13,12 @@ repositories { mavenCentral() } +kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } +} + tasks.test { useJUnitPlatform() } @@ -19,13 +26,18 @@ tasks.test { dependencies { implementation(kotlin("stdlib-jdk8")) implementation(kotlin("reflect")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.10.1") + implementation(libs.kotlinx.coroutines.jdk8) implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.18.2") - implementation("ch.qos.logback:logback-classic:1.5.16") + implementation(libs.logback) + + ksp(libs.komok.tech.di) + implementation(libs.komok.tech.di.lib) + implementation(libs.komok.tech.dotenv) + implementation(libs.komok.tech.logging) implementation("com.rometools:rome:2.1.0") implementation("com.github.dfabulich:sitemapgen4j:1.1.2") @@ -41,9 +53,9 @@ dependencies { implementation("io.ktor:ktor-client-apache:3.0.3") implementation("io.ktor:ktor-client-jackson:3.0.3") - testImplementation("io.mockk:mockk:1.13.14") - testImplementation("org.junit.jupiter:junit-jupiter:5.11.4") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") + testImplementation(libs.mockk) + testImplementation(libs.junit.jupiter) + testRuntimeOnly(libs.junit.platform.launcher) } tasks.distZip { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..5af6a984f --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,76 @@ +[versions] +bouncycastle = "1.78.1" +flyway = "11.1.0" +hikari = "6.2.1" +jooq = "3.19.16" +junit = "5.11.4" +kaml = "0.67.0" +komok = "1.0.8" +kotlin = "2.1.0" +kotlinx-coroutines = "1.10.1" +kotlinx-serialization = "1.8.0" +ksp = "2.1.0-1.0.29" +ktor = "3.0.3" +logback = "1.5.16" +micrometer = "1.14.2" +mockk = "1.13.14" +postgresql = "42.7.4" +xmlutil = "0.90.1" + +[libraries] +bouncycastle-bcpkix = { module = "org.bouncycastle:bcpkix-jdk18on", version.ref = "bouncycastle" } + +flyway-database-postgresql = { module = "org.flywaydb:flyway-database-postgresql", version.ref = "flyway" } + +hikari = { module = "com.zaxxer:HikariCP", version.ref = "hikari" } + +jooq-codegen = { module = "org.jooq:jooq-codegen", version.ref = "jooq" } +jooq-core = { module = "org.jooq:jooq", version.ref = "jooq" } + +junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" } +junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" } + +kaml = { module = "com.charleskorn.kaml:kaml", version.ref = "kaml" } + +komok-tech-di = { module = "io.heapy.komok:komok-tech-di", version.ref = "komok" } +komok-tech-di-lib = { module = "io.heapy.komok:komok-tech-di-lib", version.ref = "komok" } +komok-tech-to-be-injected = { module = "io.heapy.komok:komok-tech-to-be-injected", version.ref = "komok" } +komok-tech-dotenv = { module = "io.heapy.komok:komok-tech-dotenv", version.ref = "komok" } +komok-tech-logging = { module = "io.heapy.komok:komok-tech-logging", version.ref = "komok" } + +kotlinx-coroutines-jdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8", version.ref = "kotlinx-coroutines" } +kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } + +kotlinx-serialization-hocon = { module = "org.jetbrains.kotlinx:kotlinx-serialization-hocon", version.ref = "kotlinx-serialization" } +kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } + +ktor-serialization-kotlinx-json = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" } +ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" } +ktor-server-content-negotiation = { group = "io.ktor", name = "ktor-server-content-negotiation", version.ref = "ktor" } +ktor-server-cio = { group = "io.ktor", name = "ktor-server-cio", version.ref = "ktor" } +ktor-server-resources = { group = "io.ktor", name = "ktor-server-resources", version.ref = "ktor" } +ktor-server-websockets = { group = "io.ktor", name = "ktor-server-websockets", version.ref = "ktor" } +ktor-client-content-negotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktor" } +ktor-server-auth-jwt = { group = "io.ktor", name = "ktor-server-auth-jwt", version.ref = "ktor" } +ktor-server-metrics-micrometer = { group = "io.ktor", name = "ktor-server-metrics-micrometer", version.ref = "ktor" } +ktor-server-call-logging = { group = "io.ktor", name = "ktor-server-call-logging", version.ref = "ktor" } +ktor-server-default-headers = { group = "io.ktor", name = "ktor-server-default-headers", version.ref = "ktor" } +ktor-server-caching-headers = { group = "io.ktor", name = "ktor-server-caching-headers", version.ref = "ktor" } +ktor-server-status-pages = { group = "io.ktor", name = "ktor-server-status-pages", version.ref = "ktor" } +ktor-server-test-host = { group = "io.ktor", name = "ktor-server-test-host", version.ref = "ktor" } + +logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } + +micrometer-registry-prometheus = { module = "io.micrometer:micrometer-registry-prometheus", version.ref = "micrometer" } + +mockk = { module = "io.mockk:mockk", version.ref = "mockk" } + +postgresql = { module = "org.postgresql:postgresql", version.ref = "postgresql" } + +xmlutil = { module = "io.github.pdvrieze.xmlutil:serialization", version.ref = "xmlutil" } + +[plugins] +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } + +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } diff --git a/src/main/kotlin/link/kotlin/scripts/Application.kt b/src/main/kotlin/link/kotlin/scripts/Application.kt index 51734dd52..fcd343b2b 100644 --- a/src/main/kotlin/link/kotlin/scripts/Application.kt +++ b/src/main/kotlin/link/kotlin/scripts/Application.kt @@ -2,29 +2,17 @@ package link.kotlin.scripts -import link.kotlin.scripts.utils.logger -import kotlin.system.exitProcess - fun main() { - try { - val generator = AwesomeKotlinGenerator.default() - - // Load data - val articles = generator.getArticles() - val links = generator.getLinks() + val generator = createApplicationModule {} + .awesomeKotlinGenerator - // Create README.md - generator.generateReadme(links) + // Load data + val articles = generator.getArticles() + val links = generator.getLinks() - // Generate resources for site - generator.generateSiteResources(links, articles) + // Create README.md + generator.generateReadme(links) - LOGGER.info("Done, exit.") - exitProcess(0) - } catch (e: Exception) { - LOGGER.error("Failed, exit.", e) - exitProcess(1) - } + // Generate resources for site + generator.generateSiteResources(links, articles) } - -private val LOGGER = logger {} diff --git a/src/main/kotlin/link/kotlin/scripts/ApplicationModule.kt b/src/main/kotlin/link/kotlin/scripts/ApplicationModule.kt new file mode 100644 index 000000000..145008962 --- /dev/null +++ b/src/main/kotlin/link/kotlin/scripts/ApplicationModule.kt @@ -0,0 +1,143 @@ +package link.kotlin.scripts + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule +import com.fasterxml.jackson.module.kotlin.kotlinModule +import io.heapy.komok.tech.di.lib.Module +import link.kotlin.scripts.model.ApplicationConfiguration +import link.kotlin.scripts.model.default +import link.kotlin.scripts.scripting.ScriptEvaluator +import link.kotlin.scripts.scripting.default +import link.kotlin.scripts.utils.Cache +import link.kotlin.scripts.utils.HttpClient +import link.kotlin.scripts.utils.callLogger +import link.kotlin.scripts.utils.default + +@Module +open class ApplicationModule { + open val objectMapper: JsonMapper by lazy { + JsonMapper.builder() + .addModule(kotlinModule { }) + .addModule(JavaTimeModule()) + .build() + } + + open val httpClient by lazy { + HttpClient.Companion.default() + } + + open val applicationConfiguration by lazy { + ApplicationConfiguration.Companion.default() + } + + open val markdownRenderer by lazy { + MarkdownRenderer.default() + } + + open val cache by lazy { + Cache.Companion.default( + mapper = objectMapper, + configuration = applicationConfiguration, + ) + } + + open val scriptEvaluator by lazy { + ScriptEvaluator.Companion.default( + cache = cache, + ) + } + + open val kotlinVersionFetcher by lazy { + KotlinVersionFetcher.default( + httpClient = httpClient, + ) + } + + open val sitemapGenerator by lazy { + SitemapGenerator( + configuration = applicationConfiguration, + ) + } + + open val pagesGenerator by lazy { + PagesGenerator.default() + } + + open val rssGenerator by lazy { + RssGenerator.default() + } + + open val siteGenerator by lazy { + SiteGenerator.default( + mapper = objectMapper, + kotlinVersionFetcher = kotlinVersionFetcher, + sitemapGenerator = sitemapGenerator, + pagesGenerator = pagesGenerator, + rssGenerator = rssGenerator, + ) + } + + open val linksChecker by lazy { + LinksChecker.default( + httpClient = httpClient, + ) + } + + open val linksProcessor by lazy { + LinksProcessor.default( + mapper = objectMapper, + httpClient = httpClient, + linksChecker = linksChecker, + configuration = applicationConfiguration, + markdownRenderer = markdownRenderer, + ) + } + + open val categoryProcessor by lazy { + CategoryProcessor.default( + linksProcessor = linksProcessor, + ) + } + + open val githubTrending by lazy { + GithubTrending.default( + cache = cache, + ) + } + + open val readmeGenerator by lazy { + MarkdownReadmeGenerator() + } + + open val linksSource by lazy { + LinksSource.default( + scriptEvaluator = scriptEvaluator, + githubTrending = githubTrending, + categoryProcessor = categoryProcessor, + ) + } + + open val articlesProcessor by lazy { + ArticlesProcessor.default( + markdownRenderer = markdownRenderer, + ) + } + + open val articlesSource by lazy { + ArticlesSource.default( + scriptEvaluator = scriptEvaluator, + articlesProcessor = articlesProcessor, + ) + } + + open val awesomeKotlinGenerator by lazy { + val implementation = DefaultAwesomeKotlinGenerator( + linksSource = linksSource, + articlesSource = articlesSource, + readmeGenerator = readmeGenerator, + siteGenerator = siteGenerator, + ) + + callLogger(implementation) + } +} diff --git a/src/main/kotlin/link/kotlin/scripts/AwesomeKotlinGenerator.kt b/src/main/kotlin/link/kotlin/scripts/AwesomeKotlinGenerator.kt index cb0249c3e..447ef2221 100644 --- a/src/main/kotlin/link/kotlin/scripts/AwesomeKotlinGenerator.kt +++ b/src/main/kotlin/link/kotlin/scripts/AwesomeKotlinGenerator.kt @@ -2,15 +2,6 @@ package link.kotlin.scripts import link.kotlin.scripts.dsl.Article import link.kotlin.scripts.dsl.Category -import link.kotlin.scripts.model.ApplicationConfiguration -import link.kotlin.scripts.model.default -import link.kotlin.scripts.scripting.ScriptEvaluator -import link.kotlin.scripts.scripting.default -import link.kotlin.scripts.utils.Cache -import link.kotlin.scripts.utils.HttpClient -import link.kotlin.scripts.utils.KotlinObjectMapper -import link.kotlin.scripts.utils.callLogger -import link.kotlin.scripts.utils.default import link.kotlin.scripts.utils.writeFile interface AwesomeKotlinGenerator { @@ -22,10 +13,10 @@ interface AwesomeKotlinGenerator { companion object } -private class DefaultAwesomeKotlinGenerator( +class DefaultAwesomeKotlinGenerator( private val linksSource: LinksSource, private val articlesSource: ArticlesSource, - private val readmeGenerator: ReadmeGenerator, + private val readmeGenerator: MarkdownReadmeGenerator, private val siteGenerator: SiteGenerator ) : AwesomeKotlinGenerator { override fun getLinks(): List { @@ -50,73 +41,3 @@ private class DefaultAwesomeKotlinGenerator( siteGenerator.generateArticles(articles) } } - -fun AwesomeKotlinGenerator.Companion.default(): AwesomeKotlinGenerator { - val mapper = KotlinObjectMapper() - val httpClient = HttpClient.default() - val configuration = ApplicationConfiguration.default() - val markdownRenderer = MarkdownRenderer.default() - - val cache = Cache.default( - mapper = mapper, - configuration = configuration - ) - - val scriptEvaluator = ScriptEvaluator.default( - cache = cache - ) - - val kotlinVersionFetcher = KotlinVersionFetcher.default( - httpClient = httpClient - ) - - val sitemapGenerator = SitemapGenerator.default( - configuration = configuration - ) - - val siteGenerator = SiteGenerator.default( - mapper = mapper, - kotlinVersionFetcher = kotlinVersionFetcher, - sitemapGenerator = sitemapGenerator, - pagesGenerator = PagesGenerator.default(), - rssGenerator = RssGenerator.default() - ) - - val linksChecker = LinksChecker.default( - httpClient = httpClient - ) - - val linksProcessor = LinksProcessor.default( - mapper = mapper, - httpClient = httpClient, - linksChecker = linksChecker, - configuration = configuration, - markdownRenderer = markdownRenderer - ) - - val categoryProcessor = CategoryProcessor.default( - linksProcessor = linksProcessor - ) - - val githubTrending = GithubTrending.default( - cache = cache - ) - - val implementation = DefaultAwesomeKotlinGenerator( - linksSource = LinksSource.default( - scriptEvaluator = scriptEvaluator, - githubTrending = githubTrending, - categoryProcessor = categoryProcessor - ), - articlesSource = ArticlesSource.default( - scriptEvaluator = scriptEvaluator, - articlesProcessor = ArticlesProcessor.default( - markdownRenderer = markdownRenderer - ) - ), - readmeGenerator = ReadmeGenerator.default(), - siteGenerator = siteGenerator - ) - - return callLogger(implementation) -} diff --git a/src/main/kotlin/link/kotlin/scripts/ReadmeGenerator.kt b/src/main/kotlin/link/kotlin/scripts/ReadmeGenerator.kt index 43dfe6dfd..74b475b95 100644 --- a/src/main/kotlin/link/kotlin/scripts/ReadmeGenerator.kt +++ b/src/main/kotlin/link/kotlin/scripts/ReadmeGenerator.kt @@ -2,23 +2,13 @@ package link.kotlin.scripts import link.kotlin.scripts.dsl.Category -interface ReadmeGenerator { - fun generate(links: List): String - - companion object -} - -private class MarkdownReadmeGenerator : ReadmeGenerator { - override fun generate(links: List): String { +class MarkdownReadmeGenerator { + fun generate(links: List): String { val readmeLinks = links.filterNot { it.name == "Kotlin User Groups" } return generateReadme(readmeLinks) } } -fun ReadmeGenerator.Companion.default(): ReadmeGenerator { - return MarkdownReadmeGenerator() -} - internal fun normalizeName(name: String): String { return name .lowercase() diff --git a/src/main/kotlin/link/kotlin/scripts/SitemapGenerator.kt b/src/main/kotlin/link/kotlin/scripts/SitemapGenerator.kt index 940c60dc0..7e9840d24 100644 --- a/src/main/kotlin/link/kotlin/scripts/SitemapGenerator.kt +++ b/src/main/kotlin/link/kotlin/scripts/SitemapGenerator.kt @@ -2,19 +2,11 @@ package link.kotlin.scripts import link.kotlin.scripts.dsl.Article import link.kotlin.scripts.model.ApplicationConfiguration -import link.kotlin.scripts.model.default -interface SitemapGenerator { - fun generate(articles: List
): String - - companion object -} - -private class DefaultSitemapGenerator( +class SitemapGenerator( private val configuration: ApplicationConfiguration -) : SitemapGenerator { - - override fun generate(articles: List
): String { +) { + fun generate(articles: List
): String { return sitemap { +SitemapUrl(configuration.siteUrl) @@ -24,11 +16,3 @@ private class DefaultSitemapGenerator( } } } - -fun SitemapGenerator.Companion.default( - configuration: ApplicationConfiguration = ApplicationConfiguration.default() -): SitemapGenerator { - return DefaultSitemapGenerator( - configuration = configuration - ) -} diff --git a/src/main/kotlin/link/kotlin/scripts/utils/HttpClient.kt b/src/main/kotlin/link/kotlin/scripts/utils/HttpClient.kt index 286e209b6..86df0bac0 100644 --- a/src/main/kotlin/link/kotlin/scripts/utils/HttpClient.kt +++ b/src/main/kotlin/link/kotlin/scripts/utils/HttpClient.kt @@ -2,7 +2,6 @@ package link.kotlin.scripts.utils import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.CancellationException -import kotlinx.coroutines.cancelFutureOnCancellation import kotlinx.coroutines.suspendCancellableCoroutine import org.apache.http.HttpResponse import org.apache.http.client.methods.HttpUriRequest diff --git a/src/main/kotlin/link/kotlin/scripts/utils/KotlinObjectMapper.kt b/src/main/kotlin/link/kotlin/scripts/utils/KotlinObjectMapper.kt deleted file mode 100644 index 6136635f4..000000000 --- a/src/main/kotlin/link/kotlin/scripts/utils/KotlinObjectMapper.kt +++ /dev/null @@ -1,13 +0,0 @@ -package link.kotlin.scripts.utils - -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule -import com.fasterxml.jackson.module.kotlin.kotlinModule - -@Suppress("FunctionName") -fun KotlinObjectMapper(): ObjectMapper = - JsonMapper.builder() - .addModule(kotlinModule { }) - .addModule(JavaTimeModule()) - .build()