[ 
https://issues.apache.org/jira/browse/CB-6437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13968920#comment-13968920
 ] 

ASF GitHub Bot commented on CB-6437:
------------------------------------

Github user martincgg commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11610878
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,215 @@
         KIND, either express or implied.  See the License for the
         specific language governing permissions and limitations
         under the License.
    -*/
    +     */
     
     var fs = require('fs'),
         path = require('path'),
    -    shelljs,
    -    optimist;
    +    child_process = require('child_process'),
    +    shelljs;
    +
    +// Dependencies requirements check
     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));
    +        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;
    +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('To update all repositories:');
    +console.log('  ./cordova-coho/coho repo-update');
    +
    +// Setting up vars, folders and libraries, to ensure full compatibility 
cross platform, absolute paths are used instead of relative paths
    +var mainModDir = process.cwd(),
    +// Cordova Coho dir, it should contain all libraries and required 
repositories
    +// [cordova-cli, cordova-android, cordova-blackberry, cordova-ios, 
cordova-windows, cordova-windows8, all plugins libraries, cordova-mobile-spec, 
cordova-js]
    +// searchDir function it was added, to look for cordova-coho folder 
backwards, for cases like absolute/path/cordova-coho/cordova-coho/...All 
libraries
    +// This is to make sure that cordova-coho exists and it's the right one.
    +coho_dir = searchDir(mainModDir, 'cordova-coho'),
    +cordova_cli = path.join(coho_dir, 'cordova-cli', 'bin', 'cordova'),
    +cordova_ms = (path.join(coho_dir, 'cordova-mobile-spec')),
    +cordova_js = (path.join(coho_dir, 'cordova-js')),
    +ms_project_dir = (path.join(mainModDir, 'mobilespec'));
    +
    +// Main libraries and path's requirements check
    +if (!fs.existsSync(coho_dir)) {
    +    console.log('Please run this script from the directory that contains 
cordova-coho');
    +    shelljs.exit(1);
     }
    -var platforms = [];
    -if (argv.android) { platforms.push('android'); }
    -if (argv.ios) { platforms.push('ios'); }
     
    -if (!fs.existsSync('cordova-mobile-spec')) {
    +if (!fs.existsSync(cordova_ms)) {
         console.log('Please run this script from the directory that contains 
cordova-mobile-spec');
         shelljs.exit(1);
     }
     
    -if (fs.existsSync('mobilespec')) {
    -    console.log('Directory "mobilespec" already exists. Delete it first 
then re-run.');
    +if (!fs.existsSync(cordova_js)) {
    +    console.log('Please run this script from the directory that contains 
cordova-js');
         shelljs.exit(1);
     }
     
    -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 
cli -r " + platforms.join(' -r '));
    -console.log('To update all repositories:');
    -console.log('  ./cordova-coho/coho repo-update');
    +//Determine which platforms are available
    +// Default platforms [Android, Blackberry], both platforms works under 
Windows, Linux and Mac OS
    +cordovaPlatforms = ['android', 'blackberry10'];
    --- End diff --
    
    Yes, agree. I didn't see the optimist module when started to work in this, 
it seems a really good idea, at first it was add android and iOS, both 
platforms, that's why I'd choose to add all possible platforms.
    
    We have options to pick, we can add the arguments like the platforms, 
android, iOS, blackberry, wp8 and so. But this allows to the user add platforms 
that are not allowed to use in their environment, let's say:
    
    Mac Os dev env for Android, iOS
    If the user types: createmobilespec android ios wp8 windows8
    the last two of them will cause problems under that dev env.
    the same thing if it were for windows 7 or XP, it's not possible add a 
platform like iOS, it would create an exception during installation that stops 
the execution.
    
    So, it would better try to prevent this errors.
    We can add logic for when user try to use a platform that is not allowed to 
warn him and stop the process immediately without create the project and 
nothing, I mean not waiting until the exception or error is caught.
    Or
    We can make it interactively, add a menu when the time to add platforms, 
after the project creation, allowing to add just the supported platform for the 
current environment.
    Menus like the following ones:
    
    Mac OS:
    Select platform:
    A) Android
    B) Blackberry
    I) iOS
    
    Windows 8:
    Select platform:
    A) Android
    B) Blackberry
    WP) Windows Phone 8
    W) Windows 8
    
    Windows 7, XP, Linux:
    Select platform:
    A) Android
    B) Blackberry



> [Mobilespec] improve and add support for blackberry, wp8, windows8
> ------------------------------------------------------------------
>
>                 Key: CB-6437
>                 URL: https://issues.apache.org/jira/browse/CB-6437
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: BlackBerry, mobile-spec, Windows 8, WP8
>    Affects Versions: 3.4.0
>            Reporter: Martin Gonzalez
>            Assignee: Martin Gonzalez
>              Labels: blackberry10, mobilespec,, module, node, support, 
> windows8, wp8
>             Fix For: 3.5.0
>
>
> The new node module for Mobilespecs can be improved.
> -Adding more functionality
> -Supporting platforms as blackberry10, windows phone 8 and windows 8.
> -Add functionality to automate some process as well.
> -Add functionality to add platforms according to the development environment 
> --- Android, Blackberry, iOS ---> Mac.
> --- Android, Blackberry, Windows 8, Windows Phone 8 ---> Windows 8.
> --- Android, Blackberry ---> Linux or any other Windows OS.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to