project-butler: An easy tool to manage multiple projects
Tags: node, npm, cli, tools
Published: 2020-09-21 08:35:29


In my time of "silence" lately I have been working on getting `project-butler` to a final release.

{% github activenode/project-butler %}

## tldr
> `npm i project-butler -g` will install a terminal alias called `p` with which you can switch between projects without `cd` and without even writing out the full name. E.g. switch to your `/bla/foo/todolist` by simply calling `p todo`

It also reads the `package.json` if exists and the existing `scripts` and can run them if needed.

## Why?

If you are like me you will probably have multiple projects laying around, probably in your home directory somewhere below `~/codestuff/...` .

If I know exactly that I want to work on e.g. `project-butler` I dont want to `cd` into the directory but i just wanted to go like `p but` or even `p b` (whatever fits me best).

I wanted to make `project-butler` as universal as it can get such that in the future it can complement all of the other tools that I am having.

## How it works

`project-butler` will create a hidden directory called `.project-butler` in your home directory and store the configuration.

In the configuration it will simply create a table with mappings from aliases -> project.

Imagine it like that:

| Aliases        | Mapped path                 |
| -------------- | --------------------------- |
| todolist,todos | ~/my-stuff/angular/todolist |
| butler,foobar  | ~/my-stuff/project-butler   |


The above table would indiciate that calling `p todos` or even `p dos` (since there is a "next-best-match-search") would always bring you to the angular todolist directory.



### Adding a project 
![Adding a project in project-butler](https://dev-to-uploads.s3.amazonaws.com/i/z44ro4d12lpug7x20wyr.gif)

`p add [aliases...]` if you are in the directory that you want to add
`p add -d ./relative/path [aliases...]` if you are outside of the directory

If you set the optional param `aliases` you can map the directory to whatever you want e.g.
`p add my-alias` and then you can open it with `p my-alias`.

Calling `p add` for the same directory multiple times will simply update it.

### Removing an alias from a project

`p remove alias` - since aliases are unique you dont have to be in the directory nor do you have to provide the directory

![Removing a project in project-butler](https://dev-to-uploads.s3.amazonaws.com/i/ix8djkkjx99dgq8g0d9g.gif)

### Removing a complete project from the list
`p remove alias -a` will remove ALL aliases and therefore the mapping. 

Alternative version: `p project-name && p remove` will jump to the project and then remove it.

### Calling an npm script with `project-butler`

Make sure that you have added the project directory to project butler.

Now you can go to the project with `p project-alias` and simply call `p script-name`. It will read the `package.json` and try to run the `script-name`. If it does not find it it will instead try to find the fitting project with that name.

### List all existing mappings
`p list-all`


## What are YOU missing in `project-butler`?

I know that at this very point project-butler is just at the start of its path and it can go a good way to become an even better daily helper.

Is there anything you can imagine this tool should solve for you? Just comment below or even try a detailed explanation on the GitHub Issues and even potentially try to contribute if you want: https://github.com/activenode/project-butler/issues