Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
51753df662 | |||
36c002581a | |||
db1cfe4746 | |||
2c254a2ecf | |||
425bc6150a | |||
b2aaa51882 | |||
8ee6623984 | |||
91ec17c51d | |||
646dbdaa3a | |||
4550fcd375 | |||
4d1b992193 | |||
cf2d482798 | |||
43853e4d71 | |||
6a650b9f1b | |||
c76cc6baf7 | |||
659fa9ba95 | |||
97c47ed696 |
17
README.md
17
README.md
@ -6,7 +6,7 @@ Write npm modules with TypeScript without hassle. TypeScript ready. Fully ES6.
|
|||||||
[](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)
|
||||||
[](https://codecov.io/github/pushrocks/npmts?branch=master)
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
|
||||||
## What is NPMTS?
|
## What is NPMTS?
|
||||||
NPMTS is your friend when it comes to write, test, publish and document NPM modules written in TypeScript.
|
NPMTS is your friend when it comes to write, test, publish and document NPM modules written in TypeScript.
|
||||||
@ -38,12 +38,13 @@ Then add it to your package.json's script section to trigger a build:
|
|||||||
|
|
||||||
1. **Config:** Check config in ./npmextra.json (Check out [npmextra](https://www.npmjs.com/package/npmextra))
|
1. **Config:** Check config in ./npmextra.json (Check out [npmextra](https://www.npmjs.com/package/npmextra))
|
||||||
1. **Clean:** Clean up from any previous builds (old js files)
|
1. **Clean:** Clean up from any previous builds (old js files)
|
||||||
1. **Transpile:** Transpile TypeScript with **inline sourcemaps** and **declaration files** to ES6
|
1. **Check:** Check project for typings declaration in package.json, unused dependencies and missing dependencies
|
||||||
|
1. **Transpile:** Transpile TypeScript with **inline sourcemaps** and **declaration files** to ES target
|
||||||
1. **Documentation:** Create TypeDoc Documentation from TypeScript files
|
1. **Documentation:** Create TypeDoc Documentation from TypeScript files
|
||||||
1. **Test:** Babelify ES6 to ES5 on the fly, instrumentalize ES5 JavaScript with istanbul and run tests with Mocha.
|
1. **Test:** Babelify ES6 to ES5 on the fly, instrumentalize ES5 JavaScript with istanbul and run tests with Mocha.
|
||||||
|
|
||||||
### npmextra.json
|
### npmextra.json
|
||||||
the npmts section in npmtsextra.json can be used to configure npmts.
|
the npmts section in npmextra.json can be used to configure npmts.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@ -64,6 +65,7 @@ the npmts section in npmtsextra.json can be used to configure npmts.
|
|||||||
| key | default value | description |
|
| key | default value | description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `"mode"` | `"default"` | "default" will do some default stuff, "custom" only does what you specify |
|
| `"mode"` | `"default"` | "default" will do some default stuff, "custom" only does what you specify |
|
||||||
|
| `"ts"` | `{"./ts/*.ts":"./","./test/test.ts":"./test/"}` | allows you to define multiple ts portions |
|
||||||
| `"tsOptions"` | `{"target":"ES5", "declaration":"true"}` | specify options for tsc |
|
| `"tsOptions"` | `{"target":"ES5", "declaration":"true"}` | specify options for tsc |
|
||||||
| `"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. |
|
||||||
|
|
||||||
@ -74,7 +76,7 @@ by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
|
|||||||
Use commonjs module system for wiring up files.
|
Use commonjs module system for wiring up files.
|
||||||
|
|
||||||
### Declaration files
|
### Declaration files
|
||||||
**npmts** also creates an `./dist/index.d.ts` declaration file by default.
|
**npmts** also creates declaration files like `./dist/index.d.ts` by default.
|
||||||
You can reference it in your package.json like this.
|
You can reference it in your package.json like this.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
@ -88,7 +90,7 @@ and tsc will pick up the declaration file automatically.
|
|||||||
|
|
||||||
## Some notes:
|
## Some notes:
|
||||||
#### Typings for third party modules that do not bundle declaration files
|
#### 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.
|
NPMTS 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.
|
||||||
@ -109,6 +111,11 @@ thanks to autogenerated source maps.
|
|||||||
* 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
|
||||||
* Use [npmdocker](https://www.npmjs.com/package/npmdocker) for running tests consistently with docker.
|
* Use [npmdocker](https://www.npmjs.com/package/npmdocker) for running tests consistently with docker.
|
||||||
|
|
||||||
|
## Future Scope:
|
||||||
|
* automatically manage badges in README
|
||||||
|
* manage tslint to enforce code best practices
|
||||||
|
* tear down any differences between local and CI environments by using brand new npmdocker
|
||||||
|
|
||||||
## About the authors:
|
## About the authors:
|
||||||
[](https://lossless.com/)
|
[](https://lossless.com/)
|
||||||
|
|
||||||
|
103
dist/npmts.check.js
vendored
103
dist/npmts.check.js
vendored
@ -4,13 +4,32 @@ var paths = require("./npmts.paths");
|
|||||||
var npmts_promisechain_1 = require("./npmts.promisechain");
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
var checkProjectTypings = function (configArg) {
|
var checkProjectTypings = function (configArg) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
|
var cwdProjectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.cwd);
|
||||||
|
if (typeof cwdProjectInfo.packageJson.typings == "undefined") {
|
||||||
|
plugins.beautylog.error("please add typings field to package.json");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
;
|
||||||
done.resolve(configArg);
|
done.resolve(configArg);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
var depcheckOptions = {
|
||||||
|
ignoreBinPackage: false,
|
||||||
|
parsers: {
|
||||||
|
'*.ts': plugins.depcheck.parser.typescript,
|
||||||
|
},
|
||||||
|
detectors: [
|
||||||
|
plugins.depcheck.detector.requireCallExpression,
|
||||||
|
plugins.depcheck.detector.importDeclaration
|
||||||
|
],
|
||||||
|
specials: [
|
||||||
|
plugins.depcheck.special.eslint,
|
||||||
|
plugins.depcheck.special.webpack
|
||||||
|
],
|
||||||
|
};
|
||||||
var checkDependencies = function (configArg) {
|
var checkDependencies = function (configArg) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
var options = {
|
var depcheckOptionsMerged = plugins.lodashObject.merge(depcheckOptions, {
|
||||||
ignoreBinPackage: false,
|
|
||||||
ignoreDirs: [
|
ignoreDirs: [
|
||||||
'test',
|
'test',
|
||||||
'dist',
|
'dist',
|
||||||
@ -19,32 +38,16 @@ var checkDependencies = function (configArg) {
|
|||||||
ignoreMatches: [
|
ignoreMatches: [
|
||||||
"@types/*",
|
"@types/*",
|
||||||
"babel-preset-*"
|
"babel-preset-*"
|
||||||
],
|
]
|
||||||
parsers: {
|
});
|
||||||
'*.ts': plugins.depcheck.parser.typescript,
|
plugins.depcheck(paths.cwd, depcheckOptionsMerged, function (unused) {
|
||||||
},
|
|
||||||
detectors: [
|
|
||||||
plugins.depcheck.detector.requireCallExpression,
|
|
||||||
plugins.depcheck.detector.importDeclaration
|
|
||||||
],
|
|
||||||
specials: [
|
|
||||||
plugins.depcheck.special.eslint,
|
|
||||||
plugins.depcheck.special.webpack
|
|
||||||
],
|
|
||||||
};
|
|
||||||
plugins.depcheck(paths.cwd, options, function (unused) {
|
|
||||||
for (var _i = 0, _a = unused.dependencies; _i < _a.length; _i++) {
|
for (var _i = 0, _a = unused.dependencies; _i < _a.length; _i++) {
|
||||||
var item = _a[_i];
|
var item = _a[_i];
|
||||||
plugins.beautylog.warn("Watch out: unused dependency " + item.red);
|
plugins.beautylog.warn("Watch out: unused dependency " + item.red);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
for (var _b = 0, _c = unused.devDependencies; _b < _c.length; _b++) {
|
for (var _b = 0, _c = unused.missing; _b < _c.length; _b++) {
|
||||||
var item = _c[_b];
|
var item = _c[_b];
|
||||||
plugins.beautylog.log("unused devDependency " + item.red);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
for (var _d = 0, _e = unused.missing; _d < _e.length; _d++) {
|
|
||||||
var item = _e[_d];
|
|
||||||
plugins.beautylog.error("unused devDependency " + item.red);
|
plugins.beautylog.error("unused devDependency " + item.red);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -52,18 +55,55 @@ var checkDependencies = function (configArg) {
|
|||||||
plugins.beautylog.info("exiting due to missing dependencies in package.json");
|
plugins.beautylog.info("exiting due to missing dependencies in package.json");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
for (var _f = 0, _g = unused.using; _f < _g.length; _f++) {
|
for (var _d = 0, _e = unused.invalidFiles; _d < _e.length; _d++) {
|
||||||
var item = _g[_f];
|
var item = _e[_d];
|
||||||
console.log(item);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
for (var _h = 0, _j = unused.invalidFiles; _h < _j.length; _h++) {
|
|
||||||
var item = _j[_h];
|
|
||||||
plugins.beautylog.warn("Watch out: could not parse file " + item.red);
|
plugins.beautylog.warn("Watch out: could not parse file " + item.red);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
for (var _k = 0, _l = unused.invalidDirs; _k < _l.length; _k++) {
|
for (var _f = 0, _g = unused.invalidDirs; _f < _g.length; _f++) {
|
||||||
var item = _l[_k];
|
var item = _g[_f];
|
||||||
|
plugins.beautylog.warn("Watch out: could not parse directory " + item.red);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
var checkDevDependencies = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var depcheckOptionsMerged = plugins.lodashObject.merge(depcheckOptions, {
|
||||||
|
ignoreDirs: [
|
||||||
|
'ts',
|
||||||
|
'dist',
|
||||||
|
'bower_components'
|
||||||
|
],
|
||||||
|
ignoreMatches: [
|
||||||
|
"@types/*",
|
||||||
|
"babel-preset-*"
|
||||||
|
]
|
||||||
|
});
|
||||||
|
plugins.depcheck(paths.cwd, depcheckOptionsMerged, function (unused) {
|
||||||
|
for (var _i = 0, _a = unused.devDependencies; _i < _a.length; _i++) {
|
||||||
|
var item = _a[_i];
|
||||||
|
plugins.beautylog.log("unused devDependency " + item.red);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
for (var _b = 0, _c = unused.missing; _b < _c.length; _b++) {
|
||||||
|
var item = _c[_b];
|
||||||
|
plugins.beautylog.error("unused devDependency " + item.red);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
if (unused.missing.length > 0) {
|
||||||
|
plugins.beautylog.info("exiting due to missing dependencies in package.json");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
for (var _d = 0, _e = unused.invalidFiles; _d < _e.length; _d++) {
|
||||||
|
var item = _e[_d];
|
||||||
|
plugins.beautylog.warn("Watch out: could not parse file " + item.red);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
for (var _f = 0, _g = unused.invalidDirs; _f < _g.length; _f++) {
|
||||||
|
var item = _g[_f];
|
||||||
plugins.beautylog.warn("Watch out: could not parse directory " + item.red);
|
plugins.beautylog.warn("Watch out: could not parse directory " + item.red);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -81,6 +121,7 @@ exports.run = function (configArg) {
|
|||||||
npmts_promisechain_1.npmtsOra.text("running project checks..."),
|
npmts_promisechain_1.npmtsOra.text("running project checks..."),
|
||||||
checkProjectTypings(configArg)
|
checkProjectTypings(configArg)
|
||||||
.then(checkDependencies)
|
.then(checkDependencies)
|
||||||
|
.then(checkDevDependencies)
|
||||||
.then(checkNodeVersion)
|
.then(checkNodeVersion)
|
||||||
.then(done.resolve);
|
.then(done.resolve);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
|
7
dist/npmts.configfile.js
vendored
7
dist/npmts.configfile.js
vendored
@ -8,12 +8,17 @@ exports.run = function (argvArg) {
|
|||||||
npmts_promisechain_1.npmtsOra.text("looking for npmextra.json");
|
npmts_promisechain_1.npmtsOra.text("looking for npmextra.json");
|
||||||
var defaultConfig = {
|
var defaultConfig = {
|
||||||
mode: "default",
|
mode: "default",
|
||||||
notest: false
|
notest: false,
|
||||||
|
nodocs: false
|
||||||
};
|
};
|
||||||
if (argvArg.notest) {
|
if (argvArg.notest) {
|
||||||
defaultConfig.notest = true;
|
defaultConfig.notest = true;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
if (argvArg.nodocs) {
|
||||||
|
defaultConfig.nodocs = true;
|
||||||
|
}
|
||||||
|
;
|
||||||
var config = plugins.npmextra.dataFor({
|
var config = plugins.npmextra.dataFor({
|
||||||
toolName: "npmts",
|
toolName: "npmts",
|
||||||
defaultSettings: defaultConfig,
|
defaultSettings: defaultConfig,
|
||||||
|
2
dist/npmts.tests.js
vendored
2
dist/npmts.tests.js
vendored
@ -25,7 +25,7 @@ var mocha = function (configArg) {
|
|||||||
plugins.gulp.src([plugins.path.join(paths.cwd, "test/test.js")])
|
plugins.gulp.src([plugins.path.join(paths.cwd, "test/test.js")])
|
||||||
.pipe(plugins.g.babel({
|
.pipe(plugins.g.babel({
|
||||||
presets: [
|
presets: [
|
||||||
plugins.path.join(paths.npmtsPackageRoot, "node_modules/babel-preset-es2015/index.js")
|
require.resolve("babel-preset-es2015")
|
||||||
]
|
]
|
||||||
}))
|
}))
|
||||||
.pipe(plugins.g.injectModules())
|
.pipe(plugins.g.injectModules())
|
||||||
|
12
dist/npmts.typedoc.js
vendored
12
dist/npmts.typedoc.js
vendored
@ -27,9 +27,15 @@ var genTypeDoc = function (configArg) {
|
|||||||
};
|
};
|
||||||
exports.run = function (configArg) {
|
exports.run = function (configArg) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
genTypeDoc(configArg)
|
if (configArg.nodocs) {
|
||||||
.then(function () {
|
|
||||||
done.resolve(configArg);
|
done.resolve(configArg);
|
||||||
});
|
}
|
||||||
|
else {
|
||||||
|
genTypeDoc(configArg)
|
||||||
|
.then(function () {
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
;
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "5.4.0",
|
"version": "5.4.7",
|
||||||
"description": "Write npm modules with TypeScript without hassle. TypeScript ready. Fully ES6.",
|
"description": "Write npm modules with TypeScript without hassle. TypeScript ready. Fully ES6.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"npmts": "dist/cli.js"
|
"npmts": "dist/cli.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npm run compile && npm run setupCheck && npm run check && npm run checkVersion && npm run checkNoTest)",
|
"test": "(npm run compile && npm run setupCheck && npm run check && npm run checkVersion && npm run checkNoTest && npm run checkNoDocs)",
|
||||||
"compile": "(rm -rf test/ && rm -r dist/ && mkdir dist/ && tsc && cp assets/cli.js dist/ )",
|
"compile": "(rm -rf test/ && rm -r dist/ && mkdir dist/ && tsc && cp assets/cli.js dist/ )",
|
||||||
"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 && npm install && 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)",
|
||||||
|
"checkNoDocs": "(cd test && node ../dist/index.js --nodocs)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -1,18 +1,36 @@
|
|||||||
import * as plugins from "./npmts.plugins";
|
import * as plugins from "./npmts.plugins";
|
||||||
import * as paths from "./npmts.paths";
|
import * as paths from "./npmts.paths";
|
||||||
import {npmtsOra} from "./npmts.promisechain";
|
import { npmtsOra } from "./npmts.promisechain";
|
||||||
|
|
||||||
let checkProjectTypings = (configArg) => {
|
let checkProjectTypings = (configArg) => {
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.Q.defer();
|
||||||
|
let cwdProjectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.cwd);
|
||||||
|
if(typeof cwdProjectInfo.packageJson.typings == "undefined"){
|
||||||
|
plugins.beautylog.error(`please add typings field to package.json`);
|
||||||
|
process.exit(1);
|
||||||
|
};
|
||||||
done.resolve(configArg);
|
done.resolve(configArg);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const depcheckOptions = {
|
||||||
|
ignoreBinPackage: false, // ignore the packages with bin entry
|
||||||
|
parsers: { // the target parsers
|
||||||
|
'*.ts': plugins.depcheck.parser.typescript,
|
||||||
|
},
|
||||||
|
detectors: [ // the target detectors
|
||||||
|
plugins.depcheck.detector.requireCallExpression,
|
||||||
|
plugins.depcheck.detector.importDeclaration
|
||||||
|
],
|
||||||
|
specials: [ // the target special parsers
|
||||||
|
plugins.depcheck.special.eslint,
|
||||||
|
plugins.depcheck.special.webpack
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
let checkDependencies = (configArg) => {
|
let checkDependencies = (configArg) => {
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.Q.defer();
|
||||||
const options = {
|
let depcheckOptionsMerged = plugins.lodashObject.merge(depcheckOptions, {
|
||||||
ignoreBinPackage: false, // ignore the packages with bin entry
|
|
||||||
ignoreDirs: [ // folder with these names will be ignored
|
ignoreDirs: [ // folder with these names will be ignored
|
||||||
'test',
|
'test',
|
||||||
'dist',
|
'dist',
|
||||||
@ -21,41 +39,58 @@ let checkDependencies = (configArg) => {
|
|||||||
ignoreMatches: [ // ignore dependencies that matches these globs
|
ignoreMatches: [ // ignore dependencies that matches these globs
|
||||||
"@types/*",
|
"@types/*",
|
||||||
"babel-preset-*"
|
"babel-preset-*"
|
||||||
],
|
]
|
||||||
parsers: { // the target parsers
|
})
|
||||||
'*.ts': plugins.depcheck.parser.typescript,
|
plugins.depcheck(paths.cwd, depcheckOptionsMerged, (unused) => {
|
||||||
},
|
for (let item of unused.dependencies) {
|
||||||
detectors: [ // the target detectors
|
|
||||||
plugins.depcheck.detector.requireCallExpression,
|
|
||||||
plugins.depcheck.detector.importDeclaration
|
|
||||||
],
|
|
||||||
specials: [ // the target special parsers
|
|
||||||
plugins.depcheck.special.eslint,
|
|
||||||
plugins.depcheck.special.webpack
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
plugins.depcheck(paths.cwd, options, (unused) => {
|
|
||||||
for (let item of unused.dependencies){
|
|
||||||
plugins.beautylog.warn(`Watch out: unused dependency ${item.red}`);
|
plugins.beautylog.warn(`Watch out: unused dependency ${item.red}`);
|
||||||
};
|
};
|
||||||
for (let item of unused.devDependencies){
|
for (let item of unused.missing) {
|
||||||
plugins.beautylog.log(`unused devDependency ${item.red}`);
|
|
||||||
};
|
|
||||||
for (let item of unused.missing){
|
|
||||||
plugins.beautylog.error(`unused devDependency ${item.red}`);
|
plugins.beautylog.error(`unused devDependency ${item.red}`);
|
||||||
};
|
};
|
||||||
if(unused.missing.length > 0){
|
if (unused.missing.length > 0) {
|
||||||
plugins.beautylog.info("exiting due to missing dependencies in package.json");
|
plugins.beautylog.info("exiting due to missing dependencies in package.json");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
for (let item of unused.using){
|
for (let item of unused.invalidFiles) {
|
||||||
console.log(item);
|
|
||||||
};
|
|
||||||
for(let item of unused.invalidFiles){
|
|
||||||
plugins.beautylog.warn(`Watch out: could not parse file ${item.red}`);
|
plugins.beautylog.warn(`Watch out: could not parse file ${item.red}`);
|
||||||
};
|
};
|
||||||
for(let item of unused.invalidDirs){
|
for (let item of unused.invalidDirs) {
|
||||||
|
plugins.beautylog.warn(`Watch out: could not parse directory ${item.red}`);
|
||||||
|
};
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
let checkDevDependencies = (configArg) => {
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let depcheckOptionsMerged = plugins.lodashObject.merge(depcheckOptions, {
|
||||||
|
ignoreDirs: [ // folder with these names will be ignored
|
||||||
|
'ts',
|
||||||
|
'dist',
|
||||||
|
'bower_components'
|
||||||
|
],
|
||||||
|
ignoreMatches: [ // ignore dependencies that matches these globs
|
||||||
|
"@types/*",
|
||||||
|
"babel-preset-*"
|
||||||
|
]
|
||||||
|
})
|
||||||
|
plugins.depcheck(paths.cwd, depcheckOptionsMerged, (unused) => {
|
||||||
|
for (let item of unused.devDependencies) {
|
||||||
|
plugins.beautylog.log(`unused devDependency ${item.red}`);
|
||||||
|
};
|
||||||
|
for (let item of unused.missing) {
|
||||||
|
plugins.beautylog.error(`unused devDependency ${item.red}`);
|
||||||
|
};
|
||||||
|
if (unused.missing.length > 0) {
|
||||||
|
plugins.beautylog.info("exiting due to missing dependencies in package.json");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
for (let item of unused.invalidFiles) {
|
||||||
|
plugins.beautylog.warn(`Watch out: could not parse file ${item.red}`);
|
||||||
|
};
|
||||||
|
for (let item of unused.invalidDirs) {
|
||||||
plugins.beautylog.warn(`Watch out: could not parse directory ${item.red}`);
|
plugins.beautylog.warn(`Watch out: could not parse directory ${item.red}`);
|
||||||
};
|
};
|
||||||
done.resolve(configArg);
|
done.resolve(configArg);
|
||||||
@ -73,9 +108,10 @@ let checkNodeVersion = (configArg) => {
|
|||||||
export let run = (configArg) => {
|
export let run = (configArg) => {
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.Q.defer();
|
||||||
npmtsOra.text("running project checks..."),
|
npmtsOra.text("running project checks..."),
|
||||||
checkProjectTypings(configArg)
|
checkProjectTypings(configArg)
|
||||||
.then(checkDependencies)
|
.then(checkDependencies)
|
||||||
.then(checkNodeVersion)
|
.then(checkDevDependencies)
|
||||||
.then(done.resolve);
|
.then(checkNodeVersion)
|
||||||
|
.then(done.resolve);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,15 @@ export var run = function(argvArg){
|
|||||||
npmtsOra.text("looking for npmextra.json");
|
npmtsOra.text("looking for npmextra.json");
|
||||||
let defaultConfig = {
|
let defaultConfig = {
|
||||||
mode: "default",
|
mode: "default",
|
||||||
notest:false
|
notest:false,
|
||||||
|
nodocs:false
|
||||||
};
|
};
|
||||||
if(argvArg.notest){
|
if(argvArg.notest){
|
||||||
defaultConfig.notest = true;
|
defaultConfig.notest = true;
|
||||||
};
|
};
|
||||||
|
if(argvArg.nodocs){
|
||||||
|
defaultConfig.nodocs = true;
|
||||||
|
};
|
||||||
let config = plugins.npmextra.dataFor({
|
let config = plugins.npmextra.dataFor({
|
||||||
toolName:"npmts",
|
toolName:"npmts",
|
||||||
defaultSettings:defaultConfig,
|
defaultSettings:defaultConfig,
|
||||||
|
@ -26,7 +26,7 @@ let mocha = function (configArg) {
|
|||||||
plugins.gulp.src([plugins.path.join(paths.cwd,"test/test.js")])
|
plugins.gulp.src([plugins.path.join(paths.cwd,"test/test.js")])
|
||||||
.pipe(plugins.g.babel({
|
.pipe(plugins.g.babel({
|
||||||
presets: [
|
presets: [
|
||||||
plugins.path.join(paths.npmtsPackageRoot,"node_modules/babel-preset-es2015/index.js")
|
require.resolve("babel-preset-es2015")
|
||||||
]
|
]
|
||||||
}))
|
}))
|
||||||
.pipe(plugins.g.injectModules())
|
.pipe(plugins.g.injectModules())
|
||||||
|
@ -1,40 +1,44 @@
|
|||||||
import "typings-global";
|
import "typings-global";
|
||||||
import plugins = require("./npmts.plugins");
|
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 genTypeDoc = function(configArg){
|
let genTypeDoc = function (configArg) {
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.Q.defer();
|
||||||
npmtsOra.text("now generating " + "TypeDoc documentation".yellow);
|
npmtsOra.text("now generating " + "TypeDoc documentation".yellow);
|
||||||
plugins.beautylog.log("TypeDoc Output:");
|
plugins.beautylog.log("TypeDoc Output:");
|
||||||
plugins.gulp.src(plugins.path.join(paths.tsDir,"**/*.ts"))
|
plugins.gulp.src(plugins.path.join(paths.tsDir, "**/*.ts"))
|
||||||
.pipe(plugins.g.typedoc({
|
.pipe(plugins.g.typedoc({
|
||||||
// TypeScript options (see typescript docs)
|
// TypeScript options (see typescript docs)
|
||||||
module: "commonjs",
|
module: "commonjs",
|
||||||
target: "es6",
|
target: "es6",
|
||||||
includeDeclarations: true,
|
includeDeclarations: true,
|
||||||
|
|
||||||
// Output options (see typedoc docs)
|
// Output options (see typedoc docs)
|
||||||
out: paths.docsDir,
|
out: paths.docsDir,
|
||||||
json: plugins.path.join(paths.docsDir,"file.json"),
|
json: plugins.path.join(paths.docsDir, "file.json"),
|
||||||
|
|
||||||
// TypeDoc options (see typedoc docs)
|
// TypeDoc options (see typedoc docs)
|
||||||
name: "my-project",
|
name: "my-project",
|
||||||
|
|
||||||
//theme: "default",
|
//theme: "default",
|
||||||
ignoreCompilerErrors: true,
|
ignoreCompilerErrors: true,
|
||||||
version: true,
|
version: true,
|
||||||
}))
|
}))
|
||||||
.pipe(plugins.g.gFunction(done.resolve,"atEnd"));
|
.pipe(plugins.g.gFunction(done.resolve, "atEnd"));
|
||||||
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();
|
||||||
genTypeDoc(configArg)
|
if (configArg.nodocs) {
|
||||||
.then(() => {
|
done.resolve(configArg);
|
||||||
done.resolve(configArg);
|
} else {
|
||||||
});
|
genTypeDoc(configArg)
|
||||||
|
.then(() => {
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
};
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
Reference in New Issue
Block a user