mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-26 19:00:08 +00:00
Compare commits
25 Commits
@now/next@
...
@now/ruby@
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3407e6bd1a | ||
|
|
553ad240f0 | ||
|
|
964ce1bb5a | ||
|
|
995aa6eddf | ||
|
|
095805e3ad | ||
|
|
b461ed238c | ||
|
|
01e7124189 | ||
|
|
acd3ac2f98 | ||
|
|
b50e4209e1 | ||
|
|
147b4e870c | ||
|
|
df8327d14c | ||
|
|
fb4d4b5953 | ||
|
|
de3701c045 | ||
|
|
9f9b7934cb | ||
|
|
bcded1dd17 | ||
|
|
8503af75ba | ||
|
|
158a50f1aa | ||
|
|
61da552dd6 | ||
|
|
fa838eecac | ||
|
|
71b6a58783 | ||
|
|
22dd78e286 | ||
|
|
e63fcf2630 | ||
|
|
98e1553c2e | ||
|
|
4dc506f17a | ||
|
|
3b396f29e9 |
4
.github/workflows/continuous-integration.yml
vendored
4
.github/workflows/continuous-integration.yml
vendored
@@ -94,7 +94,7 @@ jobs:
|
||||
|
||||
coverage:
|
||||
name: Coverage
|
||||
timeout-minutes: 10
|
||||
timeout-minutes: 5
|
||||
needs: [test-unit, test-now-cli, test-now-dev, test-integration]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -107,3 +107,5 @@ jobs:
|
||||
path: packages/now-cli/.nyc_output
|
||||
- run: yarn install
|
||||
- run: yarn workspace now run coverage
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
3
.github/workflows/publish.yml
vendored
3
.github/workflows/publish.yml
vendored
@@ -20,6 +20,9 @@ jobs:
|
||||
run: yarn install --check-files --frozen-lockfile
|
||||
- name: Build
|
||||
run: yarn build
|
||||
env:
|
||||
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
|
||||
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
|
||||
- name: Publish
|
||||
run: yarn publish-from-github
|
||||
env:
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@ coverage
|
||||
packages/now-cli/.builders
|
||||
packages/now-cli/assets
|
||||
packages/now-cli/src/util/dev/templates/*.ts
|
||||
packages/now-cli/src/util/constants.ts
|
||||
packages/now-cli/test/**/yarn.lock
|
||||
!packages/now-cli/test/dev/**/yarn.lock
|
||||
packages/now-cli/test/**/node_modules
|
||||
|
||||
18
README.md
18
README.md
@@ -5,30 +5,18 @@
|
||||
|
||||
## Usage
|
||||
|
||||
To install the latest version of Now CLI, visit [zeit.co/download](https://zeit.co/download) or run this command:
|
||||
|
||||
```
|
||||
npm i -g now
|
||||
```
|
||||
|
||||
To quickly start a new project, run the following commands:
|
||||
|
||||
```
|
||||
now init # Pick an example project to clone
|
||||
cd <PROJECT> # Change directory to the newly created project
|
||||
now # Deploy to the cloud
|
||||
```
|
||||
Get started by [Importing a Git Project](https://zeit.co/import) and use `git push` to deploy. Alternatively, you can [install Now CLI](https://zeit.co/download).
|
||||
|
||||
## Documentation
|
||||
|
||||
For details on how to use Now CLI, check out our [documentation](https://zeit.co/docs/now-cli).
|
||||
For details on how to use ZEIT Now, check out our [documentation](https://zeit.co/docs).
|
||||
|
||||
## Caught a Bug?
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
2. Install dependencies with `yarn install`
|
||||
3. Compile the code: `yarn build`
|
||||
4. Link the package to the global module directory: `yarn link`
|
||||
4. Link the package to the global module directory: `cd ./packages/now-cli && yarn link`
|
||||
5. You can now start using `now` anywhere inside the command line
|
||||
|
||||
As always, you should use `yarn test-unit` to run the tests and see if your changes have broken anything.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/build-utils",
|
||||
"version": "2.0.1-canary.0",
|
||||
"version": "2.1.1-canary.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.js",
|
||||
|
||||
@@ -130,15 +130,15 @@ export async function detectBuilders(
|
||||
|
||||
let fallbackEntrypoint: string | null = null;
|
||||
|
||||
const preDefaultRoutes: Source[] = [];
|
||||
const preDynamicRoutes: Source[] = [];
|
||||
const apiRoutes: Source[] = [];
|
||||
const dynamicRoutes: Source[] = [];
|
||||
|
||||
// API
|
||||
for (const fileName of sortedFiles) {
|
||||
const apiBuilder = maybeGetApiBuilder(fileName, apiMatches, options);
|
||||
|
||||
if (apiBuilder) {
|
||||
const { routeError, defaultRoute, dynamicRoute } = getApiRoute(
|
||||
const { routeError, apiRoute, isDynamic } = getApiRoute(
|
||||
fileName,
|
||||
apiSortedFiles,
|
||||
options,
|
||||
@@ -156,12 +156,11 @@ export async function detectBuilders(
|
||||
};
|
||||
}
|
||||
|
||||
if (dynamicRoute) {
|
||||
preDynamicRoutes.push(dynamicRoute);
|
||||
}
|
||||
|
||||
if (defaultRoute) {
|
||||
preDefaultRoutes.push(defaultRoute);
|
||||
if (apiRoute) {
|
||||
apiRoutes.push(apiRoute);
|
||||
if (isDynamic) {
|
||||
dynamicRoutes.push(apiRoute);
|
||||
}
|
||||
}
|
||||
|
||||
addToUsedFunctions(apiBuilder);
|
||||
@@ -287,9 +286,9 @@ export async function detectBuilders(
|
||||
}
|
||||
}
|
||||
|
||||
const routesResult = mergeRoutes(
|
||||
preDefaultRoutes,
|
||||
preDynamicRoutes,
|
||||
const routesResult = getRouteResult(
|
||||
apiRoutes,
|
||||
dynamicRoutes,
|
||||
usedOutputDirectory,
|
||||
apiBuilders,
|
||||
frontendBuilder,
|
||||
@@ -622,16 +621,16 @@ function getApiRoute(
|
||||
options: Options,
|
||||
absolutePathCache: Map<string, string>
|
||||
): {
|
||||
defaultRoute: Source | null;
|
||||
dynamicRoute: Source | null;
|
||||
apiRoute: Source | null;
|
||||
isDynamic: boolean;
|
||||
routeError: ErrorResponse | null;
|
||||
} {
|
||||
const conflictingSegment = getConflictingSegment(fileName);
|
||||
|
||||
if (conflictingSegment) {
|
||||
return {
|
||||
defaultRoute: null,
|
||||
dynamicRoute: null,
|
||||
apiRoute: null,
|
||||
isDynamic: false,
|
||||
routeError: {
|
||||
code: 'conflicting_path_segment',
|
||||
message:
|
||||
@@ -650,8 +649,8 @@ function getApiRoute(
|
||||
);
|
||||
|
||||
return {
|
||||
defaultRoute: null,
|
||||
dynamicRoute: null,
|
||||
apiRoute: null,
|
||||
isDynamic: false,
|
||||
routeError: {
|
||||
code: 'conflicting_file_path',
|
||||
message:
|
||||
@@ -669,8 +668,8 @@ function getApiRoute(
|
||||
);
|
||||
|
||||
return {
|
||||
defaultRoute: out.route,
|
||||
dynamicRoute: out.isDynamic ? out.route : null,
|
||||
apiRoute: out.route,
|
||||
isDynamic: out.isDynamic,
|
||||
routeError: null,
|
||||
};
|
||||
}
|
||||
@@ -881,9 +880,9 @@ function createRouteFromPath(
|
||||
return { route, isDynamic };
|
||||
}
|
||||
|
||||
function mergeRoutes(
|
||||
preDefaultRoutes: Source[],
|
||||
preDynamicRoutes: Source[],
|
||||
function getRouteResult(
|
||||
apiRoutes: Source[],
|
||||
dynamicRoutes: Source[],
|
||||
outputDirectory: string,
|
||||
apiBuilders: Builder[],
|
||||
frontendBuilder: Builder | null,
|
||||
@@ -897,7 +896,7 @@ function mergeRoutes(
|
||||
const redirectRoutes: Route[] = [];
|
||||
const rewriteRoutes: Route[] = [];
|
||||
|
||||
if (preDefaultRoutes && preDefaultRoutes.length > 0) {
|
||||
if (apiRoutes && apiRoutes.length > 0) {
|
||||
if (options.featHandleMiss) {
|
||||
const extSet = detectApiExtensions(apiBuilders);
|
||||
|
||||
@@ -932,21 +931,16 @@ function mergeRoutes(
|
||||
}
|
||||
}
|
||||
|
||||
if (preDynamicRoutes) {
|
||||
rewriteRoutes.push(...preDynamicRoutes);
|
||||
}
|
||||
|
||||
if (preDefaultRoutes.length) {
|
||||
rewriteRoutes.push({
|
||||
src: '^/api(/.*)?$',
|
||||
status: 404,
|
||||
continue: true,
|
||||
});
|
||||
}
|
||||
rewriteRoutes.push(...dynamicRoutes);
|
||||
rewriteRoutes.push({
|
||||
src: '^/api(/.*)?$',
|
||||
status: 404,
|
||||
continue: true,
|
||||
});
|
||||
} else {
|
||||
defaultRoutes.push(...preDefaultRoutes);
|
||||
defaultRoutes.push(...apiRoutes);
|
||||
|
||||
if (preDefaultRoutes.length) {
|
||||
if (apiRoutes.length) {
|
||||
defaultRoutes.push({
|
||||
status: 404,
|
||||
src: '^/api(/.*)?$',
|
||||
|
||||
@@ -206,10 +206,10 @@ export async function runNpmInstall(
|
||||
debug(`Installing to ${destPath}`);
|
||||
const { hasPackageLockJson } = await scanParentDirs(destPath);
|
||||
|
||||
const opts = { cwd: destPath, ...spawnOpts } || {
|
||||
cwd: destPath,
|
||||
env: process.env,
|
||||
};
|
||||
const opts: SpawnOptions = { cwd: destPath, ...spawnOpts };
|
||||
const env = opts.env ? { ...opts.env } : { ...process.env };
|
||||
delete env.NODE_ENV;
|
||||
opts.env = env;
|
||||
|
||||
if (hasPackageLockJson) {
|
||||
commandArgs = args.filter(a => a !== '--prefer-offline');
|
||||
@@ -239,10 +239,7 @@ export async function runBundleInstall(
|
||||
}
|
||||
|
||||
assert(path.isAbsolute(destPath));
|
||||
const opts = { cwd: destPath, ...spawnOpts } || {
|
||||
cwd: destPath,
|
||||
env: process.env,
|
||||
};
|
||||
const opts = { cwd: destPath, ...spawnOpts };
|
||||
|
||||
await spawnAsync(
|
||||
'bundle',
|
||||
@@ -270,10 +267,7 @@ export async function runPipInstall(
|
||||
}
|
||||
|
||||
assert(path.isAbsolute(destPath));
|
||||
const opts = { cwd: destPath, ...spawnOpts } || {
|
||||
cwd: destPath,
|
||||
env: process.env,
|
||||
};
|
||||
const opts = { cwd: destPath, ...spawnOpts };
|
||||
|
||||
await spawnAsync(
|
||||
'pip3',
|
||||
|
||||
@@ -4,7 +4,7 @@ import FileRef from './file-ref';
|
||||
import { Lambda } from './lambda';
|
||||
|
||||
interface PrerenderOptions {
|
||||
expiration: number;
|
||||
expiration: number | false;
|
||||
lambda: Lambda;
|
||||
fallback: FileBlob | FileFsRef | FileRef | null;
|
||||
group?: number;
|
||||
@@ -13,7 +13,7 @@ interface PrerenderOptions {
|
||||
|
||||
export class Prerender {
|
||||
public type: 'Prerender';
|
||||
public expiration: number;
|
||||
public expiration: number | false;
|
||||
public lambda: Lambda;
|
||||
public fallback: FileBlob | FileFsRef | FileRef | null;
|
||||
public group?: number;
|
||||
|
||||
21
packages/now-build-utils/test/fixtures/16-node-env-install/build.js
vendored
Normal file
21
packages/now-build-utils/test/fixtures/16-node-env-install/build.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
function checkPkgOrThrow(pkgname) {
|
||||
try {
|
||||
const dep = require(pkgname);
|
||||
if (!dep) {
|
||||
throw new Error('Undefined');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`Expected package "${pkgname}" to be installed.`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// We expect both `dependencies` and `devDependencies` to be installed
|
||||
// even when NODE_ENV=production.
|
||||
checkPkgOrThrow('tls-check');
|
||||
checkPkgOrThrow('exeggcute');
|
||||
|
||||
// This is to satisfy `@now/static-build` which needs a `dist` directory.
|
||||
const { exec } = require('exeggcute');
|
||||
exec('mkdir dist', __dirname);
|
||||
exec('echo "node-env:RANDOMNESS_PLACEHOLDER" > dist/index.html', __dirname);
|
||||
6
packages/now-build-utils/test/fixtures/16-node-env-install/now.json
vendored
Normal file
6
packages/now-build-utils/test/fixtures/16-node-env-install/now.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "package.json", "use": "@now/static-build" }],
|
||||
"build": { "env": { "NODE_ENV": "production" } },
|
||||
"probes": [{ "path": "/", "mustContain": "node-env:RANDOMNESS_PLACEHOLDER" }]
|
||||
}
|
||||
12
packages/now-build-utils/test/fixtures/16-node-env-install/package.json
vendored
Normal file
12
packages/now-build-utils/test/fixtures/16-node-env-install/package.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "node build.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"tls-check": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"exeggcute": "1.0.0"
|
||||
}
|
||||
}
|
||||
8
packages/now-build-utils/test/fixtures/17-node-env-build/now.json
vendored
Normal file
8
packages/now-build-utils/test/fixtures/17-node-env-build/now.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "package.json", "use": "@now/static-build" }],
|
||||
"build": { "env": { "NODE_ENV": "custom-value:RANDOMNESS_PLACEHOLDER" } },
|
||||
"probes": [
|
||||
{ "path": "/", "mustContain": "custom-value:RANDOMNESS_PLACEHOLDER" }
|
||||
]
|
||||
}
|
||||
6
packages/now-build-utils/test/fixtures/17-node-env-build/package.json
vendored
Normal file
6
packages/now-build-utils/test/fixtures/17-node-env-build/package.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "mkdir public && echo $NODE_ENV > public/index.html"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,6 @@ To quickly start a new project, run the following commands:
|
||||
```
|
||||
now init # Pick an example project
|
||||
cd <PROJECT> # Change directory to the new project
|
||||
now dev # Run locally during development
|
||||
now # Deploy to the cloud
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "now",
|
||||
"version": "17.0.5-canary.4",
|
||||
"version": "17.0.5-canary.7",
|
||||
"preferGlobal": true,
|
||||
"license": "Apache-2.0",
|
||||
"description": "The command-line interface for Now",
|
||||
|
||||
@@ -4,7 +4,13 @@ import execa from 'execa';
|
||||
import { join } from 'path';
|
||||
import pipe from 'promisepipe';
|
||||
import { createGzip } from 'zlib';
|
||||
import { createWriteStream, mkdirp, remove, writeJSON } from 'fs-extra';
|
||||
import {
|
||||
createWriteStream,
|
||||
mkdirp,
|
||||
remove,
|
||||
writeJSON,
|
||||
writeFile,
|
||||
} from 'fs-extra';
|
||||
|
||||
import { getDistTag } from '../src/util/get-dist-tag';
|
||||
import pkg from '../package.json';
|
||||
@@ -47,10 +53,34 @@ async function createBuildersTarball() {
|
||||
);
|
||||
}
|
||||
|
||||
async function createConstants() {
|
||||
console.log('Creating constants.ts');
|
||||
const filename = join(dirRoot, 'src/util/constants.ts');
|
||||
const contents = `// This file is auto-generated
|
||||
export const GA_TRACKING_ID: string | undefined = ${envToString(
|
||||
'GA_TRACKING_ID'
|
||||
)};
|
||||
export const SENTRY_DSN: string | undefined = ${envToString('SENTRY_DSN')};
|
||||
`;
|
||||
await writeFile(filename, contents, 'utf8');
|
||||
}
|
||||
|
||||
function envToString(key: string) {
|
||||
const value = process.env[key];
|
||||
if (!value) {
|
||||
console.log(`- Constant ${key} is not assigned`);
|
||||
}
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const isDev = process.argv[2] === '--dev';
|
||||
|
||||
if (!isDev) {
|
||||
// Read the secrets from GitHub Actions and generate a file.
|
||||
// During local development, these secrets will be empty.
|
||||
await createConstants();
|
||||
|
||||
// Create a tarball from all the `@now` scoped builders which will be bundled
|
||||
// with Now CLI
|
||||
await createBuildersTarball();
|
||||
|
||||
@@ -284,13 +284,22 @@ export default async function main(
|
||||
return 0;
|
||||
}
|
||||
|
||||
org = await selectOrg(
|
||||
output,
|
||||
'Which scope do you want to deploy to?',
|
||||
client,
|
||||
ctx.config.currentTeam,
|
||||
autoConfirm
|
||||
);
|
||||
try {
|
||||
org = await selectOrg(
|
||||
output,
|
||||
'Which scope do you want to deploy to?',
|
||||
client,
|
||||
ctx.config.currentTeam,
|
||||
autoConfirm
|
||||
);
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
output.error(err.message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
// We use `localConfig` here to read the name
|
||||
// even though the `now.json` file can change
|
||||
|
||||
@@ -37,7 +37,7 @@ export default async function add(
|
||||
try {
|
||||
({ contextName } = await getScope(client));
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED') {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
output.error(err.message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export default async function add(
|
||||
try {
|
||||
({ contextName } = await getScope(client));
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED') {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
output.error(err.message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export default async function move(
|
||||
try {
|
||||
({ contextName, user } = await getScope(client));
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED') {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
output.error(err.message);
|
||||
return 1;
|
||||
}
|
||||
@@ -214,4 +214,4 @@ async function findDestinationMatch(
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ export default async function transferIn(
|
||||
try {
|
||||
({ contextName } = await getScope(client));
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED') {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
output.error(err.message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import exit from '../util/exit';
|
||||
import Client from '../util/client.ts';
|
||||
import logo from '../util/output/logo';
|
||||
import getScope from '../util/get-scope';
|
||||
import createOutput from '../util/output';
|
||||
|
||||
const e = encodeURIComponent;
|
||||
|
||||
@@ -63,13 +64,26 @@ const main = async ctx => {
|
||||
await exit(0);
|
||||
}
|
||||
|
||||
const output = createOutput({ debug });
|
||||
|
||||
const {
|
||||
authConfig: { token },
|
||||
config: { currentTeam },
|
||||
} = ctx;
|
||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
||||
|
||||
const { contextName } = await getScope(client);
|
||||
let contextName = null;
|
||||
|
||||
try {
|
||||
({ contextName } = await getScope(client));
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
output.error(err.message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
try {
|
||||
await run({ client, contextName });
|
||||
|
||||
@@ -76,7 +76,17 @@ export default async function({
|
||||
|
||||
const stopUserSpinner = wait('Fetching user information');
|
||||
const client = new Client({ apiUrl, token });
|
||||
const user = await getUser(client);
|
||||
let user;
|
||||
try {
|
||||
user = await getUser(client);
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
console.error(error(err.message));
|
||||
return 1;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
stopUserSpinner();
|
||||
|
||||
|
||||
@@ -21,7 +21,17 @@ export default async function({ teams, config, apiUrl, token }) {
|
||||
|
||||
const stopUserSpinner = wait('Fetching user information');
|
||||
const client = new Client({ apiUrl, token, currentTeam });
|
||||
const user = await getUser(client);
|
||||
let user;
|
||||
try {
|
||||
user = await getUser(client);
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
console.error(error(err.message));
|
||||
return 1;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
stopUserSpinner();
|
||||
|
||||
|
||||
@@ -40,13 +40,23 @@ export default async function({ apiUrl, token, debug, args, config }) {
|
||||
|
||||
const stopUserSpinner = wait('Fetching user information');
|
||||
const client = new Client({ apiUrl, token });
|
||||
const user = await getUser(client);
|
||||
let user;
|
||||
try {
|
||||
user = await getUser(client);
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
console.error(error(err.message));
|
||||
return 1;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
stopUserSpinner();
|
||||
|
||||
if (accountIsCurrent) {
|
||||
currentTeam = {
|
||||
slug: user.username || user.email
|
||||
slug: user.username || user.email,
|
||||
};
|
||||
} else {
|
||||
currentTeam = list.find(team => team.id === currentTeam);
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
export const GA_TRACKING_ID = 'UA-117491914-3';
|
||||
export const SENTRY_DSN = 'https://26a24e59ba954011919a524b341b6ab5@sentry.io/1323225';
|
||||
@@ -8,22 +8,26 @@ import * as configFiles from './config/files';
|
||||
|
||||
const config: any = configFiles.getConfigFilePath();
|
||||
|
||||
export const shouldCollectMetrics = (
|
||||
config.collectMetrics === undefined
|
||||
|| config.collectMetrics === true)
|
||||
&& process.env.NOW_CLI_COLLECT_METRICS !== '0';
|
||||
export const shouldCollectMetrics =
|
||||
(config.collectMetrics === undefined || config.collectMetrics === true) &&
|
||||
process.env.NOW_CLI_COLLECT_METRICS !== '0' &&
|
||||
GA_TRACKING_ID;
|
||||
|
||||
export const metrics = () => {
|
||||
const token = typeof config.token === 'string' ? config.token : platform() + release();
|
||||
export const metrics = (): ua.Visitor => {
|
||||
const token =
|
||||
typeof config.token === 'string' ? config.token : platform() + release();
|
||||
const salt = userInfo().username;
|
||||
const hash = crypto.pbkdf2Sync(token, salt, 1000, 64, 'sha512').toString('hex').substring(0, 24);
|
||||
const hash = crypto
|
||||
.pbkdf2Sync(token, salt, 1000, 64, 'sha512')
|
||||
.toString('hex')
|
||||
.substring(0, 24);
|
||||
|
||||
return ua(GA_TRACKING_ID, {
|
||||
return ua(GA_TRACKING_ID || '', {
|
||||
cid: hash,
|
||||
strictCidFormat: false,
|
||||
uid: hash,
|
||||
headers: {
|
||||
'User-Agent': userAgent
|
||||
}
|
||||
'User-Agent': userAgent,
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -247,12 +247,14 @@ function testFixtureStdio(directory, fn) {
|
||||
|
||||
if (stderr.includes(`Requested port ${port} is already in use`)) {
|
||||
dev.kill('SIGTERM');
|
||||
throw new Error(`Failed for "${directory}" with port ${port}.`);
|
||||
throw new Error(
|
||||
`Failed for "${directory}" with port ${port} with stderr "${stderr}".`
|
||||
);
|
||||
}
|
||||
|
||||
if (stderr.includes('Command failed') || stderr.includes('Error!')) {
|
||||
dev.kill('SIGTERM');
|
||||
throw new Error(`Failed for "${directory}".`);
|
||||
throw new Error(`Failed for "${directory}" with stderr "${stderr}".`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -461,6 +463,8 @@ test(
|
||||
t.regex(await rand.text(), /random number/gm);
|
||||
const rand2 = await fetchWithRetry(`http://localhost:${port}/api/rand.js`);
|
||||
t.regex(await rand2.text(), /random number/gm);
|
||||
const notfound = await fetch(`http://localhost:${port}/api`);
|
||||
t.is(notfound.status, 404);
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
ncc build index.ts -o dist
|
||||
ncc build install.ts -o dist/install
|
||||
ncc build index.ts -e @now/build-utils -o dist
|
||||
ncc build install.ts -e @now/build-utils -o dist/install
|
||||
mv dist/install/index.js dist/install.js
|
||||
rm -rf dist/install
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/go",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5-canary.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/go",
|
||||
|
||||
@@ -7,10 +7,10 @@ cp -v "$bridge_defs" src/now__bridge.ts
|
||||
|
||||
tsc
|
||||
|
||||
ncc build src/dev-server.ts -o dist/dev
|
||||
ncc build src/dev-server.ts -e @now/build-utils -o dist/dev
|
||||
mv dist/dev/index.js dist/dev-server.js
|
||||
rm -rf dist/dev
|
||||
|
||||
ncc build src/index.ts -o dist/main
|
||||
ncc build src/index.ts -e @now/build-utils -o dist/main
|
||||
mv dist/main/index.js dist/index.js
|
||||
rm -rf dist/main
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/next",
|
||||
"version": "2.3.18",
|
||||
"version": "2.4.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/next-js",
|
||||
|
||||
@@ -366,11 +366,16 @@ export const build = async ({
|
||||
// Load the /_next/data routes for both dynamic SSG and SSP pages.
|
||||
// These must be combined and sorted to prevent conflicts
|
||||
for (const dataRoute of routesManifest.dataRoutes) {
|
||||
const ssgDataRoute = prerenderManifest.lazyRoutes[dataRoute.page];
|
||||
const ssgDataRoute =
|
||||
prerenderManifest.fallbackRoutes[dataRoute.page] ||
|
||||
prerenderManifest.legacyBlockingRoutes[dataRoute.page];
|
||||
|
||||
// we don't need to add routes for non-lazy SSG routes since
|
||||
// they have outputs which would override the routes anyways
|
||||
if (prerenderManifest.routes[dataRoute.page]) {
|
||||
if (
|
||||
prerenderManifest.staticRoutes[dataRoute.page] ||
|
||||
prerenderManifest.omittedRoutes.includes(dataRoute.page)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -669,9 +674,8 @@ export const build = async ({
|
||||
// Lazily prerendered routes have a fallback `.html` file on newer
|
||||
// Next.js versions so we need to also not treat it as a static page here.
|
||||
if (
|
||||
prerenderManifest.routes[routeName] ||
|
||||
(prerenderManifest.lazyRoutes[routeName] &&
|
||||
prerenderManifest.lazyRoutes[routeName].fallback)
|
||||
prerenderManifest.staticRoutes[routeName] ||
|
||||
prerenderManifest.fallbackRoutes[routeName]
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -913,33 +917,49 @@ export const build = async ({
|
||||
}
|
||||
|
||||
let prerenderGroup = 1;
|
||||
const onPrerenderRoute = (routeKey: string, isLazy: boolean) => {
|
||||
const onPrerenderRoute = (
|
||||
routeKey: string,
|
||||
{ isBlocking, isFallback }: { isBlocking: boolean; isFallback: boolean }
|
||||
) => {
|
||||
if (isBlocking && isFallback) {
|
||||
throw new Error(
|
||||
'invariant: isBlocking and isFallback cannot both be true'
|
||||
);
|
||||
}
|
||||
|
||||
// Get the route file as it'd be mounted in the builder output
|
||||
const routeFileNoExt = routeKey === '/' ? '/index' : routeKey;
|
||||
const lazyHtmlFallback =
|
||||
isLazy && prerenderManifest.lazyRoutes[routeKey].fallback;
|
||||
|
||||
const htmlFsRef =
|
||||
isLazy && !lazyHtmlFallback
|
||||
const htmlFsRef = isBlocking
|
||||
? // Blocking pages do not have an HTML fallback
|
||||
null
|
||||
: new FileFsRef({
|
||||
fsPath: path.join(
|
||||
pagesDir,
|
||||
isFallback
|
||||
? // Fallback pages have a special file.
|
||||
prerenderManifest.fallbackRoutes[routeKey].fallback
|
||||
: // Otherwise, the route itself should exist as a static HTML
|
||||
// file.
|
||||
`${routeFileNoExt}.html`
|
||||
),
|
||||
});
|
||||
const jsonFsRef =
|
||||
// JSON data does not exist for fallback or blocking pages
|
||||
isFallback || isBlocking
|
||||
? null
|
||||
: new FileFsRef({
|
||||
fsPath: path.join(
|
||||
pagesDir,
|
||||
`${lazyHtmlFallback || routeFileNoExt + '.html'}`
|
||||
),
|
||||
fsPath: path.join(pagesDir, `${routeFileNoExt}.json`),
|
||||
});
|
||||
const jsonFsRef = isLazy
|
||||
? null
|
||||
: new FileFsRef({
|
||||
fsPath: path.join(pagesDir, `${routeFileNoExt}.json`),
|
||||
});
|
||||
|
||||
let initialRevalidate: false | number;
|
||||
let srcRoute: string | null;
|
||||
let dataRoute: string;
|
||||
|
||||
if (isLazy) {
|
||||
const pr = prerenderManifest.lazyRoutes[routeKey];
|
||||
if (isFallback || isBlocking) {
|
||||
const pr = isFallback
|
||||
? prerenderManifest.fallbackRoutes[routeKey]
|
||||
: prerenderManifest.legacyBlockingRoutes[routeKey];
|
||||
initialRevalidate = 1; // TODO: should Next.js provide this default?
|
||||
// @ts-ignore
|
||||
if (initialRevalidate === false) {
|
||||
@@ -949,7 +969,7 @@ export const build = async ({
|
||||
srcRoute = null;
|
||||
dataRoute = pr.dataRoute;
|
||||
} else {
|
||||
const pr = prerenderManifest.routes[routeKey];
|
||||
const pr = prerenderManifest.staticRoutes[routeKey];
|
||||
({ initialRevalidate, srcRoute, dataRoute } = pr);
|
||||
}
|
||||
|
||||
@@ -975,20 +995,14 @@ export const build = async ({
|
||||
}
|
||||
|
||||
prerenders[outputPathPage] = new Prerender({
|
||||
expiration:
|
||||
initialRevalidate === false
|
||||
? MAX_AGE_ONE_YEAR * 10
|
||||
: initialRevalidate,
|
||||
expiration: initialRevalidate,
|
||||
lambda,
|
||||
fallback: htmlFsRef,
|
||||
group: prerenderGroup,
|
||||
bypassToken: prerenderManifest.bypassToken,
|
||||
});
|
||||
prerenders[outputPathData] = new Prerender({
|
||||
expiration:
|
||||
initialRevalidate === false
|
||||
? MAX_AGE_ONE_YEAR * 10
|
||||
: initialRevalidate,
|
||||
expiration: initialRevalidate,
|
||||
lambda,
|
||||
fallback: jsonFsRef,
|
||||
group: prerenderGroup,
|
||||
@@ -998,21 +1012,24 @@ export const build = async ({
|
||||
++prerenderGroup;
|
||||
};
|
||||
|
||||
Object.keys(prerenderManifest.routes).forEach(route =>
|
||||
onPrerenderRoute(route, false)
|
||||
Object.keys(prerenderManifest.staticRoutes).forEach(route =>
|
||||
onPrerenderRoute(route, { isBlocking: false, isFallback: false })
|
||||
);
|
||||
Object.keys(prerenderManifest.lazyRoutes).forEach(route =>
|
||||
onPrerenderRoute(route, true)
|
||||
Object.keys(prerenderManifest.fallbackRoutes).forEach(route =>
|
||||
onPrerenderRoute(route, { isBlocking: false, isFallback: true })
|
||||
);
|
||||
Object.keys(prerenderManifest.legacyBlockingRoutes).forEach(route =>
|
||||
onPrerenderRoute(route, { isBlocking: true, isFallback: false })
|
||||
);
|
||||
|
||||
// We still need to use lazyRoutes if the dataRoutes field
|
||||
// isn't available for backwards compatibility
|
||||
if (!(routesManifest && routesManifest.dataRoutes)) {
|
||||
// Dynamic pages for lazy routes should be handled by the lambda flow.
|
||||
Object.keys(prerenderManifest.lazyRoutes).forEach(lazyRoute => {
|
||||
const { dataRouteRegex, dataRoute } = prerenderManifest.lazyRoutes[
|
||||
lazyRoute
|
||||
];
|
||||
[
|
||||
...Object.entries(prerenderManifest.fallbackRoutes),
|
||||
...Object.entries(prerenderManifest.legacyBlockingRoutes),
|
||||
].forEach(([, { dataRouteRegex, dataRoute }]) => {
|
||||
dataRoutes.push({
|
||||
// Next.js provided data route regex
|
||||
src: dataRouteRegex.replace(
|
||||
@@ -1068,7 +1085,8 @@ export const build = async ({
|
||||
entryDirectory,
|
||||
dynamicPages,
|
||||
false,
|
||||
routesManifest
|
||||
routesManifest,
|
||||
new Set(prerenderManifest.omittedRoutes)
|
||||
).then(arr =>
|
||||
arr.map(route => {
|
||||
route.src = route.src.replace('^', `^${dynamicPrefix}`);
|
||||
@@ -1076,6 +1094,23 @@ export const build = async ({
|
||||
})
|
||||
);
|
||||
|
||||
// We need to delete lambdas from output instead of omitting them from the
|
||||
// start since we rely on them for powering Preview Mode (read above in
|
||||
// onPrerenderRoute).
|
||||
prerenderManifest.omittedRoutes.forEach(routeKey => {
|
||||
// Get the route file as it'd be mounted in the builder output
|
||||
const routeFileNoExt = path.posix.join(
|
||||
entryDirectory,
|
||||
routeKey === '/' ? '/index' : routeKey
|
||||
);
|
||||
if (typeof lambdas[routeFileNoExt] === undefined) {
|
||||
throw new Error(
|
||||
`invariant: unknown lambda ${routeKey} (lookup: ${routeFileNoExt}) | please report this immediately`
|
||||
);
|
||||
}
|
||||
delete lambdas[routeFileNoExt];
|
||||
});
|
||||
|
||||
return {
|
||||
output: {
|
||||
...publicDirectoryFiles,
|
||||
|
||||
@@ -354,7 +354,8 @@ export async function getDynamicRoutes(
|
||||
entryDirectory: string,
|
||||
dynamicPages: string[],
|
||||
isDev?: boolean,
|
||||
routesManifest?: RoutesManifest
|
||||
routesManifest?: RoutesManifest,
|
||||
omittedRoutes?: Set<string>
|
||||
): Promise<Source[]> {
|
||||
if (!dynamicPages.length) {
|
||||
return [];
|
||||
@@ -364,14 +365,16 @@ export async function getDynamicRoutes(
|
||||
switch (routesManifest.version) {
|
||||
case 1:
|
||||
case 2: {
|
||||
return routesManifest.dynamicRoutes.map(
|
||||
({ page, regex }: { page: string; regex: string }) => {
|
||||
return routesManifest.dynamicRoutes
|
||||
.filter(({ page }) =>
|
||||
omittedRoutes ? !omittedRoutes.has(page) : true
|
||||
)
|
||||
.map(({ page, regex }: { page: string; regex: string }) => {
|
||||
return {
|
||||
src: regex,
|
||||
dest: !isDev ? path.join('/', entryDirectory, page) : page,
|
||||
};
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
default: {
|
||||
// update MIN_ROUTES_MANIFEST_VERSION
|
||||
@@ -617,7 +620,7 @@ export async function createLambdaFromPseudoLayers({
|
||||
export type NextPrerenderedRoutes = {
|
||||
bypassToken: string | null;
|
||||
|
||||
routes: {
|
||||
staticRoutes: {
|
||||
[route: string]: {
|
||||
initialRevalidate: number | false;
|
||||
dataRoute: string;
|
||||
@@ -625,14 +628,24 @@ export type NextPrerenderedRoutes = {
|
||||
};
|
||||
};
|
||||
|
||||
lazyRoutes: {
|
||||
legacyBlockingRoutes: {
|
||||
[route: string]: {
|
||||
fallback?: string;
|
||||
routeRegex: string;
|
||||
dataRoute: string;
|
||||
dataRouteRegex: string;
|
||||
};
|
||||
};
|
||||
|
||||
fallbackRoutes: {
|
||||
[route: string]: {
|
||||
fallback: string;
|
||||
routeRegex: string;
|
||||
dataRoute: string;
|
||||
dataRouteRegex: string;
|
||||
};
|
||||
};
|
||||
|
||||
omittedRoutes: string[];
|
||||
};
|
||||
|
||||
export async function getExportIntent(
|
||||
@@ -717,30 +730,58 @@ export async function getPrerenderManifest(
|
||||
.catch(() => false);
|
||||
|
||||
if (!hasManifest) {
|
||||
return { routes: {}, lazyRoutes: {}, bypassToken: null };
|
||||
return {
|
||||
staticRoutes: {},
|
||||
legacyBlockingRoutes: {},
|
||||
fallbackRoutes: {},
|
||||
bypassToken: null,
|
||||
omittedRoutes: [],
|
||||
};
|
||||
}
|
||||
|
||||
const manifest: {
|
||||
version: 1;
|
||||
routes: {
|
||||
[key: string]: {
|
||||
initialRevalidateSeconds: number | false;
|
||||
dataRoute: string;
|
||||
srcRoute: string | null;
|
||||
};
|
||||
};
|
||||
dynamicRoutes: {
|
||||
[key: string]: {
|
||||
fallback?: string;
|
||||
routeRegex: string;
|
||||
dataRoute: string;
|
||||
dataRouteRegex: string;
|
||||
};
|
||||
};
|
||||
preview?: {
|
||||
previewModeId: string;
|
||||
};
|
||||
} = JSON.parse(await fs.readFile(pathPrerenderManifest, 'utf8'));
|
||||
const manifest:
|
||||
| {
|
||||
version: 1;
|
||||
routes: {
|
||||
[key: string]: {
|
||||
initialRevalidateSeconds: number | false;
|
||||
dataRoute: string;
|
||||
srcRoute: string | null;
|
||||
};
|
||||
};
|
||||
dynamicRoutes: {
|
||||
[key: string]: {
|
||||
fallback?: string;
|
||||
routeRegex: string;
|
||||
dataRoute: string;
|
||||
dataRouteRegex: string;
|
||||
};
|
||||
};
|
||||
preview?: {
|
||||
previewModeId: string;
|
||||
};
|
||||
}
|
||||
| {
|
||||
version: 2;
|
||||
routes: {
|
||||
[route: string]: {
|
||||
initialRevalidateSeconds: number | false;
|
||||
srcRoute: string | null;
|
||||
dataRoute: string;
|
||||
};
|
||||
};
|
||||
dynamicRoutes: {
|
||||
[route: string]: {
|
||||
routeRegex: string;
|
||||
fallback: string | false;
|
||||
dataRoute: string;
|
||||
dataRouteRegex: string;
|
||||
};
|
||||
};
|
||||
preview: {
|
||||
previewModeId: string;
|
||||
};
|
||||
} = JSON.parse(await fs.readFile(pathPrerenderManifest, 'utf8'));
|
||||
|
||||
switch (manifest.version) {
|
||||
case 1: {
|
||||
@@ -748,10 +789,12 @@ export async function getPrerenderManifest(
|
||||
const lazyRoutes = Object.keys(manifest.dynamicRoutes);
|
||||
|
||||
const ret: NextPrerenderedRoutes = {
|
||||
routes: {},
|
||||
lazyRoutes: {},
|
||||
staticRoutes: {},
|
||||
legacyBlockingRoutes: {},
|
||||
fallbackRoutes: {},
|
||||
bypassToken:
|
||||
(manifest.preview && manifest.preview.previewModeId) || null,
|
||||
omittedRoutes: [],
|
||||
};
|
||||
|
||||
routes.forEach(route => {
|
||||
@@ -760,7 +803,7 @@ export async function getPrerenderManifest(
|
||||
dataRoute,
|
||||
srcRoute,
|
||||
} = manifest.routes[route];
|
||||
ret.routes[route] = {
|
||||
ret.staticRoutes[route] = {
|
||||
initialRevalidate:
|
||||
initialRevalidateSeconds === false
|
||||
? false
|
||||
@@ -778,7 +821,68 @@ export async function getPrerenderManifest(
|
||||
dataRouteRegex,
|
||||
} = manifest.dynamicRoutes[lazyRoute];
|
||||
|
||||
ret.lazyRoutes[lazyRoute] = {
|
||||
if (fallback) {
|
||||
ret.fallbackRoutes[lazyRoute] = {
|
||||
routeRegex,
|
||||
fallback,
|
||||
dataRoute,
|
||||
dataRouteRegex,
|
||||
};
|
||||
} else {
|
||||
ret.legacyBlockingRoutes[lazyRoute] = {
|
||||
routeRegex,
|
||||
dataRoute,
|
||||
dataRouteRegex,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
case 2: {
|
||||
const routes = Object.keys(manifest.routes);
|
||||
const lazyRoutes = Object.keys(manifest.dynamicRoutes);
|
||||
|
||||
const ret: NextPrerenderedRoutes = {
|
||||
staticRoutes: {},
|
||||
legacyBlockingRoutes: {},
|
||||
fallbackRoutes: {},
|
||||
bypassToken: manifest.preview.previewModeId,
|
||||
omittedRoutes: [],
|
||||
};
|
||||
|
||||
routes.forEach(route => {
|
||||
const {
|
||||
initialRevalidateSeconds,
|
||||
dataRoute,
|
||||
srcRoute,
|
||||
} = manifest.routes[route];
|
||||
ret.staticRoutes[route] = {
|
||||
initialRevalidate:
|
||||
initialRevalidateSeconds === false
|
||||
? false
|
||||
: Math.max(1, initialRevalidateSeconds),
|
||||
dataRoute,
|
||||
srcRoute,
|
||||
};
|
||||
});
|
||||
|
||||
lazyRoutes.forEach(lazyRoute => {
|
||||
const {
|
||||
routeRegex,
|
||||
fallback,
|
||||
dataRoute,
|
||||
dataRouteRegex,
|
||||
} = manifest.dynamicRoutes[lazyRoute];
|
||||
|
||||
if (!fallback) {
|
||||
// Fallback behavior is disabled, all routes would've been provided
|
||||
// in the top-level `routes` key (`staticRoutes`).
|
||||
ret.omittedRoutes.push(lazyRoute);
|
||||
return;
|
||||
}
|
||||
|
||||
ret.fallbackRoutes[lazyRoute] = {
|
||||
routeRegex,
|
||||
fallback,
|
||||
dataRoute,
|
||||
@@ -789,7 +893,13 @@ export async function getPrerenderManifest(
|
||||
return ret;
|
||||
}
|
||||
default: {
|
||||
return { routes: {}, lazyRoutes: {}, bypassToken: null };
|
||||
return {
|
||||
staticRoutes: {},
|
||||
legacyBlockingRoutes: {},
|
||||
fallbackRoutes: {},
|
||||
bypassToken: null,
|
||||
omittedRoutes: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
packages/now-next/test/fixtures/22-ssg-v2/next.config.js
vendored
Normal file
5
packages/now-next/test/fixtures/22-ssg-v2/next.config.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
generateBuildId() {
|
||||
return 'testing-build-id';
|
||||
},
|
||||
};
|
||||
218
packages/now-next/test/fixtures/22-ssg-v2/now.json
vendored
Normal file
218
packages/now-next/test/fixtures/22-ssg-v2/now.json
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "package.json", "use": "@now/next" }],
|
||||
"probes": [
|
||||
{
|
||||
"path": "/lambda",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "MISS"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/forever",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "PRERENDER"
|
||||
}
|
||||
},
|
||||
{ "delay": 2000 },
|
||||
{
|
||||
"path": "/forever",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "HIT"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/another",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "PRERENDER"
|
||||
}
|
||||
},
|
||||
{ "delay": 2000 },
|
||||
{
|
||||
"path": "/another",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "HIT"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/blog/post-1",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "PRERENDER"
|
||||
}
|
||||
},
|
||||
{ "delay": 2000 },
|
||||
{
|
||||
"path": "/blog/post-1",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "HIT"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/blog/post-2",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "PRERENDER"
|
||||
}
|
||||
},
|
||||
{ "delay": 2000 },
|
||||
{
|
||||
"path": "/blog/post-2",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "HIT"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/blog/post-3",
|
||||
"status": 200,
|
||||
"mustContain": "loading..."
|
||||
},
|
||||
{ "delay": 2000 },
|
||||
{
|
||||
"path": "/blog/post-3",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "/HIT|STALE/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/blog/post-4.json",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "MISS"
|
||||
}
|
||||
},
|
||||
{ "delay": 2000 },
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/blog/post-4.json",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "/HIT|STALE/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/blog/post-3",
|
||||
"status": 200,
|
||||
"mustContain": "post-3"
|
||||
},
|
||||
{
|
||||
"path": "/blog/post-1/comment-1",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "PRERENDER"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/blog/post-2/comment-2",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "PRERENDER"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/blog/post-3/comment-3",
|
||||
"status": 200,
|
||||
"mustContain": "loading..."
|
||||
},
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/lambda.json",
|
||||
"status": 404
|
||||
},
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/forever.json",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "/PRERENDER|HIT/"
|
||||
}
|
||||
},
|
||||
{ "delay": 2000 },
|
||||
{
|
||||
"path": "/blog/post-3/comment-3",
|
||||
"status": 200,
|
||||
"mustContain": "comment-3"
|
||||
},
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/forever.json",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "HIT"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/another.json",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "/HIT|STALE/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/another2.json",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "PRERENDER"
|
||||
}
|
||||
},
|
||||
{ "delay": 2000 },
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/another2.json",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "HIT"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/blog/post-1.json",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "/HIT|STALE|PRERENDER/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/blog/post-1337/comment-1337.json",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "PRERENDER"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/nofallback/one",
|
||||
"status": 200,
|
||||
"mustContain": "one"
|
||||
},
|
||||
{
|
||||
"path": "/nofallback/two",
|
||||
"status": 200,
|
||||
"mustContain": "two"
|
||||
},
|
||||
{
|
||||
"path": "/nofallback/nope",
|
||||
"status": 404,
|
||||
"mustContain": "This page could not be found"
|
||||
},
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/nofallback/one.json",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "/HIT|STALE|PRERENDER/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/nofallback/two.json",
|
||||
"status": 200,
|
||||
"responseHeaders": {
|
||||
"x-now-cache": "/HIT|STALE|PRERENDER/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/_next/data/testing-build-id/nofallback/nope.json",
|
||||
"status": 404
|
||||
}
|
||||
]
|
||||
}
|
||||
7
packages/now-next/test/fixtures/22-ssg-v2/package.json
vendored
Normal file
7
packages/now-next/test/fixtures/22-ssg-v2/package.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"next": "9.2.3-canary.14",
|
||||
"react": "^16.8.6",
|
||||
"react-dom": "^16.8.6"
|
||||
}
|
||||
}
|
||||
21
packages/now-next/test/fixtures/22-ssg-v2/pages/another.js
vendored
Normal file
21
packages/now-next/test/fixtures/22-ssg-v2/pages/another.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticProps() {
|
||||
return {
|
||||
props: {
|
||||
world: 'world',
|
||||
time: new Date().getTime(),
|
||||
},
|
||||
revalidate: 5,
|
||||
};
|
||||
}
|
||||
|
||||
export default ({ world, time }) => {
|
||||
return (
|
||||
<>
|
||||
<p>hello: {world}</p>
|
||||
<span>time: {time}</span>
|
||||
</>
|
||||
);
|
||||
};
|
||||
21
packages/now-next/test/fixtures/22-ssg-v2/pages/another2.js
vendored
Normal file
21
packages/now-next/test/fixtures/22-ssg-v2/pages/another2.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticProps() {
|
||||
return {
|
||||
props: {
|
||||
world: 'world',
|
||||
time: new Date().getTime(),
|
||||
},
|
||||
revalidate: 5,
|
||||
};
|
||||
}
|
||||
|
||||
export default ({ world, time }) => {
|
||||
return (
|
||||
<>
|
||||
<p>hello: {world}</p>
|
||||
<span>time: {time}</span>
|
||||
</>
|
||||
);
|
||||
};
|
||||
37
packages/now-next/test/fixtures/22-ssg-v2/pages/blog/[post]/[comment].js
vendored
Normal file
37
packages/now-next/test/fixtures/22-ssg-v2/pages/blog/[post]/[comment].js
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from 'react';
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticPaths() {
|
||||
return {
|
||||
paths: [
|
||||
'/blog/post-1/comment-1',
|
||||
{ params: { post: 'post-2', comment: 'comment-2' } },
|
||||
'/blog/post-1337/comment-1337',
|
||||
],
|
||||
fallback: true,
|
||||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticProps({ params }) {
|
||||
return {
|
||||
props: {
|
||||
post: params.post,
|
||||
comment: params.comment,
|
||||
time: new Date().getTime(),
|
||||
},
|
||||
revalidate: 2,
|
||||
};
|
||||
}
|
||||
|
||||
export default ({ post, comment, time }) => {
|
||||
if (!post) return <p>loading...</p>;
|
||||
|
||||
return (
|
||||
<>
|
||||
<p>Post: {post}</p>
|
||||
<p>Comment: {comment}</p>
|
||||
<span>time: {time}</span>
|
||||
</>
|
||||
);
|
||||
};
|
||||
37
packages/now-next/test/fixtures/22-ssg-v2/pages/blog/[post]/index.js
vendored
Normal file
37
packages/now-next/test/fixtures/22-ssg-v2/pages/blog/[post]/index.js
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from 'react';
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticPaths() {
|
||||
return {
|
||||
paths: ['/blog/post-1', { params: { post: 'post-2' } }],
|
||||
fallback: true,
|
||||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticProps({ params }) {
|
||||
if (params.post === 'post-10') {
|
||||
await new Promise(resolve => {
|
||||
setTimeout(() => resolve(), 1000);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
post: params.post,
|
||||
time: (await import('perf_hooks')).performance.now(),
|
||||
},
|
||||
revalidate: 10,
|
||||
};
|
||||
}
|
||||
|
||||
export default ({ post, time }) => {
|
||||
if (!post) return <p>loading...</p>;
|
||||
|
||||
return (
|
||||
<>
|
||||
<p>Post: {post}</p>
|
||||
<span>time: {time}</span>
|
||||
</>
|
||||
);
|
||||
};
|
||||
21
packages/now-next/test/fixtures/22-ssg-v2/pages/forever.js
vendored
Normal file
21
packages/now-next/test/fixtures/22-ssg-v2/pages/forever.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticProps() {
|
||||
return {
|
||||
props: {
|
||||
world: 'world',
|
||||
time: new Date().getTime(),
|
||||
},
|
||||
revalidate: false,
|
||||
};
|
||||
}
|
||||
|
||||
export default ({ world, time }) => {
|
||||
return (
|
||||
<>
|
||||
<p>hello: {world}</p>
|
||||
<span>time: {time}</span>
|
||||
</>
|
||||
);
|
||||
};
|
||||
1
packages/now-next/test/fixtures/22-ssg-v2/pages/index.js
vendored
Normal file
1
packages/now-next/test/fixtures/22-ssg-v2/pages/index.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default () => 'Hi';
|
||||
5
packages/now-next/test/fixtures/22-ssg-v2/pages/lambda.js
vendored
Normal file
5
packages/now-next/test/fixtures/22-ssg-v2/pages/lambda.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
const Page = ({ data }) => <p>{data} world</p>;
|
||||
|
||||
Page.getInitialProps = () => ({ data: 'hello' });
|
||||
|
||||
export default Page;
|
||||
31
packages/now-next/test/fixtures/22-ssg-v2/pages/nofallback/[slug].js
vendored
Normal file
31
packages/now-next/test/fixtures/22-ssg-v2/pages/nofallback/[slug].js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticPaths() {
|
||||
return {
|
||||
paths: ['/nofallback/one', { params: { slug: 'two' } }],
|
||||
fallback: false,
|
||||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticProps({ params }) {
|
||||
return {
|
||||
props: {
|
||||
slug: params.slug,
|
||||
time: (await import('perf_hooks')).performance.now(),
|
||||
},
|
||||
revalidate: 10,
|
||||
};
|
||||
}
|
||||
|
||||
export default ({ slug, time }) => {
|
||||
return (
|
||||
<>
|
||||
<p>
|
||||
Slug ({slug.length}): {slug}
|
||||
</p>
|
||||
<span>time: {time}</span>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -21,23 +21,23 @@ mv dist/types dist/index.d.ts
|
||||
|
||||
# bundle helpers.ts with ncc
|
||||
rm dist/helpers.js
|
||||
ncc build src/helpers.ts -o dist/helpers
|
||||
ncc build src/helpers.ts -e @now/build-utils -o dist/helpers
|
||||
mv dist/helpers/index.js dist/helpers.js
|
||||
rm -rf dist/helpers
|
||||
|
||||
# build source-map-support/register for source maps
|
||||
ncc build ../../node_modules/source-map-support/register -o dist/source-map-support
|
||||
ncc build ../../node_modules/source-map-support/register -e @now/build-utils -o dist/source-map-support
|
||||
mv dist/source-map-support/index.js dist/source-map-support.js
|
||||
rm -rf dist/source-map-support
|
||||
|
||||
# build typescript
|
||||
ncc build ../../node_modules/typescript/lib/typescript -o dist/typescript
|
||||
ncc build ../../node_modules/typescript/lib/typescript -e @now/build-utils -o dist/typescript
|
||||
mv dist/typescript/index.js dist/typescript.js
|
||||
mkdir -p dist/typescript/lib
|
||||
mv dist/typescript/typescript/lib/*.js dist/typescript/lib/
|
||||
mv dist/typescript/typescript/lib/*.d.ts dist/typescript/lib/
|
||||
rm -r dist/typescript/typescript
|
||||
|
||||
ncc build src/index.ts -o dist/main
|
||||
ncc build src/index.ts -e @now/build-utils -o dist/main
|
||||
mv dist/main/index.js dist/index.js
|
||||
rm -rf dist/main
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/node",
|
||||
"version": "1.4.1",
|
||||
"version": "1.4.2-canary.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/node-js",
|
||||
|
||||
@@ -12,15 +12,5 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"probes": [
|
||||
{
|
||||
"path": "/lighthouse",
|
||||
"mustContain": "lighthouse:RANDOMNESS_PLACEHOLDER"
|
||||
},
|
||||
{
|
||||
"path": "/screenshot",
|
||||
"mustContain": "screenshot:RANDOMNESS_PLACEHOLDER"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
37
packages/now-node/test/fixtures/35-puppeteer/probe.js
vendored
Normal file
37
packages/now-node/test/fixtures/35-puppeteer/probe.js
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
const assert = require('assert').strict;
|
||||
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||
|
||||
async function tryTest({
|
||||
testName,
|
||||
deploymentUrl,
|
||||
fetch,
|
||||
randomness,
|
||||
retries = 4,
|
||||
}) {
|
||||
try {
|
||||
const res = await fetch(`https://${deploymentUrl}/${testName}`);
|
||||
assert.equal(res.status, 200);
|
||||
const text = await res.text();
|
||||
assert.equal(text.trim(), `${testName}:${randomness}`);
|
||||
console.log(`Finished testing "${testName}" probe.`);
|
||||
} catch (e) {
|
||||
if (retries === 0) {
|
||||
console.error(e);
|
||||
throw e;
|
||||
}
|
||||
console.log(`Failed "${testName}" probe. Retries remaining: ${retries}`);
|
||||
await sleep(1000);
|
||||
await tryTest({
|
||||
testName,
|
||||
deploymentUrl,
|
||||
fetch,
|
||||
randomness,
|
||||
retries: retries - 1,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = async ({ deploymentUrl, fetch, randomness }) => {
|
||||
await tryTest({ testName: 'lighthouse', deploymentUrl, fetch, randomness });
|
||||
await tryTest({ testName: 'screenshot', deploymentUrl, fetch, randomness });
|
||||
};
|
||||
@@ -1 +1 @@
|
||||
ncc build src/index.ts -o dist
|
||||
ncc build src/index.ts -e @now/build-utils -o dist
|
||||
|
||||
@@ -45,6 +45,7 @@ if 'handler' in __now_variables or 'Handler' in __now_variables:
|
||||
|
||||
payload = json.loads(event['body'])
|
||||
path = unquote(payload['path'])
|
||||
path = path.replace(' ', '%20')
|
||||
headers = payload['headers']
|
||||
method = payload['method']
|
||||
encoding = payload.get('encoding')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/python",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5-canary.1",
|
||||
"main": "./dist/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/python",
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "*.py", "use": "@now/python" }],
|
||||
"routes": [{ "src": "/another", "dest": "custom.py" }],
|
||||
"routes": [{ "src": "/(.+)", "dest": "custom.py" }],
|
||||
"probes": [
|
||||
{ "path": "/?hello=/", "mustContain": "path=/?hello=/" },
|
||||
{ "path": "/another?hello=/", "mustContain": "path=/another?hello=/" }
|
||||
{ "path": "/another?hello=/", "mustContain": "path=/another?hello=/" },
|
||||
{ "path": "/another?hello=/", "mustContain": "path=/another?hello=/" },
|
||||
{ "path": "/?say=hello%20world", "mustContain": "/?say=hello%20world" },
|
||||
{ "path": "/?say%20hello=nice", "mustContain": "/?say%20hello=nice" },
|
||||
{
|
||||
"path": "/hello%20world?say=nice",
|
||||
"mustContain": "/hello%20world?say=nice"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/routing-utils",
|
||||
"version": "1.6.1-canary.0",
|
||||
"version": "1.7.0",
|
||||
"description": "ZEIT Now routing utilities",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
||||
@@ -6,15 +6,12 @@ export function appendRoutesToPhase({
|
||||
newRoutes,
|
||||
phase,
|
||||
}: AppendRoutesToPhaseProps) {
|
||||
if (prevRoutes === null) {
|
||||
return [];
|
||||
}
|
||||
const routes = prevRoutes ? [...prevRoutes] : [];
|
||||
if (newRoutes === null || newRoutes.length === 0) {
|
||||
return prevRoutes;
|
||||
return routes;
|
||||
}
|
||||
let isInPhase = false;
|
||||
let insertIndex = -1;
|
||||
const routes = [...prevRoutes];
|
||||
|
||||
routes.forEach((r, i) => {
|
||||
if (isHandler(r)) {
|
||||
|
||||
13
packages/now-routing-utils/test/append.spec.js
vendored
13
packages/now-routing-utils/test/append.spec.js
vendored
@@ -1,7 +1,7 @@
|
||||
const { deepEqual } = require('assert');
|
||||
const { appendRoutesToPhase } = require('../dist/append');
|
||||
|
||||
test('appendRoutesToPhase `routes=null`', () => {
|
||||
test('appendRoutesToPhase `routes=null` and `newRoutes=[]`', () => {
|
||||
const routes = null;
|
||||
const newRoutes = [];
|
||||
const phase = 'filesystem';
|
||||
@@ -10,7 +10,16 @@ test('appendRoutesToPhase `routes=null`', () => {
|
||||
deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('appendRoutesToPhase `newRoutes=null`', () => {
|
||||
test('appendRoutesToPhase `routes=null` and one `newRoutes`', () => {
|
||||
const routes = null;
|
||||
const newRoutes = [{ src: '/foo', dest: '/bar' }];
|
||||
const phase = 'filesystem';
|
||||
const actual = appendRoutesToPhase({ routes, newRoutes, phase });
|
||||
const expected = [{ handle: 'filesystem' }, ...newRoutes];
|
||||
deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('appendRoutesToPhase `routes=[]` and `newRoutes=null`', () => {
|
||||
const routes = [];
|
||||
const newRoutes = null;
|
||||
const phase = 'filesystem';
|
||||
|
||||
@@ -1 +1 @@
|
||||
ncc build index.ts -o dist
|
||||
ncc build index.ts -e @now/build-utils -o dist
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@now/ruby",
|
||||
"author": "Nathan Cahill <nathan@nathancahill.com>",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3-canary.3",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/ruby",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'cowsay'
|
||||
|
||||
Handler = Proc.new do |req, res|
|
||||
res.status = 200
|
||||
res['Content-Type'] = 'text/plain'
|
||||
res.body = Cowsay.say('gem:RANDOMNESS_PLACEHOLDER', 'cow')
|
||||
res.status = 200
|
||||
res['Content-Type'] = 'text/plain'
|
||||
res.body = Cowsay.say('gem:RANDOMNESS_PLACEHOLDER', 'cow')
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
rack (2.1.1)
|
||||
rack (2.2.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -10,4 +10,4 @@ DEPENDENCIES
|
||||
rack (~> 2.0)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
2.1.4
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
rack (2.1.1)
|
||||
rack (2.2.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -10,4 +10,4 @@ DEPENDENCIES
|
||||
rack (~> 2.0)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
2.1.4
|
||||
|
||||
3
packages/now-ruby/test/fixtures/09-activesupport/Gemfile
vendored
Normal file
3
packages/now-ruby/test/fixtures/09-activesupport/Gemfile
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "activesupport", "~> 6.0"
|
||||
26
packages/now-ruby/test/fixtures/09-activesupport/Gemfile.lock
vendored
Normal file
26
packages/now-ruby/test/fixtures/09-activesupport/Gemfile.lock
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activesupport (6.0.2.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
zeitwerk (~> 2.2)
|
||||
concurrent-ruby (1.1.6)
|
||||
i18n (1.8.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
minitest (5.14.0)
|
||||
thread_safe (0.3.6)
|
||||
tzinfo (1.2.6)
|
||||
thread_safe (~> 0.1)
|
||||
zeitwerk (2.2.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activesupport (~> 6.0)
|
||||
|
||||
BUNDLED WITH
|
||||
2.1.4
|
||||
14
packages/now-ruby/test/fixtures/09-activesupport/index.rb
vendored
Normal file
14
packages/now-ruby/test/fixtures/09-activesupport/index.rb
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
require 'active_support'
|
||||
require 'active_support/core_ext'
|
||||
|
||||
Handler = Proc.new do |request, response|
|
||||
response.status = 200
|
||||
response["Content-Type"] = "text/plain"
|
||||
response.body = <<-BODY
|
||||
10y+ future:
|
||||
#{Date.current + 10.years}
|
||||
|
||||
test:
|
||||
gem:RANDOMNESS_PLACEHOLDER
|
||||
BODY
|
||||
end
|
||||
5
packages/now-ruby/test/fixtures/09-activesupport/now.json
vendored
Normal file
5
packages/now-ruby/test/fixtures/09-activesupport/now.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "index.rb", "use": "@now/ruby" }],
|
||||
"probes": [{ "path": "/", "mustContain": "gem:RANDOMNESS_PLACEHOLDER" }]
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
ncc build src/index.ts -o dist
|
||||
ncc build src/index.ts -e @now/build-utils -o dist
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/static-build",
|
||||
"version": "0.14.13-canary.0",
|
||||
"version": "0.14.13-canary.1",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/static-builds",
|
||||
|
||||
@@ -91,7 +91,6 @@ async function testDeployment(
|
||||
bodies['now.json'] = Buffer.from(JSON.stringify(nowJson));
|
||||
delete bodies['probe.js'];
|
||||
const { deploymentId, deploymentUrl } = await nowDeploy(bodies, randomness);
|
||||
console.log('deploymentUrl', `https://${deploymentUrl}`);
|
||||
|
||||
for (const probe of nowJson.probes || []) {
|
||||
console.log('testing', JSON.stringify(probe));
|
||||
|
||||
Reference in New Issue
Block a user