[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13978023#comment-13978023 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on the pull request: https://github.com/apache/cordova-cli/pull/151#issuecomment-41141270 I've been working on some other stuff with cordova-mobile-spec, but I came back to this topic to deliver the pending changes removing callback functions, and use only promises and superspawn following the recommendations and feedback provided. Summary: -Removed: All callbacks functions. -Every function returns a promise. -Use of superspawn instead of shelljs. -Use of Q.defer(), to resolve or reject promises. -Removed mostly all anonymous functions. It's cleaner and complexity has been reduced without promises-callbacks statements combination. Q.allSettled it will wait until all promises are resolved, and then write the log file, collecting all data. @agrieve , thanks for the feedback and all the suggestions that you provided me. If this is last commit is well accomplished, let me know to start to work on add support for blackberry, wp8 and windows 8, using the same pattern. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13978407#comment-13978407 ] ASF subversion and git services commented on CB-6329: - Commit 106014ae77119043fd4b481cd39f5839dbc7cf66 in cordova-cli's branch refs/heads/master from [~agrieve] [ https://git-wip-us.apache.org/repos/asf?p=cordova-cli.git;h=106014a ] CB-6329 Delete unused info-utils.js [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13978405#comment-13978405 ] ASF subversion and git services commented on CB-6329: - Commit 9372f0dd3ca9d9bc8982d0aaae7ee11ff1e58b9e in cordova-cli's branch refs/heads/master from [~martin.c.glez.glez] [ https://git-wip-us.apache.org/repos/asf?p=cordova-cli.git;h=9372f0d ] CB-6329 improve 'cordova info' command info.js file has been modified to work mainly asynchronous. Added info-utils, which contains several useful functions required by info.js -It doesn't require a template to set an output. -getNode, getCordova, doPlatforms works asynchronous, works with callbacks and deals with errors. -it writes a report (info.txt) in rootProject. This changes are required for futures improvements. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13978406#comment-13978406 ] ASF subversion and git services commented on CB-6329: - Commit cdb5deff99f60c0e10d44d49de63bd07ce2e5ca1 in cordova-cli's branch refs/heads/master from [~agrieve] [ https://git-wip-us.apache.org/repos/asf?p=cordova-cli.git;h=cdb5def ] CB-6329 Clean-up of cordova info changes previously merged. github: close #151 [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13978413#comment-13978413 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on the pull request: https://github.com/apache/cordova-cli/pull/151#issuecomment-41184231 Merged. I did a clean-up commit along with it that you can see here: https://git-wip-us.apache.org/repos/asf?p=cordova-cli.git;a=blobdiff;f=src/info.js;h=c8b8e248ed8f1cf99edb9324a056ea35fbfa563b;hp=a61d88e0d2834969490fd825eb792903a735c312;hb=cdb5deff;hpb=9372f0dd3ca9d9bc8982d0aaae7ee11ff1e58b9e [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13978461#comment-13978461 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on the pull request: https://github.com/apache/cordova-cli/pull/151#issuecomment-41187328 Ok, I've see what you've done with it, it's Ok, I tried to keep it consistent as you recommend. Didn't knew about process.version, neither about package.version. I just have a question. For future improvements or additional support do you want me to set all in the same file? just a yes or not to clarify. that's it. Thanks @agrieve . [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13978504#comment-13978504 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on the pull request: https://github.com/apache/cordova-cli/pull/151#issuecomment-41190420 Unless there are functions that will be used by other files as well, keep it in one file. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13978532#comment-13978532 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on the pull request: https://github.com/apache/cordova-cli/pull/151#issuecomment-41192677 Ok, I got it, thanks Andrew, have a nice day. 2014-04-23 12:30 GMT-05:00 agrieve notificati...@github.com: Unless there are functions that will be used by other files as well, keep it in one file. — Reply to this email directly or view it on GitHubhttps://github.com/apache/cordova-cli/pull/151#issuecomment-41190420 . [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13960101#comment-13960101 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11301928 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); +}()), (function (){ +//Get Cordova version +return (Q.denodeify (info_utils.getCordovaInfo)()); +}()), (function (){ + //Get project config.xml file + return 'Config.xml File: \n\n'+ (fs.readFileSync(cordova_util.projectConfig(projectRoot), 'utf-8')) +'\n\n\n' +}()), (function (){ + //Get list of plugins +return 'Plugins: \n\n' + doPlugins( projectRoot ) +'\n\n\n'; +}()), (function (){ +//Get Platforms information +return (Q.denodeify (doPlatforms)(projectRoot)); +}())]).then(function (promises){ +for(var t in promises) +print_SaveMsg( projectRoot, (function (){ return promises[t].state==='fulfilled' ? promises[t].value : promises[t].state==='rejected' ? promises[t].reason : 'Still working' }()) ); + }); }; -function doPlatform( currentPlatform ) { -var output = ; -switch( currentPlatform ){ -case ios: -output = shell.exec('xcodebuild -version',{silent:true} ).output; -break; -case android: -output = shell.exec('android list target',{silent:true} ).output; +function delLog(projectRoot){ +if(fs.existsSync(path.join(projectRoot,'info.txt'))){ +fs.unlink(path.join(projectRoot,'info.txt'), function (err) { +if (err) {throw err; console.log(Unable to delete info.txt
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13960113#comment-13960113 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on the pull request: https://github.com/apache/cordova-cli/pull/151#issuecomment-39585091 Last commit. -Removed functions: appendLog, writeLog, delLog. -No indent on top-level functions -Changed for loop from for(var t in promises) to promises.forEach(function(p)) -Other minor changes Well @agrieve , this is what I got, I have a combination of callbacks and promises, trying to take good advantages of both of them, you have more experience and expertise than me in this subject, if you want me to change the whole thing to promises, just let me know, but I rather focus efforts on in adding support to other platforms and make more improvements, but like I said, if you consider that the best action to take is change the whole thing to promises and not a combination of callbacks and promises, it's Ok, I'll do it. Thanks a lot again for your feedback. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958947#comment-13958947 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260150 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ --- End diff -- There's a lot of unnecessary (function(){})() going on here. You could simplify to: console.log('Collecting Data...'); Q.allSettled([Q.denodeify(...), Q.denodeify(...), ...) [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958948#comment-13958948 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260194 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); --- End diff -- Might clean things up even more to have info_utils.* return promises instead of callbacks. Then you don't need to denodify, and error reporting becomes easier. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958949#comment-13958949 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260238 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); +}()), (function (){ +//Get Cordova version +return (Q.denodeify (info_utils.getCordovaInfo)()); +}()), (function (){ + //Get project config.xml file + return 'Config.xml File: \n\n'+ (fs.readFileSync(cordova_util.projectConfig(projectRoot), 'utf-8')) +'\n\n\n' +}()), (function (){ + //Get list of plugins +return 'Plugins: \n\n' + doPlugins( projectRoot ) +'\n\n\n'; +}()), (function (){ +//Get Platforms information +return (Q.denodeify (doPlatforms)(projectRoot)); +}())]).then(function (promises){ +for(var t in promises) --- End diff -- Never use a for in loop on arrays. Use promises.forEach(function(p)), or a regular for loop. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958953#comment-13958953 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260317 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); +}()), (function (){ +//Get Cordova version +return (Q.denodeify (info_utils.getCordovaInfo)()); +}()), (function (){ + //Get project config.xml file + return 'Config.xml File: \n\n'+ (fs.readFileSync(cordova_util.projectConfig(projectRoot), 'utf-8')) +'\n\n\n' +}()), (function (){ + //Get list of plugins +return 'Plugins: \n\n' + doPlugins( projectRoot ) +'\n\n\n'; +}()), (function (){ +//Get Platforms information +return (Q.denodeify (doPlatforms)(projectRoot)); +}())]).then(function (promises){ +for(var t in promises) +print_SaveMsg( projectRoot, (function (){ return promises[t].state==='fulfilled' ? promises[t].value : promises[t].state==='rejected' ? promises[t].reason : 'Still working' }()) ); + }); }; -function doPlatform( currentPlatform ) { -var output = ; -switch( currentPlatform ){ -case ios: -output = shell.exec('xcodebuild -version',{silent:true} ).output; -break; -case android: -output = shell.exec('android list target',{silent:true} ).output; +function delLog(projectRoot){ +if(fs.existsSync(path.join(projectRoot,'info.txt'))){ +fs.unlink(path.join(projectRoot,'info.txt'), function (err) { +if (err) {throw err; console.log(Unable to delete info.txt
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958950#comment-13958950 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260263 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); +}()), (function (){ +//Get Cordova version +return (Q.denodeify (info_utils.getCordovaInfo)()); +}()), (function (){ + //Get project config.xml file + return 'Config.xml File: \n\n'+ (fs.readFileSync(cordova_util.projectConfig(projectRoot), 'utf-8')) +'\n\n\n' +}()), (function (){ + //Get list of plugins +return 'Plugins: \n\n' + doPlugins( projectRoot ) +'\n\n\n'; +}()), (function (){ +//Get Platforms information +return (Q.denodeify (doPlatforms)(projectRoot)); +}())]).then(function (promises){ +for(var t in promises) +print_SaveMsg( projectRoot, (function (){ return promises[t].state==='fulfilled' ? promises[t].value : promises[t].state==='rejected' ? promises[t].reason : 'Still working' }()) ); + }); }; -function doPlatform( currentPlatform ) { -var output = ; -switch( currentPlatform ){ -case ios: -output = shell.exec('xcodebuild -version',{silent:true} ).output; -break; -case android: -output = shell.exec('android list target',{silent:true} ).output; +function delLog(projectRoot){ +if(fs.existsSync(path.join(projectRoot,'info.txt'))){ +fs.unlink(path.join(projectRoot,'info.txt'), function (err) { +if (err) {throw err; console.log(Unable to delete info.txt
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958951#comment-13958951 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260290 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); +}()), (function (){ +//Get Cordova version +return (Q.denodeify (info_utils.getCordovaInfo)()); +}()), (function (){ + //Get project config.xml file + return 'Config.xml File: \n\n'+ (fs.readFileSync(cordova_util.projectConfig(projectRoot), 'utf-8')) +'\n\n\n' +}()), (function (){ + //Get list of plugins +return 'Plugins: \n\n' + doPlugins( projectRoot ) +'\n\n\n'; +}()), (function (){ +//Get Platforms information +return (Q.denodeify (doPlatforms)(projectRoot)); +}())]).then(function (promises){ +for(var t in promises) +print_SaveMsg( projectRoot, (function (){ return promises[t].state==='fulfilled' ? promises[t].value : promises[t].state==='rejected' ? promises[t].reason : 'Still working' }()) ); + }); }; -function doPlatform( currentPlatform ) { -var output = ; -switch( currentPlatform ){ -case ios: -output = shell.exec('xcodebuild -version',{silent:true} ).output; -break; -case android: -output = shell.exec('android list target',{silent:true} ).output; +function delLog(projectRoot){ +if(fs.existsSync(path.join(projectRoot,'info.txt'))){ +fs.unlink(path.join(projectRoot,'info.txt'), function (err) { +if (err) {throw err; console.log(Unable to delete info.txt
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958955#comment-13958955 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260409 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); +}()), (function (){ +//Get Cordova version +return (Q.denodeify (info_utils.getCordovaInfo)()); +}()), (function (){ + //Get project config.xml file + return 'Config.xml File: \n\n'+ (fs.readFileSync(cordova_util.projectConfig(projectRoot), 'utf-8')) +'\n\n\n' +}()), (function (){ + //Get list of plugins +return 'Plugins: \n\n' + doPlugins( projectRoot ) +'\n\n\n'; +}()), (function (){ +//Get Platforms information +return (Q.denodeify (doPlatforms)(projectRoot)); +}())]).then(function (promises){ +for(var t in promises) +print_SaveMsg( projectRoot, (function (){ return promises[t].state==='fulfilled' ? promises[t].value : promises[t].state==='rejected' ? promises[t].reason : 'Still working' }()) ); + }); }; -function doPlatform( currentPlatform ) { -var output = ; -switch( currentPlatform ){ -case ios: -output = shell.exec('xcodebuild -version',{silent:true} ).output; -break; -case android: -output = shell.exec('android list target',{silent:true} ).output; +function delLog(projectRoot){ --- End diff -- don't indent top-level functions [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958959#comment-13958959 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260509 --- Diff: src/info-utils.js --- @@ -0,0 +1,58 @@ +/** +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +License); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ +var cordova_util = require('./util'), +child_process = require('child_process'), +path = require('path'), +fs= require('fs'), +_self; + +_self = { + +getNodeInfo: function( callback ){ +_self.execFunc('node', '--version', function(call){callback(Node version: +call);}); +}, + +getCordovaInfo: function( callback ){ +_self.execFunc('cordova', '--version', function(call){callback(Cordova version: +call);}); +}, + +getPlatformInfo: function(platform, projectRoot, callback ){ +var command=, args=; +switch( platform ){ +case ios: +_self.execFunc('xcodebuild', '-version', function(call){callback('iOS Platform:\n\n' +call);}); +break; +case android: +_self.execFunc('android', 'list target', function(call){callback('Android Platform:\n\n' +call);}); +break; +} +}, + +execFunc: function(command, args, callback){ --- End diff -- Feel free to ignore me and leave as-is, but might simplify to use superspawn instead of this, since that already returns a promise. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958958#comment-13958958 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260484 --- Diff: src/info-utils.js --- @@ -0,0 +1,58 @@ +/** +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +License); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ +var cordova_util = require('./util'), +child_process = require('child_process'), +path = require('path'), +fs= require('fs'), +_self; + +_self = { + +getNodeInfo: function( callback ){ +_self.execFunc('node', '--version', function(call){callback(Node version: +call);}); --- End diff -- I'd lean towards having these all as helper functions within info.js. Could be convinced otherwise. wondering what your rationale is? [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958962#comment-13958962 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260674 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); +}()), (function (){ +//Get Cordova version +return (Q.denodeify (info_utils.getCordovaInfo)()); +}()), (function (){ + //Get project config.xml file + return 'Config.xml File: \n\n'+ (fs.readFileSync(cordova_util.projectConfig(projectRoot), 'utf-8')) +'\n\n\n' +}()), (function (){ + //Get list of plugins +return 'Plugins: \n\n' + doPlugins( projectRoot ) +'\n\n\n'; +}()), (function (){ +//Get Platforms information +return (Q.denodeify (doPlatforms)(projectRoot)); +}())]).then(function (promises){ +for(var t in promises) --- End diff -- Understood, I'm changing it, I'll use the first one. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958961#comment-13958961 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260643 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); --- End diff -- Well, Ok I can do it without any problem, but I've leave it in that way, because all the promises are requested at time, then, all callbacks are processed asynchronously, so Q.allSettled, it will wait until every promises is recovered, meanwhile the callbacks completed, so it won't be necessary wait until the first promise is complete, to get the next one, I like it in that way, just because all callbacks are sent and the promises are retrieved when callbacks are completed, not waiting for execution one after another, that's the reason why I have implemented in that way. But no problem, just confirm me please, are you sure that it would be better, if I change the whole methods to promises? [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958963#comment-13958963 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260700 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); +}()), (function (){ +//Get Cordova version +return (Q.denodeify (info_utils.getCordovaInfo)()); +}()), (function (){ + //Get project config.xml file + return 'Config.xml File: \n\n'+ (fs.readFileSync(cordova_util.projectConfig(projectRoot), 'utf-8')) +'\n\n\n' +}()), (function (){ + //Get list of plugins +return 'Plugins: \n\n' + doPlugins( projectRoot ) +'\n\n\n'; +}()), (function (){ +//Get Platforms information +return (Q.denodeify (doPlatforms)(projectRoot)); +}())]).then(function (promises){ +for(var t in promises) +print_SaveMsg( projectRoot, (function (){ return promises[t].state==='fulfilled' ? promises[t].value : promises[t].state==='rejected' ? promises[t].reason : 'Still working' }()) ); + }); }; -function doPlatform( currentPlatform ) { -var output = ; -switch( currentPlatform ){ -case ios: -output = shell.exec('xcodebuild -version',{silent:true} ).output; -break; -case android: -output = shell.exec('android list target',{silent:true} ).output; +function delLog(projectRoot){ --- End diff -- Ok, zero indent on functions [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958965#comment-13958965 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11260908 --- Diff: src/info-utils.js --- @@ -0,0 +1,58 @@ +/** +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +License); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ +var cordova_util = require('./util'), +child_process = require('child_process'), +path = require('path'), +fs= require('fs'), +_self; + +_self = { + +getNodeInfo: function( callback ){ +_self.execFunc('node', '--version', function(call){callback(Node version: +call);}); --- End diff -- The main reason is the possibility of use this helper functions to be used by other js files, if another process requires to get any relevant information provided by utils-info.js, besides, I'm working improving and providing more information, and it would be better keep it outside of info.js file. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13958999#comment-13958999 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11262183 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ --- End diff -- https://github.com/kriskowal/q/wiki/API-Reference#promiseallsettled Example of Q.allSettled usage, and also I've tried to use just the returning the value [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13959046#comment-13959046 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11264328 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); +}()), (function (){ +//Get Cordova version +return (Q.denodeify (info_utils.getCordovaInfo)()); +}()), (function (){ + //Get project config.xml file + return 'Config.xml File: \n\n'+ (fs.readFileSync(cordova_util.projectConfig(projectRoot), 'utf-8')) +'\n\n\n' +}()), (function (){ + //Get list of plugins +return 'Plugins: \n\n' + doPlugins( projectRoot ) +'\n\n\n'; +}()), (function (){ +//Get Platforms information +return (Q.denodeify (doPlatforms)(projectRoot)); +}())]).then(function (promises){ +for(var t in promises) +print_SaveMsg( projectRoot, (function (){ return promises[t].state==='fulfilled' ? promises[t].value : promises[t].state==='rejected' ? promises[t].reason : 'Still working' }()) ); + }); }; -function doPlatform( currentPlatform ) { -var output = ; -switch( currentPlatform ){ -case ios: -output = shell.exec('xcodebuild -version',{silent:true} ).output; -break; -case android: -output = shell.exec('android list target',{silent:true} ).output; +function delLog(projectRoot){ +if(fs.existsSync(path.join(projectRoot,'info.txt'))){ +fs.unlink(path.join(projectRoot,'info.txt'), function (err) { +if (err) {throw err; console.log(Unable to delete info.txt
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13959050#comment-13959050 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11264375 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); +}()), (function (){ +//Get Cordova version +return (Q.denodeify (info_utils.getCordovaInfo)()); +}()), (function (){ + //Get project config.xml file + return 'Config.xml File: \n\n'+ (fs.readFileSync(cordova_util.projectConfig(projectRoot), 'utf-8')) +'\n\n\n' +}()), (function (){ + //Get list of plugins +return 'Plugins: \n\n' + doPlugins( projectRoot ) +'\n\n\n'; +}()), (function (){ +//Get Platforms information +return (Q.denodeify (doPlatforms)(projectRoot)); +}())]).then(function (promises){ +for(var t in promises) +print_SaveMsg( projectRoot, (function (){ return promises[t].state==='fulfilled' ? promises[t].value : promises[t].state==='rejected' ? promises[t].reason : 'Still working' }()) ); + }); }; -function doPlatform( currentPlatform ) { -var output = ; -switch( currentPlatform ){ -case ios: -output = shell.exec('xcodebuild -version',{silent:true} ).output; -break; -case android: -output = shell.exec('android list target',{silent:true} ).output; +function delLog(projectRoot){ +if(fs.existsSync(path.join(projectRoot,'info.txt'))){ +fs.unlink(path.join(projectRoot,'info.txt'), function (err) { +if (err) {throw err; console.log(Unable to delete info.txt
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13959441#comment-13959441 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11278577 --- Diff: src/info.js --- @@ -16,123 +16,99 @@ specific language governing permissions and limitations under the License. */ -var cordova_util = require('./util'), -shell = require('shelljs'), -path = require('path'), -fs= require('fs'), -Q = require('q'), -events= require('./events'); - -/* -A utility funciton to help output the information needed -when submitting a help request. - -Outputs to a file -*/ +var cordova_util = require('./util'), +path = require('path'), +fs= require('fs'), +child_process = require('child_process'), +Q = require('q'), +info_utils = require('./info-utils'); + +/* +A utility funciton to help output the information needed +when submitting a help request. + +Outputs to a file +*/ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +if (!projectRoot) { +return Q.reject( new Error('Current working directory is not a Cordova-based project.') ); } -}).join(\n); -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); -return Q(); +delLog(projectRoot); +//Array of functions, Q.allSettled +return Q.allSettled([ (function (){ +console.log(Collecting Data...); +//Get Node version +return (Q.denodeify (info_utils.getNodeInfo)()); +}()), (function (){ +//Get Cordova version +return (Q.denodeify (info_utils.getCordovaInfo)()); +}()), (function (){ + //Get project config.xml file + return 'Config.xml File: \n\n'+ (fs.readFileSync(cordova_util.projectConfig(projectRoot), 'utf-8')) +'\n\n\n' +}()), (function (){ + //Get list of plugins +return 'Plugins: \n\n' + doPlugins( projectRoot ) +'\n\n\n'; +}()), (function (){ +//Get Platforms information +return (Q.denodeify (doPlatforms)(projectRoot)); +}())]).then(function (promises){ +for(var t in promises) +print_SaveMsg( projectRoot, (function (){ return promises[t].state==='fulfilled' ? promises[t].value : promises[t].state==='rejected' ? promises[t].reason : 'Still working' }()) ); + }); }; -function doPlatform( currentPlatform ) { -var output = ; -switch( currentPlatform ){ -case ios: -output = shell.exec('xcodebuild -version',{silent:true} ).output; -break; -case android: -output = shell.exec('android list target',{silent:true} ).output; +function delLog(projectRoot){ +if(fs.existsSync(path.join(projectRoot,'info.txt'))){ +fs.unlink(path.join(projectRoot,'info.txt'), function (err) { +if (err) {throw err; console.log(Unable to delete info.txt
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13957985#comment-13957985 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on the pull request: https://github.com/apache/cordova-cli/pull/151#issuecomment-39364969 Well, the feedback was attended thanks a lot, here's the new commit, this are the changes: -Added, proper indent (4 spaces). -Removed, trailing whitespace -Fixed, callbacks double assignation. - \r replaced by \n. Also, now it uses Q to work with callbacks, this time is going to return every value retrieve from the environment, all promises it will be called, those promises are callbacks data, Q.allSettled is going to call all of them, and then wait until every single one of them is fulfilled or rejected, then is going to print the data and save into a file. Adding this logic, it returns promises, and cleans the code of heavy nesting of callbacks. The only disadvantage, is that it requires to wait until everything is done to show it in the screen, if it takes too much time retrieving the data, the user may think that the terminal is frozen, which is unlikely. @agrieve is this what you recommend me to do? https://github.com/martincgg/cordova-cli/blob/31ea565bac97a6f35c484cba3461fb726f24e07a/src/info.js#L42 This is better?. Btw thanks a lot for the feedback. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13951202#comment-13951202 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r1107 --- Diff: src/info-utils.js --- @@ -0,0 +1,58 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +var cordova_util = require('./util'), +child_process = require('child_process'), --- End diff -- nit: indent these [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13951203#comment-13951203 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11080008 --- Diff: src/info-utils.js --- @@ -0,0 +1,58 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +var cordova_util = require('./util'), +child_process = require('child_process'), +path = require('path'), +fs= require('fs'), +_self; + +_self = { + +getNodeInfo: function( callback ){ + callback(_self.execFunc('node', '--version', function(call){callback(call);})); --- End diff -- Please use 4 space indent and remove trailing whitespace [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13951206#comment-13951206 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11080035 --- Diff: src/info-utils.js --- @@ -0,0 +1,58 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +var cordova_util = require('./util'), +child_process = require('child_process'), +path = require('path'), +fs= require('fs'), +_self; + +_self = { + +getNodeInfo: function( callback ){ + callback(_self.execFunc('node', '--version', function(call){callback(call);})); + }, + +getCordovaInfo: function( callback ){ + callback(_self.execFunc('cordova', '--version', function(call){callback(call);})); --- End diff -- you're calling callback twice here and above. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13951207#comment-13951207 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11080089 --- Diff: src/info-utils.js --- @@ -0,0 +1,58 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +var cordova_util = require('./util'), +child_process = require('child_process'), +path = require('path'), +fs= require('fs'), +_self; + +_self = { + +getNodeInfo: function( callback ){ + callback(_self.execFunc('node', '--version', function(call){callback(call);})); + }, + +getCordovaInfo: function( callback ){ + callback(_self.execFunc('cordova', '--version', function(call){callback(call);})); + }, + +getPlatformInfo: function(platform, projectRoot, callback ){ + var command=, args=; + switch( platform ){ + case ios: + _self.execFunc('xcodebuild', '-version', function(call){callback('iOS Platform:\r\r' +call);}); + break; + case android: + _self.execFunc('android', 'list target', function(call){callback('Android Platform:\r\r' +call);}); --- End diff -- Why use \r? I think \n is much more common for newlines. Not sure if \r even works correctly? [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13951220#comment-13951220 ] ASF GitHub Bot commented on CB-6329: Github user agrieve commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11080227 --- Diff: src/info.js --- @@ -30,105 +29,80 @@ var cordova_util = require('./util'), Outputs to a file */ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), -output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), +output; +delLog(projectRoot); +//Get Node info +info_utils.getNodeInfo(function (result){ +if( result ){ +print_SaveMsg(projectRoot, Node version: + result); +//Get Cordova version +info_utils.getCordovaInfo(function (result){ +if( result ){print_SaveMsg(projectRoot,Cordova version: + result ); +// Get config.xml file +fs.readFile(cordova_util.projectConfig(projectRoot) , 'utf-8' , function ( err , result ){ +if(err) {print_SaveMsg(projectRoot,Error reading config.xml file+ err);} +print_SaveMsg(projectRoot,'Config.xml File: \r'+ result +'\r\r\r'); +print_SaveMsg(projectRoot,'Plugins: \r' + doPlugins( projectRoot ) +'\r\r\r'); +//Get platforms info +doPlatforms(projectRoot, function (result){ +if( result ){ +print_SaveMsg(projectRoot,result); +} +}); +}); +} +}); } -}).join(\n); - -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); +}); return Q(); --- End diff -- Not this this is not synchronous, you need to have the returned promise not resolve until the command is completed. Have a look at other examples where promises are used. It may also clean up your code above to use promises instead of such heavy nesting. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13951462#comment-13951462 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11087295 --- Diff: src/info-utils.js --- @@ -0,0 +1,58 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +var cordova_util = require('./util'), +child_process = require('child_process'), +path = require('path'), +fs= require('fs'), +_self; + +_self = { + +getNodeInfo: function( callback ){ + callback(_self.execFunc('node', '--version', function(call){callback(call);})); --- End diff -- got it [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13951463#comment-13951463 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11087336 --- Diff: src/info-utils.js --- @@ -0,0 +1,58 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +var cordova_util = require('./util'), +child_process = require('child_process'), +path = require('path'), +fs= require('fs'), +_self; + +_self = { + +getNodeInfo: function( callback ){ + callback(_self.execFunc('node', '--version', function(call){callback(call);})); + }, + +getCordovaInfo: function( callback ){ + callback(_self.execFunc('cordova', '--version', function(call){callback(call);})); --- End diff -- yes, you're right, I can change that. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13951464#comment-13951464 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11087348 --- Diff: src/info-utils.js --- @@ -0,0 +1,58 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +var cordova_util = require('./util'), +child_process = require('child_process'), +path = require('path'), +fs= require('fs'), +_self; + +_self = { + +getNodeInfo: function( callback ){ + callback(_self.execFunc('node', '--version', function(call){callback(call);})); + }, + +getCordovaInfo: function( callback ){ + callback(_self.execFunc('cordova', '--version', function(call){callback(call);})); + }, + +getPlatformInfo: function(platform, projectRoot, callback ){ + var command=, args=; + switch( platform ){ + case ios: + _self.execFunc('xcodebuild', '-version', function(call){callback('iOS Platform:\r\r' +call);}); + break; + case android: + _self.execFunc('android', 'list target', function(call){callback('Android Platform:\r\r' +call);}); --- End diff -- If you say so, I can change them all [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13951460#comment-13951460 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11087286 --- Diff: src/info-utils.js --- @@ -0,0 +1,58 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +var cordova_util = require('./util'), +child_process = require('child_process'), --- End diff -- my mistake, sorry. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13951468#comment-13951468 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11087487 --- Diff: src/info.js --- @@ -30,105 +29,80 @@ var cordova_util = require('./util'), Outputs to a file */ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), -output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), +output; +delLog(projectRoot); +//Get Node info +info_utils.getNodeInfo(function (result){ +if( result ){ +print_SaveMsg(projectRoot, Node version: + result); +//Get Cordova version +info_utils.getCordovaInfo(function (result){ +if( result ){print_SaveMsg(projectRoot,Cordova version: + result ); +// Get config.xml file +fs.readFile(cordova_util.projectConfig(projectRoot) , 'utf-8' , function ( err , result ){ +if(err) {print_SaveMsg(projectRoot,Error reading config.xml file+ err);} +print_SaveMsg(projectRoot,'Config.xml File: \r'+ result +'\r\r\r'); +print_SaveMsg(projectRoot,'Plugins: \r' + doPlugins( projectRoot ) +'\r\r\r'); +//Get platforms info +doPlatforms(projectRoot, function (result){ +if( result ){ +print_SaveMsg(projectRoot,result); +} +}); +}); +} +}); } -}).join(\n); - -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); +}); return Q(); --- End diff -- Noted, I'm going to look for another to do so. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13951472#comment-13951472 ] ASF GitHub Bot commented on CB-6329: Github user martincgg commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/151#discussion_r11087542 --- Diff: src/info.js --- @@ -30,105 +29,80 @@ var cordova_util = require('./util'), Outputs to a file */ module.exports = function info() { - -//Get the template -var projectRoot = cordova_util.cdProjectRoot(); - -var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'info.txt'), 'utf-8').split(\n), -output; - -output = raw.map(function(line) { -if(line.match('%') ) { -var type = (line.substr(5)).replace(\r,), -out = ; - -switch(type) { -case Node: -out = shell.exec('node --version',{silent:true}).output; -break; -case Cordova: -out = require('../package').version; -break; -case Config: -out = fs.readFileSync( cordova_util.projectConfig(projectRoot) ); -break; -case Platforms: -out = doPlatforms( projectRoot ); -break; -case Plugins: -out = doPlugins( projectRoot ); -break; -default: -break; -} -return line.replace( %+type, out ); -} else { -return line; +//Get projectRoot +var projectRoot = cordova_util.cdProjectRoot(), +output; +delLog(projectRoot); +//Get Node info +info_utils.getNodeInfo(function (result){ +if( result ){ +print_SaveMsg(projectRoot, Node version: + result); +//Get Cordova version +info_utils.getCordovaInfo(function (result){ +if( result ){print_SaveMsg(projectRoot,Cordova version: + result ); +// Get config.xml file +fs.readFile(cordova_util.projectConfig(projectRoot) , 'utf-8' , function ( err , result ){ +if(err) {print_SaveMsg(projectRoot,Error reading config.xml file+ err);} +print_SaveMsg(projectRoot,'Config.xml File: \r'+ result +'\r\r\r'); +print_SaveMsg(projectRoot,'Plugins: \r' + doPlugins( projectRoot ) +'\r\r\r'); +//Get platforms info +doPlatforms(projectRoot, function (result){ +if( result ){ +print_SaveMsg(projectRoot,result); +} +}); +}); +} +}); } -}).join(\n); - -// /* -// Write to File; -// */ -events.emit('results', output); -fs.writeFileSync('info.txt', output ); +}); return Q(); --- End diff -- Another way [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6329) [cordova-cli] improve 'cordova info' command to work asynchronous
[ https://issues.apache.org/jira/browse/CB-6329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13948306#comment-13948306 ] ASF GitHub Bot commented on CB-6329: GitHub user martincgg opened a pull request: https://github.com/apache/cordova-cli/pull/151 CB-6329 improve 'cordova info' command info.js file has been modified to work mainly asynchronous. Added info-utils, which contains several useful functions required by info.js -It doesn't require a template to set an output. -getNode, getCordova, doPlatforms works asynchronous, works with callbacks and deals with errors. -it writes a report (info.txt) in rootProject. This changes are required for futures improvements. You can merge this pull request into a Git repository by running: $ git pull https://github.com/martincgg/cordova-cli CB-6329 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-cli/pull/151.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 #151 commit aaf54666f4c9a99d910620d42baf5599d85dd7df Author: Martin Gonzalez martin.c.glez.g...@gmail.com Date: 2014-03-26T18:48:08Z CB-6329 improve 'cordova info' command info.js file has been modified to work mainly asynchronous. Added info-utils, which contains several useful functions required by info.js -It doesn't require a template to set an output. -getNode, getCordova, doPlatforms works asynchronous, works with callbacks and deals with errors. -it writes a report (info.txt) in rootProject. This changes are required for futures improvements. [cordova-cli] improve 'cordova info' command to work asynchronous - Key: CB-6329 URL: https://issues.apache.org/jira/browse/CB-6329 Project: Apache Cordova Issue Type: Improvement Components: CLI Affects Versions: 3.4.0 Reporter: Martin Gonzalez Assignee: Martin Gonzalez Labels: blackberry, cordova-cli, environment, info, wp8 Fix For: 3.5.0 The 'cordova info' command it works in total sync, it takes some time to pull and push all data from the environment, so in order to use callbacks more friendly, I'd like to modify the flow structure of the file and improve it to use get callback outputs, write summary or log file without templates. I also, I'd like to add a secondary file that holds all specific functions related with 'get information about the dev environment'. -- This message was sent by Atlassian JIRA (v6.2#6252)