Switch to tap
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
/* ------------------------------------------
|
||||
* This module compiles TypeScript files
|
||||
* This module compiles the module's TypeScript files
|
||||
* Note: Test files are only compiled in memory
|
||||
* -------------------------------------------- */
|
||||
import * as q from 'smartq'
|
||||
|
||||
|
@ -5,18 +5,13 @@ import * as paths from '../npmts.paths'
|
||||
import * as plugins from './mod00.plugins'
|
||||
|
||||
export let run = function (configArg) {
|
||||
let done = q.defer()
|
||||
let config = configArg
|
||||
plugins.beautylog.ora.text('now compiling ' + 'TypeScript'.yellow)
|
||||
plugins.tsn.compileGlobStringObject(config.ts,config.tsOptions,paths.cwd)
|
||||
.then(() => {
|
||||
plugins.beautylog.ok('compiled main TypeScript!')
|
||||
plugins.beautylog.log('now compiling tests!')
|
||||
return plugins.tsn.compileGlobStringObject(config.testTs,config.tsOptions,paths.cwd)
|
||||
})
|
||||
.then(function () {
|
||||
plugins.beautylog.ok('compiled all TypeScript!')
|
||||
done.resolve(config)
|
||||
}).catch(err => { console.log(err) })
|
||||
return done.promise
|
||||
let done = q.defer()
|
||||
let config = configArg
|
||||
plugins.beautylog.ora.text('now compiling ' + 'TypeScript'.yellow)
|
||||
plugins.tsn.compileGlobStringObject(config.ts, config.tsOptions, paths.cwd)
|
||||
.then(() => {
|
||||
plugins.beautylog.ok(`compiled the module's TypeScript!`)
|
||||
done.resolve(config)
|
||||
}).catch(err => { console.log(err) })
|
||||
return done.promise
|
||||
}
|
||||
|
@ -12,116 +12,107 @@ import { INpmtsConfig } from '../npmts.config'
|
||||
* runs mocha
|
||||
* @returns INpmtsConfig
|
||||
*/
|
||||
let mocha = function (configArg: INpmtsConfig) {
|
||||
plugins.beautylog.ora.text('Instrumentalizing and testing transpiled JS')
|
||||
plugins.beautylog.ora.end() // end plugins.beautylog.ora for tests.
|
||||
let done = q.defer()
|
||||
let tap = function (configArg: INpmtsConfig) {
|
||||
let done = q.defer()
|
||||
|
||||
let coverageSmartstream = new plugins.smartstream.Smartstream([
|
||||
plugins.gulp.src([plugins.path.join(paths.cwd, './ts/**/*.ts')]),
|
||||
plugins.gulpSourcemaps.init(),
|
||||
plugins.gulpTypeScript({
|
||||
target: 'ES5',
|
||||
emitDecoratorMetadata: true,
|
||||
experimentalDecorators: true,
|
||||
lib: ['DOM', 'ES5', 'ES2015.Promise', 'ES2015.Generator', 'ES2015.Iterable']
|
||||
}),
|
||||
plugins.gulpIstanbul({
|
||||
}),
|
||||
plugins.gulpSourcemaps.write(),
|
||||
plugins.gulpFunction.forEach(async file => {
|
||||
file.path = file.path.replace(paths.tsDir, paths.distDir)
|
||||
}),
|
||||
plugins.gulpInjectModules(),
|
||||
plugins.through2.obj(
|
||||
(file, enc, cb) => {
|
||||
cb()
|
||||
},
|
||||
(cb) => {
|
||||
cb()
|
||||
}
|
||||
)
|
||||
])
|
||||
/**
|
||||
* the TabBuffer for npmts
|
||||
*/
|
||||
let npmtsTapBuffer = new plugins.tapbuffer.TabBuffer()
|
||||
|
||||
let localSmartstream = new plugins.smartstream.Smartstream([
|
||||
plugins.gulp.src([plugins.path.join(paths.cwd, 'test/test.ts')]),
|
||||
plugins.gulpTypeScript({
|
||||
target: 'ES5',
|
||||
emitDecoratorMetadata: true,
|
||||
experimentalDecorators: true,
|
||||
lib: ['DOM', 'ES5', 'ES2015.Promise', 'ES2015.Generator', 'ES2015.Iterable']
|
||||
}),
|
||||
plugins.gulpInjectModules(),
|
||||
plugins.gulpMocha(),
|
||||
plugins.gulpIstanbul.writeReports({
|
||||
dir: plugins.path.join(paths.cwd, './coverage'),
|
||||
reporters: ['lcovonly', 'json', 'text', 'text-summary']
|
||||
})
|
||||
])
|
||||
coverageSmartstream.run()
|
||||
.then(
|
||||
() => {
|
||||
plugins.beautylog.info('code is now transpiled to ES5, instrumented with istanbul, and injected for mocha!')
|
||||
return localSmartstream.run()
|
||||
.then(() => { done.resolve(configArg) }, (err) => {
|
||||
plugins.beautylog.error('Tests failed!')
|
||||
console.log(err)
|
||||
if (configArg.watch) {
|
||||
done.resolve(configArg)
|
||||
} else {
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
},
|
||||
(err) => {
|
||||
console.log(err)
|
||||
})
|
||||
return done.promise
|
||||
/**
|
||||
* handle the testable files
|
||||
*/
|
||||
let testableFilesSmartstream = new plugins.smartstream.Smartstream([
|
||||
plugins.gulp.src([ plugins.path.join(paths.cwd, './ts/**/*.ts') ]),
|
||||
plugins.gulpSourcemaps.init(),
|
||||
plugins.gulpTypeScript({
|
||||
target: 'ES5',
|
||||
emitDecoratorMetadata: true,
|
||||
experimentalDecorators: true,
|
||||
lib: [ 'DOM', 'ES5', 'ES2015.Promise', 'ES2015.Generator', 'ES2015.Iterable' ]
|
||||
}),
|
||||
plugins.gulpSourcemaps.write(),
|
||||
plugins.gulpFunction.forEach(async file => {
|
||||
file.path = file.path.replace(paths.tsDir, paths.distDir)
|
||||
}),
|
||||
npmtsTapBuffer.pipeTestableFiles(),
|
||||
plugins.smartstream.cleanPipe()
|
||||
])
|
||||
|
||||
/**
|
||||
* handle the test files
|
||||
*/
|
||||
let testFilesSmartstream = new plugins.smartstream.Smartstream([
|
||||
plugins.gulp.src([ plugins.path.join(paths.cwd, 'test/test.ts') ]),
|
||||
plugins.gulpTypeScript({
|
||||
target: 'ES5',
|
||||
emitDecoratorMetadata: true,
|
||||
experimentalDecorators: true,
|
||||
lib: [ 'DOM', 'ES5', 'ES2015.Promise', 'ES2015.Generator', 'ES2015.Iterable' ]
|
||||
}),
|
||||
npmtsTapBuffer.pipeTestFiles(),
|
||||
plugins.smartstream.cleanPipe()
|
||||
])
|
||||
|
||||
// lets run the smartstream
|
||||
Promise.all([
|
||||
testableFilesSmartstream.run(),
|
||||
testFilesSmartstream.run()
|
||||
]).then(
|
||||
async () => {
|
||||
await npmtsTapBuffer.runTests()
|
||||
done.resolve(configArg)
|
||||
}, (err) => {
|
||||
plugins.beautylog.error('Tests failed!')
|
||||
console.log(err)
|
||||
if (configArg.watch) {
|
||||
done.resolve(configArg)
|
||||
} else {
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
|
||||
return done.promise
|
||||
}
|
||||
|
||||
let coverage = function (configArg: INpmtsConfig) {
|
||||
let done = q.defer()
|
||||
plugins.smartcov.get.percentage(plugins.path.join(paths.coverageDir, 'lcov.info'), 2)
|
||||
.then(function (percentageArg) {
|
||||
if (percentageArg >= configArg.coverageTreshold) {
|
||||
plugins.beautylog.ok(
|
||||
`${percentageArg.toString()}% `
|
||||
+ `coverage exceeds your treshold of `
|
||||
+ `${configArg.coverageTreshold.toString()}%`
|
||||
)
|
||||
} else {
|
||||
plugins.beautylog.warn(
|
||||
`${percentageArg.toString()}% `
|
||||
+ `coverage fails your treshold of `
|
||||
+ `${configArg.coverageTreshold.toString()}%`
|
||||
)
|
||||
plugins.beautylog.error('exiting due to coverage failure')
|
||||
if (!configArg.watch) { process.exit(1) }
|
||||
}
|
||||
done.resolve(configArg)
|
||||
})
|
||||
return done.promise
|
||||
let handleCoverageData = function (configArg: INpmtsConfig) {
|
||||
let done = q.defer()
|
||||
if (71 >= configArg.coverageTreshold) {
|
||||
plugins.beautylog.ok(
|
||||
`${(71).toString()}% `
|
||||
+ `coverage exceeds your treshold of `
|
||||
+ `${configArg.coverageTreshold.toString()}%`
|
||||
)
|
||||
} else {
|
||||
plugins.beautylog.warn(
|
||||
`${(71).toString()}% `
|
||||
+ `coverage fails your treshold of `
|
||||
+ `${configArg.coverageTreshold.toString()}%`
|
||||
)
|
||||
plugins.beautylog.error('exiting due to coverage failure')
|
||||
if (!configArg.watch) { process.exit(1) }
|
||||
}
|
||||
done.resolve(configArg)
|
||||
return done.promise
|
||||
}
|
||||
|
||||
export let run = function (configArg: INpmtsConfig) {
|
||||
let done = q.defer<INpmtsConfig>()
|
||||
let config = configArg
|
||||
if (config.test === true) {
|
||||
plugins.beautylog.ora.text('now starting tests')
|
||||
plugins.beautylog.log(
|
||||
'------------------------------------------------------\n' +
|
||||
'*************************** TESTS: ***************************\n' +
|
||||
'--------------------------------------------------------------'
|
||||
)
|
||||
let done = q.defer<INpmtsConfig>()
|
||||
let config = configArg
|
||||
if (config.test === true) {
|
||||
plugins.beautylog.ora.text('now starting tests')
|
||||
plugins.beautylog.ora.end()
|
||||
plugins.beautylog.log('ready for tapbuffer:')
|
||||
|
||||
mocha(config)
|
||||
.then(coverage)
|
||||
.then(() => {
|
||||
done.resolve(config)
|
||||
}).catch(err => { console.log(err) })
|
||||
} else {
|
||||
plugins.beautylog.ora.end()
|
||||
tap(config)
|
||||
.then(handleCoverageData)
|
||||
.then(() => {
|
||||
done.resolve(config)
|
||||
}
|
||||
return done.promise
|
||||
}).catch(err => { console.log(err) })
|
||||
} else {
|
||||
plugins.beautylog.ora.end()
|
||||
done.resolve(config)
|
||||
}
|
||||
return done.promise
|
||||
}
|
||||
|
@ -2,18 +2,14 @@ export * from '../npmts.plugins'
|
||||
|
||||
import * as gulp from 'gulp'
|
||||
import * as gulpFunction from 'gulp-function'
|
||||
import * as gulpIstanbul from 'gulp-istanbul'
|
||||
let gulpInjectModules = require('gulp-inject-modules')
|
||||
import * as gulpMocha from 'gulp-mocha'
|
||||
import * as gulpSourcemaps from 'gulp-sourcemaps'
|
||||
import * as gulpTypeScript from 'gulp-typescript'
|
||||
import * as tapbuffer from 'tapbuffer'
|
||||
|
||||
export {
|
||||
gulp,
|
||||
gulpFunction,
|
||||
gulpIstanbul,
|
||||
gulpInjectModules,
|
||||
gulpMocha,
|
||||
gulpSourcemaps,
|
||||
gulpTypeScript
|
||||
gulpTypeScript,
|
||||
tapbuffer
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import * as npmextra from 'npmextra'
|
||||
import * as projectinfo from 'projectinfo'
|
||||
import * as path from 'path'
|
||||
import * as smartcli from 'smartcli'
|
||||
import * as smartcov from 'smartcov'
|
||||
import * as smartenv from 'smartenv'
|
||||
import * as smartfile from 'smartfile'
|
||||
import * as smartpath from 'smartpath'
|
||||
@ -25,7 +24,6 @@ export {
|
||||
projectinfo,
|
||||
path,
|
||||
smartcli,
|
||||
smartcov,
|
||||
smartenv,
|
||||
smartfile,
|
||||
smartpath,
|
||||
|
Reference in New Issue
Block a user