added clean --all

This commit is contained in:
2017-02-11 23:37:01 +01:00
parent 9b8636b472
commit abf5cd1e24
14 changed files with 458 additions and 113 deletions

View File

@@ -1,15 +1,4 @@
import * as plugins from "./npmdocker.plugins";
import * as promisechain from "./npmdocker.promisechain";
import * as ConfigModule from "./npmdocker.config";
promisechain.run()
.then((configArg:ConfigModule.IConfig) => {
if(configArg.exitCode == 0){
plugins.beautylog.success("container ended all right!");
} else {
plugins.beautylog.error("container ended with error!");
process.exit(1);
}
});
import * as plugins from './npmdocker.plugins'
import * as cli from './npmdocker.cli'
cli.run()

48
ts/npmdocker.cli.ts Normal file
View File

@@ -0,0 +1,48 @@
import * as plugins from './npmdocker.plugins'
import * as paths from './npmdocker.paths'
// modules
import * as ConfigModule from './npmdocker.config'
import * as DockerModule from './npmdocker.docker'
let npmdockerCli = new plugins.smartcli.Smartcli()
plugins.beautylog.ora.start()
export let run = () => {
npmdockerCli.standardTask().then(argvArg => {
let done = plugins.q.defer()
ConfigModule.run()
.then(DockerModule.run)
.then((configArg) => {
done.resolve(configArg)
})
return done.promise
}).then((configArg: ConfigModule.IConfig) => {
if (configArg.exitCode === 0) {
plugins.beautylog.success('container ended all right!')
} else {
plugins.beautylog.error('container ended with error!')
process.exit(1)
}
})
npmdockerCli.addCommand('clean').then(argvArg => {
plugins.beautylog.ora.text('cleaning up docker env...')
if (argvArg.all) {
plugins.beautylog.ora.text('killing any running docker containers...')
plugins.shelljs.exec(`docker kill $(docker ps -q)`)
plugins.beautylog.ora.text('removing stopped containers...')
plugins.shelljs.exec(`docker rm $(docker ps -a -q)`)
plugins.beautylog.ora.text('removing images...')
plugins.shelljs.exec(`docker rmi $(docker images -q -f dangling=true)`)
plugins.beautylog.ora.text('removing all other images...')
plugins.shelljs.exec(`docker rmi $(docker images -q)`)
}
plugins.beautylog.ora.endOk('docker environment now is clean!')
})
npmdockerCli.startParse()
}

View File

@@ -1,10 +1,24 @@
import "typings-global";
export import beautylog = require("beautylog");
export import npmextra = require("npmextra");
export import path = require("path");
export import projectinfo = require("projectinfo");
export import q = require("smartq");
export import qenv = require("qenv");
export import shelljs = require("shelljs");
export import smartfile = require("smartfile");
export import smartstring = require("smartstring");
import 'typings-global'
import * as beautylog from 'beautylog'
import * as npmextra from 'npmextra'
import * as path from 'path'
import * as projectinfo from 'projectinfo'
import * as q from 'smartq'
import * as qenv from 'qenv'
import * as shelljs from 'shelljs'
import * as smartcli from 'smartcli'
import * as smartfile from 'smartfile'
import * as smartstring from 'smartstring'
export {
beautylog,
npmextra,
path,
projectinfo,
q,
qenv,
shelljs,
smartcli,
smartfile,
smartstring
}

View File

@@ -1,17 +0,0 @@
import * as plugins from "./npmdocker.plugins";
import * as paths from "./npmdocker.paths";
//modules
import * as ConfigModule from "./npmdocker.config";
import * as DockerModule from "./npmdocker.docker";
plugins.beautylog.ora.start();
export let run = () => {
let done = plugins.q.defer();
ConfigModule.run()
.then(DockerModule.run)
.then((configArg) => {
done.resolve(configArg);
})
return done.promise;
}