-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(autolinking)!: prioritise files with
*Package.java|*Package.kt
…
… in `getPackageClassName` (#2384) * perf(autolinking)!: prioritise files with `*Package.java|*Package.kt` in `getPackageClassName` * fix: get all files when getting files inside project * test: add tests
- Loading branch information
1 parent
9c813dc
commit 1754348
Showing
6 changed files
with
113 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/cli-platform-android/src/config/__fixtures__/files/React.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.some.example; | ||
|
||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.uimanager.ViewManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class SomeExampleJavaPackage implements ReactPackage { | ||
|
||
@Override | ||
public List<NativeModule> createNativeModules( | ||
ReactApplicationContext reactContext) { | ||
List<NativeModule> modules = new ArrayList<>(); | ||
modules.add(new SomeExampleModule(reactContext)); | ||
return modules; | ||
} | ||
|
||
@Override | ||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | ||
return Collections.emptyList(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/cli-platform-android/src/config/__fixtures__/files/React.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.some.example; | ||
|
||
import android.view.View | ||
import com.facebook.react.ReactPackage | ||
import com.facebook.react.bridge.NativeModule | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.uimanager.ReactShadowNode | ||
import com.facebook.react.uimanager.ViewManager | ||
import java.util.* | ||
|
||
class SomeExampleKotlinPackage : ReactPackage { | ||
|
||
override fun createNativeModules(reactContext: ReactApplicationContext): MutableList<NativeModule> | ||
= mutableListOf(MaterialPaletteModule(reactContext)) | ||
|
||
override fun createViewManagers(reactContext: ReactApplicationContext?): | ||
MutableList<ViewManager<View, ReactShadowNode>> = Collections.emptyList() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cli-platform-android/src/config/isProjectUsingKotlin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import {getMainActivityFiles} from './findPackageClassName'; | ||
|
||
export default function isProjectUsingKotlin(sourceDir: string): boolean { | ||
const mainActivityFiles = getMainActivityFiles(sourceDir); | ||
const mainActivityFiles = getMainActivityFiles(sourceDir, false); | ||
|
||
return mainActivityFiles.some((file) => file.endsWith('.kt')); | ||
} |