fix(core): update
This commit is contained in:
14
ts/index.ts
14
ts/index.ts
@ -1,13 +1 @@
|
||||
/* ================================================== *
|
||||
**** NPMTS ****
|
||||
Fabulous TypeScript development
|
||||
* ================================================== */
|
||||
|
||||
import * as early from 'early';
|
||||
early.start('NPMTS');
|
||||
import * as plugins from './npmts.plugins';
|
||||
import * as cli from './npmts.cli';
|
||||
early.stop().then(() => {
|
||||
let loaded = plugins; // to make sure plugins get actually loaded
|
||||
cli.run();
|
||||
});
|
||||
console.log('tscoverage');
|
@ -1,27 +0,0 @@
|
||||
/* ------------------------------------------
|
||||
* This module compiles the module's TypeScript files
|
||||
* Note: Test files are only compiled in memory
|
||||
* -------------------------------------------- */
|
||||
import * as q from 'smartq';
|
||||
|
||||
import { INpmtsConfig } from '../npmts.config';
|
||||
|
||||
import * as plugins from './mod.plugins';
|
||||
|
||||
import * as NpmtsAssets from './mod.assets';
|
||||
import * as NpmtsCheck from './mod.check';
|
||||
import * as NpmtsClean from './mod.clean';
|
||||
import * as NpmtsCompile from './mod.compile';
|
||||
|
||||
export let run = function(configArg: INpmtsConfig): Promise<INpmtsConfig> {
|
||||
let done = q.defer<INpmtsConfig>();
|
||||
plugins.beautylog.ora.text('starting TypeScript Compilation');
|
||||
NpmtsClean.run(configArg)
|
||||
.then(NpmtsCheck.run)
|
||||
.then(NpmtsCompile.run)
|
||||
.then(NpmtsAssets.run)
|
||||
.then(function() {
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
@ -1,26 +0,0 @@
|
||||
import * as q from 'smartq';
|
||||
|
||||
import paths = require('../npmts.paths');
|
||||
|
||||
import plugins = require('./mod.plugins');
|
||||
import { projectInfo } from '../mod_compile/mod.check';
|
||||
|
||||
export let run = function(configArg) {
|
||||
let done = q.defer();
|
||||
let config = configArg;
|
||||
plugins.beautylog.ora.text('now looking at ' + 'required assets');
|
||||
if (config.cli === true) {
|
||||
let mainJsPath = projectInfo.packageJson.main;
|
||||
let cliJsString: string = plugins.smartfile.fs.toStringSync(
|
||||
plugins.path.join(paths.npmtsAssetsDir, 'cli.js')
|
||||
);
|
||||
cliJsString = cliJsString.replace('{{pathToIndex}}', mainJsPath);
|
||||
plugins.smartfile.memory.toFsSync(cliJsString, plugins.path.join(paths.distDir, 'cli.js'));
|
||||
plugins.beautylog.ok('installed CLI assets!');
|
||||
done.resolve(config);
|
||||
} else {
|
||||
plugins.beautylog.ok('No additional assets required!');
|
||||
done.resolve(config);
|
||||
}
|
||||
return done.promise;
|
||||
};
|
@ -1,139 +0,0 @@
|
||||
import * as q from 'smartq';
|
||||
import { ProjectinfoNpm } from 'projectinfo';
|
||||
|
||||
// interfaces
|
||||
import { INpmtsConfig } from '../npmts.config';
|
||||
|
||||
import * as paths from '../npmts.paths';
|
||||
|
||||
import * as plugins from './mod.plugins';
|
||||
|
||||
export let projectInfo: ProjectinfoNpm;
|
||||
|
||||
let checkProjectTypings = (configArg: INpmtsConfig) => {
|
||||
let done = q.defer<INpmtsConfig>();
|
||||
plugins.beautylog.ora.text('Check Module: Check Project Typings...');
|
||||
projectInfo = new ProjectinfoNpm(paths.cwd);
|
||||
if (typeof projectInfo.packageJson.typings === 'undefined') {
|
||||
plugins.beautylog.error(`please add typings field to package.json`);
|
||||
process.exit(1);
|
||||
}
|
||||
done.resolve(configArg);
|
||||
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: INpmtsConfig) => {
|
||||
let done = q.defer<INpmtsConfig>();
|
||||
plugins.beautylog.ora.text('Check Module: Check Dependencies...');
|
||||
let depcheckOptionsMerged = plugins.lodash.merge(depcheckOptions, {
|
||||
ignoreDirs: [
|
||||
// folder with these names will be ignored
|
||||
'test',
|
||||
'dist',
|
||||
'bower_components'
|
||||
],
|
||||
ignoreMatches: [
|
||||
// ignore dependencies that matches these globs
|
||||
'@types/*',
|
||||
'babel-preset-*'
|
||||
]
|
||||
});
|
||||
plugins.depcheck(paths.cwd, depcheckOptionsMerged, unused => {
|
||||
for (let item of unused.dependencies) {
|
||||
plugins.beautylog.warn(`Watch out: unused dependency "${item}"`);
|
||||
}
|
||||
for (let item in unused.missing) {
|
||||
plugins.beautylog.error(`missing dependency "${item}" in package.json`);
|
||||
}
|
||||
if (unused.missing.length > 0) {
|
||||
plugins.beautylog.info('exiting due to missing dependencies in package.json');
|
||||
process.exit(1);
|
||||
}
|
||||
for (let item in unused.invalidFiles) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse file ${item}`);
|
||||
}
|
||||
for (let item in unused.invalidDirs) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse directory ${item}`);
|
||||
}
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
let checkDevDependencies = (configArg: INpmtsConfig) => {
|
||||
let done = q.defer<INpmtsConfig>();
|
||||
plugins.beautylog.ora.text('Check Module: Check devDependencies...');
|
||||
let depcheckOptionsMerged = plugins.lodash.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}`);
|
||||
}
|
||||
for (let item in unused.missing) {
|
||||
plugins.beautylog.error(`missing devDependency ${item}`);
|
||||
}
|
||||
if (unused.missing.length > 0) {
|
||||
plugins.beautylog.info('exiting due to missing dependencies in package.json');
|
||||
process.exit(1);
|
||||
}
|
||||
for (let item in unused.invalidFiles) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse file ${item}`);
|
||||
}
|
||||
for (let item in unused.invalidDirs) {
|
||||
plugins.beautylog.warn(`Watch out: could not parse directory ${item}`);
|
||||
}
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
let checkNodeVersion = (configArg: INpmtsConfig) => {
|
||||
let done = q.defer<INpmtsConfig>();
|
||||
plugins.beautylog.ora.text('checking node version');
|
||||
done.resolve(configArg);
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
export let run = async (configArg: INpmtsConfig) => {
|
||||
plugins.beautylog.ora.text('Check Module: ...');
|
||||
|
||||
if (configArg.checkDependencies) {
|
||||
configArg = await checkProjectTypings(configArg);
|
||||
configArg = await checkDependencies(configArg);
|
||||
configArg = await checkDevDependencies(configArg);
|
||||
configArg = await checkNodeVersion(configArg);
|
||||
return configArg;
|
||||
} else {
|
||||
configArg = await checkProjectTypings(configArg);
|
||||
return configArg;
|
||||
}
|
||||
};
|
@ -1,32 +0,0 @@
|
||||
import * as q from 'smartq';
|
||||
import paths = require('../npmts.paths');
|
||||
|
||||
import plugins = require('./mod.plugins');
|
||||
|
||||
/**
|
||||
* removes the dist directory which will be entirely rebuild
|
||||
*/
|
||||
let removeDist = function() {
|
||||
plugins.beautylog.ora.text('cleaning dist folder');
|
||||
return plugins.smartfile.fs.remove(paths.distDir);
|
||||
};
|
||||
|
||||
/**
|
||||
* remove old pages
|
||||
*/
|
||||
let removePages = function() {
|
||||
plugins.beautylog.ora.text('cleaning pages folder');
|
||||
return plugins.smartfile.fs.remove(paths.pagesDir);
|
||||
};
|
||||
|
||||
export let run = function(configArg) {
|
||||
plugins.beautylog.ora.text('cleaning up from previous builds...');
|
||||
let done = q.defer();
|
||||
removeDist()
|
||||
.then(removePages)
|
||||
.then(function() {
|
||||
plugins.beautylog.ok('Cleaned up from previous builds!');
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
@ -1,21 +0,0 @@
|
||||
import * as q from 'smartq';
|
||||
|
||||
import * as paths from '../npmts.paths';
|
||||
|
||||
import * as plugins from './mod.plugins';
|
||||
|
||||
export let run = function(configArg) {
|
||||
let done = q.defer();
|
||||
let config = configArg;
|
||||
plugins.beautylog.ora.text('now compiling ' + 'TypeScript');
|
||||
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;
|
||||
};
|
@ -1,7 +0,0 @@
|
||||
export * from '../npmts.plugins';
|
||||
|
||||
import * as tsn from 'tsn';
|
||||
import * as smartchok from 'smartchok';
|
||||
import * as smartstream from 'smartstream';
|
||||
|
||||
export { tsn, smartchok, smartstream };
|
@ -1,15 +0,0 @@
|
||||
/* ------------------------------------------
|
||||
* This module creates TypeScript documentation
|
||||
* -------------------------------------------- */
|
||||
import * as q from 'smartq';
|
||||
|
||||
import * as paths from '../npmts.paths';
|
||||
import { INpmtsConfig } from '../npmts.config';
|
||||
|
||||
import * as plugins from './mod.plugins';
|
||||
|
||||
export let run = function(configArg: INpmtsConfig) {
|
||||
let done = q.defer<INpmtsConfig>();
|
||||
done.resolve(configArg);
|
||||
return done.promise;
|
||||
};
|
@ -1 +0,0 @@
|
||||
export * from '../npmts.plugins';
|
@ -1,145 +0,0 @@
|
||||
/* ------------------------------------------
|
||||
* This module tests the compiled TypeScript files
|
||||
* -------------------------------------------- */
|
||||
import plugins = require('./mod.plugins');
|
||||
import paths = require('../npmts.paths');
|
||||
|
||||
import * as q from 'smartq';
|
||||
|
||||
// interfaces
|
||||
import { INpmtsConfig } from '../npmts.config';
|
||||
import { Smartfile } from 'smartfile';
|
||||
|
||||
let testTypeScriptConfig = {
|
||||
target: 'ES5',
|
||||
emitDecoratorMetadata: true,
|
||||
experimentalDecorators: true,
|
||||
lib: ['DOM', 'ESNext']
|
||||
};
|
||||
|
||||
/**
|
||||
* runs mocha
|
||||
* @returns INpmtsConfig
|
||||
*/
|
||||
let tap = function(configArg: INpmtsConfig) {
|
||||
let done = q.defer();
|
||||
|
||||
/**
|
||||
* the TabBuffer for npmts
|
||||
*/
|
||||
let npmtsTapBuffer = new plugins.tapbuffer.TabBuffer();
|
||||
|
||||
npmtsTapBuffer.setConfig(configArg.testConfig);
|
||||
|
||||
/**
|
||||
* handle the testable files
|
||||
*/
|
||||
let testableFilesSmartstream = new plugins.smartstream.Smartstream([
|
||||
plugins.smartgulp.src([plugins.path.join(paths.cwd, './ts/**/*.ts')]),
|
||||
plugins.gulpSourcemaps.init(),
|
||||
plugins.gulpTypeScript(testTypeScriptConfig),
|
||||
plugins.gulpSourcemaps.write(),
|
||||
npmtsTapBuffer.pipeTestableFiles(),
|
||||
plugins.smartstream.cleanPipe()
|
||||
]);
|
||||
|
||||
/**
|
||||
* handle the test files
|
||||
*/
|
||||
let testFilesSmartstream = new plugins.smartstream.Smartstream([
|
||||
plugins.smartgulp.src([plugins.path.join(paths.cwd, 'test/*.ts')]),
|
||||
plugins.gulpSourcemaps.init(),
|
||||
plugins.gulpTypeScript(testTypeScriptConfig),
|
||||
plugins.gulpSourcemaps.write(),
|
||||
npmtsTapBuffer.pipeTestFiles(),
|
||||
plugins.smartstream.cleanPipe()
|
||||
]);
|
||||
|
||||
// lets run the smartstream
|
||||
Promise.all([testableFilesSmartstream.run(), testFilesSmartstream.run()]).then(
|
||||
async () => {
|
||||
configArg.runData.coverageLcovInfo = 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 handleCoverageData = async (configArg: INpmtsConfig) => {
|
||||
let coverageResult: number = 0; // the coverage in percent
|
||||
if (configArg.runData.coverageLcovInfo) {
|
||||
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) {
|
||||
plugins.beautylog.ok(
|
||||
`${coverageResult.toString()}% ` +
|
||||
`coverage exceeds your treshold of ` +
|
||||
`${configArg.coverageTreshold.toString()}%`
|
||||
);
|
||||
} else {
|
||||
plugins.beautylog.warn(
|
||||
`${coverageResult.toString()}% ` +
|
||||
`coverage fails your treshold of ` +
|
||||
`${configArg.coverageTreshold.toString()}%`
|
||||
);
|
||||
plugins.beautylog.error('exiting due to coverage failure');
|
||||
if (!configArg.watch) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
return configArg;
|
||||
};
|
||||
|
||||
/**
|
||||
* run this module
|
||||
* @param configArg some config for how to run this module
|
||||
*/
|
||||
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.ora.end();
|
||||
plugins.beautylog.log('ready for tapbuffer:');
|
||||
if (configArg.testConfig.coverage) {
|
||||
tap(config)
|
||||
.then(handleCoverageData)
|
||||
.then(() => {
|
||||
done.resolve(config);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
} else {
|
||||
tap(config)
|
||||
.then(() => {
|
||||
done.resolve(config);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
plugins.beautylog.ora.end();
|
||||
done.resolve(config);
|
||||
}
|
||||
return done.promise;
|
||||
};
|
@ -1,10 +0,0 @@
|
||||
export * from '../npmts.plugins';
|
||||
|
||||
import * as gulpFunction from 'gulp-function';
|
||||
import * as gulpSourcemaps from 'gulp-sourcemaps';
|
||||
import * as gulpTypeScript from 'gulp-typescript';
|
||||
import * as smartcov from 'smartcov';
|
||||
import * as smartgulp from 'smartgulp';
|
||||
import * as tapbuffer from 'tapbuffer';
|
||||
|
||||
export { gulpFunction, gulpSourcemaps, gulpTypeScript, smartcov, smartgulp, tapbuffer };
|
115
ts/npmts.cli.ts
115
ts/npmts.cli.ts
@ -1,115 +0,0 @@
|
||||
import * as q from 'smartq';
|
||||
|
||||
import * as plugins from './npmts.plugins';
|
||||
import * as paths from './npmts.paths';
|
||||
import * as NpmtsConfig from './npmts.config';
|
||||
import * as NpmtsMods from './npmts.mods';
|
||||
import * as NpmtsWatch from './npmts.watch';
|
||||
import * as NpmtsShip from './npmts.ship';
|
||||
|
||||
/**
|
||||
* smartanalytics
|
||||
* this data is fully anonymized (no Ips or any other personal information is tracked).
|
||||
* It just keeps track which of our tools are really used...
|
||||
* ... so we know where to spend our limited resources for improving them.
|
||||
* Since yarn is out and there is heavy caching going on,
|
||||
* pure download stats are just not reliable enough for us anymore
|
||||
* Feel free to dig into the smartanalytics package, if you are interested in how it works.
|
||||
* It is just an https call to our own Lossless Analytics API.
|
||||
* Our privacy policy can be found here: https://lossless.gmbh/privacy.html
|
||||
*/
|
||||
let npmtsAnalytics = new plugins.smartanalytics.Analytics({
|
||||
apiEndPoint: 'https://pubapi.lossless.one/analytics',
|
||||
projectId: 'gitzone',
|
||||
appName: 'npmts'
|
||||
});
|
||||
|
||||
process.nextTick(async () => {
|
||||
// make the analytics call
|
||||
npmtsAnalytics
|
||||
.recordEvent('npmToolExecution', {
|
||||
executionMode: (await NpmtsConfig.configPromise).mode,
|
||||
tsOptions: (await NpmtsConfig.configPromise).tsOptions,
|
||||
watch: (await NpmtsConfig.configPromise).watch,
|
||||
coverageTreshold: (await NpmtsConfig.configPromise).coverageTreshold
|
||||
})
|
||||
.catch(err => {
|
||||
plugins.beautylog.warn('Lossless Analytics API not available...');
|
||||
});
|
||||
});
|
||||
|
||||
export let run = async () => {
|
||||
let done = q.defer();
|
||||
|
||||
plugins.beautylog.figletSync('NPMTS');
|
||||
let npmtsProjectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.npmtsPackageRoot);
|
||||
// check for updates
|
||||
await plugins.smartupdate.standardHandler.check(
|
||||
'npmts',
|
||||
npmtsProjectInfo.version,
|
||||
'http://gitzone.gitlab.io/npmts/changelog.html'
|
||||
);
|
||||
plugins.beautylog.log('---------------------------------------------');
|
||||
let npmtsCli = new plugins.smartcli.Smartcli();
|
||||
|
||||
// build
|
||||
npmtsCli.addCommand('build').subscribe(
|
||||
async argvArg => {
|
||||
let done = q.defer();
|
||||
plugins.beautylog.info('npmts version: ' + npmtsProjectInfo.version);
|
||||
const configArg: NpmtsConfig.INpmtsConfig = await NpmtsConfig.run(argvArg);
|
||||
|
||||
plugins.beautylog.ora.start('loading additional modules...');
|
||||
NpmtsMods.modCompile
|
||||
.load()
|
||||
.then(modCompile => {
|
||||
return modCompile.run(configArg);
|
||||
})
|
||||
.then(configArg => {
|
||||
let done = q.defer<NpmtsConfig.INpmtsConfig>();
|
||||
NpmtsMods.modDocs
|
||||
.load()
|
||||
.then(modDocs => {
|
||||
return modDocs.run(configArg);
|
||||
})
|
||||
.then(configArg => {
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
})
|
||||
.then(configArg => {
|
||||
let done = q.defer<NpmtsConfig.INpmtsConfig>();
|
||||
NpmtsMods.modTest
|
||||
.load()
|
||||
.then(modTest => {
|
||||
return modTest.run(configArg);
|
||||
})
|
||||
.then(configArg => {
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
})
|
||||
.then(NpmtsWatch.run)
|
||||
.then(NpmtsShip.run);
|
||||
|
||||
return done.promise;
|
||||
},
|
||||
err => {
|
||||
if (err instanceof Error) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// standard task
|
||||
npmtsCli.standardTask().subscribe(async argvArg => {
|
||||
await npmtsCli.trigger('build');
|
||||
});
|
||||
|
||||
// cli metadata
|
||||
npmtsCli.addVersion(npmtsProjectInfo.version);
|
||||
|
||||
// start parsing
|
||||
npmtsCli.startParse();
|
||||
return await done.promise;
|
||||
};
|
@ -1,110 +0,0 @@
|
||||
import plugins = require('./npmts.plugins');
|
||||
import paths = require('./npmts.paths');
|
||||
|
||||
import * as smartq from 'smartq';
|
||||
|
||||
// interfaces
|
||||
import { ITapbufferConfig } from 'tapbuffer';
|
||||
|
||||
/**
|
||||
* specifies the different modes available
|
||||
* default -> uses default options no matterm what
|
||||
* merge -> uses merged default + custom options
|
||||
* custom -> only uses specified options
|
||||
*/
|
||||
export type npmtsMode = 'default' | 'custom' | 'merge';
|
||||
|
||||
export interface INpmtsConfig {
|
||||
argv: any;
|
||||
coverageTreshold: number;
|
||||
checkDependencies: boolean;
|
||||
mode: npmtsMode;
|
||||
test: boolean;
|
||||
testTs: any;
|
||||
testConfig: ITapbufferConfig;
|
||||
ts: any;
|
||||
tsOptions: any;
|
||||
watch: boolean;
|
||||
runData: {
|
||||
coverageLcovInfo?: string;
|
||||
coverageResult?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export let run = function(argvArg) {
|
||||
let done = smartq.defer<INpmtsConfig>();
|
||||
let defaultConfig: INpmtsConfig = {
|
||||
argv: undefined,
|
||||
coverageTreshold: 70,
|
||||
checkDependencies: true,
|
||||
mode: 'default',
|
||||
test: true,
|
||||
testTs: {},
|
||||
testConfig: {
|
||||
parallel: true,
|
||||
coverage: true
|
||||
},
|
||||
ts: {},
|
||||
tsOptions: {},
|
||||
watch: false,
|
||||
runData: {}
|
||||
};
|
||||
|
||||
// mix with configfile
|
||||
plugins.beautylog.ora.text('running npmextra');
|
||||
|
||||
let localNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
|
||||
let config: INpmtsConfig = localNpmextra.dataFor<INpmtsConfig>('npmts', defaultConfig);
|
||||
|
||||
// add argv
|
||||
config.argv = argvArg;
|
||||
|
||||
// check mode
|
||||
switch (config.mode) {
|
||||
case 'default':
|
||||
case 'custom':
|
||||
case 'merge':
|
||||
plugins.beautylog.ok('mode is ' + config.mode);
|
||||
done.resolve(config);
|
||||
break;
|
||||
default:
|
||||
plugins.beautylog.error(`mode not recognised! Can be default or custom`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// handle default mode
|
||||
if (config.mode === 'default' || config.mode === 'merge') {
|
||||
config.ts = {
|
||||
'./ts/**/*.ts': './dist/'
|
||||
};
|
||||
config.testTs = {
|
||||
'./test/**/*.ts': './test/'
|
||||
};
|
||||
}
|
||||
|
||||
// mix with commandline
|
||||
if (config.argv.notest) {
|
||||
config.test = false;
|
||||
}
|
||||
|
||||
if (config.argv.nocoverage) {
|
||||
config.testConfig.coverage = false;
|
||||
}
|
||||
|
||||
if (config.argv.nochecks) {
|
||||
config.checkDependencies = false;
|
||||
}
|
||||
|
||||
if (config.argv.watch) {
|
||||
config.watch = true;
|
||||
}
|
||||
|
||||
plugins.beautylog.ok('build options are ready!');
|
||||
done.resolve(config);
|
||||
configDeferred.resolve(config);
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
// config deferred usage
|
||||
let configDeferred = smartq.defer<INpmtsConfig>();
|
||||
export let configPromise = configDeferred.promise;
|
@ -1,11 +0,0 @@
|
||||
import * as plugins from './npmts.plugins';
|
||||
|
||||
import { LazyModule } from 'smartsystem';
|
||||
|
||||
import * as _modCompile from './mod_compile/index';
|
||||
import * as _modDocs from './mod_docs/index';
|
||||
import * as _modTest from './mod_test/index';
|
||||
|
||||
export let modCompile = new LazyModule<typeof _modCompile>('./mod_compile/index', __dirname);
|
||||
export let modDocs = new LazyModule<typeof _modDocs>('./mod_docs/index', __dirname);
|
||||
export let modTest = new LazyModule<typeof _modTest>('./mod_test/index', __dirname);
|
@ -1,24 +0,0 @@
|
||||
import plugins = require('./npmts.plugins');
|
||||
|
||||
// NPMTS Paths
|
||||
export let npmtsPackageRoot = plugins.path.join(__dirname, '../');
|
||||
|
||||
// Project paths
|
||||
export let cwd = process.cwd();
|
||||
|
||||
// Directories
|
||||
export let tsDir = plugins.path.join(cwd, 'ts/');
|
||||
export let distDir = plugins.path.join(cwd, 'dist/');
|
||||
export let testDir = plugins.path.join(cwd, 'test/');
|
||||
export let typingsDir = plugins.path.join(cwd, 'ts/typings/');
|
||||
export let coverageDir = plugins.path.join(cwd, 'coverage/');
|
||||
|
||||
// Pages
|
||||
export let pagesDir = plugins.path.join(cwd, 'pages/');
|
||||
export let pagesApiDir = plugins.path.join(pagesDir, '/api');
|
||||
|
||||
export let npmtsAssetsDir = plugins.path.join(__dirname, '../assets/');
|
||||
|
||||
// Files
|
||||
export let indexTS = plugins.path.join(cwd, 'ts/index.ts');
|
||||
export let testTS = plugins.path.join(cwd, 'ts/test.ts');
|
@ -1,36 +0,0 @@
|
||||
import * as beautylog from 'beautylog';
|
||||
let depcheck = require('depcheck');
|
||||
|
||||
import * as lodash from 'lodash';
|
||||
import * as npmextra from 'npmextra';
|
||||
import * as projectinfo from 'projectinfo';
|
||||
import * as path from 'path';
|
||||
import * as smartanalytics from 'smartanalytics';
|
||||
import * as smartcli from '@pushrocks/smartcli';
|
||||
import * as smarterror from 'smarterror';
|
||||
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';
|
||||
import * as smartupdate from 'smartupdate';
|
||||
import * as through2 from 'through2';
|
||||
|
||||
export {
|
||||
beautylog,
|
||||
depcheck,
|
||||
lodash,
|
||||
npmextra,
|
||||
projectinfo,
|
||||
path,
|
||||
smartanalytics,
|
||||
smartcli,
|
||||
smarterror,
|
||||
smartfile,
|
||||
smartpath,
|
||||
smartstream,
|
||||
smartstring,
|
||||
smartsystem,
|
||||
smartupdate,
|
||||
through2
|
||||
};
|
@ -1,31 +0,0 @@
|
||||
import * as q from 'smartq';
|
||||
|
||||
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);
|
||||
};
|
@ -1,34 +0,0 @@
|
||||
import * as q from 'smartq';
|
||||
import * as smartchok from 'smartchok';
|
||||
|
||||
import * as plugins from './npmts.plugins';
|
||||
import * as cli from './npmts.cli';
|
||||
|
||||
import { INpmtsConfig } from './npmts.config';
|
||||
|
||||
let npmtsSmartchok: smartchok.Smartchok = null;
|
||||
export let run = (configArg: INpmtsConfig) => {
|
||||
let done = q.defer();
|
||||
if (configArg.watch && npmtsSmartchok === null) {
|
||||
let pathsToWatch: string[] = [];
|
||||
for (let key in configArg.ts) {
|
||||
pathsToWatch.push(key);
|
||||
}
|
||||
for (let key in configArg.testTs) {
|
||||
pathsToWatch.push(key);
|
||||
}
|
||||
npmtsSmartchok = new smartchok.Smartchok(pathsToWatch);
|
||||
npmtsSmartchok.getObservableFor('change').then(changeObservableArg => {
|
||||
plugins.beautylog.info('now watching...');
|
||||
changeObservableArg.subscribe(() => {
|
||||
cli.run();
|
||||
});
|
||||
});
|
||||
npmtsSmartchok.start();
|
||||
done.resolve(configArg);
|
||||
} else {
|
||||
plugins.beautylog.info('not watching');
|
||||
done.resolve(configArg);
|
||||
}
|
||||
return done.promise;
|
||||
};
|
Reference in New Issue
Block a user