Skip to content

Commit 1883f11

Browse files
committed
feat: make new config nullable
1 parent dbd2ad3 commit 1883f11

File tree

5 files changed

+31
-28
lines changed

5 files changed

+31
-28
lines changed

docs/dependencies.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ type AndroidDependencyParams = {
5555
packageImportPath?: string;
5656
packageInstance?: string;
5757
buildTypes?: string[];
58-
libraryName?: string;
59-
componentDescriptors?: string[];
60-
androidMkPath?: string;
58+
libraryName?: string | null;
59+
componentDescriptors?: string[] | null;
60+
androidMkPath?: string | null;
6161
};
6262
```
6363

docs/platforms.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ type AndroidDependencyConfig = {
118118
packageInstance: string;
119119
dependencyConfiguration?: string;
120120
buildTypes: string[];
121-
libraryName?: string;
122-
componentDescriptors?: string[];
123-
androidMkPath?: string;
121+
libraryName?: string | null;
122+
componentDescriptors?: string[] | null;
123+
androidMkPath?: string | null;
124124
};
125125
```

packages/cli-config/src/schema.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ export const dependencyConfig = t
8383
packageInstance: t.string(),
8484
dependencyConfiguration: t.string(),
8585
buildTypes: t.array().items(t.string()).default([]),
86-
libraryName: t.string(),
87-
componentDescriptors: t.array().items(t.string()),
88-
androidMkPath: t.string(),
86+
libraryName: t.string().allow(null),
87+
componentDescriptors: t.array().items(t.string()).allow(null),
88+
androidMkPath: t.string().allow(null),
8989
})
9090
.default({}),
9191
})
@@ -134,9 +134,9 @@ export const projectConfig = t
134134
packageInstance: t.string(),
135135
dependencyConfiguration: t.string(),
136136
buildTypes: t.array().items(t.string()).default([]),
137-
libraryName: t.string(),
138-
componentDescriptors: t.array().items(t.string()),
139-
androidMkPath: t.string(),
137+
libraryName: t.string().allow(null),
138+
componentDescriptors: t.array().items(t.string()).allow(null),
139+
androidMkPath: t.string().allow(null),
140140
})
141141
.allow(null),
142142
}),

packages/cli-types/src/android.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ export type AndroidDependencyConfig = {
1919
packageInstance: string;
2020
dependencyConfiguration?: string;
2121
buildTypes: string[];
22-
libraryName?: string;
23-
componentDescriptors?: string[];
24-
androidMkPath?: string;
22+
libraryName?: string | null;
23+
componentDescriptors?: string[] | null;
24+
androidMkPath?: string | null;
2525
};
2626

2727
export type AndroidDependencyParams = {
@@ -32,7 +32,7 @@ export type AndroidDependencyParams = {
3232
packageImportPath?: string;
3333
packageInstance?: string;
3434
buildTypes?: string[];
35-
libraryName?: string;
36-
componentDescriptors?: string[];
37-
androidMkPath?: string;
35+
libraryName?: string | null;
36+
componentDescriptors?: string[] | null;
37+
androidMkPath?: string | null;
3838
};

packages/platform-android/native_modules.gradle

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ class ReactNativeModules {
257257

258258
if (packages.size() > 0) {
259259
libraryIncludes = packages.collect {
260-
"include ${it.androidMkPath}"
261-
}.join('\n')
260+
it.androidMkPath ? "include ${it.androidMkPath}" : null
261+
}.minus(null).join('\n')
262262
libraryModules = packages.collect {
263-
"${codegenLibPrefix}${it.libraryName}"
264-
}.join(" \\\n ")
263+
it.libraryName ? "${codegenLibPrefix}${it.libraryName}" : null
264+
}.minus(null).join(" \\\n ")
265265
}
266266

267267
String generatedFileContents = generatedFileContentsTemplate
@@ -285,21 +285,24 @@ class ReactNativeModules {
285285

286286
if (packages.size() > 0) {
287287
rncliCppIncludes = packages.collect {
288+
if (!it.libraryName) {
289+
return null
290+
}
288291
def result = "#include <${it.libraryName}.h>"
289-
if (it.componentDescriptors.size() > 0) {
292+
if (it.componentDescriptors && it.componentDescriptors.size() > 0) {
290293
result += "\n#include <${codegenReactComponentsDir}/${it.libraryName}/${codegenComponentDescriptorsHeaderFile}>"
291294
}
292295
result
293-
}.join('\n')
296+
}.minus(null).join('\n')
294297
rncliCppModuleProviders = packages.collect {
295-
""" auto module_${it.libraryName} = ${it.libraryName}_ModuleProvider(moduleName, params);
298+
it.libraryName ? """ auto module_${it.libraryName} = ${it.libraryName}_ModuleProvider(moduleName, params);
296299
if (module_${it.libraryName} != nullptr) {
297300
return module_${it.libraryName};
298-
}"""
299-
}.join("\n")
301+
}""" : null
302+
}.minus(null).join("\n")
300303
rncliCppComponentDescriptors = packages.collect {
301304
def result = ""
302-
if (it.componentDescriptors.size() > 0) {
305+
if (it.componentDescriptors && it.componentDescriptors.size() > 0) {
303306
result += it.componentDescriptors.collect {
304307
" providerRegistry->add(concreteComponentDescriptorProvider<${it}>());"
305308
}.join('\n')

0 commit comments

Comments
 (0)