From f8e79d8f5c4a50b4408d51df1b88de6799abe0bc Mon Sep 17 00:00:00 2001 From: Ahmad Awais Date: Fri, 24 Apr 2020 23:49:28 +0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20NEW:=20First=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 12 ++++++ .gitattributes | 1 + .github/funding.yml | 6 +++ .gitignore | 72 +++++++++++++++++++++++++++++++++++ .npmrc | 1 + .prettierrc | 10 +++++ code-of-conduct.md | 74 ++++++++++++++++++++++++++++++++++++ index.js | 18 +++++++++ license | 21 +++++++++++ package.json | 48 +++++++++++++++++++++++ readme.md | 92 +++++++++++++++++++++++++++++++++++++++++++++ test.js | 12 ++++++ utils/cli.js | 38 +++++++++++++++++++ utils/init.js | 22 +++++++++++ utils/theEnd.js | 6 +++ 15 files changed, 433 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/funding.yml create mode 100644 .gitignore create mode 100644 .npmrc create mode 100644 .prettierrc create mode 100644 code-of-conduct.md create mode 100644 index.js create mode 100644 license create mode 100644 package.json create mode 100644 readme.md create mode 100644 test.js create mode 100644 utils/cli.js create mode 100644 utils/init.js create mode 100644 utils/theEnd.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1c6314a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = tab +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.github/funding.yml b/.github/funding.yml new file mode 100644 index 0000000..d2dab8a --- /dev/null +++ b/.github/funding.yml @@ -0,0 +1,6 @@ +custom: + [ + 'https://github.com/ahmadawais/sponsor', + 'https://NodeCLI.com', + 'https://VSCode.pro', + ] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e35307f --- /dev/null +++ b/.gitignore @@ -0,0 +1,72 @@ +# NPM # +########## +# Ignore all directories called node_modules in current folder and any subfolders. +node_modules/ +/node_modules/ + +# Packages # +############ +*.7z +*.dmg +*.gz +*.bz2 +*.iso +*.jar +*.rar +*.tar +*.zip +*.tgz +*.map + +# Logs and databases # +###################### +*.log +*.sql +*.env + +# OS generated files # +###################### +**.DS_Store* +ehthumbs.db +Icon? +Thumbs.db +._* + +# Vim generated files # +###################### +*.un~ + +# SASS # +########## +**/.sass-cache +**/.sass-cache/* +**/.map + +# Composer # +########## +!assets/js/vendor/ +wpcs/ +/vendor/ + +# Bower # +########## +assets/bower_components/* + +# Codekit # +########## +/codekit-config.json +*.codekit +**.codekit-cache/* + +# Compiled Files and Build Dirs # +########## +/README.html + +# PhpStrom Project Files # +.idea/ +library/vendors/composer +assets/img/.DS_Store + +# No lock files. +package-lock.json +yarn.lock diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..dca71ac --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "trailingComma": "none", + "bracketSpacing": false, + "arrowParens": "avoid", + "singleQuote": true, + "printWidth": 80, + "useTabs": true, + "tabWidth": 4, + "semi": true +} diff --git a/code-of-conduct.md b/code-of-conduct.md new file mode 100644 index 0000000..c555933 --- /dev/null +++ b/code-of-conduct.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at me@AhmadAwais.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [https://contributor-covenant.org/version/1/4][version] + +[homepage]: https://contributor-covenant.org +[version]: https://contributor-covenant.org/version/1/4/ diff --git a/index.js b/index.js new file mode 100644 index 0000000..b3c66af --- /dev/null +++ b/index.js @@ -0,0 +1,18 @@ +#!/usr/bin/env node + +const ora = require('ora'); +const spinner = ora({text: ''}); +const cli = require('./utils/cli.js'); +const init = require('./utils/init.js'); +const to = require('await-to-js').default; +const theEnd = require('./utils/theEnd.js'); +const handleError = require('cli-handle-error'); + +// CLI. +const [input] = cli.input; +const option = cli.flags.option; + +(async () => { + init(); + theEnd(); +})(); diff --git a/license b/license new file mode 100644 index 0000000..5f56a0e --- /dev/null +++ b/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020-present Ahmad Awais. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/package.json b/package.json new file mode 100644 index 0000000..2c1f2a9 --- /dev/null +++ b/package.json @@ -0,0 +1,48 @@ +{ + "name": "ramadan-cli", + "version": "0.0.1", + "description": "CLI to check Sehar and Iftar times in Ramadan.", + "license": "MIT", + "repository": "ahmadawais/ramadan-cli", + "author": { + "name": "Ahmad Awais", + "email": "me@AhmadAwais.com", + "url": "https://twitter.com/MrAhmadAwais" + }, + "main": "index.js", + "engines": { + "node": ">=12.x" + }, + "bin": { + "ramadan-cli": "index.js" + }, + "files": [ + "index.js", + "utils/*" + ], + "keywords": [ + "ramadan-cli", + "Ahmad Awais", + "ahmadawais" + ], + "devDependencies": { + "ava": "^3.7.1", + "execa": "^4.0.0", + "prettier": "^2.0.5" + }, + "scripts": { + "test": "ava", + "format": "prettier --write \"./**/*.{js,json}\"" + }, + "dependencies": { + "await-to-js": "^2.1.1", + "chalk": "^4.0.0", + "cli-check-node": "^1.3.0", + "cli-handle-error": "^4.1.0", + "cli-handle-unhandled": "^1.1.0", + "cli-welcome": "^1.4.0", + "meow": "^6.1.0", + "ora": "^4.0.4", + "update-notifier": "^4.1.0" + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..c254d81 --- /dev/null +++ b/readme.md @@ -0,0 +1,92 @@ +# ramadan-cli + +[![DOWNLOADS](https://img.shields.io/npm/dt/ramadan-cli?label=DOWNLOADS%20%20โฏ&colorA=6A788D&colorB=6A788D&style=flat)](https://www.npmjs.com/package/ramadan-cli) [![Learn VSCode](https://img.shields.io/badge/-VSCODE.pro%20%E2%86%92-gray.svg?colorB=6A788D&style=flat)](https://VSCode.pro/?utm_source=GitHubFOSS) +[![Follow @MrAhmadAwais on Twitter](https://img.shields.io/badge/FOLLOW%20@MRAHMADAWAIS%20%E2%86%92-gray.svg?colorA=6A788D&colorB=6A788D&style=flat)](https://twitter.com/mrahmadawais/) + +> CLI to check Sehar and Iftar times in Ramadan. + +
+ +[![๐Ÿ“Ÿ](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/install.png)](./../../) + +## Install + +```sh +npm install -g ramadan-cli + +# OR. +npx ramadan-cli +``` + +
+ +[![โš™๏ธ](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/usage.png)](./../../) + +## Usage + +```sh +ramadan-cli [options] +``` + +
+ +[![๐Ÿ“](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/log.png)](changelog.md) + +## Changelog + +[โฏ Read the changelog here โ†’](changelog.md) + +
+ +**KEY**: `๐Ÿ“ฆ NEW`, `๐Ÿ‘Œ IMPROVE`, `๐Ÿ› FIX`, `๐Ÿ“– DOC`, `๐Ÿš€ RELEASE`, and `๐Ÿค– TEST` + +> _I use [Emoji-log](https://github.com/ahmadawais/Emoji-Log), you should try it and simplify your git commits._ + + + +
+ +[![๐Ÿ“ƒ](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/license.png)](./../../) + +## License & Conduct + +- MIT ยฉ [Ahmad Awais](https://twitter.com/MrAhmadAwais/) +- [Code of Conduct](code-of-conduct.md) + +
+ +[![๐Ÿ™Œ](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/connect.png)](./../../) + +## Connect + +
+

GitHub @AhmadAwais (follow) To stay up to date on free & open-source software

+

Twitter @MrAhmadAwais (follow) To get #OneDevMinute daily hot tips & trolls

+

YouTube AhmadAwais (subscribe) To tech talks & #OneDevMinute videos

+

Blog: AhmadAwais.com (read) In-depth & long form technical articles

+

LinkedIn @MrAhmadAwais (connect) On the LinkedIn profile y'all

+
+ +
+ +[![๐Ÿ‘Œ](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/sponsor.png)](./../../) + +## Sponsor + +Me ([Ahmad Awais](https://twitter.com/mrahmadawais/)) and my incredible wife ([Maedah Batool](https://twitter.com/MaedahBatool/)) are two engineers who fell in love with open source and then with each other. You can read more [about me here](https://ahmadawais.com/about). If you or your company use any of my projects or like what Iโ€™m doing then consider backing me. I'm in this for the long run. An open-source developer advocate. + +- ๐ŸŒŸ **$9.99/month (recommended)** โฏ [Two cups of Caffรจ latte (coffee) every month โ†’](https://pay.paddle.com/checkout/540217) +- ๐Ÿš€ **$99.99 (one-time sponsor)** โฏ [Support an hour of open-source code โ†’](https://pay.paddle.com/checkout/515568) +- ๐Ÿ”ฐ **$49.99 (one-time sponsor)** โฏ [Support an hour of maintenance โ†’](https://pay.paddle.com/checkout/527253) +- โ˜•๏ธ **$9.99 (one-time sponsor)** โฏ [Lunch/coffee โ†’](https://pay.paddle.com/checkout/527254) + +
+ +Or you can back me by checking out my super fun video course. As developers, we spend over 200 Hrs/month with our code editors โ€” it's only fair to learn your next editor deeply. This course will save you 15-20 hours every month. Become a VSCode Power User โ†’

+ +
VSCODE
+ +
+ +[![VSCode](https://img.shields.io/badge/-VSCode.pro%20%E2%86%92-gray.svg?colorB=4D2AFF&style=flat)](https://VSCode.pro/?utm_source=GitHubFOSS) +[![Ahmad on Twitter](https://img.shields.io/twitter/follow/mrahmadawais.svg?style=social&label=Follow%20@MrAhmadAwais)](https://twitter.com/mrahmadawais/) diff --git a/test.js b/test.js new file mode 100644 index 0000000..f00a6f8 --- /dev/null +++ b/test.js @@ -0,0 +1,12 @@ +/** + * Testing with ava. + * + * @link https://github.com/avajs/ava/blob/master/docs/01-writing-tests.md + */ +const test = require('ava'); +const execa = require('execa'); + +test('main', async t => { + const {stdout} = await execa('./index.js', ['--version']); + t.true(stdout.length > 0); +}); diff --git a/utils/cli.js b/utils/cli.js new file mode 100644 index 0000000..04dead6 --- /dev/null +++ b/utils/cli.js @@ -0,0 +1,38 @@ +const meow = require('meow'); +const chalk = require('chalk'); +const green = chalk.green; +const yellow = chalk.yellow; +const cyan = chalk.cyan; +const dim = chalk.dim; + +module.exports = meow( + ` + Usage + ${green(`ramadan-cli`)} ${cyan(``)} ${yellow(`[--option]`)} + + Commands + ${cyan(`command`)} Description + + Options + ${yellow(`--option`)}, ${yellow(`-o`)} Description + + Examples + ${green(`ramadan-cli`)} ${cyan(`command`)} + ${green(`ramadan-cli`)} ${yellow(`--option`)} + + โฏ You can also run command + option at once: + ${green(`ramadan-cli`)} ${cyan(`command`)} ${yellow(`-o`)} +`, + { + booleanDefault: undefined, + hardRejection: false, + inferType: false, + flags: { + option: { + type: 'boolean', + default: false, + alias: 'o' + } + } + } +); diff --git a/utils/init.js b/utils/init.js new file mode 100644 index 0000000..559f8b8 --- /dev/null +++ b/utils/init.js @@ -0,0 +1,22 @@ +const welcome = require('cli-welcome'); +const checkNode = require('cli-check-node'); +const pkgJSON = require('./../package.json'); +const updateNotifier = require('update-notifier'); +const unhandledError = require('cli-handle-unhandled'); + +module.exports = async () => { + unhandledError(); + checkNode(`12`); + welcome(`ramadan-cli`, `by Awais.dev\n${pkgJSON.description}`, { + bgColor: `#007C91`, + color: `#FFFFFF`, + bold: true, + clear: true, + version: `v${pkgJSON.version}` + }); + updateNotifier({ + pkg: pkgJSON, + shouldNotifyInNpmScript: true, + updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week. + }).notify({ isGlobal: true }); +}; diff --git a/utils/theEnd.js b/utils/theEnd.js new file mode 100644 index 0000000..24b9395 --- /dev/null +++ b/utils/theEnd.js @@ -0,0 +1,6 @@ +const sym = require('log-symbols'); +const chalk = require('chalk'); + +module.exports = async () => { + console.log(`${sym.success} All done.\n`); +};