diff --git a/packages/now-next/src/index.ts b/packages/now-next/src/index.ts
index a567206f4..a72267fab 100644
--- a/packages/now-next/src/index.ts
+++ b/packages/now-next/src/index.ts
@@ -354,30 +354,12 @@ export const build = async ({
}
}
- const exportIntent = await getExportIntent(entryPath);
const userExport = await getExportStatus(entryPath);
- if (exportIntent || userExport) {
+ if (userExport) {
+ const exportIntent = await getExportIntent(entryPath);
const { trailingSlash = false } = exportIntent || {};
- if (!userExport) {
- await writePackageJson(entryPath, {
- ...pkg,
- scripts: {
- ...pkg.scripts,
- 'now-automatic-next-export': `next export --outdir "${path.resolve(
- entryPath,
- 'out'
- )}"`,
- },
- });
-
- await runPackageJsonScript(entryPath, 'now-automatic-next-export', {
- ...spawnOpts,
- env,
- });
- }
-
const resultingExport = await getExportStatus(entryPath);
if (!resultingExport) {
throw new Error(
diff --git a/packages/now-next/test/fixtures/12-export-auto/next.config.js b/packages/now-next/test/fixtures/12-no-export-auto/next.config.js
similarity index 100%
rename from packages/now-next/test/fixtures/12-export-auto/next.config.js
rename to packages/now-next/test/fixtures/12-no-export-auto/next.config.js
diff --git a/packages/now-next/test/fixtures/12-export-auto/now.json b/packages/now-next/test/fixtures/12-no-export-auto/now.json
similarity index 85%
rename from packages/now-next/test/fixtures/12-export-auto/now.json
rename to packages/now-next/test/fixtures/12-no-export-auto/now.json
index df62d5694..eb3d3fc0a 100644
--- a/packages/now-next/test/fixtures/12-export-auto/now.json
+++ b/packages/now-next/test/fixtures/12-no-export-auto/now.json
@@ -12,7 +12,7 @@
},
{
"path": "/",
- "mustContain": "nextExport\":true"
+ "mustNotContain": "nextExport\":true"
}
]
}
diff --git a/packages/now-next/test/fixtures/12-export-auto/package.json b/packages/now-next/test/fixtures/12-no-export-auto/package.json
similarity index 100%
rename from packages/now-next/test/fixtures/12-export-auto/package.json
rename to packages/now-next/test/fixtures/12-no-export-auto/package.json
diff --git a/packages/now-next/test/fixtures/12-export-auto/pages/about.js b/packages/now-next/test/fixtures/12-no-export-auto/pages/about.js
similarity index 100%
rename from packages/now-next/test/fixtures/12-export-auto/pages/about.js
rename to packages/now-next/test/fixtures/12-no-export-auto/pages/about.js
diff --git a/packages/now-next/test/fixtures/12-export-auto/pages/index.js b/packages/now-next/test/fixtures/12-no-export-auto/pages/index.js
similarity index 100%
rename from packages/now-next/test/fixtures/12-export-auto/pages/index.js
rename to packages/now-next/test/fixtures/12-no-export-auto/pages/index.js
diff --git a/packages/now-next/test/fixtures/13-export-custom-routes/package.json b/packages/now-next/test/fixtures/13-export-custom-routes/package.json
index 80dcb99fc..5f6bab3d4 100644
--- a/packages/now-next/test/fixtures/13-export-custom-routes/package.json
+++ b/packages/now-next/test/fixtures/13-export-custom-routes/package.json
@@ -1,4 +1,7 @@
{
+ "scripts": {
+ "build": "next build && next export"
+ },
"dependencies": {
"next": "canary",
"react": "^16.8.6",
diff --git a/packages/now-next/test/fixtures/14-next-offline/next.config.js b/packages/now-next/test/fixtures/14-next-offline/next.config.js
new file mode 100644
index 000000000..37e17d337
--- /dev/null
+++ b/packages/now-next/test/fixtures/14-next-offline/next.config.js
@@ -0,0 +1,8 @@
+const withOffline = require('next-offline');
+
+module.exports = withOffline({
+ generateBuildId() {
+ return 'testing-build-id';
+ },
+ exportPathMap: d => d,
+});
diff --git a/packages/now-next/test/fixtures/14-next-offline/now.json b/packages/now-next/test/fixtures/14-next-offline/now.json
new file mode 100644
index 000000000..eb3d3fc0a
--- /dev/null
+++ b/packages/now-next/test/fixtures/14-next-offline/now.json
@@ -0,0 +1,18 @@
+{
+ "version": 2,
+ "builds": [{ "src": "package.json", "use": "@now/next" }],
+ "probes": [
+ {
+ "path": "/",
+ "mustContain": "Hi There"
+ },
+ {
+ "path": "/about",
+ "mustContain": "Hi on About"
+ },
+ {
+ "path": "/",
+ "mustNotContain": "nextExport\":true"
+ }
+ ]
+}
diff --git a/packages/now-next/test/fixtures/14-next-offline/package.json b/packages/now-next/test/fixtures/14-next-offline/package.json
new file mode 100644
index 000000000..e5aad9323
--- /dev/null
+++ b/packages/now-next/test/fixtures/14-next-offline/package.json
@@ -0,0 +1,8 @@
+{
+ "dependencies": {
+ "next": "canary",
+ "next-offline": "4.0.6",
+ "react": "^16.8.6",
+ "react-dom": "^16.8.6"
+ }
+}
diff --git a/packages/now-next/test/fixtures/14-next-offline/pages/about.js b/packages/now-next/test/fixtures/14-next-offline/pages/about.js
new file mode 100644
index 000000000..add30e58d
--- /dev/null
+++ b/packages/now-next/test/fixtures/14-next-offline/pages/about.js
@@ -0,0 +1,7 @@
+function About() {
+ return
Hi on About
;
+}
+
+About.getInitialProps = () => ({});
+
+export default About;
diff --git a/packages/now-next/test/fixtures/14-next-offline/pages/index.js b/packages/now-next/test/fixtures/14-next-offline/pages/index.js
new file mode 100644
index 000000000..0552e96ca
--- /dev/null
+++ b/packages/now-next/test/fixtures/14-next-offline/pages/index.js
@@ -0,0 +1,7 @@
+function Home() {
+ return Hi There
;
+}
+
+Home.getInitialProps = () => ({});
+
+export default Home;
diff --git a/test/lib/deployment/test-deployment.js b/test/lib/deployment/test-deployment.js
index 2795a3dc3..fb80de1ea 100644
--- a/test/lib/deployment/test-deployment.js
+++ b/test/lib/deployment/test-deployment.js
@@ -7,8 +7,8 @@ const { spawn } = require('child_process');
const fetch = require('./fetch-retry.js');
const { nowDeploy } = require('./now-deploy.js');
-async function packAndDeploy (builderPath) {
- await spawnAsync('npm', [ '--loglevel', 'warn', 'pack' ], {
+async function packAndDeploy(builderPath) {
+ await spawnAsync('npm', ['--loglevel', 'warn', 'pack'], {
stdio: 'inherit',
cwd: builderPath,
});
@@ -23,7 +23,7 @@ async function packAndDeploy (builderPath) {
const RANDOMNESS_PLACEHOLDER_STRING = 'RANDOMNESS_PLACEHOLDER';
-async function testDeployment (
+async function testDeployment(
{ builderUrl, buildUtilsUrl },
fixturePath,
buildDelegate
@@ -85,7 +85,7 @@ async function testDeployment (
for (const probe of nowJson.probes || []) {
console.log('testing', JSON.stringify(probe));
if (probe.delay) {
- await new Promise((resolve) => setTimeout(resolve, probe.delay));
+ await new Promise(resolve => setTimeout(resolve, probe.delay));
continue;
}
const probeUrl = `https://${deploymentUrl}${probe.path}`;
@@ -109,31 +109,40 @@ async function testDeployment (
}
}
- if (probe.mustContain) {
- if (!text.includes(probe.mustContain)) {
+ if (probe.mustContain || probe.mustNotContain) {
+ const shouldContain = !!probe.mustContain;
+ const containsIt = text.includes(probe.mustContain);
+ if (
+ (!containsIt && probe.mustContain) ||
+ (containsIt && probe.mustNotContain)
+ ) {
fs.writeFileSync(path.join(__dirname, 'failed-page.txt'), text);
const headers = Array.from(resp.headers.entries())
- .map(([ k, v ]) => ` ${k}=${v}`)
+ .map(([k, v]) => ` ${k}=${v}`)
.join('\n');
throw new Error(
- `Fetched page ${probeUrl} does not contain ${probe.mustContain}.` +
- ` Instead it contains ${text.slice(0, 60)}` +
+ `Fetched page ${probeUrl} does${
+ shouldContain ? ' not' : ''
+ } contain ${
+ shouldContain ? probe.mustContain : probe.mustNotContain
+ }.` +
+ (shouldContain ? ` Instead it contains ${text.slice(0, 60)}` : '') +
` Response headers:\n ${headers}`
);
}
} else if (probe.responseHeaders) {
// eslint-disable-next-line no-loop-func
- Object.keys(probe.responseHeaders).forEach((header) => {
+ Object.keys(probe.responseHeaders).forEach(header => {
const actual = resp.headers.get(header);
const expected = probe.responseHeaders[header];
const isEqual = Array.isArray(expected)
- ? expected.every((h) => actual.includes(h))
+ ? expected.every(h => actual.includes(h))
: expected.startsWith('/') && expected.endsWith('/')
? new RegExp(expected.slice(1, -1)).test(actual)
: expected === actual;
if (!isEqual) {
const headers = Array.from(resp.headers.entries())
- .map(([ k, v ]) => ` ${k}=${v}`)
+ .map(([k, v]) => ` ${k}=${v}`)
.join('\n');
throw new Error(
@@ -154,7 +163,7 @@ async function testDeployment (
return { deploymentId, deploymentUrl };
}
-async function nowDeployIndexTgz (file) {
+async function nowDeployIndexTgz(file) {
const bodies = {
'index.tgz': fs.readFileSync(file),
'now.json': Buffer.from(JSON.stringify({ version: 2 })),
@@ -163,7 +172,7 @@ async function nowDeployIndexTgz (file) {
return (await nowDeploy(bodies)).deploymentUrl;
}
-async function fetchDeploymentUrl (url, opts) {
+async function fetchDeploymentUrl(url, opts) {
for (let i = 0; i < 50; i += 1) {
const resp = await fetch(url, opts);
const text = await resp.text();
@@ -171,13 +180,13 @@ async function fetchDeploymentUrl (url, opts) {
return { resp, text };
}
- await new Promise((r) => setTimeout(r, 1000));
+ await new Promise(r => setTimeout(r, 1000));
}
throw new Error(`Failed to wait for deployment READY. Url is ${url}`);
}
-async function fetchTgzUrl (url) {
+async function fetchTgzUrl(url) {
for (let i = 0; i < 500; i += 1) {
const resp = await fetch(url);
if (resp.status === 200) {
@@ -188,19 +197,19 @@ async function fetchTgzUrl (url) {
}
}
- await new Promise((r) => setTimeout(r, 1000));
+ await new Promise(r => setTimeout(r, 1000));
}
throw new Error(`Failed to wait for builder url READY. Url is ${url}`);
}
-async function spawnAsync (...args) {
+async function spawnAsync(...args) {
return await new Promise((resolve, reject) => {
const child = spawn(...args);
let result;
if (child.stdout) {
result = '';
- child.stdout.on('data', (chunk) => {
+ child.stdout.on('data', chunk => {
result += chunk.toString();
});
}