From 6632fff831babf1be52b96adb87f4e2179f5ecfc Mon Sep 17 00:00:00 2001 From: Ryan Bahan Date: Thu, 2 Apr 2026 19:10:02 -0600 Subject: [PATCH] Remove terminal-link, use existing ansi-escapes and supports-hyperlinks The single call site in content-tokens.ts is replaced with a direct check of supportsHyperlinks.stdout and ansiEscapes.link(), both of which are already dependencies used by the Link.tsx component. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/cli-kit/package.json | 1 - .../src/private/node/content-tokens.ts | 8 ++++++-- pnpm-lock.yaml | 20 ------------------- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/packages/cli-kit/package.json b/packages/cli-kit/package.json index c0f8ada24dd..abcb38f0c36 100644 --- a/packages/cli-kit/package.json +++ b/packages/cli-kit/package.json @@ -156,7 +156,6 @@ "stacktracey": "2.1.8", "strip-ansi": "7.1.0", "supports-hyperlinks": "3.1.0", - "terminal-link": "3.0.0", "ts-error": "1.0.6", "which": "4.0.0", "zod": "3.24.4" diff --git a/packages/cli-kit/src/private/node/content-tokens.ts b/packages/cli-kit/src/private/node/content-tokens.ts index 932c53389c0..5f2cbb5eee3 100644 --- a/packages/cli-kit/src/private/node/content-tokens.ts +++ b/packages/cli-kit/src/private/node/content-tokens.ts @@ -1,7 +1,8 @@ import colors from '../../public/node/colors.js' import {OutputMessage, stringifyMessage} from '../../public/node/output.js' import {relativizePath} from '../../public/node/path.js' -import terminalLink from 'terminal-link' +import ansiEscapes from 'ansi-escapes' +import supportsHyperlinks from 'supports-hyperlinks' import cjs from 'color-json' import type {Change} from 'diff' @@ -35,7 +36,10 @@ export class LinkContentToken extends ContentToken { const text = colors.green(stringifyMessage(this.value)) const url = this.link ?? '' const defaultFallback = this.value === this.link ? text : `${text} ( ${url} )` - return terminalLink(text, url, {fallback: () => this.fallback ?? defaultFallback}) + if (supportsHyperlinks.stdout) { + return ansiEscapes.link(text, url) + } + return this.fallback ?? defaultFallback } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index de8fba7428c..6d6ac541a03 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -465,9 +465,6 @@ importers: supports-hyperlinks: specifier: 3.1.0 version: 3.1.0 - terminal-link: - specifier: 3.0.0 - version: 3.0.0 ts-error: specifier: 1.0.6 version: 1.0.6 @@ -4270,10 +4267,6 @@ packages: resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} engines: {node: '>=8'} - ansi-escapes@5.0.0: - resolution: {integrity: sha512-5GFMVX8HqE/TB+FuBJGuO5XG0WrsA6ptUqoODaT/n9mmUaZFkqnBueB4leqGBCmrUHnCnC4PCZTCd0E7QQ83bA==} - engines: {node: '>=12'} - ansi-escapes@6.2.1: resolution: {integrity: sha512-4nJ3yixlEthEJ9Rk4vPcdBRkZvQZlYyu8j4/Mqz5sgIkddmEnH2Yj2ZrnP9S3tQOvSNRUIgVNF/1yPpRAGNRig==} engines: {node: '>=14.16'} @@ -8228,10 +8221,6 @@ packages: resolution: {integrity: sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==} engines: {node: '>=8'} - terminal-link@3.0.0: - resolution: {integrity: sha512-flFL3m4wuixmf6IfhFJd1YPiLiMuxEc8uHRM1buzIeZPm22Au2pDqBJQgdo7n1WfPU1ONFGv7YDwpFBmHGF6lg==} - engines: {node: '>=12'} - terminal-size@4.0.1: resolution: {integrity: sha512-avMLDQpUI9I5XFrklECw1ZEUPJhqzcwSWsyyI8blhRLT+8N1jLJWLWWYQpB2q2xthq8xDvjZPISVh53T/+CLYQ==} engines: {node: '>=18'} @@ -13609,10 +13598,6 @@ snapshots: dependencies: type-fest: 0.21.3 - ansi-escapes@5.0.0: - dependencies: - type-fest: 1.4.0 - ansi-escapes@6.2.1: {} ansi-escapes@7.3.0: @@ -18086,11 +18071,6 @@ snapshots: term-size@2.2.1: {} - terminal-link@3.0.0: - dependencies: - ansi-escapes: 5.0.0 - supports-hyperlinks: 3.1.0 - terminal-size@4.0.1: {} test-exclude@7.0.2: