strider icon indicating copy to clipboard operation
strider copied to clipboard

Allow additional execution build.js defined in package.json

Open PatrickWolleb opened this issue 13 years ago • 8 comments

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

PatrickWolleb avatar Dec 16 '12 12:12 PatrickWolleb

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" }

niallo avatar Dec 17 '12 08:12 niallo

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?

PatrickWolleb avatar Dec 18 '12 13:12 PatrickWolleb

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

niallo avatar Dec 18 '12 13:12 niallo

I have started working on this plugin here:

https://github.com/Strider-CD/strider-custom

Hopefully have something you can try soon.

niallo avatar Dec 18 '12 14:12 niallo

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.

niallo avatar Dec 18 '12 15:12 niallo

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

niallo avatar Dec 18 '12 15:12 niallo

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

PatrickWolleb avatar Mar 10 '13 17:03 PatrickWolleb

Awesome - glad it works!

niallo avatar Mar 12 '13 21:03 niallo