now modularized, implements #11

This commit is contained in:
2016-10-21 17:48:52 +02:00
parent 4f93ef3fb2
commit 8e4a4e5766
56 changed files with 453 additions and 261 deletions

27
ts/mod00/index.ts Normal file
View File

@ -0,0 +1,27 @@
/* ------------------------------------------
* This module compiles TypeScript files
* -------------------------------------------- */
import * as q from 'q'
import { npmtsOra } from '../npmts.log'
import { INpmtsConfig } from '../npmts.config'
import * as plugins from './mod00.plugins'
import * as NpmtsAssets from './mod00.assets'
import * as NpmtsCheck from './mod00.check'
import * as NpmtsClean from './mod00.clean'
import * as NpmtsCompile from './mod00.compile'
export let run = function(configArg: INpmtsConfig): q.Promise<INpmtsConfig> {
let done = q.defer<INpmtsConfig>()
npmtsOra.text('starting TypeScript Compilation')
NpmtsClean.run(configArg)
.then(NpmtsCheck.run)
.then(NpmtsCompile.run)
.then(NpmtsAssets.run)
.then(function(){
done.resolve(configArg)
})
return done.promise
}

View File

@ -1,10 +1,10 @@
import plugins = require('./npmts.plugins')
import paths = require('./npmts.paths')
import * as q from 'q'
import { npmtsOra } from './npmts.promisechain'
import { projectInfo } from './npmts.check'
import paths = require('../npmts.paths')
import { npmtsOra } from '../npmts.log'
import plugins = require('./mod00.plugins')
import { projectInfo } from '../mod00/mod00.check'
export var run = function(configArg){
let done = q.defer()

View File

@ -1,10 +1,10 @@
import * as plugins from './npmts.plugins'
import * as paths from './npmts.paths'
import * as q from 'q'
import { ProjectinfoNpm } from 'projectinfo'
import { npmtsOra } from './npmts.promisechain'
import {ProjectinfoNpm} from 'projectinfo'
import * as paths from '../npmts.paths'
import { npmtsOra } from '../npmts.log'
import * as plugins from './mod00.plugins'
export let projectInfo: ProjectinfoNpm

View File

@ -1,9 +1,9 @@
import plugins = require('./npmts.plugins')
import paths = require('./npmts.paths')
import * as q from 'q'
import paths = require('../npmts.paths')
import { npmtsOra } from './npmts.promisechain'
import { npmtsOra } from '../npmts.log'
import plugins = require('./mod00.plugins')
/**
* removes the dist directory which will be entirely rebuild

View File

@ -1,9 +1,9 @@
import plugins = require('./npmts.plugins')
import paths = require('./npmts.paths')
import * as q from 'q'
import {npmtsOra} from './npmts.promisechain'
import * as paths from '../npmts.paths'
import { npmtsOra } from '../npmts.log'
import * as plugins from './mod00.plugins'
export let run = function (configArg) {
let done = q.defer()

13
ts/mod00/mod00.plugins.ts Normal file
View File

@ -0,0 +1,13 @@
export * from '../npmts.plugins'
import * as tsn from 'tsn'
import * as shelljs from 'shelljs'
import * as smartchok from 'smartchok'
import * as smartstream from 'smartstream'
export {
tsn,
shelljs,
smartchok,
smartstream
}

View File

@ -1,12 +1,18 @@
import plugins = require('./npmts.plugins')
import paths = require('./npmts.paths')
import { npmtsOra } from './npmts.promisechain'
/* ------------------------------------------
* This module creates TypeScript documentation
* -------------------------------------------- */
import * as q from 'q'
import { projectInfo } from './npmts.check'
import * as paths from '../npmts.paths'
import { npmtsOra } from '../npmts.log'
import { INpmtsConfig } from '../npmts.config'
let genTypeDoc = function (configArg) {
import * as plugins from './mod01.plugins'
import { projectInfo } from '../mod00/mod00.check'
let genTypeDoc = function (configArg: INpmtsConfig) {
let done = q.defer()
npmtsOra.text('now generating ' + 'TypeDoc documentation'.yellow)
plugins.beautylog.log('TypeDoc Output:')
@ -31,9 +37,11 @@ let genTypeDoc = function (configArg) {
])
localSmartstream.run().then(
() => {
plugins.beautylog.ok('TypeDoc documentation generated!')
done.resolve(configArg)
},
(err) => {
plugins.beautylog.warn('TypeDoc documentation generation failed!')
console.log(err)
done.resolve(configArg)
}
@ -41,8 +49,8 @@ let genTypeDoc = function (configArg) {
return done.promise
}
export let run = function (configArg) {
let done = q.defer()
export let run = function (configArg: INpmtsConfig) {
let done = q.defer<INpmtsConfig>()
if (configArg.docs) {
genTypeDoc(configArg)
.then(() => {

View File

@ -0,0 +1,9 @@
export * from '../npmts.plugins'
import * as gulp from 'gulp'
let gulpTypedoc = require('gulp-typedoc')
export {
gulp,
gulpTypedoc
}

View File

@ -1,10 +1,13 @@
import plugins = require('./npmts.plugins')
import paths = require('./npmts.paths')
/* ------------------------------------------
* This module tests the compiled TypeScript files
* -------------------------------------------- */
import plugins = require('./mod02.plugins')
import paths = require('../npmts.paths')
import * as q from 'q'
import { npmtsOra } from './npmts.promisechain'
import { INpmtsConfig } from './npmts.options'
import { npmtsOra } from '../npmts.log'
import { INpmtsConfig } from '../npmts.config'
/**
* runs mocha
@ -43,6 +46,7 @@ let mocha = function (configArg: INpmtsConfig) {
localSmartstream.run()
.then(() => { done.resolve(configArg) }, (err) => {
plugins.beautylog.error('Tests failed!')
console.log(err)
if (configArg.watch) {
done.resolve(configArg)
} else {
@ -78,7 +82,7 @@ let coverage = function (configArg: INpmtsConfig) {
}
export let run = function (configArg: INpmtsConfig) {
let done = q.defer()
let done = q.defer<INpmtsConfig>()
let config = configArg
if (config.test === true) {
npmtsOra.text('now starting tests')

19
ts/mod02/mod02.plugins.ts Normal file
View File

@ -0,0 +1,19 @@
export * from '../npmts.plugins'
import * as gulp from 'gulp'
import * as gulpBabel from 'gulp-babel'
import * as gulpIstanbul from 'gulp-istanbul'
import * as gulpFunction from 'gulp-function'
let gulpInjectModules = require('gulp-inject-modules')
import * as gulpMocha from 'gulp-mocha'
import * as gulpSourcemaps from 'gulp-sourcemaps'
export {
gulp,
gulpBabel,
gulpIstanbul,
gulpFunction,
gulpInjectModules,
gulpMocha,
gulpSourcemaps
}

View File

@ -1,7 +1,13 @@
import * as q from 'q'
import * as plugins from './npmts.plugins'
import * as paths from './npmts.paths'
import * as promisechain from './npmts.promisechain'
import * as q from 'q'
import * as NpmtsConfig from './npmts.config'
import * as NpmtsMods from './npmts.mods'
import * as NpmtsWatch from './npmts.watch'
import * as NpmtsShip from './npmts.ship'
import { npmtsOra } from './npmts.log'
export let run = () => {
let done = q.defer()
@ -11,8 +17,43 @@ export let run = () => {
.then((argvArg) => {
plugins.beautylog.figletSync('NPMTS')
plugins.beautylog.info('npmts version: ' + npmtsProjectInfo.version)
promisechain.run(argvArg).catch((err) => { console.log(err) })
return NpmtsConfig.run(argvArg)
})
.then((configArg: NpmtsConfig.INpmtsConfig) => {
let done = q.defer()
npmtsOra.start('loading additional modules...')
NpmtsMods.mod00.load()
.then((mod00) => {
return mod00.run(configArg)
})
.then(configArg => {
let done = q.defer<NpmtsConfig.INpmtsConfig>()
NpmtsMods.mod01.load()
.then(mod01 => {
return mod01.run(configArg)
})
.then(configArg => {
done.resolve(configArg)
})
return done.promise
})
.then(configArg => {
let done = q.defer<NpmtsConfig.INpmtsConfig>()
NpmtsMods.mod02.load()
.then(mod02 => {
return mod02.run(configArg)
})
.then(configArg => {
done.resolve(configArg)
})
return done.promise
})
.then(NpmtsWatch.run)
.then(NpmtsShip.run)
return done.promise
})
.catch((err) => { console.log(err) })
npmtsCli.addVersion(npmtsProjectInfo.version)
npmtsCli.startParse()
return done.promise

View File

@ -3,7 +3,7 @@ import paths = require('./npmts.paths')
import * as q from 'q'
import { npmtsOra } from './npmts.promisechain'
import { npmtsOra } from './npmts.log'
export type npmtsMode = 'default' | 'custom'

2
ts/npmts.log.ts Normal file
View File

@ -0,0 +1,2 @@
import {Ora} from 'beautylog'
export let npmtsOra = new Ora('setting up TaskChain','cyan')

11
ts/npmts.mods.ts Normal file
View File

@ -0,0 +1,11 @@
import * as plugins from './npmts.plugins'
import { LazyModule } from 'smartsystem'
import * as _mod00 from './mod00/index'
import * as _mod01 from './mod01/index'
import * as _mod02 from './mod02/index'
export let mod00 = new LazyModule<typeof _mod00>('./mod00/index',__dirname)
export let mod01 = new LazyModule<typeof _mod01>('./mod01/index',__dirname)
export let mod02 = new LazyModule<typeof _mod02>('./mod02/index',__dirname)

View File

@ -1,22 +1,11 @@
import 'typings-global'
import * as beautylog from 'beautylog'
let depcheck = require('depcheck')
import * as gulp from 'gulp'
import * as gulpBabel from 'gulp-babel'
import * as gulpIstanbul from 'gulp-istanbul'
import * as gulpFunction from 'gulp-function'
let gulpInjectModules = require('gulp-inject-modules')
import * as gulpMocha from 'gulp-mocha'
import * as gulpSourcemaps from 'gulp-sourcemaps'
let gulpTypedoc = require('gulp-typedoc')
import * as lodash from 'lodash'
import * as npmextra from 'npmextra'
import * as projectinfo from 'projectinfo'
import * as path from 'path'
import * as shelljs from 'shelljs'
import * as smartchok from 'smartchok'
import * as smartcli from 'smartcli'
import * as smartcov from 'smartcov'
import * as smartenv from 'smartenv'
@ -24,26 +13,16 @@ import * as smartfile from 'smartfile'
import * as smartpath from 'smartpath'
import * as smartstream from 'smartstream'
import * as smartstring from 'smartstring'
import * as smartsystem from 'smartsystem'
export let sourceMapSupport = require('source-map-support').install() // display errors correctly during testing
import * as tsn from 'tsn'
export {
beautylog,
depcheck,
gulp,
gulpBabel,
gulpFunction,
gulpInjectModules,
gulpIstanbul,
gulpMocha,
gulpSourcemaps,
gulpTypedoc,
lodash,
npmextra,
projectinfo,
path,
shelljs,
smartchok,
smartcli,
smartcov,
smartenv,
@ -51,5 +30,5 @@ export {
smartpath,
smartstream,
smartstring,
tsn
smartsystem
}

View File

@ -1,52 +0,0 @@
import plugins = require('./npmts.plugins')
import {Ora} from 'beautylog'
import * as q from 'q'
export let npmtsOra = new Ora('setting up TaskChain','cyan')
import * as NpmtsAssets from './npmts.assets'
import * as NpmtsCheck from './npmts.check'
import * as NpmtsClean from './npmts.clean'
import * as NpmtsCompile from './npmts.compile'
import * as NpmtsTypeDoc from './npmts.typedoc'
import * as NpmtsOptions from './npmts.options'
import * as NpmtsTests from './npmts.tests'
import * as NpmtsWatch from './npmts.watch'
export let run = function(argvArg){
let done = q.defer()
npmtsOra.start()
NpmtsOptions.run(argvArg)
.then(NpmtsClean.run)
.then(NpmtsCheck.run)
.then(NpmtsCompile.run)
.then(NpmtsAssets.run)
.then(NpmtsTypeDoc.run)
.then(NpmtsTests.run)
.then(NpmtsWatch.run)
.then(function(configArg){
let shipString = '' +
'\n' +
'\n' +
' # # ( )\n' +
' ___#_#___|__\n' +
' _ |____________| _\n' +
' _=====| | | | | |==== _\n' +
' =====| |.---------------------------. | |====\n' +
" <--------------------' . . . . . . . . '--------------/\n" +
' \\ /\n' +
' \\___________________________________________________________/\n' +
' wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n' +
' wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n' +
' wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n'
if (process.env.CI) {
console.log(shipString)
plugins.beautylog.success('READY TO SHIP!')
} else {
plugins.beautylog.success('Done!')
}
done.resolve(configArg)
})
return done.promise
}

30
ts/npmts.ship.ts Normal file
View File

@ -0,0 +1,30 @@
import * as q from 'q'
import * as plugins from './npmts.plugins'
import { INpmtsConfig } from './npmts.config'
export let run = (configArg: INpmtsConfig) => {
let done = q.defer()
let shipString = '' +
'\n' +
'\n' +
' # # ( )\n' +
' ___#_#___|__\n' +
' _ |____________| _\n' +
' _=====| | | | | |==== _\n' +
' =====| |.---------------------------. | |====\n' +
" <--------------------' . . . . . . . . '--------------/\n" +
' \\ /\n' +
' \\___________________________________________________________/\n' +
' wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n' +
' wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n' +
' wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n'
if (process.env.CI) {
console.log(shipString)
plugins.beautylog.success('READY TO SHIP!')
} else {
plugins.beautylog.success('Done!')
}
done.resolve(configArg)
}

View File

@ -1,11 +1,12 @@
import * as plugins from './npmts.plugins'
import * as promisechain from './npmts.promisechain'
import * as q from 'q'
import * as smartchok from 'smartchok'
import { INpmtsConfig } from './npmts.options'
import * as plugins from './npmts.plugins'
import * as cli from './npmts.cli'
let npmtsSmartchok: plugins.smartchok.Smartchok = null
import { INpmtsConfig } from './npmts.config'
let npmtsSmartchok: smartchok.Smartchok = null
export let run = (configArg: INpmtsConfig) => {
let done = q.defer()
if (configArg.watch && npmtsSmartchok === null) {
@ -16,16 +17,17 @@ export let run = (configArg: INpmtsConfig) => {
for (let key in configArg.testTs) {
pathsToWatch.push(key)
}
npmtsSmartchok = new plugins.smartchok.Smartchok(pathsToWatch)
npmtsSmartchok = new smartchok.Smartchok(pathsToWatch)
npmtsSmartchok.getObservableFor('change').then((changeObservableArg) => {
plugins.beautylog.info('now watching...')
changeObservableArg.subscribe(() => {
promisechain.run(configArg)
cli.run()
})
})
npmtsSmartchok.start()
done.resolve(configArg)
} else {
plugins.beautylog.info('not watching')
done.resolve(configArg)
}
return done.promise