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

refactor: Move function to files which use them #1589

Merged
merged 4 commits into from
Feb 12, 2021
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
109 changes: 42 additions & 67 deletions docs/flank-scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ Properties are skipped by git and should not be attached to a commit. Note, the
│ ├── assemble
│ │ ├── BuildFlank.kt
│ │ ├── BuildGo.kt
│ │ ├── GradleCommand.kt
│ │ ├── android
│ │ │ ├── BuildBaseAndroidApk.kt
│ │ │ ├── BuildBaseAndroidTests.kt
Expand All @@ -224,101 +223,77 @@ Properties are skipped by git and should not be attached to a commit. Note, the
│ │ ├── BuildIosTestArtifacts.kt
│ │ ├── BuildTestPlansExample.kt
│ │ ├── IosBuildCommand.kt
│ │ ├── LipoHelper.kt
│ │ ├── RunFtlLocal.kt
│ │ └── UniversalFramework.kt
│ ├── ci
│ ├── common
│ │ ├── ConventionalCommitFormatter.kt
│ │ ├── DownloadSoftware.kt
│ │ ├── EarlGreyExampleConsts.kt
│ │ ├── GenerateChangeLog.kt
│ │ └── ReleaseNotesWithType.kt
│ ├── contribution
│ ├── dependencies
│ │ ├── DependenciesResultCheck.kt
│ │ ├── DependencyExtensions.kt
│ │ ├── DependencyUpdate.kt
│ │ ├── DownloadSoftware.kt
│ │ ├── FindOutdatedDependencies.kt
│ │ ├── FindVersionInLines.kt
│ │ ├── GradleDependency.kt
│ │ ├── InstallXcPretty.kt
│ │ ├── SetupIosEnv.kt
│ │ ├── UpdateAllDependencies.kt
│ │ ├── UpdateDependencies.kt
│ │ ├── UpdateGradle.kt
│ │ ├── UpdatePlugins.kt
│ │ ├── UpdateVersionsInFile.kt
│ │ └── updatebinaries
│ │ ├── UpdateAtomic.kt
│ │ ├── UpdateBinaries.kt
│ │ ├── UpdateLlvm.kt
│ │ └── UpdateSwift.kt
│ │ └── common
│ │ ├── DependenciesResultCheck.kt
│ │ ├── DependencyExtensions.kt
│ │ ├── DependencyUpdate.kt
│ │ ├── FindOutdatedDependencies.kt
│ │ ├── GradleDependency.kt
│ │ ├── UpdateDependencies.kt
│ │ ├── UpdateGradle.kt
│ │ ├── UpdatePlugins.kt
│ │ └── UpdateVersionsInFile.kt
│ ├── firebase
│ │ ├── CheckForSDKUpdateCommand.kt
│ │ ├── CheckForSDKUpdate.kt
│ │ ├── CommitList.kt
│ │ ├── Extensions.kt
│ │ ├── GenerateJavaClient.kt
│ │ ├── LastSDKUpdateRun.kt
│ │ ├── OpenedUpdates.kt
│ │ ├── SDKUpdateContext.kt
│ │ └── UpdateApiJson.kt
│ │ ├── UpdateApiJson.kt
│ │ └── common
│ │ └── Extensions.kt
│ ├── github
│ │ ├── CopyGitHubProperties.kt
│ │ ├── DeleteOldRelease.kt
│ │ ├── DeleteOldTag.kt
│ │ ├── FindReferenceIssue.kt
│ │ ├── ReleaseFlank.kt
│ │ ├── SetAssignees.kt
│ │ └── SetLabels.kt
│ ├── integration
│ │ └── ReleaseFlank.kt
│ ├── integrationtests
│ │ ├── CommitList.kt
│ │ ├── Extensions.kt
│ │ ├── IntegrationContext.kt
│ │ ├── IssueList.kt
│ │ ├── PrepareMessage.kt
│ │ ├── ProcessIntegrationTestsResult.kt
│ │ └── WorkflowSummary.kt
│ │ └── common
│ │ ├── ITResults.kt
│ │ ├── IntegrationContext.kt
│ │ └── PrepareMessage.kt
│ ├── jfrog
│ │ ├── DeleteOldSnapshot.kt
│ │ ├── JFrogCommandHelper.kt
│ │ └── SyncMaven.kt
│ ├── linter
│ │ ├── ApplyKtlintToIdea.kt
│ │ └── LinkGitHooks.kt
│ ├── pullrequest
│ ├── release
│ │ ├── AppendReleaseNotes.kt
│ │ ├── CreateReleaseNotes.kt
│ │ ├── NextReleaseTag.kt
│ │ ├── hub
│ │ └── jfrog
│ │ ├── DeleteOldSnapshot.kt
│ │ ├── JFrogCommandHelper.kt
│ │ └── SyncMaven.kt
│ ├── shell
│ │ ├── buildexample
│ │ │ ├── android
│ │ │ ├── go
│ │ │ └── ios
│ │ ├── firebase
│ │ │ ├── apiclient
│ │ │ └── sdk
│ │ └── updatebinaries
│ └── testartifacts
│ ├── ArtifactsArchive.kt
│ ├── Constants.kt
│ ├── Context.kt
│ ├── DownloadFixtures.kt
│ ├── IsNewVersionAvailable.kt
│ ├── LinkArtifacts.kt
│ ├── PrepareTestArtifacts.kt
│ ├── RemoveRemoteCopy.kt
│ ├── ResolveArtifacts.kt
│ ├── TestArtifactsRepo.kt
│ ├── UploadFixtures.kt
│ └── ZipArtifacts.kt
│ │ └── NextReleaseTag.kt
│ ├── testartifacts
│ │ ├── ArtifactsArchive.kt
│ │ ├── Context.kt
│ │ ├── DownloadFixtures.kt
│ │ ├── Helpers.kt
│ │ ├── LinkArtifacts.kt
│ │ ├── PrepareTestArtifacts.kt
│ │ ├── RemoveRemoteCopy.kt
│ │ ├── ResolveArtifacts.kt
│ │ ├── UploadFixtures.kt
│ │ └── ZipArtifacts.kt
│ └── updatebinaries
│ ├── UpdateAtomic.kt
│ ├── UpdateBinaries.kt
│ ├── UpdateLlvm.kt
│ └── UpdateSwift.kt
└── utils
├── Env.kt
├── FastFailForWindows.kt
├── Git.kt
├── GradleCommand.kt
├── MarkdownFormatter.kt
├── Path.kt
├── Serialization.kt
Expand Down
2 changes: 1 addition & 1 deletion flank-scripts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ shadowJar.apply {
}
}
// <breaking change>.<feature added>.<fix/minor change>
version = "1.6.1"
version = "1.6.2"
group = "com.github.flank"

