Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sapphirecode/dcm

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sapphirecode/dcm - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

39

dist/lib/commands.js

@@ -56,5 +56,7 @@ "use strict";

var tasks_1 = require("@sapphirecode/tasks");
var debug_1 = __importDefault(require("debug"));
var exec_1 = require("./exec");
var docker_interface_1 = require("./docker_interface");
var util_1 = require("./util");
var log = (0, debug_1.default)('sapphirecode:docker-compose-backup:commands');
function init_structure(store) {

@@ -98,2 +100,8 @@ return __awaiter(this, void 0, void 0, function () {

}
function check_startable(dependencies, started) {
var sublog = log.extend('check_startable');
var missing = dependencies.filter(function (dep) { return !started.includes(dep); });
sublog('Startable:', missing.length === 0, 'missing:', missing);
return missing.length === 0;
}
function do_up(store, include_passive, pull) {

@@ -131,2 +139,3 @@ return __awaiter(this, void 0, void 0, function () {

}
log('Queue:', queue.map(function (s) { return s.name; }));
threads = [];

@@ -136,35 +145,34 @@ for (i = 0; i < 4; i++) {

threads.push(new Promise(function (res, reject) { return __awaiter(_this, void 0, void 0, function () {
var service, waiting_for, e_1;
var service, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 8, , 9]);
_a.trys.push([0, 7, , 8]);
_a.label = 1;
case 1:
if (!(queue.length > 0)) return [3 /*break*/, 7];
if (!(queue.length > 0)) return [3 /*break*/, 6];
service = queue.shift();
(0, assert_1.default)(typeof service !== 'undefined');
waiting_for = 0;
log("Checking ".concat(service.name));
_a.label = 2;
case 2:
waiting_for = service.depends_on.filter(function (dep) { return started.indexOf(dep) < 0; }).length;
if (!!check_startable(service.depends_on, started)) return [3 /*break*/, 4];
return [4 /*yield*/, (0, util_1.delay)(100)];
case 3:
_a.sent();
_a.label = 4;
return [3 /*break*/, 2];
case 4:
if (waiting_for > 0) return [3 /*break*/, 2];
_a.label = 5;
case 5: return [4 /*yield*/, (service === null || service === void 0 ? void 0 : service.up())];
case 6:
log("Starting ".concat(service.name));
return [4 /*yield*/, (service === null || service === void 0 ? void 0 : service.up())];
case 5:
_a.sent();
return [3 /*break*/, 1];
case 6:
res();
return [3 /*break*/, 8];
case 7:
res();
return [3 /*break*/, 9];
case 8:
e_1 = _a.sent();
reject(e_1);
return [3 /*break*/, 9];
case 9: return [2 /*return*/];
return [3 /*break*/, 8];
case 8: return [2 /*return*/];
}

@@ -177,2 +185,3 @@ });

_a.sent();
log('All services started');
return [2 /*return*/];

@@ -179,0 +188,0 @@ }

@@ -9,2 +9,3 @@ import path from 'path';

} from '@sapphirecode/tasks';
import debug from 'debug';
import { Store } from './store';

@@ -16,2 +17,4 @@ import { exec_command } from './exec';

const log = debug ('sapphirecode:docker-compose-backup:commands');
async function init_structure (store: Store): Promise<void> {

@@ -25,2 +28,9 @@ await store.read_docker_status ();

function check_startable (dependencies: string[], started: string[]): boolean {
const sublog = log.extend ('check_startable');
const missing = dependencies.filter ((dep) => !started.includes (dep));
sublog ('Startable:', missing.length === 0, 'missing:', missing);
return missing.length === 0;
}
export async function do_up (

@@ -56,2 +66,4 @@ store: Store,

log ('Queue:', queue.map ((s) => s.name));
const threads = [];

@@ -65,9 +77,7 @@ for (let i = 0; i < 4; i++) {

assert (typeof service !== 'undefined');
let waiting_for = 0;
do {
waiting_for = service.depends_on.filter (
(dep) => started.indexOf (dep) < 0
).length;
log (`Checking ${service.name}`);
while (!check_startable (service.depends_on, started))
await delay (100);
} while (waiting_for > 0);
log (`Starting ${service.name}`);
await service?.up ();

@@ -83,2 +93,3 @@ }

await Promise.all (threads);
log ('All services started');
}

@@ -85,0 +96,0 @@

{
"name": "@sapphirecode/dcm",
"version": "1.2.1",
"version": "1.2.2",
"main": "index.js",

@@ -26,2 +26,3 @@ "description": "Managing docker compose configurations, volumes and networks",

"@sapphirecode/eslint-config-ts": "^1.2.2",
"@types/debug": "^4.1.12",
"@types/dockerode": "^3.3.23",

@@ -53,2 +54,3 @@ "@types/jasmine": "^5.1.4",

"class-validator": "^0.14.0",
"debug": "^4.3.4",
"dockerode": "^4.0.0",

@@ -55,0 +57,0 @@ "reflect-metadata": "^0.1.13",

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