Skip to content

Commit 25dbfa2

Browse files
committed
Release 0.8.1
DynamicEnvironment supports accepting a String Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent 8465cb0 commit 25dbfa2

File tree

12 files changed

+58
-45
lines changed

12 files changed

+58
-45
lines changed

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CONTRIBUTING.adoc

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ You can run/debug the existing unit tests or write your own to play with the too
5555
If you're a Java developer and new to Kotlin, don't worry, Kotlin is a JVM language and can be used anywhere Java is used.
5656
In fact, it has got the reputation of *"Better Java!"*.
5757
* A typical Java developer can ramp up on Kotlin in less than a week. These resources can help catalyze your ramp-up:
58+
** https://play.kotlinlang.org/byExample/overview[Learn Kotlin by Example]
5859
** https://www.coursera.org/learn/kotlin-for-java-developers[*Kotlin for Java Developers | Coursera*], a free course
5960
** https://www.kotlinprimer.com/[The Kotlin Primer], tailor-made to facilitate Kotlin adoption inside Java-centric organizations
6061
* If you use Intellij, Kotlin plugin comes bundled.
62+
* If you use VS Code based IDEs (e.g. Cursor) install this official https://github.com/Kotlin/kotlin-lsp[Kotlin Language Server plugin]
6163
Similar development aids should be present for other code editors too.
6264

6365
== Code Formatting
@@ -70,6 +72,17 @@ It may be slow for the first run, but subsequent runs should be faster.
7072

7173
== Manual publishing
7274

75+
=== Gradle Nexus Publish Plugin
76+
77+
We use https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-central[Gradle Nexus Publish Plugin]
78+
to publish to Maven Central. Follow the usage instructions to set up Sonatype credentials and add them to your `~/.gradle/gradle.properties`.
79+
80+
[source,bash]
81+
----
82+
sonatypeUsername=<your-username>
83+
sonatypePassword=<your-password>
84+
----
85+
7386
=== Versioning Strategy
7487

7588
====
@@ -80,17 +93,19 @@ It may be slow for the first run, but subsequent runs should be faster.
8093
* B = Profit (Feature / Improvement)
8194
* C = Broke something by accident (Bug)
8295

83-
Follow the Versioning Strategy to increment version link:buildSrc/{sourcedir}/Config.kt[here]
96+
Follow the Versioning Strategy to increment version link:buildSrc/{sourcedir}/Config.kt[here].
97+
For SNAPSHOT releases, add a `-SNAPSHOT` at the end of version number
98+
99+
=== Publish
84100

85-
* For SNAPSHOT releases, add a `-SNAPSHOT` at the end of version number
86-
* Run this command to publish it to Nexus:
101+
Run this command to publish it to Nexus:
87102

88103
[source,bash]
89104
----
90105
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Dorg.gradle.parallel=false --no-configuration-cache
91106
----
92107

93-
* You can monitor for the new version jar to reflect in link:https://repo1.maven.org/maven2/com/salesforce/revoman/revoman/[Maven Central]. It usually takes less than 30 minutes.
108+
* You can monitor for the new version jar to reflect in https://repo1.maven.org/maven2/com/salesforce/revoman/revoman/[Maven Central]. It usually takes less than 30 minutes.
94109

95110
== Code of Conduct
96111
Please follow our link:CODE_OF_CONDUCT.md[Code of Conduct]

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ endif::[]
1818
:pmtemplates: src/integrationTest/resources/pm-templates
1919
:imagesdir: docs/images
2020
:prewrap!:
21-
:revoman-version: 0.8.0
21+
:revoman-version: 0.8.1
2222

