Compare commits

...

15 Commits

Author SHA1 Message Date
Nathan Rajlich
2e0cee490d Publish Canary
- @vercel/build-utils@2.2.2-canary.8
 - vercel@18.0.1-canary.20
 - @vercel/client@7.1.1-canary.5
 - @vercel/go@1.0.8-canary.2
 - @vercel/next@2.5.5-canary.7
 - @vercel/node@1.5.2-canary.9
 - @vercel/python@1.1.7-canary.3
 - @vercel/ruby@1.1.1-canary.2
 - @vercel/static-build@0.16.1-canary.6
2020-05-06 22:16:10 -07:00
Nathan Rajlich
8a9b67a3f3 [now-build-utils] Use @now runtimes for zero-config (#4284)
* [now-build-utils] Use `@now` runtimes for zero-config

This is a temporary change until the `@vercel` runtimes work in
production.

* Temporary fix to E2E
2020-05-06 22:09:06 -07:00
Nathan Rajlich
f1d9a5da96 [now-build-utils][now-cli] Fix isOfficialRuntime() edge case bug (#4282)
Fixes a bug where `isOfficialRuntime('static', '@now/static-build')` was returning `true` when it should have been `false`.

And use the function from `@vercel/build-utils` in Vercel CLI.
2020-05-07 03:33:35 +00:00
Nathan Rajlich
8d9c463e1f [now-cli] Update references to Now CLI as Vercel CLI (#4279)
Update references to Now CLI as Vercel CLI 

Co-authored-by: Steven <steven@ceriously.com>
2020-05-06 21:15:20 -04:00
Steven
e07e8f841a [now-cli] Add special case for .vercel.app (#4281)
There are a few places the CLI needs to know about the special suffix `.now.sh` so we also need to include the upcoming `.vercel.app` suffix.
2020-05-07 01:09:21 +00:00
Steven
0b8a2c0dab [now-cli] Update README.md image (#4278)
This PR updates the name, logo, and tagline.

This will look correct in both light mode and dark mode and the text is no longer part of the image.
2020-05-06 19:44:24 -04:00
Shu Ding
9c2b7132fa add cors headers (#4280) 2020-05-07 07:40:29 +08:00
Steven
d4639a5108 [now-cli] Rename bin to support vercel and vc (#4277)
We want to make sure the bin matches the [installed package name](https://docs.npmjs.com/files/package.json#bin).

This means `npm i -g now` will remain `now` and `npm i -g vercel` will use `vercel` as the binary name.

This allows support for different versions on one machine such as `npm i -g now@17 vercel@19` for example.

In addition, we will also install a shorthand `vc` so you can do `vc env pull` for example.
2020-05-06 23:12:06 +00:00
Steven
ba25004ea8 [all] Check for VERCEL_ environment variables with getPlatformEnv() (#4274)
Added the following env vars, most are undocumented but its good to be consistent:

- `VERCEL_REGION`
- `VERCEL_DEBUG`
- `VERCEL_BUILDER_DEBUG`
- `VERCEL_TOKEN`
- `__VERCEL_SKIP_DEV_CMD`

I also updated the error code prefixes to remove `NOW_`.
There `code` isn't used anywhere, this is just to make it unique and a little shorter.
2020-05-06 22:13:12 +00:00
Steven
639a9b03d2 [now-cli][now-go][now-python] Use `<project>/.vercel/cache' dir during dev (#4273)
We renamed `.now` to `.vercel` in #4234 but still fallback to `.now` if it exists. This is because we don't want users to have to re-link all their existing projects. So we need to make sure that the Runtimes know which directory to use for caching. This PR introduces the `devCacheDir` for this purpose.
2020-05-06 19:23:39 +00:00
Nathan Rajlich
28ffdfbeef Add logging to debug failed npm publish for legacy package names in CI (#4266)
As you can see in https://github.com/zeit/now/runs/647945621,
the final step for publishing the legacy `@now` packages failed
with a 401 error from npm.

This additional logging an to attempt to debug why that is happening.
2020-05-06 18:22:09 +00:00
Steven
5e222d3c03 [tests] Fix cancel workflow pattern (#4264)
Sometimes, the "Cancel" workflow wouldn't run because it didn't match the branch name.
This PR will fix the glob to match any branch name.

- `*`: Matches zero or more characters, but does not match the `/` character.
- `**`: Matches zero or more of any character.

https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
2020-05-06 02:14:55 +00:00
Steven
94c8464728 [now-node][now-static-build] Add test for timezone utc (#4265)
This PR adds a couple tests to ensure that the timezone offset is `0` meaning [UTC](https://en.wikipedia.org/wiki/Coordinated_Universal_Time).
2020-05-06 01:14:35 +00:00
Nathan Rajlich
898478d1e1 Publish Canary
- @vercel/frameworks@0.0.14-canary.0
 - @vercel/build-utils@2.2.2-canary.7
 - @vercel/cgi@1.0.5-canary.1
 - vercel@18.0.1-canary.19
 - @vercel/client@7.1.1-canary.4
 - @vercel/go@1.0.8-canary.1
 - @vercel/next@2.5.5-canary.6
 - @vercel/node-bridge@1.2.7-canary.3
 - @vercel/node@1.5.2-canary.8
 - @vercel/python@1.1.7-canary.2
 - @vercel/routing-utils@1.8.2-canary.5
 - @vercel/ruby@1.1.1-canary.1
 - @vercel/static-build@0.16.1-canary.5
2020-05-05 17:11:39 -07:00
Nathan Rajlich
8a68211cad [all] Rename packages to vercel and add logic to publish legacy package names to npm (#4233)
https://vercel.com/blog/zeit-is-now-vercel

* Updates all org packages from `@now` to `@vercel`
* Updates Now CLI package name from `now` to `vercel`
  * Packages contains `"bin"` entries for _both_ `vercel` and `now` in the package.json
* Updates `now-client` package name to `@vercel/client` (org scoped, for authenticity)

There is also a new `publish-legacy.sh` script which ensures that all the legacy package names (i.e. `now`, `now-client`, `@now/node`, etc.) will still be published as well.

We will remove this legacy publishing logic on Jan 1, 2021.
2020-05-05 23:43:57 +00:00
277 changed files with 852 additions and 567 deletions

View File

@@ -2,7 +2,7 @@ name: Cancel
on:
push:
branches:
- '*'
- '**'
- '!master'
jobs:

View File

@@ -28,7 +28,7 @@ jobs:
- run: yarn run lint
if: matrix.os == 'ubuntu-latest' && matrix.node == 12 # only run lint once
- run: yarn run test-unit --clean false
- run: yarn workspace now run coverage
- run: yarn workspace vercel run coverage
if: matrix.os == 'ubuntu-latest' && matrix.node == 12 # only run coverage once
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

1
.gitignore vendored
View File

@@ -6,6 +6,7 @@ npm-debug.log
yarn-error.log
.nyc_output
coverage
coverage.lcov
*.swp
*.bak
*.tgz

View File

@@ -1,11 +1,15 @@
![now](https://assets.zeit.co/image/upload/v1581518533/repositories/now-cli/v4.png)
<p align="center">
<img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96">
<h3 align="center">Vercel</h3>
<p align="center">Develop. Preview. Ship.</p>
</p>
[![CI Status](https://badgen.net/github/checks/zeit/now?label=CI)](https://github.com/zeit/now/actions?workflow=CI)
[![Join the community on GitHub Discussions](https://badgen.net/badge/join%20the%20discussion/on%20github/black?icon=github)](https://github.com/zeit/now/discussions)
## Usage
Get started by [Importing a Git Project](https://vercel.com/import) and use `git push` to deploy. Alternatively, you can [install Now CLI](https://vercel.com/download).
Get started by [Importing a Git Project](https://vercel.com/import) and use `git push` to deploy. Alternatively, you can [install Vercel CLI](https://vercel.com/download).
## Documentation
@@ -17,12 +21,10 @@ For details on how to use Vercel, check out our [documentation](https://vercel.c
2. Install dependencies with `yarn install`
3. Compile the code: `yarn build`
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
5. You can start using `vercel` 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.
## How to Create a Release
If you have write access to this repository, you can read more about how to publish a release [here](https://github.com/zeit/now/wiki/Creating-a-Release).

View File

@@ -19,5 +19,8 @@ export default withApiHandler(async function(
req: NowRequest,
res: NowResponse
) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET');
res.setHeader('Access-Control-Allow-Headers', 'Authorization, Accept, Content-Type');
return res.status(200).json(frameworks);
});

View File

@@ -1,5 +1,5 @@
{
"name": "now-builders",
"name": "vercel-monorepo",
"version": "0.0.0",
"private": true,
"license": "MIT",
@@ -27,6 +27,7 @@
"json5": "2.1.1",
"lint-staged": "9.2.5",
"node-fetch": "2.6.0",
"npm-package-arg": "6.1.0",
"prettier": "1.18.2"
},
"scripts": {

View File

@@ -1,6 +1,6 @@
{
"name": "@now/frameworks",
"version": "0.0.13",
"name": "@vercel/frameworks",
"version": "0.0.14-canary.0",
"main": "frameworks.json",
"license": "UNLICENSED"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@now/build-utils",
"version": "2.2.2-canary.6",
"name": "@vercel/build-utils",
"version": "2.2.2-canary.8",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.js",
@@ -12,8 +12,8 @@
},
"scripts": {
"build": "./build.sh",
"test-unit": "jest --env node --verbose --runInBand test/unit.*test.*",
"test-integration-once": "jest --env node --verbose --runInBand test/integration.test.js",
"test-unit": "jest --env node --verbose --runInBand --bail test/unit.*test.*",
"test-integration-once": "jest --env node --verbose --runInBand --bail test/integration.test.js",
"prepublishOnly": "./build.sh"
},
"devDependencies": {

View File

@@ -1,5 +1,7 @@
import { getPlatformEnv } from './';
export default function debug(message: string, ...additional: any[]) {
if (process.env.NOW_BUILDER_DEBUG) {
if (getPlatformEnv('BUILDER_DEBUG')) {
console.log(message, ...additional);
}
}

View File

@@ -1,8 +1,9 @@
import minimatch from 'minimatch';
import { valid as validSemver } from 'semver';
import { parse as parsePath, extname } from 'path';
import { Route, Source } from '@now/routing-utils';
import { Route, Source } from '@vercel/routing-utils';
import { PackageJson, Builder, Config, BuilderFunctions } from './types';
import { isOfficialRuntime } from './';
interface ErrorResponse {
code: string;
@@ -55,7 +56,7 @@ export function detectApiDirectory(builders: Builder[]): string | null {
function getPublicBuilder(builders: Builder[]): Builder | null {
const builder = builders.find(
builder =>
builder.use === '@now/static' &&
isOfficialRuntime('static', builder.use) &&
/^.*\/\*\*\/\*$/.test(builder.src) &&
builder.config &&
builder.config.zeroConfig === true
@@ -594,7 +595,7 @@ function checkUnusedFunctions(
}
// Next.js can use functions only for `src/pages` or `pages`
if (frontendBuilder && frontendBuilder.use.startsWith('@now/next')) {
if (frontendBuilder && isOfficialRuntime('next', frontendBuilder.use)) {
for (const fnKey of unusedFunctions.values()) {
if (fnKey.startsWith('pages/') || fnKey.startsWith('src/pages')) {
unusedFunctions.delete(fnKey);
@@ -959,7 +960,7 @@ function getRouteResult(
outputDirectory &&
frontendBuilder &&
!options.featHandleMiss &&
frontendBuilder.use === '@now/static'
isOfficialRuntime('static', frontendBuilder.use)
) {
defaultRoutes.push({
src: '/(.*)',

View File

@@ -1,4 +1,4 @@
import { Framework, FrameworkDetectionItem } from '@now/frameworks';
import { Framework, FrameworkDetectionItem } from '@vercel/frameworks';
import { DetectorFilesystem } from './detectors/filesystem';
export interface DetectFrameworkOptions {

View File

@@ -23,7 +23,7 @@ interface Props {
message: string;
/**
* A unique error code for this particular error.
* Should start with the builder name such as `NOW_NODE_`.
* Should start with the builder name such as `NODE_`.
*/
code: string;
/**

View File

@@ -54,7 +54,7 @@ export async function getSupportedNodeVersion(
engineRange +
'".';
throw new NowBuildError({
code: 'NOW_BUILD_UTILS_NODE_VERSION_INVALID',
code: 'BUILD_UTILS_NODE_VERSION_INVALID',
link:
'https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version',
message: intro + '\n' + pleaseSet,
@@ -72,7 +72,7 @@ export async function getSupportedNodeVersion(
engineRange +
'".';
throw new NowBuildError({
code: 'NOW_BUILD_UTILS_NODE_VERSION_DISCONTINUED',
code: 'BUILD_UTILS_NODE_VERSION_DISCONTINUED',
link:
'https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version',
message: intro + '\n' + pleaseSet + '\n' + upstreamProvider,

View File

@@ -39,7 +39,7 @@ export function spawnAsync(
: 'Command';
reject(
new NowBuildError({
code: `NOW_BUILD_UTILS_SPAWN_${code || signal}`,
code: `BUILD_UTILS_SPAWN_${code || signal}`,
message:
opts.stdio === 'inherit'
? `${cmd} exited with ${code || signal}`
@@ -81,7 +81,7 @@ export function execAsync(
return reject(
new NowBuildError({
code: `NOW_BUILD_UTILS_EXEC_${code || signal}`,
code: `BUILD_UTILS_EXEC_${code || signal}`,
message: `${cmd} exited with ${code || signal}`,
})
);

View File

@@ -80,3 +80,29 @@ export { readConfigFile } from './fs/read-config-file';
export * from './schemas';
export * from './types';
export * from './errors';
/**
* Helper function to support both `@vercel` and legacy `@now` official Runtimes.
*/
export const isOfficialRuntime = (desired: string, name?: string): boolean => {
if (typeof name !== 'string') {
return false;
}
return (
name === `@vercel/${desired}` ||
name === `@now/${desired}` ||
name.startsWith(`@vercel/${desired}@`) ||
name.startsWith(`@now/${desired}@`)
);
};
export const isStaticRuntime = (name?: string): boolean => {
return isOfficialRuntime('static', name);
};
/**
* Helper function to support both `VERCEL_` and legacy `NOW_` env vars.
*/
export const getPlatformEnv = (name: string): string | undefined => {
return process.env[`VERCEL_${name}`] || process.env[`NOW_${name}`];
};

View File

@@ -49,8 +49,9 @@ export interface Config {
export interface Meta {
isDev?: boolean;
devCacheDir?: string;
skipDownload?: boolean;
requestPath?: string;
requestPath?: string | null;
filesChanged?: string[];
filesRemoved?: string[];
env?: Env;

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "api/index.js", "use": "@now/node" }],
"builds": [{ "src": "api/index.js", "use": "@vercel/node" }],
"probes": [
{
"path": "/api/index.js",

View File

@@ -1,9 +1,9 @@
{
"version": 2,
"builds": [
{ "src": "with-npm/index.js", "use": "@now/node" },
{ "src": "with-yarn/index.js", "use": "@now/node" },
{ "src": "with-yarn-and-npm/index.js", "use": "@now/node" }
{ "src": "with-npm/index.js", "use": "@vercel/node" },
{ "src": "with-yarn/index.js", "use": "@vercel/node" },
{ "src": "with-yarn-and-npm/index.js", "use": "@vercel/node" }
],
"probes": [
{ "path": "/with-npm", "mustContain": "npm:RANDOMNESS_PLACEHOLDER" },

View File

@@ -3,7 +3,7 @@
"builds": [
{
"src": "index.js",
"use": "@now/node"
"use": "@vercel/node"
}
],
"probes": [{ "path": "/", "mustContain": "found:RANDOMNESS_PLACEHOLDER" }]

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/static-build" }],
"builds": [{ "src": "package.json", "use": "@vercel/static-build" }],
"build": { "env": { "NODE_ENV": "production" } },
"probes": [{ "path": "/", "mustContain": "node-env:RANDOMNESS_PLACEHOLDER" }]
}

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/static-build" }],
"builds": [{ "src": "package.json", "use": "@vercel/static-build" }],
"build": { "env": { "NODE_ENV": "custom-value:RANDOMNESS_PLACEHOLDER" } },
"probes": [
{ "path": "/", "mustContain": "custom-value:RANDOMNESS_PLACEHOLDER" }

View File

@@ -2,8 +2,8 @@
"version": 2,
"build": { "env": { "NPM_ONLY_PRODUCTION": "1" } },
"builds": [
{ "src": "npm/package.json", "use": "@now/static-build" },
{ "src": "yarn/package.json", "use": "@now/static-build" }
{ "src": "npm/package.json", "use": "@vercel/static-build" },
{ "src": "yarn/package.json", "use": "@vercel/static-build" }
],
"probes": [
{ "path": "/npm", "mustContain": "npm-prod:RANDOMNESS_PLACEHOLDER" },

View File

@@ -27,7 +27,7 @@ for (const fixture of fs.readdirSync(fixturesPath)) {
}
// eslint-disable-next-line no-loop-func
it(`should build ${fixture}`, async () => {
it(`Should build "${fixture}"`, async () => {
await expect(
testDeployment(
{ builderUrl, buildUtilsUrl },
@@ -53,7 +53,7 @@ for (const builder of buildersToTestWith) {
// don't run all foreign fixtures, just some
if (['01-cowsay', '01-cache-headers', '03-env-vars'].includes(fixture)) {
// eslint-disable-next-line no-loop-func
it(`should build ${builder}/${fixture}`, async () => {
it(`Should build "${builder}/${fixture}"`, async () => {
await expect(
testDeployment(
{ builderUrl, buildUtilsUrl },
@@ -113,15 +113,13 @@ it('Test `detectBuilders` and `detectRoutes`', async () => {
const { builders, defaultRoutes } = await detectBuilders(files, pkg);
const nowConfig = { builds: builders, routes: defaultRoutes, probes };
await fs.writeFile(
path.join(fixture, 'now.json'),
JSON.stringify(nowConfig, null, 2)
);
const deployment = await testDeployment(
{ builderUrl, buildUtilsUrl },
fixture
);
const deployment = await testDeployment({ builderUrl }, fixture);
expect(deployment).toBeDefined();
});
@@ -199,9 +197,6 @@ it('Test `detectBuilders` with `index` files', async () => {
JSON.stringify(nowConfig, null, 2)
);
const deployment = await testDeployment(
{ builderUrl, buildUtilsUrl },
fixture
);
const deployment = await testDeployment({ builderUrl }, fixture);
expect(deployment).toBeDefined();
});

View File

@@ -1,10 +1,10 @@
import { Source, Route, Handler } from '@now/routing-utils';
import { detectBuilders } from '../src';
import { Source, Route, Handler } from '@vercel/routing-utils';
import {
detectBuilders,
detectOutputDirectory,
detectApiDirectory,
detectApiExtensions,
} from '../';
} from '../src';
describe('Test `detectBuilders`', () => {
it('should never select now.json src', async () => {

View File

@@ -1,6 +1,6 @@
import path from 'path';
import { readFileSync } from 'fs-extra';
import { Framework } from '@now/frameworks';
import { Framework } from '@vercel/frameworks';
import { detectFramework, DetectorFilesystem } from '../src';
const frameworkList = JSON.parse(

View File

@@ -0,0 +1,40 @@
import assert from 'assert';
import { isOfficialRuntime, isStaticRuntime } from '../src';
describe('Test `isOfficialRuntime()`', () => {
it('should be correct', () => {
assert.equal(true, isOfficialRuntime('static', '@vercel/static'));
assert.equal(true, isOfficialRuntime('static', '@now/static'));
assert.equal(false, isOfficialRuntime('static', '@vercel/static-build'));
assert.equal(false, isOfficialRuntime('static', '@now/static-build'));
assert.equal(true, isOfficialRuntime('node', '@vercel/node'));
assert.equal(true, isOfficialRuntime('node', '@now/node'));
assert.equal(true, isOfficialRuntime('node', '@vercel/node@1.0.0'));
assert.equal(true, isOfficialRuntime('node', '@now/node@1.0.0'));
assert.equal(false, isOfficialRuntime('node', '@my-fork/node'));
assert.equal(false, isOfficialRuntime('node', '@now/node-server'));
assert.equal(
true,
isOfficialRuntime('static-build', '@vercel/static-build')
);
assert.equal(true, isOfficialRuntime('static-build', '@now/static-build'));
assert.equal(
true,
isOfficialRuntime('static-build', '@vercel/static-build@1.0.0')
);
assert.equal(false, isOfficialRuntime('static-build', '@vercel/static'));
assert.equal(false, isOfficialRuntime('static-build', '@now/static'));
});
});
describe('Test `isStaticRuntime()`', () => {
it('should be correct', () => {
assert.equal(true, isStaticRuntime('@vercel/static'));
assert.equal(true, isStaticRuntime('@now/static'));
assert.equal(false, isStaticRuntime('@vercel/static-build'));
assert.equal(false, isStaticRuntime('@now/static-build'));
assert.equal(false, isStaticRuntime('@now/node'));
});
});

View File

@@ -134,21 +134,21 @@ it('should throw for discontinued versions', async () => {
});
it('should support require by path for legacy builders', () => {
const index = require('@now/build-utils');
const index = require('@vercel/build-utils');
const download2 = require('@now/build-utils/fs/download.js');
const getWriteableDirectory2 = require('@now/build-utils/fs/get-writable-directory.js');
const glob2 = require('@now/build-utils/fs/glob.js');
const rename2 = require('@now/build-utils/fs/rename.js');
const download2 = require('@vercel/build-utils/fs/download.js');
const getWriteableDirectory2 = require('@vercel/build-utils/fs/get-writable-directory.js');
const glob2 = require('@vercel/build-utils/fs/glob.js');
const rename2 = require('@vercel/build-utils/fs/rename.js');
const {
runNpmInstall: runNpmInstall2,
} = require('@now/build-utils/fs/run-user-scripts.js');
const streamToBuffer2 = require('@now/build-utils/fs/stream-to-buffer.js');
} = require('@vercel/build-utils/fs/run-user-scripts.js');
const streamToBuffer2 = require('@vercel/build-utils/fs/stream-to-buffer.js');
const FileBlob2 = require('@now/build-utils/file-blob.js');
const FileFsRef2 = require('@now/build-utils/file-fs-ref.js');
const FileRef2 = require('@now/build-utils/file-ref.js');
const { Lambda: Lambda2 } = require('@now/build-utils/lambda.js');
const FileBlob2 = require('@vercel/build-utils/file-blob.js');
const FileFsRef2 = require('@vercel/build-utils/file-fs-ref.js');
const FileRef2 = require('@vercel/build-utils/file-ref.js');
const { Lambda: Lambda2 } = require('@vercel/build-utils/lambda.js');
expect(download2).toBe(index.download);
expect(getWriteableDirectory2).toBe(index.getWriteableDirectory);

View File

@@ -1,6 +1,6 @@
{
"name": "@now/cgi",
"version": "1.0.5-canary.0",
"name": "@vercel/cgi",
"version": "1.0.5-canary.1",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -1,22 +1,27 @@
![now](https://assets.zeit.co/image/upload/v1581518533/repositories/now-cli/v4.png)
<p align="center">
<img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96">
<h3 align="center">Vercel</h3>
<p align="center">Develop. Preview. Ship.</p>
</p>
[![Join the community on GitHub Discussions](https://badgen.net/badge/join%20the%20discussion/on%20github/black?icon=github)](https://github.com/zeit/now/discussions)
## Usages
To install the latest version of Now CLI, visit [vercel.com/download](https://vercel.com/download) or run this command:
To install the latest version of Vercel CLI, visit [vercel.com/download](https://vercel.com/download) or run this command:
```sh
npm i -g now
npm i -g vercel
```
To quickly start a new project, run the following commands:
```
now init # Pick an example project
vercel init # Pick an example project
cd <PROJECT> # Change directory to the new project
now # Deploy to the cloud
vercel # Deploy to the cloud
```
## Documentation
For details on how to use Now CLI, check out our [documentation](https://vercel.com/docs).
For details on how to use Vercel CLI, check out our [documentation](https://vercel.com/docs).

View File

@@ -1,6 +1,6 @@
{
"name": "now",
"version": "18.0.1-canary.18",
"name": "vercel",
"version": "18.0.1-canary.20",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Now",
@@ -41,7 +41,8 @@
"all": true
},
"bin": {
"now": "./dist/index.js"
"vc": "./dist/index.js",
"vercel": "./dist/index.js"
},
"files": [
"dist",

View File

@@ -122,7 +122,10 @@ const printDeploymentStatus = async (
// but fallback to the first alias in the list
const mainAlias =
aliasList.find(
alias => !alias.endsWith('.now.sh') && !isWildcardAlias(alias)
alias =>
!alias.endsWith('.now.sh') &&
!alias.endsWith('.vercel.app') &&
!isWildcardAlias(alias)
) || aliasList[0];
isWildcard = isWildcardAlias(mainAlias);

View File

@@ -43,7 +43,7 @@ export default async function dev(
return link.exitCode;
}
if (link.status === 'not_linked' && !process.env.__NOW_SKIP_DEV_COMMAND) {
if (link.status === 'not_linked' && !process.env.__VERCEL_SKIP_DEV_CMD) {
output.error(
`Your codebase isnt linked to a project on Vercel. Run ${getCommandName()} to link it.`
);

View File

@@ -1,6 +1,6 @@
import path from 'path';
import chalk from 'chalk';
import { PackageJson } from '@now/build-utils';
import { PackageJson } from '@vercel/build-utils';
import getArgs from '../../util/get-args';
import getSubcommand from '../../util/get-subcommand';

View File

@@ -163,12 +163,12 @@ export default async function main(ctx) {
// Some people are using entire domains as app names, so
// we need to account for this here
if (app && toHost(app).endsWith('.now.sh')) {
const asHost = app ? toHost(app) : '';
if (asHost.endsWith('.now.sh') || asHost.endsWith('.vercel.app')) {
note(
`We suggest using \`${getPkgName()} inspect <deployment>\` for retrieving details about a single deployment`
);
const asHost = toHost(app);
const hostParts = asHost.split('-');
if (hostParts < 2) {

View File

@@ -14,8 +14,6 @@ import setupDomain from '../domains/setup-domain';
import stamp from '../output/stamp';
import waitForScale from '../scale/wait-verify-deployment-scale';
const NOW_SH_REGEX = /\.now\.sh$/;
export default async function assignAlias(
output: Output,
client: Client,
@@ -87,7 +85,11 @@ export default async function assignAlias(
// Check if the alias is a custom domain and if case we have a positive
// we have to configure the DNS records and certificate
if (alias.indexOf('.') !== -1 && !NOW_SH_REGEX.test(alias)) {
if (
alias.indexOf('.') !== -1 &&
!alias.endsWith('.now.sh') &&
!alias.endsWith('.vercel.app')
) {
// Now the domain shouldn't be available and it might or might not belong to the user
const result = await setupDomain(output, client, alias, contextName);
if (result instanceof Error) {

View File

@@ -5,8 +5,6 @@ import Client from '../client';
import createCertForAlias from '../certs/create-cert-for-alias';
import setupDomain from '../domains/setup-domain';
const NOW_SH_REGEX = /\.now\.sh$/;
type AliasRecord = {
uid: string;
alias: string;
@@ -23,7 +21,7 @@ export default async function upsertPathAlias(
) {
let externalDomain = false;
if (!NOW_SH_REGEX.test(alias)) {
if (!alias.endsWith('.now.sh') && !alias.endsWith('.vercel.app')) {
const domainInfo = await setupDomain(output, client, alias, contextName);
if (domainInfo instanceof Error) {
return domainInfo;

View File

@@ -5,7 +5,7 @@ import {
createDeployment,
DeploymentOptions,
NowClientOptions,
} from 'now-client';
} from '@vercel/client';
import { Output } from '../output';
// @ts-ignore
import Now from '../../util';
@@ -35,7 +35,7 @@ function printInspectUrl(
const projectName = q.join('-');
const inspectUrl = `https://vercel.com/${orgSlug}/${projectName}/${deploymentShortId}${
apex !== 'now.sh' ? `/${apex}` : ''
apex !== 'now.sh' && apex !== 'vercel.app' ? `/${apex}` : ''
}`;
output.print(

View File

@@ -6,7 +6,7 @@ import {
createLegacyDeployment,
DeploymentOptions,
NowClientOptions,
} from 'now-client';
} from '@vercel/client';
import { Output } from '../output';
// @ts-ignore
import Now from '../../util';

View File

@@ -8,7 +8,7 @@ import { extract } from 'tar-fs';
import { createHash } from 'crypto';
import { createGunzip } from 'zlib';
import { join } from 'path';
import { PackageJson } from '@now/build-utils';
import { PackageJson } from '@vercel/build-utils';
import XDGAppPaths from 'xdg-app-paths';
import {
createReadStream,
@@ -31,12 +31,17 @@ declare const __non_webpack_require__: typeof require;
const registryTypes = new Set(['version', 'tag', 'range']);
const localBuilders: { [key: string]: BuilderWithPackage } = {
'@now/static': {
const createStaticBuilder = (scope: string): BuilderWithPackage => {
return {
runInProcess: true,
builder: Object.freeze(staticBuilder),
package: Object.freeze({ name: '@now/static', version: '' }),
},
package: Object.freeze({ name: `@${scope}/static`, version: '' }),
};
};
const localBuilders: { [key: string]: BuilderWithPackage } = {
'@now/static': createStaticBuilder('now'),
'@vercel/static': createStaticBuilder('vercel'),
};
const distTag = getDistTag(pkg.version);
@@ -142,14 +147,14 @@ function getNpmVersion(use = ''): string {
return '';
}
export function getBuildUtils(packages: string[]): string {
export function getBuildUtils(packages: string[], org: string): string {
const version = packages
.map(getNpmVersion)
.some(ver => ver.includes('canary'))
? 'canary'
: 'latest';
return `@now/build-utils@${version}`;
return `@${org}/build-utils@${version}`;
}
function parseVersionSafe(rawSpec: string) {
@@ -230,7 +235,10 @@ export async function installBuilders(
const buildersPkgPath = join(builderDir, 'package.json');
const buildersPkgBefore = await readJSON(buildersPkgPath);
packages.push(getBuildUtils(packages));
packages.push(
getBuildUtils(packages, 'vercel'),
getBuildUtils(packages, 'now')
);
// Filter out any packages that come packaged with `now-cli`
const packagesToInstall = packages.filter(p =>
@@ -299,7 +307,10 @@ export async function updateBuilders(
const buildersPkgPath = join(builderDir, 'package.json');
const buildersPkgBefore = await readJSON(buildersPkgPath);
packages.push(getBuildUtils(packages));
packages.push(
getBuildUtils(packages, 'vercel'),
getBuildUtils(packages, 'now')
);
await retry(
() =>

View File

@@ -6,7 +6,14 @@ import { promisify } from 'util';
import { delimiter, dirname, join } from 'path';
import { fork, ChildProcess } from 'child_process';
import { createFunction } from '@zeit/fun';
import { Builder, File, Lambda, FileBlob, FileFsRef } from '@now/build-utils';
import {
Builder,
File,
Lambda,
FileBlob,
FileFsRef,
isOfficialRuntime,
} from '@vercel/build-utils';
import plural from 'pluralize';
import minimatch from 'minimatch';
import _treeKill from 'tree-kill';
@@ -30,8 +37,9 @@ import {
BuilderParams,
EnvConfigs,
} from './types';
import { normalizeRoutes } from '@now/routing-utils';
import { normalizeRoutes } from '@vercel/routing-utils';
import getUpdateCommand from '../get-update-command';
import { getVercelDirectory } from '../projects/link';
interface BuildMessage {
type: string;
@@ -68,6 +76,7 @@ async function createBuildProcess(
PATH,
...envConfigs.allEnv,
NOW_REGION: 'dev1',
VERCEL_REGION: 'dev1',
};
const buildProcess = fork(modulePath, [], {
@@ -115,7 +124,7 @@ export async function executeBuild(
const startTime = Date.now();
const showBuildTimestamp =
match.use !== '@now/static' && (!isInitialBuild || debug);
!isOfficialRuntime('static', match.use) && (!isInitialBuild || debug);
if (showBuildTimestamp) {
devServer.output.log(`Building ${match.use}:${entrypoint}`);
@@ -140,6 +149,9 @@ export async function executeBuild(
);
}
const vercelDir = getVercelDirectory(workPath);
const devCacheDir = join(vercelDir, 'cache');
const buildParams: BuilderParams = {
files,
entrypoint,
@@ -148,10 +160,11 @@ export async function executeBuild(
meta: {
isDev: true,
requestPath,
devCacheDir,
filesChanged,
filesRemoved,
// This env distiniction is only necessary to maintain
// backwards compatibility with the `@now/next` builder.
// backwards compatibility with the `@vercel/next` builder.
env: envConfigs.runEnv,
buildEnv: envConfigs.buildEnv,
},
@@ -367,6 +380,7 @@ export async function executeBuild(
...asset.environment,
...envConfigs.runEnv,
NOW_REGION: 'dev1',
VERCEL_REGION: 'dev1',
},
},
});
@@ -404,7 +418,7 @@ export async function getBuildMatches(
}
const noMatches: Builder[] = [];
const builds = nowConfig.builds || [{ src: '**', use: '@now/static' }];
const builds = nowConfig.builds || [{ src: '**', use: '@vercel/static' }];
for (const buildConfig of builds) {
let { src, use } = buildConfig;

View File

@@ -1,11 +1,11 @@
export function getBundledBuilders() {
return [
'@now/go',
'@now/next',
'@now/node',
'@now/ruby',
'@now/python',
'@now/static-build',
'@now/build-utils',
'@vercel/go',
'@vercel/next',
'@vercel/node',
'@vercel/ruby',
'@vercel/python',
'@vercel/static-build',
'@vercel/build-utils',
];
}

View File

@@ -5,7 +5,7 @@ import isURL from './is-url';
import DevServer from './server';
import { HttpHeadersConfig, RouteConfig, RouteResult } from './types';
import { isHandler, Route, HandleValue } from '@now/routing-utils';
import { isHandler, Route, HandleValue } from '@vercel/routing-utils';
export function resolveRouteParameters(
str: string,

View File

@@ -12,18 +12,18 @@ import serveHandler from 'serve-handler';
import { watch, FSWatcher } from 'chokidar';
import { parse as parseDotenv } from 'dotenv';
import { basename, dirname, extname, join } from 'path';
import {
getTransformedRoutes,
appendRoutesToPhase,
HandleValue,
} from '@now/routing-utils';
import directoryTemplate from 'serve-handler/src/directory';
import getPort from 'get-port';
import { ChildProcess } from 'child_process';
import isPortReachable from 'is-port-reachable';
import which from 'which';
import { getVercelIgnore } from 'now-client';
import { getVercelIgnore } from '@vercel/client';
import {
getTransformedRoutes,
appendRoutesToPhase,
HandleValue,
} from '@vercel/routing-utils';
import {
Builder,
FileFsRef,
@@ -32,7 +32,8 @@ import {
detectApiDirectory,
detectApiExtensions,
spawnCommand,
} from '@now/build-utils';
isOfficialRuntime,
} from '@vercel/build-utils';
import { once } from '../once';
import link from '../output/link';
@@ -92,11 +93,11 @@ interface FSEvent {
}
function sortBuilders(buildA: Builder, buildB: Builder) {
if (buildA && buildA.use && buildA.use.startsWith('@now/static-build')) {
if (buildA && buildA.use && isOfficialRuntime('static-build', buildA.use)) {
return 1;
}
if (buildB && buildB.use && buildB.use.startsWith('@now/static-build')) {
if (buildB && buildB.use && isOfficialRuntime('static-build', buildB.use)) {
return -1;
}
@@ -411,7 +412,7 @@ export default class DevServer {
.catch(cleanup);
}
// Sort build matches to make sure `@now/static-build` is always last
// Sort build matches to make sure `@vercel/static-build` is always last
this.buildMatches = new Map(
[...this.buildMatches.entries()].sort((matchA, matchB) => {
return sortBuilders(matchA[1] as Builder, matchB[1] as Builder);
@@ -434,7 +435,7 @@ export default class DevServer {
src,
builderWithPkg: { package: pkg },
} = buildMatch;
if (pkg.name === '@now/static') continue;
if (isOfficialRuntime('static', pkg.name)) continue;
if (pkg.name && updatedBuilders.includes(pkg.name)) {
shutdownBuilder(buildMatch, this.output);
this.buildMatches.delete(src);
@@ -596,7 +597,7 @@ export default class DevServer {
config.builds = config.builds.filter(filterFrontendBuilds);
}
// `@now/static-build` needs to be the last builder
// `@vercel/static-build` needs to be the last builder
// since it might catch all other requests
config.builds.sort(sortBuilders);
}
@@ -1695,6 +1696,7 @@ export default class DevServer {
...process.env,
...this.envConfigs.allEnv,
NOW_REGION: 'dev1',
VERCEL_REGION: 'dev1',
PORT: `${port}`,
};
@@ -2036,7 +2038,7 @@ async function checkForPort(
function filterFrontendBuilds(build: Builder) {
return (
!build.use.startsWith('@now/static-build') &&
!build.use.startsWith('@now/next')
!isOfficialRuntime('static-build', build.use) &&
!isOfficialRuntime('next', build.use)
);
}

View File

@@ -8,9 +8,10 @@ import {
Lambda,
PackageJson,
Config,
} from '@now/build-utils';
import { NowConfig } from 'now-client';
import { HandleValue, Route } from '@now/routing-utils';
Meta,
} from '@vercel/build-utils';
import { NowConfig } from '@vercel/client';
import { HandleValue, Route } from '@vercel/routing-utils';
import { Output } from '../output';
export { NowConfig };
@@ -82,14 +83,7 @@ export interface BuilderParamsBase {
files: BuilderInputs;
entrypoint: string;
config: Config;
meta?: {
isDev?: boolean;
requestPath?: string | null;
filesChanged?: string[];
filesRemoved?: string[];
env?: EnvConfig;
buildEnv?: EnvConfig;
};
meta?: Meta;
}
export interface BuilderParams extends BuilderParamsBase {

View File

@@ -6,9 +6,9 @@ import {
redirectsSchema,
rewritesSchema,
trailingSlashSchema,
} from '@now/routing-utils';
} from '@vercel/routing-utils';
import { NowConfig } from './types';
import { functionsSchema, buildsSchema } from '@now/build-utils';
import { functionsSchema, buildsSchema } from '@vercel/build-utils';
const ajv = new Ajv();

View File

@@ -4,6 +4,7 @@ import { NowError } from './now-error';
import param from './output/param';
import cmd from './output/cmd';
import code from './output/code';
import { getPkgName } from './pkg-name';
/**
* This error is thrown when there is an API error with a payload. The error
@@ -52,7 +53,7 @@ export class TeamDeleted extends NowError<'TEAM_DELETED', {}> {
super({
code: 'TEAM_DELETED',
message: `Your team was deleted. You can switch to a different one using ${param(
'now switch'
`${getPkgName()} switch`
)}.`,
meta: {},
});
@@ -143,7 +144,7 @@ export class SourceNotFound extends NowError<'SOURCE_NOT_FOUND', {}> {
code: 'SOURCE_NOT_FOUND',
meta: {},
message: `Not able to purchase. Please add a payment method using ${cmd(
'now billing add'
`${getPkgName()} billing add`
)}.`,
});
}

View File

@@ -3,7 +3,7 @@ import ignore from 'ignore';
import dockerignore from '@zeit/dockerignore';
import _glob, { IOptions } from 'glob';
import fs from 'fs-extra';
import { getVercelIgnore } from 'now-client';
import { getVercelIgnore } from '@vercel/client';
import IGNORED from './ignored';
import uniqueStrings from './unique-strings';
import getLocalConfigPath from './config/local-path';

View File

@@ -1,4 +1,4 @@
import { Framework } from '@now/frameworks';
import { Framework } from '@vercel/frameworks';
import Client from './client';
export async function getFrameworks(client: Client) {

View File

@@ -2,7 +2,7 @@ import inquirer from 'inquirer';
import confirm from './confirm';
import chalk from 'chalk';
import { Output } from '../output';
import { Framework } from '@now/frameworks';
import { Framework } from '@vercel/frameworks';
import { isSettingValue } from '../is-setting-value';
export interface ProjectSettings {

View File

@@ -1,4 +1,4 @@
import { SettingValue } from '@now/frameworks';
import { SettingValue } from '@vercel/frameworks';
export function isSettingValue(setting: any): setting is SettingValue {
return setting && typeof setting.value === 'string';

View File

@@ -1,6 +1,7 @@
import crypto from 'crypto';
import ua from 'universal-analytics';
import { platform, release, userInfo } from 'os';
import { getPlatformEnv } from '@vercel/build-utils';
import userAgent from './ua-browser';
import { GA_TRACKING_ID } from './constants';
@@ -10,7 +11,7 @@ const config: any = configFiles.getConfigFilePath();
export const shouldCollectMetrics =
(config.collectMetrics === undefined || config.collectMetrics === true) &&
process.env.NOW_CLI_COLLECT_METRICS !== '0' &&
getPlatformEnv('CLI_COLLECT_METRICS') !== '0' &&
GA_TRACKING_ID;
export const metrics = (): ua.Visitor => {

View File

@@ -1,6 +1,6 @@
import { join } from 'path';
import { exists } from 'fs-extra';
import { PackageJson } from '@now/build-utils';
import { PackageJson } from '@vercel/build-utils';
import Client from './client';
import { Config } from '../types';

View File

@@ -14,6 +14,7 @@ import chalk from 'chalk';
import { prependEmoji, emoji } from '../emoji';
import AJV from 'ajv';
import { isDirectory } from '../config/global-path';
import { getPlatformEnv } from '@vercel/build-utils';
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
@@ -38,11 +39,17 @@ const linkSchema = {
},
};
async function getLink(path?: string): Promise<ProjectLink | null> {
const cwd = path || process.cwd();
/**
* Returns the `<cwd>/.vercel` directory for the current project
* with a fallback to <cwd>/.now` if it exists.
*/
export function getVercelDirectory(cwd: string = process.cwd()) {
const possibleDirs = [join(cwd, VERCEL_DIR), join(cwd, VERCEL_DIR_FALLBACK)];
return possibleDirs.find(d => isDirectory(d)) || possibleDirs[0];
}
const dir = possibleDirs.find(d => isDirectory(d)) || possibleDirs[0];
async function getLink(path?: string): Promise<ProjectLink | null> {
const dir = getVercelDirectory(path);
return getLinkFromDir(dir);
}
@@ -98,7 +105,8 @@ export async function getLinkedProject(
| { status: 'not_linked'; org: null; project: null }
| { status: 'error'; exitCode: number }
> {
const { VERCEL_ORG_ID, VERCEL_PROJECT_ID } = getFlags();
const VERCEL_ORG_ID = getPlatformEnv('ORG_ID');
const VERCEL_PROJECT_ID = getPlatformEnv('PROJECT_ID');
const shouldUseEnv = Boolean(VERCEL_ORG_ID && VERCEL_PROJECT_ID);
if ((VERCEL_ORG_ID || VERCEL_PROJECT_ID) && !shouldUseEnv) {
@@ -157,20 +165,6 @@ export async function getLinkedProject(
return { status: 'linked', org, project };
}
export function getFlags() {
let {
VERCEL_ORG_ID,
VERCEL_PROJECT_ID,
NOW_ORG_ID,
NOW_PROJECT_ID,
} = process.env;
// Fallback to old NOW env vars if available
VERCEL_ORG_ID = VERCEL_ORG_ID || NOW_ORG_ID;
VERCEL_PROJECT_ID = VERCEL_PROJECT_ID || NOW_PROJECT_ID;
return { VERCEL_ORG_ID, VERCEL_PROJECT_ID };
}
export async function linkFolderToProject(
output: Output,
path: string,
@@ -178,7 +172,8 @@ export async function linkFolderToProject(
projectName: string,
orgSlug: string
) {
const { VERCEL_ORG_ID, VERCEL_PROJECT_ID } = getFlags();
const VERCEL_ORG_ID = getPlatformEnv('ORG_ID');
const VERCEL_PROJECT_ID = getPlatformEnv('PROJECT_ID');
// if defined, skip linking
if (VERCEL_ORG_ID || VERCEL_PROJECT_ID) {

View File

@@ -2,7 +2,7 @@ import path from 'path';
import { CantParseJSONFile } from './errors-ts';
import readJSONFile from './read-json-file';
import { Config } from '../types';
import { PackageJson } from '@now/build-utils';
import { PackageJson } from '@vercel/build-utils';
interface CustomPackage extends PackageJson {
now?: Config;

View File

@@ -4,21 +4,21 @@ import { filterPackage } from '../src/util/dev/builder-cache';
test('[dev-builder] filter install "latest", cached canary', async t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1-canary.0',
'@vercel/build-utils': '0.0.1-canary.0',
},
};
const result = filterPackage('@now/build-utils', 'canary', buildersPkg);
const result = filterPackage('@vercel/build-utils', 'canary', buildersPkg);
t.is(result, true);
});
test('[dev-builder] filter install "canary", cached stable', async t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1',
'@vercel/build-utils': '0.0.1',
},
};
const result = filterPackage(
'@now/build-utils@canary',
'@vercel/build-utils@canary',
'latest',
buildersPkg
);
@@ -28,21 +28,21 @@ test('[dev-builder] filter install "canary", cached stable', async t => {
test('[dev-builder] filter install "latest", cached stable', async t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1',
'@vercel/build-utils': '0.0.1',
},
};
const result = filterPackage('@now/build-utils', 'latest', buildersPkg);
const result = filterPackage('@vercel/build-utils', 'latest', buildersPkg);
t.is(result, false);
});
test('[dev-builder] filter install "canary", cached canary', async t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1-canary.0',
'@vercel/build-utils': '0.0.1-canary.0',
},
};
const result = filterPackage(
'@now/build-utils@canary',
'@vercel/build-utils@canary',
'canary',
buildersPkg
);
@@ -52,7 +52,7 @@ test('[dev-builder] filter install "canary", cached canary', async t => {
test('[dev-builder] filter install URL, cached stable', async t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1',
'@vercel/build-utils': '0.0.1',
},
};
const result = filterPackage('https://tarball.now.sh', 'latest', buildersPkg);
@@ -62,7 +62,7 @@ test('[dev-builder] filter install URL, cached stable', async t => {
test('[dev-builder] filter install URL, cached canary', async t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1-canary.0',
'@vercel/build-utils': '0.0.1-canary.0',
},
};
const result = filterPackage('https://tarball.now.sh', 'canary', buildersPkg);
@@ -72,20 +72,20 @@ test('[dev-builder] filter install URL, cached canary', async t => {
test('[dev-builder] filter install "latest", cached URL - stable', async t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': 'https://tarball.now.sh',
'@vercel/build-utils': 'https://tarball.now.sh',
},
};
const result = filterPackage('@now/build-utils', 'latest', buildersPkg);
const result = filterPackage('@vercel/build-utils', 'latest', buildersPkg);
t.is(result, true);
});
test('[dev-builder] filter install "latest", cached URL - canary', async t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': 'https://tarball.now.sh',
'@vercel/build-utils': 'https://tarball.now.sh',
},
};
const result = filterPackage('@now/build-utils', 'canary', buildersPkg);
const result = filterPackage('@vercel/build-utils', 'canary', buildersPkg);
t.is(result, true);
});

View File

@@ -192,30 +192,60 @@ test('[DevServer] Does not install builders if there are no builds', async t =>
test('[DevServer] Installs canary build-utils if one more more builders is canary', t => {
t.is(
getBuildUtils(['@now/static', '@now/node@canary']),
'@now/build-utils@canary'
getBuildUtils(['@vercel/static', '@vercel/node@canary'], 'vercel'),
'@vercel/build-utils@canary'
);
t.is(
getBuildUtils(['@now/static', '@now/node@0.7.4-canary.0']),
'@now/build-utils@canary'
getBuildUtils(['@vercel/static', '@vercel/node@0.7.4-canary.0'], 'vercel'),
'@vercel/build-utils@canary'
);
t.is(
getBuildUtils(['@now/static', '@now/node@0.8.0']),
'@now/build-utils@latest'
getBuildUtils(['@vercel/static', '@vercel/node@0.8.0'], 'vercel'),
'@vercel/build-utils@latest'
);
t.is(getBuildUtils(['@now/static', '@now/node']), '@now/build-utils@latest');
t.is(getBuildUtils(['@now/static']), '@now/build-utils@latest');
t.is(getBuildUtils(['@now/md@canary']), '@now/build-utils@canary');
t.is(getBuildUtils(['custom-builder']), '@now/build-utils@latest');
t.is(getBuildUtils(['custom-builder@canary']), '@now/build-utils@canary');
t.is(getBuildUtils(['canary-bird']), '@now/build-utils@latest');
t.is(getBuildUtils(['canary-bird@4.0.0']), '@now/build-utils@latest');
t.is(getBuildUtils(['canary-bird@canary']), '@now/build-utils@canary');
t.is(getBuildUtils(['@canary/bird']), '@now/build-utils@latest');
t.is(getBuildUtils(['@canary/bird@0.1.0']), '@now/build-utils@latest');
t.is(getBuildUtils(['@canary/bird@canary']), '@now/build-utils@canary');
t.is(getBuildUtils(['https://example.com']), '@now/build-utils@latest');
t.is(getBuildUtils(['']), '@now/build-utils@latest');
t.is(
getBuildUtils(['@vercel/static', '@vercel/node'], 'vercel'),
'@vercel/build-utils@latest'
);
t.is(
getBuildUtils(['@vercel/static'], 'vercel'),
'@vercel/build-utils@latest'
);
t.is(
getBuildUtils(['@vercel/md@canary'], 'vercel'),
'@vercel/build-utils@canary'
);
t.is(
getBuildUtils(['custom-builder'], 'vercel'),
'@vercel/build-utils@latest'
);
t.is(
getBuildUtils(['custom-builder@canary'], 'vercel'),
'@vercel/build-utils@canary'
);
t.is(getBuildUtils(['canary-bird'], 'vercel'), '@vercel/build-utils@latest');
t.is(
getBuildUtils(['canary-bird@4.0.0'], 'vercel'),
'@vercel/build-utils@latest'
);
t.is(
getBuildUtils(['canary-bird@canary'], 'vercel'),
'@vercel/build-utils@canary'
);
t.is(getBuildUtils(['@canary/bird'], 'vercel'), '@vercel/build-utils@latest');
t.is(
getBuildUtils(['@canary/bird@0.1.0'], 'vercel'),
'@vercel/build-utils@latest'
);
t.is(
getBuildUtils(['@canary/bird@canary'], 'vercel'),
'@vercel/build-utils@canary'
);
t.is(
getBuildUtils(['https://example.com'], 'vercel'),
'@vercel/build-utils@latest'
);
t.is(getBuildUtils([''], 'vercel'), '@vercel/build-utils@latest');
});
test(
@@ -255,7 +285,7 @@ test(
);
test(
'[DevServer] Test `@now/static` routing',
'[DevServer] Test `@vercel/static` routing',
testFixture('now-dev-static-routes', async (t, server) => {
{
const res = await fetch(`${server.address}/`);
@@ -266,7 +296,7 @@ test(
);
test(
'[DevServer] Test `@now/static-build` routing',
'[DevServer] Test `@vercel/static-build` routing',
testFixture('now-dev-static-build-routing', async (t, server) => {
{
const res = await fetch(`${server.address}/api/date`);

View File

@@ -104,7 +104,7 @@ async function exec(directory, args = []) {
return execa(binaryPath, ['dev', directory, ...args], {
reject: false,
shell: true,
env: { __NOW_SKIP_DEV_COMMAND: 1 },
env: { __VERCEL_SKIP_DEV_CMD: 1 },
});
}
@@ -180,7 +180,7 @@ async function testFixture(directory, opts = {}, args = []) {
shell: true,
stdio: 'pipe',
...opts,
env: { ...opts.env, __NOW_SKIP_DEV_COMMAND: 1 },
env: { ...opts.env, __VERCEL_SKIP_DEV_CMD: 1 },
}
);
@@ -287,7 +287,7 @@ function testFixtureStdio(
let printedOutput = false;
const env = skipDeploy
? { ...process.env, __NOW_SKIP_DEV_COMMAND: 1 }
? { ...process.env, __VERCEL_SKIP_DEV_CMD: 1 }
: process.env;
dev = execa(
binaryPath,

View File

@@ -1,5 +1,12 @@
module.exports = stdout =>
stdout
.split('\n')
.filter(line => line.includes('.now.sh'))
.map(line => line.split(' ').filter(part => part.includes('.now.sh'))[0]);
.filter(line => line.includes('.now.sh') || line.includes('.vercel.app'))
.map(
line =>
line
.split(' ')
.filter(
part => part.includes('.now.sh') || part.includes('.vercel.app')
)[0]
);

View File

@@ -172,7 +172,8 @@ fs.writeFileSync(
'index.js',
fs
.readFileSync('index.js', 'utf8')
.replace('BUILD_ENV_DEBUG', process.env.NOW_BUILDER_DEBUG ? 'on' : 'off'),
.replace('BUILD_ENV_DEBUG', process.env.NOW_BUILDER_DEBUG ? 'on' : 'off')
.replace('BUILD_ENV_DEBUG', process.env.VERCEL_BUILDER_DEBUG ? 'on' : 'off'),
);
`,
'index.js': `

View File

@@ -18,7 +18,7 @@ import prepareFixtures from './helpers/prepare';
const binaryPath = path.resolve(__dirname, `../scripts/start.js`);
const fixture = name => path.join(__dirname, 'fixtures', 'integration', name);
const deployHelpMessage = `${logo} now [options] <command | path>`;
const deployHelpMessage = `${logo} vercel [options] <command | path>`;
const session = Math.random()
.toString(36)
.split('.')[1];

View File

@@ -31,7 +31,7 @@ function execa(file, args, options) {
const binaryPath = path.resolve(__dirname, `../scripts/start.js`);
const fixture = name => path.join(__dirname, 'fixtures', 'integration', name);
const deployHelpMessage = `${logo} now [options] <command | path>`;
const deployHelpMessage = `${logo} vercel [options] <command | path>`;
let session = 'temp-session';
const isCanary = pkg.version.includes('canary');
@@ -850,7 +850,7 @@ test('try to purchase a domain', async t => {
t.is(exitCode, 1);
t.true(
stderr.includes(
`Error! Could not purchase domain. Please add a payment method using \`now billing add\`.`
`Error! Could not purchase domain. Please add a payment method using \`vercel billing add\`.`
)
);
});
@@ -1167,7 +1167,9 @@ test('ensure username in list is right', async t => {
// Ensure the exit code is right
t.is(exitCode, 0);
const line = stdout.split('\n').find(line => line.includes('.now.sh'));
const line = stdout
.split('\n')
.find(line => line.includes('.now.sh') || line.includes('.vercel.app'));
const columns = line.split(/\s+/);
// Ensure username column have username
@@ -1801,7 +1803,7 @@ test('try to initialize misspelled example (noce) in non-tty', async t => {
tmpDir = tmp.dirSync({ unsafeCleanup: true });
const cwd = tmpDir.name;
const goal =
'Error! No example found for noce, run `now init` to see the list of available examples.';
'Error! No example found for noce, run `vercel init` to see the list of available examples.';
const { stdout, stderr, exitCode } = await execute(['init', 'noce'], { cwd });
@@ -1817,7 +1819,7 @@ test('try to initialize example "example-404"', async t => {
tmpDir = tmp.dirSync({ unsafeCleanup: true });
const cwd = tmpDir.name;
const goal =
'Error! No example found for example-404, run `now init` to see the list of available examples.';
'Error! No example found for example-404, run `vercel init` to see the list of available examples.';
const { stdout, stderr, exitCode } = await execute(['init', 'example-404'], {
cwd,

View File

@@ -1,6 +1,6 @@
{
"name": "now-client",
"version": "7.1.1-canary.3",
"name": "@vercel/client",
"version": "7.1.1-canary.5",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"homepage": "https://vercel.com",
@@ -15,7 +15,7 @@
},
"scripts": {
"build": "tsc",
"test-integration-once": "jest --verbose --runInBand"
"test-integration-once": "jest --verbose --runInBand --bail"
},
"devDependencies": {
"@types/async-retry": "1.4.1",

View File

@@ -1,5 +1,10 @@
import { Builder, BuilderFunctions } from '@now/build-utils';
import { NowHeader, Route, NowRedirect, NowRewrite } from '@now/routing-utils';
import { Builder, BuilderFunctions } from '@vercel/build-utils';
import {
NowHeader,
Route,
NowRedirect,
NowRewrite,
} from '@vercel/routing-utils';
export { DeploymentEventType } from './utils';

View File

@@ -237,9 +237,7 @@ export const prepareFiles = (
};
export function createDebug(debug?: boolean) {
const isDebug = debug || process.env.NOW_CLIENT_DEBUG;
if (isDebug) {
if (debug) {
return (...logs: string[]) => {
process.stderr.write(
[`[now-client-debug] ${new Date().toISOString()}`, ...logs].join(' ') +

View File

@@ -1,4 +1,4 @@
ncc build index.ts -e @now/build-utils -o dist
ncc build install.ts -e @now/build-utils -o dist/install
ncc build index.ts -e @vercel/build-utils -o dist
ncc build install.ts -e @vercel/build-utils -o dist/install
mv dist/install/index.js dist/install.js
rm -rf dist/install

View File

@@ -4,7 +4,7 @@ import fetch from 'node-fetch';
import { mkdirp, pathExists } from 'fs-extra';
import { dirname, join } from 'path';
import { homedir } from 'os';
import { debug } from '@now/build-utils';
import { debug } from '@vercel/build-utils';
import stringArgv from 'string-argv';
const archMap = new Map([['x64', 'amd64'], ['x86', '386']]);

View File

@@ -9,11 +9,11 @@ import {
createLambda,
getWriteableDirectory,
BuildOptions,
Meta,
shouldServe,
Files,
debug,
Meta,
} from '@now/build-utils';
} from '@vercel/build-utils';
import { createGo, getAnalyzedEntrypoint, OUT_EXTENSION } from './go-helpers';
const handlerFileName = `handler${OUT_EXTENSION}`;
@@ -134,13 +134,9 @@ Learn more: https://vercel.com/docs/runtimes#official-runtimes/go
if (meta.isDev) {
// Create cache so Go rebuilds fast with `now dev`
goPath = join(
workPath,
'.now',
'cache',
'now-go',
basename(entrypoint, '.go')
);
// Old versions of the CLI don't assign this property
const { devCacheDir = join(workPath, '.now', 'cache') } = meta;
goPath = join(devCacheDir, 'now-go', basename(entrypoint, '.go'));
const destNow = join(goPath, 'src', 'lambda');
await download(downloadedFiles, destNow);
downloadedFiles = await glob('**', destNow);

View File

@@ -1,6 +1,6 @@
{
"name": "@now/go",
"version": "1.0.8-canary.0",
"name": "@vercel/go",
"version": "1.0.8-canary.2",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -11,7 +11,7 @@
},
"scripts": {
"build": "./build.sh",
"test-integration-once": "jest --env node --verbose --runInBand",
"test-integration-once": "jest --env node --verbose --runInBand --bail",
"prepublish": "./build.sh",
"now-postinstall": "node dist/install.js"
},

View File

@@ -1,8 +1,8 @@
{
"version": 2,
"builds": [
{ "src": "index.go", "use": "@now/go" },
{ "src": "subdirectory/index.go", "use": "@now/go" }
{ "src": "index.go", "use": "@vercel/go" },
{ "src": "subdirectory/index.go", "use": "@vercel/go" }
],
"probes": [
{ "path": "/", "mustContain": "cow:RANDOMNESS_PLACEHOLDER" },

View File

@@ -3,12 +3,12 @@
"builds": [
{
"src": "/api/go-one/one.go",
"use": "@now/go",
"use": "@vercel/go",
"config": { "parallel": true }
},
{
"src": "/api/go-two/two.go",
"use": "@now/go",
"use": "@vercel/go",
"config": { "parallel": true }
}
],

View File

@@ -3,7 +3,7 @@
"builds": [
{
"src": "env/index.go",
"use": "@now/go"
"use": "@vercel/go"
}
],
"env": {

View File

@@ -1,4 +1,4 @@
{
"version": 2,
"builds": [{ "src": "index.go", "use": "@now/go" }]
"builds": [{ "src": "index.go", "use": "@vercel/go" }]
}

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "*.go", "use": "@now/go" }],
"builds": [{ "src": "*.go", "use": "@vercel/go" }],
"env": {
"RANDOMNESS_ENV_VAR": "RANDOMNESS_PLACEHOLDER"
}

View File

@@ -3,14 +3,14 @@
"builds": [
{
"src": "index.go",
"use": "@now/go",
"use": "@vercel/go",
"config": {
"includeFiles": ["templates/**"]
}
},
{
"src": "another.go",
"use": "@now/go",
"use": "@vercel/go",
"config": {
"includeFiles": "templates/**"
}

View File

@@ -1,5 +1,5 @@
{
"version": 2,
"builds": [{ "src": "index.go", "use": "@now/go" }],
"builds": [{ "src": "index.go", "use": "@vercel/go" }],
"probes": [{ "path": "/", "mustContain": "RANDOMNESS_PLACEHOLDER" }]
}

View File

@@ -1,5 +1,5 @@
{
"version": 2,
"builds": [{ "src": "index.go", "use": "@now/go" }],
"builds": [{ "src": "index.go", "use": "@vercel/go" }],
"probes": [{ "path": "/", "mustContain": "RANDOMNESS_PLACEHOLDER" }]
}

View File

@@ -1,5 +1,5 @@
{
"version": 2,
"builds": [{ "src": "api/*.go", "use": "@now/go" }],
"builds": [{ "src": "api/*.go", "use": "@vercel/go" }],
"probes": [{ "path": "/api", "mustContain": "RANDOMNESS_PLACEHOLDER" }]
}

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "**/*.go", "use": "@now/go" }],
"builds": [{ "src": "**/*.go", "use": "@vercel/go" }],
"probes": [
{ "path": "/sub-1", "mustContain": "RANDOMNESS_PLACEHOLDER" },
{ "path": "/sub-2", "mustContain": "RANDOMNESS_PLACEHOLDER" }

View File

@@ -1,5 +1,5 @@
{
"version": 2,
"builds": [{ "src": "api/nested/*.go", "use": "@now/go" }],
"builds": [{ "src": "api/nested/*.go", "use": "@vercel/go" }],
"probes": [{ "path": "/api/nested", "mustContain": "RANDOMNESS_PLACEHOLDER" }]
}

View File

@@ -1,5 +1,5 @@
{
"version": 2,
"builds": [{ "src": "api/**/*.go", "use": "@now/go" }],
"builds": [{ "src": "api/**/*.go", "use": "@vercel/go" }],
"probes": [{ "path": "/api", "mustContain": "RANDOMNESS_PLACEHOLDER" }]
}

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "*.go", "use": "@now/go" }],
"builds": [{ "src": "*.go", "use": "@vercel/go" }],
"probes": [
{ "path": "/", "mustContain": "RANDOMNESS_PLACEHOLDER" },
{ "path": "/multiple.go", "mustContain": "three:RANDOMNESS_PLACEHOLDER" }

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "index.go", "use": "@now/go" }],
"builds": [{ "src": "index.go", "use": "@vercel/go" }],
"build": { "env": { "GO_BUILD_FLAGS": "-tags first -ldflags '-s -w'" } },
"probes": [{ "path": "/", "mustContain": "first:RANDOMNESS_PLACEHOLDER" }]
}

View File

@@ -3,7 +3,7 @@
"builds": [
{
"src": "api/v1/**/*.go",
"use": "@now/go",
"use": "@vercel/go",
"config": { "zeroConfig": true }
}
],

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "api/**/*.go", "use": "@now/go" }],
"builds": [{ "src": "api/**/*.go", "use": "@vercel/go" }],
"probes": [
{
"path": "/api/[hello].go",

View File

@@ -7,10 +7,10 @@ cp -v "$bridge_defs" src/now__bridge.ts
tsc
ncc build src/dev-server.ts -e @now/build-utils -o dist/dev
ncc build src/dev-server.ts -e @vercel/build-utils -o dist/dev
mv dist/dev/index.js dist/dev-server.js
rm -rf dist/dev
ncc build src/index.ts -e @now/build-utils -o dist/main
ncc build src/index.ts -e @vercel/build-utils -o dist/main
mv dist/main/index.js dist/index.js
rm -rf dist/main

View File

@@ -1,12 +1,12 @@
{
"name": "@now/next",
"version": "2.5.5-canary.5",
"name": "@vercel/next",
"version": "2.5.5-canary.7",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
"scripts": {
"build": "./build.sh",
"test-integration-once": "jest --env node --verbose --runInBand",
"test-integration-once": "jest --env node --verbose --runInBand --bail",
"prepublishOnly": "./build.sh"
},
"repository": {

View File

@@ -20,13 +20,13 @@ import {
execCommand,
getNodeBinPath,
NowBuildError,
} from '@now/build-utils';
import { Route, Handler } from '@now/routing-utils';
} from '@vercel/build-utils';
import { Route, Handler } from '@vercel/routing-utils';
import {
convertHeaders,
convertRedirects,
convertRewrites,
} from '@now/routing-utils/dist/superstatic';
} from '@vercel/routing-utils/dist/superstatic';
import nodeFileTrace, { NodeFileTraceReasons } from '@zeit/node-file-trace';
import { ChildProcess, fork } from 'child_process';
import {
@@ -165,7 +165,7 @@ function isLegacyNext(nextVersion: string) {
return true;
}
const name = '[@now/next]';
const name = '[@vercel/next]';
const urls: stringMap = {};
function startDevServer(entryPath: string, runtimeEnv: EnvConfig) {
@@ -215,7 +215,7 @@ export const build = async ({
if (!nextVersion) {
throw new NowBuildError({
code: 'NOW_NEXT_NO_VERSION',
code: 'NEXT_NO_VERSION',
message:
'No Next.js version could be detected in "package.json". Make sure `"next"` is installed in "dependencies" or "devDependencies"',
});
@@ -283,7 +283,7 @@ export const build = async ({
}
console.warn(
"WARNING: your application is being deployed in @now/next's legacy mode. http://err.sh/zeit/now/now-next-legacy-mode"
"WARNING: your application is being deployed in @vercel/next's legacy mode. http://err.sh/zeit/now/now-next-legacy-mode"
);
debug('Normalizing package.json');
@@ -443,16 +443,16 @@ export const build = async ({
if (!nextBasePath.startsWith('/')) {
throw new NowBuildError({
code: 'NOW_NEXT_BASEPATH_STARTING_SLASH',
code: 'NEXT_BASEPATH_STARTING_SLASH',
message:
'basePath must start with `/`. Please upgrade your `@now/next` builder and try again. Contact support if this continues to happen.',
'basePath must start with `/`. Please upgrade your `@vercel/next` builder and try again. Contact support if this continues to happen.',
});
}
if (nextBasePath.endsWith('/')) {
throw new NowBuildError({
code: 'NOW_NEXT_BASEPATH_TRAILING_SLASH',
code: 'NEXT_BASEPATH_TRAILING_SLASH',
message:
'basePath must not end with `/`. Please upgrade your `@now/next` builder and try again. Contact support if this continues to happen.',
'basePath must not end with `/`. Please upgrade your `@vercel/next` builder and try again. Contact support if this continues to happen.',
});
}
@@ -467,10 +467,10 @@ export const build = async ({
default: {
// update MIN_ROUTES_MANIFEST_VERSION in ./utils.ts
throw new NowBuildError({
code: 'NOW_NEXT_VERSION_OUTDATED',
code: 'NEXT_VERSION_OUTDATED',
message:
'This version of `@now/next` does not support the version of Next.js you are trying to deploy.\n' +
'Please upgrade your `@now/next` builder and try again. Contact support if this continues to happen.',
'This version of `@vercel/next` does not support the version of Next.js you are trying to deploy.\n' +
'Please upgrade your `@vercel/next` builder and try again. Contact support if this continues to happen.',
});
}
}
@@ -485,7 +485,7 @@ export const build = async ({
const resultingExport = await getExportStatus(entryPath);
if (!resultingExport) {
throw new NowBuildError({
code: 'NOW_NEXT_EXPORT_FAILED',
code: 'NEXT_EXPORT_FAILED',
message:
'Exporting Next.js app failed. Please check your build logs and contact us if this continues.',
});
@@ -493,7 +493,7 @@ export const build = async ({
if (resultingExport.success !== true) {
throw new NowBuildError({
code: 'NOW_NEXT_EXPORT_FAILED',
code: 'NEXT_EXPORT_FAILED',
message: 'Export of Next.js app failed. Please check your build logs.',
});
}
@@ -639,7 +639,7 @@ export const build = async ({
'BUILD_ID not found in ".next". The "package.json" "build" script did not run "next build"'
);
throw new NowBuildError({
code: 'NOW_NEXT_NO_BUILD_ID',
code: 'NEXT_NO_BUILD_ID',
message: 'Missing BUILD_ID',
});
}
@@ -786,7 +786,7 @@ export const build = async ({
}
throw new NowBuildError({
code: 'NOW_NEXT_NO_SERVERLESS_PAGES',
code: 'NEXT_NO_SERVERLESS_PAGES',
message: 'No serverless pages were built',
link: 'https://err.sh/zeit/now/now-next-no-serverless-pages-built',
});
@@ -997,7 +997,7 @@ export const build = async ({
) => {
if (isBlocking && isFallback) {
throw new NowBuildError({
code: 'NOW_NEXT_ISBLOCKING_ISFALLBACK',
code: 'NEXT_ISBLOCKING_ISFALLBACK',
message: 'invariant: isBlocking and isFallback cannot both be true',
});
}
@@ -1040,7 +1040,7 @@ export const build = async ({
if (initialRevalidate === false) {
// Lazy routes cannot be "snapshotted" in time.
throw new NowBuildError({
code: 'NOW_NEXT_ISLAZY_INITIALREVALIDATE',
code: 'NEXT_ISLAZY_INITIALREVALIDATE',
message: 'invariant isLazy: initialRevalidate !== false',
});
}
@@ -1064,7 +1064,7 @@ export const build = async ({
const lambda = lambdas[outputSrcPathPage];
if (lambda == null) {
throw new NowBuildError({
code: 'NOW_NEXT_MISSING_LAMBDA',
code: 'NEXT_MISSING_LAMBDA',
message: `Unable to find lambda for route: ${routeFileNoExt}`,
});
}
@@ -1072,7 +1072,7 @@ export const build = async ({
if (initialRevalidate === false) {
if (htmlFsRef == null || jsonFsRef == null) {
throw new NowBuildError({
code: 'NOW_NEXT_HTMLFSREF_JSONFSREF',
code: 'NEXT_HTMLFSREF_JSONFSREF',
message: 'invariant: htmlFsRef != null && jsonFsRef != null',
});
}
@@ -1189,7 +1189,7 @@ export const build = async ({
);
if (typeof lambdas[routeFileNoExt] === undefined) {
throw new NowBuildError({
code: 'NOW_NEXT__UNKNOWN_ROUTE_KEY',
code: 'NEXT__UNKNOWN_ROUTE_KEY',
message: `invariant: unknown lambda ${routeKey} (lookup: ${routeFileNoExt}) | please report this immediately`,
});
}
@@ -1328,7 +1328,7 @@ export const prepareCache = async ({
const nextVersion = getNextVersion(pkg);
if (!nextVersion)
throw new NowBuildError({
code: 'NOW_NEXT_VERSION_PARSE_FAILED',
code: 'NEXT_VERSION_PARSE_FAILED',
message: 'Could not parse Next.js version',
});
const isLegacy = isLegacyNext(nextVersion);

View File

@@ -4,8 +4,8 @@ import url from 'url';
import { Bridge } from './now__bridge';
if (!process.env.NODE_ENV) {
process.env.NODE_ENV =
process.env.NOW_REGION === 'dev1' ? 'development' : 'production';
const region = process.env.VERCEL_REGION || process.env.NOW_REGION;
process.env.NODE_ENV = region === 'dev1' ? 'development' : 'production';
}
const app = next({});

View File

@@ -1,6 +1,6 @@
if (!process.env.NODE_ENV) {
process.env.NODE_ENV =
process.env.NOW_REGION === 'dev1' ? 'development' : 'production';
const region = process.env.VERCEL_REGION || process.env.NOW_REGION;
process.env.NODE_ENV = region === 'dev1' ? 'development' : 'production';
}
import { Server } from 'http';

View File

@@ -13,8 +13,8 @@ import {
Lambda,
NowBuildError,
isSymbolicLink,
} from '@now/build-utils';
import { Route, Source, NowHeader, NowRewrite } from '@now/routing-utils';
} from '@vercel/build-utils';
import { Route, Source, NowHeader, NowRewrite } from '@vercel/routing-utils';
type stringMap = { [key: string]: string };
@@ -41,8 +41,8 @@ function validateEntrypoint(entrypoint: string) {
) {
throw new NowBuildError({
message:
'Specified "src" for "@now/next" has to be "package.json" or "next.config.js"',
code: 'NOW_NEXT_INCORRECT_SRC',
'Specified "src" for "@vercel/next" has to be "package.json" or "next.config.js"',
code: 'NEXT_INCORRECT_SRC',
});
}
}
@@ -296,7 +296,7 @@ async function getRoutes(
return routes;
}
// TODO: update to use type from @now/routing-utils after
// TODO: update to use type from `@vercel/routing-utils` after
// adding permanent: true/false handling
export type Redirect = NowRewrite & {
statusCode?: number;
@@ -352,7 +352,7 @@ export async function getRoutesManifest(
throw new NowBuildError({
message: `A "routes-manifest.json" couldn't be found. Is the correct output directory configured? This setting does not need to be changed in most cases`,
link: 'https://err.sh/zeit/now/now-next-routes-manifest',
code: 'NOW_NEXT_NO_ROUTES_MANIFEST',
code: 'NEXT_NO_ROUTES_MANIFEST',
});
}
@@ -398,9 +398,9 @@ export async function getDynamicRoutes(
// update MIN_ROUTES_MANIFEST_VERSION
throw new NowBuildError({
message:
'This version of `@now/next` does not support the version of Next.js you are trying to deploy.\n' +
'Please upgrade your `@now/next` builder and try again. Contact support if this continues to happen.',
code: 'NOW_NEXT_VERSION_UPGRADE',
'This version of `@vercel/next` does not support the version of Next.js you are trying to deploy.\n' +
'Please upgrade your `@vercel/next` builder and try again. Contact support if this continues to happen.',
code: 'NEXT_VERSION_UPGRADE',
});
}
}
@@ -441,7 +441,7 @@ export async function getDynamicRoutes(
throw new NowBuildError({
message:
'Found usage of dynamic routes but not on a new enough version of Next.js.',
code: 'NOW_NEXT_DYNAMIC_ROUTES_OUTDATED',
code: 'NEXT_DYNAMIC_ROUTES_OUTDATED',
});
}

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }],
"builds": [{ "src": "package.json", "use": "@vercel/next" }],
"probes": [
{
"path": "/_next/static/testing-build-id/pages/index.js",

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }],
"builds": [{ "src": "package.json", "use": "@vercel/next" }],
"probes": [
{ "path": "/hello1", "mustContain": "Hello World 1" },
{ "path": "/nested/hello2", "mustContain": "Hello World 2" }

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }],
"builds": [{ "src": "package.json", "use": "@vercel/next" }],
"probes": [
{ "path": "/nested/fb", "mustContain": "Hello Firebase: <!-- -->0" },
{ "path": "/nested/moar/fb", "mustContain": "Hello Firebase: <!-- -->0" }

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }],
"builds": [{ "src": "package.json", "use": "@vercel/next" }],
"probes": [
{
"path": "/lambda",

View File

@@ -2,7 +2,7 @@
"builds": [
{
"src": "package.json",
"use": "@now/next",
"use": "@vercel/next",
"config": {
"functions": {
"src/pages/api/memory.js": {

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }],
"builds": [{ "src": "package.json", "use": "@vercel/next" }],
"probes": [
{
"path": "/redir1",

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }],
"builds": [{ "src": "package.json", "use": "@vercel/next" }],
"probes": [
{
"path": "/_next/static/build-id/pages/hello.js",

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "packages/web/next.config.js", "use": "@now/next" }],
"builds": [{ "src": "packages/web/next.config.js", "use": "@vercel/next" }],
"routes": [{ "src": "/(.*)", "dest": "/packages/web/$1", "continue": true }],
"probes": [
{

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }],
"builds": [{ "src": "package.json", "use": "@vercel/next" }],
"probes": [
{
"path": "/_next/static/testing-build-id/pages/index.js",

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }],
"builds": [{ "src": "package.json", "use": "@vercel/next" }],
"probes": [
{
"path": "/",

Some files were not shown because too many files have changed in this diff Show More