cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject spec commit: CB-6372 Enable variable platforms
Date Sat, 29 Mar 2014 02:15:27 GMT
Repository: cordova-mobile-spec
Updated Branches:
  refs/heads/master b580fd9d0 -> d434ff29b


CB-6372 Enable variable platforms

Added command-line parms so you can choose which platforms to use. This is
groundwork for adding additional platforms.


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

Branch: refs/heads/master
Commit: d434ff29b60e7f055df19f9414cbe59a0a535313
Parents: b580fd9
Author: Marcel Kinard <cmarcelk@gmail.com>
Authored: Fri Mar 28 21:52:13 2014 -0400
Committer: Marcel Kinard <cmarcelk@gmail.com>
Committed: Fri Mar 28 21:52:13 2014 -0400

----------------------------------------------------------------------
 createmobilespec/createmobilespec.js | 40 ++++++++++++++++++++++++-------
 createmobilespec/package.json        |  4 +++-
 2 files changed, 35 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/d434ff29/createmobilespec/createmobilespec.js
----------------------------------------------------------------------
diff --git a/createmobilespec/createmobilespec.js b/createmobilespec/createmobilespec.js
index 6aaaf7e..c1dc59d 100755
--- a/createmobilespec/createmobilespec.js
+++ b/createmobilespec/createmobilespec.js
@@ -21,15 +21,32 @@
 
 var fs = require('fs'),
     path = require('path'),
-    shelljs;
+    shelljs,
+    optimist;
 try {
     shelljs = require('shelljs');
+    optimist = require('optimist');
 } catch (e) {
     console.error('Missing module. Please run "npm install" from this directory:\n\t' +
                    path.dirname(__dirname));
     process.exit(2);
 }
 
+var tokens = process.argv.slice(2);
+var argv = optimist(tokens)
+           .default('android', false)
+           .default('ios', false)
+           .usage('Usage: $0 [--android] [--ios]\nDefault is to use Android and iOS.')
+           .argv;
+// preserve the original behavior when there are no args
+if (tokens.length === 0) {
+    argv.android = true;
+    argv.ios = true;
+}
+var platforms = [];
+if (argv.android) { platforms.push('android'); }
+if (argv.ios) { platforms.push('ios'); }
+
 if (!fs.existsSync('cordova-mobile-spec')) {
     console.log('Please run this script from the directory that contains cordova-mobile-spec');
     shelljs.exit(1);
@@ -42,7 +59,7 @@ if (fs.existsSync('mobilespec')) {
 
 console.log('Creating mobilespec project. If you have any errors, it may be from missing
repositories.');
 console.log('To clone needed repositories:');
-console.log('  ./cordova-coho/coho repo-clone -r plugins -r mobile-spec -r android -r ios
-r cli');
+console.log("  ./cordova-coho/coho repo-clone -r plugins -r mobile-spec -r cli -r " + platforms.join('
-r '));
 console.log('To update all repositories:');
 console.log('  ./cordova-coho/coho repo-update');
 
@@ -71,17 +88,24 @@ var localPlatforms = {
 JSON.stringify(localPlatforms).to('.cordova/config.json');
 
 console.log('Adding platforms...');
-shelljs.exec('../cordova-cli/bin/cordova platform add ios android');
+shelljs.exec('../cordova-cli/bin/cordova platform add ' + platforms.join(' '));
+
 console.log('Adding plugins...');
 shelljs.exec('../cordova-cli/bin/cordova plugin add ../cordova-mobile-spec/dependencies-plugin
--searchpath ' + repoParent);
-console.log('Updating iOS subproject...');
-shelljs.rm('-rf', 'platforms/ios/CordovaLib');
-shelljs.exec('../cordova-ios/bin/update_cordova_subproject platforms/ios/mobilespec.xcodeproj');
+
+if (argv.ios) {
+    console.log('Updating iOS subproject...');
+    shelljs.rm('-rf', 'platforms/ios/CordovaLib');
+    shelljs.exec('../cordova-ios/bin/update_cordova_subproject platforms/ios/mobilespec.xcodeproj');
+}
+
 console.log('Updating js...');
-shelljs.cp('-f', '../cordova-js/pkg/cordova.android.js', 'platforms/android/platform_www/cordova.js');
-shelljs.cp('-f', '../cordova-js/pkg/cordova.ios.js', 'platforms/ios/platform_www/cordova.js');
+if (argv.android) { shelljs.cp('-f', '../cordova-js/pkg/cordova.android.js', 'platforms/android/platform_www/cordova.js');
}
+if (argv.ios) { shelljs.cp('-f', '../cordova-js/pkg/cordova.ios.js', 'platforms/ios/platform_www/cordova.js');
}
+
 console.log('Preparing...');
 shelljs.exec('../cordova-cli/bin/cordova prepare');
+
 console.log('Linking CLI...');
 fs.symlinkSync('../cordova-cli/bin/cordova', 'cordova');
 shelljs.popd();

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/d434ff29/createmobilespec/package.json
----------------------------------------------------------------------
diff --git a/createmobilespec/package.json b/createmobilespec/package.json
index d410df6..e53e817 100644
--- a/createmobilespec/package.json
+++ b/createmobilespec/package.json
@@ -7,6 +7,8 @@
   "repository": {
      "type": "git",
      "url": "https://git-wip-us.apache.org/repos/asf/cordova-mobile-spec.git"},
-  "dependencies": { "shelljs": "0.2.6" },
+  "dependencies": {
+     "shelljs": "0.2.6",
+     "optimist": "0.6.1" },
   "private": true
 }


Mime
View raw message