Execute hook scripts only for cordova 6 or older versions
MODIFY
package.json
package.json
"ios"
]
},
- "dependencies": {
- "xml2js": "~0.4.19",
- "minimist": "~1.2.0"
- },
"repository": {
"type": "git",
"url": "https://github.com/mapsplugin/cordova-plugin-googlemaps.git"

MODIFY
src/after_plugin_install.js
src/after_plugin_install.js
module.exports = function(ctx) {
+ var versions = ctx.opts.cordova.version.split(/\./g);
+ if (versions[0] > 6) {
+ // If cordova platform version is higher than 6,
+ // cordova-cli works well, so skip it.
+ return;
+ }
+
var fs = ctx.requireCordovaModule('fs'),
path = ctx.requireCordovaModule('path'),
Q = ctx.requireCordovaModule('q');

MODIFY
src/before_plugin_install.js
src/before_plugin_install.js
@@ -8,6 +8,11 @@ module.exports = function(ctx) {
pluginXmlPath = path.join(__dirname, '..', 'plugin.xml');
var versions = ctx.opts.cordova.version.split(/\./g);
+ if (versions[0] > 6) {
+ // If cordova platform version is higher than 6,
+ // cordova-cli works well, so skip it.
+ return;
+ }
var Module = require('module').Module;
var NODE_MODULES_DIR = path.join(__dirname, '..', 'node_modules');
@@ -26,7 +31,7 @@ module.exports = function(ctx) {
return Q.Promise(function(resolve, reject, notify) {
var exec = require('child_process').exec;
- exec('npm install xml2js minimist --save 2>&1', function(err, stdout) {
+ exec('npm install xml2js@0.4.19 minimist@1.2.0 --save 2>&1', function(err, stdout) {
if (err) {
reject(err);
} else {

MODIFY
src/before_plugin_rm.js
src/before_plugin_rm.js
module.exports = function(ctx) {
+ var versions = ctx.opts.cordova.version.split(/\./g);
+ if (versions[0] > 6) {
+ // If cordova platform version is higher than 6,
+ // cordova-cli works well, so skip it.
+ return;
+ }
+
var fs = ctx.requireCordovaModule('fs'),
path = ctx.requireCordovaModule('path'),
Q = ctx.requireCordovaModule('q');
var projectRoot = ctx.opts.projectRoot,
configXmlPath = path.join(projectRoot, 'config.xml');
- var versions = ctx.opts.cordova.version.split(/\./g);
var Module = require('module').Module;
var NODE_MODULES_DIR = path.join(__dirname, '..', 'node_modules');

MODIFY
src/ios/check_sdk_version.js
src/ios/check_sdk_version.js
@@ -35,77 +35,4 @@ module.exports = function(ctx) {
resolve();
});
- return ctx.cordova.plugin.list(projectRoot, {
- fire: function() {
- return Q.Promise(function(resolve, reject, notify) {
- resolve();
- });
- }
- })
- .then(function(pluginList) {
- console.log(pluginList);
- });
-
-return;
- if (ctx.opts.cordova.platforms.indexOf('ios') < 0) {
- return;
- }
-
- var fs = ctx.requireCordovaModule('fs'),
- path = ctx.requireCordovaModule('path'),
- Q = ctx.requireCordovaModule('q');
-
- var projectRoot = ctx.opts.projectRoot;
- var configXml = fs.readFileSync(path.join(projectRoot, "config.xml")) + "";
- var matches = configXml.match(/engine name=\"android\" spec=\"(.+?)\"/gi);
- if (!matches) {
- return;
- }
- matches[0] = matches[0].replace(/engine name=\"android\" spec=\"~?([\d\.]+)\"/g, "$1");
- var androidLibVersion = parseInt(matches[0].replace(/\./g, ""), 10);
- var androidPlatformDir = path.join(projectRoot, "platforms", "android");
- var androidProjDir = (androidLibVersion >= 700) ? path.join("app", "src", "main") : "";
- androidProjDir = path.join(androidPlatformDir, androidProjDir);
- var dstLibsDir = path.join(androidProjDir, "libs");
- var tbxmlSource = path.join(__dirname, "tbxml-android", "libs");
-
- var copyFile = function(filename, srcDir, dstDir) {
- return Q.promise(function(resolve, reject, notify) {
- fs.stat(dstDir, function(error, stat) {
- if (error || !stat) {
- fs.mkdirSync(dstDir);
- }
- var srcFile = path.join(srcDir, filename);
- var dstFile = path.join(dstDir, filename);
-
- // for debug
- // console.log(" [copy] " + srcFile + " -> " + dstFile);
- fs.writeFileSync(dstFile, fs.readFileSync(srcFile));
- resolve();
- });
- });
- };
-
- return Q.Promise(function(resolve, reject, notify) {
- fs.stat(dstLibsDir, function(error, stat) {
- if (error || !stat) {
- fs.mkdirSync(dstLibsDir);
- }
-
- var files = [];
- files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "arm64-v8a"), path.join(dstLibsDir, "arm64-v8a")));
- files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "armeabi"), path.join(dstLibsDir, "armeabi")));
- files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "armeabi-v7a"), path.join(dstLibsDir, "armeabi-v7a")));
- files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "mips"), path.join(dstLibsDir, "mips")));
- files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "mips64"), path.join(dstLibsDir, "mips64")));
- files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "x86"), path.join(dstLibsDir, "x86")));
- files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "x86_64"), path.join(dstLibsDir, "x86_64")));
-
- resolve(files);
- });
- })
- .then(function(files) {
- return Q.all(files);
- });
-
};

Execute hook scripts only for cordova 6 or older versions