Skip to content

Commit ffffcdb

Browse files
authored
feat: Pass internalSrcFolder and name to zisi (#4821)
* feat: pass internalSrcFolder to zisi and add test * feat: pass functionconfig name and test it * fix: kick CI * test: also check internalSrcFolder path * test: add .serial to fix tests
1 parent 692f582 commit ffffcdb

File tree

9 files changed

+59
-2
lines changed

9 files changed

+59
-2
lines changed

packages/build/src/plugins_core/functions/zisi.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ export const getZisiParameters = ({
2323
const zisiFeatureFlags = getZisiFeatureFlags(featureFlags)
2424
// Only internal functions are allowed to have a json config file
2525
const configFileDirectories = [resolve(internalFunctionsSrc)]
26-
27-
return { basePath: buildDir, config, manifest, featureFlags: zisiFeatureFlags, repositoryRoot, configFileDirectories }
26+
return {
27+
basePath: buildDir,
28+
config,
29+
manifest,
30+
featureFlags: zisiFeatureFlags,
31+
repositoryRoot,
32+
configFileDirectories,
33+
internalSrcFolder: internalFunctionsSrc,
34+
}
2835
}
2936

3037
// The function configuration keys returned by @netlify/config are not an exact
@@ -33,6 +40,7 @@ export const getZisiParameters = ({
3340
export const normalizeFunctionConfig = ({ buildDir, functionConfig = {}, isRunningLocally, nodeVersion }) => ({
3441
externalNodeModules: functionConfig.external_node_modules,
3542
includedFiles: functionConfig.included_files,
43+
name: functionConfig.name,
3644
includedFilesBasePath: buildDir,
3745
ignoredNodeModules: functionConfig.ignored_node_modules,
3846
nodeVersion,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"config": { "nodeBundler": "none", "name": "Function One" },
3+
"version": 1
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"config": { "nodeBundler": "none" },
3+
"version": 1
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"config": { "nodeBundler": "none" },
3+
"version": 1
4+
}

packages/build/tests/core/tests.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,39 @@ test.serial('configFileDirectories is passed to zip-it-and-ship-it', async (t) =
533533
])
534534
})
535535

536+
test.serial('internalSrcFolder is passed to zip-it-and-ship-it', async (t) => {
537+
const zipItAndShipItSpy = sinon.spy(zipItAndShipIt, 'zipFunctions')
538+
539+
await new Fixture('./fixtures/functions_internal_src_folder').withFlags({ mode: 'buildbot' }).runWithBuild()
540+
zipItAndShipItSpy.restore()
541+
const { args: call1Args } = zipItAndShipItSpy.getCall(0)
542+
543+
const { internalSrcFolder, manifest } = call1Args[2]
544+
const { functions } = await importJsonFile(manifest)
545+
546+
t.is(internalSrcFolder, join(FIXTURES_DIR, 'functions_internal_src_folder/.netlify/functions-internal'))
547+
t.is(functions[0].isInternal, true)
548+
t.is(functions[1].isInternal, false)
549+
})
550+
551+
test.serial('functions can have a config with name passed to zip-it-and-ship-it', async (t) => {
552+
const zipItAndShipItSpy = sinon.spy(zipItAndShipIt, 'zipFunctions')
553+
await new Fixture('./fixtures/functions_display_name')
554+
.withFlags({
555+
mode: 'buildbot',
556+
featureFlags: { project_deploy_configuration_api_use_per_function_configuration_files: true },
557+
})
558+
.runWithBuild()
559+
560+
zipItAndShipItSpy.restore()
561+
562+
const { args: call1Args } = zipItAndShipItSpy.getCall(0)
563+
const { functions: functions } = await importJsonFile(call1Args[2].manifest)
564+
565+
t.is(functions[0].displayName, 'Function One')
566+
t.is(functions[1].displayName, undefined)
567+
})
568+
536569
test.serial('zip-it-and-ship-it runs without error when loading json config files', async (t) => {
537570
const output = await new Fixture('./fixtures/functions_config_json')
538571
.withFlags({

0 commit comments

Comments
 (0)