Compare commits

..

19 Commits

Author SHA1 Message Date
56841d5bb0 3.0.2 2016-02-18 12:55:35 +01:00
40301ede35 disable declaration files for now 2016-02-18 12:55:24 +01:00
70213b04bc disable declaration files for now 2016-02-18 12:55:00 +01:00
5160aab180 3.0.1 2016-02-17 06:04:02 +01:00
e8806e548b fix coverage 2016-02-17 06:00:12 +01:00
fcdaad540e fix coverage 2016-02-17 05:59:29 +01:00
6f33b1f5ef 3.0.0 2016-02-17 05:51:55 +01:00
45418d6049 update test 2016-02-17 05:51:51 +01:00
4261ee3687 cleanup 2016-02-17 05:50:12 +01:00
9fc3606163 cleanup 2016-02-17 05:49:10 +01:00
2436b30605 update default behaviour 2016-02-17 05:45:42 +01:00
9ad59704be 2.4.1 2016-02-17 04:26:44 +01:00
29f3832d63 switch to commonjs module as default 2016-02-17 04:26:26 +01:00
2d82a3a037 2.4.0 2016-02-17 01:48:38 +01:00
4806f5ceff updated readme 2016-02-17 01:40:01 +01:00
f2ef982189 added sourcemap support 2016-02-17 01:16:21 +01:00
5d6ead017b 2.3.2 2016-02-16 11:29:07 +01:00
1c2b4e421d fix compile script 2016-02-16 11:28:57 +01:00
6cf7d2ca0b update test 2016-02-16 11:14:05 +01:00
25 changed files with 72 additions and 53 deletions

2
.gitignore vendored

