Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
8104609306 | |||
a3077f7800 | |||
c947121243 | |||
4b3f0649fa | |||
523c62530f | |||
aa57617fc7 | |||
ef89a33dfc | |||
474a730a09 | |||
e3b029c240 | |||
290824190d | |||
923d78caab | |||
6587b74a23 | |||
aa0a35f258 | |||
09b8809ede | |||
e25566490b | |||
3ed7473066 | |||
1202a68b01 | |||
c67d43e16d | |||
df74769533 | |||
5aef714497 | |||
24701afcb2 | |||
cbfbd4ee67 | |||
6df449394d | |||
27b6119bbb | |||
b22abef889 | |||
4d8a7a4202 | |||
72bc08e973 | |||
430f636ae4 | |||
bbc8f13ecf | |||
a01f07f62c | |||
36316e63b2 | |||
5c5e88c226 | |||
af968f65df | |||
f0cc2f4cd6 | |||
f167226830 | |||
3e49b365b6 |
@ -45,17 +45,3 @@ trigger:
|
|||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
pages:
|
|
||||||
stage: page
|
|
||||||
script:
|
|
||||||
- npmci test lts
|
|
||||||
- mkdir .public
|
|
||||||
- cp -r test/assets/docs/ .public
|
|
||||||
- cp -r test/assets/coverage/ .public
|
|
||||||
- mv .public public
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
only:
|
|
||||||
- tags
|
|
74
README.md
74
README.md
@ -3,7 +3,6 @@ Write npm modules with TypeScript without hassle.
|
|||||||
|
|
||||||
## Status
|
## Status
|
||||||
[](https://gitlab.com/pushrocks/npmts/commits/master)
|
[](https://gitlab.com/pushrocks/npmts/commits/master)
|
||||||
[](https://ci.appveyor.com/project/philkunz/npmts/branch/master)
|
|
||||||
[](https://david-dm.org/pushrocks/npmts)
|
[](https://david-dm.org/pushrocks/npmts)
|
||||||
[](https://www.bithound.io/github/pushrocks/npmts/master/dependencies/npm)
|
[](https://www.bithound.io/github/pushrocks/npmts/master/dependencies/npm)
|
||||||
[](https://www.bithound.io/github/pushrocks/npmts)
|
[](https://www.bithound.io/github/pushrocks/npmts)
|
||||||
@ -14,10 +13,13 @@ NPMTS is your friend when it comes to write, test, publish and document NPM modu
|
|||||||
By default NPMTS will **bundle declaration files**. As a result npm module **code completion in editors like Visual Studio Code** works.
|
By default NPMTS will **bundle declaration files**. As a result npm module **code completion in editors like Visual Studio Code** works.
|
||||||
|
|
||||||
There is a docker image available that includes npmts to make CI a breeze:
|
There is a docker image available that includes npmts to make CI a breeze:
|
||||||
[hosttoday/ht-docker-npmg on Dockerhub](https://hub.docker.com/r/hosttoday/ht-docker-npmg/)
|
[hosttoday/ht-docker-node:npmts on Dockerhub](https://hub.docker.com/r/hosttoday/ht-docker-node/)
|
||||||
|
|
||||||
### Install
|
### Install
|
||||||
First install npmts globally, then install the npmts checker:
|
First install npmts globally, then install the npmts-g locally.
|
||||||
|
|
||||||
|
> **npmts-g* checks if the global version of npmts suffices the modules requirements.
|
||||||
|
If not it installs npmts locally in the right version during npm install.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm install npmts -g # installs npmts globally
|
npm install npmts -g # installs npmts globally
|
||||||
@ -28,50 +30,34 @@ Then add it to your package.json's script section to trigger a build:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npmts"
|
"test": "(npmts)"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Default task execution order
|
### Default task execution order
|
||||||
|
|
||||||
1. Check config in ./npmts.json
|
1. Check config in ./npmextra.json (Check out [npmextra](https://www.npmjs.com/package/npmextra))
|
||||||
1. Clean up from any previous builds (old js files)
|
1. Clean up from any previous builds (old js files)
|
||||||
1. Install typings
|
1. Transpile TypeScript with **inline sourcemaps** and **declaration files** to ES6
|
||||||
1. Transpile TypeScript with **inline sourcemaps** and **declaration files**
|
1. Create TypeDoc Documentation from TypeScript files
|
||||||
1. Create JsDoc Documentation
|
1. Instrumentalize transpiled ES6 JavaScript with istanbul and run tests with Mocha
|
||||||
1. Instrumentalize created JavaScript files with istanbul
|
|
||||||
1. Run Tests
|
|
||||||
1. Create Coverage report
|
|
||||||
|
|
||||||
#### npmts.json
|
#### npmtsextra.json
|
||||||
the npmts.json is the main config file. You can use it to customize the behaviour of NPMTS.
|
the npmts section in npmtsextra.json can be used to configure npmts.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"mode":"default",
|
"npmts":{
|
||||||
"codecov":{
|
"mode":"default",
|
||||||
"publish":true,
|
"ts":{
|
||||||
"token":"sometoken"
|
"./customdir/*.ts":"./"
|
||||||
},
|
},
|
||||||
"ts":{
|
"tsOptions":{
|
||||||
"./customdir/*.ts":"./"
|
"declaration":false,
|
||||||
},
|
"target":"ES6"
|
||||||
"docs": {
|
},
|
||||||
"publish":true,
|
"cli":true
|
||||||
"destination":"github"
|
}
|
||||||
},
|
|
||||||
"tsOptions":{
|
|
||||||
"declaration":false,
|
|
||||||
"target":"ES6"
|
|
||||||
},
|
|
||||||
"typings":[
|
|
||||||
"./ts/typings.json",
|
|
||||||
"./subts1/typings.json",
|
|
||||||
"./subts2/typings.json",
|
|
||||||
"./customdir/typings.json"
|
|
||||||
],
|
|
||||||
"typingsInclude":"auto",
|
|
||||||
"cli":true
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -84,14 +70,6 @@ the npmts.json is the main config file. You can use it to customize the behaviou
|
|||||||
| `"typings"` | `["./ts/typings.json"]` | allows you to specify multiple locations for typings.json to install. This is needed for modules that do not yet bundle typings |
|
| `"typings"` | `["./ts/typings.json"]` | allows you to specify multiple locations for typings.json to install. This is needed for modules that do not yet bundle typings |
|
||||||
| `"cli"` | "false" | some modules are designed to be used from cli. If set to true NPMTS will create a cli.js that wires you dist files up for cli use. |
|
| `"cli"` | "false" | some modules are designed to be used from cli. If set to true NPMTS will create a cli.js that wires you dist files up for cli use. |
|
||||||
|
|
||||||
#### Typings
|
|
||||||
**npmts** looks for `./ts/typings.json` by default and installs any defined typings to `.ts/typings/`.
|
|
||||||
|
|
||||||
> Note: You can reference the typings files in any of your TypeScript code with a
|
|
||||||
`/// <reference path="/some/path/main.d.ts">`
|
|
||||||
We are currently working on a "typingsInclude" option, that will autoload any typings during compilation.
|
|
||||||
tsconfig is NOT supported, since it would render this module useless
|
|
||||||
|
|
||||||
#### 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
|
||||||
`./dist/*.js` and `./test/test.js`
|
`./dist/*.js` and `./test/test.js`
|
||||||
@ -111,7 +89,8 @@ This is in line with the latest TypeScript best practices.
|
|||||||
You can then import plugins via the TypeScript `import` Syntax
|
You can then import plugins via the TypeScript `import` Syntax
|
||||||
and tsc will pick up the declaration file automatically.
|
and tsc will pick up the declaration file automatically.
|
||||||
|
|
||||||
> Note: If you don't want declaration files, set tsOptions.declaration to false in npmts.json
|
#### Typings for third party modules that do not bundle declaration files
|
||||||
|
NPMTS does no longer supports typings.json. Instead use the new TypeScript 2.x approach to typings using the @types/ npm scope.
|
||||||
|
|
||||||
#### Instrumentalize Code
|
#### Instrumentalize Code
|
||||||
npmts instrumentalizes (using istanbul) the created JavaScript code to create a coverage report.
|
npmts instrumentalizes (using istanbul) the created JavaScript code to create a coverage report.
|
||||||
@ -124,7 +103,6 @@ Any errors will be shown with reference to their originating source in TypeScrip
|
|||||||
thanks to autogenerated source maps.
|
thanks to autogenerated source maps.
|
||||||
|
|
||||||
## Example Usage in modules:
|
## Example Usage in modules:
|
||||||
* [gulp-typings](https://www.npmjs.com/package/gulp-typings)
|
|
||||||
* [gulp-browser](https://www.npmjs.com/package/gulp-typings)
|
* [gulp-browser](https://www.npmjs.com/package/gulp-typings)
|
||||||
|
|
||||||
> We will add more options over time.
|
> We will add more options over time.
|
||||||
@ -132,7 +110,7 @@ thanks to autogenerated source maps.
|
|||||||
## Tips and tricks:
|
## Tips and tricks:
|
||||||
|
|
||||||
* Use [npmts-g](https://www.npmjs.com/package/npmts-g) to use globally installed npmts and install npmts locally if no global npmts is available.
|
* Use [npmts-g](https://www.npmjs.com/package/npmts-g) to use globally installed npmts and install npmts locally if no global npmts is available.
|
||||||
* Use [npmpage](https://www.npmjs.com/package/npmtspage) to create a webpage from coverage reports and JsDocs for the module
|
* Use [npmpage](https://www.npmjs.com/package/npmtspage) to create a webpage from coverage reports and TypeDoc for the module
|
||||||
* Use [hosttoday/ht-docker-node:npmts](https://hub.docker.com/r/hosttoday/ht-docker-node/) for speedy CI builds
|
* Use [hosttoday/ht-docker-node:npmts](https://hub.docker.com/r/hosttoday/ht-docker-node/) for speedy CI builds
|
||||||
|
|
||||||
## About the authors:
|
## About the authors:
|
||||||
|
1
dist/npmts.cli.d.ts
vendored
1
dist/npmts.cli.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
import "typings-global";
|
|
2
dist/npmts.cli.js
vendored
2
dist/npmts.cli.js
vendored
@ -1,2 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
2
dist/npmts.compile.js
vendored
2
dist/npmts.compile.js
vendored
@ -9,7 +9,7 @@ var compileTs = function (tsFileArrayArg, tsOptionsArg) {
|
|||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
var tsOptionsDefault = {
|
var tsOptionsDefault = {
|
||||||
declaration: true,
|
declaration: true,
|
||||||
target: "ES5",
|
target: "ES6",
|
||||||
module: "commonjs"
|
module: "commonjs"
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
28
dist/npmts.jsdoc.js
vendored
28
dist/npmts.jsdoc.js
vendored
@ -1,28 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
var plugins = require("./npmts.plugins");
|
|
||||||
var paths = require("./npmts.paths");
|
|
||||||
var npmts_promisechain_1 = require("./npmts.promisechain");
|
|
||||||
var genJsdoc = function (configArg) {
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
npmts_promisechain_1.npmtsOra.text("now generating " + "JsDoc documentation".yellow);
|
|
||||||
plugins.gulp.src([
|
|
||||||
plugins.path.join(paths.cwd, "README.md"),
|
|
||||||
plugins.path.join(paths.distDir, "**/*.js")
|
|
||||||
])
|
|
||||||
.pipe(plugins.g.jsdoc3({
|
|
||||||
opts: {
|
|
||||||
destination: paths.docsDir
|
|
||||||
}
|
|
||||||
}, function () {
|
|
||||||
plugins.beautylog.ok("JsDoc documentation has been generated!");
|
|
||||||
done.resolve(configArg);
|
|
||||||
}));
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
exports.run = function (configArg) {
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
genJsdoc(configArg)
|
|
||||||
.then(done.resolve);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
10
dist/npmts.plugins.d.ts
vendored
10
dist/npmts.plugins.d.ts
vendored
@ -2,14 +2,16 @@ import "typings-global";
|
|||||||
export import beautylog = require("beautylog");
|
export import beautylog = require("beautylog");
|
||||||
export declare let gulp: any;
|
export declare let gulp: any;
|
||||||
export declare let g: {
|
export declare let g: {
|
||||||
gFunction: any;
|
babel: any;
|
||||||
istanbul: any;
|
istanbul: any;
|
||||||
jsdoc3: any;
|
gFunction: any;
|
||||||
|
injectModules: any;
|
||||||
mocha: any;
|
mocha: any;
|
||||||
replace: any;
|
replace: any;
|
||||||
|
sourcemaps: any;
|
||||||
|
typedoc: any;
|
||||||
};
|
};
|
||||||
export declare let lodashObject: any;
|
export declare let lodashObject: any;
|
||||||
export declare let merge2: any;
|
|
||||||
export import projectinfo = require("projectinfo");
|
export import projectinfo = require("projectinfo");
|
||||||
export import path = require("path");
|
export import path = require("path");
|
||||||
export import Q = require("q");
|
export import Q = require("q");
|
||||||
@ -22,4 +24,4 @@ export import smartfile = require("smartfile");
|
|||||||
export import smartpath = require("smartpath");
|
export import smartpath = require("smartpath");
|
||||||
export import smartstring = require("smartstring");
|
export import smartstring = require("smartstring");
|
||||||
export declare let sourceMapSupport: any;
|
export declare let sourceMapSupport: any;
|
||||||
export declare let tsn: any;
|
export import tsn = require("tsn");
|
||||||
|
10
dist/npmts.plugins.js
vendored
10
dist/npmts.plugins.js
vendored
@ -3,14 +3,16 @@ require("typings-global");
|
|||||||
exports.beautylog = require("beautylog");
|
exports.beautylog = require("beautylog");
|
||||||
exports.gulp = require("gulp");
|
exports.gulp = require("gulp");
|
||||||
exports.g = {
|
exports.g = {
|
||||||
gFunction: require("gulp-function"),
|
babel: require("gulp-babel"),
|
||||||
istanbul: require("gulp-istanbul"),
|
istanbul: require("gulp-istanbul"),
|
||||||
jsdoc3: require("gulp-jsdoc3"),
|
gFunction: require("gulp-function"),
|
||||||
|
injectModules: require("gulp-inject-modules"),
|
||||||
mocha: require("gulp-mocha"),
|
mocha: require("gulp-mocha"),
|
||||||
replace: require("gulp-replace")
|
replace: require("gulp-replace"),
|
||||||
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
|
typedoc: require("gulp-typedoc")
|
||||||
};
|
};
|
||||||
exports.lodashObject = require('lodash/fp/object');
|
exports.lodashObject = require('lodash/fp/object');
|
||||||
exports.merge2 = require("merge2");
|
|
||||||
exports.projectinfo = require("projectinfo");
|
exports.projectinfo = require("projectinfo");
|
||||||
exports.path = require("path");
|
exports.path = require("path");
|
||||||
exports.Q = require("q");
|
exports.Q = require("q");
|
||||||
|
4
dist/npmts.promisechain.js
vendored
4
dist/npmts.promisechain.js
vendored
@ -6,7 +6,7 @@ var NpmtsAssets = require("./npmts.assets");
|
|||||||
var NpmtsClean = require("./npmts.clean");
|
var NpmtsClean = require("./npmts.clean");
|
||||||
var NpmtsCompile = require("./npmts.compile");
|
var NpmtsCompile = require("./npmts.compile");
|
||||||
var NpmtsConfigFile = require("./npmts.configfile");
|
var NpmtsConfigFile = require("./npmts.configfile");
|
||||||
var NpmtsJsdoc = require("./npmts.jsdoc");
|
var NpmtsTypeDoc = require("./npmts.typedoc");
|
||||||
var NpmtsOptions = require("./npmts.options");
|
var NpmtsOptions = require("./npmts.options");
|
||||||
var NpmtsTests = require("./npmts.tests");
|
var NpmtsTests = require("./npmts.tests");
|
||||||
exports.promisechain = function (argvArg) {
|
exports.promisechain = function (argvArg) {
|
||||||
@ -17,7 +17,7 @@ exports.promisechain = function (argvArg) {
|
|||||||
.then(NpmtsClean.run)
|
.then(NpmtsClean.run)
|
||||||
.then(NpmtsCompile.run)
|
.then(NpmtsCompile.run)
|
||||||
.then(NpmtsAssets.run)
|
.then(NpmtsAssets.run)
|
||||||
.then(NpmtsJsdoc.run)
|
.then(NpmtsTypeDoc.run)
|
||||||
.then(NpmtsTests.run)
|
.then(NpmtsTests.run)
|
||||||
.then(function (configArg) {
|
.then(function (configArg) {
|
||||||
var shipString = "" +
|
var shipString = "" +
|
||||||
|
57
dist/npmts.tests.js
vendored
57
dist/npmts.tests.js
vendored
@ -7,32 +7,38 @@ var npmts_promisechain_1 = require("./npmts.promisechain");
|
|||||||
*
|
*
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
var istanbul = function (configArg) {
|
var mocha = function (configArg) {
|
||||||
npmts_promisechain_1.npmtsOra.text("Instrumentalizing transpiled JS...");
|
npmts_promisechain_1.npmtsOra.text("Instrumentalizing and testing transpiled JS");
|
||||||
|
npmts_promisechain_1.npmtsOra.end(); // end npmtsOra for tests.
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
|
||||||
.pipe(plugins.g.istanbul()) // Covering files
|
.pipe(plugins.g.sourcemaps.init())
|
||||||
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
|
.pipe(plugins.g.babel({
|
||||||
.pipe(plugins.g.gFunction(function () {
|
presets: [
|
||||||
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!");
|
require.resolve("babel-preset-es2015")
|
||||||
done.resolve(configArg);
|
]
|
||||||
}, "atEnd"));
|
}))
|
||||||
return done.promise;
|
.pipe(plugins.g.istanbul({}))
|
||||||
};
|
.pipe(plugins.g.sourcemaps.write())
|
||||||
/**
|
.pipe(plugins.g.injectModules())
|
||||||
*
|
.on("finish", function () {
|
||||||
* @returns {*}
|
plugins.gulp.src([plugins.path.join(paths.cwd, "test/test.js")])
|
||||||
*/
|
.pipe(plugins.g.babel({
|
||||||
var mocha = function (configArg) {
|
presets: [
|
||||||
var done = plugins.Q.defer();
|
plugins.path.join(paths.npmtsPackageRoot, "node_modules/babel-preset-es2015/index.js")
|
||||||
npmts_promisechain_1.npmtsOra.end(); // end npmtsOra for tests.
|
]
|
||||||
var stream = plugins.gulp.src(["./test/test.js"])
|
}))
|
||||||
.pipe(plugins.g.mocha())
|
.pipe(plugins.g.injectModules())
|
||||||
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
|
.pipe(plugins.g.mocha())
|
||||||
.pipe(plugins.g.gFunction(function () {
|
.pipe(plugins.g.istanbul.writeReports({
|
||||||
plugins.beautylog.ok("Tests have passed!");
|
dir: './coverage',
|
||||||
done.resolve(configArg);
|
reporters: ['lcovonly', 'json', 'text', 'text-summary']
|
||||||
}, "atEnd"));
|
}))
|
||||||
|
.pipe(plugins.g.gFunction(function () {
|
||||||
|
plugins.beautylog.ok("Tested!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
}, "atEnd"));
|
||||||
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
var coverage = function (configArg) {
|
var coverage = function (configArg) {
|
||||||
@ -61,8 +67,7 @@ exports.run = function (configArg) {
|
|||||||
plugins.beautylog.log("-------------------------------------------------------\n" +
|
plugins.beautylog.log("-------------------------------------------------------\n" +
|
||||||
"*************************** TESTS: ***************************\n" +
|
"*************************** TESTS: ***************************\n" +
|
||||||
"--------------------------------------------------------------");
|
"--------------------------------------------------------------");
|
||||||
istanbul(config)
|
mocha(config)
|
||||||
.then(mocha)
|
|
||||||
.then(coverage)
|
.then(coverage)
|
||||||
.then(function () {
|
.then(function () {
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
|
35
dist/npmts.typedoc.js
vendored
Normal file
35
dist/npmts.typedoc.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
var genTypeDoc = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
npmts_promisechain_1.npmtsOra.text("now generating " + "TypeDoc documentation".yellow);
|
||||||
|
plugins.beautylog.log("TypeDoc Output:");
|
||||||
|
plugins.gulp.src(plugins.path.join(paths.tsDir, "**/*.ts"))
|
||||||
|
.pipe(plugins.g.typedoc({
|
||||||
|
// TypeScript options (see typescript docs)
|
||||||
|
module: "commonjs",
|
||||||
|
target: "es6",
|
||||||
|
includeDeclarations: true,
|
||||||
|
// Output options (see typedoc docs)
|
||||||
|
out: paths.docsDir,
|
||||||
|
json: plugins.path.join(paths.docsDir, "file.json"),
|
||||||
|
// TypeDoc options (see typedoc docs)
|
||||||
|
name: "my-project",
|
||||||
|
//theme: "default",
|
||||||
|
ignoreCompilerErrors: true,
|
||||||
|
version: true,
|
||||||
|
}))
|
||||||
|
.pipe(plugins.g.gFunction(done.resolve, "atEnd"));
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
genTypeDoc(configArg)
|
||||||
|
.then(function () {
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
24
package.json
24
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "5.3.7",
|
"version": "5.3.21",
|
||||||
"description": "write npm modules with TypeScript",
|
"description": "write npm modules with TypeScript",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -29,21 +29,24 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/npmts#readme",
|
"homepage": "https://gitlab.com/pushrocks/npmts#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/minimatch": "^2.0.22-alpha",
|
"@types/minimatch": "*",
|
||||||
"@types/q": "0.0.21-alpha",
|
"@types/q": "*",
|
||||||
"@types/shelljs": "^0.3.21-alpha",
|
"@types/shelljs": "*",
|
||||||
"beautylog": "5.0.12",
|
"babel-preset-es2015": "^6.9.0",
|
||||||
|
"beautylog": "5.0.14",
|
||||||
"early": "^2.0.13",
|
"early": "^2.0.13",
|
||||||
"gulp": "3.9.1",
|
"gulp": "3.9.1",
|
||||||
|
"gulp-babel": "^6.1.2",
|
||||||
"gulp-concat": "^2.6.0",
|
"gulp-concat": "^2.6.0",
|
||||||
"gulp-function": "^1.3.6",
|
"gulp-function": "^1.3.6",
|
||||||
"gulp-if": "^2.0.1",
|
"gulp-if": "^2.0.1",
|
||||||
|
"gulp-inject-modules": "^1.0.0",
|
||||||
"gulp-istanbul": "^1.0.0",
|
"gulp-istanbul": "^1.0.0",
|
||||||
"gulp-jsdoc3": "^0.3.0",
|
|
||||||
"gulp-mocha": "^2.2.0",
|
"gulp-mocha": "^2.2.0",
|
||||||
"gulp-replace": "^0.5.4",
|
"gulp-replace": "^0.5.4",
|
||||||
|
"gulp-sourcemaps": "^1.6.0",
|
||||||
|
"gulp-typedoc": "^2.0.0",
|
||||||
"lodash": "^4.13.1",
|
"lodash": "^4.13.1",
|
||||||
"merge2": "1.0.2",
|
|
||||||
"projectinfo": "1.0.3",
|
"projectinfo": "1.0.3",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"shelljs": "^0.7.0",
|
"shelljs": "^0.7.0",
|
||||||
@ -53,9 +56,10 @@
|
|||||||
"smartenv": "1.2.5",
|
"smartenv": "1.2.5",
|
||||||
"smartfile": "4.0.10",
|
"smartfile": "4.0.10",
|
||||||
"smartpath": "3.2.2",
|
"smartpath": "3.2.2",
|
||||||
"smartstring": "^2.0.10",
|
"smartstring": "^2.0.14",
|
||||||
"source-map-support": "^0.4.1",
|
"source-map-support": "^0.4.2",
|
||||||
"tsn": "^1.0.4",
|
"tsn": "^1.0.7",
|
||||||
|
"typedoc": "^0.4.4",
|
||||||
"typescript": "^2.0.0-dev.20160630",
|
"typescript": "^2.0.0-dev.20160630",
|
||||||
"typings-global": "*"
|
"typings-global": "*"
|
||||||
},
|
},
|
||||||
|
@ -1 +0,0 @@
|
|||||||
import "typings-global";
|
|
@ -10,7 +10,7 @@ let compileTs = (tsFileArrayArg:string[],tsOptionsArg = {}) => {
|
|||||||
|
|
||||||
let tsOptionsDefault = {
|
let tsOptionsDefault = {
|
||||||
declaration: true,
|
declaration: true,
|
||||||
target: "ES5",
|
target: "ES6",
|
||||||
module: "commonjs"
|
module: "commonjs"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
import "typings-global";
|
|
||||||
import plugins = require("./npmts.plugins");
|
|
||||||
import paths = require("./npmts.paths");
|
|
||||||
import {npmtsOra} from "./npmts.promisechain";
|
|
||||||
|
|
||||||
let genJsdoc = function(configArg){
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
npmtsOra.text("now generating " + "JsDoc documentation".yellow);
|
|
||||||
plugins.gulp.src([
|
|
||||||
plugins.path.join(paths.cwd,"README.md"),
|
|
||||||
plugins.path.join(paths.distDir,"**/*.js")
|
|
||||||
])
|
|
||||||
.pipe(plugins.g.jsdoc3({
|
|
||||||
opts: {
|
|
||||||
destination: paths.docsDir
|
|
||||||
}
|
|
||||||
}, function(){
|
|
||||||
plugins.beautylog.ok("JsDoc documentation has been generated!");
|
|
||||||
done.resolve(configArg)
|
|
||||||
}));
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export let run = function(configArg){
|
|
||||||
let done = plugins.Q.defer();
|
|
||||||
genJsdoc(configArg)
|
|
||||||
.then(done.resolve);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
@ -2,14 +2,16 @@ import "typings-global";
|
|||||||
export import beautylog = require("beautylog");
|
export import beautylog = require("beautylog");
|
||||||
export let gulp = require("gulp");
|
export let gulp = require("gulp");
|
||||||
export let g = {
|
export let g = {
|
||||||
gFunction: require("gulp-function"),
|
babel: require("gulp-babel"),
|
||||||
istanbul: require("gulp-istanbul"),
|
istanbul: require("gulp-istanbul"),
|
||||||
jsdoc3: require("gulp-jsdoc3"),
|
gFunction: require("gulp-function"),
|
||||||
|
injectModules: require("gulp-inject-modules"),
|
||||||
mocha: require("gulp-mocha"),
|
mocha: require("gulp-mocha"),
|
||||||
replace: require("gulp-replace")
|
replace: require("gulp-replace"),
|
||||||
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
|
typedoc: require("gulp-typedoc")
|
||||||
};
|
};
|
||||||
export let lodashObject = require('lodash/fp/object');
|
export let lodashObject = require('lodash/fp/object');
|
||||||
export let merge2 = require("merge2");
|
|
||||||
export import projectinfo = require("projectinfo");
|
export import projectinfo = require("projectinfo");
|
||||||
export import path = require("path");
|
export import path = require("path");
|
||||||
export import Q = require("q");
|
export import Q = require("q");
|
||||||
@ -22,4 +24,4 @@ export import smartfile = require("smartfile");
|
|||||||
export import smartpath = require("smartpath");
|
export import smartpath = require("smartpath");
|
||||||
export import smartstring = require("smartstring");
|
export import smartstring = require("smartstring");
|
||||||
export let sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing
|
export let sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing
|
||||||
export let tsn = require("tsn");
|
export import tsn = require("tsn");
|
@ -8,7 +8,7 @@ import NpmtsAssets = require("./npmts.assets");
|
|||||||
import NpmtsClean = require("./npmts.clean");
|
import NpmtsClean = require("./npmts.clean");
|
||||||
import NpmtsCompile = require("./npmts.compile");
|
import NpmtsCompile = require("./npmts.compile");
|
||||||
import NpmtsConfigFile = require("./npmts.configfile");
|
import NpmtsConfigFile = require("./npmts.configfile");
|
||||||
import NpmtsJsdoc = require("./npmts.jsdoc");
|
import NpmtsTypeDoc = require("./npmts.typedoc");
|
||||||
import NpmtsOptions = require("./npmts.options");
|
import NpmtsOptions = require("./npmts.options");
|
||||||
import NpmtsTests = require("./npmts.tests");
|
import NpmtsTests = require("./npmts.tests");
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ export let promisechain = function(argvArg){
|
|||||||
.then(NpmtsClean.run)
|
.then(NpmtsClean.run)
|
||||||
.then(NpmtsCompile.run)
|
.then(NpmtsCompile.run)
|
||||||
.then(NpmtsAssets.run)
|
.then(NpmtsAssets.run)
|
||||||
.then(NpmtsJsdoc.run)
|
.then(NpmtsTypeDoc.run)
|
||||||
.then(NpmtsTests.run)
|
.then(NpmtsTests.run)
|
||||||
.then(function(configArg){
|
.then(function(configArg){
|
||||||
let shipString = "" +
|
let shipString = "" +
|
||||||
|
@ -7,33 +7,39 @@ import {npmtsOra} from "./npmts.promisechain";
|
|||||||
*
|
*
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
let istanbul = function (configArg) {
|
let mocha = function (configArg) {
|
||||||
npmtsOra.text("Instrumentalizing transpiled JS...");
|
npmtsOra.text("Instrumentalizing and testing transpiled JS");
|
||||||
|
npmtsOra.end(); // end npmtsOra for tests.
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.Q.defer();
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
|
||||||
.pipe(plugins.g.istanbul()) // Covering files
|
.pipe(plugins.g.sourcemaps.init())
|
||||||
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
|
.pipe(plugins.g.babel({
|
||||||
.pipe(plugins.g.gFunction(function(){
|
presets: [
|
||||||
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!");
|
require.resolve("babel-preset-es2015")
|
||||||
done.resolve(configArg);
|
]
|
||||||
},"atEnd"));
|
}))
|
||||||
return done.promise;
|
.pipe(plugins.g.istanbul({
|
||||||
};
|
}))
|
||||||
|
.pipe(plugins.g.sourcemaps.write())
|
||||||
/**
|
.pipe(plugins.g.injectModules())
|
||||||
*
|
.on("finish",function(){
|
||||||
* @returns {*}
|
plugins.gulp.src([plugins.path.join(paths.cwd,"test/test.js")])
|
||||||
*/
|
.pipe(plugins.g.babel({
|
||||||
let mocha = function (configArg) {
|
presets: [
|
||||||
let done = plugins.Q.defer();
|
plugins.path.join(paths.npmtsPackageRoot,"node_modules/babel-preset-es2015/index.js")
|
||||||
npmtsOra.end(); // end npmtsOra for tests.
|
]
|
||||||
let stream = plugins.gulp.src(["./test/test.js"])
|
}))
|
||||||
.pipe(plugins.g.mocha())
|
.pipe(plugins.g.injectModules())
|
||||||
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
|
.pipe(plugins.g.mocha())
|
||||||
.pipe(plugins.g.gFunction(function(){
|
.pipe(plugins.g.istanbul.writeReports({
|
||||||
plugins.beautylog.ok("Tests have passed!");
|
dir: './coverage',
|
||||||
done.resolve(configArg);
|
reporters: [ 'lcovonly', 'json', 'text', 'text-summary']
|
||||||
},"atEnd"));
|
}))
|
||||||
|
.pipe(plugins.g.gFunction(function(){
|
||||||
|
plugins.beautylog.ok("Tested!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
},"atEnd"));
|
||||||
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,8 +76,7 @@ export let run = function(configArg) {
|
|||||||
"--------------------------------------------------------------"
|
"--------------------------------------------------------------"
|
||||||
);
|
);
|
||||||
|
|
||||||
istanbul(config)
|
mocha(config)
|
||||||
.then(mocha)
|
|
||||||
.then(coverage)
|
.then(coverage)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
|
40
ts/npmts.typedoc.ts
Normal file
40
ts/npmts.typedoc.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import "typings-global";
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
|
|
||||||
|
let genTypeDoc = function(configArg){
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
npmtsOra.text("now generating " + "TypeDoc documentation".yellow);
|
||||||
|
plugins.beautylog.log("TypeDoc Output:");
|
||||||
|
plugins.gulp.src(plugins.path.join(paths.tsDir,"**/*.ts"))
|
||||||
|
.pipe(plugins.g.typedoc({
|
||||||
|
// TypeScript options (see typescript docs)
|
||||||
|
module: "commonjs",
|
||||||
|
target: "es6",
|
||||||
|
includeDeclarations: true,
|
||||||
|
|
||||||
|
// Output options (see typedoc docs)
|
||||||
|
out: paths.docsDir,
|
||||||
|
json: plugins.path.join(paths.docsDir,"file.json"),
|
||||||
|
|
||||||
|
// TypeDoc options (see typedoc docs)
|
||||||
|
name: "my-project",
|
||||||
|
|
||||||
|
//theme: "default",
|
||||||
|
ignoreCompilerErrors: true,
|
||||||
|
version: true,
|
||||||
|
}))
|
||||||
|
.pipe(plugins.g.gFunction(done.resolve,"atEnd"));
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export let run = function(configArg){
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
genTypeDoc(configArg)
|
||||||
|
.then(() => {
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
Reference in New Issue
Block a user