From dcc379607b3bb78c12f8c90ed8e651cd3750e437 Mon Sep 17 00:00:00 2001 From: Marco Lipparini <1532277+liarco@users.noreply.github.com> Date: Wed, 19 Jul 2023 12:24:15 +0200 Subject: [PATCH] Fixing broken release (#6) --- package.json | 2 +- src/index.ts | 33 +++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index f81e4a4..a6bcbe9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mep-agency/local-dev-db", - "version": "1.0.0-alpha11", + "version": "1.0.0-alpha12", "private": false, "description": "A zero-config local MariaDB instance for local development (using Docker)", "author": "Marco Lipparini ", diff --git a/src/index.ts b/src/index.ts index dc1358a..14021b8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ import mysql from 'mysql'; import config from './config'; -const PACKAGE_INSTALLATION_PATH = `${__dirname}/../..`; +const LDD_ROOT_PATH = `${__dirname}/..`; interface DockerImagesCommandResult { images: { @@ -21,7 +21,7 @@ interface DockerImagesCommandResult { const dockerCompose: typeof dockerCommand = async (command, options) => { try { return await dockerCommand( - `compose --file "${PACKAGE_INSTALLATION_PATH}/docker/docker-compose.yml" --project-name "ldd" ${command}`, + `compose --file "${LDD_ROOT_PATH}/docker/docker-compose.yml" --project-name "ldd" ${command}`, { echo: false, ...(options ?? {}) }, ); } catch (e: any) { @@ -83,18 +83,27 @@ program `phpmyadmin:${process.env.LDD_PMA_IMAGE_TAG ?? 'latest'}`, ]; - const availableImagesImages = ((await dockerCommand('images', { echo: false })) as DockerImagesCommandResult).images - .map((imageData) => `${imageData.repository}:${imageData.tag}`) - .filter((imageName) => requiredImages.includes(imageName)); + try { + const availableImagesImages = ((await dockerCommand('images', { echo: false })) as DockerImagesCommandResult).images + .map((imageData) => `${imageData.repository}:${imageData.tag}`) + .filter((imageName) => requiredImages.includes(imageName)); - const missingImages = requiredImages.filter((requiredImage) => !availableImagesImages.includes(requiredImage)); + const missingImages = requiredImages.filter((requiredImage) => !availableImagesImages.includes(requiredImage)); - if (missingImages.length > 0) { - console.info(''); - console.info('The following images will be downloaded as they are required but not available:'); - missingImages.map((image) => console.info(` - ${image}`)); - console.info(''); - console.info('This may take some time, please wait...'); + if (missingImages.length > 0) { + console.info(''); + console.info('The following images will be downloaded as they are required but not available:'); + missingImages.map((image) => console.info(` - ${image}`)); + console.info(''); + console.info('This may take some time, please wait...'); + } + } catch (e: any) { + if (e.stderr === undefined) { + throw e; + } + + console.error(`ERROR: ${e.stderr}`); + process.exit(1); } await dockerCompose('up -d');