Compare commits

..

26 Commits

Author SHA1 Message Date
Steven
b626f3fe57 Publish Stable
- @vercel/frameworks@0.0.14
 - @vercel/build-utils@2.3.0
 - @vercel/cgi@1.0.5
 - vercel@19.0.0
 - @vercel/client@8.0.0
 - @vercel/go@1.1.0
 - @vercel/next@2.6.0
 - @vercel/node-bridge@1.3.0
 - @vercel/node@1.6.0
 - @vercel/python@1.2.0
 - @vercel/routing-utils@1.8.2
 - @vercel/ruby@1.2.0
 - @vercel/static-build@0.17.0
2020-05-07 18:52:35 -04:00
Steven
96bc0c9bee Publish Canary
- vercel@18.0.1-canary.24
2020-05-07 17:56:40 -04:00
Steven
f4ff8c0268 [now-cli] Change precedence of auth directory (#4299) 2020-05-07 23:55:35 +02:00
Steven
1a5681f287 [now-cli] Add getTitleName() and update getCommandName() (#4296)
This PR adds two functions:

* `getTitleName()` - used to get the uppercase Vercel or Now package name, for example `vercel --version`
* `getCommandName()` - used to get the `vercel` command followed by subcommands, for example in error suggestions
2020-05-07 21:24:15 +00:00
Ana Trajkovska
88b66ae646 Publish Canary
- vercel@18.0.1-canary.23
2020-05-07 22:37:48 +02:00
Ana Trajkovska
db0124782a Implement pagination for vercel teams ls (#4294)
* Implement pagination for `now teams ls`

* Set default empty object

* Use output logger

* Trigger build
2020-05-07 22:36:54 +02:00
Nathan Rajlich
a7a5d4d169 [now-cli] Special case @vercel/static when updating builders (#4295) 2020-05-07 19:40:52 +00:00
Nathan Rajlich
4b39e96c28 Ensure the npm registry is used during "Publish" workflow (#4286)
Unset the `npm_config_registry` env var which yarn overwrites to the
yarn registry, which we don't want since the `.npmrc` file that gets
created is configured to the npm registry.
2020-05-07 19:00:16 +00:00
Steven
f459db9f83 [now-cli] Add e2e test for vercel.json and .vercelignore (#4292)
This PR adds a test for a deployment as well as `now dev` to ensure both `vercel.json` and `.vercelignore` are applied.

I also fixed the remaining test helpers to work with `vercel.json`.
2020-05-07 18:04:37 +00:00
Ana Trajkovska
ad19021969 Publish Canary
- vercel@18.0.1-canary.22
2020-05-07 18:54:37 +02:00
Ana Trajkovska
95e41874e4 Replace now with vercel in pagination message (#4290) 2020-05-07 18:49:15 +02:00
Ana Trajkovska
4d20a1d77b Publish Canary
- vercel@18.0.1-canary.21
2020-05-07 14:56:28 +02:00
Ana Trajkovska
325ee261cb Implement pagination for now dns ls (#4257) 2020-05-07 14:53:08 +02:00
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
120 changed files with 756 additions and 597 deletions

View File

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

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,14 +1,13 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"packages": ["packages/*"],
"command": {
"publish": {
"npmClient": "npm",
"allowBranch": ["master", "canary"],
"registry": "https://registry.npmjs.org/"
}
},
"version": "independent"
}
"npmClient": "yarn",
"useWorkspaces": true,
"packages": ["packages/*"],
"command": {
"publish": {
"npmClient": "npm",
"allowBranch": ["master"],
"registry": "https://registry.npmjs.org/"
}
},
"version": "independent"
}

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/build-utils",
"version": "2.2.2-canary.7",
"version": "2.3.0",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.js",

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

@@ -391,11 +391,11 @@ function getApiMatches({ tag }: Options = {}) {
const config = { zeroConfig: true };
return [
{ src: 'api/**/*.js', use: `@vercel/node${withTag}`, config },
{ src: 'api/**/*.ts', use: `@vercel/node${withTag}`, config },
{ src: 'api/**/!(*_test).go', use: `@vercel/go${withTag}`, config },
{ src: 'api/**/*.py', use: `@vercel/python${withTag}`, config },
{ src: 'api/**/*.rb', use: `@vercel/ruby${withTag}`, config },
{ src: 'api/**/*.js', use: `@now/node${withTag}`, config },
{ src: 'api/**/*.ts', use: `@now/node${withTag}`, config },
{ src: 'api/**/!(*_test).go', use: `@now/go${withTag}`, config },
{ src: 'api/**/*.py', use: `@now/python${withTag}`, config },
{ src: 'api/**/*.rb', use: `@now/ruby${withTag}`, config },
];
}
@@ -457,7 +457,7 @@ function detectFrontBuilder(
}
if (framework === 'nextjs') {
return { src: 'package.json', use: `@vercel/next${withTag}`, config };
return { src: 'package.json', use: `@now/next${withTag}`, config };
}
// Entrypoints for other frameworks
@@ -480,7 +480,7 @@ function detectFrontBuilder(
return {
src: source || 'package.json',
use: `@vercel/static-build${withTag}`,
use: `@now/static-build${withTag}`,
config,
};
}

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

@@ -85,9 +85,24 @@ 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 (
typeof name === 'string' &&
(name.startsWith(`@vercel/${desired}`) ||
name.startsWith(`@now/${desired}`))
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

@@ -119,10 +119,7 @@ it('Test `detectBuilders` and `detectRoutes`', async () => {
JSON.stringify(nowConfig, null, 2)
);
const deployment = await testDeployment(
{ builderUrl, buildUtilsUrl },
fixture
);
const deployment = await testDeployment({ builderUrl }, fixture);
expect(deployment).toBeDefined();
});
@@ -200,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

@@ -35,7 +35,7 @@ describe('Test `detectBuilders`', () => {
};
const files = ['package.json', 'pages/index.js'];
const { builders, errors } = await detectBuilders(files, pkg);
expect(builders![0].use).toBe('@vercel/next');
expect(builders![0].use).toBe('@now/next');
expect(errors).toBe(null);
});
@@ -46,7 +46,7 @@ describe('Test `detectBuilders`', () => {
};
const files = ['package.json', 'pages/index.js'];
const { builders, errors } = await detectBuilders(files, pkg);
expect(builders![0].use).toBe('@vercel/next');
expect(builders![0].use).toBe('@now/next');
expect(errors).toBe(null);
});
@@ -75,7 +75,7 @@ describe('Test `detectBuilders`', () => {
it('no package.json + no build + raw static + api', async () => {
const files = ['api/users.js', 'index.html'];
const { builders, errors } = await detectBuilders(files);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/users.js');
expect(builders![1].use).toBe('@now/static');
expect(builders![1].src).toBe('!{api/**,package.json}');
@@ -86,7 +86,7 @@ describe('Test `detectBuilders`', () => {
it('package.json + no build + root + api', async () => {
const files = ['index.html', 'api/[endpoint].js', 'static/image.png'];
const { builders, errors } = await detectBuilders(files);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/[endpoint].js');
expect(builders![1].use).toBe('@now/static');
expect(builders![1].src).toBe('!{api/**,package.json}');
@@ -102,7 +102,7 @@ describe('Test `detectBuilders`', () => {
];
const { builders } = await detectBuilders(files);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/[endpoint]/[id].js');
expect(builders!.length).toBe(1);
});
@@ -115,9 +115,9 @@ describe('Test `detectBuilders`', () => {
const files = ['package.json', 'api/endpoint.js', 'public/index.html'];
const { builders } = await detectBuilders(files, pkg);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/endpoint.js');
expect(builders![1].use).toBe('@vercel/next');
expect(builders![1].use).toBe('@now/next');
expect(builders![1].src).toBe('package.json');
expect(builders!.length).toBe(2);
});
@@ -130,9 +130,9 @@ describe('Test `detectBuilders`', () => {
const files = ['package.json', 'api/endpoint.js', 'index.html'];
const { builders } = await detectBuilders(files, pkg);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/endpoint.js');
expect(builders![1].use).toBe('@vercel/next');
expect(builders![1].use).toBe('@now/next');
expect(builders![1].src).toBe('package.json');
expect(builders!.length).toBe(2);
});
@@ -141,7 +141,7 @@ describe('Test `detectBuilders`', () => {
const files = ['api/endpoint.js', 'index.html', 'favicon.ico'];
const { builders } = await detectBuilders(files);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/endpoint.js');
expect(builders![1].use).toBe('@now/static');
expect(builders![1].src).toBe('!{api/**,package.json}');
@@ -157,7 +157,7 @@ describe('Test `detectBuilders`', () => {
];
const { builders } = await detectBuilders(files);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/endpoint.js');
expect(builders![1].use).toBe('@now/static');
expect(builders![1].src).toBe('public/**/*');
@@ -201,7 +201,7 @@ describe('Test `detectBuilders`', () => {
const files = ['package.json', 'public/index.html', 'README.md'];
const { builders } = await detectBuilders(files, pkg);
expect(builders![0].use).toBe('@vercel/next');
expect(builders![0].use).toBe('@now/next');
expect(builders![0].src).toBe('package.json');
expect(builders!.length).toBe(1);
});
@@ -214,7 +214,7 @@ describe('Test `detectBuilders`', () => {
const files = ['package.json', 'pages/index.js'];
const { builders } = await detectBuilders(files, pkg);
expect(builders![0].use).toBe('@vercel/static-build');
expect(builders![0].use).toBe('@now/static-build');
expect(builders![0].src).toBe('package.json');
expect(builders!.length).toBe(1);
});
@@ -227,7 +227,7 @@ describe('Test `detectBuilders`', () => {
const files = ['package.json', 'pages/index.js'];
const { builders } = await detectBuilders(files, pkg, { tag: 'canary' });
expect(builders![0].use).toBe('@vercel/static-build@canary');
expect(builders![0].use).toBe('@now/static-build@canary');
expect(builders![0].src).toBe('package.json');
expect(builders!.length).toBe(1);
});
@@ -237,7 +237,7 @@ describe('Test `detectBuilders`', () => {
const files = ['package.json', 'api/[endpoint].js'];
const { builders } = await detectBuilders(files, pkg);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/[endpoint].js');
expect(builders!.length).toBe(1);
});
@@ -278,9 +278,9 @@ describe('Test `detectBuilders`', () => {
];
const { builders } = await detectBuilders(files, pkg, { tag: 'canary' });
expect(builders![0].use).toBe('@vercel/node@canary');
expect(builders![1].use).toBe('@vercel/node@canary');
expect(builders![2].use).toBe('@vercel/next@canary');
expect(builders![0].use).toBe('@now/node@canary');
expect(builders![1].use).toBe('@now/node@canary');
expect(builders![2].use).toBe('@now/next@canary');
expect(builders!.length).toBe(3);
});
@@ -296,9 +296,9 @@ describe('Test `detectBuilders`', () => {
];
const { builders } = await detectBuilders(files, pkg, { tag: 'latest' });
expect(builders![0].use).toBe('@vercel/node@latest');
expect(builders![1].use).toBe('@vercel/node@latest');
expect(builders![2].use).toBe('@vercel/next@latest');
expect(builders![0].use).toBe('@now/node@latest');
expect(builders![1].use).toBe('@now/node@latest');
expect(builders![2].use).toBe('@now/next@latest');
expect(builders!.length).toBe(3);
});
@@ -314,9 +314,9 @@ describe('Test `detectBuilders`', () => {
];
const { builders } = await detectBuilders(files, pkg, { tag: 'haha' });
expect(builders![0].use).toBe('@vercel/node@haha');
expect(builders![1].use).toBe('@vercel/node@haha');
expect(builders![2].use).toBe('@vercel/next@haha');
expect(builders![0].use).toBe('@now/node@haha');
expect(builders![1].use).toBe('@now/node@haha');
expect(builders![2].use).toBe('@now/next@haha');
expect(builders!.length).toBe(3);
});
@@ -334,8 +334,8 @@ describe('Test `detectBuilders`', () => {
expect(warnings[0].code).toBe('conflicting_files');
expect(builders).toBeDefined();
expect(builders!.length).toBe(2);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![1].use).toBe('@vercel/next');
expect(builders![0].use).toBe('@now/node');
expect(builders![1].use).toBe('@now/next');
});
it('many static files + one api file', async () => {
@@ -344,7 +344,7 @@ describe('Test `detectBuilders`', () => {
const { builders } = await detectBuilders(files);
expect(builders!.length).toBe(2);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/index.ts');
expect(builders![1].use).toBe('@now/static');
expect(builders![1].src).toBe('!{api/**,package.json}');
@@ -374,7 +374,7 @@ describe('Test `detectBuilders`', () => {
expect(builders!.length).toBe(1);
expect(builders![0]).toEqual({
src: 'package.json',
use: '@vercel/next',
use: '@now/next',
config: {
zeroConfig: true,
functions: {
@@ -412,7 +412,7 @@ describe('Test `detectBuilders`', () => {
expect(builders!.length).toBe(3);
expect(builders![0]).toEqual({
src: 'api/teams/members.ts',
use: '@vercel/node',
use: '@now/node',
config: {
zeroConfig: true,
functions: {
@@ -437,7 +437,7 @@ describe('Test `detectBuilders`', () => {
});
expect(builders![2]).toEqual({
src: 'package.json',
use: '@vercel/next',
use: '@now/next',
config: {
zeroConfig: true,
},
@@ -538,7 +538,7 @@ describe('Test `detectBuilders`', () => {
expect(errors![0].code).toBe('invalid_function');
});
it('Do not allow functions that are not used by @vercel/next', async () => {
it('Do not allow functions that are not used by @now/next', async () => {
const pkg = {
scripts: { build: 'next build' },
dependencies: { next: '9.0.0' },
@@ -564,7 +564,7 @@ describe('Test `detectBuilders`', () => {
expect(errors).toBe(null);
expect(builders).not.toBe(null);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].config).toMatchObject({
functions,
zeroConfig: true,
@@ -584,7 +584,7 @@ describe('Test `detectBuilders`', () => {
expect(errors).toBe(null);
expect(builders).not.toBe(null);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].config).toMatchObject({
functions,
zeroConfig: true,
@@ -607,7 +607,7 @@ describe('Test `detectBuilders`', () => {
expect(errors).toBe(null);
expect(builders).not.toBe(null);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].config).toMatchObject({
functions,
zeroConfig: true,
@@ -705,7 +705,7 @@ describe('Test `detectBuilders`', () => {
expect(builders).toEqual([
{
use: '@vercel/static-build',
use: '@now/static-build',
src: 'config.yaml',
config: {
zeroConfig: true,
@@ -727,7 +727,7 @@ describe('Test `detectBuilders`', () => {
expect(builders).toEqual([
{
use: '@vercel/static-build',
use: '@now/static-build',
src: 'package.json',
config: {
zeroConfig: true,
@@ -744,14 +744,14 @@ describe('Test `detectBuilders`', () => {
expect(builders).toEqual([
{
use: '@vercel/ruby',
use: '@now/ruby',
src: 'api/date.rb',
config: {
zeroConfig: true,
},
},
{
use: '@vercel/static-build',
use: '@now/static-build',
src: 'config.rb',
config: {
zeroConfig: true,
@@ -765,7 +765,7 @@ describe('Test `detectBuilders`', () => {
const files = ['server/hello.ts', 'public/index.html'];
const functions = {
'server/**/*.ts': {
runtime: '@vercel/node@1.3.1',
runtime: '@now/node@1.3.1',
},
};
@@ -868,7 +868,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
redirectRoutes,
rewriteRoutes,
} = await detectBuilders(files, pkg, { featHandleMiss });
expect(builders![0].use).toBe('@vercel/next');
expect(builders![0].use).toBe('@now/next');
expect(errors).toBe(null);
expect(defaultRoutes).toStrictEqual([]);
expect(redirectRoutes).toStrictEqual([]);
@@ -888,7 +888,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
redirectRoutes,
rewriteRoutes,
} = await detectBuilders(files, pkg, { featHandleMiss });
expect(builders![0].use).toBe('@vercel/next');
expect(builders![0].use).toBe('@now/next');
expect(errors).toBe(null);
expect(defaultRoutes).toStrictEqual([]);
expect(redirectRoutes).toStrictEqual([]);
@@ -950,7 +950,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
redirectRoutes,
rewriteRoutes,
} = await detectBuilders(files, null, { featHandleMiss });
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/users.js');
expect(builders![1].use).toBe('@now/static');
expect(builders![1].src).toBe('!{api/**,package.json}');
@@ -970,7 +970,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
const { builders, errors } = await detectBuilders(files, null, {
featHandleMiss,
});
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/[endpoint].js');
expect(builders![1].use).toBe('@now/static');
expect(builders![1].src).toBe('!{api/**,package.json}');
@@ -991,7 +991,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
redirectRoutes,
rewriteRoutes,
} = await detectBuilders(files, undefined, { featHandleMiss });
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/[endpoint]/[id].js');
expect(builders!.length).toBe(1);
@@ -1017,9 +1017,9 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
redirectRoutes,
rewriteRoutes,
} = await detectBuilders(files, pkg, { featHandleMiss });
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/endpoint.js');
expect(builders![1].use).toBe('@vercel/next');
expect(builders![1].use).toBe('@now/next');
expect(builders![1].src).toBe('package.json');
expect(builders!.length).toBe(2);
@@ -1044,9 +1044,9 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
redirectRoutes,
rewriteRoutes,
} = await detectBuilders(files, pkg, { featHandleMiss });
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/endpoint.js');
expect(builders![1].use).toBe('@vercel/next');
expect(builders![1].use).toBe('@now/next');
expect(builders![1].src).toBe('package.json');
expect(builders!.length).toBe(2);
@@ -1067,7 +1067,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
redirectRoutes,
rewriteRoutes,
} = await detectBuilders(files, null, { featHandleMiss });
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/endpoint.js');
expect(builders![1].use).toBe('@now/static');
expect(builders![1].src).toBe('!{api/**,package.json}');
@@ -1094,7 +1094,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
redirectRoutes,
rewriteRoutes,
} = await detectBuilders(files, pkg, { featHandleMiss });
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/version.js');
expect(builders![1].use).toBe('@now/static');
expect(builders![1].src).toBe('!{api/**,package.json}');
@@ -1119,7 +1119,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
const { builders } = await detectBuilders(files, undefined, {
featHandleMiss,
});
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/endpoint.js');
expect(builders![1].use).toBe('@now/static');
expect(builders![1].src).toBe('public/**/*');
@@ -1167,7 +1167,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
const files = ['package.json', 'public/index.html', 'README.md'];
const { builders } = await detectBuilders(files, pkg, { featHandleMiss });
expect(builders![0].use).toBe('@vercel/next');
expect(builders![0].use).toBe('@now/next');
expect(builders![0].src).toBe('package.json');
expect(builders!.length).toBe(1);
});
@@ -1180,7 +1180,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
const files = ['package.json', 'pages/index.js'];
const { builders } = await detectBuilders(files, pkg, { featHandleMiss });
expect(builders![0].use).toBe('@vercel/static-build');
expect(builders![0].use).toBe('@now/static-build');
expect(builders![0].src).toBe('package.json');
expect(builders!.length).toBe(1);
});
@@ -1196,7 +1196,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
tag: 'canary',
featHandleMiss,
});
expect(builders![0].use).toBe('@vercel/static-build@canary');
expect(builders![0].use).toBe('@now/static-build@canary');
expect(builders![0].src).toBe('package.json');
expect(builders!.length).toBe(1);
});
@@ -1206,7 +1206,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
const files = ['package.json', 'api/[endpoint].js'];
const { builders } = await detectBuilders(files, pkg, { featHandleMiss });
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/[endpoint].js');
expect(builders!.length).toBe(1);
});
@@ -1256,9 +1256,9 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
tag: 'canary',
featHandleMiss,
});
expect(builders![0].use).toBe('@vercel/node@canary');
expect(builders![1].use).toBe('@vercel/node@canary');
expect(builders![2].use).toBe('@vercel/next@canary');
expect(builders![0].use).toBe('@now/node@canary');
expect(builders![1].use).toBe('@now/node@canary');
expect(builders![2].use).toBe('@now/next@canary');
expect(builders!.length).toBe(3);
});
@@ -1277,9 +1277,9 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
tag: 'latest',
featHandleMiss,
});
expect(builders![0].use).toBe('@vercel/node@latest');
expect(builders![1].use).toBe('@vercel/node@latest');
expect(builders![2].use).toBe('@vercel/next@latest');
expect(builders![0].use).toBe('@now/node@latest');
expect(builders![1].use).toBe('@now/node@latest');
expect(builders![2].use).toBe('@now/next@latest');
expect(builders!.length).toBe(3);
});
@@ -1298,9 +1298,9 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
tag: 'haha',
featHandleMiss,
});
expect(builders![0].use).toBe('@vercel/node@haha');
expect(builders![1].use).toBe('@vercel/node@haha');
expect(builders![2].use).toBe('@vercel/next@haha');
expect(builders![0].use).toBe('@now/node@haha');
expect(builders![1].use).toBe('@now/node@haha');
expect(builders![2].use).toBe('@now/next@haha');
expect(builders!.length).toBe(3);
});
@@ -1320,8 +1320,8 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
expect(warnings[0].code).toBe('conflicting_files');
expect(builders).toBeDefined();
expect(builders!.length).toBe(2);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![1].use).toBe('@vercel/next');
expect(builders![0].use).toBe('@now/node');
expect(builders![1].use).toBe('@now/next');
});
it('many static files + one api file', async () => {
@@ -1332,7 +1332,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
});
expect(builders!.length).toBe(2);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].src).toBe('api/index.ts');
expect(builders![1].use).toBe('@now/static');
expect(builders![1].src).toBe('!{api/**,package.json}');
@@ -1363,7 +1363,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
expect(builders!.length).toBe(1);
expect(builders![0]).toEqual({
src: 'package.json',
use: '@vercel/next',
use: '@now/next',
config: {
zeroConfig: true,
functions: {
@@ -1404,7 +1404,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
expect(builders!.length).toBe(3);
expect(builders![0]).toEqual({
src: 'api/teams/members.ts',
use: '@vercel/node',
use: '@now/node',
config: {
zeroConfig: true,
functions: {
@@ -1429,7 +1429,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
});
expect(builders![2]).toEqual({
src: 'package.json',
use: '@vercel/next',
use: '@now/next',
config: {
zeroConfig: true,
},
@@ -1538,7 +1538,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
expect(errors![0].code).toBe('invalid_function');
});
it('Do not allow functions that are not used by @vercel/next', async () => {
it('Do not allow functions that are not used by @now/next', async () => {
const pkg = {
scripts: { build: 'next build' },
dependencies: { next: '9.0.0' },
@@ -1568,7 +1568,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
expect(errors).toBe(null);
expect(builders).not.toBe(null);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].config).toMatchObject({
functions,
zeroConfig: true,
@@ -1589,7 +1589,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
expect(errors).toBe(null);
expect(builders).not.toBe(null);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].config).toMatchObject({
functions,
zeroConfig: true,
@@ -1613,7 +1613,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
expect(errors).toBe(null);
expect(builders).not.toBe(null);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![0].config).toMatchObject({
functions,
zeroConfig: true,
@@ -1737,7 +1737,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
expect(builders).toEqual([
{
use: '@vercel/static-build',
use: '@now/static-build',
src: 'config.yaml',
config: {
zeroConfig: true,
@@ -1759,7 +1759,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
expect(builders).toEqual([
{
use: '@vercel/static-build',
use: '@now/static-build',
src: 'package.json',
config: {
zeroConfig: true,
@@ -1779,14 +1779,14 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
expect(builders).toEqual([
{
use: '@vercel/ruby',
use: '@now/ruby',
src: 'api/date.rb',
config: {
zeroConfig: true,
},
},
{
use: '@vercel/static-build',
use: '@now/static-build',
src: 'config.rb',
config: {
zeroConfig: true,
@@ -1800,7 +1800,7 @@ describe('Test `detectBuilders` with `featHandleMiss=true`', () => {
const files = ['server/hello.ts', 'public/index.html'];
const functions = {
'server/**/*.ts': {
runtime: '@vercel/node@1.3.1',
runtime: '@now/node@1.3.1',
},
};
@@ -2000,10 +2000,10 @@ it('Test `detectRoutes`', async () => {
const { builders, defaultRoutes } = await detectBuilders(files);
expect(builders!.length).toBe(4);
expect(builders![0].use).toBe('@vercel/node');
expect(builders![1].use).toBe('@vercel/node');
expect(builders![2].use).toBe('@vercel/node');
expect(builders![3].use).toBe('@vercel/node');
expect(builders![0].use).toBe('@now/node');
expect(builders![1].use).toBe('@now/node');
expect(builders![2].use).toBe('@now/node');
expect(builders![3].use).toBe('@now/node');
expect(defaultRoutes!.length).toBe(5);
}
@@ -2883,7 +2883,7 @@ describe('Test `detectOutputDirectory`', () => {
config: { zeroConfig: true },
},
{
use: '@vercel/node',
use: '@now/node',
src: 'api/index.js',
},
];
@@ -2896,7 +2896,7 @@ describe('Test `detectApiDirectory`', () => {
it('should be `null` with no config', async () => {
const builders = [
{
use: '@vercel/node',
use: '@now/node',
src: 'api/**/*.js',
},
];
@@ -2907,7 +2907,7 @@ describe('Test `detectApiDirectory`', () => {
it('should be `null` with no zero config builds', async () => {
const builders = [
{
use: '@vercel/node',
use: '@now/node',
src: 'api/**/*.js',
config: {},
},
@@ -2919,7 +2919,7 @@ describe('Test `detectApiDirectory`', () => {
it('should be `api` with one zero config', async () => {
const builders = [
{
use: '@vercel/node',
use: '@now/node',
src: 'api/**/*.js',
config: { zeroConfig: true },
},
@@ -2931,12 +2931,12 @@ describe('Test `detectApiDirectory`', () => {
it('should be `api` with one zero config and one without config', async () => {
const builders = [
{
use: '@vercel/node',
use: '@now/node',
src: 'api/**/*.js',
config: { zeroConfig: true },
},
{
use: '@vercel/php',
use: '@now/php',
src: 'api/**/*.php',
},
];
@@ -2947,7 +2947,7 @@ describe('Test `detectApiDirectory`', () => {
it('should be `null` with zero config but without api directory', async () => {
const builders = [
{
use: '@vercel/next',
use: '@now/next',
src: 'package.json',
config: { zeroConfig: true },
},
@@ -2961,28 +2961,28 @@ describe('Test `detectApiExtensions`', () => {
it('should have correct extensions', async () => {
const builders = [
{
use: '@vercel/node',
use: '@now/node',
src: 'api/**/*.js',
config: {
zeroConfig: true,
},
},
{
use: '@vercel/python',
use: '@now/python',
src: 'api/**/*.py',
config: {
zeroConfig: true,
},
},
{
use: '@vercel/go',
use: '@now/go',
src: 'api/**/*.go',
config: {
zeroConfig: true,
},
},
{
use: '@vercel/ruby',
use: '@now/ruby',
src: 'api/**/*.rb',
config: {
zeroConfig: true,
@@ -3002,7 +3002,7 @@ describe('Test `detectApiExtensions`', () => {
},
},
{
use: '@vercel/next',
use: '@now/next',
src: 'package.json',
// No api directory should not be added
config: {

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

@@ -1,6 +1,6 @@
{
"name": "@vercel/cgi",
"version": "1.0.5-canary.1",
"version": "1.0.5",
"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": "vercel",
"version": "18.0.1-canary.19",
"version": "19.0.0",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Now",
@@ -41,7 +41,7 @@
"all": true
},
"bin": {
"now": "./dist/index.js",
"vc": "./dist/index.js",
"vercel": "./dist/index.js"
},
"files": [

View File

@@ -9,8 +9,7 @@ import getScope from '../../util/get-scope.ts';
import stamp from '../../util/output/stamp.ts';
import strlen from '../../util/strlen.ts';
import getCommandFlags from '../../util/get-command-flags';
import cmd from '../../util/output/cmd.ts';
import { getPkgName } from '../../util/pkg-name.ts';
import { getCommandName } from '../../util/pkg-name.ts';
export default async function ls(ctx, opts, args, output) {
const {
@@ -56,7 +55,7 @@ export default async function ls(ctx, opts, args, output) {
if (args.length > 1) {
output.error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} alias ls [alias]`
`${getCommandName('alias ls [alias]')}`
)}`
);
return 1;
@@ -107,8 +106,8 @@ export default async function ls(ctx, opts, args, output) {
if (pagination && pagination.count === 20) {
const flags = getCommandFlags(opts, ['_', '--next']);
output.log(
`To display the next page run ${cmd(
`${getPkgName()} alias ls${flags} --next ${pagination.next}`
`To display the next page run ${getCommandName(
`alias ls${flags} --next ${pagination.next}`
)}`
);
}

View File

@@ -2,7 +2,6 @@ import chalk from 'chalk';
import ms from 'ms';
import table from 'text-table';
import Now from '../../util';
import cmd from '../../util/output/cmd.ts';
import Client from '../../util/client.ts';
import getScope from '../../util/get-scope.ts';
import removeAliasById from '../../util/alias/remove-alias-by-id';
@@ -11,7 +10,7 @@ import strlen from '../../util/strlen.ts';
import promptBool from '../../util/prompt-bool';
import { isValidName } from '../../util/is-valid-name';
import findAliasByAliasOrId from '../../util/alias/find-alias-by-alias-or-id';
import { getPkgName } from '../../util/pkg-name.ts';
import { getCommandName } from '../../util/pkg-name.ts';
export default async function rm(ctx, opts, args, output) {
const {
@@ -47,16 +46,14 @@ export default async function rm(ctx, opts, args, output) {
if (args.length !== 1) {
output.error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} alias rm <alias>`
`${getCommandName('alias rm <alias>')}`
)}`
);
return 1;
}
if (!aliasOrId) {
output.error(
`${cmd(`${getPkgName()} alias rm <alias>`)} expects one argument`
);
output.error(`${getCommandName('alias rm <alias>')} expects one argument`);
return 1;
}
@@ -71,7 +68,7 @@ export default async function rm(ctx, opts, args, output) {
output.error(
`Alias not found by "${aliasOrId}" under ${chalk.bold(contextName)}`
);
output.log(`Run ${cmd(`${getPkgName} alias ls`)} to see your aliases.`);
output.log(`Run ${getCommandName('alias ls')} to see your aliases.`);
return 1;
}

View File

@@ -7,7 +7,6 @@ import { Output } from '../../util/output';
import * as ERRORS from '../../util/errors-ts';
import assignAlias from '../../util/alias/assign-alias';
import Client from '../../util/client';
import cmd from '../../util/output/cmd';
import formatDnsTable from '../../util/format-dns-table';
import formatNSTable from '../../util/format-ns-table';
import getDeploymentForAlias from '../../util/alias/get-deployment-for-alias';
@@ -23,7 +22,7 @@ import handleCertError from '../../util/certs/handle-cert-error';
import isWildcardAlias from '../../util/alias/is-wildcard-alias';
import link from '../../util/output/link';
import { User } from '../../types';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -78,8 +77,8 @@ export default async function set(
// If there are more than two args we have to error
if (args.length > 2) {
output.error(
`${cmd(
`${getPkgName()} alias <deployment> <target>`
`${getCommandName(
`alias <deployment> <target>`
)} accepts at most two arguments`
);
return 1;
@@ -129,7 +128,7 @@ export default async function set(
output.error(
`To ship to production, optionally configure your domains (${link(
'https://vercel.com/docs/v2/custom-domains'
)}) and run ${cmd(`${getPkgName()} --prod`)}.`
)}) and run ${getCommandName(`--prod`)}.`
);
return 1;
}
@@ -304,8 +303,8 @@ function handleSetupDomainError<T>(
)}\n\n`
);
output.print(
` Once your domain uses either the nameservers or the TXT DNS record from above, run again ${cmd(
`${getPkgName()} domains verify <domain>`
` Once your domain uses either the nameservers or the TXT DNS record from above, run again ${getCommandName(
'domains verify <domain>'
)}.\n`
);
output.print(
@@ -313,8 +312,8 @@ function handleSetupDomainError<T>(
);
} else {
output.print(
` Once your domain uses the nameservers from above, run again ${cmd(
`${getPkgName()} domains verify <domain>`
` Once your domain uses the nameservers from above, run again ${getCommandName(
'domains verify <domain>'
)}.\n`
);
}
@@ -477,7 +476,7 @@ function handleCreateAliasError<T>(
output.log(
`Update the scale settings on ${chalk.dim(
error.meta.url
)} with \`${getPkgName()} scale\` and try again`
)} with ${getCommandName('scale')} and try again`
);
output.log('Read more: https://err.sh/now/v2-no-min');
return 1;
@@ -493,7 +492,7 @@ function handleCreateAliasError<T>(
output.log(
`Update the scale settings on ${chalk.dim(
error.meta.url
)} with \`${getPkgName()} scale\` and try again`
)} with ${getCommandName('scale')} and try again`
);
return 1;
}
@@ -513,7 +512,7 @@ function handleCreateAliasError<T>(
output.log(
`Update the scale settings on ${chalk.dim(
error.meta.url
)} with \`${getPkgName()} scale\` and try again`
)} with ${getCommandName('scale')} and try again`
);
return 1;
}
@@ -523,8 +522,8 @@ function handleCreateAliasError<T>(
`There is no certificate for the domain ${error.meta.domain} and it could not be created.`
);
output.log(
`Please generate a new certificate manually with ${cmd(
`${getPkgName()} certs issue ${error.meta.domain}`
`Please generate a new certificate manually with ${getCommandName(
`certs issue ${error.meta.domain}`
)}`
);
return 1;

View File

@@ -9,7 +9,7 @@ import createCertFromFile from '../../util/certs/create-cert-from-file';
import createCertForCns from '../../util/certs/create-cert-for-cns';
import { NowContext } from '../../types';
import { Output } from '../../util/output';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
interface Options {
'--overwrite'?: boolean;
@@ -77,7 +77,9 @@ async function add(
);
output.print(
` ${chalk.cyan(
`${getPkgName()} certs add --crt <domain.crt> --key <domain.key> --ca <ca.crt>`
`${getCommandName(
'certs add --crt <domain.crt> --key <domain.key> --ca <ca.crt>'
)}`
)}\n`
);
now.close();
@@ -89,9 +91,9 @@ async function add(
} else {
output.warn(
`${chalk.cyan(
`${getPkgName()} certs add`
getCommandName('certs add')
)} will be soon deprecated. Please use ${chalk.cyan(
`${getPkgName()} certs issue <cn> <cns>`
getCommandName('certs issue <cn> <cns>')
)} instead`
);
@@ -100,7 +102,7 @@ async function add(
`Invalid number of arguments to create a custom certificate entry. Usage:`
);
output.print(
` ${chalk.cyan(`${getPkgName()} certs add <cn>[, <cn>]`)}\n`
` ${chalk.cyan(getCommandName('certs add <cn>[, <cn>]'))}\n`
);
now.close();
return 1;

View File

@@ -14,7 +14,7 @@ import getScope from '../../util/get-scope';
import stamp from '../../util/output/stamp';
import startCertOrder from '../../util/certs/start-cert-order';
import handleCertError from '../../util/certs/handle-cert-error';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--ca': string;
@@ -81,7 +81,9 @@ export default async function issue(
);
output.print(
` ${chalk.cyan(
`${getPkgName()} certs issue --crt <domain.crt> --key <domain.key> --ca <ca.crt>`
getCommandName(
'certs issue --crt <domain.crt> --key <domain.key> --ca <ca.crt>'
)
)}\n`
);
return 1;
@@ -109,7 +111,7 @@ export default async function issue(
`Invalid number of arguments to create a custom certificate entry. Usage:`
);
output.print(
` ${chalk.cyan(`${getPkgName()} certs issue <cn>[, <cn>]`)}\n`
` ${chalk.cyan(getCommandName('certs issue <cn>[, <cn>]'))}\n`
);
return 1;
}
@@ -193,7 +195,7 @@ async function runStartOrder(
` There are no pending challenges. Finish the issuance by running: \n`
);
output.print(
` ${chalk.cyan(`${getPkgName()} certs issue ${cns.join(' ')}`)}\n`
` ${chalk.cyan(getCommandName(`certs issue ${cns.join(' ')}`))}\n`
);
return 0;
}
@@ -226,7 +228,7 @@ async function runStartOrder(
process.stdout.write(`${rows.join('\n')}\n\n`);
output.log(`To issue the certificate once the records are added, run:`);
output.print(
` ${chalk.cyan(`${getPkgName()} certs issue ${cns.join(' ')}`)}\n`
` ${chalk.cyan(getCommandName(`certs issue ${cns.join(' ')}`))}\n`
);
output.print(' Read more: https://err.sh/now/solve-challenges-manually\n');
return 0;

View File

@@ -3,7 +3,6 @@ import ms from 'ms';
import table from 'text-table';
// @ts-ignore
import Now from '../../util';
import cmd from '../../util/output/cmd';
import Client from '../../util/client';
import getScope from '../../util/get-scope';
import stamp from '../../util/output/stamp';
@@ -12,7 +11,7 @@ import strlen from '../../util/strlen';
import { Output } from '../../util/output';
import { NowContext, Cert } from '../../types';
import getCommandFlags from '../../util/get-command-flags';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
interface Options {
'--debug'?: boolean;
@@ -55,7 +54,7 @@ async function ls(
if (args.length !== 0) {
output.error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} certs ls`
`${getCommandName('certs ls')}`
)}`
);
return 1;
@@ -79,8 +78,8 @@ async function ls(
if (pagination && pagination.count === 20) {
const flags = getCommandFlags(opts, ['_', '--next']);
output.log(
`To display the next page run ${cmd(
`${getPkgName()} certs ls${flags} --next ${pagination.next}`
`To display the next page run ${getCommandName(
`certs ls${flags} --next ${pagination.next}`
)}`
);
}

View File

@@ -12,7 +12,7 @@ import Client from '../../util/client';
import getScope from '../../util/get-scope';
import stamp from '../../util/output/stamp';
import param from '../../util/output/param';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -50,7 +50,7 @@ async function rm(
if (args.length !== 1) {
output.error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} certs rm <id or cn>`
`${getCommandName('certs rm <id or cn>')}`
)}`
);
return 1;

View File

@@ -54,7 +54,7 @@ import validatePaths, {
validateRootDirectory,
} from '../../util/validate-paths';
import { readLocalConfig } from '../../util/config/files';
import { getPkgName } from '../../util/pkg-name.ts';
import { getCommandName } from '../../util/pkg-name.ts';
const addProcessEnv = async (log, env) => {
let val;
@@ -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);
@@ -665,8 +668,8 @@ export default async function main(
if (err instanceof BuildError) {
output.error('Build failed');
output.error(
`Check your logs at https://${now.url}/_logs or run ${code(
`${getPkgName()} logs ${now.url}`,
`Check your logs at https://${now.url}/_logs or run ${getCommandName(
`logs ${now.url}`,
{
// Backticks are interpreted as part of the URL, causing CMD+Click
// behavior to fail in editors like VSCode.
@@ -797,7 +800,7 @@ function handleCreateDeployError(output, error) {
if (error instanceof BuildsRateLimited) {
output.error(error.message);
output.note(
`Run ${code(`${getPkgName()} upgrade`)} to increase your builds limit.`
`Run ${getCommandName('upgrade')} to increase your builds limit.`
);
return 1;
}

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

@@ -13,7 +13,7 @@ import cmd from '../../util/output/cmd';
import dev from './dev';
import readPackage from '../../util/read-package';
import readConfig from '../../util/config/read-config';
import { getPkgName } from '../../util/pkg-name';
import { getPkgName, getCommandName } from '../../util/pkg-name';
const COMMAND_CONFIG = {
dev: ['dev'],
@@ -110,9 +110,7 @@ export default async function main(ctx: NowContext) {
}
if (argv._.length > 2) {
output.error(
`${cmd(`${getPkgName()} dev [dir]`)} accepts at most one argument`
);
output.error(`${getCommandName(`dev [dir]`)} accepts at most one argument`);
return 1;
}

View File

@@ -13,7 +13,7 @@ import getScope from '../../util/get-scope';
import parseAddDNSRecordArgs from '../../util/dns/parse-add-dns-record-args';
import stamp from '../../util/output/stamp';
import getDNSData from '../../util/dns/get-dns-data';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -50,7 +50,7 @@ export default async function add(
if (!parsedParams) {
output.error(
`Invalid number of arguments. See: ${chalk.cyan(
`${getPkgName()} dns --help`
`${getCommandName('dns --help')}`
)} for usage.`
);
return 1;

View File

@@ -6,7 +6,7 @@ import getScope from '../../util/get-scope';
import { DomainNotFound, InvalidDomain } from '../../util/errors-ts';
import stamp from '../../util/output/stamp';
import importZonefile from '../../util/dns/import-zonefile';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -42,7 +42,7 @@ export default async function add(
if (args.length !== 2) {
output.error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} dns import <domain> <zonefile>`
`${getCommandName('dns import <domain> <zonefile>')}`
)}`
);
return 1;

View File

@@ -85,8 +85,8 @@ const help = () => {
'`1584722256178`'
)} is the time in milliseconds since the UNIX epoch.
${chalk.cyan(`$ ${getPkgName()} dns ls --next 1584722256178`)}
${chalk.cyan(`$ ${getPkgName()} dns ls zeit.rocks --next 1584722256178`)}
`);
};

View File

@@ -1,20 +1,18 @@
import chalk from 'chalk';
import ms from 'ms';
import plural from 'pluralize';
import { Output } from '../../util/output';
import { DomainNotFound } from '../../util/errors-ts';
import { ThenArg, DNSRecord, NowContext } from '../../types';
import { DNSRecord, NowContext } from '../../types';
import Client from '../../util/client';
import formatTable from '../../util/format-table';
import getDNSRecords from '../../util/dns/get-dns-records';
import getDNSRecords, {
DomainRecordsItem,
} from '../../util/dns/get-dns-records';
import getDomainDNSRecords from '../../util/dns/get-domain-dns-records';
import getScope from '../../util/get-scope';
import stamp from '../../util/output/stamp';
import getCommandFlags from '../../util/get-command-flags';
import cmd from '../../util/output/cmd';
import { getPkgName } from '../../util/pkg-name';
type DNSRecords = ThenArg<ReturnType<typeof getDNSRecords>>;
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -54,7 +52,7 @@ export default async function ls(
if (args.length > 1) {
output.error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} dns ls [domain]`
`${getCommandName('dns ls [domain]')}`
)}`
);
return 1;
@@ -94,10 +92,8 @@ export default async function ls(
if (pagination && pagination.count === 20) {
const flags = getCommandFlags(opts, ['_', '--next']);
output.log(
`To display the next page run ${cmd(
`${getPkgName()} dns ls ${domainName}${flags} --next ${
pagination.next
}`
`To display the next page run ${getCommandName(
`dns ls ${domainName}${flags} --next ${pagination.next}`
)}`
);
}
@@ -105,18 +101,31 @@ export default async function ls(
return 0;
}
const dnsRecords = await getDNSRecords(output, client, contextName);
const { records: dnsRecords, pagination } = await getDNSRecords(
output,
client,
contextName,
nextTimestamp
);
const nRecords = dnsRecords.reduce((p, r) => r.records.length + p, 0);
output.log(
`${plural('Record', nRecords, true)} found under ${chalk.bold(
`${nRecords > 0 ? 'Records' : 'No records'} found under ${chalk.bold(
contextName
)} ${chalk.gray(lsStamp())}`
);
console.log(getDNSRecordsTable(dnsRecords));
if (pagination && pagination.count === 20) {
const flags = getCommandFlags(opts, ['_', '--next']);
output.log(
`To display the next page run ${getCommandName(
`dns ls${flags} --next ${pagination.next}`
)}`
);
}
return 0;
}
function getDNSRecordsTable(dnsRecords: DNSRecords) {
function getDNSRecordsTable(dnsRecords: DomainRecordsItem[]) {
return formatTable(
['', 'id', 'name', 'type', 'value', 'created'],
['l', 'r', 'l', 'l', 'l', 'l'],
@@ -130,7 +139,7 @@ function getDNSRecordsTable(dnsRecords: DNSRecords) {
function getDNSRecordRow(record: DNSRecord) {
const isSystemRecord = record.creator === 'system';
const createdAt = `${ms(
Date.now() - new Date(Number(record.created)).getTime()
Date.now() - new Date(Number(record.createdAt)).getTime()
)} ago`;
const priority = record.mxPriority || record.priority || null;
return [

View File

@@ -8,7 +8,7 @@ import deleteDNSRecordById from '../../util/dns/delete-dns-record-by-id';
import getDNSRecordById from '../../util/dns/get-dns-record-by-id';
import getScope from '../../util/get-scope';
import stamp from '../../util/output/stamp';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -28,10 +28,9 @@ export default async function rm(
const { apiUrl } = ctx;
const debug = opts['--debug'];
const client = new Client({ apiUrl, token, currentTeam, debug });
let contextName = null;
try {
({ contextName } = await getScope(client));
await getScope(client);
} catch (err) {
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
output.error(err.message);
@@ -45,25 +44,20 @@ export default async function rm(
if (args.length !== 1) {
output.error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} dns rm <id>`
`${getCommandName('dns rm <id>')}`
)}`
);
return 1;
}
const domainRecord = await getDNSRecordById(
output,
client,
contextName,
recordId
);
const record = await getDNSRecordById(client, recordId);
if (!domainRecord) {
if (!record) {
output.error('DNS record not found');
return 1;
}
const { domainName, record } = domainRecord;
const { domain: domainName } = record;
const yes = await readConfirmation(
output,
'The following record will be removed permanently',
@@ -127,7 +121,7 @@ function getDeleteTableRow(domainName: string, record: DNSRecord) {
`${recordName} ${record.type} ${record.value} ${record.mxPriority || ''}`
),
chalk.gray(
`${ms(Date.now() - new Date(Number(record.created)).getTime())} ago`
`${ms(Date.now() - new Date(Number(record.createdAt)).getTime())} ago`
),
];
}

View File

@@ -12,7 +12,7 @@ import formatNSTable from '../../util/format-ns-table';
import getScope from '../../util/get-scope';
import stamp from '../../util/output/stamp';
import param from '../../util/output/param';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName, getTitleName } from '../../util/pkg-name';
type Options = {
'--cdn': boolean;
@@ -48,13 +48,13 @@ export default async function add(
}
if (opts['--cdn'] !== undefined || opts['--no-cdn'] !== undefined) {
output.error(`Toggling CF from ${getPkgName()} CLI is deprecated.`);
output.error(`Toggling CF from ${getTitleName()} CLI is deprecated.`);
return 1;
}
if (args.length !== 1) {
output.error(
`${cmd(`${getPkgName()} domains add <domain>`)} expects one argument`
`${getCommandName('domains add <domain>')} expects one argument`
);
return 1;
}
@@ -76,7 +76,7 @@ export default async function add(
output.error(
`You are adding '${domainName}' as a domain name containing a subdomain part '${subdomain}'\n` +
` This feature is deprecated, please add just the root domain: ${chalk.cyan(
`${getPkgName()} domain add ${domain}`
`${getCommandName(`domain add ${domain}`)}`
)}`
);
return 1;
@@ -142,7 +142,7 @@ export default async function add(
);
output.print(
` If you want to force running a verification, you can run ${cmd(
`${getPkgName()} domains verify <domain>`
`${getCommandName('domains verify <domain>')}`
)}\n`
);
output.print(' Read more: https://err.sh/now/domain-verification\n\n');

View File

@@ -5,7 +5,6 @@ import { NowContext } from '../../types';
import { Output } from '../../util/output';
import * as ERRORS from '../../util/errors-ts';
import Client from '../../util/client';
import cmd from '../../util/output/cmd';
import getDomainPrice from '../../util/domains/get-domain-price';
import getDomainStatus from '../../util/domains/get-domain-status';
import getScope from '../../util/get-scope';
@@ -13,7 +12,7 @@ import param from '../../util/output/param';
import promptBool from '../../util/input/prompt-bool';
import purchaseDomain from '../../util/domains/purchase-domain';
import stamp from '../../util/output/stamp';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -49,7 +48,7 @@ export default async function buy(
const [domainName] = args;
if (!domainName) {
output.error(
`Missing domain name. Run ${cmd(`${getPkgName()} domains --help`)}`
`Missing domain name. Run ${getCommandName(`domains --help`)}`
);
return 1;
}
@@ -63,8 +62,8 @@ export default async function buy(
const { domain: rootDomain, subdomain } = parsedDomain;
if (subdomain || !rootDomain) {
output.error(
`Invalid domain name "${domainName}". Run ${cmd(
`${getPkgName()} domains --help`
`Invalid domain name "${domainName}". Run ${getCommandName(
`domains --help`
)}`
);
return 1;
@@ -121,8 +120,8 @@ export default async function buy(
if (buyResult instanceof ERRORS.SourceNotFound) {
output.error(
`Could not purchase domain. Please add a payment method using ${cmd(
`${getPkgName()} billing add`
`Could not purchase domain. Please add a payment method using ${getCommandName(
`billing add`
)}.`
);
return 1;
@@ -189,8 +188,8 @@ export default async function buy(
);
} else {
output.note(
`You may now use your domain as an alias to your deployments. Run ${cmd(
`${getPkgName()} alias --help`
`You may now use your domain as an alias to your deployments. Run ${getCommandName(
`alias --help`
)}`
);
}

View File

@@ -3,7 +3,6 @@ import { DomainNotFound, DomainPermissionDenied } from '../../util/errors-ts';
import { NowContext } from '../../types';
import { Output } from '../../util/output';
import Client from '../../util/client';
import cmd from '../../util/output/cmd';
import stamp from '../../util/output/stamp';
import dnsTable from '../../util/format-dns-table';
import formatDate from '../../util/format-date';
@@ -11,7 +10,7 @@ import formatNSTable from '../../util/format-ns-table';
import getDomainByName from '../../util/domains/get-domain-by-name';
import getScope from '../../util/get-scope';
import getDomainPrice from '../../util/domains/get-domain-price';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -50,7 +49,7 @@ export default async function inspect(
if (!domainName) {
output.error(
`${cmd(`${getPkgName()} domains inspect <domain>`)} expects one argument`
`${getCommandName(`domains inspect <domain>`)} expects one argument`
);
return 1;
}
@@ -58,7 +57,7 @@ export default async function inspect(
if (args.length !== 1) {
output.error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} domains inspect <domain>`
`${getCommandName('domains inspect <domain>')}`
)}`
);
return 1;
@@ -75,7 +74,7 @@ export default async function inspect(
output.error(
`Domain not found by "${domainName}" under ${chalk.bold(contextName)}`
);
output.log(`Run ${cmd(`${getPkgName()} domains ls`)} to see your domains.`);
output.log(`Run ${getCommandName(`domains ls`)} to see your domains.`);
return 1;
}
@@ -85,7 +84,7 @@ export default async function inspect(
contextName
)}`
);
output.log(`Run ${cmd(`${getPkgName()} domains ls`)} to see your domains.`);
output.log(`Run ${getCommandName(`domains ls`)} to see your domains.`);
return 1;
}
@@ -172,8 +171,8 @@ export default async function inspect(
` We will run a verification for you and you will receive an email upon completion.\n`
);
output.print(
` If you want to force running a verification, you can run ${cmd(
`${getPkgName()} domains verify <domain>`
` If you want to force running a verification, you can run ${getCommandName(
`domains verify <domain>`
)}\n`
);
output.print(' Read more: https://err.sh/now/domain-verification\n\n');

View File

@@ -10,8 +10,7 @@ import strlen from '../../util/strlen';
import { Output } from '../../util/output';
import { Domain, NowContext } from '../../types';
import getCommandFlags from '../../util/get-command-flags';
import cmd from '../../util/output/cmd';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -55,7 +54,7 @@ export default async function ls(
if (args.length !== 0) {
output.error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} domains ls`
`${getCommandName('domains ls')}`
)}`
);
return 1;
@@ -76,8 +75,8 @@ export default async function ls(
if (pagination && pagination.count === 20) {
const flags = getCommandFlags(opts, ['_', '--next']);
output.log(
`To display the next page run ${cmd(
`${getPkgName()} domains ls${flags} --next ${pagination.next}`
`To display the next page run ${getCommandName(
`domains ls${flags} --next ${pagination.next}`
)}`
);
}

View File

@@ -5,7 +5,6 @@ import { NowContext, User, Team } from '../../types';
import { Output } from '../../util/output';
import * as ERRORS from '../../util/errors-ts';
import Client from '../../util/client';
import cmd from '../../util/output/cmd';
import getScope from '../../util/get-scope';
import withSpinner from '../../util/with-spinner';
import moveOutDomain from '../../util/domains/move-out-domain';
@@ -16,7 +15,7 @@ import getDomainAliases from '../../util/alias/get-domain-aliases';
import getDomainByName from '../../util/domains/get-domain-by-name';
import promptBool from '../../util/input/prompt-bool';
import getTeams from '../../util/get-teams';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -54,8 +53,8 @@ export default async function move(
const { domainName, destination } = await getArgs(args);
if (!isRootDomain(domainName)) {
output.error(
`Invalid domain name "${domainName}". Run ${cmd(
`${getPkgName()} domains --help`
`Invalid domain name "${domainName}". Run ${getCommandName(
`domains --help`
)}`
);
return 1;
@@ -64,7 +63,7 @@ export default async function move(
const domain = await getDomainByName(client, contextName, domainName);
if (domain instanceof ERRORS.DomainNotFound) {
output.error(`Domain not found under ${chalk.bold(contextName)}`);
output.log(`Run ${cmd(`${getPkgName()} domains ls`)} to see your domains.`);
output.log(`Run ${getCommandName(`domains ls`)} to see your domains.`);
return 1;
}
if (domain instanceof ERRORS.DomainPermissionDenied) {
@@ -103,9 +102,7 @@ export default async function move(
output.warn(
`This domain's ${chalk.bold(
plural('alias', aliases.length, true)
)} will be removed. Run ${chalk.dim(
`${getPkgName()} alias ls`
)} to list them.`
)} will be removed. Run ${getCommandName(`alias ls`)} to list them.`
);
if (
!(await promptBool(
@@ -145,7 +142,7 @@ export default async function move(
}
if (moveTokenResult instanceof ERRORS.DomainNotFound) {
output.error(`Domain not found under ${chalk.bold(contextName)}`);
output.log(`Run ${cmd(`${getPkgName()} domains ls`)} to see your domains.`);
output.log(`Run ${getCommandName(`domains ls`)} to see your domains.`);
return 1;
}
if (moveTokenResult instanceof ERRORS.DomainPermissionDenied) {

View File

@@ -5,7 +5,6 @@ import { DomainNotFound, DomainPermissionDenied } from '../../util/errors-ts';
import { NowContext, Domain } from '../../types';
import { Output } from '../../util/output';
import Client from '../../util/client';
import cmd from '../../util/output/cmd';
import deleteCertById from '../../util/certs/delete-cert-by-id';
import getDomainByName from '../../util/domains/get-domain-by-name';
import getScope from '../../util/get-scope';
@@ -16,7 +15,7 @@ import * as ERRORS from '../../util/errors-ts';
import param from '../../util/output/param';
import promptBool from '../../util/input/prompt-bool';
import setCustomSuffix from '../../util/domains/set-custom-suffix';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -53,7 +52,7 @@ export default async function rm(
if (!domainName) {
output.error(
`${cmd(`${getPkgName()} domains rm <domain>`)} expects one argument`
`${getCommandName(`domains rm <domain>`)} expects one argument`
);
return 1;
}
@@ -61,7 +60,7 @@ export default async function rm(
if (args.length !== 1) {
output.error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} domains rm <domain>`
`${getCommandName('domains rm <domain>')}`
)}`
);
return 1;
@@ -72,7 +71,7 @@ export default async function rm(
output.error(
`Domain not found by "${domainName}" under ${chalk.bold(contextName)}`
);
output.log(`Run ${cmd(`${getPkgName()} domains ls`)} to see your domains.`);
output.log(`Run ${getCommandName(`domains ls`)} to see your domains.`);
return 1;
}
@@ -82,7 +81,7 @@ export default async function rm(
contextName
)}`
);
output.log(`Run ${cmd(`${getPkgName()} domains ls`)} to see your domains.`);
output.log(`Run ${getCommandName(`domains ls`)} to see your domains.`);
return 1;
}
@@ -149,7 +148,7 @@ async function removeDomain(
if (removeResult instanceof ERRORS.DomainNotFound) {
output.error(`Domain not found under ${chalk.bold(contextName)}`);
output.log(`Run ${cmd(`${getPkgName()} domains ls`)} to see your domains.`);
output.log(`Run ${getCommandName(`domains ls`)} to see your domains.`);
return 1;
}
@@ -207,9 +206,7 @@ async function removeDomain(
output.warn(
`This domain's ${chalk.bold(
plural('alias', aliases.length, true)
)} will be removed. Run ${chalk.dim(
`${getPkgName()} alias ls`
)} to list them.`
)} will be removed. Run ${getCommandName(`alias ls`)} to list them.`
);
}
@@ -217,9 +214,7 @@ async function removeDomain(
output.warn(
`This domain's ${chalk.bold(
plural('certificate', certs.length, true)
)} will be removed. Run ${chalk.dim(
`${getPkgName()} cert ls`
)} to list them.`
)} will be removed. Run ${getCommandName(`cert ls`)} to list them.`
);
}

View File

@@ -4,7 +4,6 @@ import { NowContext } from '../../types';
import { Output } from '../../util/output';
import * as ERRORS from '../../util/errors-ts';
import Client from '../../util/client';
import cmd from '../../util/output/cmd';
import getScope from '../../util/get-scope';
import param from '../../util/output/param';
import transferInDomain from '../../util/domains/transfer-in-domain';
@@ -15,7 +14,7 @@ import getDomainPrice from '../../util/domains/get-domain-price';
import checkTransfer from '../../util/domains/check-transfer';
import promptBool from '../../util/input/prompt-bool';
import isRootDomain from '../../util/is-root-domain';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -52,15 +51,15 @@ export default async function transferIn(
const [domainName] = args;
if (!domainName) {
output.error(
`Missing domain name. Run ${cmd(`${getPkgName()} domains --help`)}`
`Missing domain name. Run ${getCommandName(`domains --help`)}`
);
return 1;
}
if (!isRootDomain(domainName)) {
output.error(
`Invalid domain name ${param(domainName)}. Run ${cmd(
`${getPkgName()} domains --help`
`Invalid domain name ${param(domainName)}. Run ${getCommandName(
`domains --help`
)}`
);
return 1;
@@ -130,8 +129,8 @@ export default async function transferIn(
if (transferInResult instanceof ERRORS.SourceNotFound) {
output.error(
`Could not purchase domain. Please add a payment method using ${cmd(
`${getPkgName()} billing add`
`Could not purchase domain. Please add a payment method using ${getCommandName(
`billing add`
)}.`
);
return 1;
@@ -161,7 +160,7 @@ export default async function transferIn(
);
output.print(` Then import it to Vercel DNS by using:\n`);
output.print(
` ${cmd(`${getPkgName()} dns import ${domainName} <zonefile>`)}\n\n`
` ${getCommandName(`dns import ${domainName} <zonefile>`)}\n\n`
);
return 0;
}

View File

@@ -3,14 +3,13 @@ import { NowContext } from '../../types';
import { Output } from '../../util/output';
import * as ERRORS from '../../util/errors-ts';
import Client from '../../util/client';
import cmd from '../../util/output/cmd';
import formatDnsTable from '../../util/format-dns-table';
import formatNSTable from '../../util/format-ns-table';
import getDomainByName from '../../util/domains/get-domain-by-name';
import getScope from '../../util/get-scope';
import stamp from '../../util/output/stamp';
import verifyDomain from '../../util/domains/verify-domain';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -48,7 +47,7 @@ export default async function verify(
if (!domainName) {
output.error(
`${cmd(`${getPkgName()} domains verify <domain>`)} expects one argument`
`${getCommandName(`domains verify <domain>`)} expects one argument`
);
return 1;
}
@@ -56,7 +55,7 @@ export default async function verify(
if (args.length !== 1) {
output.error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} domains verify <domain>`
`${getCommandName('domains verify <domain>')}`
)}`
);
return 1;
@@ -67,7 +66,7 @@ export default async function verify(
output.error(
`Domain not found by "${domainName}" under ${chalk.bold(contextName)}`
);
output.log(`Run ${cmd(`${getPkgName()} domains ls`)} to see your domains.`);
output.log(`Run ${getCommandName(`domains ls`)} to see your domains.`);
return 1;
}
@@ -77,7 +76,7 @@ export default async function verify(
contextName
)}`
);
output.log(`Run ${cmd(`${getPkgName()} domains ls`)} to see your domains.`);
output.log(`Run ${getCommandName(`domains ls`)} to see your domains.`);
return 1;
}
@@ -114,8 +113,8 @@ export default async function verify(
)}\n\n`
);
output.print(
` Once your domain uses either the nameservers or the TXT DNS record from above, run again ${cmd(
`${getPkgName()} domains verify <domain>`
` Once your domain uses either the nameservers or the TXT DNS record from above, run again ${getCommandName(
`domains verify <domain>`
)}.\n`
);
output.print(
@@ -140,8 +139,8 @@ export default async function verify(
)} was verified using DNS TXT record. ${verifyStamp()}`
);
output.print(
` You can verify with nameservers too. Run ${cmd(
`${getPkgName()} domains inspect ${domain.name}`
` You can verify with nameservers too. Run ${getCommandName(
`domains inspect ${domain.name}`
)} to find out the intended set.\n`
);
return 0;

View File

@@ -12,12 +12,11 @@ import {
getEnvTargetChoices,
} from '../../util/env/env-target';
import readStandardInput from '../../util/input/read-standard-input';
import cmd from '../../util/output/cmd';
import param from '../../util/output/param';
import withSpinner from '../../util/with-spinner';
import { emoji, prependEmoji } from '../../util/emoji';
import { isKnownError } from '../../util/env/known-error';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -35,8 +34,8 @@ export default async function add(
if (args.length > 2) {
output.error(
`Invalid number of arguments. Usage: ${cmd(
`${getPkgName()} env add <name> ${getEnvTargetPlaceholder()}`
`Invalid number of arguments. Usage: ${getCommandName(
`env add <name> ${getEnvTargetPlaceholder()}`
)}`
);
return 1;
@@ -44,8 +43,8 @@ export default async function add(
if (stdInput && (!envName || !envTarget)) {
output.error(
`Invalid number of arguments. Usage: ${cmd(
`${getPkgName()} env add <name> <target> < <file>`
`Invalid number of arguments. Usage: ${getCommandName(
`env add <name> <target> < <file>`
)}`
);
return 1;
@@ -88,8 +87,8 @@ export default async function add(
output.error(
`The variable ${param(
envName
)} has already been added to all Environments. To remove, run ${cmd(
`${getPkgName()} env rm ${envName}`
)} has already been added to all Environments. To remove, run ${getCommandName(
`env rm ${envName}`
)}.`
);
return 1;

View File

@@ -10,10 +10,9 @@ import {
getEnvTargetPlaceholder,
} from '../../util/env/env-target';
import stamp from '../../util/output/stamp';
import cmd from '../../util/output/cmd';
import param from '../../util/output/param';
import getCommandFlags from '../../util/get-command-flags';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -31,8 +30,8 @@ export default async function ls(
if (args.length > 1) {
output.error(
`Invalid number of arguments. Usage: ${cmd(
`${getPkgName()} env ls ${getEnvTargetPlaceholder()}`
`Invalid number of arguments. Usage: ${getCommandName(
`env ls ${getEnvTargetPlaceholder()}`
)}`
);
return 1;
@@ -75,8 +74,8 @@ export default async function ls(
if (pagination && pagination.count === 20) {
const flags = getCommandFlags(opts, ['_', '--next']);
output.log(
`To display the next page run ${cmd(
`${getPkgName()} env ls${flags} --next ${pagination.next}`
`To display the next page run ${getCommandName(
`env ls${flags} --next ${pagination.next}`
)}`
);
}

View File

@@ -6,13 +6,12 @@ import Client from '../../util/client';
import stamp from '../../util/output/stamp';
import getEnvVariables from '../../util/env/get-env-records';
import getDecryptedSecret from '../../util/env/get-decrypted-secret';
import cmd from '../../util/output/cmd';
import param from '../../util/output/param';
import withSpinner from '../../util/with-spinner';
import { join } from 'path';
import { promises, existsSync } from 'fs';
import { emoji, prependEmoji } from '../../util/emoji';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
const { writeFile } = promises;
type Options = {
@@ -29,9 +28,7 @@ export default async function pull(
) {
if (args.length > 1) {
output.error(
`Invalid number of arguments. Usage: ${cmd(
`${getPkgName()} env pull <file>`
)}`
`Invalid number of arguments. Usage: ${getCommandName(`env pull <file>`)}`
);
return 1;
}

View File

@@ -12,12 +12,11 @@ import {
} from '../../util/env/env-target';
import Client from '../../util/client';
import stamp from '../../util/output/stamp';
import cmd from '../../util/output/cmd';
import param from '../../util/output/param';
import withSpinner from '../../util/with-spinner';
import { emoji, prependEmoji } from '../../util/emoji';
import { isKnownError } from '../../util/env/known-error';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -33,8 +32,8 @@ export default async function rm(
) {
if (args.length > 2) {
output.error(
`Invalid number of arguments. Usage: ${cmd(
`${getPkgName()} env rm <name> ${getEnvTargetPlaceholder()}`
`Invalid number of arguments. Usage: ${getCommandName(
`env rm <name> ${getEnvTargetPlaceholder()}`
)}`
);
return 1;

View File

@@ -15,7 +15,7 @@ import success from '../../util/output/success';
import info from '../../util/output/info';
import cmd from '../../util/output/cmd';
import didYouMean from '../../util/init/did-you-mean';
import { getPkgName } from '../../util/pkg-name';
import { getCommandName } from '../../util/pkg-name';
type Options = {
'--debug': boolean;
@@ -153,11 +153,11 @@ async function extractExample(
const folderRel = path.relative(process.cwd(), folder);
const deployHint =
folderRel === ''
? listItem(`To deploy, run ${cmd(getPkgName())}.`)
? listItem(`To deploy, run ${getCommandName()}.`)
: listItem(
`To deploy, ${cmd(`cd ${folderRel}`)} and run ${cmd(
getPkgName()
)}.`
`To deploy, ${cmd(
`cd ${folderRel}`
)} and run ${getCommandName()}.`
);
console.log(success(`${successLog}\n${deployHint}`));
return 0;
@@ -207,8 +207,8 @@ function prepareFolder(cwd: string, folder: string, force?: boolean) {
*/
async function guess(exampleList: string[], name: string) {
const GuessError = new Error(
`No example found for ${chalk.bold(name)}, run ${cmd(
`${getPkgName()} init`
`No example found for ${chalk.bold(name)}, run ${getCommandName(
`init`
)} to see the list of available examples.`
);

View File

@@ -4,7 +4,6 @@ import getArgs from '../util/get-args';
import buildsList from '../util/output/builds';
import routesList from '../util/output/routes';
import indent from '../util/output/indent';
import cmd from '../util/output/cmd.ts';
import createOutput from '../util/output';
import Now from '../util';
import logo from '../util/output/logo';
@@ -13,7 +12,7 @@ import { handleError } from '../util/error';
import strlen from '../util/strlen.ts';
import Client from '../util/client.ts';
import getScope from '../util/get-scope.ts';
import { getPkgName } from '../util/pkg-name.ts';
import { getPkgName, getCommandName } from '../util/pkg-name.ts';
const STATIC = 'STATIC';
@@ -74,9 +73,7 @@ export default async function main(ctx) {
id = argv._[1];
if (argv._.length !== 2) {
error(
`${cmd(`${getPkgName()} inspect <url>`)} expects exactly one argument`
);
error(`${getCommandName('inspect <url>')} expects exactly one argument`);
help();
return 1;
}

View File

@@ -18,7 +18,7 @@ import toHost from '../util/to-host';
import parseMeta from '../util/parse-meta';
import { isValidName } from '../util/is-valid-name';
import getCommandFlags from '../util/get-command-flags';
import { getPkgName } from '../util/pkg-name.ts';
import { getPkgName, getCommandName } from '../util/pkg-name.ts';
const help = () => {
console.log(`
@@ -98,7 +98,7 @@ export default async function main(ctx) {
});
if (argv._.length > 2) {
error(`${cmd(`${getPkgName()} ls [app]`)} accepts at most one argument`);
error(`${getCommandName('ls [app]')} accepts at most one argument`);
return 1;
}
@@ -163,12 +163,14 @@ 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`
`We suggest using ${getCommandName(
'inspect <deployment>'
)} for retrieving details about a single deployment`
);
const asHost = toHost(app);
const hostParts = asHost.split('-');
if (hostParts < 2) {
@@ -234,9 +236,7 @@ export default async function main(ctx) {
now.close();
stopSpinner();
log(`Found matching path alias: ${chalk.cyan(item.alias)}`);
log(
`Please run ${cmd(`${getPkgName()} alias ls ${item.alias}`)} instead`
);
log(`Please run ${getCommandName(`alias ls ${item.alias}`)} instead`);
return 0;
}
@@ -287,13 +287,13 @@ export default async function main(ctx) {
if (app == null) {
log(
`To list more deployments for a project run ${cmd(
`${getPkgName()} ls [project]`
`${getCommandName('ls [project]')}`
)}`
);
} else if (!argv['--all']) {
log(
`To list deployment instances run ${cmd(
`${getPkgName()} ls --all [project]`
`${getCommandName('ls --all [project]')}`
)}`
);
}
@@ -348,10 +348,8 @@ export default async function main(ctx) {
if (pagination && pagination.count === 20) {
const flags = getCommandFlags(argv, ['_', '--next']);
log(
`To display the next page run ${cmd(
`${getPkgName()} ls${app ? ' ' + app : ''}${flags} --next ${
pagination.next
}`
`To display the next page run ${getCommandName(
`ls${app ? ' ' + app : ''}${flags} --next ${pagination.next}`
)}`
);
}

View File

@@ -10,7 +10,6 @@ import getArgs from '../util/get-args';
import error from '../util/output/error';
import highlight from '../util/output/highlight';
import ok from '../util/output/ok';
import cmd from '../util/output/cmd.ts';
import param from '../util/output/param.ts';
import eraseLines from '../util/output/erase-lines';
import sleep from '../util/sleep';
@@ -115,8 +114,8 @@ const readEmail = async () => {
if (err.message === 'stdin lacks setRawMode support') {
throw new Error(
error(
`Interactive mode not supported please run ${cmd(
`${getPkgName()} login you@domain.com`
`Interactive mode not supported please run ${getCommandName(
`login you@domain.com`
)}`
)
);

View File

@@ -10,10 +10,9 @@ import logo from '../util/output/logo';
import getScope from '../util/get-scope';
import createOutput from '../util/output';
import getCommandFlags from '../util/get-command-flags';
import cmd from '../util/output/cmd.ts';
import wait from '../util/output/wait';
import getPrefixedFlags from '../util/get-prefixed-flags';
import { getPkgName } from '../util/pkg-name.ts';
import { getPkgName, getCommandName } from '../util/pkg-name.ts';
const e = encodeURIComponent;
@@ -123,7 +122,7 @@ async function run({ client, contextName }) {
console.error(
error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} projects ls`
`${getCommandName('projects ls')}`
)}`
)
);
@@ -184,10 +183,8 @@ async function run({ client, contextName }) {
'-d',
'-y',
]);
const nextCmd = `${getPkgName()} projects ls${flags} --next ${
pagination.next
}`;
console.log(`To display the next page run ${cmd(nextCmd)}`);
const nextCmd = `projects ls${flags} --next ${pagination.next}`;
console.log(`To display the next page run ${getCommandName(nextCmd)}`);
}
}
return;
@@ -198,7 +195,7 @@ async function run({ client, contextName }) {
console.error(
error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} project rm <name>`
`${getCommandName('project rm <name>')}`
)}`
)
);
@@ -240,14 +237,14 @@ async function run({ client, contextName }) {
console.error(
error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} projects add <name>`
`${getCommandName('projects add <name>')}`
)}`
)
);
if (args.length > 1) {
const example = chalk.cyan(
`$ ${getPkgName()} projects add "${args.join(' ')}"`
`${getCommandName(`projects add "${args.join(' ')}"`)}`
);
console.log(
`> If your project name has spaces, make sure to wrap it in quotes. Example: \n ${example} `

View File

@@ -7,7 +7,6 @@ import Now from '../util';
import getAliases from '../util/alias/get-aliases';
import createOutput from '../util/output';
import logo from '../util/output/logo';
import cmd from '../util/output/cmd.ts';
import elapsed from '../util/output/elapsed.ts';
import { normalizeURL } from '../util/url';
import Client from '../util/client.ts';
@@ -18,7 +17,7 @@ import removeProject from '../util/projects/remove-project';
import getProjectByIdOrName from '../util/projects/get-project-by-id-or-name';
import getDeploymentByIdOrHost from '../util/deploy/get-deployment-by-id-or-host';
import getDeploymentsByProjectId from '../util/deploy/get-deployments-by-project-id';
import { getPkgName } from '../util/pkg-name.ts';
import { getPkgName, getCommandName } from '../util/pkg-name.ts';
const help = () => {
console.log(`
@@ -94,7 +93,7 @@ export default async function main(ctx) {
}
if (ids.length < 1) {
error(`${cmd(`${getPkgName()} rm`)} expects at least one argument`);
error(`${getCommandName('rm')} expects at least one argument`);
help();
return 1;
}
@@ -215,9 +214,9 @@ export default async function main(ctx) {
log(
`Could not find ${argv.safe ? 'unaliased' : 'any'} deployments ` +
`or projects matching ` +
`${ids.map(id => chalk.bold(`"${id}"`)).join(', ')}. Run ${cmd(
`${getPkgName()} ls`
)} to list.`
`${ids
.map(id => chalk.bold(`"${id}"`))
.join(', ')}. Run ${getCommandName('ls')} to list.`
);
client.close();
return 1;

View File

@@ -12,9 +12,8 @@ import getScope from '../util/get-scope.ts';
import createOutput from '../util/output';
import confirm from '../util/input/confirm';
import getCommandFlags from '../util/get-command-flags';
import cmd from '../util/output/cmd.ts';
import getPrefixedFlags from '../util/get-prefixed-flags';
import { getPkgName } from '../util/pkg-name.ts';
import { getPkgName, getCommandName } from '../util/pkg-name.ts';
const help = () => {
console.log(`
@@ -149,7 +148,7 @@ async function run({ output, token, contextName, currentTeam, ctx }) {
console.error(
error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} secret ls`
`${getCommandName('secret ls')}`
)}`
)
);
@@ -197,10 +196,8 @@ async function run({ output, token, contextName, currentTeam, ctx }) {
'-d',
'-y',
]);
const nextCmd = `${getPkgName()} secrets ${subcommand}${flags} --next ${
pagination.next
}`;
output.log(`To display the next page run ${cmd(nextCmd)}`);
const nextCmd = `secrets ${subcommand}${flags} --next ${pagination.next}`;
output.log(`To display the next page run ${getCommandName(nextCmd)}`);
}
return secrets.close();
}
@@ -210,7 +207,7 @@ async function run({ output, token, contextName, currentTeam, ctx }) {
console.error(
error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} secret rm <name>`
`${getCommandName('secret rm <name>')}`
)}`
)
);
@@ -252,7 +249,7 @@ async function run({ output, token, contextName, currentTeam, ctx }) {
console.error(
error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} secret rename <old-name> <new-name>`
`${getCommandName('secret rename <old-name> <new-name>')}`
)}`
)
);
@@ -275,14 +272,14 @@ async function run({ output, token, contextName, currentTeam, ctx }) {
console.error(
error(
`Invalid number of arguments. Usage: ${chalk.cyan(
`${getPkgName()} secret add <name> <value>`
`${getCommandName('secret add <name> <value>')}`
)}`
)
);
if (args.length > 2) {
const example = chalk.cyan(
`$ ${getPkgName()} secret add -- "${args[0]}"`
`$ ${getCommandName('secret add -- "${args[0]}"')}`
);
console.log(
`If your secret has spaces or starts with '-', make sure to terminate command options with double dash and wrap it in quotes. Example: \n ${example} `
@@ -307,7 +304,9 @@ async function run({ output, token, contextName, currentTeam, ctx }) {
}
if (typeof value === 'boolean') {
const example = chalk.cyan(`$ ${getPkgName()} secret add -- "${name}"`);
const example = chalk.cyan(
`$ ${getCommandName('secret add -- "${name}"')}`
);
console.log(
`If your secret starts with '-', make sure to terminate command options with double dash and wrap it in quotes. Example: \n ${example} `
);

View File

@@ -32,6 +32,7 @@ const help = () => {
'DIR'
)} Path to the global ${'`.vercel`'} directory
-d, --debug Debug mode [off]
-N, --next Show next page of results
${chalk.dim('Examples:')}
@@ -51,6 +52,12 @@ const help = () => {
${chalk.gray('')} Invite new members (interactively)
${chalk.cyan(`$ ${getPkgName()} teams invite`)}
${chalk.gray('')} Paginate results, where ${chalk.dim(
'`1584722256178`'
)} is the time in milliseconds since the UNIX epoch.
${chalk.cyan(`$ ${getPkgName()} teams ls --next 1584722256178`)}
`);
};
@@ -66,6 +73,7 @@ const main = async ctx => {
help: 'h',
debug: 'd',
switch: 'change',
next: 'N',
},
});
@@ -118,6 +126,7 @@ async function run({ token, config }) {
config,
apiUrl,
token,
argv,
});
break;
}

View File

@@ -7,12 +7,11 @@ import rightPad from '../../util/output/right-pad';
import eraseLines from '../../util/output/erase-lines';
import chars from '../../util/output/chars';
import success from '../../util/output/success';
import cmd from '../../util/output/cmd.ts';
import note from '../../util/output/note';
import textInput from '../../util/input/text';
import invite from './invite';
import { writeToConfigFile } from '../../util/config/files';
import { getPkgName } from '../../util/pkg-name.ts';
import { getPkgName, getCommandName } from '../../util/pkg-name.ts';
const validateSlugKeypress = (data, value) =>
// TODO: the `value` here should contain the current value + the keypress
@@ -27,8 +26,8 @@ const validateNameKeypress = (data, value) =>
const gracefulExit = () => {
console.log(); // Blank line
note(
`Your team is now active for all ${getPkgName()} commands!\n Run ${cmd(
`${getPkgName()} switch`
`Your team is now active for all ${getPkgName()} commands!\n Run ${getCommandName(
`switch`
)} to change it in the future.`
);
return 0;
@@ -152,8 +151,8 @@ export default async function({ apiUrl, token, teams, config }) {
apiUrl,
config,
introMsg: 'Invite your teammates! When done, press enter on an empty field',
noopMsg: `You can invite teammates later by running ${cmd(
`${getPkgName()} teams invite`
noopMsg: `You can invite teammates later by running ${getCommandName(
`teams invite`
)}`,
});

View File

@@ -14,7 +14,7 @@ import eraseLines from '../../util/output/erase-lines';
import success from '../../util/output/success';
import getUser from '../../util/get-user.ts';
import Client from '../../util/client.ts';
import { getPkgName } from '../../util/pkg-name.ts';
import { getCommandName } from '../../util/pkg-name.ts';
const validateEmail = data => regexEmail.test(data.trim()) || data.length === 0;
@@ -97,8 +97,8 @@ export default async function({
// We specifically need a team scope here
let err = `You can't run this command under ${param(
user.username || user.email
)}.\nPlease select a team scope using ${cmd(
`${getPkgName()} switch`
)}.\nPlease select a team scope using ${getCommandName(
`switch`
)} or use ${cmd('--scope')}`;
return fatalError(err);
}

View File

@@ -8,12 +8,28 @@ import info from '../../util/output/info';
import error from '../../util/output/error';
import chars from '../../util/output/chars';
import table from '../../util/output/table';
import createOutput from '../../util/output';
import getUser from '../../util/get-user.ts';
import Client from '../../util/client.ts';
import getPrefixedFlags from '../../util/get-prefixed-flags';
import { getPkgName } from '../../util/pkg-name.ts';
import getCommandFlags from '../../util/get-command-flags';
import cmd from '../../util/output/cmd.ts';
export default async function({ teams, config, apiUrl, token, argv }) {
const { next } = argv;
const output = createOutput({ debug: argv['--debug'] });
if (typeof next !== 'undefined' && !Number.isInteger(next)) {
output.error('Please provide a number for flag --next');
return 1;
}
export default async function({ teams, config, apiUrl, token }) {
const stopSpinner = wait('Fetching teams');
const list = (await teams.ls()).teams;
const { teams: list, pagination } = await teams.ls({
next,
apiVersion: 2,
});
let { currentTeam } = config;
const accountIsCurrent = !currentTeam;
@@ -78,4 +94,14 @@ export default async function({ teams, config, apiUrl, token }) {
teamList.map(team => [team.current, team.value, team.name]),
[1, 5]
);
if (pagination && pagination.count === 20) {
const prefixedArgs = getPrefixedFlags(argv);
const flags = getCommandFlags(prefixedArgs, ['_', '--next', '-N', '-d']);
const nextCmd = `${getPkgName()} teams ls${flags} --next ${
pagination.next
}`;
console.log(); // empty line
output.log(`To display the next page run ${cmd(nextCmd)}`);
}
}

View File

@@ -7,7 +7,7 @@ import getArgs from '../util/get-args';
import { NowContext } from '../types';
import createOutput from '../util/output';
import getUpdateCommand from '../util/get-update-command';
import { getPkgName } from '../util/pkg-name';
import { getPkgName, getTitleName } from '../util/pkg-name';
const help = () => {
console.log(`
@@ -27,7 +27,7 @@ const help = () => {
${chalk.dim('Examples:')}
${chalk.gray('')} Update ${getPkgName()} CLI to the latest "canary" version
${chalk.gray('')} Update ${getTitleName()} CLI to the latest "canary" version
${chalk.cyan(`$ ${getPkgName()} update --channel=canary`)}
`);
@@ -58,7 +58,9 @@ export default async function main(ctx: NowContext): Promise<number> {
const debugEnabled = argv['--debug'];
const output = createOutput({ debug: debugEnabled });
output.log(
`Please run ${cmd(await getUpdateCommand())} to update ${getPkgName()} CLI`
`Please run ${cmd(
await getUpdateCommand()
)} to update ${getTitleName()} CLI`
);
return 0;
}

View File

@@ -48,7 +48,7 @@ import { NowError } from './util/now-error';
import { SENTRY_DSN } from './util/constants.ts';
import getUpdateCommand from './util/get-update-command';
import { metrics, shouldCollectMetrics } from './util/metrics.ts';
import { getPkgName } from './util/pkg-name.ts';
import { getCommandName, getTitleName } from './util/pkg-name.ts';
const VERCEL_DIR = getGlobalPathConfig();
const VERCEL_CONFIG_PATH = configFiles.getConfigFilePath();
@@ -151,7 +151,7 @@ const main = async argv_ => {
`${chalk.bgRed('UPDATE AVAILABLE')} ` +
`Run ${cmd(
await getUpdateCommand()
)} to install ${getPkgName()} CLI ${update.latest}`
)} to install ${getTitleName()} CLI ${update.latest}`
)
);
@@ -164,7 +164,7 @@ const main = async argv_ => {
output.print(
`${chalk.grey(
`${getPkgName()} CLI ${pkg.version}${
`${getTitleName()} CLI ${pkg.version}${
targetOrSubcommand === 'dev' ? ' dev (beta)' : ''
}${
pkg.version.includes('canary') || targetOrSubcommand === 'dev'
@@ -322,7 +322,9 @@ const main = async argv_ => {
console.error(
error(
`The content of "${hp(VERCEL_AUTH_CONFIG_PATH)}" is invalid. ` +
`No \`token\` property found inside. Run \`${getPkgName()} login\` to authorize.`
`No \`token\` property found inside. Run ${getCommandName(
'login'
)} to authorize.`
)
);
return 1;
@@ -464,7 +466,7 @@ const main = async argv_ => {
error({
message:
'No existing credentials found. Please run ' +
`${param(`${getPkgName()} login`)} or pass ${param('--token')}`,
`${getCommandName('login')} or pass ${param('--token')}`,
slug: 'no-credentials-found',
})
);

View File

@@ -187,6 +187,9 @@ export type DNSRecord = {
value: string;
created: number;
updated: number;
createdAt: number;
updatedAt: number;
domain: string;
};
type SRVRecordData = {

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

@@ -32,8 +32,8 @@ const getGlobalPathConfig = (): string => {
const possibleConfigPaths = [
...vercelDirectories, // latest vercel directory
...XDGAppPaths('now').dataDirs(), // legacy now directory
path.join(homedir(), '.now'), // legacy config in user's home directory.
path.join(homedir(), '.now'), // legacy config in user's home directory
...XDGAppPaths('now').dataDirs(), // legacy XDG directory
];
// The customPath flag is the preferred location,

View File

@@ -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

@@ -8,8 +8,8 @@ import { extract } from 'tar-fs';
import { createHash } from 'crypto';
import { createGunzip } from 'zlib';
import { join } from 'path';
import { PackageJson } from '@vercel/build-utils';
import XDGAppPaths from 'xdg-app-paths';
import { PackageJson, isStaticRuntime } from '@vercel/build-utils';
import {
createReadStream,
mkdirp,
@@ -322,7 +322,7 @@ export async function updateBuilders(
'--exact',
'--no-lockfile',
'--non-interactive',
...packages.filter(p => p !== '@now/static'),
...packages.filter(p => !isStaticRuntime(p)),
],
{
cwd: builderDir,

View File

@@ -12,12 +12,12 @@ import {
Lambda,
FileBlob,
FileFsRef,
isOfficialRuntime,
} from '@vercel/build-utils';
import plural from 'pluralize';
import minimatch from 'minimatch';
import _treeKill from 'tree-kill';
import { isOfficialRuntime } from '../is-official-runtime';
import { Output } from '../output';
import highlight from '../output/highlight';
import { relative } from '../path-helpers';
@@ -39,6 +39,7 @@ import {
} from './types';
import { normalizeRoutes } from '@vercel/routing-utils';
import getUpdateCommand from '../get-update-command';
import { getVercelDirectory } from '../projects/link';
interface BuildMessage {
type: string;
@@ -75,6 +76,7 @@ async function createBuildProcess(
PATH,
...envConfigs.allEnv,
NOW_REGION: 'dev1',
VERCEL_REGION: 'dev1',
};
const buildProcess = fork(modulePath, [], {
@@ -147,6 +149,9 @@ export async function executeBuild(
);
}
const vercelDir = getVercelDirectory(workPath);
const devCacheDir = join(vercelDir, 'cache');
const buildParams: BuilderParams = {
files,
entrypoint,
@@ -155,6 +160,7 @@ export async function executeBuild(
meta: {
isDev: true,
requestPath,
devCacheDir,
filesChanged,
filesRemoved,
// This env distiniction is only necessary to maintain
@@ -374,6 +380,7 @@ export async function executeBuild(
...asset.environment,
...envConfigs.runEnv,
NOW_REGION: 'dev1',
VERCEL_REGION: 'dev1',
},
},
});

View File

@@ -32,6 +32,7 @@ import {
detectApiDirectory,
detectApiExtensions,
spawnCommand,
isOfficialRuntime,
} from '@vercel/build-utils';
import { once } from '../once';
@@ -41,7 +42,6 @@ import { relative } from '../path-helpers';
import { getDistTag } from '../get-dist-tag';
import getNowConfigPath from '../config/local-path';
import { MissingDotenvVarsError } from '../errors-ts';
import { isOfficialRuntime } from '../is-official-runtime';
import { version as cliVersion } from '../../../package.json';
import { staticFiles as getFiles, getAllProjectFiles } from '../get-files';
import {
@@ -1696,6 +1696,7 @@ export default class DevServer {
...process.env,
...this.envConfigs.allEnv,
NOW_REGION: 'dev1',
VERCEL_REGION: 'dev1',
PORT: `${port}`,
};

View File

@@ -8,6 +8,7 @@ import {
Lambda,
PackageJson,
Config,
Meta,
} from '@vercel/build-utils';
import { NowConfig } from '@vercel/client';
import { HandleValue, Route } from '@vercel/routing-utils';
@@ -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

@@ -1,25 +1,9 @@
import getDNSRecords from './get-dns-records';
import { DNSRecord } from '../../types';
import { Output } from '../output';
import Client from '../client';
type Result = {
domainName: string,
record: DNSRecord
}
export default async function getDNSRecordById(
output: Output,
client: Client,
contextName: string,
id: string
): Promise<Result | null> {
const recordsByDomains = await getDNSRecords(output, client, contextName);
return recordsByDomains.reduce((result: Result | null, { domainName, records }) => {
if (result) {
return result;
}
const record = records.find(record => record.id === id);
return record ? { domainName, record } : null;
}, null);
): Promise<DNSRecord> {
return client.fetch<DNSRecord>(`/v5/domains/records/${id}`);
}

View File

@@ -5,7 +5,7 @@ import Client from '../client';
import getDomainDNSRecords from './get-domain-dns-records';
import getDomains from '../domains/get-domains';
type DomainRecordsItem = {
export type DomainRecordsItem = {
domainName: string;
records: DNSRecord[];
};
@@ -13,16 +13,24 @@ type DomainRecordsItem = {
export default async function getDNSRecords(
output: Output,
client: Client,
contextName: string
contextName: string,
next?: number
) {
const domainNames = await getDomainNames(client, contextName);
const { domainNames, pagination } = await getDomainNames(
client,
contextName,
next
);
const domainsRecords = await Promise.all(
domainNames.map(createGetDomainRecords(output, client))
);
const onlyRecords = domainsRecords.map(item =>
item instanceof DomainNotFound ? [] : item
) as DNSRecord[][];
return onlyRecords.reduce(getAddDomainName(domainNames), []);
return {
records: onlyRecords.reduce(getAddDomainName(domainNames), []),
pagination,
};
}
function createGetDomainRecords(output: Output, client: Client) {
@@ -40,12 +48,16 @@ function getAddDomainName(domainNames: string[]) {
...prev,
{
domainName: domainNames[idx],
records: item.sort((a, b) => a.slug.localeCompare(b.slug)),
records: item,
},
];
}
async function getDomainNames(client: Client, contextName: string) {
const { domains } = await getDomains(client, contextName);
return domains.map(domain => domain.name).sort((a, b) => a.localeCompare(b));
async function getDomainNames(
client: Client,
contextName: string,
next?: number
) {
const { domains, pagination } = await getDomains(client, contextName, next);
return { domainNames: domains.map(domain => domain.name), pagination };
}

View File

@@ -1,10 +1,8 @@
import bytes from 'bytes';
import { Response } from 'node-fetch';
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';
import { getCommandName } from './pkg-name';
/**
* This error is thrown when there is an API error with a payload. The error
@@ -52,8 +50,8 @@ export class TeamDeleted extends NowError<'TEAM_DELETED', {}> {
constructor() {
super({
code: 'TEAM_DELETED',
message: `Your team was deleted. You can switch to a different one using ${param(
`${getPkgName()} switch`
message: `Your team was deleted. You can switch to a different one using ${getCommandName(
`switch`
)}.`,
meta: {},
});
@@ -143,8 +141,8 @@ export class SourceNotFound extends NowError<'SOURCE_NOT_FOUND', {}> {
super({
code: 'SOURCE_NOT_FOUND',
meta: {},
message: `Not able to purchase. Please add a payment method using ${cmd(
`${getPkgName()} billing add`
message: `Not able to purchase. Please add a payment method using ${getCommandName(
`billing add`
)}.`,
});
}

View File

@@ -1,7 +0,0 @@
export const isOfficialRuntime = (desired: string, name?: string): boolean => {
return (
typeof name === 'string' &&
(name.startsWith(`@vercel/${desired}`) ||
name.startsWith(`@now/${desired}`))
);
};

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,13 +1,36 @@
// @ts-ignore
import title from 'title';
import pkg from './pkg';
import cmd from './output/cmd';
/**
* Returns the package name such as `vercel` or `now`.
*/
export function getPkgName(): string {
if (!pkg.name) {
throw new Error('Expected package.json to have a `name` property.');
throw new Error('Expected `package.json` to have a `name` property.');
}
return pkg.name;
}
export function getCommandName() {
return cmd(getPkgName());
/**
* Returns the package name with title-case
* such as `Vercel` or `Now`.
*/
export function getTitleName(): string {
const str = getPkgName();
return title(str);
}
/**
* Returns the package name with subcommand(s)
* as a suffix such as `vercel env pull` or `now env pull`.
*/
export function getCommandName(subcommands?: string): string {
let vercel = getPkgName();
if (subcommands) {
vercel = `${vercel} ${subcommands}`;
}
return cmd(vercel);
}

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

@@ -1,4 +1,5 @@
import Now from './index';
import { URLSearchParams } from 'url';
export default class Teams extends Now {
async create({ slug }) {
@@ -101,9 +102,16 @@ export default class Teams extends Now {
});
}
async ls() {
async ls({ next, apiVersion = 1 } = {}) {
return this.retry(async bail => {
const res = await this._fetch(`/teams`);
const query = new URLSearchParams();
if (next) {
query.set('limit', 20);
query.set('until', next);
}
const res = await this._fetch(`/v${apiVersion}/teams?${query}`);
if (res.status === 403) {
const error = new Error('Unauthorized');

View File

@@ -0,0 +1,2 @@
.vercel
public

View File

@@ -0,0 +1,3 @@
.vercel
public
api/two.js

View File

@@ -0,0 +1 @@
module.exports = (_req, res) => res.end('One');

View File

@@ -0,0 +1 @@
module.exports = (_req, res) => res.end('Two');

View File

@@ -0,0 +1,5 @@
<h1>Home Page</h1>
<a href="/api/one">1. Should exist</a>
<a href="/api/two">2. Should NOT exist</a>
<a href="/api/three">3. Should rewrite to one</a>

View File

@@ -0,0 +1,3 @@
{
"rewrites": [{ "source": "/api/three", "destination": "/api/one" }]
}

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 },
}
);
@@ -232,34 +232,22 @@ function testFixtureStdio(
{ expectedCode = 0, skipDeploy } = {}
) {
return async t => {
const dir = fixture(directory);
const cwd = fixtureAbsolute(directory);
const token = await fetchTokenWithRetry();
let deploymentUrl;
// Deploy fixture and link project
if (!skipDeploy) {
const project = join(
fixtureAbsolute(directory),
'.vercel',
'project.json'
);
const project = join(cwd, '.vercel', 'project.json');
if (await fs.exists(project)) {
await fs.unlink(project);
}
const gitignore = join(fixtureAbsolute(directory), '.gitignore');
const gitignore = join(cwd, '.gitignore');
const gitignoreOrig = await fs.exists(gitignore);
let { stdout, stderr, exitCode } = await execa(
binaryPath,
[
dir,
'-t',
token,
'--confirm',
'--public',
'--no-clipboard',
'--debug',
],
{ reject: false }
['-t', token, '--confirm', '--public', '--no-clipboard', '--debug'],
{ cwd, reject: false }
);
console.log({ stdout, stderr, exitCode });
if (!gitignoreOrig && (await fs.exists(gitignore))) {
@@ -274,7 +262,7 @@ function testFixtureStdio(
// Start dev
let dev;
await runNpmInstall(dir);
await runNpmInstall(cwd);
const stdoutList = [];
const stderrList = [];
@@ -287,13 +275,12 @@ 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,
['dev', dir, '-l', port, '-t', token, '--debug'],
{ env }
);
dev = execa(binaryPath, ['dev', '-l', port, '-t', token, '--debug'], {
cwd,
env,
});
dev.stdout.on('data', data => {
stdoutList.push(data);
@@ -1285,6 +1272,15 @@ test(
)
);
test(
'[now dev] 28-vercel-json-and-ignore',
testFixtureStdio('28-vercel-json-and-ignore', async testPath => {
await testPath(200, '/api/one', 'One');
await testPath(404, '/api/two');
await testPath(200, '/api/three', 'One');
})
);
test(
'[now dev] Use `@now/python` with Flask requirements.txt',
testFixtureStdio('python-flask', async testPath => {

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

@@ -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

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/client",
"version": "7.1.1-canary.4",
"version": "8.0.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"homepage": "https://vercel.com",

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

@@ -9,10 +9,10 @@ import {
createLambda,
getWriteableDirectory,
BuildOptions,
Meta,
shouldServe,
Files,
debug,
Meta,
} from '@vercel/build-utils';
import { createGo, getAnalyzedEntrypoint, OUT_EXTENSION } from './go-helpers';
@@ -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": "@vercel/go",
"version": "1.0.8-canary.1",
"version": "1.1.0",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/next",
"version": "2.5.5-canary.6",
"version": "2.6.0",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",

View File

@@ -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"',
});
@@ -443,14 +443,14 @@ 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 `@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 `@vercel/next` builder and try again. Contact support if this continues to happen.',
});
@@ -467,7 +467,7 @@ 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 `@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

@@ -42,7 +42,7 @@ function validateEntrypoint(entrypoint: string) {
throw new NowBuildError({
message:
'Specified "src" for "@vercel/next" has to be "package.json" or "next.config.js"',
code: 'NOW_NEXT_INCORRECT_SRC',
code: 'NEXT_INCORRECT_SRC',
});
}
}
@@ -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',
});
}
@@ -400,7 +400,7 @@ export async function getDynamicRoutes(
message:
'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: 'NOW_NEXT_VERSION_UPGRADE',
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 @@
{
"name": "@vercel/node-bridge",
"version": "1.2.7-canary.3",
"version": "1.3.0",
"license": "MIT",
"main": "./index.js",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/node",
"version": "1.5.2-canary.8",
"version": "1.6.0",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",

View File

@@ -31,8 +31,8 @@ Server.prototype.listen = function listen() {
};
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';
}
try {
@@ -85,7 +85,7 @@ exports.launcher = bridge.launcher;`;
export function makeAwsLauncher({
entrypointPath,
awsLambdaHandler = ''
awsLambdaHandler = '',
}: LauncherConfiguration): string {
const funcName = awsLambdaHandler.split('.').pop();
return `const url = require("url");

View File

@@ -182,7 +182,7 @@ export function register(opts: Options = {}): Register {
function createTSError(diagnostics: ReadonlyArray<_ts.Diagnostic>) {
const message = formatDiagnostics(diagnostics, diagnosticHost);
return new NowBuildError({ code: 'NOW_NODE_TYPESCRIPT_ERROR', message });
return new NowBuildError({ code: 'NODE_TYPESCRIPT_ERROR', message });
}
function reportTSError(

View File

@@ -0,0 +1,3 @@
export default (_req, res) => {
res.end(`RANDOMNESS_PLACEHOLDER:offset:${new Date().getTimezoneOffset()}`);
};

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