@react-native/gradle-plugin 0.76.0-nightly-20240910-84f2d2512 → 0.76.0-rc.1
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/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/package.json +1 -1
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GeneratePackageListTask.kt +11 -2
- package/shared/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt +17 -2
- package/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt +48 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip
|
|
4
4
|
networkTimeout=10000
|
|
5
5
|
validateDistributionUrl=true
|
|
6
6
|
zipStoreBase=GRADLE_USER_HOME
|
package/package.json
CHANGED
|
@@ -30,10 +30,19 @@ abstract class GeneratePackageListTask : DefaultTask() {
|
|
|
30
30
|
|
|
31
31
|
@TaskAction
|
|
32
32
|
fun taskAction() {
|
|
33
|
-
val model =
|
|
33
|
+
val model =
|
|
34
|
+
JsonUtils.fromAutolinkingConfigJson(autolinkInputFile.get().asFile)
|
|
35
|
+
?: error(
|
|
36
|
+
"""
|
|
37
|
+
RNGP - Autolinking: Could not parse autolinking config file:
|
|
38
|
+
${autolinkInputFile.get().asFile.absolutePath}
|
|
39
|
+
|
|
40
|
+
The file is either missing or not containing valid JSON so the build won't succeed.
|
|
41
|
+
"""
|
|
42
|
+
.trimIndent())
|
|
34
43
|
|
|
35
44
|
val packageName =
|
|
36
|
-
model
|
|
45
|
+
model.project?.android?.packageName
|
|
37
46
|
?: error(
|
|
38
47
|
"RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field.")
|
|
39
48
|
|
|
@@ -21,8 +21,23 @@ object JsonUtils {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
fun fromAutolinkingConfigJson(input: File): ModelAutolinkingConfigJson? =
|
|
24
|
-
input.bufferedReader().use {
|
|
25
|
-
runCatching {
|
|
24
|
+
input.bufferedReader().use { reader ->
|
|
25
|
+
runCatching {
|
|
26
|
+
// We sanitize the output of the `config` command as it could contain debug logs
|
|
27
|
+
// such as:
|
|
28
|
+
//
|
|
29
|
+
// > AwesomeProject@0.0.1 npx
|
|
30
|
+
// > rnc-cli config
|
|
31
|
+
//
|
|
32
|
+
// which will render the JSON invalid.
|
|
33
|
+
val content =
|
|
34
|
+
reader
|
|
35
|
+
.readLines()
|
|
36
|
+
.filterNot { line -> line.startsWith(">") }
|
|
37
|
+
.joinToString("\n")
|
|
38
|
+
.trim()
|
|
39
|
+
gsonConverter.fromJson(content, ModelAutolinkingConfigJson::class.java)
|
|
40
|
+
}
|
|
26
41
|
.getOrNull()
|
|
27
42
|
}
|
|
28
43
|
}
|
|
@@ -186,6 +186,54 @@ class JsonUtilsTest {
|
|
|
186
186
|
assertThat("implementation").isEqualTo(parsed.project!!.android!!.dependencyConfiguration)
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
+
@Test
|
|
190
|
+
fun fromAutolinkingConfigJson_withInfoLogs_sanitizeAndParseIt() {
|
|
191
|
+
@Suppress("JsonStandardCompliance")
|
|
192
|
+
val validJson =
|
|
193
|
+
createJsonFile(
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
> AwesomeProject@0.0.1 npx
|
|
197
|
+
> rnc-cli config
|
|
198
|
+
|
|
199
|
+
{
|
|
200
|
+
"reactNativeVersion": "1000.0.0",
|
|
201
|
+
"project": {
|
|
202
|
+
"ios": {
|
|
203
|
+
"sourceDir": "./packages/rn-tester",
|
|
204
|
+
"xcodeProject": {
|
|
205
|
+
"name": "RNTesterPods.xcworkspace",
|
|
206
|
+
"isWorkspace": true
|
|
207
|
+
},
|
|
208
|
+
"automaticPodsInstallation": false
|
|
209
|
+
},
|
|
210
|
+
"android": {
|
|
211
|
+
"sourceDir": "./packages/rn-tester",
|
|
212
|
+
"appName": "RN-Tester",
|
|
213
|
+
"packageName": "com.facebook.react.uiapp",
|
|
214
|
+
"applicationId": "com.facebook.react.uiapp",
|
|
215
|
+
"mainActivity": ".RNTesterActivity",
|
|
216
|
+
"watchModeCommandParams": [
|
|
217
|
+
"--mode HermesDebug"
|
|
218
|
+
],
|
|
219
|
+
"dependencyConfiguration": "implementation"
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
"""
|
|
224
|
+
.trimIndent())
|
|
225
|
+
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
|
|
226
|
+
|
|
227
|
+
assertThat("./packages/rn-tester").isEqualTo(parsed.project!!.android!!.sourceDir)
|
|
228
|
+
assertThat("RN-Tester").isEqualTo(parsed.project!!.android!!.appName)
|
|
229
|
+
assertThat("com.facebook.react.uiapp").isEqualTo(parsed.project!!.android!!.packageName)
|
|
230
|
+
assertThat("com.facebook.react.uiapp").isEqualTo(parsed.project!!.android!!.applicationId)
|
|
231
|
+
assertThat(".RNTesterActivity").isEqualTo(parsed.project!!.android!!.mainActivity)
|
|
232
|
+
assertThat("--mode HermesDebug")
|
|
233
|
+
.isEqualTo(parsed.project!!.android!!.watchModeCommandParams!![0])
|
|
234
|
+
assertThat("implementation").isEqualTo(parsed.project!!.android!!.dependencyConfiguration)
|
|
235
|
+
}
|
|
236
|
+
|
|
189
237
|
@Test
|
|
190
238
|
fun fromAutolinkingConfigJson_withDependenciesSpecified_canParseIt() {
|
|
191
239
|
val validJson =
|