[GitHub] cordova-windows pull request #207: CB-12142: Move windows-specific logic fro...

2016-11-18 Thread asfgit
Github user asfgit closed the pull request at:

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


---
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 #207: CB-12142: Move windows-specific logic fro...

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

https://github.com/apache/cordova-windows/pull/207#discussion_r87808967
  
--- Diff: template/cordova/lib/PluginInfo.js ---
@@ -0,0 +1,150 @@
+var semver = require('semver');
+var CommonPluginInfo = require('cordova-common').PluginInfo;
+
+var MANIFESTS = {
+'windows': {
+'8.1.0': 'package.windows.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'phone': {
+'8.1.0': 'package.phone.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'all': {
+'8.1.0': ['package.windows.appxmanifest', 
'package.phone.appxmanifest'],
+'10.0.0': 'package.windows10.appxmanifest'
+}
+};
+
+var SUBSTS = ['package.phone.appxmanifest', 
'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
+var TARGETS = ['windows', 'phone', 'all'];
+/*
+A class for holidng the information currently stored in plugin.xml
+It's inherited from cordova-common's PluginInfo class
+In addition it overrides getConfigFiles method to use windows-specific 
logic
+ */
+function PluginInfo(dirname) {
+// We needn't use 'util.inherit' in this case because there aren't any 
methods on prototype in  cordova-common's PluginInfo class
+CommonPluginInfo.apply(this, arguments);
+var parentGetConfigFiles = this.getConfigFiles;
+var parentGetEditConfigs = this.getEditConfigs;
+
+this.getEditConfigs = function(platform) {
+var editConfigs = parentGetEditConfigs(platform);
+return processChanges(editConfigs);
+};
+
+this.getConfigFiles = function(platform) {
+var configFiles = parentGetConfigFiles(platform);
+return processChanges(configFiles);
+};
+
+function processChanges(changes) {
+var hasManifestChanges  = checkManifestChanges(changes);
+
+// Demux 'package.appxmanifest' into relevant platform-specific 
appx manifests.
+// Only spend the cycles if there are version-specific plugin 
settings
+if (hasManifestChanges)
+{
+var oldChanges = changes;
+changes = [];
+
+oldChanges.forEach(function(change, changeIndex) {
+// Only support semver/device-target demux for 
package.appxmanifest
+// Pass through in case something downstream wants to use 
it
+if (change.target !== 'package.appxmanifest') {
+changes.push(change);
+return;
+}
+
+// No semver/device-target for this config-file, pass it 
through
+if (!(hasChangeVersion(change) || 
hasChangeTarget(change))) {
+// New windows template separate manifest files for 
Windows10, Windows8.1 and WP8.1
+changes = 
changes.concat(demuxChangeWithSubsts(change));
+return;
+}
+
+var targetDeviceSet = getDeviceTargetSetForChange(change);
+changes = replaceChangeTarget(targetDeviceSet, change, 
changes);
+});
+}
+return changes;
+}
+
+function checkManifestChanges(changes) {
--- End diff --

You're calling this only once - is there a real need to wrap this into 
function?


---
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 #207: CB-12142: Move windows-specific logic fro...

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

https://github.com/apache/cordova-windows/pull/207#discussion_r87807973
  
--- Diff: template/cordova/lib/PluginInfo.js ---
@@ -0,0 +1,150 @@
+var semver = require('semver');
+var CommonPluginInfo = require('cordova-common').PluginInfo;
+
+var MANIFESTS = {
+'windows': {
+'8.1.0': 'package.windows.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'phone': {
+'8.1.0': 'package.phone.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'all': {
+'8.1.0': ['package.windows.appxmanifest', 
'package.phone.appxmanifest'],
+'10.0.0': 'package.windows10.appxmanifest'
+}
+};
+
+var SUBSTS = ['package.phone.appxmanifest', 
'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
+var TARGETS = ['windows', 'phone', 'all'];
+/*
+A class for holidng the information currently stored in plugin.xml
+It's inherited from cordova-common's PluginInfo class
+In addition it overrides getConfigFiles method to use windows-specific 
logic
+ */
+function PluginInfo(dirname) {
+// We needn't use 'util.inherit' in this case because there aren't any 
methods on prototype in  cordova-common's PluginInfo class
+CommonPluginInfo.apply(this, arguments);
+var parentGetConfigFiles = this.getConfigFiles;
+var parentGetEditConfigs = this.getEditConfigs;
+
+this.getEditConfigs = function(platform) {
+var editConfigs = parentGetEditConfigs(platform);
+return processChanges(editConfigs);
+};
+
+this.getConfigFiles = function(platform) {
+var configFiles = parentGetConfigFiles(platform);
+return processChanges(configFiles);
+};
+
+function processChanges(changes) {
--- End diff --

I'd suggest to move this out of `PluginInfo` - this way it'd be possible to 
use this function in tests (using `rewire`)


---
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 #207: CB-12142: Move windows-specific logic fro...

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

https://github.com/apache/cordova-windows/pull/207#discussion_r87810709
  
--- Diff: template/cordova/lib/PluginInfo.js ---
@@ -0,0 +1,150 @@
+var semver = require('semver');
+var CommonPluginInfo = require('cordova-common').PluginInfo;
+
+var MANIFESTS = {
+'windows': {
+'8.1.0': 'package.windows.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'phone': {
+'8.1.0': 'package.phone.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'all': {
+'8.1.0': ['package.windows.appxmanifest', 
'package.phone.appxmanifest'],
+'10.0.0': 'package.windows10.appxmanifest'
+}
+};
+
+var SUBSTS = ['package.phone.appxmanifest', 
'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
+var TARGETS = ['windows', 'phone', 'all'];
+/*
+A class for holidng the information currently stored in plugin.xml
+It's inherited from cordova-common's PluginInfo class
+In addition it overrides getConfigFiles method to use windows-specific 
logic
+ */
+function PluginInfo(dirname) {
+// We needn't use 'util.inherit' in this case because there aren't any 
methods on prototype in  cordova-common's PluginInfo class
+CommonPluginInfo.apply(this, arguments);
+var parentGetConfigFiles = this.getConfigFiles;
+var parentGetEditConfigs = this.getEditConfigs;
+
+this.getEditConfigs = function(platform) {
+var editConfigs = parentGetEditConfigs(platform);
+return processChanges(editConfigs);
+};
+
+this.getConfigFiles = function(platform) {
+var configFiles = parentGetConfigFiles(platform);
+return processChanges(configFiles);
+};
+
+function processChanges(changes) {
+var hasManifestChanges  = checkManifestChanges(changes);
+
+// Demux 'package.appxmanifest' into relevant platform-specific 
appx manifests.
+// Only spend the cycles if there are version-specific plugin 
settings
+if (hasManifestChanges)
+{
+var oldChanges = changes;
+changes = [];
+
+oldChanges.forEach(function(change, changeIndex) {
+// Only support semver/device-target demux for 
package.appxmanifest
+// Pass through in case something downstream wants to use 
it
+if (change.target !== 'package.appxmanifest') {
+changes.push(change);
+return;
+}
+
+// No semver/device-target for this config-file, pass it 
through
+if (!(hasChangeVersion(change) || 
hasChangeTarget(change))) {
+// New windows template separate manifest files for 
Windows10, Windows8.1 and WP8.1
+changes = 
changes.concat(demuxChangeWithSubsts(change));
+return;
+}
+
+var targetDeviceSet = getDeviceTargetSetForChange(change);
+changes = replaceChangeTarget(targetDeviceSet, change, 
changes);
+});
+}
+return changes;
+}
+
+function checkManifestChanges(changes) {
+return changes.some(function(change) {
+return change.target === 'package.appxmanifest';
+});
+}
+function hasChangeVersion(change) {
+return (typeof change.versions !== 'undefined');
+}
+
+function hasChangeTarget(change) {
+return (typeof change.deviceTarget !== 'undefined');
+}
+
+function demuxChangeWithSubsts(change) {
+return SUBSTS.map(function(subst) {
+ return createChangeWithNewTarget(change, subst);
+});
+}
+
+function createChangeWithNewTarget(change, substTarget) {
+var changeWithNewTarget = {};
+Object.keys(change).forEach(function(changeKey) {
+changeWithNewTarget[changeKey] = change[changeKey];
+});
+changeWithNewTarget.target = substTarget;
+return changeWithNewTarget;
+}
+
+function getDeviceTargetSetForChange(change) {
+var targetDeviceSet = hasChangeTarget(change) ? 
change.deviceTarget : 'all';
+if (TARGETS.indexOf(targetDeviceSet) === -1) {
+// target-device couldn't be resolved, fix it up here to a 
valid value
+targetDeviceSet = 'all';
+}
+return targetDeviceSet;
+}
+
+// This is a local function that creates the new replacement 
representing the
+// mutation.  

[GitHub] cordova-windows pull request #207: CB-12142: Move windows-specific logic fro...

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

https://github.com/apache/cordova-windows/pull/207#discussion_r87809002
  
--- Diff: template/cordova/lib/PluginInfo.js ---
@@ -0,0 +1,150 @@
+var semver = require('semver');
+var CommonPluginInfo = require('cordova-common').PluginInfo;
+
+var MANIFESTS = {
+'windows': {
+'8.1.0': 'package.windows.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'phone': {
+'8.1.0': 'package.phone.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'all': {
+'8.1.0': ['package.windows.appxmanifest', 
'package.phone.appxmanifest'],
+'10.0.0': 'package.windows10.appxmanifest'
+}
+};
+
+var SUBSTS = ['package.phone.appxmanifest', 
'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
+var TARGETS = ['windows', 'phone', 'all'];
+/*
+A class for holidng the information currently stored in plugin.xml
+It's inherited from cordova-common's PluginInfo class
+In addition it overrides getConfigFiles method to use windows-specific 
logic
+ */
+function PluginInfo(dirname) {
+// We needn't use 'util.inherit' in this case because there aren't any 
methods on prototype in  cordova-common's PluginInfo class
+CommonPluginInfo.apply(this, arguments);
+var parentGetConfigFiles = this.getConfigFiles;
+var parentGetEditConfigs = this.getEditConfigs;
+
+this.getEditConfigs = function(platform) {
+var editConfigs = parentGetEditConfigs(platform);
+return processChanges(editConfigs);
+};
+
+this.getConfigFiles = function(platform) {
+var configFiles = parentGetConfigFiles(platform);
+return processChanges(configFiles);
+};
+
+function processChanges(changes) {
+var hasManifestChanges  = checkManifestChanges(changes);
+
+// Demux 'package.appxmanifest' into relevant platform-specific 
appx manifests.
+// Only spend the cycles if there are version-specific plugin 
settings
+if (hasManifestChanges)
+{
+var oldChanges = changes;
+changes = [];
+
+oldChanges.forEach(function(change, changeIndex) {
+// Only support semver/device-target demux for 
package.appxmanifest
+// Pass through in case something downstream wants to use 
it
+if (change.target !== 'package.appxmanifest') {
+changes.push(change);
+return;
+}
+
+// No semver/device-target for this config-file, pass it 
through
+if (!(hasChangeVersion(change) || 
hasChangeTarget(change))) {
+// New windows template separate manifest files for 
Windows10, Windows8.1 and WP8.1
+changes = 
changes.concat(demuxChangeWithSubsts(change));
+return;
+}
+
+var targetDeviceSet = getDeviceTargetSetForChange(change);
+changes = replaceChangeTarget(targetDeviceSet, change, 
changes);
+});
+}
+return changes;
+}
+
+function checkManifestChanges(changes) {
+return changes.some(function(change) {
+return change.target === 'package.appxmanifest';
+});
+}
+function hasChangeVersion(change) {
--- End diff --

Ditto


---
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 #207: CB-12142: Move windows-specific logic fro...

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

https://github.com/apache/cordova-windows/pull/207#discussion_r87810296
  
--- Diff: template/cordova/lib/PluginInfo.js ---
@@ -0,0 +1,150 @@
+var semver = require('semver');
+var CommonPluginInfo = require('cordova-common').PluginInfo;
+
+var MANIFESTS = {
+'windows': {
+'8.1.0': 'package.windows.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'phone': {
+'8.1.0': 'package.phone.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'all': {
+'8.1.0': ['package.windows.appxmanifest', 
'package.phone.appxmanifest'],
+'10.0.0': 'package.windows10.appxmanifest'
+}
+};
+
+var SUBSTS = ['package.phone.appxmanifest', 
'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
+var TARGETS = ['windows', 'phone', 'all'];
+/*
+A class for holidng the information currently stored in plugin.xml
+It's inherited from cordova-common's PluginInfo class
+In addition it overrides getConfigFiles method to use windows-specific 
logic
+ */
+function PluginInfo(dirname) {
+// We needn't use 'util.inherit' in this case because there aren't any 
methods on prototype in  cordova-common's PluginInfo class
+CommonPluginInfo.apply(this, arguments);
+var parentGetConfigFiles = this.getConfigFiles;
+var parentGetEditConfigs = this.getEditConfigs;
+
+this.getEditConfigs = function(platform) {
+var editConfigs = parentGetEditConfigs(platform);
+return processChanges(editConfigs);
+};
+
+this.getConfigFiles = function(platform) {
+var configFiles = parentGetConfigFiles(platform);
+return processChanges(configFiles);
+};
+
+function processChanges(changes) {
+var hasManifestChanges  = checkManifestChanges(changes);
+
+// Demux 'package.appxmanifest' into relevant platform-specific 
appx manifests.
+// Only spend the cycles if there are version-specific plugin 
settings
+if (hasManifestChanges)
+{
+var oldChanges = changes;
+changes = [];
+
+oldChanges.forEach(function(change, changeIndex) {
+// Only support semver/device-target demux for 
package.appxmanifest
+// Pass through in case something downstream wants to use 
it
+if (change.target !== 'package.appxmanifest') {
+changes.push(change);
+return;
+}
+
+// No semver/device-target for this config-file, pass it 
through
+if (!(hasChangeVersion(change) || 
hasChangeTarget(change))) {
+// New windows template separate manifest files for 
Windows10, Windows8.1 and WP8.1
+changes = 
changes.concat(demuxChangeWithSubsts(change));
+return;
+}
+
+var targetDeviceSet = getDeviceTargetSetForChange(change);
+changes = replaceChangeTarget(targetDeviceSet, change, 
changes);
--- End diff --

Consider renaming `replaceChangeTarget` to something more appropriate as it 
doesn't really replace anything in the original array


---
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 #207: CB-12142: Move windows-specific logic fro...

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

https://github.com/apache/cordova-windows/pull/207#discussion_r87809027
  
--- Diff: template/cordova/lib/PluginInfo.js ---
@@ -0,0 +1,150 @@
+var semver = require('semver');
+var CommonPluginInfo = require('cordova-common').PluginInfo;
+
+var MANIFESTS = {
+'windows': {
+'8.1.0': 'package.windows.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'phone': {
+'8.1.0': 'package.phone.appxmanifest',
+'10.0.0': 'package.windows10.appxmanifest'
+},
+'all': {
+'8.1.0': ['package.windows.appxmanifest', 
'package.phone.appxmanifest'],
+'10.0.0': 'package.windows10.appxmanifest'
+}
+};
+
+var SUBSTS = ['package.phone.appxmanifest', 
'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
+var TARGETS = ['windows', 'phone', 'all'];
+/*
+A class for holidng the information currently stored in plugin.xml
+It's inherited from cordova-common's PluginInfo class
+In addition it overrides getConfigFiles method to use windows-specific 
logic
+ */
+function PluginInfo(dirname) {
+// We needn't use 'util.inherit' in this case because there aren't any 
methods on prototype in  cordova-common's PluginInfo class
+CommonPluginInfo.apply(this, arguments);
+var parentGetConfigFiles = this.getConfigFiles;
+var parentGetEditConfigs = this.getEditConfigs;
+
+this.getEditConfigs = function(platform) {
+var editConfigs = parentGetEditConfigs(platform);
+return processChanges(editConfigs);
+};
+
+this.getConfigFiles = function(platform) {
+var configFiles = parentGetConfigFiles(platform);
+return processChanges(configFiles);
+};
+
+function processChanges(changes) {
+var hasManifestChanges  = checkManifestChanges(changes);
+
+// Demux 'package.appxmanifest' into relevant platform-specific 
appx manifests.
+// Only spend the cycles if there are version-specific plugin 
settings
+if (hasManifestChanges)
+{
+var oldChanges = changes;
+changes = [];
+
+oldChanges.forEach(function(change, changeIndex) {
+// Only support semver/device-target demux for 
package.appxmanifest
+// Pass through in case something downstream wants to use 
it
+if (change.target !== 'package.appxmanifest') {
+changes.push(change);
+return;
+}
+
+// No semver/device-target for this config-file, pass it 
through
+if (!(hasChangeVersion(change) || 
hasChangeTarget(change))) {
+// New windows template separate manifest files for 
Windows10, Windows8.1 and WP8.1
+changes = 
changes.concat(demuxChangeWithSubsts(change));
+return;
+}
+
+var targetDeviceSet = getDeviceTargetSetForChange(change);
+changes = replaceChangeTarget(targetDeviceSet, change, 
changes);
+});
+}
+return changes;
+}
+
+function checkManifestChanges(changes) {
+return changes.some(function(change) {
+return change.target === 'package.appxmanifest';
+});
+}
+function hasChangeVersion(change) {
+return (typeof change.versions !== 'undefined');
+}
+
+function hasChangeTarget(change) {
--- End diff --

Same here


---
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