You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
3.3 KiB
95 lines
3.3 KiB
// Generated by CoffeeScript 1.6.2
|
|
var balUtil, pathUtil,
|
|
__hasProp = {}.hasOwnProperty,
|
|
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
|
|
|
balUtil = require('bal-util');
|
|
|
|
pathUtil = require('path');
|
|
|
|
module.exports = function(BasePlugin) {
|
|
var GhpagesPlugin, _ref;
|
|
|
|
return GhpagesPlugin = (function(_super) {
|
|
__extends(GhpagesPlugin, _super);
|
|
|
|
function GhpagesPlugin() {
|
|
_ref = GhpagesPlugin.__super__.constructor.apply(this, arguments);
|
|
return _ref;
|
|
}
|
|
|
|
GhpagesPlugin.prototype.name = 'ghpages';
|
|
|
|
GhpagesPlugin.prototype.config = {
|
|
deployBranch: 'gh-pages',
|
|
environment: 'static'
|
|
};
|
|
|
|
GhpagesPlugin.prototype.consoleSetup = function(opts) {
|
|
var commander, config, consoleInterface, docpad, me;
|
|
|
|
consoleInterface = opts.consoleInterface, commander = opts.commander;
|
|
me = this;
|
|
config = this.config;
|
|
docpad = this.docpad;
|
|
docpad.setInstanceConfig({
|
|
env: config.environment
|
|
});
|
|
commander.command('deploy-ghpages').description("deploys your " + config.environment + " website to the " + config.deployBranch + " branch").action(consoleInterface.wrapAction(function(next) {
|
|
var outGitPath, outPath;
|
|
|
|
docpad.log('info', 'Deployment to GitHub Pages starting...');
|
|
outPath = docpad.config.outPath;
|
|
outGitPath = pathUtil.join(outPath, '.git');
|
|
return balUtil.rmdirDeep(outGitPath, function(err) {
|
|
if (err) {
|
|
return next(err);
|
|
}
|
|
return docpad.action('generate', {
|
|
env: config.environment
|
|
}, function(err) {
|
|
if (err) {
|
|
return next(err);
|
|
}
|
|
return balUtil.spawnCommand('git', ['config', 'remote.origin.url'], function(err, stdout, stderr) {
|
|
var remoteRepoUrl;
|
|
|
|
if (err) {
|
|
return next(err);
|
|
}
|
|
remoteRepoUrl = stdout.replace(/\n/, "");
|
|
return balUtil.spawnCommand('git', ['log', '--oneline'], function(err, stdout, stderr) {
|
|
var gitCommands, lastCommit;
|
|
|
|
if (err) {
|
|
return next(err);
|
|
}
|
|
lastCommit = stdout.split('\n')[0];
|
|
gitCommands = [['init'], ['add', '.'], ['commit', '-m', lastCommit], ['push', '--force', remoteRepoUrl, "master:" + config.deployBranch]];
|
|
return balUtil.spawnCommands('git', gitCommands, {
|
|
cwd: outPath,
|
|
output: true
|
|
}, function(err, stdout, stderr) {
|
|
if (err) {
|
|
return next(err);
|
|
}
|
|
return balUtil.rmdirDeep(outGitPath, function(err) {
|
|
if (err) {
|
|
return next(err);
|
|
}
|
|
docpad.log('info', 'Deployment to GitHub Pages completed successfully');
|
|
return next();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}));
|
|
return this;
|
|
};
|
|
|
|
return GhpagesPlugin;
|
|
|
|
})(BasePlugin);
|
|
};
|