Package: p
pP makes it easier to jump between projects and get work done.
It gathers up all of the available commands/scripts in a repo,
and aliases them top <name>.P is not a project requirement or dependency -- it is a personal
tool.Nothing in your project should depend on p, but rather conform
to p-friendly standards which are usable with or without p itself.
This means that if you use p,
you get the best experience possible.
And for the contributors who don't use p,
at least they get a well-documented and well-maintained developer experience.If youpersonallystart using it,
you'll probably find thatpis the first thing you run aftercd <project>to get your bearings and start doing work.But... why?Install or updateDon't add it to a project. Add it to your machine, system-wide or user-wide.# System-wide or user-wide, not per project$pip3install-UpWhat it looks like$ cd project
$ p
  Usage: p [OPTIONS] COMMAND [ARGS]...

  Options:
  --version
  --help     Show this message and exit.

  Commands:
  compile-assets  Using: npm run compile-assets
  install         Using: ./scripts/install
  load-fixtures   Using: ./scripts/load-fixtures
  pre-commit      Using: ./scripts/pre-commit
  test            Using: ./scripts/testSupported tools and workflowsNote that p really only supports stuff that we use atDropseed.So this list is intentionally short.If you use p day-to-day and would like to see support for something not listed here,just let us know!Executable scriptsP will automatically find executable scripts in./scriptsor./bin.They should have no extension (don't need ".sh") and should be executable (chmod +x ./scripts/thing).The filename will be added as a command so that they can simply be run by doingp {script-name}.For example, this structure:$ tree scripts/
scripts/
├── compile-assets
├── load-fixtures
├── pre-commit
├── setup
├── start-postgres
├── test
└── workWill result in:$ p
  Usage: p [OPTIONS] COMMAND [ARGS]...

  Options:
    --version
    --help     Show this message and exit.

  Commands:
    compile-assets  Using: ./scripts/compile-assets
    load-fixtures   Using: ./scripts/load-fixtures
    pre-commit      Using: ./scripts/pre-commit
    setup           Using: ./scripts/setup
    start-postgres  Using: ./scripts/start-postgres
    test            Using: ./scripts/test
    work            Using: ./scripts/workMakefileIf there is aMakefilein your project,
p will automatically parse.PHONYand make those commands available via p.
So if you havemake test,
it will also be available to p users viap test.package.json scriptsEntries in yourpackage.json"scripts" will automatically be mapped to p commands.For example:{"scripts":{"start":"react-scripts start"}}Would result in:Usage: p [OPTIONS] COMMAND [ARGS]...

Options:
  --version
  --help     Show this message and exit.

Commands:
  start    Using: npm run startGit hooksP also provides automatic installation ofgit hooks.For example, if you have a command namedpre-commit, runningp installorp {git-hook-name}will prompt you to install
it into your local.githooksfor the repo.Then when you rungit commit,
yourp pre-commitwill be run automatically.An example of apre-commitscript:#!/bin/sh -eblackpullapprove--check--excludemigrationsGrouping (advanced)To make the p help more user friendly you can group and hide commands from the top-level.
This works automatically by using a:in your command name.For example, if you have commands likedb:loadanddb:reset, you'll get adbgroup.
You can runp dbto see the subcommands in db, and runp db loadto run a subcommand.$ p
  Usage: p [OPTIONS] COMMAND [ARGS]...

  Options:
    --version
    --help     Show this message and exit.

  Commands:
    db

$ p db load(You can also invoke the grouped commands directly asp db:load.)WhyContext switching sucksIt can often take several minutes just to figure out how tostartworking on
something.Every project is different, but damn near every project comes with a set of
development commands or scripts to run common actions. And if it doesn’t, then
it probably should.
Different languages, people, and tools accomplish this in different ways. Some
projects use the good ol’Makefile, while others usepackage.json“scripts”,
bash scripts,rake,fabric, and so on and so on…P was built to make it easier to jump between projects,
and to save some keystrokes in the meantime.Improving developer experienceIdeally, p will “just work”.
But if not,
it is often in your project’s best interest to design a developer experience thatwouldwork if someone were using p.
That is – script out some of the most commonly used actions for your project (install,test,deploy, etc.),
and put them in a uniform place where contributors can easily figure out how to use them.
Now even the people who don't use p at least have a shot at getting up and running on their own.The search for a universal experienceFor a long time I've been in search of the perfect development task manager to use on every project.
But that proved to be difficult as the repos got smaller,
more self-contained,
and spread across languages and dependency systems.Using a Makefile is the closest thing to what I'm looking for.
Most people havemake.
But there's a lot of things I just can't stand about it
(it's just ugly, and I can't help but think that it feels like some kind ofhack).I've settled on the idea of using a "scripts" folder with one-off files for each task.
Usually just bash scripts,
but can easily be a small Python script or something else.
These work basically everywhere,
and it's not hard to tell someone to do./scripts/test.But even the "scripts" pattern doesn't make senseon every project.
Some frameworks/projects already come with a solution,
like pre-existingpackage.json"scripts".
Do we really want to create makescripts/testthat just runsnpm run test?
Seems dumb.
"I guess we'll use npm scripts on this project..."So, every project inevitably ends up being a little bit different.
But for those of us that have to constantly jump around between those projects,
p smooths out the rough edges in our day-to-day,
and enables us to make per-project decisions about the developer experience
(and reminds us to even be thinking about that in the first place).Bonus: git hooksGit hooks can be a super useful,
but confusing process to use.
Thegistis that they generally aren't shared or set up for each user of a project automatically.
There are some tools likepre-commitorhuskythat really go the extra mile in creating a system for git hooks,
but a lot of our projects don't really warrant that and,
again,
it felt strange to now have a project dependency in that process...
Do we install that thing per-project even if the project doesn't use that language otherwise?
If we install it on our machines outside the project,
is that now a requirement that can't be required?
Is it even possible to run the hook/linter/formatter without that tool?Anyway, p embraces git's (implied) attitude about hooks: they're optional.If a user has p,
then we'll take an extra step to install the git hook for them and put things in place.
It's a nice-to-have.If you don't have p, then at least you can still run your linters/formatters manually if you want (i.e.npm run pre-commit).And if you need torequirethat those checks are run,
no matter who (or what) commits to the project?
Then set them up in CI.
You don't need anything special to do this --
just run your script/command as a step like a non-p user would.It's not fancy,
and it works for us.Inspired byDropseed’sproject-cli (private)Flint Hills Design’sfhd-cli (private)https://github.com/github/scripts-to-rule-them-allhttps://github.com/bkeepers/strappydoohaving too many projects