Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
6f33b1f5ef | |||
45418d6049 | |||
4261ee3687 | |||
9fc3606163 | |||
2436b30605 | |||
9ad59704be | |||
29f3832d63 | |||
2d82a3a037 | |||
4806f5ceff | |||
f2ef982189 | |||
5d6ead017b | |||
1c2b4e421d | |||
6cf7d2ca0b |
4
.gitignore
vendored
4
.gitignore
vendored
@ -5,4 +5,6 @@ test/**/node_modules/
|
|||||||
test/**/typings/
|
test/**/typings/
|
||||||
test/**/coverage/
|
test/**/coverage/
|
||||||
ts/*.js
|
ts/*.js
|
||||||
ts/*.js.map
|
ts/*.js.map
|
||||||
|
|
||||||
|
.DS_Store
|
10
README.md
10
README.md
@ -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
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
index.js
13
index.js
@ -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))
|
||||||
]);
|
]);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "2.3.1",
|
"version": "3.0.0",
|
||||||
"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
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
BIN
test/assets/test/.DS_Store
vendored
Normal file
Binary file not shown.
2
test/assets/test/test.d.ts
vendored
2
test/assets/test/test.d.ts
vendored
@ -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,6 @@
|
|||||||
#!/usr/bin/env node
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
|
|
||||||
/// <reference path="./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 +8,4 @@ describe("testplugins", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
//# sourceMappingURL=test.js.map
|
1
test/assets/test/test.js.map
Normal file
1
test/assets/test/test.js.map
Normal file
@ -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(){
|
8
test/assets/test/typings.json
Normal file
8
test/assets/test/typings.json
Normal file
@ -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
test/assets/tsfile1.d.ts
vendored
1
test/assets/tsfile1.d.ts
vendored
@ -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"),
|
||||||
|
Reference in New Issue
Block a user