Skip to content

Commit 3aa1fc6

Browse files
jackiewmachariawangoimachariatoken-generator-app[bot]
authored
fix: implement fallbacks to fix terminal-link vscode hyperlinks (#4456)
* fix: implement fallbacks to fix terminal-link vscode hyperlinks Co-authored-by: wangoimacharia <[email protected]> Co-authored-by: token-generator-app[bot] <token-generator-app[bot]@users.noreply.github.com>
1 parent e9c1789 commit 3aa1fc6

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

src/commands/sites/sites-create-template.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ const inquirer = require('inquirer')
55
const pick = require('lodash/pick')
66
const parseGitHubUrl = require('parse-github-url')
77
const prettyjson = require('prettyjson')
8-
const terminalLink = require('terminal-link')
98

10-
const { chalk, error, getRepoData, log, logJson, track, warn } = require('../../utils')
9+
const { chalk, error, getRepoData, getTerminalLink, log, logJson, track, warn } = require('../../utils')
1110
const { configureRepo } = require('../../utils/init/config')
1211
const { getGitHubToken } = require('../../utils/init/config-github')
1312
const { createRepo, getTemplatesFromGitHub, validateTemplate } = require('../../utils/sites/utils')
@@ -77,7 +76,7 @@ const sitesCreateTemplate = async (repository, options, command) => {
7776
if (!exists) {
7877
const githubLink = getGitHubLink({ options, templateName })
7978
error(
80-
`Could not find template ${chalk.bold(templateName)}. Please verify it exists and you can ${terminalLink(
79+
`Could not find template ${chalk.bold(templateName)}. Please verify it exists and you can ${getTerminalLink(
8180
'access to it on GitHub',
8281
githubLink,
8382
)}`,
@@ -86,7 +85,7 @@ const sitesCreateTemplate = async (repository, options, command) => {
8685
}
8786
if (!isTemplate) {
8887
const githubLink = getGitHubLink({ options, templateName })
89-
error(`${terminalLink(chalk.bold(templateName), githubLink)} is not a valid GitHub template`)
88+
error(`${getTerminalLink(chalk.bold(templateName), githubLink)} is not a valid GitHub template`)
9089
return
9190
}
9291

src/lib/exec-fetcher.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ const process = require('process')
44

55
const { fetchLatest, fetchVersion, newerVersion, updateAvailable } = require('gh-release-fetch')
66
const isExe = require('isexe')
7-
const terminalLink = require('terminal-link')
87

98
// cannot directly import from ../utils as it would create a circular dependency.
109
// the file `src/utils/live-tunnel.js` depends on this file
11-
const { NETLIFYDEVWARN, error, log } = require('../utils/command-helpers')
10+
const { NETLIFYDEVWARN, error, getTerminalLink, log } = require('../utils/command-helpers')
1211
const execa = require('../utils/execa')
1312

1413
const isWindows = () => process.platform === 'win32'
@@ -125,7 +124,7 @@ const fetchLatestVersion = async ({ destination, execName, extension, latestVers
125124
`${execName} is not supported on ${platform} with CPU architecture ${arch}`,
126125
)
127126

128-
const issueLink = terminalLink('Create a new CLI issue', createIssueLink.href)
127+
const issueLink = getTerminalLink('Create a new CLI issue', createIssueLink.href)
129128

130129
error(`The operating system ${platform} with the CPU architecture ${arch} is currently not supported!
131130

src/lib/functions/registry.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@ const { mkdir } = require('fs').promises
33
const { extname, isAbsolute, join } = require('path')
44
const { env } = require('process')
55

6-
const terminalLink = require('terminal-link')
7-
8-
const { NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, log, warn, watchDebounced } = require('../../utils')
6+
const {
7+
NETLIFYDEVERR,
8+
NETLIFYDEVLOG,
9+
NETLIFYDEVWARN,
10+
chalk,
11+
getTerminalLink,
12+
log,
13+
warn,
14+
watchDebounced,
15+
} = require('../../utils')
916
const { getLogMessage } = require('../log')
1017

1118
const { NetlifyFunction } = require('./netlify-function')
@@ -152,7 +159,7 @@ class FunctionsRegistry {
152159
this.functions.set(name, func)
153160
this.buildFunctionAndWatchFiles(func)
154161

155-
log(`${NETLIFYDEVLOG} ${chalk.green('Loaded')} function ${terminalLink(chalk.yellow(name), func.url)}.`)
162+
log(`${NETLIFYDEVLOG} ${chalk.green('Loaded')} function ${getTerminalLink(chalk.yellow(name), func.url)}.`)
156163
}
157164

158165
async scan(relativeDirs) {

src/utils/command-helpers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const WSL = require('is-wsl')
1010
const debounce = require('lodash/debounce')
1111
const { default: omit } = require('omit.js')
1212
const pEvent = require('p-event')
13+
const terminalLink = require('terminal-link')
1314

1415
const { name, version } = require('../../package.json')
1516
const { clearSpinner, startSpinner } = require('../lib/spinner')
@@ -230,11 +231,14 @@ const watchDebounced = async (target, { depth, onAdd = () => {}, onChange = () =
230231
return watcher
231232
}
232233

234+
const getTerminalLink = (text, url) => terminalLink(text, url, { fallback: () => `${text} ${url}` })
235+
233236
module.exports = {
234237
BANG,
235238
chalk,
236239
error,
237240
exit,
241+
getTerminalLink,
238242
getToken,
239243
log,
240244
logJson,

0 commit comments

Comments
 (0)