Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making invert more build system agnostic. #37

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading