Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Fix #3 #4 Add Version Check and Update Readme (#5)
Browse files Browse the repository at this point in the history
Fix #3 #4 Add Version Check and Update Readme
  • Loading branch information
excalith authored Oct 2, 2019
2 parents f90c835 + dc6eff5 commit b639633
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 13 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<a href="https://travis-ci.org/excalith/git-cheats-cli">
<img alt="Build Status" height="18" src="https://img.shields.io/travis/excalith/git-cheats-cli.svg">
</a>
<a href="https://www.npmjs.com/package/git-commands-cli">
<img alt="NPM Installs" height="18" src="https://img.shields.io/npm/dt/git-commands-cli.svg?label=installs">
</a>
<a href="https://github.com/excalith/Git-Cheats-Cli/issues">
<img alt="Build Status" height="18" src="https://img.shields.io/github/issues/excalith/Git-Cheats-Cli.svg">
</a>
Expand All @@ -34,14 +37,16 @@ You can either use web based [GitCheats App](http://gitcheats.com) from your bro

## How To Install:

- Requirements
- [NodeJS](https://nodejs.org)
- [NPM](https://www.npmjs.com/get-npm)
### Using NPM

`npm i -g git-commands-cli`

### Clone

- Clone or Download this repository
- Within the directory, from your favorite terminal
- npm install
- npm link (might ask for permission depending on your OS)
- Now you can use gitcheats directly from your terminal!

## Available Commands:

Expand All @@ -51,6 +56,7 @@ You can either use web based [GitCheats App](http://gitcheats.com) from your bro
| gitcheats [command] | Print command descriptions right into your terminal |
| gitcheats --open [command] | Open gitcheats.com in browser with your command filtered |
| gitcheats --language [key] | Set your preffered language (Default: en) |
| gitcheats --version | Shows and checks version |
| gitcheats --help | Show commands for the app |

## How To Contribute:
Expand Down
41 changes: 40 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ const Configstore = require("configstore");
const pkg = require("./package.json");
const jsonLink =
"https://raw.githubusercontent.com/excalith/git-cheats/master/assets/commands.json";
const boxen = require("boxen");
const checkForUpdate = require("update-check");
const conf = new Configstore(pkg.name, { lang: "en" });

let cmd = process.argv[2];
let bar = chalk.green("║ ");
let lang = conf.get("lang");

// Check Arguments
if (cmd == "-h" || cmd == "--help") {
if (cmd === "-v" || cmd === "--version") {
ShowVersion();
} else if (cmd == "-h" || cmd == "--help") {
ShowHelp();
} else if (cmd == "-o" || cmd == "--open") {
LaunchBrowser(process.argv[3]);
Expand All @@ -26,6 +30,41 @@ if (cmd == "-h" || cmd == "--help") {
LaunchBrowser(false);
}

//** Check Updates */
async function ShowVersion() {
let update = null;

try {
update = await checkForUpdate(pkg);
} catch (error) {
console.log(chalk.red("\nFailed to check for updates:"));
console.error(error);
}

let updateText;
let commandText;

if (update) {
updateText =
"Update available " +
chalk.gray(pkg.version) +
" → " +
chalk.green(update.latest);
commandText = "Run " + chalk.cyan("npm i -g " + pkg.name) + " to update";
} else {
updateText = "You are using the latest version";
commandText = pkg.name + " v" + pkg.version;
}

console.log(
boxen(updateText + "\n" + commandText, {
padding: 1,
margin: 1,
align: "center"
})
);
}

/**
* Shows CLI help
*/
Expand Down
154 changes: 148 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "git-commands-cli",
"version": "1.3.3",
"version": "1.3.4",
"description": "A Companion CLI App For Gitcheats",
"main": "cli.js",
"scripts": {
Expand All @@ -17,11 +17,13 @@
"author": "Can Cellek",
"license": "MIT",
"dependencies": {
"boxen": "^4.1.0",
"chalk": "^2.4.2",
"configstore": "^5.0.0",
"opn": "^6.0.0",
"ora": "^4.0.2",
"request": "^2.88.0"
"request": "^2.88.0",
"update-check": "^1.5.3"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit b639633

Please sign in to comment.