From 93cd579269717934b2b8e72d6258b712c1675eaa Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 22 Jun 2023 04:15:19 +0200 Subject: [PATCH] Switch to ansi_up for ansi rendering in actions (#25401) Fixes: https://github.com/go-gitea/gitea/issues/24777 --- package-lock.json | 32 ++++--------- package.json | 2 +- web_src/js/components/RepoActionView.test.js | 30 ------------ web_src/js/components/RepoActionView.vue | 48 +------------------- web_src/js/render/ansi.js | 44 ++++++++++++++++++ web_src/js/render/ansi.test.js | 21 +++++++++ 6 files changed, 77 insertions(+), 100 deletions(-) delete mode 100644 web_src/js/components/RepoActionView.test.js create mode 100644 web_src/js/render/ansi.js create mode 100644 web_src/js/render/ansi.test.js diff --git a/package-lock.json b/package-lock.json index e808ccf2a8..43846cf4a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@primer/octicons": "19.3.0", "@webcomponents/custom-elements": "1.6.0", "add-asset-webpack-plugin": "2.0.1", - "ansi-to-html": "0.7.2", + "ansi_up": "5.2.1", "asciinema-player": "3.4.0", "clippie": "4.0.1", "css-loader": "6.8.1", @@ -2465,6 +2465,14 @@ "ajv": "^8.8.2" } }, + "node_modules/ansi_up": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/ansi_up/-/ansi_up-5.2.1.tgz", + "integrity": "sha512-5bz5T/7FRmlxA37zDXhG6cAwlcZtfnmNLDJra66EEIT3kYlw5aPJdbkJEhm59D6kA4Wi5ict6u6IDYHJaQlH+g==", + "engines": { + "node": "*" + } + }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -2487,20 +2495,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/ansi-to-html": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/ansi-to-html/-/ansi-to-html-0.7.2.tgz", - "integrity": "sha512-v6MqmEpNlxF+POuyhKkidusCHWWkaLcGRURzivcU3I9tv7k4JVhFcnukrM5Rlk2rUywdZuzYAZ+kbZqWCnfN3g==", - "dependencies": { - "entities": "^2.2.0" - }, - "bin": { - "ansi-to-html": "bin/ansi-to-html" - }, - "engines": { - "node": ">=8.0.0" - } - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -4210,14 +4204,6 @@ "node": ">=10.13.0" } }, - "node_modules/entities": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, "node_modules/envinfo": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", diff --git a/package.json b/package.json index 0701862cc2..dd2eff7195 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@primer/octicons": "19.3.0", "@webcomponents/custom-elements": "1.6.0", "add-asset-webpack-plugin": "2.0.1", - "ansi-to-html": "0.7.2", + "ansi_up": "5.2.1", "asciinema-player": "3.4.0", "clippie": "4.0.1", "css-loader": "6.8.1", diff --git a/web_src/js/components/RepoActionView.test.js b/web_src/js/components/RepoActionView.test.js deleted file mode 100644 index 011c20d8d1..0000000000 --- a/web_src/js/components/RepoActionView.test.js +++ /dev/null @@ -1,30 +0,0 @@ -import {expect, test} from 'vitest'; - -import {ansiLogToHTML} from './RepoActionView.vue'; -import AnsiToHTML from 'ansi-to-html'; - -test('processConsoleLine', () => { - expect(ansiLogToHTML('abc')).toEqual('abc'); - expect(ansiLogToHTML('abc\n')).toEqual('abc'); - expect(ansiLogToHTML('abc\r\n')).toEqual('abc'); - expect(ansiLogToHTML('\r')).toEqual(''); - expect(ansiLogToHTML('\rx\rabc')).toEqual('x\nabc'); - expect(ansiLogToHTML('\rabc\rx\r')).toEqual('abc\nx'); - - expect(ansiLogToHTML('\x1b[30mblack\x1b[37mwhite')).toEqual('blackwhite'); - expect(ansiLogToHTML('