@norcy/react-native-toolkit 0.1.152 → 0.1.154

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.
@@ -1,42 +1,56 @@
1
1
  /**
2
2
  * Norcy Toolkit - Common Android Build Configuration
3
- *
4
3
  * 提供通用的 Android 构建配置和依赖管理函数
5
- * 包含 React Native 基础依赖、AndroidX、友盟统计等
6
4
  */
7
5
 
8
- /**
9
- * 应用通用依赖
10
- *
11
- * @param targetProject 当前项目
12
- * @param enableHermes 是否启用 Hermes 引擎
13
- * @param jscFlavor JSC 的 flavor (如果不使用 Hermes)
14
- */
6
+ ext.applyNorcyDefaultConfig = { targetProject, options = [:] ->
7
+ def enableSeparateBuildPerCPUArchitecture = options.enableSeparateBuildPerCPUArchitecture ?: false
8
+ def abiFiltersList = options.abiFilters ?: ["armeabi-v7a", "arm64-v8a"]
9
+
10
+ targetProject.android {
11
+ defaultConfig {
12
+ multiDexEnabled true
13
+ ndk {
14
+ abiFilters(*abiFiltersList)
15
+ }
16
+ }
17
+
18
+ splits {
19
+ abi {
20
+ reset()
21
+ enable enableSeparateBuildPerCPUArchitecture
22
+ universalApk true
23
+ include(*abiFiltersList)
24
+ }
25
+ }
26
+
27
+ signingConfigs {
28
+ debug {
29
+ storeFile targetProject.file('debug.keystore')
30
+ storePassword 'android'
31
+ keyAlias 'androiddebugkey'
32
+ keyPassword 'android'
33
+ }
34
+ }
35
+ }
36
+ }
37
+
15
38
  ext.applyNorcyCommonDependencies = { targetProject, enableHermes, jscFlavor ->
16
39
  targetProject.dependencies {
17
- // 基础依赖
18
40
  implementation fileTree(dir: "libs", include: ["*.jar"])
19
41
 
20
- // React Native 核心
21
42
  //noinspection GradleDynamicVersion
22
- implementation "com.facebook.react:react-native:0.62.2.9.1" // From node_modules
23
-
24
- // AndroidX
43
+ implementation "com.facebook.react:react-native:0.62.2.9.1"
25
44
  implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
26
-
27
- // MultiDex
28
45
  implementation 'com.android.support:multidex:2.0.1'
29
46
 
30
- // 友盟统计
31
- implementation 'com.umeng.umsdk:common:9.6.3' // 必选
32
- implementation 'com.umeng.umsdk:asms:1.8.0' // 必选
33
- implementation 'com.umeng.umsdk:uyumao:1.1.2' // 高级运营分析功能依赖库
47
+ implementation 'com.umeng.umsdk:common:9.6.3'
48
+ implementation 'com.umeng.umsdk:asms:1.8.0'
49
+ implementation 'com.umeng.umsdk:uyumao:1.1.2'
34
50
 
35
- // Toolkit 相关的通用项目依赖
36
51
  implementation targetProject.project(':react-native-splash-screen')
37
52
  implementation targetProject.project(':react-native-blob-util')
38
53
 
39
- // JavaScript 引擎依赖
40
54
  if (enableHermes) {
41
55
  def hermesPath = "../../node_modules/hermes-engine/android/"
42
56
  debugImplementation files(hermesPath + "hermes-debug.aar")
@@ -47,21 +61,30 @@ ext.applyNorcyCommonDependencies = { targetProject, enableHermes, jscFlavor ->
47
61
  }
48
62
  }
49
63
 
50
- /**
51
- * 应用通用的 Android 配置
52
- * 包括 compileOptions, packagingOptions, lintOptions 等
53
- *
54
- * @param targetProject 当前项目
55
- */
64
+ ext.applyNorcyBuildTypes = { targetProject, options = [:] ->
65
+ def enableProguardInReleaseBuilds = options.enableProguardInReleaseBuilds ?: false
66
+
67
+ targetProject.android {
68
+ buildTypes {
69
+ debug {
70
+ signingConfig signingConfigs.debug
71
+ }
72
+ release {
73
+ minifyEnabled enableProguardInReleaseBuilds
74
+ proguardFiles targetProject.android.getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
75
+ crunchPngs false
76
+ }
77
+ }
78
+ }
79
+ }
80
+
56
81
  ext.applyNorcyCommonAndroidConfig = { targetProject ->
57
82
  targetProject.android {
58
- // Java 编译选项
59
83
  compileOptions {
60
84
  sourceCompatibility JavaVersion.VERSION_1_8
61
85
  targetCompatibility JavaVersion.VERSION_1_8
62
86
  }
63
87
 
64
- // 解决 libc++ 冲突
65
88
  packagingOptions {
66
89
  pickFirst "lib/armeabi-v7a/libc++_shared.so"
67
90
  pickFirst "lib/arm64-v8a/libc++_shared.so"
@@ -69,17 +92,15 @@ ext.applyNorcyCommonAndroidConfig = { targetProject ->
69
92
  pickFirst "lib/x86_64/libc++_shared.so"
70
93
  }
71
94
 
72
- // Lint 配置
73
95
  lintOptions {
74
96
  checkReleaseBuilds false
75
97
  }
76
98
 
77
- // 为不同 ABI 设置不同的版本码
78
99
  applicationVariants.all { variant ->
79
100
  variant.outputs.each { output ->
80
101
  def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
81
- def abi = output.getFilter("ABI") // OutputFile.ABI 的值就是字符串 "ABI"
82
- if (abi != null) { // null for the universal-debug, universal-release variants
102
+ def abi = output.getFilter("ABI")
103
+ if (abi != null) {
83
104
  output.versionCodeOverride =
84
105
  versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
85
106
  }
@@ -87,10 +108,24 @@ ext.applyNorcyCommonAndroidConfig = { targetProject ->
87
108
  }
88
109
  }
89
110
 
90
- // 添加 BUCK 支持的 task
91
111
  targetProject.tasks.create('copyDownloadableDepsToLibs', Copy) {
92
112
  from targetProject.configurations.compile
93
113
  into 'libs'
94
114
  }
95
115
  }
96
116
 
117
+ ext.applyNorcyCommonPlugins = { targetProject, options = [:] ->
118
+ def sentryPropertiesPath = options.sentryPropertiesPath ?: "../sentry.properties"
119
+
120
+ targetProject.apply from: targetProject.file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
121
+ targetProject.applyNativeModulesAppBuildGradle(targetProject)
122
+
123
+ targetProject.apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
124
+ targetProject.apply from: "../../node_modules/@sentry/react-native/sentry.gradle"
125
+
126
+ targetProject.ext.sentryCli = [
127
+ logLevel: "debug",
128
+ sentryProperties: sentryPropertiesPath
129
+ ]
130
+ }
131
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@norcy/react-native-toolkit",
3
- "version": "0.1.152",
3
+ "version": "0.1.154",
4
4
  "description": "My Toolkit",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",