shipitjs / shipit-deploy

Set of deployment tasks for Shipit based on git and rsync commands.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create configuration variables to "current" and "releases"

j1v3WKF opened this issue · comments

For some deployments, it is helpful to be able to customize 'shipit.releasesPath' and 'shipit.currentPath' variables...

Not having found solutions I created options in shipfile.js, like this :

    shipit.initConfig({
        default: {
            ...
            currentPath: 'mycurrent',
            releasesPath: 'mycurrent_releases',
          ...
   )};

And I boot these options in task/deploys/publish.js

    function updateSymbolicLink() {
      shipit.log('Publishing release "%s"', shipit.releasePath);

      var relativeReleasePath = path.join('' + shipit.config.releasesPath + '', shipit.releaseDirname);

      return shipit.remote('cd ' + shipit.config.deployTo + ' && ln -nfs ' + relativeReleasePath + ' ' + shipit.config.currentPath + '')
      .then(function () {
        shipit.log(chalk.green('Release published.'));
      });
    }

and in lib/init.js

module.exports = function(shipit) {
  shipit.currentPath = path.join(shipit.config.deployTo, '' + shipit.config.currentPath + '');
  shipit.releasesPath = path.join(shipit.config.deployTo, '' + shipit.config.releasePath + '');
  shipit.config.gitLogFormat = shipit.config.gitLogFormat || '%h: %s - %an';
  _.assign(shipit.constructor.prototype, require('./shipit'));

  return shipit;
};

It works well for deploy and rollback function.

Is there an easier way or do I complete my fork and propose a PR ?

I added the management of a default vaue and I just issue a Pul Request on #93

Can you explain why is it important for you to customize these two paths?

In my current professional setup, I have a file index.php which provides a menu to differents repo which are web applications.

So the Apache DocmentRoot is set to this path and it can not be changed because it would involve too much change in the overall system.

Also my technical manager wants realeases are store in a different path from that of the Document Root.

So, I implement this options to meet these requirements while being able to benefit from the power of shipit-deploy.

Also my last commit makes this implementation as an optional, like this

  if ( shipit.config.currentPath == undefined )
    shipit.config.currentPath = 'current';

  if ( shipit.config.releasesPath == undefined )
    shipit.config.releasesPath = 'releases';

for .gitignore, the .idea actually have nothing to do there, sorry

OK, can you please just fix the PR and I will merge it.