cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Maj <...@adobe.com>
Subject Re: git commit: [CB-3755] Update platform version from config.xml
Date Tue, 11 Jun 2013 15:20:39 GMT
Hey Tommy can you file issues for BB10 + WP7/8 support for this feature?
So we keep track of what needs to be covered for other platforms.

Cheers,
Fil

On 6/11/13 1:42 AM, "devgeeks@apache.org" <devgeeks@apache.org> wrote:

>Updated Branches:
>  refs/heads/master2 5011b0caf -> 04648ad00
>
>
>[CB-3755] Update platform version from config.xml
>
>- Updates AndroidManifest.xml android:versionName with version from
>config.xml
>- Updates AppName-Info.plist CFBundleVersion with version from config.xml
>
>NOTE: So far this is only handling Android and iOS. WP7/8 and Blackberry
>need to be updated as well
>
>
>Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
>Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/04648ad0
>Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/04648ad0
>Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/04648ad0
>
>Branch: refs/heads/master2
>Commit: 04648ad00a2e2601f4052ca9da90377f54f9dbcd
>Parents: 5011b0c
>Author: Tommy-Carlos Williams <tommy@devgeeks.org>
>Authored: Tue Jun 11 18:33:24 2013 +1000
>Committer: Tommy-Carlos Williams <tommy@devgeeks.org>
>Committed: Tue Jun 11 18:33:24 2013 +1000
>
>----------------------------------------------------------------------
> spec/cordova-cli/config_parser.spec.js          | 20 ++++++++++++++++++++
> .../android/android_parser.spec.js              |  7 +++++++
> spec/platform-script/ios/ios_parser.spec.js     |  8 ++++++++
> src/config_parser.js                            |  6 ++++++
> src/metadata/android_parser.js                  |  6 ++++++
> src/metadata/ios_parser.js                      |  4 ++++
> 6 files changed, 51 insertions(+)
>----------------------------------------------------------------------
>
>
>http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/04648ad0/spec/cord
>ova-cli/config_parser.spec.js
>----------------------------------------------------------------------
>diff --git a/spec/cordova-cli/config_parser.spec.js
>b/spec/cordova-cli/config_parser.spec.js
>index 77658fb..303b3d6 100644
>--- a/spec/cordova-cli/config_parser.spec.js
>+++ b/spec/cordova-cli/config_parser.spec.js
>@@ -63,6 +63,26 @@ describe('config.xml parser', function () {
>         });
>     });
> 
>+    describe('version', function() {
>+        var cfg;
>+
>+        beforeEach(function() {
>+            cfg = new config_parser(xml);
>+        });
>+
>+        it('should get the version', function() {
>+            expect(cfg.version()).toEqual('2.0.0');
>+        });
>+        it('should allow setting the version', function() {
>+            cfg.version('2.0.1');
>+            expect(cfg.version()).toEqual('2.0.1');
>+        });
>+        it('should write to disk after setting the version', function() {
>+            cfg.version('2.0.1');
>+            expect(fs.readFileSync(xml,
>'utf-8')).toMatch(/version="2.0.1"/);
>+        });
>+    });
>+
>     describe('app name', function() {
>         var cfg;
> 
>
>http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/04648ad0/spec/plat
>form-script/android/android_parser.spec.js
>----------------------------------------------------------------------
>diff --git a/spec/platform-script/android/android_parser.spec.js
>b/spec/platform-script/android/android_parser.spec.js
>index c0f77c1..4759a2c 100644
>--- a/spec/platform-script/android/android_parser.spec.js
>+++ b/spec/platform-script/android/android_parser.spec.js
>@@ -98,6 +98,13 @@ describe('android project parser', function() {
>             expect(fs.existsSync(javs)).toBe(true);
>             expect(fs.readFileSync(javs, 'utf-8')).toMatch(/package
>ca.filmaj.dewd/i);
>         });
>+        it('should update the application version properly', function() {
>+            config.version('2.0.1');
>+            project.update_from_config(config);
>+
>+            var manifest = new
>et.ElementTree(et.XML(fs.readFileSync(android_manifest, 'utf-8')));
>+            
>expect(manifest.getroot().attrib["android:versionName"]).toEqual('2.0.1');
>+        });
>         it('should handle unsupported "-" in the application package
>name', function() {
>             var javs = path.join(android_path, 'src', 'ca', 'filmaj',
>'the_dewd', 'cordovaExample.java');
>             var orig_javs = path.join(android_path, 'src', 'org',
>'apache', 'cordova', 'cordovaExample', 'cordovaExample.java');
>
>http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/04648ad0/spec/plat
>form-script/ios/ios_parser.spec.js
>----------------------------------------------------------------------
>diff --git a/spec/platform-script/ios/ios_parser.spec.js
>b/spec/platform-script/ios/ios_parser.spec.js
>index 8598c3f..25f7833 100644
>--- a/spec/platform-script/ios/ios_parser.spec.js
>+++ b/spec/platform-script/ios/ios_parser.spec.js
>@@ -90,6 +90,14 @@ describe('ios project parser', function () {
>                 done();
>             });
>         });
>+        it('should update the application version (CFBundleVersion)
>properly', function (done) {
>+            config.version('2.0.1');
>+            project.update_from_config(config, function () {
>+                var plist_contents = fs.readFileSync(ios_plist, 'utf-8');
>+                expect(plist_contents).toMatch(/<string>2.0.1/);
>+                done();
>+            });
>+        });
>         it('should update the whitelist in the project config.xml',
>function (done) {
>             project.update_from_config(config, function () {
>                 var config_contents = fs.readFileSync(ios_config_xml,
>'utf-8');
>
>http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/04648ad0/src/confi
>g_parser.js
>----------------------------------------------------------------------
>diff --git a/src/config_parser.js b/src/config_parser.js
>index c9c4028..082b7f2 100644
>--- a/src/config_parser.js
>+++ b/src/config_parser.js
>@@ -40,6 +40,12 @@ config_parser.prototype = {
>             this.update();
>         } else return this.doc.find('name').text;
>     },
>+    version:function(version) {
>+        if (version) {
>+            this.doc.getroot().attrib.version = version;
>+            this.update();
>+        } else return this.doc.getroot().attrib.version;
>+    },
>     update:function() {
>         fs.writeFileSync(this.path, this.doc.write({indent: 4}),
>'utf-8');
>     }
>
>http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/04648ad0/src/metad
>ata/android_parser.js
>----------------------------------------------------------------------
>diff --git a/src/metadata/android_parser.js
>b/src/metadata/android_parser.js
>index b66e58b..314338d 100644
>--- a/src/metadata/android_parser.js
>+++ b/src/metadata/android_parser.js
>@@ -78,6 +78,12 @@ module.exports.prototype = {
>         fs.writeFileSync(this.strings, strings.write({indent: 4}),
>'utf-8');
>         events.emit('log', 'Wrote out Android application name to "' +
>name + '"');
> 
>+        // Update the version by changing the AndroidManifest
>android:versionName
>+        var manifest = new
>et.ElementTree(et.XML(fs.readFileSync(this.manifest, 'utf-8')));
>+        var version = config.version();
>+        manifest.getroot().attrib["android:versionName"] = version;
>+        fs.writeFileSync(this.manifest, manifest.write({indent: 4}),
>'utf-8');
>+
>         // Update package name by changing the AndroidManifest id and
>moving the entry class around to the proper package directory
>         var manifest = new
>et.ElementTree(et.XML(fs.readFileSync(this.manifest, 'utf-8')));
>         var pkg = config.packageName();
>
>http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/04648ad0/src/metad
>ata/ios_parser.js
>----------------------------------------------------------------------
>diff --git a/src/metadata/ios_parser.js b/src/metadata/ios_parser.js
>index a8c6229..8ed1af8 100644
>--- a/src/metadata/ios_parser.js
>+++ b/src/metadata/ios_parser.js
>@@ -89,15 +89,19 @@ module.exports.prototype = {
>         }
>         var name = config.name();
>         var pkg = config.packageName();
>+        var version = config.version();
> 
>         // Update package id (bundle id)
>         var plistFile = path.join(this.cordovaproj, this.originalName +
>'-Info.plist');
>         var infoPlist = plist.parseFileSync(plistFile);
>         infoPlist['CFBundleIdentifier'] = pkg;
>+        // Update version (bundle version)
>+        infoPlist['CFBundleVersion'] = version;
>         var info_contents = plist.build(infoPlist);
>         info_contents =
>info_contents.replace(/<string>[\s\r\n]*<\/string>/g,'<string></string>');
>         fs.writeFileSync(plistFile, info_contents, 'utf-8');
>         events.emit('log', 'Wrote out iOS Bundle Identifier to "' + pkg
>+ '"');
>+        events.emit('log', 'Wrote out iOS Bundle Version to "' + version
>+ '"');
> 
>         // Update whitelist
>         var self = this;
>


Mime
View raw message