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

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

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

    https://github.com/apache/cordova-mobile-spec/pull/103#discussion_r16607454
  
    --- Diff: createmobilespec/createmobilespec.js ---
    @@ -210,122 +267,153 @@ if (argv.plugman) {
         shelljs.cp("-f", path.join(mobile_spec_git_dir, 'config.xml'), 
path.join(projectDirName, 'config.xml'));
     
         // Config.json file ---> linked to local libraries
    -    shelljs.pushd(cli_project_dir);
    +    pushd(cli_project_dir);
         var localPlatforms = {
    -        "amazon-fireos" : top_dir + "cordova-amazon-fireos" ,
    -        "android" : top_dir + "cordova-android" ,
    -        "ios" : top_dir + "cordova-ios" ,
    -        "blackberry10" : top_dir + "cordova-blackberry" ,
    -        "wp8" : top_dir + "cordova-wp8" + path.sep + "wp8",
    -        "windows8" : top_dir + "cordova-windows",
    -        "windows" : path.join(top_dir, "cordova-windows", "windows")
    +        "amazon-fireos" : [top_dir, "cordova-amazon-fireos"],
    +        "android" : [top_dir, "cordova-android"],
    +        "ios" : [top_dir, "cordova-ios"],
    +        "blackberry10" : [top_dir, "cordova-blackberry"],
    +        "wp8" : [top_dir, "cordova-wp8", "wp8"],
    +        "windows8" : [top_dir, "cordova-windows"],
    +        "windows" : [top_dir, "cordova-windows", "windows"]
         };
     
         // Executing platform Add
         console.log("Adding platforms...");
    -    platforms.forEach(function (platform) {
    +    [].concat(platforms).forEach(function (platform) {
             console.log("Adding Platform: " + platform);
    -        var platformArg = argv.global ? platform : 
localPlatforms[platform];
    +        var platformArg;
    +        if (argv.global) {
    +            platformArg = platform;
    +        } else {
    +            platformArg = path.join.apply(null, localPlatforms[platform]);
    +            if (!fs.existsSync(platformArg)) {
    +                couldNotFind(localPlatforms[platform][1], platform);
    +                platforms = platforms.filter(function (p) { return p != 
platform; });
    +                return;
    +            }
    +        }
             console.log("platformArg: " + cli + " " + platformArg);
             shelljs.exec(cli + ' platform add "' + platformArg + '" 
--verbose');
         });
    -    shelljs.popd();
    +    popd();
     }
     
     ////////////////////// install plugins for each platform
    -
    -if (argv.plugman) {
    -    console.log("Adding plugins using plugman...");
    -    platforms.forEach(function (platform) {
    -        var projName = getProjName(platform),
    -            nodeCommand = /^win/.test(process.platform) ? process.argv[0] 
+" " : "";
    -        shelljs.pushd(projName);
    -        // plugin path must be relative and not absolute (sigh)
    -        shelljs.exec(nodeCommand + path.join(top_dir, "cordova-plugman", 
"main.js") +
    -                     " install --platform " + platform +
    -                     " --project . --plugin " + path.join("..", 
"cordova-mobile-spec", "dependencies-plugin") +
    -                     " --searchpath " + top_dir);
    -        shelljs.popd();
    -    });
    -} else {
    -    // don't use local git repos for plugins when using --global
    -    var searchpath = argv.global ? "" : " --searchpath " + top_dir;
    -    shelljs.pushd(cli_project_dir);
    -    console.log("Adding plugins using CLI...");
    -    console.log("Searchpath:", searchpath);
    -    shelljs.exec(cli + " plugin add " + path.join(mobile_spec_git_dir, 
"dependencies-plugin") +
    -                 searchpath);
    -    shelljs.popd();
    -}
    +function installPlugins() {
    +    if (argv.plugman) {
    +        console.log("Adding plugins using plugman...");
    +        if (!fs.existsSync(path.join(top_dir, "cordova-plugman"))) {
    +            couldNotFind('plugman');
    +            console.log("  ln -s cordova-lib/cordova-lib 
cordova-plugman/node_modules");
    +            return;
    +        }
    +        platforms.forEach(function (platform) {
    +            var projName = getProjName(platform),
    +                nodeCommand = /^win/.test(process.platform) ? 
process.argv[0] +" " : "";
    +            pushd(projName);
    +            // plugin path must be relative and not absolute (sigh)
    +            shelljs.exec(nodeCommand + path.join(top_dir, 
"cordova-plugman", "main.js") +
    +                         " install --platform " + platform +
    +                         " --project . --plugin " + path.join("..", 
"cordova-mobile-spec", "dependencies-plugin") +
    +                         " --searchpath " + top_dir);
    +            popd();
    +        });
    +    } else {
    +        // don't use local git repos for plugins when using --global
    +        var searchpath = argv.global ? "" : " --searchpath " + top_dir;
    +        pushd(cli_project_dir);
    +        console.log("Adding plugins using CLI...");
    +        console.log("Searchpath:", searchpath);
    +        if (!fs.existsSync('cordova-plugin-test-framework')) {
    +            couldNotFind('cordova-plugin-test-framework');
    +        }
    +        shelljs.exec(cli + " plugin add " + path.join(mobile_spec_git_dir, 
"dependencies-plugin") +
    +                     searchpath);
    +        popd();
    +    }
     
     ////////////////////// install new-style test plugins
    -
    -if (argv.plugman) {
    -  // TODO
    -} else {
    -    shelljs.pushd(cli_project_dir);
    -    console.log("Adding plugin tests using CLI...");
    -    shelljs.ls('plugins').forEach(function(plugin) {
    -      var potential_tests_plugin_xml = path.join('plugins', plugin, 
'tests', 'plugin.xml');
    -      if (fs.existsSync(potential_tests_plugin_xml)) {
    -        shelljs.exec(cli + " plugin add " + 
path.dirname(potential_tests_plugin_xml));
    -      }
    -    });
    -    shelljs.popd();
    +    if (argv.plugman) {
    +      // TODO
    +    } else {
    +        pushd(cli_project_dir);
    +        console.log("Adding plugin tests using CLI...");
    +        shelljs.ls('plugins').forEach(function(plugin) {
    +          var potential_tests_plugin_xml = path.join('plugins', plugin, 
'tests', 'plugin.xml');
    +          if (fs.existsSync(potential_tests_plugin_xml)) {
    +            shelljs.exec(cli + " plugin add " + 
path.dirname(potential_tests_plugin_xml));
    +          }
    +        });
    +        popd();
    +    }
     }
     
     ////////////////////// update js files for each platform from cordova-js
    -
    -if (argv.skipjs) {
    -    console.log("Skipping the js update.");
    -} else if (!argv.global) {
    -    console.log("Updating js for platforms...");
    -
    -    shelljs.pushd(cordova_js_git_dir);
    -    var code = shelljs.exec("grunt").code;
    -    if (code) {
    -        console.log("Failed to build js.");
    -        process.exit(1);
    +function updateJS() {
    +    if (argv.skipjs) {
    +        console.log("Skipping the js update.");
    +    } else if (!argv.global) {
    +        if (!fs.existsSync(cordova_js_git_dir)) {
    +            couldNotFind("js", "cordova-js");
    +        } else {
    +            console.log("Updating js for platforms...");
    +
    +            pushd(cordova_js_git_dir);
    --- End diff --
    
    Something like this is needed:
    ```js
    +            try {
    +                require(path.join(cordova_js_git_dir, "node_modules", 
"grunt"));
    +            } catch (e) {
    +                console.error("\trun `npm install` from: "+ 
cordova_js_git_dir);
    +            }
    ```


> Make createmobilespec friendlier
> --------------------------------
>
>                 Key: CB-7350
>                 URL: https://issues.apache.org/jira/browse/CB-7350
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: mobile-spec
>    Affects Versions: 3.5.0
>            Reporter: Josh Soref
>            Assignee: Josh Soref
>
> * Don't assume that the people running mobilespec are developers -- In my 
> experience, they aren't
> * The READMEs needed a refresh
> * Asking people to install grunt-cli globally is silly, we have npm 
> dependencies, we can use them.
> * The pushd/popd spam is really not helpful afaict
> * Provide information about how to use coho to get the right things more or 
> less at the right time
> * Fix the __dirname output to be correct
> ... some other stuff...



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

Reply via email to