2016-02-22 21:22:39 +00:00
|
|
|
/// <reference path="./typings/main.d.ts" />
|
|
|
|
import plugins = require("./npmts.plugins");
|
|
|
|
import paths = require("./npmts.paths");
|
|
|
|
|
2016-02-23 17:35:28 +00:00
|
|
|
var genJsdoc = function(configArg){
|
2016-02-22 21:22:39 +00:00
|
|
|
var done = plugins.Q.defer();
|
|
|
|
plugins.beautylog.log("now generating " + "JsDoc documentation".blue);
|
|
|
|
plugins.gulp.src([
|
|
|
|
plugins.path.join(paths.cwd,"README.md"),
|
|
|
|
plugins.path.join(paths.distDir,"**/*.js")
|
|
|
|
])
|
|
|
|
.pipe(plugins.g.jsdoc3({
|
|
|
|
opts: {
|
|
|
|
destination: paths.docsDir
|
|
|
|
}
|
2016-02-23 17:35:28 +00:00
|
|
|
}, function(){
|
|
|
|
done.resolve(configArg)
|
|
|
|
}));
|
2016-02-22 21:22:39 +00:00
|
|
|
return done.promise;
|
|
|
|
};
|
|
|
|
|
2016-02-23 17:35:28 +00:00
|
|
|
var publishDocs = function(configArg){
|
2016-02-22 21:22:39 +00:00
|
|
|
var done = plugins.Q.defer();
|
2016-02-23 17:10:03 +00:00
|
|
|
var gitUrl = plugins.projectinfo.npm(
|
|
|
|
paths.cwd,
|
|
|
|
{
|
|
|
|
gitAccessToken:process.env.GITHUB_TOKEN
|
|
|
|
}
|
|
|
|
).git.httpsUrl;
|
2016-02-22 21:22:39 +00:00
|
|
|
|
2016-02-23 17:10:03 +00:00
|
|
|
var deployScript = ""
|
|
|
|
+ "cd " + paths.docsDir + " "
|
2016-02-23 17:58:44 +00:00
|
|
|
+ "&& git init " + "> /dev/null 2>&1 "
|
|
|
|
+ "&& git config user.name \"TRAVIS CI\" " + "> /dev/null 2>&1 "
|
|
|
|
+ "&& git config user.email \"travis@shipzone.io\" " + "> /dev/null 2>&1 "
|
|
|
|
+ "&& git add . " + "> /dev/null 2>&1 "
|
|
|
|
+ "&& git commit -m \"Deploy to GitHub Pages\" " + "> /dev/null 2>&1 "
|
2016-02-23 17:10:03 +00:00
|
|
|
+ "&& git push --force --quiet "
|
|
|
|
+ "\"" + gitUrl + "\" "
|
2016-02-23 17:58:44 +00:00
|
|
|
+ "master:gh-pages " + "> /dev/null 2>&1";
|
2016-02-22 21:22:39 +00:00
|
|
|
|
2016-02-25 07:39:38 +00:00
|
|
|
if(plugins.smartenv.getEnv().isTravis && configArg.docs && configArg.docs.publish){
|
|
|
|
plugins.beautylog.log("now publishing docs to GitHub");
|
2016-02-22 21:22:39 +00:00
|
|
|
if (!plugins.shelljs.which('git')) {
|
|
|
|
plugins.beautylog.error('Git is not installed');
|
|
|
|
plugins.shelljs.exit(1);
|
|
|
|
} else if (plugins.shelljs.exec(deployScript).code !== 0) {
|
|
|
|
plugins.beautylog.error('Error: Git failed');
|
|
|
|
plugins.shelljs.exit(1);
|
|
|
|
}
|
2016-02-23 19:02:07 +00:00
|
|
|
plugins.beautylog.success("Docs have been deployed to GitHub");
|
2016-02-23 17:35:28 +00:00
|
|
|
done.resolve(configArg);
|
2016-02-22 21:22:39 +00:00
|
|
|
} else {
|
2016-02-23 17:35:28 +00:00
|
|
|
done.resolve(configArg);
|
2016-02-22 21:22:39 +00:00
|
|
|
}
|
|
|
|
return done.promise;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-02-23 17:35:28 +00:00
|
|
|
export var run = function(configArg){
|
2016-02-22 21:22:39 +00:00
|
|
|
var done = plugins.Q.defer();
|
2016-02-23 17:35:28 +00:00
|
|
|
genJsdoc(configArg)
|
2016-02-22 21:22:39 +00:00
|
|
|
.then(publishDocs)
|
|
|
|
.then(done.resolve);
|
|
|
|
return done.promise;
|
|
|
|
};
|