diff --git a/README.md b/README.md index 1a43cfb..5a57e0c 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,15 @@ Then use it in package.json's script section to trigger a build: ``` ### Default behaviour -by default npmts looks for an `./ts/index.ts` and a `./ts/test.ts` that will compile to +by default npmts looks for `./ts/index.ts` and `./ts/test.ts` that will compile to `./index.js` and `./test.js` +#### Declaration files + ### Custom behaviour We are currently building support for custom behaviour with a super simple config file. Check back soon. ## Readme for Devs There is a [README-dev.md](README-dev.md) in the repo. -This is only of interest for you if are looking to improve or build upon this package. \ No newline at end of file +This is only of interest for you when looking to contribute to, improve or build upon this package. \ No newline at end of file diff --git a/compile/compile.js b/compile/compile.js index cad03bf..672f90c 100644 --- a/compile/compile.js +++ b/compile/compile.js @@ -1,25 +1,35 @@ // import gulp -var gulp = require("gulp"); -var gulpTypescript = require("gulp-typescript"); -var gulpInsert = require("gulp-insert"); var plugins = { - beautylog: require("beautylog") + beautylog: require("beautylog"), + gulp: require("gulp"), + g:{ + typescript: require("gulp-typescript"), + insert: require("gulp-insert") + }, + mergeStream: require("merge2") + }; + plugins.beautylog.log('now compiling the mojo.io gulp tasks'); -gulp.task('indexTS', function() { - var stream = gulp.src('../ts/index.ts') - .pipe(gulpTypescript({ - out: "index.js" - })) - .pipe(gulpInsert.prepend('#!/usr/bin/env node\n\n')) - .pipe(gulp.dest("../")); - return stream; +plugins.gulp.task('indexTS', function() { + var tsResult = plugins.gulp.src('../ts/index.ts') + .pipe(plugins.g.typescript({ + out:"index.js", + declaration:true + })); + + return plugins.mergeStream([ + tsResult.dts.pipe(plugins.gulp.dest('../')), + tsResult.js + .pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n')) + .pipe(plugins.gulp.dest('../')) + ]); }); -gulp.task('default',['indexTS'], function() { +plugins.gulp.task('default',['indexTS'], function() { plugins.beautylog.success('Typescript compiled'); }); -gulp.start.apply(gulp, ['default']); \ No newline at end of file +plugins.gulp.start.apply(plugins.gulp, ['default']); \ No newline at end of file diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..e5acb58 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,32 @@ +/// +declare module NpmtsPlugins { + var init: () => { + beautylog: any; + gulp: any; + g: { + typescript: any; + insert: any; + }; + mergeStream: any; + path: any; + smartcli: any; + }; +} +declare module NpmtsPaths { + var init: () => any; +} +declare module NpmtsDefault { + var init: () => void; +} +declare var plugins: { + beautylog: any; + gulp: any; + g: { + typescript: any; + insert: any; + }; + mergeStream: any; + path: any; + smartcli: any; +}; +declare var paths: any; diff --git a/index.js b/index.js index 565c79a..eaeaafe 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,11 @@ var NpmtsPlugins; var plugins = { beautylog: require("beautylog"), gulp: require("gulp"), - gulpTypeScript: require("gulp-typescript"), + g: { + typescript: require("gulp-typescript"), + insert: require("gulp-insert") + }, + mergeStream: require("merge2"), path: require("path"), smartcli: require("smartcli") }; @@ -32,15 +36,21 @@ var NpmtsDefault; (function (NpmtsDefault) { NpmtsDefault.init = function () { plugins.gulp.task("indexTS", function () { - plugins.gulp.src(paths.indexTS) - .pipe(plugins.gulpTypeScript({ - out: "index.js" - })) - .pipe(plugins.gulp.dest(paths.cwd)); + var tsResult = plugins.gulp.src(paths.indexTS) + .pipe(plugins.g.typescript({ + out: "index.js", + declaration: true + })); + return plugins.mergeStream([ + tsResult.dts.pipe(plugins.gulp.dest(paths.cwd)), + tsResult.js + .pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n')) + .pipe(plugins.gulp.dest(paths.cwd)) + ]); }); plugins.gulp.task("testTS", function () { plugins.gulp.src(paths.testTS) - .pipe(plugins.gulpTypeScript({ + .pipe(plugins.g.typescript({ out: "test.js" })) .pipe(plugins.gulp.dest(paths.cwd)); diff --git a/package.json b/package.json index 4baec52..47c5042 100644 --- a/package.json +++ b/package.json @@ -26,10 +26,11 @@ }, "homepage": "https://github.com/pushrocks/npmts#readme", "dependencies": { - "beautylog": "^2.0.2", - "gulp": "^3.9.0", - "gulp-insert": "^0.5.0", - "gulp-typescript": "^2.10.0", + "beautylog": "2.0.2", + "gulp": "3.9.0", + "gulp-insert": "0.5.0", + "gulp-typescript": "2.10.0", + "merge2": "0.3.6", "smartcli": "0.0.11" } } diff --git a/ts/npmts.default.js b/ts/npmts.default.js index b80c053..710c9ef 100644 --- a/ts/npmts.default.js +++ b/ts/npmts.default.js @@ -3,15 +3,21 @@ var NpmtsDefault; (function (NpmtsDefault) { NpmtsDefault.init = function () { plugins.gulp.task("indexTS", function () { - plugins.gulp.src(paths.indexTS) - .pipe(plugins.gulpTypeScript({ - out: "index.js" - })) - .pipe(plugins.gulp.dest(paths.cwd)); + var tsResult = plugins.gulp.src(paths.indexTS) + .pipe(plugins.g.typescript({ + out: "index.js", + declaration: true + })); + return plugins.mergeStream([ + tsResult.dts.pipe(plugins.gulp.dest(paths.cwd)), + tsResult.js + .pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n')) + .pipe(plugins.gulp.dest(paths.cwd)) + ]); }); plugins.gulp.task("testTS", function () { plugins.gulp.src(paths.testTS) - .pipe(plugins.gulpTypeScript({ + .pipe(plugins.g.typescript({ out: "test.js" })) .pipe(plugins.gulp.dest(paths.cwd)); diff --git a/ts/npmts.default.js.map b/ts/npmts.default.js.map index 83de721..4f1dd16 100644 --- a/ts/npmts.default.js.map +++ b/ts/npmts.default.js.map @@ -1 +1 @@ -{"version":3,"file":"npmts.default.js","sourceRoot":"","sources":["npmts.default.ts"],"names":["NpmtsDefault"],"mappings":"AAAA,mCAAmC;AAEnC,IAAO,YAAY,CAwBlB;AAxBD,WAAO,YAAY,EAAC,CAAC;IACNA,iBAAIA,GAAGA;QACd,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACzB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;iBAC1B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;gBACzB,GAAG,EAAE,UAAU;aAClB,CAAC,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{ export var init = function() { plugins.gulp.task("indexTS", function(){ - plugins.gulp.src(paths.indexTS) - .pipe(plugins.gulpTypeScript({ - out: "index.js" - })) - .pipe(plugins.gulp.dest(paths.cwd)) + var tsResult = plugins.gulp.src(paths.indexTS) + .pipe(plugins.g.typescript({ + out:"index.js", + declaration:true + })); + + return plugins.mergeStream([ + tsResult.dts.pipe(plugins.gulp.dest(paths.cwd)), + tsResult.js + .pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n')) + .pipe(plugins.gulp.dest(paths.cwd)) + ]); }); plugins.gulp.task("testTS", function(){ plugins.gulp.src(paths.testTS) - .pipe(plugins.gulpTypeScript({ + .pipe(plugins.g.typescript({ out: "test.js" })) .pipe(plugins.gulp.dest(paths.cwd)) diff --git a/ts/npmts.plugins.js b/ts/npmts.plugins.js index a1ac4d4..eb4e752 100644 --- a/ts/npmts.plugins.js +++ b/ts/npmts.plugins.js @@ -5,7 +5,11 @@ var NpmtsPlugins; var plugins = { beautylog: require("beautylog"), gulp: require("gulp"), - gulpTypeScript: require("gulp-typescript"), + g: { + typescript: require("gulp-typescript"), + insert: require("gulp-insert") + }, + mergeStream: require("merge2"), path: require("path"), smartcli: require("smartcli") }; diff --git a/ts/npmts.plugins.js.map b/ts/npmts.plugins.js.map index 71e1df9..c2fffde 100644 --- a/ts/npmts.plugins.js.map +++ b/ts/npmts.plugins.js.map @@ -1 +1 @@ -{"version":3,"file":"npmts.plugins.js","sourceRoot":"","sources":["npmts.plugins.ts"],"names":["NpmtsPlugins"],"mappings":"AAAA,mCAAmC;AACnC,IAAO,YAAY,CAWlB;AAXD,WAAO,YAAY,EAAC,CAAC;IACNA,iBAAIA,GAAGA;QACd,IAAI,OAAO,GAAG;YACV,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC;YAC/B,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;YACrB,cAAc,EAAE,OAAO,CAAC,iBAAiB,CAAC;YAC1C,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;YACrB,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC;SAChC,CAAC;QACF,MAAM,CAAC,OAAO,CAAC;IACnB,CAAC,CAAAA;AACLA,CAACA,EAXM,YAAY,KAAZ,YAAY,QAWlB"} \ No newline at end of file +{"version":3,"file":"npmts.plugins.js","sourceRoot":"","sources":["npmts.plugins.ts"],"names":["NpmtsPlugins"],"mappings":"AAAA,mCAAmC;AACnC,IAAO,YAAY,CAelB;AAfD,WAAO,YAAY,EAAC,CAAC;IACNA,iBAAIA,GAAGA;QACd,IAAI,OAAO,GAAG;YACV,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC;YAC/B,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;YACrB,CAAC,EAAE;gBACC,UAAU,EAAE,OAAO,CAAC,iBAAiB,CAAC;gBACtC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC;aACjC;YACD,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC;YAC9B,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;YACrB,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC;SAChC,CAAC;QACF,MAAM,CAAC,OAAO,CAAC;IACnB,CAAC,CAAAA;AACLA,CAACA,EAfM,YAAY,KAAZ,YAAY,QAelB"} \ No newline at end of file diff --git a/ts/npmts.plugins.ts b/ts/npmts.plugins.ts index d8337f4..ed0be13 100644 --- a/ts/npmts.plugins.ts +++ b/ts/npmts.plugins.ts @@ -4,7 +4,11 @@ module NpmtsPlugins { var plugins = { beautylog: require("beautylog"), gulp: require("gulp"), - gulpTypeScript: require("gulp-typescript"), + g: { + typescript: require("gulp-typescript"), + insert: require("gulp-insert") + }, + mergeStream: require("merge2"), path: require("path"), smartcli: require("smartcli") };