2323
'''
2424

build.gradle.kts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,12 @@ kover { reports { total { html { onCheck = true } } } }
7171

7272
moshi { enableSealed = true }
7373

74-
nexusPublishing { this.repositories { sonatype { stagingProfileId = STAGING_PROFILE_ID } } }
74+
nexusPublishing {
75+
this.repositories {
76+
sonatype {
77+
stagingProfileId = STAGING_PROFILE_ID
78+
nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/")
79+
snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/")
80+
}
81+
}
82+
}

buildSrc/src/main/kotlin/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
* ************************************************************************************************
77
*/
88
const val GROUP_ID = "com.salesforce.revoman"
9-
const val VERSION = "0.8.0"
9+
const val VERSION = "0.8.1"
1010
const val ARTIFACT_ID = "revoman"
1111
const val STAGING_PROFILE_ID = "1ea0a23e61ba7d"

src/main/kotlin/com/salesforce/revoman/ReVoman.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ object ReVoman {
6363
kicks
6464
.fold(dynamicEnvironment to listOf<Rundown>()) { (accumulatedMutableEnv, rundowns), kick ->
6565
val rundown =
66-
revUp(
67-
kick.overrideDynamicEnvironments(
68-
kick.dynamicEnvironmentsFlattened(),
69-
accumulatedMutableEnv,
70-
)
71-
)
66+
revUp(kick.overrideDynamicEnvironment(kick.dynamicEnvironment() + accumulatedMutableEnv))
7267
val accumulatedRundowns = rundowns + rundown
7368
postExeHook.accept(rundown, accumulatedRundowns)
7469
rundown.mutableEnv.mutableEnvCopyWithValuesOfType<String>() to accumulatedRundowns
@@ -107,11 +102,7 @@ object ReVoman {
107102
kick.globalSkipTypes(),
108103
)
109104
val environment =
110-
mergeEnvs(
111-
kick.environmentPaths(),
112-
kick.environmentInputStreams(),
113-
kick.dynamicEnvironmentsFlattened(),
114-
)
105+
mergeEnvs(kick.environmentPaths(), kick.environmentInputStreams(), kick.dynamicEnvironment())
115106
val pm =
116107
PostmanSDK(moshiReVoman, kick.nodeModulesPath(), regexReplacer, environment.toMutableMap())
117108
val stepNameToReport =

src/main/kotlin/com/salesforce/revoman/input/config/KickDef.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,10 @@ internal interface KickDef {
3535

3636
fun environmentInputStreams(): List<InputStream>
3737

38-
fun dynamicEnvironments(): List<Map<String, String>>
38+
fun dynamicEnvironment(): Map<String, Any?>
3939

4040
fun nodeModulesPath(): String?
4141

42-
@Value.Derived
43-
fun dynamicEnvironmentsFlattened(): Map<String, String> =
44-
if (dynamicEnvironments().isEmpty()) emptyMap()
45-
else dynamicEnvironments().reduce { acc, map -> acc + map }
46-
4742
fun customDynamicVariableGenerators(): Map<String, CustomDynamicVariableGenerator>
4843

4944
@Value.Default fun haltOnAnyFailure(): Boolean = false

src/main/kotlin/com/salesforce/revoman/internal/json/MoshiReVoman.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ open class MoshiReVoman(builder: Moshi.Builder) {
106106
fun jsonToObjToPrettyJson(input: String?, serializeNulls: Boolean = false): String? =
107107
input?.let { toPrettyJson(fromJson(it), serializeNulls) }
108108

109+
fun anyToString(value: Any?): String =
110+
when (value) {
111+
is String -> value
112+
// * NOTE 08 Mar 2025 gopala.akshintala: To be consistent with Postman app behavior
113+
null -> "null"
114+
else -> toJson(value)
115+
}
116+
109117
companion object {
110118
@Synchronized
111119
@JvmOverloads

src/main/kotlin/com/salesforce/revoman/internal/postman/PostmanSDK.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class PostmanSDK(
5151
@Suppress("unused") fun xml2Json(xml: String): Any?
5252
}
5353

54+
internal fun getAsString(key: String): String = moshiReVoman.anyToString(environment[key])
55+
5456
inner class JSEvaluator(nodeModulesPath: String? = null) {
5557
private val jsContext: Context
5658
private var imports = ""

src/main/kotlin/com/salesforce/revoman/internal/postman/RegexReplacer.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ class RegexReplacer(
4444
value ->
4545
pm.environment[variableKey] = value
4646
}
47-
?: (if (pm.environment[variableKey] is String)
48-
replaceVariablesRecursively(pm.environment[variableKey] as String, pm)
49-
else pm.environment[variableKey].toString())
50-
?.also { value -> pm.environment[variableKey] = value }
47+
?: replaceVariablesRecursively(pm.getAsString(variableKey), pm)?.also { value ->
48+
pm.environment[variableKey] = value
49+
}
5150
?: matchResult.value
5251
}
5352
}

0 commit comments

Comments
 (0)