├── .editorconfig ├── .gitignore ├── .prettierrc ├── .travis.yml ├── LICENSE ├── README.md ├── app.js ├── cli.js ├── config.js ├── media ├── logo.svg ├── media-availability.gif └── media-suggestions.gif ├── package-lock.json ├── package.json └── wait.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [{package.json,*.yml}] 12 | indent_style = space 13 | indent_size = 2 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "tabWidth": 2 4 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "node" 4 | - "6" 5 | cache: 6 | directories: 7 | - "node_modules" 8 | script: 9 | - node src/index.js & 10 | - npm test -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Shriram Balaji 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 | # [![Domain Hunt](media/logo.svg)](https://github.com/Shriram-Balaji/cli-domain-hunt) 2 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FShriram-Balaji%2Fcli-domain-hunt.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FShriram-Balaji%2Fcli-domain-hunt?ref=badge_shield) 3 | 4 | > A command line interface to easily search, suggest and compare domains 5 | 6 | ## Usage 7 | 8 | ### Installation 9 | 10 | ```console 11 | $ npm install -g cli-domain-hunt 12 | ``` 13 | 14 | ### Availability 15 | 16 | This command provides information about the availability of the domain and the period of renewal. 17 | 18 | ```console 19 | $ domain-hunt domain-name.com 20 | ``` 21 | 22 | ![Availability](media/media-availability.gif) 23 | 24 | ### Suggestions 25 | 26 | This command provides alternative suggestions about a domain. 27 | 28 | ```console 29 | $ domain-hunt -s domain.com 30 | ``` 31 | 32 | ![Suggestions](media/media-suggestions.gif) 33 | 34 | 35 | ## Pre-requisites 36 | 37 | node > 8 38 | 39 | ## License 40 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FShriram-Balaji%2Fcli-domain-hunt.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FShriram-Balaji%2Fcli-domain-hunt?ref=badge_large) 41 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const fetch = require("node-fetch"); 3 | const chalk = require("chalk"); 4 | const terminalLink = require("terminal-link"); 5 | const { error, success, debug } = require("util-box").outputUtil; 6 | const { httpUtil } = require("util-box"); 7 | const config = require("./config"); 8 | const wait = require("./wait"); 9 | 10 | // fetch alternate domain-name suggestions 11 | async function fetchSuggestions(input) { 12 | let reqUrl = httpUtil.makeQueryString({ domain: input }, `${config.API_ENDPOINT}/suggestions`); 13 | const stopSpinner = wait("Hunting Domain Suggestions"); 14 | try { 15 | let res = await fetch(reqUrl); 16 | if (!/2[0-9]/.test(res.status)) { 17 | error("Error! Unable to fetch suggestions.", res.status); 18 | } else { 19 | let body = await res.json(); 20 | console.log( 21 | ` ${chalk.white(` 22 | 🌎 Here are some suggestions similar to ${chalk.cyan.underline(input)}`)} ` 23 | ); 24 | body.map(domains => { 25 | console.log( 26 | `${chalk.greenBright(terminalLink(domains.domain, `${config.PROVIDER_ENDPOINT}${domains.domain}`))} ` 27 | ); 28 | }); 29 | stopSpinner(); 30 | } 31 | } catch (err) { 32 | error(`Sorry! Unable to fetch suggestions due to Error ${err}`); 33 | stopSpinner(); 34 | } 35 | } 36 | 37 | // check domain name availability 38 | async function checkAvailability(input) { 39 | debug(`Checking availability for ${input}`); 40 | let reqUrl = httpUtil.makeQueryString({ domain: input }, `${config.API_ENDPOINT}/available`); 41 | const stopSpinner = wait("Hunting domain availability"); 42 | try { 43 | let res = await fetch(reqUrl); 44 | if (!/2[0-9]/.test(res.status)) { 45 | debug(`Error! Expected 2xx, found ${res.status}`); 46 | error(` 47 | Unable to fetch Domain Availability! Error: ${res.status}`); 48 | stopSpinner(); 49 | } else { 50 | let body = await res.json(); 51 | if (body.available) { 52 | if (body.period > 1) body.numberofYears = "years"; 53 | else body.numberofYears = "year"; 54 | let domainLink = terminalLink(body.domain, `${config.PROVIDER_ENDPOINT}${body.domain}`); 55 | console.log(` 56 | ${chalk.bold.underline(`Available`)} 57 | ${chalk.dim("The prices are subject to vary based on discounts, taxes and other fees")} 58 | Domain : ${chalk.greenBright(domainLink)} 59 | Price : ${chalk.white(body.price / 1000000)} ${chalk.yellowBright(body.currency)} 60 | Period : ${chalk.white(body.period)} ${body.numberofYears} 61 | `); 62 | } else { 63 | console.log(` 64 | Oh no! That domain seems to be taken. 65 | `); 66 | fetchSuggestions(input); 67 | } 68 | stopSpinner(); 69 | } 70 | } catch (err) { 71 | error(` 72 | Unable to Fetch domain availability ${err}`); 73 | stopSpinner(); 74 | } 75 | } 76 | 77 | const performComparison = input => { 78 | debug(`comparing the ${input}`); 79 | }; 80 | 81 | const app = (input, flags) => { 82 | if (!input) { 83 | console.log(` 84 | ${chalk.red( 85 | `Missing or invalid input: domain-name 86 | Please enter a valid domain name` 87 | )} 88 | `); 89 | console.log(`${chalk.gray("Use the --help to view usage instructions")}`); 90 | } else { 91 | if (flags.compare || flags.c) performComparison(input); 92 | if (flags.suggestions || flags.s) fetchSuggestions(input); 93 | else checkAvailability(input); 94 | } 95 | }; 96 | 97 | module.exports = app; 98 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | const meow = require("meow"); 4 | const chalk = require("chalk"); 5 | const app = require("./app"); 6 | const helpText = ` 7 | ${chalk.dim(`Usage: `)} 8 | 9 | ${chalk.cyan(`$ domain-hunt name.com`)} 10 | 11 | ${chalk.dim(`Options:`)} 12 | -c, --compare Compare Domain Prices across namespace providers 13 | -s, --suggest Suggest alternate domain names for a given domain 14 | `; 15 | const cli = meow(helpText, { 16 | flags: { 17 | compare: { 18 | type: "boolean", 19 | alias: "c" 20 | }, 21 | suggest: { 22 | type: "boolean", 23 | alias: "s" 24 | } 25 | } 26 | }); 27 | app(cli.input[0], cli.flags); 28 | -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | const config = () => {}; 2 | config.API_ENDPOINT = "https://domain-hunt.now.sh/api"; 3 | config.PROVIDER_ENDPOINT = "https://godaddy.com/dpp/find?checkAvail=1&tmskey=&domainToCheck="; 4 | module.exports = config; 5 | -------------------------------------------------------------------------------- /media/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /media/media-availability.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shrirambalaji/cli-domain-hunt/34b95692e16854479df44b1f62d1db86c8d0b391/media/media-availability.gif -------------------------------------------------------------------------------- /media/media-suggestions.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shrirambalaji/cli-domain-hunt/34b95692e16854479df44b1f62d1db86c8d0b391/media/media-suggestions.gif -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cli-domain-hunt", 3 | "version": "1.0.7", 4 | "description": "A command line interface for finding and suggesting domain-names to buy.", 5 | "main": "cli.js", 6 | "scripts": { 7 | "test": "ava", 8 | "start": "babel-node --presets env cli.js" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/Shriram-Balaji/cli-domain-hunt.git" 13 | }, 14 | "bin": { 15 | "domain-hunt": "./cli.js" 16 | }, 17 | "keywords": [ 18 | "['cli'", 19 | "'command-line'", 20 | "'domain-search'", 21 | "'domain'", 22 | "'whois']" 23 | ], 24 | "author": "Shriram Balaji", 25 | "license": "MIT", 26 | "bugs": { 27 | "url": "https://github.com/Shriram-Balaji/cli-domain-hunt/issues" 28 | }, 29 | "homepage": "https://github.com/Shriram-Balaji/cli-domain-hunt#readme", 30 | "devDependencies": { 31 | "ava": "1.0.0-rc.2", 32 | "babel-core": "^6.26.3", 33 | "babel-preset-env": "^1.6.1", 34 | "babel-register": "^6.26.0", 35 | "execa": "^0.10.0", 36 | "prettier": "^1.12.1" 37 | }, 38 | "babel": { 39 | "presets": [ 40 | [ 41 | "env", 42 | { 43 | "targets": { 44 | "node": "current" 45 | } 46 | } 47 | ] 48 | ] 49 | }, 50 | "dependencies": { 51 | "ansi-escapes": "^3.1.0", 52 | "chalk": "^2.4.1", 53 | "meow": "^5.0.0", 54 | "node-fetch": "^2.1.2", 55 | "ora": "^2.0.0", 56 | "terminal-link": "^1.1.0", 57 | "util-box": "^1.0.4" 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /wait.js: -------------------------------------------------------------------------------- 1 | const ora = require("ora"); 2 | const { gray } = require("chalk"); 3 | const { eraseLines } = require("ansi-escapes"); 4 | const wait = (msg, timeOut = 300) => { 5 | let running = false; 6 | let spinner = null; 7 | let stopped = false; 8 | setTimeout(() => { 9 | if (stopped) return; 10 | spinner = ora(gray(msg)); 11 | spinner.color = "gray"; 12 | spinner.start(); 13 | running = true; 14 | }, timeOut); 15 | const setText = msg => { 16 | spinner.text = msg; 17 | }; 18 | 19 | const cancel = () => { 20 | stopped = true; 21 | if (running) { 22 | spinner.stop(); 23 | // why is this needed 24 | process.stderr.write(eraseLines(1)); 25 | running = false; 26 | } 27 | process.removeListener("dhExit", cancel); 28 | }; 29 | process.on("dhExit", cancel); 30 | return cancel; 31 | }; 32 | 33 | module.exports = wait; 34 | --------------------------------------------------------------------------------