Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flights-search-cli

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flights-search-cli - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

jest.config.js

55

build/executables/flights.js
#!/usr/bin/env node
'use strict';
"use strict";
var _regenerator = require('babel-runtime/regenerator');
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _regenerator2 = _interopRequireDefault(_regenerator);
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _commander = _interopRequireDefault(require("commander"));
var _commander = require('commander');
var _package = _interopRequireDefault(require("../../package.json"));
var _commander2 = _interopRequireDefault(_commander);
var _identifyOptions = _interopRequireDefault(require("../identifyOptions"));
var _package = require('../../package.json');
var _searchFlights = _interopRequireDefault(require("../searchFlights"));
var _package2 = _interopRequireDefault(_package);
_commander["default"].version(_package["default"].version).description('Search flights from the command line');
var _identifyOptions = require('../identifyOptions');
var _identifyOptions2 = _interopRequireDefault(_identifyOptions);
var _searchFlights = require('../searchFlights');
var _searchFlights2 = _interopRequireDefault(_searchFlights);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_commander2.default.version(_package2.default.version).description('Search flights from the command line');
_commander2.default.command('search').description('Search flights').option('-s, --start-airport <iata_code>', 'Starting Airport').option('-e, --end-airport <iata_code>', 'Ending Airport').option('-l, --leaving-between <window>', 'Date(s) or Datetime(s) of departure').option('-r, --returning-between <window>', 'Date(s) or Datetime(s) of return').option('-$, --max-price <usd_amount>', 'Max ticket price (in USD)').option('-d, --direct-flight', 'Only select direct flights').option('-1, --one-way', 'Do not consider return flight').action(function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(command) {
_commander["default"].command('search').description('Search flights').option('-s, --start-airport <iata_code>', 'Starting Airport').option('-e, --end-airport <iata_code>', 'Ending Airport').option('-l, --leaving-between <window>', 'Date(s) or Datetime(s) of departure').option('-r, --returning-between <window>', 'Date(s) or Datetime(s) of return').option('-$, --max-price <usd_amount>', 'Max ticket price (in USD)').option('-d, --direct-flight', 'Only select direct flights').option('-1, --one-way', 'Do not consider return flight').action(
/*#__PURE__*/
function () {
var _ref = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(command) {
var options, _ref2, origin, destination, departureDateTimeRange, returnDateTimeRange, maximumPrice, onlyDirectFlights, onlyOneWay;
return _regenerator2.default.wrap(function _callee$(_context) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {

@@ -43,3 +35,3 @@ switch (_context.prev = _context.next) {

_context.next = 4;
return (0, _identifyOptions2.default)({
return (0, _identifyOptions["default"])({
startAirportOption: options.startAirport,

@@ -64,3 +56,3 @@ endAirportOption: options.endAirport,

_context.next = 14;
return (0, _searchFlights2.default)({
return (0, _searchFlights["default"])({
originOption: origin,

@@ -81,12 +73,11 @@ destinationOption: destination,

_context.prev = 16;
_context.t0 = _context['catch'](0);
_context.t0 = _context["catch"](0);
console.error("Rut ro - there was an error: ".concat(_context.t0)); // eslint-disable-line no-console
console.error('Rut ro - there was an error: ' + _context.t0); // eslint-disable-line no-console
case 19:
case 'end':
case "end":
return _context.stop();
}
}
}, _callee, undefined, [[0, 16]]);
}, _callee, null, [[0, 16]]);
}));

@@ -99,2 +90,2 @@

_commander2.default.parse(process.argv);
_commander["default"].parse(process.argv);

@@ -1,23 +0,26 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = firstMatchingAirport;
var _regenerator = require('babel-runtime/regenerator');
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _skypicker = require("skypicker");
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
function firstMatchingAirport(_x) {
return _firstMatchingAirport.apply(this, arguments);
}
var _skypicker = require('skypicker');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(searchTerm) {
function _firstMatchingAirport() {
_firstMatchingAirport = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(searchTerm) {
var searchResults;
return _regenerator2.default.wrap(function _callee$(_context) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {

@@ -41,20 +44,15 @@ switch (_context.prev = _context.next) {

return _context.abrupt('return', searchResults.locations[0]);
return _context.abrupt("return", searchResults.locations[0]);
case 5:
return _context.abrupt('return', null);
return _context.abrupt("return", null);
case 6:
case 'end':
case "end":
return _context.stop();
}
}
}, _callee, this);
}, _callee);
}));
function firstMatchingAirport(_x) {
return _ref.apply(this, arguments);
}
return firstMatchingAirport;
}();
return _firstMatchingAirport.apply(this, arguments);
}

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = formatDepartureWindow;
exports["default"] = formatDepartureWindow;
function formatDepartureWindow(_ref) {
var start = _ref.start,
end = _ref.end;
return {

@@ -13,0 +13,0 @@ days: {

@@ -1,14 +0,12 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = formatDepartureWindow;
exports["default"] = formatDepartureWindow;
var _momentTimezone = require('moment-timezone');
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
var _momentTimezone2 = _interopRequireDefault(_momentTimezone);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var formatDate = function formatDate(_ref) {

@@ -18,3 +16,3 @@ var date = _ref.date,

year = _ref.year;
return (0, _momentTimezone2.default)().year(year).month(month).date(date).startOf('day').toISOString();
return (0, _momentTimezone["default"])().year(year).month(month).date(date).startOf('day').toISOString();
};

@@ -25,3 +23,3 @@

minute = _ref2.minute;
return (0, _momentTimezone2.default)().hour(hour).minute(minute).format('HH:mm');
return (0, _momentTimezone["default"])().hour(hour).minute(minute).format('HH:mm');
};

@@ -32,3 +30,2 @@

timeOfDay = _ref3.timeOfDay;
return {

@@ -35,0 +32,0 @@ days: {

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,12 +6,7 @@ Object.defineProperty(exports, "__esModule", {

});
exports["default"] = void 0;
var _freeze = require('babel-runtime/core-js/object/freeze');
var _countryCodeEmoji = require("country-code-emoji");
var _freeze2 = _interopRequireDefault(_freeze);
var _countryCodeEmoji = require('country-code-emoji');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var locationTypeEmojis = (0, _freeze2.default)({
var locationTypeEmojis = Object.freeze({
airport: '🛫',

@@ -32,2 +27,3 @@ 'autonomous territory': '📍',

exports.default = formatLocationType;
var _default = formatLocationType;
exports["default"] = _default;

@@ -1,17 +0,14 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _momentTimezone = require('moment-timezone');
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
var _momentTimezone2 = _interopRequireDefault(_momentTimezone);
var _airlineIATAMapping = _interopRequireDefault(require("../airlineIATAMapping"));
var _airlineIATAMapping = require('../airlineIATAMapping');
var _airlineIATAMapping2 = _interopRequireDefault(_airlineIATAMapping);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var formatTrip = function formatTrip(trip) {

@@ -23,26 +20,22 @@ var flyTo = trip.flyTo,

route = trip.route;
var returnDuration = trip.return_duration;
var departureDuration = trip.fly_duration;
var timeFormat = 'ddd, M/D/YY h:mm A'; // TODO @jaebradley change from hard-coded USD price
var timeFormat = 'ddd, M/D/YY h:mm A';
var formattedTripDetails = "".concat(flyFrom, " \u27A1\uFE0F ").concat(flyTo, " | \uD83D\uDCB0 $").concat(price, " | \u2708\uFE0F ").concat(airlines.map(function (airline) {
return _airlineIATAMapping["default"][airline].name;
}).join(' / '));
// TODO @jaebradley change from hard-coded USD price
var formattedTripDetails = flyFrom + ' \u27A1\uFE0F ' + flyTo + ' | \uD83D\uDCB0 $' + price + ' | \u2708\uFE0F ' + airlines.map(function (airline) {
return _airlineIATAMapping2.default[airline].name;
}).join(' / ');
if (route) {
var firstRoute = route[0];
// Skypicker defines the local departure / arrival times in UTC
var firstRoute = route[0]; // Skypicker defines the local departure / arrival times in UTC
// moment automatically converts the UTC timestamp to best-guess local timestamp
// So need to convert "back" to UTC in order to get correct local timestamp
var departureTime = (0, _momentTimezone2.default)(1000 * firstRoute.dTime).tz('GMT').format(timeFormat);
formattedTripDetails = formattedTripDetails + ' | \uD83D\uDEEB ' + departureTime + ' (' + departureDuration + ')';
var departureTime = (0, _momentTimezone["default"])(1000 * firstRoute.dTime).tz('GMT').format(timeFormat);
formattedTripDetails = "".concat(formattedTripDetails, " | \uD83D\uDEEB ").concat(departureTime, " (").concat(departureDuration, ")");
if (route.length > 1 && returnDuration) {
var lastRoute = route[route.length - 1];
var arrivalTime = (0, _momentTimezone2.default)(1000 * lastRoute.aTime).tz('GMT').format(timeFormat);
formattedTripDetails = formattedTripDetails + ' | \uD83D\uDEEC ' + arrivalTime + ' (' + returnDuration + ')';
var arrivalTime = (0, _momentTimezone["default"])(1000 * lastRoute.aTime).tz('GMT').format(timeFormat);
formattedTripDetails = "".concat(formattedTripDetails, " | \uD83D\uDEEC ").concat(arrivalTime, " (").concat(returnDuration, ")");
}

@@ -54,2 +47,3 @@ }

exports.default = formatTrip;
var _default = formatTrip;
exports["default"] = _default;

@@ -1,26 +0,33 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = identifyOptions;
var _promise = require('babel-runtime/core-js/promise');
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _promise2 = _interopRequireDefault(_promise);
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
var _accounting = _interopRequireDefault(require("accounting"));
var _regenerator = require('babel-runtime/regenerator');
var _firstMatchingAirport = _interopRequireDefault(require("./firstMatchingAirport"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _parseDepartureWindow = _interopRequireDefault(require("./parseDepartureWindow"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _formatDepartureWindow = _interopRequireDefault(require("./formatDepartureWindow"));
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
function asyncExecuteSafely(_x) {
return _asyncExecuteSafely.apply(this, arguments);
}
var asyncExecuteSafely = function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(func) {
return _regenerator2.default.wrap(function _callee$(_context) {
function _asyncExecuteSafely() {
_asyncExecuteSafely = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(func) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {

@@ -34,40 +41,19 @@ switch (_context.prev = _context.next) {

case 3:
return _context.abrupt('return', _context.sent);
return _context.abrupt("return", _context.sent);
case 6:
_context.prev = 6;
_context.t0 = _context['catch'](0);
return _context.abrupt('return', null);
_context.t0 = _context["catch"](0);
return _context.abrupt("return", null);
case 9:
case 'end':
case "end":
return _context.stop();
}
}
}, _callee, this, [[0, 6]]);
}, _callee, null, [[0, 6]]);
}));
return _asyncExecuteSafely.apply(this, arguments);
}
return function asyncExecuteSafely(_x) {
return _ref.apply(this, arguments);
};
}();
var _accounting = require('accounting');
var _accounting2 = _interopRequireDefault(_accounting);
var _firstMatchingAirport = require('./firstMatchingAirport');
var _firstMatchingAirport2 = _interopRequireDefault(_firstMatchingAirport);
var _parseDepartureWindow = require('./parseDepartureWindow');
var _parseDepartureWindow2 = _interopRequireDefault(_parseDepartureWindow);
var _formatDepartureWindow = require('./formatDepartureWindow');
var _formatDepartureWindow2 = _interopRequireDefault(_formatDepartureWindow);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function executeSafely(func) {

@@ -81,42 +67,41 @@ try {

exports.default = function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(_ref2) {
var startAirportOption = _ref2.startAirportOption,
endAirportOption = _ref2.endAirportOption,
departureWindowOption = _ref2.departureWindowOption,
returnWindowOption = _ref2.returnWindowOption,
maxPriceOption = _ref2.maxPriceOption,
onlyDirectFlightsOption = _ref2.onlyDirectFlightsOption,
onlyOneWayOption = _ref2.onlyOneWayOption;
function identifyOptions(_x2) {
return _identifyOptions.apply(this, arguments);
}
var _ref4, _ref5, origin, destination, departureDateTimeRange, returnDateTimeRange, maximumPrice, onlyDirectFlights, onlyOneWay;
function _identifyOptions() {
_identifyOptions = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee2(_ref) {
var startAirportOption, endAirportOption, departureWindowOption, returnWindowOption, maxPriceOption, onlyDirectFlightsOption, onlyOneWayOption, _ref2, _ref3, origin, destination, departureDateTimeRange, returnDateTimeRange, maximumPrice, onlyDirectFlights, onlyOneWay;
return _regenerator2.default.wrap(function _callee2$(_context2) {
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return _promise2.default.all([asyncExecuteSafely(function () {
return (0, _firstMatchingAirport2.default)(startAirportOption);
startAirportOption = _ref.startAirportOption, endAirportOption = _ref.endAirportOption, departureWindowOption = _ref.departureWindowOption, returnWindowOption = _ref.returnWindowOption, maxPriceOption = _ref.maxPriceOption, onlyDirectFlightsOption = _ref.onlyDirectFlightsOption, onlyOneWayOption = _ref.onlyOneWayOption;
_context2.next = 3;
return Promise.all([asyncExecuteSafely(function () {
return (0, _firstMatchingAirport["default"])(startAirportOption);
}), asyncExecuteSafely(function () {
return (0, _firstMatchingAirport2.default)(endAirportOption);
return (0, _firstMatchingAirport["default"])(endAirportOption);
})]);
case 2:
_ref4 = _context2.sent;
_ref5 = (0, _slicedToArray3.default)(_ref4, 2);
origin = _ref5[0];
destination = _ref5[1];
case 3:
_ref2 = _context2.sent;
_ref3 = (0, _slicedToArray2["default"])(_ref2, 2);
origin = _ref3[0];
destination = _ref3[1];
departureDateTimeRange = executeSafely(function () {
return (0, _formatDepartureWindow2.default)((0, _parseDepartureWindow2.default)(departureWindowOption));
return (0, _formatDepartureWindow["default"])((0, _parseDepartureWindow["default"])(departureWindowOption));
});
returnDateTimeRange = executeSafely(function () {
return (0, _formatDepartureWindow2.default)((0, _parseDepartureWindow2.default)(returnWindowOption));
return (0, _formatDepartureWindow["default"])((0, _parseDepartureWindow["default"])(returnWindowOption));
});
maximumPrice = executeSafely(function () {
return _accounting2.default.unformat(maxPriceOption);
return _accounting["default"].unformat(maxPriceOption);
});
onlyDirectFlights = !!onlyDirectFlightsOption;
onlyOneWay = !!onlyOneWayOption;
return _context2.abrupt('return', {
return _context2.abrupt("return", {
origin: origin,

@@ -131,15 +116,10 @@ destination: destination,

case 12:
case 'end':
case 13:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}, _callee2);
}));
function identifyOptions(_x2) {
return _ref3.apply(this, arguments);
}
return identifyOptions;
}();
return _identifyOptions.apply(this, arguments);
}

@@ -1,19 +0,14 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = parseDepartureWindow;
var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
exports.default = parseDepartureWindow;
var _momentTimezone = require('moment-timezone');
var _momentTimezone2 = _interopRequireDefault(_momentTimezone);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*

@@ -25,30 +20,41 @@ If single date, use entire day

*/
function parseDepartureWindow(departureWindow) {
var _departureWindow$spli = departureWindow.split('|'),
_departureWindow$spli2 = (0, _slicedToArray3.default)(_departureWindow$spli, 2),
_departureWindow$spli2 = (0, _slicedToArray2["default"])(_departureWindow$spli, 2),
startInput = _departureWindow$spli2[0],
endInput = _departureWindow$spli2[1];
if ((0, _momentTimezone2.default)(startInput, _momentTimezone2.default.HTML5_FMT.DATE).isValid()) {
var start = (0, _momentTimezone2.default)(startInput, _momentTimezone2.default.HTML5_FMT.DATE).startOf('day');
if ((0, _momentTimezone["default"])(startInput, _momentTimezone["default"].HTML5_FMT.DATE).isValid()) {
var start = (0, _momentTimezone["default"])(startInput, _momentTimezone["default"].HTML5_FMT.DATE).startOf('day');
if ((0, _momentTimezone2.default)(endInput, _momentTimezone2.default.HTML5_FMT.DATE).isValid()) {
return { start: start, end: (0, _momentTimezone2.default)(endInput, _momentTimezone2.default.HTML5_FMT.DATE).endOf('day') };
if ((0, _momentTimezone["default"])(endInput, _momentTimezone["default"].HTML5_FMT.DATE).isValid()) {
return {
start: start,
end: (0, _momentTimezone["default"])(endInput, _momentTimezone["default"].HTML5_FMT.DATE).endOf('day')
};
}
return { start: start, end: start.clone().endOf('day') };
return {
start: start,
end: start.clone().endOf('day')
};
}
if ((0, _momentTimezone2.default)(startInput, _momentTimezone2.default.HTML5_FMT.DATETIME_LOCAL).isValid()) {
var _start = (0, _momentTimezone2.default)(startInput, _momentTimezone2.default.HTML5_FMT.DATETIME_LOCAL);
if ((0, _momentTimezone["default"])(startInput, _momentTimezone["default"].HTML5_FMT.DATETIME_LOCAL).isValid()) {
var _start = (0, _momentTimezone["default"])(startInput, _momentTimezone["default"].HTML5_FMT.DATETIME_LOCAL);
if ((0, _momentTimezone2.default)(endInput, _momentTimezone2.default.HTML5_FMT.DATETIME_LOCAL).isValid()) {
return { start: _start, end: (0, _momentTimezone2.default)(endInput, _momentTimezone2.default.HTML5_FMT.DATETIME_LOCAL) };
if ((0, _momentTimezone["default"])(endInput, _momentTimezone["default"].HTML5_FMT.DATETIME_LOCAL).isValid()) {
return {
start: _start,
end: (0, _momentTimezone["default"])(endInput, _momentTimezone["default"].HTML5_FMT.DATETIME_LOCAL)
};
}
return { start: _start, end: _start.clone() };
return {
start: _start,
end: _start.clone()
};
}
throw new Error('Unparseable departure window: ' + departureWindow);
throw new Error("Unparseable departure window: ".concat(departureWindow));
}

@@ -1,61 +0,47 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _promise = require('babel-runtime/core-js/promise');
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _promise2 = _interopRequireDefault(_promise);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _regenerator = require('babel-runtime/regenerator');
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _skypicker = require("skypicker");
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _inquirer = _interopRequireDefault(require("inquirer"));
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _inquirerAutocompletePrompt = _interopRequireDefault(require("inquirer-autocomplete-prompt"));
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _formatLocationType = _interopRequireDefault(require("../formatters/formatLocationType"));
var _createClass2 = require('babel-runtime/helpers/createClass');
_inquirer["default"].registerPrompt('autocomplete', _inquirerAutocompletePrompt["default"]);
var _createClass3 = _interopRequireDefault(_createClass2);
var _skypicker = require('skypicker');
var _inquirer = require('inquirer');
var _inquirer2 = _interopRequireDefault(_inquirer);
var _inquirerAutocompletePrompt = require('inquirer-autocomplete-prompt');
var _inquirerAutocompletePrompt2 = _interopRequireDefault(_inquirerAutocompletePrompt);
var _formatLocationType = require('../formatters/formatLocationType');
var _formatLocationType2 = _interopRequireDefault(_formatLocationType);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_inquirer2.default.registerPrompt('autocomplete', _inquirerAutocompletePrompt2.default);
var LocationSelector = function () {
var LocationSelector =
/*#__PURE__*/
function () {
function LocationSelector() {
(0, _classCallCheck3.default)(this, LocationSelector);
(0, _classCallCheck2["default"])(this, LocationSelector);
this.locations = {};
}
(0, _createClass3.default)(LocationSelector, [{
key: 'select',
(0, _createClass2["default"])(LocationSelector, [{
key: "select",
value: function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(message) {
var _select = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(message) {
var _this = this;
var selection, _locations$selection$, id, code, name;
var selection, _this$locations$selec, id, code, name;
return _regenerator2.default.wrap(function _callee$(_context) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {

@@ -65,3 +51,3 @@ switch (_context.prev = _context.next) {

_context.next = 2;
return _inquirer2.default.prompt([{
return _inquirer["default"].prompt([{
name: 'location',

@@ -77,7 +63,11 @@ type: 'autocomplete',

selection = _context.sent;
_locations$selection$ = this.locations[selection.location], id = _locations$selection$.id, code = _locations$selection$.code, name = _locations$selection$.name;
return _context.abrupt('return', { id: id, code: code, name: name });
_this$locations$selec = this.locations[selection.location], id = _this$locations$selec.id, code = _this$locations$selec.code, name = _this$locations$selec.name;
return _context.abrupt("return", {
id: id,
code: code,
name: name
});
case 5:
case 'end':
case "end":
return _context.stop();

@@ -90,3 +80,3 @@ }

function select(_x) {
return _ref.apply(this, arguments);
return _select.apply(this, arguments);
}

@@ -97,14 +87,19 @@

}, {
key: 'findMatches',
key: "findMatches",
value: function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
var _findMatches = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee2() {
var _this2 = this;
var location = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var searchResults, locationNames;
return _regenerator2.default.wrap(function _callee2$(_context2) {
var location,
searchResults,
locationNames,
_args2 = arguments;
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
location = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : '';
_context2.next = 3;
return (0, _skypicker.searchLocationsByTerm)({

@@ -116,10 +111,9 @@ term: location,

case 2:
case 3:
searchResults = _context2.sent;
locationNames = [];
searchResults.locations.forEach(function (result) {
if (result.active && result.type === 'airport') {
var formattedLocationType = (0, _formatLocationType2.default)(result.type, result.code);
var locationKey = result.name + ' ' + formattedLocationType;
var formattedLocationType = (0, _formatLocationType["default"])(result.type, result.code);
var locationKey = "".concat(result.name, " ").concat(formattedLocationType);
_this2.locations[locationKey] = result;

@@ -129,15 +123,14 @@ locationNames.push(locationKey);

});
return _context2.abrupt("return", Promise.resolve(locationNames));
return _context2.abrupt('return', _promise2.default.resolve(locationNames));
case 6:
case 'end':
case 7:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}, _callee2);
}));
function findMatches() {
return _ref2.apply(this, arguments);
return _findMatches.apply(this, arguments);
}

@@ -151,2 +144,3 @@

exports.default = LocationSelector;
var _default = LocationSelector;
exports["default"] = _default;

@@ -1,45 +0,37 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _regenerator = require('babel-runtime/regenerator');
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _inquirer = _interopRequireDefault(require("inquirer"));
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _inquirerDatepickerPrompt = _interopRequireDefault(require("inquirer-datepicker-prompt"));
var _inquirer = require('inquirer');
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
var _inquirer2 = _interopRequireDefault(_inquirer);
_inquirer["default"].registerPrompt('datetime', _inquirerDatepickerPrompt["default"]);
var _inquirerDatepickerPrompt = require('inquirer-datepicker-prompt');
var selectDate =
/*#__PURE__*/
function () {
var _ref = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(_ref2) {
var message, _ref2$initial, initial, _ref3, date, parsedDate;
var _inquirerDatepickerPrompt2 = _interopRequireDefault(_inquirerDatepickerPrompt);
var _momentTimezone = require('moment-timezone');
var _momentTimezone2 = _interopRequireDefault(_momentTimezone);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_inquirer2.default.registerPrompt('datetime', _inquirerDatepickerPrompt2.default);
var selectDate = function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(_ref) {
var message = _ref.message,
_ref$initial = _ref.initial,
initial = _ref$initial === undefined ? (0, _momentTimezone2.default)() : _ref$initial;
var _ref3, date, parsedDate;
return _regenerator2.default.wrap(function _callee$(_context) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return _inquirer2.default.prompt([{
message = _ref2.message, _ref2$initial = _ref2.initial, initial = _ref2$initial === void 0 ? (0, _momentTimezone["default"])() : _ref2$initial;
_context.next = 3;
return _inquirer["default"].prompt([{
type: 'datetime',

@@ -52,7 +44,7 @@ name: 'date',

case 2:
case 3:
_ref3 = _context.sent;
date = _ref3.date;
parsedDate = (0, _momentTimezone2.default)(date);
return _context.abrupt('return', {
parsedDate = (0, _momentTimezone["default"])(date);
return _context.abrupt("return", {
date: parsedDate.date(),

@@ -63,15 +55,16 @@ month: parsedDate.month(),

case 6:
case 'end':
case 7:
case "end":
return _context.stop();
}
}
}, _callee, undefined);
}, _callee);
}));
return function selectDate(_x) {
return _ref2.apply(this, arguments);
return _ref.apply(this, arguments);
};
}();
exports.default = selectDate;
var _default = selectDate;
exports["default"] = _default;

@@ -1,33 +0,28 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _regenerator = require('babel-runtime/regenerator');
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _selectDate = _interopRequireDefault(require("./selectDate"));
var _momentTimezone = require('moment-timezone');
var _selectTimeOfDay = _interopRequireDefault(require("./selectTimeOfDay"));
var _momentTimezone2 = _interopRequireDefault(_momentTimezone);
var _selectDate = require('./selectDate');
var _selectDate2 = _interopRequireDefault(_selectDate);
var _selectTimeOfDay = require('./selectTimeOfDay');
var _selectTimeOfDay2 = _interopRequireDefault(_selectTimeOfDay);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var selectDepartureWindow = function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
var selectDepartureWindow =
/*#__PURE__*/
function () {
var _ref = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee() {
var departureStartDate, departureEndDate, departureStartTimeOfDay, departureEndTimeOfDay;
return _regenerator2.default.wrap(function _callee$(_context) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {

@@ -37,3 +32,5 @@ switch (_context.prev = _context.next) {

_context.next = 2;
return (0, _selectDate2.default)({ message: 'Start of your departure range window?' });
return (0, _selectDate["default"])({
message: 'Start of your departure range window?'
});

@@ -43,5 +40,5 @@ case 2:

_context.next = 5;
return (0, _selectDate2.default)({
return (0, _selectDate["default"])({
message: 'End of your departure range window?',
initial: (0, _momentTimezone2.default)().year(departureStartDate.year).month(departureStartDate.month).date(departureStartDate.date).startOf('day')
initial: (0, _momentTimezone["default"])().year(departureStartDate.year).month(departureStartDate.month).date(departureStartDate.date).startOf('day')
});

@@ -52,3 +49,5 @@

_context.next = 8;
return (0, _selectTimeOfDay2.default)({ message: 'Start of your departure time of day window?' });
return (0, _selectTimeOfDay["default"])({
message: 'Start of your departure time of day window?'
});

@@ -58,5 +57,5 @@ case 8:

_context.next = 11;
return (0, _selectTimeOfDay2.default)({
return (0, _selectTimeOfDay["default"])({
message: 'End of your departure time of day window?',
initial: (0, _momentTimezone2.default)().endOf('day')
initial: (0, _momentTimezone["default"])().endOf('day')
});

@@ -66,3 +65,3 @@

departureEndTimeOfDay = _context.sent;
return _context.abrupt('return', {
return _context.abrupt("return", {
date: {

@@ -79,7 +78,7 @@ start: departureStartDate,

case 13:
case 'end':
case "end":
return _context.stop();
}
}
}, _callee, undefined);
}, _callee);
}));

@@ -92,2 +91,3 @@

exports.default = selectDepartureWindow;
var _default = selectDepartureWindow;
exports["default"] = _default;

@@ -1,26 +0,25 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _regenerator = require('babel-runtime/regenerator');
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _inquirer = _interopRequireDefault(require("inquirer"));
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _inquirer = require('inquirer');
var _inquirer2 = _interopRequireDefault(_inquirer);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var selectDirectFlightsOnly = function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
var selectDirectFlightsOnly =
/*#__PURE__*/
function () {
var _ref = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee() {
var _ref2, directFlightsOnly;
return _regenerator2.default.wrap(function _callee$(_context) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {

@@ -30,7 +29,7 @@ switch (_context.prev = _context.next) {

_context.next = 2;
return _inquirer2.default.prompt([{
return _inquirer["default"].prompt([{
type: 'confirm',
name: 'directFlightsOnly',
message: 'Select only direct flights?',
default: false
"default": false
}]);

@@ -41,10 +40,10 @@

directFlightsOnly = _ref2.directFlightsOnly;
return _context.abrupt('return', directFlightsOnly);
return _context.abrupt("return", directFlightsOnly);
case 5:
case 'end':
case "end":
return _context.stop();
}
}
}, _callee, undefined);
}, _callee);
}));

@@ -57,2 +56,3 @@

exports.default = selectDirectFlightsOnly;
var _default = selectDirectFlightsOnly;
exports["default"] = _default;

@@ -1,26 +0,25 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _regenerator = require('babel-runtime/regenerator');
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _inquirer = _interopRequireDefault(require("inquirer"));
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _inquirer = require('inquirer');
var _inquirer2 = _interopRequireDefault(_inquirer);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var selectIsRoundTrip = function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
var selectIsRoundTrip =
/*#__PURE__*/
function () {
var _ref = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee() {
var _ref2, isRoundTrip;
return _regenerator2.default.wrap(function _callee$(_context) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {

@@ -30,7 +29,7 @@ switch (_context.prev = _context.next) {

_context.next = 2;
return _inquirer2.default.prompt([{
return _inquirer["default"].prompt([{
type: 'confirm',
name: 'isRoundTrip',
message: 'Is this a round-trip flight?',
default: true
"default": true
}]);

@@ -41,10 +40,10 @@

isRoundTrip = _ref2.isRoundTrip;
return _context.abrupt('return', isRoundTrip);
return _context.abrupt("return", isRoundTrip);
case 5:
case 'end':
case "end":
return _context.stop();
}
}
}, _callee, undefined);
}, _callee);
}));

@@ -57,2 +56,3 @@

exports.default = selectIsRoundTrip;
var _default = selectIsRoundTrip;
exports["default"] = _default;

@@ -1,31 +0,18 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _regenerator = require('babel-runtime/regenerator');
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _inquirer = _interopRequireDefault(require("inquirer"));
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _isFinite = require('babel-runtime/core-js/number/is-finite');
var _isFinite2 = _interopRequireDefault(_isFinite);
var _isNan = require('babel-runtime/core-js/number/is-nan');
var _isNan2 = _interopRequireDefault(_isNan);
var _inquirer = require('inquirer');
var _inquirer2 = _interopRequireDefault(_inquirer);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var isValidPrice = function isValidPrice(price) {
if (!(0, _isNan2.default)(parseFloat(price)) && (0, _isFinite2.default)(parseFloat(price)) && parseFloat(price) > 0) {
if (!Number.isNaN(parseFloat(price)) && Number.isFinite(parseFloat(price)) && parseFloat(price) > 0) {
return true;

@@ -37,7 +24,11 @@ }

var selectMaximumPrice = function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
var selectMaximumPrice =
/*#__PURE__*/
function () {
var _ref = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee() {
var _ref2, maximumPrice;
return _regenerator2.default.wrap(function _callee$(_context) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {

@@ -47,8 +38,9 @@ switch (_context.prev = _context.next) {

_context.next = 2;
return _inquirer2.default.prompt([{
return _inquirer["default"].prompt([{
type: 'input',
name: 'maximumPrice',
message: 'Select maximum price (USD)', // TODO: @jaebradley change hard-coded currency
message: 'Select maximum price (USD)',
// TODO: @jaebradley change hard-coded currency
validate: isValidPrice,
default: 2000
"default": 2000
}]);

@@ -59,10 +51,10 @@

maximumPrice = _ref2.maximumPrice;
return _context.abrupt('return', maximumPrice);
return _context.abrupt("return", maximumPrice);
case 5:
case 'end':
case "end":
return _context.stop();
}
}
}, _callee, undefined);
}, _callee);
}));

@@ -75,2 +67,3 @@

exports.default = selectMaximumPrice;
var _default = selectMaximumPrice;
exports["default"] = _default;

@@ -1,45 +0,37 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _regenerator = require('babel-runtime/regenerator');
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _inquirer = _interopRequireDefault(require("inquirer"));
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _inquirerDatepickerPrompt = _interopRequireDefault(require("inquirer-datepicker-prompt"));
var _inquirer = require('inquirer');
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
var _inquirer2 = _interopRequireDefault(_inquirer);
_inquirer["default"].registerPrompt('datetime', _inquirerDatepickerPrompt["default"]);
var _inquirerDatepickerPrompt = require('inquirer-datepicker-prompt');
var selectTimeOfDay =
/*#__PURE__*/
function () {
var _ref = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(_ref2) {
var message, _ref2$initial, initial, _ref3, timeOfDay, parsedTimeOfDay;
var _inquirerDatepickerPrompt2 = _interopRequireDefault(_inquirerDatepickerPrompt);
var _momentTimezone = require('moment-timezone');
var _momentTimezone2 = _interopRequireDefault(_momentTimezone);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_inquirer2.default.registerPrompt('datetime', _inquirerDatepickerPrompt2.default);
var selectTimeOfDay = function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(_ref) {
var message = _ref.message,
_ref$initial = _ref.initial,
initial = _ref$initial === undefined ? (0, _momentTimezone2.default)().startOf('day') : _ref$initial;
var _ref3, timeOfDay, parsedTimeOfDay;
return _regenerator2.default.wrap(function _callee$(_context) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return _inquirer2.default.prompt([{
message = _ref2.message, _ref2$initial = _ref2.initial, initial = _ref2$initial === void 0 ? (0, _momentTimezone["default"])().startOf('day') : _ref2$initial;
_context.next = 3;
return _inquirer["default"].prompt([{
type: 'datetime',

@@ -52,7 +44,7 @@ name: 'timeOfDay',

case 2:
case 3:
_ref3 = _context.sent;
timeOfDay = _ref3.timeOfDay;
parsedTimeOfDay = (0, _momentTimezone2.default)(timeOfDay);
return _context.abrupt('return', {
parsedTimeOfDay = (0, _momentTimezone["default"])(timeOfDay);
return _context.abrupt("return", {
hour: parsedTimeOfDay.hour(),

@@ -62,15 +54,16 @@ minute: parsedTimeOfDay.minute()

case 6:
case 'end':
case 7:
case "end":
return _context.stop();
}
}
}, _callee, undefined);
}, _callee);
}));
return function selectTimeOfDay(_x) {
return _ref2.apply(this, arguments);
return _ref.apply(this, arguments);
};
}();
exports.default = selectTimeOfDay;
var _default = selectTimeOfDay;
exports["default"] = _default;

@@ -1,86 +0,62 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _regenerator = require('babel-runtime/regenerator');
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _inquirer = _interopRequireDefault(require("inquirer"));
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _skypicker = require("skypicker");
var _inquirer = require('inquirer');
var _open = _interopRequireDefault(require("open"));
var _inquirer2 = _interopRequireDefault(_inquirer);
var _selectDepartureWindow = _interopRequireDefault(require("./prompters/selectDepartureWindow"));
var _skypicker = require('skypicker');
var _selectIsRoundTrip = _interopRequireDefault(require("./prompters/selectIsRoundTrip"));
var _open = require('open');
var _locationSelector = _interopRequireDefault(require("./prompters/locationSelector"));
var _open2 = _interopRequireDefault(_open);
var _selectMaximumPrice = _interopRequireDefault(require("./prompters/selectMaximumPrice"));
var _selectDepartureWindow = require('./prompters/selectDepartureWindow');
var _selectDirectFlightsOnly = _interopRequireDefault(require("./prompters/selectDirectFlightsOnly"));
var _selectDepartureWindow2 = _interopRequireDefault(_selectDepartureWindow);
var _formatTrip = _interopRequireDefault(require("./formatters/formatTrip"));
var _selectIsRoundTrip = require('./prompters/selectIsRoundTrip');
var _formatDepartureWindow = _interopRequireDefault(require("./formatters/formatDepartureWindow"));
var _selectIsRoundTrip2 = _interopRequireDefault(_selectIsRoundTrip);
var searchFlights =
/*#__PURE__*/
function () {
var _ref = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(_ref2) {
var originOption, destinationOption, departureDateTimeRangeOption, returnDateTimeRangeOption, maximumPriceOption, onlyDirectFlightsOption, onlyOneWayOption, locationSelector, origin, destination, isRoundTrip, maximumPrice, onlyDirectFlights, departureDateTimeRange, returnDepartureDateTimeRange, returnDepartureWindow, parameters, searchResults, tripMapping, formattedTrips, _ref3, trip;
var _locationSelector = require('./prompters/locationSelector');
var _locationSelector2 = _interopRequireDefault(_locationSelector);
var _selectMaximumPrice = require('./prompters/selectMaximumPrice');
var _selectMaximumPrice2 = _interopRequireDefault(_selectMaximumPrice);
var _selectDirectFlightsOnly = require('./prompters/selectDirectFlightsOnly');
var _selectDirectFlightsOnly2 = _interopRequireDefault(_selectDirectFlightsOnly);
var _formatTrip = require('./formatters/formatTrip');
var _formatTrip2 = _interopRequireDefault(_formatTrip);
var _formatDepartureWindow = require('./formatters/formatDepartureWindow');
var _formatDepartureWindow2 = _interopRequireDefault(_formatDepartureWindow);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var searchFlights = function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(_ref) {
var originOption = _ref.originOption,
destinationOption = _ref.destinationOption,
departureDateTimeRangeOption = _ref.departureDateTimeRangeOption,
returnDateTimeRangeOption = _ref.returnDateTimeRangeOption,
maximumPriceOption = _ref.maximumPriceOption,
onlyDirectFlightsOption = _ref.onlyDirectFlightsOption,
onlyOneWayOption = _ref.onlyOneWayOption;
var locationSelector, origin, destination, isRoundTrip, maximumPrice, onlyDirectFlights, departureDateTimeRange, returnDepartureDateTimeRange, returnDepartureWindow, parameters, searchResults, tripMapping, formattedTrips, _ref3, trip;
return _regenerator2.default.wrap(function _callee$(_context) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
locationSelector = new _locationSelector2.default();
originOption = _ref2.originOption, destinationOption = _ref2.destinationOption, departureDateTimeRangeOption = _ref2.departureDateTimeRangeOption, returnDateTimeRangeOption = _ref2.returnDateTimeRangeOption, maximumPriceOption = _ref2.maximumPriceOption, onlyDirectFlightsOption = _ref2.onlyDirectFlightsOption, onlyOneWayOption = _ref2.onlyOneWayOption;
locationSelector = new _locationSelector["default"]();
_context.t0 = originOption;
if (_context.t0) {
_context.next = 6;
_context.next = 7;
break;
}
_context.next = 5;
_context.next = 6;
return locationSelector.select('Select origin');
case 5:
case 6:
_context.t0 = _context.sent;
case 6:
case 7:
origin = _context.t0;

@@ -90,15 +66,14 @@ _context.t1 = destinationOption;

if (_context.t1) {
_context.next = 12;
_context.next = 13;
break;
}
_context.next = 11;
_context.next = 12;
return locationSelector.select('Select destination');
case 11:
case 12:
_context.t1 = _context.sent;
case 12:
case 13:
destination = _context.t1;
isRoundTrip = void 0;

@@ -126,3 +101,3 @@ if (!returnDateTimeRangeOption) {

_context.next = 24;
return (0, _selectIsRoundTrip2.default)();
return (0, _selectIsRoundTrip["default"])();

@@ -141,3 +116,3 @@ case 24:

_context.next = 29;
return (0, _selectMaximumPrice2.default)();
return (0, _selectMaximumPrice["default"])();

@@ -157,3 +132,3 @@ case 29:

_context.next = 35;
return (0, _selectDirectFlightsOnly2.default)();
return (0, _selectDirectFlightsOnly["default"])();

@@ -172,5 +147,5 @@ case 35:

_context.t5 = _formatDepartureWindow2.default;
_context.t5 = _formatDepartureWindow["default"];
_context.next = 42;
return (0, _selectDepartureWindow2.default)();
return (0, _selectDepartureWindow["default"])();

@@ -183,6 +158,5 @@ case 42:

departureDateTimeRange = _context.t4;
returnDepartureDateTimeRange = void 0;
if (!isRoundTrip) {
_context.next = 55;
_context.next = 54;
break;

@@ -192,3 +166,3 @@ }

if (!returnDateTimeRangeOption) {
_context.next = 51;
_context.next = 50;
break;

@@ -198,15 +172,14 @@ }

returnDepartureDateTimeRange = returnDateTimeRangeOption;
_context.next = 55;
_context.next = 54;
break;
case 51:
_context.next = 53;
return (0, _selectDepartureWindow2.default)();
case 50:
_context.next = 52;
return (0, _selectDepartureWindow["default"])();
case 53:
case 52:
returnDepartureWindow = _context.sent;
returnDepartureDateTimeRange = (0, _formatDepartureWindow["default"])(returnDepartureWindow);
returnDepartureDateTimeRange = (0, _formatDepartureWindow2.default)(returnDepartureWindow);
case 55:
case 54:
parameters = {

@@ -221,3 +194,4 @@ departureIdentifier: origin.id,

},
currencyCode: 'USD', // TODO @jaebradley: change from hard-coded value
currencyCode: 'USD',
// TODO @jaebradley: change from hard-coded value
partner: 'picky',

@@ -227,18 +201,16 @@ directFlightsOnly: onlyDirectFlights,

};
_context.next = 58;
_context.next = 57;
return (0, _skypicker.searchFlights)(parameters);
case 58:
case 57:
searchResults = _context.sent;
tripMapping = {};
formattedTrips = [];
searchResults.data.forEach(function (result) {
var formattedTrip = (0, _formatTrip2.default)(result);
var formattedTrip = (0, _formatTrip["default"])(result);
tripMapping[formattedTrip] = result.deep_link;
formattedTrips.push(formattedTrip);
});
_context.next = 64;
return _inquirer2.default.prompt([{
_context.next = 63;
return _inquirer["default"].prompt([{
type: 'list',

@@ -250,22 +222,21 @@ name: 'trip',

case 64:
case 63:
_ref3 = _context.sent;
trip = _ref3.trip;
(0, _open["default"])(tripMapping[trip]);
(0, _open2.default)(tripMapping[trip]);
case 67:
case 'end':
case 66:
case "end":
return _context.stop();
}
}
}, _callee, undefined);
}, _callee);
}));
return function searchFlights(_x) {
return _ref2.apply(this, arguments);
return _ref.apply(this, arguments);
};
}();
exports.default = searchFlights;
var _default = searchFlights;
exports["default"] = _default;
{
"name": "flights-search-cli",
"version": "1.1.0",
"version": "1.1.1",
"description": "Search Flights From Your Terminal",

@@ -10,11 +10,11 @@ "main": "index.js",

"scripts": {
"codecov": "codecov",
"compile": "babel -d build/ src/ --ignore node_modules,*.test.js",
"lint": "eslint --ext .js .",
"lint-commit-message": "./node_modules/.bin/commitlint --edit $HUSKY_GIT_PARAMS",
"test": "jest --coverage --passWithNoTests",
"codecov": "npx codecov",
"compile": "npx babel -d build/ src/",
"lint": "npx eslint --ext .js .",
"lint-commit-message": "npx commitlint --edit $HUSKY_GIT_PARAMS",
"test": "npx jest --passWithNoTests",
"prepublishOnly": "npm run compile",
"gc": "commit",
"semantic-release": "semantic-release",
"travis-deploy-once": "travis-deploy-once"
"gc": "npx commit",
"semantic-release": "npx semantic-release",
"travis-deploy-once": "npx travis-deploy-once"
},

@@ -35,36 +35,34 @@ "repository": {

"homepage": "https://github.com/jaebradley/flights-search-cli#readme",
"jest": {
"testEnvironment": "node"
},
"devDependencies": {
"@commitlint/cli": "^8.1.0",
"@commitlint/config-angular": "^8.1.0",
"@commitlint/prompt": "^8.1.0",
"@commitlint/prompt-cli": "^8.1.0",
"@commitlint/travis-cli": "^8.2.0",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"codecov": "^3.0.0",
"eslint": "^6.3.0",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-angular": "^8.3.4",
"@commitlint/prompt": "^8.3.5",
"@commitlint/prompt-cli": "^8.3.5",
"@commitlint/travis-cli": "^8.3.5",
"codecov": "^3.6.5",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.18.2",
"husky": "^3.0.5",
"jest": "^24.9.0",
"semantic-release": "^15.6.0",
"travis-deploy-once": "^5.0.0"
"eslint-plugin-import": "^2.20.1",
"husky": "^4.2.3",
"jest": "^25.1.0",
"semantic-release": "^17.0.3",
"travis-deploy-once": "^5.0.11"
},
"dependencies": {
"accounting": "^0.4.1",
"babel-plugin-transform-runtime": "^6.23.0",
"chalk": "^2.3.1",
"commander": "^3.0.1",
"@babel/plugin-transform-runtime": "^7.8.3",
"chalk": "^3.0.0",
"commander": "^4.1.1",
"country-code-emoji": "1.0.0",
"fuzzy": "^0.1.3",
"inquirer": "^7.0.0",
"inquirer-autocomplete-prompt": "^1.0.0",
"inquirer": "^6.5.2",
"inquirer-autocomplete-prompt": "^1.0.2",
"inquirer-datepicker-prompt": "^0.4.2",
"moment-timezone": "^0.5.14",
"open": "6.4.0",
"moment-timezone": "^0.5.27",
"open": "7.0.2",
"skypicker": "^1.0.3"
}
}

@@ -5,4 +5,7 @@ # flights-search-cli

[![Build Status](https://travis-ci.org/jaebradley/flights-search-cli.svg?branch=master)](https://travis-ci.org/jaebradley/flights-search-cli)
[![codecov](https://codecov.io/gh/jaebradley/flights-search-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/jaebradley/flights-search-cli)
[![npm](https://img.shields.io/npm/v/flights-search-cli.svg)](https://www.npmjs.com/package/flights-search-cli)
[![npm](https://img.shields.io/npm/dt/flights-search-cli.svg)](https://www.npmjs.com/package/flights-search-cli)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/flights-search-cli)
[![npm-total-downloads](https://img.shields.io/npm/dt/flights-search-cli.svg)](https://www.npmjs.com/package/flights-search-cli)
![GitHub](https://img.shields.io/github/license/jaebradley/flights-search-cli)

@@ -9,0 +12,0 @@ ![alt-text](https://imgur.com/54yeBhy.png)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc