now using gulp-typings
This commit is contained in:
@ -4,89 +4,66 @@ import paths = require("./npmts.paths");
|
||||
export var 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 ---------------
|
||||
* ----------------------------------------------- */
|
||||
var typingsDone = plugins.Q.defer();
|
||||
var typingsCounter:number = 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:boolean;
|
||||
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:boolean = (
|
||||
!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.g.header('#!/usr/bin/env node\n\n'))
|
||||
.pipe(plugins.gulp.dest(outputDir));
|
||||
moduleStream.add(stream);
|
||||
/* -------------------------------------------------
|
||||
* ----------- compile TypeScript --------------------------
|
||||
* ----------------------------------------------- */
|
||||
for (var key in config.ts) {
|
||||
var outputPathIsDir:boolean;
|
||||
try {
|
||||
if(plugins.fs.statSync(plugins.path.join(paths.cwd,config.ts[key])).isDirectory()){
|
||||
outputPathIsDir = true;
|
||||
}
|
||||
}
|
||||
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:boolean = (
|
||||
!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.g.header('#!/usr/bin/env node\n\n'))
|
||||
.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;
|
||||
};
|
||||
|
@ -16,6 +16,7 @@ export var run = function(){
|
||||
break;
|
||||
default:
|
||||
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
||||
process.exit(1);
|
||||
};
|
||||
} else {
|
||||
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
||||
|
19
ts/npmts.install.ts
Normal file
19
ts/npmts.install.ts
Normal file
@ -0,0 +1,19 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import plugins = require("./npmts.plugins");
|
||||
import paths = require("./npmts.paths");
|
||||
export var run = function(configArg){
|
||||
var config = configArg;
|
||||
var done = plugins.Q.defer();
|
||||
/* -------------------------------------------------
|
||||
* ----------- install typings ---------------
|
||||
* ----------------------------------------------- */
|
||||
plugins.beautylog.log("now installing " + "typings".yellow);
|
||||
let 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;
|
||||
};
|
@ -14,6 +14,7 @@ var genJsdoc = function(configArg){
|
||||
destination: paths.docsDir
|
||||
}
|
||||
}, function(){
|
||||
plugins.beautylog.ok("JsDoc has been generated!");
|
||||
done.resolve(configArg)
|
||||
}));
|
||||
return done.promise;
|
||||
@ -48,7 +49,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 {
|
||||
done.resolve(configArg);
|
||||
|
@ -8,7 +8,7 @@ export var run = function(configArg){
|
||||
}
|
||||
if (config.mode == "default"){
|
||||
config.typings = [
|
||||
"./ts/"
|
||||
"./ts/typings.json"
|
||||
];
|
||||
config.ts = {
|
||||
["./ts/**/*.ts"]: "./dist/",
|
||||
|
@ -10,7 +10,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"),
|
||||
@ -22,6 +23,6 @@ var plugins = {
|
||||
smartcli: require("smartcli"),
|
||||
smartenv: require("smartenv"),
|
||||
smartfile: require("smartfile"),
|
||||
typings: require("typings")
|
||||
smartpath: require("smartpath")
|
||||
};
|
||||
export = plugins;
|
@ -1,6 +1,7 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import NpmtsConfigFile = require("./npmts.configfile");
|
||||
import NpmtsOptions = require("./npmts.options");
|
||||
import NpmtsInstall = require("./npmts.install");
|
||||
import NpmtsCompile = require("./npmts.compile");
|
||||
import NpmtsJsdoc = require("./npmts.jsdoc");
|
||||
import NpmtsTests = require("./npmts.tests");
|
||||
@ -8,6 +9,7 @@ export var run = function(){
|
||||
var promisechain;
|
||||
NpmtsConfigFile.run()
|
||||
.then(NpmtsOptions.run)
|
||||
.then(NpmtsInstall.run)
|
||||
.then(NpmtsCompile.run)
|
||||
.then(NpmtsJsdoc.run)
|
||||
.then(NpmtsTests.run);
|
||||
|
@ -26,10 +26,14 @@ export var 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){
|
||||
@ -37,6 +41,7 @@ export var run = function(configArg) {
|
||||
done.resolve(config);
|
||||
})
|
||||
} else {
|
||||
plugins.beautylog.ok("Tests have passed!");
|
||||
done.resolve(config);
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user