You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ka...@apache.org on 2015/03/12 22:43:58 UTC
cordova-lib git commit: CB-8499 Merge platforms.js from cordova and
plugman
Repository: cordova-lib
Updated Branches:
refs/heads/master 92f40d2d4 -> ec45040c9
CB-8499 Merge platforms.js from cordova and plugman
Till now we had two separate places for platform specific code
cordova/metadata exposed via cordova/platforms.js
plugman/platforms exposed via plugman/platforms.js
This change merges the two `platforms.js` files into `platforms/platforms.js`
containing a single class exposing functionality from both places.
The class is instantiated via
prj = platforms.getPlatformProject(platform, project_dir)
`prj` can then be used just like the platform parsers were used before in cordova
e.g. `prj.www_dir()` or the handlers in plugman e.g: `prj.parseProjectFile()`.
This is a compatibility layer so that the platform specific code could be
easier consolidated and eventually moved to the platform repos.
GitHub: close #183
This is a squash of several commits, separate commits can be seen at
https://github.com/kamrik/cordova-lib/tree/platformcode-CB-8595
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/ec45040c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/ec45040c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/ec45040c
Branch: refs/heads/master
Commit: ec45040c9bfe2a84e02fb302dc17a913ce8b67b9
Parents: 92f40d2
Author: Mark Koudritsky <ka...@gmail.com>
Authored: Thu Mar 12 17:40:23 2015 -0400
Committer: Mark Koudritsky <ka...@gmail.com>
Committed: Thu Mar 12 17:43:05 2015 -0400
----------------------------------------------------------------------
cordova-lib/cordova-lib.js | 2 +-
cordova-lib/spec-cordova/build.spec.js | 2 +-
cordova-lib/spec-cordova/cofdova-lib.spec.js | 23 +++++
cordova-lib/spec-cordova/compile.spec.js | 2 +-
cordova-lib/spec-cordova/emulate.spec.js | 2 +-
cordova-lib/spec-cordova/lazy_load.spec.js | 2 +-
.../metadata/android_parser.spec.js | 2 +-
.../metadata/blackberry_parser.spec.js | 2 +-
.../metadata/browser_parser.spec.js | 2 +-
.../metadata/firefoxos_parser.spec.js | 2 +-
.../spec-cordova/metadata/ios_parser.spec.js | 2 +-
.../metadata/windows8_parser.spec.js | 2 +-
.../spec-cordova/metadata/wp8_parser.spec.js | 2 +-
cordova-lib/spec-cordova/prepare.spec.js | 21 +++--
cordova-lib/spec-cordova/run.spec.js | 2 +-
cordova-lib/spec-plugman/platform.spec.js | 44 ---------
.../spec-plugman/util/action-stack.spec.js | 6 +-
cordova-lib/src/PluginInfo.js | 23 ++++-
cordova-lib/src/cordova/lazy_load.js | 2 +-
cordova-lib/src/cordova/platform.js | 6 +-
cordova-lib/src/cordova/platforms.js | 30 ------
cordova-lib/src/cordova/platformsConfig.json | 64 -------------
cordova-lib/src/cordova/prepare.js | 10 +-
cordova-lib/src/cordova/serve.js | 6 +-
cordova-lib/src/cordova/util.js | 2 +-
cordova-lib/src/platforms/platforms.js | 99 ++++++++++++++++++++
cordova-lib/src/platforms/platformsConfig.json | 74 +++++++++++++++
cordova-lib/src/plugman/install.js | 46 ++-------
cordova-lib/src/plugman/platforms.js | 32 -------
cordova-lib/src/plugman/prepare-browserify.js | 8 +-
cordova-lib/src/plugman/prepare.js | 4 +-
cordova-lib/src/plugman/uninstall.js | 57 +++--------
cordova-lib/src/plugman/util/ConfigFile.js | 4 +-
cordova-lib/src/plugman/util/action-stack.js | 9 +-
cordova-lib/src/plugman/util/config-changes.js | 4 +-
35 files changed, 291 insertions(+), 309 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/cordova-lib.js
----------------------------------------------------------------------
diff --git a/cordova-lib/cordova-lib.js b/cordova-lib/cordova-lib.js
index 453bffc..e5540b6 100644
--- a/cordova-lib/cordova-lib.js
+++ b/cordova-lib/cordova-lib.js
@@ -29,7 +29,7 @@ exports = module.exports = {
cordova: require('./src/cordova/cordova'),
events: require('./src/events'),
configparser: require('./src/configparser/ConfigParser.js'),
- cordova_platforms: require('./src/cordova/platforms'),
+ cordova_platforms: require('./src/platforms/platforms'),
//// MAIN CORDOVA TOOLS API
PluginInfo: require('./src/PluginInfo'),
CordovaError: require('./src/CordovaError')
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/build.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/build.spec.js b/cordova-lib/spec-cordova/build.spec.js
index 6b4b4ae..973e961 100644
--- a/cordova-lib/spec-cordova/build.spec.js
+++ b/cordova-lib/spec-cordova/build.spec.js
@@ -17,7 +17,7 @@
under the License.
*/
var cordova = require('../src/cordova/cordova'),
- platforms = require('../src/cordova/platforms'),
+ platforms = require('../src/platforms/platforms'),
HooksRunner = require('../src/hooks/HooksRunner'),
Q = require('q'),
util = require('../src/cordova/util');
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/cofdova-lib.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/cofdova-lib.spec.js b/cordova-lib/spec-cordova/cofdova-lib.spec.js
new file mode 100644
index 0000000..7f734b4
--- /dev/null
+++ b/cordova-lib/spec-cordova/cofdova-lib.spec.js
@@ -0,0 +1,23 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+/* jshint unused:false */
+
+// Verify that cordova-lib.js can be loaded
+var cordovaLib = require('../cordova-lib');
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/compile.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/compile.spec.js b/cordova-lib/spec-cordova/compile.spec.js
index 2a77a7d..ea69743 100644
--- a/cordova-lib/spec-cordova/compile.spec.js
+++ b/cordova-lib/spec-cordova/compile.spec.js
@@ -17,7 +17,7 @@
under the License.
*/
var cordova = require('../src/cordova/cordova'),
- platforms = require('../src/cordova/platforms'),
+ platforms = require('../src/platforms/platforms'),
path = require('path'),
HooksRunner = require('../src/hooks/HooksRunner'),
superspawn = require('../src/cordova/superspawn'),
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/emulate.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/emulate.spec.js b/cordova-lib/spec-cordova/emulate.spec.js
index 51e8f7f..9561447 100644
--- a/cordova-lib/spec-cordova/emulate.spec.js
+++ b/cordova-lib/spec-cordova/emulate.spec.js
@@ -17,7 +17,7 @@
under the License.
*/
var cordova = require('../src/cordova/cordova'),
- platforms = require('../src/cordova/platforms'),
+ platforms = require('../src/platforms/platforms'),
superspawn = require('../src/cordova/superspawn'),
path = require('path'),
HooksRunner = require('../src/hooks/HooksRunner'),
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/lazy_load.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/lazy_load.spec.js b/cordova-lib/spec-cordova/lazy_load.spec.js
index 876b713..a986f27 100644
--- a/cordova-lib/spec-cordova/lazy_load.spec.js
+++ b/cordova-lib/spec-cordova/lazy_load.spec.js
@@ -28,7 +28,7 @@ var lazy_load = require('../src/cordova/lazy_load'),
request = require('request'),
fs = require('fs'),
Q = require('q'),
- platforms = require('../src/cordova/platforms');
+ platforms = require('../src/platforms/platforms');
describe('lazy_load module', function() {
var custom_path, npm_cache_add, fakeLazyLoad;
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/metadata/android_parser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/metadata/android_parser.spec.js b/cordova-lib/spec-cordova/metadata/android_parser.spec.js
index 2673d9c..fd29806 100644
--- a/cordova-lib/spec-cordova/metadata/android_parser.spec.js
+++ b/cordova-lib/spec-cordova/metadata/android_parser.spec.js
@@ -19,7 +19,7 @@
/* jshint boss:true */
-var platforms = require('../../src/cordova/platforms'),
+var platforms = require('../../src/platforms/platforms'),
util = require('../../src/cordova/util'),
path = require('path'),
shell = require('shelljs'),
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/metadata/blackberry_parser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/metadata/blackberry_parser.spec.js b/cordova-lib/spec-cordova/metadata/blackberry_parser.spec.js
index 413dd37..aea0a49 100644
--- a/cordova-lib/spec-cordova/metadata/blackberry_parser.spec.js
+++ b/cordova-lib/spec-cordova/metadata/blackberry_parser.spec.js
@@ -17,7 +17,7 @@
under the License.
*/
-var platforms = require('../../src/cordova/platforms'),
+var platforms = require('../../src/platforms/platforms'),
util = require('../../src/cordova/util'),
path = require('path'),
shell = require('shelljs'),
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/metadata/browser_parser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/metadata/browser_parser.spec.js b/cordova-lib/spec-cordova/metadata/browser_parser.spec.js
index a41adec..2677103 100644
--- a/cordova-lib/spec-cordova/metadata/browser_parser.spec.js
+++ b/cordova-lib/spec-cordova/metadata/browser_parser.spec.js
@@ -17,7 +17,7 @@
under the License.
*/
-var platforms = require('../../src/cordova/platforms'),
+var platforms = require('../../src/platforms/platforms'),
util = require('../../src/cordova/util'),
path = require('path'),
shell = require('shelljs'),
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/metadata/firefoxos_parser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/metadata/firefoxos_parser.spec.js b/cordova-lib/spec-cordova/metadata/firefoxos_parser.spec.js
index c4b0747..c918d16 100644
--- a/cordova-lib/spec-cordova/metadata/firefoxos_parser.spec.js
+++ b/cordova-lib/spec-cordova/metadata/firefoxos_parser.spec.js
@@ -19,7 +19,7 @@
/* jshint boss:true */
-var platforms = require('../../src/cordova/platforms'),
+var platforms = require('../../src/platforms/platforms'),
util = require('../../src/cordova/util'),
path = require('path'),
shell = require('shelljs'),
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/metadata/ios_parser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/metadata/ios_parser.spec.js b/cordova-lib/spec-cordova/metadata/ios_parser.spec.js
index ba2ee45..d338b20 100644
--- a/cordova-lib/spec-cordova/metadata/ios_parser.spec.js
+++ b/cordova-lib/spec-cordova/metadata/ios_parser.spec.js
@@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
-var platforms = require('../../src/cordova/platforms'),
+var platforms = require('../../src/platforms/platforms'),
util = require('../../src/cordova/util'),
path = require('path'),
shell = require('shelljs'),
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/metadata/windows8_parser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/metadata/windows8_parser.spec.js b/cordova-lib/spec-cordova/metadata/windows8_parser.spec.js
index 531f57a..f8371d5 100644
--- a/cordova-lib/spec-cordova/metadata/windows8_parser.spec.js
+++ b/cordova-lib/spec-cordova/metadata/windows8_parser.spec.js
@@ -19,7 +19,7 @@
/* jshint boss:true */
-var platforms = require('../../src/cordova/platforms'),
+var platforms = require('../../src/platforms/platforms'),
util = require('../../src/cordova/util'),
path = require('path'),
shell = require('shelljs'),
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/metadata/wp8_parser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/metadata/wp8_parser.spec.js b/cordova-lib/spec-cordova/metadata/wp8_parser.spec.js
index 4b7db2a..5228fa7 100644
--- a/cordova-lib/spec-cordova/metadata/wp8_parser.spec.js
+++ b/cordova-lib/spec-cordova/metadata/wp8_parser.spec.js
@@ -19,7 +19,7 @@
/* jshint boss:true, sub:true */
-var platforms = require('../../src/cordova/platforms'),
+var platforms = require('../../src/platforms/platforms'),
util = require('../../src/cordova/util'),
path = require('path'),
shell = require('shelljs'),
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/prepare.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/prepare.spec.js b/cordova-lib/spec-cordova/prepare.spec.js
index 793dd2a..87ae5ed 100644
--- a/cordova-lib/spec-cordova/prepare.spec.js
+++ b/cordova-lib/spec-cordova/prepare.spec.js
@@ -25,7 +25,7 @@ var shell = require('shelljs'),
prepare = require('../src/cordova/prepare'),
lazy_load = require('../src/cordova/lazy_load'),
ConfigParser = require('../src/configparser/ConfigParser'),
- platforms = require('../src/cordova/platforms'),
+ platforms = require('../src/platforms/platforms'),
HooksRunner = require('../src/hooks/HooksRunner'),
xmlHelpers = require('../src/util/xml-helpers'),
et = require('elementtree'),
@@ -69,16 +69,17 @@ describe('prepare command', function() {
cd_project_root = spyOn(util, 'cdProjectRoot').andReturn(project_dir);
list_platforms = spyOn(util, 'listPlatforms').andReturn(supported_platforms);
fire = spyOn(HooksRunner.prototype, 'fire').andReturn(Q());
- supported_platforms.forEach(function(p) {
- parsers[p] = jasmine.createSpy(p + ' update_project').andReturn(Q());
- spyOn(platforms[p], 'parser').andReturn({
- update_project:parsers[p],
- update_www: jasmine.createSpy(p + ' update_www'),
+
+ spyOn(platforms, 'getPlatformProject').andCallFake(function(platform, rootDir) {
+ return {
+ update_www: jasmine.createSpy(platform + ' update_www'),
cordovajs_path: function(libDir) { return 'path/to/cordova.js/in/.cordova/lib';},
- www_dir:function() { return path.join(project_dir, 'platforms', p, 'www'); },
- config_xml: function () { return path.join(project_dir, 'platforms', p, 'www', 'config.xml');}
- });
+ www_dir:function() { return path.join(project_dir, 'platforms', platform, 'www'); },
+ config_xml: function () { return path.join(project_dir, 'platforms', platform, 'www', 'config.xml');},
+ update_project: function () { return Q();},
+ };
});
+
plugman_prepare = spyOn(plugman, 'prepare').andReturn(Q());
find_plugins = spyOn(util, 'findPlugins').andReturn([]);
spyOn(PlatformJson, 'load').andReturn(new PlatformJson(null, null, {}));
@@ -96,7 +97,7 @@ describe('prepare command', function() {
describe('failure', function() {
it('should not run outside of a cordova-based project by calling util.isCordova', function(done) {
is_cordova.andReturn(false);
- cd_project_root.andCallThrough();//undo spy here because prepare depends on cdprojectRoot for isCordova check
+ cd_project_root.andCallThrough(); // undo spy here because prepare depends on cdprojectRoot for isCordova check
Q().then(prepare).then(function() {
expect('this call').toBe('fail');
}, function(err) {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-cordova/run.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/run.spec.js b/cordova-lib/spec-cordova/run.spec.js
index 0864807..6271cfe 100644
--- a/cordova-lib/spec-cordova/run.spec.js
+++ b/cordova-lib/spec-cordova/run.spec.js
@@ -17,7 +17,7 @@
under the License.
*/
var cordova = require('../src/cordova/cordova'),
- platforms = require('../src/cordova/platforms'),
+ platforms = require('../src/platforms/platforms'),
superspawn = require('../src/cordova/superspawn'),
path = require('path'),
HooksRunner = require('../src/hooks/HooksRunner'),
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-plugman/platform.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platform.spec.js b/cordova-lib/spec-plugman/platform.spec.js
deleted file mode 100644
index 356e833..0000000
--- a/cordova-lib/spec-plugman/platform.spec.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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 platforms = require('../src/plugman/platforms');
-var pluginTags = ['source-file', 'header-file', 'lib-file', 'resource-file', 'framework'];
-
-function getTest(platformId, pluginTag) {
- return function() {
- it('should exist', function() {
- expect(platforms[platformId][pluginTag] ).toBeDefined();
- });
- it('with an install method', function() {
- expect(platforms[platformId][pluginTag].install ).toBeDefined();
- });
- it('with an uninstall method', function() {
- expect(platforms[platformId][pluginTag].uninstall ).toBeDefined();
- });
- };
-}
-
-for(var platformId in platforms) {
- for(var index = 0, len = pluginTags.length; index < len; index++) {
- var funk = getTest(platformId,pluginTags[index]);
- describe(platformId + ' should have a ' + pluginTags[index] + ' object', funk);
- }
-
-}
-
-
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/spec-plugman/util/action-stack.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/util/action-stack.spec.js b/cordova-lib/spec-plugman/util/action-stack.spec.js
index 0db4734..5eb4847 100644
--- a/cordova-lib/spec-plugman/util/action-stack.spec.js
+++ b/cordova-lib/spec-plugman/util/action-stack.spec.js
@@ -16,7 +16,9 @@
specific language governing permissions and limitations
under the License.
*/
+var path = require('path');
var action_stack = require('../../src/plugman/util/action-stack');
+var android_one_project = path.join(__dirname, '..', 'projects', 'android_one');
describe('action-stack', function() {
var stack;
@@ -34,7 +36,7 @@ describe('action-stack', function() {
stack.push(stack.createAction(first_spy, first_args, function(){}, []));
stack.push(stack.createAction(second_spy, second_args, function(){}, []));
stack.push(stack.createAction(third_spy, third_args, function(){}, []));
- stack.process('android', 'blah');
+ stack.process('android', android_one_project);
expect(first_spy).toHaveBeenCalledWith(first_args[0], jasmine.any(Object));
expect(second_spy).toHaveBeenCalledWith(second_args[0], jasmine.any(Object));
expect(third_spy).toHaveBeenCalledWith(third_args[0], jasmine.any(Object));
@@ -58,7 +60,7 @@ describe('action-stack', function() {
// process should throw
var error;
runs(function() {
- stack.process('android', 'blah').fail(function(err) { error = err; });
+ stack.process('android', android_one_project).fail(function(err) { error = err; });
});
waitsFor(function(){ return error; }, 'process promise never resolved', 500);
runs(function() {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/PluginInfo.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/PluginInfo.js b/cordova-lib/src/PluginInfo.js
index 7aefa15..b037b92 100644
--- a/cordova-lib/src/PluginInfo.js
+++ b/cordova-lib/src/PluginInfo.js
@@ -160,6 +160,7 @@ function PluginInfo(dirname) {
function _parseSourceFile(tag) {
return {
+ itemType: 'source-file',
src: tag.attrib.src,
framework: isStrTrue(tag.attrib.framework),
weak: isStrTrue(tag.attrib.weak),
@@ -175,6 +176,7 @@ function PluginInfo(dirname) {
function getHeaderFiles(platform) {
var headerFiles = _getTagsInPlatform(self._et, 'header-file', platform, function(tag) {
return {
+ itemType: 'header-file',
src: tag.attrib.src,
targetDir: tag.attrib['target-dir']
};
@@ -189,6 +191,7 @@ function PluginInfo(dirname) {
function getResourceFiles(platform) {
var resourceFiles = _getTagsInPlatform(self._et, 'resource-file', platform, function(tag) {
return {
+ itemType: 'resource-file',
src: tag.attrib.src,
target: tag.attrib.target
};
@@ -203,6 +206,7 @@ function PluginInfo(dirname) {
function getLibFiles(platform) {
var libFiles = _getTagsInPlatform(self._et, 'lib-file', platform, function(tag) {
return {
+ itemType: 'lib-file',
src: tag.attrib.src,
arch: tag.attrib.arch,
Include: tag.attrib.Include,
@@ -212,7 +216,7 @@ function PluginInfo(dirname) {
});
return libFiles;
}
-
+
// <hook>
// Example:
// <hook type="before_build" src="scripts/beforeBuild.js" />
@@ -267,7 +271,7 @@ function PluginInfo(dirname) {
return { name: n.attrib.name };
});
};
-
+
self.getPlatformsArray = function() {
return self._et.findall('platform').map(function(n) {
return n.attrib.name;
@@ -276,6 +280,7 @@ function PluginInfo(dirname) {
self.getFrameworks = function(platform) {
return _getTags(self._et, 'framework', platform, function(el) {
var ret = {
+ itemType: 'framework',
type: el.attrib.type,
parent: el.attrib.parent,
custom: isStrTrue(el.attrib.custom),
@@ -288,6 +293,20 @@ function PluginInfo(dirname) {
return ret;
});
};
+
+ self.getFilesAndFrameworks = getFilesAndFrameworks;
+ function getFilesAndFrameworks(platform) {
+ // Please avoid changing the order of the calls below, files will be
+ // installed in this order.
+ var items = [].concat(
+ self.getSourceFiles(platform),
+ self.getHeaderFiles(platform),
+ self.getResourceFiles(platform),
+ self.getFrameworks(platform),
+ self.getLibFiles(platform)
+ );
+ return items;
+ }
///// End of PluginInfo methods /////
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/cordova/lazy_load.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/lazy_load.js b/cordova-lib/src/cordova/lazy_load.js
index bd97805..4b1b270 100644
--- a/cordova-lib/src/cordova/lazy_load.js
+++ b/cordova-lib/src/cordova/lazy_load.js
@@ -24,7 +24,7 @@ var path = require('path'),
_ = require('underscore'),
fs = require('fs'),
shell = require('shelljs'),
- platforms = require('./platforms'),
+ platforms = require('../platforms/platforms'),
npmconf = require('npmconf'),
events = require('../events'),
request = require('request'),
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index 0e3c2e6..d3de237 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -29,7 +29,7 @@ var config = require('./config'),
lazy_load = require('./lazy_load'),
CordovaError = require('../CordovaError'),
Q = require('q'),
- platforms = require('./platforms'),
+ platforms = require('../platforms/platforms'),
promiseutil = require('../util/promise-util'),
superspawn = require('./superspawn'),
semver = require('semver'),
@@ -165,7 +165,7 @@ function addHelper(cmd, hooksRunner, projectRoot, targets, opts) {
}
}).then(function() {
// Save platform@version into platforms.json. i.e: 'android@https://github.com/apache/cordova-android.git'
- // If no version was specified, save the edge version
+ // If no version was specified, save the edge version
var versionToSave = version || platforms[platform].version;
events.emit('verbose', 'saving ' + platform + '@' + versionToSave + ' into platforms.json');
platformMetadata.save(projectRoot, platform, versionToSave);
@@ -630,7 +630,7 @@ function installPluginsForNewPlatform(platform, projectRoot, cfg, opts) {
// The www dir is nuked on each prepare so we keep cordova.js in platform_www
function copy_cordova_js(projectRoot, platform) {
var platformPath = path.join(projectRoot, 'platforms', platform);
- var parser = new platforms[platform].parser(platformPath);
+ var parser = platforms.getPlatformProject(platform, platformPath);
var platform_www = path.join(platformPath, 'platform_www');
shell.mkdir('-p', platform_www);
shell.cp('-f', path.join(parser.www_dir(), 'cordova.js'), path.join(platform_www, 'cordova.js'));
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/cordova/platforms.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platforms.js b/cordova-lib/src/cordova/platforms.js
deleted file mode 100644
index 715d857..0000000
--- a/cordova-lib/src/cordova/platforms.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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 platforms = require('./platformsConfig.json');
-
-var addModuleProperty = require('./util').addModuleProperty;
-Object.keys(platforms).forEach(function(key) {
- var obj = platforms[key];
- if (obj.parser) {
- addModuleProperty(module, 'parser', obj.parser, false, obj);
- }
-});
-
-module.exports = platforms;
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/cordova/platformsConfig.json
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platformsConfig.json b/cordova-lib/src/cordova/platformsConfig.json
deleted file mode 100644
index 7a33fe9..0000000
--- a/cordova-lib/src/cordova/platformsConfig.json
+++ /dev/null
@@ -1,64 +0,0 @@
-{
- "ios": {
- "hostos": ["darwin"],
- "parser": "./metadata/ios_parser",
- "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git",
- "version": "3.8.0"
- },
- "android": {
- "parser": "./metadata/android_parser",
- "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-android.git",
- "version": "3.7.1"
- },
- "ubuntu": {
- "hostos": ["linux"],
- "parser": "./metadata/ubuntu_parser",
- "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-ubuntu.git",
- "version": "4.0.0"
- },
- "amazon-fireos": {
- "parser": "./metadata/amazon_fireos_parser",
- "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-amazon-fireos.git",
- "version": "3.6.3"
- },
- "wp8": {
- "hostos": ["win32"],
- "parser": "./metadata/wp8_parser",
- "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-wp8.git",
- "version": "3.7.1",
- "altplatform": "wp"
- },
- "blackberry10": {
- "parser": "./metadata/blackberry10_parser",
- "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-blackberry.git",
- "version": "3.7.0"
- },
- "www": {
- "hostos": [],
- "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-app-hello-world.git",
- "source": "git",
- "version": "3.6.3"
- },
- "firefoxos": {
- "parser": "./metadata/firefoxos_parser",
- "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-firefoxos.git",
- "version": "3.6.3"
- },
- "windows8": {
- "hostos": ["win32"],
- "parser": "./metadata/windows_parser",
- "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-windows.git",
- "version": "3.8.0"
- },
- "windows": {
- "hostos": ["win32"],
- "parser": "./metadata/windows_parser",
- "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-windows.git",
- "version": "3.8.0"
- },
- "browser": {
- "parser": "./metadata/browser_parser",
- "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-browser.git",
- "version": "3.6.0"
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/cordova/prepare.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/prepare.js b/cordova-lib/src/cordova/prepare.js
index 9256423..cb3f5f7 100644
--- a/cordova-lib/src/cordova/prepare.js
+++ b/cordova-lib/src/cordova/prepare.js
@@ -20,7 +20,7 @@
var cordova_util = require('./util'),
ConfigParser = require('../configparser/ConfigParser'),
path = require('path'),
- platforms = require('./platforms'),
+ platforms = require('../platforms/platforms'),
fs = require('fs'),
shell = require('shelljs'),
et = require('elementtree'),
@@ -31,7 +31,7 @@ var cordova_util = require('./util'),
PlatformMunger = require('../plugman/util/config-changes').PlatformMunger,
PlatformJson = require('../plugman/util/PlatformJson'),
restore = require('./restore-util');
-
+
var PluginInfoProvider = require('../PluginInfoProvider');
@@ -58,7 +58,7 @@ function prepare(options) {
options = cordova_util.preProcessOptions(options);
var paths = options.platforms.map(function(p) {
var platform_path = path.join(projectRoot, 'platforms', p);
- var parser = (new platforms[p].parser(platform_path));
+ var parser = platforms.getPlatformProject(p, platform_path);
return parser.www_dir();
});
options.paths = paths;
@@ -73,8 +73,8 @@ function prepare(options) {
return Q.all(options.platforms.map(function(platform) {
var platformPath = path.join(projectRoot, 'platforms', platform);
- var parser = new platforms[platform].parser(platformPath),
- defaults_xml_path = path.join(platformPath, 'cordova', 'defaults.xml');
+ var parser = platforms.getPlatformProject(platform, platformPath);
+ var defaults_xml_path = path.join(platformPath, 'cordova', 'defaults.xml');
// If defaults.xml is present, overwrite platform config.xml with
// it Otherwise save whatever is there as defaults so it can be
// restored or copy project config into platform if none exists.
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/cordova/serve.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/serve.js b/cordova-lib/src/cordova/serve.js
index 09e5c8e..35ddb52 100644
--- a/cordova-lib/src/cordova/serve.js
+++ b/cordova-lib/src/cordova/serve.js
@@ -21,7 +21,7 @@ var cordova_util = require('./util'),
crypto = require('crypto'),
path = require('path'),
shell = require('shelljs'),
- platforms = require('./platforms'),
+ platforms = require('../platforms/platforms'),
ConfigParser = require('../configparser/ConfigParser'),
HooksRunner = require('../hooks/HooksRunner'),
Q = require('q'),
@@ -111,7 +111,7 @@ function launchServer(projectRoot, port) {
urlPath = urlPath.slice(platformId.length + 1);
try {
- parser = new platforms[platformId].parser(path.join(projectRoot, 'platforms', platformId));
+ parser = platforms.getPlatformProject(platformId, path.join(projectRoot, 'platforms', platformId));
} catch (e) {
return do404();
}
@@ -220,7 +220,7 @@ function calculateMd5(fileName) {
}
function processAddRequest(request, response, platformId, projectRoot) {
- var parser = new platforms[platformId].parser(path.join(projectRoot, 'platforms', platformId));
+ var parser = platforms.getPlatformProject(platformId, path.join(projectRoot, 'platforms', platformId));
var wwwDir = parser.www_dir();
var payload = {
'configPath': '/' + platformId + '/config.xml',
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/cordova/util.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/util.js b/cordova-lib/src/cordova/util.js
index 4382b66..e661c9e 100644
--- a/cordova-lib/src/cordova/util.js
+++ b/cordova-lib/src/cordova/util.js
@@ -157,7 +157,7 @@ function deleteSvnFolders(dir) {
}
function listPlatforms(project_dir) {
- var core_platforms = require('./platforms');
+ var core_platforms = require('../platforms/platforms');
var platforms_dir = path.join(project_dir, 'platforms');
if ( !fs.existsSync(platforms_dir)) {
return [];
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/platforms/platforms.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/platforms/platforms.js b/cordova-lib/src/platforms/platforms.js
new file mode 100644
index 0000000..ee8f314
--- /dev/null
+++ b/cordova-lib/src/platforms/platforms.js
@@ -0,0 +1,99 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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 platforms = require('./platformsConfig.json');
+
+// Remove this block soon. The parser property is no longer used in
+// cordova-lib but some downstream tools still use it.
+var addModuleProperty = require('../cordova/util').addModuleProperty;
+Object.keys(platforms).forEach(function(key) {
+ var obj = platforms[key];
+ if (obj.parser_file) {
+ addModuleProperty(module, 'parser', obj.parser_file, false, obj);
+ }
+});
+
+
+// Avoid loading the same platform projects more than once (identified by path)
+var cachedProjects = {};
+
+var PARSER_PUBLIC_METHODS = [
+ 'config_xml',
+ 'cordovajs_path',
+ 'update_from_config',
+ 'update_project',
+ 'update_www',
+ 'www_dir',
+];
+
+var HANDLER_PUBLIC_METHODS = [
+ 'package_name',
+ 'parseProjectFile',
+ 'purgeProjectFileCache',
+];
+
+
+// A single class that exposes functionality from platform specific files from
+// both places cordova/metadata and plugman/platforms. Hopefully, to be soon
+// replaced by real unified platform specific classes.
+function PlatformProjectAdapter(platform, platformRootDir) {
+ var self = this;
+ self.root = platformRootDir;
+ self.platform = platform;
+ var ParserConstructor = require(platforms[platform].parser_file);
+ self.parser = new ParserConstructor(platformRootDir);
+ self.handler = require(platforms[platform].handler_file);
+
+ // Expose all public methods from the parser and handler, properly bound.
+ PARSER_PUBLIC_METHODS.forEach(function(method) {
+ self[method] = self.parser[method].bind(self.parser);
+ });
+
+ HANDLER_PUBLIC_METHODS.forEach(function(method) {
+ if (self.handler[method]) {
+ self[method] = self.handler[method].bind(self.handler);
+ }
+ });
+
+ self.getInstaller = function(type) {
+ return self.handler[type].install;
+ };
+
+ self.getUninstaller = function(type) {
+ return self.handler[type].uninstall;
+ };
+}
+
+// getPlatformProject() should be the only method of instantiating the
+// PlatformProject classes for now.
+function getPlatformProject(platform, platformRootDir) {
+ var cached = cachedProjects[platformRootDir];
+ if (cached && cached.platform == platform) {
+ return cachedProjects[platformRootDir];
+ } else if (platforms[platform]) {
+ var adapter = new PlatformProjectAdapter(platform, platformRootDir);
+ cachedProjects[platformRootDir] = adapter;
+ return adapter;
+ } else {
+ throw new Error('Unknown platform ' + platform);
+ }
+}
+
+module.exports = platforms;
+module.exports.getPlatformProject = getPlatformProject;
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/platforms/platformsConfig.json
----------------------------------------------------------------------
diff --git a/cordova-lib/src/platforms/platformsConfig.json b/cordova-lib/src/platforms/platformsConfig.json
new file mode 100644
index 0000000..62b194b
--- /dev/null
+++ b/cordova-lib/src/platforms/platformsConfig.json
@@ -0,0 +1,74 @@
+{
+ "ios": {
+ "hostos": ["darwin"],
+ "parser_file": "../cordova/metadata/ios_parser",
+ "handler_file": "../plugman/platforms/ios",
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git",
+ "version": "3.8.0"
+ },
+ "android": {
+ "parser_file": "../cordova/metadata/android_parser",
+ "handler_file": "../plugman/platforms/android",
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-android.git",
+ "version": "3.7.1"
+ },
+ "ubuntu": {
+ "hostos": ["linux"],
+ "parser_file": "../cordova/metadata/ubuntu_parser",
+ "handler_file": "../plugman/platforms/ubuntu",
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-ubuntu.git",
+ "version": "4.0.0"
+ },
+ "amazon-fireos": {
+ "parser_file": "../cordova/metadata/amazon_fireos_parser",
+ "handler_file": "../plugman/platforms/amazon-fireos",
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-amazon-fireos.git",
+ "version": "3.6.3"
+ },
+ "wp8": {
+ "hostos": ["win32"],
+ "parser_file": "../cordova/metadata/wp8_parser",
+ "handler_file": "../plugman/platforms/wp8",
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-wp8.git",
+ "version": "3.7.1",
+ "altplatform": "wp"
+ },
+ "blackberry10": {
+ "parser_file": "../cordova/metadata/blackberry10_parser",
+ "handler_file": "../plugman/platforms/blackberry10",
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-blackberry.git",
+ "version": "3.7.0"
+ },
+ "www": {
+ "hostos": [],
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-app-hello-world.git",
+ "source": "git",
+ "version": "3.6.3"
+ },
+ "firefoxos": {
+ "parser_file": "../cordova/metadata/firefoxos_parser",
+ "handler_file": "../plugman/platforms/firefoxos",
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-firefoxos.git",
+ "version": "3.6.3"
+ },
+ "windows8": {
+ "hostos": ["win32"],
+ "parser_file": "../cordova/metadata/windows_parser",
+ "handler_file": "../plugman/platforms/windows",
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-windows.git",
+ "version": "3.8.0"
+ },
+ "windows": {
+ "hostos": ["win32"],
+ "parser_file": "../cordova/metadata/windows_parser",
+ "handler_file": "../plugman/platforms/windows",
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-windows.git",
+ "version": "3.8.0"
+ },
+ "browser": {
+ "parser_file": "../cordova/metadata/browser_parser",
+ "handler_file": "../plugman/platforms/browser",
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-browser.git",
+ "version": "3.6.0"
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js
index bcdbbac..3e8ab60 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -28,7 +28,7 @@ var path = require('path'),
PlatformJson = require('./util/PlatformJson'),
CordovaError = require('../CordovaError'),
Q = require('q'),
- platform_modules = require('./platforms'),
+ platform_modules = require('../platforms/platforms'),
os = require('os'),
underscore = require('underscore'),
shell = require('shelljs'),
@@ -527,50 +527,18 @@ function handleInstall(actions, pluginInfo, platform, project_dir, plugins_dir,
// @tests - important this event is checked spec/install.spec.js
events.emit('verbose', 'Install start for "' + pluginInfo.id + '" on ' + platform + '.');
-
- var handler = platform_modules[platform];
-
- var sourceFiles = pluginInfo.getSourceFiles(platform);
- var headerFiles = pluginInfo.getHeaderFiles(platform);
- var libFiles = pluginInfo.getLibFiles(platform);
- var resourceFiles = pluginInfo.getResourceFiles(platform);
- var frameworkFiles = pluginInfo.getFrameworks(platform);
+ var handler = platform_modules.getPlatformProject(platform, project_dir);
+ var frameworkFiles = pluginInfo.getFrameworks(platform); // Frameworks are needed later
+ var pluginItems = pluginInfo.getFilesAndFrameworks(platform);
// queue up native stuff
- sourceFiles.forEach(function(item) {
- actions.push(actions.createAction(handler['source-file'].install,
+ pluginItems.forEach(function(item) {
+ actions.push(actions.createAction(handler.getInstaller(item.itemType),
[item, plugin_dir, project_dir, pluginInfo.id, options],
- handler['source-file'].uninstall,
+ handler.getUninstaller(item.itemType),
[item, project_dir, pluginInfo.id, options]));
});
- headerFiles.forEach(function(item) {
- actions.push(actions.createAction(handler['header-file'].install,
- [item, plugin_dir, project_dir, pluginInfo.id, options],
- handler['header-file'].uninstall,
- [item, project_dir, pluginInfo.id, options]));
- });
-
- resourceFiles.forEach(function(item) {
- actions.push(actions.createAction(handler['resource-file'].install,
- [item, plugin_dir, project_dir, pluginInfo.id, options],
- handler['resource-file'].uninstall,
- [item, project_dir, pluginInfo.id, options]));
- });
- frameworkFiles.forEach(function(item) {
- actions.push(actions.createAction(handler['framework'].install,
- [item, plugin_dir, project_dir, pluginInfo.id, options],
- handler['framework'].uninstall,
- [item, project_dir, pluginInfo.id, options]));
- });
- libFiles.forEach(function(item) {
- actions.push(actions.createAction(handler['lib-file'].install,
- [item, plugin_dir, project_dir, pluginInfo.id, options],
- handler['lib-file'].uninstall,
- [item, project_dir, pluginInfo.id, options]));
-
- });
-
// run through the action stack
return actions.process(platform, project_dir)
.then(function(err) {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/plugman/platforms.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms.js b/cordova-lib/src/plugman/platforms.js
deleted file mode 100644
index a99a934..0000000
--- a/cordova-lib/src/plugman/platforms.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
-*/
-
-module.exports = {
- 'android': require('./platforms/android'),
- 'amazon-fireos': require('./platforms/amazon-fireos'),
- 'ios': require('./platforms/ios'),
- 'blackberry10': require('./platforms/blackberry10'),
- 'wp8': require('./platforms/wp8'),
- 'windows8' : require('./platforms/windows'),
- 'windows' : require('./platforms/windows'),
- 'firefoxos': require('./platforms/firefoxos'),
- 'ubuntu': require('./platforms/ubuntu'),
- 'tizen': require('./platforms/tizen'),
- 'browser': require('./platforms/browser')
-};
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/plugman/prepare-browserify.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/prepare-browserify.js b/cordova-lib/src/plugman/prepare-browserify.js
index a69a4f9..3014ed1 100644
--- a/cordova-lib/src/plugman/prepare-browserify.js
+++ b/cordova-lib/src/plugman/prepare-browserify.js
@@ -19,12 +19,10 @@
/* jshint unused:false, expr:true */
-var platform_modules = require('./platforms'),
+var platform_modules = require('../platforms/platforms'),
path = require('path'),
through = require('through2'),
config_changes = require('./util/config-changes'),
- wp8 = require('./platforms/wp8'),
- windows = require('./platforms/windows'),
common = require('./platforms/common'),
fs = require('fs'),
childProcess = require('child_process'),
@@ -143,7 +141,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
events.emit('verbose', 'Preparing ' + platform + ' browserify project');
pluginInfoProvider = pluginInfoProvider || new PluginInfoProvider(); // Allow null for backwards-compat.
var platformJson = PlatformJson.load(plugins_dir, platform);
- var wwwDir = www_dir || platform_modules[platform].www_dir(project_dir);
+ var wwwDir = www_dir || platform_modules.getPlatformProject(platform, project_dir).www_dir();
var scripts = [];
uninstallQueuedPlugins(platformJson, www_dir);
@@ -229,7 +227,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
var cordova_plugins = 'module.exports.metadata = \n';
cordova_plugins += JSON.stringify(pluginMetadata, null, ' ') + '\n';
cordova_plugins += 'modules.exports = modules.exports.metadata;';
-
+
events.emit('verbose', 'Writing out cordova_plugins.js...');
fs.writeFileSync(path.join(wwwDir, 'cordova_plugins.js'), cordova_plugins, 'utf8');
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/plugman/prepare.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/prepare.js b/cordova-lib/src/plugman/prepare.js
index 763605b..55ac90f 100644
--- a/cordova-lib/src/plugman/prepare.js
+++ b/cordova-lib/src/plugman/prepare.js
@@ -19,7 +19,7 @@
/* jshint expr:true, quotmark:false */
-var platform_modules = require('./platforms'),
+var platform_modules = require('../platforms/platforms'),
path = require('path'),
config_changes = require('./util/config-changes'),
common = require('./platforms/common'),
@@ -46,7 +46,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
events.emit('verbose', 'Preparing ' + platform + ' project');
pluginInfoProvider = pluginInfoProvider || new PluginInfoProvider(); // Allow null for backwards-compat.
var platformJson = PlatformJson.load(plugins_dir, platform);
- var wwwDir = www_dir || platform_modules[platform].www_dir(project_dir);
+ var wwwDir = www_dir || platform_modules.getPlatformProject(platform, project_dir).www_dir();
// Check if there are any plugins queued for uninstallation, and if so, remove any of their plugin web assets loaded in
// via <js-module> elements
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/plugman/uninstall.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/uninstall.js b/cordova-lib/src/plugman/uninstall.js
index 4d09996..2a58ced 100644
--- a/cordova-lib/src/plugman/uninstall.js
+++ b/cordova-lib/src/plugman/uninstall.js
@@ -29,7 +29,7 @@ var path = require('path'),
underscore = require('underscore'),
Q = require('q'),
events = require('../events'),
- platform_modules = require('./platforms'),
+ platform_modules = require('../platforms/platforms'),
plugman = require('./plugman'),
promiseutil = require('../util/promise-util'),
HooksRunner = require('../hooks/HooksRunner'),
@@ -293,58 +293,25 @@ function runUninstallPlatform(actions, platform, project_dir, plugin_dir, plugin
function handleUninstall(actions, platform, pluginInfo, project_dir, www_dir, plugins_dir, is_top_level, options) {
var plugin_id = pluginInfo.id;
var plugin_dir = pluginInfo.dir;
- var platform_modules = require('./platforms');
- var handler = platform_modules[platform];
- www_dir = www_dir || handler.www_dir(project_dir);
+ var handler = platform_modules.getPlatformProject(platform, project_dir);
+ www_dir = www_dir || handler.www_dir();
events.emit('log', 'Uninstalling ' + plugin_id + ' from ' + platform);
+ var pluginItems = pluginInfo.getFilesAndFrameworks(platform);
var assets = pluginInfo.getAssets(platform);
- var sourceFiles = pluginInfo.getSourceFiles(platform);
- var headerFiles = pluginInfo.getHeaderFiles(platform);
- var libFiles = pluginInfo.getLibFiles(platform);
- var resourceFiles = pluginInfo.getResourceFiles(platform);
var frameworkFiles = pluginInfo.getFrameworks(platform);
// queue up native stuff
- sourceFiles.forEach(function(source) {
- actions.push(actions.createAction(handler['source-file'].uninstall,
- [source, project_dir, plugin_id, options],
- handler['source-file'].install,
- [source, plugin_dir, project_dir, plugin_id, options]));
+ pluginItems.forEach(function(item) {
+ // CB-5238 Don't uninstall non custom frameworks.
+ if (item.itemType == 'framework' && !item.custom) return;
+ actions.push(actions.createAction(handler.getUninstaller(item.itemType),
+ [item, project_dir, plugin_id, options],
+ handler.getInstaller(item.itemType),
+ [item, plugin_dir, project_dir, plugin_id, options]));
});
- headerFiles.forEach(function(header) {
- actions.push(actions.createAction(handler['header-file'].uninstall,
- [header, project_dir, plugin_id, options],
- handler['header-file'].install,
- [header, plugin_dir, project_dir, plugin_id, options]));
- });
-
- resourceFiles.forEach(function(resource) {
- actions.push(actions.createAction(handler['resource-file'].uninstall,
- [resource, project_dir, plugin_id, options],
- handler['resource-file'].install,
- [resource, plugin_dir, project_dir, options]));
- });
-
- // CB-5238 custom frameworks only
- frameworkFiles.forEach(function(framework) {
- if (framework.custom) {
- actions.push(actions.createAction(handler['framework'].uninstall,
- [framework, project_dir, plugin_id, options],
- handler['framework'].install,
- [framework, plugin_dir, project_dir, options]));
- }
- });
-
- libFiles.forEach(function(libFile) {
- actions.push(actions.createAction(handler['lib-file'].uninstall,
- [libFile, project_dir, plugin_id, options],
- handler['lib-file'].install,
- [libFile, plugin_dir, project_dir, plugin_id, options]));
- });
-
- // queue up asset installation
+ // queue up asset uninstallation
var common = require('./platforms/common');
assets.forEach(function(asset) {
actions.push(actions.createAction(common.asset.uninstall, [asset, www_dir, plugin_id], common.asset.install, [asset, plugin_dir, www_dir]));
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/plugman/util/ConfigFile.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/ConfigFile.js b/cordova-lib/src/plugman/util/ConfigFile.js
index 9af5c87..c317668 100644
--- a/cordova-lib/src/plugman/util/ConfigFile.js
+++ b/cordova-lib/src/plugman/util/ConfigFile.js
@@ -22,7 +22,7 @@ var et = require('elementtree');
var glob = require('glob');
var plist = require('plist');
-var platforms = require('./../platforms');
+var platforms = require('../../platforms/platforms');
var plist_helpers = require('./../util/plist-helpers');
var xml_helpers = require('../../util/xml-helpers');
@@ -69,7 +69,7 @@ function ConfigFile_load() {
self.data = xml_helpers.parseElementtreeSync(filepath);
} else if (ext == '.pbxproj') {
self.type = 'pbxproj';
- var projectFile = platforms.ios.parseProjectFile(self.project_dir);
+ var projectFile = platforms.getPlatformProject('ios', self.project_dir).parseProjectFile(self.project_dir);
self.data = projectFile.xcode;
self.cordovaVersion = projectFile.cordovaVersion;
} else {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/plugman/util/action-stack.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/action-stack.js b/cordova-lib/src/plugman/util/action-stack.js
index a62883d..c8bd21b 100644
--- a/cordova-lib/src/plugman/util/action-stack.js
+++ b/cordova-lib/src/plugman/util/action-stack.js
@@ -19,7 +19,7 @@
/* jshint quotmark:false */
-var platforms = require("../platforms"),
+var platforms = require("../../platforms/platforms"),
events = require('../../events'),
Q = require('q');
@@ -50,12 +50,13 @@ ActionStack.prototype = {
var project_files;
// parse platform-specific project files once
- if (platforms[platform].parseProjectFile) {
+ var platformProject = platforms.getPlatformProject(platform, project_dir);
+ if (platformProject.parseProjectFile) {
events.emit('verbose', 'Parsing ' + platform + ' project files...');
- project_files = platforms[platform].parseProjectFile(project_dir);
+ project_files = platformProject.parseProjectFile(project_dir);
}
- while(this.stack.length) {
+ while (this.stack.length) {
var action = this.stack.shift();
var handler = action.handler.run;
var action_params = action.handler.params;
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ec45040c/cordova-lib/src/plugman/util/config-changes.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/config-changes.js b/cordova-lib/src/plugman/util/config-changes.js
index b1cf0bb..7d7d69c 100644
--- a/cordova-lib/src/plugman/util/config-changes.js
+++ b/cordova-lib/src/plugman/util/config-changes.js
@@ -36,7 +36,7 @@ var fs = require('fs'),
path = require('path'),
et = require('elementtree'),
semver = require('semver'),
- platforms = require('./../platforms'),
+ platforms = require('../../platforms/platforms'),
events = require('../../events'),
ConfigKeeper = require('./ConfigKeeper');
@@ -70,7 +70,7 @@ function PlatformMunger(platform, project_dir, plugins_dir, platformJson, plugin
this.platform = platform;
this.project_dir = project_dir;
this.plugins_dir = plugins_dir;
- this.platform_handler = platforms[platform];
+ this.platform_handler = platforms.getPlatformProject(platform, project_dir);
this.config_keeper = new ConfigKeeper(project_dir);
this.platformJson = platformJson;
this.pluginInfoProvider = pluginInfoProvider;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org