rsnext/plopfile.js
Tim Neutkens cc0da4bd29
Opt-in to dynamic rendering when reading searchParams (#46205)
Ensures that using `searchParams` opts into dynamic rendering.

Fixes #43077 
fix NEXT-601 ([link](https://linear.app/vercel/issue/NEXT-601))

<!--
Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-03-16 21:46:35 +01:00

104 lines
2.7 KiB
JavaScript

module.exports = function (plop) {
const toFileName = (str) => str.toLowerCase().replace(/ /g, '-')
plop.setHelper('toFileName', toFileName)
plop.setGenerator('test', {
description: 'Create a new test',
prompts: [
{
type: 'confirm',
name: 'appDir',
message: 'Is this test for the app directory?',
default: true,
},
{
type: 'input',
name: 'name',
message: 'Test name',
},
{
type: 'list',
name: 'type',
message: 'Test type',
choices: [
{
name: 'e2e - Test "next dev" and "next build && next start"',
value: 'e2e',
},
{
name: 'production - Test "next build && next start"',
value: 'production',
},
{ name: 'development - Test "next dev"', value: 'development' },
{ name: 'unit - Test individual files', value: 'unit' },
],
},
],
actions: function (data) {
const appDirPath = data.appDir ? 'app-dir/' : ''
let templatePath = `test/${
data.type === 'unit' ? 'unit' : 'e2e'
}/${appDirPath}test-template`
let targetPath = `test/{{ type }}/${appDirPath}`
return [
{
type: 'addMany',
templateFiles: `${templatePath}/**/*`,
base: templatePath,
destination: targetPath,
},
]
},
})
plop.setGenerator('error', {
description: 'Create a new error document',
prompts: [
{
name: 'name',
type: 'input',
message: 'Url path with dashes. E.g. circular-structure',
},
{
name: 'title',
type: 'input',
message: 'Title for the error. E.g. Circular Structure',
},
{
name: 'why',
type: 'input',
message: 'What caused the error to happen?',
},
{
name: 'fix',
type: 'input',
message: 'What are the possible ways to fix it?',
},
],
actions: function ({ name }) {
return [
{
type: 'add',
path: `errors/{{ toFileName name }}.md`,
templateFile: `errors/template.txt`,
},
{
type: 'modify',
path: 'errors/manifest.json',
transform(fileContents) {
const manifestData = JSON.parse(fileContents)
manifestData.routes[0].routes.push({
title: toFileName(name),
path: `/errors/${toFileName(name)}.md`,
})
return JSON.stringify(manifestData, null, 2)
},
},
`Url for the error: https://nextjs.org/docs/messages/${toFileName(
name
)}`,
]
},
})
}