Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove feature flag for execution order #381

Merged
merged 3 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions node/__snapshots__/declaration.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,48 +44,3 @@ exports[`Ensure the order of edge functions with FF 1`] = `
},
]
`;

exports[`Ensure the order of edge functions without FF 1`] = `
[
{
"function": "user-toml-a",
"path": "/path1",
},
{
"function": "user-toml-c",
"path": "/path3",
},
{
"function": "user-toml-b",
"path": "/path2",
},
{
"function": "framework-manifest-a",
"path": "/path1",
},
{
"function": "framework-manifest-c",
"path": "/path3",
},
{
"function": "framework-manifest-b",
"path": "/path2",
},
{
"function": "framework-isc-c",
"path": "/path1",
},
{
"function": "framework-isc-c",
"path": "/path2",
},
{
"function": "user-isc-c",
"path": "/path1",
},
{
"function": "user-isc-c",
"path": "/path2",
},
]
`;
34 changes: 1 addition & 33 deletions node/declaration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,7 @@ test('Ensure the order of edge functions with FF', () => {
'framework-isc-c': { path: ['/path1', '/path2'] },
} as Record<string, FunctionConfig>

expect(
mergeDeclarations(tomlConfig, userFuncConfig, internalFuncConfig, deployConfigDeclarations, {
edge_functions_correct_order: true,
}),
).toMatchSnapshot()
})

test('Ensure the order of edge functions without FF', () => {
const deployConfigDeclarations: Declaration[] = [
{ function: 'framework-manifest-a', path: '/path1' },
{ function: 'framework-manifest-c', path: '/path3' },
{ function: 'framework-manifest-b', path: '/path2' },
]

const tomlConfig: Declaration[] = [
{ function: 'user-toml-a', path: '/path1' },
{ function: 'user-toml-c', path: '/path3' },
{ function: 'user-toml-b', path: '/path2' },
]

const userFuncConfig = {
'user-isc-c': { path: ['/path1', '/path2'] },
} as Record<string, FunctionConfig>

const internalFuncConfig = {
'framework-isc-c': { path: ['/path1', '/path2'] },
} as Record<string, FunctionConfig>

expect(
mergeDeclarations(tomlConfig, userFuncConfig, internalFuncConfig, deployConfigDeclarations, {
edge_functions_correct_order: false,
}),
).toMatchSnapshot()
expect(mergeDeclarations(tomlConfig, userFuncConfig, internalFuncConfig, deployConfigDeclarations)).toMatchSnapshot()
})

test('In-source config takes precedence over netlify.toml config', () => {
Expand Down
45 changes: 15 additions & 30 deletions node/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,25 @@ export const mergeDeclarations = (
userFunctionsConfig: Record<string, FunctionConfig>,
internalFunctionsConfig: Record<string, FunctionConfig>,
deployConfigDeclarations: Declaration[],
featureFlags: FeatureFlags = {},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_featureFlags: FeatureFlags = {},
// eslint-disable-next-line max-params
) => {
const functionsVisited: Set<string> = new Set()

let declarations: Declaration[] = getDeclarationsFromInput(
deployConfigDeclarations,
internalFunctionsConfig,
functionsVisited,
)

// eslint-disable-next-line unicorn/prefer-ternary
if (featureFlags.edge_functions_correct_order) {
declarations = [
// INTEGRATIONS
// 1. Declarations from the integrations deploy config
...getDeclarationsFromInput(deployConfigDeclarations, internalFunctionsConfig, functionsVisited),
// 2. Declarations from the integrations ISC
...createDeclarationsFromFunctionConfigs(internalFunctionsConfig, functionsVisited),

// USER
// 3. Declarations from the users toml config
...getDeclarationsFromInput(tomlDeclarations, userFunctionsConfig, functionsVisited),
// 4. Declarations from the users ISC
...createDeclarationsFromFunctionConfigs(userFunctionsConfig, functionsVisited),
]
} else {
declarations = [
...getDeclarationsFromInput(tomlDeclarations, userFunctionsConfig, functionsVisited),
...getDeclarationsFromInput(deployConfigDeclarations, internalFunctionsConfig, functionsVisited),
...createDeclarationsFromFunctionConfigs(internalFunctionsConfig, functionsVisited),
...createDeclarationsFromFunctionConfigs(userFunctionsConfig, functionsVisited),
]
}
const declarations: Declaration[] = [
// INTEGRATIONS
// 1. Declarations from the integrations deploy config
...getDeclarationsFromInput(deployConfigDeclarations, internalFunctionsConfig, functionsVisited),
// 2. Declarations from the integrations ISC
...createDeclarationsFromFunctionConfigs(internalFunctionsConfig, functionsVisited),

// USER
// 3. Declarations from the users toml config
...getDeclarationsFromInput(tomlDeclarations, userFunctionsConfig, functionsVisited),
// 4. Declarations from the users ISC
...createDeclarationsFromFunctionConfigs(userFunctionsConfig, functionsVisited),
]

return declarations
}
Expand Down
1 change: 0 additions & 1 deletion node/feature_flags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const defaultFlags = {
edge_functions_correct_order: false,
edge_functions_fail_unsupported_regex: false,
}

Expand Down