You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by martincgg <gi...@git.apache.org> on 2014/04/14 21:48:40 UTC

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

GitHub user martincgg opened a pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55

    CB-6437[Improvements & support for more platforms]

    -Added full compatibility cross platform
    -Works with absolute paths
    -Added support for Blackberry10, Windows 8 and Windows Phone 8
    -Added 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.
    
    - Added more requirements checks
    - Added functionality to delete project folder if exists (recursive
    function)
    - Added functionality to locate libraries
    - Added function to copy with exclusion list
    - Added createmobilespec.bat & createmobilespec.sh
    - Added symlink for windows & Linux based OS.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/martincgg/cordova-mobile-spec CB-6437

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-mobile-spec/pull/55.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #55
    
----
commit 7a5475e9a70c2e13d742ca46dbd529fd8ff1968f
Author: Martin Gonzalez <ma...@gmail.com>
Date:   2014-04-14T19:46:17Z

    CB-6437[Improvements & support for more platforms]
    
    -Added full compatibility cross platform
    -Working with absolute paths
    -Added support for Blackberry10, Windows 8 and Windows Phone 8
    -Added 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.
    - Added more requirements checks
    - Added functionality to delete project folder if exists (recursive
    function)
    - Added functionality to locate libraries
    - Added function to copy with exclusion list
    - Added createmobilespec.bat & createmobilespec.sh
    - Added symlink for windows & Linux based OS.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#issuecomment-41211898
  
    I tried to merge this, but it didn't merge cleanly. Conflicts in 3 files. Could you rebase your branch on master so it will merge cleanly?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#issuecomment-40413680
  
    Changed tabs for spaces


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11607031
  
    --- Diff: createmobilespec/createmobilespec.sh ---
    @@ -0,0 +1,3 @@
    +#!/bin/bash 
    --- End diff --
    
    All files should include the Apache header.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11855414
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,197 @@
         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'),
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +
    +// 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.
    +var mainModDir     = process.cwd(),
    +    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(coho_dir, "mobilespec"),
    +    platforms      = [],
    +//Setting up optimist features
    +    tokens         = process.argv.slice(2),
    +    argv           = optimist(tokens)
    +                     .usage("Usage: $0 [--platform].")
    +                     .argv;
    +
    +// 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')) {
    -    console.log('Please run this script from the directory that contains 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');
    +// No arguments throws error
    +if (tokens.length === 0) {
    +    throw new Error('No arguments found');
    +}
    +if (argv.help) {console.log("Usage: createmobilespec --platformName"); return;}
    +if (argv.android) { platforms.push("android");}
    +if (argv.ios) { platforms.push("ios");}
    +if (argv.blackberry10) { platforms.push("blackberry10");}
    +if (argv.wp8) { platforms.push("wp8");}
    +if (argv.windows8) { platforms.push("windows8");}
    +
    +if (platforms.length === 0){
    +    throw new Error ('No supported platforms');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    +// Custom function to delete project folder, using recursive actions
    +try {
    +    delFileSync(ms_project_dir);
    +} catch (e) {
    +    //The project directory after an android build and emulation is locked by ADB.exe (Android Debug Bridge).
    +    //Kill the process & restart folder deletion
    +        console.log("Not all files were deleted, killing Adb.exe process to unlock project folder ...");
    +        if (/^win/.test(process.platform)) {
    +        shelljs.exec("TASKKILL /F /IM ADB.exe /T");
    +        delFileSync(ms_project_dir);
    +        }else
    +            throw new Error("Error during folder deletion, try to remove mobilespec project folder manually");
    +    }
     
    -shelljs.pushd('cordova-js');
    -shelljs.exec('grunt');
    -shelljs.popd();
    +// Creating the project, linked to cordova-mobile-spec library
    +shelljs.pushd(coho_dir);
    +shelljs.exec(cordova_cli + " create mobilespec org.apache.cordova.mobilespec MobileSpec_Tests --link-to cordova-mobile-spec");
     
    -shelljs.pushd('mobilespec');
    +// Executing grunt task, to generate updated js files for each platform
    +shelljs.pushd(cordova_js);
    +shelljs.exec("grunt");
    +
    +shelljs.pushd(ms_project_dir);
    --- End diff --
    
    mobilespec project is created at cordova-coho/mobilespec.
    In order to use --link-to(only works with local paths), instead of copy.
    Nothing is created inside createmobilespec


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11640926
  
    --- 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 --
    
    When optimist was being used and the default behavior was to create both Android and iOS, that was just preserving the original behavior of the shell script when this ran only on OSX. Now that you are getting createmobilespec to work on Windows and Linux dev machines, it's probably wise to revisit that default behavior. I'd suggest that the new default is to create only the mobile platforms that are requested. For example "createmobilespec --android --blackberry10". If no args are specified, then exit with an error. These should be the same words used in the "cordova platform add" command, for consistency. And I would also suggest to have them be args instead of a menu, so that createmobilespec can be used by a parent script in a scenario such as Medic (continuous integration test). Interactive input would make that use case difficult.
    
    I see your point about checking which mobile platforms are appropriate for the dev workstation, but if the "cordova platform add" command is doing that checking already (which is what createmobilespec is calling anyway), then I would suggest to not bother implementing that check again here in createmobilespec, and just let the error bubble up from "cordova platform add". createmobilespec is going to be used only by people developing Cordova, so they should already have some knowledge of the basic rules, as compared to an app developer. So I think it is OK to let "cordova platform add" catch the issue instead of duplicating the "check" logic here, as long as the error does bubble up in a presentation that is comprehensible.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11816596
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,197 @@
         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'),
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +
    +// 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.
    +var mainModDir     = process.cwd(),
    +    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(coho_dir, "mobilespec"),
    +    platforms      = [],
    +//Setting up optimist features
    +    tokens         = process.argv.slice(2),
    +    argv           = optimist(tokens)
    +                     .usage("Usage: $0 [--platform].")
    --- End diff --
    
    Could you spell out what specific arguments are possible here instead of just a generic? Including "--help"?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11817216
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,197 @@
         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'),
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +
    +// 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.
    +var mainModDir     = process.cwd(),
    +    coho_dir       = searchDir(mainModDir, "cordova-coho"),
    --- End diff --
    
    I don't understand why you need to search for the cordova-coho directory. Since the script needs to be invoked from the parent of cordova-coho, it should be a simple direct placement.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#issuecomment-41587797
  
    Merge conflict resolved


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#issuecomment-41051785
  
    Several changes delivered: 
    
    -Deleted top level functions.
    -Used optimist methods to print help.
    -Changes on paths.
    -Other minor changes.
    
    Clarification about:
    https://github.com/martincgg/cordova-mobile-spec/blob/fc67802256b5af079b562f88a639fc5354f94857/createmobilespec/createmobilespec.js#L161
    
    That's an anonymous function, declaration and invocation, the reason of that function is that inside pkg, there's all js files for each platform, some of those files are a match with their platform invocation name, but windows phone is not a match, given the fact that cordova.windowsphone.js works for wp7 & wp8.
    The function is just going to verify if the platform name is wp8, and use windowsphone string to get the right file.
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11877931
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,163 @@
         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'),
    +     */
    +     
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +// 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.
    +shelljs.pushd("../../../cordova-coho")
    +var coho_dir       = process.cwd()+path.sep,
    +    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(coho_dir, "mobilespec"),
    +    platforms      = [],
    +    //Setting up optimist features
    +    tokens         = process.argv.slice(2),
    +    argv = optimist.usage('\n\nCreatemobilespec usage: \n$0 [--android] [--ios]')
    +                    .alias('h', 'help')
    +                    .argv;
    +
    +// 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')) {
    -    console.log('Please run this script from the directory that contains 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');
    +// No arguments throws error
    +if (tokens.length === 0) {
    +    throw new Error('No arguments found');
    +}
    +
    +if (argv.help) {optimist.showHelp(); return;}
    +if (argv.android) { platforms.push("android");}
    +if (argv.ios) { platforms.push("ios");}
    +if (argv.blackberry10) { platforms.push("blackberry10");}
    +if (argv.wp8) { platforms.push("wp8");}
    +if (argv.windows8) { platforms.push("windows8");}
    +
    +if (platforms.length === 0){
    +    throw new Error ('No supported platforms');
    --- End diff --
    
    Understood, It's a better message, I'll change it, and I'll show the help information.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11643490
  
    --- 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'];
    +if (/^win/.test(process.platform)) {
    +    //Determine windows 8 platform
    +    child_process.exec('wmic os get caption', function (error, stdout, stderr) {
    +        if (error !== null) {
    +            callback = 'Error performing command: ' + error + "\n" + stderr;
    +        } else {
    +            // If Windows 8, add Windows Phone 8 and Windows8 platform to the array
    +            if ((/.*(Windows 8).*/gi).test(((stdout.replace(/\r\r\n/i, ': ')).replace(/\s\s+/g, '')).replace((/\n|\r/gi), ''))) {
    +                cordovaPlatforms.push('wp8', 'windows8');
    +            }
    +        }
    +    });
    +} else {
    +    //If Mac Os, add iOS platform
    +    if (/^darwin/.test(process.platform))
    +        cordovaPlatforms.push('ios');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    --- End diff --
    
    Agree, I've took some troubles to deal with that structure, let me check the behavior under Windows & Linux with --link-to statement. I'll move the project creation to cordova-coho at the same level of cordova-mobile-spec.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11823910
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,197 @@
         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'),
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +
    +// 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.
    +var mainModDir     = process.cwd(),
    +    coho_dir       = searchDir(mainModDir, "cordova-coho"),
    --- End diff --
    
    I just wanted to make sure that we were in the right directory, avoid fail if a error is found, something like a wrong directory or so. Make the module work no matter where's located inside the mobile spec library or any other library.
    No worries, I got rid of it. It will always look for the coho directory with 3 jumps back.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11874991
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,163 @@
         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'),
    +     */
    +     
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +// 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.
    +shelljs.pushd("../../../cordova-coho")
    +var coho_dir       = process.cwd()+path.sep,
    +    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(coho_dir, "mobilespec"),
    +    platforms      = [],
    +    //Setting up optimist features
    +    tokens         = process.argv.slice(2),
    +    argv = optimist.usage('\n\nCreatemobilespec usage: \n$0 [--android] [--ios]')
    +                    .alias('h', 'help')
    +                    .argv;
    +
    +// 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')) {
    -    console.log('Please run this script from the directory that contains 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');
    +// No arguments throws error
    +if (tokens.length === 0) {
    +    throw new Error('No arguments found');
    +}
    +
    +if (argv.help) {optimist.showHelp(); return;}
    +if (argv.android) { platforms.push("android");}
    +if (argv.ios) { platforms.push("ios");}
    +if (argv.blackberry10) { platforms.push("blackberry10");}
    +if (argv.wp8) { platforms.push("wp8");}
    +if (argv.windows8) { platforms.push("windows8");}
    +
    +if (platforms.length === 0){
    +    throw new Error ('No supported platforms');
    --- End diff --
    
    This verbage is a bit vague if it is Cordova's fault or the user's fault. How about something like "No platforms were selected. Please choose at least one of the supported platforms." and invoke optimist.showHelp(). Is there anyone to catch this throw?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#issuecomment-40864472
  
    New commit, with several changes.
    Summary:
    
    Added:
    -Logic to deal with arguments, to accept platforms.
    -Logic when no arguments are present, to fail and throw error.
    -Support for help argument, to show usage.
    
    Supported platforms (args): --android, --ios, --blackberry10, --wp8,
    --windows8.
    
    Removed: top level function for custom copy.
    
    Changed:
    -Path directory for mobilespec, current location at
    cordova-coho/mobilespec.
    -link-to instead of copy for mobilespec project.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11607945
  
    --- 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'];
    +if (/^win/.test(process.platform)) {
    +    //Determine windows 8 platform
    +    child_process.exec('wmic os get caption', function (error, stdout, stderr) {
    +        if (error !== null) {
    +            callback = 'Error performing command: ' + error + "\n" + stderr;
    +        } else {
    +            // If Windows 8, add Windows Phone 8 and Windows8 platform to the array
    +            if ((/.*(Windows 8).*/gi).test(((stdout.replace(/\r\r\n/i, ': ')).replace(/\s\s+/g, '')).replace((/\n|\r/gi), ''))) {
    +                cordovaPlatforms.push('wp8', 'windows8');
    +            }
    +        }
    +    });
    +} else {
    +    //If Mac Os, add iOS platform
    +    if (/^darwin/.test(process.platform))
    +        cordovaPlatforms.push('ios');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    --- End diff --
    
    Totally agree, until I've found out that it throws a Error when are not local paths:
    https://github.com/apache/cordova-cli/blob/master/src/cli.js#L139
    
    Before in createmobilespec.sh it was in the cordova-mobile-spec folder, but now the module is under cordova-mobile-spec/createmobilespec, so now it produces an exception when the local path is not found.
    That's why, the project is created and then copied to the www.
    Another reason is that the module is under the same folder that we are trying to copy-to, so it generates conflicts because is linking itself.
    
    cordova-mobile-spec/createmobilespec/mobilespec <-- this is the project
    Linked to cordova-mobile-spec it wouldn't work just fine.
    
     


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11641446
  
    --- 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'];
    +if (/^win/.test(process.platform)) {
    +    //Determine windows 8 platform
    +    child_process.exec('wmic os get caption', function (error, stdout, stderr) {
    +        if (error !== null) {
    +            callback = 'Error performing command: ' + error + "\n" + stderr;
    +        } else {
    +            // If Windows 8, add Windows Phone 8 and Windows8 platform to the array
    +            if ((/.*(Windows 8).*/gi).test(((stdout.replace(/\r\r\n/i, ': ')).replace(/\s\s+/g, '')).replace((/\n|\r/gi), ''))) {
    +                cordovaPlatforms.push('wp8', 'windows8');
    +            }
    +        }
    +    });
    +} else {
    +    //If Mac Os, add iOS platform
    +    if (/^darwin/.test(process.platform))
    +        cordovaPlatforms.push('ios');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    --- End diff --
    
    I'm a Linux geek that's not real familiar with Windows. My interpretation of that cli function is that it wants the symlink destination to be on the same drive as the symlink source. If my understanding is correct, is it just a matter of leaving the drive letter off if it is on the same drive?
    
    If the project is getting created in the cordova-mobile-spec tree, that doesn't feel like the right place, as it kinda pollutes the git repo with runtime artifacts. Yes a .gitignore could address that, but it still feels like the wrong place. Better would be the project directory being a peer of cordova-mobile-spec, or at least outside of that tree.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg closed the pull request at:

    https://github.com/apache/cordova-mobile-spec/pull/55


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11817386
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,197 @@
         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'),
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +
    +// 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.
    +var mainModDir     = process.cwd(),
    +    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(coho_dir, "mobilespec"),
    +    platforms      = [],
    +//Setting up optimist features
    +    tokens         = process.argv.slice(2),
    +    argv           = optimist(tokens)
    +                     .usage("Usage: $0 [--platform].")
    +                     .argv;
    +
    +// 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')) {
    -    console.log('Please run this script from the directory that contains 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');
    +// No arguments throws error
    +if (tokens.length === 0) {
    +    throw new Error('No arguments found');
    +}
    +if (argv.help) {console.log("Usage: createmobilespec --platformName"); return;}
    +if (argv.android) { platforms.push("android");}
    +if (argv.ios) { platforms.push("ios");}
    +if (argv.blackberry10) { platforms.push("blackberry10");}
    +if (argv.wp8) { platforms.push("wp8");}
    +if (argv.windows8) { platforms.push("windows8");}
    +
    +if (platforms.length === 0){
    +    throw new Error ('No supported platforms');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    +// Custom function to delete project folder, using recursive actions
    +try {
    +    delFileSync(ms_project_dir);
    +} catch (e) {
    +    //The project directory after an android build and emulation is locked by ADB.exe (Android Debug Bridge).
    +    //Kill the process & restart folder deletion
    +        console.log("Not all files were deleted, killing Adb.exe process to unlock project folder ...");
    +        if (/^win/.test(process.platform)) {
    +        shelljs.exec("TASKKILL /F /IM ADB.exe /T");
    +        delFileSync(ms_project_dir);
    +        }else
    +            throw new Error("Error during folder deletion, try to remove mobilespec project folder manually");
    +    }
     
    -shelljs.pushd('cordova-js');
    -shelljs.exec('grunt');
    -shelljs.popd();
    +// Creating the project, linked to cordova-mobile-spec library
    +shelljs.pushd(coho_dir);
    +shelljs.exec(cordova_cli + " create mobilespec org.apache.cordova.mobilespec MobileSpec_Tests --link-to cordova-mobile-spec");
     
    -shelljs.pushd('mobilespec');
    +// Executing grunt task, to generate updated js files for each platform
    +shelljs.pushd(cordova_js);
    +shelljs.exec("grunt");
    +
    +shelljs.pushd(ms_project_dir);
    +
    +// Config.json file ---> linked to local libraries
     var localPlatforms = {
    -    "id": "org.apache.mobilespec",
    -    "name": "mobilespec",
    -    "lib": {
    -        "android": {
    -            "uri": repoParent + "/cordova-android"
    +    "id" : "org.apache.cordova",
    +    "name" : "mobilespec",
    +    "lib" : {
    +        "android" : {
    +            "uri" : coho_dir + "cordova-android"
    +        },
    +        "ios" : {
    +            "uri" : coho_dir + "cordova-ios"
             },
    -        "ios": {
    -            "uri": repoParent + "/cordova-ios"
    +        "blackberry10" : {
    +            "uri" : coho_dir + "cordova-blackberry"
    +        },
    +        "wp8" : {
    +            "uri" : coho_dir + "cordova-wp8"
    +        },
    +        "windows8" : {
    +            "uri" : coho_dir + "cordova-windows"
             }
         }
     };
    -JSON.stringify(localPlatforms).to('.cordova/config.json');
    -
    -console.log('Adding platforms...');
    -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);
    -
    -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');
    +JSON.stringify(localPlatforms).to(".cordova/config.json");
    +
    +//Executing platform Add
    +console.log("Adding platforms...");
    +platforms.forEach(function (platform) {
    +    console.log("Adding Platform: " + platform);
    +    shelljs.exec(cordova_cli + " platform add " + platform + " --verbose");
    +});
    +
    +// Installing plugins, using local library and dependencies file.
    +console.log("Adding plugins...");
    +shelljs.exec(cordova_cli +" plugin add " + path.join(cordova_ms, "dependencies-plugin") + " --searchpath " + coho_dir);
    +
    +// Updating Js files for each added platform
    +console.log("Updating js for platforms...");
    +platforms.forEach(function (platform) {
    +    shelljs.cp("-f", path.join(cordova_js, "pkg", "cordova." + (function () {
    +                return platform === "wp8" ? "windowsphone" : platform;
    +            }
    +                ()) + ".js"), path.join(ms_project_dir, "platforms", platform, "platform_www", "cordova.js"));
    +    console.log("Javascript file updated for " + platform);
    +});
    +
    +// Executing cordova prepare
    +console.log("Preparing project...");
    +shelljs.exec(cordova_cli + " prepare");
    +console.log("Linking CLI...");
    +// Writing link files to use Local CLI
    +if (/^win/.test(process.platform)) {
    +    var winBatchFile = "node  " + cordova_cli + " %*";
    +    fs.writeFileSync(path.join(ms_project_dir, "cordova.bat"), winBatchFile);
    +} else {
    +    fs.symlinkSync(cordova_cli, "cordova");
    +}
    +console.log("\"mobilespec\" project created at:\n" + ms_project_dir);
    +console.log("Symlink to CLI created as mobilespec/cordova");
    +
    +// Looks for a directory in the provided path, from end to beginning
    +// path/to/search/pathsamename_as_required/paths/pathrequired/path/path <------ Starts to look from here, the last one
    +function searchDir(fullPath, dir) {
    +    var newPath = "",
    +    arrayDirs = fullPath.split(path.sep);
    +    for (var i = arrayDirs.length; i > 0; i--) {
    +        if (arrayDirs[i] === dir) {
    +            for (var j = 0; j < i; j++) {
    +                newPath += arrayDirs[j] + path.sep;
    +            }
    +            return (newPath + arrayDirs[i] + path.sep);
    +        }
    +    }
    +    return false;
     }
     
    -console.log('Updating 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();
    -
    -console.log('App created in the mobilespec/ directory.');
    -console.log('Symlink to CLI created as mobilespec/cordova');
    -
    +// Recursive function to delete a tree of directories or a single file, until every file in the directory is deleted, and the directory as well.
    +function delFileSync(fileDir_Path) {
    --- End diff --
    
    Why can't shelljs.rm('-r', path) be used here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11643737
  
    --- 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 --
    
    It makes perfect sense, I understand the point, and I'm agree, if a parent script uses createmobilespec, interactions will become in a problem, I'll change the source to use optimist to get args, and of course it would be better if we let to the cordova manage the errors.
    I'll make the changes and commit them soon.
    Thanks for the feedback.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11606571
  
    --- 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'];
    +if (/^win/.test(process.platform)) {
    +    //Determine windows 8 platform
    +    child_process.exec('wmic os get caption', function (error, stdout, stderr) {
    +        if (error !== null) {
    +            callback = 'Error performing command: ' + error + "\n" + stderr;
    +        } else {
    +            // If Windows 8, add Windows Phone 8 and Windows8 platform to the array
    +            if ((/.*(Windows 8).*/gi).test(((stdout.replace(/\r\r\n/i, ': ')).replace(/\s\s+/g, '')).replace((/\n|\r/gi), ''))) {
    +                cordovaPlatforms.push('wp8', 'windows8');
    +            }
    +        }
    +    });
    +} else {
    +    //If Mac Os, add iOS platform
    +    if (/^darwin/.test(process.platform))
    +        cordovaPlatforms.push('ios');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    --- End diff --
    
    Preserving the --link-to will allow changes inside the "cordova-mobile-spec" directory to be immediately reflected into the "mobilespec" project without needing to copy files over. It uses a symlink. This is a helpful behavior that I suggest be preserved.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#issuecomment-41573670
  
    Done, rebased on master, ready to be merged.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11876001
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,163 @@
         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'),
    +     */
    +     
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +// 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.
    +shelljs.pushd("../../../cordova-coho")
    +var coho_dir       = process.cwd()+path.sep,
    +    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(coho_dir, "mobilespec"),
    +    platforms      = [],
    +    //Setting up optimist features
    +    tokens         = process.argv.slice(2),
    +    argv = optimist.usage('\n\nCreatemobilespec usage: \n$0 [--android] [--ios]')
    +                    .alias('h', 'help')
    +                    .argv;
    +
    +// 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')) {
    -    console.log('Please run this script from the directory that contains 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');
    +// No arguments throws error
    +if (tokens.length === 0) {
    +    throw new Error('No arguments found');
    +}
    +
    +if (argv.help) {optimist.showHelp(); return;}
    +if (argv.android) { platforms.push("android");}
    +if (argv.ios) { platforms.push("ios");}
    +if (argv.blackberry10) { platforms.push("blackberry10");}
    +if (argv.wp8) { platforms.push("wp8");}
    +if (argv.windows8) { platforms.push("windows8");}
    +
    +if (platforms.length === 0){
    +    throw new Error ('No supported platforms');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    +// Custom function to delete project folder, using recursive actions
    +try {
    +    shelljs.rm('-r', ms_project_dir);
    +} catch (e) {
    +    //The project directory after an android build and emulation is locked by ADB.exe (Android Debug Bridge).
    +    //Kill the process & restart folder deletion
    +    console.log("Not all files were deleted, killing Adb.exe process to unlock project folder ...");
    +    if (/^win/.test(process.platform)) {
    +        shelljs.exec("TASKKILL /F /IM ADB.exe /T");
    +        shelljs.rm('-r', ms_project_dir);
    +        }else
    +            throw new Error("Error during folder deletion, try to remove mobilespec project folder manually");
    +    }
    +
    +// Creating the project, linked to cordova-mobile-spec library
    +shelljs.pushd(coho_dir);
    +shelljs.exec(cordova_cli + " create mobilespec org.apache.cordova.mobilespec MobileSpec_Tests --link-to cordova-mobile-spec");
    --- End diff --
    
    Yes, it can be created as equal, I just have to verify if --link-to allows the usage of cordova-coho/cordova-mobile-spec folder.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11874862
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,163 @@
         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'),
    +     */
    +     
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +// 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.
    +shelljs.pushd("../../../cordova-coho")
    +var coho_dir       = process.cwd()+path.sep,
    +    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(coho_dir, "mobilespec"),
    +    platforms      = [],
    +    //Setting up optimist features
    +    tokens         = process.argv.slice(2),
    +    argv = optimist.usage('\n\nCreatemobilespec usage: \n$0 [--android] [--ios]')
    --- End diff --
    
    Usage string needs to include all the options (other platforms, plus h/help).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11816716
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,197 @@
         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'),
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +
    +// 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.
    +var mainModDir     = process.cwd(),
    +    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(coho_dir, "mobilespec"),
    +    platforms      = [],
    +//Setting up optimist features
    +    tokens         = process.argv.slice(2),
    +    argv           = optimist(tokens)
    +                     .usage("Usage: $0 [--platform].")
    +                     .argv;
    +
    +// 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')) {
    -    console.log('Please run this script from the directory that contains 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');
    +// No arguments throws error
    +if (tokens.length === 0) {
    +    throw new Error('No arguments found');
    +}
    +if (argv.help) {console.log("Usage: createmobilespec --platformName"); return;}
    +if (argv.android) { platforms.push("android");}
    +if (argv.ios) { platforms.push("ios");}
    +if (argv.blackberry10) { platforms.push("blackberry10");}
    +if (argv.wp8) { platforms.push("wp8");}
    +if (argv.windows8) { platforms.push("windows8");}
    +
    +if (platforms.length === 0){
    +    throw new Error ('No supported platforms');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    +// Custom function to delete project folder, using recursive actions
    +try {
    +    delFileSync(ms_project_dir);
    +} catch (e) {
    +    //The project directory after an android build and emulation is locked by ADB.exe (Android Debug Bridge).
    +    //Kill the process & restart folder deletion
    +        console.log("Not all files were deleted, killing Adb.exe process to unlock project folder ...");
    +        if (/^win/.test(process.platform)) {
    +        shelljs.exec("TASKKILL /F /IM ADB.exe /T");
    --- End diff --
    
    Indentation is missing in this block.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11606359
  
    --- 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 --
    
    I don't think the goal is to build all possible mobile platforms. A frequent developer workflow is to work on only one mobile platform at a time. The last commit reads command-line args to let users self-select which mobile platforms to build. I suggest that behavior be preserved.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11607297
  
    --- 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'];
    +if (/^win/.test(process.platform)) {
    +    //Determine windows 8 platform
    +    child_process.exec('wmic os get caption', function (error, stdout, stderr) {
    +        if (error !== null) {
    +            callback = 'Error performing command: ' + error + "\n" + stderr;
    +        } else {
    +            // If Windows 8, add Windows Phone 8 and Windows8 platform to the array
    +            if ((/.*(Windows 8).*/gi).test(((stdout.replace(/\r\r\n/i, ': ')).replace(/\s\s+/g, '')).replace((/\n|\r/gi), ''))) {
    +                cordovaPlatforms.push('wp8', 'windows8');
    +            }
    +        }
    +    });
    +} else {
    +    //If Mac Os, add iOS platform
    +    if (/^darwin/.test(process.platform))
    +        cordovaPlatforms.push('ios');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    +// Custom function to delete project folder, using recursive actions
    +try {
    +    delFileSync(ms_project_dir);
    +} catch (e) {
    +    //Why this?, well during tests, trying to delete the project directory after make an android build and emulation, the folder is locked by ADB.exe (Android Debug Bridge).
    +    //Cordova allows project creation in an empty folder.
    +    //It just locks the project folder, not the files under, so catching up the exception, allows to continue.
    +    console.log("Not all files were deleted");
    --- End diff --
    
    Well, I had some logic to kill the adb.exe, using shelljs.exec, but well adb.exe is part of the Android SDK, if this process is working with other files or in another process.
    
    But I can add logic, to kill the process if the exception is caught.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#issuecomment-41101717
  
    Thanks @purplecabbage , that's a good option too.
    Changes:
    
    -Changed mobilespec project as cordova-coho peer.
    -Added describe to optimist to show a better organized output.
    -Changed error outputs with help output and notice messages.
    
    --link-to it worked well with the local cordova-coho/cordova-mobile-spec.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#issuecomment-41705027
  
    Merged


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by purplecabbage <gi...@git.apache.org>.
Github user purplecabbage commented on the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#issuecomment-41097230
  
    Or just add a .gitignore


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
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



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11816666
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,197 @@
         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'),
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +
    +// 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.
    +var mainModDir     = process.cwd(),
    +    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(coho_dir, "mobilespec"),
    +    platforms      = [],
    +//Setting up optimist features
    +    tokens         = process.argv.slice(2),
    +    argv           = optimist(tokens)
    +                     .usage("Usage: $0 [--platform].")
    +                     .argv;
    +
    +// 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')) {
    -    console.log('Please run this script from the directory that contains 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');
    +// No arguments throws error
    +if (tokens.length === 0) {
    +    throw new Error('No arguments found');
    +}
    +if (argv.help) {console.log("Usage: createmobilespec --platformName"); return;}
    --- End diff --
    
    I believe optimist provides some built-in help capabilities. Can you use those instead of rolling your own? Also "-h" and "-?" should be aliases for "--help".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11875752
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,163 @@
         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'),
    +     */
    +     
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +// 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.
    +shelljs.pushd("../../../cordova-coho")
    +var coho_dir       = process.cwd()+path.sep,
    +    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(coho_dir, "mobilespec"),
    +    platforms      = [],
    +    //Setting up optimist features
    +    tokens         = process.argv.slice(2),
    +    argv = optimist.usage('\n\nCreatemobilespec usage: \n$0 [--android] [--ios]')
    +                    .alias('h', 'help')
    +                    .argv;
    +
    +// 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')) {
    -    console.log('Please run this script from the directory that contains 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');
    +// No arguments throws error
    +if (tokens.length === 0) {
    +    throw new Error('No arguments found');
    +}
    +
    +if (argv.help) {optimist.showHelp(); return;}
    +if (argv.android) { platforms.push("android");}
    +if (argv.ios) { platforms.push("ios");}
    +if (argv.blackberry10) { platforms.push("blackberry10");}
    +if (argv.wp8) { platforms.push("wp8");}
    +if (argv.windows8) { platforms.push("windows8");}
    +
    +if (platforms.length === 0){
    +    throw new Error ('No supported platforms');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    +// Custom function to delete project folder, using recursive actions
    +try {
    +    shelljs.rm('-r', ms_project_dir);
    +} catch (e) {
    +    //The project directory after an android build and emulation is locked by ADB.exe (Android Debug Bridge).
    +    //Kill the process & restart folder deletion
    +    console.log("Not all files were deleted, killing Adb.exe process to unlock project folder ...");
    +    if (/^win/.test(process.platform)) {
    +        shelljs.exec("TASKKILL /F /IM ADB.exe /T");
    +        shelljs.rm('-r', ms_project_dir);
    +        }else
    +            throw new Error("Error during folder deletion, try to remove mobilespec project folder manually");
    +    }
    +
    +// Creating the project, linked to cordova-mobile-spec library
    +shelljs.pushd(coho_dir);
    +shelljs.exec(cordova_cli + " create mobilespec org.apache.cordova.mobilespec MobileSpec_Tests --link-to cordova-mobile-spec");
    --- End diff --
    
    Is this creating the mobilespec project inside the cordova-coho directory? I'd suggest not to create stuff that isn't automatically cleaned up inside a git repo. Could the mobilespec project be created as a peer to cordova-coho instead?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by martincgg <gi...@git.apache.org>.
Github user martincgg commented on the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#issuecomment-40410078
  
    Tested it under Windows 7 & 8(Run as adminstrator), Mac and Linux(Ubuntu).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11606853
  
    --- 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'];
    +if (/^win/.test(process.platform)) {
    +    //Determine windows 8 platform
    +    child_process.exec('wmic os get caption', function (error, stdout, stderr) {
    +        if (error !== null) {
    +            callback = 'Error performing command: ' + error + "\n" + stderr;
    +        } else {
    +            // If Windows 8, add Windows Phone 8 and Windows8 platform to the array
    +            if ((/.*(Windows 8).*/gi).test(((stdout.replace(/\r\r\n/i, ': ')).replace(/\s\s+/g, '')).replace((/\n|\r/gi), ''))) {
    +                cordovaPlatforms.push('wp8', 'windows8');
    +            }
    +        }
    +    });
    +} else {
    +    //If Mac Os, add iOS platform
    +    if (/^darwin/.test(process.platform))
    +        cordovaPlatforms.push('ios');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    +// Custom function to delete project folder, using recursive actions
    +try {
    +    delFileSync(ms_project_dir);
    +} catch (e) {
    +    //Why this?, well during tests, trying to delete the project directory after make an android build and emulation, the folder is locked by ADB.exe (Android Debug Bridge).
    +    //Cordova allows project creation in an empty folder.
    +    //It just locks the project folder, not the files under, so catching up the exception, allows to continue.
    +    console.log("Not all files were deleted");
    --- End diff --
    
    In this case, would it make sense to properly delete the contents that are locked by stopping adb, instead of eating the exception and continuing with a half-deleted folder? Given that this is to run tests, and clean state and reproducible environment is desired.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11604897
  
    --- 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');
    +	shelljs = require('shelljs');
    --- End diff --
    
    Please replace tabs with 4 spaces. (Yes, this is a nit.) Tabs appear in several of your additions.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...

Posted by cmarcelk <gi...@git.apache.org>.
Github user cmarcelk commented on a diff in the pull request:

    https://github.com/apache/cordova-mobile-spec/pull/55#discussion_r11817282
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -17,99 +16,197 @@
         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'),
    +var fs            = require("fs"),
    +    path          = require("path"),
    +    child_process = require("child_process"),
         shelljs,
         optimist;
    +
    +// Dependencies requirements check
     try {
    -    shelljs = require('shelljs');
    -    optimist = require('optimist');
    +    shelljs = require("shelljs");
    +    optimist = require("optimist");
     } catch (e) {
    -    console.error('Missing module. Please run "npm install" from this directory:\n\t' +
    +    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;
    +// Print relevant information
    +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
    +
    +// 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.
    +var mainModDir     = process.cwd(),
    +    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(coho_dir, "mobilespec"),
    +    platforms      = [],
    +//Setting up optimist features
    +    tokens         = process.argv.slice(2),
    +    argv           = optimist(tokens)
    +                     .usage("Usage: $0 [--platform].")
    +                     .argv;
    +
    +// 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')) {
    -    console.log('Please run this script from the directory that contains 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');
    +// No arguments throws error
    +if (tokens.length === 0) {
    +    throw new Error('No arguments found');
    +}
    +if (argv.help) {console.log("Usage: createmobilespec --platformName"); return;}
    +if (argv.android) { platforms.push("android");}
    +if (argv.ios) { platforms.push("ios");}
    +if (argv.blackberry10) { platforms.push("blackberry10");}
    +if (argv.wp8) { platforms.push("wp8");}
    +if (argv.windows8) { platforms.push("windows8");}
    +
    +if (platforms.length === 0){
    +    throw new Error ('No supported platforms');
    +}
     
    -var repoParent = process.cwd();
    +// Setting up config.fatal as true, if something goes wrong the program it will terminate
     shelljs.config.fatal = true;
     
    -shelljs.exec('./cordova-cli/bin/cordova create mobilespec --link-to cordova-mobile-spec');
    +// Custom function to delete project folder, using recursive actions
    +try {
    +    delFileSync(ms_project_dir);
    +} catch (e) {
    +    //The project directory after an android build and emulation is locked by ADB.exe (Android Debug Bridge).
    +    //Kill the process & restart folder deletion
    +        console.log("Not all files were deleted, killing Adb.exe process to unlock project folder ...");
    +        if (/^win/.test(process.platform)) {
    +        shelljs.exec("TASKKILL /F /IM ADB.exe /T");
    +        delFileSync(ms_project_dir);
    +        }else
    +            throw new Error("Error during folder deletion, try to remove mobilespec project folder manually");
    +    }
     
    -shelljs.pushd('cordova-js');
    -shelljs.exec('grunt');
    -shelljs.popd();
    +// Creating the project, linked to cordova-mobile-spec library
    +shelljs.pushd(coho_dir);
    +shelljs.exec(cordova_cli + " create mobilespec org.apache.cordova.mobilespec MobileSpec_Tests --link-to cordova-mobile-spec");
     
    -shelljs.pushd('mobilespec');
    +// Executing grunt task, to generate updated js files for each platform
    +shelljs.pushd(cordova_js);
    +shelljs.exec("grunt");
    +
    +shelljs.pushd(ms_project_dir);
    --- End diff --
    
    Consider doing a popd if the directory in the pushd is no longer needed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---