mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-12 12:57:47 +00:00
Compare commits
37 Commits
@vercel/py
...
@vercel/py
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8189fb2373 | ||
|
|
76f544cbea | ||
|
|
e246d2ed71 | ||
|
|
ed4c759c49 | ||
|
|
2656647891 | ||
|
|
3b3c468f3a | ||
|
|
4214de2ce0 | ||
|
|
40b7af4349 | ||
|
|
f4d86cb9df | ||
|
|
0492fcb0fc | ||
|
|
3a217dc750 | ||
|
|
b626f3fe57 | ||
|
|
96bc0c9bee | ||
|
|
f4ff8c0268 | ||
|
|
1a5681f287 | ||
|
|
88b66ae646 | ||
|
|
db0124782a | ||
|
|
a7a5d4d169 | ||
|
|
4b39e96c28 | ||
|
|
f459db9f83 | ||
|
|
ad19021969 | ||
|
|
95e41874e4 | ||
|
|
4d20a1d77b | ||
|
|
325ee261cb | ||
|
|
2e0cee490d | ||
|
|
8a9b67a3f3 | ||
|
|
f1d9a5da96 | ||
|
|
8d9c463e1f | ||
|
|
e07e8f841a | ||
|
|
0b8a2c0dab | ||
|
|
9c2b7132fa | ||
|
|
d4639a5108 | ||
|
|
ba25004ea8 | ||
|
|
639a9b03d2 | ||
|
|
28ffdfbeef | ||
|
|
5e222d3c03 | ||
|
|
94c8464728 |
2
.github/workflows/cancel.yml
vendored
2
.github/workflows/cancel.yml
vendored
@@ -2,7 +2,7 @@ name: Cancel
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
- '**'
|
||||
- '!master'
|
||||
|
||||
jobs:
|
||||
|
||||
12
README.md
12
README.md
@@ -1,11 +1,15 @@
|
||||

