Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3289318DEF for ; Wed, 10 Feb 2016 08:09:54 +0000 (UTC) Received: (qmail 17022 invoked by uid 500); 10 Feb 2016 08:09:54 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 16981 invoked by uid 500); 10 Feb 2016 08:09:54 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 16968 invoked by uid 99); 10 Feb 2016 08:09:54 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Feb 2016 08:09:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D4C89E04A2; Wed, 10 Feb 2016 08:09:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: daserge@apache.org To: commits@cordova.apache.org Date: Wed, 10 Feb 2016 08:09:53 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/5] cordova-lib git commit: CB-10482 Remove references to windows8 from cordova-lib/cli Repository: cordova-lib Updated Branches: refs/heads/master ecba9324f -> a3285602b http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-common/spec/fixtures/projects/windows8/www/css/index.css ---------------------------------------------------------------------- diff --git a/cordova-common/spec/fixtures/projects/windows8/www/css/index.css b/cordova-common/spec/fixtures/projects/windows8/www/css/index.css deleted file mode 100644 index 51daa79..0000000 --- a/cordova-common/spec/fixtures/projects/windows8/www/css/index.css +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -* { - -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */ -} - -body { - -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */ - -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */ - -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */ - background-color:#E4E4E4; - background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); - background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); - background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); - background-image:-webkit-gradient( - linear, - left top, - left bottom, - color-stop(0, #A7A7A7), - color-stop(0.51, #E4E4E4) - ); - background-attachment:fixed; - font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif; - font-size:12px; - height:100%; - margin:0px; - padding:0px; - text-transform:uppercase; - width:100%; -} - -/* Portrait layout (default) */ -.app { - background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */ - position:absolute; /* position in the center of the screen */ - left:50%; - top:50%; - height:50px; /* text area height */ - width:225px; /* text area width */ - text-align:center; - padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */ - margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */ - /* offset horizontal: half of text area width */ -} - -/* Landscape layout (with min-width) */ -@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) { - .app { - background-position:left center; - padding:75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */ - margin:-90px 0px 0px -198px; /* offset vertical: half of image height */ - /* offset horizontal: half of image width and text area width */ - } -} - -h1 { - font-size:24px; - font-weight:normal; - margin:0px; - overflow:visible; - padding:0px; - text-align:center; -} - -.event { - border-radius:4px; - -webkit-border-radius:4px; - color:#FFFFFF; - font-size:12px; - margin:0px 30px; - padding:2px 0px; -} - -.event.listening { - background-color:#333333; - display:block; -} - -.event.received { - background-color:#4B946A; - display:none; -} - -@keyframes fade { - from { opacity: 1.0; } - 50% { opacity: 0.4; } - to { opacity: 1.0; } -} - -@-webkit-keyframes fade { - from { opacity: 1.0; } - 50% { opacity: 0.4; } - to { opacity: 1.0; } -} - -.blink { - animation:fade 3000ms infinite; - -webkit-animation:fade 3000ms infinite; -} http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-common/spec/fixtures/projects/windows8/www/img/logo.png ---------------------------------------------------------------------- diff --git a/cordova-common/spec/fixtures/projects/windows8/www/img/logo.png b/cordova-common/spec/fixtures/projects/windows8/www/img/logo.png deleted file mode 100644 index 86a48a8..0000000 Binary files a/cordova-common/spec/fixtures/projects/windows8/www/img/logo.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-common/spec/fixtures/projects/windows8/www/img/smalllogo.png ---------------------------------------------------------------------- diff --git a/cordova-common/spec/fixtures/projects/windows8/www/img/smalllogo.png b/cordova-common/spec/fixtures/projects/windows8/www/img/smalllogo.png deleted file mode 100644 index 0e648ef..0000000 Binary files a/cordova-common/spec/fixtures/projects/windows8/www/img/smalllogo.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-common/spec/fixtures/projects/windows8/www/img/splashscreen.png ---------------------------------------------------------------------- diff --git a/cordova-common/spec/fixtures/projects/windows8/www/img/splashscreen.png b/cordova-common/spec/fixtures/projects/windows8/www/img/splashscreen.png deleted file mode 100644 index d1e6c98..0000000 Binary files a/cordova-common/spec/fixtures/projects/windows8/www/img/splashscreen.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-common/spec/fixtures/projects/windows8/www/img/storelogo.png ---------------------------------------------------------------------- diff --git a/cordova-common/spec/fixtures/projects/windows8/www/img/storelogo.png b/cordova-common/spec/fixtures/projects/windows8/www/img/storelogo.png deleted file mode 100644 index dd00478..0000000 Binary files a/cordova-common/spec/fixtures/projects/windows8/www/img/storelogo.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-common/spec/fixtures/projects/windows8/www/index.html ---------------------------------------------------------------------- diff --git a/cordova-common/spec/fixtures/projects/windows8/www/index.html b/cordova-common/spec/fixtures/projects/windows8/www/index.html deleted file mode 100644 index ca8ab84..0000000 --- a/cordova-common/spec/fixtures/projects/windows8/www/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - Hello World - - -
-

Apache Cordova

- -
- - - - - http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-common/spec/fixtures/projects/windows8/www/js/index.js ---------------------------------------------------------------------- diff --git a/cordova-common/spec/fixtures/projects/windows8/www/js/index.js b/cordova-common/spec/fixtures/projects/windows8/www/js/index.js deleted file mode 100644 index 87b5660..0000000 --- a/cordova-common/spec/fixtures/projects/windows8/www/js/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -var app = { - // Application Constructor - initialize: function() { - this.bindEvents(); - }, - // Bind Event Listeners - // - // Bind any events that are required on startup. Common events are: - // 'load', 'deviceready', 'offline', and 'online'. - bindEvents: function() { - document.addEventListener('deviceready', this.onDeviceReady, false); - }, - // deviceready Event Handler - // - // The scope of 'this' is the event. In order to call the 'receivedEvent' - // function, we must explicitly call 'app.receivedEvent(...);' - onDeviceReady: function() { - app.receivedEvent('deviceready'); - }, - // Update DOM on a Received Event - receivedEvent: function(id) { - var parentElement = document.getElementById(id); - var listeningElement = parentElement.querySelector('.listening'); - var receivedElement = parentElement.querySelector('.received'); - - listeningElement.setAttribute('style', 'display:none;'); - receivedElement.setAttribute('style', 'display:block;'); - - console.log('Received Event: ' + id); - } -}; http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-common/src/ConfigChanges/ConfigChanges.js ---------------------------------------------------------------------- diff --git a/cordova-common/src/ConfigChanges/ConfigChanges.js b/cordova-common/src/ConfigChanges/ConfigChanges.js index a38fca6..a914fc8 100644 --- a/cordova-common/src/ConfigChanges/ConfigChanges.js +++ b/cordova-common/src/ConfigChanges/ConfigChanges.js @@ -106,8 +106,8 @@ function remove_plugin_changes(pluginInfo, is_top_level) { // 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 Windows8, Windows8.1 and WP8.1 - var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows80.appxmanifest', 'package.windows10.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); @@ -149,7 +149,7 @@ function add_plugin_changes(pluginInfo, plugin_vars, is_top_level, should_increm // 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.windows80.appxmanifest', 'package.windows10.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); @@ -203,7 +203,6 @@ function generate_plugin_config_munge(pluginInfo, vars) { { var manifests = { 'windows': { - '8.0.0': 'package.windows80.appxmanifest', '8.1.0': 'package.windows.appxmanifest', '10.0.0': 'package.windows10.appxmanifest' }, @@ -212,7 +211,6 @@ function generate_plugin_config_munge(pluginInfo, vars) { '10.0.0': 'package.windows10.appxmanifest' }, 'all': { - '8.0.0': 'package.windows80.appxmanifest', '8.1.0': ['package.windows.appxmanifest', 'package.phone.appxmanifest'], '10.0.0': 'package.windows10.appxmanifest' } http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-common/src/PluginInfo/PluginInfo.js ---------------------------------------------------------------------- diff --git a/cordova-common/src/PluginInfo/PluginInfo.js b/cordova-common/src/PluginInfo/PluginInfo.js index 073f3f9..2554a3c 100644 --- a/cordova-common/src/PluginInfo/PluginInfo.js +++ b/cordova-common/src/PluginInfo/PluginInfo.js @@ -376,9 +376,6 @@ function addCordova(someArray) { // applied to each element. function _getTags(pelem, tag, platform, transform) { var platformTag = pelem.find('./platform[@name="' + platform + '"]'); - if (platform == 'windows' && !platformTag) { - platformTag = pelem.find('platform[@name="' + 'windows8' + '"]'); - } var tagsInRoot = pelem.findall(tag); tagsInRoot = tagsInRoot || []; var tagsInPlatform = platformTag ? platformTag.findall(tag) : []; @@ -392,9 +389,6 @@ function _getTags(pelem, tag, platform, transform) { // Same as _getTags() but only looks inside a platfrom section. function _getTagsInPlatform(pelem, tag, platform, transform) { var platformTag = pelem.find('./platform[@name="' + platform + '"]'); - if (platform == 'windows' && !platformTag) { - platformTag = pelem.find('platform[@name="' + 'windows8' + '"]'); - } var tags = platformTag ? platformTag.findall(tag) : []; if ( typeof transform === 'function' ) { tags = tags.map(transform); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/spec-cordova/metadata/windows8_parser.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/metadata/windows8_parser.spec.js b/cordova-lib/spec-cordova/metadata/windows8_parser.spec.js deleted file mode 100644 index a1ad7ac..0000000 --- a/cordova-lib/spec-cordova/metadata/windows8_parser.spec.js +++ /dev/null @@ -1,184 +0,0 @@ -/** - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ - -/* jshint boss:true */ - -var windowsParser = require('../../src/cordova/metadata/windows_parser'), - util = require('../../src/cordova/util'), - path = require('path'), - shell = require('shelljs'), - child_process = require('child_process'), - xmlHelpers = require('cordova-common').xmlHelpers, - et = require('elementtree'), - Q = require('q'), - fs = require('fs'), - config = require('../../src/cordova/config'), - Parser = require('../../src/cordova/metadata/parser'), - ConfigParser = require('cordova-common').ConfigParser, - HooksRunner = require('../../src/hooks/HooksRunner'); - -// Create a real config object before mocking out everything. -var cfg = new ConfigParser(path.join(__dirname, '..', 'test-config.xml')); - -describe('windows8 project parser', function() { - - var proj = '/some/path'; - var exists, exec, custom, readdir, config_read; - var winXml; - beforeEach(function() { - exists = spyOn(fs, 'existsSync').andReturn(true); - exec = spyOn(child_process, 'exec').andCallFake(function(cmd, opts, cb) { - if (!cb) cb = opts; - cb(null, '', ''); - }); - custom = spyOn(config, 'has_custom_path').andReturn(false); - config_read = spyOn(config, 'read').andCallFake(function() { - return custom() ? { - lib: { - windows8: { - url: custom() - } - } - } - : ({}); - }); - readdir = spyOn(fs, 'readdirSync').andReturn(['test.jsproj']); - winXml = null; - spyOn(xmlHelpers, 'parseElementtreeSync').andCallFake(function(path) { - return winXml = new et.ElementTree(et.XML('')); - }); - }); - - function wrapper(promise, done, post) { - promise.then(post, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - } - - function errorWrapper(promise, done, post) { - promise.then(function() { - expect('this call').toBe('fail'); - }, post).fin(done); - } - - describe('constructions', function() { - it('should throw if provided directory does not contain a jsproj file', function() { - readdir.andReturn([]); - expect(function() { - new windowsParser(proj); - }).toThrow(); - }); - it('should create an instance with path, manifest properties', function() { - expect(function() { - var parser = new windowsParser(proj); - expect(parser.projDir).toEqual(proj); - expect(parser.manifestPath).toEqual(path.join(proj, 'package.appxmanifest')); - }).not.toThrow(); - }); - it('should be an instance of Parser', function() { - expect(new windowsParser(proj) instanceof Parser).toBe(true); - }); - it('should call super with the correct arguments', function() { - var call = spyOn(Parser, 'call'); - var p = new windowsParser(proj); - expect(call).toHaveBeenCalledWith(p, 'windows8', proj); - }); - }); - - describe('instance', function() { - var parser, cp, rm, is_cordova, write, read, mv, mkdir; - var windows8_proj = path.join(proj, 'platforms', 'windows8'); - beforeEach(function() { - parser = new windowsParser(windows8_proj); - cp = spyOn(shell, 'cp'); - rm = spyOn(shell, 'rm'); - mv = spyOn(shell, 'mv'); - mkdir = spyOn(shell, 'mkdir'); - is_cordova = spyOn(util, 'isCordova').andReturn(proj); - write = spyOn(fs, 'writeFileSync'); - read = spyOn(fs, 'readFileSync').andReturn(''); - }); - - describe('update_from_config method', function() { - beforeEach(function() { - cfg.name = function() { return 'testname'; }; - cfg.content = function() { return 'index.html'; }; - cfg.packageName = function() { return 'testpkg'; }; - cfg.version = function() { return 'one point oh'; }; - readdir.andReturn(['test.sln']); - }); - - it('should write out the app name to package.appxmanifest', function() { - parser.update_from_config(cfg); - var identityNode = winXml.getroot().find('.//Identity'); - expect(identityNode.attrib.Name).toEqual(cfg.packageName()); - }); - - it('should write out the app version to package.appxmanifest', function() { - parser.update_from_config(cfg); - var identityNode = winXml.getroot().find('.//Identity'); - expect(identityNode.attrib.Version).toEqual('one point oh'); - }); - }); - - describe('www_dir method', function() { - it('should return www', function() { - expect(parser.www_dir()).toEqual(path.join(windows8_proj, 'www')); - }); - }); - describe('update_www method', function() { - var update_project; - beforeEach(function() { - update_project = spyOn(parser, 'update_project'); - }); - it('should rm project-level www and cp in platform agnostic www', function() { - parser.update_www(path.join('lib','dir')); - expect(rm).toHaveBeenCalled(); - expect(cp).toHaveBeenCalled(); - }); - }); - describe('update_project method', function() { - var config, www, svn, fire, shellls; - beforeEach(function() { - config = spyOn(parser, 'update_from_config'); - www = spyOn(parser, 'update_www'); - shellls = spyOn(shell, 'ls').andReturn([]); - svn = spyOn(util, 'deleteSvnFolders'); - exists.andReturn(false); - fire = spyOn(HooksRunner.prototype, 'fire').andReturn(Q()); - }); - it('should call update_from_config', function() { - parser.update_project(); - expect(config).toHaveBeenCalled(); - }); - it('should throw if update_from_config throws', function(done) { - var err = new Error('uh oh!'); - config.andCallFake(function() { throw err; }); - errorWrapper(parser.update_project({}), done, function(err) { - expect(err).toEqual(err); - }); - }); - it('should call deleteSvnFolders', function(done) { - wrapper(parser.update_project(), done, function() { - expect(svn).toHaveBeenCalled(); - }); - }); - }); - }); -}); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/spec-cordova/metadata/windows_parser.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/metadata/windows_parser.spec.js b/cordova-lib/spec-cordova/metadata/windows_parser.spec.js new file mode 100644 index 0000000..3f3bf11 --- /dev/null +++ b/cordova-lib/spec-cordova/metadata/windows_parser.spec.js @@ -0,0 +1,168 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +/* jshint boss:true */ + +var windowsParser = require('../../src/cordova/metadata/windows_parser'), + util = require('../../src/cordova/util'), + path = require('path'), + shell = require('shelljs'), + child_process = require('child_process'), + xmlHelpers = require('cordova-common').xmlHelpers, + et = require('elementtree'), + Q = require('q'), + fs = require('fs'), + config = require('../../src/cordova/config'), + Parser = require('../../src/cordova/metadata/parser'), + ConfigParser = require('cordova-common').ConfigParser, + HooksRunner = require('../../src/hooks/HooksRunner'); + +var cfg = new ConfigParser(path.join(__dirname, '..', 'test-config.xml')); + +describe('windows project parser', function() { + + var proj = '/some/path'; + var exists, exec, custom, readdir, config_read; + var winXml; + beforeEach(function() { + exists = spyOn(fs, 'existsSync').andReturn(true); + exec = spyOn(child_process, 'exec').andCallFake(function(cmd, opts, cb) { + if (!cb) cb = opts; + cb(null, '', ''); + }); + custom = spyOn(config, 'has_custom_path').andReturn(false); + config_read = spyOn(config, 'read').andCallFake(function() { + return custom() ? { + lib: { + windows: { + url: custom() + } + } + } + : ({}); + }); + readdir = spyOn(fs, 'readdirSync').andReturn(['TestApp.projitems']); + winXml = null; + spyOn(xmlHelpers, 'parseElementtreeSync').andCallFake(function(path) { + return winXml = new et.ElementTree(et.XML('')); + }); + }); + + function wrapper(promise, done, post) { + promise.then(post, function(err) { + expect(err).toBeUndefined(); + }).fin(done); + } + + function errorWrapper(promise, done, post) { + promise.then(function() { + expect('this call').toBe('fail'); + }, post).fin(done); + } + + describe('constructions', function() { + it('should throw if provided directory does not contain a projitems file', function() { + readdir.andReturn([]); + expect(function() { + new windowsParser(proj); + }).toThrow(); + }); + it('should create an instance with path property', function() { + expect(function() { + var parser = new windowsParser(proj); + expect(parser.projDir).toEqual(proj); + }).not.toThrow(); + }); + it('should be an instance of Parser', function() { + expect(new windowsParser(proj) instanceof Parser).toBe(true); + }); + it('should call super with the correct arguments', function() { + var call = spyOn(Parser, 'call'); + var p = new windowsParser(proj); + expect(call).toHaveBeenCalledWith(p, 'windows', proj); + }); + }); + + describe('instance', function() { + var parser, cp, rm, is_cordova, write, read, mv, mkdir; + var windows_proj = path.join(proj, 'platforms', 'windows'); + beforeEach(function() { + parser = new windowsParser(windows_proj); + cp = spyOn(shell, 'cp'); + rm = spyOn(shell, 'rm'); + mv = spyOn(shell, 'mv'); + mkdir = spyOn(shell, 'mkdir'); + is_cordova = spyOn(util, 'isCordova').andReturn(proj); + write = spyOn(fs, 'writeFileSync'); + read = spyOn(fs, 'readFileSync').andReturn(''); + }); + + describe('update_from_config method', function() { + it('should throw if the platform does not contain prepare script', function() { + expect(function() { + parser.update_from_config(cfg); + }).toThrow(); + }); + }); + + describe('www_dir method', function() { + it('should return www', function() { + expect(parser.www_dir()).toEqual(path.join(windows_proj, 'www')); + }); + }); + describe('update_www method', function() { + var update_project; + beforeEach(function() { + update_project = spyOn(parser, 'update_project'); + }); + it('should rm project-level www and cp in platform agnostic www', function() { + parser.update_www(path.join('lib','dir')); + expect(rm).toHaveBeenCalled(); + expect(cp).toHaveBeenCalled(); + }); + }); + describe('update_project method', function() { + var config, www, svn, fire, shellls; + beforeEach(function() { + config = spyOn(parser, 'update_from_config'); + www = spyOn(parser, 'update_www'); + shellls = spyOn(shell, 'ls').andReturn([]); + svn = spyOn(util, 'deleteSvnFolders'); + exists.andReturn(false); + fire = spyOn(HooksRunner.prototype, 'fire').andReturn(Q()); + }); + it('should call update_from_config', function() { + parser.update_project(); + expect(config).toHaveBeenCalled(); + }); + it('should throw if update_from_config throws', function(done) { + var err = new Error('uh oh!'); + config.andCallFake(function() { throw err; }); + errorWrapper(parser.update_project({}), done, function(err) { + expect(err).toEqual(err); + }); + }); + it('should call deleteSvnFolders', function(done) { + wrapper(parser.update_project(), done, function() { + expect(svn).toHaveBeenCalled(); + }); + }); + }); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/spec-plugman/install.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/install.spec.js b/cordova-lib/spec-plugman/install.spec.js index 8420511..a5895f2 100644 --- a/cordova-lib/spec-plugman/install.spec.js +++ b/cordova-lib/spec-plugman/install.spec.js @@ -50,6 +50,8 @@ var install = require('../src/plugman/install'), 'com.adobe.vars' : path.join(plugins_dir, 'com.adobe.vars'), 'org.test.defaultvariables' : path.join(plugins_dir, 'org.test.defaultvariables'), 'org.test.invalid.engine.script' : path.join(plugins_dir, 'org.test.invalid.engine.script'), + 'org.test.invalid.engine.no.platform' : path.join(plugins_dir, 'org.test.invalid.engine.no.platform'), + 'org.test.invalid.engine.no.scriptSrc' : path.join(plugins_dir, 'org.test.invalid.engine.no.scriptSrc'), 'A' : path.join(plugins_dir, 'dependencies', 'A'), 'B' : path.join(plugins_dir, 'dependencies', 'B'), 'C' : path.join(plugins_dir, 'dependencies', 'C'), @@ -505,18 +507,46 @@ describe('install', function() { }); }); it('should throw if the engine scriptSrc escapes out of the plugin dir.', function(done) { - var success = jasmine.createSpy('success'); - spyOn(PlatformJson.prototype, 'isPluginInstalled').andReturn(false); - install('android', project, plugins['org.test.invalid.engine.script']) - .then(success) - .fail(function(err) { + var success = jasmine.createSpy('success'), + fail = jasmine.createSpy('fail').andCallFake(function(err) { // expect(err).toBeDefined(); expect(err.message.indexOf('security violation:')).toBe(0); + }); + + spyOn(PlatformJson.prototype, 'isPluginInstalled').andReturn(false); + install('android', project, plugins['org.test.invalid.engine.script']) + .then(success) + .fail(fail) + .fin(function() { + expect(success).not.toHaveBeenCalled(); + expect(fail).toHaveBeenCalled(); done(); - }) + }); + }); + it('should throw if a non-default cordova engine platform attribute is not defined.', function(done) { + var success = jasmine.createSpy('success'), + fail = jasmine.createSpy('fail'); + spyOn(PlatformJson.prototype, 'isPluginInstalled').andReturn(false); + install('android', project, plugins['org.test.invalid.engine.no.platform']) + .then(success) + .fail(fail) + .fin(function() { + expect(success).not.toHaveBeenCalled(); + expect(fail).toHaveBeenCalled(); + done(); + }); + }); + it('should throw if a non-default cordova engine scriptSrc attribute is not defined.', function(done) { + var success = jasmine.createSpy('success'), + fail = jasmine.createSpy('fail'); + spyOn(PlatformJson.prototype, 'isPluginInstalled').andReturn(false); + install('android', project, plugins['org.test.invalid.engine.no.scriptSrc']) + .then(success) + .fail(fail) .fin(function() { expect(success).not.toHaveBeenCalled(); + expect(fail).toHaveBeenCalled(); done(); }); }); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/spec-plugman/plugins/org.test.invalid.engine.no.platform/plugin.xml ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/plugins/org.test.invalid.engine.no.platform/plugin.xml b/cordova-lib/spec-plugman/plugins/org.test.invalid.engine.no.platform/plugin.xml new file mode 100644 index 0000000..c35302d --- /dev/null +++ b/cordova-lib/spec-plugman/plugins/org.test.invalid.engine.no.platform/plugin.xml @@ -0,0 +1,28 @@ + + + + + + Engine Choo Choo + + + + + http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/spec-plugman/plugins/org.test.invalid.engine.no.scriptSrc/plugin.xml ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/plugins/org.test.invalid.engine.no.scriptSrc/plugin.xml b/cordova-lib/spec-plugman/plugins/org.test.invalid.engine.no.scriptSrc/plugin.xml new file mode 100644 index 0000000..a928d03 --- /dev/null +++ b/cordova-lib/spec-plugman/plugins/org.test.invalid.engine.no.scriptSrc/plugin.xml @@ -0,0 +1,28 @@ + + + + + + Engine Choo Choo + + + + + http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/src/cordova/lazy_load.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/cordova/lazy_load.js b/cordova-lib/src/cordova/lazy_load.js index f83b539..9079329 100644 --- a/cordova-lib/src/cordova/lazy_load.js +++ b/cordova-lib/src/cordova/lazy_load.js @@ -76,9 +76,6 @@ function Platform(platformString) { // Returns a promise for the path to the lazy-loaded directory. function based_on_config(project_root, platform, opts) { var custom_path = config.has_custom_path(project_root, platform); - if (custom_path === false && platform === 'windows') { - custom_path = config.has_custom_path(project_root, 'windows8'); - } if (custom_path) { var dot_file = config.read(project_root), mixed_platforms = _.extend({}, platforms); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/src/cordova/metadata/windows_parser.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/cordova/metadata/windows_parser.js b/cordova-lib/src/cordova/metadata/windows_parser.js index ae08183..41bf528 100644 --- a/cordova-lib/src/cordova/metadata/windows_parser.js +++ b/cordova-lib/src/cordova/metadata/windows_parser.js @@ -22,39 +22,27 @@ var fs = require('fs'), path = require('path'), util = require('../util'), - events = require('cordova-common').events, shell = require('shelljs'), Q = require('q'), Parser = require('./parser'), ConfigParser = require('cordova-common').ConfigParser, CordovaError = require('cordova-common').CordovaError, - xml = require('cordova-common').xmlHelpers, HooksRunner = require('../../hooks/HooksRunner'); function windows_parser(project) { - try { - this.isOldProjectTemplate = false; // Check that it's a universal windows store project var projFile = fs.readdirSync(project).filter(function(e) { return e.match(/\.projitems$/i); })[0]; + if (!projFile) { - this.isOldProjectTemplate = true; - projFile = fs.readdirSync(project).filter(function(e) { return e.match(/\.jsproj$/i); })[0]; - } - if (!projFile) { - throw new CordovaError('No project file in "'+project+'"'); + throw new CordovaError('No project file in "' + project + '"'); } // Call the base class constructor - Parser.call(this, 'windows8', project); + Parser.call(this, 'windows', project); this.projDir = project; this.projFilePath = path.join(this.projDir, projFile); - - if (this.isOldProjectTemplate) { - this.manifestPath = path.join(this.projDir, 'package.appxmanifest'); - } - } catch(e) { throw new CordovaError('The provided path "' + project + '" is not a Windows project. ' + e); } @@ -65,134 +53,22 @@ require('util').inherits(windows_parser, Parser); module.exports = windows_parser; windows_parser.prototype.update_from_config = function(config) { - //check config parser if (config instanceof ConfigParser) { } else throw new Error('update_from_config requires a ConfigParser object'); - if (!this.isOldProjectTemplate) { - // If there is platform-defined prepare script, require and exec it - var platformPrepare = require(path.join(this.projDir, 'cordova', 'lib', 'prepare')); - platformPrepare.applyPlatformConfig(); - return; - } - - // code below is required for compatibility reason. New template version is not required this anymore. - - //Get manifest file - var manifest = xml.parseElementtreeSync(this.manifestPath); - - var version = this.fixConfigVersion(config.version()); - var name = config.name(); - var pkgName = config.packageName(); - var author = config.author(); - - var identityNode = manifest.find('.//Identity'); - if(identityNode) { - // Update app name in identity - var appIdName = identityNode['attrib']['Name']; - if (appIdName != pkgName) { - identityNode['attrib']['Name'] = pkgName; - } - - // Update app version - var appVersion = identityNode['attrib']['Version']; - if(appVersion != version) { - identityNode['attrib']['Version'] = version; - } - } - - // Update name (windows8 has it in the Application[@Id] and Application.VisualElements[@DisplayName]) - var app = manifest.find('.//Application'); - if(app) { - - var appId = app['attrib']['Id']; - - if (appId != pkgName) { - app['attrib']['Id'] = pkgName; - } - - var visualElems = manifest.find('.//VisualElements') || manifest.find('.//m2:VisualElements'); - - if(visualElems) { - var displayName = visualElems['attrib']['DisplayName']; - if(displayName != name) { - visualElems['attrib']['DisplayName'] = name; - } - } - else { - throw new Error('update_from_config expected a valid package.appxmanifest' + - ' with a node'); - } - } - else { - throw new Error('update_from_config expected a valid package.appxmanifest' + - ' with a node'); - } - - // Update properties - var properties = manifest.find('.//Properties'); - if (properties && properties.find) { - var displayNameElement = properties.find('.//DisplayName'); - if (displayNameElement && displayNameElement.text != name) { - displayNameElement.text = name; - } - - var publisherNameElement = properties.find('.//PublisherDisplayName'); - if (publisherNameElement && publisherNameElement.text != author) { - publisherNameElement.text = author; - } + var platformPrepare; + try { + // The platform must contain the prepare script - require and exec it + platformPrepare = require(path.join(this.projDir, 'cordova', 'lib', 'prepare')); + } catch (e) { + throw new CordovaError('prepare script not found in the platform path "' + this.projDir + '"'); } - // sort Capability elements as per CB-5350 Windows8 build fails due to invalid 'Capabilities' definition - // to sort elements we remove them and then add again in the appropriate order - var capabilitiesRoot = manifest.find('.//Capabilities'), - capabilities = capabilitiesRoot._children || []; - - capabilities.forEach(function(elem){ - capabilitiesRoot.remove(elem); - }); - capabilities.sort(function(a, b) { - return (a.tag > b.tag)? 1: -1; - }); - capabilities.forEach(function(elem){ - capabilitiesRoot.append(elem); - }); - - //Write out manifest - fs.writeFileSync(this.manifestPath, manifest.write({indent: 4}), 'utf-8'); - - // Update icons - var icons = config.getIcons('windows8'); - var platformRoot = this.projDir; - var appRoot = util.isCordova(platformRoot); - - // Icons, that should be added to platform - var platformIcons = [ - {dest: 'images/logo.png', width: 150, height: 150}, - {dest: 'images/smalllogo.png', width: 30, height: 30}, - {dest: 'images/storelogo.png', width: 50, height: 50}, - ]; - - platformIcons.forEach(function (item) { - var icon = icons.getBySize(item.width, item.height) || icons.getDefault(); - if (icon){ - var src = path.join(appRoot, icon.src), - dest = path.join(platformRoot, item.dest); - events.emit('verbose', 'Copying icon from ' + src + ' to ' + dest); - shell.cp('-f', src, dest); - } - }); - - // Update splashscreen - // Image size for Windows 8 should be 620 x 300 px - // See http://msdn.microsoft.com/en-us/library/windows/apps/hh465338.aspx for reference - var splash = config.getSplashScreens('windows8').getBySize(620, 300); - if (splash){ - var src = path.join(appRoot, splash.src), - dest = path.join(platformRoot, 'images/splashscreen.png'); - events.emit('verbose', 'Copying icon from ' + src + ' to ' + dest); - shell.cp('-f', src, dest); + try { + platformPrepare.applyPlatformConfig(); + } catch (e) { + throw new CordovaError('Error occured while trying to call legacy applyPlatformConfig method of the platform prepare script: "' + e + '"'); } }; @@ -238,19 +114,14 @@ windows_parser.prototype.update_www = function() { shell.cp('-rf', path.join(app_www, '*'), this.www_dir()); // Copy all files from merges directory. - // CB-6976 Windows Universal Apps. For smooth transition from 'windows8' platform - // we allow using 'windows8' merges for new 'windows' platform - this.copy_merges('windows8'); this.copy_merges('windows'); // Copy over stock platform www assets (cordova.js) shell.cp('-rf', path.join(platform_www, '*'), this.www_dir()); }; -// calls the nessesary functions to update the windows8 project +// calls the nessesary functions to update the windows project windows_parser.prototype.update_project = function(cfg, opts) { - // console.log("Updating windows8 project..."); - try { this.update_from_config(cfg); } catch(e) { @@ -261,7 +132,7 @@ windows_parser.prototype.update_project = function(cfg, opts) { var projectRoot = util.isCordova(process.cwd()); var hooksRunner = new HooksRunner(projectRoot); - return hooksRunner.fire('pre_package', { wwwPath:this.www_dir(), platforms: [this.isOldProjectTemplate ? 'windows8' : 'windows'], nohooks: opts? opts.nohooks: [] }) + return hooksRunner.fire('pre_package', { wwwPath:this.www_dir(), platforms: ['windows'], nohooks: opts? opts.nohooks: [] }) .then(function() { // overrides (merges) are handled in update_www() that.add_bom(); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/src/cordova/platform.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js index a30b1b9..87f2e58 100644 --- a/cordova-lib/src/cordova/platform.js +++ b/cordova-lib/src/cordova/platform.js @@ -136,14 +136,6 @@ function addHelper(cmd, hooksRunner, projectRoot, targets, opts) { throw new CordovaError('Platform "' + platform + '" is not yet added. See `' + cordova_util.binname + ' platform list`.'); } - - // CB-6976 Windows Universal Apps. Special case to upgrade from windows8 to windows platform - if (platform == 'windows8' && !fs.existsSync(path.join(projectRoot, 'platforms', 'windows'))) { - var platformPathWindows = path.join(projectRoot, 'platforms', 'windows'); - fs.renameSync(platformPath, platformPathWindows); - platform = 'windows'; - platformPath = platformPathWindows; - } } var options = { @@ -592,11 +584,6 @@ function platform(command, targets, opts) { switch (command) { case 'add': - // CB-6976 Windows Universal Apps. windows8 is now alias for windows - var idxWindows8 = targets.indexOf('windows8'); - if (idxWindows8 >=0) { - targets[idxWindows8] = 'windows'; - } return add(hooksRunner, projectRoot, targets, opts); case 'rm': case 'remove': http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/src/platforms/PlatformApiPoly.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/platforms/PlatformApiPoly.js b/cordova-lib/src/platforms/PlatformApiPoly.js index 51d68ea..1258325 100644 --- a/cordova-lib/src/platforms/PlatformApiPoly.js +++ b/cordova-lib/src/platforms/PlatformApiPoly.js @@ -197,12 +197,6 @@ PlatformApiPoly.prototype.prepare = function (cordovaProject, options) { this._config = new ConfigParser(ownConfig); xmlHelpers.mergeXml(cordovaProject.projectConfig.doc.getroot(), this._config.doc.getroot(), this.platform, true); - // CB-6976 Windows Universal Apps. For smooth transition and to prevent mass api failures - // we allow using windows8 tag for new windows platform - if (this.platform == 'windows') { - xmlHelpers.mergeXml(cordovaProject.projectConfig.doc.getroot(), - this._config.doc.getroot(), 'windows8', true); - } this._config.write(); // Update own www dir with project's www assets and plugins' assets and js-files http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/src/platforms/platformsConfig.json ---------------------------------------------------------------------- diff --git a/cordova-lib/src/platforms/platformsConfig.json b/cordova-lib/src/platforms/platformsConfig.json index 9581541..ff5c3d3 100644 --- a/cordova-lib/src/platforms/platformsConfig.json +++ b/cordova-lib/src/platforms/platformsConfig.json @@ -67,14 +67,6 @@ "version": "~3.6.3", "deprecated": false }, - "windows8": { - "hostos": ["win32"], - "parser_file": "../cordova/metadata/windows_parser", - "handler_file": "../plugman/platforms/windows", - "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-windows.git", - "version": "~4.3.0", - "deprecated": false - }, "windows": { "hostos": ["win32"], "parser_file": "../cordova/metadata/windows_parser", http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/src/plugman/install.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js index 6653e07..d0e87df 100644 --- a/cordova-lib/src/plugman/install.js +++ b/cordova-lib/src/plugman/install.js @@ -232,11 +232,11 @@ function getEngines(pluginInfo, platform, project_dir, plugin_dir){ var cordovaEngineIndex, cordovaPlatformEngineIndex, theName, platformIndex, defaultPlatformIndex; // load in known defaults and update when necessary - engines.forEach(function(engine){ + engines.forEach(function(engine) { theName = engine.name; // check to see if the engine is listed as a default engine - if(defaultEngines[theName]){ + if (defaultEngines[theName]) { // make sure engine is for platform we are installing on defaultPlatformIndex = defaultEngines[theName].platform.indexOf(platform); if(defaultPlatformIndex > -1 || defaultEngines[theName].platform === '*'){ @@ -252,14 +252,19 @@ function getEngines(pluginInfo, platform, project_dir, plugin_dir){ uncheckedEngines.push(defaultEngines[theName]); } // check for other engines - }else{ + } else { + if (typeof engine.platform === 'undefined' || typeof engine.scriptSrc === 'undefined') { + throw new CordovaError('warn', 'engine.platform or engine.scriptSrc is not defined in custom engine \'' + + theName + '\' from plugin \'' + pluginInfo.id + '\' for ' + platform); + } + platformIndex = engine.platform.indexOf(platform); // CB-7183: security check for scriptSrc path escaping outside the plugin var scriptSrcPath = path.resolve(plugin_dir, engine.scriptSrc); if (scriptSrcPath.indexOf(plugin_dir) !== 0) { throw new Error('security violation: scriptSrc '+scriptSrcPath+' is out of plugin dir '+plugin_dir); } - if(platformIndex > -1 || engine.platform === '*'){ + if (platformIndex > -1 || engine.platform === '*') { uncheckedEngines.push({ 'name': theName, 'platform': engine.platform, 'scriptSrc':scriptSrcPath, 'minVersion' : engine.version}); } } http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/a3285602/cordova-lib/src/plugman/util/default-engines.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/plugman/util/default-engines.js b/cordova-lib/src/plugman/util/default-engines.js index bd62b12..510ed97 100644 --- a/cordova-lib/src/plugman/util/default-engines.js +++ b/cordova-lib/src/plugman/util/default-engines.js @@ -35,8 +35,6 @@ module.exports = function(project_dir){ { 'platform':'blackberry10', 'scriptSrc': path.join(project_dir,'cordova','version') }, 'cordova-wp8': { 'platform':'wp8', 'scriptSrc': path.join(project_dir,'cordova','version') }, - 'cordova-windows8': - { 'platform':'windows8', 'scriptSrc': path.join(project_dir,'cordova','version') }, 'cordova-windows': { 'platform':'windows', 'scriptSrc': path.join(project_dir,'cordova','version') }, 'apple-xcode' : --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org