Skip to content

Commit

Permalink
Add paid choice and update dependencies 📝
Browse files Browse the repository at this point in the history
  • Loading branch information
welksonramos committed Feb 2, 2018
1 parent e7ab4d9 commit d21d482
Show file tree
Hide file tree
Showing 6 changed files with 4,788 additions and 68 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [0.6.2] - 2018-01-02

## Added

- Paid choice in template

## Fixed

- Fix fs callback in awesome-br.js
- Update dependencies

## [0.6.1] - 2016-07-01

## Fixed
Expand Down
11 changes: 7 additions & 4 deletions lib/awesome-br.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const updateNotifier = require('update-notifier');
const pkg = require('../package.json');

// Checa se existe atualizações disponiveis
updateNotifier({pkg}).notify();
updateNotifier({ pkg }).notify();

const currentDir = process.cwd();
const filePath = `${currentDir}/sections/${args}.json`;

const fileExists = pathExists.sync(filePath);

function help(){
function help() {
process.stdout.write(`
Usage:
awesome-br <section> [Options]
Expand All @@ -46,8 +46,11 @@ if (args.indexOf('-V') !== -1 || args.indexOf('--version') !== -1) {

inquirer.prompt(questions).then(answers => {
if (!fileExists) {
fs.writeFile(filePath, `[${JSON.stringify(sectionTemplate(answers), null, 2)}]`);
console.log('✔ Arquivo gerado com sucesso!');
fs.writeFile(filePath, `[${JSON.stringify(sectionTemplate(answers), null, 2)}]`, err => {
if (err) throw err;
console.log('✔ Arquivo gerado com sucesso!');
});

} else {
updateFile(sectionTemplate(answers));
}
Expand Down
106 changes: 56 additions & 50 deletions lib/questions.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,61 @@
'use strict';

module.exports = [
{
name: "title",
type: "input",
message: "Título:"
}, {
name: "url",
type: "input",
message: "URL:"
}, {
name: "type",
type: "list",
message: "Tipo:",
choices : [
"artigo",
"apostila",
"curso",
"dica",
"documentação",
"guia",
"hangout",
"livro",
"pacote",
"palestra",
"screencast",
"site",
"slide",
"slideshare",
"styleguide",
"tutorial",
"url",
"vídeo"
], filter: function (str){
return str.toLowerCase();
{
name: "title",
type: "input",
message: "Título:"
}, {
name: "url",
type: "input",
message: "URL:"
}, {
name: "type",
type: "list",
message: "Tipo:",
choices: [
"apostila",
"artigo",
"curso",
"dica",
"documentação",
"guia",
"hangout",
"livro",
"pacote",
"palestra",
"screencast",
"site",
"slide",
"slideshare",
"styleguide",
"tutorial",
"url",
"vídeo"
], filter: function (str) {
return str.toLowerCase();
}
}, {
name: "tags",
type: "input",
message: "Tags (separadas por vírgulas):"
}, {
name: "authorName",
type: "input",
message: "Nome do Autor:"
}, {
name: "paid",
type: "confirm",
message: "Conteúdo pago?",
default: false
},
{
name: "authorUrl",
type: "input",
message: "URL do site do Autor:"
}, {
name: "isOk",
type: "confirm",
message: "Todos os dados estão corretos?"
}
}, {
name:"tags",
type:"input",
message: "Tags (separadas por vírgulas):"
}, {
name:"authorName",
type: "input",
message: "Nome do Autor:"
}, {
name: "authorUrl",
type: "input",
message: "URL do site do Autor:"
}, {
name:"isOk",
type:"confirm",
message:"Todos os dados estão corretos?"
}
];
17 changes: 9 additions & 8 deletions lib/template.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module.exports = sectionTemplate = answers => {
return {
'name': `${answers.title}`,
'url': `${answers.url}`,
'type': `${answers.type}`,
'tags': [`${answers.tags}`.split(',')],
'author': {
'name': `${answers.authorName}`,
'url': `${answers.authorUrl}`
}
'url': `${answers.url}`,
'type': `${answers.type}`,
'tags': [`${answers.tags}`.split(',')],
'paid': `${answers.paid}`,
'author': {
'name': `${answers.authorName}`,
'url': `${answers.authorUrl}`
}
}
}
}
Loading

0 comments on commit d21d482

Please sign in to comment.