now using gulp-typings

This commit is contained in:
2016-03-12 10:21:16 +01:00
parent 8efa67a4ff
commit 9f74fab2b2
23 changed files with 199 additions and 176 deletions

1
dist/index.js vendored
View File

@@ -1,3 +1,4 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
console.log("**** starting NPMTS ****");
var plugins = require("./npmts.plugins");

121
dist/npmts.compile.js vendored
View File

@@ -1,89 +1,62 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
plugins.beautylog.log("now running custom tasks");
plugins.beautylog.log("now compiling " + "TypeScript".yellow);
var moduleStream = plugins.merge2({ end: false });
/* -------------------------------------------------
* ----------- first install typings ---------------
* ----------- compile TypeScript --------------------------
* ----------------------------------------------- */
var typingsDone = plugins.Q.defer();
var typingsCounter = 0;
var typingsCounterAdvance = function () {
typingsCounter++;
if (typeof config.typings[typingsCounter] != "undefined") {
installTypings();
}
else {
plugins.beautylog.success("custom typings installed successfully");
typingsDone.resolve();
}
};
var installTypings = function () {
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
plugins.typings.install({ production: false, cwd: plugins.path.join(paths.cwd, config.typings[typingsCounter]) })
.then(function () {
typingsCounterAdvance();
}, function () {
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
typingsCounterAdvance();
});
};
installTypings();
/* -------------------------------------------------
* ----------- second compile TS -------------------
* ----------------------------------------------- */
typingsDone.promise.then(function () {
for (var key in config.ts) {
plugins.beautylog.log("now compiling" + key.blue);
var outputPathIsDir;
try {
if (plugins.fs.statSync(plugins.path.join(paths.cwd, config.ts[key])).isDirectory()) {
outputPathIsDir = true;
}
for (var key in config.ts) {
var outputPathIsDir;
try {
if (plugins.fs.statSync(plugins.path.join(paths.cwd, config.ts[key])).isDirectory()) {
outputPathIsDir = true;
}
catch (err) {
outputPathIsDir = false;
}
//do some evaluation of the environment
var outputNameSpecified = (!outputPathIsDir
&& (plugins.path.extname(config.ts[key]) == ".js"));
var outputName = (function () {
if (outputNameSpecified) {
return plugins.path.basename(config.ts[key]);
}
else {
return undefined;
}
})();
var outputDir = (function () {
if (outputNameSpecified) {
return plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]));
}
else {
return plugins.path.join(paths.cwd, config.ts[key]);
}
})();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, key), "!**/typings/**"])
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
.pipe(plugins.g.typescript({
out: outputName,
target: "ES5",
module: "commonjs"
}))
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
.pipe(plugins.gulp.dest(outputDir));
moduleStream.add(stream);
}
moduleStream.on("queueDrain", function () {
plugins.beautylog.success("custom TypeScript installed successfully");
moduleStream.on("finish", function () {
done.resolve(config);
});
moduleStream.end();
catch (err) {
outputPathIsDir = false;
}
//do some evaluation of the environment
var outputNameSpecified = (!outputPathIsDir
&& (plugins.path.extname(config.ts[key]) == ".js"));
var outputName = (function () {
if (outputNameSpecified) {
return plugins.path.basename(config.ts[key]);
}
else {
return undefined;
}
})();
var outputDir = (function () {
if (outputNameSpecified) {
return plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]));
}
else {
return plugins.path.join(paths.cwd, config.ts[key]);
}
})();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, key), "!**/typings/**"])
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
.pipe(plugins.g.typescript({
out: outputName,
target: "ES5",
module: "commonjs"
}))
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
.pipe(plugins.gulp.dest(outputDir));
moduleStream.add(stream);
}
moduleStream.on("queueDrain", function () {
plugins.beautylog.ok("TypeScript is compiled!");
moduleStream.on("finish", function () {
done.resolve(config);
});
moduleStream.end();
});
/*==================== END TYPESCRIPT =====================*/
return done.promise;
};

View File

