Merging future and master
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/73047c40 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/73047c40 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/73047c40 Branch: refs/heads/future Commit: 73047c40acfe453d973dc106369461f020e0d9a7 Parents: d3c01ad bd69965 Author: Tim Kim <[email protected]> Authored: Mon Apr 15 11:51:23 2013 -0700 Committer: Tim Kim <[email protected]> Committed: Mon Apr 15 11:51:23 2013 -0700 ---------------------------------------------------------------------- README.md | 23 + platforms/android.js | 60 +- platforms/bb10.js | 152 -- platforms/blackberry.js | 156 ++ platforms/ios.js | 173 +- plugman.js | 67 +- test/android-one-install.js | 61 +- test/android-one-uninstall.js | 7 +- test/android-two-install.js | 36 +- test/bb10-install.js | 100 - test/bb10-uninstall.js | 111 - test/blackberry-install.js | 105 + test/blackberry-uninstall.js | 111 + test/config-changes.js | 2 +- test/ios-config-xml-install.js | 303 +++ test/ios-config-xml-uninstall.js | 227 ++ test/ios-install.js | 260 --- test/ios-plist-install.js | 237 ++ test/ios-plist-uninstall.js | 219 ++ test/ios-uninstall.js | 238 -- test/plugins/ChildBrowser/plugin-old.xml | 83 + test/plugins/ChildBrowser/plugin.xml | 36 +- test/plugins/DummyPlugin/plugin.xml | 17 +- .../plugins/DummyPlugin/src/BlackBerry10/client.js | 19 - test/plugins/DummyPlugin/src/BlackBerry10/index.js | 19 - test/plugins/DummyPlugin/src/blackberry/client.js | 19 + test/plugins/DummyPlugin/src/blackberry/index.js | 19 + test/plugins/FaultyPlugin/plugin.xml | 73 + .../FaultyPlugin/src/android/FaultyPlugin.java | 19 + test/plugins/FaultyPlugin/src/ios/FaultyPlugin.h | 49 + test/plugins/FaultyPlugin/src/ios/FaultyPlugin.m | 86 + test/plugins/PGSQLitePlugin | 1 - test/plugins/WebNotifications/plugin.xml | 6 +- test/plugins/WeblessPlugin/plugin.xml | 21 +- test/plugins/cordova.echo/.gitignore | 1 + test/plugins/cordova.echo/plugin.xml | 33 +- .../cordova.echo/src/BlackBerry10/client.js | 53 - .../src/BlackBerry10/device/echoJnext.so | Bin 1291818 -> 0 bytes .../plugins/cordova.echo/src/BlackBerry10/index.js | 85 - .../cordova.echo/src/BlackBerry10/manifest.json | 5 - .../src/BlackBerry10/public/json/autolink.h | 38 - .../src/BlackBerry10/public/json/config.h | 62 - .../src/BlackBerry10/public/json/features.h | 61 - .../src/BlackBerry10/public/json/forwards.h | 58 - .../src/BlackBerry10/public/json/json.h | 29 - .../src/BlackBerry10/public/json/reader.h | 215 -- .../src/BlackBerry10/public/json/value.h | 1088 --------- .../src/BlackBerry10/public/json/writer.h | 193 -- .../src/BlackBerry10/public/json_batchallocator.h | 144 -- .../src/BlackBerry10/public/json_internalarray.inl | 448 ---- .../src/BlackBerry10/public/json_internalmap.inl | 607 ----- .../src/BlackBerry10/public/json_reader.cpp | 913 -------- .../src/BlackBerry10/public/json_value.cpp | 1745 --------------- .../src/BlackBerry10/public/json_valueiterator.inl | 292 --- .../src/BlackBerry10/public/json_writer.cpp | 848 ------- .../src/BlackBerry10/public/plugin.cpp | 339 --- .../cordova.echo/src/BlackBerry10/public/plugin.h | 89 - .../src/BlackBerry10/public/tokenizer.cpp | 241 -- .../src/BlackBerry10/public/tokenizer.h | 74 - .../src/BlackBerry10/simulator/echoJnext.so | Bin 231778 -> 0 bytes .../cordova.echo/src/BlackBerry10/src/echo.cpp | 121 - .../cordova.echo/src/BlackBerry10/src/echo.hpp | 45 - test/plugins/cordova.echo/src/blackberry/client.js | 53 + .../src/blackberry/device/echoJnext.so | Bin 0 -> 1291818 bytes test/plugins/cordova.echo/src/blackberry/index.js | 85 + .../cordova.echo/src/blackberry/manifest.json | 5 + .../src/blackberry/public/json/autolink.h | 19 + .../src/blackberry/public/json/config.h | 43 + .../src/blackberry/public/json/features.h | 42 + .../src/blackberry/public/json/forwards.h | 39 + .../cordova.echo/src/blackberry/public/json/json.h | 10 + .../src/blackberry/public/json/reader.h | 196 ++ .../src/blackberry/public/json/value.h | 1069 +++++++++ .../src/blackberry/public/json/writer.h | 174 ++ .../src/blackberry/public/json_batchallocator.h | 125 + .../src/blackberry/public/json_internalarray.inl | 448 ++++ .../src/blackberry/public/json_internalmap.inl | 607 +++++ .../src/blackberry/public/json_reader.cpp | 894 ++++++++ .../src/blackberry/public/json_value.cpp | 1726 ++++++++++++++ .../src/blackberry/public/json_valueiterator.inl | 292 +++ .../src/blackberry/public/json_writer.cpp | 829 +++++++ .../cordova.echo/src/blackberry/public/plugin.cpp | 320 +++ .../cordova.echo/src/blackberry/public/plugin.h | 70 + .../src/blackberry/public/tokenizer.cpp | 222 ++ .../cordova.echo/src/blackberry/public/tokenizer.h | 55 + .../src/blackberry/simulator/echoJnext.so | Bin 0 -> 231778 bytes .../cordova.echo/src/blackberry/src/echo.cpp | 121 + .../cordova.echo/src/blackberry/src/echo.hpp | 45 + test/plugins/cordova.echo/src/device/echoJnext.so | Bin 0 -> 1291818 bytes .../cordova.echo/src/simulator/echoJnext.so | Bin 0 -> 231778 bytes test/plugman.js | 178 ++ test/projects/BlackBerry10/www/config.xml | 97 - test/projects/BlackBerry10/www/plugins.xml | 35 - test/projects/FriendSting-Info.plist | 78 + test/projects/android_one/AndroidManifest.xml | 2 + test/projects/blackberry/www/config.xml | 97 + test/projects/blackberry/www/plugins.xml | 35 + test/projects/ios-config-xml/SampleApp-Info.plist | 78 + .../ios-config-xml/SampleApp/SampleApp-Info.plist | 78 + test/projects/ios-config-xml/SampleApp/config.xml | 4 +- .../CordovaLib.xcodeproj/project.pbxproj | 636 ++++++ .../SampleApp.xcodeproj/project.orig.pbxproj | 498 ++++ .../ios-plist/SampleApp.xcodeproj/project.pbxproj | 498 ++++ test/projects/ios-plist/SampleApp/PhoneGap.plist | 53 + .../ios-plist/SampleApp/SampleApp-Info.plist | 80 + .../CordovaLib.xcodeproj/project.pbxproj | 636 ------ .../ios/SampleApp.xcodeproj/project.orig.pbxproj | 498 ---- .../ios/SampleApp.xcodeproj/project.pbxproj | 498 ---- test/projects/ios/SampleApp/PhoneGap.plist | 53 - test/www-only.js | 80 - util/plugin_loader.js | 179 +- util/search-and-replace.js | 37 + 112 files changed, 12001 insertions(+), 10858 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/73047c40/README.md ---------------------------------------------------------------------- diff --cc README.md index 789a35c,1e9fce9..02d4674 --- a/README.md +++ b/README.md @@@ -409,6 -431,6 +431,7 @@@ TODO: show how the foo plugin example f * Mike Reinstein * Anis Kadri * Braden Shepherdson ++* Tim Kim ## Contributors http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/73047c40/platforms/blackberry.js ---------------------------------------------------------------------- diff --cc platforms/blackberry.js index 0000000,b7096bf..cdd89ee mode 000000,100644..100644 --- a/platforms/blackberry.js +++ b/platforms/blackberry.js @@@ -1,0 -1,156 +1,156 @@@ + /* + * + * Copyright 2013 Anis Kadri + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + + var fs = require('fs') // use existsSync in 0.6.x + , path = require('path') + , shell = require('shelljs') + , et = require('elementtree') + , getConfigChanges = require('../util/config-changes') + , sourceDir = 'src' + , xml_helpers = require(path.join(__dirname, '..', 'util', 'xml-helpers')); + + + exports.handlePlugin = function (action, project_dir, plugin_dir, plugin_et) { + var plugin_id = plugin_et._root.attrib['id'] + , version = plugin_et._root.attrib['version'] + , external_hosts = [] + , platformTag = plugin_et.find('./platform[@name="blackberry"]') + + if (!platformTag) { + // Either this plugin doesn't support this platform, or it's a JS-only plugin. + // Either way, return now. + return; + } + + var sourceFiles = platformTag.findall('./source-file') + , libFiles = platformTag.findall('./library-file') + , configChanges = getConfigChanges(platformTag); + // find which config-files we're interested in + Object.keys(configChanges).forEach(function (configFile) { + if (!fs.existsSync(path.resolve(project_dir, configFile))) { + delete configChanges[configFile]; + } + }); + + // collision detection + if(action.match(/force-/) == null) { + if(action == "install" && pluginInstalled(plugin_et, project_dir)) { + throw "Plugin "+plugin_id+" already installed" + } else if(action == "uninstall" && !pluginInstalled(plugin_et, project_dir)) { + throw "Plugin "+plugin_id+" not installed" + } + } else { + action = action.replace('force-', ''); + } + + // move source files + sourceFiles.forEach(function (sourceFile) { + var srcDir = path.resolve(project_dir, + sourceFile.attrib['target-dir']) + , destFile = path.resolve(srcDir, + path.basename(sourceFile.attrib['src'])); + + if (action == 'install') { + shell.mkdir('-p', srcDir); + var srcFile = srcPath(plugin_dir, sourceFile.attrib['src']); + shell.cp(srcFile, destFile); + } else { + fs.unlinkSync(destFile); + // check if directory is empty + var curDir = srcDir; + while(curDir !== path.join(project_dir, 'src')) { + if(fs.readdirSync(curDir).length == 0) { + fs.rmdirSync(curDir); + curDir = path.resolve(curDir, '..'); + } else { + // directory not empty...do nothing + break; + } + } + } + }) + + // move library files + libFiles.forEach(function (libFile) { + var libDir = path.resolve(project_dir, + libFile.attrib['target-dir']) + + if (action == 'install') { + shell.mkdir('-p', libDir); - ++ + var src = path.resolve(plugin_dir, + libFile.attrib['src']), + dest = path.resolve(libDir, + path.basename(libFile.attrib['src'])); + + shell.cp(src, dest); + } else { + var destFile = path.resolve(libDir, + path.basename(libFile.attrib['src'])); + + fs.unlinkSync(destFile); + // check if directory is empty + var files = fs.readdirSync(libDir); + if(files.length == 0) { + shell.rm('-rf', libDir); + } + } + }) + + + // edit configuration files + Object.keys(configChanges).forEach(function (filename) { + var filepath = path.resolve(project_dir, filename), + xmlDoc = xml_helpers.parseElementtreeSync(filepath), + output; + + configChanges[filename].forEach(function (configNode) { + var selector = configNode.attrib["parent"], + children = configNode.findall('*'); + + if( action == 'install') { + if (!xml_helpers.graftXML(xmlDoc, children, selector)) { + throw new Error('failed to add children to ' + filename); + } + } else { + if (!xml_helpers.pruneXML(xmlDoc, children, selector)) { + throw new Error('failed to remove children from' + filename); + } + } + }); + + output = xmlDoc.write({indent: 4}); + fs.writeFileSync(filepath, output); + }); + } + + + function srcPath(pluginPath, filename) { + return path.resolve(pluginPath, filename); + } + + function pluginInstalled(plugin_et, project_dir) { + var config_tag = plugin_et.find('./platform[@name="blackberry"]/config-file[@target="config.xml"]/feature'); + if (!config_tag) { + return false; + } + var plugin_name = config_tag.attrib.id; + return (fs.readFileSync(path.resolve(project_dir, 'config.xml'), 'utf8') + .match(new RegExp(plugin_name, "g")) != null); + } http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/73047c40/plugman.js ---------------------------------------------------------------------- diff --cc plugman.js index 6db4804,9010dfd..eea2549 --- a/plugman.js +++ b/plugman.js @@@ -31,10 -31,11 +31,10 @@@ var fs = require('fs' , platform_modules = { 'android': require('./platforms/android'), 'ios': require('./platforms/ios'), - 'bb10': require('./platforms/bb10') + 'blackberry': require('./platforms/blackberry') }; - var known_opts = { 'platform' : [ 'ios', 'android', 'bb10' ] + var known_opts = { 'platform' : [ 'ios', 'android', 'blackberry' ] - , 'project' : path , 'plugin' : [String, path, url] , 'remove' : Boolean