|
||||
<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>
|
||||
|
||||
[](https://github.com/zeit/now/actions?workflow=CI)
|
||||
[](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).
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
25
lerna.json
25
lerna.json
@@ -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"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/frameworks",
|
||||
"version": "0.0.14-canary.0",
|
||||
"version": "0.0.14",
|
||||
"main": "frameworks.json",
|
||||
"license": "UNLICENSED"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/build-utils",
|
||||
"version": "2.2.2-canary.7",
|
||||
"version": "2.3.1",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.js",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
/**
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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}`,
|
||||
})
|
||||
);
|
||||
|
||||
@@ -85,9 +85,37 @@ 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.
|
||||
* Throws an error if *both* env vars are defined.
|
||||
*/
|
||||
export const getPlatformEnv = (name: string): string | undefined => {
|
||||
const vName = `VERCEL_${name}`;
|
||||
const nName = `NOW_${name}`;
|
||||
const v = process.env[vName];
|
||||
const n = process.env[nName];
|
||||
if (typeof v === 'string') {
|
||||
if (typeof n === 'string') {
|
||||
throw new Error(
|
||||
`Both "${vName}" and "${nName}" env vars are defined. Please only define the "${vName}" env var`
|
||||
);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
return n;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
45
packages/now-build-utils/test/unit.get-platform-env.test.ts
vendored
Normal file
45
packages/now-build-utils/test/unit.get-platform-env.test.ts
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
import assert from 'assert';
|
||||
import { getPlatformEnv } from '../src';
|
||||
|
||||
describe('Test `getPlatformEnv()`', () => {
|
||||
it('should support `VERCEL_` prefix', () => {
|
||||
try {
|
||||
assert.equal(undefined, getPlatformEnv('FOO'));
|
||||
|
||||
process.env.VERCEL_FOO = 'bar';
|
||||
assert.equal('bar', getPlatformEnv('FOO'));
|
||||
} finally {
|
||||
delete process.env.VERCEL_FOO;
|
||||
}
|
||||
});
|
||||
|
||||
it('should support `NOW_` prefix', () => {
|
||||
try {
|
||||
assert.equal(undefined, getPlatformEnv('FOO'));
|
||||
|
||||
process.env.NOW_FOO = 'bar';
|
||||
assert.equal('bar', getPlatformEnv('FOO'));
|
||||
} finally {
|
||||
delete process.env.NOW_FOO;
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error if both env vars exist', () => {
|
||||
let err: Error | null = null;
|
||||
try {
|
||||
process.env.NOW_FOO = 'bar';
|
||||
process.env.VERCEL_FOO = 'baz';
|
||||
getPlatformEnv('FOO');
|
||||
} catch (_err) {
|
||||
err = _err;
|
||||
} finally {
|
||||
delete process.env.NOW_FOO;
|
||||
delete process.env.VERCEL_FOO;
|
||||
}
|
||||
assert(err);
|
||||
assert.equal(
|
||||
err!.message,
|
||||
'Both "VERCEL_FOO" and "NOW_FOO" env vars are defined. Please only define the "VERCEL_FOO" env var'
|
||||
);
|
||||
});
|
||||
});
|
||||
40
packages/now-build-utils/test/unit.is-official-runtime.test.ts
vendored
Normal file
40
packages/now-build-utils/test/unit.is-official-runtime.test.ts
vendored
Normal 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'));
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/cgi",
|
||||
"version": "1.0.5-canary.1",
|
||||
"version": "1.0.5",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||

|
||||
<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>
|
||||
|
||||
[](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).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vercel",
|
||||
"version": "18.0.1-canary.19",
|
||||
"version": "19.0.1",
|
||||
"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": [
|
||||
|
||||
@@ -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}`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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}`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import fs from 'fs-extra';
|
||||
import { resolve, basename, parse, join } from 'path';
|
||||
import { fileNameSymbol } from '@vercel/client';
|
||||
import Client from '../../util/client.ts';
|
||||
import getScope from '../../util/get-scope.ts';
|
||||
import createOutput from '../../util/output';
|
||||
@@ -112,11 +113,10 @@ export default async ctx => {
|
||||
}
|
||||
}
|
||||
|
||||
const file = highlight('vercel.json');
|
||||
const prop = code('version');
|
||||
|
||||
if (localConfig) {
|
||||
const { version } = localConfig;
|
||||
const file = highlight(localConfig[fileNameSymbol]);
|
||||
const prop = code('version');
|
||||
|
||||
if (version) {
|
||||
if (typeof version === 'number') {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { join } from 'path';
|
||||
import { write as copy } from 'clipboardy';
|
||||
import chalk from 'chalk';
|
||||
import title from 'title';
|
||||
import { fileNameSymbol } from '@vercel/client';
|
||||
import Client from '../../util/client';
|
||||
import { handleError } from '../../util/error';
|
||||
import getArgs from '../../util/get-args';
|
||||
@@ -54,7 +55,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 +123,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);
|
||||
@@ -370,7 +374,7 @@ export default async function main(
|
||||
output.print(
|
||||
`${prependEmoji(
|
||||
`The ${highlight(
|
||||
'vercel.json'
|
||||
localConfig[fileNameSymbol]
|
||||
)} file should be inside of the provided root directory.`,
|
||||
emoji('warning')
|
||||
)}\n`
|
||||
@@ -384,7 +388,7 @@ export default async function main(
|
||||
output.print(
|
||||
`${prependEmoji(
|
||||
`The ${code('name')} property in ${highlight(
|
||||
'vercel.json'
|
||||
localConfig[fileNameSymbol]
|
||||
)} is deprecated (https://zeit.ink/5F)`,
|
||||
emoji('warning')
|
||||
)}\n`
|
||||
@@ -401,7 +405,7 @@ export default async function main(
|
||||
if (typeof localConfig.env !== 'undefined' && !isObject(localConfig.env)) {
|
||||
error(
|
||||
`The ${code('env')} property in ${highlight(
|
||||
'vercel.json'
|
||||
localConfig[fileNameSymbol]
|
||||
)} needs to be an object`
|
||||
);
|
||||
return 1;
|
||||
@@ -411,7 +415,7 @@ export default async function main(
|
||||
if (!isObject(localConfig.build)) {
|
||||
error(
|
||||
`The ${code('build')} property in ${highlight(
|
||||
'vercel.json'
|
||||
localConfig[fileNameSymbol]
|
||||
)} needs to be an object`
|
||||
);
|
||||
return 1;
|
||||
@@ -423,7 +427,7 @@ export default async function main(
|
||||
) {
|
||||
error(
|
||||
`The ${code('build.env')} property in ${highlight(
|
||||
'vercel.json'
|
||||
localConfig[fileNameSymbol]
|
||||
)} needs to be an object`
|
||||
);
|
||||
return 1;
|
||||
@@ -634,11 +638,11 @@ export default async function main(
|
||||
}
|
||||
|
||||
if (purchase === false || purchase instanceof UserAborted) {
|
||||
handleCreateDeployError(output, deployment);
|
||||
handleCreateDeployError(output, deployment, localConfig);
|
||||
return 1;
|
||||
}
|
||||
|
||||
handleCreateDeployError(output, purchase);
|
||||
handleCreateDeployError(output, purchase, localConfig);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -658,15 +662,15 @@ export default async function main(
|
||||
err instanceof ConflictingFilePath ||
|
||||
err instanceof ConflictingPathSegment
|
||||
) {
|
||||
handleCreateDeployError(output, err);
|
||||
handleCreateDeployError(output, err, localConfig);
|
||||
return 1;
|
||||
}
|
||||
|
||||
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.
|
||||
@@ -704,7 +708,7 @@ export default async function main(
|
||||
);
|
||||
}
|
||||
|
||||
function handleCreateDeployError(output, error) {
|
||||
function handleCreateDeployError(output, error, localConfig) {
|
||||
if (error instanceof InvalidDomain) {
|
||||
output.error(`The domain ${error.meta.domain} is not valid`);
|
||||
return 1;
|
||||
@@ -733,7 +737,7 @@ function handleCreateDeployError(output, error) {
|
||||
|
||||
output.error(
|
||||
`The property ${code(prop)} is not allowed in ${highlight(
|
||||
'vercel.json'
|
||||
localConfig[fileNameSymbol]
|
||||
)} – please remove it.`
|
||||
);
|
||||
|
||||
@@ -758,7 +762,7 @@ function handleCreateDeployError(output, error) {
|
||||
|
||||
output.error(
|
||||
`The property ${code(prop)} in ${highlight(
|
||||
'vercel.json'
|
||||
localConfig[fileNameSymbol]
|
||||
)} can only be of type ${code(title(params.type))}.`
|
||||
);
|
||||
|
||||
@@ -769,7 +773,7 @@ function handleCreateDeployError(output, error) {
|
||||
|
||||
output.error(
|
||||
`Failed to validate ${highlight(
|
||||
'vercel.json'
|
||||
localConfig[fileNameSymbol]
|
||||
)}: ${message}\nDocumentation: ${link}`
|
||||
);
|
||||
|
||||
@@ -797,7 +801,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;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import link from '../../util/output/link';
|
||||
import exit from '../../util/exit';
|
||||
// @ts-ignore
|
||||
import Now from '../../util';
|
||||
// @ts-ignore
|
||||
import NowSecrets from '../../util/secrets';
|
||||
import uniq from '../../util/unique-strings';
|
||||
import promptBool from '../../util/input/prompt-bool';
|
||||
// @ts-ignore
|
||||
@@ -633,20 +635,7 @@ async function sync({
|
||||
nowConfig.build.env = deploymentBuildEnv;
|
||||
}
|
||||
|
||||
const hasSecrets = Object.keys(deploymentEnv).some(key =>
|
||||
(deploymentEnv[key] || '').startsWith('@')
|
||||
);
|
||||
|
||||
const secretsPromise = hasSecrets ? now.listSecrets() : null;
|
||||
|
||||
const findSecret = async (uidOrName: string) => {
|
||||
const secrets = await Promise.resolve(secretsPromise);
|
||||
|
||||
return secrets.filter(
|
||||
(secret: { name: string; uid: string }) =>
|
||||
secret.name === uidOrName || secret.uid === uidOrName
|
||||
);
|
||||
};
|
||||
const nowSecrets = new NowSecrets({ apiUrl, token, debug, currentTeam });
|
||||
|
||||
const env_ = await Promise.all(
|
||||
Object.keys(deploymentEnv).map(async (key: string) => {
|
||||
@@ -673,36 +662,17 @@ async function sync({
|
||||
|
||||
if (val[0] === '@') {
|
||||
const uidOrName = val.substr(1);
|
||||
const _secrets = await findSecret(uidOrName);
|
||||
const secret = await nowSecrets.getSecretByNameOrId(uidOrName);
|
||||
|
||||
if (_secrets.length === 0) {
|
||||
if (uidOrName === '') {
|
||||
error(
|
||||
`Empty reference provided for env key ${chalk.bold(
|
||||
`"${chalk.bold(key)}"`
|
||||
)}`
|
||||
);
|
||||
} else {
|
||||
error(
|
||||
`No secret found by uid or name ${chalk.bold(
|
||||
`"${uidOrName}"`
|
||||
)}`,
|
||||
'env-no-secret'
|
||||
);
|
||||
}
|
||||
|
||||
await exit(1);
|
||||
} else if (_secrets.length > 1) {
|
||||
if (!secret) {
|
||||
error(
|
||||
`Ambiguous secret ${chalk.bold(
|
||||
`"${uidOrName}"`
|
||||
)} (matches ${chalk.bold(_secrets.length)} secrets)`
|
||||
`No secret found by uid or name ${chalk.bold(`"${uidOrName}"`)}`,
|
||||
'env-no-secret'
|
||||
);
|
||||
|
||||
await exit(1);
|
||||
}
|
||||
|
||||
val = { uid: _secrets[0].uid };
|
||||
val = { uid: secret.uid };
|
||||
}
|
||||
|
||||
return [key, typeof val === 'string' ? val.replace(/^\\@/, '@') : val];
|
||||
|
||||
@@ -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 isn’t linked to a project on Vercel. Run ${getCommandName()} to link it.`
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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`)}
|
||||
|
||||
`);
|
||||
};
|
||||
|
||||
|
||||
@@ -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 [
|
||||
|
||||
@@ -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`
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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}`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
21
packages/now-cli/src/commands/env/add.ts
vendored
21
packages/now-cli/src/commands/env/add.ts
vendored
@@ -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;
|
||||
@@ -99,6 +98,8 @@ export default async function add(
|
||||
|
||||
if (stdInput) {
|
||||
envValue = stdInput;
|
||||
} else if (isSystemEnvVariable(envName)) {
|
||||
envValue = '';
|
||||
} else {
|
||||
const { inputValue } = await inquirer.prompt({
|
||||
type: 'password',
|
||||
@@ -147,3 +148,7 @@ export default async function add(
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function isSystemEnvVariable(envName: string) {
|
||||
return envName.startsWith('VERCEL_');
|
||||
}
|
||||
|
||||
11
packages/now-cli/src/commands/env/ls.ts
vendored
11
packages/now-cli/src/commands/env/ls.ts
vendored
@@ -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}`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
7
packages/now-cli/src/commands/env/pull.ts
vendored
7
packages/now-cli/src/commands/env/pull.ts
vendored
@@ -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;
|
||||
}
|
||||
|
||||
7
packages/now-cli/src/commands/env/rm.ts
vendored
7
packages/now-cli/src/commands/env/rm.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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.`
|
||||
);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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}`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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`
|
||||
)}`
|
||||
)
|
||||
);
|
||||
|
||||
@@ -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} `
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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} `
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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`
|
||||
)}`,
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,20 +151,20 @@ const main = async argv_ => {
|
||||
`${chalk.bgRed('UPDATE AVAILABLE')} ` +
|
||||
`Run ${cmd(
|
||||
await getUpdateCommand()
|
||||
)} to install ${getPkgName()} CLI ${update.latest}`
|
||||
)} to install ${getTitleName()} CLI ${update.latest}`
|
||||
)
|
||||
);
|
||||
|
||||
console.log(
|
||||
info(
|
||||
`Changelog: https://github.com/zeit/now/releases/tag/now@${update.latest}`
|
||||
`Changelog: https://github.com/zeit/now/releases/tag/vercel@${update.latest}`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
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',
|
||||
})
|
||||
);
|
||||
|
||||
@@ -2,8 +2,6 @@ import { NowConfig } from './util/dev/types';
|
||||
|
||||
export type ThenArg<T> = T extends Promise<infer U> ? U : T;
|
||||
|
||||
export type Config = NowConfig;
|
||||
|
||||
export interface NowContext {
|
||||
argv: string[];
|
||||
apiUrl: string;
|
||||
@@ -14,7 +12,7 @@ export interface NowContext {
|
||||
currentTeam: string;
|
||||
updateChannel: string;
|
||||
};
|
||||
localConfig: Config;
|
||||
localConfig: NowConfig;
|
||||
}
|
||||
|
||||
type Billing = {
|
||||
@@ -187,6 +185,9 @@ export type DNSRecord = {
|
||||
value: string;
|
||||
created: number;
|
||||
updated: number;
|
||||
createdAt: number;
|
||||
updatedAt: number;
|
||||
domain: string;
|
||||
};
|
||||
|
||||
type SRVRecordData = {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -2,7 +2,8 @@ import path from 'path';
|
||||
import chalk from 'chalk';
|
||||
import Client from '../client';
|
||||
import { Output } from '../output';
|
||||
import { User, Config } from '../../types';
|
||||
import { User } from '../../types';
|
||||
import { NowConfig } from '../dev/types';
|
||||
import getDeploymentsByAppName from '../deploy/get-deployments-by-appname';
|
||||
import getDeploymentByIdOrHost from '../deploy/get-deployment-by-id-or-host';
|
||||
|
||||
@@ -34,7 +35,7 @@ export async function getDeploymentForAlias(
|
||||
localConfigPath: string | undefined,
|
||||
user: User,
|
||||
contextName: string,
|
||||
localConfig: Config
|
||||
localConfig: NowConfig
|
||||
) {
|
||||
const cancelWait = output.spinner(
|
||||
`Fetching deployment to alias in ${chalk.bold(contextName)}`
|
||||
|
||||
@@ -5,7 +5,8 @@ import getAppName from '../deploy/get-app-name';
|
||||
import fetchDeploymentByIdOrHost from '../deploy/get-deployment-by-id-or-host';
|
||||
import Client from '../client';
|
||||
import { Output } from '../output';
|
||||
import { User, Config } from '../../types';
|
||||
import { User } from '../../types';
|
||||
import { NowConfig } from '../dev/types';
|
||||
|
||||
export default async function getDeploymentForAlias(
|
||||
client: Client,
|
||||
@@ -14,7 +15,7 @@ export default async function getDeploymentForAlias(
|
||||
localConfigPath: string | undefined,
|
||||
user: User,
|
||||
contextName: string,
|
||||
localConfig: Config
|
||||
localConfig: NowConfig
|
||||
) {
|
||||
const cancelWait = output.spinner(
|
||||
`Fetching deployment to alias in ${chalk.bold(contextName)}`
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import toHost from '../to-host';
|
||||
import { Config } from '../../types';
|
||||
import { NowConfig } from '../dev/types';
|
||||
import * as ERRORS from '../errors-ts';
|
||||
|
||||
export function getTargetsForAlias(args: string[], { alias }: Config) {
|
||||
export function getTargetsForAlias(args: string[], { alias }: NowConfig) {
|
||||
if (args.length) {
|
||||
return targetsToHosts([args[args.length - 1]]);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import { join as joinPath } from 'path';
|
||||
import { join, basename } from 'path';
|
||||
import loadJSON from 'load-json-file';
|
||||
import writeJSON from 'write-json-file';
|
||||
import { existsSync } from 'fs';
|
||||
import { fileNameSymbol } from '@vercel/client';
|
||||
import getGlobalPathConfig from './global-path';
|
||||
import getLocalPathConfig from './local-path';
|
||||
import { NowError } from '../now-error';
|
||||
import error from '../output/error';
|
||||
import highlight from '../output/highlight';
|
||||
import { NowConfig } from '../dev/types';
|
||||
|
||||
const VERCEL_DIR = getGlobalPathConfig();
|
||||
const CONFIG_FILE_PATH = joinPath(VERCEL_DIR, 'config.json');
|
||||
const AUTH_CONFIG_FILE_PATH = joinPath(VERCEL_DIR, 'auth.json');
|
||||
const CONFIG_FILE_PATH = join(VERCEL_DIR, 'config.json');
|
||||
const AUTH_CONFIG_FILE_PATH = join(VERCEL_DIR, 'auth.json');
|
||||
|
||||
// reads `CONFIG_FILE_PATH` atomically
|
||||
export const readConfigFile = () => loadJSON.sync(CONFIG_FILE_PATH);
|
||||
@@ -87,7 +89,10 @@ export function getAuthConfigFilePath() {
|
||||
return AUTH_CONFIG_FILE_PATH;
|
||||
}
|
||||
|
||||
export function readLocalConfig(prefix: string = process.cwd()) {
|
||||
export function readLocalConfig(
|
||||
prefix: string = process.cwd()
|
||||
): NowConfig | null {
|
||||
let config: NowConfig | null = null;
|
||||
let target = '';
|
||||
|
||||
try {
|
||||
@@ -105,29 +110,24 @@ export function readLocalConfig(prefix: string = process.cwd()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let localConfigExists;
|
||||
|
||||
try {
|
||||
localConfigExists = existsSync(target);
|
||||
if (existsSync(target)) {
|
||||
config = loadJSON.sync(target);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(error(`Config file does not exist: ${target}`));
|
||||
if (err.name === 'JSONError') {
|
||||
console.error(error(err.message));
|
||||
} else {
|
||||
const code = err.code ? ` (${err.code})` : '';
|
||||
console.error(error(`Failed to read config file: ${target}${code}`));
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (localConfigExists) {
|
||||
try {
|
||||
return loadJSON.sync(target);
|
||||
} catch (err) {
|
||||
if (err.name === 'JSONError') {
|
||||
console.log(error(err.message));
|
||||
} else {
|
||||
const code = err.code ? `(${err.code})` : '';
|
||||
console.error(error(`Failed to read config file: ${target} (${code})`));
|
||||
}
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
if (!config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
config[fileNameSymbol] = basename(target);
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { join } from 'path';
|
||||
import { CantParseJSONFile } from '../errors-ts';
|
||||
import readJSONFile from '../read-json-file';
|
||||
import { Config } from '../../types';
|
||||
import { NowConfig } from '../dev/types';
|
||||
import getLocalConfigPath from './local-path';
|
||||
|
||||
export default async function readConfig(dir: string) {
|
||||
@@ -13,7 +13,7 @@ export default async function readConfig(dir: string) {
|
||||
}
|
||||
|
||||
if (result) {
|
||||
return result as Config;
|
||||
return result as NowConfig;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import path from 'path';
|
||||
import { NowError } from '../now-error';
|
||||
import { Output } from '../output';
|
||||
import { Config } from '../../types';
|
||||
import { NowConfig } from '../dev/types';
|
||||
import readPackage from '../read-package';
|
||||
|
||||
export default async function getAppName(
|
||||
output: Output,
|
||||
config: Config,
|
||||
config: NowConfig,
|
||||
localConfigPath?: string
|
||||
) {
|
||||
// If the name is in the configuration, return it
|
||||
|
||||
@@ -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(
|
||||
@@ -109,7 +109,7 @@ export default async function processDeployment({
|
||||
let buildSpinner = null;
|
||||
let deploySpinner = null;
|
||||
|
||||
let deployingSpinner = output.spinner(
|
||||
const deployingSpinner = output.spinner(
|
||||
isSettingUpProject
|
||||
? 'Setting up project'
|
||||
: `Deploying ${chalk.bold(`${org.slug}/${projectName}`)}`,
|
||||
@@ -120,170 +120,176 @@ export default async function processDeployment({
|
||||
// the deployment is done
|
||||
const indications = [];
|
||||
|
||||
for await (const event of createDeployment(
|
||||
nowClientOptions,
|
||||
requestBody,
|
||||
nowConfig
|
||||
)) {
|
||||
if (event.type === 'hashes-calculated') {
|
||||
hashes = event.payload;
|
||||
}
|
||||
|
||||
if (['tip', 'notice', 'warning'].includes(event.type)) {
|
||||
indications.push(event);
|
||||
}
|
||||
|
||||
if (event.type === 'file-count') {
|
||||
debug(
|
||||
`Total files ${event.payload.total.size}, ${event.payload.missing.length} changed`
|
||||
);
|
||||
|
||||
const missingSize = event.payload.missing
|
||||
.map((sha: string) => event.payload.total.get(sha).data.length)
|
||||
.reduce((a: number, b: number) => a + b, 0);
|
||||
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
try {
|
||||
for await (const event of createDeployment(
|
||||
nowClientOptions,
|
||||
requestBody,
|
||||
nowConfig
|
||||
)) {
|
||||
if (event.type === 'hashes-calculated') {
|
||||
hashes = event.payload;
|
||||
}
|
||||
if (buildSpinner) {
|
||||
buildSpinner();
|
||||
|
||||
if (['tip', 'notice', 'warning'].includes(event.type)) {
|
||||
indications.push(event);
|
||||
}
|
||||
if (deploySpinner) {
|
||||
deploySpinner();
|
||||
}
|
||||
if (deployingSpinner) {
|
||||
|
||||
if (event.type === 'file-count') {
|
||||
debug(
|
||||
`Total files ${event.payload.total.size}, ${event.payload.missing.length} changed`
|
||||
);
|
||||
|
||||
const missingSize = event.payload.missing
|
||||
.map((sha: string) => event.payload.total.get(sha).data.length)
|
||||
.reduce((a: number, b: number) => a + b, 0);
|
||||
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
}
|
||||
if (buildSpinner) {
|
||||
buildSpinner();
|
||||
}
|
||||
if (deploySpinner) {
|
||||
deploySpinner();
|
||||
}
|
||||
deployingSpinner();
|
||||
bar = new Progress(`${chalk.gray('>')} Upload [:bar] :percent :etas`, {
|
||||
width: 20,
|
||||
complete: '=',
|
||||
incomplete: '',
|
||||
total: missingSize,
|
||||
clear: true,
|
||||
});
|
||||
}
|
||||
bar = new Progress(`${chalk.gray('>')} Upload [:bar] :percent :etas`, {
|
||||
width: 20,
|
||||
complete: '=',
|
||||
incomplete: '',
|
||||
total: missingSize,
|
||||
clear: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (event.type === 'file-uploaded') {
|
||||
debug(
|
||||
`Uploaded: ${event.payload.file.names.join(' ')} (${bytes(
|
||||
event.payload.file.data.length
|
||||
)})`
|
||||
);
|
||||
if (event.type === 'file-uploaded') {
|
||||
debug(
|
||||
`Uploaded: ${event.payload.file.names.join(' ')} (${bytes(
|
||||
event.payload.file.data.length
|
||||
)})`
|
||||
);
|
||||
|
||||
if (bar) {
|
||||
bar.tick(event.payload.file.data.length);
|
||||
if (bar) {
|
||||
bar.tick(event.payload.file.data.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.type === 'created') {
|
||||
if (deployingSpinner) {
|
||||
if (event.type === 'created') {
|
||||
deployingSpinner();
|
||||
|
||||
now._host = event.payload.url;
|
||||
|
||||
await linkFolderToProject(
|
||||
output,
|
||||
cwd || paths[0],
|
||||
{
|
||||
orgId: org.id,
|
||||
projectId: event.payload.projectId,
|
||||
},
|
||||
projectName,
|
||||
org.slug
|
||||
);
|
||||
|
||||
now.url = event.payload.url;
|
||||
|
||||
printInspectUrl(output, event.payload.url, deployStamp, org.slug);
|
||||
|
||||
if (quiet) {
|
||||
process.stdout.write(`https://${event.payload.url}`);
|
||||
}
|
||||
|
||||
if (queuedSpinner === null) {
|
||||
queuedSpinner =
|
||||
event.payload.readyState === 'QUEUED'
|
||||
? output.spinner('Queued', 0)
|
||||
: output.spinner('Building', 0);
|
||||
}
|
||||
}
|
||||
|
||||
now._host = event.payload.url;
|
||||
if (event.type === 'building') {
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
}
|
||||
|
||||
await linkFolderToProject(
|
||||
output,
|
||||
cwd || paths[0],
|
||||
{
|
||||
orgId: org.id,
|
||||
projectId: event.payload.projectId,
|
||||
},
|
||||
projectName,
|
||||
org.slug
|
||||
);
|
||||
|
||||
now.url = event.payload.url;
|
||||
|
||||
printInspectUrl(output, event.payload.url, deployStamp, org.slug);
|
||||
|
||||
if (quiet) {
|
||||
process.stdout.write(`https://${event.payload.url}`);
|
||||
if (buildSpinner === null) {
|
||||
buildSpinner = output.spinner('Building', 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (queuedSpinner === null) {
|
||||
queuedSpinner =
|
||||
event.payload.readyState === 'QUEUED'
|
||||
? output.spinner('Queued', 0)
|
||||
: output.spinner('Building', 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.type === 'building') {
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
if (event.type === 'canceled') {
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
}
|
||||
if (buildSpinner) {
|
||||
buildSpinner();
|
||||
}
|
||||
return event.payload;
|
||||
}
|
||||
|
||||
if (buildSpinner === null) {
|
||||
buildSpinner = output.spinner('Building', 0);
|
||||
}
|
||||
}
|
||||
if (event.type === 'ready') {
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
}
|
||||
if (buildSpinner) {
|
||||
buildSpinner();
|
||||
}
|
||||
|
||||
if (event.type === 'canceled') {
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
}
|
||||
if (buildSpinner) {
|
||||
buildSpinner();
|
||||
}
|
||||
return event.payload;
|
||||
}
|
||||
|
||||
if (event.type === 'ready') {
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
}
|
||||
if (buildSpinner) {
|
||||
buildSpinner();
|
||||
deploySpinner = output.spinner('Completing', 0);
|
||||
}
|
||||
|
||||
deploySpinner = output.spinner('Completing', 0);
|
||||
}
|
||||
|
||||
// Handle error events
|
||||
if (event.type === 'error') {
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
}
|
||||
if (buildSpinner) {
|
||||
buildSpinner();
|
||||
}
|
||||
if (deploySpinner) {
|
||||
deploySpinner();
|
||||
}
|
||||
if (deployingSpinner) {
|
||||
// Handle error events
|
||||
if (event.type === 'error') {
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
}
|
||||
if (buildSpinner) {
|
||||
buildSpinner();
|
||||
}
|
||||
if (deploySpinner) {
|
||||
deploySpinner();
|
||||
}
|
||||
deployingSpinner();
|
||||
|
||||
const error = await now.handleDeploymentError(event.payload, {
|
||||
hashes,
|
||||
env,
|
||||
});
|
||||
|
||||
if (error.code === 'missing_project_settings') {
|
||||
return error;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
const error = await now.handleDeploymentError(event.payload, {
|
||||
hashes,
|
||||
env,
|
||||
});
|
||||
|
||||
if (error.code === 'missing_project_settings') {
|
||||
return error;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Handle alias-assigned event
|
||||
if (event.type === 'alias-assigned') {
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
}
|
||||
if (buildSpinner) {
|
||||
buildSpinner();
|
||||
}
|
||||
if (deploySpinner) {
|
||||
deploySpinner();
|
||||
}
|
||||
if (deployingSpinner) {
|
||||
// Handle alias-assigned event
|
||||
if (event.type === 'alias-assigned') {
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
}
|
||||
if (buildSpinner) {
|
||||
buildSpinner();
|
||||
}
|
||||
if (deploySpinner) {
|
||||
deploySpinner();
|
||||
}
|
||||
deployingSpinner();
|
||||
}
|
||||
|
||||
event.payload.indications = indications;
|
||||
return event.payload;
|
||||
event.payload.indications = indications;
|
||||
return event.payload;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (queuedSpinner) {
|
||||
queuedSpinner();
|
||||
}
|
||||
if (buildSpinner) {
|
||||
buildSpinner();
|
||||
}
|
||||
if (deploySpinner) {
|
||||
deploySpinner();
|
||||
}
|
||||
deployingSpinner();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
@@ -268,6 +268,7 @@ export async function installBuilders(
|
||||
'--exact',
|
||||
'--no-lockfile',
|
||||
'--non-interactive',
|
||||
'--ignore-workspace-root-check',
|
||||
...packagesToInstall,
|
||||
],
|
||||
{
|
||||
@@ -322,7 +323,8 @@ export async function updateBuilders(
|
||||
'--exact',
|
||||
'--no-lockfile',
|
||||
'--non-interactive',
|
||||
...packages.filter(p => p !== '@now/static'),
|
||||
'--ignore-workspace-root-check',
|
||||
...packages.filter(p => !isStaticRuntime(p)),
|
||||
],
|
||||
{
|
||||
cwd: builderDir,
|
||||
@@ -352,7 +354,8 @@ export async function getBuilder(
|
||||
builderPkg: string,
|
||||
yarnDir: string,
|
||||
output: Output,
|
||||
builderDir?: string
|
||||
builderDir?: string,
|
||||
isRetry = false
|
||||
): Promise<BuilderWithPackage> {
|
||||
let builderWithPkg: BuilderWithPackage = localBuilders[builderPkg];
|
||||
if (!builderWithPkg) {
|
||||
@@ -371,7 +374,7 @@ export async function getBuilder(
|
||||
package: Object.freeze(pkg),
|
||||
};
|
||||
} catch (err) {
|
||||
if (err.code === 'MODULE_NOT_FOUND') {
|
||||
if (err.code === 'MODULE_NOT_FOUND' && !isRetry) {
|
||||
output.debug(
|
||||
`Attempted to require ${builderPkg}, but it is not installed`
|
||||
);
|
||||
@@ -379,7 +382,7 @@ export async function getBuilder(
|
||||
await installBuilders(pkgSet, yarnDir, output, builderDir);
|
||||
|
||||
// Run `getBuilder()` again now that the builder has been installed
|
||||
return getBuilder(builderPkg, yarnDir, output, builderDir);
|
||||
return getBuilder(builderPkg, yarnDir, output, builderDir, true);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ import { ChildProcess } from 'child_process';
|
||||
import isPortReachable from 'is-port-reachable';
|
||||
import which from 'which';
|
||||
|
||||
import { getVercelIgnore } from '@vercel/client';
|
||||
import { getVercelIgnore, fileNameSymbol } from '@vercel/client';
|
||||
import {
|
||||
getTransformedRoutes,
|
||||
appendRoutesToPhase,
|
||||
@@ -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 {
|
||||
@@ -495,7 +495,11 @@ export default class DevServer {
|
||||
|
||||
// The default empty `vercel.json` is used to serve all files as static
|
||||
// when no `vercel.json` is present
|
||||
let config: NowConfig = this.cachedNowConfig || { version: 2 };
|
||||
let configPath = 'vercel.json';
|
||||
let config: NowConfig = this.cachedNowConfig || {
|
||||
version: 2,
|
||||
[fileNameSymbol]: configPath,
|
||||
};
|
||||
|
||||
// We need to delete these properties for zero config to work
|
||||
// with file changes
|
||||
@@ -504,11 +508,11 @@ export default class DevServer {
|
||||
delete this.cachedNowConfig.routes;
|
||||
}
|
||||
|
||||
let configPath = 'vercel.json';
|
||||
try {
|
||||
configPath = getNowConfigPath(this.cwd);
|
||||
this.output.debug(`Reading ${configPath}`);
|
||||
config = JSON.parse(await fs.readFile(configPath, 'utf8'));
|
||||
config[fileNameSymbol] = configPath;
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
this.output.debug(err.toString());
|
||||
@@ -1696,6 +1700,7 @@ export default class DevServer {
|
||||
...process.env,
|
||||
...this.envConfigs.allEnv,
|
||||
NOW_REGION: 'dev1',
|
||||
VERCEL_REGION: 'dev1',
|
||||
PORT: `${port}`,
|
||||
};
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -70,7 +70,9 @@ function validateKey(
|
||||
|
||||
const error = validate.errors[0];
|
||||
|
||||
return `Invalid \`${key}\` property: ${error.dataPath} ${error.message}`;
|
||||
return `Invalid \`${String(key)}\` property: ${error.dataPath} ${
|
||||
error.message
|
||||
}`;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
@@ -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`
|
||||
)}.`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import path from 'path';
|
||||
import { fileNameSymbol } from '@vercel/client';
|
||||
import {
|
||||
CantParseJSONFile,
|
||||
CantFindConfig,
|
||||
@@ -7,15 +8,15 @@ import {
|
||||
import humanizePath from './humanize-path';
|
||||
import readJSONFile from './read-json-file';
|
||||
import readPackage from './read-package';
|
||||
import { Config } from '../types';
|
||||
import { NowConfig } from './dev/types';
|
||||
import { Output } from './output';
|
||||
|
||||
let config: Config;
|
||||
let config: NowConfig;
|
||||
|
||||
export default async function getConfig(
|
||||
output: Output,
|
||||
configFile?: string
|
||||
): Promise<Config | Error> {
|
||||
): Promise<NowConfig | Error> {
|
||||
// If config was already read, just return it
|
||||
if (config) {
|
||||
return config;
|
||||
@@ -42,7 +43,8 @@ export default async function getConfig(
|
||||
return localConfig;
|
||||
}
|
||||
if (localConfig !== null) {
|
||||
config = localConfig;
|
||||
config = localConfig as NowConfig;
|
||||
config[fileNameSymbol] = configFile;
|
||||
return config;
|
||||
}
|
||||
}
|
||||
@@ -55,7 +57,8 @@ export default async function getConfig(
|
||||
}
|
||||
if (vercelConfig !== null) {
|
||||
output.debug(`Found config in file ${vercelFilePath}`);
|
||||
config = vercelConfig;
|
||||
config = vercelConfig as NowConfig;
|
||||
config[fileNameSymbol] = 'vercel.json';
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -67,7 +70,8 @@ export default async function getConfig(
|
||||
}
|
||||
if (mainConfig !== null) {
|
||||
output.debug(`Found config in file ${nowFilePath}`);
|
||||
config = mainConfig;
|
||||
config = mainConfig as NowConfig;
|
||||
config[fileNameSymbol] = 'now.json';
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -78,13 +82,16 @@ export default async function getConfig(
|
||||
return pkgConfig;
|
||||
}
|
||||
if (pkgConfig) {
|
||||
output.debug(`Found config in package ${nowFilePath}`);
|
||||
config = pkgConfig;
|
||||
output.debug(`Found config in package ${pkgFilePath}`);
|
||||
config = pkgConfig as NowConfig;
|
||||
config[fileNameSymbol] = 'package.json';
|
||||
return config;
|
||||
}
|
||||
|
||||
// If we couldn't find the config anywhere return error
|
||||
return new CantFindConfig([nowFilePath, pkgFilePath].map(humanizePath));
|
||||
return new CantFindConfig(
|
||||
[vercelFilePath, nowFilePath, pkgFilePath].map(humanizePath)
|
||||
);
|
||||
}
|
||||
|
||||
async function readConfigFromPackage(file: string) {
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
export const isOfficialRuntime = (desired: string, name?: string): boolean => {
|
||||
return (
|
||||
typeof name === 'string' &&
|
||||
(name.startsWith(`@vercel/${desired}`) ||
|
||||
name.startsWith(`@now/${desired}`))
|
||||
);
|
||||
};
|
||||
@@ -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 => {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { exists } from 'fs-extra';
|
||||
import { PackageJson } from '@vercel/build-utils';
|
||||
|
||||
import Client from './client';
|
||||
import { Config } from '../types';
|
||||
import { NowConfig } from './dev/types';
|
||||
import { CantParseJSONFile, ProjectNotFound } from './errors-ts';
|
||||
import getProjectByIdOrName from './projects/get-project-by-id-or-name';
|
||||
|
||||
@@ -33,7 +33,7 @@ export default async function preferV2Deployment({
|
||||
hasDockerfile: boolean;
|
||||
hasServerfile: boolean;
|
||||
pkg: PackageJson | CantParseJSONFile | null;
|
||||
localConfig: Config | undefined;
|
||||
localConfig: NowConfig | undefined;
|
||||
projectName?: string;
|
||||
}): Promise<null | string> {
|
||||
if (localConfig && localConfig.version) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import path from 'path';
|
||||
import { CantParseJSONFile } from './errors-ts';
|
||||
import readJSONFile from './read-json-file';
|
||||
import { Config } from '../types';
|
||||
import { NowConfig } from './dev/types';
|
||||
import { PackageJson } from '@vercel/build-utils';
|
||||
|
||||
interface CustomPackage extends PackageJson {
|
||||
now?: Config;
|
||||
now?: NowConfig;
|
||||
}
|
||||
|
||||
export default async function readPackage(file?: string) {
|
||||
|
||||
@@ -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');
|
||||
|
||||
2
packages/now-cli/test/dev/fixtures/28-vercel-json-and-ignore/.gitignore
vendored
Normal file
2
packages/now-cli/test/dev/fixtures/28-vercel-json-and-ignore/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.vercel
|
||||
public
|
||||
@@ -0,0 +1,3 @@
|
||||
.vercel
|
||||
public
|
||||
api/two.js
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = (_req, res) => res.end('One');
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = (_req, res) => res.end('Two');
|
||||
@@ -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>
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"rewrites": [{ "source": "/api/three", "destination": "/api/one" }]
|
||||
}
|
||||
@@ -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 => {
|
||||
|
||||
@@ -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]
|
||||
);
|
||||
|
||||
@@ -134,6 +134,10 @@ module.exports = async session => {
|
||||
'now.json': '{"builder": 1, "type": "static"}',
|
||||
'index.html': '<span>test</span',
|
||||
},
|
||||
'builds-wrong-vercel': {
|
||||
'vercel.json': '{"fake": 1}',
|
||||
'index.html': '<h1>Fake</h1>',
|
||||
},
|
||||
'builds-no-list': {
|
||||
'now.json': `{
|
||||
"version": 2,
|
||||
@@ -172,7 +176,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': `
|
||||
|
||||
100
packages/now-cli/test/integration.js
vendored
100
packages/now-cli/test/integration.js
vendored
@@ -25,7 +25,7 @@ import { fetchTokenWithRetry } from '../../../test/lib/deployment/now-deploy';
|
||||
|
||||
// log command when running `execa`
|
||||
function execa(file, args, options) {
|
||||
console.log(`$ now ${args.join(' ')}`);
|
||||
console.log(`$ vercel ${args.join(' ')}`);
|
||||
return _execa(file, args, options);
|
||||
}
|
||||
|
||||
@@ -410,6 +410,28 @@ test('Deploy `api-env` fixture and test `now env` command', async t => {
|
||||
t.is(exitCode, 0, formatOutput({ stderr, stdout }));
|
||||
}
|
||||
|
||||
async function nowEnvAddSystemEnv() {
|
||||
const now = execa(
|
||||
binaryPath,
|
||||
['env', 'add', 'VERCEL_URL', ...defaultArgs],
|
||||
{
|
||||
reject: false,
|
||||
cwd: target,
|
||||
}
|
||||
);
|
||||
|
||||
await waitForPrompt(
|
||||
now,
|
||||
chunk =>
|
||||
chunk.includes('which Environments') && chunk.includes('VERCEL_URL')
|
||||
);
|
||||
now.stdin.write('a\n'); // select all
|
||||
|
||||
const { exitCode, stderr, stdout } = await now;
|
||||
|
||||
t.is(exitCode, 0, formatOutput({ stderr, stdout }));
|
||||
}
|
||||
|
||||
async function nowEnvLsIncludesVar() {
|
||||
const { exitCode, stderr, stdout } = await execa(
|
||||
binaryPath,
|
||||
@@ -434,6 +456,12 @@ test('Deploy `api-env` fixture and test `now env` command', async t => {
|
||||
const myStdinVars = lines.filter(line => line.includes('MY_STDIN_VAR'));
|
||||
t.is(myStdinVars.length, 1);
|
||||
t.regex(myStdinVars.join('\n'), /preview/gm);
|
||||
|
||||
const vercelVars = lines.filter(line => line.includes('VERCEL_URL'));
|
||||
t.is(vercelVars.length, 3);
|
||||
t.regex(vercelVars.join('\n'), /development/gm);
|
||||
t.regex(vercelVars.join('\n'), /preview/gm);
|
||||
t.regex(vercelVars.join('\n'), /production/gm);
|
||||
}
|
||||
|
||||
async function nowEnvPull() {
|
||||
@@ -450,7 +478,9 @@ test('Deploy `api-env` fixture and test `now env` command', async t => {
|
||||
t.regex(stderr, /Created .env file/gm);
|
||||
|
||||
const contents = fs.readFileSync(path.join(target, '.env'), 'utf8');
|
||||
t.is(contents, 'MY_ENV_VAR="MY_VALUE"\n');
|
||||
const lines = new Set(contents.split('\n'));
|
||||
t.true(lines.has('MY_ENV_VAR="MY_VALUE"'));
|
||||
t.true(lines.has('VERCEL_URL=""'));
|
||||
}
|
||||
|
||||
async function nowDeployWithVar() {
|
||||
@@ -472,6 +502,7 @@ test('Deploy `api-env` fixture and test `now env` command', async t => {
|
||||
const apiJson = await apiRes.json();
|
||||
t.is(apiJson['MY_ENV_VAR'], 'MY_VALUE');
|
||||
t.is(apiJson['MY_STDIN_VAR'], 'MY_STDIN_VALUE');
|
||||
t.is(apiJson['VERCEL_URL'], host);
|
||||
|
||||
const homeUrl = `https://${host}`;
|
||||
console.log({ homeUrl });
|
||||
@@ -480,6 +511,7 @@ test('Deploy `api-env` fixture and test `now env` command', async t => {
|
||||
const homeJson = await homeRes.json();
|
||||
t.is(homeJson['MY_ENV_VAR'], 'MY_VALUE');
|
||||
t.is(homeJson['MY_STDIN_VAR'], 'MY_STDIN_VALUE');
|
||||
t.is(apiJson['VERCEL_URL'], host);
|
||||
}
|
||||
|
||||
async function nowEnvRemove() {
|
||||
@@ -517,15 +549,38 @@ test('Deploy `api-env` fixture and test `now env` command', async t => {
|
||||
t.is(exitCode, 0, formatOutput({ stderr, stdout }));
|
||||
}
|
||||
|
||||
async function nowEnvRemoveWithNameOnly() {
|
||||
const vc = execa(
|
||||
binaryPath,
|
||||
['env', 'rm', 'VERCEL_URL', '-y', ...defaultArgs],
|
||||
{
|
||||
reject: false,
|
||||
cwd: target,
|
||||
}
|
||||
);
|
||||
|
||||
await waitForPrompt(
|
||||
vc,
|
||||
chunk =>
|
||||
chunk.includes('which Environments') && chunk.includes('VERCEL_URL')
|
||||
);
|
||||
vc.stdin.write('a\n'); // select all
|
||||
|
||||
const { exitCode, stderr, stdout } = await vc;
|
||||
t.is(exitCode, 0, formatOutput({ stderr, stdout }));
|
||||
}
|
||||
|
||||
await nowDeploy();
|
||||
await nowEnvLsIsEmpty();
|
||||
await nowEnvAdd();
|
||||
await nowEnvAddFromStdin();
|
||||
await nowEnvAddSystemEnv();
|
||||
await nowEnvLsIncludesVar();
|
||||
await nowEnvPull();
|
||||
await nowDeployWithVar();
|
||||
await nowEnvRemove();
|
||||
await nowEnvRemoveWithArgs();
|
||||
await nowEnvRemoveWithNameOnly();
|
||||
await nowEnvLsIsEmpty();
|
||||
});
|
||||
|
||||
@@ -1167,7 +1222,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
|
||||
@@ -1364,20 +1421,12 @@ test('ensure the `scope` property works with username', async t => {
|
||||
t.is(contentType, 'text/html; charset=utf-8');
|
||||
});
|
||||
|
||||
test('try to create a builds deployments with wrong config', async t => {
|
||||
test('try to create a builds deployments with wrong now.json', async t => {
|
||||
const directory = fixture('builds-wrong');
|
||||
|
||||
const { stderr, stdout, exitCode } = await execa(
|
||||
binaryPath,
|
||||
[
|
||||
directory,
|
||||
'--public',
|
||||
'--name',
|
||||
session,
|
||||
...defaultArgs,
|
||||
'--force',
|
||||
'--confirm',
|
||||
],
|
||||
[directory, '--public', ...defaultArgs, '--confirm'],
|
||||
{
|
||||
reject: false,
|
||||
}
|
||||
@@ -1391,7 +1440,30 @@ test('try to create a builds deployments with wrong config', async t => {
|
||||
t.is(exitCode, 1);
|
||||
t.true(
|
||||
stderr.includes(
|
||||
'Error! The property `builder` is not allowed in vercel.json – please remove it.'
|
||||
'Error! The property `builder` is not allowed in now.json – please remove it.'
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
test('try to create a builds deployments with wrong vercel.json', async t => {
|
||||
const directory = fixture('builds-wrong-vercel');
|
||||
|
||||
const { stderr, stdout, exitCode } = await execa(
|
||||
binaryPath,
|
||||
[directory, '--public', ...defaultArgs, '--confirm'],
|
||||
{
|
||||
reject: false,
|
||||
}
|
||||
);
|
||||
|
||||
console.log(stderr);
|
||||
console.log(stdout);
|
||||
console.log(exitCode);
|
||||
|
||||
t.is(exitCode, 1);
|
||||
t.true(
|
||||
stderr.includes(
|
||||
'Error! The property `fake` is not allowed in vercel.json – please remove it.'
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/client",
|
||||
"version": "7.1.1-canary.4",
|
||||
"version": "8.0.1",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"homepage": "https://vercel.com",
|
||||
|
||||
@@ -111,9 +111,10 @@ export default function buildCreateDeployment(version: number) {
|
||||
debug(`Deploying the provided path as single file`);
|
||||
}
|
||||
|
||||
let configPath: string | undefined;
|
||||
if (!nowConfig) {
|
||||
// If the user did not provide a config file, use the one in the root directory.
|
||||
const configPath = fileList
|
||||
configPath = fileList
|
||||
.map(f => relative(cwd, f))
|
||||
.find(f => f === 'vercel.json' || f === 'now.json');
|
||||
nowConfig = await parseNowJSON(configPath);
|
||||
@@ -126,7 +127,7 @@ export default function buildCreateDeployment(version: number) {
|
||||
nowConfig.files.length > 0
|
||||
) {
|
||||
// See the docs: https://vercel.com/docs/v1/features/configuration/#files-(array)
|
||||
debug('Filtering file list based on `files` key in vercel.json');
|
||||
debug(`Filtering file list based on \`files\` key in "${configPath}"`);
|
||||
const allowedFiles = new Set<string>(['Dockerfile']);
|
||||
const allowedDirs = new Set<string>();
|
||||
nowConfig.files.forEach(relPath => {
|
||||
|
||||
@@ -106,7 +106,10 @@ interface LegacyNowConfig {
|
||||
aliases?: string | string[];
|
||||
}
|
||||
|
||||
export const fileNameSymbol = Symbol('fileName');
|
||||
|
||||
export interface NowConfig extends LegacyNowConfig {
|
||||
[fileNameSymbol]?: string;
|
||||
name?: string;
|
||||
version?: number;
|
||||
env?: Dictionary<string>;
|
||||
|
||||
@@ -109,11 +109,16 @@ export async function getVercelIgnore(
|
||||
|
||||
const files = await Promise.all(
|
||||
cwds.map(async cwd => {
|
||||
let str = await maybeRead(join(cwd, '.vercelignore'), '');
|
||||
if (!str) {
|
||||
str = await maybeRead(join(cwd, '.nowignore'), '');
|
||||
const [vercelignore, nowignore] = await Promise.all([
|
||||
maybeRead(join(cwd, '.vercelignore'), ''),
|
||||
maybeRead(join(cwd, '.nowignore'), ''),
|
||||
]);
|
||||
if (vercelignore && nowignore) {
|
||||
throw new Error(
|
||||
'Cannot use both a `.vercelignore` and `.nowignore` file. Please delete the `.nowignore` file.'
|
||||
);
|
||||
}
|
||||
return str;
|
||||
return vercelignore || nowignore;
|
||||
})
|
||||
);
|
||||
|
||||
@@ -237,9 +242,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(' ') +
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user