New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@rocketmakers/shell-commands

Package Overview
Dependencies
Maintainers
6
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rocketmakers/shell-commands - npm Package Compare versions

Comparing version
5.2.1
to
5.3.0
+32
-0
lib/docker-compose.d.ts
/// <reference types="node" />
import { IShellOptions } from './shell';
export declare namespace DockerCompose {
/**
* Determines whether `docker compose` (v2) is supported or if we need to use the legacy `docker-compose` command
*/
function isV2Supported(): Promise<boolean>;
/**
* Executes a docker compose command either with v1 or v2 based on availability.
*
* The v2 version is preferred since it's included in docker CLI but for the time being it's not on linux.
* @param args The arguments to pass to the compose command
* @param options The optional {@link IShellOptions} to include
*/
function exec(args: string[], options?: IShellOptions): Promise<string>;
/**
* Builds containers using a given docker-compose config file
* @param composePath The path to the config file
* @param uniqueProjectName The name to give to the project rather than using the current directory name
* @param env Optional environment variables to use
*/
function build(composePath: string, uniqueProjectName: string, env?: NodeJS.ProcessEnv): Promise<string>;
/**
* Builds a single service named in a given docker-compose config file
* @param composePath The path to the config file
* @param uniqueProjectName The name to give to the project rather than using the current directory name
* @param serviceName The name of the service to build from the config file
* @param env Optional environment variables to use
*/
function buildService(composePath: string, uniqueProjectName: string, serviceName: string, env?: NodeJS.ProcessEnv): Promise<string>;
/**
* Gets a list of services included in a given docker-compose config file
* @param composePath The path to the config file
* @param env Optional environment variables to use
* @returns The list of services as a string array
*/
function getServices(composePath: string, env?: NodeJS.ProcessEnv): Promise<string[]>;
}
+51
-9

@@ -5,22 +5,64 @@ "use strict";

const yml = require("js-yaml");
const docker_1 = require("./docker");
const logger_1 = require("./logger");
const prerequisites_1 = require("./prerequisites");
const shell_1 = require("./shell");
const logger = (0, logger_1.createLogger)('docker-compose');
var DockerCompose;
(function (DockerCompose) {
const exe = 'docker-compose';
prerequisites_1.Prerequisites.register({
command: exe,
description: 'Defining and running groups of docker containers',
docsUrl: 'https://docs.docker.com/compose/',
});
prerequisites_1.Prerequisites.register(docker_1.Docker.prerequisite);
/**
* Determines whether `docker compose` (v2) is supported or if we need to use the legacy `docker-compose` command
*/
async function isV2Supported() {
logger.debug('Checking for v2 docker compose support');
const output = await shell_1.Shell.execOutput('docker', ['compose', 'version'], { allowFail: true });
logger.debug(`Output from "docker compose version": '${output}'`);
return output.includes('Docker Compose version');
}
DockerCompose.isV2Supported = isV2Supported;
/**
* Executes a docker compose command either with v1 or v2 based on availability.
*
* The v2 version is preferred since it's included in docker CLI but for the time being it's not on linux.
* @param args The arguments to pass to the compose command
* @param options The optional {@link IShellOptions} to include
*/
async function exec(args, options = {}) {
if (await isV2Supported()) {
return shell_1.Shell.exec('docker', ['compose', ...args], options);
}
logger.warn('Docker compose v2 not supported - falling back to v1');
return shell_1.Shell.exec('docker-compose', args, options);
}
DockerCompose.exec = exec;
/**
* Builds containers using a given docker-compose config file
* @param composePath The path to the config file
* @param uniqueProjectName The name to give to the project rather than using the current directory name
* @param env Optional environment variables to use
*/
function build(composePath, uniqueProjectName, env) {
return shell_1.Shell.exec(exe, ['--project-name', uniqueProjectName, '-f', composePath, 'build'], { env });
return exec(['--project-name', uniqueProjectName, '-f', composePath, 'build'], { env });
}
DockerCompose.build = build;
/**
* Builds a single service named in a given docker-compose config file
* @param composePath The path to the config file
* @param uniqueProjectName The name to give to the project rather than using the current directory name
* @param serviceName The name of the service to build from the config file
* @param env Optional environment variables to use
*/
function buildService(composePath, uniqueProjectName, serviceName, env) {
return shell_1.Shell.exec(exe, ['--project-name', uniqueProjectName, '-f', composePath, 'build', serviceName], { env });
return exec(['--project-name', uniqueProjectName, '-f', composePath, 'build', serviceName], { env });
}
DockerCompose.buildService = buildService;
/**
* Gets a list of services included in a given docker-compose config file
* @param composePath The path to the config file
* @param env Optional environment variables to use
* @returns The list of services as a string array
*/
async function getServices(composePath, env) {
const configStr = await shell_1.Shell.exec(exe, ['-f', composePath, 'config'], { log: false, output: true, env });
const configStr = await exec(['-f', composePath, 'config'], { log: false, output: true, env });
const config = yml.safeLoad(configStr);

@@ -27,0 +69,0 @@ return Object.keys(config.services);

@@ -10,2 +10,7 @@ export declare namespace Docker {

}
const prerequisite: {
command: string;
description: string;
docsUrl: string;
};
/**

@@ -12,0 +17,0 @@ * Tag a local image with a remote tag.

+3
-2

@@ -9,7 +9,8 @@ "use strict";

const exe = 'docker';
prerequisites_1.Prerequisites.register({
Docker.prerequisite = {
command: exe,
description: 'Running software in containers',
docsUrl: 'https://docs.docker.com/',
});
};
prerequisites_1.Prerequisites.register(Docker.prerequisite);
/**

@@ -16,0 +17,0 @@ * Tag a local image with a remote tag.

{
"name": "@rocketmakers/shell-commands",
"version": "5.2.1",
"version": "5.3.0",
"description": "",

@@ -5,0 +5,0 @@ "directories": {