From cdc2707b944a1f5156568e72876cfa4803ba222e Mon Sep 17 00:00:00 2001 From: Florian Richter Date: Wed, 8 Jan 2020 17:45:43 +0100 Subject: [PATCH] Replace boxen with simpler implementation (#44) --- package.json | 1 - src/utils/message-formatter.ts | 18 +++--------------- yarn.lock | 28 +--------------------------- 3 files changed, 4 insertions(+), 43 deletions(-) diff --git a/package.json b/package.json index 824eda03..a27879e9 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "@oclif/plugin-not-found": "^1.2.3", "@oclif/plugin-warn-if-update-available": "^1.7.0", "@sap/cloud-sdk-generator": ">=1.14.0", - "boxen": "^4.2.0", "cli-ux": "^5.4.1", "execa": "^3.4.0", "fast-glob": "^3.1.1", diff --git a/src/utils/message-formatter.ts b/src/utils/message-formatter.ts index e59c147e..f61e5fbd 100644 --- a/src/utils/message-formatter.ts +++ b/src/utils/message-formatter.ts @@ -2,20 +2,8 @@ * Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. */ -// The boxen dependency creates this warning in ci: Opening `/dev/tty` failed (6): Device not configured -// It is likely an issue of github actions: https://github.com/actions/runner/issues/241 -// If this becomes an issue we will have to consider other solutions than boxen -import boxen = require('boxen'); - export function boxMessage(lines: string[]): string { - return boxen(lines.join('\n'), { - borderStyle: { - topLeft: '+', - topRight: '+', - bottomLeft: '+', - bottomRight: '+', - horizontal: '-', - vertical: ' ' - } - }); + const lineLength = lines.reduce((prev, curr) => (prev < curr.length ? curr.length : prev), 0); + const sep = `+${[...Array(lineLength)].map(() => '-').join('')}+`; + return ['', sep, ...lines.map(line => ` ${line} `), sep].join('\n'); } diff --git a/yarn.lock b/yarn.lock index 98d0b8cb..d99c1fbd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1076,20 +1076,6 @@ boxen@^3.0.0: type-fest "^0.3.0" widest-line "^2.0.0" -boxen@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/boxen/-/boxen-4.2.0.tgz#e411b62357d6d6d36587c8ac3d5d974daa070e64" - integrity sha512-eB4uT9RGzg2odpER62bBwSLvUeGC+WbRjjyyFhGsKnc8wp/m0+hQsMUvUe3H2V0D5vw0nBdO1hCJoZo5mKeuIQ== - dependencies: - ansi-align "^3.0.0" - camelcase "^5.3.1" - chalk "^3.0.0" - cli-boxes "^2.2.0" - string-width "^4.1.0" - term-size "^2.1.0" - type-fest "^0.8.1" - widest-line "^3.1.0" - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -5546,7 +5532,7 @@ string-width@^3.0.0, string-width@^3.1.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" -string-width@^4.0.0, string-width@^4.1.0: +string-width@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== @@ -5723,11 +5709,6 @@ term-size@^1.2.0: dependencies: execa "^0.7.0" -term-size@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/term-size/-/term-size-2.1.1.tgz#f81ec25854af91a480d2f9d0c77ffcb26594ed1a" - integrity sha512-UqvQSch04R+69g4RDhrslmGvGL3ucDRX/U+snYW0Mab4uCAyKSndUksaoqlJ81QKSpRnIsuOYQCbC2ZWx2896A== - terminal-link@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/terminal-link/-/terminal-link-2.1.1.tgz#14a64a27ab3c0df933ea546fba55f2d078edc994" @@ -6266,13 +6247,6 @@ widest-line@^2.0.0, widest-line@^2.0.1: dependencies: string-width "^2.1.1" -widest-line@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-3.1.0.tgz#8292333bbf66cb45ff0de1603b136b7ae1496eca" - integrity sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg== - dependencies: - string-width "^4.0.0" - winston-transport@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.3.0.tgz#df68c0c202482c448d9b47313c07304c2d7c2c66"