Ahmad Awais

NAVIGATE


SHARE


Introducing:
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.

#TrueStory:#

πŸ€” 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.
gpm

# Alternatively, you can also run it via:
gatsby-package-manager

# 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!

I help businesses understand developers πŸ“Ÿ Just launched Node.js CLI Automation Course πŸ‘¨β€πŸ« Edutainer at VSCode.pro 🎩 An award-winning GitHub Star open-source engineer & advocate 🦊 Google Developers Expert Web DevRel 🌳 Node.js foundation Community Committee Outreach Lead ✌️ Author of various open-source dev-tools and software libraries used by millions of developers worldwide ⓦ WordPress Core Developer πŸ“£ TEDx Speaker πŸ™Œ Leading developers and publishing technical content for over a decade πŸ’œ Loves his wife (Maedah) ❯ Learn more β†’

Say πŸ‘‹ on Twitter @MrAhmadAwais | Subscribe to the Developers Takeaway!

πŸ“¨

Developers Takeaway

Takeaway my professional opinion on open-source, developer relations, growing your business with family, and everything in between! Delivered to your inbox a couple of times every year. I'm even funny at times. I hate spam β€” pinky-promise!

πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’» 118,947 Developers Already Subscribed
Comments 0
There are currently no comments.