-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add next v9 test and improve fixture tooling (#14)
- Loading branch information
1 parent
c14f21e
commit 0ab5f1c
Showing
19 changed files
with
284 additions
and
134 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
package-lock=false |
This file contains 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,3 @@ | ||
'@harperdb/nextjs': | ||
package: '@harperdb/nextjs' | ||
files: '/*' |
This file contains 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 @@ | ||
module.exports = {}; |
This file contains 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,17 @@ | ||
{ | ||
"name": "next-9", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint", | ||
"postinstall": "npm link @harperdb/nextjs" | ||
}, | ||
"dependencies": { | ||
"@harperdb/nextjs": "*", | ||
"next": "^9.5.5", | ||
"react": "^16.14.0", | ||
"react-dom": "^16.14.0" | ||
} | ||
} |
This file contains 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 @@ | ||
import Head from 'next/head'; | ||
|
||
export default function App({ Component, pageProps }) { | ||
return ( | ||
<> | ||
<Head> | ||
<title>HarperDB - Next.js v9 App</title> | ||
</Head> | ||
<Component {...pageProps} /> | ||
</> | ||
); | ||
} |
This file contains 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,15 @@ | ||
import Document, { Html, Head, Main, NextScript } from 'next/document'; | ||
|
||
export default class MyDocument extends Document { | ||
render() { | ||
return ( | ||
<Html> | ||
<Head /> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
); | ||
} | ||
} |
This file contains 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 @@ | ||
import Link from 'next/link'; | ||
|
||
export default function Index() { | ||
return ( | ||
<div> | ||
<h1>Next.js v9</h1> | ||
<Link href="/page-2">Page 2</Link> | ||
</div> | ||
); | ||
} |
This file contains 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 @@ | ||
import Link from 'next/link'; | ||
|
||
export default function Page2() { | ||
return ( | ||
<div> | ||
<h1>Page 2</h1> | ||
<Link href="/">Home</Link> | ||
</div> | ||
); | ||
} |
This file contains 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 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 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 @@ | ||
import { test, expect } from '../util/test-fixture.js'; | ||
|
||
test.describe.configure({ mode: 'serial' }); | ||
|
||
test('home page', async ({ nextApp, page }) => { | ||
await page.goto(nextApp.rest.toString()); | ||
await expect(page.locator('h1')).toHaveText('Next.js v9'); | ||
}); | ||
|
||
test('title', async ({ nextApp, page }) => { | ||
await page.goto(nextApp.rest.toString()); | ||
await expect(page).toHaveTitle('HarperDB - Next.js v9 App'); | ||
}); | ||
|
||
test('page 2', async ({ nextApp, page }) => { | ||
await page.goto(nextApp.rest.toString()); | ||
await page.locator('a').click(); | ||
await expect(page.locator('h1')).toHaveText('Page 2'); | ||
}); |
This file contains 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,70 @@ | ||
import { spawn } from 'node:child_process'; | ||
import { join } from 'node:path'; | ||
import { DEBUG, ROOT, getNodeBaseImageName, getNextImageName } from './constants-and-names.js'; | ||
import { CONTAINER_ENGINE } from './container-engine.js'; | ||
import { CollectedTransform } from './collected-transform.js'; | ||
|
||
function validateResult(result) { | ||
const success = result.code === 0; | ||
|
||
if (DEBUG || !success) { | ||
console.log(`Image \x1b[94m${result.name}\x1b[0m build process exited with: \x1b[35m${result.code}\x1b[0m\n`); | ||
result.stdout !== '' && console.log('\x1b[32mstdout\x1b[0m:\n' + result.stdout + '\n'); | ||
result.stderr !== '' && console.log('\x1b[31mstderr\x1b[0m:\n' + result.stderr + '\n'); | ||
} | ||
|
||
if (!success) { | ||
process.exit(1); | ||
} | ||
} | ||
|
||
function build(name, args, options = {}) { | ||
return new Promise((resolve, reject) => { | ||
const buildProcess = spawn(CONTAINER_ENGINE, args, { cwd: ROOT, stdio: ['ignore', 'pipe', 'pipe'], ...options }); | ||
|
||
const collectedStdout = buildProcess.stdout.pipe(new CollectedTransform()); | ||
const collectedStderr = buildProcess.stderr.pipe(new CollectedTransform()); | ||
|
||
buildProcess.on('error', reject); | ||
buildProcess.on('close', (code) => | ||
resolve({ | ||
name, | ||
code, | ||
stdout: collectedStdout.output, | ||
stderr: collectedStderr.output, | ||
}) | ||
); | ||
}); | ||
} | ||
|
||
export function buildNodeImage(nodeMajor, validate = true) { | ||
const buildPromise = build(getNodeBaseImageName(nodeMajor), [ | ||
'build', | ||
'--build-arg', | ||
`NODE_MAJOR=${nodeMajor}`, | ||
'-t', | ||
getNodeBaseImageName(nodeMajor), | ||
'-f', | ||
join(ROOT, 'util', 'docker', 'base.dockerfile'), | ||
ROOT, | ||
]); | ||
|
||
return validate ? buildPromise.then(validateResult) : buildPromise; | ||
} | ||
|
||
export function buildNextImage(nextMajor, nodeMajor, validate = true) { | ||
const buildPromise = build(getNextImageName(nextMajor, nodeMajor), [ | ||
'build', | ||
'--build-arg', | ||
`BASE_IMAGE=${getNodeBaseImageName(nodeMajor)}`, | ||
'--build-arg', | ||
`NEXT_MAJOR=${nextMajor}`, | ||
'-t', | ||
getNextImageName(nextMajor, nodeMajor), | ||
'-f', | ||
join(ROOT, 'util', 'docker', 'next.dockerfile'), | ||
ROOT, | ||
]); | ||
|
||
return validate ? buildPromise.then(validateResult) : buildPromise; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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
Oops, something went wrong.