Remove ansi-escapes from cli-kit (inline OSC-8 hyperlink) - #7722
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the ansi-escapes dependency from @shopify/cli-kit by inlining a small OSC-8 hyperlink helper and switching the two prior call sites over to it, with corresponding dependency/lockfile updates.
Changes:
- Removed
ansi-escapesfrompackages/cli-kit/package.json. - Replaced
ansiEscapes.link(...)usage with a localosc8Link(...)helper in the Ink<Link>component and inLinkContentToken. - Updated
pnpm-lock.yamlto reflect the dependency change (and additional lockfile rewrites).
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
pnpm-lock.yaml |
Removes ansi-escapes from the packages/cli-kit importer entry and updates lockfile entries. |
packages/cli-kit/src/private/node/ui/components/Link.tsx |
Inlines osc8Link and replaces the previous ansiEscapes.link call for terminal hyperlink rendering. |
packages/cli-kit/src/private/node/content-tokens.ts |
Inlines osc8Link and replaces the previous ansiEscapes.link call for hyperlink content tokens. |
packages/cli-kit/package.json |
Drops the direct ansi-escapes dependency from @shopify/cli-kit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "ajv": "8.18.0", | ||
| "ansi-escapes": "6.2.1", | ||
| "archiver": "5.3.2", | ||
| "archiver": "5.3.2", | ||
| "bottleneck": "2.19.5", |
| function osc8Link(text: string, url: string): string { | ||
| return `\x1b]8;;${url}\x07${text}\x1b]8;;\x07` | ||
| } |
| function osc8Link(text: string, url: string): string { | ||
| return `\x1b]8;;${url}\x07${text}\x1b]8;;\x07` | ||
| } |
| '@ast-grep/napi-linux-arm64-gnu@0.33.0': | ||
| resolution: {integrity: sha512-3ZnA2k57kxfvLg4s9+6rHaCx1FbWt0EF8fumJMf5nwevu7GbVOOhCkzAetZe80FBgZuIOSR4IS2QMj9ZHI0UdQ==, tarball: https://registry.npmjs.org/@ast-grep/napi-linux-arm64-gnu/-/napi-linux-arm64-gnu-0.33.0.tgz} | ||
| resolution: {integrity: sha512-3ZnA2k57kxfvLg4s9+6rHaCx1FbWt0EF8fumJMf5nwevu7GbVOOhCkzAetZe80FBgZuIOSR4IS2QMj9ZHI0UdQ==} | ||
| engines: {node: '>= 10'} | ||
| cpu: [arm64] | ||
| os: [linux] |
Co-Authored-By: Claude <noreply@anthropic.com>
b0b30ee to
3ef7855
Compare
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationspackages/cli-kit/dist/private/node/hyperlink.d.ts/**
* Wraps `text` in an OSC-8 terminal hyperlink escape sequence pointing at `url`.
*
* See https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda for the
* OSC-8 spec. The terminal must support hyperlinks for this to render as a link;
* callers should gate on `supports-hyperlinks` before using it.
*/
export declare function osc8Link(text: string, url: string): string;
Existing type declarationsWe found no diffs with existing type declarations |
|
This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. |
What
Removes the
ansi-escapesnpm dependency from@shopify/cli-kitand replaces its only usage with a self-contained 3-line OSC-8 hyperlink helper.Why
ansi-escapeshas generated 52 Dependabot version bumps over 24 months in this repo. The only API used isansiEscapes.link(text, url), which is a trivial OSC-8 escape sequence. Inlining it eliminates the dependency entirely, reducing Dependabot churn with no functional change.Implementation
The replacement helper (BEL terminator variant, matches the original library's output):
Applied to:
packages/cli-kit/src/private/node/ui/components/Link.tsxpackages/cli-kit/src/private/node/content-tokens.tsPlatform/terminal hyperlink support detection continues to be handled externally by
supports-hyperlinks— no change to that logic.Validation
pnpm --filter @shopify/cli-kit type-check— passespnpm --filter @shopify/cli-kit lint— passespnpm --filter @shopify/cli-kit exec vitest run— Link + content-tokens tests: 10/10 passing🤖 Automated dependency-removal initiative — AI-generated draft, needs human review.