Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
fe7d2f1024 | |||
9f0343b01c | |||
04a02f6b96 | |||
cb3f343c92 | |||
6227e47037 | |||
2730ca4299 | |||
07aae64965 | |||
56841d5bb0 | |||
40301ede35 | |||
70213b04bc | |||
5160aab180 | |||
e8806e548b | |||
fcdaad540e | |||
6f33b1f5ef | |||
45418d6049 | |||
4261ee3687 | |||
9fc3606163 | |||
2436b30605 | |||
9ad59704be | |||
29f3832d63 |
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
|
@ -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.
|
||||||
|
2
index.d.ts
vendored
2
index.d.ts
vendored
@ -6,7 +6,6 @@ declare module NpmtsPlugins {
|
|||||||
gulp: any;
|
gulp: any;
|
||||||
g: {
|
g: {
|
||||||
coveralls: any;
|
coveralls: any;
|
||||||
header: any;
|
|
||||||
istanbul: any;
|
istanbul: any;
|
||||||
mocha: any;
|
mocha: any;
|
||||||
sourcemaps: any;
|
sourcemaps: any;
|
||||||
@ -45,7 +44,6 @@ declare var plugins: {
|
|||||||
gulp: any;
|
gulp: any;
|
||||||
g: {
|
g: {
|
||||||
coveralls: any;
|
coveralls: any;
|
||||||
header: any;
|
|
||||||
istanbul: any;
|
istanbul: any;
|
||||||
mocha: any;
|
mocha: any;
|
||||||
sourcemaps: any;
|
sourcemaps: any;
|
||||||
|
24
index.js
24
index.js
@ -10,7 +10,6 @@ var NpmtsPlugins;
|
|||||||
gulp: require("gulp"),
|
gulp: require("gulp"),
|
||||||
g: {
|
g: {
|
||||||
coveralls: require("gulp-coveralls"),
|
coveralls: require("gulp-coveralls"),
|
||||||
header: require("gulp-header"),
|
|
||||||
istanbul: require("gulp-istanbul"),
|
istanbul: require("gulp-istanbul"),
|
||||||
mocha: require("gulp-mocha"),
|
mocha: require("gulp-mocha"),
|
||||||
sourcemaps: require("gulp-sourcemaps"),
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
@ -85,8 +84,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"];
|
||||||
@ -167,20 +166,15 @@ 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 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.sourcemaps.init()) // This means sourcemaps will be generated
|
||||||
.pipe(plugins.g.typescript({
|
.pipe(plugins.g.typescript({
|
||||||
out: outputName,
|
out: outputName,
|
||||||
declaration: true,
|
target: "ES5",
|
||||||
target: "ES5"
|
module: "commonjs"
|
||||||
}));
|
}))
|
||||||
var stream = plugins.mergeStream([
|
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||||
tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
|
.pipe(plugins.gulp.dest(outputDir));
|
||||||
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.gulp.dest(outputDir))
|
|
||||||
]);
|
|
||||||
moduleStream.add(stream);
|
moduleStream.add(stream);
|
||||||
}
|
}
|
||||||
moduleStream.on("queueDrain", function () {
|
moduleStream.on("queueDrain", function () {
|
||||||
@ -201,7 +195,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.4.0",
|
"version": "3.1.1",
|
||||||
"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",
|
||||||
@ -30,7 +30,6 @@
|
|||||||
"fs-extra": "^0.26.5",
|
"fs-extra": "^0.26.5",
|
||||||
"gulp": "3.9.1",
|
"gulp": "3.9.1",
|
||||||
"gulp-coveralls": "^0.1.4",
|
"gulp-coveralls": "^0.1.4",
|
||||||
"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-sourcemaps": "^1.6.0",
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
var testplugin = {
|
var testplugin = {
|
||||||
logSomething: function () {
|
logSomething: function () {
|
4
test/assets/index.d.ts
vendored
4
test/assets/index.d.ts
vendored
@ -1,4 +0,0 @@
|
|||||||
/// <reference path="ts/typings/main.d.ts" />
|
|
||||||
declare var testplugin: {
|
|
||||||
logSomething: () => void;
|
|
||||||
};
|
|
@ -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 () {
|
||||||
@ -11,4 +9,4 @@ describe("testplugins", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsNENBQTRDO0FBQzVDLE9BQU8sQ0FBQyxHQUFHLENBQUMseUJBQXlCLENBQUMsQ0FBQztBQUN2QyxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsYUFBYSxDQUFDLENBQUM7QUFDeEMsUUFBUSxDQUFDLGFBQWEsRUFBQztJQUNuQixRQUFRLENBQUMsZUFBZSxFQUFDO1FBQ3JCLEVBQUUsQ0FBQyxzQkFBc0IsRUFBQztZQUN0QixVQUFVLENBQUMsWUFBWSxFQUFFLENBQUE7UUFDN0IsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUMsQ0FBQztBQUNQLENBQUMsQ0FBQyxDQUFDIiwiZmlsZSI6InRlc3QuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi90eXBpbmdzL21haW4uZC50c1wiIC8+XG5jb25zb2xlLmxvZyhcIioqKiogc3RhcnRpbmcgdGVzdCAqKioqXCIpO1xudmFyIHRlc3RwbHVnaW4gPSByZXF1aXJlKFwiLi4vaW5kZXguanNcIik7XG5kZXNjcmliZShcInRlc3RwbHVnaW5zXC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0aW9uKCl7XG4gICAgICAgIGl0KFwic2hvdWxkIGxvZyBzb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgdGVzdHBsdWdpbi5sb2dTb21ldGhpbmcoKVxuICAgICAgICB9KTtcbiAgICB9KTtcbn0pOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
||||||
|
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
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,20 +67,16 @@ module NpmtsCompile {
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd,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.sourcemaps.init()) // This means sourcemaps will be generated
|
||||||
.pipe(plugins.g.typescript({
|
.pipe(plugins.g.typescript({
|
||||||
out: outputName,
|
out: outputName,
|
||||||
declaration: true,
|
target: "ES5",
|
||||||
target: "ES5"
|
module: "commonjs"
|
||||||
}));
|
}))
|
||||||
var stream = plugins.mergeStream([
|
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||||
tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
|
//.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
|
||||||
tsStream.js
|
.pipe(plugins.gulp.dest(outputDir));
|
||||||
.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.add(stream);
|
||||||
}
|
}
|
||||||
moduleStream.on("queueDrain",function(){
|
moduleStream.on("queueDrain",function(){
|
||||||
|
@ -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);
|
||||||
|
@ -7,7 +7,6 @@ module NpmtsPlugins {
|
|||||||
gulp: require("gulp"),
|
gulp: require("gulp"),
|
||||||
g: {
|
g: {
|
||||||
coveralls: require("gulp-coveralls"),
|
coveralls: require("gulp-coveralls"),
|
||||||
header: require("gulp-header"),
|
|
||||||
istanbul: require("gulp-istanbul"),
|
istanbul: require("gulp-istanbul"),
|
||||||
mocha: require("gulp-mocha"),
|
mocha: require("gulp-mocha"),
|
||||||
sourcemaps: require("gulp-sourcemaps"),
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user