Comparing version 0.0.1 to 0.0.2
'use strict'; | ||
const requireDir = require('require-dir'); | ||
module.exports = requireDir('./lib', { recurse: true }); | ||
module.exports = require('./lib'); |
@@ -7,3 +7,3 @@ 'use strict'; | ||
const pod = require('./pod'); | ||
const { pod } = require('./'); | ||
@@ -21,5 +21,3 @@ module.exports = function(opts) { | ||
.on('error', err => console.error(err)) | ||
.on('close', err => { | ||
console.log('close', err); | ||
}); | ||
.on('close', err => console.log('close', err)); | ||
logger.stdout.on('data', data => process.stdout.write(data)); | ||
@@ -29,4 +27,4 @@ logger.stderr.on('data', data => process.stderr.write(data)); | ||
} | ||
return pod(podname) | ||
return pod.get(podname) | ||
.then(execLogger); | ||
}; |
'use strict'; | ||
const _ = require('lodash'); | ||
const inquirer = require('inquirer'); | ||
const Promise = require('bluebird'); | ||
const exec = Promise.promisify(require('child_process').exec); | ||
const prompt = inquirer.createPromptModule(); | ||
module.exports = function(podname) { | ||
exports.get = function(podname) { | ||
@@ -19,15 +21,52 @@ const regExp = new RegExp(podname ? `^${podname}` : ''); | ||
const keys = _.map(array.shift(), _.toLower); | ||
const list = _.transform(array, (result, items) => { | ||
if (items.length !== keys.length) { | ||
return; | ||
} | ||
const item = _.transform(keys, (result, key, index) => { | ||
result[key] = items[index]; | ||
}, {}); | ||
if (regExp.test(item.name)) { | ||
result.push(item); | ||
} | ||
}); | ||
const list = _.chain(array) | ||
.reject(arr => arr.length !== keys.length) | ||
.map(arr => _.transform(keys, (result, key, index) => result[key] = arr[index], {})) | ||
.filter(pod => regExp.test(pod.name)) | ||
.value(); | ||
return list; | ||
}); | ||
}; | ||
exports.delete = function(podname) { | ||
if (!podname) { | ||
console.warn('looking into all pods...'); | ||
} | ||
let pods; | ||
return this.get(podname) | ||
.then(_pods => { | ||
pods = _pods; | ||
if (_.isEmpty(pods)) { | ||
return Promise.reject(new Error('Pod not found')); | ||
} | ||
console.log('pod list:'); | ||
_.forEach(pods, pod => console.log(`\t[${[pod.name]}]`)); | ||
return prompt({ | ||
name: 'confirm', | ||
type: 'confirm', | ||
message: 'Do you want to delete the pods?' | ||
}); | ||
}) | ||
.then(({ confirm }) => { | ||
if (!confirm) { | ||
return Promise.reject(new Error('Confirmation failed')); | ||
} | ||
if (podname) { | ||
return { confirm: true }; | ||
} | ||
return prompt({ | ||
name: 'confirm', | ||
type: 'confirm', | ||
message: 'Are you sure?' | ||
}); | ||
}) | ||
.then(({ confirm }) => { | ||
if (!confirm) { | ||
return Promise.reject(new Error('Confirmation failed')); | ||
} | ||
return Promise.map(pods, pod => exec(`kubectl delete pod ${pod.name}`)); | ||
}) | ||
.then(() => console.log('deleted')); | ||
}; |
{ | ||
"name": "kube-tools", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "", | ||
@@ -15,5 +15,6 @@ "main": "index.js", | ||
"dependencies": { | ||
"lodash": "^4.16.2", | ||
"require-dir": "^0.3.0" | ||
"bluebird": "^3.4.6", | ||
"inquirer": "^1.2.1", | ||
"lodash": "^4.16.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4423
8
99
3
3
+ Addedbluebird@^3.4.6
+ Addedinquirer@^1.2.1
+ Addedansi-escapes@1.4.0(transitive)
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedbluebird@3.7.2(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcli-cursor@1.0.2(transitive)
+ Addedcli-width@2.2.1(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedconcat-stream@1.6.2(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedexit-hook@1.1.1(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedexternal-editor@1.1.1(transitive)
+ Addedfigures@1.7.0(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedinquirer@1.2.3(transitive)
+ Addedis-fullwidth-code-point@1.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedmute-stream@0.0.6(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedonetime@1.1.0(transitive)
+ Addedos-shim@0.1.3(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedrestore-cursor@1.0.1(transitive)
+ Addedrun-async@2.4.1(transitive)
+ Addedrx@4.1.0(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedspawn-sync@1.0.15(transitive)
+ Addedstring-width@1.0.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtmp@0.0.29(transitive)
+ Addedtypedarray@0.0.6(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedrequire-dir@^0.3.0
- Removedrequire-dir@0.3.2(transitive)