Updated Branches:
  refs/heads/cordova-client ac2b66dbc -> 11165e99a

added a dot parser, start of syncing up config.xml between user and client


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/11165e99
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/11165e99
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/11165e99

Branch: refs/heads/cordova-client
Commit: 11165e99a558c24c10d9a4f6f80d24bb383a18bc
Parents: 0f92128
Author: Fil Maj <maj....@gmail.com>
Authored: Tue Sep 18 16:23:13 2012 -0700
Committer: Fil Maj <maj....@gmail.com>
Committed: Tue Sep 18 16:23:13 2012 -0700

----------------------------------------------------------------------
 README.md                                          |   12 +---
 spec/dot_parser.spec.js                            |   65 +++++++++++++++
 .../android/src/android/SomethingWithR.java        |    6 ++
 spec/fixtures/projects/test/.cordova               |    1 +
 src/config_parser.js                               |    6 +-
 src/dot_parser.js                                  |   43 ++++++++++
 src/platform.js                                    |    6 +-
 7 files changed, 123 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/11165e99/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 41d8b90..c5e10bd 100644
--- a/README.md
+++ b/README.md
@@ -134,8 +134,8 @@ Plugin integration hinges on:
 
 ## TO-DO
 
-- bootstrapping the tests
 - properly extracting info from config.xml
+- bootstrapping the tests
 - checking SDK compatibility
 - blackberry support
 - windows phone support
