We have been using command line scripts and tools since long but it’s only recently that we discovered how much they can help productivity.
We are actively working on our product KodeCRM and a part of the work is developing, maintaining and releasing updates to modules/extensions for integration with different opensource ecommerce platforms such as Opencart, Magento etc. During the last few weeks one glaring pain point we have found in this entire process is that of quickly setting up environments for testing and debugging whenever an update is made to the extensions (for various reasons such as bug fixes, support for newer versions of the platforms or api changes) and it needs to be tested on multiple versions of multiple platforms for compatibility just before releasing.
One thing that most of the OS platforms that we develop modules for have in common is a web based installation wizard. Being written in PHP, all the user needs to do is drop the files somewhere inside the document root and point the browser to the url. The installation wizard shows up for the first time and guides the user through a sequence of clicks and literally installs itself.
Now this is awesome, particularly for a non-technical user trying to do a DIY installation for evaluating their options. But for developers like us, who need to do it many times, it means a lot of clicks and frustration! In this case it’s significantly faster to use command line than the GUI. Because where there is repetition of tasks, the ability to record actions comes in handy. And command line interface inherently supports recording of actions to some extent by means of scripts.
To alleviate the pain, we have written a command line installer script for opencart that takes some arguments and sets up an instance of Opencart locally. Such a script already existed for Magento which is really where we got the inspiration from for writing one for Opencart.
To automate further, there are simple shell scripts written on top of these installer scripts. They take care of things like downloading the platform files, moving them to the document root of the local server, ensuring that certain files have sufficient permissions, setting up the database, adding test data to the database and finally adding the KodeCRM extension files. After all this is done the script spits out some links to the console. All that’s left to be done now is to open them in a browser and start testing. In future an interesting experiment would be to take it to the next level by automating the testing part too by using Selenium.
Talking of repeated tasks there is one more thing that’s automated using scripts which is creating a release or zip package of the files so that the extension can be hosted for download.
All these tools have been of immense help to us and it’s hard to imagine now how we could live without them earlier. So if you are a developer, it can’t be stressed enough that you should automate day-to-day tasks by writing command line scripts. It really goes without saying that your deployment process must be automated. If you don’t know shell scripting, learn some basics or use whichever scripting language you are familiar with eg. python, php, ruby, perl etc.
All our scripts mentioned above are open source and can be found in the git repositories of the respective modules on github. The Opencart command line installer can be found here. We opened a pull request to the main Opencart project on github and are super happy that it’s been merged into the main project (Yay! )
For more info and updates about opensource code released by us, check out our organization page on github