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");
|
|
|
|
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* () {
|
|
|
|
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-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* () {
|
|
|
|
plugins.beautylog.ok('Starting speedtest');
|
|
|
|
yield plugins.smartshell.exec(`docker pull tianon/speedtest && docker run --r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