2017-02-11 22:37:01 +00:00
|
|
|
"use strict";
|
2017-03-28 23:01:37 +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());
|
|
|
|
});
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2017-02-11 22:37:01 +00:00
|
|
|
const plugins = require("./npmdocker.plugins");
|
|
|
|
// modules
|
|
|
|
const ConfigModule = require("./npmdocker.config");
|
|
|
|
const DockerModule = require("./npmdocker.docker");
|
2017-04-21 11:44:18 +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.
|
|
|
|
* It is just an https call to Google Analytics.
|
|
|
|
* Our privacy policy can be found here: https://lossless.gmbh/privacy.html
|
|
|
|
*/
|
2017-10-07 12:15:29 +00:00
|
|
|
let npmdockerAnalytics = new plugins.smartanalytics.Analytics({
|
|
|
|
apiEndPoint: 'https://pubapi.lossless.one',
|
|
|
|
appName: 'npmdocker',
|
|
|
|
projectId: 'gitzone'
|
|
|
|
});
|
|
|
|
npmdockerAnalytics.recordEvent('npmtoolexecution', {
|
|
|
|
somedata: 'somedata'
|
|
|
|
});
|
2017-02-11 22:37:01 +00:00
|
|
|
let npmdockerCli = new plugins.smartcli.Smartcli();
|
|
|
|
exports.run = () => {
|
2017-03-28 23:01:37 +00:00
|
|
|
npmdockerCli.standardTask().then((argvArg) => __awaiter(this, void 0, void 0, function* () {
|
2017-07-16 11:58:41 +00:00
|
|
|
plugins.beautylog.figletSync('npmdocker');
|
2017-03-28 23:01:37 +00:00
|
|
|
let configArg = yield ConfigModule.run()
|
|
|
|
.then(DockerModule.run);
|
2017-02-11 22:37:01 +00:00
|
|
|
if (configArg.exitCode === 0) {
|
|
|
|
plugins.beautylog.success('container ended all right!');
|
|
|
|
}
|
|
|
|
else {
|
2017-04-20 19:57:44 +00:00
|
|
|
plugins.beautylog.error(`container ended with error! Exit Code is ${configArg.exitCode}`);
|
2017-02-11 22:37:01 +00:00
|
|
|
process.exit(1);
|
|
|
|
}
|
2017-03-28 23:01:37 +00:00
|
|
|
}));
|
2017-07-16 11:58:41 +00:00
|
|
|
/**
|
|
|
|
* this command is executed inside docker and meant for use from outside docker
|
|
|
|
*/
|
2017-04-02 12:48:23 +00:00
|
|
|
npmdockerCli.addCommand('runinside').then((argvArg) => __awaiter(this, void 0, void 0, function* () {
|
|
|
|
plugins.beautylog.ok('Allright. We are now in Docker!');
|
|
|
|
plugins.beautylog.log('now trying to run your specified command');
|
|
|
|
let configArg = yield ConfigModule.run();
|
|
|
|
yield plugins.smartshell.exec(configArg.command).then(response => {
|
|
|
|
if (response.exitCode !== 0) {
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}));
|
2017-03-28 23:01:37 +00:00
|
|
|
npmdockerCli.addCommand('clean').then((argvArg) => __awaiter(this, void 0, void 0, function* () {
|
|
|
|
plugins.beautylog.ora.start();
|
2017-02-11 22:37:01 +00:00
|
|
|
plugins.beautylog.ora.text('cleaning up docker env...');
|
|
|
|
if (argvArg.all) {
|
|
|
|
plugins.beautylog.ora.text('killing any running docker containers...');
|
2017-03-28 23:01:37 +00:00
|
|
|
yield plugins.smartshell.exec(`docker kill $(docker ps -q)`);
|
2017-02-11 22:37:01 +00:00
|
|
|
plugins.beautylog.ora.text('removing stopped containers...');
|
2017-03-28 23:01:37 +00:00
|
|
|
yield plugins.smartshell.exec(`docker rm $(docker ps -a -q)`);
|
2017-02-11 22:37:01 +00:00
|
|
|
plugins.beautylog.ora.text('removing images...');
|
2017-03-28 23:01:37 +00:00
|
|
|
yield plugins.smartshell.exec(`docker rmi $(docker images -q -f dangling=true)`);
|
2017-02-11 22:37:01 +00:00
|
|
|
plugins.beautylog.ora.text('removing all other images...');
|
2017-03-28 23:01:37 +00:00
|
|
|
yield plugins.smartshell.exec(`docker rmi $(docker images -a -q)`);
|
2017-02-12 15:04:27 +00:00
|
|
|
plugins.beautylog.ora.text('removing all volumes...');
|
2017-03-28 23:01:37 +00:00
|
|
|
yield plugins.smartshell.exec(`docker volume rm $(docker volume ls -f dangling=true -q)`);
|
2017-02-11 22:37:01 +00:00
|
|
|
}
|
|
|
|
plugins.beautylog.ora.endOk('docker environment now is clean!');
|
2017-03-28 23:01:37 +00:00
|
|
|
}));
|
|
|
|
npmdockerCli.addCommand('speedtest').then((argvArg) => __awaiter(this, void 0, void 0, function* () {
|
2017-07-16 11:58:41 +00:00
|
|
|
plugins.beautylog.figletSync('npmdocker');
|
2017-03-28 23:01:37 +00:00
|
|
|
plugins.beautylog.ok('Starting speedtest');
|
|
|
|
yield plugins.smartshell.exec(`docker pull tianon/speedtest && docker run --rm tianon/speedtest`);
|
|
|
|
}));
|
2017-02-11 22:37:01 +00:00
|
|
|
npmdockerCli.startParse();
|
|
|
|
};
|
2017-10-07 12:15:29 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNsaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLCtDQUE4QztBQUc5Qyx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