You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/08/24 00:06:01 UTC
[3/5] git commit: make the firefoxos parser actually build the project
make the firefoxos parser actually build the project
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/786f8f06
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/786f8f06
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/786f8f06
Branch: refs/heads/ffos
Commit: 786f8f06d17206c239ae2cc086c0d5be777617c2
Parents: a3d8ce7
Author: James Long <lo...@gmail.com>
Authored: Wed Aug 21 14:12:39 2013 -0400
Committer: James Long <lo...@gmail.com>
Committed: Wed Aug 21 14:12:39 2013 -0400
----------------------------------------------------------------------
src/metadata/firefoxos_parser.js | 100 +++++++++++++++++++++++++++++++++-
1 file changed, 99 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/786f8f06/src/metadata/firefoxos_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/firefoxos_parser.js b/src/metadata/firefoxos_parser.js
index 4ef985b..6fa8105 100644
--- a/src/metadata/firefoxos_parser.js
+++ b/src/metadata/firefoxos_parser.js
@@ -1,4 +1,9 @@
+var fs = require('fs');
var path = require('path');
+var shell = require('shelljs');
+var util = require('../util');
+var config_parser = require('../config_parser');
+var config = require('../config');
module.exports = function firefoxos_parser(project) {
this.path = project;
@@ -9,11 +14,104 @@ module.exports.check_requirements = function(project_root, callback) {
};
module.exports.prototype = {
+ update_from_config: function(config, callback) {
+ if (!(config instanceof config_parser)) {
+ var err = new Error('update_from_config requires a config_parser object');
+ if (callback) {
+ callback(err);
+ return;
+ }
+ else {
+ throw err;
+ }
+ }
+
+ var name = config.name();
+ var pkg = config.packageName();
+ var version = config.version();
+
+ var manifestPath = path.join(this.www_dir(), 'manifest.webapp');
+ var manifest;
+
+ if(fs.existsSync(manifestPath)) {
+ manifest = JSON.parse(fs.readFileSync(manifestPath));
+ }
+ else {
+ manifest = {};
+ }
+
+ manifest.version = version;
+ manifest.name = name;
+ manifest.pkgName = pkg;
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest));
+
+ if(callback) {
+ callback();
+ }
+ },
+
www_dir: function() {
return path.join(this.path, 'www');
},
+ update_www: function() {
+ var projectRoot = util.isCordova(this.path);
+ var projectWww = util.projectWww(projectRoot);
+ var platformWww = this.www_dir();
+
+ shell.rm('-rf', platformWww);
+ shell.cp('-rf', projectWww, this.path);
+
+ var customPath = config.has_custom_path(projectRoot, 'firefoxos');
+ var libPath = (customPath ?
+ customPath :
+ path.join(util.libDirectory, 'firefoxos', 'cordova',
+ require('../../platforms').ios.version));
+ shell.cp('-f',
+ path.join(libPath, 'cordova-lib', 'cordova.js'),
+ path.join(platformWww, 'cordova.js'));
+ },
+
+ update_overrides: function() {
+ var projectRoot = util.isCordova(this.path);
+ var mergesPath = path.join(util.appDir(projectRoot), 'merges', 'firefoxos');
+ if(fs.existsSync(mergesPath)) {
+ var overrides = path.join(mergesPath, '*');
+ shell.cp('-rf', overrides, this.www_dir());
+ }
+ },
+
+ update_staging: function() {
+ var projectRoot = util.isCordova(this.path);
+ var stagingDir = path.join(this.path, '.staging', 'www');
+
+ if(fs.existsSync(stagingDir)) {
+ shell.cp('-rf',
+ path.join(stagingDir, '*'),
+ this.www_dir());
+ }
+ },
+
update_project: function(cfg, callback) {
- callback();
+ this.update_www();
+
+ this.update_from_config(cfg, function(err) {
+ if(err) {
+ if(callback) {
+ callback(err);
+ }
+ else {
+ throw err;
+ }
+ } else {
+ this.update_overrides();
+ this.update_staging();
+ util.deleteSvnFolders(this.www_dir());
+
+ if(callback) {
+ callback();
+ }
+ }
+ }.bind(this));
}
};