-
Notifications
You must be signed in to change notification settings - Fork 88
feat: fail build when netlify form detected #2512
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bbccdf7
feat: verify no netlify forms
orinokai 39511ed
test: ensure build is failed when netlify forms detected
orinokai 0ab3d7d
chore: format with prettier
orinokai 56de105
Merge branch 'main' into rs/verify-no-forms
pieh 0d66533
feat: make verification passive by outputing warning
orinokai 9a500d2
feat: include static content for forms verification
orinokai ccd1351
test: skip forms verification test until we are failing the build
orinokai 1916736
Merge branch 'rs/verify-no-forms' of github.com:netlify/netlify-plugi…
orinokai faed5fa
feat: also verify no netlify forms for APP_PAGE
orinokai eee0e83
Update tests/integration/netlify-forms.test.ts
orinokai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const metadata = { | ||
title: 'Netlify Forms', | ||
description: 'Test for verifying Netlify Forms', | ||
} | ||
|
||
export default function RootLayout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Page() { | ||
return ( | ||
<form data-netlify="true"> | ||
<button type="submit">Send</button> | ||
</form> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
output: 'standalone', | ||
eslint: { | ||
ignoreDuringBuilds: true, | ||
}, | ||
generateBuildId: () => 'build-id', | ||
} | ||
|
||
module.exports = nextConfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "netlify-forms", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"postinstall": "next build", | ||
"dev": "next dev", | ||
"build": "next build" | ||
}, | ||
"dependencies": { | ||
"@netlify/functions": "^2.7.0", | ||
"next": "latest", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "18.2.75" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": false, | ||
"noEmit": true, | ||
"incremental": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve", | ||
"plugins": [ | ||
{ | ||
"name": "next" | ||
} | ||
] | ||
}, | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { getLogger } from 'lambda-local' | ||
import { v4 } from 'uuid' | ||
import { beforeEach, expect, it, vi } from 'vitest' | ||
import { type FixtureTestContext } from '../utils/contexts.js' | ||
import { createFixture, runPlugin } from '../utils/fixture.js' | ||
import { generateRandomObjectID, startMockBlobStore } from '../utils/helpers.js' | ||
|
||
getLogger().level = 'alert' | ||
|
||
beforeEach<FixtureTestContext>(async (ctx) => { | ||
// set for each test a new deployID and siteID | ||
ctx.deployID = generateRandomObjectID() | ||
ctx.siteID = v4() | ||
vi.stubEnv('SITE_ID', ctx.siteID) | ||
vi.stubEnv('DEPLOY_ID', ctx.deployID) | ||
vi.stubEnv('NETLIFY_PURGE_API_TOKEN', 'fake-token') | ||
// hide debug logs in tests | ||
// vi.spyOn(console, 'debug').mockImplementation(() => {}) | ||
|
||
await startMockBlobStore(ctx) | ||
}) | ||
|
||
it.skip<FixtureTestContext>('test', async (ctx) => { | ||
orinokai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await createFixture('netlify-forms', ctx) | ||
|
||
const runPluginPromise = runPlugin(ctx) | ||
|
||
await expect(runPluginPromise).rejects.toThrow( | ||
'@netlify/plugin-next@5 does not support Netlify Forms', | ||
) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.