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.
|
|
|
|
* 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 = () => {
|
2018-05-18 11:17:52 +00:00
|
|
|
npmdockerCli.standardTask().subscribe((argvArg) => __awaiter(this, void 0, void 0, function* () {
|
2017-07-16 11:58:41 +00:00
|
|
|
plugins.beautylog.figletSync('npmdocker');
|
2018-05-18 11:09:14 +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
|
|
|
|
*/
|
2018-05-18 11:17:52 +00:00
|
|
|
npmdockerCli.addCommand('runinside').subscribe((argvArg) => __awaiter(this, void 0, void 0, function* () {
|
2017-04-02 12:48:23 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}));
|
2018-05-18 11:17:52 +00:00
|
|
|
npmdockerCli.addCommand('clean').subscribe((argvArg) => __awaiter(this, void 0, void 0, function* () {
|
2017-03-28 23:01:37 +00:00
|
|
|
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
|
|
|
}));
|
2018-05-18 11:17:52 +00:00
|
|
|
npmdockerCli.addCommand('speedtest').subscribe((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();
|
|
|
|
};
|
2018-05-18 11:17:52 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNsaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Oz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