├── README.md ├── questions └── safadao.js ├── package.json ├── main.js └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # Dev-Safadao 2 | Saiba seu nome DevSafadão com esse super cli feito em NodeJS 3 | 4 | > Não é enganação, funciona de verdade, mude sua vida agora mesmo :o 5 | 6 | #Instalação 7 | Você pode obter essa incrível ferramenta através do NPM. 8 | ```bash 9 | $ [sudo] npm i -g devsafadao 10 | ``` 11 | 12 | #Execução 13 | Para utilizar essa maravilha, executar o seguinte comando no seu terminal: 14 | ```bash 15 | $ [sudo] devsafadao 16 | ``` 17 | A incrível ferramenta do DevSafadão vai te fazer umas perguntinhas, e *voilá* :) 18 | -------------------------------------------------------------------------------- /questions/safadao.js: -------------------------------------------------------------------------------- 1 | const questions = [ 2 | { 3 | type: 'input', 4 | name: 'name', 5 | message: 'Qual seu nome?', 6 | default: 'Eliseu' 7 | }, 8 | { 9 | type: 'confirm', 10 | name: 'hasGitHub', 11 | message: 'Você tem github?', 12 | }, 13 | { 14 | when: function (response) { 15 | return response.hasGitHub 16 | }, 17 | type: 'input', 18 | name: 'username', 19 | message: 'Qual seu username?', 20 | validate: function (input) { 21 | if (input && input.length) 22 | return true 23 | 24 | return false 25 | } 26 | }, 27 | { 28 | when: function (response) { 29 | return !response.hasGitHub 30 | }, 31 | type: 'input', 32 | name: 'language', 33 | message: 'Qual sua linguagem favorita?', 34 | } 35 | ] 36 | 37 | module.exports = questions -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "devsafadao", 3 | "version": "1.2.1", 4 | "description": "Descubra seu nome DEVSAFADAO", 5 | "main": "main.js", 6 | "author": "ZeuCxb", 7 | "license": "MIT", 8 | "dependencies": { 9 | "inquirer": "^1.1.0", 10 | "node-fetch": "^1.5.3", 11 | "ora": "^0.2.3" 12 | }, 13 | "devDependencies": {}, 14 | "preferGlobal": true, 15 | "bin": { 16 | "devsafadao": "main.js" 17 | }, 18 | "files": [ 19 | "main.js", 20 | "questions" 21 | ], 22 | "engines": { 23 | "node": ">=4" 24 | }, 25 | "scripts": { 26 | "test": "echo \"Error: no test specified\" && exit 1" 27 | }, 28 | "repository": { 29 | "type": "git", 30 | "url": "git+https://github.com/ZeuCxb/Dev-Safadao.git" 31 | }, 32 | "keywords": [ 33 | "dev", 34 | "safadao", 35 | "js" 36 | ], 37 | "bugs": { 38 | "url": "https://github.com/ZeuCxb/Dev-Safadao/issues" 39 | }, 40 | "homepage": "https://github.com/ZeuCxb/Dev-Safadao#readme" 41 | } 42 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict' 3 | 4 | const inquirer = require('inquirer') 5 | const fetch = require('node-fetch') 6 | const ora = require('ora') 7 | const spinner = ora({ color: 'yellow', text: 'Carregando ...'}) 8 | 9 | var questions = require('./questions/safadao.js') 10 | 11 | inquirer.prompt(questions) 12 | .then((answers) => { 13 | if(answers.hasGitHub) { 14 | let options = { 15 | method: 'GET', 16 | headers: {'User-Agent':'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'} 17 | } 18 | 19 | let url = `https://api.github.com/users/${answers.username}/repos` 20 | 21 | spinner.text = 'Vasculhando seu GitHub...' 22 | spinner.start() 23 | 24 | fetch(url, options).then((res) => { 25 | if (res.status === 404) { 26 | spinner.stop() 27 | console.log('Usuário do Github não encontrado.') 28 | process.exit(1) 29 | } 30 | 31 | return res.json() 32 | }).then((repos) => { 33 | let languages = [] 34 | 35 | spinner.text = 'Verificando seus repositórios...' 36 | repos.map(repo => { 37 | if(repo.language != null) { 38 | if(languages[repo.language]) { 39 | languages[repo.language]++ 40 | } else { 41 | languages[repo.language] = 1 42 | } 43 | } 44 | }) 45 | 46 | spinner.text = 'Ordenando os resultados...' 47 | 48 | let language = Object.keys(languages).sort((a, b) => { 49 | return languages[b] - languages[a] 50 | }) 51 | 52 | spinner.stop() 53 | 54 | console.log('Seu nome de DEVSAFADÃO é:') 55 | console.log(`${answers.name} safadão do ${language[0]}!`) 56 | }) 57 | } else { 58 | spinner.stop() 59 | console.log('Você não é um DEVSAFADÃO.') 60 | console.log(`Mas se fosse, seria: ${answers.name} safadão do ${answers.language}!`) 61 | console.log('P.S: DEVS SAFADÕES, TEM GITHUB.') 62 | } 63 | }) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/linux,node,osx,windows 2 | 3 | ### Linux ### 4 | *~ 5 | 6 | # temporary files which can be created if a process still has a handle open of a deleted file 7 | .fuse_hidden* 8 | 9 | # KDE directory preferences 10 | .directory 11 | 12 | # Linux trash folder which might appear on any partition or disk 13 | .Trash-* 14 | 15 | 16 | ### Node ### 17 | # Logs 18 | logs 19 | *.log 20 | npm-debug.log* 21 | 22 | # Runtime data 23 | pids 24 | *.pid 25 | *.seed 26 | 27 | # Directory for instrumented libs generated by jscoverage/JSCover 28 | lib-cov 29 | 30 | # Coverage directory used by tools like istanbul 31 | coverage 32 | 33 | # nyc test coverage 34 | .nyc_output 35 | 36 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 37 | .grunt 38 | 39 | # node-waf configuration 40 | .lock-wscript 41 | 42 | # Compiled binary addons (http://nodejs.org/api/addons.html) 43 | build/Release 44 | 45 | # Dependency directories 46 | node_modules 47 | jspm_packages 48 | 49 | # Optional npm cache directory 50 | .npm 51 | 52 | # Optional REPL history 53 | .node_repl_history 54 | 55 | 56 | ### OSX ### 57 | *.DS_Store 58 | .AppleDouble 59 | .LSOverride 60 | 61 | # Icon must end with two \r 62 | Icon 63 | 64 | 65 | # Thumbnails 66 | ._* 67 | 68 | # Files that might appear in the root of a volume 69 | .DocumentRevisions-V100 70 | .fseventsd 71 | .Spotlight-V100 72 | .TemporaryItems 73 | .Trashes 74 | .VolumeIcon.icns 75 | .com.apple.timemachine.donotpresent 76 | 77 | # Directories potentially created on remote AFP share 78 | .AppleDB 79 | .AppleDesktop 80 | Network Trash Folder 81 | Temporary Items 82 | .apdisk 83 | 84 | 85 | ### Windows ### 86 | # Windows image file caches 87 | Thumbs.db 88 | ehthumbs.db 89 | 90 | # Folder config file 91 | Desktop.ini 92 | 93 | # Recycle Bin used on file shares 94 | $RECYCLE.BIN/ 95 | 96 | # Windows Installer files 97 | *.cab 98 | *.msi 99 | *.msm 100 | *.msp 101 | 102 | # Windows shortcuts 103 | *.lnk --------------------------------------------------------------------------------