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 CFF83EED4 for ; Wed, 9 Jan 2013 23:00:36 +0000 (UTC) Received: (qmail 74454 invoked by uid 500); 9 Jan 2013 23:00:36 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 74380 invoked by uid 500); 9 Jan 2013 23:00:36 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 74229 invoked by uid 99); 9 Jan 2013 23:00:36 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jan 2013 23:00:36 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 08D6C122DB; Wed, 9 Jan 2013 23:00:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: filmaj@apache.org To: commits@cordova.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [1/11] updates for 2.3.0 support. bumped version. removed checked-in native project fixtures for tests, now on install create fixtures based on actual `create` scripts for platforms. Message-Id: <20130109230036.08D6C122DB@tyr.zones.apache.org> Date: Wed, 9 Jan 2013 23:00:36 +0000 (UTC) http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/css/index.css ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/css/index.css b/spec/fixtures/projects/native/ios/www/css/index.css deleted file mode 100644 index f1f9d76..0000000 --- a/spec/fixtures/projects/native/ios/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-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-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */ - -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */ -} - -body { - 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-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/img/logo.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/img/logo.png b/spec/fixtures/projects/native/ios/www/img/logo.png deleted file mode 100644 index 9519e7d..0000000 Binary files a/spec/fixtures/projects/native/ios/www/img/logo.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/index.html ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/index.html b/spec/fixtures/projects/native/ios/www/index.html deleted file mode 100644 index 92484ad..0000000 --- a/spec/fixtures/projects/native/ios/www/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - Hello World - - -
-

Apache Cordova

- -
- - - - - http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/js/index.js ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/js/index.js b/spec/fixtures/projects/native/ios/www/js/index.js deleted file mode 100644 index 3b75d3f..0000000 --- a/spec/fixtures/projects/native/ios/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 explicity 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-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-57-2x.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-57-2x.png b/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-57-2x.png deleted file mode 100644 index efd9c37..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-57-2x.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-57.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-57.png b/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-57.png deleted file mode 100644 index c795fc4..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-57.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-72-2x.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-72-2x.png b/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-72-2x.png deleted file mode 100644 index dd819da..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-72-2x.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-72.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-72.png b/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-72.png deleted file mode 100644 index b1cfde7..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/icon/ios/icon-72.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-landscape-2x.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-landscape-2x.png b/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-landscape-2x.png deleted file mode 100644 index 95c542d..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-landscape-2x.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-landscape.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-landscape.png b/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-landscape.png deleted file mode 100644 index 04be5ac..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-landscape.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-portrait-2x.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-portrait-2x.png b/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-portrait-2x.png deleted file mode 100644 index aae1862..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-portrait-2x.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-portrait.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-portrait.png b/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-portrait.png deleted file mode 100644 index 41e839d..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-ipad-portrait.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-landscape-2x.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-landscape-2x.png b/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-landscape-2x.png deleted file mode 100644 index 0165669..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-landscape-2x.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-landscape.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-landscape.png b/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-landscape.png deleted file mode 100644 index d154883..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-landscape.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-portrait-2x.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-portrait-2x.png b/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-portrait-2x.png deleted file mode 100644 index bd24886..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-portrait-2x.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-portrait.png ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-portrait.png b/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-portrait.png deleted file mode 100644 index 6fcba56..0000000 Binary files a/spec/fixtures/projects/native/ios/www/res/screen/ios/screen-iphone-portrait.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/fixtures/projects/test/www/config.xml ---------------------------------------------------------------------- diff --git a/spec/fixtures/projects/test/www/config.xml b/spec/fixtures/projects/test/www/config.xml index 84b4137..cfb59fc 100644 --- a/spec/fixtures/projects/test/www/config.xml +++ b/spec/fixtures/projects/test/www/config.xml @@ -1,5 +1,5 @@ - + bond. james bond. http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/helper.js ---------------------------------------------------------------------- diff --git a/spec/helper.js b/spec/helper.js index 95afaf3..ce6a952 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -1,44 +1 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; - -var shell = require('shelljs'), - path = require('path'), - fs = require('fs'), - android_project = path.join(__dirname, 'fixtures', 'projects', 'native', 'android'), - bb_project = path.join(__dirname, 'fixtures', 'projects', 'native', 'blackberry'); - -var orig_exec = shell.exec; - -module.exports = { - enabled:false, - enable:function() { - module.exports.enabled = true; - require('shelljs').exec = function(cmd, opts) { - // Match various commands to exec - if (cmd.match(/android.bin.create/)) { - var r = new RegExp(/android.bin.create"\s"([\/\\\w-_\.\s]*)"/); - var dir = r.exec(cmd)[1]; - shell.cp('-r', android_project, path.join(dir, '..')); - fs.chmodSync(path.join(dir, 'cordova', 'debug'), '754'); - return {code:0}; - } else if (cmd.match(/blackberry.bin.create/)) { - var r = new RegExp(/blackberry.bin.create"\s"([\/\\\w-_\.\s]*)"/); - var dir = r.exec(cmd)[1]; - var platformsDir = path.join(dir, '..'); - shell.cp('-r', bb_project, platformsDir); - // TODO: will need to handle bb sub-platforms - shell.mv(path.join(platformsDir, 'blackberry'), path.join(platformsDir, 'blackberry-10')); - return {code:0}; - } - // Fire off to original exec - return orig_exec.apply(null, arguments); - } - }, - disable:function() { - module.exports.enabled = false; - require('shelljs').exec = orig_exec; - } -}; - -if (!module.exports.enabled) { - module.exports.enable(); -} http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/hooker.spec.js ---------------------------------------------------------------------- diff --git a/spec/hooker.spec.js b/spec/hooker.spec.js index b6bea95..2055757 100644 --- a/spec/hooker.spec.js +++ b/spec/hooker.spec.js @@ -10,6 +10,7 @@ var cwd = process.cwd(); describe('hooker', function() { it('should throw if provided directory is not a cordova project', function() { + shell.rm('-rf', tempDir); shell.mkdir('-p', tempDir); this.after(function() { shell.rm('-rf', tempDir); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/metadata/android_parser.spec.js ---------------------------------------------------------------------- diff --git a/spec/metadata/android_parser.spec.js b/spec/metadata/android_parser.spec.js index 6371e6b..d0cf31f 100644 --- a/spec/metadata/android_parser.spec.js +++ b/spec/metadata/android_parser.spec.js @@ -1,19 +1,21 @@ var android_parser = require('../../src/metadata/android_parser'), config_parser = require('../../src/config_parser'), + util = require('../../src/util'), path = require('path'), shell = require('shelljs'), fs = require('fs'), et = require('elementtree'), - cfg_path = path.join(__dirname, '..', 'fixtures', 'projects', 'test', 'www', 'config.xml'), - android_path = path.join(__dirname, '..', 'fixtures', 'projects', 'native', 'android'), - android_strings = path.join(android_path, 'res', 'values', 'strings.xml'), - android_manifest = path.join(android_path, 'AndroidManifest.xml'), - android_config = path.join(android_path, 'res', 'xml', 'config.xml'), tempDir = path.join(__dirname, '..', '..', 'temp'), cordova = require('../../cordova'); + cfg_path = path.join(__dirname, '..', 'fixtures', 'projects', 'test', 'www', 'config.xml'), + android_path = path.join(__dirname, '..', 'fixtures', 'projects', 'native', 'android_fixture'), + create = path.join(__dirname, '..', '..', 'lib', 'android', 'bin', 'create'); var cwd = process.cwd(); +var android_strings = path.join(android_path, 'res', 'values', 'strings.xml'); +var android_manifest = path.join(android_path, 'AndroidManifest.xml'); +var android_config = path.join(android_path, 'res', 'xml', 'config.xml'); var original_strings = fs.readFileSync(android_strings, 'utf-8'); var original_manifest = fs.readFileSync(android_manifest, 'utf-8'); var original_config = fs.readFileSync(cfg_path, 'utf-8'); @@ -61,8 +63,8 @@ describe('android project parser', function() { expect(app_name).toBe('bond. james bond.'); }); it('should update the application package name properly', function() { - var javs = path.join(android_path, 'src', 'ca', 'filmaj', 'dewd', 'HelloCordova.java'); - var orig_javs = path.join(android_path, 'src', 'io', 'cordova', 'hellocordova', 'HelloCordova.java'); + var javs = path.join(android_path, 'src', 'ca', 'filmaj', 'dewd', 'cordovaExample.java'); + var orig_javs = path.join(android_path, 'src', 'io', 'cordova', 'hellocordova', 'cordovaExample.java'); var orig_contents = fs.readFileSync(orig_javs, 'utf-8'); this.after(function() { fs.writeFileSync(orig_javs, orig_contents, 'utf-8'); @@ -114,7 +116,7 @@ describe('android project parser', function() { }); it('should write out android js to cordova.js', function() { parser.update_www(); - expect(fs.readFileSync(path.join(android_platform, 'assets', 'www', 'cordova.js'),'utf-8')).toBe(fs.readFileSync(path.join(__dirname, '..', '..', 'lib', 'android', 'framework', 'assets', 'js', 'cordova.android.js'), 'utf-8')); + expect(fs.readFileSync(path.join(android_platform, 'assets', 'www', 'cordova.js'),'utf-8')).toBe(fs.readFileSync(path.join(util.libDirectory, 'cordova-android', 'framework', 'assets', 'js', 'cordova.android.js'), 'utf-8')); }); }); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/metadata/blackberry_parser.spec.js ---------------------------------------------------------------------- diff --git a/spec/metadata/blackberry_parser.spec.js b/spec/metadata/blackberry_parser.spec.js index c4cb1d3..d1d28b7 100644 --- a/spec/metadata/blackberry_parser.spec.js +++ b/spec/metadata/blackberry_parser.spec.js @@ -6,9 +6,9 @@ var blackberry_parser = require('../../src/metadata/blackberry_parser'), cordova = require('../../cordova'), fs = require('fs'), tempDir = path.join(__dirname, '..', '..', 'temp'), - tempBb = path.join(tempDir, 'platforms', 'blackberry-10'), + tempBb = path.join(tempDir, 'platforms', 'blackberry'), cfg_path = path.join(__dirname, '..', 'fixtures', 'projects', 'test', 'www', 'config.xml'), - blackberry_path = path.join(__dirname, '..', 'fixtures', 'projects', 'native', 'blackberry'), + blackberry_path = path.join(__dirname, '..', 'fixtures', 'projects', 'native', 'blackberry_fixture'), blackberry_config = path.join(blackberry_path, 'www', 'config.xml'); var cwd = process.cwd(); @@ -103,13 +103,6 @@ describe('blackberry project parser', function() { parser.update_www(); expect(fs.existsSync(path.join(tempBb, 'www', 'somescript.js'))).toBe(true); }); - it('should write out bb qnx js to cordova.js', function() { - var qnx_dir = path.join(tempBb, 'www', 'qnx'); - var qnx_js_path = path.join(qnx_dir, fs.readdirSync(qnx_dir)[0]); - var qnx_js = fs.readFileSync(qnx_js_path, 'utf-8'); - parser.update_www(); - expect(fs.readFileSync(path.join(tempBb, 'www', 'cordova.js'),'utf-8')).toBe(qnx_js); - }); it('should not overwrite the blackberry-specific config.xml', function() { var www_cfg = fs.readFileSync(path.join(tempDir, 'www', 'config.xml'), 'utf-8'); parser.update_www(); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/metadata/ios_parser.spec.js ---------------------------------------------------------------------- diff --git a/spec/metadata/ios_parser.spec.js b/spec/metadata/ios_parser.spec.js index 272a710..2005d01 100644 --- a/spec/metadata/ios_parser.spec.js +++ b/spec/metadata/ios_parser.spec.js @@ -1,22 +1,23 @@ var ios_parser = require('../../src/metadata/ios_parser'), config_parser = require('../../src/config_parser'), cordova = require('../../cordova'), + util = require('../../src/util'), path = require('path'), shell = require('shelljs'), fs = require('fs'), cfg_path = path.join(__dirname, '..', 'fixtures', 'projects', 'test', 'www', 'config.xml'), - ios_path = path.join(__dirname, '..', 'fixtures', 'projects', 'native', 'ios'), + ios_path = path.join(__dirname, '..', 'fixtures', 'projects', 'native', 'ios_fixture'), tempDir = path.join(__dirname, '..', '..', 'temp'), - ios_plist = path.join(ios_path, 'balls', 'balls-Info.plist'), - ios_pbx = path.join(ios_path, 'balls.xcodeproj', 'project.pbxproj'), - cordova_plist = path.join(ios_path, 'balls', 'Cordova.plist'); + ios_plist = path.join(ios_path, 'cordovaExample', 'cordovaExample-Info.plist'), + ios_pbx = path.join(ios_path, 'cordovaExample.xcodeproj', 'project.pbxproj'), + ios_config_xml = path.join(ios_path, 'cordovaExample', 'config.xml'); var cwd = process.cwd(); var original_pbx = fs.readFileSync(ios_pbx, 'utf-8'); var original_plist = fs.readFileSync(ios_plist, 'utf-8'); var original_config = fs.readFileSync(cfg_path, 'utf-8'); -var orig_cordova = fs.readFileSync(cordova_plist, 'utf-8'); +var orig_cordova = fs.readFileSync(ios_config_xml, 'utf-8'); describe('ios project parser', function() { it('should throw an exception with a path that is not a native ios project', function() { @@ -41,7 +42,7 @@ describe('ios project parser', function() { }); afterEach(function() { fs.writeFileSync(ios_pbx, original_pbx, 'utf-8'); - fs.writeFileSync(cordova_plist, orig_cordova, 'utf-8'); + fs.writeFileSync(ios_config_xml, orig_cordova, 'utf-8'); fs.writeFileSync(ios_plist, original_plist, 'utf-8'); fs.writeFileSync(cfg_path, original_config, 'utf-8'); }); @@ -80,7 +81,7 @@ describe('ios project parser', function() { expect(plist_contents).toMatch(/ca.filmaj.dewd/); }); }); - it('should update the externalhosts whitelist properly', function() { + it('should update the whitelist in the project config.xml', function() { var cb = jasmine.createSpy(); runs(function() { @@ -90,8 +91,8 @@ describe('ios project parser', function() { waitsFor(function() { return cb.wasCalled; }, "update_from_config callback"); runs(function() { - var plist_contents = fs.readFileSync(cordova_plist, 'utf-8'); - expect(plist_contents).toMatch(/ExternalHosts<\/key>\s*\s*\*<\/string>/); + var config_contents = fs.readFileSync(ios_config_xml, 'utf-8'); + expect(config_contents).toMatch(//); }); }); }); @@ -131,7 +132,7 @@ describe('ios project parser', function() { runs(function() { parser = new ios_parser(ios_platform); parser.update_www(); - expect(fs.readFileSync(path.join(ios_platform, 'www', 'cordova.js'),'utf-8')).toBe(fs.readFileSync(path.join(__dirname, '..', '..', 'lib', 'ios', 'bin', 'templates', 'project', 'www', 'cordova-2.2.0.js'), 'utf-8')); + expect(fs.readFileSync(path.join(ios_platform, 'www', 'cordova.js'),'utf-8')).toBe(fs.readFileSync(path.join(util.libDirectory, 'cordova-ios', 'CordovaLib', 'cordova.ios.js'), 'utf-8')); }); }); }); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/platform.spec.js ---------------------------------------------------------------------- diff --git a/spec/platform.spec.js b/spec/platform.spec.js index da4b2e5..77808af 100644 --- a/spec/platform.spec.js +++ b/spec/platform.spec.js @@ -47,42 +47,38 @@ describe('platform command', function() { }).toThrow(); }); - var listing_tests = function(_invocation) { - return function() { - beforeEach(function() { - cordova.create(tempDir); - process.chdir(tempDir); - }); + describe('`ls`', function() { + beforeEach(function() { + cordova.create(tempDir); + process.chdir(tempDir); + }); - afterEach(function() { - process.chdir(cwd); - }); + afterEach(function() { + process.chdir(cwd); + }); - it('should list out no platforms for a fresh project', function() { - expect(cordova.platform(_invocation).length).toEqual(0); - }); + it('should list out no platforms for a fresh project', function() { + expect(cordova.platform('list').length).toEqual(0); + }); - it('should list out added platforms in a project', function() { - var cbtwo = jasmine.createSpy(); - var cb = jasmine.createSpy(); + it('should list out added platforms in a project', function() { + var cbtwo = jasmine.createSpy(); + var cb = jasmine.createSpy(); - runs(function() { - cordova.platform('add', 'android', cb); - }); - waitsFor(function() { return cb.wasCalled; }, "create callback"); - runs(function() { - expect(cordova.platform(_invocation)[0]).toEqual('android'); - cordova.platform('add', 'ios', cbtwo); - }); - waitsFor(function() { return cbtwo.wasCalled; }, "create callback number two"); - runs(function() { - expect(cordova.platform(_invocation)[1]).toEqual('ios'); - }); + runs(function() { + cordova.platform('add', 'android', cb); + }); + waitsFor(function() { return cb.wasCalled; }, "android create callback"); + runs(function() { + expect(cordova.platform('list')[0]).toEqual('android'); + cordova.platform('add', 'ios', cbtwo); }); - }; - }; - describe('`ls`', listing_tests('ls')); - describe('`list`', listing_tests('list')); + waitsFor(function() { return cbtwo.wasCalled; }, "create callback number two"); + runs(function() { + expect(cordova.platform('list')[1]).toEqual('ios'); + }); + }); + }); describe('`add`', function() { beforeEach(function() { @@ -95,55 +91,24 @@ describe('platform command', function() { }); describe('without any libraries cloned', function() { - var lib = path.join(__dirname, '..', 'lib'); - var libs = fs.readdirSync(lib); - + var bkup = path.join(util.libDirectory, '..', 'bkup'); beforeEach(function() { - libs.forEach(function(p) { - var s = path.join(lib, p); - var d = path.join(lib, p + '-bkup'); - shell.mv(s, d); - }); + shell.mkdir('-p', bkup); + shell.mv(util.libDirectory, bkup); }); afterEach(function() { - libs.forEach(function(p) { - var s = path.join(lib, p + '-bkup', '*'); - var d = path.join(lib, p); - shell.mkdir(d); - shell.mv(s, d); - shell.rm('-rf', path.join(lib, p + '-bkup')); - }); + shell.mv(path.join(bkup, fs.readdirSync(bkup)[0]), path.join(util.libDirectory, '..')); + shell.rm('-rf', bkup); }); - it('should download the android library', function() { + it('should download the cordova library', function() { var s = spyOn(request, 'get'); try { cordova.platform('add', 'android', function() {}); } catch(e) {} expect(s).toHaveBeenCalled(); - expect(s.calls[0].args[0]).toMatch(/cordova-android\/zipball/); - }); - it('should download the ios library', function() { - var s = spyOn(request, 'get'); - try { - cordova.platform('add', 'ios', function() {}); - } catch(e) {} - - expect(s).toHaveBeenCalled(); - expect(s.calls[0].args[0]).toMatch(/cordova-ios\/zipball/); - }); - it('should download the blackberry library', function() { - var s = spyOn(request, 'get'); - try { - cordova.platform('add', 'blackberry', function() {}); - } catch(e) {} - - expect(s).toHaveBeenCalled(); - expect(s.calls[0].args[0]).toMatch(/cordova-blackberry-webworks\/zipball/); + expect(s.calls[0].args[0]).toMatch(/apache.org\/dist\/cordova.*\.zip$/); }); - it('should add a basic android project'); - it('should add a basic ios project'); - it('should add a basic blackberry project'); }); describe('android', function() { @@ -187,23 +152,23 @@ describe('platform command', function() { }).toThrow(); }); }); - describe('blackberry-10', function() { + describe('blackberry', function() { it('should add a basic blackberry project', function() { var cb = jasmine.createSpy(); var s = spyOn(require('prompt'), 'get').andReturn(true); runs(function() { - cordova.platform('add', 'blackberry-10', cb); + cordova.platform('add', 'blackberry', cb); s.mostRecentCall.args[1](null, {}); // fake out prompt }); waitsFor(function() { return cb.wasCalled; }, "platform add blackberry"); runs(function() { - expect(fs.existsSync(path.join(tempDir, 'platforms', 'blackberry-10', 'www'))).toBe(true); + expect(fs.existsSync(path.join(tempDir, 'platforms', 'blackberry', 'www'))).toBe(true); }); }); it('should call blackberry_parser\'s update_project', function() { var s = spyOn(blackberry_parser.prototype, 'update_project'); - cordova.platform('add', 'blackberry-10'); + cordova.platform('add', 'blackberry'); expect(s).toHaveBeenCalled(); }); }); @@ -220,46 +185,42 @@ describe('platform command', function() { }); }); - var removing_tests = function(_invocation) { - return function() { - beforeEach(function() { - cordova.create(tempDir); - process.chdir(tempDir); - }); + describe('`remove`',function() { + beforeEach(function() { + cordova.create(tempDir); + process.chdir(tempDir); + }); - afterEach(function() { - process.chdir(cwd); - }); + afterEach(function() { + process.chdir(cwd); + }); - it('should remove a supported and added platform', function() { - var cb = jasmine.createSpy(); + it('should remove a supported and added platform', function() { + var cb = jasmine.createSpy(); - runs(function() { - cordova.platform('add', ['android', 'ios'], cb); - }); - waitsFor(function() { return cb.wasCalled; }, "android+ios platfomr add callback"); - runs(function() { - cordova.platform(_invocation, 'android'); - expect(cordova.platform('ls').length).toEqual(1); - expect(cordova.platform('ls')[0]).toEqual('ios'); - }); + runs(function() { + cordova.platform('add', ['android', 'ios'], cb); }); - it('should be able to remove multiple platforms', function() { - var cb = jasmine.createSpy(); + waitsFor(function() { return cb.wasCalled; }, "android+ios platfomr add callback"); + runs(function() { + cordova.platform('remove', 'android'); + expect(cordova.platform('ls').length).toEqual(1); + expect(cordova.platform('ls')[0]).toEqual('ios'); + }); + }); + it('should be able to remove multiple platforms', function() { + var cb = jasmine.createSpy(); - runs(function() { - cordova.platform('add', ['android', 'ios'], cb); - }); - waitsFor(function() { return cb.wasCalled; }, "android+ios platfomr add callback"); - runs(function() { - cordova.platform(_invocation, ['android','ios']); - expect(cordova.platform('ls').length).toEqual(0); - }); + runs(function() { + cordova.platform('add', ['android', 'ios'], cb); }); - }; - }; - describe('`rm`', removing_tests('rm')); - describe('`remove`', removing_tests('remove')); + waitsFor(function() { return cb.wasCalled; }, "android+ios platfomr add callback"); + runs(function() { + cordova.platform('remove', ['android','ios']); + expect(cordova.platform('ls').length).toEqual(0); + }); + }); + }); describe('hooks', function() { var s; http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/spec/plugin.spec.js ---------------------------------------------------------------------- diff --git a/spec/plugin.spec.js b/spec/plugin.spec.js index 07101fe..4840671 100644 --- a/spec/plugin.spec.js +++ b/spec/plugin.spec.js @@ -42,25 +42,21 @@ describe('plugin command', function() { }).toThrow(); }); - var listing_tests = function(_invocation) { - return function() { - beforeEach(function() { - cordova.create(tempDir); - }); + describe('`ls`', function() { + beforeEach(function() { + cordova.create(tempDir); + }); - afterEach(function() { - process.chdir(cwd); - }); + afterEach(function() { + process.chdir(cwd); + }); - it('should list out no plugins for a fresh project', function() { - process.chdir(tempDir); + it('should list out no plugins for a fresh project', function() { + process.chdir(tempDir); - expect(cordova.plugin(_invocation)).toEqual('No plugins added. Use `cordova plugin add `.'); - }); - }; - }; - describe('`ls`', listing_tests('ls')); - describe('`list`', listing_tests('list')); + expect(cordova.plugin('list')).toEqual('No plugins added. Use `cordova plugin add `.'); + }); + }); describe('`add`', function() { beforeEach(function() { @@ -165,98 +161,94 @@ describe('plugin command', function() { }); }); - var removing_tests = function(_invocation) { - return function() { - beforeEach(function() { - cordova.create(tempDir); - process.chdir(tempDir); - }); + describe('`rm`',function() { + beforeEach(function() { + cordova.create(tempDir); + process.chdir(tempDir); + }); - afterEach(function() { - process.chdir(cwd); + afterEach(function() { + process.chdir(cwd); + }); + describe('failure', function() { + it('should throw if your app has no platforms added', function() { + expect(function() { + cordova.plugin(_invocation, testPlugin); + }).toThrow('You need at least one platform added to your app. Use `cordova platform add `.'); }); - describe('failure', function() { - it('should throw if your app has no platforms added', function() { + it('should throw if plugin is not added to project', function() { + var cb = jasmine.createSpy(); + runs(function() { + cordova.platform('add', 'ios', cb); + }); + waitsFor(function() { return cb.wasCalled; }, 'ios platform add'); + runs(function() { expect(function() { - cordova.plugin(_invocation, testPlugin); - }).toThrow('You need at least one platform added to your app. Use `cordova platform add `.'); + cordova.plugin(_invocation, 'test', function() {}); + }).toThrow('Plugin "test" not added to project.'); + }); + }); + }); + describe('success', function() { + it('should remove plugin www assets from project www folder', function() { + var cb = jasmine.createSpy(); + var pluginCb = jasmine.createSpy(); + var removeCb = jasmine.createSpy(); + runs(function() { + cordova.platform('add', 'ios', cb); + }); + waitsFor(function() { return cb.wasCalled; }, 'ios platform add'); + runs(function() { + cordova.plugin('add', testPlugin, pluginCb); }); - it('should throw if plugin is not added to project', function() { - var cb = jasmine.createSpy(); - runs(function() { - cordova.platform('add', 'ios', cb); - }); - waitsFor(function() { return cb.wasCalled; }, 'ios platform add'); - runs(function() { - expect(function() { - cordova.plugin(_invocation, 'test', function() {}); - }).toThrow('Plugin "test" not added to project.'); - }); + waitsFor(function() { return pluginCb.wasCalled; }, 'test plugin add'); + runs(function() { + cordova.plugin(_invocation, 'test', removeCb); + }); + waitsFor(function() { return removeCb.wasCalled; }, 'test plugin remove'); + runs(function() { + expect(fs.existsSync(path.join(tempDir, 'www', 'test.js'))).toBe(false); }); }); - describe('success', function() { - it('should remove plugin www assets from project www folder', function() { - var cb = jasmine.createSpy(); - var pluginCb = jasmine.createSpy(); - var removeCb = jasmine.createSpy(); - runs(function() { - cordova.platform('add', 'ios', cb); - }); - waitsFor(function() { return cb.wasCalled; }, 'ios platform add'); - runs(function() { - cordova.plugin('add', testPlugin, pluginCb); - }); - waitsFor(function() { return pluginCb.wasCalled; }, 'test plugin add'); - runs(function() { - cordova.plugin(_invocation, 'test', removeCb); - }); - waitsFor(function() { return removeCb.wasCalled; }, 'test plugin remove'); - runs(function() { - expect(fs.existsSync(path.join(tempDir, 'www', 'test.js'))).toBe(false); - }); + it('should remove the full plugin from the plugins directory', function() { + var cb = jasmine.createSpy(); + var pluginCb = jasmine.createSpy(); + var removeCb = jasmine.createSpy(); + runs(function() { + cordova.platform('add', 'ios', cb); }); - it('should remove the full plugin from the plugins directory', function() { - var cb = jasmine.createSpy(); - var pluginCb = jasmine.createSpy(); - var removeCb = jasmine.createSpy(); - runs(function() { - cordova.platform('add', 'ios', cb); - }); - waitsFor(function() { return cb.wasCalled; }, 'ios platform add'); - runs(function() { - cordova.plugin('add', testPlugin, pluginCb); - }); - waitsFor(function() { return pluginCb.wasCalled; }, 'test plugin add'); - runs(function() { - cordova.plugin(_invocation, 'test', removeCb); - }); - waitsFor(function() { return removeCb.wasCalled; }, 'test plugin remove'); - runs(function() { - expect(fs.existsSync(path.join(tempDir, 'plugins', 'test'))).toBe(false); - }); + waitsFor(function() { return cb.wasCalled; }, 'ios platform add'); + runs(function() { + cordova.plugin('add', testPlugin, pluginCb); + }); + waitsFor(function() { return pluginCb.wasCalled; }, 'test plugin add'); + runs(function() { + cordova.plugin(_invocation, 'test', removeCb); + }); + waitsFor(function() { return removeCb.wasCalled; }, 'test plugin remove'); + runs(function() { + expect(fs.existsSync(path.join(tempDir, 'plugins', 'test'))).toBe(false); + }); + }); + it('should be able to handle removing multiple plugins', function() { + cordova.platform('add', 'android'); + var cb = jasmine.createSpy(); + var cbtwo = jasmine.createSpy(); + runs(function() { + cordova.plugin('add', [testPlugin, androidPlugin], cb); }); - it('should be able to handle removing multiple plugins', function() { - cordova.platform('add', 'android'); - var cb = jasmine.createSpy(); - var cbtwo = jasmine.createSpy(); - runs(function() { - cordova.plugin('add', [testPlugin, androidPlugin], cb); - }); - waitsFor(function() { return cb.wasCalled; }, 'test+android plugin add'); - runs(function() { - cordova.plugin(_invocation, [testPlugin, androidPlugin], cbtwo); - }); - waitsFor(function() { return cbtwo.wasCalled; }, 'test+android plugin rm'); - runs(function() { - expect(fs.existsSync(path.join(tempDir, 'plugins', 'test'))).toBe(false); - expect(fs.existsSync(path.join(tempDir, 'plugins', 'android'))).toBe(false); - }); + waitsFor(function() { return cb.wasCalled; }, 'test+android plugin add'); + runs(function() { + cordova.plugin(_invocation, [testPlugin, androidPlugin], cbtwo); + }); + waitsFor(function() { return cbtwo.wasCalled; }, 'test+android plugin rm'); + runs(function() { + expect(fs.existsSync(path.join(tempDir, 'plugins', 'test'))).toBe(false); + expect(fs.existsSync(path.join(tempDir, 'plugins', 'android'))).toBe(false); }); }); - }; - }; - describe('`rm`', removing_tests('rm')); - describe('`remove`', removing_tests('remove')); + }); + }); describe('hooks', function() { var s; http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/src/build.js ---------------------------------------------------------------------- diff --git a/src/build.js b/src/build.js index deb60f8..ad16563 100644 --- a/src/build.js +++ b/src/build.js @@ -18,7 +18,8 @@ function shell_out_to_debug(projectRoot, platform) { var cmd = path.join(projectRoot, 'platforms', platform); // TODO: wait for https://issues.apache.org/jira/browse/CB-1548 to be fixed before we axe this // TODO: this is bb10 only for now - if (platform.indexOf('blackberry') > -1) { + // TODO: PLATFORM LIBRARY INCONSISTENCY + if (platform == 'blackberry') { cmd = 'ant -f "' + path.join(cmd, 'build.xml') + '" qnx load-device'; } else { cmd = '"' + cmd + '/cordova/build"'; @@ -74,14 +75,14 @@ module.exports = function build (platforms, callback) { shell_out_to_debug(projectRoot, 'android'); end(); break; - case 'blackberry-10': - platformPath = path.join(projectRoot, 'platforms', 'blackberry-10'); + case 'blackberry': + platformPath = path.join(projectRoot, 'platforms', 'blackberry'); parser = new blackberry_parser(platformPath); // Update the related platform project from the config parser.update_project(cfg, function() { // Shell it - shell_out_to_debug(projectRoot, 'blackberry-10'); + shell_out_to_debug(projectRoot, 'blackberry'); end(); }); break; http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/src/emulate.js ---------------------------------------------------------------------- diff --git a/src/emulate.js b/src/emulate.js index 40340e2..3847766 100644 --- a/src/emulate.js +++ b/src/emulate.js @@ -14,8 +14,8 @@ var cordova_util = require('./util'), function shell_out_to_emulate(root, platform) { var cmd = path.join(root, 'platforms', platform, 'cordova', 'emulate'); - // TODO: bad bad bad - if (platform.indexOf('blackberry') > -1) { + // TODO: PLATFORM LIBRARY INCONSISTENCY + if (platform == 'blackberry') { cmd = 'ant -f ' + path.join(root, 'platforms', platform, 'build.xml') + ' qnx load-simulator'; } else if (platform.indexOf('android') > -1) { cmd = path.join(root, 'platforms', platform, 'cordova', 'run'); @@ -69,20 +69,19 @@ module.exports = function emulate (platforms, callback) { shell_out_to_emulate(projectRoot, 'android'); end(); break; - case 'blackberry-10': - platformPath = path.join(projectRoot, 'platforms', 'blackberry-10'); + case 'blackberry': + platformPath = path.join(projectRoot, 'platforms', 'blackberry'); parser = new blackberry_parser(platformPath); // Update the related platform project from the config parser.update_project(cfg, function() { // Shell it - shell_out_to_emulate(projectRoot, 'blackberry-10'); + shell_out_to_emulate(projectRoot, 'blackberry'); end(); }); break; case 'ios': platformPath = path.join(projectRoot, 'platforms', 'ios'); - js = path.join(__dirname, '..', 'lib', 'ios', 'CordovaLib', 'javascript', 'cordova.ios.js'); parser = new ios_parser(platformPath); // Update the related platform project from the config parser.update_project(cfg, function() { http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/src/metadata/android_parser.js ---------------------------------------------------------------------- diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js index 3c6a844..90b06b8 100644 --- a/src/metadata/android_parser.js +++ b/src/metadata/android_parser.js @@ -1,8 +1,8 @@ -var fs = require('fs'), - path = require('path'), - et = require('elementtree'), - util = require('../util'), - shell = require('shelljs'), +var fs = require('fs'), + path = require('path'), + et = require('elementtree'), + util = require('../util'), + shell = require('shelljs'), config_parser = require('../config_parser'); module.exports = function android_parser(project) { @@ -62,7 +62,7 @@ module.exports.prototype = { var www = path.join(projectRoot, 'www'); var platformWww = path.join(this.path, 'assets'); shell.cp('-rf', www, platformWww); - var jsPath = path.join(__dirname, '..', '..', 'lib', 'android', 'framework', 'assets', 'js', 'cordova.android.js'); + var jsPath = path.join(util.libDirectory, 'cordova-android', 'framework', 'assets', 'js', 'cordova.android.js'); fs.writeFileSync(path.join(platformWww, 'www', 'cordova.js'), fs.readFileSync(jsPath, 'utf-8'), 'utf-8'); }, update_project:function(cfg) { http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/src/metadata/ios_parser.js ---------------------------------------------------------------------- diff --git a/src/metadata/ios_parser.js b/src/metadata/ios_parser.js index 6359839..03ee168 100644 --- a/src/metadata/ios_parser.js +++ b/src/metadata/ios_parser.js @@ -19,6 +19,7 @@ module.exports = function ios_parser(project) { } this.path = project; this.pbxproj = path.join(this.xcodeproj, 'project.pbxproj'); + this.config = new config_parser(path.join(this.cordovaproj, 'config.xml')); }; module.exports.prototype = { update_from_config:function(config, callback) { @@ -34,6 +35,18 @@ module.exports.prototype = { var info_contents = plist.build(infoPlist); info_contents = info_contents.replace(/\s*<\/string>/,''); fs.writeFileSync(plistFile, info_contents, 'utf-8'); + + // Update whitelist + var self = this; + this.config.doc.findall('access').forEach(function(a) { + self.config.doc.getroot().remove(0, a); + }); + config.access.get().forEach(function(uri) { + var el = new et.Element('access'); + el.attrib.origin = uri; + self.config.doc.getroot().append(el); + }); + this.config.update(); // Update product name var proj = new xcode.project(this.pbxproj); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/src/platform.js ---------------------------------------------------------------------- diff --git a/src/platform.js b/src/platform.js index 01d6bc3..686d3db 100644 --- a/src/platform.js +++ b/src/platform.js @@ -1,15 +1,15 @@ -var config_parser = require('./config_parser'), - cordova_util = require('./util'), - util = require('util'), - fs = require('fs'), - path = require('path'), - android_parser= require('./metadata/android_parser'), - blackberry_parser= require('./metadata/blackberry_parser'), - ios_parser = require('./metadata/ios_parser'), - hooker = require('./hooker'), - n = require('ncallbacks'), - semver = require('semver'), - shell = require('shelljs'); +var config_parser = require('./config_parser'), + cordova_util = require('./util'), + util = require('util'), + fs = require('fs'), + path = require('path'), + android_parser = require('./metadata/android_parser'), + blackberry_parser = require('./metadata/blackberry_parser'), + ios_parser = require('./metadata/ios_parser'), + hooker = require('./hooker'), + n = require('ncallbacks'), + semver = require('semver'), + shell = require('shelljs'); module.exports = function platform(command, targets, callback) { var projectRoot = cordova_util.isCordova(process.cwd()); @@ -44,61 +44,56 @@ module.exports = function platform(command, targets, callback) { hooks.fire('before_platform_add'); var output = path.join(projectRoot, 'platforms', target); - var shell_to_cordova = function() { - if (target == 'ios') { - // Check xcode + version. - var xcode = shell.exec('xcodebuild -version', {silent:true}); - if (xcode.code != 0) throw 'Xcode is not installed. Cannot add iOS platform.'; - var xc_version = xcode.output.split('\n')[0].split(' ')[1]; - var MIN_XCODE_VERSION = '4.5.x'; - if (semver.lt(xc_version, MIN_XCODE_VERSION)) throw ('Xcode version installed is too old. Minimum: ' + MIN_XCODE_VERSION + ', yours: ' + xc_version); - } - // Create a platform app using the ./bin/create scripts that exist in each repo. - // TODO: eventually refactor to allow multiple versions to be created. - // Check if output directory already exists. - if (fs.existsSync(output)) { - throw new Error('Platform "' + target + '" already exists' ); - } + if (target == 'ios') { + // Check xcode + version. + var xcode = shell.exec('xcodebuild -version', {silent:true}); + if (xcode.code != 0) throw 'Xcode is not installed. Cannot add iOS platform.'; + var xc_version = xcode.output.split('\n')[0].split(' ')[1]; + var MIN_XCODE_VERSION = '4.5.x'; + if (semver.lt(xc_version, MIN_XCODE_VERSION)) throw ('Xcode version installed is too old. Minimum: ' + MIN_XCODE_VERSION + ', yours: ' + xc_version); + } + // Create a platform app using the ./bin/create scripts that exist in each repo. + // TODO: eventually refactor to allow multiple versions to be created. + // Check if output directory already exists. + if (fs.existsSync(output)) { + throw new Error('Platform "' + target + '" already exists' ); + } - // Run platform's create script - var bin = path.join(__dirname, '..', 'lib', cordova_util.underlyingLib(target), 'bin', 'create'); - var pkg = cfg.packageName().replace(/[^\w.]/g,'_'); - var name = cfg.name().replace(/\W/g,'_'); - var command = util.format('"%s" "%s" "%s" "%s"', bin, output, (cordova_util.underlyingLib(target)=='blackberry'?name:pkg), name); + // Run platform's create script + var bin = path.join(cordova_util.libDirectory, 'cordova-' + target, 'bin', 'create'); + var pkg = cfg.packageName().replace(/[^\w.]/g,'_'); + var name = cfg.name().replace(/\W/g,'_'); + // TODO: PLATFORM LIBRARY INCONSISTENCY: order/number of arguments to create + var command = util.format('"%s" "%s" "%s" "%s"', bin, output, (target=='blackberry'?name:pkg), name); - var create = shell.exec(command, {silent:true}); - if (create.code > 0) { - throw new Error('An error occured during creation of ' + target + ' sub-project. ' + create.output); - } + var create = shell.exec(command, {silent:true}); + if (create.code > 0) { + throw new Error('An error occured during creation of ' + target + ' sub-project. ' + create.output); + } - switch(cordova_util.underlyingLib(target)) { - case 'android': - var android = new android_parser(output); - android.update_project(cfg); + switch(target) { + case 'android': + var android = new android_parser(output); + android.update_project(cfg); + hooks.fire('after_platform_add'); + end(); + break; + case 'ios': + var ios = new ios_parser(output); + ios.update_project(cfg, function() { hooks.fire('after_platform_add'); end(); - break; - case 'ios': - var ios = new ios_parser(output); - ios.update_project(cfg, function() { - hooks.fire('after_platform_add'); - end(); - }); - break; - case 'blackberry': - var bb = new blackberry_parser(output); - bb.update_project(cfg, function() { - hooks.fire('after_platform_add'); - end(); - }); - break; - } - }; + }); + break; + case 'blackberry': + var bb = new blackberry_parser(output); + bb.update_project(cfg, function() { + hooks.fire('after_platform_add'); + end(); + }); + break; + } - // If the Cordova library for this platform is missing, get it. - if (!cordova_util.havePlatformLib(target)) { - cordova_util.getPlatformLib(target, shell_to_cordova); - } else shell_to_cordova(); }); break; case 'rm': http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/src/plugin.js ---------------------------------------------------------------------- diff --git a/src/plugin.js b/src/plugin.js index 63b1bf4..5937443 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -144,7 +144,7 @@ module.exports = function plugin(command, targets, callback) { // Iterate over all matchin app-plugin platforms in the project and uninstall the // plugin. intersection.forEach(function(platform) { - var cmd = util.format('%s --platform %s --project "%s" --plugin "%s" --remove', cli, platform, path.join(projectRoot, 'platforms', platform), targetPath); + var cmd = util.format('%s --remove --platform %s --project "%s" --plugin "%s"', cli, platform, path.join(projectRoot, 'platforms', platform), targetPath); var plugin_cli = shell.exec(cmd, {silent:true}); if (plugin_cli.code > 0) throw 'An error occured during plugin uninstallation for ' + platform + '. ' + plugin_cli.output; }); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/src/util.js ---------------------------------------------------------------------- diff --git a/src/util.js b/src/util.js index 6f7b2b6..c780eda 100644 --- a/src/util.js +++ b/src/util.js @@ -2,22 +2,23 @@ var fs = require('fs'), path = require('path'), util = require('util'), request = require('request'), - admzip = require('adm-zip'), - shell = require('shelljs'); + n = require('ncallbacks'), + shell = require('shelljs'), + unzip = require('unzip'), + platforms = require('../platforms'); -var cordova_lib_tag = '2.3.0rc1'; - -var repos = { - ios:'https://github.com/apache/cordova-ios/', - android:'https://github.com/apache/cordova-android/', - blackberry:'https://github.com/apache/cordova-blackberry/' -}; +var cordova_lib_tag = '2.3.0'; +var libs_path = path.join(__dirname, '..', 'lib') +var lib_path = path.join(libs_path, 'cordova-' + cordova_lib_tag); +var archive_path = path.join(libs_path, 'cordova-' + cordova_lib_tag + '-src.zip'); +var root_url = 'http://apache.org/dist/cordova/cordova-' + cordova_lib_tag + '-src.zip'; function chmod(path) { shell.exec('chmod +x "' + path + '"', {silent:true}); } module.exports = { + libDirectory:lib_path, // Runs up the directory chain looking for a .cordova directory. // IF it is found we are in a Cordova project. // If not.. we're not. @@ -36,18 +37,17 @@ module.exports = { }, // Determines whether the library has a copy of the specified // Cordova implementation at the current proper version - havePlatformLib: function havePlatformLib(platform, callback) { - var dir = path.join(__dirname, '..', 'lib', module.exports.underlyingLib(platform)); - if (fs.existsSync(dir)) { - var versionFile = path.join(dir, 'VERSION'); - if (platform == 'ios') versionFile = path.join(dir, 'CordovaLib', 'VERSION'); - var version = fs.readFileSync(versionFile, 'utf-8').replace(/\s/g,''); - if (version != cordova_lib_tag) { - shell.rm('-rf', dir); - return false; - } else return true; + havePlatformLib: function havePlatformLib(platform) { + if (module.exports.haveCordovaLib()) { + var dir = path.join(lib_path, 'cordova-' + platform); + if (fs.existsSync(dir)) return true; + else return false; } else return false; }, + haveCordovaLib: function haveCordovaLib() { + if (fs.existsSync(lib_path)) return true; + else return false; + }, /** * checkout a platform from the git repo * @param target string platform to get (enum of 'ios' or 'android' for now) @@ -55,64 +55,69 @@ module.exports = { */ getPlatformLib: function getPlatformLib(target, callback) { // verify platform is supported - target = module.exports.underlyingLib(target); - if (!repos[target]) { + if (platforms.indexOf(target) == -1) { throw new Error('platform "' + target + '" not found.'); } - var outPath = path.join(__dirname, '..', 'lib', target); - shell.mkdir('-p', outPath); - - var tempPath = path.join(__dirname, '..', 'temp'); - shell.mkdir('-p', tempPath); - - var tempFile = path.join(tempPath, target + '-' + cordova_lib_tag + '.zip'); - - console.log('Downloading ' + target + ' library, this may take a while...'); - request.get(repos[target] + 'zipball/' + cordova_lib_tag, function(err) { - if (err) throw ('Error during download of ' + target + 'library.'); - var zip = new admzip(tempFile); - var extractPoint = path.join(tempPath, target); - zip.extractAllTo(extractPoint); - var tempDir = path.join(extractPoint, fs.readdirSync(extractPoint)[0]); - shell.mv('-f', path.join(tempDir, '*'), outPath); - - // chmod the create file - var create = path.join(outPath, 'bin', 'create'); - chmod(create); + function movePlatform() { + } - // chmod executable scripts - if (target == 'ios') { - chmod(path.join(outPath, 'bin', 'replaces')); - chmod(path.join(outPath, 'bin', 'update_cordova_subproject')); - chmod(path.join(outPath, 'bin', 'templates', 'project', 'cordova', 'build')); - chmod(path.join(outPath, 'bin', 'templates', 'project', 'cordova', 'run')); - chmod(path.join(outPath, 'bin', 'templates', 'project', 'cordova', 'release')); - chmod(path.join(outPath, 'bin', 'templates', 'project', 'cordova', 'emulate')); - } else if (target == 'android') { - chmod(path.join(outPath, 'bin', 'templates', 'cordova', 'cordova')); - chmod(path.join(outPath, 'bin', 'templates', 'cordova', 'build')); - chmod(path.join(outPath, 'bin', 'templates', 'cordova', 'run')); - chmod(path.join(outPath, 'bin', 'templates', 'cordova', 'clean')); - chmod(path.join(outPath, 'bin', 'templates', 'cordova', 'release')); - } else if (target == 'blackberry') { - chmod(path.join(outPath, 'bin', 'templates', 'cordova', 'debug')); - chmod(path.join(outPath, 'bin', 'templates', 'cordova', 'emulate')); - } + if (!module.exports.haveCordovaLib()) { + module.exports.getCordovaLib(movePlatform); + } else { + movePlatform(); + } + }, + extractCordovaLib:function(callback) { + console.log('Extracting cordova...'); + var end = n(platforms.length, function() { + if (callback) callback(); + }); - // Clean up - shell.rm('-rf', tempFile); - shell.rm('-rf', extractPoint); + fs.createReadStream(archive_path).pipe(unzip.Extract({ path: libs_path })).on('close', function() { + // Extract each platform lib too + platforms.forEach(function(platform) { + var archive = path.join(lib_path, 'cordova-' + platform + '.zip'); + var out_path = path.join(lib_path, 'cordova-' + platform); + shell.mkdir('-p', out_path); + fs.createReadStream(archive).pipe(unzip.Extract({ path:out_path })).on('close', function() { + var platform_path = path.join(lib_path, 'cordova-' + platform); - // Callback - if (callback) callback(); - }).pipe(fs.createWriteStream(tempFile)); + // chmod the create file + var create = path.join(platform_path, 'bin', 'create'); + chmod(create); + // chmod executable scripts + if (platform == 'ios') { + chmod(path.join(platform_path, 'bin', 'replaces')); + chmod(path.join(platform_path, 'bin', 'update_cordova_subproject')); + chmod(path.join(platform_path, 'bin', 'templates', 'project', 'cordova', 'build')); + chmod(path.join(platform_path, 'bin', 'templates', 'project', 'cordova', 'run')); + chmod(path.join(platform_path, 'bin', 'templates', 'project', 'cordova', 'release')); + chmod(path.join(platform_path, 'bin', 'templates', 'project', 'cordova', 'emulate')); + } else if (platform == 'android') { + chmod(path.join(platform_path, 'bin', 'templates', 'cordova', 'cordova')); + chmod(path.join(platform_path, 'bin', 'templates', 'cordova', 'build')); + chmod(path.join(platform_path, 'bin', 'templates', 'cordova', 'run')); + chmod(path.join(platform_path, 'bin', 'templates', 'cordova', 'clean')); + chmod(path.join(platform_path, 'bin', 'templates', 'cordova', 'release')); + } else if (platform == 'blackberry') { + chmod(path.join(platform_path, 'bin', 'templates', 'cordova', 'debug')); + chmod(path.join(platform_path, 'bin', 'templates', 'cordova', 'emulate')); + } + end(); + }); + }); + }); }, - underlyingLib:function underlyingLib(name) { - var pos = name.indexOf('-'); - if (pos > -1) { - name = name.substr(0, pos); + getCordovaLib:function (callback) { + if (!fs.existsSync(archive_path)) { + console.log('Downloading cordova-' + cordova_lib_tag + ', this may take a while...'); + request.get(root_url, function(err) { + if (err) throw ('Error during cordova download!'); + module.exports.extractCordovaLib(callback); + }).pipe(fs.createWriteStream(archive_path)); + } else { + module.exports.extractCordovaLib(callback); } - return name; } }; http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5742036a/test_bootstrap.js ---------------------------------------------------------------------- diff --git a/test_bootstrap.js b/test_bootstrap.js deleted file mode 100644 index 1d149ff..0000000 --- a/test_bootstrap.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * TEST BOOTSTRAP FILE - * Runs through any bs to make sure the tests are good to go. - **/ - -var fs = require('fs'), - path = require('path'), - util = require('./src/util'), - ncallbacks=require('ncallbacks'), - platforms = require('./platforms'); - -var end = ncallbacks(platforms.length, function() { - process.exit(0); -}); - -// If a platform library dependency does not exist, will clone it down. -platforms.forEach(function(p) { - if (!util.havePlatformLib(p)) { - util.getPlatformLib(p, end); - } -});