cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [03/14] git commit: addition of merges functionality
Date Fri, 22 Mar 2013 22:49:48 GMT
addition of merges functionality

merges functionality which allows for merging in www content per
platform.  For more detail see the following email thread with
Dude, first thing I have to say that I love this, I think its a really
great addition, and will clean up project code a tonne. Some

- don't like the folder name. Its precious, I know, but I think we can
some up w/ some better than isn't camel cased. www-overrides or maybe
just "clobbers" or "merges" seems more descriptive to me (in my ideal
fantasy world platforms wouldn't even be in revision control and would
be a build artifact. we're not there yet obviously!)

- if I have something in the overrides folder that IS NOT in the www
equiv would it just get copied/merged in? seems this would be so but
this isn't clear

This def belongs in the cordova-cli project. What I also like is that
we could really start envisioning more shim type code working here.
(For cases like Chrome Packaged Apps or what have you.)

On Sun, Feb 10, 2013 at 3:22 AM, Michael Wolf
<> wrote:
Awesome.  Its funny you mention the platform name, when I first did
this in our build system I ended up following the iOS pattern of doing
like ~platform name like they do ~iphone or ~ipad.  However it just
became a pain as you had to change file names and more importantly it
confused as to what was purely in browser versus what would go into the
platform builds.  So what I ended up having us do was have an overrides
folder that just has the same file structure of the www such that you
just copy over and what evers in the overrides folder overwrites the
www file which had been copied in.  see below as an example.  Anywho…
happy to contribute is this the map git ?


On 2/9/13 5:52 AM, "Brian LeRoux" <> wrote:

I love this idea. A much older prototype of the CLI stuff had some
smarts that when it detected a file with a platform name in the string
it copied it only to that platform.

Do a pull request and link in this thread for discussion. I think it
would be a great addition to the workflow.

On Fri, Feb 8, 2013 at 6:15 PM, Michael Wolf <>
Hey Man:

I have been loving the updates in the phone gap cli.  Have a feature Id
to add, its something which I had in our internal cynergy build scripts
support building for multiple platforms at once and mocking in, in
The idea is a platform overrides folder, which will override
css/js/html/images etc when deployed to a specific platform.  For
images you want to replace on android but not iOS, or js code you want
mock in browser, but then replace w/ a real implementation when
building for
android/ios, or instead of writing conditional platform logic for a fix
iOS or android you replace the actual js file on each platform.   This
is a
strategy which we have used on our projects since the early halo days,
it has helped a lot in simplifying production code…. Particualry when
try and build for a common base between say something for ios/android
windows phone. Anywho….

I have an implantation working in the cordova cli node scripts.  How
might I
go about swinging this idea by team, more than happy to add the feature.



Branch: refs/heads/next
Commit: b7bd89ac4cf4383b3fff7728b3987314bd482069
Parents: c1c6638
Author: michael.wolf <michael.wolf@MWolf-MBP.local>
Authored: Mon Feb 11 22:28:58 2013 -0500
Committer: Fil Maj <>
Committed: Mon Mar 4 10:43:35 2013 -0800

 src/create.js                     |    1 +
 src/metadata/android_parser.js    |    8 ++++++++
 src/metadata/blackberry_parser.js |    9 +++++++++
 src/metadata/ios_parser.js        |    9 +++++++++
 src/platform.js                   |    8 ++++++++
 5 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/src/create.js b/src/create.js
index c2f20bd..c4ddb1d 100644
--- a/src/create.js
+++ b/src/create.js
@@ -59,6 +59,7 @@ module.exports = function create (dir, id, name) {
     // Create basic project structure.
     shell.mkdir('-p', dotCordova);
     shell.mkdir('-p', path.join(dir, 'platforms'));
+    shell.mkdir('-p', path.join(dir, 'merges'));
     shell.mkdir('-p', path.join(dir, 'plugins'));
     var hooks = path.join(dotCordova, 'hooks');
     shell.mkdir('-p', hooks);
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index a79101f..e83bb82 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -144,6 +144,14 @@ module.exports.prototype = {
         // delete any .svn folders copied over
+    // update the overrides folder into the www folder
+    update_overrides:function() {
+        var projectRoot = util.isCordova(this.path);
+        var overrides = path.join(projectRoot, 'merges','android','*');
+        shell.cp('-rf', overrides, this.www_dir());
+    },
     update_project:function(cfg, callback) {
diff --git a/src/metadata/blackberry_parser.js b/src/metadata/blackberry_parser.js
index e10fa83..91d0f60 100644
--- a/src/metadata/blackberry_parser.js
+++ b/src/metadata/blackberry_parser.js
@@ -120,6 +120,15 @@ module.exports.prototype = {
+    // update the overrides folder into the www folder
+    update_overrides:function() {
+        var projectRoot = util.isCordova(this.path);
+        var platformWww = path.join(this.path, 'www');
+        var overrides = path.join(projectRoot, 'merges','blackberry');
+        shell.cp('-rf', overrides+'/*',platformWww);
+    },
     write_project_properties:function() {
         // TODO: eventually support all blackberry sub-platforms
         var projectRoot = util.isCordova(this.path);
diff --git a/src/metadata/ios_parser.js b/src/metadata/ios_parser.js
index 9a9f306..03455ed 100644
--- a/src/metadata/ios_parser.js
+++ b/src/metadata/ios_parser.js
@@ -153,6 +153,15 @@ module.exports.prototype = {
+    // update the overrides folder into the www folder
+    update_overrides:function() {
+        var projectRoot = util.isCordova(this.path);
+        var project_www = path.join(this.path, 'www');
+        var overrides = path.join(projectRoot, 'merges','ios');
+        shell.cp('-rf', overrides+'/*',project_www);
+    },
     update_project:function(cfg, callback) {
         var self = this;
         this.update_from_config(cfg, function() {
diff --git a/src/platform.js b/src/platform.js
index cd3098b..4705130 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -38,6 +38,10 @@ module.exports = function platform(command, targets, callback) {
     var hooks = new hooker(projectRoot),
+    var createOverrides = function(target){
+        shell.mkdir('-p', path.join('merges',target));
+    };
     if (arguments.length === 0) command = 'ls';
     if (targets) {
         if (!(targets instanceof Array)) targets = [targets];
@@ -91,12 +95,14 @@ module.exports = function platform(command, targets, callback) {
                                 case 'android':
                                     var android = new android_parser(output);
+                                    createOverrides(target);
                                 case 'ios':
                                     var ios = new ios_parser(output);
                                     ios.update_project(cfg, function() {
+                                        createOverrides(target);
@@ -104,6 +110,7 @@ module.exports = function platform(command, targets, callback) {
                                 case 'blackberry':
                                     var bb = new blackberry_parser(output);
                                     bb.update_project(cfg, function() {
+                                        createOverrides(target);
@@ -119,6 +126,7 @@ module.exports = function platform(command, targets, callback) {
             targets.forEach(function(target) {
                 shell.rm('-rf', path.join(projectRoot, 'platforms', target));
+                shell.rm('-rf', path.join(projectRoot,'merges',target));

View raw message