New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cordova-android-firebase-gradle-release

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-android-firebase-gradle-release - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

5

package.json
{
"name": "cordova-android-firebase-gradle-release",
"version": "2.1.0",
"version": "3.0.0",
"description": "Cordova/Phonegap plugin to align versions of the Firebase library specified by other plugins to a specific version",

@@ -9,6 +9,5 @@ "author": "Dave Alden",

"q": "^1.4.1",
"xml2js": "~0.4.19",
"semver": "5.1.0"
"semver": "5.6.0"
},
"devDependencies": {}
}
var PLUGIN_NAME = "cordova-android-firebase-gradle-release";
var PLUGIN_VAR = "FIREBASE_VERSION";
var PACKAGE_PATTERN = /(compile|implementation|api|annotationProcessor)( "com.google.firebase:[^:]+:)([^"]+)"/g;
var PLUGIN_GRADLE_FOLDER_PATH = "platforms/android/"+PLUGIN_NAME;
var VERSION_PATTERN = /def FIREBASE_VERSION = "[^"]+"/;
var VERSION_TEMPLATE = "def FIREBASE_VERSION = \"<VERSION>\"";
var VERSION_PATTERN = new RegExp('def '+PLUGIN_VAR+' = "[^"]+"');
var VERSION_TEMPLATE = "def "+PLUGIN_VAR+" = \"<VERSION>\"";

@@ -18,3 +19,3 @@ var V6 = "V6";

var deferral, fs, path, parser, semver,
var deferral, fs, path, semver,
platformVersion;

@@ -33,3 +34,3 @@

var cordovaVersion = require(path.resolve(process.cwd(),'platforms/android/cordova/version')).version;
if(semver.satisfies(cordovaVersion, "6")){
if (semver.satisfies(cordovaVersion, "6.x", { includePrerelease: true })){
return V6;

@@ -44,3 +45,2 @@ }

path = require('path');
parser = require('xml2js');
semver = require('semver');

@@ -54,42 +54,28 @@ } catch (e) {

// Read config.xml
var configXmlFilePath = path.resolve(process.cwd(), 'config.xml');
if(!fs.existsSync(configXmlFilePath)){
configXmlFilePath = path.resolve(process.cwd(), 'www/config.xml');
var customVersion;
try{
var packageJSON = JSON.parse(fs.readFileSync('./package.json'));
customVersion = packageJSON.cordova.plugins[PLUGIN_NAME][PLUGIN_VAR];
}catch(e){
log("No custom version found in package.json - using plugin default");
}
if(!fs.existsSync(configXmlFilePath)){
throw "Failed to find config.xml if project root or www/";
}
var data = fs.readFileSync(configXmlFilePath);
parser.parseString(data, attempt(function (err, result) {
if (err) throw err;
var version, plugins = result.widget.plugin;
for (var n = 0, len = plugins.length; n < len; n++) {
var plugin = plugins[n];
if (plugin.$.name === PLUGIN_NAME && plugin.variable && plugin.variable.length > 0) {
version = plugin.variable.pop().$.value;
break;
}
}
if (version) {
// build.gradle
var buildGradlePath = path.resolve(process.cwd(), FILE_PATHS[platformVersion]["build.gradle"]);
var contents = fs.readFileSync(buildGradlePath).toString();
fs.writeFileSync(buildGradlePath, contents.replace(PACKAGE_PATTERN, "$1" + version + '"'), 'utf8');
log("Wrote custom version '" + version + "' to " + buildGradlePath);
// plugin gradle
var pluginGradleFolderPath = path.resolve(process.cwd(), PLUGIN_GRADLE_FOLDER_PATH);
var pluginGradleFileName = fs.readdirSync(pluginGradleFolderPath)[0];
var pluginGradleFilePath = path.resolve(pluginGradleFolderPath, pluginGradleFileName);
var pluginGradleFileContents = fs.readFileSync(pluginGradleFilePath).toString();
pluginGradleFileContents = pluginGradleFileContents.replace(VERSION_PATTERN, VERSION_TEMPLATE.replace(/<VERSION>/, version));
fs.writeFileSync(pluginGradleFilePath, pluginGradleFileContents, 'utf8');
log("Wrote custom version '" + version + "' to " + pluginGradleFilePath);
} else {
log("No custom version found in config.xml - using plugin default");
}
deferral.resolve();
}));
// build.gradle
if (customVersion) {
var buildGradlePath = path.resolve(process.cwd(), FILE_PATHS[platformVersion]["build.gradle"]);
var contents = fs.readFileSync(buildGradlePath).toString();
fs.writeFileSync(buildGradlePath, contents.replace(PACKAGE_PATTERN, "$1" + customVersion + '"'), 'utf8');
log("Wrote custom version '" + customVersion + "' to " + buildGradlePath);
// plugin gradle
var pluginGradleFolderPath = path.resolve(process.cwd(), PLUGIN_GRADLE_FOLDER_PATH);
var pluginGradleFileName = fs.readdirSync(pluginGradleFolderPath)[0];
var pluginGradleFilePath = path.resolve(pluginGradleFolderPath, pluginGradleFileName);
var pluginGradleFileContents = fs.readFileSync(pluginGradleFilePath).toString();
pluginGradleFileContents = pluginGradleFileContents.replace(VERSION_PATTERN, VERSION_TEMPLATE.replace(/<VERSION>/, customVersion));
fs.writeFileSync(pluginGradleFilePath, pluginGradleFileContents, 'utf8');
log("Wrote custom version '" + customVersion + "' to " + pluginGradleFilePath);
}
deferral.resolve();
}

@@ -96,0 +82,0 @@

plugin.xml

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