2018-04-08 23:03:39 +00:00
|
|
|
import * as q from 'smartq';
|
2016-10-21 15:48:52 +00:00
|
|
|
|
2018-04-08 23:03:39 +00:00
|
|
|
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';
|
2016-10-21 15:48:52 +00:00
|
|
|
|
2017-04-17 12:55:35 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
2017-08-29 14:15:24 +00:00
|
|
|
* It is just an https call to our own Lossless Analytics API.
|
2017-04-17 12:55:35 +00:00
|
|
|
* Our privacy policy can be found here: https://lossless.gmbh/privacy.html
|
|
|
|
*/
|
2017-08-29 14:15:24 +00:00
|
|
|
let npmtsAnalytics = new plugins.smartanalytics.Analytics({
|
2017-09-08 16:04:40 +00:00
|
|
|
apiEndPoint: 'https://pubapi.lossless.one/analytics',
|
2017-08-29 14:15:24 +00:00
|
|
|
projectId: 'gitzone',
|
|
|
|
appName: 'npmts'
|
2018-04-08 23:03:39 +00:00
|
|
|
});
|
2017-08-29 14:15:24 +00:00
|
|
|
|
|
|
|
process.nextTick(async () => {
|
|
|
|
// make the analytics call
|
2018-04-08 23:03:39 +00:00
|
|
|
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...');
|
|
|
|
});
|
|
|
|
});
|
2017-03-04 22:44:16 +00:00
|
|
|
|
2017-08-16 21:46:20 +00:00
|
|
|
export let run = async () => {
|
2018-04-08 23:03:39 +00:00
|
|
|
let done = q.defer();
|
2017-08-29 14:15:24 +00:00
|
|
|
|
2018-04-08 23:03:39 +00:00
|
|
|
plugins.beautylog.figletSync('NPMTS');
|
|
|
|
let npmtsProjectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.npmtsPackageRoot);
|
2017-08-16 17:13:01 +00:00
|
|
|
// check for updates
|
2018-04-08 23:03:39 +00:00
|
|
|
await plugins.smartupdate.standardHandler.check(
|
|
|
|
'npmts',
|
|
|
|
npmtsProjectInfo.version,
|
|
|
|
'http://gitzone.gitlab.io/npmts/changelog.html'
|
|
|
|
);
|
|
|
|
plugins.beautylog.log('---------------------------------------------');
|
|
|
|
let npmtsCli = new plugins.smartcli.Smartcli();
|
2018-05-03 16:05:37 +00:00
|
|
|
|
2018-05-03 10:35:41 +00:00
|
|
|
// build
|
2018-05-03 16:05:37 +00:00
|
|
|
npmtsCli.addCommand('build').subscribe(
|
|
|
|
async argvArg => {
|
2018-04-08 23:03:39 +00:00
|
|
|
let done = q.defer();
|
2018-05-03 10:35:41 +00:00
|
|
|
plugins.beautylog.info('npmts version: ' + npmtsProjectInfo.version);
|
|
|
|
const configArg: NpmtsConfig.INpmtsConfig = await NpmtsConfig.run(argvArg);
|
|
|
|
|
2018-04-08 23:03:39 +00:00
|
|
|
plugins.beautylog.ora.start('loading additional modules...');
|
|
|
|
NpmtsMods.modCompile
|
|
|
|
.load()
|
|
|
|
.then(modCompile => {
|
|
|
|
return modCompile.run(configArg);
|
2016-10-21 15:48:52 +00:00
|
|
|
})
|
2017-03-04 22:44:16 +00:00
|
|
|
.then(configArg => {
|
2018-04-08 23:03:39 +00:00
|
|
|
let done = q.defer<NpmtsConfig.INpmtsConfig>();
|
|
|
|
NpmtsMods.modDocs
|
|
|
|
.load()
|
2017-11-28 16:33:55 +00:00
|
|
|
.then(modDocs => {
|
2018-04-08 23:03:39 +00:00
|
|
|
return modDocs.run(configArg);
|
2017-03-04 22:44:16 +00:00
|
|
|
})
|
|
|
|
.then(configArg => {
|
2018-04-08 23:03:39 +00:00
|
|
|
done.resolve(configArg);
|
|
|
|
});
|
|
|
|
return done.promise;
|
2016-10-06 19:03:30 +00:00
|
|
|
})
|
2017-03-04 22:44:16 +00:00
|
|
|
.then(configArg => {
|
2018-04-08 23:03:39 +00:00
|
|
|
let done = q.defer<NpmtsConfig.INpmtsConfig>();
|
|
|
|
NpmtsMods.modTest
|
|
|
|
.load()
|
2017-11-28 16:33:55 +00:00
|
|
|
.then(modTest => {
|
2018-04-08 23:03:39 +00:00
|
|
|
return modTest.run(configArg);
|
2017-03-04 22:44:16 +00:00
|
|
|
})
|
|
|
|
.then(configArg => {
|
2018-04-08 23:03:39 +00:00
|
|
|
done.resolve(configArg);
|
|
|
|
});
|
|
|
|
return done.promise;
|
2017-03-04 22:44:16 +00:00
|
|
|
})
|
|
|
|
.then(NpmtsWatch.run)
|
2018-04-08 23:03:39 +00:00
|
|
|
.then(NpmtsShip.run);
|
2017-03-04 22:44:16 +00:00
|
|
|
|
2018-04-08 23:03:39 +00:00
|
|
|
return done.promise;
|
2018-05-03 16:05:37 +00:00
|
|
|
},
|
|
|
|
err => {
|
2018-04-08 23:03:39 +00:00
|
|
|
if (err instanceof Error) {
|
|
|
|
console.log(err);
|
|
|
|
}
|
2018-05-03 16:05:37 +00:00
|
|
|
}
|
|
|
|
);
|
2018-05-03 10:35:41 +00:00
|
|
|
|
|
|
|
// standard task
|
|
|
|
npmtsCli.standardTask().subscribe(async argvArg => {
|
2018-05-03 16:05:37 +00:00
|
|
|
await npmtsCli.trigger('build');
|
|
|
|
});
|
2018-05-03 10:35:41 +00:00
|
|
|
|
|
|
|
// cli metadata
|
2018-04-08 23:03:39 +00:00
|
|
|
npmtsCli.addVersion(npmtsProjectInfo.version);
|
2018-05-03 10:35:41 +00:00
|
|
|
|
|
|
|
// start parsing
|
2018-04-08 23:03:39 +00:00
|
|
|
npmtsCli.startParse();
|
|
|
|
return await done.promise;
|
|
|
|
};
|