Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
9cd24695db | |||
46c79e711b | |||
4b07c9951f |
2
dist/mod00/mod00.check.js
vendored
2
dist/mod00/mod00.check.js
vendored
@ -85,7 +85,7 @@ let checkDevDependencies = (configArg) => {
|
|||||||
plugins.beautylog.log(`unused devDependency ${item}`);
|
plugins.beautylog.log(`unused devDependency ${item}`);
|
||||||
}
|
}
|
||||||
for (let item in unused.missing) {
|
for (let item in unused.missing) {
|
||||||
plugins.beautylog.error(`unused devDependency ${item}`);
|
plugins.beautylog.error(`missing devDependency ${item}`);
|
||||||
}
|
}
|
||||||
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');
|
||||||
|
8
dist/mod02/index.js
vendored
8
dist/mod02/index.js
vendored
@ -77,7 +77,13 @@ let tap = function (configArg) {
|
|||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
let handleCoverageData = (configArg) => __awaiter(this, void 0, void 0, function* () {
|
let handleCoverageData = (configArg) => __awaiter(this, void 0, void 0, function* () {
|
||||||
let coverageResult = yield plugins.smartcov.get.percentageFromLcovString(configArg.runData.coverageLcovInfo, 2);
|
let coverageResult = 0; // the coverage in percent
|
||||||
|
if (configArg.runData.coverageLcovInfo) {
|
||||||
|
coverageResult = yield plugins.smartcov.get.percentageFromLcovString(configArg.runData.coverageLcovInfo, 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugins.beautylog.warn('Hey... Did your tests import and use your module that you are trying to test?');
|
||||||
|
}
|
||||||
if (coverageResult >= configArg.coverageTreshold) {
|
if (coverageResult >= configArg.coverageTreshold) {
|
||||||
plugins.beautylog.ok(`${(coverageResult).toString()}% `
|
plugins.beautylog.ok(`${(coverageResult).toString()}% `
|
||||||
+ `coverage exceeds your treshold of `
|
+ `coverage exceeds your treshold of `
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "7.0.16",
|
"version": "7.0.17",
|
||||||
"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": {
|
||||||
|
12
readme.md
12
readme.md
@ -11,9 +11,9 @@ Write npm modules with TypeScript without hassle. TypeScript ready. Fully ES6.
|
|||||||
[](https://GitLab.com/gitzone/npmts/commits/master)
|
[](https://GitLab.com/gitzone/npmts/commits/master)
|
||||||
[](https://GitLab.com/gitzone/npmts/commits/master)
|
[](https://GitLab.com/gitzone/npmts/commits/master)
|
||||||
[](https://www.npmjs.com/package/npmts)
|
[](https://www.npmjs.com/package/npmts)
|
||||||
[](https://david-dm.org/gitzone/npmts)
|
[](https://david-dm.org/gitzonetools/npmts)
|
||||||
[](https://www.bithound.io/github/gitzone/npmts/master/dependencies/npm)
|
[](https://www.bithound.io/github/gitzonetools/npmts/master/dependencies/npm)
|
||||||
[](https://www.bithound.io/github/gitzone/npmts)
|
[](https://www.bithound.io/github/gitzonetools/npmts)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
[](http://standardjs.com/)
|
[](http://standardjs.com/)
|
||||||
@ -22,7 +22,7 @@ Write npm modules with TypeScript without hassle. TypeScript ready. Fully ES6.
|
|||||||
NPMTS is your friend when writing, testing, publishing and documenting npm modules written in TypeScript.
|
NPMTS is your friend when writing, testing, publishing and documenting npm modules written in TypeScript.
|
||||||
|
|
||||||
npmts will
|
npmts will
|
||||||
|
|
||||||
1. check your dependencies and package.json (unused, missing, updates, security)
|
1. check your dependencies and package.json (unused, missing, updates, security)
|
||||||
1. transpile your code with tsc,
|
1. transpile your code with tsc,
|
||||||
1. test your code with tap (supports the fancy stuff like Promises, Generators, async/await, sourcemaps, parallel test execution in child processes)
|
1. test your code with tap (supports the fancy stuff like Promises, Generators, async/await, sourcemaps, parallel test execution in child processes)
|
||||||
@ -33,7 +33,9 @@ For more information on how tests are run check out the [tapbuffer module](https
|
|||||||
This works on your machine and in CI. There is a prebuild docker image available that includes npmts to make CI a breeze:
|
This works on your machine and in CI. There is a prebuild docker image available that includes npmts to make CI a breeze:
|
||||||
[hosttoday/ht-docker-node:npmts on Dockerhub](https://hub.docker.com/r/hosttoday/ht-docker-node/)
|
[hosttoday/ht-docker-node:npmts on Dockerhub](https://hub.docker.com/r/hosttoday/ht-docker-node/)
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
[](https://git.zone)
|
[](https://push.rocks)
|
||||||
|
@ -8,119 +8,119 @@ import * as plugins from './mod00.plugins'
|
|||||||
export let projectInfo: ProjectinfoNpm
|
export let projectInfo: ProjectinfoNpm
|
||||||
|
|
||||||
let checkProjectTypings = (configArg) => {
|
let checkProjectTypings = (configArg) => {
|
||||||
let done = q.defer()
|
let done = q.defer()
|
||||||
plugins.beautylog.ora.text('Check Module: Check Project Typings...')
|
plugins.beautylog.ora.text('Check Module: Check Project Typings...')
|
||||||
projectInfo = new ProjectinfoNpm(paths.cwd)
|
projectInfo = new ProjectinfoNpm(paths.cwd)
|
||||||
if (typeof projectInfo.packageJson.typings === 'undefined') {
|
if (typeof projectInfo.packageJson.typings === 'undefined') {
|
||||||
plugins.beautylog.error(`please add typings field to package.json`)
|
plugins.beautylog.error(`please add typings field to package.json`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
};
|
};
|
||||||
done.resolve(configArg)
|
done.resolve(configArg)
|
||||||
return done.promise
|
return done.promise
|
||||||
}
|
}
|
||||||
|
|
||||||
const depcheckOptions = {
|
const depcheckOptions = {
|
||||||
ignoreBinPackage: false, // ignore the packages with bin entry
|
ignoreBinPackage: false, // ignore the packages with bin entry
|
||||||
parsers: { // the target parsers
|
parsers: { // the target parsers
|
||||||
'*.ts': plugins.depcheck.parser.typescript
|
'*.ts': plugins.depcheck.parser.typescript
|
||||||
},
|
},
|
||||||
detectors: [ // the target detectors
|
detectors: [ // the target detectors
|
||||||
plugins.depcheck.detector.requireCallExpression,
|
plugins.depcheck.detector.requireCallExpression,
|
||||||
plugins.depcheck.detector.importDeclaration
|
plugins.depcheck.detector.importDeclaration
|
||||||
],
|
],
|
||||||
specials: [ // the target special parsers
|
specials: [ // the target special parsers
|
||||||
plugins.depcheck.special.eslint,
|
plugins.depcheck.special.eslint,
|
||||||
plugins.depcheck.special.webpack
|
plugins.depcheck.special.webpack
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
let checkDependencies = (configArg) => {
|
let checkDependencies = (configArg) => {
|
||||||
let done = q.defer()
|
let done = q.defer()
|
||||||
plugins.beautylog.ora.text('Check Module: Check Dependencies...')
|
plugins.beautylog.ora.text('Check Module: Check Dependencies...')
|
||||||
let depcheckOptionsMerged = plugins.lodash.merge(depcheckOptions, {
|
let depcheckOptionsMerged = plugins.lodash.merge(depcheckOptions, {
|
||||||
ignoreDirs: [ // folder with these names will be ignored
|
ignoreDirs: [ // folder with these names will be ignored
|
||||||
'test',
|
'test',
|
||||||
'dist',
|
'dist',
|
||||||
'bower_components'
|
'bower_components'
|
||||||
],
|
],
|
||||||
ignoreMatches: [ // ignore dependencies that matches these globs
|
ignoreMatches: [ // ignore dependencies that matches these globs
|
||||||
'@types/*',
|
'@types/*',
|
||||||
'babel-preset-*'
|
'babel-preset-*'
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
plugins.depcheck(paths.cwd, depcheckOptionsMerged, (unused) => {
|
plugins.depcheck(paths.cwd, depcheckOptionsMerged, (unused) => {
|
||||||
for (let item of unused.dependencies) {
|
for (let item of unused.dependencies) {
|
||||||
plugins.beautylog.warn(`Watch out: unused dependency "${item}"`)
|
plugins.beautylog.warn(`Watch out: unused dependency "${item}"`)
|
||||||
}
|
}
|
||||||
for (let item in unused.missing) {
|
for (let item in unused.missing) {
|
||||||
plugins.beautylog.error(`missing dependency "${item}" in package.json`)
|
plugins.beautylog.error(`missing dependency "${item}" in package.json`)
|
||||||
}
|
}
|
||||||
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 in unused.invalidFiles) {
|
for (let item in unused.invalidFiles) {
|
||||||
plugins.beautylog.warn(`Watch out: could not parse file ${item}`)
|
plugins.beautylog.warn(`Watch out: could not parse file ${item}`)
|
||||||
};
|
};
|
||||||
for (let item in unused.invalidDirs) {
|
for (let item in unused.invalidDirs) {
|
||||||
plugins.beautylog.warn(`Watch out: could not parse directory ${item}`)
|
plugins.beautylog.warn(`Watch out: could not parse directory ${item}`)
|
||||||
}
|
}
|
||||||
done.resolve(configArg)
|
done.resolve(configArg)
|
||||||
})
|
})
|
||||||
return done.promise
|
return done.promise
|
||||||
}
|
}
|
||||||
|
|
||||||
let checkDevDependencies = (configArg) => {
|
let checkDevDependencies = (configArg) => {
|
||||||
let done = q.defer()
|
let done = q.defer()
|
||||||
plugins.beautylog.ora.text('Check Module: Check devDependencies...')
|
plugins.beautylog.ora.text('Check Module: Check devDependencies...')
|
||||||
let depcheckOptionsMerged = plugins.lodash.merge(depcheckOptions, {
|
let depcheckOptionsMerged = plugins.lodash.merge(depcheckOptions, {
|
||||||
ignoreDirs: [ // folder with these names will be ignored
|
ignoreDirs: [ // folder with these names will be ignored
|
||||||
'ts',
|
'ts',
|
||||||
'dist',
|
'dist',
|
||||||
'bower_components'
|
'bower_components'
|
||||||
],
|
],
|
||||||
ignoreMatches: [ // ignore dependencies that matches these globs
|
ignoreMatches: [ // ignore dependencies that matches these globs
|
||||||
'@types/*',
|
'@types/*',
|
||||||
'babel-preset-*'
|
'babel-preset-*'
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
plugins.depcheck(paths.cwd, depcheckOptionsMerged, (unused) => {
|
plugins.depcheck(paths.cwd, depcheckOptionsMerged, (unused) => {
|
||||||
for (let item of unused.devDependencies) {
|
for (let item of unused.devDependencies) {
|
||||||
plugins.beautylog.log(`unused devDependency ${item}`)
|
plugins.beautylog.log(`unused devDependency ${item}`)
|
||||||
}
|
}
|
||||||
for (let item in unused.missing) {
|
for (let item in unused.missing) {
|
||||||
plugins.beautylog.error(`unused devDependency ${item}`)
|
plugins.beautylog.error(`missing devDependency ${item}`)
|
||||||
}
|
}
|
||||||
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 in unused.invalidFiles) {
|
for (let item in unused.invalidFiles) {
|
||||||
plugins.beautylog.warn(`Watch out: could not parse file ${item}`)
|
plugins.beautylog.warn(`Watch out: could not parse file ${item}`)
|
||||||
}
|
}
|
||||||
for (let item in unused.invalidDirs) {
|
for (let item in unused.invalidDirs) {
|
||||||
plugins.beautylog.warn(`Watch out: could not parse directory ${item}`)
|
plugins.beautylog.warn(`Watch out: could not parse directory ${item}`)
|
||||||
}
|
}
|
||||||
done.resolve(configArg)
|
done.resolve(configArg)
|
||||||
})
|
})
|
||||||
return done.promise
|
return done.promise
|
||||||
}
|
}
|
||||||
|
|
||||||
let checkNodeVersion = (configArg) => {
|
let checkNodeVersion = (configArg) => {
|
||||||
let done = q.defer()
|
let done = q.defer()
|
||||||
plugins.beautylog.ora.text('checking node version')
|
plugins.beautylog.ora.text('checking node version')
|
||||||
done.resolve(configArg)
|
done.resolve(configArg)
|
||||||
return done.promise
|
return done.promise
|
||||||
}
|
}
|
||||||
|
|
||||||
export let run = (configArg) => {
|
export let run = (configArg) => {
|
||||||
let done = q.defer()
|
let done = q.defer()
|
||||||
plugins.beautylog.ora.text('Check Module: ...')
|
plugins.beautylog.ora.text('Check Module: ...')
|
||||||
checkProjectTypings(configArg)
|
checkProjectTypings(configArg)
|
||||||
.then(checkDependencies)
|
.then(checkDependencies)
|
||||||
.then(checkDevDependencies)
|
.then(checkDevDependencies)
|
||||||
.then(checkNodeVersion)
|
.then(checkNodeVersion)
|
||||||
.then(done.resolve)
|
.then(done.resolve)
|
||||||
.catch((err) => { console.log(err) })
|
.catch((err) => { console.log(err) })
|
||||||
return done.promise
|
return done.promise
|
||||||
}
|
}
|
||||||
|
@ -77,10 +77,16 @@ let tap = function (configArg: INpmtsConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let handleCoverageData = async (configArg: INpmtsConfig) => {
|
let handleCoverageData = async (configArg: INpmtsConfig) => {
|
||||||
let coverageResult = await plugins.smartcov.get.percentageFromLcovString(
|
let coverageResult: number = 0 // the coverage in percent
|
||||||
configArg.runData.coverageLcovInfo,
|
if (configArg.runData.coverageLcovInfo) {
|
||||||
2
|
coverageResult = await plugins.smartcov.get.percentageFromLcovString(
|
||||||
)
|
configArg.runData.coverageLcovInfo,
|
||||||
|
2
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.warn('Hey... Did your tests import and use your module that you are trying to test?')
|
||||||
|
}
|
||||||
|
|
||||||
if (coverageResult >= configArg.coverageTreshold) {
|
if (coverageResult >= configArg.coverageTreshold) {
|
||||||
plugins.beautylog.ok(
|
plugins.beautylog.ok(
|
||||||
`${(coverageResult).toString()}% `
|
`${(coverageResult).toString()}% `
|
||||||
|
Reference in New Issue
Block a user