@ -6,3 +6,5 @@ test/**/typings/
test/**/coverage/ test/**/coverage/
ts/*.js ts/*.js
ts/*.js.map ts/*.js.map
.DS_Store

@ -30,7 +30,7 @@ Then use it in package.json's script section to trigger a build:
**Execution order of tasks** **Execution order of tasks**
1. Install typings 1. Install typings
2. Compile TypeScript 2. Transpile TypeScript with inline sourcemaps
3. Create Declaration Files 3. Create Declaration Files
4. Instrumentalize created JavaScript files with istanbul 4. Instrumentalize created JavaScript files with istanbul
5. Run Tests 5. Run Tests
@ -43,8 +43,10 @@ Then use it in package.json's script section to trigger a build:
You can then reference the ./ts/typings/main.d.ts file in your TypeScript code. You can then reference the ./ts/typings/main.d.ts file in your TypeScript code.
#### TypeScript #### TypeScript
by default npmts looks for `./ts/index.ts` and `./ts/test.ts` that will compile to by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
`./index.js` and `./test.js` `./dist/*.js` and `./test/test.js`
Use commonjs module system for wiring up files.
#### Declaration files #### Declaration files
**npmts** also creates an `index.d.ts` declaration file by default. **npmts** also creates an `index.d.ts` declaration file by default.
@ -62,6 +64,8 @@ npmts instrumentalizes the created JavaScript code to create a coverage report.
When Typings have been installed, TypeScript + Declaration files have been transpiled and the resulting JS has been instrumentalized, When Typings have been installed, TypeScript + Declaration files have been transpiled and the resulting JS has been instrumentalized,
npmts runs `.test/test.js` with mocha. npmts runs `.test/test.js` with mocha.
Any errors will be shown with reference to their originating source in TypeScript.
When requiring the module from other TypeScript files, When requiring the module from other TypeScript files,
the TypeScript Compiler will use the declaration file to resolve typings. the TypeScript Compiler will use the declaration file to resolve typings.

@ -4,7 +4,7 @@ var plugins = {
gulp: require("gulp"), gulp: require("gulp"),
g:{ g:{
typescript: require("gulp-typescript"), typescript: require("gulp-typescript"),
insert: require("gulp-insert") header: require("gulp-header")
}, },
mergeStream: require("merge2") mergeStream: require("merge2")
@ -23,7 +23,7 @@ plugins.gulp.task('indexTS', function() {
return plugins.mergeStream([ return plugins.mergeStream([
tsResult.dts.pipe(plugins.gulp.dest('../')), tsResult.dts.pipe(plugins.gulp.dest('../')),
tsResult.js tsResult.js
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n')) .pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest('../')) .pipe(plugins.gulp.dest('../'))
]); ]);
}); });

4
index.d.ts vendored

@ -9,9 +9,11 @@ declare module NpmtsPlugins {
header: any; header: any;
istanbul: any; istanbul: any;
mocha: any; mocha: any;
sourcemaps: any;
typescript: any; typescript: any;
}; };
mergeStream: any; mergeStream: any;
sourceMapSupport: any;
path: any; path: any;
q: any; q: any;
smartcli: any; smartcli: any;
@ -46,9 +48,11 @@ declare var plugins: {
header: any; header: any;
istanbul: any; istanbul: any;
mocha: any; mocha: any;
sourcemaps: any;
typescript: any; typescript: any;
}; };
mergeStream: any; mergeStream: any;
sourceMapSupport: any;
path: any; path: any;
q: any; q: any;
smartcli: any; smartcli: any;

@ -13,9 +13,11 @@ var NpmtsPlugins;
header: require("gulp-header"), header: require("gulp-header"),
istanbul: require("gulp-istanbul"), istanbul: require("gulp-istanbul"),
mocha: require("gulp-mocha"), mocha: require("gulp-mocha"),
sourcemaps: require("gulp-sourcemaps"),
typescript: require("gulp-typescript") typescript: require("gulp-typescript")
}, },
mergeStream: require("merge2"), mergeStream: require("merge2"),
sourceMapSupport: require("source-map-support").install(),
path: require("path"), path: require("path"),
q: require("q"), q: require("q"),
smartcli: require("smartcli"), smartcli: require("smartcli"),
@ -83,8 +85,8 @@ var NpmtsOptions;
"./ts/" "./ts/"
]; ];
config.ts = (_a = {}, config.ts = (_a = {},
_a["./ts/index.ts"] = "./index.js", _a["./ts/**/*.ts"] = "./dist/",
_a["./ts/test.ts"] = "./test/test.js", _a["./test/test.ts"] = "./test/",
_a _a
); );
config.test = ["./index.js"]; config.test = ["./index.js"];
@ -165,15 +167,18 @@ var NpmtsCompile;
return plugins.path.join(paths.cwd, config.ts[key]); return plugins.path.join(paths.cwd, config.ts[key]);
} }
})(); })();
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd, key)) var tsStream = 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({ .pipe(plugins.g.typescript({
out: outputName, out: outputName,
declaration: true, declaration: true,
target: "ES5" target: "ES5",
module: "commonjs"
})); }));
var stream = plugins.mergeStream([ var stream = plugins.mergeStream([
tsStream.dts.pipe(plugins.gulp.dest(outputDir)), //tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
tsStream.js tsStream.js
.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.g.header('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest(outputDir)) .pipe(plugins.gulp.dest(outputDir))
]); ]);
@ -197,7 +202,7 @@ var NpmtsTests;
var done = plugins.q.defer(); var done = plugins.q.defer();
var config = configArg; var config = configArg;
var istanbul = function () { var istanbul = function () {
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "index.js")]) var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
.pipe(plugins.g.istanbul()) .pipe(plugins.g.istanbul())
.pipe(plugins.g.istanbul.hookRequire()); .pipe(plugins.g.istanbul.hookRequire());
return stream; return stream;

