Skip to content

Commit

Permalink
refactor shared scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
soumak77 committed Sep 28, 2018
1 parent 4f1f932 commit 4657e66
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 31 deletions.
7 changes: 3 additions & 4 deletions scripts/android/after_plugin_install.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
var androidHelper = require('../lib/android-helper');
var utilities = require("../lib/utilities");
var helper = require('./helper');

module.exports = function(context) {

// Modify the Gradle build file to add a task that will upload the debug symbols
// at build time.
androidHelper.restoreRootBuildGradle();
androidHelper.modifyRootBuildGradle();
helper.restoreRootBuildGradle();
helper.modifyRootBuildGradle();
};
5 changes: 2 additions & 3 deletions scripts/android/before_plugin_uninstall.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
var androidHelper = require('../lib/android-helper');
var utilities = require("../lib/utilities");
var helper = require('./helper');

module.exports = function(context) {

// Remove the Gradle modifications that were added when the plugin was installed.
androidHelper.restoreRootBuildGradle();
helper.restoreRootBuildGradle();
};
File renamed without changes.
9 changes: 4 additions & 5 deletions scripts/ios/after_plugin_install.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
var iosHelper = require("../lib/ios-helper");
var utilities = require("../lib/utilities");
var helper = require("./helper");

module.exports = function(context) {

// Add a build phase which runs a shell script that executes the Crashlytics
// run command line tool which uploads the debug symbols at build time.
var xcodeProjectPath = utilities.getXcodeProjectPath(context);
iosHelper.removeShellScriptBuildPhase(context, xcodeProjectPath);
iosHelper.addShellScriptBuildPhase(context, xcodeProjectPath);
var xcodeProjectPath = helper.getXcodeProjectPath(context);
helper.removeShellScriptBuildPhase(context, xcodeProjectPath);
helper.addShellScriptBuildPhase(context, xcodeProjectPath);
};
7 changes: 3 additions & 4 deletions scripts/ios/before_plugin_uninstall.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
var iosHelper = require("../lib/ios-helper");
var utilities = require("../lib/utilities");
var helper = require("./helper");

module.exports = function(context) {

// Remove the build script that was added when the plugin was installed.
var xcodeProjectPath = utilities.getXcodeProjectPath(context);
iosHelper.removeShellScriptBuildPhase(context, xcodeProjectPath);
var xcodeProjectPath = helper.getXcodeProjectPath(context);
helper.removeShellScriptBuildPhase(context, xcodeProjectPath);
};
17 changes: 15 additions & 2 deletions scripts/lib/ios-helper.js → scripts/ios/helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var fs = require("fs");
var utilities = require("./utilities");
var utilities = require("../lib/utilities");

/**
* This is used as the display text for the build phase block in XCode as well as the
Expand All @@ -9,6 +9,19 @@ var comment = "\"Crashlytics\"";

module.exports = {

/**
* Used to get the path to the XCode project's .pbxproj file.
*
* @param {object} context - The Cordova context.
* @returns The path to the XCode project's .pbxproj file.
*/
getXcodeProjectPath: function (context) {

var appName = utilities.getAppName(context);

return path.join("platforms", "ios", appName + ".xcodeproj", "project.pbxproj");
},

/**
* This helper is used to add a build phase to the XCode project which runs a shell
* script during the build process. The script executes Crashlytics run command line
Expand Down Expand Up @@ -126,4 +139,4 @@ module.exports = {
// Finally, write the .pbxproj back out to disk.
fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync());
}
};
};
13 changes: 0 additions & 13 deletions scripts/lib/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ module.exports = {
return "cordova-plugin-firebase";
},

/**
* Used to get the path to the XCode project's .pbxproj file.
*
* @param {object} context - The Cordova context.
* @returns The path to the XCode project's .pbxproj file.
*/
getXcodeProjectPath: function (context) {

var appName = this.getAppName(context);

return path.join("platforms", "ios", appName + ".xcodeproj", "project.pbxproj");
},

copyKey: function (platform) {
for (var i = 0; i < platform.src.length; i++) {
var file = platform.src[i];
Expand Down

0 comments on commit 4657e66

Please sign in to comment.