Comparing version 0.0.3 to 0.0.4
@@ -1,3 +0,128 @@ | ||
export declare const findByGlass: (input: string) => any; | ||
export declare const findByGlass: (input: string) => string | ({ | ||
name: string; | ||
glass: string; | ||
ingredients: ({ | ||
unit: string; | ||
amount: number; | ||
ingredient: string; | ||
label?: undefined; | ||
special?: undefined; | ||
} | { | ||
unit: string; | ||
amount: number; | ||
ingredient: string; | ||
label: string; | ||
special?: undefined; | ||
} | { | ||
special: string; | ||
unit?: undefined; | ||
amount?: undefined; | ||
ingredient?: undefined; | ||
label?: undefined; | ||
})[]; | ||
preparation: string; | ||
category?: undefined; | ||
garnish?: undefined; | ||
} | { | ||
name: string; | ||
glass: string; | ||
category: string; | ||
ingredients: ({ | ||
unit: string; | ||
amount: number; | ||
ingredient: string; | ||
label: string; | ||
special?: undefined; | ||
} | { | ||
unit: string; | ||
amount: number; | ||
ingredient: string; | ||
label?: undefined; | ||
special?: undefined; | ||
} | { | ||
special: string; | ||
unit?: undefined; | ||
amount?: undefined; | ||
ingredient?: undefined; | ||
label?: undefined; | ||
})[]; | ||
garnish: string; | ||
preparation: string; | ||
} | { | ||
name: string; | ||
glass: string; | ||
category: string; | ||
ingredients: ({ | ||
unit: string; | ||
amount: number; | ||
ingredient: string; | ||
label?: undefined; | ||
special?: undefined; | ||
} | { | ||
unit: string; | ||
amount: number; | ||
ingredient: string; | ||
label: string; | ||
special?: undefined; | ||
} | { | ||
special: string; | ||
unit?: undefined; | ||
amount?: undefined; | ||
ingredient?: undefined; | ||
label?: undefined; | ||
})[]; | ||
preparation: string; | ||
garnish?: undefined; | ||
} | { | ||
name: string; | ||
glass: string; | ||
category: string; | ||
ingredients: ({ | ||
unit: string; | ||
amount: number; | ||
ingredient: string; | ||
label: string; | ||
special?: undefined; | ||
} | { | ||
unit: string; | ||
amount: number; | ||
ingredient: string; | ||
label?: undefined; | ||
special?: undefined; | ||
} | { | ||
special: string; | ||
unit?: undefined; | ||
amount?: undefined; | ||
ingredient?: undefined; | ||
label?: undefined; | ||
})[]; | ||
preparation?: undefined; | ||
garnish?: undefined; | ||
} | { | ||
name: string; | ||
glass: string; | ||
ingredients: ({ | ||
unit: string; | ||
amount: number; | ||
ingredient: string; | ||
label: string; | ||
special?: undefined; | ||
} | { | ||
unit: string; | ||
amount: number; | ||
ingredient: string; | ||
label?: undefined; | ||
special?: undefined; | ||
} | { | ||
special: string; | ||
unit?: undefined; | ||
amount?: undefined; | ||
ingredient?: undefined; | ||
label?: undefined; | ||
})[]; | ||
garnish: string; | ||
preparation: string; | ||
category?: undefined; | ||
})[]; | ||
export declare const findByLiquor: (input: string) => string | string[]; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.findByLiquor = exports.findByGlass = void 0; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const cocktails_1 = require("../cocktails"); | ||
const logUtils_1 = require("../utils/logUtils"); | ||
const utils_1 = require("../utils/utils"); | ||
const log = console.log; | ||
const prefix = 'You need to supply a type of'; | ||
@@ -17,7 +13,7 @@ // todo fix any | ||
if (drinks.length) { | ||
log(`${chalk_1.default.magenta.bold("Here are all the drinks you can make with a " + input + " glass")}`); | ||
drinks.map(x => log(`${utils_1.spacer}${x.name}`)); | ||
logUtils_1.logTitle(`Here are all the drinks you can make with a ${input} glass`); | ||
drinks.map(x => logUtils_1.logBody(x.name)); | ||
} | ||
else { | ||
log(`${chalk_1.default.magenta.bold("No drinks found using a " + input + " glass")}`); | ||
logUtils_1.logTitle(`No drinks found using a ${input} glass`); | ||
} | ||
@@ -28,3 +24,3 @@ return drinks; | ||
const errorString = `${prefix} glass!`; | ||
log(errorString); | ||
logUtils_1.log(errorString); | ||
return errorString; | ||
@@ -36,3 +32,3 @@ } | ||
if (input) { | ||
let drinkArray = []; | ||
const drinkArray = []; | ||
// Check the entire list of ingredients (normalized) and push to new array if found | ||
@@ -43,6 +39,6 @@ cocktails_1.data.map(drink => { var _a; return (_a = drink.ingredients) === null || _a === void 0 ? void 0 : _a.map(ingredientList => ingredientList.ingredient && (utils_1.normalizeLiquor(ingredientList.ingredient) === utils_1.normalizeLiquor(input)) && drinkArray.push(drink.name)); }); | ||
if (drinkArray.length) { | ||
dedeupeDrinkArray.map(drink => log(drink)); | ||
dedeupeDrinkArray.map(drink => logUtils_1.log(drink)); | ||
} | ||
else { | ||
log('No drinks found'); | ||
logUtils_1.log('No drinks found'); | ||
} | ||
@@ -53,3 +49,3 @@ return dedeupeDrinkArray; | ||
const errorString = `${prefix} liquor!`; | ||
log(errorString); | ||
logUtils_1.log(errorString); | ||
return errorString; | ||
@@ -56,0 +52,0 @@ } |
@@ -44,3 +44,3 @@ #!/usr/bin/env node | ||
if (argv.r) { | ||
make_1.makeRandom(); | ||
make_1.makeByRandom(); | ||
} | ||
@@ -47,0 +47,0 @@ else { |
#!/usr/bin/env node | ||
export declare const makeByName: (input: string) => any; | ||
export declare const makeRandom: () => any; | ||
export declare const makeByRandom: () => any; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,7 +7,7 @@ #!/usr/bin/env node | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.makeRandom = exports.makeByName = void 0; | ||
exports.makeByRandom = exports.makeByName = void 0; | ||
const cocktails_1 = require("../cocktails"); | ||
const output_1 = __importDefault(require("./output")); | ||
const utils_1 = require("../utils/utils"); | ||
const log = console.log; | ||
const logUtils_1 = require("../utils/logUtils"); | ||
// todo fix any | ||
@@ -23,3 +23,3 @@ const makeByName = (input) => { | ||
const errorString = "I don't know that one 😭"; | ||
log(errorString); | ||
logUtils_1.log(errorString); | ||
return (errorString); | ||
@@ -30,10 +30,10 @@ } | ||
// todo fix any | ||
const makeRandom = () => { | ||
const makeByRandom = () => { | ||
const drinkInput = utils_1.getRandomInt(cocktails_1.data.length); | ||
const recipe = cocktails_1.data[drinkInput]; | ||
log('Picking a random cocktail for you!'); | ||
logUtils_1.log('✨ Picking a random cocktail for you! ✨'); | ||
output_1.default(recipe); | ||
return recipe; | ||
}; | ||
exports.makeRandom = makeRandom; | ||
exports.makeByRandom = makeByRandom; | ||
//# sourceMappingURL=index.js.map |
@@ -16,4 +16,4 @@ export interface Result { | ||
} | ||
declare const logOutput: (result: Result) => (string | string[])[]; | ||
export default logOutput; | ||
declare const logMakeOutput: (result: Result) => (string | string[])[]; | ||
export default logMakeOutput; | ||
//# sourceMappingURL=output.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const utils_1 = require("../utils/utils"); | ||
const log = console.log; | ||
const logOutput = (result) => { | ||
const logUtils_1 = require("../utils/logUtils"); | ||
const logMakeOutput = (result) => { | ||
var _a, _b; | ||
@@ -15,14 +10,14 @@ const outputArray = []; | ||
const drinkName = `Here's how you make a ${result.name}`; | ||
log(`${chalk_1.default.magenta.bold(drinkName)}`); | ||
logUtils_1.logTitle(drinkName); | ||
outputArray.push(drinkName); | ||
// Glass | ||
const glassType = `Glassware: ${result.glass}`; | ||
log(glassType); | ||
logUtils_1.log(glassType); | ||
outputArray.push(glassType); | ||
// List ingredients | ||
log('Mix together:'); | ||
logUtils_1.log('Mix together:'); | ||
(_a = result.ingredients) === null || _a === void 0 ? void 0 : _a.map(x => { | ||
if (x.unit) { | ||
const ingredient = `${x.amount}${x.unit} of ${x.label || x.ingredient}`; | ||
console.log(`${utils_1.spacer}${ingredient}`); | ||
logUtils_1.logBody(ingredient); | ||
ingredientsArray.push(ingredient); | ||
@@ -32,3 +27,3 @@ } | ||
const special = x.special; | ||
log(`${utils_1.spacer}${special}`); | ||
logUtils_1.logBody(special); | ||
ingredientsArray.push(special); | ||
@@ -40,15 +35,15 @@ } | ||
const prep = `${result.preparation}`; | ||
log(prep); | ||
logUtils_1.log(prep); | ||
outputArray.push(prep); | ||
// Garnish | ||
const garnish = `Garnish: ${(_b = result.garnish) === null || _b === void 0 ? void 0 : _b.toLowerCase()}`; | ||
result.garnish && log(garnish); | ||
result.garnish && logUtils_1.log(garnish); | ||
outputArray.push(garnish); | ||
// Finish | ||
const finish = 'Drink up 🥃'; | ||
log(finish); | ||
logUtils_1.log(finish); | ||
outputArray.push(finish); | ||
return outputArray; | ||
}; | ||
exports.default = logOutput; | ||
exports.default = logMakeOutput; | ||
//# sourceMappingURL=output.js.map |
export declare const getRandomInt: (max: number) => number; | ||
export declare const spacer = " - "; | ||
export declare const getCocktailName: (input: any) => string; | ||
export declare const normalizeLiquor: (input: string) => string; | ||
//# sourceMappingURL=utils.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.normalizeLiquor = exports.getCocktailName = exports.spacer = exports.getRandomInt = void 0; | ||
exports.normalizeLiquor = exports.getCocktailName = exports.getRandomInt = void 0; | ||
const getRandomInt = (max) => { | ||
@@ -8,3 +8,2 @@ return Math.floor(Math.random() * Math.floor(max)); | ||
exports.getRandomInt = getRandomInt; | ||
exports.spacer = ' - '; | ||
// todo fix any | ||
@@ -20,7 +19,4 @@ const getCocktailName = (input) => { | ||
exports.getCocktailName = getCocktailName; | ||
// TODO: | ||
// all rums return rum | ||
// whiskey || whiskey returns whiskey | ||
const normalizeLiquor = (input) => { | ||
let drinkInput = input.toLowerCase(); | ||
const drinkInput = input.toLowerCase(); | ||
let normalized; | ||
@@ -27,0 +23,0 @@ if (drinkInput === 'whisky' || drinkInput === 'whiskey') { |
{ | ||
"name": "barcart", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "find cocktails based on what you have", | ||
@@ -5,0 +5,0 @@ "main": "cli.js", |
@@ -11,6 +11,34 @@ # barcart | ||
## commands | ||
* barcat make {drinkName} | ||
* barcart make -r | ||
* barcart find -g {glassware} | ||
* barcart find -l {liquor} (WIP) | ||
## CLI commands | ||
### Make | ||
* List instructions based on a drink name: `barcart make ${drinkName}` | ||
* List instructions for random drinks: `barcart make -r` | ||
### Find | ||
* List drinks based on glassware: `barcart find -g ${glassware}` | ||
* List drinks based on liquor: `barcart find -l ${liquor}` | ||
#### Notes: | ||
Liquors are normalized, this means that: | ||
* "whisky" and "whiskey" are considerd the same thing when searching | ||
* "white rum", "black rum", etc. are considered the same thing when searching | ||
## Usage | ||
### Make | ||
```js | ||
import { makeByName, makeByRandom } from 'barcart/lib/make'; | ||
const foo = makeByName('manhattan'); | ||
const bar = makeByRandom(); | ||
``` | ||
### Find | ||
```js | ||
import { findByGlass, findByLiquor } from 'barcart/lib/find'; | ||
const foo = findByGlass('martini'); | ||
const bar = findByLiquor('rum'); | ||
``` |
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 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 not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
105842
34
1825
43