expo-modules-autolinking 2.1.12 → 2.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/android/expo-gradle-plugin/expo-autolinking-plugin-shared/src/main/kotlin/expo/modules/plugin/configuration/MavenCredentials.kt +0 -1
- package/android/expo-gradle-plugin/expo-autolinking-settings-plugin/build.gradle.kts +1 -0
- package/android/expo-gradle-plugin/expo-autolinking-settings-plugin/src/main/kotlin/expo/modules/plugin/gradle/MavenArtifactRepositoryExtension.kt +22 -7
- package/android/expo-gradle-plugin/expo-autolinking-settings-plugin/src/main/kotlin/expo/modules/plugin/utils/Env.kt +8 -0
- package/android/expo-gradle-plugin/expo-autolinking-settings-plugin/src/test/kotlin/expo/modules/plugin/MavenArtifactRepositoryExtensionTest.kt +112 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 2.1.13 — 2025-07-01
|
|
14
|
+
|
|
15
|
+
### 💡 Others
|
|
16
|
+
|
|
17
|
+
- Added `System.getenv()` syntax support to credentials for extraMavenRepos. ([#37343](https://github.com/expo/expo/pull/37343) by [@kudo](https://github.com/kudo))
|
|
18
|
+
|
|
13
19
|
## 2.1.12 — 2025-06-18
|
|
14
20
|
|
|
15
21
|
### 🐛 Bug fixes
|
|
@@ -4,7 +4,6 @@ import kotlinx.serialization.Serializable
|
|
|
4
4
|
import kotlinx.serialization.json.JsonContentPolymorphicSerializer
|
|
5
5
|
import kotlinx.serialization.json.JsonElement
|
|
6
6
|
import kotlinx.serialization.json.jsonObject
|
|
7
|
-
import kotlin.collections.contains
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Based type of maven credentials object.
|
|
@@ -4,6 +4,7 @@ import expo.modules.plugin.configuration.AWSMavenCredentials
|
|
|
4
4
|
import expo.modules.plugin.configuration.BasicMavenCredentials
|
|
5
5
|
import expo.modules.plugin.configuration.HttpHeaderMavenCredentials
|
|
6
6
|
import expo.modules.plugin.configuration.MavenCredentials
|
|
7
|
+
import expo.modules.plugin.utils.Env
|
|
7
8
|
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
|
|
8
9
|
import org.gradle.api.credentials.AwsCredentials
|
|
9
10
|
import org.gradle.api.credentials.HttpHeaderCredentials
|
|
@@ -35,26 +36,40 @@ internal fun MavenArtifactRepository.applyCredentials(mavenCredentials: MavenCre
|
|
|
35
36
|
is BasicMavenCredentials -> {
|
|
36
37
|
val (username, password) = mavenCredentials
|
|
37
38
|
credentials { credentials ->
|
|
38
|
-
credentials.username = username
|
|
39
|
-
credentials.password = password
|
|
39
|
+
credentials.username = resolveEnvVar(username)
|
|
40
|
+
credentials.password = resolveEnvVar(password)
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
is HttpHeaderMavenCredentials -> {
|
|
44
45
|
val (name, value) = mavenCredentials
|
|
45
46
|
credentials(HttpHeaderCredentials::class.java) { credentials ->
|
|
46
|
-
credentials.name = name
|
|
47
|
-
credentials.value = value
|
|
47
|
+
credentials.name = resolveEnvVar(name)
|
|
48
|
+
credentials.value = resolveEnvVar(value)
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
is AWSMavenCredentials -> {
|
|
52
53
|
val (accessKey, secretKey, sessionToken) = mavenCredentials
|
|
53
54
|
credentials(AwsCredentials::class.java) { credentials ->
|
|
54
|
-
credentials.accessKey = accessKey
|
|
55
|
-
credentials.secretKey = secretKey
|
|
56
|
-
credentials.sessionToken = sessionToken
|
|
55
|
+
credentials.accessKey = resolveEnvVar(accessKey)
|
|
56
|
+
credentials.secretKey = resolveEnvVar(secretKey)
|
|
57
|
+
credentials.sessionToken = sessionToken?.let { resolveEnvVar(it) }
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
}
|
|
62
|
+
|
|
63
|
+
private val ENV_REGEX = """System\.getenv\(['"]([A-Za-z0-9_]+)['"]\)""".toRegex()
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Utility function to substitute environment variables in strings.
|
|
67
|
+
* Supports patterns like System.getEnv('VAR_NAME') or System.getEnv("VAR_NAME")
|
|
68
|
+
*/
|
|
69
|
+
private fun resolveEnvVar(input: String): String {
|
|
70
|
+
return ENV_REGEX.replace(input) { match ->
|
|
71
|
+
val name = match.groupValues[1]
|
|
72
|
+
// Return original if env var not found
|
|
73
|
+
Env.getProcessEnv(name) ?: match.value
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
package expo.modules.plugin
|
|
2
|
+
|
|
3
|
+
import com.google.common.truth.Truth
|
|
4
|
+
import expo.modules.plugin.configuration.AWSMavenCredentials
|
|
5
|
+
import expo.modules.plugin.configuration.BasicMavenCredentials
|
|
6
|
+
import expo.modules.plugin.configuration.HttpHeaderMavenCredentials
|
|
7
|
+
import expo.modules.plugin.gradle.applyCredentials
|
|
8
|
+
import expo.modules.plugin.utils.Env
|
|
9
|
+
import io.mockk.every
|
|
10
|
+
import io.mockk.mockkObject
|
|
11
|
+
import io.mockk.unmockkObject
|
|
12
|
+
import org.gradle.api.credentials.AwsCredentials
|
|
13
|
+
import org.gradle.api.credentials.HttpHeaderCredentials
|
|
14
|
+
import org.gradle.testfixtures.ProjectBuilder
|
|
15
|
+
import org.junit.After
|
|
16
|
+
import org.junit.Before
|
|
17
|
+
import org.junit.Test
|
|
18
|
+
import java.net.URI
|
|
19
|
+
|
|
20
|
+
class MavenArtifactRepositoryExtensionTest {
|
|
21
|
+
@Before
|
|
22
|
+
fun setUp() {
|
|
23
|
+
mockkObject(Env)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@After
|
|
27
|
+
fun tearDown() {
|
|
28
|
+
unmockkObject(Env)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Test
|
|
32
|
+
fun `should apply credentials from string values`() {
|
|
33
|
+
val project = ProjectBuilder.builder().build()
|
|
34
|
+
val mavenRepo = project.repositories.maven {
|
|
35
|
+
it.url = URI("auth.maven.test")
|
|
36
|
+
it.applyCredentials(BasicMavenCredentials("username", "password"))
|
|
37
|
+
}
|
|
38
|
+
Truth.assertThat(mavenRepo.credentials.username).isEqualTo("username")
|
|
39
|
+
Truth.assertThat(mavenRepo.credentials.password).isEqualTo("password")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Test
|
|
43
|
+
fun `should apply credentials from environment variables`() {
|
|
44
|
+
val project = ProjectBuilder.builder().build()
|
|
45
|
+
|
|
46
|
+
every { Env.getProcessEnv("envUsername") } returns "basic1"
|
|
47
|
+
every { Env.getProcessEnv("envPassword") } returns "basic2"
|
|
48
|
+
val mavenRepoBasic = project.repositories.maven {
|
|
49
|
+
it.url = URI("auth.maven.test")
|
|
50
|
+
it.applyCredentials(BasicMavenCredentials("System.getenv('envUsername')", "System.getenv(\"envPassword\")"))
|
|
51
|
+
}
|
|
52
|
+
Truth.assertThat(mavenRepoBasic.credentials.username).isEqualTo("basic1")
|
|
53
|
+
Truth.assertThat(mavenRepoBasic.credentials.password).isEqualTo("basic2")
|
|
54
|
+
|
|
55
|
+
every { Env.getProcessEnv("envName") } returns "httpHeader1"
|
|
56
|
+
every { Env.getProcessEnv("envValue") } returns "httpHeader2"
|
|
57
|
+
val mavenRepoHttpHeader = project.repositories.maven {
|
|
58
|
+
it.url = URI("auth.maven.test")
|
|
59
|
+
it.applyCredentials(HttpHeaderMavenCredentials("System.getenv('envName')", "System.getenv(\"envValue\")"))
|
|
60
|
+
}
|
|
61
|
+
val httpHeaderCredentials = mavenRepoHttpHeader.getCredentials(HttpHeaderCredentials::class.java)
|
|
62
|
+
Truth.assertThat(httpHeaderCredentials.name).isEqualTo("httpHeader1")
|
|
63
|
+
Truth.assertThat(httpHeaderCredentials.value).isEqualTo("httpHeader2")
|
|
64
|
+
|
|
65
|
+
every { Env.getProcessEnv("envAccessKey") } returns "aws1"
|
|
66
|
+
every { Env.getProcessEnv("envSecretKey") } returns "aws2"
|
|
67
|
+
every { Env.getProcessEnv("envSessionToken") } returns "aws3"
|
|
68
|
+
val mavenRepoAws = project.repositories.maven {
|
|
69
|
+
it.url = URI("auth.maven.test")
|
|
70
|
+
it.applyCredentials(AWSMavenCredentials(
|
|
71
|
+
"System.getenv('envAccessKey')",
|
|
72
|
+
"System.getenv(\"envSecretKey\")",
|
|
73
|
+
"System.getenv('envSessionToken')"))
|
|
74
|
+
}
|
|
75
|
+
val awsCredentials = mavenRepoAws.getCredentials(AwsCredentials::class.java)
|
|
76
|
+
Truth.assertThat(awsCredentials.accessKey).isEqualTo("aws1")
|
|
77
|
+
Truth.assertThat(awsCredentials.secretKey).isEqualTo("aws2")
|
|
78
|
+
Truth.assertThat(awsCredentials.sessionToken).isEqualTo("aws3")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Test
|
|
82
|
+
fun `should fallback to original inputs if environment variables not found`() {
|
|
83
|
+
val project = ProjectBuilder.builder().build()
|
|
84
|
+
|
|
85
|
+
val mavenRepoBasic = project.repositories.maven {
|
|
86
|
+
it.url = URI("auth.maven.test")
|
|
87
|
+
it.applyCredentials(BasicMavenCredentials("System.getenv('envUsername')", "System.getenv(\"envPassword\")"))
|
|
88
|
+
}
|
|
89
|
+
Truth.assertThat(mavenRepoBasic.credentials.username).isEqualTo("System.getenv('envUsername')")
|
|
90
|
+
Truth.assertThat(mavenRepoBasic.credentials.password).isEqualTo("System.getenv(\"envPassword\")")
|
|
91
|
+
|
|
92
|
+
val mavenRepoHttpHeader = project.repositories.maven {
|
|
93
|
+
it.url = URI("auth.maven.test")
|
|
94
|
+
it.applyCredentials(HttpHeaderMavenCredentials("System.getenv('envName')", "System.getenv(\"envValue\")"))
|
|
95
|
+
}
|
|
96
|
+
val httpHeaderCredentials = mavenRepoHttpHeader.getCredentials(HttpHeaderCredentials::class.java)
|
|
97
|
+
Truth.assertThat(httpHeaderCredentials.name).isEqualTo("System.getenv('envName')")
|
|
98
|
+
Truth.assertThat(httpHeaderCredentials.value).isEqualTo("System.getenv(\"envValue\")")
|
|
99
|
+
|
|
100
|
+
val mavenRepoAws = project.repositories.maven {
|
|
101
|
+
it.url = URI("auth.maven.test")
|
|
102
|
+
it.applyCredentials(AWSMavenCredentials(
|
|
103
|
+
"System.getenv('envAccessKey')",
|
|
104
|
+
"System.getenv(\"envSecretKey\")",
|
|
105
|
+
"System.getenv('envSessionToken')"))
|
|
106
|
+
}
|
|
107
|
+
val awsCredentials = mavenRepoAws.getCredentials(AwsCredentials::class.java)
|
|
108
|
+
Truth.assertThat(awsCredentials.accessKey).isEqualTo("System.getenv('envAccessKey')")
|
|
109
|
+
Truth.assertThat(awsCredentials.secretKey).isEqualTo("System.getenv(\"envSecretKey\")")
|
|
110
|
+
Truth.assertThat(awsCredentials.sessionToken).isEqualTo("System.getenv('envSessionToken')")
|
|
111
|
+
}
|
|
112
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-autolinking",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.13",
|
|
4
4
|
"description": "Scripts that autolink Expo modules.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"homepage": "https://github.com/expo/expo/tree/main/packages/expo-modules-autolinking#readme",
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"expo-module-scripts": "~4.1.
|
|
37
|
+
"expo-module-scripts": "~4.1.8",
|
|
38
38
|
"minimatch": "^9.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"require-from-string": "^2.0.2",
|
|
47
47
|
"resolve-from": "^5.0.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "9731a6191dcab84e9c3a24492bbe70c56d6f5cc3"
|
|
50
50
|
}
|