You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/12/24 22:22:53 UTC
[1/3] cordova-lib git commit: CB-8215 Improve error message when
`` is missing `target-dir` on android
Repository: cordova-lib
Updated Branches:
refs/heads/master 2148d9597 -> 68ac4cdbf
CB-8215 Improve error message when `<source-file>` is missing `target-dir` on android
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/68ac4cdb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/68ac4cdb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/68ac4cdb
Branch: refs/heads/master
Commit: 68ac4cdbf13a16a0ff473c90205c3bd38b75beaf
Parents: 7e09363
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Dec 24 16:20:34 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Dec 24 16:22:33 2014 -0500
----------------------------------------------------------------------
cordova-lib/src/plugman/platforms/android.js | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/68ac4cdb/cordova-lib/src/plugman/platforms/android.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/android.js b/cordova-lib/src/plugman/platforms/android.js
index d72a0b1..2073c50 100644
--- a/cordova-lib/src/plugman/platforms/android.js
+++ b/cordova-lib/src/plugman/platforms/android.js
@@ -28,6 +28,7 @@ var path = require('path')
, xml_helpers = require(path.join(__dirname, '..', '..', 'util', 'xml-helpers'))
, properties_parser = require('properties-parser')
, android_project = require('../util/android-project')
+ , CordovaError = require('../../CordovaError')
;
var projectFileCache = {};
@@ -51,9 +52,17 @@ module.exports = {
},
'source-file':{
install:function(source_el, plugin_dir, project_dir, plugin_id) {
- var dest = path.join(source_el.attrib['target-dir'], path.basename(source_el.attrib['src']));
+ var src = source_el.attrib['src'];
+ if (!src) {
+ throw new CordovaError('<source-file> element is missing "src" attribute: ' + source_el);
+ }
+ var targetDir = source_el.attrib['target-dir'];
+ if (!targetDir) {
+ throw new CordovaError('<source-file> element is missing "target-dir" attribute: ' + source_el);
+ }
+ var dest = path.join(targetDir, path.basename(src));
- common.copyNewFile(plugin_dir, source_el.attrib['src'], project_dir, dest);
+ common.copyNewFile(plugin_dir, src, project_dir, dest);
},
uninstall:function(source_el, project_dir, plugin_id) {
var dest = path.join(source_el.attrib['target-dir'], path.basename(source_el.attrib['src']));
@@ -96,7 +105,7 @@ module.exports = {
install:function(source_el, plugin_dir, project_dir, plugin_id) {
var src = source_el.attrib.src;
var custom = source_el.attrib.custom;
- if (!src) throw new Error('src not specified in framework element');
+ if (!src) throw new CordovaError('src not specified in <framework>: ' + source_el);
events.emit('verbose', 'Installing Android library: ' + src);
var parent = source_el.attrib.parent;
@@ -124,7 +133,7 @@ module.exports = {
uninstall:function(source_el, project_dir, plugin_id) {
var src = source_el.attrib.src;
var custom = source_el.attrib.custom;
- if (!src) throw new Error('src not specified in framework element');
+ if (!src) throw new CordovaError('src not specified in <framework>: ' + source_el);
events.emit('verbose', 'Uninstalling Android library: ' + src);
var parent = source_el.attrib.parent;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[3/3] cordova-lib git commit: CB-8216 Resolve plugin paths relative
to original CWD
Posted by ag...@apache.org.
CB-8216 Resolve plugin paths relative to original CWD
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/402d04bf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/402d04bf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/402d04bf
Branch: refs/heads/master
Commit: 402d04bf353095ff2deed353abf41a3515341e38
Parents: 2148d95
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Dec 24 16:19:23 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Dec 24 16:22:33 2014 -0500
----------------------------------------------------------------------
cordova-lib/src/cordova/util.js | 25 +++++++++++++++++++++++++
cordova-lib/src/plugman/fetch.js | 3 ++-
2 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/402d04bf/cordova-lib/src/cordova/util.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/util.js b/cordova-lib/src/cordova/util.js
index 5992ab9..504bcf5 100644
--- a/cordova-lib/src/cordova/util.js
+++ b/cordova-lib/src/cordova/util.js
@@ -33,6 +33,8 @@ if (!global_config_path) {
global_config_path = path.join(HOME, '.cordova');
}
+var origCwd = null;
+
var lib_path = path.join(global_config_path, 'lib');
shell.mkdir('-p', lib_path);
@@ -51,6 +53,8 @@ exports.projectWww = projectWww;
exports.projectConfig = projectConfig;
exports.preProcessOptions = preProcessOptions;
exports.addModuleProperty = addModuleProperty;
+exports.getOrigWorkingDirectory = getOrigWorkingDirectory;
+exports.fixRelativePath = fixRelativePath;
function isRootDir(dir) {
if (fs.existsSync(path.join(dir, 'www'))) {
@@ -109,10 +113,31 @@ function cdProjectRoot() {
if (!projectRoot) {
throw new CordovaError('Current working directory is not a Cordova-based project.');
}
+ if (!origCwd) {
+ origCwd = process.env.PWD || process.cwd();
+ }
+ process.env.PWD = projectRoot;
process.chdir(projectRoot);
return projectRoot;
}
+function getOrigWorkingDirectory() {
+ return origCwd || process.env.PWD || process.cwd();
+}
+
+// Fixes up relative paths that are no longer valid due to chdir() within cdProjectRoot().
+function fixRelativePath(value, /* optional */ cwd) {
+ // Don't touch absolute paths.
+ if (value[1] == ':' || value[0] == path.sep) {
+ return value;
+ }
+ var newDir = cwd || process.env.PWD || process.cwd();
+ var origDir = getOrigWorkingDirectory();
+ var pathDiff = path.relative(newDir, origDir);
+ var ret = path.normalize(path.join(pathDiff, value));
+ return ret;
+}
+
// Recursively deletes .svn folders from a target path
function deleteSvnFolders(dir) {
var contents = fs.readdirSync(dir);
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/402d04bf/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index 48bb9b5..2170611 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -34,6 +34,7 @@ var shell = require('shelljs'),
path = require('path'),
Q = require('q'),
registry = require('./registry/registry');
+var cordovaUtil = require('../cordova/util');
// Cache of PluginInfo objects for plugins in search path.
var localPlugins = null;
@@ -102,7 +103,7 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
var p, // The Q promise to be returned.
linkable = true,
- plugin_dir = path.join(plugin_src, options.subdir);
+ plugin_dir = cordovaUtil.fixRelativePath(path.join(plugin_src, options.subdir));
if (fs.existsSync(plugin_dir)) {
p = Q(plugin_dir);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/3] cordova-lib git commit: CB-8217 Fix plugin add --link when
plugin given as relative path
Posted by ag...@apache.org.
CB-8217 Fix plugin add --link when plugin given as relative path
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/7e093635
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/7e093635
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/7e093635
Branch: refs/heads/master
Commit: 7e093635280e47ce7202fa9876beb57e8a1183b3
Parents: 402d04b
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Dec 24 16:20:00 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Dec 24 16:22:33 2014 -0500
----------------------------------------------------------------------
cordova-lib/src/plugman/fetch.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7e093635/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index 2170611..edc0d43 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -251,8 +251,10 @@ function copyPlugin(plugin_dir, plugins_dir, link) {
var dest = path.join(plugins_dir, pinfo.id);
shell.rm('-rf', dest);
if (link) {
- events.emit('verbose', 'Linking plugin "' + plugin_dir + '" => "' + dest + '"');
- fs.symlinkSync(plugin_dir, dest, 'dir');
+ var isRelativePath = plugin_dir[1] != ':' && plugin_dir[0] != path.sep;
+ var fixedPath = isRelativePath ? path.join(path.relative(plugins_dir, process.env.PWD || process.cwd()), plugin_dir) : plugin_dir;
+ events.emit('verbose', 'Linking "' + dest + '" => "' + fixedPath + '"');
+ fs.symlinkSync(fixedPath, dest, 'dir');
} else {
shell.mkdir('-p', dest);
events.emit('verbose', 'Copying plugin "' + plugin_dir + '" => "' + dest + '"');
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org