Compare commits

..

14 Commits

Author SHA1 Message Date
JJ Kasper
ad0cc858ed Publish Canary
- vercel@20.0.0-canary.11
 - @vercel/next@2.6.18-canary.0
 - @vercel/node@1.7.5-canary.1
2020-08-04 09:06:29 -05:00
JJ Kasper
4bb7180de9 [next] Ensure trailing slash resolves to functions correctly (#4972)
This makes sure the routes mapping to the serverless functions handle the trailing slash being present or not. This also adds additional test cases to ensure it is functioning correctly
2020-08-04 03:35:50 +00:00
Steven
7a4faa480d [node][next] Bump node-file-trace to 0.8.2 (#4969)
Bump `node-file-trace` to [0.8.2](https://github.com/vercel/node-file-trace/releases/tag/0.8.2)
2020-08-03 11:09:52 -04:00
JJ Kasper
421be5d738 Publish Stable
- @vercel/next@2.6.17
2020-07-31 10:29:04 -05:00
JJ Kasper
b8eaf10974 Publish Canary
- vercel@20.0.0-canary.10
 - @vercel/next@2.6.17-canary.1
2020-07-31 10:20:59 -05:00
JJ Kasper
92a4bf27cf [next] Fix monorepo build edge case without build script (#4956)
This fixes an edge case where a monorepo Next.js app fails to build due to running `next build` manually instead of via `package.json` scripts like we previously were doing. 

Failing project with current `@vercel/next` running `next build` manually: https://vercel.com/jj4/test2020/15fhg1ko3
Succeeding project running changing back to running `next build` through a `package.json` script: https://vercel.com/jj4/test2020/dths5f1nv

x-ref: https://github.com/vercel/vercel/pull/4863
Fixes: https://github.com/vercel/next.js/issues/15713
2020-07-31 15:17:14 +00:00
Steven
2672838b64 Publish Canary
- vercel@20.0.0-canary.9
 - @vercel/next@2.6.17-canary.0
 - @vercel/redwood@0.0.2-canary.3
2020-07-31 09:15:51 -04:00
Steven
1c96071ddc [cli][redwood] Update redwood port detection in vc dev (#4937)
Fixes redwood support for `vc dev`
2020-07-31 13:14:04 +00:00
Steven
71cdf759da [tests] Ignore custom next 404 (#4955)
Commenting out this test assertion until we can fix it in #4946
2020-07-30 20:40:41 -04:00
Torsten Dittmann
93ebd213de [examples] Update deprecated and outdated Svelte example packages (#4706) 2020-07-30 15:44:39 -07:00
JJ Kasper
a32ba8f214 Publish Stable
- @vercel/next@2.6.16
2020-07-30 14:15:29 -05:00
JJ Kasper
d416f70a6e Publish Canary
- @vercel/frameworks@0.0.18-canary.2
 - vercel@20.0.0-canary.8
 - @vercel/next@2.6.16-canary.0
 - @vercel/node@1.7.5-canary.0
 - @vercel/routing-utils@1.8.4-canary.0
 - @vercel/redwood@0.0.2-canary.2
2020-07-30 13:45:26 -05:00
JJ Kasper
ba9e1dd0ba [routing-utils] Update header replacing to handle more cases (#4942)
This adds handling for more cases while updating header values to make sure to escape any characters that could break compiling with `path-to-regexp`

x-ref: https://github.com/vercel/next.js/pull/15592
2020-07-30 18:22:30 +00:00
Steven
d513f74b70 [frameworks][redwood] Bump to RedwoodJS to 0.15.0 (#4953)
Implements https://github.com/redwoodjs/redwood/pull/904
2020-07-30 10:52:04 -04:00
38 changed files with 20848 additions and 645 deletions

View File

@@ -3,6 +3,6 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"@redwoodjs/api": "0.14.0"
"@redwoodjs/api": "0.15.0"
}
}

View File

@@ -7,7 +7,7 @@
]
},
"devDependencies": {
"@redwoodjs/core": "0.14.0"
"@redwoodjs/core": "0.15.0"
},
"eslintConfig": {
"extends": "@redwoodjs/eslint-config"

View File

@@ -6,8 +6,8 @@
"defaults"
],
"dependencies": {
"@redwoodjs/router": "0.14.0",
"@redwoodjs/web": "0.14.0",
"@redwoodjs/router": "0.15.0",
"@redwoodjs/web": "0.15.0",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1"

14339
examples/redwoodjs/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -2,17 +2,17 @@
"name": "svelte-app",
"version": "1.0.0",
"devDependencies": {
"@rollup/plugin-commonjs": "^13.0.0",
"@rollup/plugin-node-resolve": "^8.1.0",
"npm-run-all": "^4.1.5",
"rollup": "^1.10.1",
"rollup-plugin-commonjs": "^9.3.4",
"rollup": "^2.18.0",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-node-resolve": "^4.2.3",
"rollup-plugin-svelte": "^5.0.3",
"rollup-plugin-terser": "^4.0.4",
"rollup-plugin-terser": "^6.1.0",
"svelte": "^3.0.0"
},
"dependencies": {
"sirv-cli": "^0.4.4"
"sirv-cli": "^1.0.1"
},
"scripts": {
"build": "rollup -c",

View File

@@ -1,6 +1,6 @@
import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';

View File

@@ -703,7 +703,7 @@
"value": "yarn rw db up --no-db-client --auto-approve && yarn rw build"
},
"devCommand": {
"value": "yarn rw dev"
"value": "yarn rw dev --fwd=\"--port=$PORT --open=false\""
},
"outputDirectory": {
"value": "RedwoodJS default"

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/frameworks",
"version": "0.0.18-canary.1",
"version": "0.0.18-canary.2",
"main": "frameworks.json",
"license": "UNLICENSED",
"scripts": {

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "20.0.0-canary.7",
"version": "20.0.0-canary.11",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -64,10 +64,10 @@
"dependencies": {
"@vercel/build-utils": "2.4.3-canary.2",
"@vercel/go": "1.1.5-canary.0",
"@vercel/next": "2.6.15",
"@vercel/node": "1.7.4",
"@vercel/next": "2.6.18-canary.0",
"@vercel/node": "1.7.5-canary.1",
"@vercel/python": "1.2.2",
"@vercel/redwood": "0.0.2-canary.1",
"@vercel/redwood": "0.0.2-canary.3",
"@vercel/ruby": "1.2.3",
"@vercel/static-build": "0.17.7-canary.1",
"update-notifier": "4.1.0"

View File

@@ -1578,6 +1578,13 @@ export default class DevServer {
debug(
`Checking build result's ${buildResult.routes.length} \`routes\` to match ${newUrl}`
);
for (const r of buildResult.routes) {
// This replace is necessary for `@vercel/redwood` but might be relevant
// for builders that wish to return routes and work with zero config.
if (r.dest) {
r.dest = r.dest.replace(/\$PORT/g, `${this.devProcessPort}`);
}
}
const matchedRoute = await devRouter(
newUrl,
req.method,

View File

@@ -20,6 +20,8 @@ let port = 3000;
const binaryPath = resolve(__dirname, `../../scripts/start.js`);
const fixture = name => join('test', 'dev', 'fixtures', name);
const fixtureAbsolute = name => join(__dirname, 'fixtures', name);
const exampleAbsolute = name =>
join(__dirname, '..', '..', '..', '..', 'examples', name);
let processCounter = 0;
const processList = new Map();
@@ -127,9 +129,10 @@ async function testPath(
path,
expectedText,
headers = {},
method = 'GET'
method = 'GET',
body = undefined
) {
const opts = { redirect: 'manual-dont-change', method };
const opts = { redirect: 'manual-dont-change', method, body };
const url = `${origin}${path}`;
const res = await fetch(url, opts);
const msg = `Testing response from ${method} ${url}`;
@@ -230,10 +233,18 @@ async function testFixture(directory, opts = {}, args = []) {
function testFixtureStdio(
directory,
fn,
{ expectedCode = 0, skipDeploy } = {}
{ expectedCode = 0, skipDeploy, isExample } = {}
) {
return async t => {
const cwd = fixtureAbsolute(directory);
const nodeMajor = Number(process.versions.node.split('.')[0]);
if (isExample && nodeMajor < 12) {
console.log(`Skipping ${directory} on Node ${process.version}`);
t.pass();
return;
}
const cwd = isExample
? exampleAbsolute(directory)
: fixtureAbsolute(directory);
const token = await fetchTokenWithRetry();
let deploymentUrl;
@@ -369,6 +380,21 @@ test.afterEach(async () => {
);
});
test(
'[vercel dev] redwoodjs example',
testFixtureStdio(
'redwoodjs',
async testPath => {
await testPath(200, '/', /<div id="redwood-app">/m);
await testPath(200, '/about', /<div id="redwood-app">/m);
const reqBody = '{"query":"{redwood{version}}"}';
const resBody = '{"data":{"redwood":{"version":"0.15.0"}}}';
await testPath(200, '/api/graphql', resBody, {}, 'POST', reqBody);
},
{ isExample: true }
)
);
test('[vercel dev] prints `npm install` errors', async t => {
const dir = fixture('runtime-not-installed');
const result = await exec(dir);
@@ -1149,7 +1175,8 @@ test(
await testPath(200, '/api/date', new RegExp(new Date().getFullYear()));
await testPath(200, '/contact', /Contact Page/);
await testPath(200, '/support', /Contact Page/);
await testPath(404, '/nothing', /Custom Next 404/);
// TODO: Fix this test assertion that fails intermittently
// await testPath(404, '/nothing', /Custom Next 404/);
})
);

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/next",
"version": "2.6.15",
"version": "2.6.18-canary.0",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -26,7 +26,7 @@
"@types/resolve-from": "5.0.1",
"@types/semver": "6.0.0",
"@types/yazl": "2.4.1",
"@zeit/node-file-trace": "0.8.1",
"@zeit/node-file-trace": "0.8.2",
"async-sema": "3.0.1",
"buffer-crc32": "0.2.13",
"escape-string-regexp": "3.0.0",

View File

@@ -235,7 +235,7 @@ export const build = async ({
await download(files, workPath, meta);
const pkg = await readPackageJson(entryPath);
let pkg = await readPackageJson(entryPath);
const nextVersionRange = await getNextVersionRange(entryPath);
const nodeVersion = await getNodeVersion(entryPath, undefined, config, meta);
const spawnOpts = getSpawnOptions(meta, nodeVersion);
@@ -331,17 +331,17 @@ export const build = async ({
]);
debug('Normalizing package.json');
const packageJson = normalizePackageJson(pkg);
debug('Normalized package.json result: ', packageJson);
await writePackageJson(entryPath, packageJson);
pkg = normalizePackageJson(pkg);
debug('Normalized package.json result: ', pkg);
await writePackageJson(entryPath, pkg);
}
const buildScriptName = getScriptName(pkg, [
let buildScriptName = getScriptName(pkg, [
'vercel-build',
'now-build',
'build',
]);
let { buildCommand } = config;
const { buildCommand } = config;
if (!buildScriptName && !buildCommand) {
console.log(
@@ -349,7 +349,15 @@ export const build = async ({
'If you need to define a different build step, please create a `vercel-build` script in your `package.json` ' +
'(e.g. `{ "scripts": { "vercel-build": "npm run prepare && next build" } }`).'
);
buildCommand = 'next build';
await writePackageJson(entryPath, {
...pkg,
scripts: {
'vercel-build': 'next build',
...pkg.scripts,
},
});
buildScriptName = 'vercel-build';
}
if (process.env.NPM_AUTH_TOKEN) {
@@ -1123,7 +1131,7 @@ export const build = async ({
src: `^${escapeStringRegexp(outputName).replace(
/\/index$/,
'(/|/index|)'
)}$`,
)}/?$`,
dest: `${path.join('/', currentLambdaGroup.lambdaIdentifier)}`,
headers: {
'x-nextjs-page': outputName,
@@ -1303,7 +1311,7 @@ export const build = async ({
if (!toRender) {
try {
const { pathname } = url.parse(req.url)
toRender = pathname
toRender = pathname.replace(/\\/$/, '')
} catch (_) {
// handle failing to parse url
res.statusCode = 400

View File

@@ -1 +1,6 @@
module.exports = { trailingSlash: true };
module.exports = {
generateBuildId() {
return 'testing-build-id';
},
trailingSlash: true,
};

View File

@@ -33,6 +33,48 @@
"path": "/test.txt",
"status": 200,
"mustContain": "this is a file"
},
{
"fetchOptions": { "redirect": "manual" },
"path": "/blog/post-1",
"status": 308,
"responseHeaders": {
"refresh": "/url=/blog/post-1/$/"
}
},
{
"fetchOptions": { "redirect": "manual" },
"path": "/blog/post-1/",
"status": 200,
"mustContain": "post: <!-- -->post-1"
},
{
"fetchOptions": { "redirect": "manual" },
"path": "/_next/data/testing-build-id/blog/post-1.json/",
"status": 308,
"responseHeaders": {
"refresh": "/url=/_next/data/testing-build-id/blog/post-1.json$/"
}
},
{
"fetchOptions": { "redirect": "manual" },
"path": "/_next/data/testing-build-id/blog/post-1.json",
"status": 200,
"mustContain": "\"post-1\""
},
{
"fetchOptions": { "redirect": "manual" },
"path": "/api/hello",
"status": 308,
"responseHeaders": {
"refresh": "/url=/api/hello/$/"
}
},
{
"fetchOptions": { "redirect": "manual" },
"path": "/api/hello/",
"status": 200,
"mustContain": "hello from API"
}
]
}

View File

@@ -1,3 +1,11 @@
export default function Page() {
return <p>nested page</p>;
}
export const getServerSideProps = () => {
return {
props: {
hello: 'world',
},
};
};

View File

@@ -0,0 +1,3 @@
export default (req, res) => {
res.end('hello from API');
};

View File

@@ -0,0 +1,11 @@
export default function Page({ post }) {
return <p>post: {post}</p>;
}
export const getServerSideProps = ({ params }) => {
return {
props: {
post: params.post,
},
};
};

View File

@@ -0,0 +1,108 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# IDEA
.idea/
*.iml

View File

@@ -0,0 +1,7 @@
module.exports = api => {
api.cache(true);
const presets = [require.resolve('next/babel')];
return { presets, plugins: [] };
};

View File

@@ -0,0 +1,31 @@
{
"version": 2,
"uploadNowJson": true,
"builds": [{ "src": "packages/www/package.json", "use": "@vercel/next" }],
"routes": [{ "src": "/(.*)", "dest": "/packages/www/$1" }],
"probes": [
{
"path": "/",
"status": 200,
"mustContain": "Hello World"
},
{
"logMustContain": "Your application is being built using `next build`"
},
{
"logMustContain": "WARNING: your application is being opted out of @vercel/next's optimized lambdas mode due to legacy routes"
},
{
"logMustNotContain": "WARNING: Your application is being opted out of \"@vercel/next\" optimized lambdas mode due to `functions` config"
},
{
"logMustNotContain": "Traced Next.js serverless functions for external files in"
},
{
"logMustNotContain": "All serverless functions created in"
},
{
"logMustNotContain": "Compressed shared serverless function files"
}
]
}

View File

@@ -0,0 +1,11 @@
{
"private": true,
"workspaces": [
"packages/*"
],
"dependencies": {
"next": "9.5.1",
"react": "16.13.1",
"react-dom": "16.13.1"
}
}

View File

@@ -0,0 +1,8 @@
module.exports = {
poweredByHeader: false,
webpack: (config, { defaultLoaders }) => {
defaultLoaders.babel.options.rootMode = 'upward';
return config;
},
};

View File

@@ -0,0 +1,6 @@
{
"name": "@vercel-crash-demo/www",
"version": "1.0.0",
"private": true,
"sideEffects": false
}

View File

@@ -0,0 +1,7 @@
import React from 'react';
const HelloWorld = () => (
<h1>Hello World</h1>
);
export default HelloWorld;

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/node",
"version": "1.7.4",
"version": "1.7.5-canary.1",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -33,7 +33,7 @@
"@types/etag": "1.8.0",
"@types/test-listen": "1.1.0",
"@zeit/ncc": "0.20.4",
"@zeit/node-file-trace": "0.8.1",
"@zeit/node-file-trace": "0.8.2",
"content-type": "1.0.4",
"cookie": "0.4.0",
"etag": "1.8.1",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/routing-utils",
"version": "1.8.3",
"version": "1.8.4-canary.0",
"description": "Vercel routing utilities",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",

View File

@@ -218,18 +218,42 @@ function replaceSegments(
return destination;
}
function safelyCompile(str: string, indexes: { [k: string]: string }): string {
if (!str) {
return str;
function safelyCompile(
value: string,
indexes: { [k: string]: string }
): string {
if (!value) {
return value;
}
// path-to-regexp cannot compile question marks
return str
.split('?')
.map(part => {
const compiler = compile(part);
return compiler(indexes);
})
.join('?');
for (const key of Object.keys(indexes)) {
if (value.includes(`:${key}`)) {
value = value
.replace(
new RegExp(`:${key}\\*`, 'g'),
`:${key}--ESCAPED_PARAM_ASTERISK`
)
.replace(
new RegExp(`:${key}\\?`, 'g'),
`:${key}--ESCAPED_PARAM_QUESTION`
)
.replace(new RegExp(`:${key}\\+`, 'g'), `:${key}--ESCAPED_PARAM_PLUS`)
.replace(
new RegExp(`:${key}(?!\\w)`, 'g'),
`--ESCAPED_PARAM_COLON${key}`
);
}
}
value = value
.replace(/(:|\*|\?|\+|\(|\)|\{|\})/g, '\\$1')
.replace(/--ESCAPED_PARAM_PLUS/g, '+')
.replace(/--ESCAPED_PARAM_COLON/g, ':')
.replace(/--ESCAPED_PARAM_QUESTION/g, '?')
.replace(/--ESCAPED_PARAM_ASTERISK/g, '*');
// the value needs to start with a forward-slash to be compiled
// correctly
return compile(`/${value}`, { validate: false })(indexes).substr(1);
}
function toSegmentDest(index: number): string {

View File

@@ -508,6 +508,60 @@ test('convertHeaders', () => {
},
],
},
{
source: '/like/params/:path',
headers: [
{
key: 'x-path',
value: ':path',
},
{
key: 'some:path',
value: 'hi',
},
{
key: 'x-test',
value: 'some:value*',
},
{
key: 'x-test-2',
value: 'value*',
},
{
key: 'x-test-3',
value: ':value?',
},
{
key: 'x-test-4',
value: ':value+',
},
{
key: 'x-test-5',
value: 'something https:',
},
{
key: 'x-test-6',
value: ':hello(world)',
},
{
key: 'x-test-7',
value: 'hello(world)',
},
{
key: 'x-test-8',
value: 'hello{1,}',
},
{
key: 'x-test-9',
value: ':hello{1,2}',
},
{
key: 'content-security-policy',
value:
"default-src 'self'; img-src *; media-src media1.com media2.com; script-src userscripts.example.com/:path",
},
],
},
]);
const expected = [
@@ -526,6 +580,25 @@ test('convertHeaders', () => {
headers: { 'on-blog': '$1', $1: 'blog' },
continue: true,
},
{
continue: true,
headers: {
'content-security-policy':
"default-src 'self'; img-src *; media-src media1.com media2.com; script-src userscripts.example.com/$1",
some$1: 'hi',
'x-path': '$1',
'x-test': 'some:value*',
'x-test-2': 'value*',
'x-test-3': ':value?',
'x-test-4': ':value+',
'x-test-5': 'something https:',
'x-test-6': ':hello(world)',
'x-test-7': 'hello(world)',
'x-test-8': 'hello{1,}',
'x-test-9': ':hello{1,2}',
},
src: '^\\/like\\/params(?:\\/([^\\/]+?))$',
},
];
deepEqual(actual, expected);
@@ -534,12 +607,14 @@ test('convertHeaders', () => {
['hello/world/file.eot', 'another/font.ttf', 'dir/arial.font.css'],
['404.html'],
['/blog/first-post', '/blog/another/one'],
['/like/params/first', '/like/params/second'],
];
const mustNotMatch = [
['hello/file.jpg', 'hello/font-css', 'dir/arial.font-css'],
['403.html', '500.html'],
['/blogg', '/random'],
['/non-match', '/like/params', '/like/params/'],
];
assertRegexMatches(actual, mustMatch, mustNotMatch);

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/redwood",
"version": "0.0.2-canary.1",
"version": "0.0.2-canary.3",
"main": "./dist/index.js",
"license": "MIT",
"homepage": "https://vercel.com/docs",
@@ -18,8 +18,7 @@
"prepublishOnly": "./build.sh"
},
"dependencies": {
"@netlify/zip-it-and-ship-it": "1.2.0",
"is-port-reachable": "3.0.0"
"@netlify/zip-it-and-ship-it": "1.2.0"
},
"devDependencies": {
"@types/aws-lambda": "8.10.19",

View File

@@ -1,5 +1,4 @@
import { join, dirname, relative, parse as parsePath, sep } from 'path';
import { ChildProcess, SpawnOptions } from 'child_process';
import {
BuildOptions,
Lambda,
@@ -13,54 +12,22 @@ import {
getSpawnOptions,
runNpmInstall,
execCommand,
spawnCommand,
readConfigFile,
FileBlob,
FileFsRef,
NowBuildError,
} from '@vercel/build-utils';
import { makeAwsLauncher } from './launcher';
const {
getDependencies,
// eslint-disable-next-line @typescript-eslint/no-var-requires
} = require('@netlify/zip-it-and-ship-it/src/dependencies.js');
//@ts-ignore
import isPortReachable from 'is-port-reachable';
interface RedwoodConfig {
web?: {
port?: number;
apiProxyPath?: string;
};
api?: {
port?: number;
};
browser?: {
open?: boolean;
};
}
const LAUNCHER_FILENAME = '___vc_launcher';
const BRIDGE_FILENAME = '___vc_bridge';
const HELPERS_FILENAME = '___vc_helpers';
const SOURCEMAP_SUPPORT_FILENAME = '__vc_sourcemap_support';
const entrypointToPort = new Map<string, number>();
const childProcesses = new Set<ChildProcess>();
export const version = 2;
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
async function waitForPort(port: number): Promise<boolean> {
for (let i = 0; i < 500; i++) {
if (await isPortReachable(port)) {
return true;
}
await sleep(100);
}
return false;
}
export async function build({
workPath,
files,
@@ -89,46 +56,10 @@ export async function build({
const {
buildCommand = 'yarn rw db up --no-db-client --auto-approve && yarn rw build',
devCommand = 'yarn rw dev',
} = config;
if (meta.isDev) {
const toml = await readConfigFile<RedwoodConfig>(
join(mountpoint, 'redwood.toml')
);
const webPort = toml?.web?.port || 8910;
const apiPort = toml?.web?.port || 8911;
let devPort = entrypointToPort.get(entrypoint);
if (typeof devPort === 'number') {
debug('`%s` server already running for %j', devCommand, entrypoint);
} else {
devPort = webPort;
entrypointToPort.set(entrypoint, devPort);
const opts: SpawnOptions = {
cwd: mountpoint,
stdio: 'inherit',
env: { ...spawnOpts.env, PORT: String(devPort) },
};
const child = spawnCommand(devCommand, opts);
child.on('exit', () => entrypointToPort.delete(entrypoint));
childProcesses.add(child);
const found = await waitForPort(devPort);
if (!found) {
throw new NowBuildError({
code: 'REDWOOD_PORT_UNAVAILABLE',
message: `Failed to detect a server running on port ${devPort}`,
action: 'More Details',
link:
'https://err.sh/vercel/vercel/now-static-build-failed-to-detect-a-server',
});
}
debug('Detected dev server for %j', entrypoint);
}
debug('Detected @vercel/redwood dev, returning routes...');
let srcBase = mountpoint.replace(/^\.\/?/, '');
@@ -138,16 +69,11 @@ export async function build({
return {
routes: [
{
src: `${srcBase}/api/(.*)`,
dest: `http://localhost:${apiPort}/$1`,
},
{
src: `${srcBase}/(.*)`,
dest: `http://localhost:${webPort}/$1`,
dest: `http://localhost:$PORT/$1`,
},
],
watch: [join(srcBase, '**/*')],
output: {},
};
}

View File

@@ -3,6 +3,6 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"@redwoodjs/api": "0.14.0"
"@redwoodjs/api": "0.15.0"
}
}

View File

@@ -7,7 +7,7 @@
]
},
"devDependencies": {
"@redwoodjs/core": "0.14.0"
"@redwoodjs/core": "0.15.0"
},
"engines": {
"node": ">=12",

View File

@@ -14,7 +14,7 @@
"method": "POST",
"headers": { "Accept": "application/json" },
"body": { "query": "{ redwood { version } }" },
"mustContain": "0.14.0"
"mustContain": "0.15.0"
}
]
}

View File

@@ -6,8 +6,8 @@
"defaults"
],
"dependencies": {
"@redwoodjs/router": "0.14.0",
"@redwoodjs/web": "0.14.0",
"@redwoodjs/router": "0.15.0",
"@redwoodjs/web": "0.15.0",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1"

File diff suppressed because it is too large Load Diff

View File

@@ -2292,10 +2292,10 @@
resolved "https://registry.yarnpkg.com/@zeit/ncc/-/ncc-0.20.4.tgz#00f0a25a88cac3712af4ba66561d9e281c6f05c9"
integrity sha512-fmq+F/QxPec+k/zvT7HiVpk7oiGFseS6brfT/AYqmCUp6QFRK7vZf2Ref46MImsg/g2W3g5X6SRvGRmOAvEfdA==
"@zeit/node-file-trace@0.8.1":
version "0.8.1"
resolved "https://registry.yarnpkg.com/@zeit/node-file-trace/-/node-file-trace-0.8.1.tgz#ace86b366c86f0522e953a2441dfc915fd485df4"
integrity sha512-r92pdExhK1cf9Ao5LaT/Ii7JLwv9O4o987cB1SiFIbAnxvW4+xqR1oCYRRvtjU1ildKKGpiBBjGRChyeYRcvxw==
"@zeit/node-file-trace@0.8.2":
version "0.8.2"
resolved "https://registry.yarnpkg.com/@zeit/node-file-trace/-/node-file-trace-0.8.2.tgz#a00d21a98015c4ea18c8b1104ad60ea91b42dcca"
integrity sha512-M6KR95Xz9af8kB8X7e4inhoIjVoKNT6WxjLQwPByAAdCP6JdCg3Fb0dbTh2WelKlAibUpfS9nANU/HUDcfedSA==
dependencies:
acorn "^7.1.1"
acorn-class-fields "^0.3.2"