Gatsby Package Manager
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)
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.
You know what
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.
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
☠️ 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.
Let’s go through the installation and usage of
gpm step by step.
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
gatsby-package-manager in your command line. Go ahead and use
gpm to install a pacakge.
❯ 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 gatsby-plugin-mdx
gpm i gatsby-plugin-mdx
❯ 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 gatsby-plugin-mdx
gpm d gatsby-plugin-mdx
gatsby-package-manager (gpm) stores your choice of using
~/.config/configstore/gatsby-package-manager.json file. This choice can be re-configured by using the option
-c when running
gpm i gatsby-plugin-mdx -c
❯ Help documentation#
You can run
gpm --help or
gpm -h to access the help documentation.
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:
- 🚀 Starters: Help search/install any of the existing starters
- 🎛 Standard Config: Help you configure a package provided we can all agree on a standard specification that
gpm can read. Something that’s part of the
package.json file, maybe?!
- 🗃 Packs: One of my apprentices, Saqib, suggested we could also have
packs command that would install recommended or opinionated
packs of packages. Let’s say
gpm pack seo or
gpm pack @ahmadawais/seo that installs different packs of packages and lists out the instructions to configure them. It would be cool.
- 🤯 Moaaar automation: Configure the packages automagically.
🌟 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.
Nothing’s ever complete, so bear with me while we keep iterating towards a better future. You can definitely help make
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!
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