Socket
Socket
Sign inDemoInstall

@react-native-community/cli-platform-android

Package Overview
Dependencies
Maintainers
30
Versions
213
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native-community/cli-platform-android - npm Package Compare versions

Comparing version 9.0.0 to 9.3.4

build/config/findBuildGradle.d.ts

2

build/commands/runAndroid/runOnAllDevices.js

@@ -93,3 +93,3 @@ "use strict";

return _adb.default.getCPU(adbPath, device);
}).filter(arch => arch != null);
}).filter((arch, index, array) => arch != null && array.indexOf(arch) === index);

@@ -96,0 +96,0 @@ if (architectures.length > 0) {

@@ -40,2 +40,11 @@ /**

};
export declare const validApp: {
'build.gradle': any;
app: {
'build.gradle': any;
};
src: {
'AndroidManifest.xml': any;
};
};
export declare const userConfigManifest: {

@@ -42,0 +51,0 @@ src: {

import { Config } from '@react-native-community/cli-types';
export declare function getAndroidProject(config: Config): import("@react-native-community/cli-types").AndroidProjectConfig;
/**
* Get the package name of the running React Native app
* @param config
* Get the package name/namespace of the running React Native app
* @param manifestPath The path to the AndroidManifest.xml
* @param buildGradlePath The path to the build.gradle[.kts] file.
*/
export declare function getPackageName(manifestPath: string): string;
export declare function getPackageName(manifestPath: string | null, buildGradlePath: string | null): string;
export declare function parsePackageNameFromAndroidManifestFile(androidManifest: string): string | null;
export declare function parseNamespaceFromBuildGradleFile(buildGradle: string): string | null;
export declare function validatePackageName(packageName: string): boolean;
//# sourceMappingURL=getAndroidProject.d.ts.map

@@ -8,2 +8,4 @@ "use strict";

exports.getPackageName = getPackageName;
exports.parsePackageNameFromAndroidManifestFile = parsePackageNameFromAndroidManifestFile;
exports.parseNamespaceFromBuildGradleFile = parseNamespaceFromBuildGradleFile;
exports.validatePackageName = validatePackageName;

@@ -57,23 +59,73 @@

/**
* Get the package name of the running React Native app
* @param config
* Util function to discover the package name from either the Manifest file or the build.gradle file.
* @param manifestPath The path to the AndroidManifest.xml
* @param buildGradlePath The path to the build.gradle[.kts] file.
*/
function getPackageName(manifestPath) {
const androidManifest = _fs().default.readFileSync(manifestPath, 'utf8');
function discoverPackageName(manifestPath, buildGradlePath) {
if (manifestPath) {
const androidManifest = _fs().default.readFileSync(manifestPath, 'utf8');
let packageNameMatchArray = androidManifest.match(/package="(.+?)"/);
const packageNameFromManifest = parsePackageNameFromAndroidManifestFile(androidManifest); // We got the package from the AndroidManifest.xml
if (!packageNameMatchArray || packageNameMatchArray.length === 0) {
throw new (_cliTools().CLIError)(`Failed to build the app: No package name found. Found errors in ${_chalk().default.underline.dim(`${manifestPath}`)}`);
if (packageNameFromManifest) {
return packageNameFromManifest;
}
}
let packageName = packageNameMatchArray[1];
if (buildGradlePath) {
// We didn't get the package from the AndroidManifest.xml,
// so we'll try to get it from the build.gradle[.kts] file
// via the namespace field.
const buildGradle = _fs().default.readFileSync(buildGradlePath, 'utf8');
const namespace = parseNamespaceFromBuildGradleFile(buildGradle);
if (namespace) {
return namespace;
}
}
throw new (_cliTools().CLIError)(`Failed to build the app: No package name found.
We couldn't parse the namespace from neither your build.gradle[.kts] file at ${_chalk().default.underline.dim(`${buildGradlePath}`)}
nor your package in the AndroidManifest at ${_chalk().default.underline.dim(`${manifestPath}`)}
`);
}
/**
* Get the package name/namespace of the running React Native app
* @param manifestPath The path to the AndroidManifest.xml
* @param buildGradlePath The path to the build.gradle[.kts] file.
*/
function getPackageName(manifestPath, buildGradlePath) {
let packageName = discoverPackageName(manifestPath, buildGradlePath);
if (!validatePackageName(packageName)) {
_cliTools().logger.warn(`Invalid application's package name "${_chalk().default.bgRed(packageName)}" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: ${_chalk().default.underline.dim('https://developer.android.com/studio/build/application-id')}`);
_cliTools().logger.warn(`Invalid application's package name "${_chalk().default.bgRed(packageName)}" in either 'AndroidManifest.xml' or 'build.gradle'. Read guidelines for setting the package name here: ${_chalk().default.underline.dim('https://developer.android.com/studio/build/application-id')}`);
}
return packageName;
}
function parsePackageNameFromAndroidManifestFile(androidManifest) {
const matchArray = androidManifest.match(/package="(.+?)"/);
if (matchArray && matchArray.length > 0) {
return matchArray[1];
} else {
return null;
}
}
function parseNamespaceFromBuildGradleFile(buildGradle) {
// search for namespace = inside the build.gradle file via regex
const matchArray = buildGradle.match(/namespace\s*[=]*\s*"(.+?)"/);
if (matchArray && matchArray.length > 0) {
return matchArray[1];
} else {
return null;
}
} // Validates that the package name is correct

@@ -80,0 +132,0 @@

@@ -41,2 +41,4 @@ "use strict";

var _findBuildGradle = require("./findBuildGradle");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -67,11 +69,12 @@

const manifestPath = userConfig.manifestPath ? _path().default.join(sourceDir, userConfig.manifestPath) : (0, _findManifest.default)(_path().default.join(sourceDir, appName));
const buildGradlePath = (0, _findBuildGradle.findBuildGradle)(sourceDir, false);
if (!manifestPath) {
if (!manifestPath && !buildGradlePath) {
return null;
}
const packageName = userConfig.packageName || (0, _getAndroidProject.getPackageName)(manifestPath);
const packageName = userConfig.packageName || (0, _getAndroidProject.getPackageName)(manifestPath, buildGradlePath);
if (!packageName) {
throw new Error(`Package name not found in ${manifestPath}`);
throw new Error(`Package name not found in neither ${manifestPath} nor ${buildGradlePath}`);
}

@@ -118,8 +121,9 @@

const manifestPath = userConfig.manifestPath ? _path().default.join(sourceDir, userConfig.manifestPath) : (0, _findManifest.default)(sourceDir);
const buildGradlePath = (0, _findBuildGradle.findBuildGradle)(sourceDir, true);
if (!manifestPath) {
if (!manifestPath && !buildGradlePath) {
return null;
}
const packageName = userConfig.packageName || (0, _getAndroidProject.getPackageName)(manifestPath);
const packageName = userConfig.packageName || (0, _getAndroidProject.getPackageName)(manifestPath, buildGradlePath);
const packageClassName = (0, _findPackageClassName.default)(sourceDir);

@@ -141,2 +145,8 @@ /**

const androidMkPath = userConfig.androidMkPath ? _path().default.join(sourceDir, userConfig.androidMkPath) : _path().default.join(sourceDir, 'build/generated/source/codegen/jni/Android.mk');
let cmakeListsPath = userConfig.cmakeListsPath ? _path().default.join(sourceDir, userConfig.cmakeListsPath) : _path().default.join(sourceDir, 'build/generated/source/codegen/jni/CMakeLists.txt');
if (process.platform === 'win32') {
cmakeListsPath = cmakeListsPath.replace(/\\/g, '/');
}
return {

@@ -150,3 +160,4 @@ sourceDir,

componentDescriptors,
androidMkPath
androidMkPath,
cmakeListsPath
};

@@ -153,0 +164,0 @@ }

{
"name": "@react-native-community/cli-platform-android",
"version": "9.0.0",
"version": "9.3.4",
"license": "MIT",

@@ -10,3 +10,3 @@ "main": "build/index.js",

"dependencies": {
"@react-native-community/cli-tools": "^9.0.0",
"@react-native-community/cli-tools": "^9.2.1",
"chalk": "^4.1.2",

@@ -26,3 +26,3 @@ "execa": "^1.0.0",

"devDependencies": {
"@react-native-community/cli-types": "^9.0.0",
"@react-native-community/cli-types": "^9.1.0",
"@types/execa": "^0.9.0",

@@ -39,3 +39,3 @@ "@types/fs-extra": "^8.1.0",

},
"gitHead": "d61d255cfc4233b90684f4892b2cc6488943a9a6"
"gitHead": "3c981e7343b4638e86168e0ca63b6de1c241369d"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc