@@ -15,6 +15,11 @@ const getNextRuntimeVersion = async (packageJsonPath: string, useNodeModulesPath
15
15
return useNodeModulesPath ? packagePlugin . version : packagePlugin . dependencies [ NEXT_PLUGIN ]
16
16
}
17
17
18
+ // Getting the path to the nextjs-plugin package.json file
19
+ const nodeModulesPath = resolveModuleRoot ( NEXT_PLUGIN ) ? join ( resolveModuleRoot ( NEXT_PLUGIN ) , 'package.json' ) : null
20
+ const pluginPackagePath = '.netlify/plugins/package.json'
21
+
22
+
18
23
// The information needed to create a function configuration file
19
24
export interface FunctionInfo {
20
25
// The name of the function, e.g. `___netlify-handler`
@@ -34,9 +39,6 @@ export interface FunctionInfo {
34
39
*/
35
40
export const writeFunctionConfiguration = async ( functionInfo : FunctionInfo ) => {
36
41
const { functionName, functionTitle, functionsDir } = functionInfo
37
- const pluginPackagePath = '.netlify/plugins/package.json'
38
- const moduleRoot = resolveModuleRoot ( NEXT_PLUGIN )
39
- const nodeModulesPath = moduleRoot ? join ( moduleRoot , 'package.json' ) : null
40
42
41
43
const nextPluginVersion =
42
44
( await getNextRuntimeVersion ( nodeModulesPath , true ) ) ||
@@ -54,3 +56,13 @@ export const writeFunctionConfiguration = async (functionInfo: FunctionInfo) =>
54
56
55
57
await writeFile ( join ( functionsDir , functionName , `${ functionName } .json` ) , JSON . stringify ( metadata ) )
56
58
}
59
+
60
+ export const writeEdgeFunctionConfiguration = async ( ) => {
61
+ const nextPluginVersion =
62
+ ( await getNextRuntimeVersion ( nodeModulesPath , true ) ) ||
63
+ ( await getNextRuntimeVersion ( pluginPackagePath , false ) ) ||
64
+ // The runtime version should always be available, but if it's not, return 'unknown'
65
+ 'unknown'
66
+
67
+ return `${ NEXT_PLUGIN_NAME } @${ nextPluginVersion } `
68
+ }
0 commit comments