You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/03/05 01:20:33 UTC

[1/10] git commit: addition of merges functionality

addition of merges functionality

merges functionality which allows for merging in www content per
platform.  For more detail see the following email thread with
brian.leroux@gmail.com
-----------------
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
feedback/queries:

- 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
<Mi...@cynergy.com> 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
https://github.com/apache/cordova-cli ?

mw

On 2/9/13 5:52 AM, "Brian LeRoux" <b...@brian.io> 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 <Mi...@cynergy.com>
wrote:
Hey Man:

I have been loving the updates in the phone gap cli.  Have a feature Id
love
to add, its something which I had in our internal cynergy build scripts
to
support building for multiple platforms at once and mocking in, in
browser.
The idea is a platform overrides folder, which will override
css/js/html/images etc when deployed to a specific platform.  For
example
images you want to replace on android but not iOS, or js code you want
to
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
in
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,
and
it has helped a lot in simplifying production code…. Particualry when
you
try and build for a common base between say something for ios/android
and
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.

mw


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

Branch: refs/heads/master
Commit: b7bd89ac4cf4383b3fff7728b3987314bd482069
Parents: c1c6638
Author: michael.wolf <mi...@MWolf-MBP.local>
Authored: Mon Feb 11 22:28:58 2013 -0500
Committer: Fil Maj <ma...@gmail.com>
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(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b7bd89ac/src/create.js
----------------------------------------------------------------------
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);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b7bd89ac/src/metadata/android_parser.js
----------------------------------------------------------------------
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
         util.deleteSvnFolders(platformWww);
     },
+
+    // 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) {
         this.update_from_config(cfg);
         this.update_www();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b7bd89ac/src/metadata/blackberry_parser.js
----------------------------------------------------------------------
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 = {
 
         util.deleteSvnFolders(platformWww);
     },
+
+    // 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);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b7bd89ac/src/metadata/ios_parser.js
----------------------------------------------------------------------
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 = {
 
         util.deleteSvnFolders(project_www);
     },
+
+    // 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() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b7bd89ac/src/platform.js
----------------------------------------------------------------------
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),
         end;
 
+    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);
                                     android.update_project(cfg);
+                                    createOverrides(target);
                                     hooks.fire('after_platform_add');
                                     end();
                                     break;
                                 case 'ios':
                                     var ios = new ios_parser(output);
                                     ios.update_project(cfg, function() {
+                                        createOverrides(target);
                                         hooks.fire('after_platform_add');
                                         end();
                                     });
@@ -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);
                                         hooks.fire('after_platform_add');
                                         end();
                                     });
@@ -119,6 +126,7 @@ module.exports = function platform(command, targets, callback) {
             targets.forEach(function(target) {
                 hooks.fire('before_platform_rm');
                 shell.rm('-rf', path.join(projectRoot, 'platforms', target));
+                shell.rm('-rf', path.join(projectRoot,'merges',target));
                 hooks.fire('after_platform_rm');
             });
             break;