@ -1,6 +1,6 @@
{ {
"name": "npmts", "name": "npmts",
"version": "2.3.1", "version": "3.0.2",
"description": "write npm modules with TypeScript", "description": "write npm modules with TypeScript",
"main": "index.js", "main": "index.js",
"typings": "./index.d.ts", "typings": "./index.d.ts",
@ -33,12 +33,14 @@
"gulp-header": "^1.7.1", "gulp-header": "^1.7.1",
"gulp-istanbul": "^0.10.3", "gulp-istanbul": "^0.10.3",
"gulp-mocha": "^2.2.0", "gulp-mocha": "^2.2.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-typescript": "2.11.0", "gulp-typescript": "2.11.0",
"gulp-typings": "0.0.0", "gulp-typings": "0.0.0",
"merge2": "1.0.1", "merge2": "1.0.1",
"q": "^1.4.1", "q": "^1.4.1",
"smartcli": "0.0.11", "smartcli": "0.0.11",
"smartfile": "0.0.11", "smartfile": "0.0.11",
"source-map-support": "^0.4.0",
"typings": "^0.6.8" "typings": "^0.6.8"
} }
} }

@ -1,4 +1,4 @@
/// <reference path="ts/typings/main.d.ts" /> /// <reference path="typings/main.d.ts" />
declare var testplugin: { declare var testplugin: {
logSomething: () => void; logSomething: () => void;
}; };

11
test/assets/dist/index.js vendored Normal file

@ -0,0 +1,11 @@
#!/usr/bin/env node
/// <reference path="./typings/main.d.ts" />
var testplugin = {
logSomething: function () {
console.log("only function executed");
}
};
module.exports = testplugin;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxudmFyIHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

@ -1,9 +0,0 @@
#!/usr/bin/env node
/// <reference path="./typings/main.d.ts" />
var testplugin = {
logSomething: function () {
console.log("only function executed");
}
};
module.exports = testplugin;

@ -1,6 +1,6 @@
{ {
"name": "test", "name": "test",
"version": "1.0.0", "version": "2.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -8,6 +8,5 @@
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {}
}
} }

BIN
test/assets/test/.DS_Store vendored Normal file

Binary file not shown.

@ -1,2 +1,2 @@
/// <reference path="ts/typings/main.d.ts" /> /// <reference path="../ts/typings/main.d.ts" />
declare var testplugin: any; declare var testplugin: any;

