tscoverage/dist/npmts.cli.js

110 lines
4.4 KiB
JavaScript
Raw Permalink Normal View History

2016-10-06 19:03:30 +00:00
"use strict";
2017-08-16 21:46:20 +00:00
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
2017-02-27 21:19:14 +00:00
Object.defineProperty(exports, "__esModule", { value: true });
2017-01-17 23:58:09 +00:00
const q = require("smartq");
2016-10-06 19:03:30 +00:00
const plugins = require("./npmts.plugins");
const paths = require("./npmts.paths");
2016-10-21 15:48:52 +00:00
const NpmtsConfig = require("./npmts.config");
const NpmtsMods = require("./npmts.mods");
const NpmtsWatch = require("./npmts.watch");
const NpmtsShip = require("./npmts.ship");
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'
});
process.nextTick(() => __awaiter(this, void 0, void 0, function* () {
// make the analytics call
npmtsAnalytics
.recordEvent('npmToolExecution', {
2017-08-29 14:15:24 +00:00
executionMode: (yield NpmtsConfig.configPromise).mode,
tsOptions: (yield NpmtsConfig.configPromise).tsOptions,
watch: (yield NpmtsConfig.configPromise).watch,
coverageTreshold: (yield NpmtsConfig.configPromise).coverageTreshold
})
.catch(err => {
2017-08-29 14:15:24 +00:00
plugins.beautylog.warn('Lossless Analytics API not available...');
});
}));
2017-08-16 21:46:20 +00:00
exports.run = () => __awaiter(this, void 0, void 0, function* () {
2016-10-06 19:03:30 +00:00
let done = q.defer();
2017-08-16 21:53:52 +00:00
plugins.beautylog.figletSync('NPMTS');
2016-10-06 19:03:30 +00:00
let npmtsProjectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.npmtsPackageRoot);
2017-08-16 17:13:01 +00:00
// check for updates
2017-08-17 10:06:08 +00:00
yield plugins.smartupdate.standardHandler.check('npmts', npmtsProjectInfo.version, 'http://gitzone.gitlab.io/npmts/changelog.html');
2017-08-16 21:53:52 +00:00
plugins.beautylog.log('---------------------------------------------');
2016-10-06 19:03:30 +00:00
let npmtsCli = new plugins.smartcli.Smartcli();
// build
npmtsCli
.addCommand('build')
.subscribe((argvArg) => __awaiter(this, void 0, void 0, function* () {
2016-10-21 15:48:52 +00:00
let done = q.defer();
plugins.beautylog.info('npmts version: ' + npmtsProjectInfo.version);
const configArg = yield NpmtsConfig.run(argvArg);
2017-01-21 22:23:00 +00:00
plugins.beautylog.ora.start('loading additional modules...');
NpmtsMods.modCompile
.load()
.then(modCompile => {
2017-11-28 16:33:55 +00:00
return modCompile.run(configArg);
2016-10-21 15:48:52 +00:00
})
.then(configArg => {
let done = q.defer();
NpmtsMods.modDocs
.load()
2017-11-28 16:33:55 +00:00
.then(modDocs => {
return modDocs.run(configArg);
2016-10-21 15:48:52 +00:00
})
.then(configArg => {
done.resolve(configArg);
});
return done.promise;
})
.then(configArg => {
let done = q.defer();
NpmtsMods.modTest
.load()
2017-11-28 16:33:55 +00:00
.then(modTest => {
return modTest.run(configArg);
2016-10-21 15:48:52 +00:00
})
.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((argvArg) => __awaiter(this, void 0, void 0, function* () {
yield npmtsCli.trigger('build');
}));
// cli metadata
2016-10-06 19:03:30 +00:00
npmtsCli.addVersion(npmtsProjectInfo.version);
// start parsing
2016-10-06 19:03:30 +00:00
npmtsCli.startParse();
2017-08-16 21:46:20 +00:00
return yield done.promise;
});