Allow additional execution build.js defined in package.json
I wonder how one can hook in build script before the tests are run. The docs state that strider clones the repo and then calls "npm test".
I've got the following template dir structure |-bin |-design |-docs |-src |---public |-----css |-----img |-----js |---routes
Before I deploy to Heroku I want to run a build script for backend and front end code and copy the optimised files into bin and then deploy bin directory to Heroku.
Thanks for any help, Patrick
Hi Patrick,
npm test is an arbitrary shell command - so you can include a pre-test build step there if you like.
For example you might have the following in your package.json:
"scripts": { "test": "make && ./node_modules/mocha/bin/mocha -R tap" }
Hi Niallo,
Thanks for your help. I am still trying to figure out a way of using strider to deploy my apps. I've got the following directory structure:
.git bin design docs src
src contains the node app for Heroku. Procfile and package.json are inside src. When deploying directly from local machine I use grunt.js to create an optimised version and save it bin. I then push git bin only with the git subtree extension to Heroku. This way I can store design and docs on GitHub but the Heroku only receives the optimised bin directory.
I would to run the entire build process in Strider. Is it possible to run git subtree from Strider after the grunt build has completed?
Ah I see. By default, Strider auto-detects node.js project by looking for a package.json in project root, and always pushes from there. It doesn't know anything about grunt or git subtrees or other stuff like that.
It would require some new code to support your project. However, it wouldn't be hard: Strider is designed to support plugins to solve exactly these kinds of problems!
We could write a simple "worker plugin" to detect a "strider.json" file in which you'd put your custom build steps and then write prepare and deploy implementations which act on that. For example, your strider.json might look like this:
{
"prepare":"grunt build",
"deploy":"git subtree push foo heroku"
}
The strider-sauce "worker plugin" already does something like this: has a custom test function if it finds a particular key in your package.json https://github.com/Strider-CD/strider-sauce/blob/master/worker.js#L207
I have started working on this plugin here:
https://github.com/Strider-CD/strider-custom
Hopefully have something you can try soon.
Ok, if you npm install strider-custom into the same dir as your Strider install and restart Strider, you will now have the strider-custom plugin loaded. Note that you'll need to update your strider-simple-worker package so please npm update strider-simple-worker too.
In your project, you can create a file named strider-custom.json which has optional keys "prepare", "test" and "deploy". These are arbitrary shell commands, so you can put your Grunt code and Heroku deploy code in there.
Try it out and let me know if it works for you. If so, I can document it and add it to the default Strider plugin list.
Here is a sample strider-custom.json I used to test the strider-custom plugin: https://github.com/niallo/strider-custom-sample/blob/master/strider-custom.json
Thank you, it works perfectly with gruntjs and git subtree!
Unfortunately, Heroku don't support installation of git subtree so I installed Strider on EC2 where I could install subtree.
Here my .json https://github.com/SHMEDIALIMITED/web-app-basic/blob/master/strider-custom.json
Awesome - glad it works!