Skip to content

fix : mask private views in new architecture #1403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,18 @@ jobs:
- run:
name: Build the SDK
command: yarn build
- run:
name: Get snapshot version
command: |
source scripts/snapshot-version.sh
echo "export SNAPSHOT_VERSION=$SNAPSHOT_VERSION" >> "$BASH_ENV"
- run:
name: Authorize with NPM
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- run: npm version $SNAPSHOT_VERSION --no-git-tag-version
- run:
name: Publish new enterprise version
command: npm publish
command: npm publish --tag snapshot

publish:
macos:
Expand Down Expand Up @@ -547,16 +553,10 @@ workflows:
- hold_release_nn:
requires: *release_dependencies
type: approval
filters:
branches:
only: master
- release_custom_package:
name: release_nn
requires:
- hold_release_nn
filters:
branches:
only: master
prepare_steps:
- prepare_custom_package:
npm_package: '@instabug/react-native-nn'
Expand Down
102 changes: 88 additions & 14 deletions android/sourcemaps.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.apache.tools.ant.taskdefs.condition.Os

gradle.projectsEvaluated {
project.afterEvaluate {
// Works for both `bundleReleaseJsAndAssets` and `createBundleReleaseJsAndAssets` and product flavors
def suffix = 'ReleaseJsAndAssets'
def bundleTasks = project(':app').tasks.findAll {
Expand All @@ -15,11 +15,13 @@ gradle.projectsEvaluated {
def flavor = name.substring(start, end).uncapitalize()
def defaultVersion = getDefaultVersion(flavor)

task.finalizedBy createUploadSourcemapsTask(flavor, defaultVersion.name, defaultVersion.code)


task.finalizedBy createUploadSourcemapsTask(flavor, defaultVersion.name, defaultVersion.code,task)
}
}

Task createUploadSourcemapsTask(String flavor, String defaultVersionName, String defaultVersionCode) {
Task createUploadSourcemapsTask(String flavor, String defaultVersionName, String defaultVersionCode, Task task) {
def name = 'uploadSourcemaps' + flavor.capitalize()

// Don't recreate the task if it already exists.
Expand All @@ -39,18 +41,26 @@ Task createUploadSourcemapsTask(String flavor, String defaultVersionName, String
try {
def appProject = project(':app')
def appDir = appProject.projectDir
def sourceMapFile = getSourceMapFile(appDir, flavor)
def sourceMapFile = getSourceMapFile(appDir, flavor,task)
println "✅ Resolved sourcemap file path: ${sourceMapFile.absolutePath}"

def jsProjectDir = rootDir.parentFile
def instabugDir = new File(['node', '-p', 'require.resolve("instabug-reactnative/package.json")'].execute(null, rootDir).text.trim()).getParentFile()

def tokenShellFile = new File(instabugDir, 'scripts/find-token.sh')
def inferredToken = executeShellScript(tokenShellFile, jsProjectDir)
def tokenJsFile = new File(instabugDir, 'scripts/find-token.js')
def inferredToken = executeNodeScript(tokenJsFile, jsProjectDir)

if (!inferredToken) {
println "❌ Unable to infer Instabug token from script: ${tokenShellFile.absolutePath}"
}

def appToken = resolveVar('App Token', 'INSTABUG_APP_TOKEN', inferredToken)

def versionName = resolveVar('Version Name', 'INSTABUG_VERSION_NAME', defaultVersionName)
def versionCode = resolveVar('Version Code', 'INSTABUG_VERSION_CODE', defaultVersionCode)

println "📦 Uploading with versionName=${versionName}, versionCode=${versionCode}, appToken=${appToken.take(5)}..."

exec {
def osCompatibility = Os.isFamily(Os.FAMILY_WINDOWS) ? ['cmd', '/c'] : []
def args = [
Expand All @@ -67,34 +77,56 @@ Task createUploadSourcemapsTask(String flavor, String defaultVersionName, String
} catch (exception) {
project.logger.error "Failed to upload source map file.\n" +
"Reason: ${exception.message}"

}
}
}

return provider.get()
}

File getSourceMapFile(File appDir, String flavor) {
File getSourceMapFile(File appDir, String flavor, Task task) {
def defaultFlavorPath = flavor.empty ? 'release' : "${flavor}Release"
def defaultSourceMapDest = "build/generated/sourcemaps/react/${defaultFlavorPath}/index.android.bundle.map"
def defaultSourceMapFile = new File(appDir, defaultSourceMapDest)
def props = task.getProperties()

def bundleAssetName = props.containsKey("bundleAssetName") ? props.bundleAssetName?.getOrNull() : null
def jsSourceMapsDir = props.containsKey("jsSourceMapsDir") ? props.jsSourceMapsDir?.getOrNull() : null
def jsIntermediateSourceMapsDir = props.containsKey("jsIntermediateSourceMapsDir") ? props.jsIntermediateSourceMapsDir?.getOrNull() : null

if (bundleAssetName && jsSourceMapsDir) {
def outputSourceMap = new File(jsSourceMapsDir.asFile.absolutePath, "${bundleAssetName}.map")
if (outputSourceMap.exists()) {
return outputSourceMap
}
}

if (bundleAssetName && jsIntermediateSourceMapsDir) {
def packagerOutputSourceMap = new File(jsIntermediateSourceMapsDir.asFile.absolutePath, "${bundleAssetName}.packager.map")
if (packagerOutputSourceMap.exists()) {
return packagerOutputSourceMap
}
}

if (defaultSourceMapFile.exists()) {
return defaultSourceMapFile
}

if (flavor.empty) {
throw new InvalidUserDataException("Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.")
println"Source map file not found at: ${defaultSourceMapFile.absolutePath}. Skipping."
return null
}

def fallbackSourceMapDest = "build/generated/sourcemaps/react/${flavor}/release/index.android.bundle.map"
def fallbackSourceMapFile = new File(appDir, fallbackSourceMapDest)

project.logger.info "Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.\n" +
println "Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.\n" +
"Falling back to ${fallbackSourceMapFile.absolutePath}."

if (!fallbackSourceMapFile.exists()) {
throw new InvalidUserDataException("Unable to find source map file at: ${fallbackSourceMapFile.absolutePath} either.")
println "Fallback source map file not found at: ${fallbackSourceMapFile.absolutePath}. Skipping."
return null
}

return fallbackSourceMapFile
Expand Down Expand Up @@ -148,21 +180,63 @@ String resolveVar(String name, String envKey, String defaultValue) {
def value = envValue ?: defaultValue

if (value == null) {
throw new InvalidUserDataException("Unable to find ${name}! " +
"Set the environment variable `${envKey}` and try again.")
println "Unable to find ${name}! " +
"Set the environment variable `${envKey}` and try again."
}

return value
}

static String executeNodeScript(File script, File workingDir) {
if (!script.exists()) {
println "Script not found: ${script.absolutePath}"
return null
}

def output = new StringBuffer()
def error = new StringBuffer()

try {
def process = ['node', script.getAbsolutePath()].execute(null, workingDir)
process.waitForProcessOutput(output, error)

if (process.exitValue() != 0) {
println "Script failed with exit code ${process.exitValue()}"
println "Standard Error:\n${error.toString().trim()}"
println "Standard Output:\n${output.toString().trim()}"
return null
}

return output.toString().trim()

} catch (Exception e) {
println "Exception while executing Node.js script: ${e.message}"
e.printStackTrace()
return null
}
}

static String executeShellScript(File script, File workingDir) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
return null
}

if (!script.canExecute()) {
// Try to set executable permission
script.setExecutable(true)
}

def output = new StringBuffer()
def error = new StringBuffer()

// Using 'sh' instead of './' to avoid needing exec permission, but keeping chmod above just in case
def process = ['sh', script.getAbsolutePath()].execute(null, workingDir)
process?.waitForProcessOutput(output, new StringBuffer())
process?.waitForProcessOutput(output, error)

if (process.exitValue() != 0) {
println "Error running script: ${error.toString().trim()}"
return null
}

return process?.exitValue() == 0 ? output.toString().trim() : null
return output.toString().trim()
}
Loading