real-votes-admin
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -10,2 +10,3 @@ #!/usr/bin/env node | ||
const EventSource = require('eventsource'); | ||
const chalk = require('chalk'); | ||
@@ -15,4 +16,6 @@ const PollBaseUrl = 'https://real-votes.herokuapp.com/api/poll/'; | ||
console.log('Hello welcome to the real-votes admin console.'); | ||
const highlight = chalk.bold.green; | ||
console.log(highlight('Hello welcome to the real-votes admin console.')); | ||
const cli = vorpal(); | ||
@@ -27,3 +30,3 @@ | ||
name: 'pollName', | ||
message: 'What would you like to name your poll? ', | ||
message: highlight('What would you like to name your poll? '), | ||
}, | ||
@@ -33,3 +36,3 @@ { | ||
name: 'choices', | ||
message: 'Please enter your choices for this poll: ', | ||
message: highlight('Please enter your choices for this poll: '), | ||
}, | ||
@@ -39,3 +42,3 @@ { | ||
name: 'votesPerUser', | ||
message: 'Please enter your max votes for this poll: ', | ||
message: highlight('Please enter your max votes for this poll: '), | ||
}, | ||
@@ -61,3 +64,3 @@ ], (answers) => { | ||
} | ||
this.log('Successfully created a poll.'); | ||
this.log(highlight('Successfully created a poll.')); | ||
callback(); | ||
@@ -69,2 +72,81 @@ }); | ||
cli | ||
.command('viewAllVotes', 'Shows all votes') | ||
.action(function(args, callback) { | ||
const options = { | ||
url: VoteBaseUrl, | ||
auth: { | ||
username: 'admin', | ||
password: process.env.PASSWORD, | ||
}, | ||
}; | ||
request.get(options, (err, res, body) => { | ||
if (err) { | ||
this.log(err); | ||
return callback(); | ||
} | ||
this.log(prettyjson.render(JSON.parse(body))); | ||
callback(); | ||
}); | ||
}); | ||
cli | ||
.command('deleteAllPolls', 'Deletes all polls') | ||
.action(function(args, callback) { | ||
this.prompt({ | ||
type: 'input', | ||
name: 'confirmation', | ||
message: highlight('Are you sure you want to input all polls, \'y\' or \'n\': '), | ||
}, | ||
(answers) => { | ||
if (answers.confirmation.toLowerCase() === 'n') return callback(); | ||
const options = { | ||
url: PollBaseUrl, | ||
auth: { | ||
username: 'admin', | ||
password: process.env.PASSWORD, | ||
}, | ||
}; | ||
request.delete(options, (err) => { | ||
if (err) { | ||
this.log(err); | ||
return callback(); | ||
} | ||
this.log(highlight('Successfully deleted all polls.')); | ||
callback(); | ||
}); | ||
}); | ||
}); | ||
cli | ||
.command('deleteAllVotes', 'Deletes all votes') | ||
.action(function(args, callback) { | ||
this.prompt({ | ||
type: 'input', | ||
name: 'confirmation', | ||
message: highlight('Are you sure you want to delete all votes, \'y\' or \'n\': '), | ||
}, | ||
(answers) => { | ||
if (answers.confirmation.toLowerCase() === 'n') return callback(); | ||
const options = { | ||
url: VoteBaseUrl, | ||
auth: { | ||
username: 'admin', | ||
password: process.env.PASSWORD, | ||
}, | ||
}; | ||
request.delete(options, (err) => { | ||
if (err) { | ||
this.log(err); | ||
return callback(); | ||
} | ||
this.log(highlight('Successfully deleted all votes.')); | ||
callback(); | ||
}); | ||
}); | ||
}); | ||
cli | ||
.command('updatePollStatus', 'Updates the status of a poll') | ||
@@ -76,3 +158,3 @@ .action(function(args, callback) { | ||
name: 'id', | ||
message: 'Please enter the polls id you want to update: ', | ||
message: highlight('Please enter the polls id you want to update: '), | ||
}, | ||
@@ -82,3 +164,3 @@ { | ||
name: 'pollStatus', | ||
message: 'Please enter the status you want to set: ', | ||
message: highlight('Please enter the status you want to set: '), | ||
}, | ||
@@ -100,3 +182,3 @@ ], (answers) => { | ||
} | ||
this.log('Successfully updated poll.'); | ||
this.log(highlight('Successfully updated poll.')); | ||
callback(); | ||
@@ -114,3 +196,3 @@ }); | ||
name: 'id', | ||
message: 'Please enter the polls id you want to delete: ', | ||
message: highlight('Please enter the polls id you want to delete: '), | ||
}, | ||
@@ -131,3 +213,3 @@ ], (answers) => { | ||
} | ||
this.log('Successfully deleted poll.'); | ||
this.log(highlight('Successfully deleted poll.')); | ||
callback(); | ||
@@ -134,0 +216,0 @@ }); |
{ | ||
"name": "real-votes-admin", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "Admin panel for the real-votes API", | ||
@@ -21,2 +21,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"chalk": "^1.1.3", | ||
"cli-pie": "git+https://github.com/real-votes/node-cli-pie.git", | ||
@@ -23,0 +24,0 @@ "eventsource": "^0.2.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15176
259
7
6
+ Addedchalk@^1.1.3