You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2017/01/07 00:28:32 UTC
cordova-lib git commit: Move windows-specific logic to cordova-windows
Repository: cordova-lib
Updated Branches:
refs/heads/master e0b0c393e -> 110b46f74
Move windows-specific logic to cordova-windows
This closes #505
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/110b46f7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/110b46f7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/110b46f7
Branch: refs/heads/master
Commit: 110b46f7483b0db0baa59cf5b1bcf17c32dd546d
Parents: e0b0c39
Author: Nikita Matrosov <ma...@gmail.com>
Authored: Tue Nov 1 12:18:45 2016 +0300
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Jan 6 15:44:26 2017 -0800
----------------------------------------------------------------------
.../spec/ConfigChanges/ConfigChanges.spec.js | 33 ------
.../src/ConfigChanges/ConfigChanges.js | 115 +------------------
2 files changed, 1 insertion(+), 147 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/110b46f7/cordova-common/spec/ConfigChanges/ConfigChanges.spec.js
----------------------------------------------------------------------
diff --git a/cordova-common/spec/ConfigChanges/ConfigChanges.spec.js b/cordova-common/spec/ConfigChanges/ConfigChanges.spec.js
index f1c7e6d..11651a2 100644
--- a/cordova-common/spec/ConfigChanges/ConfigChanges.spec.js
+++ b/cordova-common/spec/ConfigChanges/ConfigChanges.spec.js
@@ -39,7 +39,6 @@ var configChanges = require('../../src/ConfigChanges/ConfigChanges'),
android_two_project = path.join(__dirname, '../fixtures/projects/android_two/*'),
android_two_no_perms_project = path.join(__dirname, '../fixtures/projects/android_two_no_perms', '*'),
ios_config_xml = path.join(__dirname, '../fixtures/projects/ios-config-xml/*'),
- windows_testapp_jsproj = path.join(__dirname, '../fixtures/projects/windows/TestApp.jsproj'),
plugins_dir = path.join(temp, 'cordova', 'plugins');
var mungeutil = require('../../src/ConfigChanges/munge-util');
var PlatformJson = require('../../src/PlatformJson');
@@ -189,38 +188,6 @@ describe('config-changes module', function() {
expect(get_munge_change(munge, 'config.xml', '/*', '<access origin="s3.amazonaws.com" />')).toBeDefined();
});
});
-
- describe('for windows project', function() {
- beforeEach(function() {
- shell.cp('-rf', windows_testapp_jsproj, temp);
- });
- it('should special case config-file elements for windows', function() {
- var munger = new configChanges.PlatformMunger('windows', temp, 'unused', null, pluginInfoProvider);
-
- var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(configplugin), {});
- var packageAppxManifest = munge.files['package.appxmanifest'];
- var windows81AppxManifest = munge.files['package.windows.appxmanifest'];
- var winphone81AppxManifest = munge.files['package.phone.appxmanifest'];
- var windows10AppxManifest = munge.files['package.windows10.appxmanifest'];
-
- expect(packageAppxManifest.parents['/Parent/Capabilities'][0].xml).toBe('<Capability Note="should-exist-for-all-appxmanifest-target-files" />');
-
- // 1 comes from versions="=8.1.0" + 1 from versions="=8.1.0" device-target="windows"
- expect(windows81AppxManifest.parents['/Parent/Capabilities'][0].xml).toBe('<Capability Note="should-exist-for-win81-win-and-phone" />');
- expect(windows81AppxManifest.parents['/Parent/Capabilities'][0].count).toBe(2);
- expect(windows81AppxManifest.parents['/Parent/Capabilities'][1].xml).toBe('<Capability Note="should-exist-for-win81-win-only" />');
- expect(windows81AppxManifest.parents['/Parent/Capabilities'][2].xml).toBe('<Capability Note="should-exist-for-win10-and-win81-win-and-phone" />');
-
- // 1 comes from versions="=8.1.0" + 1 from versions="=8.1.0" device-target="phone"
- expect(winphone81AppxManifest.parents['/Parent/Capabilities'][0].xml).toBe('<Capability Note="should-exist-for-win81-win-and-phone" />');
- expect(winphone81AppxManifest.parents['/Parent/Capabilities'][0].count).toBe(2);
- expect(winphone81AppxManifest.parents['/Parent/Capabilities'][1].xml).toBe('<Capability Note="should-exist-for-win81-phone-only" />');
- expect(winphone81AppxManifest.parents['/Parent/Capabilities'][2].xml).toBe('<Capability Note="should-exist-for-win10-and-win81-win-and-phone" />');
-
- expect(windows10AppxManifest.parents['/Parent/Capabilities'][0].xml).toBe('<Capability Note="should-exist-for-win10-and-win81-win-and-phone" />');
- expect(windows10AppxManifest.parents['/Parent/Capabilities'][1].xml).toBe('<Capability Note="should-exist-in-win10-only" />');
- });
- });
});
describe('processing of plugins (via process method)', function() {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/110b46f7/cordova-common/src/ConfigChanges/ConfigChanges.js
----------------------------------------------------------------------
diff --git a/cordova-common/src/ConfigChanges/ConfigChanges.js b/cordova-common/src/ConfigChanges/ConfigChanges.js
index f9201eb..4a58132 100644
--- a/cordova-common/src/ConfigChanges/ConfigChanges.js
+++ b/cordova-common/src/ConfigChanges/ConfigChanges.js
@@ -31,11 +31,8 @@
/* jshint sub:true */
-var fs = require('fs'),
- path = require('path'),
+var path = require('path'),
et = require('elementtree'),
- semver = require('semver'),
- events = require('../events'),
ConfigKeeper = require('./ConfigKeeper'),
CordovaLogger = require('../CordovaLogger');
@@ -109,18 +106,6 @@ function remove_plugin_changes(pluginInfo, is_top_level) {
var munge = mungeutil.decrement_munge(global_munge, config_munge);
for (var file in munge.files) {
- // CB-6976 Windows Universal Apps. Compatibility fix for existing plugins.
- if (self.platform == 'windows' && file == 'package.appxmanifest' &&
- !fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
- // New windows template separate manifest files for Windows10, Windows8.1 and WP8.1
- var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
- /* jshint loopfunc:true */
- substs.forEach(function(subst) {
- events.emit('verbose', 'Applying munge to ' + subst);
- self.apply_file_munge(subst, munge.files[file], true);
- });
- /* jshint loopfunc:false */
- }
self.apply_file_munge(file, munge.files[file], /* remove = */ true);
}
@@ -250,18 +235,6 @@ function munge_helper(should_increment, self, platform_config, config_munge) {
}
for (var file in munge.files) {
- // CB-6976 Windows Universal Apps. Compatibility fix for existing plugins.
- if (self.platform == 'windows' && file == 'package.appxmanifest' &&
- !fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
- var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
- /* jshint loopfunc:true */
- substs.forEach(function(subst) {
- events.emit('verbose', 'Applying munge to ' + subst);
- self.apply_file_munge(subst, munge.files[file]);
- });
- /* jshint loopfunc:false */
- }
-
self.apply_file_munge(file, munge.files[file]);
}
@@ -333,92 +306,6 @@ function generate_plugin_config_munge(pluginInfo, vars, edit_config_changes) {
Array.prototype.push.apply(changes, edit_config_changes);
}
- // Demux 'package.appxmanifest' into relevant platform-specific appx manifests.
- // Only spend the cycles if there are version-specific plugin settings
- if (self.platform === 'windows' &&
- changes.some(function(change) {
- return ((typeof change.versions !== 'undefined') ||
- (typeof change.deviceTarget !== 'undefined'));
- }))
- {
- 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 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;
- }
-
- var hasVersion = (typeof change.versions !== 'undefined');
- var hasTargets = (typeof change.deviceTarget !== 'undefined');
-
- // No semver/device-target for this config-file, pass it through
- if (!(hasVersion || hasTargets)) {
- changes.push(change);
- return;
- }
-
- var targetDeviceSet = hasTargets ? change.deviceTarget : 'all';
- if (['windows', 'phone', 'all'].indexOf(targetDeviceSet) === -1) {
- // target-device couldn't be resolved, fix it up here to a valid value
- targetDeviceSet = 'all';
- }
- var knownWindowsVersionsForTargetDeviceSet = Object.keys(manifests[targetDeviceSet]);
-
- // at this point, 'change' targets package.appxmanifest and has a version attribute
- knownWindowsVersionsForTargetDeviceSet.forEach(function(winver) {
- // This is a local function that creates the new replacement representing the
- // mutation. Used to save code further down.
- var createReplacement = function(manifestFile, originalChange) {
- var replacement = {
- target: manifestFile,
- parent: originalChange.parent,
- after: originalChange.after,
- xmls: originalChange.xmls,
- versions: originalChange.versions,
- deviceTarget: originalChange.deviceTarget
- };
- return replacement;
- };
-
- // version doesn't satisfy, so skip
- if (hasVersion && !semver.satisfies(winver, change.versions)) {
- return;
- }
-
- var versionSpecificManifests = manifests[targetDeviceSet][winver];
- if (versionSpecificManifests.constructor === Array) {
- // e.g. all['8.1.0'] === ['pkg.windows.appxmanifest', 'pkg.phone.appxmanifest']
- versionSpecificManifests.forEach(function(manifestFile) {
- changes.push(createReplacement(manifestFile, change));
- });
- }
- else {
- // versionSpecificManifests is actually a single string
- changes.push(createReplacement(versionSpecificManifests, change));
- }
- });
- });
- }
-
changes.forEach(function(change) {
change.xmls.forEach(function(xml) {
// 1. stringify each xml
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org