This repo is the step-by-step guide to develop the CLI in Nodejs. This repo is the part of the GDG (Google Developer Groups), New Delhi/Gurgaon.
- Event Name: Code-lab : Web Developers Day 3 by Google Developer Group, New Delhi
- Date: 28th April 2019
- Location: 91Springboard, Gurgaon
- Event Link: GDG Event Page
- Event Name: Code-lab : Develop your First CLI, Bangalore
- Date: 12th May 2019
- Location: Microsoft, Bangalore
- Event Link: JSLovers
My name is Neha Sharma. I am working as technical lead. I am the organizer of JSLovers community. I am tech and non-tech speaker. Apart form coding I enjoy doing calligraphy.
You can reach me :
- Twitter : @hellonehha
- Linkdin : @/in/nehha/
- Instagram : @calligraphyzen
- Email : [email protected]
- ✅ Knowledge of Javascript
- ✅ Knowledge of nodejs
- ✅ Comfortble working with CLI and IDE
- ✅ Github account
- ✅ NPM account
- What is nodejs & CLI [Theory]
- Project walkthrough [Theory]
- Folder structure [Theory]
- Installing package.json [Code]
- Create your data [Code]
- Code time [Code]
- Publish the npm [Code]
- Walkthrough of Nodejs, CLI , and Project
- Setup your machine - nodejs, folder structure, package.json
- Create your data
- Install require package and print your first message
- Write the code
- Publish the NPM
This repo is step-by-step guide. You can clone the repo or follow along.Every folder is marked below with what is expected in it.
Introduction to nodejs and CLI.
Folder : session-1/intro.md
Folder : session-1
-
Install nodejs
-
Create a folder - "myprofile"
-
Create package.json
npm init
Folder : session-2
Go to folder session-2/myprofile/data
.
If you want to update the content you can edit it in data.js
Folder : session-3
Go to folder session-3/myprofile
.
In this we will identify the commands and add it to the commands folder.
To sync with data.js
we have following commands (user input) :
- about me
- contact me
- experience
- summary
To print the choices on the terminal we will use the npm package inquirer
.
Folder : session-4
This section is totally optional. To make the CLI' content more colorful and presentable. We will use two more packages:
- chalk : Will let us provide the colors to the texts.
- cfonts : Will let us write a big fancy welcome message.
- inquirer : Common interactive command line user interfaces.
- commander : Common interactive command line user interfaces.
-
Add
#!/usr/bin/env node
on the top ofindex.js
. Read about it here : https://en.wikipedia.org/wiki/Shebang_%28Unix%29 -
In
package.json
, add section ofbin
"bin": { "myprofile": "./index.js" }
-
Run the following command
npm link
-
Now go to the terminal and write
myprofile
-
Create an account in npmjs.com
-
On terminal run the following command & enter the username and password.
npm login
-
To publish
npm publish
You can check your package after publishing : https://www.npmjs.com/~{username}/{package-name}
-
Go to the desire folder. eg :
cd session-2/myprofile
-
Install the dependency
npm install
-
From the root of the
myprofile
run the following command to start the applicationnode index.js
If you are only interested in the end code then clone the session-4
folder.
Collabrations are the awesome way to create small things better, and big. If you see anything which can be improved ? If you see something can be added here? Before telling to anyone else, raise the PR :) . If you are new to the collabrations and have no idea how to do it. Do not worry, reach to me [email protected]