tscoverage/dist/npmts.jsdoc.js

56 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-03-12 09:21:16 +00:00
"use strict";
2016-02-22 21:22:39 +00:00
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var 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 () {
2016-03-14 03:53:35 +00:00
plugins.beautylog.ok("JsDoc documentation has been generated!");
2016-02-23 17:35:28 +00:00
done.resolve(configArg);
}));
2016-02-22 21:22:39 +00:00
return done.promise;
};
2016-03-26 13:08:48 +00:00
exports.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;
var deployScript = ""
+ "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 17:10:03 +00:00
+ "&& git push --force --quiet "
+ "\"" + gitUrl + "\" "
+ "master:gh-pages " + "> /dev/null 2>&1";
2016-03-26 16:35:55 +00: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);
2016-02-22 21:22:39 +00:00
}
2016-03-26 16:35:55 +00:00
else if (plugins.shelljs.exec(deployScript).code !== 0) {
plugins.beautylog.error('Git failed!');
plugins.shelljs.exit(1);
2016-02-22 21:22:39 +00:00
}
2016-03-26 16:35:55 +00:00
plugins.beautylog.ok("JsDoc documentation has been deployed to GitHub!");
done.resolve(configArg);
2016-02-22 21:22:39 +00:00
return done.promise;
};
2016-02-23 17:35:28 +00:00
exports.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(done.resolve);
return done.promise;
};