Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/remove-ansi-escapes-cli-kit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopify/cli-kit": patch
---

Remove `ansi-escapes` dependency; inline a 3-line OSC-8 hyperlink helper to reduce Dependabot churn.
3 changes: 1 addition & 2 deletions packages/cli-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@
"@opentelemetry/sdk-metrics": "1.30.0",
"@types/archiver": "5.3.2",
"ajv": "8.18.0",
"ansi-escapes": "6.2.1",
"archiver": "5.3.2",
"archiver": "5.3.2",
"bottleneck": "2.19.5",
"chalk": "5.4.1",
"change-case": "4.1.2",
Expand Down
7 changes: 5 additions & 2 deletions packages/cli-kit/src/private/node/content-tokens.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import colors from '../../public/node/colors.js'
import {OutputMessage, stringifyMessage} from '../../public/node/output.js'
import {relativizePath} from '../../public/node/path.js'
import ansiEscapes from 'ansi-escapes'
import supportsHyperlinks from 'supports-hyperlinks'
import cjs from 'color-json'
import type {Change} from 'diff'

function osc8Link(text: string, url: string): string {
return `\x1b]8;;${url}\x07${text}\x1b]8;;\x07`
}

export abstract class ContentToken<T> {
value: T

Expand Down Expand Up @@ -37,7 +40,7 @@ export class LinkContentToken extends ContentToken<OutputMessage> {
const url = this.link ?? ''
const defaultFallback = this.value === this.link ? text : `${text} ( ${url} )`
if (supportsHyperlinks.stdout) {
return ansiEscapes.link(text, url)
return osc8Link(text, url)
}
return this.fallback ?? defaultFallback
}
Expand Down
7 changes: 5 additions & 2 deletions packages/cli-kit/src/private/node/ui/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import {LinksContext, ContextValue as LinksContextValue} from '../contexts/LinksContext.js'
import {Text} from 'ink'
import React, {FunctionComponent, useContext} from 'react'
import ansiEscapes from 'ansi-escapes'
import supportsHyperlinks from 'supports-hyperlinks'
import chalk from 'chalk'

function osc8Link(text: string, url: string): string {
return `\x1b]8;;${url}\x07${text}\x1b]8;;\x07`
}

interface LinkProps {
url: string
label?: string
Expand All @@ -27,7 +30,7 @@ function link(label: string | undefined, url: string, linksContext: LinksContext
return label ? `${label} [${linkId}]` : `[${linkId}]`
}

return ansiEscapes.link(label ?? url, url)
return osc8Link(label ?? url, url)
}

/**
Expand Down
Loading
Loading