1
1
import { readFile } from 'fs/promises'
2
- import path from 'path'
2
+ import path , { join } from 'path'
3
3
import { promisify } from 'util'
4
4
5
5
import fromArray from 'from2-array'
6
6
import pumpModule from 'pump'
7
7
8
+ import { INTERNAL_FUNCTIONS_FOLDER } from '../functions/functions.mjs'
9
+
8
10
import { hasherCtor , manifestCollectorCtor } from './hasher-segments.mjs'
9
11
10
12
const pump = promisify ( pumpModule )
@@ -65,7 +67,12 @@ const getFunctionZips = async ({
65
67
66
68
const { zipFunctions } = await import ( '@netlify/zip-it-and-ship-it' )
67
69
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
+ } )
69
76
}
70
77
71
78
const hashFns = async (
@@ -100,7 +107,7 @@ const hashFns = async (
100
107
statusCb,
101
108
tmpDir,
102
109
} )
103
- const fileObjs = functionZips . map ( ( { path : functionPath , runtime } ) => ( {
110
+ const fileObjs = functionZips . map ( ( { displayName , path : functionPath , runtime } ) => ( {
104
111
filepath : functionPath ,
105
112
root : tmpDir ,
106
113
relname : path . relative ( tmpDir , functionPath ) ,
@@ -110,7 +117,11 @@ const hashFns = async (
110
117
assetType : 'function' ,
111
118
normalizedPath : path . basename ( functionPath , path . extname ( functionPath ) ) ,
112
119
runtime,
120
+ displayName,
113
121
} ) )
122
+ const fnConfig = functionZips
123
+ . filter ( ( func ) => Boolean ( func . displayName ) )
124
+ . reduce ( ( funcs , curr ) => ( { ...funcs , [ curr . name ] : { display_name : curr . displayName } } ) , { } )
114
125
const functionSchedules = functionZips
115
126
. map ( ( { name, schedule } ) => schedule && { name, cron : schedule } )
116
127
. filter ( Boolean )
@@ -130,8 +141,7 @@ const hashFns = async (
130
141
const manifestCollector = manifestCollectorCtor ( functions , fnShaMap , { statusCb, assetType } )
131
142
132
143
await pump ( functionStream , hasher , manifestCollector )
133
-
134
- return { functionSchedules, functions, functionsWithNativeModules, fnShaMap }
144
+ return { functionSchedules, functions, functionsWithNativeModules, fnShaMap, fnConfig }
135
145
}
136
146
137
147
export default hashFns
0 commit comments