@@ -1,3 +1,4 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
@@ -16,6 +17,7 @@ exports.run = function () {
break;
default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
}
;
}

20
dist/npmts.install.js vendored Normal file
View File

@@ -0,0 +1,20 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
exports.run = function (configArg) {
var config = configArg;
var done = plugins.Q.defer();
/* -------------------------------------------------
* ----------- install typings ---------------
* ----------------------------------------------- */
plugins.beautylog.log("now installing " + "typings".yellow);
var absoluteTypingsArray = plugins.smartpath.absolute(config.typings, paths.cwd);
plugins.gulp.src(absoluteTypingsArray)
.pipe(plugins.g.typings())
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("typings are installed!");
done.resolve(config);
}, "atEnd"));
return done.promise;
};

4
dist/npmts.jsdoc.js vendored
View File

@@ -1,3 +1,4 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
@@ -13,6 +14,7 @@ var genJsdoc = function (configArg) {
destination: paths.docsDir
}
}, function () {
plugins.beautylog.ok("JsDoc has been generated!");
done.resolve(configArg);
}));
return done.promise;
@@ -42,7 +44,7 @@ var publishDocs = function (configArg) {
plugins.beautylog.error('Error: Git failed');
plugins.shelljs.exit(1);
}
plugins.beautylog.success("Docs have been deployed to GitHub");
plugins.beautylog.ok("JsDoc has been deployed to GitHub!");
done.resolve(configArg);
}
else {

View File

@@ -1,3 +1,4 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
exports.run = function (configArg) {
@@ -8,7 +9,7 @@ exports.run = function (configArg) {
}
if (config.mode == "default") {
config.typings = [
"./ts/"
"./ts/typings.json"
];
config.ts = (_a = {},
_a["./ts/**/*.ts"] = "./dist/",

1
dist/npmts.paths.js vendored
View File

@@ -1,3 +1,4 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = {};

View File

@@ -1,3 +1,4 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = {
beautylog: require("beautylog"),
@@ -10,7 +11,8 @@ var plugins = {
jsdoc3: require("gulp-jsdoc3"),
mocha: require("gulp-mocha"),
sourcemaps: require("gulp-sourcemaps"),
typescript: require("gulp-typescript")
typescript: require("gulp-typescript"),
typings: require("gulp-typings")
},
merge2: require("merge2"),
projectinfo: require("projectinfo"),
@@ -21,6 +23,6 @@ var plugins = {
smartcli: require("smartcli"),
smartenv: require("smartenv"),
smartfile: require("smartfile"),
typings: require("typings")
smartpath: require("smartpath")
};
module.exports = plugins;

View File

@@ -1,6 +1,8 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var NpmtsConfigFile = require("./npmts.configfile");
var NpmtsOptions = require("./npmts.options");
var NpmtsInstall = require("./npmts.install");
var NpmtsCompile = require("./npmts.compile");
var NpmtsJsdoc = require("./npmts.jsdoc");
var NpmtsTests = require("./npmts.tests");
@@ -8,6 +10,7 @@ exports.run = function () {
var promisechain;
NpmtsConfigFile.run()
.then(NpmtsOptions.run)
.then(NpmtsInstall.run)
.then(NpmtsCompile.run)
.then(NpmtsJsdoc.run)
.then(NpmtsTests.run);

8
dist/npmts.tests.js vendored
View File

@@ -1,3 +1,4 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
@@ -20,9 +21,13 @@ exports.run = function (configArg) {
var coveralls = function () {
plugins.beautylog.log("now uploading coverage data to coveralls");
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
.pipe(plugins.g.coveralls());
.pipe(plugins.g.coveralls())
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("coverage data has beend uploaded Coveralls!");
}, "atEnd"));
return stream;
};
plugins.beautylog.log("now starting tests");
istanbul().on("finish", function () {
mocha().on("finish", function () {
if (plugins.smartenv.getEnv().isTravis && config.coveralls) {
@@ -31,6 +36,7 @@ exports.run = function (configArg) {
});
}
else {
plugins.beautylog.ok("Tests have passed!");
done.resolve(config);
}
});