From ee3657b95e71352ad232469885fc8dc8b62c815c Mon Sep 17 00:00:00 2001 From: Addie Rudy Date: Tue, 23 Jul 2024 13:59:31 -0400 Subject: [PATCH] fix(deploy-cli): Fixed bugs related to ESM conversion Improved CLI text formatting --- cli/config-manage.ts | 6 +++++- cli/consts.ts | 8 ++++---- package.json | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cli/config-manage.ts b/cli/config-manage.ts index 1584d6d..e2c707a 100644 --- a/cli/config-manage.ts +++ b/cli/config-manage.ts @@ -3,8 +3,12 @@ import { type DeployConfig } from '../lib/shared/common/deploy-config' import { formatText } from './consts' import prompt from 'prompt-sync' import { CONFIG_VERSION } from './config-version' -import path from 'path' +import path, { dirname } from 'path' import figlet from 'figlet' +import { fileURLToPath } from 'url' +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) + const deployConfig = path.join(__dirname, '../bin/config.json') const prompter = prompt({ sigint: true }) diff --git a/cli/consts.ts b/cli/consts.ts index 98234fc..adf3c84 100644 --- a/cli/consts.ts +++ b/cli/consts.ts @@ -1,4 +1,4 @@ -import * as ansi from 'ansi-escape-sequences' +import ansi from 'ansi-escape-sequences' interface FormattingOptions { bigHeader?: boolean @@ -59,7 +59,7 @@ export const formatText = ( let outputText = '' const styles: ansi.Style[] = [] if (formatting.bold === true) { - styles.push(ansi.style.bold as ansi.Style) + styles.push('bold') } if (formatting.textColor !== undefined) { styles.push(formatting.textColor) @@ -68,10 +68,10 @@ export const formatText = ( styles.push(formatting.backgroundColor) } if (formatting.italic === true) { - styles.push(ansi.style.italic as ansi.Style) + styles.push('italic') } if (formatting.underline === true) { - styles.push(ansi.style.underline as ansi.Style) + styles.push('underline') } if (styles.length > 0) { outputText = ansi.format(text, styles) diff --git a/package.json b/package.json index 22f3e0a..328cd6d 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.2.0", "type": "module", "scripts": { - "config": "node -r ts-node/register ./cli/config.ts", + "config": "tsx ./cli/config.ts", "build": "tsc && npm run codegen && npm run build:appsync && npm run build:ui", "build:ui": "cd lib/user-interface/genai-newsletter-ui/ && vite build", "build:appsync": "tsx ./lib/api/functions/bundle.ts",