Even though Bower has worked and continues to work for PureScript, most end user applications benefit greatly by having a static set of dependencies installed. This post will go over the relatively simple steps it takes to upgrade an existing project using Bower to use Psc-Package instead.
Let's review some reasons why you might not want Bower:
- You might want to use a package set to guarantee that all packages you install will work together. Furthermore, you might want to add packages at specific versions that you know work with the rest of the modules in your set.
- Everyone will complain at you forever if you keep using it. Not a very technical reason, but who wants to hear the same complaints day in, day out?
Well, these all seem like pretty normal reasons to not use Bower, right? Let's get started.
Thanks to the hard work of Hardy Jones, you can now install
psc-package through npm. Just
npm install -g psc-package and it'll work!
Go into your project and run
psc-package init to initialize the project with a
psc-package.json. You'll get a file that looks like this:
You might want to choose a different package set to use here. In my case, I have my own package set in my repo with tagged releases, so I have the lines
source edited like so:
One caveat: psc-package packages don't use
purescript- as a prefix and don't specify the version in the dependency list. One easy way for you to get your dependencies is to do the following:
- Go to
- Copy the list of dependencies and paste it into a new buffer
- If you use vim/spacemacs, first you probably want to use
purescript-, and then use
:%norm f:Da,to use normal mode to find
:, delete to the end of the line, and append
,. You probably want to hit
xto delete the last comma, and then use
:%y+to copy the buffer into your clipboard.
- Take your dependencies and paste them into your
psc-package update and it'll figure out what all you need and install them. If you have stuff that's not in here, then you'll have to add stuff to your package set, but thankfully that's not too much work. I'll cover this at the end.
Otherwise, everything should now have been correctly installed and all.
rm -rf bower_components; rm bower.json. Congratulations, you are now Bower-free!
At this point, you should be able to run all
pulp commands without any prefixes whatsoever. If
pulp build doesn't work, then you either need to update your code, find a package set that suits what you're using, or actually go out and ask for help from Twitter #purescript/@jusrin00 or #puresript on the FP Slack (https://fpchat-invite.herokuapp.com/).
If you need to add more dependencies, then nothing more than
psc-package install your-dependency should be required.
Hopefully this has shown you some concrete ways to move from Bower to Psc-Package. Let me know on Twitter or the FP Slack if you need any help!
Tl;dr this blog post in a tweet: https://twitter.com/jusrin00/status/923811954262757376
- My YouTube video on new project setup with Pulp: https://www.youtube.com/watch?v=bNavBHmIknQ
At this point, you probably want to talk to someone, but overall there are only these steps:
package.jsonin the repo to copy an existing spec and change the things as you need, like version, dependencies, etc.
travis.shand break when it starts verifying the set, as you probably don't want to spend all the time verifying the full set.
psc-package verify your-new-packageto verify that package.
- Push the commit in a branch or a tag, whichever you wish.
- Start using this from your projects!