mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-12 12:57:47 +00:00
Compare commits
21 Commits
@now/php-b
...
@now/php-b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77d445af71 | ||
|
|
79251ad180 | ||
|
|
a215dc9103 | ||
|
|
ea7d8f0f6c | ||
|
|
2232efc984 | ||
|
|
b64ce0f3c0 | ||
|
|
74233d50ad | ||
|
|
8aebec9fc3 | ||
|
|
54584b7763 | ||
|
|
d163fcbd71 | ||
|
|
04c2996c76 | ||
|
|
2b69b898ed | ||
|
|
846aa11d6a | ||
|
|
a314a74479 | ||
|
|
40f029a72c | ||
|
|
493d8a778f | ||
|
|
cb5dcb658f | ||
|
|
d77287d07b | ||
|
|
61d66bd957 | ||
|
|
ae73df9e3c | ||
|
|
cb09ae5bbf |
19
lerna.json
19
lerna.json
@@ -2,7 +2,24 @@
|
|||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"useWorkspaces": true,
|
"useWorkspaces": true,
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/now-build-utils",
|
||||||
|
"packages/now-node-bridge",
|
||||||
|
"packages/now-php-bridge",
|
||||||
|
"packages/now-bash",
|
||||||
|
"packages/now-cgi",
|
||||||
|
"packages/now-go",
|
||||||
|
"packages/now-html-minifier",
|
||||||
|
"packages/now-lambda",
|
||||||
|
"packages/now-md",
|
||||||
|
"packages/now-mdx-deck",
|
||||||
|
"packages/now-next",
|
||||||
|
"packages/now-node",
|
||||||
|
"packages/now-node-server",
|
||||||
|
"packages/now-optipng",
|
||||||
|
"packages/now-php",
|
||||||
|
"packages/now-python",
|
||||||
|
"packages/now-static-build",
|
||||||
|
"packages/now-wordpress"
|
||||||
],
|
],
|
||||||
"command": {
|
"command": {
|
||||||
"publish": {
|
"publish": {
|
||||||
|
|||||||
32
packages/now-bash/.editorconfig
Normal file
32
packages/now-bash/.editorconfig
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[{*.json,*.json.example,*.gyp,*.yml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.py]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
# Ideal settings - some plugins might support these.
|
||||||
|
[*.js]
|
||||||
|
quote_type = single
|
||||||
|
|
||||||
|
[{*.c,*.cc,*.h,*.hh,*.cpp,*.hpp,*.m,*.mm,*.mpp,*.js,*.java,*.go,*.rs,*.php,*.ng,*.jsx,*.ts,*.d,*.cs,*.swift}]
|
||||||
|
curly_bracket_next_line = false
|
||||||
|
spaces_around_operators = true
|
||||||
|
spaces_around_brackets = outside
|
||||||
|
# close enough to 1TB
|
||||||
|
indent_brace_style = K&R
|
||||||
@@ -38,12 +38,3 @@ if ! declare -f handler > /dev/null; then
|
|||||||
echo "ERROR: A \`handler\` function must be defined in \"$ENTRYPOINT\"!" >&2
|
echo "ERROR: A \`handler\` function must be defined in \"$ENTRYPOINT\"!" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Show a tree of the final lambda build
|
|
||||||
show_tree() {
|
|
||||||
import "static-binaries@0.0.6"
|
|
||||||
static_binaries tree
|
|
||||||
echo "Final lambda file tree:"
|
|
||||||
tree -a .
|
|
||||||
}
|
|
||||||
IMPORT_DEBUG= IMPORT_CACHE="$(mktemp -d)" show_tree
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/bash",
|
"name": "@now/bash",
|
||||||
"version": "0.0.4-canary.1",
|
"version": "0.1.1",
|
||||||
"description": "Now 2.0 builder for HTTP endpoints written in Bash",
|
"description": "Now 2.0 builder for HTTP endpoints written in Bash",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "Nathan Rajlich <nate@zeit.co>",
|
"author": "Nathan Rajlich <nate@zeit.co>",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import "static-binaries@0.0.6"
|
import "static-binaries@1.0.0"
|
||||||
static_binaries jq
|
static_binaries jq
|
||||||
|
|
||||||
# These get reset upon each request
|
# These get reset upon each request
|
||||||
@@ -35,7 +35,7 @@ _lambda_runtime_next() {
|
|||||||
# Get an event
|
# Get an event
|
||||||
local event
|
local event
|
||||||
event="$(mktemp)"
|
event="$(mktemp)"
|
||||||
_lambda_runtime_api invocation/next -D "$headers" | jq -r '.body' > "$event"
|
_lambda_runtime_api invocation/next -D "$headers" | jq --raw-output --monochrome-output '.body' > "$event"
|
||||||
|
|
||||||
local request_id
|
local request_id
|
||||||
request_id="$(grep -Fi Lambda-Runtime-Aws-Request-Id "$headers" | tr -d '[:space:]' | cut -d: -f2)"
|
request_id="$(grep -Fi Lambda-Runtime-Aws-Request-Id "$headers" | tr -d '[:space:]' | cut -d: -f2)"
|
||||||
@@ -61,28 +61,25 @@ _lambda_runtime_next() {
|
|||||||
|
|
||||||
if [ "$exit_code" -eq 0 ]; then
|
if [ "$exit_code" -eq 0 ]; then
|
||||||
# Send the response
|
# Send the response
|
||||||
local response
|
jq --raw-input --raw-output --compact-output --slurp --monochrome-output \
|
||||||
response="$(jq -cnMr \
|
|
||||||
--arg statusCode "$(cat "$_STATUS_CODE")" \
|
--arg statusCode "$(cat "$_STATUS_CODE")" \
|
||||||
--argjson headers "$(cat "$_HEADERS")" \
|
--argjson headers "$(cat "$_HEADERS")" \
|
||||||
--arg body "$(base64 --wrap=0 < "$body")" \
|
'{statusCode:$statusCode|tonumber, headers:$headers, encoding:"base64", body:.|@base64}' < "$body" \
|
||||||
'{statusCode:$statusCode|tonumber, headers:$headers, encoding:"base64", body:$body}')"
|
| _lambda_runtime_api "invocation/$request_id/response" -X POST -d @- > /dev/null
|
||||||
rm -f "$body" "$_HEADERS"
|
rm -f "$body" "$_HEADERS"
|
||||||
_lambda_runtime_api "invocation/$request_id/response" -X POST -d "$response" > /dev/null
|
|
||||||
else
|
else
|
||||||
echo "\`handler\` function return code: $exit_code"
|
echo "\`handler\` function return code: $exit_code"
|
||||||
local error='{"exitCode":'"$exit_code"'}'
|
_lambda_runtime_api "invocation/$request_id/error" -X POST -d @- > /dev/null <<< '{"exitCode":'"$exit_code"'}'
|
||||||
_lambda_runtime_api "invocation/$request_id/error" -X POST -d "$error" > /dev/null
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_lambda_runtime_body() {
|
_lambda_runtime_body() {
|
||||||
if [ "$(jq -r '.body | type' < "$1")" = "string" ]; then
|
if [ "$(jq --raw-output '.body | type' < "$1")" = "string" ]; then
|
||||||
if [ "$(jq -r '.encoding' < "$1")" = "base64" ]; then
|
if [ "$(jq --raw-output '.encoding' < "$1")" = "base64" ]; then
|
||||||
jq -r '.body' < "$1" | base64 -d
|
jq --raw-output '.body' < "$1" | base64 -d
|
||||||
else
|
else
|
||||||
# assume plain-text body
|
# assume plain-text body
|
||||||
jq -r '.body' < "$1"
|
jq --raw-output '.body' < "$1"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class FileRef {
|
|||||||
const resp = await fetch(url);
|
const resp = await fetch(url);
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
const error = new BailableError(
|
const error = new BailableError(
|
||||||
`${resp.status} ${resp.statusText}`,
|
`download: ${resp.status} ${resp.statusText} for ${url}`,
|
||||||
);
|
);
|
||||||
if (resp.status === 403) error.bail = true;
|
if (resp.status === 403) error.bail = true;
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
|
||||||
const dev = !process.env.AWS_EXECUTION_ENV;
|
const prod = process.env.AWS_EXECUTION_ENV || process.env.X_GOOGLE_CODE_LOCATION;
|
||||||
const TMP_PATH = dev ? path.join(process.cwd(), 'tmp') : '/tmp';
|
const TMP_PATH = prod ? '/tmp' : path.join(__dirname, 'tmp');
|
||||||
|
|
||||||
module.exports = async function getWritableDirectory() {
|
module.exports = async function getWritableDirectory() {
|
||||||
const name = Math.floor(Math.random() * 0x7fffffff).toString(16);
|
const name = Math.floor(Math.random() * 0x7fffffff).toString(16);
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ const fs = require('fs-extra');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { spawn } = require('child_process');
|
const { spawn } = require('child_process');
|
||||||
|
|
||||||
|
const prod = process.env.AWS_EXECUTION_ENV
|
||||||
|
|| process.env.X_GOOGLE_CODE_LOCATION;
|
||||||
|
|
||||||
function spawnAsync(command, args, cwd) {
|
function spawnAsync(command, args, cwd) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const child = spawn(command, args, { stdio: 'inherit', cwd });
|
const child = spawn(command, args, { stdio: 'inherit', cwd });
|
||||||
@@ -52,7 +55,7 @@ async function scanParentDirs(destPath, scriptName) {
|
|||||||
return { hasScript, hasPackageLockJson };
|
return { hasScript, hasPackageLockJson };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runNpmInstall(destPath, args = []) {
|
async function installDependencies(destPath, args = []) {
|
||||||
assert(path.isAbsolute(destPath));
|
assert(path.isAbsolute(destPath));
|
||||||
|
|
||||||
let commandArgs = args;
|
let commandArgs = args;
|
||||||
@@ -63,7 +66,7 @@ async function runNpmInstall(destPath, args = []) {
|
|||||||
commandArgs = args.filter(a => a !== '--prefer-offline');
|
commandArgs = args.filter(a => a !== '--prefer-offline');
|
||||||
await spawnAsync('npm', ['install'].concat(commandArgs), destPath);
|
await spawnAsync('npm', ['install'].concat(commandArgs), destPath);
|
||||||
await spawnAsync('npm', ['cache', 'clean', '--force'], destPath);
|
await spawnAsync('npm', ['cache', 'clean', '--force'], destPath);
|
||||||
} else if (process.env.AWS_EXECUTION_ENV) {
|
} else if (prod) {
|
||||||
console.log('using memory-fs for yarn cache');
|
console.log('using memory-fs for yarn cache');
|
||||||
await spawnAsync(
|
await spawnAsync(
|
||||||
'node',
|
'node',
|
||||||
@@ -99,6 +102,7 @@ async function runPackageJsonScript(destPath, scriptName) {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
runShellScript,
|
runShellScript,
|
||||||
runNpmInstall,
|
installDependencies,
|
||||||
|
runNpmInstall: installDependencies,
|
||||||
runPackageJsonScript,
|
runPackageJsonScript,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/build-utils",
|
"name": "@now/build-utils",
|
||||||
"version": "0.4.32-canary.4",
|
"version": "0.4.32",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async-retry": "1.2.3",
|
"async-retry": "1.2.3",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/cgi",
|
"name": "@now/cgi",
|
||||||
"version": "0.0.15-canary.0",
|
"version": "0.0.15",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "best -I test/*.js",
|
"test": "best -I test/*.js",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/go",
|
"name": "@now/go",
|
||||||
"version": "0.2.12-canary.0",
|
"version": "0.2.12",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "best -I test/*.js",
|
"test": "best -I test/*.js",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/html-minifier",
|
"name": "@now/html-minifier",
|
||||||
"version": "1.0.7-canary.0",
|
"version": "1.0.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"html-minifier": "3.5.21"
|
"html-minifier": "3.5.21"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/lambda",
|
"name": "@now/lambda",
|
||||||
"version": "0.4.9-canary.0",
|
"version": "0.4.9",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@now/build-utils": ">=0.0.1"
|
"@now/build-utils": ">=0.0.1"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/md",
|
"name": "@now/md",
|
||||||
"version": "0.4.9-canary.0",
|
"version": "0.4.9",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"rehype-document": "^2.2.0",
|
"rehype-document": "^2.2.0",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ exports.build = async ({ files, entrypoint, workPath }) => {
|
|||||||
const packageJson = { dependencies: { 'mdx-deck': '1.7.15' } };
|
const packageJson = { dependencies: { 'mdx-deck': '1.7.15' } };
|
||||||
const packageJsonPath = path.join(workPath, 'package.json');
|
const packageJsonPath = path.join(workPath, 'package.json');
|
||||||
await writeFile(packageJsonPath, JSON.stringify(packageJson));
|
await writeFile(packageJsonPath, JSON.stringify(packageJson));
|
||||||
console.log('running npm install...');
|
console.log('installing dependencies...');
|
||||||
process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = '1'; // TODO opts argument for runNpmInstall
|
process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = '1'; // TODO opts argument for runNpmInstall
|
||||||
await runNpmInstall(path.dirname(packageJsonPath), [
|
await runNpmInstall(path.dirname(packageJsonPath), [
|
||||||
'--prod',
|
'--prod',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/mdx-deck",
|
"name": "@now/mdx-deck",
|
||||||
"version": "0.4.18-canary.1",
|
"version": "0.4.18",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@now/build-utils": ">=0.0.1"
|
"@now/build-utils": ">=0.0.1"
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ exports.build = async ({ files, workPath, entrypoint }) => {
|
|||||||
await writeNpmRc(workPath, process.env.NPM_AUTH_TOKEN);
|
await writeNpmRc(workPath, process.env.NPM_AUTH_TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('running npm install...');
|
console.log('installing dependencies...');
|
||||||
await runNpmInstall(workPath, ['--prefer-offline']);
|
await runNpmInstall(workPath, ['--prefer-offline']);
|
||||||
console.log('running user script...');
|
console.log('running user script...');
|
||||||
await runPackageJsonScript(workPath, 'now-build');
|
await runPackageJsonScript(workPath, 'now-build');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/next",
|
"name": "@now/next",
|
||||||
"version": "0.0.83-canary.0",
|
"version": "0.0.84",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@now/node-bridge": "0.1.4",
|
"@now/node-bridge": "0.1.4",
|
||||||
|
|||||||
@@ -91,7 +91,14 @@ class Bridge {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
req.on('error', reject);
|
req.on('error', (error) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
// this lets express print the true error of why the connection was closed.
|
||||||
|
// it is probably 'Cannot set headers after they are sent to the client'
|
||||||
|
reject(error);
|
||||||
|
}, 2);
|
||||||
|
});
|
||||||
|
|
||||||
if (body) req.write(body);
|
if (body) req.write(body);
|
||||||
req.end();
|
req.end();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/node-bridge",
|
"name": "@now/node-bridge",
|
||||||
"version": "0.1.10-canary.1",
|
"version": "0.1.10",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@now/build-utils": ">=0.0.1"
|
"@now/build-utils": ">=0.0.1"
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ async function downloadInstallAndBundle(
|
|||||||
console.log('downloading user files...');
|
console.log('downloading user files...');
|
||||||
const downloadedFiles = await download(files, userPath);
|
const downloadedFiles = await download(files, userPath);
|
||||||
|
|
||||||
console.log('running npm install for user...');
|
console.log('installing dependencies for user\'s code...');
|
||||||
const entrypointFsDirname = path.join(userPath, path.dirname(entrypoint));
|
const entrypointFsDirname = path.join(userPath, path.dirname(entrypoint));
|
||||||
await runNpmInstall(entrypointFsDirname, npmArguments);
|
await runNpmInstall(entrypointFsDirname, npmArguments);
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ async function downloadInstallAndBundle(
|
|||||||
'package.json': new FileBlob({
|
'package.json': new FileBlob({
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
dependencies: {
|
dependencies: {
|
||||||
'@zeit/ncc': '0.6.0',
|
'@zeit/ncc': '0.11.0',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
@@ -55,7 +55,7 @@ async function downloadInstallAndBundle(
|
|||||||
nccPath,
|
nccPath,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('running npm install for ncc...');
|
console.log('installing dependencies for ncc...');
|
||||||
await runNpmInstall(nccPath, npmArguments);
|
await runNpmInstall(nccPath, npmArguments);
|
||||||
return [downloadedFiles, userPath, nccPath, entrypointFsDirname];
|
return [downloadedFiles, userPath, nccPath, entrypointFsDirname];
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,8 @@ async function compile(workNccPath, downloadedFiles, entrypoint) {
|
|||||||
preparedFiles[path.join('user', entrypoint)] = blob;
|
preparedFiles[path.join('user', entrypoint)] = blob;
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
for (const assetName of Object.keys(assets)) {
|
for (const assetName of Object.keys(assets)) {
|
||||||
const blob2 = new FileBlob({ data: assets[assetName] });
|
const { source: data, permissions: mode } = assets[assetName];
|
||||||
|
const blob2 = new FileBlob({ data, mode });
|
||||||
preparedFiles[
|
preparedFiles[
|
||||||
path.join('user', path.dirname(entrypoint), assetName)
|
path.join('user', path.dirname(entrypoint), assetName)
|
||||||
] = blob2;
|
] = blob2;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/node-server",
|
"name": "@now/node-server",
|
||||||
"version": "0.4.26-canary.6",
|
"version": "0.4.26",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@now/node-bridge": "^0.1.10-canary.1",
|
"@now/node-bridge": "^0.1.10",
|
||||||
"fs-extra": "7.0.1"
|
"fs-extra": "7.0.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
7
packages/now-node-server/test/fixtures/06-content-type/index.js
vendored
Normal file
7
packages/now-node-server/test/fixtures/06-content-type/index.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
const http = require('http');
|
||||||
|
|
||||||
|
const server = http.createServer((req, resp) => {
|
||||||
|
resp.end('RANDOMNESS_PLACEHOLDER');
|
||||||
|
});
|
||||||
|
|
||||||
|
server.listen();
|
||||||
6
packages/now-node-server/test/fixtures/06-content-type/now.json
vendored
Normal file
6
packages/now-node-server/test/fixtures/06-content-type/now.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"builds": [
|
||||||
|
{ "src": "index.js", "use": "@now/node-server" }
|
||||||
|
]
|
||||||
|
}
|
||||||
7
packages/now-node-server/test/fixtures/06-content-type/probe.js
vendored
Normal file
7
packages/now-node-server/test/fixtures/06-content-type/probe.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
module.exports = async ({ deploymentUrl, fetch, randomness }) => {
|
||||||
|
const resp = await fetch(`https://${deploymentUrl}/`);
|
||||||
|
assert.equal(resp.headers.get('content-type'), null);
|
||||||
|
assert.equal(await resp.text(), randomness);
|
||||||
|
};
|
||||||
@@ -2,7 +2,7 @@ const http = require('http');
|
|||||||
const isBundled = require('./is-bundled.js');
|
const isBundled = require('./is-bundled.js');
|
||||||
|
|
||||||
const server = http.createServer((req, resp) => {
|
const server = http.createServer((req, resp) => {
|
||||||
resp.end(isBundled() ? 'RANDOMNESS_PLACEHOLDER:with-bundle' : '');
|
resp.end(isBundled() ? 'RANDOMNESS_PLACEHOLDER:with-bundle' : 'WITHOUT-BUNDLE-THAT-IS-WRONG');
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen();
|
server.listen();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
module.exports = () => path.basename(__filename) === 'index.js';
|
// eslint-disable-next-line no-eval
|
||||||
|
module.exports = () => path.basename(eval('__filename')) === 'index.js';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const http = require('http');
|
|||||||
const isBundled = require('./is-bundled.js');
|
const isBundled = require('./is-bundled.js');
|
||||||
|
|
||||||
const server = http.createServer((req, resp) => {
|
const server = http.createServer((req, resp) => {
|
||||||
resp.end(isBundled() ? '' : 'RANDOMNESS_PLACEHOLDER:without-bundle');
|
resp.end(isBundled() ? 'WITH-BUNDLE-THAT-IS-WRONG' : 'RANDOMNESS_PLACEHOLDER:without-bundle');
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen();
|
server.listen();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
module.exports = () => path.basename(__filename) === 'index.js';
|
// eslint-disable-next-line no-eval
|
||||||
|
module.exports = () => path.basename(eval('__filename')) === 'index.js';
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ async function downloadInstallAndBundle(
|
|||||||
console.log('downloading user files...');
|
console.log('downloading user files...');
|
||||||
const downloadedFiles = await download(files, userPath);
|
const downloadedFiles = await download(files, userPath);
|
||||||
|
|
||||||
console.log('running npm install for user...');
|
console.log('installing dependencies for user\'s code...');
|
||||||
const entrypointFsDirname = path.join(userPath, path.dirname(entrypoint));
|
const entrypointFsDirname = path.join(userPath, path.dirname(entrypoint));
|
||||||
await runNpmInstall(entrypointFsDirname, npmArguments);
|
await runNpmInstall(entrypointFsDirname, npmArguments);
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ async function downloadInstallAndBundle(
|
|||||||
'package.json': new FileBlob({
|
'package.json': new FileBlob({
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
dependencies: {
|
dependencies: {
|
||||||
'@zeit/ncc': '0.6.0',
|
'@zeit/ncc': '0.11.0',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
@@ -53,7 +53,7 @@ async function downloadInstallAndBundle(
|
|||||||
nccPath,
|
nccPath,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('running npm install for ncc...');
|
console.log('installing dependencies for ncc...');
|
||||||
await runNpmInstall(nccPath, npmArguments);
|
await runNpmInstall(nccPath, npmArguments);
|
||||||
return [downloadedFiles, nccPath, entrypointFsDirname];
|
return [downloadedFiles, nccPath, entrypointFsDirname];
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,8 @@ async function compile(workNccPath, downloadedFiles, entrypoint) {
|
|||||||
preparedFiles[path.join('user', entrypoint)] = blob;
|
preparedFiles[path.join('user', entrypoint)] = blob;
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
for (const assetName of Object.keys(assets)) {
|
for (const assetName of Object.keys(assets)) {
|
||||||
const blob2 = new FileBlob({ data: assets[assetName] });
|
const { source: data, permissions: mode } = assets[assetName];
|
||||||
|
const blob2 = new FileBlob({ data, mode });
|
||||||
preparedFiles[
|
preparedFiles[
|
||||||
path.join('user', path.dirname(entrypoint), assetName)
|
path.join('user', path.dirname(entrypoint), assetName)
|
||||||
] = blob2;
|
] = blob2;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/node",
|
"name": "@now/node",
|
||||||
"version": "0.4.28-canary.5",
|
"version": "0.4.28",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@now/node-bridge": "^0.1.10-canary.1",
|
"@now/node-bridge": "^0.1.10",
|
||||||
"fs-extra": "7.0.1"
|
"fs-extra": "7.0.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
@@ -4,21 +4,24 @@ async function test1({ deploymentUrl, fetch, randomness }) {
|
|||||||
const bodyMustBe = `${randomness}:content-length`;
|
const bodyMustBe = `${randomness}:content-length`;
|
||||||
const resp = await fetch(`https://${deploymentUrl}/test1.js`);
|
const resp = await fetch(`https://${deploymentUrl}/test1.js`);
|
||||||
assert.equal(resp.status, 401);
|
assert.equal(resp.status, 401);
|
||||||
assert.equal(resp.headers.get('content-length'), bodyMustBe.length);
|
|
||||||
assert.equal(await resp.text(), bodyMustBe);
|
assert.equal(await resp.text(), bodyMustBe);
|
||||||
|
assert.equal(resp.headers.get('content-length'), bodyMustBe.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function test2({ deploymentUrl, fetch }) {
|
async function test2({ deploymentUrl, fetch }) {
|
||||||
|
const bodyMustBe = '';
|
||||||
const resp = await fetch(`https://${deploymentUrl}/test2.js`);
|
const resp = await fetch(`https://${deploymentUrl}/test2.js`);
|
||||||
assert.equal(resp.status, 502);
|
assert.equal(resp.status, 401);
|
||||||
|
assert.equal(await resp.text(), bodyMustBe);
|
||||||
|
assert.equal(resp.headers.get('content-length'), bodyMustBe.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function test3({ deploymentUrl, fetch, randomness }) {
|
async function test3({ deploymentUrl, fetch, randomness }) {
|
||||||
const bodyMustBe = `${randomness}:content-length`;
|
const bodyMustBe = `${randomness}:content-length`;
|
||||||
const resp = await fetch(`https://${deploymentUrl}/test3.js`);
|
const resp = await fetch(`https://${deploymentUrl}/test3.js`);
|
||||||
assert.equal(resp.status, 401);
|
assert.equal(resp.status, 401);
|
||||||
assert.equal(resp.headers.get('content-length'), null);
|
|
||||||
assert.equal(await resp.text(), bodyMustBe);
|
assert.equal(await resp.text(), bodyMustBe);
|
||||||
|
assert.equal(resp.headers.get('content-length'), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = async ({ deploymentUrl, fetch, randomness }) => {
|
module.exports = async ({ deploymentUrl, fetch, randomness }) => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module.exports = (_, resp) => {
|
module.exports = (_, resp) => {
|
||||||
resp.writeHead(401, { 'content-length': 2 });
|
resp.writeHead(401, { 'content-length': 2 });
|
||||||
resp.end(`${process.env.RANDOMNESS_ENV_VAR}:content-length`);
|
resp.end();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/optipng",
|
"name": "@now/optipng",
|
||||||
"version": "0.4.8-canary.0",
|
"version": "0.4.8",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"multipipe": "2.0.3",
|
"multipipe": "2.0.3",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/php-bridge",
|
"name": "@now/php-bridge",
|
||||||
"version": "0.4.13-canary.1",
|
"version": "0.4.13",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fastcgi-client": "0.0.1"
|
"fastcgi-client": "0.0.1"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/php",
|
"name": "@now/php",
|
||||||
"version": "0.4.13-canary.2",
|
"version": "0.4.13",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@now/php-bridge": "^0.4.13-canary.1"
|
"@now/php-bridge": "^0.4.13"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@now/build-utils": ">=0.0.1"
|
"@now/build-utils": ">=0.0.1"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/static-build",
|
"name": "@now/static-build",
|
||||||
"version": "0.4.17-canary.0",
|
"version": "0.4.17",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@now/build-utils": ">=0.0.1"
|
"@now/build-utils": ">=0.0.1"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@now/wordpress",
|
"name": "@now/wordpress",
|
||||||
"version": "0.4.14-canary.1",
|
"version": "0.4.14",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@now/php-bridge": "^0.4.13-canary.1",
|
"@now/php-bridge": "^0.4.13",
|
||||||
"node-fetch": "2.3.0",
|
"node-fetch": "2.3.0",
|
||||||
"yauzl": "2.10.0"
|
"yauzl": "2.10.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,6 +20,22 @@ it(
|
|||||||
FOUR_MINUTES,
|
FOUR_MINUTES,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it(
|
||||||
|
'Should build the monorepo example',
|
||||||
|
async () => {
|
||||||
|
const { buildResult } = await runBuildLambda(
|
||||||
|
path.join(__dirname, 'monorepo'),
|
||||||
|
);
|
||||||
|
expect(buildResult['www/index']).toBeDefined();
|
||||||
|
const filePaths = Object.keys(buildResult);
|
||||||
|
const hasUnderScoreAppStaticFile = filePaths.some(filePath => filePath.match(/static.*\/pages\/_app\.js$/));
|
||||||
|
const hasUnderScoreErrorStaticFile = filePaths.some(filePath => filePath.match(/static.*\/pages\/_error\.js$/));
|
||||||
|
expect(hasUnderScoreAppStaticFile).toBeTruthy();
|
||||||
|
expect(hasUnderScoreErrorStaticFile).toBeTruthy();
|
||||||
|
},
|
||||||
|
FOUR_MINUTES,
|
||||||
|
);
|
||||||
|
|
||||||
it(
|
it(
|
||||||
'Should build the legacy standard example',
|
'Should build the legacy standard example',
|
||||||
async () => {
|
async () => {
|
||||||
|
|||||||
6
test/integration/now-next/monorepo/now.json
Normal file
6
test/integration/now-next/monorepo/now.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"builds": [
|
||||||
|
{ "src": "www/package.json", "use": "@now/next" }
|
||||||
|
]
|
||||||
|
}
|
||||||
3
test/integration/now-next/monorepo/www/next.config.js
Normal file
3
test/integration/now-next/monorepo/www/next.config.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
target: 'serverless',
|
||||||
|
};
|
||||||
11
test/integration/now-next/monorepo/www/package.json
Normal file
11
test/integration/now-next/monorepo/www/package.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "monorepo",
|
||||||
|
"dependencies": {
|
||||||
|
"next": "^8.0.0-canary.2",
|
||||||
|
"react": "^16.7.0",
|
||||||
|
"react-dom": "^16.7.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"now-build": "next build"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
test/integration/now-next/monorepo/www/pages/index.js
Normal file
1
test/integration/now-next/monorepo/www/pages/index.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export default () => 'Index page';
|
||||||
@@ -114,7 +114,11 @@ async function fetchWithAuth (url, opts = {}) {
|
|||||||
|
|
||||||
if (!opts.headers.Authorization) {
|
if (!opts.headers.Authorization) {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
const { NOW_TOKEN_FACTORY_URL } = process.env;
|
const { NOW_TOKEN, NOW_TOKEN_FACTORY_URL } = process.env;
|
||||||
|
|
||||||
|
if (NOW_TOKEN) {
|
||||||
|
token = NOW_TOKEN;
|
||||||
|
} else
|
||||||
if (NOW_TOKEN_FACTORY_URL) {
|
if (NOW_TOKEN_FACTORY_URL) {
|
||||||
const resp = await fetch(NOW_TOKEN_FACTORY_URL);
|
const resp = await fetch(NOW_TOKEN_FACTORY_URL);
|
||||||
token = (await resp.json()).token;
|
token = (await resp.json()).token;
|
||||||
|
|||||||
Reference in New Issue
Block a user