Skip to content
Merged
7 changes: 3 additions & 4 deletions src/commands/sites/sites-create-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ const inquirer = require('inquirer')
const pick = require('lodash/pick')
const parseGitHubUrl = require('parse-github-url')
const prettyjson = require('prettyjson')
const terminalLink = require('terminal-link')

const { chalk, error, getRepoData, log, logJson, track, warn } = require('../../utils')
const { chalk, error, getRepoData, getTerminalLink, log, logJson, track, warn } = require('../../utils')
const { configureRepo } = require('../../utils/init/config')
const { getGitHubToken } = require('../../utils/init/config-github')
const { createRepo, getTemplatesFromGitHub, validateTemplate } = require('../../utils/sites/utils')
Expand Down Expand Up @@ -77,7 +76,7 @@ const sitesCreateTemplate = async (repository, options, command) => {
if (!exists) {
const githubLink = getGitHubLink({ options, templateName })
error(
`Could not find template ${chalk.bold(templateName)}. Please verify it exists and you can ${terminalLink(
`Could not find template ${chalk.bold(templateName)}. Please verify it exists and you can ${getTerminalLink(
'access to it on GitHub',
githubLink,
)}`,
Expand All @@ -86,7 +85,7 @@ const sitesCreateTemplate = async (repository, options, command) => {
}
if (!isTemplate) {
const githubLink = getGitHubLink({ options, templateName })
error(`${terminalLink(chalk.bold(templateName), githubLink)} is not a valid GitHub template`)
error(`${getTerminalLink(chalk.bold(templateName), githubLink)} is not a valid GitHub template`)
return
}

Expand Down
5 changes: 2 additions & 3 deletions src/lib/exec-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ const process = require('process')

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

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

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

const issueLink = terminalLink('Create a new CLI issue', createIssueLink.href)
const issueLink = getTerminalLink('Create a new CLI issue', createIssueLink.href)

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

Expand Down
15 changes: 11 additions & 4 deletions src/lib/functions/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ const { mkdir } = require('fs').promises
const { extname, isAbsolute, join } = require('path')
const { env } = require('process')

const terminalLink = require('terminal-link')

const { NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, log, warn, watchDebounced } = require('../../utils')
const {
NETLIFYDEVERR,
NETLIFYDEVLOG,
NETLIFYDEVWARN,
chalk,
getTerminalLink,
log,
warn,
watchDebounced,
} = require('../../utils')
const { getLogMessage } = require('../log')

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

log(`${NETLIFYDEVLOG} ${chalk.green('Loaded')} function ${terminalLink(chalk.yellow(name), func.url)}.`)
log(`${NETLIFYDEVLOG} ${chalk.green('Loaded')} function ${getTerminalLink(chalk.yellow(name), func.url)}.`)
}

async scan(relativeDirs) {
Expand Down
4 changes: 4 additions & 0 deletions src/utils/command-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const WSL = require('is-wsl')
const debounce = require('lodash/debounce')
const { default: omit } = require('omit.js')
const pEvent = require('p-event')
const terminalLink = require('terminal-link')

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

const getTerminalLink = (text, url) => terminalLink(text, url, { fallback: () => `${text} ${url}` })

module.exports = {
BANG,
chalk,
error,
exit,
getTerminalLink,
getToken,
log,
logJson,
Expand Down