Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Nov 7, 2024
1 parent 1e9a502 commit 526aa6b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion storage/framework/core/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@
"@stacksjs/types": "workspace:*",
"@stacksjs/utils": "workspace:*",
"@stacksjs/validation": "workspace:*",
"ansi-escapes": "^7.0.0",
"cac": "^6.7.14",
"consola": "^3.2.3",
"kolorist": "1.8.0",
"ora": "^8.1.0",
"prompts": "^2.4.2"
"prompts": "^2.4.2",
"supports-hyperlinks": "^3.1.0"
},
"devDependencies": {
"@stacksjs/development": "workspace:*",
Expand Down
18 changes: 18 additions & 0 deletions storage/framework/core/cli/src/console.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
import { log } from '@stacksjs/logging'
import ansiEscapes from 'ansi-escapes'
import prompts from 'prompts'
import supportsHyperlinks from 'supports-hyperlinks'

export { log, prompts }

// thanks to https://github.com/sindresorhus/terminal-link/blob/main/index.js
// eslint-disable-next-line ts/no-unsafe-function-type
export default function terminalLink(text: string, url: string, { target = 'stdout', ...options }: { target?: string, fallback?: boolean | Function }): string {
// @ts-expect-error - it is not properly typed
if (!supportsHyperlinks[target]) {
// If the fallback has been explicitly disabled, don't modify the text itself.
if (options.fallback === false) {
return text
}

return typeof options.fallback === 'function' ? options.fallback(text, url) : `${text} (\u200B${url}\u200B)`
}

return ansiEscapes.link(text, url)
}

0 comments on commit 526aa6b

Please sign in to comment.