Articles by Victoria

Automate GitHub: Build a CLI App with Node.js #2

Apr 28, 20211 min read
cover

Welcome back to the 2nd and final part of the tutorial on how to build a simple CLI tool that can automate GitHub workflows.

Step 7: New_repo.js (newRepo)

Use octokit's repos.createForAuthenticatedUser() to create a remote repository.

Step 8: New_repo.js (ignoreFiles)

Use glob to list all files and inquirer to let users select which files to add to .gitignore.

Step 9: New_repo.js (initialCommit)

Use simple-git to:
1. git init
2. git add .gitignore
3. git add ./*
4. git commit
5. git remote add origin
6. git push

Final Product

The completed CLI tool can now:
• Authenticate users
• Create remote repos
• Initialize git
• Create .gitignore
• Commit and push files

Optional: Publishing

Add "bin" property to package.json, then publish to npm.

Conclusion

We've built a complete CLI tool with Node.js. Thanks for reading!

Share:

More Articles