11import { readFile } from 'fs/promises'
2- import path from 'path'
2+ import path , { join } from 'path'
33import { promisify } from 'util'
44
55import fromArray from 'from2-array'
66import pumpModule from 'pump'
77
8+ import { INTERNAL_FUNCTIONS_FOLDER } from '../functions/functions.mjs'
9+
810import { hasherCtor , manifestCollectorCtor } from './hasher-segments.mjs'
911
1012const pump = promisify ( pumpModule )
@@ -65,7 +67,12 @@ const getFunctionZips = async ({
6567
6668 const { zipFunctions } = await import ( '@netlify/zip-it-and-ship-it' )
6769
68- return await zipFunctions ( directories , tmpDir , { basePath : rootDir , config : functionsConfig } )
70+ return await zipFunctions ( directories , tmpDir , {
71+ featureFlags : { project_deploy_configuration_api_use_per_function_configuration_files : true } ,
72+ basePath : rootDir ,
73+ configFileDirectories : [ join ( '.netlify' , INTERNAL_FUNCTIONS_FOLDER ) ] ,
74+ config : functionsConfig ,
75+ } )
6976}
7077
7178const hashFns = async (
@@ -100,7 +107,7 @@ const hashFns = async (
100107 statusCb,
101108 tmpDir,
102109 } )
103- const fileObjs = functionZips . map ( ( { path : functionPath , runtime } ) => ( {
110+ const fileObjs = functionZips . map ( ( { displayName , path : functionPath , runtime } ) => ( {
104111 filepath : functionPath ,
105112 root : tmpDir ,
106113 relname : path . relative ( tmpDir , functionPath ) ,
@@ -110,7 +117,11 @@ const hashFns = async (
110117 assetType : 'function' ,
111118 normalizedPath : path . basename ( functionPath , path . extname ( functionPath ) ) ,
112119 runtime,
120+ displayName,
113121 } ) )
122+ const fnConfig = functionZips
123+ . filter ( ( func ) => Boolean ( func . displayName ) )
124+ . reduce ( ( funcs , curr ) => ( { ...funcs , [ curr . name ] : { display_name : curr . displayName } } ) , { } )
114125 const functionSchedules = functionZips
115126 . map ( ( { name, schedule } ) => schedule && { name, cron : schedule } )
116127 . filter ( Boolean )
@@ -130,8 +141,7 @@ const hashFns = async (
130141 const manifestCollector = manifestCollectorCtor ( functions , fnShaMap , { statusCb, assetType } )
131142
132143 await pump ( functionStream , hasher , manifestCollector )
133-
134- return { functionSchedules, functions, functionsWithNativeModules, fnShaMap }
144+ return { functionSchedules, functions, functionsWithNativeModules, fnShaMap, fnConfig }
135145}
136146
137147export default hashFns
0 commit comments