New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

docker-cli-js

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docker-cli-js - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

9

dist/index.d.ts
import * as Promise from 'bluebird';
export declare class Docker {
private options;
constructor(options?: Options);
constructor(options?: IOptions);
command(command: string, callback?: (err, data) => void): Promise<any>;
}
export interface Options {
export interface IOptions {
machineName?: string;
currentWorkingDirectory?: string;
}
export declare class Options implements IOptions {
machineName: string;
currentWorkingDirectory: string;
constructor(machineName?: string, currentWorkingDirectory?: string);
}
"use strict";
var _ = require('lodash');
var Promise = require('bluebird');

@@ -8,9 +9,22 @@ var child_process = require('child_process');

var exec = child_process.exec;
var array2Oject = function (lines) {
return lines.reduce(function (object, linep) {
var line = linep.trim();
if (line.length === 0) {
return object;
}
var parts = line.split(':');
var key = parts[0];
var value = parts.slice(1).join(':');
key = _.snakeCase(key);
object[key] = value.trim();
return object;
}, {});
};
var extractResult = function (result) {
var extracterArray = [
{
re: / build /,
re: /build/,
run: function (resultp) {
var obj = JSON.parse(resultp.raw);
var lines = obj[0].split(os.EOL);
var lines = resultp.raw.split(os.EOL);
lines.forEach(function (line) {

@@ -28,10 +42,10 @@ var re = /Successfully built (.*)$/;

});
return (resultp.response = lines);
resultp.response = lines;
return resultp;
},
},
{
re: / run /,
re: /run/,
run: function (resultp) {
var obj = JSON.parse(resultp.raw);
resultp.containerId = obj[0].trim();
resultp.containerId = resultp.raw.trim();
return resultp;

@@ -41,6 +55,5 @@ },

{
re: / ps /,
re: /ps/,
run: function (resultp) {
var obj = JSON.parse(resultp.raw);
var lines = obj[0].split(os.EOL);
var lines = resultp.raw.split(os.EOL);
resultp.containerList = cli_table_2_json_1.cliTable2Json(lines);

@@ -51,6 +64,5 @@ return resultp;

{
re: / images /,
re: /images/,
run: function (resultp) {
var obj = JSON.parse(resultp.raw);
var lines = obj[0].split(os.EOL);
var lines = resultp.raw.split(os.EOL);
resultp.images = cli_table_2_json_1.cliTable2Json(lines);

@@ -61,6 +73,5 @@ return resultp;

{
re: / network ls /,
re: /network ls/,
run: function (resultp) {
var obj = JSON.parse(resultp.raw);
var lines = obj[0].split(os.EOL);
var lines = resultp.raw.split(os.EOL);
resultp.network = cli_table_2_json_1.cliTable2Json(lines);

@@ -71,6 +82,5 @@ return resultp;

{
re: / inspect /,
re: /inspect/,
run: function (resultp) {
var obj = JSON.parse(resultp.raw);
var object = JSON.parse(obj[0]);
var object = JSON.parse(resultp.raw);
resultp.object = object;

@@ -80,2 +90,10 @@ return resultp;

},
{
re: /info/,
run: function (resultp) {
var lines = resultp.raw.split(os.EOL);
resultp.object = array2Oject(lines);
return resultp;
},
},
];

@@ -105,3 +123,3 @@ extracterArray.forEach(function (extracter) {

var docker = this;
var execCommand = 'docker ' + command;
var execCommand = 'docker ';
var machineconfig = '';

@@ -112,3 +130,2 @@ return Promise.resolve().then(function () {

return dockerMachine.command('config ' + docker.options.machineName).then(function (data) {
console.log('data = ', data);
machineconfig = data.machine.config;

@@ -118,4 +135,5 @@ });

}).then(function () {
execCommand += ' ' + machineconfig + ' ';
console.log('execCommand =', execCommand);
return Promise.delay(2000);
}).then(function () {
execCommand += ' ' + machineconfig + ' ' + command;
var execOptions = {

@@ -130,11 +148,8 @@ cwd: docker.options.currentWorkingDirectory,

};
console.log('exec options =', execOptions);
return new Promise(function (resolve, reject) {
exec(execCommand, execOptions, function (error, stdout, stderr) {
return exec(execCommand, execOptions, function (error, stdout, stderr) {
if (error) {
console.error("exec error: " + error);
reject(error);
return reject(stderr);
}
console.log("stdout: " + stdout);
resolve(stdout);
resolve({ result: stdout });
});

@@ -145,3 +160,3 @@ });

command: execCommand,
raw: JSON.stringify(data),
raw: data.result,
};

@@ -154,2 +169,10 @@ return extractResult(result);

exports.Docker = Docker;
var Options = (function () {
function Options(machineName, currentWorkingDirectory) {
this.machineName = machineName;
this.currentWorkingDirectory = currentWorkingDirectory;
}
return Options;
}());
exports.Options = Options;
//# sourceMappingURL=index.js.map
"use strict";
var test = require('blue-tape');
var path = require('path');
var index_1 = require('./index');

@@ -7,10 +8,16 @@ var config = require('../my_config.json');

test('docker-cli-js', function (t) {
t.test('config', function (t) {
t.test('info', function (t) {
var docker = new index_1.Docker();
docker.command('info').then(function (data) {
return docker.command('info').then(function (data) {
console.log(data);
t.ok(data);
t.ok(data.object.server_version);
});
t.end();
});
var options = new index_1.Options(null, path.join(__dirname, '..', 'test', 'nginx'));
var docker = new index_1.Docker(options);
return docker.command('build -t nginximg .').then(function (data) {
console.log('data = ', data);
});
});
//# sourceMappingURL=index.spec.js.map
{
"name": "docker-cli-js",
"version": "2.0.0",
"version": "2.0.1",
"description": "A node.js wrapper for the docker-machine CLI",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc