Skip to content

Commit 6cee5bc

Browse files
authored
feat: show displayName for any function that has one being run with ntl dev (#5444)
* feat: show displayName for any function that has one being run with ntl dev * fix: change .netlify to use getPathInHome * fix: change getPathInHome to getPathInProject for registry and hash-fns
1 parent cd9ebf8 commit 6cee5bc

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/lib/functions/netlify-function.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default class NetlifyFunction {
1818
constructor({
1919
config,
2020
directory,
21+
displayName,
2122
mainFile,
2223
name,
2324
projectRoot,
@@ -31,6 +32,7 @@ export default class NetlifyFunction {
3132
this.errorExit = errorExit
3233
this.mainFile = mainFile
3334
this.name = name
35+
this.displayName = displayName
3436
this.projectRoot = projectRoot
3537
this.runtime = runtime
3638
this.timeoutBackground = timeoutBackground

src/lib/functions/registry.mjs

+10-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
warn,
1515
watchDebounced,
1616
} from '../../utils/command-helpers.mjs'
17-
import { SERVE_FUNCTIONS_FOLDER } from '../../utils/functions/functions.mjs'
17+
import { INTERNAL_FUNCTIONS_FOLDER, SERVE_FUNCTIONS_FOLDER } from '../../utils/functions/functions.mjs'
1818
import { getLogMessage } from '../log.mjs'
1919
import { getPathInProject } from '../settings.mjs'
2020

@@ -164,7 +164,12 @@ export class FunctionsRegistry {
164164
this.functions.set(name, func)
165165
this.buildFunctionAndWatchFiles(func)
166166

167-
log(`${NETLIFYDEVLOG} ${chalk.green('Loaded')} function ${getTerminalLink(chalk.yellow(name), func.url)}.`)
167+
log(
168+
`${NETLIFYDEVLOG} ${chalk.green('Loaded')} function ${getTerminalLink(
169+
chalk.yellow(func.displayName || name),
170+
func.url,
171+
)}.`,
172+
)
168173
}
169174

170175
// This function is here so we can mock it in tests
@@ -191,6 +196,7 @@ export class FunctionsRegistry {
191196
buildRustSource: env.NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE === 'true',
192197
project_deploy_configuration_api_use_per_function_configuration_files: true,
193198
},
199+
configFileDirectories: [getPathInProject([INTERNAL_FUNCTIONS_FOLDER])],
194200
config: this.config.functions,
195201
})
196202

@@ -207,7 +213,7 @@ export class FunctionsRegistry {
207213
await Promise.all(deletedFunctions.map((func) => this.unregisterFunction(func.name)))
208214

209215
await Promise.all(
210-
functions.map(async ({ mainFile, name, runtime: runtimeName }) => {
216+
functions.map(async ({ displayName, mainFile, name, runtime: runtimeName }) => {
211217
const runtime = runtimes[runtimeName]
212218

213219
// If there is no matching runtime, it means this function is not yet
@@ -226,6 +232,7 @@ export class FunctionsRegistry {
226232
directory: directories.find((directory) => mainFile.startsWith(directory)),
227233
mainFile,
228234
name,
235+
displayName,
229236
projectRoot: this.projectRoot,
230237
runtime,
231238
timeoutBackground: this.timeouts.backgroundFunctions,

src/utils/deploy/hash-fns.mjs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { readFile } from 'fs/promises'
2-
import path, { join } from 'path'
2+
import path from 'path'
33
import { promisify } from 'util'
44

55
import fromArray from 'from2-array'
66
import pumpModule from 'pump'
77

8+
import { getPathInProject } from '../../lib/settings.mjs'
89
import { INTERNAL_FUNCTIONS_FOLDER } from '../functions/functions.mjs'
910

1011
import { hasherCtor, manifestCollectorCtor } from './hasher-segments.mjs'
@@ -70,7 +71,7 @@ const getFunctionZips = async ({
7071
return await zipFunctions(directories, tmpDir, {
7172
featureFlags: { project_deploy_configuration_api_use_per_function_configuration_files: true },
7273
basePath: rootDir,
73-
configFileDirectories: [join('.netlify', INTERNAL_FUNCTIONS_FOLDER)],
74+
configFileDirectories: [getPathInProject([INTERNAL_FUNCTIONS_FOLDER])],
7475
config: functionsConfig,
7576
})
7677
}

0 commit comments

Comments
 (0)