cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmarcelk <...@git.apache.org>
Subject [GitHub] cordova-mobile-spec pull request: CB-6437[Improvements & support f...
Date Tue, 15 Apr 2014 15:55:29 GMT
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.
---

Mime
View raw message