@ -1,8 +1,8 @@
#!/usr/bin/env node #!/usr/bin/env node
/// <reference path="./typings/main.d.ts" /> /// <reference path="../ts/typings/main.d.ts" />
console.log("**** starting test ****"); console.log("**** starting test ****");
var testplugin = require("../index.js"); var testplugin = require("../dist/index.js");
describe("testplugins", function () { describe("testplugins", function () {
describe(".logSomething", function () { describe(".logSomething", function () {
it("should log something", function () { it("should log something", function () {
@ -10,3 +10,5 @@ describe("testplugins", function () {
}); });
}); });
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELE9BQU8sQ0FBQyxHQUFHLENBQUMseUJBQXlCLENBQUMsQ0FBQztBQUN2QyxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQztBQUM3QyxRQUFRLENBQUMsYUFBYSxFQUFDO0lBQ25CLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsRUFBRSxDQUFDLHNCQUFzQixFQUFDO1lBQ3RCLFVBQVUsQ0FBQyxZQUFZLEVBQUUsQ0FBQTtRQUM3QixDQUFDLENBQUMsQ0FBQztJQUNQLENBQUMsQ0FBQyxDQUFDO0FBQ1AsQ0FBQyxDQUFDLENBQUMiLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuLi90cy90eXBpbmdzL21haW4uZC50c1wiIC8+XG5jb25zb2xlLmxvZyhcIioqKiogc3RhcnRpbmcgdGVzdCAqKioqXCIpO1xudmFyIHRlc3RwbHVnaW4gPSByZXF1aXJlKFwiLi4vZGlzdC9pbmRleC5qc1wiKTtcbmRlc2NyaWJlKFwidGVzdHBsdWdpbnNcIixmdW5jdGlvbigpe1xuICAgIGRlc2NyaWJlKFwiLmxvZ1NvbWV0aGluZ1wiLGZ1bmN0aW9uKCl7XG4gICAgICAgIGl0KFwic2hvdWxkIGxvZyBzb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgdGVzdHBsdWdpbi5sb2dTb21ldGhpbmcoKVxuICAgICAgICB9KTtcbiAgICB9KTtcbn0pOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==

@ -0,0 +1 @@
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AACvC,IAAI,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC7C,QAAQ,CAAC,aAAa,EAAC;IACnB,QAAQ,CAAC,eAAe,EAAC;QACrB,EAAE,CAAC,sBAAsB,EAAC;YACtB,UAAU,CAAC,YAAY,EAAE,CAAA;QAC7B,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

@ -1,6 +1,6 @@
/// <reference path="./typings/main.d.ts" /> /// <reference path="../ts/typings/main.d.ts" />
console.log("**** starting test ****"); console.log("**** starting test ****");
var testplugin = require("../index.js"); var testplugin = require("../dist/index.js");
describe("testplugins",function(){ describe("testplugins",function(){
describe(".logSomething",function(){ describe(".logSomething",function(){
it("should log something",function(){ it("should log something",function(){

@ -0,0 +1,8 @@
{
"ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
}
}

@ -1,11 +0,0 @@
/// <reference path="./typings/main.d.ts" />
console.log("**** starting test ****");
var testplugin = require("../index.js");
describe("testplugins", function () {
describe(".logSomething", function () {
it("should log something", function () {
testplugin.logSomething();
});
});
});
//# sourceMappingURL=test.js.map

@ -1 +0,0 @@
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AACvC,IAAI,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACxC,QAAQ,CAAC,aAAa,EAAC;IACnB,QAAQ,CAAC,eAAe,EAAC;QACrB,EAAE,CAAC,sBAAsB,EAAC;YACtB,UAAU,CAAC,YAAY,EAAE,CAAA;QAC7B,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

@ -1,6 +1,7 @@
{ {
"ambientDependencies": { "ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777", "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d", "colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777" "vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
} }

@ -1 +0,0 @@
declare var something: string;

@ -1,3 +0,0 @@
#!/usr/bin/env node
var something = "something";

@ -67,15 +67,18 @@ module NpmtsCompile {
} }
})(); })();
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd,key)) var tsStream = 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({ .pipe(plugins.g.typescript({
out: outputName, out: outputName,
declaration: true, declaration: true,
target: "ES5" target: "ES5",
module: "commonjs"
})); }));
var stream = plugins.mergeStream([ var stream = plugins.mergeStream([
tsStream.dts.pipe(plugins.gulp.dest(outputDir)), //tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
tsStream.js tsStream.js
.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.g.header('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest(outputDir)) .pipe(plugins.gulp.dest(outputDir))
]); ]);

@ -11,8 +11,8 @@ module NpmtsOptions {
"./ts/" "./ts/"
]; ];
config.ts = { config.ts = {
["./ts/index.ts"]: "./index.js", ["./ts/**/*.ts"]: "./dist/",
["./ts/test.ts"]: "./test/test.js" ["./test/test.ts"]: "./test/"
}; };
config.test = ["./index.js"]; config.test = ["./index.js"];
done.resolve(config); done.resolve(config);

@ -10,10 +10,12 @@ module NpmtsPlugins {
header: require("gulp-header"), header: require("gulp-header"),
istanbul: require("gulp-istanbul"), istanbul: require("gulp-istanbul"),
mocha: require("gulp-mocha"), mocha: require("gulp-mocha"),
sourcemaps: require("gulp-sourcemaps"),
typescript: require("gulp-typescript") typescript: require("gulp-typescript")
}, },
mergeStream: require("merge2"), mergeStream: require("merge2"),
sourceMapSupport:require("source-map-support").install(),
path: require("path"), path: require("path"),
q:require("q"), q:require("q"),
smartcli: require("smartcli"), smartcli: require("smartcli"),

@ -4,7 +4,7 @@ module NpmtsTests {
var done = plugins.q.defer(); var done = plugins.q.defer();
var config = configArg; var config = configArg;
var istanbul = function () { var istanbul = function () {
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"index.js")]) var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
// Covering files // Covering files
.pipe(plugins.g.istanbul()) .pipe(plugins.g.istanbul())
// Force `require` to return covered files // Force `require` to return covered files