Skip to content

Commit

Permalink
Making invert more build system agnostic. Added a "BuildSystem" field…
Browse files Browse the repository at this point in the history
… and renamed mavenRepoUrls to artifactRepositories to be mroe agnostic. Only showing "Gradle" navigation items if it is using the Gradle build system. (#37)
  • Loading branch information
handstandsam authored Dec 10, 2024
1 parent 2dd09a3 commit 1b1ae95
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InvertAllCollectedDataRepo(

val httpsRemoteRepoUrlForCommit: String = "${projectMetadata.remoteRepoUrl}/blob/${projectMetadata.latestCommitGitSha}"

val mavenRepoUrls = projectMetadata.mavenRepoUrls
val mavenRepoUrls = projectMetadata.artifactRepositories

val projectPaths: Set<ModulePath> by lazy {
mutableSetOf<String>().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.squareup.invert.internal.tasks
import com.squareup.invert.internal.GitDataCollector
import com.squareup.invert.logging.InvertLogger
import com.squareup.invert.models.GitBranch
import com.squareup.invert.models.js.BuildSystem
import com.squareup.invert.models.js.MetadataJsReportModel
import java.io.File
import java.time.Instant
Expand Down Expand Up @@ -42,6 +43,13 @@ object ProjectMetadataCollector {
remoteGitRepoUrl
}

val buildSystem = if (gitProjectDir.listFiles().any { it.name.contains(".gradle") }) {
// Has a settings.gradle or settings.gradle.kts or build.gradle or build.gradle.kts file in the root
BuildSystem.GRADLE
} else {
BuildSystem.OTHER
}

return MetadataJsReportModel(
currentTime = time.epochSecond,
currentTimeStr = formatter.format(time),
Expand All @@ -54,7 +62,8 @@ object ProjectMetadataCollector {
latestCommitSha = currentBranchHash,
remoteRepoGit = remoteGitRepoUrl,
remoteRepoUrl = remoteRepoUrl,
mavenRepoUrls = repoUrls,
artifactRepositories = repoUrls,
buildSystem = buildSystem,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.squareup.invert.models.js

enum class BuildSystem {
GRADLE,
OTHER,
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ data class MetadataJsReportModel(
val tagName: GitTag?,
val remoteRepoGit: String,
val remoteRepoUrl: String,
val mavenRepoUrls: List<String>
val artifactRepositories: List<String>,
val buildSystem: BuildSystem,
)
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,6 @@ object DefaultNavItems {
OwnerBreakdownReportPage.navPage.toNavItem()
)
),
NavPageGroup(
"Gradle", setOf(
GradlePluginsReportPage.navPage.toNavItem().copy(
matchesCurrentNavRoute = {
it is GradlePluginsNavRoute || it is PluginDetailNavRoute
},
destinationNavRoute = GradlePluginsNavRoute(null)
),
ArtifactsReportPage.navPage.toNavItem().copy(
matchesCurrentNavRoute = {
it is ArtifactsNavRoute || it is ArtifactDetailNavRoute
}
),
GradleRepositoriesReportPage.navPage.toNavItem(),
ConfigurationsNavRoute.navPage.toNavItem().copy(
matchesCurrentNavRoute = {
it is ConfigurationsNavRoute || it is ConfigurationDetailNavRoute
}
),
AnnotationProcessorsReportPage.navPage.toNavItem(),
KotlinCompilerPluginsReportPage.navPage.toNavItem(),
)
),
NavPageGroup(
"Insights", setOf(
LeafModulesNavRoute.navPage.toNavItem(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fun GradleRepositoriesComposable(
}
Br()
Ul({ classes("fs-6") }) {
metadata!!.mavenRepoUrls.forEach { mavenRepoUrl ->
metadata!!.artifactRepositories.forEach { mavenRepoUrl ->
Li {
A(href = mavenRepoUrl) {
Text(mavenRepoUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ import com.squareup.invert.common.navigation.NavPage
import com.squareup.invert.common.navigation.NavPageGroup
import com.squareup.invert.common.navigation.NavRoute
import com.squareup.invert.common.navigation.NavRouteRepo
import com.squareup.invert.common.navigation.toNavItem
import com.squareup.invert.common.pages.AnnotationProcessorsReportPage
import com.squareup.invert.common.pages.ArtifactDetailNavRoute
import com.squareup.invert.common.pages.ArtifactsNavRoute
import com.squareup.invert.common.pages.ArtifactsReportPage
import com.squareup.invert.common.pages.ConfigurationDetailNavRoute
import com.squareup.invert.common.pages.ConfigurationsNavRoute
import com.squareup.invert.common.pages.GradlePluginsNavRoute
import com.squareup.invert.common.pages.GradlePluginsReportPage
import com.squareup.invert.common.pages.GradleRepositoriesReportPage
import com.squareup.invert.common.pages.KotlinCompilerPluginsReportPage
import com.squareup.invert.common.pages.PluginDetailNavRoute
import com.squareup.invert.common.utils.FormattingUtils.dateDisplayStr
import org.jetbrains.compose.web.attributes.ATarget.Blank
import org.jetbrains.compose.web.attributes.target
Expand Down Expand Up @@ -37,7 +49,37 @@ fun LeftNavigationComposable(
Ul({ classes("list-unstyled", "ps-0") }) {
val random = Random(0)
val navGroups by navGroupsRepo.navGroups.collectAsState(setOf())
navGroups
navGroups.let {
if (metadataOrig?.artifactRepositories?.isNotEmpty() == true) {
it.plus(
NavPageGroup(
"Gradle", setOf(
GradlePluginsReportPage.navPage.toNavItem().copy(
matchesCurrentNavRoute = {
it is GradlePluginsNavRoute || it is PluginDetailNavRoute
},
destinationNavRoute = GradlePluginsNavRoute(null)
),
ArtifactsReportPage.navPage.toNavItem().copy(
matchesCurrentNavRoute = {
it is ArtifactsNavRoute || it is ArtifactDetailNavRoute
}
),
GradleRepositoriesReportPage.navPage.toNavItem(),
ConfigurationsNavRoute.navPage.toNavItem().copy(
matchesCurrentNavRoute = {
it is ConfigurationsNavRoute || it is ConfigurationDetailNavRoute
}
),
AnnotationProcessorsReportPage.navPage.toNavItem(),
KotlinCompilerPluginsReportPage.navPage.toNavItem(),
)
),
)
} else {
it
}
}
.forEach { navPageGroup: NavPageGroup ->
val collapseId = "nav-group-id-" + random.nextInt()
Li({ classes("mb-1") }) {
Expand Down

0 comments on commit 1b1ae95

Please sign in to comment.