@@ -149,13 +149,3 @@ It would be useful to support Bash command-line 
completions, in the [same manner
 - it would be useful
 - it would force us into some consistency to maintain an easy completion script
 
-### Random Notes
-posted to the mailing list by BrianL
-
-yah. there is tonnes of prior art for this stuff. I will update the wiki but 
quickly, this was stable: 
[https://github.com/brianleroux/Cordova/tree/b816aacfb7583174be9f44f71dc32c8465d1319]()
-
-then other things happened. Those scripts ended up in the mainline projects. 
The idea was a standard package format for a project and upgrading would 
consist only of swapping out the bin directory. The scripts would live local 
the project avoiding version hell between releases.
-
-This new thinking is different. We now think the native project as it were 
should host its own scripts. Upgrading not a consideration. Maybe it should be. 
You're thinking of a master global script, which is cool and something I've 
always wanted, but the version thing needs to be considered. perhaps not an 
issue between releases if the native project (the target of www) deals with the 
version itself...
-
-cordova-client internally depends on pluginstall, a tool written by Andrew 
Lunny to support installing plugins for the iOS and Android platforms 
[https://github.com/alunny/pluginstall]()

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/11165e99/spec/dot_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/dot_parser.spec.js b/spec/dot_parser.spec.js
new file mode 100644
index 0000000..8543b60
--- /dev/null
+++ b/spec/dot_parser.spec.js
@@ -0,0 +1,65 @@
+var cordova = require('../cordova'),
+    path = require('path'),
+    fs = require('fs'),
+    dot_parser = require('../src/dot_parser'),
+    file = path.join(__dirname, 'fixtures', 'projects', 'test', '.cordova');
+
+var original_dot = fs.readFileSync(file, 'utf-8');
+
+describe('dot cordova file parser', function() {
+    afterEach(function() {
+        fs.writeFileSync(file, original_dot, 'utf-8');
+    });
+
+    it("should read a .cordova file", function() {
+        var dot;
+        expect(function() {
+            dot = new dot_parser(file);
+        }).not.toThrow();
+        expect(dot).toBeDefined();
+    });
+
+    describe('get', function() {
+        var dot;
+        beforeEach(function() {
+            dot = new dot_parser(file);
+        });
+
+        it("should be able to return app name", function() {
+            expect(dot.name()).toBe("test");
+        });
+        it("should be able to return app id (or package)", function() {
+            expect(dot.packageName()).toBe("org.apache.cordova");
+        });
+        it("should be able to return app platforms", function() {
+            var ps = dot.ls_platforms();
+            expect(ps[0]).toBe('android');
+            expect(ps[1]).toBe('ios');
+        });
+    });
+    describe('set', function() {
+        var dot;
+        beforeEach(function() {
+            dot = new dot_parser(file);
+        });
+
+        it("should be able to write app name", function() {
+            dot.name('new');
+            expect(JSON.parse(fs.readFileSync(file, 
'utf-8')).name).toBe('new');
+        });
+        it("should be able to write app id (or package)", function () {
+            dot.packageName('ca.filmaj.app');
+            expect(JSON.parse(fs.readFileSync(file, 
'utf-8')).id).toBe('ca.filmaj.app');
+        });
+        it("should be able to add platforms", function() {
+            dot.add_platform('blackberry');
+            expect(JSON.parse(fs.readFileSync(file, 
'utf-8')).platforms.length).toBe(3);
+            expect(JSON.parse(fs.readFileSync(file, 
'utf-8')).platforms[2]).toBe('blackberry');
+        });
+        it("should be able to remove platforms", function() {
+            dot.remove_platform('ios');
+            expect(JSON.parse(fs.readFileSync(file, 
'utf-8')).platforms.length).toBe(1);
+            expect(JSON.parse(fs.readFileSync(file, 
'utf-8')).platforms[0]).toBe('android');
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/11165e99/spec/fixtures/plugins/android/src/android/SomethingWithR.java
----------------------------------------------------------------------
diff --git a/spec/fixtures/plugins/android/src/android/SomethingWithR.java 
b/spec/fixtures/plugins/android/src/android/SomethingWithR.java
new file mode 100644
index 0000000..c3af060
--- /dev/null
+++ b/spec/fixtures/plugins/android/src/android/SomethingWithR.java
@@ -0,0 +1,6 @@
+import com.yourapp.R;
+
+import android.app.*;
+
+public class SomethingWithR {
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/11165e99/spec/fixtures/projects/test/.cordova
----------------------------------------------------------------------
diff --git a/spec/fixtures/projects/test/.cordova 
b/spec/fixtures/projects/test/.cordova
new file mode 100644
index 0000000..44ab66e
--- /dev/null
+++ b/spec/fixtures/projects/test/.cordova
@@ -0,0 +1 @@
+{"name":"test","id":"org.apache.cordova","platforms":["android", "ios"]}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/11165e99/src/config_parser.js
----------------------------------------------------------------------
diff --git a/src/config_parser.js b/src/config_parser.js
index ec21814..9060fe4 100644
--- a/src/config_parser.js
+++ b/src/config_parser.js
@@ -2,9 +2,9 @@ var et = require('elementtree'),
     platforms = require('./../platforms'),
     fs = require('fs');
 
-function config_parser(xmlPath) {
-    this.path = xmlPath;
-    this.doc = new et.ElementTree(et.XML(fs.readFileSync(xmlPath, 'utf-8')));
+function config_parser(path) {
+    this.path = path;
+    this.doc = new et.ElementTree(et.XML(fs.readFileSync(path, 'utf-8')));
 }
 
 config_parser.prototype = {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/11165e99/src/dot_parser.js
----------------------------------------------------------------------
diff --git a/src/dot_parser.js b/src/dot_parser.js
new file mode 100644
index 0000000..f73fa7d
--- /dev/null
+++ b/src/dot_parser.js
@@ -0,0 +1,43 @@
+var fs = require('fs');
+
+function dot_parser(path) {
+    this.path = path;
+    this.json = JSON.parse(fs.readFileSync(path, 'utf-8'));
+}
+
+dot_parser.prototype = {
+    ls_platforms:function() {
+        return this.json.platforms;
+    },
+    add_platform:function(platform) {
+        if (this.json.platforms.indexOf(platform) > -1) return;
+        else {
+            this.json.platforms.push(platform);
+            this.update();
+        }
+    },
+    remove_platform:function(platform) {
+        if (this.json.platforms.indexOf(platform) == -1) return;
+        else {
+            this.json.platforms.splice(this.json.platforms.indexOf(platform), 
1);
+            this.update();
+        }
+    },
+    packageName:function(id) {
+        if (id) {
+            this.json.id = id;
+            this.update();
+        } else return this.json.id;
+    },
+    name:function(name) {
+        if (name) {
+            this.json.name = name;
+            this.update();
+        } else return this.json.name;
+    },
+    update:function() {
+        fs.writeFileSync(this.path, JSON.stringify(this.json), 'utf-8');
+    }
+};
+
+module.exports = dot_parser;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/11165e99/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 9ad4503..3d26727 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -55,8 +55,10 @@ module.exports = function platform(command, target, 
callback) {
                         throw ('An error occured during git-clone of ' + 
repos[target] + '. ' + buffers.err);
                     }
 
-                    // Check out the right version. Currently: 2.1.0rc1.
-                    cmd = util.format('cd "%s" && git checkout 2.1.0rc1', 
outPath);
+                    // Check out the right version. Currently: 2.1.0.
+                    cmd = 'cd "%s" && git checkout 2.1.0';
+                    if (target == "android") cmd = 'cd "%s" && git checkout 
47daaaf';
+                    cmd = util.format(cmd, outPath);
                     exec(cmd, flow.set({
                         key:'tagcheckout',
                         firstArgIsError:false,

Reply via email to