Skip to content
Closed
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
11 changes: 11 additions & 0 deletions tests/smoke/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ if (nextVersionSatisfies('>=16.0.0')) {
const body = await response.json()
expect(body).toEqual({ proxy: true })
})

test('pnpm monorepo with proxy / node middleware with setup using base directory instead of package path', async () => {
// proxy ~= node middleware
const fixture = await selfCleaningFixtureFactories.pnpmMonorepoBaseProxy()

const response = await fetch(fixture.url)
expect(response.status).toBe(200)

const body = await response.json()
expect(body).toEqual({ proxy: true })
})
}

test('yarn@3 monorepo with pnpm linker', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
eslint: {
ignoreDuringBuilds: true,
},
}

module.exports = nextConfig
13 changes: 13 additions & 0 deletions tests/smoke/fixtures/pnpm-monorepo-base-proxy/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "pnpm-monorepo-base-proxy-app",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "next build"
},
"dependencies": {
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default function Home({ ssr }) {
return (
<main>
<div data-testid="smoke">SSR: {ssr ? 'yes' : 'no'}</div>
</main>
)
}

export const getServerSideProps = async () => {
return {
props: {
ssr: true,
},
}
}
6 changes: 6 additions & 0 deletions tests/smoke/fixtures/pnpm-monorepo-base-proxy/app/proxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { NextRequest } from 'next/server'
import { NextResponse } from 'next/server'

export async function proxy(request: NextRequest) {
return NextResponse.json({ proxy: true })
}
7 changes: 7 additions & 0 deletions tests/smoke/fixtures/pnpm-monorepo-base-proxy/netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build]
base = "app"
command = "pnpm run build"
publish = ".next"

[[plugins]]
package = "@netlify/plugin-nextjs"
4 changes: 4 additions & 0 deletions tests/smoke/fixtures/pnpm-monorepo-base-proxy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "monorepo",
"private": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- 'app'
45 changes: 33 additions & 12 deletions tests/utils/create-e2e-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { exec } from 'node:child_process'
import { existsSync } from 'node:fs'
import { appendFile, copyFile, mkdir, mkdtemp, readFile, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { dirname, join } from 'node:path'
import { dirname, join, relative } from 'node:path'
import process from 'node:process'
import { fileURLToPath } from 'node:url'
import { cpus } from 'os'
Expand Down Expand Up @@ -228,6 +228,14 @@ async function installRuntime(
await rm(join(isolatedFixtureRoot, 'package-lock.json'), { force: true })
}

let relativePathToPackage = relative(
join(isolatedFixtureRoot, siteRelDir),
join(isolatedFixtureRoot, packageName),
)
if (!relativePathToPackage.startsWith('.')) {
relativePathToPackage = `./${relativePathToPackage}`
}

switch (packageManger) {
case 'npm':
command = `npm install --ignore-scripts --no-audit --legacy-peer-deps ${packageName} ${
Expand All @@ -248,7 +256,7 @@ async function installRuntime(
env['YARN_ENABLE_SCRIPTS'] = 'false'
break
case 'pnpm':
command = `pnpm add file:${join(isolatedFixtureRoot, packageName)} ${
command = `pnpm add file:${relativePathToPackage} ${
workspaceRelPath ? `--filter ./${workspaceRelPath}` : ''
} --ignore-scripts`
break
Expand Down Expand Up @@ -349,24 +357,27 @@ export async function deploySiteWithBuildbot(
newZip.addLocalFolder(isolatedFixtureRoot, '', (entry) => {
if (
// don't include node_modules / .git / publish dir in zip
entry.startsWith('node_modules') ||
entry.startsWith('.git') ||
entry.includes('node_modules') ||
entry.includes('.git') ||
entry.startsWith(publishDirectory)
) {
return false
}
return true
})

const result = await fetch(`https://api.netlify.com/api/v1/sites/${siteId}/builds`, {
method: 'POST',
headers: {
'Content-Type': 'application/zip',
Authorization: `Bearer ${process.env.NETLIFY_AUTH_TOKEN}`,
const result = await fetch(
`https://api.netlify.com/api/v1/sites/${siteId}/builds?clear_cache=true`,
{
method: 'POST',
headers: {
'Content-Type': 'application/zip',
Authorization: `Bearer ${process.env.NETLIFY_AUTH_TOKEN}`,
},
// @ts-expect-error sigh, it works
body: newZip.toBuffer(),
},
// @ts-expect-error sigh, it works
body: newZip.toBuffer(),
})
)
const { deploy_id } = await result.json()

let didRunOnBuildStartCallback = false
Expand Down Expand Up @@ -636,6 +647,16 @@ export const fixtureFactories = {
publishDirectory: 'apps/site/.next',
smoke: true,
}),
pnpmMonorepoBaseProxy: () =>
createE2EFixture('pnpm-monorepo-base-proxy', {
buildCommand: 'pnpm run build',
generateNetlifyToml: false,
packageManger: 'pnpm',
publishDirectory: '.next',
runtimeInstallationPath: 'app',
smoke: true,
useBuildbot: true,
}),
dynamicCms: () => createE2EFixture('dynamic-cms'),
after: () => createE2EFixture('after'),
}
Loading