shell> hg init
I do like to have an option to switch Kohana with new version easily in my projects. To achieve that I unpack downloaded Kohana into kohana directory of my project. I then copy application directory from kohana folder into root of my project, so it is on the same level with kohana directory. The same needs to be done with index.php and .htacess. Structure of my project looks like this after that:
project |- application |- kohana |- .htaccess |- index.php
Now I have to change lines in index.php, which point to "modules" and "system" subdirectories of kohana to point at the right place. It is done by putting "kohana/" in front of them. Now whenever I want to try new version of Kohana with the project I just backup old kohana directory and unpack new Kohana into kohana directory in my project.
Every framework has its specifics. While most of the work is done to test run the project setup, I know it will fail. Inside application directory there are "application/logs" and "application/cache" directories which need to be enabled for writing.
Moreover I do not want to pollute our Mercurial repository with content of mentioned directories as it is not necessary for others. So I want to make sure that nothing stored in there will get into central repository. Which reveals rather unpleasant Mercurial feature, that prevents empty directories to be committed into the repository.
To address these problems I will have to first create an .hgignore file in root of the project to make sure nothing unwanted will be passed to the repository:
application/logs application/cache
Now it's a time for Fabric. I create fabfile.py in root of the project. In the file I create an "init" target to make sure that once anybody gets the project out of the central repository, he can initialize it easily. Here is what I put into fabfile.py:
from fabric.api import local def init(): """Prepares local environment for a project.""" local('mkdir -p application/logs') local('mkdir -p application/cache') local('chmod 777 application/logs') local('chmod 777 application/cache')Now when my colleagues clones/pulls the project from our central Mercurial repository, they just have to run "init" task for the project in a terminal:
shell> fab init
Now the project is ready to be cloned into our central Mercurial repository. To sum up a bit, here is how it looks now:
project |- application |- kohana |- .htaccess |- .htignore |- index.php |- fabfile.py
All files can be now added to the Mercurial repository via:
shell> hg add
Then changes can be commited:
shell> hg ci -m "initializing project"
And now stored to the central repository
.
No comments:
Post a Comment