Comparing version
11
index.js
#!/usr/bin/env node | ||
const chalk = require('chalk'); | ||
const yargs = require('yargs'); | ||
@@ -8,2 +7,3 @@ | ||
const rocketLaunch = require('./lib/modules/rocketLaunch'); | ||
const info = require('./lib/modules/info'); | ||
@@ -13,3 +13,3 @@ var argv = yargs | ||
.demandCommand(1) | ||
.command('about', 'Info about the CLI', about) | ||
.command('about', 'Info about the CLI', info.about) | ||
.command('next', 'Get next rocket launch', | ||
@@ -23,2 +23,5 @@ function (yargs) { | ||
describe: 'Define time zone for time info e.g. America/New_York, Europe/Paris, Asia/Shanghai' | ||
}).option('lt', { | ||
alias: 'limit', | ||
describe: 'Define amount of upcoming events to show' | ||
}); | ||
@@ -31,5 +34,1 @@ }, | ||
.argv; | ||
function about() { | ||
console.log(chalk.green('Welcome to Space CLI'), '- a CLI for space information' + '\n\n' + 'Credits:' + '\n' + 'https://launchlibrary.net/ - API documentation for upcoming launches'); | ||
} |
const axios = require('axios'); | ||
const chalk = require('chalk'); | ||
const time = require('./time'); | ||
const helpers = require('../helpers'); | ||
exports.nextLaunch = function (argv) { | ||
axios.get('https://launchlibrary.net/1.2/launch/next/1').then((response) => { | ||
let next = response.data.launches[0]; | ||
let launchCount = argv.limit > 1 ? argv.limit : 1; | ||
axios.get('https://launchlibrary.net/1.2/launch/next/' + launchCount).then((response) => { | ||
let nextCount = response.data.launches.length; | ||
let timezone = argv.timezone; | ||
let timezoneError = false; | ||
let title = chalk.yellow('Next launch:') + ' ' + next.id + ' ' + next.name; | ||
let schedule = chalk.cyan('Scheduled launch attempt:') + ' ' + next.net; | ||
for (let i = 0; i < nextCount; i++) { | ||
let next = response.data.launches[i]; | ||
let title = chalk.yellow('Next launch:') + ' ' + next.id + ' ' + next.name; | ||
let schedule = chalk.cyan('Scheduled launch attempt:') + ' ' + next.net; | ||
if (timezone && timezone.length > 0) { | ||
time.convertTimezone(next.net, timezone, function (error, data) { | ||
if (!error) { | ||
schedule = chalk.cyan('Scheduled launch attempt:') + ' ' + data; | ||
return; | ||
} | ||
return console.log(chalk.red(error)); | ||
}); | ||
} | ||
if (timezone && timezone.length > 0 && !timezoneError) { | ||
helpers.convertTimezone(next.net, timezone, function (error, data) { | ||
if (!error) { | ||
schedule = chalk.cyan('Scheduled launch attempt:') + ' ' + data; | ||
return; | ||
} | ||
timezoneError = true; | ||
return helpers.printMessage(chalk.red(error)); | ||
}); | ||
} | ||
if (argv.details) { | ||
let broadcasts = chalk.cyan('Broadcasts:') + ' ' + next.vidURLs; | ||
let rocket = chalk.cyan('Rocket:') + ' ' + next.rocket.name; | ||
let dataBreak; | ||
if (nextCount > 1) { | ||
dataBreak = '\n'; | ||
} | ||
console.log(title + '\n' + schedule + '\n' + broadcasts + '\n' + rocket); | ||
} else { | ||
console.log(title + '\n' + schedule); | ||
if (argv.details) { | ||
let broadcasts = chalk.cyan('Broadcasts:') + ' ' + next.vidURLs; | ||
let rocket = chalk.cyan('Rocket:') + ' ' + next.rocket.name; | ||
helpers.printMessage(title + '\n' + schedule + '\n' + broadcasts + '\n' + rocket + dataBreak); | ||
} else { | ||
helpers.printMessage(title + '\n' + schedule + dataBreak); | ||
} | ||
} | ||
}); | ||
}; |
{ | ||
"name": "space-cli", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "CLI for space information", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"lint": "eslint index.js lib/*", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha ./test/**/*.test.js" | ||
}, | ||
@@ -35,7 +35,12 @@ "keywords": [ | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"eslint": "^3.18.0", | ||
"eslint-config-standard": "^7.1.0", | ||
"eslint-plugin-promise": "^3.5.0", | ||
"eslint-plugin-standard": "^2.1.1" | ||
"eslint-plugin-standard": "^2.1.1", | ||
"mocha": "^3.2.0", | ||
"moxios": "^0.3.0", | ||
"sinon": "^2.1.0", | ||
"sinon-chai": "^2.9.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
5750
16.94%8
14.29%80
29.03%2
-33.33%9
125%