mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-18 02:39:49 +00:00
Generate JS
This commit is contained in:
parent
73dd625ede
commit
19c51929a9
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript 1.12.4
|
// Generated by CoffeeScript 1.12.4
|
||||||
(function() {
|
(function() {
|
||||||
var Docker, Promise, _, chalk, filterOutSupervisorContainer, form;
|
var Docker, Promise, _, chalk, dockerPort, dockerTimeout, filterOutSupervisorContainer, form;
|
||||||
|
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
|
||||||
@ -12,7 +12,11 @@
|
|||||||
|
|
||||||
chalk = require('chalk');
|
chalk = require('chalk');
|
||||||
|
|
||||||
filterOutSupervisorContainer = function(container) {
|
exports.dockerPort = dockerPort = 2375;
|
||||||
|
|
||||||
|
exports.dockerTimeout = dockerTimeout = 2000;
|
||||||
|
|
||||||
|
exports.filterOutSupervisorContainer = filterOutSupervisorContainer = function(container) {
|
||||||
var i, len, name, ref;
|
var i, len, name, ref;
|
||||||
ref = container.Names;
|
ref = container.Names;
|
||||||
for (i = 0, len = ref.length; i < len; i++) {
|
for (i = 0, len = ref.length; i < len; i++) {
|
||||||
@ -24,86 +28,86 @@
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
exports.selectContainerFromDevice = Promise.method(function(deviceIp, filterSupervisor) {
|
||||||
filterOutSupervisorContainer: filterOutSupervisorContainer,
|
var docker;
|
||||||
selectContainerFromDevice: Promise.method(function(deviceIp, filterSupervisor) {
|
if (filterSupervisor == null) {
|
||||||
var docker;
|
filterSupervisor = false;
|
||||||
if (filterSupervisor == null) {
|
}
|
||||||
filterSupervisor = false;
|
docker = new Docker({
|
||||||
|
host: deviceIp,
|
||||||
|
port: dockerPort,
|
||||||
|
timeout: dockerTimeout
|
||||||
|
});
|
||||||
|
return docker.listContainersAsync({
|
||||||
|
all: true
|
||||||
|
}).filter(function(container) {
|
||||||
|
if (!filterSupervisor) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
docker = new Docker({
|
return filterOutSupervisorContainer(container);
|
||||||
host: deviceIp,
|
}).then(function(containers) {
|
||||||
port: 2375
|
if (_.isEmpty(containers)) {
|
||||||
});
|
throw new Error("No containers found in " + deviceIp);
|
||||||
return docker.listContainersAsync({
|
|
||||||
all: true
|
|
||||||
}).filter(function(container) {
|
|
||||||
if (!filterSupervisor) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return filterOutSupervisorContainer(container);
|
|
||||||
}).then(function(containers) {
|
|
||||||
if (_.isEmpty(containers)) {
|
|
||||||
throw new Error("No containers found in " + deviceIp);
|
|
||||||
}
|
|
||||||
return form.ask({
|
|
||||||
message: 'Select a container',
|
|
||||||
type: 'list',
|
|
||||||
choices: _.map(containers, function(container) {
|
|
||||||
var containerName, containerStatus, shortContainerId;
|
|
||||||
containerName = container.Names[0] || 'Untitled';
|
|
||||||
shortContainerId = ('' + container.Id).substr(0, 11);
|
|
||||||
containerStatus = container.Status;
|
|
||||||
return {
|
|
||||||
name: containerName + " (" + shortContainerId + ") - " + containerStatus,
|
|
||||||
value: container.Id
|
|
||||||
};
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
pipeContainerStream: Promise.method(function(arg) {
|
|
||||||
var container, deviceIp, docker, follow, name, outStream, ref;
|
|
||||||
deviceIp = arg.deviceIp, name = arg.name, outStream = arg.outStream, follow = (ref = arg.follow) != null ? ref : false;
|
|
||||||
docker = new Docker({
|
|
||||||
host: deviceIp,
|
|
||||||
port: 2375
|
|
||||||
});
|
|
||||||
container = docker.getContainer(name);
|
|
||||||
return container.inspectAsync().then(function(containerInfo) {
|
|
||||||
var ref1;
|
|
||||||
return containerInfo != null ? (ref1 = containerInfo.State) != null ? ref1.Running : void 0 : void 0;
|
|
||||||
}).then(function(isRunning) {
|
|
||||||
return container.attachAsync({
|
|
||||||
logs: !follow || !isRunning,
|
|
||||||
stream: follow && isRunning,
|
|
||||||
stdout: true,
|
|
||||||
stderr: true
|
|
||||||
});
|
|
||||||
}).then(function(containerStream) {
|
|
||||||
return containerStream.pipe(outStream);
|
|
||||||
})["catch"](function(err) {
|
|
||||||
err = '' + err.statusCode;
|
|
||||||
if (err === '404') {
|
|
||||||
return console.log(chalk.red.bold("Container '" + name + "' not found."));
|
|
||||||
}
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
getSubShellCommand: function(command) {
|
|
||||||
var os;
|
|
||||||
os = require('os');
|
|
||||||
if (os.platform() === 'win32') {
|
|
||||||
return {
|
|
||||||
program: 'cmd.exe',
|
|
||||||
args: ['/s', '/c', command]
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
program: '/bin/sh',
|
|
||||||
args: ['-c', command]
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
return form.ask({
|
||||||
|
message: 'Select a container',
|
||||||
|
type: 'list',
|
||||||
|
choices: _.map(containers, function(container) {
|
||||||
|
var containerName, containerStatus, shortContainerId;
|
||||||
|
containerName = container.Names[0] || 'Untitled';
|
||||||
|
shortContainerId = ('' + container.Id).substr(0, 11);
|
||||||
|
containerStatus = container.Status;
|
||||||
|
return {
|
||||||
|
name: containerName + " (" + shortContainerId + ") - " + containerStatus,
|
||||||
|
value: container.Id
|
||||||
|
};
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.pipeContainerStream = Promise.method(function(arg) {
|
||||||
|
var container, deviceIp, docker, follow, name, outStream, ref;
|
||||||
|
deviceIp = arg.deviceIp, name = arg.name, outStream = arg.outStream, follow = (ref = arg.follow) != null ? ref : false;
|
||||||
|
docker = new Docker({
|
||||||
|
host: deviceIp,
|
||||||
|
port: dockerPort
|
||||||
|
});
|
||||||
|
container = docker.getContainer(name);
|
||||||
|
return container.inspectAsync().then(function(containerInfo) {
|
||||||
|
var ref1;
|
||||||
|
return containerInfo != null ? (ref1 = containerInfo.State) != null ? ref1.Running : void 0 : void 0;
|
||||||
|
}).then(function(isRunning) {
|
||||||
|
return container.attachAsync({
|
||||||
|
logs: !follow || !isRunning,
|
||||||
|
stream: follow && isRunning,
|
||||||
|
stdout: true,
|
||||||
|
stderr: true
|
||||||
|
});
|
||||||
|
}).then(function(containerStream) {
|
||||||
|
return containerStream.pipe(outStream);
|
||||||
|
})["catch"](function(err) {
|
||||||
|
err = '' + err.statusCode;
|
||||||
|
if (err === '404') {
|
||||||
|
return console.log(chalk.red.bold("Container '" + name + "' not found."));
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.getSubShellCommand = function(command) {
|
||||||
|
var os;
|
||||||
|
os = require('os');
|
||||||
|
if (os.platform() === 'win32') {
|
||||||
|
return {
|
||||||
|
program: 'cmd.exe',
|
||||||
|
args: ['/s', '/c', command]
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
program: '/bin/sh',
|
||||||
|
args: ['-c', command]
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ limitations under the License.
|
|||||||
alias: 'a'
|
alias: 'a'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, forms, pipeContainerStream, ref, selectContainerFromDevice;
|
var Promise, forms, pipeContainerStream, ref, selectContainerFromDevice;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
@ -34,6 +34,7 @@ limitations under the License.
|
|||||||
alias: 'p'
|
alias: 'p'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, _, child_process, forms, getSubShellCommand, verbose;
|
var Promise, _, child_process, forms, getSubShellCommand, verbose;
|
||||||
child_process = require('child_process');
|
child_process = require('child_process');
|
||||||
|
@ -29,6 +29,8 @@ limitations under the License.
|
|||||||
|
|
||||||
resinPush.primary = true;
|
resinPush.primary = true;
|
||||||
|
|
||||||
|
resinPush.root = true;
|
||||||
|
|
||||||
module.exports = resinPush;
|
module.exports = resinPush;
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
@ -41,14 +41,16 @@ limitations under the License.
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
primary: true,
|
primary: true,
|
||||||
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Docker, Promise, SpinnerPromise, _, discover, prettyjson;
|
var Docker, Promise, SpinnerPromise, _, discover, dockerPort, dockerTimeout, prettyjson, ref;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
prettyjson = require('prettyjson');
|
prettyjson = require('prettyjson');
|
||||||
Docker = require('docker-toolbelt');
|
Docker = require('docker-toolbelt');
|
||||||
discover = require('resin-sync').discover;
|
discover = require('resin-sync').discover;
|
||||||
SpinnerPromise = require('resin-cli-visuals').SpinnerPromise;
|
SpinnerPromise = require('resin-cli-visuals').SpinnerPromise;
|
||||||
|
ref = require('./common'), dockerPort = ref.dockerPort, dockerTimeout = ref.dockerTimeout;
|
||||||
if (options.timeout != null) {
|
if (options.timeout != null) {
|
||||||
options.timeout *= 1000;
|
options.timeout *= 1000;
|
||||||
}
|
}
|
||||||
@ -59,13 +61,17 @@ limitations under the License.
|
|||||||
stopMessage: 'Reporting scan results'
|
stopMessage: 'Reporting scan results'
|
||||||
});
|
});
|
||||||
}).filter(function(arg) {
|
}).filter(function(arg) {
|
||||||
var address, docker;
|
var address;
|
||||||
address = arg.address;
|
address = arg.address;
|
||||||
docker = new Docker({
|
return Promise["try"](function() {
|
||||||
host: address,
|
var docker;
|
||||||
port: 2375
|
docker = new Docker({
|
||||||
});
|
host: address,
|
||||||
return docker.infoAsync()["return"](true).catchReturn(false);
|
port: dockerPort,
|
||||||
|
timeout: dockerTimeout
|
||||||
|
});
|
||||||
|
return docker.pingAsync();
|
||||||
|
})["return"](true).catchReturn(false);
|
||||||
}).tap(function(devices) {
|
}).tap(function(devices) {
|
||||||
if (_.isEmpty(devices)) {
|
if (_.isEmpty(devices)) {
|
||||||
throw new Error('Could not find any resinOS devices in the local network');
|
throw new Error('Could not find any resinOS devices in the local network');
|
||||||
@ -75,7 +81,8 @@ limitations under the License.
|
|||||||
host = arg.host, address = arg.address;
|
host = arg.host, address = arg.address;
|
||||||
docker = new Docker({
|
docker = new Docker({
|
||||||
host: address,
|
host: address,
|
||||||
port: 2375
|
port: dockerPort,
|
||||||
|
timeout: dockerTimeout
|
||||||
});
|
});
|
||||||
return Promise.props({
|
return Promise.props({
|
||||||
dockerInfo: docker.infoAsync().catchReturn('Could not get Docker info'),
|
dockerInfo: docker.infoAsync().catchReturn('Could not get Docker info'),
|
||||||
|
@ -45,6 +45,7 @@ limitations under the License.
|
|||||||
alias: 'p'
|
alias: 'p'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, _, child_process, forms, getSubShellCommand, ref, selectContainerFromDevice, verbose;
|
var Promise, _, child_process, forms, getSubShellCommand, ref, selectContainerFromDevice, verbose;
|
||||||
child_process = require('child_process');
|
child_process = require('child_process');
|
||||||
|
@ -33,6 +33,7 @@ limitations under the License.
|
|||||||
alias: 'a'
|
alias: 'a'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, ResinLocalDockerUtils, chalk, config, filterOutSupervisorContainer, forms, ref, ref1, selectContainerFromDevice;
|
var Promise, ResinLocalDockerUtils, chalk, config, filterOutSupervisorContainer, forms, ref, ref1, selectContainerFromDevice;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
Loading…
Reference in New Issue
Block a user