Compare commits

..

14 Commits

Author SHA1 Message Date
Steven
89172a6e89 Publish
- @now/go@0.5.0
 - @now/next@0.4.0
 - @now/node-bridge@1.1.3
 - @now/node-server@0.7.3
 - @now/node@0.7.3
 - @now/python@0.2.4
 - @now/static-build@0.5.7
2019-05-24 12:29:57 -04:00
Steven
e8f1dbaa46 Empty commit to satisfy lerna 2019-05-24 12:27:37 -04:00
Sophearak Tha
16b5b6fdf3 Publish
- @now/python@0.2.4-canary.2
2019-05-24 20:59:19 +07:00
Sophearak Tha
3bab29ff76 Add custom path and proper check (#527)
* Add custom path and proper check

* Change route tests to use another name
2019-05-24 20:55:28 +07:00
Sophearak Tha
d675d2e668 Use unquote() for http handler (#525)
* Use unquote() for http handler

* Add tests for url params http handler
2019-05-24 20:27:44 +07:00
Joe Haddad
2dda88e676 Publish
- @now/next@0.3.4-canary.4
2019-05-23 15:32:28 -07:00
Joe Haddad
5a0090eb1f [now-next] Ensure route begins with a slash (#524)
* Ensure route begins with a slash

* Simplift

* Apply suggestions from code review

Co-Authored-By: Connor Davis <mail@connordav.is>

* Adjust spacing
2019-05-23 15:31:13 -07:00
Sophearak Tha
d438b4ec4e Publish
- @now/go@0.4.8-canary.1
 - @now/python@0.2.4-canary.1
2019-05-23 20:34:53 +07:00
Sophearak Tha
f8810fd7e6 [now-python] Make sure to pass decode url params (#496)
* Make sure to pass decode url params

* Add tests cover default and custom routes behaviour on url param

* Removed `unquote` since `urlparse` already return expected value

* Using unquote in both PATH_INFO and QUERY_STRING

* Better code structure now_init.py

* Better test
2019-05-23 09:27:44 -04:00
Sophearak Tha
a642cfea96 [now-go] Add option to use private Git for go get (#513)
* Add option to use private Git

* Update packages/now-go/index.ts

Co-Authored-By: Steven <steven@ceriously.com>

* Fix import error

* Using `GIT_CREDENTIALS` over multiple env vars

* Ignore initialize Git credentials in `meta.isDev`
2019-05-23 11:39:36 +07:00
Joe Haddad
2daa20a9f2 Publish
- @now/next@0.3.4-canary.3
2019-05-22 18:36:15 -07:00
JJ Kasper
4d5c0c40f0 [now-next] Update to use routes for static pages (#521) 2019-05-22 20:25:10 -05:00
Joe Haddad
29051681df Publish
- @now/next@0.3.4-canary.2
2019-05-22 16:18:59 -07:00
JJ Kasper
96d5e81538 [now-next] Handle statically exported pages (#520)
* Add support for auto exported pages

* Add entryDirectory to staticPages mapping

* Map to FsFileRef instead of path
2019-05-22 16:14:24 -07:00
17 changed files with 114 additions and 26 deletions

View File

@@ -1,5 +1,7 @@
import { join, sep, dirname, basename } from 'path';
import { readFile, writeFile, pathExists, move, copy } from 'fs-extra';
import { homedir } from 'os';
import execa from 'execa';
import {
glob,
@@ -29,6 +31,18 @@ interface BuildParamsType extends BuildOptions {
meta: BuildParamsMeta;
}
// Initialize private git repo for Go Modules
async function initPrivateGit(credentials: string) {
await execa('git', [
'config',
'--global',
'credential.helper',
`store --file ${join(homedir(), '.git-credentials')}`,
]);
await writeFile(join(homedir(), '.git-credentials'), credentials);
}
export const version = 2;
export const config = {
@@ -42,6 +56,11 @@ export async function build({
workPath,
meta = {} as BuildParamsMeta,
}: BuildParamsType) {
if (process.env.GIT_CREDENTIALS && !meta.isDev) {
console.log('Initialize Git credentials...');
await initPrivateGit(process.env.GIT_CREDENTIALS);
}
console.log('Downloading user files...');
const entrypointArr = entrypoint.split(sep);

View File

@@ -1,6 +1,6 @@
{
"name": "@now/go",
"version": "0.4.8-canary.0",
"version": "0.5.0",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -1,6 +1,6 @@
{
"name": "@now/next",
"version": "0.3.4-canary.1",
"version": "0.4.0",
"license": "MIT",
"main": "./dist/index",
"scripts": {
@@ -14,7 +14,7 @@
"directory": "packages/now-next"
},
"dependencies": {
"@now/node-bridge": "^1.1.3-canary.0",
"@now/node-bridge": "^1.1.3",
"fs-extra": "^7.0.0",
"get-port": "^5.0.0",
"resolve-from": "^5.0.0",

View File

@@ -155,14 +155,13 @@ export const build = async ({
entrypoint,
meta = {} as BuildParamsMeta,
}: BuildParamsType): Promise<{
routes?: any[];
routes?: { src: string; dest: string }[];
output: Files;
watch?: string[];
childProcesses: ChildProcess[];
}> => {
validateEntrypoint(entrypoint);
const routes: any[] = [];
const entryDirectory = path.dirname(entrypoint);
const entryPath = path.join(workPath, entryDirectory);
const dotNext = path.join(entryPath, '.next');
@@ -289,7 +288,9 @@ export const build = async ({
await unlinkFile(path.join(entryPath, '.npmrc'));
}
const routes: { src: string; dest: string }[] = [];
const lambdas: { [key: string]: Lambda } = {};
const staticPages: { [key: string]: FileFsRef } = {};
if (isLegacy) {
const filesAfterBuild = await glob('**', entryPath);
@@ -381,10 +382,21 @@ export const build = async ({
fsPath: path.join(__dirname, 'launcher.js'),
}),
};
const pages = await glob(
'**/*.js',
path.join(entryPath, '.next', 'serverless', 'pages')
);
const pagesDir = path.join(entryPath, '.next', 'serverless', 'pages');
const pages = await glob('**/*.js', pagesDir);
const staticPageFiles = await glob('**/*.html', pagesDir);
Object.keys(staticPageFiles).forEach((page: string) => {
const staticRoute = path.join(entryDirectory, page);
staticPages[staticRoute] = staticPageFiles[page];
const pathname = page.replace(/\.html$/, '');
routes.push({
src: `^${path.join('/', entryDirectory, pathname)}$`,
dest: path.join('/', staticRoute),
});
});
const pageKeys = Object.keys(pages);
@@ -473,10 +485,11 @@ export const build = async ({
output: {
...publicFiles,
...lambdas,
...staticPages,
...staticFiles,
...staticDirectoryFiles,
},
routes: [],
routes,
watch: [],
childProcesses: [],
};

View File

@@ -1,6 +1,6 @@
{
"name": "@now/node-bridge",
"version": "1.1.3-canary.0",
"version": "1.1.3",
"license": "MIT",
"main": "./index.js",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@now/node-server",
"version": "0.7.3-canary.0",
"version": "0.7.3",
"license": "MIT",
"repository": {
"type": "git",
@@ -8,7 +8,7 @@
"directory": "packages/now-node-server"
},
"dependencies": {
"@now/node-bridge": "^1.1.3-canary.0",
"@now/node-bridge": "^1.1.3",
"@zeit/ncc": "0.18.5",
"fs-extra": "7.0.1"
},

View File

@@ -1,6 +1,6 @@
{
"name": "@now/node",
"version": "0.7.3-canary.0",
"version": "0.7.3",
"license": "MIT",
"main": "./dist/index",
"repository": {
@@ -9,7 +9,7 @@
"directory": "packages/now-node"
},
"dependencies": {
"@now/node-bridge": "^1.1.3-canary.0",
"@now/node-bridge": "^1.1.3",
"@zeit/ncc": "0.18.5",
"fs-extra": "7.0.1"
},

View File

@@ -22,6 +22,7 @@ _now_imported, _now_is_legacy = _now_get_import()
if _now_is_legacy:
print('using HTTP Handler')
from http.server import HTTPServer
from urllib.parse import unquote
import requests
import _thread
server = HTTPServer(('', 0), _now_imported)
@@ -30,7 +31,7 @@ if _now_is_legacy:
_thread.start_new_thread(server.handle_request, ())
payload = json.loads(event['body'])
path = payload['path']
path = unquote(payload['path'])
headers = payload['headers']
method = payload['method']
encoding = payload.get('encoding')
@@ -53,10 +54,7 @@ if _now_is_legacy:
else:
print('using Web Server Gateway Interface (WSGI)')
import sys
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
from urllib.parse import urlparse, unquote
from werkzeug._compat import BytesIO
from werkzeug._compat import string_types
from werkzeug._compat import to_bytes
@@ -75,13 +73,14 @@ else:
if isinstance(body, string_types):
body = to_bytes(body, charset='utf-8')
urlinfo = urlparse(payload['path'])
path = unquote(payload['path'])
query = urlparse(path).query
environ = {
'CONTENT_LENGTH': str(len(body)),
'CONTENT_TYPE': headers.get('content-type', ''),
'PATH_INFO': payload['path'],
'QUERY_STRING': urlinfo.query,
'PATH_INFO': path,
'QUERY_STRING': query,
'REMOTE_ADDR': headers.get(
'x-forwarded-for', headers.get(
'x-real-ip', payload.get(
@@ -102,7 +101,7 @@ else:
}
for key, value in environ.items():
if isinstance(value, string_types):
if isinstance(value, string_types) and key != 'QUERY_STRING':
environ[key] = wsgi_encoding_dance(value)
for key, value in headers.items():

View File

@@ -1,6 +1,6 @@
{
"name": "@now/python",
"version": "0.2.4-canary.0",
"version": "0.2.4",
"main": "index.js",
"license": "MIT",
"repository": {

View File

@@ -0,0 +1,7 @@
from flask import Flask, Response, __version__
app = Flask(__name__)
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
return Response("path=%s" %(path), mimetype='text/html')

View File

@@ -0,0 +1,7 @@
from flask import Flask, Response, __version__
app = Flask(__name__)
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
return Response("path=%s" %(path), mimetype='text/html')

View File

@@ -0,0 +1,13 @@
{
"version": 2,
"builds": [
{ "src": "*.py", "use": "@now/python" }
],
"routes": [
{ "src": "/another", "dest": "custom.py" }
],
"probes": [
{ "path": "/?hello=/", "mustContain": "path=?hello=/" },
{ "path": "/another?hello=/", "mustContain": "path=another?hello=/" }
]
}

View File

@@ -0,0 +1 @@
Flask==1.0.2

View File

@@ -0,0 +1,8 @@
from http.server import BaseHTTPRequestHandler
class handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write(str("path=").encode()+self.path.encode())
return

View File

@@ -0,0 +1,8 @@
from http.server import BaseHTTPRequestHandler
class handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write(str("path=").encode()+self.path.encode())
return

View File

@@ -0,0 +1,13 @@
{
"version": 2,
"builds": [
{ "src": "*.py", "use": "@now/python" }
],
"routes": [
{ "src": "/another", "dest": "custom.py" }
],
"probes": [
{ "path": "/?hello=/", "mustContain": "path=/?hello=/" },
{ "path": "/another?hello=/", "mustContain": "path=/another?hello=/" }
]
}

View File

@@ -1,6 +1,6 @@
{
"name": "@now/static-build",
"version": "0.5.7-canary.0",
"version": "0.5.7",
"license": "MIT",
"repository": {
"type": "git",