[GitHub] cordova-windows pull request #213: CB-12163 Make resource-file copy files ag...

2017-01-25 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/cordova-windows/pull/213


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request #213: CB-12163 Make resource-file copy files ag...

2016-12-14 Thread ktop
Github user ktop commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/213#discussion_r92438038
  
--- Diff: template/cordova/lib/PluginHandler.js ---
@@ -53,18 +53,37 @@ var handlers = {
 },
 'resource-file':{
 install:function(obj, plugin, project, options) {
-// do not copy, but reference the file in the plugin folder. 
This allows to
-// have multiple source files map to the same target and 
select the appropriate
-// one based on the current build settings, e.g. architecture.
-// also, we don't check for existence. This allows to insert 
build variables
-// into the source file name, e.g.
-// 
-var relativeSrcPath = getPluginFilePath(plugin, obj.src, 
project.projectFolder);
-project.addResourceFileToProject(relativeSrcPath, obj.target, 
getTargetConditions(obj));
+var targetConditions = getTargetConditions(obj);
+if (targetConditions.reference) {
+// do not copy, but reference the file in the plugin 
folder. This allows to
+// have multiple source files map to the same target and 
select the appropriate
+// one based on the current build settings, e.g. 
architecture.
+// also, we don't check for existence. This allows to 
insert build variables
+// into the source file name, e.g.
+// 
+var relativeSrcPath = getPluginFilePath(plugin, obj.src, 
project.projectFolder);
+project.addResourceFileToProject(relativeSrcPath, 
obj.target, targetConditions);
+} else {
+// if target already exists, emit warning to consider 
using a reference instead of copying
+if (fs.existsSync(path.resolve(project.root, obj.target))) 
{
+events.emit('warn', ' with target ' + 
obj.target + ' already exists and will be overwritten ' +
+'by a  with the same target. Consider 
using the attribute reference="true" in the ' +
+' tag to avoid overwriting files with 
the same target. ');
--- End diff --

I agree it would make it clearer for users. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request #213: CB-12163 Make resource-file copy files ag...

2016-12-14 Thread vladimir-kotikov
Github user vladimir-kotikov commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/213#discussion_r92344562
  
--- Diff: template/cordova/lib/JsprojManager.js ---
@@ -121,7 +121,12 @@ jsprojManager.prototype = {
 copyToOutputDirectory.text = 'Always';
 children.push(copyToOutputDirectory);
 
-var item = createItemGroupElement('ItemGroup/Content', sourcePath, 
targetConditions, children);
+var item;
--- End diff --

IMO it'd be better to calculate path for `content` element outside this 
method (in `'resource-file'.install`) - this way you will avoid checking the 
same condition (`if (targetConditions.reference) ...`) twice and won't need to 
modify this method at all.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request #213: CB-12163 Make resource-file copy files ag...

2016-12-14 Thread vladimir-kotikov
Github user vladimir-kotikov commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/213#discussion_r92345318
  
--- Diff: template/cordova/lib/PluginHandler.js ---
@@ -188,7 +207,7 @@ module.exports.getUninstaller = function(type) {
 };
 
 function getTargetConditions(obj) {
-return { versions: obj.versions, deviceTarget: obj.deviceTarget, arch: 
obj.arch };
+return { versions: obj.versions, deviceTarget: obj.deviceTarget, arch: 
obj.arch, reference: obj.reference };
--- End diff --

As per comments above `reference` field is not really required - i's easier 
to use `obj.reference` directly


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request #213: CB-12163 Make resource-file copy files ag...

2016-12-14 Thread vladimir-kotikov
Github user vladimir-kotikov commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/213#discussion_r92344997
  
--- Diff: template/cordova/lib/PluginHandler.js ---
@@ -53,18 +53,37 @@ var handlers = {
 },
 'resource-file':{
 install:function(obj, plugin, project, options) {
-// do not copy, but reference the file in the plugin folder. 
This allows to
-// have multiple source files map to the same target and 
select the appropriate
-// one based on the current build settings, e.g. architecture.
-// also, we don't check for existence. This allows to insert 
build variables
-// into the source file name, e.g.
-// 
-var relativeSrcPath = getPluginFilePath(plugin, obj.src, 
project.projectFolder);
-project.addResourceFileToProject(relativeSrcPath, obj.target, 
getTargetConditions(obj));
+var targetConditions = getTargetConditions(obj);
+if (targetConditions.reference) {
+// do not copy, but reference the file in the plugin 
folder. This allows to
+// have multiple source files map to the same target and 
select the appropriate
+// one based on the current build settings, e.g. 
architecture.
+// also, we don't check for existence. This allows to 
insert build variables
+// into the source file name, e.g.
+// 
+var relativeSrcPath = getPluginFilePath(plugin, obj.src, 
project.projectFolder);
+project.addResourceFileToProject(relativeSrcPath, 
obj.target, targetConditions);
+} else {
+// if target already exists, emit warning to consider 
using a reference instead of copying
+if (fs.existsSync(path.resolve(project.root, obj.target))) 
{
+events.emit('warn', ' with target ' + 
obj.target + ' already exists and will be overwritten ' +
+'by a  with the same target. Consider 
using the attribute reference="true" in the ' +
+' tag to avoid overwriting files with 
the same target. ');
--- End diff --

Might be also useful to add that adding `reference` will not copy user 
files to destination directory. WDYT?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request #213: CB-12163 Make resource-file copy files ag...

2016-12-14 Thread vladimir-kotikov
Github user vladimir-kotikov commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/213#discussion_r92344993
  
--- Diff: template/cordova/lib/PluginHandler.js ---
@@ -53,18 +53,37 @@ var handlers = {
 },
 'resource-file':{
 install:function(obj, plugin, project, options) {
-// do not copy, but reference the file in the plugin folder. 
This allows to
-// have multiple source files map to the same target and 
select the appropriate
-// one based on the current build settings, e.g. architecture.
-// also, we don't check for existence. This allows to insert 
build variables
-// into the source file name, e.g.
-// 
-var relativeSrcPath = getPluginFilePath(plugin, obj.src, 
project.projectFolder);
-project.addResourceFileToProject(relativeSrcPath, obj.target, 
getTargetConditions(obj));
+var targetConditions = getTargetConditions(obj);
+if (targetConditions.reference) {
--- End diff --

I think that the object that `getTargetConditions` returns was originally 
meant to hold details about target platform (Win8.1, WP8.1, Win10) and 
architecture to create a `condition` attribute, so `reference` field  doesn't 
really fit here - you might just check `if (obj.reference) ...`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request #213: CB-12163 Make resource-file copy files ag...

2016-12-06 Thread ktop
GitHub user ktop opened a pull request:

https://github.com/apache/cordova-windows/pull/213

CB-12163 Make resource-file copy files again



### Platforms affected
- Windows

### What does this PR do?
- Revert the functionality of resource-file in plugin.xml. It will now copy 
files again instead of using the references. 

### What testing has been done on this change?
- Updated the spec tests and ran them
- Created a new app with the updated resource-file and check to see if it 
copies files. 

### Checklist
- [X] [Reported an issue](http://cordova.apache.org/contribute/issues.html) 
in the JIRA database
- [X] Commit message follows the format: "CB-3232: (android) Fix bug with 
resolving file paths", where CB- is the JIRA ID & "android" is the platform 
affected.
- [X] Added automated test coverage as appropriate for this change.



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/ktop/cordova-windows cb12163

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cordova-windows/pull/213.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #213


commit d00e0c33d388f410d6444920d72b7ac1e86df3ef
Author: ktop 
Date:   2016-12-06T20:58:42Z

CB-12163 Make resource-file copy files again




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org