Skip to content
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

use install/uninstall hooks instead of add/remove hooks #883

Merged
merged 2 commits into from
Sep 28, 2018
Merged
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
13 changes: 8 additions & 5 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ xmlns:android="http://schemas.android.com/apk/res/android">
</engines>

<platform name="android">
<hook type="after_prepare" src="scripts/android/after_prepare.js" />
<hook type="after_plugin_install" src="scripts/android/after_plugin_install.js" />
<hook type="before_plugin_uninstall" src="scripts/android/before_plugin_uninstall.js" />

<js-module name="FirebasePlugin" src="www/firebase.js">
<clobbers target="FirebasePlugin" />
</js-module>
Expand Down Expand Up @@ -57,10 +61,13 @@ xmlns:android="http://schemas.android.com/apk/res/android">
<framework src="com.google.firebase:firebase-messaging:+" />
<framework src="com.google.firebase:firebase-config:+" />
<framework src="com.google.firebase:firebase-perf:+" />

</platform>

<platform name="ios">
<hook type="after_prepare" src="scripts/ios/after_prepare.js" />
<hook type="after_plugin_install" src="scripts/ios/after_plugin_install.js" />
<hook type="before_plugin_uninstall" src="scripts/ios/before_plugin_uninstall.js" />

<js-module name="FirebasePlugin" src="www/firebase.js">
<clobbers target="FirebasePlugin" />
</js-module>
Expand Down Expand Up @@ -111,8 +118,4 @@ xmlns:android="http://schemas.android.com/apk/res/android">
<clobbers target="FirebasePlugin" />
</js-module>
</platform>

<hook src="scripts/after_prepare.js" type="after_prepare" />
<hook src="scripts/after_plugin_add.js" type="after_plugin_add" />
<hook src="scripts/before_plugin_rm.js" type="before_plugin_rm" />
</plugin>
24 changes: 0 additions & 24 deletions scripts/after_plugin_add.js

This file was deleted.

119 changes: 0 additions & 119 deletions scripts/after_prepare.js

This file was deleted.

10 changes: 10 additions & 0 deletions scripts/android/after_plugin_install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var androidHelper = require('../lib/android-helper');
var utilities = require("../lib/utilities");

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();
};
39 changes: 39 additions & 0 deletions scripts/android/after_prepare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env node

'use strict';

/**
* This hook makes sure projects using [cordova-plugin-firebase](https://github.com/arnesson/cordova-plugin-firebase)
* will build properly and have the required key files copied to the proper destinations when the app is build on Ionic Cloud using the package command.
* Credits: https://github.com/arnesson.
*/
var fs = require('fs');
var path = require('path');
var utilities = require("../lib/utilities");

var config = fs.readFileSync('config.xml').toString();
var name = utilities.getValue(config, 'name');

var ANDROID_DIR = 'platforms/android';

var PLATFORM = {
ANDROID: {
dest: [
ANDROID_DIR + '/google-services.json',
ANDROID_DIR + '/app/google-services.json'
],
src: [
'google-services.json',
ANDROID_DIR + '/assets/www/google-services.json',
'www/google-services.json',
ANDROID_DIR + '/app/src/main/google-services.json'
],
}
};

module.exports = function (context) {
if (utilities.directoryExists(ANDROID_DIR)) {
console.log('Preparing Firebase on Android');
utilities.copyKey(PLATFORM.ANDROID);
}
};
8 changes: 8 additions & 0 deletions scripts/android/before_plugin_uninstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var androidHelper = require('../lib/android-helper');
var utilities = require("../lib/utilities");

module.exports = function(context) {

// Remove the Gradle modifications that were added when the plugin was installed.
androidHelper.restoreRootBuildGradle();
};
20 changes: 0 additions & 20 deletions scripts/before_plugin_rm.js

This file was deleted.

11 changes: 11 additions & 0 deletions scripts/ios/after_plugin_install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var iosHelper = require("../lib/ios-helper");
var utilities = require("../lib/utilities");

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);
};
39 changes: 39 additions & 0 deletions scripts/ios/after_prepare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env node

'use strict';

/**
* This hook makes sure projects using [cordova-plugin-firebase](https://github.com/arnesson/cordova-plugin-firebase)
* will build properly and have the required key files copied to the proper destinations when the app is build on Ionic Cloud using the package command.
* Credits: https://github.com/arnesson.
*/
var fs = require('fs');
var path = require('path');
var utilities = require("../lib/utilities");

var config = fs.readFileSync('config.xml').toString();
var name = utilities.getValue(config, 'name');

var IOS_DIR = 'platforms/ios';

var PLATFORM = {
IOS: {
dest: [
IOS_DIR + '/' + name + '/Resources/GoogleService-Info.plist',
IOS_DIR + '/' + name + '/Resources/Resources/GoogleService-Info.plist'
],
src: [
'GoogleService-Info.plist',
IOS_DIR + '/www/GoogleService-Info.plist',
'www/GoogleService-Info.plist'
]
}
};

module.exports = function (context) {
// Copy key files to their platform specific folders
if (utilities.directoryExists(IOS_DIR)) {
console.log('Preparing Firebase on iOS');
utilities.copyKey(PLATFORM.IOS);
}
};
9 changes: 9 additions & 0 deletions scripts/ios/before_plugin_uninstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var iosHelper = require("../lib/ios-helper");
var utilities = require("../lib/utilities");

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);
};
Loading