Compare commits

..

33 Commits

Author SHA1 Message Date
Andy Bitz
3ed99a5b25 Publish
- @now/next@0.5.4
2019-07-10 23:43:45 +02:00
Andy
f8b08926f2 [now-next] Create a serverless config by creating a new config (#688)
* [now-next] Create a serverless config by creating a new config

* Adjust config for promises

* Add tests and fixes

* Fix the tests

* Always create the config for non-dev mode

* Removed unused version

* Handle promises

* Adjust test

* Removed semver check

* Removed import

* Try tests

* Update tests

* Log results

* Add more logging

* More logging

* Fixed typo and removed logging
2019-07-10 23:43:03 +02:00
Andy Bitz
354e80b3e3 Publish
- @now/build-utils@0.8.3
2019-07-10 17:47:53 +02:00
Andy Bitz
0cfb4a8466 Revert "Remove deprecated builders (#733)"
This reverts commit 6766e9a099.
2019-07-10 17:44:31 +02:00
Andy Bitz
8facd2845f Revert "[now-node-server] Remove package source code (#721)"
This reverts commit d327426c93.
2019-07-10 17:44:28 +02:00
Andy Bitz
9dae464fa6 Revert "Publish"
This reverts commit 6ff4b25d79.
2019-07-10 17:43:42 +02:00
Andy Bitz
6ff4b25d79 Publish
- @now/build-utils@0.8.3
 - @now/node@0.11.2
2019-07-10 17:39:49 +02:00
Steven
6766e9a099 Remove deprecated builders (#733)
* Remove deprecated builders

* Update comment so that tests  run
2019-07-10 17:38:59 +02:00
Steven
d327426c93 [now-node-server] Remove package source code (#721)
* [now-node-server] Remove package

* Update comment so tests run
2019-07-10 17:36:07 +02:00
Andy Bitz
47f73c856f Revert "Remove deprecated builders (#733)"
This reverts commit 9d15c35623.
2019-07-10 17:34:33 +02:00
Andy Bitz
9fdd247773 Revert "[now-node-server] Remove package source code (#721)"
This reverts commit a55ce5da8f.
2019-07-10 17:34:31 +02:00
Andy Bitz
fe59cabf15 Revert "Publish"
This reverts commit da37a9bc06.
2019-07-10 15:30:00 +02:00
Andy Bitz
da37a9bc06 Publish
- @now/build-utils@0.8.3
 - @now/node@0.11.2
2019-07-10 15:19:34 +02:00
Andy
bad779be1f Use --pure-lockfile on build (#738)
* Use --pure-lockfile on build

* Add --pure-lockfile to publish
2019-07-10 15:17:31 +02:00
Andy Bitz
5eb5deb8eb Revert "Publish"
This reverts commit f9afee7dba.
2019-07-10 15:09:42 +02:00
Andy Bitz
f9afee7dba Publish
- @now/build-utils@0.8.3
 - @now/node@0.11.2
2019-07-10 14:28:37 +02:00
Andy
547e9ed684 Add --pure-lockfile option (#737) 2019-07-10 14:26:31 +02:00
Andy Bitz
68d2927cbf Revert "Publish"
This reverts commit ca7f716432.
2019-07-10 14:16:22 +02:00
Andy Bitz
ca7f716432 Publish
- @now/build-utils@0.8.3
 - @now/node@0.11.2
2019-07-10 14:02:12 +02:00
Steven
9d15c35623 Remove deprecated builders (#733)
* Remove deprecated builders

* Update comment so that tests  run
2019-07-10 13:51:37 +02:00
Steven
a55ce5da8f [now-node-server] Remove package source code (#721)
* [now-node-server] Remove package

* Update comment so tests run
2019-07-10 13:49:40 +02:00
Connor Davis
f0a06b797e Update CODEOWNERS 2019-07-10 13:46:33 +02:00
Andy
0a77f43832 [now-build-utils] Add warnings and simpler routes (#734)
* [now-build-utils] Add warnings

* Make routes regexes simpler

* Adjust tests

* Adjust tests

* Fix tests

* Remove now-build script check
2019-07-10 13:46:13 +02:00
Andy Bitz
4ce0d31688 Publish
- @now/bash@1.0.1
 - @now/go@0.5.5
 - @now/python@0.2.11
2019-07-09 01:09:23 +02:00
Andy
280802615f [now-bash][now-go][now-python] Support zero config (#723)
* [now-bash][now-go][now-python] Support zero config

* Remove default config
2019-07-09 01:01:27 +02:00
Andy Bitz
c7db281065 Publish
- @now/build-utils@0.8.2
2019-07-08 17:14:04 +02:00
Andy
ca00739041 [now-build-utils] Fix default routes on windows and adjust error message (#720)
* [now-build-utils] Fix default routes on windows and adjust error message

* Remove extra condition
2019-07-08 17:13:29 +02:00
Andy Bitz
11f8b17599 Publish
- @now/build-utils@0.8.1
2019-07-08 12:40:23 +02:00
Andy Bitz
970ab7d5c5 Revert "Fixed yarn.lock (#717)"
This reverts commit 5bfbd63e13.
2019-07-08 12:39:19 +02:00
Andy Bitz
71c082dccd Revert "Publish"
This reverts commit 76a185eb90.
2019-07-08 12:34:31 +02:00
Andy Bitz
76a185eb90 Publish
- @now/build-utils@0.8.1
2019-07-08 12:23:30 +02:00
Andy
8c0f3d107d [now-build-utils] Ignore dot and underscore prefix for api directory (#718)
* [now-build-utils] Add support for `_` and `.` prefixes in `api/`

 * Remove log statement

* Ignore dot and underscore prefix for api directory

* Set one builder per file if there are files to ignore

* Always return all builds with their exact match
2019-07-08 12:22:40 +02:00
Leo Lamprecht
5bfbd63e13 Fixed yarn.lock (#717)
This reverts commit d83b09ffbd.
2019-07-07 16:00:20 +00:00
41 changed files with 393 additions and 57 deletions

2
.github/CODEOWNERS vendored
View File

@@ -4,7 +4,7 @@
* @styfle
/packages/now-node @styfle @tootallnate @lucleray
/packages/now-node-bridge @styfle @tootallnate @lucleray
/packages/now-next @timer @dav-is
/packages/now-next @timer
/packages/now-go @styfle @sophearak
/packages/now-python @styfle @sophearak
/packages/now-rust @styfle @mike-engel @anmonteiro

12
.github/main.workflow vendored
View File

@@ -18,21 +18,21 @@ action "1. Canary yarn install" {
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
needs = ["0. Canary PR not deleted"]
runs = "yarn"
args = "install"
args = "--pure-lockfile install"
}
action "2. Canary yarn run build" {
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
needs = ["1. Canary yarn install"]
runs = "yarn"
args = "run build"
args = "--pure-lockfile run build"
}
action "3. Canary yarn run publish" {
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
needs = ["2. Canary yarn run build"]
runs = "yarn"
args = "run publish-from-github"
args = "--pure-lockfile run publish-from-github"
secrets = ["NPM_TOKEN"]
}
@@ -57,20 +57,20 @@ action "1. Master yarn install" {
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
needs = ["0. Master PR not deleted"]
runs = "yarn"
args = "install"
args = "--pure-lockfile install"
}
action "2. Master yarn run build" {
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
needs = ["1. Master yarn install"]
runs = "yarn"
args = "run build"
args = "--pure-lockfile run build"
}
action "3. Master yarn run publish" {
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
needs = ["2. Master yarn run build"]
runs = "yarn"
args = "run publish-from-github"
args = "--pure-lockfile run publish-from-github"
secrets = ["NPM_TOKEN"]
}

View File

@@ -10,7 +10,7 @@ const {
} = require('@now/build-utils'); // eslint-disable-line import/no-extraneous-dependencies
exports.config = {
maxLambdaSize: '10mb',
maxLambdaSize: '30mb',
};
// From this list: https://import.pw/importpw/import/docs/config.md

View File

@@ -1,6 +1,6 @@
{
"name": "@now/bash",
"version": "1.0.0",
"version": "1.0.1",
"description": "Now 2.0 builder for HTTP endpoints written in Bash",
"main": "index.js",
"author": "Nathan Rajlich <nate@zeit.co>",

View File

@@ -1,6 +1,6 @@
{
"name": "@now/build-utils",
"version": "0.8.0",
"version": "0.8.3",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.js",

View File

@@ -20,28 +20,76 @@ const API_BUILDERS: Builder[] = [
{ src: 'api/**/*.sh', use: '@now/bash', config },
];
export async function detectBuilder(pkg: PackageJson): Promise<Builder> {
interface Warning {
code: string;
message: string;
}
export async function detectBuilder(
pkg: PackageJson
): Promise<{
builder: null | Builder;
warnings: null | Warning[];
}> {
let warnings: null | Warning[] = null;
const scripts = pkg.scripts || {};
if (!scripts.build) {
warnings = [
{
code: 'missing_build_script',
message:
'Your `package.json` file is missing a `build` property inside the `script` property',
},
];
}
for (const [dependency, builder] of BUILDERS) {
const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
// Return the builder when a dependency matches
if (deps[dependency]) {
return builder;
return { builder, warnings };
}
}
// If there is no `build` and `now-build` script
// we'll not select `@now/static-build`
// since it would fail
if (!scripts.build) {
return { builder: null, warnings };
}
// By default we'll choose the `static-build` builder
return { src, use: '@now/static-build', config };
const builder = { src, use: '@now/static-build', config };
return { builder, warnings };
}
// Files that match a specific pattern will get ignored
export function ignoreApiFilter(file: string) {
if (file.includes('/.')) {
return false;
}
if (file.includes('/_')) {
return false;
}
return true;
}
export async function detectApiBuilders(
files: string[]
): Promise<Builder[] | null> {
const builds = files.map(file => {
return API_BUILDERS.find(({ src }): boolean => minimatch(file, src));
const builds = files.filter(ignoreApiFilter).map(file => {
const result = API_BUILDERS.find(
({ src }): boolean => minimatch(file, src)
);
return result ? { ...result, src: file } : null;
});
// We can use `new Set` here since `builds` contains references to `API_BUILDERS`
const finishedBuilds = Array.from(new Set(builds.filter(Boolean)));
const finishedBuilds = builds.filter(Boolean);
return finishedBuilds.length > 0 ? (finishedBuilds as Builder[]) : null;
}

View File

@@ -1,7 +1,17 @@
import path from 'path';
import { Route } from './types';
import { parse as parsePath } from 'path';
import { ignoreApiFilter } from './detect-builder';
function joinPath(...segments: string[]) {
const joinedPath = segments.join('/');
return joinedPath.replace(/\/{2,}/g, '/');
}
function concatArrayOfText(texts: string[]): string {
if (texts.length <= 2) {
return texts.join(' and ');
}
const last = texts.pop();
return `${texts.join(', ')}, and ${last}`;
}
@@ -11,7 +21,7 @@ function concatArrayOfText(texts: string[]): string {
// It will return `null` if there are no brackets
// and therefore no segment.
function getSegmentName(segment: string): string | null {
const { name } = path.parse(segment);
const { name } = parsePath(segment);
if (name.startsWith('[') && name.endsWith(']')) {
return name.slice(1, -1);
@@ -23,7 +33,6 @@ function getSegmentName(segment: string): string | null {
function createRouteFromPath(filePath: string): Route {
const parts = filePath.split('/');
let append: string = '';
let counter: number = 1;
const query: string[] = [];
@@ -33,23 +42,12 @@ function createRouteFromPath(filePath: string): Route {
const isLast = index === parts.length - 1;
if (name !== null) {
// We can't use `URLSearchParams` because `$` would get escaped
query.push(`${name}=$${counter++}`);
if (isLast) {
// We append this to the last one
// to make sure GET params still work
// and are just appended to our GET params
append += `$${counter++}`;
return `([^\\/|\\?]+)\\/?(?:\\?(.*))?`;
}
return `([^\\/]+)`;
} else if (isLast) {
// If it is the last part we want to remove the extension
// and capture everything after that as regex group and append it
const { name: fileName } = path.parse(segment);
append += `$${counter++}`;
return `${fileName}(.*)`;
const { name: fileName } = parsePath(segment);
return fileName;
}
return segment;
@@ -57,9 +55,7 @@ function createRouteFromPath(filePath: string): Route {
);
const src = `^/${srcParts.join('/')}$`;
const dest = `/${filePath}${query.length ? '?' : ''}${query.join('&')}${
query.length ? '&' : ''
}${append}`;
const dest = `/${filePath}?${query.join('&')}`;
return { src, dest };
}
@@ -101,8 +97,8 @@ function partiallyMatches(pathA: string, pathB: string): boolean {
// got resolved, so we can check if they have conflicts
function pathOccurrences(filePath: string, files: string[]): string[] {
const getAbsolutePath = (unresolvedPath: string): string => {
const { dir, name } = path.parse(unresolvedPath);
const parts = path.join(dir, name).split('/');
const { dir, name } = parsePath(unresolvedPath);
const parts = joinPath(dir, name).split('/');
return parts.map(part => part.replace(/\[.*\]/, '1')).join('/');
};
@@ -183,7 +179,9 @@ export async function detectApiRoutes(
// The deepest routes need to be
// the first ones to get handled
const sortedFiles = files.sort(sortFilesBySegmentCount);
const sortedFiles = files
.filter(ignoreApiFilter)
.sort(sortFilesBySegmentCount);
const defaultRoutes: Route[] = [];
@@ -196,8 +194,6 @@ export async function detectApiRoutes(
const conflictingSegment = getConflictingSegment(file);
console.log({ file, conflictingSegment });
if (conflictingSegment) {
return {
defaultRoutes: null,

View File

@@ -139,7 +139,7 @@ for (const fixture of fs.readdirSync(fixturesPath)) {
// few foreign tests
const buildersToTestWith = ['now-node-server', 'now-static-build'];
const buildersToTestWith = ['now-node', 'now-static-build'];
// eslint-disable-next-line no-restricted-syntax
for (const builder of buildersToTestWith) {
@@ -168,20 +168,21 @@ for (const builder of buildersToTestWith) {
it('Test `detectBuilder`', async () => {
{
const pkg = { dependencies: { next: '1.0.0' } };
const builder = await detectBuilder(pkg);
const { builder, warnings } = await detectBuilder(pkg);
expect(builder.use).toBe('@now/next');
expect(warnings.length).toBe(1);
}
{
const pkg = { devDependencies: { next: '1.0.0' } };
const builder = await detectBuilder(pkg);
const { builder } = await detectBuilder(pkg);
expect(builder.use).toBe('@now/next');
}
{
const pkg = {};
const builder = await detectBuilder(pkg);
expect(builder.use).toBe('@now/static-build');
const { builder } = await detectBuilder(pkg);
expect(builder).toBe(null);
}
});
@@ -207,6 +208,18 @@ it('Test `detectApiBuilders`', async () => {
const builders = await detectApiBuilders(files);
expect(builders).toBe(null);
}
{
const files = [
'api/users/[id].js',
'api/_utils/handler.js',
'api/users/.helper.js',
'api/teams/_helper.js',
];
const builders = await detectApiBuilders(files);
expect(builders.length).toBe(1);
}
});
it('Test `detectApiRoutes`', async () => {
@@ -244,4 +257,15 @@ it('Test `detectApiRoutes`', async () => {
const { defaultRoutes } = await detectApiRoutes(files);
expect(defaultRoutes.length).toBe(2);
}
{
const files = [
'api/_utils/handler.js',
'api/[endpoint]/.helper.js',
'api/[endpoint]/[id].js',
];
const builders = await detectApiBuilders(files);
expect(builders.length).toBe(1);
}
});

View File

@@ -120,7 +120,14 @@ Learn more: https://zeit.co/docs/v2/deployments/official-builders/go-now-go/#ent
const parsedAnalyzed = JSON.parse(analyzed) as Analyzed;
if (meta.isDev) {
const base = dirname(downloadedFiles['now.json'].fsPath);
let base = null;
if (config && config.zeroConfig) {
base = workPath;
} else {
base = dirname(downloadedFiles['now.json'].fsPath);
}
const destNow = join(
base,
'.now',

View File

@@ -1,6 +1,6 @@
{
"name": "@now/go",
"version": "0.5.4",
"version": "0.5.5",
"license": "MIT",
"homepage": "https://zeit.co/docs/v2/deployments/official-builders/go-now-go",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@now/next",
"version": "0.5.3",
"version": "0.5.4",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://zeit.co/docs/v2/deployments/official-builders/next-js-now-next",

View File

@@ -0,0 +1,51 @@
import path from 'path';
import fs from 'fs-extra';
function getCustomData(importName: string) {
return `
module.exports = function(...args) {
let original = require('./${importName}');
const finalConfig = {};
const target = { target: 'serverless' };
if (typeof original === 'function' && original.constructor.name === 'AsyncFunction') {
// AsyncFunctions will become promises
original = original(...args);
}
if (original instanceof Promise) {
// Special case for promises, as it's currently not supported
// and will just error later on
return original
.then((orignalConfig) => Object.assign(finalConfig, orignalConfig))
.then((config) => Object.assign(config, target));
} else if (typeof original === 'function') {
Object.assign(finalConfig, original(...args));
} else if (typeof original === 'object') {
Object.assign(finalConfig, original);
}
Object.assign(finalConfig, target);
return finalConfig;
}
`.trim();
}
function getDefaultData() {
return `module.exports = { target: 'serverless' };`;
}
export default async function createServerlessConfig(workPath: string) {
const configPath = path.join(workPath, 'next.config.js');
const backupConfigName = `next.config.original.${Date.now()}.js`;
const backupConfigPath = path.join(workPath, backupConfigName);
if (fs.existsSync(configPath)) {
await fs.rename(configPath, backupConfigPath);
await fs.writeFile(configPath, getCustomData(backupConfigName));
} else {
await fs.writeFile(configPath, getDefaultData());
}
}

View File

@@ -42,6 +42,7 @@ import {
getDynamicRoutes,
isDynamicRoute,
} from './utils';
import createServerlessConfig from './create-serverless-config';
interface BuildParamsMeta {
isDev: boolean | undefined;
@@ -165,8 +166,6 @@ export const build = async ({
watch?: string[];
childProcesses: ChildProcess[];
}> => {
process.env.__NEXT_BUILDER_EXPERIMENTAL_TARGET = 'serverless';
validateEntrypoint(entrypoint);
const entryDirectory = path.dirname(entrypoint);
@@ -176,12 +175,16 @@ export const build = async ({
console.log(`${name} Downloading user files...`);
await download(files, workPath, meta);
const nodeVersion = await getNodeVersion(entryPath);
const spawnOpts = getSpawnOptions(meta, nodeVersion);
const pkg = await readPackageJson(entryPath);
const nextVersion = getNextVersion(pkg);
if (!meta.isDev) {
await createServerlessConfig(workPath);
}
const nodeVersion = await getNodeVersion(entryPath);
const spawnOpts = getSpawnOptions(meta, nodeVersion);
if (!nextVersion) {
throw new Error(
'No Next.js version could be detected in "package.json". Make sure `"next"` is installed in "dependencies" or "devDependencies"'

View File

@@ -1,5 +1,6 @@
/* global it, expect */
const path = require('path');
const fs = require('fs-extra');
const runBuildLambda = require('../../../../test/lib/run-build-lambda');
const FOUR_MINUTES = 240000;
@@ -111,3 +112,119 @@ it(
},
FOUR_MINUTES,
);
it(
'Should build the serverless-config example',
async () => {
const {
workPath,
buildResult: { output },
} = await runBuildLambda(path.join(__dirname, 'serverless-config'));
expect(output.index).toBeDefined();
expect(output.goodbye).toBeDefined();
const filePaths = Object.keys(output);
const serverlessError = filePaths.some(filePath => filePath.match(/_error/));
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();
expect(serverlessError).toBeTruthy();
const contents = await fs.readdir(workPath);
expect(contents.some(name => name === 'next.config.js')).toBeTruthy();
expect(
contents.some(name => name.includes('next.config.original.')),
).toBeTruthy();
},
FOUR_MINUTES,
);
it(
'Should not build the serverless-config-async example',
async () => {
let error = null;
try {
await runBuildLambda(path.join(__dirname, 'serverless-config-async'));
} catch (err) {
error = err;
}
expect(error).not.toBe(null);
},
FOUR_MINUTES,
);
it(
'Should not build the serverless-config-promise example',
async () => {
let error = null;
try {
await runBuildLambda(path.join(__dirname, 'serverless-config-promise'));
} catch (err) {
error = err;
}
expect(error).not.toBe(null);
},
FOUR_MINUTES,
);
it(
'Should build the serverless-config-object example',
async () => {
const {
workPath,
buildResult: { output },
} = await runBuildLambda(path.join(__dirname, 'serverless-config-object'));
expect(output['index.html']).toBeDefined();
expect(output.goodbye).toBeDefined();
const filePaths = Object.keys(output);
const serverlessError = filePaths.some(filePath => filePath.match(/_error/));
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();
expect(serverlessError).toBeTruthy();
const contents = await fs.readdir(workPath);
expect(contents.some(name => name === 'next.config.js')).toBeTruthy();
expect(
contents.some(name => name.includes('next.config.original.')),
).toBeTruthy();
},
FOUR_MINUTES,
);
it(
'Should build the serverless-no-config example',
async () => {
const {
workPath,
buildResult: { output },
} = await runBuildLambda(path.join(__dirname, 'serverless-no-config'));
expect(output['index.html']).toBeDefined();
expect(output.goodbye).toBeDefined();
const filePaths = Object.keys(output);
const serverlessError = filePaths.some(filePath => filePath.match(/_error/));
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();
expect(serverlessError).toBeTruthy();
const contents = await fs.readdir(workPath);
expect(contents.some(name => name === 'next.config.js')).toBeTruthy();
expect(
contents.some(name => name.includes('next.config.original.')),
).toBeFalsy();
},
FOUR_MINUTES,
);

View File

@@ -0,0 +1,3 @@
module.exports = async function () {
return {};
};

View File

@@ -0,0 +1,4 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "latest",
"react": "latest",
"react-dom": "latest"
}
}

View File

@@ -0,0 +1,3 @@
const F = () => 'Goodbye World!';
F.getInitialProps = async () => ({});
export default F;

View File

@@ -0,0 +1 @@
export default () => 'Hello World!';

View File

@@ -0,0 +1 @@
module.exports = {};

View File

@@ -0,0 +1,4 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "latest",
"react": "latest",
"react-dom": "latest"
}
}

View File

@@ -0,0 +1,3 @@
const F = () => 'Goodbye World!';
F.getInitialProps = async () => ({});
export default F;

View File

@@ -0,0 +1 @@
export default () => 'Hello World!';

View File

@@ -0,0 +1 @@
module.exports = new Promise(res => res({}));

View File

@@ -0,0 +1,4 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "latest",
"react": "latest",
"react-dom": "latest"
}
}

View File

@@ -0,0 +1,3 @@
const F = () => 'Goodbye World!';
F.getInitialProps = async () => ({});
export default F;

View File

@@ -0,0 +1 @@
export default () => 'Hello World!';

View File

@@ -0,0 +1 @@
module.exports = () => ({});

View File

@@ -0,0 +1,4 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "8.1.0",
"react": "latest",
"react-dom": "latest"
}
}

View File

@@ -0,0 +1,3 @@
const F = () => 'Goodbye World!';
F.getInitialProps = async () => ({});
export default F;

View File

@@ -0,0 +1 @@
export default () => 'Hello World!';

View File

@@ -0,0 +1,4 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next", "config": { "zeroConfig": true } }]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "latest",
"react": "latest",
"react-dom": "latest"
}
}

View File

@@ -0,0 +1,3 @@
const F = () => 'Goodbye World!';
F.getInitialProps = async () => ({});
export default F;

View File

@@ -0,0 +1 @@
export default () => 'Hello World!';

View File

@@ -1,6 +1,6 @@
{
"name": "@now/python",
"version": "0.2.10",
"version": "0.2.11",
"main": "./dist/index.js",
"license": "MIT",
"homepage": "https://zeit.co/docs/v2/deployments/official-builders/python-now-python",

View File

@@ -92,12 +92,20 @@ export const build = async ({
files: originalFiles,
entrypoint,
meta = {},
config,
}: BuildOptions) => {
console.log('downloading files...');
let downloadedFiles = await download(originalFiles, workPath, meta);
if (meta.isDev) {
const base = dirname(downloadedFiles['now.json'].fsPath);
let base = null;
if (config && config.zeroConfig) {
base = workPath;
} else {
base = dirname(downloadedFiles['now.json'].fsPath);
}
const destNow = join(base, '.now', 'cache', basename(entrypoint, '.py'));
await download(downloadedFiles, destNow);
downloadedFiles = await glob('**', destNow);

View File

@@ -52,6 +52,7 @@ async function runBuildLambda(inputPath) {
return {
analyzeResult,
buildResult,
workPath,
};
}