tscoverage/ts/npmts.jsdoc.ts

65 lines
2.1 KiB
TypeScript
Raw Normal View History

2016-05-25 05:23:48 +02:00
import "typings-global";
2016-02-22 22:22:39 +01:00
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
2016-05-17 02:32:40 +02:00
import {npmtsOra} from "./npmts.promisechain";
2016-02-22 22:22:39 +01:00
2016-03-26 14:08:48 +01:00
let genJsdoc = function(configArg){
let done = plugins.Q.defer();
npmtsOra.text("now generating " + "JsDoc documentation".yellow);
2016-02-22 22:22:39 +01:00
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 18:35:28 +01:00
}, function(){
2016-03-14 04:53:35 +01:00
plugins.beautylog.ok("JsDoc documentation has been generated!");
2016-02-23 18:35:28 +01:00
done.resolve(configArg)
}));
2016-02-22 22:22:39 +01:00
return done.promise;
};
2016-03-26 14:08:48 +01:00
export let publishDocs = function(configArg){
let done = plugins.Q.defer();
let gitUrl = plugins.projectinfo.npm(
2016-02-23 18:10:03 +01:00
paths.cwd,
{
gitAccessToken:process.env.GITHUB_TOKEN
}
).git.httpsUrl;
2016-02-22 22:22:39 +01:00
2016-03-26 14:08:48 +01:00
let deployScript = ""
2016-02-23 18:10:03 +01:00
+ "cd " + paths.docsDir + " "
+ "&& 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 18:10:03 +01:00
+ "&& git push --force --quiet "
+ "\"" + gitUrl + "\" "
+ "master:gh-pages " + "> /dev/null 2>&1";
2016-02-22 22:22:39 +01:00
2016-03-26 17:25:45 +01:00
plugins.beautylog.log("now publishing JsDoc documentation to GitHub");
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('Git failed!');
plugins.shelljs.exit(1);
2016-02-22 22:22:39 +01:00
}
2016-03-26 17:25:45 +01:00
plugins.beautylog.ok("JsDoc documentation has been deployed to GitHub!");
done.resolve(configArg);
2016-02-22 22:22:39 +01:00
return done.promise;
};
2016-03-26 14:08:48 +01:00
export let run = function(configArg){
let done = plugins.Q.defer();
2016-02-23 18:35:28 +01:00
genJsdoc(configArg)
2016-02-22 22:22:39 +01:00
.then(done.resolve);
return done.promise;
};