Ahmad Awais



Gatsby Package Manager

Ahmad AwaisAhmad Awais

I’ve been using Gatsby for a couple of years now. If you know me you know I hate repetition and that most of my open-source software revolve around solving a problem that I don’t want to solve again and again.

That’s why I am launching gatsby-package-manager (gpm) (🌟 the repo)

Gatsby Package Manager

Gatsby Package Manager gpm#

The gpm helps you install a Gatsby package with all of its dependencies. It also allows you to read the docs for a package right there in the command line — without having to browse any sites.

Yes, that’s it. Currently, the idea is quite simple which I suppose will grow as the Gatsby ecosystem grows and we have more things to deal with.

🌟 Star Gatsby Package Manager on GitHub & follow Awais to get updates

The Problem gpm Solves#

You know what npm and yarn do? They install a package and all of their dependencies for you so that you only have to remember what the package name is and not what their dependencies look like.

Before gpm you had to manually install a Gatsby package along with all the peer dependencies. I for one could never remember all of them.


🤔 So, it goes like this. I wake up one fine morning. Today, I’m working on a Gatsby site duh. I love to write content with MDX.

🙈 I go ahead and npm install gatsby-plugin-mdx but that’s not all I have to install. For the life of me, I can’t remember the peer dependencies needed to be installed.

🧐 So, I Google Gatsby Plugin MDX, land on the plugin page, scroll…scroll…scroll…table of contents…why MDX…yada…yadda…yadda… there you are. I then npm install @mdx-js/mdx @mdx-js/react.

☠️ That’s not quite how it should work. And then I close the tab and forget to read the first section of the readme.md docs — since I just need a refresher on how to configure this package. I’ve done it before. The entire story repeats itself.

gpm saves the day:#

🤔 I run gpm install gatsby-plugin-mdx and the package + the peer dependencies get installed. I also get a link the docs that I can click to read them online or most probably I fetch the docs in the terminal by running gpm docs gatsby-plugin-mdx.

😎 Easy peasy lemon squeezy.

🌟 Star Gatsby Package Manager on GitHub & follow Awais to get updates

Installation & Usage#

Let’s go through the installation and usage of gpm step by step.

❯ Install gpm#

Installing gatsby-package-manager

First of all install the gpm npm package.

# Install globally via npm.
npm install -g gatsby-package-manager

# OR: Install globally via yarn.
yarn global add gatsby-package-manager

Now you have access to gpm or gatsby-package-manager in your command line. Go ahead and use gpm to install a pacakge.

❯ Install a package#

Install a package

Installs a Gatsby package with all of its peer dependencies.

# 1: Interactive mode.
# Type `gpm` and answer the questions asked.

# Alternatively, you can also run it via:

# 2: Direct mode.
# Several ways to run the same command.
gpm install 
gpm i 
gpm install gatsby-plugin-mdx
gpm i gatsby-plugin-mdx

❯ Docs for a package#

Docs for a package

Prints the docs, i.e., readme.md file of a package in the command line.

# Several ways to run the same command.
gpm docs 
gpm d 
gpm docs gatsby-plugin-mdx
gpm d gatsby-plugin-mdx

❯ Configure npm or yarn#

The gatsby-package-manager (gpm) stores your choice of using npm or yarn in ~/.config/configstore/gatsby-package-manager.json file. This choice can be re-configured by using the option --config or -c when running gpm.

gpm --config
gpm -c
gpm i gatsby-plugin-mdx -c

❯ Help documentation#

You can run gpm --help or gpm -h to access the help documentation.

What’s Next?#

That’s all for now but I see this as an opportunity for what comes next. I believe with time Gatsby packages, the plugins, and themes, they’ll get a bit more complicated. gpm will help make Gatsby package management easy.

Some things that I could think gpm can do in the future:

🌟 For now, go ahead and star the Gatsby Package Manager gpm repository on GitHub & follow my GitHub and Twitter to get updates or show appreciation.

Have fun and use your code for good. Peace! ✌️

P.S. If you’re a package/plugin author, read this part of the documentation.

Contributions Welcome#

Nothing’s ever complete, so bear with me while we keep iterating towards a better future. You can definitely help make gpm better.

Coz every night I lie in bed
The brightest colors fill my head
A million dreams are keeping me awake
I think of what the world could be
A vision of the one I see
A million dreams is all it’s gonna take
A million dreams for the world we’re gonna make …

listen to → A million dreams!

Founder & CEO at Langbase.com · Ex VP DevRel Rapid · Google Developers Advisory Board (gDAB) founding member. 🧑‍💻 AI/ML/DevTools Angel InvestorAI/ML Advisory Board member San Francisco, DevNetwork

🎩 Award-winning Open Source Engineer & Dev Advocate 🦊 Google Developers Expert Web DevRel 🚀 NASA Mars Ingenuity Helicopter mission code contributor 🏆 8th GitHub Stars Award recipient with 3x GitHub Stars Award (Listed as GitHub's #1 JavaScript trending developer).

🌳 Node.js foundation Community Committee Outreach Lead, Member Linux Foundation, OpenAPI Business Governing Board, and DigitalOcean Navigator. 📟 Teaching thousands of developers Node.js CLI Automation (100 videos · 22 Projects) & VSCode.pro course. Over 142 Million views, 22 yrs Blogging, 56K developers learning, 200+ FOSS.

✌️ Author of various open-source dev-tools and software libraries utilized by millions of developers worldwide WordPress Core Developer 📣 TEDx Speaker with 100+ international talks.

As quoted by: Satya Nadella · CEO of Microsoft — Awais is an awesome example for developers.
🙌 Leading developers and publishing technical content for over a decade 💜 Loves his wife (Maedah) ❯ Read more about Ahmad Awais.

👋… Awais is mostly active on Twitter @MrAhmadAwais


Developers Takeaway

Stay ahead in the web dev community with Ahmad's expert insights on open-source, developer relations, dev-tools, and side-hustles. Insider-email-only-content. Don't miss out - subscirbe for a dose of professional advice and a dash of humor. No spam, pinky-promise!

✨ 172,438 Developers Already Subscribed
Comments 0
There are currently no comments.