@gfean/react-native-bundle-drop 0.4.3 → 0.4.4
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/BundleDropExpo.podspec +21 -0
- package/README.md +250 -124
- package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +33 -3
- package/app.plugin.js +3 -0
- package/expo/android/build.gradle +159 -0
- package/expo/android/src/main/AndroidManifest.xml +1 -0
- package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoConfiguration.kt +35 -0
- package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoIdentityModule.kt +30 -0
- package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoPackage.kt +29 -0
- package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoReactNativeHostHandler.kt +16 -0
- package/expo/bundle-drop-expo-gradle-plugin/build.gradle +31 -0
- package/expo/bundle-drop-expo-gradle-plugin/src/main/groovy/com/bundledrop/gradle/BundleDropExpoPlugin.groovy +83 -0
- package/expo/bundle-drop-expo-gradle-plugin/src/main/groovy/com/bundledrop/gradle/GenerateBundleDropBuildIdentityTask.groovy +57 -0
- package/expo/ios/Sources/BundleDropExpoIdentity.m +31 -0
- package/expo/ios/Sources/BundleDropExpoReactDelegateHandler.swift +24 -0
- package/expo-module.config.json +19 -0
- package/ios/BundleDropLocator.swift +7 -1
- package/lib/CLI/cli.d.ts +1 -2
- package/lib/CLI/cli.js +116 -14
- package/lib/CLI/scripts/aipowered/apply-setup-plan.d.ts +12 -0
- package/lib/CLI/scripts/aipowered/apply-setup-plan.js +55 -0
- package/lib/CLI/scripts/aipowered/backend-client.d.ts +6 -1
- package/lib/CLI/scripts/aipowered/backend-client.js +25 -2
- package/lib/CLI/scripts/aipowered/init-project-config.d.ts +17 -0
- package/lib/CLI/scripts/aipowered/init-project-config.js +400 -0
- package/lib/CLI/scripts/aipowered/scanner.d.ts +10 -1
- package/lib/CLI/scripts/aipowered/scanner.js +252 -5
- package/lib/CLI/scripts/aipowered/types.d.ts +39 -0
- package/lib/CLI/scripts/aipowered/validate-plan.d.ts +12 -0
- package/lib/CLI/scripts/aipowered/validate-plan.js +76 -1
- package/lib/CLI/scripts/doctor.d.ts +17 -0
- package/lib/CLI/scripts/doctor.js +412 -0
- package/lib/CLI/scripts/expo/build-receipt.d.ts +26 -0
- package/lib/CLI/scripts/expo/build-receipt.js +223 -0
- package/lib/CLI/scripts/expo/configure-expo.d.ts +28 -0
- package/lib/CLI/scripts/expo/configure-expo.js +268 -0
- package/lib/CLI/scripts/expo/eas-build-proof.d.ts +22 -0
- package/lib/CLI/scripts/expo/eas-build-proof.js +116 -0
- package/lib/CLI/scripts/expo/package-manager.d.ts +11 -0
- package/lib/CLI/scripts/expo/package-manager.js +84 -0
- package/lib/CLI/scripts/expo/write-build-receipt.d.ts +25 -0
- package/lib/CLI/scripts/expo/write-build-receipt.js +325 -0
- package/lib/CLI/scripts/expo/write-eas-build-receipt.d.ts +8 -0
- package/lib/CLI/scripts/expo/write-eas-build-receipt.js +71 -0
- package/lib/CLI/scripts/init-config.d.ts +18 -1
- package/lib/CLI/scripts/init-config.js +29 -8
- package/lib/CLI/scripts/init-metro-config.d.ts +7 -0
- package/lib/CLI/scripts/init-metro-config.js +28 -8
- package/lib/CLI/scripts/login-cli.js +17 -3
- package/lib/CLI/scripts/post-init.d.ts +6 -1
- package/lib/CLI/scripts/post-init.js +6 -33
- package/lib/CLI/scripts/upload-cli.d.ts +1 -0
- package/lib/CLI/scripts/upload-cli.js +106 -36
- package/lib/context.d.ts +0 -2
- package/lib/context.js +18 -2
- package/lib/expo/buildIdentity.d.ts +15 -0
- package/lib/expo/buildIdentity.js +201 -0
- package/lib/expo/buildReceipt.d.ts +42 -0
- package/lib/expo/buildReceipt.js +272 -0
- package/lib/expo/config.d.ts +7 -0
- package/lib/expo/config.js +43 -0
- package/lib/expo/configCache.d.ts +1 -0
- package/lib/expo/configCache.js +20 -0
- package/lib/expo/errors.d.ts +6 -0
- package/lib/expo/errors.js +11 -0
- package/lib/expo/expoUpdatesOwnership.d.ts +13 -0
- package/lib/expo/expoUpdatesOwnership.js +22 -0
- package/lib/expo/exportExpoProject.d.ts +21 -0
- package/lib/expo/exportExpoProject.js +125 -0
- package/lib/expo/exportValidation.d.ts +11 -0
- package/lib/expo/exportValidation.js +115 -0
- package/lib/expo/index.d.ts +18 -0
- package/lib/expo/index.js +25 -0
- package/lib/expo/localModules.d.ts +4 -0
- package/lib/expo/localModules.js +51 -0
- package/lib/expo/nativeIdentity.d.ts +1 -0
- package/lib/expo/nativeIdentity.js +17 -0
- package/lib/expo/projectType.d.ts +7 -0
- package/lib/expo/projectType.js +200 -0
- package/lib/expo/runtimeVersion.d.ts +13 -0
- package/lib/expo/runtimeVersion.js +45 -0
- package/lib/expo/types.d.ts +15 -0
- package/lib/expo/types.js +2 -0
- package/lib/fs/userProperties.d.ts +0 -2
- package/lib/fs/userProperties.js +0 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -2
- package/lib/loadConfig.d.ts +15 -7
- package/lib/loadConfig.js +2 -19
- package/lib/metro.d.ts +17 -0
- package/lib/metro.js +57 -0
- package/lib/native/bundleDropNative.d.ts +2 -0
- package/lib/native/bundleDropNative.js +9 -1
- package/lib/runtime/service.js +12 -1
- package/lib/scripts/bundle.d.ts +2 -2
- package/lib/scripts/bundle.js +10 -97
- package/lib/scripts/canonicalArtifact.d.ts +30 -0
- package/lib/scripts/canonicalArtifact.js +212 -0
- package/lib/scripts/exportProject.d.ts +41 -0
- package/lib/scripts/exportProject.js +82 -0
- package/package.json +51 -46
- package/plugin/constants.js +9 -0
- package/plugin/expoUpdates.js +131 -0
- package/plugin/index.js +11 -0
- package/plugin/markers.js +31 -0
- package/plugin/withBundleDrop.js +36 -0
- package/plugin/xcodeBuildPhase.js +77 -0
- package/react-native.config.js +20 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import groovy.json.JsonSlurper
|
|
2
|
+
import javax.inject.Inject
|
|
3
|
+
import org.gradle.process.ExecOperations
|
|
4
|
+
|
|
5
|
+
abstract class BundleDropCommandExecutor {
|
|
6
|
+
@Inject
|
|
7
|
+
abstract ExecOperations getExecOperations()
|
|
8
|
+
|
|
9
|
+
void execute(File workingDirectory, String executable, List<?> arguments) {
|
|
10
|
+
execOperations.exec { spec ->
|
|
11
|
+
spec.workingDir workingDirectory
|
|
12
|
+
spec.executable executable
|
|
13
|
+
spec.args arguments
|
|
14
|
+
}.assertNormalExitValue()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
buildscript {
|
|
19
|
+
repositories {
|
|
20
|
+
google()
|
|
21
|
+
mavenCentral()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
apply plugin: "com.android.library"
|
|
26
|
+
apply plugin: "expo-module-gradle-plugin"
|
|
27
|
+
|
|
28
|
+
def packageJson = new JsonSlurper().parseText(file("../../package.json").text)
|
|
29
|
+
def bundleDropCoreDirectory = file("../../android").canonicalFile
|
|
30
|
+
def bundleDropCoreProjects = rootProject.allprojects.findAll { candidate ->
|
|
31
|
+
candidate.projectDir.canonicalFile == bundleDropCoreDirectory
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (bundleDropCoreProjects.size() != 1) {
|
|
35
|
+
throw new GradleException(
|
|
36
|
+
"Bundle Drop's Expo adapter requires exactly one core Android project autolinked from ${bundleDropCoreDirectory}; " +
|
|
37
|
+
"found ${bundleDropCoreProjects.size()}. " +
|
|
38
|
+
"Verify react-native.config.js is present in the installed package and rerun Expo prebuild."
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
def bundleDropCoreProject = bundleDropCoreProjects.first()
|
|
42
|
+
|
|
43
|
+
group = "com.bundledrop"
|
|
44
|
+
version = packageJson.nativeVersion ?: packageJson.version
|
|
45
|
+
|
|
46
|
+
android {
|
|
47
|
+
namespace "com.bundledrop.expo"
|
|
48
|
+
|
|
49
|
+
defaultConfig {
|
|
50
|
+
minSdkVersion 24
|
|
51
|
+
versionName version.toString()
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
dependencies {
|
|
56
|
+
implementation project(path: bundleDropCoreProject.path)
|
|
57
|
+
implementation "com.facebook.react:react-android"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
def bundleDropReceiptWriter = file("../../lib/CLI/scripts/expo/write-build-receipt.js").canonicalFile
|
|
61
|
+
def bundleDropExpoProjectRoot = rootProject.projectDir.parentFile.canonicalFile
|
|
62
|
+
|
|
63
|
+
def bundleDropPackagedArtifacts = { Task task ->
|
|
64
|
+
def artifacts = []
|
|
65
|
+
task.outputs.files.files.each { File output ->
|
|
66
|
+
if (output.isFile() && (output.name.endsWith(".apk") || output.name.endsWith(".aab"))) {
|
|
67
|
+
artifacts.add(output.canonicalFile)
|
|
68
|
+
} else if (output.isDirectory()) {
|
|
69
|
+
output.eachFileRecurse { File candidate ->
|
|
70
|
+
if (candidate.isFile() && (candidate.name.endsWith(".apk") || candidate.name.endsWith(".aab"))) {
|
|
71
|
+
artifacts.add(candidate.canonicalFile)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return artifacts.unique { it.path }.sort { left, right -> left.path <=> right.path }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
def bundleDropVariantForTask = { applicationProject, Task task ->
|
|
80
|
+
def taskName = task.name.toLowerCase()
|
|
81
|
+
def matchingVariants = applicationProject.android.applicationVariants.findAll { variant ->
|
|
82
|
+
taskName.contains(variant.name.toLowerCase())
|
|
83
|
+
}.sort { left, right -> right.name.length() <=> left.name.length() }
|
|
84
|
+
if (matchingVariants.isEmpty()) {
|
|
85
|
+
throw new GradleException(
|
|
86
|
+
"Bundle Drop could not map ${task.name} to an Android application variant."
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
return matchingVariants.first()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
def bundleDropVariantIdentity = { variant, File artifact = null ->
|
|
93
|
+
def matchingOutputs = artifact == null ? [] : variant.outputs.findAll { output ->
|
|
94
|
+
output.outputFileName == artifact.name
|
|
95
|
+
}
|
|
96
|
+
def output
|
|
97
|
+
if (matchingOutputs.size() == 1) {
|
|
98
|
+
output = matchingOutputs.first()
|
|
99
|
+
} else if (variant.outputs.size() == 1) {
|
|
100
|
+
output = variant.outputs.first()
|
|
101
|
+
} else {
|
|
102
|
+
def outputLabel = artifact == null ? variant.name : artifact.name
|
|
103
|
+
throw new GradleException(
|
|
104
|
+
"Bundle Drop could not map ${outputLabel} to an exact Android variant output."
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
def appVersion = output.versionNameOverride ?: variant.versionName
|
|
108
|
+
def nativeBuildVersion = output.versionCodeOverride ?: output.versionCode ?: variant.versionCode
|
|
109
|
+
if (appVersion == null || nativeBuildVersion == null) {
|
|
110
|
+
throw new GradleException(
|
|
111
|
+
"Bundle Drop could not resolve the packaged Android versionName/versionCode."
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
return [appVersion: appVersion.toString(), nativeBuildVersion: nativeBuildVersion.toString()]
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// This module is Expo-only. Attach proof after Android's application package/bundle task
|
|
118
|
+
// succeeds, when an exact APK/AAB exists; never infer native success from Metro or Gradle env.
|
|
119
|
+
rootProject.gradle.projectsEvaluated {
|
|
120
|
+
rootProject.allprojects { applicationProject ->
|
|
121
|
+
applicationProject.plugins.withId("com.android.application") {
|
|
122
|
+
def bundleDropCommandExecutor = applicationProject.objects.newInstance(
|
|
123
|
+
BundleDropCommandExecutor
|
|
124
|
+
)
|
|
125
|
+
// AGP does not expose a safe post-package callback. Keep this narrow legacy
|
|
126
|
+
// hook only for signed APK/AAB proof; candidate generation is owned by the
|
|
127
|
+
// app-scoped Android Components plugin declared in expo-module.config.json.
|
|
128
|
+
applicationProject.tasks.configureEach { Task task ->
|
|
129
|
+
if (task.name ==~ /(?i)(package|bundle).*release/) {
|
|
130
|
+
def variant = bundleDropVariantForTask(applicationProject, task)
|
|
131
|
+
task.doLast {
|
|
132
|
+
def artifacts = bundleDropPackagedArtifacts(task)
|
|
133
|
+
if (!artifacts.isEmpty()) {
|
|
134
|
+
if (!bundleDropReceiptWriter.isFile()) {
|
|
135
|
+
throw new GradleException(
|
|
136
|
+
"Bundle Drop receipt writer is missing from the installed package: ${bundleDropReceiptWriter}"
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
// Split APKs are separately signed outputs. Use the lexically first exact
|
|
140
|
+
// artifact so the proof is deterministic and can be re-hashed at upload.
|
|
141
|
+
def artifact = artifacts.first()
|
|
142
|
+
def nodeBinary = System.getenv("NODE_BINARY") ?: "node"
|
|
143
|
+
def packagedIdentity = bundleDropVariantIdentity(variant, artifact)
|
|
144
|
+
bundleDropCommandExecutor.execute(applicationProject.projectDir, nodeBinary, [
|
|
145
|
+
bundleDropReceiptWriter.path,
|
|
146
|
+
"--project-root", bundleDropExpoProjectRoot.path,
|
|
147
|
+
"--platform", "android",
|
|
148
|
+
"--artifact", artifact.path,
|
|
149
|
+
"--android-sdk", applicationProject.android.sdkDirectory.canonicalPath,
|
|
150
|
+
"--app-version", packagedIdentity.appVersion,
|
|
151
|
+
"--native-build-version", packagedIdentity.nativeBuildVersion
|
|
152
|
+
])
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package com.bundledrop.expo
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.content.pm.PackageManager
|
|
5
|
+
import android.os.Build
|
|
6
|
+
|
|
7
|
+
internal object BundleDropExpoConfiguration {
|
|
8
|
+
private const val ENABLED_META_DATA = "com.bundledrop.EXPO_ENABLED"
|
|
9
|
+
|
|
10
|
+
@Volatile
|
|
11
|
+
private var otaStartupEnabled = false
|
|
12
|
+
|
|
13
|
+
fun isEnabled(context: Context): Boolean {
|
|
14
|
+
val applicationInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
15
|
+
context.packageManager.getApplicationInfo(
|
|
16
|
+
context.packageName,
|
|
17
|
+
PackageManager.ApplicationInfoFlags.of(PackageManager.GET_META_DATA.toLong()),
|
|
18
|
+
)
|
|
19
|
+
} else {
|
|
20
|
+
@Suppress("DEPRECATION")
|
|
21
|
+
context.packageManager.getApplicationInfo(
|
|
22
|
+
context.packageName,
|
|
23
|
+
PackageManager.GET_META_DATA,
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return applicationInfo.metaData?.getBoolean(ENABLED_META_DATA, false) == true
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
fun resolveOtaStartupEnabled(context: Context, useDeveloperSupport: Boolean): Boolean {
|
|
31
|
+
return (!useDeveloperSupport && isEnabled(context)).also { otaStartupEnabled = it }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fun isOtaStartupEnabled(): Boolean = otaStartupEnabled
|
|
35
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package com.bundledrop.expo
|
|
2
|
+
|
|
3
|
+
import android.os.Build
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
+
|
|
7
|
+
internal class BundleDropExpoIdentityModule(
|
|
8
|
+
reactContext: ReactApplicationContext,
|
|
9
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
10
|
+
override fun getName(): String = "BundleDropExpoIdentity"
|
|
11
|
+
|
|
12
|
+
override fun getConstants(): Map<String, Any> {
|
|
13
|
+
val packageInfo = reactApplicationContext.packageManager.getPackageInfo(
|
|
14
|
+
reactApplicationContext.packageName,
|
|
15
|
+
0,
|
|
16
|
+
)
|
|
17
|
+
val buildVersion = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
18
|
+
packageInfo.longVersionCode
|
|
19
|
+
} else {
|
|
20
|
+
@Suppress("DEPRECATION")
|
|
21
|
+
packageInfo.versionCode.toLong()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return mapOf(
|
|
25
|
+
"appVersion" to (packageInfo.versionName ?: ""),
|
|
26
|
+
"appBuildVersion" to buildVersion.toString(),
|
|
27
|
+
"otaStartupEnabled" to BundleDropExpoConfiguration.isOtaStartupEnabled(),
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.bundledrop.expo
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.facebook.react.ReactPackage
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.uimanager.ViewManager
|
|
8
|
+
import expo.modules.core.interfaces.Package
|
|
9
|
+
import expo.modules.core.interfaces.ReactNativeHostHandler
|
|
10
|
+
|
|
11
|
+
class BundleDropExpoPackage : Package, ReactPackage {
|
|
12
|
+
override fun createReactNativeHostHandlers(
|
|
13
|
+
context: Context,
|
|
14
|
+
): List<ReactNativeHostHandler> {
|
|
15
|
+
return listOf(BundleDropExpoReactNativeHostHandler(context))
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override fun createNativeModules(
|
|
19
|
+
reactContext: ReactApplicationContext,
|
|
20
|
+
): List<NativeModule> {
|
|
21
|
+
return listOf(BundleDropExpoIdentityModule(reactContext))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override fun createViewManagers(
|
|
25
|
+
reactContext: ReactApplicationContext,
|
|
26
|
+
): List<ViewManager<*, *>> {
|
|
27
|
+
return emptyList()
|
|
28
|
+
}
|
|
29
|
+
}
|
package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoReactNativeHostHandler.kt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.bundledrop.expo
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.bundledrop.BundleDropNativePaths
|
|
5
|
+
import expo.modules.core.interfaces.ReactNativeHostHandler
|
|
6
|
+
|
|
7
|
+
internal class BundleDropExpoReactNativeHostHandler(
|
|
8
|
+
private val context: Context,
|
|
9
|
+
) : ReactNativeHostHandler {
|
|
10
|
+
override fun getJSBundleFile(useDeveloperSupport: Boolean): String? {
|
|
11
|
+
if (!BundleDropExpoConfiguration.resolveOtaStartupEnabled(context, useDeveloperSupport)) {
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
return BundleDropNativePaths.getDownloadedBundlePath(context)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
plugins {
|
|
2
|
+
id 'groovy-gradle-plugin'
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
group = 'com.bundledrop'
|
|
6
|
+
|
|
7
|
+
repositories {
|
|
8
|
+
google()
|
|
9
|
+
mavenCentral()
|
|
10
|
+
gradlePluginPortal()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
dependencies {
|
|
14
|
+
// Match Expo's own app-scoped Gradle plugins. These public APIs remain
|
|
15
|
+
// binary-compatible when the consuming Expo SDK supplies a newer AGP.
|
|
16
|
+
compileOnly 'com.android.tools.build:gradle:8.5.0'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
java {
|
|
20
|
+
sourceCompatibility = JavaVersion.VERSION_11
|
|
21
|
+
targetCompatibility = JavaVersion.VERSION_11
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
gradlePlugin {
|
|
25
|
+
plugins {
|
|
26
|
+
bundleDropExpoPlugin {
|
|
27
|
+
id = 'bundle-drop-expo-gradle-plugin'
|
|
28
|
+
implementationClass = 'com.bundledrop.gradle.BundleDropExpoPlugin'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
package com.bundledrop.gradle
|
|
2
|
+
|
|
3
|
+
import org.gradle.api.GradleException
|
|
4
|
+
import org.gradle.api.Plugin
|
|
5
|
+
import org.gradle.api.Project
|
|
6
|
+
|
|
7
|
+
class BundleDropExpoPlugin implements Plugin<Project> {
|
|
8
|
+
private static final String EXPO_ADAPTER_PROJECT = ':bundledrop-expo'
|
|
9
|
+
|
|
10
|
+
@Override
|
|
11
|
+
void apply(Project project) {
|
|
12
|
+
def packageRoot = resolvePackageRoot(project)
|
|
13
|
+
def receiptWriter = new File(
|
|
14
|
+
packageRoot,
|
|
15
|
+
'lib/CLI/scripts/expo/write-build-receipt.js'
|
|
16
|
+
).canonicalFile
|
|
17
|
+
if (!receiptWriter.isFile()) {
|
|
18
|
+
throw new GradleException(
|
|
19
|
+
"Bundle Drop receipt writer is missing from the installed package: ${receiptWriter}"
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
def androidComponents = project.extensions.getByName('androidComponents')
|
|
24
|
+
androidComponents.onVariants(
|
|
25
|
+
androidComponents.selector().withBuildType('release')
|
|
26
|
+
) { variant ->
|
|
27
|
+
registerIdentityAsset(project, variant, receiptWriter)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private static File resolvePackageRoot(Project project) {
|
|
32
|
+
def adapterProject = project.rootProject.findProject(EXPO_ADAPTER_PROJECT)
|
|
33
|
+
if (adapterProject == null) {
|
|
34
|
+
throw new GradleException(
|
|
35
|
+
"Bundle Drop could not find the autolinked ${EXPO_ADAPTER_PROJECT} project."
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def packageRoot = adapterProject.projectDir.parentFile.parentFile.canonicalFile
|
|
40
|
+
if (!new File(packageRoot, 'package.json').isFile()) {
|
|
41
|
+
throw new GradleException(
|
|
42
|
+
"Bundle Drop could not resolve its package root from ${adapterProject.projectDir}."
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
return packageRoot
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private static void registerIdentityAsset(Project project, variant, File receiptWriter) {
|
|
49
|
+
if (variant.outputs.size() != 1) {
|
|
50
|
+
throw new GradleException(
|
|
51
|
+
"Bundle Drop requires one exact Android output for ${variant.name}."
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
def variantOutput = variant.outputs.first()
|
|
56
|
+
def capitalizedVariant = variant.name.substring(0, 1).toUpperCase() +
|
|
57
|
+
variant.name.substring(1)
|
|
58
|
+
def identityTask = project.tasks.register(
|
|
59
|
+
"generateBundleDrop${capitalizedVariant}BuildIdentity",
|
|
60
|
+
GenerateBundleDropBuildIdentityTask
|
|
61
|
+
) { task ->
|
|
62
|
+
task.appVersion.set(variantOutput.versionName)
|
|
63
|
+
task.nativeBuildVersion.set(variantOutput.versionCode.map { versionCode ->
|
|
64
|
+
versionCode.toString()
|
|
65
|
+
})
|
|
66
|
+
task.nodeBinary.set(System.getenv('NODE_BINARY') ?: 'node')
|
|
67
|
+
task.receiptWriter.set(receiptWriter)
|
|
68
|
+
task.expoProjectRoot.set(project.rootProject.projectDir.parentFile)
|
|
69
|
+
task.outputDirectory.set(
|
|
70
|
+
project.layout.buildDirectory.dir(
|
|
71
|
+
"generated/bundleDropIdentity/${variant.name}/assets"
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
// Expo config and remote app-version state are resolved by the Node
|
|
75
|
+
// writer, so always refresh this small deterministic build input.
|
|
76
|
+
task.outputs.upToDateWhen { false }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
variant.sources.assets.addGeneratedSourceDirectory(identityTask) { task ->
|
|
80
|
+
task.outputDirectory
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package com.bundledrop.gradle
|
|
2
|
+
|
|
3
|
+
import javax.inject.Inject
|
|
4
|
+
import org.gradle.api.DefaultTask
|
|
5
|
+
import org.gradle.api.file.DirectoryProperty
|
|
6
|
+
import org.gradle.api.file.RegularFileProperty
|
|
7
|
+
import org.gradle.api.provider.Property
|
|
8
|
+
import org.gradle.api.tasks.Input
|
|
9
|
+
import org.gradle.api.tasks.InputFile
|
|
10
|
+
import org.gradle.api.tasks.Internal
|
|
11
|
+
import org.gradle.api.tasks.OutputDirectory
|
|
12
|
+
import org.gradle.api.tasks.PathSensitive
|
|
13
|
+
import org.gradle.api.tasks.PathSensitivity
|
|
14
|
+
import org.gradle.api.tasks.TaskAction
|
|
15
|
+
import org.gradle.process.ExecOperations
|
|
16
|
+
|
|
17
|
+
abstract class GenerateBundleDropBuildIdentityTask extends DefaultTask {
|
|
18
|
+
@Input
|
|
19
|
+
abstract Property<String> getAppVersion()
|
|
20
|
+
|
|
21
|
+
@Input
|
|
22
|
+
abstract Property<String> getNativeBuildVersion()
|
|
23
|
+
|
|
24
|
+
@Input
|
|
25
|
+
abstract Property<String> getNodeBinary()
|
|
26
|
+
|
|
27
|
+
@InputFile
|
|
28
|
+
@PathSensitive(PathSensitivity.NONE)
|
|
29
|
+
abstract RegularFileProperty getReceiptWriter()
|
|
30
|
+
|
|
31
|
+
@Internal
|
|
32
|
+
abstract DirectoryProperty getExpoProjectRoot()
|
|
33
|
+
|
|
34
|
+
@OutputDirectory
|
|
35
|
+
abstract DirectoryProperty getOutputDirectory()
|
|
36
|
+
|
|
37
|
+
@Inject
|
|
38
|
+
abstract ExecOperations getExecOperations()
|
|
39
|
+
|
|
40
|
+
@TaskAction
|
|
41
|
+
void generateIdentity() {
|
|
42
|
+
def projectRoot = expoProjectRoot.get().asFile
|
|
43
|
+
def outputFile = outputDirectory.file('bundle-drop/build-identity.json').get().asFile
|
|
44
|
+
|
|
45
|
+
execOperations.exec { spec ->
|
|
46
|
+
spec.workingDir projectRoot
|
|
47
|
+
spec.executable nodeBinary.get()
|
|
48
|
+
spec.args([
|
|
49
|
+
receiptWriter.get().asFile.path,
|
|
50
|
+
'--project-root', projectRoot.path,
|
|
51
|
+
'--candidate-output', outputFile.path,
|
|
52
|
+
'--app-version', appVersion.get(),
|
|
53
|
+
'--native-build-version', nativeBuildVersion.get()
|
|
54
|
+
])
|
|
55
|
+
}.assertNormalExitValue()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <ExpoModulesCore/EXAppDefines.h>
|
|
3
|
+
#import <React/RCTBridgeModule.h>
|
|
4
|
+
|
|
5
|
+
@interface BundleDropExpoIdentity : NSObject <RCTBridgeModule>
|
|
6
|
+
@end
|
|
7
|
+
|
|
8
|
+
@implementation BundleDropExpoIdentity
|
|
9
|
+
|
|
10
|
+
RCT_EXPORT_MODULE(BundleDropExpoIdentity)
|
|
11
|
+
|
|
12
|
+
+ (BOOL)requiresMainQueueSetup
|
|
13
|
+
{
|
|
14
|
+
return NO;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
- (NSDictionary<NSString *, id> *)constantsToExport
|
|
18
|
+
{
|
|
19
|
+
NSDictionary *info = NSBundle.mainBundle.infoDictionary;
|
|
20
|
+
NSString *appVersion = info[@"CFBundleShortVersionString"] ?: @"";
|
|
21
|
+
NSString *appBuildVersion = info[@"CFBundleVersion"] ?: @"";
|
|
22
|
+
BOOL pluginEnabled = [info[@"BundleDropExpoEnabled"] boolValue];
|
|
23
|
+
|
|
24
|
+
return @{
|
|
25
|
+
@"appVersion": appVersion,
|
|
26
|
+
@"appBuildVersion": appBuildVersion,
|
|
27
|
+
@"otaStartupEnabled": @(pluginEnabled && !EXAppDefines.APP_DEBUG),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import Foundation
|
|
3
|
+
import BundleDrop
|
|
4
|
+
|
|
5
|
+
public final class BundleDropExpoReactDelegateHandler: ExpoReactDelegateHandler {
|
|
6
|
+
private static let enabledInfoPlistKey = "BundleDropExpoEnabled"
|
|
7
|
+
|
|
8
|
+
public override func bundleURL(reactDelegate: ExpoReactDelegate) -> URL? {
|
|
9
|
+
guard Self.isEnabled else { return nil }
|
|
10
|
+
guard !Self.isDeveloperSupportBuild else { return nil }
|
|
11
|
+
return BundleDropLocatorCore.bundleURL()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private static var isEnabled: Bool {
|
|
15
|
+
Bundle.main.object(forInfoDictionaryKey: enabledInfoPlistKey) as? Bool == true
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private static var isDeveloperSupportBuild: Bool {
|
|
19
|
+
// Use the same signal as Expo's dev-launcher and dev-menu handlers. A
|
|
20
|
+
// production app may link expo-dev-client without enabling developer
|
|
21
|
+
// support, so class presence is not a reliable ownership signal.
|
|
22
|
+
EXAppDefines.APP_DEBUG
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"platforms": ["apple", "android"],
|
|
3
|
+
"apple": {
|
|
4
|
+
"podspecPath": "BundleDropExpo.podspec",
|
|
5
|
+
"swiftModuleName": "BundleDropExpo",
|
|
6
|
+
"reactDelegateHandlers": ["BundleDropExpoReactDelegateHandler"]
|
|
7
|
+
},
|
|
8
|
+
"android": {
|
|
9
|
+
"name": "bundledrop-expo",
|
|
10
|
+
"path": "expo/android",
|
|
11
|
+
"gradlePlugins": [
|
|
12
|
+
{
|
|
13
|
+
"id": "bundle-drop-expo-gradle-plugin",
|
|
14
|
+
"group": "com.bundledrop",
|
|
15
|
+
"sourceDir": "expo/bundle-drop-expo-gradle-plugin"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -3,6 +3,7 @@ import Foundation
|
|
|
3
3
|
@objc(BundleDropLocatorCore) public final class BundleDropLocatorCore: NSObject {
|
|
4
4
|
|
|
5
5
|
static let binaryVersionKey = "BundleDropBinaryVersion"
|
|
6
|
+
static let runtimeVersionInfoKey = "BundleDropRuntimeVersion"
|
|
6
7
|
|
|
7
8
|
/// Matches Android `BundleDropOtaPrefs.KEY_OTA_ENABLED` for cross-platform debugging.
|
|
8
9
|
static let otaEnabledKey = "bundledrop_ota_enabled"
|
|
@@ -15,7 +16,12 @@ import Foundation
|
|
|
15
16
|
static func getBinaryVersionKey(bundle: Bundle = .main) -> String {
|
|
16
17
|
let version = bundle.infoDictionary?["CFBundleShortVersionString"] as? String ?? "unknown"
|
|
17
18
|
let build = bundle.infoDictionary?["CFBundleVersion"] as? String ?? "0"
|
|
18
|
-
|
|
19
|
+
let binaryVersion = "\(version)-\(build)"
|
|
20
|
+
guard let runtimeVersion = bundle.infoDictionary?[runtimeVersionInfoKey] as? String,
|
|
21
|
+
!runtimeVersion.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
|
22
|
+
return binaryVersion
|
|
23
|
+
}
|
|
24
|
+
return "runtime:\(runtimeVersion)|binary:\(binaryVersion)"
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
@objc public static func bundleURL() -> URL? {
|
package/lib/CLI/cli.d.ts
CHANGED