cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [20/24] git commit: CB-5816 Review-response: fix unix-centric paths to path.join(), minor typographic changes
Date Wed, 14 May 2014 00:10:02 GMT
CB-5816 Review-response: fix unix-centric paths to path.join(), minor typographic changes


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

Branch: refs/heads/master
Commit: 52a52556f4b07d7bf5f4dc5db657eb6e942c57c5
Parents: ef16bde
Author: braas <braas@steckelfisch.nl>
Authored: Wed Apr 30 11:07:10 2014 +0200
Committer: braas <braas@steckelfisch.nl>
Committed: Wed Apr 30 11:07:10 2014 +0200

----------------------------------------------------------------------
 bin/lib/create.js                          | 15 +++--
 bin/templates/project/cordova/build        |  4 +-
 bin/templates/project/cordova/clean        |  3 +-
 bin/templates/project/cordova/lib/build.js | 90 ++++++++++++-------------
 bin/templates/project/cordova/lib/clean.js | 12 ++--
 5 files changed, 61 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/52a52556/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index b3f720c..213402d 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -36,13 +36,13 @@ exports.createProject = function(project_path,package_name,project_name){
     project_name = typeof project_name !== 'undefined' ? project_name : 'CordovaExample';
 
     // Check if project already exists
-    if(fs.existsSync(project_path)) {
+    if (fs.existsSync(project_path)) {
         console.error('Project already exists! Delete and recreate');
         process.exit(2);
     }
     
     // Check that requirements are met and proper targets are installed
-    if(!check_reqs.run()) {
+    if (!check_reqs.run()) {
         console.error('Please make sure you meeet the software requirements in order to build
an firefoxos cordova project');
         process.exit(2);
     }
@@ -52,21 +52,24 @@ exports.createProject = function(project_path,package_name,project_name){
     console.log('Package Name '+ package_name);
     console.log('Project Name '+ project_name);
 
-    //copy template folder
+    //copy template directory
     shjs.cp('-r', path.join(ROOT, 'bin', 'templates', 'project', 'www'), project_path);
 
-    //copy check_reqs file ,creat bin/lib if it does not exist yet
-    if(!fs.existsSync(path.join(project_path,'cordova', 'lib'))) {
+    //create cordova/lib if it does not exist yet
+    if (!fs.existsSync(path.join(project_path,'cordova', 'lib'))) {
         shjs.mkdir('-p', path.join(project_path,'cordova', 'lib'));
     }
 
+    //copy required node_modules
     shjs.cp('-r', path.join(ROOT, 'node_modules'), path.join(project_path,'cordova'));
+
+    //copy check_reqs file
     shjs.cp( path.join(ROOT, 'bin', 'lib', 'check_reqs.js'), path.join(project_path,'cordova',
'lib'));
     
     //copy cordova js file
     shjs.cp('-r', path.join(ROOT, 'cordova-lib', 'cordova.js'), path.join(project_path,'www'));
 
-    //copy cordova folder
+    //copy cordova directory
     shjs.cp('-r', path.join(ROOT, 'bin', 'templates', 'project', 'cordova'), project_path);

     [
         'run',

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/52a52556/bin/templates/project/cordova/build
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/build b/bin/templates/project/cordova/build
index fa7408c..51f43c5 100755
--- a/bin/templates/project/cordova/build
+++ b/bin/templates/project/cordova/build
@@ -26,14 +26,14 @@ var path = require('path'),
     args  = process.argv;
 
 // provide help
-if( args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
+if ( args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
                     args[2] == 'help' || args[2] == '-help' || args[2] == '/help') {
     build.help();
     process.exit(0);
 }
 
 // check for the correct argument count, the correct options
-if(   (args.length > 3)
+if (  (args.length > 3)
    || (args[2] && (   (args[2] != '--debug') 
                    && (args[2] != '--release')))) {
       console.error('please only use --debug or --release as argument');

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/52a52556/bin/templates/project/cordova/clean
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/clean b/bin/templates/project/cordova/clean
index bb161fe..da21bc7 100644
--- a/bin/templates/project/cordova/clean
+++ b/bin/templates/project/cordova/clean
@@ -26,7 +26,7 @@ var path = require('path'),
     args  = process.argv;
 
 // Support basic help commands
-if(args.length > 2
+if ( args.length > 2
    || args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
                     args[2] == 'help' || args[2] == '-help' || args[2] == '/help') {
     console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'clean')) );
@@ -35,4 +35,3 @@ if(args.length > 2
     clean.cleanProject();
 }
 
-

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/52a52556/bin/templates/project/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/build.js b/bin/templates/project/cordova/lib/build.js
index 2df4ba6..08bdfa6 100644
--- a/bin/templates/project/cordova/lib/build.js
+++ b/bin/templates/project/cordova/lib/build.js
@@ -25,15 +25,18 @@ var path = require('path'),
     shjs = require('shelljs'),
     zip = require('adm-zip'),
     check_reqs = require('./check_reqs'),
-    buildDirInMerge ='build--release';
+    buildReleaseDirInMerge  = 'build--release',
+    platformWwwDir          = path.join('platforms', 'firefoxos', 'www'),
+    platformBuildDir        = path.join('platforms', 'firefoxos', 'build'),
+    buildReleaseDirInWwwDir = path.join(platformWwwDir, buildReleaseDirInMerge)
+;
 
 function hasMergesCustomReleaseArtifactsDir() {
-    return fs.existsSync('merges/firefoxos/'+buildDirInMerge);
+    return fs.existsSync(path.join('merges', 'firefoxos', buildReleaseDirInMerge));
 }
 
-
 function hasCustomReleaseArtifactsDir() {
-    return fs.existsSync('platforms/firefoxos/www/'+buildDirInMerge);
+    return fs.existsSync(path.join(platformWwwDir,buildReleaseDirInMerge));
 }
 
 /**
@@ -41,71 +44,64 @@ function hasCustomReleaseArtifactsDir() {
  * checks that merges/firefoxos/build--release is avialable and properly filled.
  *
  */
-function hasAllMergesRequiredCustomReleaseArtifacts() {
-    if(!fs.existsSync('merges/firefoxos/'+buildDirInMerge+'/manifest.webapp')) { 
-        console.error('\nPlease provide <project>/merges/firefoxos/'+buildDirInMerge+'/package.manifest');
+function hasAllRequiredCustomReleaseArtifacts() {
+    var mergeDir = path.join('merges', 'firefoxos', buildReleaseDirInMerge);
+    if (!fs.existsSync( path.join(mergeDir, 'manifest.webapp'))) { 
+        console.error('\nPlease provide <project> '+mergeDir+'/manifest.webapp');
     }
 
-    if(!fs.existsSync('merges/firefoxos/'+buildDirInMerge+'/index.html')) {
-        console.error('\nPlease provide <project>/merges/firefoxos/'+buildDirInMerge+'/index.html');
+    if (!fs.existsSync( path.join(mergeDir, 'index.html'))) {
+        console.error('\nPlease provide <project> '+mergeDir+'/index.html');
     }
 
-    return (   fs.existsSync('merges/firefoxos/'+buildDirInMerge+'/package.manifest')
-            && fs.existsSync('merges/firefoxos/'+buildDirInMerge+'/index.html') );
+    return (   fs.existsSync( path.join(mergeDir, 'manifest.webapp'))
+            && fs.existsSync( path.join(mergeDir, 'index.html')) );
 }
 
 /**
- * hasAllRequiredCustomReleaseArtifacts()
+ * hasCopiedRequiredCustomReleaseArtifacts()
  * checks that 'cordova prepare' has copied merges/firefoxos to platforms/firefoxos/www
  *
  */
-function hasAllRequiredCustomReleaseArtifacts() {
-    if(!fs.existsSync('platforms/firefoxos/www/'+buildDirInMerge+'/manifest.webapp')) { 
-        console.error('\nPlease provide <project>/merges/firefoxos/'+buildDirInMerge+'/package.manifest');
+function hasCopiedAllRequiredCustomReleaseArtifacts() {
+    if (!fs.existsSync( path.join(buildReleaseDirInWwwDir, 'manifest.webapp'))) { 
+        console.error('\n'+path.join(buildReleaseDirInWwwDir, 'manifest.webapp')+' is not
found');
     }
 
-    if(!fs.existsSync('platforms/firefoxos/www/'+buildDirInMerge+'/index.html')) {
-        console.error('\nPlease provide <project>/merges/firefoxos/'+buildDirInMerge+'/index.html');
+    if (!fs.existsSync( path.join(buildReleaseDirInWwwDir, 'index.html'))) {
+        console.error('\n'+path.join(buildReleaseDirInWwwDir, 'index.html')+' is not found');
     }
 
-    return (   fs.existsSync('platforms/firefoxos/www/'+buildDirInMerge+'/package.manifest')
-            && fs.existsSync('platforms/firefoxos/www/'+buildDirInMerge+'/index.html')
);
+    return (   fs.existsSync( path.join(buildReleaseDirInWwwDir, 'manifest.webapp'))
+            && fs.existsSync( path.join(buildReleaseDirInWwwDir, 'index.html')) );
 }
 
-
 function moveWwwBuildReleaseToBuild() {
     hasAllRequiredCustomReleaseArtifacts();
-    console.log('Move index.html and manifest.webapp provided at \'merges/firefoxos/'+buildDirInMerge+'/\'
to platforms/firefoxos/build');
-    shjs.mv('-f', 'platforms/firefoxos/www/'+buildDirInMerge+'/index.html', 'platforms/firefoxos/build/index.html');
-    shjs.mv('-f' ,'platforms/firefoxos/www/'+buildDirInMerge+'/package.manifest', 'platforms/firefoxos/build/package.manifest');
+    
+    shjs.mv('-f', path.join(buildReleaseDirInWwwDir, 'index.html'),       path.join(platformBuildDir,
'index.html'));
+    shjs.mv('-f' ,path.join(buildReleaseDirInWwwDir, 'manifest.webapp'),  path.join(platformBuildDir,
'manifest.webapp'));
 }
 
-
-
-
 // cordova merges merge/firefoxos to platforms/firefoxos/www
 // this removes the 'build--release' directory from platforms/firefoxos/www
 function removeWwwBuildRelease() {
-    console.log('Remove '+buildDirInMerge+' from \'platforms/firefoxos/www\'');
-    if(fs.existsSync('platforms/firefoxos/www/'+buildDirInMerge)) {
-        shjs.rm('-r', 'platforms/firefoxos/www/'+buildDirInMerge);
+    if (fs.existsSync(buildReleaseDirInWwwDir)) {
+        shjs.rm('-r', buildReleaseDirInWwwDir);
     }
 }
 
-
 /**
  * buildProject
- *   --debug (default):
- *      
+ *   --debug (default):      
  *
  *   --release
  *
- *
  */
 exports.buildProject = function(buildTarget){
 
     // Check that requirements are (stil) met
-    if(!check_reqs.run()) {
+    if (!check_reqs.run()) {
         console.error('Please make sure you meet the software requirements in order to build
a firefoxos cordova project');
         process.exit(2);
     }
@@ -113,39 +109,39 @@ exports.buildProject = function(buildTarget){
     clean.cleanProject(); // remove old build result
     
     // if 'debug' (default), remove files we only need for 'release'
-    if(buildTarget == 'debug') {
+    if (buildTarget == 'debug') {
         if(hasCustomReleaseArtifactsDir()){ 
             removeWwwBuildRelease();
         }
         process.exit(0);
     }
 
-    if(buildTarget == 'release') {
-        console.log('Building Firefoxos project');
+    if (buildTarget == 'release') {
+        console.log('Building Firefoxos project in '+platformBuildDir);
 
-        if(!hasAllMergesRequiredCustomReleaseArtifacts()) {
+        if (!hasAllRequiredCustomReleaseArtifacts()) {
                console.error('\nCheck \'https://developer.mozilla.org/en-US/Marketplace/Publishing/Packaged_apps\'
for the required artifacts');
                console.error('\n');
                process.exit(2);
         }
 
-        if(!hasAllRequiredCustomReleaseArtifacts()) {
+        if (!hasCopiedAllRequiredCustomReleaseArtifacts()) {
                console.error('\nIf merges/firefoxos/build-release has proper content, make
sure \'cordova prepare firefoxos\' is run.');
                console.error('\n');
                process.exit(2);
         }
 
-        if(!fs.existsSync('platforms/firefoxos/build')) {
-            fs.mkdir('platforms/firefoxos/build'); 
+        if (!fs.existsSync(platformBuildDir)) {
+            fs.mkdir(platformBuildDir); 
         }
 
         moveWwwBuildReleaseToBuild();
         removeWwwBuildRelease(); 
 
-        // add the project in a zipfile
+        // add the project to a zipfile
         var zipFile = zip();
-        zipFile.addLocalFolder('platforms/firefoxos/www', '.');
-        zipFile.writeZip("platforms/firefoxos/build/package.zip");
+        zipFile.addLocalFolder(platformWwwDir, '.');
+        zipFile.writeZip(path.join(platformBuildDir, 'package.zip'));
 
         process.exit(0);
     }
@@ -153,15 +149,13 @@ exports.buildProject = function(buildTarget){
     // should never get here
     console.error('Illegal target to build a firefoxos cordova project ('+buildTarget+')');
     process.exit(2);
-
 }
 
 module.exports.help = function() {
     console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'build')) +
' [build_type]');
     console.log('Build Types : ');
     console.log('    \'--debug\': Default build.');
-    console.log('    \'--release\': will build a zip-file of the project in \'platforms/firefoxos/build\'.');
-    console.log('                  Please provide manifest.webapp and index.html in merges/firefoxos/'+buildDirInMerge);
+    console.log('    \'--release\': will build a zip-file of the project in \''+platformBuildDir+'\'.');
+    console.log('                  Please provide manifest.webapp and index.html in '+path.join('merges',
'firefoxos', buildReleaseDirInMerge));
 }
 
-

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/52a52556/bin/templates/project/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/clean.js b/bin/templates/project/cordova/lib/clean.js
index 52bf0f3..2024527 100644
--- a/bin/templates/project/cordova/lib/clean.js
+++ b/bin/templates/project/cordova/lib/clean.js
@@ -21,24 +21,26 @@
  
 var fs = require('fs'),
     shjs = require('shelljs'),
-    check_reqs = require('./check_reqs');
+    check_reqs = require('./check_reqs'),
+    platformBuildDir = path.join('platforms', 'firefoxos', 'build'),
+;
 
 exports.cleanProject = function(){
 
     // Check that requirements are (stil) met
-    if(!check_reqs.run()) {
+    if (!check_reqs.run()) {
         console.error('Please make sure you meet the software requirements in order to clean
an firefoxos cordova project');
         process.exit(2);
     }
     
     console.log('Cleaning Firefoxos project');
     try {
-        if(fs.existsSync('platforms/firefoxos/build')) {
-            shjs.rm('-r', 'platforms/firefoxos/build');
+        if (fs.existsSync(platformBuildDir)) {
+            shjs.rm('-r', 'platformBuildDir);
         }
     }
     catch(err) {
-        console.log('could not remove platforms/firefoxos/build : '+err.message);
+        console.log('could not remove '+platformBuildDir+' : '+err.message);
     }
 
 


Mime
View raw message