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);
+ }
```
---
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 [email protected] or file a JIRA ticket
with INFRA.
---