application {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package flank.scripts.cli.dependencies

import com.github.ajalt.clikt.core.CliktCommand
import flank.scripts.ops.dependencies.updatebinaries.updateBinaries
import flank.scripts.ops.updatebinaries.updateBinaries

object UpdateBinariesCommand : CliktCommand(
name = "update_binaries",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
import com.github.ajalt.clikt.parameters.types.enum
import flank.scripts.ops.integrationtests.ITResults
import flank.scripts.ops.integrationtests.common.ITResults
import flank.scripts.ops.integrationtests.processIntegrationTestsResult

object ProcessResultCommand : CliktCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package flank.scripts.cli.release
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
import flank.scripts.ops.release.jfrog.jFrogDeleteOldSnapshot
import flank.scripts.ops.jfrog.jFrogDeleteOldSnapshot

object DeleteSnapshotCommand : CliktCommand(
name = "delete_snapshot",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package flank.scripts.cli.release
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
import flank.scripts.ops.release.jfrog.jFrogSync
import flank.scripts.ops.jfrog.jFrogSync
import kotlin.system.exitProcess

object SyncWithMavenCentralCommand : CliktCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package flank.scripts.ops.assemble.ios
import flank.common.archive
import flank.common.currentPath
import flank.common.iOSTestProjectsPath
import flank.scripts.ops.dependencies.downloadXcPrettyIfNeeded
import flank.scripts.ops.dependencies.installPodsIfNeeded
import flank.scripts.ops.common.downloadXcPrettyIfNeeded
import flank.scripts.ops.common.installPodsIfNeeded
import flank.scripts.utils.failIfWindows
import flank.scripts.utils.pipe
import java.nio.file.Files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package flank.scripts.ops.assemble.ios

import flank.common.archive
import flank.scripts.ops.dependencies.downloadXcPrettyIfNeeded
import flank.scripts.ops.common.downloadXcPrettyIfNeeded
import flank.scripts.utils.failIfWindows
import flank.scripts.utils.pipe
import java.nio.file.Files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package flank.scripts.ops.assemble.ios

import flank.common.flankFixturesIosTmpPath
import flank.scripts.ops.dependencies.downloadCocoaPodsIfNeeded
import flank.scripts.ops.dependencies.downloadXcPrettyIfNeeded
import flank.scripts.ops.dependencies.installPodsIfNeeded
import flank.scripts.ops.common.downloadCocoaPodsIfNeeded
import flank.scripts.ops.common.downloadXcPrettyIfNeeded
import flank.scripts.ops.common.installPodsIfNeeded
import flank.scripts.utils.pipe
import java.nio.file.Path
import java.nio.file.Paths
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package flank.scripts.ops.assemble.ios

import flank.common.archive
import flank.common.flankFixturesIosTmpPath
import flank.scripts.ops.dependencies.downloadCocoaPodsIfNeeded
import flank.scripts.ops.dependencies.downloadXcPrettyIfNeeded
import flank.scripts.ops.dependencies.installPodsIfNeeded
import flank.scripts.ops.common.downloadCocoaPodsIfNeeded
import flank.scripts.ops.common.downloadXcPrettyIfNeeded
import flank.scripts.ops.common.installPodsIfNeeded
import flank.scripts.utils.pipe
import java.io.File
import java.nio.file.Path
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ fun createUniversalFrameworkFiles() {
)
}

fun createLipoCommand(
outputPath: String,
vararg files: String
) = "lipo -create ${files.joinToString(" ")} -output $outputPath"

private fun copyAppFrameworkFiles(fromPath: String, toPath: String) {
Paths.get(fromPath, APP_FRAMEWORK_FRAMEWORK).toFile()
.copyRecursively(Paths.get(toPath, APP_FRAMEWORK_FRAMEWORK).toFile(), overwrite = true)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package flank.scripts.ops.dependencies
package flank.scripts.ops.common

import flank.scripts.utils.checkAndInstallIfNeed
import flank.scripts.utils.commandInstalledOr
import flank.scripts.utils.runCommand
import java.nio.file.Path

Expand All @@ -17,17 +16,3 @@ fun installPodsIfNeeded(path: Path) {
if (path.toFile().listFiles().map { it.name }.contains("Podfile"))
"pod install --project-directory=$path --verbose".runCommand()
}

fun checkIfPipInstalled() {
"pip".commandInstalledOr {
println("You need pip fot this script. To install it follow https://pip.pypa.io/en/stable/installing/")
}
}

fun downloadSortJsonIfNeeded() {
"sort-json".checkAndInstallIfNeed("npm -g install sort-json")
}

fun installClientGeneratorIfNeeded() {
"generate_library".checkAndInstallIfNeed("pip install google-apis-client-generator")
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,17 @@ private fun GithubPullRequest.toReleaseNoteMessage() =
type to "- ${markdownLink("#$number", htmlUrl)} $title ${assignees.format()}"
}

internal fun String.mapPrTitleWithType() = when {
startsWith("feat") -> "Features" to skipConventionalCommitPrefix().capitalize()
startsWith("fix") -> "Bug Fixes" to skipConventionalCommitPrefix().capitalize()
startsWith("docs") -> "Documentation" to skipConventionalCommitPrefix().capitalize()
startsWith("refactor") -> "Refactor" to skipConventionalCommitPrefix().capitalize()
startsWith("ci") -> "CI Changes" to skipConventionalCommitPrefix().capitalize()
startsWith("test") -> "Tests update" to skipConventionalCommitPrefix().capitalize()
startsWith("perf") -> "Performance upgrade" to skipConventionalCommitPrefix().capitalize()
else -> null // we do not accept other prefix to have update in release notes
}

private fun String.skipConventionalCommitPrefix() = substring(indexOf(':') + 2)

private fun List<GithubUser>.format() = "(${joinToString { (login, url) -> markdownLink(login, url) }})"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package flank.scripts.ops.dependencies

import flank.scripts.ops.common.downloadXcPrettyIfNeeded
import flank.scripts.utils.failIfWindows

fun installXcPretty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package flank.scripts.ops.dependencies

import flank.common.iOSTestProjectsPath
import flank.scripts.ops.common.EARL_GREY_EXAMPLE
import flank.scripts.ops.common.downloadCocoaPodsIfNeeded
import flank.scripts.ops.common.installPodsIfNeeded
import flank.scripts.utils.failIfWindows
import java.nio.file.Paths

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package flank.scripts.ops.dependencies
package flank.scripts.ops.dependencies.common

import flank.scripts.utils.Version
import kotlinx.serialization.SerialName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package flank.scripts.ops.dependencies

val Dependency.groupWithName get() = "$group:$name:"
import flank.scripts.ops.dependencies.common.Dependency

val Dependency.versionToUpdate
get() = availableVersion?.release
?: availableVersion?.milestone
?: availableVersion?.integration
?: version

fun GradleDependency.needsUpdate() = running.version < current.version || running.version < releaseCandidate.version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package flank.scripts.ops.dependencies
package flank.scripts.ops.dependencies.common

import flank.scripts.utils.Version

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package flank.scripts.ops.dependencies
package flank.scripts.ops.dependencies.common

import flank.scripts.utils.toObject
import java.io.File

fun File.outDatedDependencies() = readText().toObject<DependenciesResultCheck>().outdated.dependencies

fun File.gradleDependency() = readText().toObject<DependenciesResultCheck>().gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package flank.scripts.ops.dependencies
package flank.scripts.ops.dependencies.common

import flank.scripts.utils.Version
import kotlinx.serialization.Serializable
Expand Down
Loading