Skip to content

Commit

Permalink
feat: show displayName for any function that has one being run with n…
Browse files Browse the repository at this point in the history
…tl 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
  • Loading branch information
khendrikse authored Feb 1, 2023
1 parent cd9ebf8 commit 6cee5bc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/lib/functions/netlify-function.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class NetlifyFunction {
constructor({
config,
directory,
displayName,
mainFile,
name,
projectRoot,
Expand All @@ -31,6 +32,7 @@ export default class NetlifyFunction {
this.errorExit = errorExit
this.mainFile = mainFile
this.name = name
this.displayName = displayName
this.projectRoot = projectRoot
this.runtime = runtime
this.timeoutBackground = timeoutBackground
Expand Down
13 changes: 10 additions & 3 deletions src/lib/functions/registry.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
warn,
watchDebounced,
} from '../../utils/command-helpers.mjs'
import { SERVE_FUNCTIONS_FOLDER } from '../../utils/functions/functions.mjs'
import { INTERNAL_FUNCTIONS_FOLDER, SERVE_FUNCTIONS_FOLDER } from '../../utils/functions/functions.mjs'
import { getLogMessage } from '../log.mjs'
import { getPathInProject } from '../settings.mjs'

Expand Down Expand Up @@ -164,7 +164,12 @@ export class FunctionsRegistry {
this.functions.set(name, func)
this.buildFunctionAndWatchFiles(func)

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

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

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

await Promise.all(
functions.map(async ({ mainFile, name, runtime: runtimeName }) => {
functions.map(async ({ displayName, mainFile, name, runtime: runtimeName }) => {
const runtime = runtimes[runtimeName]

// If there is no matching runtime, it means this function is not yet
Expand All @@ -226,6 +232,7 @@ export class FunctionsRegistry {
directory: directories.find((directory) => mainFile.startsWith(directory)),
mainFile,
name,
displayName,
projectRoot: this.projectRoot,
runtime,
timeoutBackground: this.timeouts.backgroundFunctions,
Expand Down
5 changes: 3 additions & 2 deletions src/utils/deploy/hash-fns.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { readFile } from 'fs/promises'
import path, { join } from 'path'
import path from 'path'
import { promisify } from 'util'

import fromArray from 'from2-array'
import pumpModule from 'pump'

import { getPathInProject } from '../../lib/settings.mjs'
import { INTERNAL_FUNCTIONS_FOLDER } from '../functions/functions.mjs'

import { hasherCtor, manifestCollectorCtor } from './hasher-segments.mjs'
Expand Down Expand Up @@ -70,7 +71,7 @@ const getFunctionZips = async ({
return await zipFunctions(directories, tmpDir, {
featureFlags: { project_deploy_configuration_api_use_per_function_configuration_files: true },
basePath: rootDir,
configFileDirectories: [join('.netlify', INTERNAL_FUNCTIONS_FOLDER)],
configFileDirectories: [getPathInProject([INTERNAL_FUNCTIONS_FOLDER])],
config: functionsConfig,
})
}
Expand Down

1 comment on commit 6cee5bc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

  • Package size: 265 MB

Please sign in to comment.