You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by da...@apache.org on 2016/08/02 09:17:44 UTC

cordova-windows git commit: CB-11558 Make windows plugin rm remove ProjectReference items

Repository: cordova-windows
Updated Branches:
  refs/heads/master 38ec99c80 -> 43b101a6c


CB-11558 Make windows plugin rm remove ProjectReference items

Also updated the tests to use relative paths to the ProjectReferences and dummy plugin


Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/43b101a6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/43b101a6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/43b101a6

Branch: refs/heads/master
Commit: 43b101a6cbd8392d61e51dca01f25296ae84c89b
Parents: 38ec99c
Author: daserge <v-...@microsoft.com>
Authored: Tue Aug 2 11:54:36 2016 +0300
Committer: daserge <v-...@microsoft.com>
Committed: Tue Aug 2 11:54:36 2016 +0300

----------------------------------------------------------------------
 spec/unit/pluginHandler/windows.spec.js | 17 +++++++++++------
 template/cordova/lib/JsprojManager.js   |  6 +++---
 template/cordova/lib/PluginHandler.js   |  4 ++--
 3 files changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/43b101a6/spec/unit/pluginHandler/windows.spec.js
----------------------------------------------------------------------
diff --git a/spec/unit/pluginHandler/windows.spec.js b/spec/unit/pluginHandler/windows.spec.js
index 38cad37..161f6f5 100644
--- a/spec/unit/pluginHandler/windows.spec.js
+++ b/spec/unit/pluginHandler/windows.spec.js
@@ -65,7 +65,8 @@ beforeEach(function () {
             };
 
             return xml.find(xpath) !== null;
-        }    });
+        }
+    });
 });
 
 var getPluginFilePath = PluginHandler.__get__('getPluginFilePath');
