Permalink
Browse files

Refactor and better print events

  • Loading branch information...
lgaticaq committed May 15, 2016
1 parent 6e8c9ea commit 52361093ad5906c51965210ad9325a6e6e2689b9
Showing with 69 additions and 76 deletions.
  1. +0 −1 .gitignore
  2. +1 −1 .npmignore
  3. +1 −1 .nvmrc
  4. +9 −9 README.md
  5. +10 −24 package.json
  6. +3 −1 src/ascii-logo.js
  7. +14 −11 src/beerjs-events.js
  8. +14 −13 src/beerjs-info.js
  9. +11 −10 src/beerjs-register.js
  10. +6 −5 src/beerjs.js
@@ -25,4 +25,3 @@ build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
lib
@@ -1,3 +1,3 @@
node_modules
src
LICENSE
.*
2 .nvmrc
@@ -1 +1 @@
v5
v6
@@ -25,7 +25,7 @@ beerjs register
## Example
```bash
beerjs info
$ beerjs info
Evento: BeerJS Santiago #9 🍺
Fecha: miércoles 6 de enero 2016
@@ -34,13 +34,13 @@ Direccion: Mariano Sanchez Fontencilla 310 of 1001
Hora: desde 19:30 hrs
Tema: Visualización de datos
Requisito: Traer hambre, sed y buena onda
```
```bash
$ beerjs events 6
beerjs events 6
Edición: 6ª edición: Octubre 2015
Fecha: miércoles 7 octubre 2015
Lugar: Platanus
Tema: Angular y TDD
Expositores: @bunzli
...
┌─────────┬────────────┬──────────┬───────────────┬─────────────┐
│ Edición │ Fecha │ Lugar │ Tema │ Expositores │
├─────────┼────────────┼──────────┼───────────────┼─────────────┤
│ 6ª │ 2015-10-07 │ Platanus │ Angular y TDD │ @bunzli │
└─────────┴────────────┴──────────┴───────────────┴─────────────┘
```
@@ -2,19 +2,15 @@
"name": "beerjs-cli",
"version": "1.3.2",
"description": "Get beerjs info (Chile) CLI",
"main": "lib",
"main": "src",
"scripts": {
"prepublish": "npm run build -s",
"prebuild": "npm run lint -s && npm run clean -s",
"build": "babel src --out-dir lib --source-maps",
"lint": "eslint src",
"clean": "rimraf lib"
"prepublish": "eslint src"
},
"engines": {
"node": ">=0.12"
"node": ">=4"
},
"bin": {
"beerjs": "lib/beerjs.js"
"beerjs": "src/beerjs.js"
},
"preferGlobal": true,
"repository": {
@@ -34,28 +30,23 @@
"homepage": "https://github.com/lgaticaq/beerjs-cli#readme",
"dependencies": {
"beerjs-info": "^2.0.1",
"chalk": "^1.1.3",
"cli-table": "^0.3.1",
"commander": "^2.9.0",
"moment": "^2.13.0",
"node-emoji": "^1.3.0",
"open": "0.0.5",
"open": "^0.0.5",
"update-notifier": "^0.7.0"
},
"devDependencies": {
"babel-cli": "^6.7.7",
"babel-core": "^6.7.7",
"babel-preset-es2015": "^6.6.0",
"eslint": "^2.8.0",
"rimraf": "^2.5.2"
"eslint": "^2.10.1"
},
"eslintConfig": {
"env": {
"es6": true,
"node": true,
"mocha": true
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": [
2,
@@ -77,10 +68,5 @@
0
]
}
},
"babel": {
"presets": [
"es2015"
]
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -2,26 +2,29 @@
'use strict';
import program from 'commander';
import beerjs from 'beerjs-info';
import logo from './ascii-logo';
const program = require('commander');
const beerjs = require('beerjs-info');
const logo = require('./ascii-logo');
const chalk = require('chalk');
const moment = require('moment');
const Table = require('cli-table');
moment.locale('es');
program
.parse(process.argv);
beerjs.getEvents().then((events) => {
console.log(logo);
beerjs.getEvents().then(events => {
console.log(chalk.green(logo));
let _events;
if (program.args.length !== 0) {
_events = events.filter(x => /(\d+)([\w\W\d\s]+)/.exec(x.title)[1] === program.args[0]);
} else {
_events = events;
}
const table = new Table({head: ['Edición', 'Fecha', 'Lugar', 'Tema', 'Expositores']});
for (let event of _events) {
console.log(`Edición: ${event.title}`);
console.log(`Fecha: ${event.date}`);
console.log(`Lugar: ${event.place}`);
console.log(`Tema: ${event.theme}`);
console.log(`Expositores: ${event.expositors}\n`);
const date = moment(event.date, 'dddd D MMMM YYYY').format('YYYY-MM-DD');
table.push([event.title.split(' ')[0], date, event.place, event.theme, event.expositors]);
}
}).catch(() => console.log('Eventos previos no encontrados'));
console.log(chalk.green(table.toString()));
}).catch(() => console.log(chalk.green('Eventos previos no encontrados')));
@@ -2,23 +2,24 @@
'use strict';
import program from 'commander';
import beerjs from 'beerjs-info';
import emoji from 'node-emoji';
import logo from './ascii-logo';
const program = require('commander');
const beerjs = require('beerjs-info');
const emoji = require('node-emoji');
const logo = require('./ascii-logo');
const chalk = require('chalk');
program
.parse(process.argv);
beerjs.getInfo().then((data) => {
console.log(logo);
console.log(`Evento: ${data.evento.replace(':beerjs:', emoji.get('beer'))}`);
console.log(`Fecha: ${data.fecha}`);
console.log(`Donde: ${data.donde}`);
console.log(`Direccion: ${data.direccion}`);
console.log(chalk.green(logo));
console.log(chalk.green(`Evento: ${data.evento.replace(':beerjs:', emoji.get('beer'))}`));
console.log(chalk.green(`Fecha: ${data.fecha}`));
console.log(chalk.green(`Donde: ${data.donde}`));
console.log(chalk.green(`Direccion: ${data.direccion}`));
if (data.hora !== null && data.hora !== undefined && data.hora !== '') {
console.log(`Hora: ${data.hora}`);
console.log(chalk.green(`Hora: ${data.hora}`));
}
console.log(`Tema: ${data.tema}`);
console.log(`Requisito: ${data.requisito}`);
}).catch(() => console.log('Evento no encontrado'));
console.log(chalk.green(`Tema: ${data.tema}`));
console.log(chalk.green(`Requisito: ${data.requisito}`));
}).catch(() => console.log(chalk.green('Evento no encontrado')));
@@ -2,20 +2,21 @@
'use strict';
import program from 'commander';
import beerjs from 'beerjs-info';
import logo from './ascii-logo';
import open from 'open';
const program = require('commander');
const beerjs = require('beerjs-info');
const logo = require('./ascii-logo');
const open = require('open');
const chalk = require('chalk');
program
.parse(process.argv);
beerjs.getRegister().then((data) => {
console.log(logo);
if (data !== null) {
console.log(`Abriendo el enlace ${data} en tu navegador...`);
beerjs.getRegister().then(data => {
console.log(chalk.green(logo));
if (data !== null && data !== undefined) {
console.log(chalk.green(`Abriendo el enlace ${data} en tu navegador...`));
open(data);
} else {
console.log('Lo sentimos, no hay cupos disponibles');
console.log(chalk.green('Lo sentimos, no hay cupos disponibles o aún no esta creado el evento'));
}
}).catch(() => console.log('Evento no encontrado'));
}).catch(() => console.log(chalk.green('Evento no encontrado')));
@@ -2,10 +2,11 @@
'use strict';
import program from 'commander';
import pkg from '../package.json';
import logo from './ascii-logo';
import updateNotifier from 'update-notifier';
const program = require('commander');
const pkg = require('../package.json');
const logo = require('./ascii-logo');
const updateNotifier = require('update-notifier');
const chalk = require('chalk');
updateNotifier({pkg}).notify();
@@ -18,6 +19,6 @@ program
.parse(process.argv);
if (program.args.length === 0) {
console.log(logo);
console.log(chalk.green(logo));
program.help();
}

0 comments on commit 5236109

Please sign in to comment.