Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
5b0814520a | |||
848d40eeac | |||
73f5a0b055 | |||
f2a169ac7d | |||
3cdd22044e | |||
60d200135e | |||
e8238dc907 | |||
007e7539c8 |
@ -1 +0,0 @@
|
|||||||
# README-dev
|
|
44
README.md
44
README.md
@ -8,7 +8,8 @@ Write npm modules with TypeScript without hassle.
|
|||||||
[](https://www.bithound.io/github/pushrocks/npmts)
|
[](https://www.bithound.io/github/pushrocks/npmts)
|
||||||
[](https://coveralls.io/github/pushrocks/npmts?branch=master)
|
[](https://coveralls.io/github/pushrocks/npmts?branch=master)
|
||||||
|
|
||||||
## How to use npmts
|
## What is NPMTS?
|
||||||
|
NPMTS is your friend when it comes to write, test, publish and document NPM modules written in TypeScript.
|
||||||
|
|
||||||
### Install
|
### Install
|
||||||
First install npmts as dev dependency:
|
First install npmts as dev dependency:
|
||||||
@ -29,18 +30,24 @@ Then use it in package.json's script section to trigger a build:
|
|||||||
|
|
||||||
**Execution order of tasks**
|
**Execution order of tasks**
|
||||||
|
|
||||||
|
1. Check config in ./npmts.json
|
||||||
|
1. Clean up from any previous builds (old js files)
|
||||||
1. Install typings
|
1. Install typings
|
||||||
2. Transpile TypeScript with inline sourcemaps
|
1. Transpile TypeScript with inline sourcemaps
|
||||||
3. Create Declaration Files
|
1. Create Declaration Files
|
||||||
4. Instrumentalize created JavaScript files with istanbul
|
1. Create JsDoc Documentation
|
||||||
5. Run Tests
|
1. Instrumentalize created JavaScript files with istanbul
|
||||||
6. Create Coverage report
|
1. Run Tests
|
||||||
7. Upload Coverage reports to travis (must be activated, only triggers on travis)
|
1. Create Coverage report
|
||||||
|
1. Upload Coverage reports to travis (Tests must pass, Coveralls must be activated, by default only triggers on travis)
|
||||||
|
1. Upload JsDoc Documentation to gh-pages branch on GitHub. (Tests must pass, requires GitHub Token)
|
||||||
|
|
||||||
|
#### npmts.json
|
||||||
|
the npmts.json is the main config file. You can use it to customize the behaviour of NPMTS.
|
||||||
|
|
||||||
#### Typings
|
#### Typings
|
||||||
**npmts** looks for `./ts/typings.json` by default and installs any defined typings to `.ts/typings/`.
|
**npmts** looks for `./ts/typings.json` by default and installs any defined typings to `.ts/typings/`.
|
||||||
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 any of your TypeScript code.
|
||||||
|
|
||||||
#### TypeScript
|
#### TypeScript
|
||||||
by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
|
by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
|
||||||
@ -57,22 +64,22 @@ You can reference it in your package.json like this:
|
|||||||
"typings": "./index.d.ts",
|
"typings": "./index.d.ts",
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can then import plugins via the TypeScript `import` Syntax
|
||||||
|
and tsc will pick up the declaration file automatically.
|
||||||
|
|
||||||
#### Instrumentalize Code
|
#### Instrumentalize Code
|
||||||
npmts instrumentalizes the created JavaScript code to create a coverage report.
|
npmts instrumentalizes (using istanbul) the created JavaScript code to create a coverage report.
|
||||||
|
|
||||||
#### Tests
|
#### Tests
|
||||||
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 looks for `.test/test.ts` which will be transpiled to test.js and run with mocha.
|
||||||
|
|
||||||
Any errors will be shown with reference to their originating source in TypeScript.
|
|
||||||
|
|
||||||
When requiring the module from other TypeScript files,
|
|
||||||
the TypeScript Compiler will use the declaration file to resolve typings.
|
|
||||||
|
|
||||||
|
Any errors will be shown with reference to their originating source in TypeScript
|
||||||
|
thanks to autogenerated source maps.
|
||||||
|
|
||||||
|
|
||||||
### Custom behaviour
|
### Custom behaviour
|
||||||
Custom behaviour can be achieved through a config file at the root of your package.
|
Custom behaviour can be achieved through the npmts.json config file at the root of your package.
|
||||||
The file must be named **npmts.json**
|
The file must be named **npmts.json**
|
||||||
|
|
||||||
```json
|
```json
|
||||||
@ -91,7 +98,4 @@ The file must be named **npmts.json**
|
|||||||
* **ts** You can list as many TypeScript files as you like. The key represents the source TypeScript file, the value the output file.
|
* **ts** You can list as many TypeScript files as you like. The key represents the source TypeScript file, the value the output file.
|
||||||
* **typings** is an array of all direcories that have a typings.json present. Uses the new typings tool from npm.
|
* **typings** is an array of all direcories that have a typings.json present. Uses the new typings tool from npm.
|
||||||
|
|
||||||
|
> We will add more options over time.
|
||||||
## Readme for Devs
|
|
||||||
There is a [README-dev.md](README-dev.md) in the repo.
|
|
||||||
This is only of interest for you when looking to contribute to, improve or build upon this package.
|
|
24
dist/npmts.jsdoc.js
vendored
24
dist/npmts.jsdoc.js
vendored
@ -34,23 +34,17 @@ exports.publishDocs = function (configArg) {
|
|||||||
+ "&& git push --force --quiet "
|
+ "&& git push --force --quiet "
|
||||||
+ "\"" + gitUrl + "\" "
|
+ "\"" + gitUrl + "\" "
|
||||||
+ "master:gh-pages " + "> /dev/null 2>&1";
|
+ "master:gh-pages " + "> /dev/null 2>&1";
|
||||||
if (configArg.docs.publish) {
|
plugins.beautylog.log("now publishing JsDoc documentation to GitHub");
|
||||||
plugins.beautylog.log("now publishing JsDoc documentation to GitHub");
|
if (!plugins.shelljs.which('git')) {
|
||||||
if (!plugins.shelljs.which('git')) {
|
plugins.beautylog.error('Git is not installed!');
|
||||||
plugins.beautylog.error('Git is not installed!');
|
plugins.shelljs.exit(1);
|
||||||
plugins.shelljs.exit(1);
|
|
||||||
}
|
|
||||||
else if (plugins.shelljs.exec(deployScript).code !== 0) {
|
|
||||||
plugins.beautylog.error('Git failed!');
|
|
||||||
plugins.shelljs.exit(1);
|
|
||||||
}
|
|
||||||
plugins.beautylog.ok("JsDoc documentation has been deployed to GitHub!");
|
|
||||||
done.resolve(configArg);
|
|
||||||
}
|
}
|
||||||
else {
|
else if (plugins.shelljs.exec(deployScript).code !== 0) {
|
||||||
console.log("GitHub documentation has not been uploaded.");
|
plugins.beautylog.error('Git failed!');
|
||||||
done.resolve(configArg);
|
plugins.shelljs.exit(1);
|
||||||
}
|
}
|
||||||
|
plugins.beautylog.ok("JsDoc documentation has been deployed to GitHub!");
|
||||||
|
done.resolve(configArg);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
exports.run = function (configArg) {
|
exports.run = function (configArg) {
|
||||||
|
3
dist/npmts.promisechain.js
vendored
3
dist/npmts.promisechain.js
vendored
@ -40,6 +40,9 @@ exports.run = function () {
|
|||||||
console.log(shipString);
|
console.log(shipString);
|
||||||
plugins.beautylog.success("READY TO SHIP!");
|
plugins.beautylog.success("READY TO SHIP!");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
plugins.beautylog.success("Done!");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return promisechain;
|
return promisechain;
|
||||||
};
|
};
|
||||||
|
2
dist/npmts.publish.js
vendored
2
dist/npmts.publish.js
vendored
@ -10,6 +10,6 @@ exports.run = function (configArg) {
|
|||||||
config.coveralls ? promiseArray.push(NpmtsTests.publishCoverage(configArg)) : void (0);
|
config.coveralls ? promiseArray.push(NpmtsTests.publishCoverage(configArg)) : void (0);
|
||||||
config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void (0);
|
config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void (0);
|
||||||
promiseArray.length === 0 ? plugins.beautylog.info("Did not publish anything!") : void (0);
|
promiseArray.length === 0 ? plugins.beautylog.info("Did not publish anything!") : void (0);
|
||||||
plugins.Q.all(promiseArray).then(done.resolve());
|
plugins.Q.all(promiseArray).then(done.resolve);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
18
dist/npmts.tests.js
vendored
18
dist/npmts.tests.js
vendored
@ -7,17 +7,10 @@ exports.publishCoverage = function (configArg) {
|
|||||||
plugins.beautylog.log("now uploading coverage data to coveralls");
|
plugins.beautylog.log("now uploading coverage data to coveralls");
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
|
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([
|
.pipe(plugins.g.gFunction(function () {
|
||||||
function () {
|
plugins.beautylog.ok("Coverage data has been uploaded to Coveralls!");
|
||||||
var done = plugins.Q.defer();
|
|
||||||
plugins.beautylog.ok("Coverage data has been uploaded to Coveralls!");
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
], "atEnd"));
|
|
||||||
stream.on("finish", function () {
|
|
||||||
done.resolve(configArg);
|
done.resolve(configArg);
|
||||||
});
|
}, "atEnd"));
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
exports.run = function (configArg) {
|
exports.run = function (configArg) {
|
||||||
@ -37,6 +30,11 @@ exports.run = function (configArg) {
|
|||||||
return stream;
|
return stream;
|
||||||
};
|
};
|
||||||
plugins.beautylog.log("now starting tests");
|
plugins.beautylog.log("now starting tests");
|
||||||
|
console.log("--------------------------------------------------------------\n" +
|
||||||
|
"***************************" +
|
||||||
|
" TESTS: ".blue +
|
||||||
|
"***************************\n" +
|
||||||
|
"--------------------------------------------------------------");
|
||||||
istanbul().on("finish", function () {
|
istanbul().on("finish", function () {
|
||||||
mocha().on("finish", function () {
|
mocha().on("finish", function () {
|
||||||
plugins.beautylog.ok("Tests have passed!");
|
plugins.beautylog.ok("Tests have passed!");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "3.6.4",
|
"version": "3.6.8",
|
||||||
"description": "write npm modules with TypeScript",
|
"description": "write npm modules with TypeScript",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
console.log("**** starting test ****");
|
|
||||||
var testplugin = require("../dist/index.js");
|
var testplugin = require("../dist/index.js");
|
||||||
describe("testplugins", function () {
|
describe("testplugins", function () {
|
||||||
describe(".logSomething", function () {
|
describe(".logSomething", function () {
|
||||||
@ -8,5 +7,4 @@ describe("testplugins", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
//# sourceMappingURL=test.js.map
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELE9BQU8sQ0FBQyxHQUFHLENBQUMseUJBQXlCLENBQUMsQ0FBQztBQUN2QyxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQztBQUM3QyxRQUFRLENBQUMsYUFBYSxFQUFDO0lBQ25CLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsRUFBRSxDQUFDLHNCQUFzQixFQUFDO1lBQ3RCLFVBQVUsQ0FBQyxZQUFZLEVBQUUsQ0FBQTtRQUM3QixDQUFDLENBQUMsQ0FBQztJQUNQLENBQUMsQ0FBQyxDQUFDO0FBQ1AsQ0FBQyxDQUFDLENBQUMiLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuLi90cy90eXBpbmdzL21haW4uZC50c1wiIC8+XG5jb25zb2xlLmxvZyhcIioqKiogc3RhcnRpbmcgdGVzdCAqKioqXCIpO1xudmFyIHRlc3RwbHVnaW4gPSByZXF1aXJlKFwiLi4vZGlzdC9pbmRleC5qc1wiKTtcbmRlc2NyaWJlKFwidGVzdHBsdWdpbnNcIixmdW5jdGlvbigpe1xuICAgIGRlc2NyaWJlKFwiLmxvZ1NvbWV0aGluZ1wiLGZ1bmN0aW9uKCl7XG4gICAgICAgIGl0KFwic2hvdWxkIGxvZyBzb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgdGVzdHBsdWdpbi5sb2dTb21ldGhpbmcoKVxuICAgICAgICB9KTtcbiAgICB9KTtcbn0pOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
|
@ -1 +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"}
|
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,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,5 +1,4 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
console.log("**** starting test ****");
|
|
||||||
var testplugin = require("../dist/index.js");
|
var testplugin = require("../dist/index.js");
|
||||||
describe("testplugins",function(){
|
describe("testplugins",function(){
|
||||||
describe(".logSomething",function(){
|
describe(".logSomething",function(){
|
||||||
|
@ -40,21 +40,18 @@ export let publishDocs = function(configArg){
|
|||||||
+ "\"" + gitUrl + "\" "
|
+ "\"" + gitUrl + "\" "
|
||||||
+ "master:gh-pages " + "> /dev/null 2>&1";
|
+ "master:gh-pages " + "> /dev/null 2>&1";
|
||||||
|
|
||||||
if(configArg.docs.publish){
|
|
||||||
plugins.beautylog.log("now publishing JsDoc documentation to GitHub");
|
plugins.beautylog.log("now publishing JsDoc documentation to GitHub");
|
||||||
if (!plugins.shelljs.which('git')) {
|
if (!plugins.shelljs.which('git')) {
|
||||||
plugins.beautylog.error('Git is not installed!');
|
plugins.beautylog.error('Git is not installed!');
|
||||||
plugins.shelljs.exit(1);
|
plugins.shelljs.exit(1);
|
||||||
} else if (plugins.shelljs.exec(deployScript).code !== 0) {
|
} else if (plugins.shelljs.exec(deployScript).code !== 0) {
|
||||||
plugins.beautylog.error('Git failed!');
|
plugins.beautylog.error('Git failed!');
|
||||||
plugins.shelljs.exit(1);
|
plugins.shelljs.exit(1);
|
||||||
}
|
|
||||||
plugins.beautylog.ok("JsDoc documentation has been deployed to GitHub!");
|
|
||||||
done.resolve(configArg);
|
|
||||||
} else {
|
|
||||||
console.log("GitHub documentation has not been uploaded.");
|
|
||||||
done.resolve(configArg);
|
|
||||||
}
|
}
|
||||||
|
plugins.beautylog.ok("JsDoc documentation has been deployed to GitHub!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ export var run = function(){
|
|||||||
if (process.env.CI){
|
if (process.env.CI){
|
||||||
console.log(shipString);
|
console.log(shipString);
|
||||||
plugins.beautylog.success("READY TO SHIP!");
|
plugins.beautylog.success("READY TO SHIP!");
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.success("Done!")
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -14,6 +14,6 @@ export let run = function(configArg){
|
|||||||
config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void(0);
|
config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void(0);
|
||||||
promiseArray.length === 0 ? plugins.beautylog.info("Did not publish anything!") : void(0);
|
promiseArray.length === 0 ? plugins.beautylog.info("Did not publish anything!") : void(0);
|
||||||
|
|
||||||
plugins.Q.all(promiseArray).then(done.resolve());
|
plugins.Q.all(promiseArray).then(done.resolve);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
@ -7,17 +7,10 @@ export let publishCoverage = function(configArg){
|
|||||||
plugins.beautylog.log("now uploading coverage data to coveralls");
|
plugins.beautylog.log("now uploading coverage data to coveralls");
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
|
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([
|
.pipe(plugins.g.gFunction(function(){
|
||||||
function(){
|
plugins.beautylog.ok("Coverage data has been uploaded to Coveralls!");
|
||||||
let done = plugins.Q.defer();
|
done.resolve(configArg);
|
||||||
plugins.beautylog.ok("Coverage data has been uploaded to Coveralls!");
|
},"atEnd"));
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
],"atEnd"));
|
|
||||||
stream.on("finish",function(){
|
|
||||||
done.resolve(configArg);
|
|
||||||
});
|
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,6 +37,13 @@ export var run = function(configArg) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
plugins.beautylog.log("now starting tests");
|
plugins.beautylog.log("now starting tests");
|
||||||
|
console.log(
|
||||||
|
"--------------------------------------------------------------\n" +
|
||||||
|
"***************************" +
|
||||||
|
" TESTS: ".blue +
|
||||||
|
"***************************\n" +
|
||||||
|
"--------------------------------------------------------------"
|
||||||
|
);
|
||||||
istanbul().on("finish",function(){
|
istanbul().on("finish",function(){
|
||||||
mocha().on("finish",function(){
|
mocha().on("finish",function(){
|
||||||
plugins.beautylog.ok("Tests have passed!");
|
plugins.beautylog.ok("Tests have passed!");
|
||||||
|
Reference in New Issue
Block a user