tahsin-cli
v1.0.1
Published
A CLI tool to intact with tahsin's gh repos.
Downloads
11
Maintainers
Readme
yourcli
A cli template that let you create your own cli, this cli can be used to interact with your github repos - open it in browser or clone it. ALso has some additional features.
Here is step by step guide to create yourcli =>
Note - before you create you cli, make sure you have installed nodejs and git on your machine.
1 /
Clone this repository,
git clone https://github.com/iamovi/yourcli.git
2 /
Open cloned project with your favorite code editor,
3 /
Install dependencies,
npm i
4 /
Before setting up, let's run it locally to see everything okay or not,
- open terminal and run -
chmod +x index
- run next -
./index
- if the Output -
iamovi@ovismint:~/Desktop/yourcli$ ./index
? Choose a category: (Use arrow keys)
❯ projects
cli-tools
libraries
games
others
Exit
- then everything is working buttery clean.
Alright, let's move to next step - we will make the cli our own =>
Note - please follow comments inside code files, you can see what you have to do.
Let's set up package.json
file first -
- open
package.json
file, - read comments section first from there,
"name": "marufovi-cli",
- change the
name
to your desired name, Exampleexample-cli
"description": "A CLI tool to intact with Maruf OVi's gh repos.",
- change description if needed,
"bin": {
"marufovi": "./index"
},
- change
marufovi
to your name, this command will be used to run your cli,
"keywords": [
"marufovi",
"web-dev",
"marufovis-cli"
],
- change
keywords
if needed,
"author": "Maruf OVi",
- change
author
if needed.
We set up your package.json
file, Lets move to next step,
Let's add your projects and repos to the cli -
open
repositories.js
file frommain
folder,path - main/repositories.js
just follow those comments,
by doing those your
repositories.js
is set up,okay now open
categories.js
file,
// categories.js
export const categories = ['projects', 'cli-tools', 'libraries', 'games', 'others'];
// edit or add more catagories if needed
- you will see these code,
- just follow those comments as you did on
repositories.js
file.
Hmmm seems like your repos and your details are set to your cli, well done.
Now let's move to next step -
- open
index
file, this is the main file of your cli - you can see comments there too just follow those comments carefully
- but let me show you
if (urlChoice.url === 'gmail') {
console.log('Gmail: [email protected]'); // add your gmail here
- add your email here,
if (actionChoice.action === 'Open') {
shell.exec(`open https://github.com/your_username/${selectedRepository}`);
} else if (actionChoice.action === 'Clone') {
const cloneUrl = `https://github.com/your_username/${selectedRepository}.git`;
const cloneSuccess = shell.exec(`git clone ${cloneUrl}`).code === 0;
// make sure to change you_username to your actual github username
- replace the
your_username
with your actual github account username, - this will interact with your github repos to clone it or open it.
And yesss you did it (We did it!!!), your cli is read to BOOM 💥.
But it's always better to test locally first -
./index
- run it and check your cli is working fine or need or check if anything needs to be changed.
Here is another way to test your cli locally
- open terminal in the project directory and run -
npm link
The npm link
command is used in Node.js to create a symbolic link between a package and a local directory. This can be helpful during development when you want to test changes to a package in a real-world scenario without having to publish it to the npm registry.
- now run the command that you gave in
package.json
file.
"bin": {
"marufovi": "./index"
},
- if it is
marufovi
then simply runmarufovi
in your terminal , the cli will run, - after testing unlink cli
npm unlink marufovi
- replace
marufovi
with yours.
Publish to npm
Congrats you made your cli, Let's publish it to npm so that anyone (you, your friends, others) can use use your cli to interact with you and with your gh repos,
- open terminal in your cli project directory,
npm login
- login your npm account, if you don't have then create one,
npm publish
- run this command to publish your cli to npm registry,
- now you can check your cli package in npm website.
Installation of your cli
Let's install your cli in your machine =>
- open terminal
npm i -g your_cli
- replace
your_cli
with the name of your actual cli, that you gave it `package.json file
"name": "marufovi-cli",
- Once it installed globally in your machine,
- simply run your cli -
"bin": {
"marufovi": "./index"
},
- with the name that you gave here,
marufovi
- your cli will run!
- now choose actions and enjoy.
If you facing any problems during making your cli, feel free to contact with me 😊.