Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
b22abef889 | |||
4d8a7a4202 | |||
72bc08e973 | |||
430f636ae4 | |||
bbc8f13ecf | |||
a01f07f62c | |||
36316e63b2 | |||
5c5e88c226 | |||
af968f65df | |||
f0cc2f4cd6 | |||
f167226830 | |||
3e49b365b6 | |||
c833374fdd | |||
778f057d87 | |||
8f57bf4dd5 | |||
5a9f07002f | |||
ca5ff20107 | |||
a406ff648a |
@ -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
|
|
37
README.md
37
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,7 +30,7 @@ Then add it to your package.json's script section to trigger a build:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npmts"
|
"test": "(npmts)"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -49,28 +51,13 @@ the npmts.json is the main config file. You can use it to customize the behaviou
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"mode":"default",
|
"mode":"default",
|
||||||
"codecov":{
|
|
||||||
"publish":true,
|
|
||||||
"token":"sometoken"
|
|
||||||
},
|
|
||||||
"ts":{
|
"ts":{
|
||||||
"./customdir/*.ts":"./"
|
"./customdir/*.ts":"./"
|
||||||
},
|
},
|
||||||
"docs": {
|
|
||||||
"publish":true,
|
|
||||||
"destination":"github"
|
|
||||||
},
|
|
||||||
"tsOptions":{
|
"tsOptions":{
|
||||||
"declaration":false,
|
"declaration":false,
|
||||||
"target":"ES6"
|
"target":"ES6"
|
||||||
},
|
},
|
||||||
"typings":[
|
|
||||||
"./ts/typings.json",
|
|
||||||
"./subts1/typings.json",
|
|
||||||
"./subts2/typings.json",
|
|
||||||
"./customdir/typings.json"
|
|
||||||
],
|
|
||||||
"typingsInclude":"auto",
|
|
||||||
"cli":true
|
"cli":true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -84,14 +71,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 +90,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 +104,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.
|
||||||
|
30
dist/npmts.jsdoc.js
vendored
30
dist/npmts.jsdoc.js
vendored
@ -3,26 +3,24 @@ require("typings-global");
|
|||||||
var plugins = require("./npmts.plugins");
|
var plugins = require("./npmts.plugins");
|
||||||
var paths = require("./npmts.paths");
|
var paths = require("./npmts.paths");
|
||||||
var npmts_promisechain_1 = require("./npmts.promisechain");
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
var genJsdoc = function (configArg) {
|
var genEsDoc = function (configArg) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
npmts_promisechain_1.npmtsOra.text("now generating " + "JsDoc documentation".yellow);
|
npmts_promisechain_1.npmtsOra.text("now generating " + "EsDoc documentation".yellow);
|
||||||
plugins.gulp.src([
|
plugins.beautylog.log("ESDoc Output:");
|
||||||
plugins.path.join(paths.cwd, "README.md"),
|
var esdocConfig = {
|
||||||
plugins.path.join(paths.distDir, "**/*.js")
|
source: paths.distDir,
|
||||||
])
|
destination: paths.docsDir
|
||||||
.pipe(plugins.g.jsdoc3({
|
};
|
||||||
opts: {
|
plugins.esdoc.generate(esdocConfig, plugins.esdocPublisher);
|
||||||
destination: paths.docsDir
|
plugins.beautylog.ok("Docs by EsDoc have been created!");
|
||||||
}
|
done.resolve(configArg);
|
||||||
}, function () {
|
|
||||||
plugins.beautylog.ok("JsDoc documentation has been generated!");
|
|
||||||
done.resolve(configArg);
|
|
||||||
}));
|
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
exports.run = function (configArg) {
|
exports.run = function (configArg) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
genJsdoc(configArg)
|
genEsDoc(configArg)
|
||||||
.then(done.resolve);
|
.then(function () {
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
4
dist/npmts.plugins.d.ts
vendored
4
dist/npmts.plugins.d.ts
vendored
@ -1,12 +1,14 @@
|
|||||||
import "typings-global";
|
import "typings-global";
|
||||||
export import beautylog = require("beautylog");
|
export import beautylog = require("beautylog");
|
||||||
|
export declare let esdoc: any;
|
||||||
|
export declare let esdocPublisher: any;
|
||||||
export declare let gulp: any;
|
export declare let gulp: any;
|
||||||
export declare let g: {
|
export declare let g: {
|
||||||
gFunction: any;
|
gFunction: any;
|
||||||
istanbul: any;
|
istanbul: any;
|
||||||
jsdoc3: any;
|
|
||||||
mocha: any;
|
mocha: any;
|
||||||
replace: any;
|
replace: any;
|
||||||
|
sourcemaps: any;
|
||||||
};
|
};
|
||||||
export declare let lodashObject: any;
|
export declare let lodashObject: any;
|
||||||
export declare let merge2: any;
|
export declare let merge2: any;
|
||||||
|
6
dist/npmts.plugins.js
vendored
6
dist/npmts.plugins.js
vendored
@ -1,13 +1,15 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
exports.beautylog = require("beautylog");
|
exports.beautylog = require("beautylog");
|
||||||
|
exports.esdoc = require("esdoc");
|
||||||
|
exports.esdocPublisher = require("esdoc/out/src/Publisher/publish");
|
||||||
exports.gulp = require("gulp");
|
exports.gulp = require("gulp");
|
||||||
exports.g = {
|
exports.g = {
|
||||||
gFunction: require("gulp-function"),
|
gFunction: require("gulp-function"),
|
||||||
istanbul: require("gulp-istanbul"),
|
istanbul: require("gulp-istanbul"),
|
||||||
jsdoc3: require("gulp-jsdoc3"),
|
|
||||||
mocha: require("gulp-mocha"),
|
mocha: require("gulp-mocha"),
|
||||||
replace: require("gulp-replace")
|
replace: require("gulp-replace"),
|
||||||
|
sourcemaps: require("gulp-sourcemaps")
|
||||||
};
|
};
|
||||||
exports.lodashObject = require('lodash/fp/object');
|
exports.lodashObject = require('lodash/fp/object');
|
||||||
exports.merge2 = require("merge2");
|
exports.merge2 = require("merge2");
|
||||||
|
2
dist/npmts.tests.js
vendored
2
dist/npmts.tests.js
vendored
@ -11,7 +11,9 @@ var istanbul = function (configArg) {
|
|||||||
npmts_promisechain_1.npmtsOra.text("Instrumentalizing transpiled JS...");
|
npmts_promisechain_1.npmtsOra.text("Instrumentalizing transpiled JS...");
|
||||||
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.sourcemaps.init())
|
||||||
.pipe(plugins.g.istanbul()) // Covering files
|
.pipe(plugins.g.istanbul()) // Covering files
|
||||||
|
.pipe(plugins.g.sourcemaps.write())
|
||||||
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
|
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
|
||||||
.pipe(plugins.g.gFunction(function () {
|
.pipe(plugins.g.gFunction(function () {
|
||||||
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!");
|
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!");
|
||||||
|
21
package.json
21
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "5.3.5",
|
"version": "5.3.10",
|
||||||
"description": "write npm modules with TypeScript",
|
"description": "write npm modules with TypeScript",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -12,8 +12,7 @@
|
|||||||
"setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)",
|
"setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)",
|
||||||
"check": "(cd test && node ../dist/index.js)",
|
"check": "(cd test && node ../dist/index.js)",
|
||||||
"checkVersion": "(cd test/ && node ../dist/index.js -v)",
|
"checkVersion": "(cd test/ && node ../dist/index.js -v)",
|
||||||
"checkNoTest": "(cd test && node ../dist/index.js --notest)",
|
"checkNoTest": "(cd test && node ../dist/index.js --notest)"
|
||||||
"install": "(mkdir test/)"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -30,11 +29,12 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/npmts#readme",
|
"homepage": "https://gitlab.com/pushrocks/npmts#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/minimatch": "^2.0.22-alpha",
|
"@types/minimatch": "^2.0.27-alpha",
|
||||||
"@types/q": "0.0.21-alpha",
|
"@types/q": "0.0.26-alpha",
|
||||||
"@types/shelljs": "^0.3.21-alpha",
|
"@types/shelljs": "^0.3.26-alpha",
|
||||||
"beautylog": "5.0.12",
|
"beautylog": "5.0.13",
|
||||||
"early": "^2.0.13",
|
"early": "^2.0.13",
|
||||||
|
"esdoc": "^0.4.7",
|
||||||
"gulp": "3.9.1",
|
"gulp": "3.9.1",
|
||||||
"gulp-concat": "^2.6.0",
|
"gulp-concat": "^2.6.0",
|
||||||
"gulp-function": "^1.3.6",
|
"gulp-function": "^1.3.6",
|
||||||
@ -43,6 +43,7 @@
|
|||||||
"gulp-jsdoc3": "^0.3.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",
|
||||||
"lodash": "^4.13.1",
|
"lodash": "^4.13.1",
|
||||||
"merge2": "1.0.2",
|
"merge2": "1.0.2",
|
||||||
"projectinfo": "1.0.3",
|
"projectinfo": "1.0.3",
|
||||||
@ -52,11 +53,11 @@
|
|||||||
"smartcli": "1.0.4",
|
"smartcli": "1.0.4",
|
||||||
"smartcov": "0.0.6",
|
"smartcov": "0.0.6",
|
||||||
"smartenv": "1.2.5",
|
"smartenv": "1.2.5",
|
||||||
"smartfile": "4.0.9",
|
"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.1",
|
||||||
"tsn": "^1.0.3",
|
"tsn": "^1.0.6",
|
||||||
"typescript": "^2.0.0-dev.20160630",
|
"typescript": "^2.0.0-dev.20160630",
|
||||||
"typings-global": "*"
|
"typings-global": "*"
|
||||||
},
|
},
|
||||||
|
@ -3,28 +3,26 @@ import plugins = require("./npmts.plugins");
|
|||||||
import paths = require("./npmts.paths");
|
import paths = require("./npmts.paths");
|
||||||
import {npmtsOra} from "./npmts.promisechain";
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
|
|
||||||
let genJsdoc = function(configArg){
|
let genEsDoc = function(configArg){
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.Q.defer();
|
||||||
npmtsOra.text("now generating " + "JsDoc documentation".yellow);
|
npmtsOra.text("now generating " + "EsDoc documentation".yellow);
|
||||||
plugins.gulp.src([
|
plugins.beautylog.log("ESDoc Output:");
|
||||||
plugins.path.join(paths.cwd,"README.md"),
|
let esdocConfig = {
|
||||||
plugins.path.join(paths.distDir,"**/*.js")
|
source: paths.distDir,
|
||||||
])
|
destination: paths.docsDir
|
||||||
.pipe(plugins.g.jsdoc3({
|
};
|
||||||
opts: {
|
plugins.esdoc.generate(esdocConfig,plugins.esdocPublisher);
|
||||||
destination: paths.docsDir
|
plugins.beautylog.ok("Docs by EsDoc have been created!");
|
||||||
}
|
done.resolve(configArg);
|
||||||
}, function(){
|
|
||||||
plugins.beautylog.ok("JsDoc documentation has been generated!");
|
|
||||||
done.resolve(configArg)
|
|
||||||
}));
|
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export let run = function(configArg){
|
export let run = function(configArg){
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.Q.defer();
|
||||||
genJsdoc(configArg)
|
genEsDoc(configArg)
|
||||||
.then(done.resolve);
|
.then(() => {
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
@ -1,12 +1,14 @@
|
|||||||
import "typings-global";
|
import "typings-global";
|
||||||
export import beautylog = require("beautylog");
|
export import beautylog = require("beautylog");
|
||||||
|
export let esdoc = require("esdoc");
|
||||||
|
export let esdocPublisher = require("esdoc/out/src/Publisher/publish");
|
||||||
export let gulp = require("gulp");
|
export let gulp = require("gulp");
|
||||||
export let g = {
|
export let g = {
|
||||||
gFunction: require("gulp-function"),
|
gFunction: require("gulp-function"),
|
||||||
istanbul: require("gulp-istanbul"),
|
istanbul: require("gulp-istanbul"),
|
||||||
jsdoc3: require("gulp-jsdoc3"),
|
|
||||||
mocha: require("gulp-mocha"),
|
mocha: require("gulp-mocha"),
|
||||||
replace: require("gulp-replace")
|
replace: require("gulp-replace"),
|
||||||
|
sourcemaps: require("gulp-sourcemaps")
|
||||||
};
|
};
|
||||||
export let lodashObject = require('lodash/fp/object');
|
export let lodashObject = require('lodash/fp/object');
|
||||||
export let merge2 = require("merge2");
|
export let merge2 = require("merge2");
|
||||||
|
@ -11,7 +11,9 @@ let istanbul = function (configArg) {
|
|||||||
npmtsOra.text("Instrumentalizing transpiled JS...");
|
npmtsOra.text("Instrumentalizing transpiled JS...");
|
||||||
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.sourcemaps.init())
|
||||||
.pipe(plugins.g.istanbul()) // Covering files
|
.pipe(plugins.g.istanbul()) // Covering files
|
||||||
|
.pipe(plugins.g.sourcemaps.write())
|
||||||
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
|
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
|
||||||
.pipe(plugins.g.gFunction(function(){
|
.pipe(plugins.g.gFunction(function(){
|
||||||
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!");
|
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!");
|
||||||
|
Reference in New Issue
Block a user