├── LICENSE.md ├── README.md ├── index.js ├── npm-debug.log ├── package.json ├── screenshots ├── screen1.png └── screen2.png └── search.js /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Akashdeep Goel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Package Hunt 2 | =========== 3 | 4 | A simple NodeJS application to search for the packages/libraries that you might need for your projects. 5 | 6 | 7 | Install 8 | -------- 9 | A stable version can be downloaded directly using npm: 10 | ``` 11 | npm install packagehunt 12 | ``` 13 | 14 | 15 | To obtain the latest version, follow the following steps- 16 | ``` 17 | 1 - git clone https://github.com/akashdeepgoel/Package-Hunt 18 | 2 - cd Package-Hunt/ 19 | 3 - npm install 20 | ``` 21 | 22 | Usage 23 | ------- 24 | If you have downloaded via npm, simply type ``` packagehunt``` in terminal or use ``` node index.js ```. 25 | 26 | 27 | Screenshots 28 | ------- 29 | 30 | ![Search with condition on stars](/screenshots/screen1.png?raw=true "") 31 | 32 | ![Search without condition](/screenshots/screen2.png?raw=true "") 33 | 34 | ## Thanks. Hope you enjoy. 35 | 36 | 37 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | //Starting point of App 2 | //Takes User Input as Requirements and sends it to Search.js 3 | var prompt = require('prompt'); 4 | var prompt1 = require('prompt'); 5 | var search = require('./search.js'); 6 | var prompt2 = require('prompt'); 7 | var prompt3 = require('prompt'); 8 | prompt.start(); 9 | console.log("****App Started****\n"); 10 | console.log("Please Give Valid Inputs as This will help in getting Better Results\n"); 11 | console.log("Please enter Your requirements Separated by Comma(,)\n"); 12 | prompt.get(['requirements'], function (err, result) { 13 | if (err) { return onErr(err); } 14 | else 15 | { 16 | var req = result.requirements; 17 | req = req.split(","); 18 | console.log("Received Inputs..Would you like to have some Github stars Preference ?..(Y/n)\n"); 19 | prompt1.start(); 20 | prompt1.get(['response'], function (err, resp) { 21 | if(err) { return onErr(err);} 22 | else 23 | { 24 | var ans = resp.response; 25 | if(ans=="n") 26 | { 27 | var language; 28 | console.log("Specify the name of Language\n"); 29 | prompt3.start(); 30 | prompt3.get(['lan'],function (err,langu) { 31 | if(err) { return onErr(err);} 32 | else 33 | { 34 | language = langu.lan; 35 | var sent = "N"; 36 | var app = new search(req,sent,language); 37 | app.run(); 38 | } 39 | }); 40 | 41 | } 42 | else 43 | { 44 | console.log("Enter the Minimum Number of Stars you prefer.\n"); 45 | prompt2.start(); 46 | prompt2.get(['stars'],function (err, star) { 47 | if(err) { return onErr(err);} 48 | else 49 | { 50 | var langreq; 51 | console.log("Specify the name of Language\n"); 52 | prompt3.start(); 53 | prompt3.get(['lan'],function (err,langu) { 54 | if(err) { return onErr(err); } 55 | else 56 | { 57 | langreq = langu.lan; 58 | var starcount = star.stars; 59 | var app = new search(req,starcount,langreq); 60 | app.run(); 61 | } 62 | }); 63 | 64 | } 65 | }); 66 | } 67 | } 68 | }); 69 | } 70 | 71 | }); 72 | function onErr(err) { 73 | console.log(err); 74 | return 1; 75 | } -------------------------------------------------------------------------------- /npm-debug.log: -------------------------------------------------------------------------------- 1 | 0 info it worked if it ends with ok 2 | 1 verbose cli [ '/home/akashdeep/.nvm/v0.10.36/bin/node', 3 | 1 verbose cli '/home/akashdeep/.nvm/v0.10.36/bin/npm', 4 | 1 verbose cli 'init' ] 5 | 2 info using npm@1.4.28 6 | 3 info using node@v0.10.36 7 | 4 verbose config Skipping project config: /home/akashdeep/.npmrc. (matches userconfig) 8 | 5 silly package data undefined 9 | 6 info init written successfully 10 | 7 error Error: Invalid name: "Package Hunt" 11 | 7 error at ensureValidName (/home/akashdeep/.nvm/v0.10.36/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:315:15) 12 | 7 error at Object.module.exports.fixNameField (/home/akashdeep/.nvm/v0.10.36/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:204:5) 13 | 7 error at /home/akashdeep/.nvm/v0.10.36/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:30:38 14 | 7 error at Array.forEach (native) 15 | 7 error at normalize (/home/akashdeep/.nvm/v0.10.36/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:29:15) 16 | 7 error at final (/home/akashdeep/.nvm/v0.10.36/lib/node_modules/npm/node_modules/read-package-json/read-json.js:342:33) 17 | 7 error at then (/home/akashdeep/.nvm/v0.10.36/lib/node_modules/npm/node_modules/read-package-json/read-json.js:126:33) 18 | 7 error at /home/akashdeep/.nvm/v0.10.36/lib/node_modules/npm/node_modules/read-package-json/read-json.js:331:40 19 | 7 error at evalmachine.:272:14 20 | 7 error at /home/akashdeep/.nvm/v0.10.36/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:102:5 21 | 8 error If you need help, you may report this *entire* log, 22 | 8 error including the npm and node versions, at: 23 | 8 error 24 | 9 error System Linux 3.13.0-53-generic 25 | 10 error command "/home/akashdeep/.nvm/v0.10.36/bin/node" "/home/akashdeep/.nvm/v0.10.36/bin/npm" "init" 26 | 11 error cwd /home/akashdeep/Projects/packagehunt 27 | 12 error node -v v0.10.36 28 | 13 error npm -v 1.4.28 29 | 14 verbose exit [ 1, true ] 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "packagehunt", 3 | "version": "1.0.4", 4 | "description": "A simple NodeJS application to search for the packages/libraries that you might require in your applications.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "bin": "index.js", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/akashdeepgoel/Package-Hunt" 13 | }, 14 | "author": { 15 | "name": "Akashdeep Goel", 16 | "email": "akashdeep.goel1996@gmail.com", 17 | "url": "https://github.com/akashdeepgoel/akashdeepgoel.github.io" 18 | }, 19 | "files": [ 20 | "index.js", 21 | "search.js" 22 | ], 23 | "keywords": [ 24 | "library search", 25 | "search", 26 | "package", 27 | "finder", 28 | "searcher" 29 | ], 30 | "dependencies": { 31 | "request": "^2.55.0", 32 | "prompt": "^0.2.14", 33 | "cheerio": "*", 34 | "request-promise": "*" 35 | }, 36 | "author": "Akashdeep Goel", 37 | "license": "ISC", 38 | "bugs": { 39 | "url": "https://github.com/akashdeepgoel/Package-Hunt/issues" 40 | }, 41 | "homepage": "https://github.com/akashdeepgoel/Package-Hunt" 42 | } -------------------------------------------------------------------------------- /screenshots/screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akashdeepgoel/Package-Hunt/c9bdf96813acf45efa0505d022cad3e255dc84bd/screenshots/screen1.png -------------------------------------------------------------------------------- /screenshots/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akashdeepgoel/Package-Hunt/c9bdf96813acf45efa0505d022cad3e255dc84bd/screenshots/screen2.png -------------------------------------------------------------------------------- /search.js: -------------------------------------------------------------------------------- 1 | //File that will Search the Web(Github) and return the correct results 2 | var cheerio = require('cheerio'); 3 | var request = require('request-promise'); 4 | 5 | module.exports = Search; 6 | 7 | function Search(requirements, response,codelang) { 8 | this.requirements = requirements; 9 | this.response = response; 10 | this.codelang = codelang; 11 | }; 12 | var output={}; 13 | 14 | Search.prototype.run = function() { 15 | if (this.response=="N") 16 | { 17 | var num = this.requirements.length-1; 18 | var track = 0; 19 | var flag = 0; 20 | var k = 0; 21 | var requestCount = 0; 22 | for(k = 0;k<=num;k++) 23 | { 24 | var fire = "https://api.github.com/search/repositories?q=in:"+this.requirements[k]+"+language:"+this.codelang; 25 | var options = { 26 | url: fire, 27 | method: 'GET', 28 | json: true, 29 | headers: { 30 | 'User-Agent': 'chrome' 31 | } 32 | }; 33 | request(options).then(function(body) { 34 | var result = body; 35 | if(result.items[0]) 36 | { 37 | output[track++]=result.items[0].full_name; 38 | } 39 | if(result.items[1]) 40 | { 41 | output[track++]=result.items[1].full_name; 42 | } 43 | requestCount++; 44 | complete(requestCount); 45 | 46 | }) 47 | .catch(function(err){ 48 | console.log("Error Fetching Results! Please try again"); 49 | }); 50 | } 51 | 52 | function complete(check) 53 | { 54 | if(check==num+1) 55 | { 56 | if(track==0) 57 | { 58 | console.log("Sorry Dev...I couldn't find anything satisfying you..:p\n"); 59 | 60 | } 61 | else 62 | { 63 | console.log("Hooray!! I have your results ready!!\n"); 64 | setTimeout(function(){ 65 | for(var it = 0;it=count&&result.items[it]) 101 | { 102 | done++; 103 | output[track++]=result.items[it].full_name; 104 | } 105 | it++; 106 | } 107 | requestCounter++; 108 | completeProcess(requestCounter); 109 | }) 110 | .catch(function(err){ 111 | console.log("Error Fetching Results! Please try again"); 112 | }); 113 | } 114 | 115 | function completeProcess(check) 116 | { 117 | if(check==num+1) 118 | { 119 | if(track==0) 120 | { 121 | console.log("Sorry Dev...I couldn't find anything satisfying you..:p\n"); 122 | 123 | } 124 | else 125 | { 126 | console.log("Hooray!! I have your results ready!!\n"); 127 | setTimeout(function(){ 128 | for(var it = 0;it