@@ -88,6 +89,10 @@ describe('windows project handler', function () {
         shell.cp('-rf', path.join(__dirname, '../fixtures/DummyProject/*'), cordovaProjectWindowsPlatformDir);
         dummyProject = JsprojManager.getProject(cordovaProjectWindowsPlatformDir);
         shell.mkdir('-p', cordovaProjectPluginsDir);
+        shell.cp('-rf', dummyplugin, cordovaProjectPluginsDir);
+        // CB-11558 Reinitialize plugin.dir to become project_root/plugins/plugin.id to avoid 
+        // different drives issue resulting in absolute path in projectReferences.
+        dummyPluginInfo = new PluginInfo(path.join(cordovaProjectPluginsDir, dummyPluginInfo.id));
     });
 
     afterEach(function () {
@@ -182,7 +187,7 @@ describe('windows project handler', function () {
             it('should copy stuff from one location to another by calling common.copyFile', function () {
                 var source = copyArray(valid_source);
                 install(source[0], dummyPluginInfo, dummyProject);
-                expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, 'src/windows/dummer.js', cordovaProjectWindowsPlatformDir, path.join('plugins', 'org.test.plugins.dummyplugin', 'dummer.js'), false);
+                expect(copyFileSpy).toHaveBeenCalledWith(dummyPluginInfo.dir, 'src/windows/dummer.js', cordovaProjectWindowsPlatformDir, path.join('plugins', 'org.test.plugins.dummyplugin', 'dummer.js'), false);
             });
             it('should throw if source-file src cannot be found', function () {
                 var source = copyArray(invalid_source);
@@ -556,19 +561,19 @@ describe('windows project handler', function () {
                 });
 
                 var xmlPath = 'ItemGroup/ProjectReference';
-                var incText = winJoin(dummyPluginInfo.dir, frameworks[6].src);
+                var incText = winJoin('..', '..', 'plugins', dummyPluginInfo.id, frameworks[6].src);
                 var targetConditions = {versions: undefined, deviceTarget: undefined, arch: 'x64'};
                 validateUninstalledProjects('framework', frameworks[6], xmlPath, incText, targetConditions, ['all']);
 
-                incText = winJoin(dummyPluginInfo.dir, frameworks[7].src);
+                incText = winJoin('..', '..', 'plugins', dummyPluginInfo.id, frameworks[7].src);
                 targetConditions = {versions: '<8.1', deviceTarget: undefined, arch: undefined};
                 validateUninstalledProjects('framework', frameworks[7], xmlPath, incText, targetConditions, ['windows8']);
 
-                incText = winJoin(dummyPluginInfo.dir, frameworks[8].src);
+                incText = winJoin('..', '..', 'plugins', dummyPluginInfo.id, frameworks[8].src);
                 targetConditions = {versions: undefined, deviceTarget: 'win', arch: undefined};
                 validateUninstalledProjects('framework', frameworks[8], xmlPath, incText, targetConditions, ['windows', 'windows8', 'windows10']);
 
-                incText = winJoin(dummyPluginInfo.dir, frameworks[9].src);
+                incText = winJoin('..', '..', 'plugins', dummyPluginInfo.id, frameworks[9].src);
                 targetConditions = {versions: '8.1', deviceTarget: 'all', arch: 'x86'};
                 validateUninstalledProjects('framework', frameworks[9], xmlPath, incText, targetConditions, ['windows', 'phone']);
 

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/43b101a6/template/cordova/lib/JsprojManager.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/JsprojManager.js b/template/cordova/lib/JsprojManager.js
index b9d1d31..21ee808 100644
--- a/template/cordova/lib/JsprojManager.js
+++ b/template/cordova/lib/JsprojManager.js
@@ -182,9 +182,9 @@ jsprojManager.prototype = {
         // relative_path is the actual path to the file in the current OS, where-as inserted_path is what we write in
         // the project file, and is always in Windows format.
         relative_path = path.normalize(relative_path);
-        var inserted_path = path.join('..', '..', relative_path).split('/').join('\\');
+        var inserted_path = relative_path.split('/').join('\\');
 
-        var pluginProjectXML = xml_helpers.parseElementtreeSync(relative_path);
+        var pluginProjectXML = xml_helpers.parseElementtreeSync(path.resolve(this.projectFolder, relative_path));
 
         // find the guid + name of the referenced project
         var projectGuid = pluginProjectXML.find("PropertyGroup/ProjectGuid").text;
@@ -265,7 +265,7 @@ jsprojManager.prototype = {
         var inserted_path = relative_path.split('/').join('\\');
 
         // find the guid + name of the referenced project
-        var pluginProjectXML = xml_helpers.parseElementtreeSync(relative_path);
+        var pluginProjectXML = xml_helpers.parseElementtreeSync(path.resolve(this.projectFolder, relative_path));
         var projectGuid = pluginProjectXML.find("PropertyGroup/ProjectGuid").text;
         var projName = getProjectName(pluginProjectXML, relative_path);
 

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/43b101a6/template/cordova/lib/PluginHandler.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/PluginHandler.js b/template/cordova/lib/PluginHandler.js
index 4856911..e2511f6 100644
--- a/template/cordova/lib/PluginHandler.js
+++ b/template/cordova/lib/PluginHandler.js
@@ -88,7 +88,7 @@ var handlers = {
             var targetDir = obj.targetDir || '';
 
             if(type === 'projectReference') {
-                dest = path.join('plugins', plugin.id, targetDir, src);
+                dest = path.join(path.relative(project.projectFolder, plugin.dir), targetDir, src);
                 project.addProjectReference(dest, getTargetConditions(obj));
             } else {
                 // path.join ignores empty paths passed so we don't check whether targetDir is not empty
@@ -105,7 +105,7 @@ var handlers = {
             var type = obj.type;
 
             if(type === 'projectReference') {
-                project.removeProjectReference(path.join(plugin.dir, src), getTargetConditions(obj));
+                project.removeProjectReference(path.join(path.relative(project.projectFolder, plugin.dir), src), getTargetConditions(obj));
             }
             else {
                 var targetPath = path.join('plugins', plugin.id);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org