cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [29/32] git commit: Added amazon-fireos platform. making cli test 'platform ls' pass. Added amazon-fireos platform in the list.
Date Fri, 06 Dec 2013 01:13:45 GMT
Added amazon-fireos platform.
making cli test 'platform ls' pass. Added amazon-fireos platform in the list.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/4722c3ff
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/4722c3ff
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/4722c3ff

Branch: refs/heads/fireos
Commit: 4722c3ff3528bf0499cd93540ca895811cda6eea
Parents: 12fd898
Author: Archana Naik <naika@lab126.com>
Authored: Thu Oct 24 17:27:46 2013 -0700
Committer: Steven Gill <stevengill97@gmail.com>
Committed: Thu Dec 5 17:07:27 2013 -0800

----------------------------------------------------------------------
 README.md                            |  11 ++
 platforms.js                         |   5 +
 spec/platform.spec.js                |   2 +-
 src/metadata/amazon_fireos_parser.js | 188 ++++++++++++++++++++++++++++++
 4 files changed, 205 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4722c3ff/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index f26d248..2f64016 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,7 @@ Check out the [Getting Started guides](http://cordova.apache.org/docs/en/edge/gu
 
 # Supported Cordova Platforms
 
+- Amazon Fire OS
 - Android
 - BlackBerry 10
 - iOS
@@ -43,6 +44,7 @@ Check out the [Getting Started guides](http://cordova.apache.org/docs/en/edge/gu
   - [Android SDK](http://developer.android.com) - **NOTE** This tool
     will not work unless you have the absolute latest updates for all
     Android SDK components. Also you will need the SDK's `tools` and `platform-tools` directories
on your __system path__ otherwise Android support will fail.
+  - [Amazon Fire OS SDK](https://developer.amazon.com/sdk/fire/IntegratingAWV.html#installawv)
- **NOTE** This tool will not work unless you have Android SDK installed and paths are updated
as mentioned above. In addition you need to install AmazonWebView SDK and copy awv_interface.jar
to corodva-amazon-fireos/framework/libs folder. If libs folder does not exist then create
one.
   - [Windows Phone SDK](http://dev.windowsphone.com/en-us/downloadsdk) - **NOTE** This tool
will not work unless you have `msbuild` on your __system path__ otherwise Windows Phone support
will fail (`msbuild.exe` is generally located in `C:\Windows\Microsoft.NET\Framework\v4.0.30319`).
 
 cordova-cli has been tested on Mas OS X, Linux, Windows 7 and Windows 8.
@@ -276,3 +278,12 @@ Windows 8 support does not include the ability to launch/run/emulate,
so you wil
 To run your app, you will need to open the .sln in the platforms/windows8 folder using Visual
Studio 2012.
 Note also that Visual Studio will inform you to reload the project if you run any of the
above commands while the project is loaded.
 
+## Amazon Fire OS
+
+Amazon Fire OS does not include the ability to emulate. You are still able to use the following
commands with Amazon Fire OS
+
+- `platform add amazon-fireos`
+- `platform remove amazon-fireos`
+- `prepare amazon-fireos`
+- `compile amazon-fireos`
+- `build amazon-fireos`

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4722c3ff/platforms.js
----------------------------------------------------------------------
diff --git a/platforms.js b/platforms.js
index d25154d..1346ed6 100644
--- a/platforms.js
+++ b/platforms.js
@@ -33,6 +33,11 @@ module.exports = {
         url    : 'https://git-wip-us.apache.org/repos/asf?p=cordova-ubuntu.git',
         version: '3.2.0'
     }, 
+     'amazon-fireos' : {
+        parser : './src/metadata/amazon_fireos_parser',
+        url    : 'https://github.com/archananaik/cordova-amazon-fireos.git',
+        version: '3.1.0'
+    },
     'wp7' : {
         parser : './src/metadata/wp7_parser',
         url    : 'https://git-wip-us.apache.org/repos/asf?p=cordova-wp8.git',

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4722c3ff/spec/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform.spec.js b/spec/platform.spec.js
index dd86fa5..5582f39 100644
--- a/spec/platform.spec.js
+++ b/spec/platform.spec.js
@@ -151,7 +151,7 @@ describe('platform command', function() {
 
             it('should list out added platforms in a project', function(done) {
                 cordova.on('results', function(res) {
-                    expect(res).toMatch(/^Installed platforms: ios, android, ubuntu, wp7,
wp8, blackberry10, firefoxos, windows8\s*Available platforms:\s*$/);
+                    expect(res).toMatch(/^Installed platforms: ios, android, ubuntu, amazon-fireos,
wp7, wp8, blackberry10, firefoxos, windows8\s*Available platforms:\s*$/);
                     done();
                 });
                 cordova.raw.platform('list');

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4722c3ff/src/metadata/amazon_fireos_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/amazon_fireos_parser.js b/src/metadata/amazon_fireos_parser.js
new file mode 100644
index 0000000..555826e
--- /dev/null
+++ b/src/metadata/amazon_fireos_parser.js
@@ -0,0 +1,188 @@
+/**
+    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 fs            = require('fs'),
+    path          = require('path'),
+    xml           = require('../xml-helpers'),
+    util          = require('../util'),
+    events        = require('../events'),
+    shell         = require('shelljs'),
+    child_process = require('child_process'),
+    project_config= require('../config'),
+    Q             = require('q'),
+    config_parser = require('../config_parser');
+
+var default_prefs = {
+    "useBrowserHistory":"true",
+    "exit-on-suspend":"false"
+};
+
+module.exports = function android_parser(project) {
+    if (!fs.existsSync(path.join(project, 'AndroidManifest.xml'))) {
+        throw new Error('The provided path "' + project + '" is not an Android project.');
+    }
+    this.path = project;
+    this.strings = path.join(this.path, 'res', 'values', 'strings.xml');
+    this.manifest = path.join(this.path, 'AndroidManifest.xml');
+    this.android_config = path.join(this.path, 'res', 'xml', 'config.xml');
+};
+
+// Returns a promise.
+module.exports.check_requirements = function(project_root) {
+    events.emit('log', 'Checking Android requirements...');
+    var command = 'android list target';
+    events.emit('verbose', 'Running "' + command + '" (output to follow)');
+    var d = Q.defer();
+    child_process.exec(command, function(err, output, stderr) {
+        events.emit('verbose', output);
+        if (err) {
+            d.reject(new Error('The command `android` failed. Make sure you have the latest
Android SDK installed, and the `android` command (inside the tools/ folder) added to your
path. Output: ' + output));
+        } else {
+            if (output.indexOf('android-17') == -1) {
+                d.reject(new Error('Please install Android target 17 (the Android 4.2 SDK).
Make sure you have the latest Android tools installed as well. Run `android` from your command-line
to install/update any missing SDKs or tools.'));
+            } else {
+                var custom_path = project_config.has_custom_path(project_root, 'android');
+                var framework_path;
+                if (custom_path) {
+                    framework_path = path.resolve(path.join(custom_path, 'framework'));
+                } else {
+                    framework_path = path.join(util.libDirectory, 'amazon-fireos', 'cordova',
require('../../platforms').android.version, 'framework');
+                }
+                var cmd = 'android update project -p "' + framework_path  + '" -t android-17';
+                events.emit('verbose', 'Running "' + cmd + '" (output to follow)...');
+                var d2 = Q.defer();
+                child_process.exec(cmd, function(err, output, stderr) {
+                    events.emit('verbose', output + stderr);
+                    if (err) {
+                        d2.reject(new Error('Error updating the Cordova library to work with
your Android environment. Command run: "' + cmd + '", output: ' + output));
+                    } else {
+                        d2.resolve();
+                    }
+                });
+                d.resolve(d2.promise);
+            }
+        }
+    });
+    return d.promise;
+};
+
+module.exports.prototype = {
+    update_from_config:function(config) {
+        if (config instanceof config_parser) {
+        } else throw new Error('update_from_config requires a config_parser object');
+
+        // Update app name by editing res/values/strings.xml
+        var name = config.name();
+        var strings = xml.parseElementtreeSync(this.strings);
+        strings.find('string[@name="app_name"]').text = name;
+        fs.writeFileSync(this.strings, strings.write({indent: 4}), 'utf-8');
+        events.emit('verbose', 'Wrote out Android application name to "' + name + '"');
+
+        var manifest = xml.parseElementtreeSync(this.manifest);
+        // Update the version by changing the AndroidManifest android:versionName
+        var version = config.version();
+        manifest.getroot().attrib["android:versionName"] = version;
+
+        // Update package name by changing the AndroidManifest id and moving the entry class
around to the proper package directory
+        var pkg = config.packageName();
+        pkg = pkg.replace(/-/g, '_'); // Java packages cannot support dashes
+        var orig_pkg = manifest.getroot().attrib.package;
+        manifest.getroot().attrib.package = pkg;
+
+        // Write out AndroidManifest.xml
+        fs.writeFileSync(this.manifest, manifest.write({indent: 4}), 'utf-8');
+
+        var orig_pkgDir = path.join(this.path, 'src', path.join.apply(null, orig_pkg.split('.')));
+        var orig_java_class = fs.readdirSync(orig_pkgDir).filter(function(f) {return f.indexOf('.svn')
== -1;})[0];
+        var pkgDir = path.join(this.path, 'src', path.join.apply(null, pkg.split('.')));
+        shell.mkdir('-p', pkgDir);
+        var orig_javs = path.join(orig_pkgDir, orig_java_class);
+        var new_javs = path.join(pkgDir, orig_java_class);
+        var javs_contents = fs.readFileSync(orig_javs, 'utf-8');
+        javs_contents = javs_contents.replace(/package [\w\.]*;/, 'package ' + pkg + ';');
+        events.emit('verbose', 'Wrote out Android package name to "' + pkg + '"');
+        fs.writeFileSync(new_javs, javs_contents, 'utf-8');
+    },
+
+    // Returns the platform-specific www directory.
+    www_dir:function() {
+        return path.join(this.path, 'assets', 'www');
+    },
+
+    staging_dir: function() {
+        return path.join(this.path, '.staging', 'www');
+    },
+
+    config_xml:function(){
+        return this.android_config;
+    },
+
+    update_www:function() {
+        var projectRoot = util.isCordova(this.path);
+        var www = util.projectWww(projectRoot);
+        var platformWww = path.join(this.path, 'assets');
+        // remove stock platform assets
+        shell.rm('-rf', this.www_dir());
+        // copy over all app www assets
+        shell.cp('-rf', www, platformWww);
+
+        // write out android lib's cordova.js
+        var custom_path = project_config.has_custom_path(projectRoot, 'android');
+        var jsPath;
+        if (custom_path) {
+            jsPath = path.resolve(path.join(custom_path, 'framework', 'assets', 'www', 'cordova.js'));
+        } else {
+            jsPath = path.join(util.libDirectory, 'amazon-fireos', 'cordova', require('../../platforms').android.version,
'framework', 'assets', 'www', 'cordova.js');
+        }
+        fs.writeFileSync(path.join(this.www_dir(), 'cordova.js'), fs.readFileSync(jsPath,
'utf-8'), 'utf-8');
+    },
+
+    // update the overrides folder into the www folder
+    update_overrides:function() {
+        var projectRoot = util.isCordova(this.path);
+        var merges_path = path.join(util.appDir(projectRoot), 'merges', 'amazon-fireos');
+        if (fs.existsSync(merges_path)) {
+            var overrides = path.join(merges_path, '*');
+            shell.cp('-rf', overrides, this.www_dir());
+        }
+    },
+
+    // update the overrides folder into the www folder
+    update_staging:function() {
+        if (fs.existsSync(this.staging_dir())) {
+            var staging = path.join(this.staging_dir(), '*');
+            shell.cp('-rf', staging, this.www_dir());
+        }
+    },
+
+    // Returns a promise.
+    update_project:function(cfg) {
+        var platformWww = path.join(this.path, 'assets');
+        try {
+            this.update_from_config(cfg);
+        } catch(e) {
+            return Q.reject(e);
+        }
+        this.update_overrides();
+        this.update_staging();
+        // delete any .svn folders copied over
+        util.deleteSvnFolders(platformWww);
+        return Q();
+    }
+};
+


Mime
View raw message