mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-23 18:59:59 +00:00
Compare commits
52 Commits
@vercel/bu
...
@vercel/bu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4c13470df | ||
|
|
2a797b77b9 | ||
|
|
85a34126df | ||
|
|
92889c5376 | ||
|
|
66a7fa30b8 | ||
|
|
a7ba405503 | ||
|
|
84145245ba | ||
|
|
90d2e8b63b | ||
|
|
0d31fe8018 | ||
|
|
37d747c241 | ||
|
|
3f052d905f | ||
|
|
0b60467d2f | ||
|
|
4384a6104f | ||
|
|
f40f95ff37 | ||
|
|
90c05250b0 | ||
|
|
030880fe74 | ||
|
|
02bc88f33b | ||
|
|
38ff557cad | ||
|
|
47c34842d5 | ||
|
|
d21b215ad0 | ||
|
|
5827737fd5 | ||
|
|
a9e078d410 | ||
|
|
b4d9b17fb8 | ||
|
|
02c55bf634 | ||
|
|
08af15055f | ||
|
|
0597aaa5e4 | ||
|
|
176856a1ea | ||
|
|
375a55ebed | ||
|
|
7d33a05581 | ||
|
|
0377c8b737 | ||
|
|
662d546388 | ||
|
|
8c514b5608 | ||
|
|
a6ec53d9d3 | ||
|
|
3ad5903f70 | ||
|
|
3cf155e999 | ||
|
|
d9a298d97c | ||
|
|
487d3c8554 | ||
|
|
9d0bfd3656 | ||
|
|
ec75333569 | ||
|
|
51aab912a2 | ||
|
|
670b2653c0 | ||
|
|
f71686fdad | ||
|
|
ec9c8ce150 | ||
|
|
a2048fc6d3 | ||
|
|
09ff9cda9f | ||
|
|
3a4d6f7848 | ||
|
|
9a0d676c0d | ||
|
|
25cd7b9e6e | ||
|
|
f926d5516c | ||
|
|
4603383850 | ||
|
|
c0c57889c8 | ||
|
|
85908a0524 |
9
.github/CONTRIBUTING.md
vendored
9
.github/CONTRIBUTING.md
vendored
@@ -94,12 +94,3 @@ Sometimes you want to test changes to a Builder against an existing project, may
|
|||||||
4. Run `vercel *.tgz` to upload the tarball file and get a URL
|
4. Run `vercel *.tgz` to upload the tarball file and get a URL
|
||||||
5. Edit any existing `vercel.json` project and replace `use` with the URL
|
5. Edit any existing `vercel.json` project and replace `use` with the URL
|
||||||
6. Run `vercel` or `vercel dev` to deploy with the experimental Builder
|
6. Run `vercel` or `vercel dev` to deploy with the experimental Builder
|
||||||
|
|
||||||
## Add a New Framework
|
|
||||||
|
|
||||||
You can add support for a new Framework by creating a Pull Request for this repository and following the steps below:
|
|
||||||
|
|
||||||
1. Add the Framework to the `@vercel/frameworks` package: The file is located in `./packages/frameworks/frameworks.json`. You can copy the structure of an existing one and adjust the required fields. Note that the `settings` property either contains a `value` or a `placeholder`. The `value` property is used when something is not configurable, the `placeholder` is used when something is configurable and can be changed with configuration. An example would be the Output Directory for Hugo, it's `public` by default but can be changed through its config file, so we use `placeholder` with an explanation of what can be used.
|
|
||||||
2. Add an example to the `./examples` directory: The name of the directory should equal the slug of the framework used in `@vercel/frameworks`. The `.github/EXAMPLE_README_TEMPLATE.md` file can be used to create a `README.md` file for the example.
|
|
||||||
3. Update the `@vercel/static-build` package: The file `./packages/now-static-build/src/frameworks.ts` has to be extended. You can add default routes that will always be applied to projects that use this Framework or specify some paths that will be cached to speed up the build process.
|
|
||||||
4. After your Pull Request has been merged and released, other users can select the example on the Vercel dashboard and deploy it.
|
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ You're running Vercel CLI in a non-terminal context and there are no credentials
|
|||||||
|
|
||||||
#### Possible Ways to Fix It
|
#### Possible Ways to Fix It
|
||||||
|
|
||||||
- Specify a value for the `--token` flag (this needs to be the token of the user account as which you'd like to act). You can either get the token from the `./vercel/auth.json` file located in your user directory or [from the dashboard](https://vercel.com/account/tokens).
|
- Specify a value for the `--token` flag (this needs to be the token of the user account as which you'd like to act). You can create a new token on your [Settings page](https://vercel.com/account/tokens).
|
||||||
- Ensure that both `~/vercel/auth.json` and `~/vercel/config.json` exist
|
- Run `vercel login` to sign in and generate a new token
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { NowRequest, NowResponse } from '@now/node';
|
import { NowRequest, NowResponse } from '@vercel/node';
|
||||||
|
|
||||||
export default (_req: NowRequest, res: NowResponse) => {
|
export default (_req: NowRequest, res: NowResponse) => {
|
||||||
const date = new Date().toString();
|
const date = new Date().toString();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"react-helmet": "^5.2.0"
|
"react-helmet": "^5.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@now/node": "^1.3.0"
|
"@vercel/node": "1.8.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "gatsby develop",
|
"dev": "gatsby develop",
|
||||||
|
|||||||
@@ -1107,15 +1107,6 @@
|
|||||||
"@nodelib/fs.scandir" "2.1.3"
|
"@nodelib/fs.scandir" "2.1.3"
|
||||||
fastq "^1.6.0"
|
fastq "^1.6.0"
|
||||||
|
|
||||||
"@now/node@^1.3.0":
|
|
||||||
version "1.7.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/@now/node/-/node-1.7.1.tgz#764a0c6bcb24967f8014c4f73ad238c292996fe3"
|
|
||||||
integrity sha512-+srVKopsVTPDR3u9eOjJryZroLTrPp8XEOuIDGBdfFcJuS7qpAomctSbfyA7WNyjC0ExtUxELqBg5sAedG5+2g==
|
|
||||||
dependencies:
|
|
||||||
"@types/node" "*"
|
|
||||||
ts-node "8.9.1"
|
|
||||||
typescript "3.9.3"
|
|
||||||
|
|
||||||
"@pieh/friendly-errors-webpack-plugin@1.7.0-chalk-2":
|
"@pieh/friendly-errors-webpack-plugin@1.7.0-chalk-2":
|
||||||
version "1.7.0-chalk-2"
|
version "1.7.0-chalk-2"
|
||||||
resolved "https://registry.yarnpkg.com/@pieh/friendly-errors-webpack-plugin/-/friendly-errors-webpack-plugin-1.7.0-chalk-2.tgz#2e9da9d3ade9d18d013333eb408c457d04eabac0"
|
resolved "https://registry.yarnpkg.com/@pieh/friendly-errors-webpack-plugin/-/friendly-errors-webpack-plugin-1.7.0-chalk-2.tgz#2e9da9d3ade9d18d013333eb408c457d04eabac0"
|
||||||
@@ -1409,6 +1400,15 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
wonka "^4.0.14"
|
wonka "^4.0.14"
|
||||||
|
|
||||||
|
"@vercel/node@1.8.5":
|
||||||
|
version "1.8.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/@vercel/node/-/node-1.8.5.tgz#2c8b9532f1bb25734a9964c52973386ed78022d4"
|
||||||
|
integrity sha512-1iw7FSR8Oau6vZB1MWfBnA5q2a/IqRHiSZSbt8lz0dyTF599q8pc5GcSv/TvmrYaEGzh3+N0S4cbmuMCqVlwJg==
|
||||||
|
dependencies:
|
||||||
|
"@types/node" "*"
|
||||||
|
ts-node "8.9.1"
|
||||||
|
typescript "3.9.3"
|
||||||
|
|
||||||
"@webassemblyjs/ast@1.9.0":
|
"@webassemblyjs/ast@1.9.0":
|
||||||
version "1.9.0"
|
version "1.9.0"
|
||||||
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964"
|
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964"
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the
|
|||||||
|
|
||||||
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
|
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
|
||||||
|
|
||||||
|
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
|
||||||
|
|
||||||
|
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
|
||||||
|
|
||||||
## Learn More
|
## Learn More
|
||||||
|
|
||||||
To learn more about Next.js, take a look at the following resources:
|
To learn more about Next.js, take a look at the following resources:
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"start": "next start"
|
"start": "next start"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"next": "10.0.0",
|
"next": "10.0.5",
|
||||||
"react": "17.0.1",
|
"react": "17.0.1",
|
||||||
"react-dom": "17.0.1"
|
"react-dom": "17.0.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,6 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
margin-top: 3rem;
|
margin-top: 3rem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vercel/build-utils",
|
"name": "@vercel/build-utils",
|
||||||
"version": "2.6.1-canary.1",
|
"version": "2.7.1-canary.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"types": "./dist/index.d.js",
|
"types": "./dist/index.d.js",
|
||||||
|
|||||||
@@ -165,8 +165,8 @@ export function getSpawnOptions(
|
|||||||
export async function getNodeVersion(
|
export async function getNodeVersion(
|
||||||
destPath: string,
|
destPath: string,
|
||||||
_nodeVersion?: string,
|
_nodeVersion?: string,
|
||||||
_config?: Config,
|
config: Config = {},
|
||||||
meta?: Meta
|
meta: Meta = {}
|
||||||
): Promise<NodeVersion> {
|
): Promise<NodeVersion> {
|
||||||
if (meta && meta.isDev) {
|
if (meta && meta.isDev) {
|
||||||
// Use the system-installed version of `node` in PATH for `vercel dev`
|
// Use the system-installed version of `node` in PATH for `vercel dev`
|
||||||
@@ -174,13 +174,22 @@ export async function getNodeVersion(
|
|||||||
return { ...latest, runtime: 'nodejs' };
|
return { ...latest, runtime: 'nodejs' };
|
||||||
}
|
}
|
||||||
const { packageJson } = await scanParentDirs(destPath, true);
|
const { packageJson } = await scanParentDirs(destPath, true);
|
||||||
let range: string | undefined;
|
let { nodeVersion } = config;
|
||||||
let isAuto = true;
|
let isAuto = true;
|
||||||
if (packageJson && packageJson.engines && packageJson.engines.node) {
|
if (packageJson && packageJson.engines && packageJson.engines.node) {
|
||||||
range = packageJson.engines.node;
|
if (
|
||||||
|
nodeVersion &&
|
||||||
|
nodeVersion !== packageJson.engines.node &&
|
||||||
|
!meta.isDev
|
||||||
|
) {
|
||||||
|
console.warn(
|
||||||
|
'Warning: Due to `engines` existing in your `package.json` file, the Node Version defined in your Project Settings will not apply. Learn More: http://vercel.link/node-version'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
nodeVersion = packageJson.engines.node;
|
||||||
isAuto = false;
|
isAuto = false;
|
||||||
}
|
}
|
||||||
return getSupportedNodeVersion(range, isAuto);
|
return getSupportedNodeVersion(nodeVersion, isAuto);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function scanParentDirs(destPath: string, readPackageJson = false) {
|
async function scanParentDirs(destPath: string, readPackageJson = false) {
|
||||||
@@ -292,6 +301,11 @@ export async function runNpmInstall(
|
|||||||
opts.prettyCommand = 'yarn install';
|
opts.prettyCommand = 'yarn install';
|
||||||
command = 'yarn';
|
command = 'yarn';
|
||||||
commandArgs = ['install', ...args];
|
commandArgs = ['install', ...args];
|
||||||
|
|
||||||
|
// Yarn v2 PnP mode may be activated, so force "node-modules" linker style
|
||||||
|
if (!env.YARN_NODE_LINKER) {
|
||||||
|
env.YARN_NODE_LINKER = 'node-modules';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.NPM_ONLY_PRODUCTION) {
|
if (process.env.NPM_ONLY_PRODUCTION) {
|
||||||
@@ -388,10 +402,17 @@ export async function runPackageJsonScript(
|
|||||||
prettyCommand,
|
prettyCommand,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// Yarn v2 PnP mode may be activated, so force "node-modules" linker style
|
||||||
|
const env: typeof process.env = { ...spawnOpts?.env };
|
||||||
|
if (!env.YARN_NODE_LINKER) {
|
||||||
|
env.YARN_NODE_LINKER = 'node-modules';
|
||||||
|
}
|
||||||
|
|
||||||
const prettyCommand = `yarn run ${scriptName}`;
|
const prettyCommand = `yarn run ${scriptName}`;
|
||||||
console.log(`Running "${prettyCommand}"`);
|
console.log(`Running "${prettyCommand}"`);
|
||||||
await spawnAsync('yarn', ['run', scriptName], {
|
await spawnAsync('yarn', ['run', scriptName], {
|
||||||
...spawnOpts,
|
...spawnOpts,
|
||||||
|
env,
|
||||||
cwd: destPath,
|
cwd: destPath,
|
||||||
prettyCommand,
|
prettyCommand,
|
||||||
});
|
});
|
||||||
|
|||||||
5
packages/now-build-utils/test/fixtures/19-yarn-v2/api/index.js
vendored
Normal file
5
packages/now-build-utils/test/fixtures/19-yarn-v2/api/index.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
const { camelCase } = require('camel-case');
|
||||||
|
|
||||||
|
module.exports = (req, res) => {
|
||||||
|
res.end(camelCase('camel-case module is working'));
|
||||||
|
};
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 2,
|
|
||||||
"builds": [{ "src": "package.json", "use": "@vercel/static-build" }],
|
|
||||||
"probes": [{ "path": "/", "mustContain": "Svelte app" }]
|
|
||||||
}
|
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
"svelte": "^3.0.0"
|
"svelte": "^3.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"camel-case": "^4.1.2",
|
||||||
"sirv-cli": "^0.4.4"
|
"sirv-cli": "^0.4.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
packages/now-build-utils/test/fixtures/19-yarn-v2/vercel.json
vendored
Normal file
11
packages/now-build-utils/test/fixtures/19-yarn-v2/vercel.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"builds": [
|
||||||
|
{ "src": "package.json", "use": "@vercel/static-build" },
|
||||||
|
{ "src": "api/index.js", "use": "@vercel/node" }
|
||||||
|
],
|
||||||
|
"probes": [
|
||||||
|
{ "path": "/", "mustContain": "Svelte app" },
|
||||||
|
{ "path": "/api", "mustContain": "camelCaseModuleIsWorking" }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -270,6 +270,16 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"camel-case@npm:^4.1.2":
|
||||||
|
version: 4.1.2
|
||||||
|
resolution: "camel-case@npm:4.1.2"
|
||||||
|
dependencies:
|
||||||
|
pascal-case: ^3.1.2
|
||||||
|
tslib: ^2.0.3
|
||||||
|
checksum: 3/0b8dcfb424c9497e45984b88ef005c66bdf8e877e36365aedfc3cf73182684fde5a14cf2c526579c0351a5f27dc39a00f1edecc25d43606075fea948c504e37f
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"caseless@npm:~0.12.0":
|
"caseless@npm:~0.12.0":
|
||||||
version: 0.12.0
|
version: 0.12.0
|
||||||
resolution: "caseless@npm:0.12.0"
|
resolution: "caseless@npm:0.12.0"
|
||||||
@@ -850,6 +860,15 @@ fsevents@~2.1.2:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"lower-case@npm:^2.0.2":
|
||||||
|
version: 2.0.2
|
||||||
|
resolution: "lower-case@npm:2.0.2"
|
||||||
|
dependencies:
|
||||||
|
tslib: ^2.0.3
|
||||||
|
checksum: 3/aabaca9cef65f7564a1005b625664527e4d169e363101e65773f8f6ff2fdcf09884a3bc02990cd7a62cf05f3538114af25ee7bef553f1ca3208c8a77ac75cbfa
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"magic-string@npm:^0.25.2":
|
"magic-string@npm:^0.25.2":
|
||||||
version: 0.25.7
|
version: 0.25.7
|
||||||
resolution: "magic-string@npm:0.25.7"
|
resolution: "magic-string@npm:0.25.7"
|
||||||
@@ -944,6 +963,16 @@ fsevents@~2.1.2:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"no-case@npm:^3.0.4":
|
||||||
|
version: 3.0.4
|
||||||
|
resolution: "no-case@npm:3.0.4"
|
||||||
|
dependencies:
|
||||||
|
lower-case: ^2.0.2
|
||||||
|
tslib: ^2.0.3
|
||||||
|
checksum: 3/84db4909caec37504c6655f995a004067f8733be8cd8d849f1578661b60a1685e086325fa4e1a5e8ce94e7416c1d0f037e2a00f635a14457183de80ab4fc7612
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"node-gyp@npm:latest":
|
"node-gyp@npm:latest":
|
||||||
version: 6.1.0
|
version: 6.1.0
|
||||||
resolution: "node-gyp@npm:6.1.0"
|
resolution: "node-gyp@npm:6.1.0"
|
||||||
@@ -1057,6 +1086,16 @@ fsevents@~2.1.2:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"pascal-case@npm:^3.1.2":
|
||||||
|
version: 3.1.2
|
||||||
|
resolution: "pascal-case@npm:3.1.2"
|
||||||
|
dependencies:
|
||||||
|
no-case: ^3.0.4
|
||||||
|
tslib: ^2.0.3
|
||||||
|
checksum: 3/31708cecab221482edc81e2bd9b9d8282d72d4f1443b31f39725aa23768c5e42d93c4c014f1bc90f7f074e2a70d5091e4892ea370e550affc9ccf1d33c900bcd
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"path-is-absolute@npm:^1.0.0":
|
"path-is-absolute@npm:^1.0.0":
|
||||||
version: 1.0.1
|
version: 1.0.1
|
||||||
resolution: "path-is-absolute@npm:1.0.1"
|
resolution: "path-is-absolute@npm:1.0.1"
|
||||||
@@ -1447,6 +1486,7 @@ fsevents@~2.1.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@rollup/plugin-commonjs": ^12.0.0
|
"@rollup/plugin-commonjs": ^12.0.0
|
||||||
"@rollup/plugin-node-resolve": ^8.0.0
|
"@rollup/plugin-node-resolve": ^8.0.0
|
||||||
|
camel-case: ^4.1.2
|
||||||
rollup: ^2.3.4
|
rollup: ^2.3.4
|
||||||
rollup-plugin-livereload: ^1.0.0
|
rollup-plugin-livereload: ^1.0.0
|
||||||
rollup-plugin-svelte: ^5.0.3
|
rollup-plugin-svelte: ^5.0.3
|
||||||
@@ -1517,6 +1557,13 @@ fsevents@~2.1.2:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"tslib@npm:^2.0.3":
|
||||||
|
version: 2.0.3
|
||||||
|
resolution: "tslib@npm:2.0.3"
|
||||||
|
checksum: 3/447bfca5deaa157806c3f77eaba74d05dd0b38b014e47ce79d98b5c77ce7d91b00a687ba13ca1b5a74d35ca1098ac7a072c0a97fad06f0266612f2a03a6c8e8f
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"tunnel-agent@npm:^0.6.0":
|
"tunnel-agent@npm:^0.6.0":
|
||||||
version: 0.6.0
|
version: 0.6.0
|
||||||
resolution: "tunnel-agent@npm:0.6.0"
|
resolution: "tunnel-agent@npm:0.6.0"
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ for (const fixture of fs.readdirSync(fixturesPath)) {
|
|||||||
|
|
||||||
// few foreign tests
|
// few foreign tests
|
||||||
|
|
||||||
const buildersToTestWith = ['now-next', 'now-node', 'now-static-build'];
|
const buildersToTestWith = ['now-node'];
|
||||||
|
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
for (const builder of buildersToTestWith) {
|
for (const builder of buildersToTestWith) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "10.x"
|
"node": "10.x"
|
||||||
}
|
}
|
||||||
46
packages/now-build-utils/test/unit.test.js
vendored
46
packages/now-build-utils/test/unit.test.js
vendored
@@ -24,6 +24,19 @@ async function expectBuilderError(promise, pattern) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let warningMessages;
|
||||||
|
const originalConsoleWarn = console.warn;
|
||||||
|
beforeEach(() => {
|
||||||
|
warningMessages = [];
|
||||||
|
console.warn = m => {
|
||||||
|
warningMessages.push(m);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
console.warn = originalConsoleWarn;
|
||||||
|
});
|
||||||
|
|
||||||
it('should re-create symlinks properly', async () => {
|
it('should re-create symlinks properly', async () => {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
console.log('Skipping test on windows');
|
console.log('Skipping test on windows');
|
||||||
@@ -150,6 +163,39 @@ it('should ignore node version in vercel dev getNodeVersion()', async () => {
|
|||||||
).toHaveProperty('runtime', 'nodejs');
|
).toHaveProperty('runtime', 'nodejs');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should select project setting from config when no package.json is found', async () => {
|
||||||
|
expect(
|
||||||
|
await getNodeVersion('/tmp', undefined, { nodeVersion: '10.x' }, {})
|
||||||
|
).toHaveProperty('range', '10.x');
|
||||||
|
expect(warningMessages).toStrictEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should prefer package.json engines over project setting from config and warn', async () => {
|
||||||
|
expect(
|
||||||
|
await getNodeVersion(
|
||||||
|
path.join(__dirname, 'pkg-engine-node'),
|
||||||
|
undefined,
|
||||||
|
{ nodeVersion: '12.x' },
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
).toHaveProperty('range', '10.x');
|
||||||
|
expect(warningMessages).toStrictEqual([
|
||||||
|
'Warning: Due to `engines` existing in your `package.json` file, the Node Version defined in your Project Settings will not apply. Learn More: http://vercel.link/node-version',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not warn when package.json engines matches project setting from config', async () => {
|
||||||
|
expect(
|
||||||
|
await getNodeVersion(
|
||||||
|
path.join(__dirname, 'pkg-engine-node'),
|
||||||
|
undefined,
|
||||||
|
{ nodeVersion: '10.x' },
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
).toHaveProperty('range', '10.x');
|
||||||
|
expect(warningMessages).toStrictEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
it('should get latest node version', async () => {
|
it('should get latest node version', async () => {
|
||||||
expect(await getLatestNodeVersion()).toHaveProperty('major', 12);
|
expect(await getLatestNodeVersion()).toHaveProperty('major', 12);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vercel",
|
"name": "vercel",
|
||||||
"version": "21.0.2-canary.2",
|
"version": "21.1.1-canary.2",
|
||||||
"preferGlobal": true,
|
"preferGlobal": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"description": "The command-line interface for Vercel",
|
"description": "The command-line interface for Vercel",
|
||||||
@@ -61,11 +61,11 @@
|
|||||||
"node": ">= 10"
|
"node": ">= 10"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vercel/build-utils": "2.6.1-canary.1",
|
"@vercel/build-utils": "2.7.1-canary.1",
|
||||||
"@vercel/go": "1.1.6",
|
"@vercel/go": "1.1.7",
|
||||||
"@vercel/node": "1.8.6-canary.0",
|
"@vercel/node": "1.9.0",
|
||||||
"@vercel/python": "1.2.3",
|
"@vercel/python": "1.2.4",
|
||||||
"@vercel/ruby": "1.2.4",
|
"@vercel/ruby": "1.2.5",
|
||||||
"update-notifier": "4.1.0"
|
"update-notifier": "4.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import chalk from 'chalk';
|
|||||||
|
|
||||||
import { handleError } from '../../util/error';
|
import { handleError } from '../../util/error';
|
||||||
|
|
||||||
import createOutput from '../../util/output';
|
|
||||||
import getArgs from '../../util/get-args';
|
import getArgs from '../../util/get-args';
|
||||||
import getSubcommand from '../../util/get-subcommand';
|
import getSubcommand from '../../util/get-subcommand';
|
||||||
import logo from '../../util/output/logo';
|
import logo from '../../util/output/logo';
|
||||||
@@ -92,15 +91,14 @@ export default async function main(ctx) {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = createOutput({ debug: argv['--debug'] });
|
|
||||||
const { subcommand, args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
const { subcommand, args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
||||||
|
|
||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
case 'ls':
|
case 'ls':
|
||||||
return ls(ctx, argv, args, output);
|
return ls(ctx, argv, args);
|
||||||
case 'rm':
|
case 'rm':
|
||||||
return rm(ctx, argv, args, output);
|
return rm(ctx, argv, args);
|
||||||
default:
|
default:
|
||||||
return set(ctx, argv, args, output);
|
return set(ctx, argv, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ import strlen from '../../util/strlen.ts';
|
|||||||
import getCommandFlags from '../../util/get-command-flags';
|
import getCommandFlags from '../../util/get-command-flags';
|
||||||
import { getCommandName } from '../../util/pkg-name.ts';
|
import { getCommandName } from '../../util/pkg-name.ts';
|
||||||
|
|
||||||
export default async function ls(ctx, opts, args, output) {
|
export default async function ls(ctx, opts, args) {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
@@ -23,6 +24,7 @@ export default async function ls(ctx, opts, args, output) {
|
|||||||
token,
|
token,
|
||||||
currentTeam,
|
currentTeam,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
@@ -47,6 +49,7 @@ export default async function ls(ctx, opts, args, output) {
|
|||||||
token,
|
token,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
currentTeam,
|
currentTeam,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
const lsStamp = stamp();
|
const lsStamp = stamp();
|
||||||
let cancelWait;
|
let cancelWait;
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ import { isValidName } from '../../util/is-valid-name';
|
|||||||
import findAliasByAliasOrId from '../../util/alias/find-alias-by-alias-or-id';
|
import findAliasByAliasOrId from '../../util/alias/find-alias-by-alias-or-id';
|
||||||
import { getCommandName } from '../../util/pkg-name.ts';
|
import { getCommandName } from '../../util/pkg-name.ts';
|
||||||
|
|
||||||
export default async function rm(ctx, opts, args, output) {
|
export default async function rm(ctx, opts, args) {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
@@ -25,6 +26,7 @@ export default async function rm(ctx, opts, args, output) {
|
|||||||
token,
|
token,
|
||||||
currentTeam,
|
currentTeam,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
@@ -39,8 +41,13 @@ export default async function rm(ctx, opts, args, output) {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $FlowFixMe
|
const now = new Now({
|
||||||
const now = new Now({ apiUrl, token, debug: debugEnabled, currentTeam });
|
apiUrl,
|
||||||
|
token,
|
||||||
|
debug: debugEnabled,
|
||||||
|
currentTeam,
|
||||||
|
output,
|
||||||
|
});
|
||||||
const [aliasOrId] = args;
|
const [aliasOrId] = args;
|
||||||
|
|
||||||
if (args.length !== 1) {
|
if (args.length !== 1) {
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ type Options = {
|
|||||||
export default async function set(
|
export default async function set(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
localConfig,
|
localConfig,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
@@ -49,6 +49,7 @@ export default async function set(
|
|||||||
token,
|
token,
|
||||||
currentTeam,
|
currentTeam,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
|
|
||||||
let user: User;
|
let user: User;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import addBilling from './add';
|
|||||||
import exit from '../../util/exit';
|
import exit from '../../util/exit';
|
||||||
import Client from '../../util/client.ts';
|
import Client from '../../util/client.ts';
|
||||||
import getScope from '../../util/get-scope.ts';
|
import getScope from '../../util/get-scope.ts';
|
||||||
import createOutput from '../../util/output';
|
|
||||||
import { getPkgName } from '../../util/pkg-name.ts';
|
import { getPkgName } from '../../util/pkg-name.ts';
|
||||||
|
|
||||||
const help = () => {
|
const help = () => {
|
||||||
@@ -90,8 +89,9 @@ function buildInquirerChoices(cards) {
|
|||||||
const _default =
|
const _default =
|
||||||
source.id === cards.defaultSource ? ` ${chalk.bold('(default)')}` : '';
|
source.id === cards.defaultSource ? ` ${chalk.bold('(default)')}` : '';
|
||||||
const id = `${chalk.cyan(`ID: ${source.id}`)}${_default}`;
|
const id = `${chalk.cyan(`ID: ${source.id}`)}${_default}`;
|
||||||
const number = `${chalk.gray('#### ').repeat(3)}${source.last4 ||
|
const number = `${chalk.gray('#### ').repeat(3)}${
|
||||||
source.card.last4}`;
|
source.last4 || source.card.last4
|
||||||
|
}`;
|
||||||
const str = [
|
const str = [
|
||||||
id,
|
id,
|
||||||
indent(source.name || source.owner.name, 2),
|
indent(source.name || source.owner.name, 2),
|
||||||
@@ -106,11 +106,16 @@ function buildInquirerChoices(cards) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run({ token, config: { currentTeam } }) {
|
async function run({ token, output, config: { currentTeam } }) {
|
||||||
const start = new Date();
|
const start = new Date();
|
||||||
const creditCards = new NowCreditCards({ apiUrl, token, debug, currentTeam });
|
const creditCards = new NowCreditCards({
|
||||||
const output = createOutput({ debug });
|
apiUrl,
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
token,
|
||||||
|
debug,
|
||||||
|
currentTeam,
|
||||||
|
output,
|
||||||
|
});
|
||||||
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -147,8 +152,9 @@ async function run({ token, config: { currentTeam } }) {
|
|||||||
const id = `${chalk.gray('-')} ${chalk.cyan(
|
const id = `${chalk.gray('-')} ${chalk.cyan(
|
||||||
`ID: ${source.id}`
|
`ID: ${source.id}`
|
||||||
)}${_default}`;
|
)}${_default}`;
|
||||||
const number = `${chalk.gray('#### ').repeat(3)}${source.last4 ||
|
const number = `${chalk.gray('#### ').repeat(3)}${
|
||||||
source.card.last4}`;
|
source.last4 || source.card.last4
|
||||||
|
}`;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
id,
|
id,
|
||||||
@@ -231,8 +237,9 @@ async function run({ token, config: { currentTeam } }) {
|
|||||||
const elapsed = ms(new Date() - start);
|
const elapsed = ms(new Date() - start);
|
||||||
console.log(
|
console.log(
|
||||||
success(
|
success(
|
||||||
`${card.brand || card.card.brand} ending in ${card.last4 ||
|
`${card.brand || card.card.brand} ending in ${
|
||||||
card.card.last4} is now the default ${chalk.gray(`[${elapsed}]`)}`
|
card.last4 || card.card.last4
|
||||||
|
} is now the default ${chalk.gray(`[${elapsed}]`)}`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -301,9 +308,9 @@ async function run({ token, config: { currentTeam } }) {
|
|||||||
const deletedCard = cards.sources.find(card => card.id === cardId);
|
const deletedCard = cards.sources.find(card => card.id === cardId);
|
||||||
const remainingCards = cards.sources.filter(card => card.id !== cardId);
|
const remainingCards = cards.sources.filter(card => card.id !== cardId);
|
||||||
|
|
||||||
let text = `${deletedCard.brand ||
|
let text = `${deletedCard.brand || deletedCard.card.brand} ending in ${
|
||||||
deletedCard.card.brand} ending in ${deletedCard.last4 ||
|
deletedCard.last4 || deletedCard.card.last4
|
||||||
deletedCard.card.last4} was deleted`;
|
} was deleted`;
|
||||||
// ${chalk.gray(`[${elapsed}]`)}
|
// ${chalk.gray(`[${elapsed}]`)}
|
||||||
|
|
||||||
if (cardId === cards.defaultSource) {
|
if (cardId === cards.defaultSource) {
|
||||||
@@ -317,11 +324,11 @@ async function run({ token, config: { currentTeam } }) {
|
|||||||
card => card.id === cards.defaultCardId
|
card => card.id === cards.defaultCardId
|
||||||
);
|
);
|
||||||
|
|
||||||
text += `\n${newDefaultCard.brand ||
|
text += `\n${
|
||||||
newDefaultCard.card.brand} ending in ${newDefaultCard.last4 ||
|
newDefaultCard.brand || newDefaultCard.card.brand
|
||||||
newDefaultCard.card.last4} in now default for ${chalk.bold(
|
} ending in ${
|
||||||
contextName
|
newDefaultCard.last4 || newDefaultCard.card.last4
|
||||||
)}`;
|
} in now default for ${chalk.bold(contextName)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import stamp from '../../util/output/stamp';
|
|||||||
import createCertFromFile from '../../util/certs/create-cert-from-file';
|
import createCertFromFile from '../../util/certs/create-cert-from-file';
|
||||||
import createCertForCns from '../../util/certs/create-cert-for-cns';
|
import createCertForCns from '../../util/certs/create-cert-for-cns';
|
||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import { getCommandName } from '../../util/pkg-name';
|
import { getCommandName } from '../../util/pkg-name';
|
||||||
|
|
||||||
interface Options {
|
interface Options {
|
||||||
@@ -22,11 +21,11 @@ interface Options {
|
|||||||
async function add(
|
async function add(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
@@ -49,6 +48,7 @@ async function add(
|
|||||||
token,
|
token,
|
||||||
currentTeam,
|
currentTeam,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -62,7 +62,13 @@ async function add(
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = new Now({ apiUrl, token, debug: debugEnabled, currentTeam });
|
const now = new Now({
|
||||||
|
apiUrl,
|
||||||
|
token,
|
||||||
|
debug: debugEnabled,
|
||||||
|
currentTeam,
|
||||||
|
output,
|
||||||
|
});
|
||||||
|
|
||||||
if (overwite) {
|
if (overwite) {
|
||||||
output.error('Overwrite option is deprecated');
|
output.error('Overwrite option is deprecated');
|
||||||
@@ -71,7 +77,7 @@ async function add(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (crtPath || keyPath || caPath) {
|
if (crtPath || keyPath || caPath) {
|
||||||
if (args.length !== 0 || (!crtPath || !keyPath || !caPath)) {
|
if (args.length !== 0 || !crtPath || !keyPath || !caPath) {
|
||||||
output.error(
|
output.error(
|
||||||
`Invalid number of arguments to create a custom certificate entry. Usage:`
|
`Invalid number of arguments to create a custom certificate entry. Usage:`
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import chalk from 'chalk';
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { handleError } from '../../util/error';
|
import { handleError } from '../../util/error';
|
||||||
|
|
||||||
import createOutput from '../../util/output';
|
|
||||||
import getArgs from '../../util/get-args';
|
import getArgs from '../../util/get-args';
|
||||||
import getSubcommand from '../../util/get-subcommand';
|
import getSubcommand from '../../util/get-subcommand';
|
||||||
import logo from '../../util/output/logo';
|
import logo from '../../util/output/logo';
|
||||||
@@ -104,17 +103,17 @@ export default async function main(ctx: NowContext) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = createOutput({ debug: argv['--debug'] });
|
const { output } = ctx;
|
||||||
const { subcommand, args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
const { subcommand, args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
case 'issue':
|
case 'issue':
|
||||||
return issue(ctx, argv, args, output);
|
return issue(ctx, argv, args);
|
||||||
case 'ls':
|
case 'ls':
|
||||||
return ls(ctx, argv, args, output);
|
return ls(ctx, argv, args);
|
||||||
case 'rm':
|
case 'rm':
|
||||||
return rm(ctx, argv, args, output);
|
return rm(ctx, argv, args);
|
||||||
case 'add':
|
case 'add':
|
||||||
return add(ctx, argv, args, output);
|
return add(ctx, argv, args);
|
||||||
case 'renew':
|
case 'renew':
|
||||||
output.error('Renewing certificates is deprecated, issue a new one.');
|
output.error('Renewing certificates is deprecated, issue a new one.');
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ type Options = {
|
|||||||
export default async function issue(
|
export default async function issue(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
@@ -55,6 +55,7 @@ export default async function issue(
|
|||||||
token,
|
token,
|
||||||
currentTeam,
|
currentTeam,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import getScope from '../../util/get-scope';
|
|||||||
import stamp from '../../util/output/stamp';
|
import stamp from '../../util/output/stamp';
|
||||||
import getCerts from '../../util/certs/get-certs';
|
import getCerts from '../../util/certs/get-certs';
|
||||||
import strlen from '../../util/strlen';
|
import strlen from '../../util/strlen';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import { NowContext, Cert } from '../../types';
|
import { NowContext, Cert } from '../../types';
|
||||||
import getCommandFlags from '../../util/get-command-flags';
|
import getCommandFlags from '../../util/get-command-flags';
|
||||||
import { getCommandName } from '../../util/pkg-name';
|
import { getCommandName } from '../../util/pkg-name';
|
||||||
@@ -21,17 +20,17 @@ interface Options {
|
|||||||
async function ls(
|
async function ls(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
const { apiUrl } = ctx;
|
||||||
const { '--debug': debug, '--next': nextTimestamp } = opts;
|
const { '--debug': debug, '--next': nextTimestamp } = opts;
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -48,7 +47,7 @@ async function ls(
|
|||||||
output.error('Please provide a number for flag --next');
|
output.error('Please provide a number for flag --next');
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
const now = new Now({ apiUrl, token, debug, currentTeam });
|
const now = new Now({ apiUrl, token, debug, currentTeam, output });
|
||||||
const lsStamp = stamp();
|
const lsStamp = stamp();
|
||||||
|
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
|
|||||||
@@ -18,21 +18,17 @@ type Options = {
|
|||||||
'--debug': boolean;
|
'--debug': boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function rm(
|
async function rm(ctx: NowContext, opts: Options, args: string[]) {
|
||||||
ctx: NowContext,
|
|
||||||
opts: Options,
|
|
||||||
args: string[],
|
|
||||||
output: Output
|
|
||||||
) {
|
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
const { apiUrl } = ctx;
|
||||||
const rmStamp = stamp();
|
const rmStamp = stamp();
|
||||||
const debug = opts['--debug'];
|
const debug = opts['--debug'];
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
|
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { resolve, basename } from 'path';
|
|||||||
import { fileNameSymbol } from '@vercel/client';
|
import { fileNameSymbol } from '@vercel/client';
|
||||||
import Client from '../../util/client.ts';
|
import Client from '../../util/client.ts';
|
||||||
import getScope from '../../util/get-scope.ts';
|
import getScope from '../../util/get-scope.ts';
|
||||||
import createOutput from '../../util/output';
|
|
||||||
import code from '../../util/output/code';
|
import code from '../../util/output/code';
|
||||||
import highlight from '../../util/output/highlight';
|
import highlight from '../../util/output/highlight';
|
||||||
import { readLocalConfig } from '../../util/config/files';
|
import { readLocalConfig } from '../../util/config/files';
|
||||||
@@ -15,6 +14,7 @@ import deploy from './latest';
|
|||||||
export default async ctx => {
|
export default async ctx => {
|
||||||
const {
|
const {
|
||||||
authConfig,
|
authConfig,
|
||||||
|
output,
|
||||||
config: { currentTeam },
|
config: { currentTeam },
|
||||||
apiUrl,
|
apiUrl,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
@@ -48,7 +48,6 @@ export default async ctx => {
|
|||||||
localConfig = readLocalConfig(paths[0]);
|
localConfig = readLocalConfig(paths[0]);
|
||||||
}
|
}
|
||||||
const debugEnabled = argv['--debug'];
|
const debugEnabled = argv['--debug'];
|
||||||
const output = createOutput({ debug: debugEnabled });
|
|
||||||
const stats = {};
|
const stats = {};
|
||||||
|
|
||||||
if (argv['--help']) {
|
if (argv['--help']) {
|
||||||
@@ -74,6 +73,7 @@ export default async ctx => {
|
|||||||
apiUrl,
|
apiUrl,
|
||||||
token: authConfig.token,
|
token: authConfig.token,
|
||||||
currentTeam,
|
currentTeam,
|
||||||
|
output,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -233,8 +233,7 @@ export default async function main(
|
|||||||
const paths = Object.keys(stats);
|
const paths = Object.keys(stats);
|
||||||
const debugEnabled = argv['--debug'];
|
const debugEnabled = argv['--debug'];
|
||||||
|
|
||||||
// $FlowFixMe
|
const { isTTY } = process.stdout;
|
||||||
const isTTY = process.stdout.isTTY;
|
|
||||||
const quiet = !isTTY;
|
const quiet = !isTTY;
|
||||||
|
|
||||||
// check paths
|
// check paths
|
||||||
@@ -263,6 +262,7 @@ export default async function main(
|
|||||||
apiUrl: ctx.apiUrl,
|
apiUrl: ctx.apiUrl,
|
||||||
token: ctx.authConfig.token,
|
token: ctx.authConfig.token,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
|
|
||||||
// retrieve `project` and `org` from .vercel
|
// retrieve `project` and `org` from .vercel
|
||||||
@@ -645,6 +645,7 @@ export default async function main(
|
|||||||
token: ctx.authConfig.token,
|
token: ctx.authConfig.token,
|
||||||
currentTeam: org.id,
|
currentTeam: org.id,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
}),
|
}),
|
||||||
err.meta.domain,
|
err.meta.domain,
|
||||||
contextName
|
contextName
|
||||||
@@ -727,6 +728,7 @@ export default async function main(
|
|||||||
token: ctx.authConfig.token,
|
token: ctx.authConfig.token,
|
||||||
currentTeam: org.type === 'team' ? org.id : null,
|
currentTeam: org.type === 'team' ? org.id : null,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
}),
|
}),
|
||||||
deployment,
|
deployment,
|
||||||
deployStamp,
|
deployStamp,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { resolve, join } from 'path';
|
|||||||
|
|
||||||
import DevServer from '../../util/dev/server';
|
import DevServer from '../../util/dev/server';
|
||||||
import parseListen from '../../util/dev/parse-listen';
|
import parseListen from '../../util/dev/parse-listen';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import { NowContext, ProjectEnvVariable } from '../../types';
|
import { NowContext, ProjectEnvVariable } from '../../types';
|
||||||
import Client from '../../util/client';
|
import Client from '../../util/client';
|
||||||
import { getLinkedProject } from '../../util/projects/link';
|
import { getLinkedProject } from '../../util/projects/link';
|
||||||
@@ -22,9 +21,9 @@ type Options = {
|
|||||||
export default async function dev(
|
export default async function dev(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
|
const { output } = ctx;
|
||||||
const [dir = '.'] = args;
|
const [dir = '.'] = args;
|
||||||
let cwd = resolve(dir);
|
let cwd = resolve(dir);
|
||||||
const listen = parseListen(opts['--listen'] || '3000');
|
const listen = parseListen(opts['--listen'] || '3000');
|
||||||
@@ -35,6 +34,7 @@ export default async function dev(
|
|||||||
token: ctx.authConfig.token,
|
token: ctx.authConfig.token,
|
||||||
currentTeam: ctx.config.currentTeam,
|
currentTeam: ctx.config.currentTeam,
|
||||||
debug,
|
debug,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
|
|
||||||
// retrieve dev command
|
// retrieve dev command
|
||||||
@@ -49,7 +49,6 @@ export default async function dev(
|
|||||||
|
|
||||||
link = await setupAndLink(
|
link = await setupAndLink(
|
||||||
ctx,
|
ctx,
|
||||||
output,
|
|
||||||
cwd,
|
cwd,
|
||||||
forceDelete,
|
forceDelete,
|
||||||
autoConfirm,
|
autoConfirm,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import getSubcommand from '../../util/get-subcommand';
|
|||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import { NowError } from '../../util/now-error';
|
import { NowError } from '../../util/now-error';
|
||||||
import handleError from '../../util/handle-error';
|
import handleError from '../../util/handle-error';
|
||||||
import createOutput from '../../util/output/create-output';
|
|
||||||
import logo from '../../util/output/logo';
|
import logo from '../../util/output/logo';
|
||||||
import cmd from '../../util/output/cmd';
|
import cmd from '../../util/output/cmd';
|
||||||
import highlight from '../../util/output/highlight';
|
import highlight from '../../util/output/highlight';
|
||||||
@@ -51,7 +50,7 @@ const help = () => {
|
|||||||
export default async function main(ctx: NowContext) {
|
export default async function main(ctx: NowContext) {
|
||||||
let argv;
|
let argv;
|
||||||
let args;
|
let args;
|
||||||
let output;
|
const { output } = ctx;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
argv = getArgs(ctx.argv.slice(2), {
|
argv = getArgs(ctx.argv.slice(2), {
|
||||||
@@ -63,9 +62,7 @@ export default async function main(ctx: NowContext) {
|
|||||||
'--port': Number,
|
'--port': Number,
|
||||||
'-p': '--port',
|
'-p': '--port',
|
||||||
});
|
});
|
||||||
const debug = argv['--debug'];
|
|
||||||
args = getSubcommand(argv._.slice(1), COMMAND_CONFIG).args;
|
args = getSubcommand(argv._.slice(1), COMMAND_CONFIG).args;
|
||||||
output = createOutput({ debug });
|
|
||||||
|
|
||||||
if ('--port' in argv) {
|
if ('--port' in argv) {
|
||||||
output.warn('`--port` is deprecated, please use `--listen` instead');
|
output.warn('`--port` is deprecated, please use `--listen` instead');
|
||||||
@@ -120,7 +117,7 @@ export default async function main(ctx: NowContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await dev(ctx, argv, args, output);
|
return await dev(ctx, argv, args);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code === 'ENOTFOUND') {
|
if (err.code === 'ENOTFOUND') {
|
||||||
// Error message will look like the following:
|
// Error message will look like the following:
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
DNSInvalidType,
|
DNSInvalidType,
|
||||||
} from '../../util/errors-ts';
|
} from '../../util/errors-ts';
|
||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import addDNSRecord from '../../util/dns/add-dns-record';
|
import addDNSRecord from '../../util/dns/add-dns-record';
|
||||||
import Client from '../../util/client';
|
import Client from '../../util/client';
|
||||||
import getScope from '../../util/get-scope';
|
import getScope from '../../util/get-scope';
|
||||||
@@ -22,17 +21,17 @@ type Options = {
|
|||||||
export default async function add(
|
export default async function add(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
|
apiUrl,
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
|
||||||
const debug = opts['--debug'];
|
const debug = opts['--debug'];
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import Client from '../../util/client';
|
import Client from '../../util/client';
|
||||||
import getScope from '../../util/get-scope';
|
import getScope from '../../util/get-scope';
|
||||||
import { DomainNotFound, InvalidDomain } from '../../util/errors-ts';
|
import { DomainNotFound, InvalidDomain } from '../../util/errors-ts';
|
||||||
@@ -15,17 +14,17 @@ type Options = {
|
|||||||
export default async function add(
|
export default async function add(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
|
apiUrl,
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
|
||||||
const debug = opts['--debug'];
|
const debug = opts['--debug'];
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import createOutput from '../../util/output';
|
|
||||||
import getArgs from '../../util/get-args';
|
import getArgs from '../../util/get-args';
|
||||||
import getSubcommand from '../../util/get-subcommand';
|
import getSubcommand from '../../util/get-subcommand';
|
||||||
import handleError from '../../util/handle-error';
|
import handleError from '../../util/handle-error';
|
||||||
@@ -112,16 +111,15 @@ export default async function main(ctx: NowContext) {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = createOutput({ debug: argv['--debug'] });
|
|
||||||
const { subcommand, args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
const { subcommand, args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
case 'add':
|
case 'add':
|
||||||
return add(ctx, argv, args, output);
|
return add(ctx, argv, args);
|
||||||
case 'import':
|
case 'import':
|
||||||
return importZone(ctx, argv, args, output);
|
return importZone(ctx, argv, args);
|
||||||
case 'rm':
|
case 'rm':
|
||||||
return rm(ctx, argv, args, output);
|
return rm(ctx, argv, args);
|
||||||
default:
|
default:
|
||||||
return ls(ctx, argv, args, output);
|
return ls(ctx, argv, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import ms from 'ms';
|
import ms from 'ms';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import { DomainNotFound } from '../../util/errors-ts';
|
import { DomainNotFound } from '../../util/errors-ts';
|
||||||
import { DNSRecord, NowContext } from '../../types';
|
import { DNSRecord, NowContext } from '../../types';
|
||||||
import Client from '../../util/client';
|
import Client from '../../util/client';
|
||||||
@@ -22,17 +21,17 @@ type Options = {
|
|||||||
export default async function ls(
|
export default async function ls(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
|
apiUrl,
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
|
||||||
const { '--debug': debug, '--next': nextTimestamp } = opts;
|
const { '--debug': debug, '--next': nextTimestamp } = opts;
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -17,17 +17,17 @@ type Options = {
|
|||||||
export default async function rm(
|
export default async function rm(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
|
apiUrl,
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
|
||||||
const debug = opts['--debug'];
|
const debug = opts['--debug'];
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await getScope(client);
|
await getScope(client);
|
||||||
@@ -100,12 +100,7 @@ function readConfirmation(
|
|||||||
process.stdin
|
process.stdin
|
||||||
.on('data', d => {
|
.on('data', d => {
|
||||||
process.stdin.pause();
|
process.stdin.pause();
|
||||||
resolve(
|
resolve(d.toString().trim().toLowerCase() === 'y');
|
||||||
d
|
|
||||||
.toString()
|
|
||||||
.trim()
|
|
||||||
.toLowerCase() === 'y'
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.resume();
|
.resume();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import * as ERRORS from '../../util/errors-ts';
|
import * as ERRORS from '../../util/errors-ts';
|
||||||
import Client from '../../util/client';
|
import Client from '../../util/client';
|
||||||
import formatNSTable from '../../util/format-ns-table';
|
import formatNSTable from '../../util/format-ns-table';
|
||||||
@@ -24,18 +23,18 @@ type Options = {
|
|||||||
export default async function add(
|
export default async function add(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
const { apiUrl } = ctx;
|
||||||
const debug = opts['--debug'];
|
const debug = opts['--debug'];
|
||||||
const force = opts['--force'];
|
const force = opts['--force'];
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import chalk from 'chalk';
|
|||||||
import psl from 'psl';
|
import psl from 'psl';
|
||||||
|
|
||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import * as ERRORS from '../../util/errors-ts';
|
import * as ERRORS from '../../util/errors-ts';
|
||||||
import Client from '../../util/client';
|
import Client from '../../util/client';
|
||||||
import getDomainPrice from '../../util/domains/get-domain-price';
|
import getDomainPrice from '../../util/domains/get-domain-price';
|
||||||
@@ -21,17 +20,17 @@ type Options = {
|
|||||||
export default async function buy(
|
export default async function buy(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
const { apiUrl } = ctx;
|
||||||
const debug = opts['--debug'];
|
const debug = opts['--debug'];
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -70,7 +69,10 @@ export default async function buy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const availableStamp = stamp();
|
const availableStamp = stamp();
|
||||||
const domainPrice = await getDomainPrice(client, domainName);
|
const [domainPrice, renewalPrice] = await Promise.all([
|
||||||
|
getDomainPrice(client, domainName),
|
||||||
|
getDomainPrice(client, domainName, 'renewal'),
|
||||||
|
]);
|
||||||
|
|
||||||
if (domainPrice instanceof Error) {
|
if (domainPrice instanceof Error) {
|
||||||
output.prettyError(domainPrice);
|
output.prettyError(domainPrice);
|
||||||
@@ -102,12 +104,21 @@ export default async function buy(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const autoRenew = await promptBool(
|
||||||
|
renewalPrice.period === 1
|
||||||
|
? `Auto renew yearly for ${chalk.bold(`$${price}`)}?`
|
||||||
|
: `Auto renew every ${renewalPrice.period} years for ${chalk.bold(
|
||||||
|
`$${price}`
|
||||||
|
)}?`,
|
||||||
|
{ defaultValue: true }
|
||||||
|
);
|
||||||
|
|
||||||
let buyResult;
|
let buyResult;
|
||||||
const purchaseStamp = stamp();
|
const purchaseStamp = stamp();
|
||||||
const stopPurchaseSpinner = output.spinner('Purchasing');
|
const stopPurchaseSpinner = output.spinner('Purchasing');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
buyResult = await purchaseDomain(client, domainName, price);
|
buyResult = await purchaseDomain(client, domainName, price, autoRenew);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
stopPurchaseSpinner();
|
stopPurchaseSpinner();
|
||||||
output.error(
|
output.error(
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import createOutput from '../../util/output';
|
|
||||||
import getArgs from '../../util/get-args';
|
import getArgs from '../../util/get-args';
|
||||||
import getSubcommand from '../../util/get-subcommand';
|
import getSubcommand from '../../util/get-subcommand';
|
||||||
import handleError from '../../util/handle-error';
|
import handleError from '../../util/handle-error';
|
||||||
@@ -106,24 +105,23 @@ export default async function main(ctx: NowContext) {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = createOutput({ debug: argv['--debug'] });
|
|
||||||
const { subcommand, args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
const { subcommand, args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
case 'add':
|
case 'add':
|
||||||
return add(ctx, argv, args, output);
|
return add(ctx, argv, args);
|
||||||
case 'inspect':
|
case 'inspect':
|
||||||
return inspect(ctx, argv, args, output);
|
return inspect(ctx, argv, args);
|
||||||
case 'move':
|
case 'move':
|
||||||
return move(ctx, argv, args, output);
|
return move(ctx, argv, args);
|
||||||
case 'buy':
|
case 'buy':
|
||||||
return buy(ctx, argv, args, output);
|
return buy(ctx, argv, args);
|
||||||
case 'rm':
|
case 'rm':
|
||||||
return rm(ctx, argv, args, output);
|
return rm(ctx, argv, args);
|
||||||
case 'transferIn':
|
case 'transferIn':
|
||||||
return transferIn(ctx, argv, args, output);
|
return transferIn(ctx, argv, args);
|
||||||
case 'verify':
|
case 'verify':
|
||||||
return verify(ctx, argv, args, output);
|
return verify(ctx, argv, args);
|
||||||
default:
|
default:
|
||||||
return ls(ctx, argv, args, output);
|
return ls(ctx, argv, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,17 +24,17 @@ type Options = {
|
|||||||
export default async function inspect(
|
export default async function inspect(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
const { apiUrl } = ctx;
|
||||||
const debug = opts['--debug'];
|
const debug = opts['--debug'];
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
|
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import Client from '../../util/client';
|
|||||||
import getDomains from '../../util/domains/get-domains';
|
import getDomains from '../../util/domains/get-domains';
|
||||||
import getScope from '../../util/get-scope';
|
import getScope from '../../util/get-scope';
|
||||||
import stamp from '../../util/output/stamp';
|
import stamp from '../../util/output/stamp';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import formatTable from '../../util/format-table';
|
import formatTable from '../../util/format-table';
|
||||||
import { formatDateWithoutTime } from '../../util/format-date';
|
import { formatDateWithoutTime } from '../../util/format-date';
|
||||||
import { Domain, NowContext } from '../../types';
|
import { Domain, NowContext } from '../../types';
|
||||||
@@ -24,17 +23,17 @@ type Options = {
|
|||||||
export default async function ls(
|
export default async function ls(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
const { apiUrl } = ctx;
|
||||||
const { '--debug': debug, '--next': nextTimestamp } = opts;
|
const { '--debug': debug, '--next': nextTimestamp } = opts;
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
if (typeof nextTimestamp !== undefined && Number.isNaN(nextTimestamp)) {
|
if (typeof nextTimestamp !== undefined && Number.isNaN(nextTimestamp)) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import chalk from 'chalk';
|
|||||||
import plural from 'pluralize';
|
import plural from 'pluralize';
|
||||||
|
|
||||||
import { NowContext, User, Team } from '../../types';
|
import { NowContext, User, Team } from '../../types';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import * as ERRORS from '../../util/errors-ts';
|
import * as ERRORS from '../../util/errors-ts';
|
||||||
import Client from '../../util/client';
|
import Client from '../../util/client';
|
||||||
import getScope from '../../util/get-scope';
|
import getScope from '../../util/get-scope';
|
||||||
@@ -25,17 +24,17 @@ type Options = {
|
|||||||
export default async function move(
|
export default async function move(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
const { apiUrl } = ctx;
|
||||||
const debug = opts['--debug'];
|
const debug = opts['--debug'];
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
let user = null;
|
let user = null;
|
||||||
|
|
||||||
|
|||||||
@@ -26,17 +26,17 @@ type Options = {
|
|||||||
export default async function rm(
|
export default async function rm(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
const { apiUrl } = ctx;
|
||||||
const debug = opts['--debug'];
|
const debug = opts['--debug'];
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
const [domainName] = args;
|
const [domainName] = args;
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import * as ERRORS from '../../util/errors-ts';
|
import * as ERRORS from '../../util/errors-ts';
|
||||||
import Client from '../../util/client';
|
import Client from '../../util/client';
|
||||||
import getScope from '../../util/get-scope';
|
import getScope from '../../util/get-scope';
|
||||||
@@ -24,17 +23,17 @@ type Options = {
|
|||||||
export default async function transferIn(
|
export default async function transferIn(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
const { apiUrl } = ctx;
|
||||||
const debug = opts['--debug'];
|
const debug = opts['--debug'];
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import { Output } from '../../util/output';
|
|
||||||
import { NowBuildError } from '@vercel/build-utils';
|
import { NowBuildError } from '@vercel/build-utils';
|
||||||
import { getCommandName } from '../../util/pkg-name';
|
import { getCommandName } from '../../util/pkg-name';
|
||||||
|
|
||||||
export default async function verify(
|
export default async function verify(
|
||||||
_ctx: NowContext,
|
{ output }: NowContext,
|
||||||
_opts: {},
|
_opts: {},
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
const [domainName] = args;
|
const [domainName] = args;
|
||||||
|
|
||||||
|
|||||||
12
packages/now-cli/src/commands/env/add.ts
vendored
12
packages/now-cli/src/commands/env/add.ts
vendored
@@ -122,7 +122,17 @@ export default async function add(
|
|||||||
const existing = new Set(
|
const existing = new Set(
|
||||||
envs.filter(r => r.key === envName).map(r => r.target)
|
envs.filter(r => r.key === envName).map(r => r.target)
|
||||||
);
|
);
|
||||||
const choices = getEnvTargetChoices().filter(c => !existing.has(c.value));
|
const choices = getEnvTargetChoices().filter(c => {
|
||||||
|
// hide Development if "Secret" is chosen
|
||||||
|
if (
|
||||||
|
envType === ProjectEnvType.Secret &&
|
||||||
|
c.value === ProjectEnvTarget.Development
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !existing.has(c.value);
|
||||||
|
});
|
||||||
|
|
||||||
if (choices.length === 0) {
|
if (choices.length === 0) {
|
||||||
output.error(
|
output.error(
|
||||||
|
|||||||
7
packages/now-cli/src/commands/env/index.ts
vendored
7
packages/now-cli/src/commands/env/index.ts
vendored
@@ -1,7 +1,6 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import createOutput from '../../util/output';
|
|
||||||
import getArgs from '../../util/get-args';
|
import getArgs from '../../util/get-args';
|
||||||
import getSubcommand from '../../util/get-subcommand';
|
import getSubcommand from '../../util/get-subcommand';
|
||||||
import getInvalidSubcommand from '../../util/get-invalid-subcommand';
|
import getInvalidSubcommand from '../../util/get-invalid-subcommand';
|
||||||
@@ -109,15 +108,15 @@ export default async function main(ctx: NowContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const debug = argv['--debug'];
|
const debug = argv['--debug'];
|
||||||
const output = createOutput({ debug });
|
|
||||||
const { subcommand, args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
const { subcommand, args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
apiUrl,
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const { apiUrl } = ctx;
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
|
||||||
const link = await getLinkedProject(output, client);
|
const link = await getLinkedProject(output, client);
|
||||||
if (link.status === 'error') {
|
if (link.status === 'error') {
|
||||||
return link.exitCode;
|
return link.exitCode;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import getArgs from '../../util/get-args';
|
|||||||
import getSubcommand from '../../util/get-subcommand';
|
import getSubcommand from '../../util/get-subcommand';
|
||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import handleError from '../../util/handle-error';
|
import handleError from '../../util/handle-error';
|
||||||
import createOutput from '../../util/output/create-output';
|
|
||||||
import logo from '../../util/output/logo';
|
import logo from '../../util/output/logo';
|
||||||
import error from '../../util/output/error';
|
import error from '../../util/output/error';
|
||||||
import init from './init';
|
import init from './init';
|
||||||
@@ -47,7 +46,6 @@ const help = () => {
|
|||||||
export default async function main(ctx: NowContext) {
|
export default async function main(ctx: NowContext) {
|
||||||
let argv;
|
let argv;
|
||||||
let args;
|
let args;
|
||||||
let output;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
argv = getArgs(ctx.argv.slice(2), {
|
argv = getArgs(ctx.argv.slice(2), {
|
||||||
@@ -55,7 +53,6 @@ export default async function main(ctx: NowContext) {
|
|||||||
'-f': Boolean,
|
'-f': Boolean,
|
||||||
});
|
});
|
||||||
args = getSubcommand(argv._.slice(1), COMMAND_CONFIG).args;
|
args = getSubcommand(argv._.slice(1), COMMAND_CONFIG).args;
|
||||||
output = createOutput({ debug: argv['--debug'] });
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
handleError(err);
|
handleError(err);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -67,15 +64,15 @@ export default async function main(ctx: NowContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argv._.length > 3) {
|
if (argv._.length > 3) {
|
||||||
output.error('Too much arguments.');
|
ctx.output.error('Too much arguments.');
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await init(ctx, argv, args, output);
|
return await init(ctx, argv, args);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(error(err.message));
|
console.log(error(err.message));
|
||||||
output.debug(err.stack);
|
ctx.output.debug(err.stack);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ const EXAMPLE_API = 'https://now-example-files.zeit.sh';
|
|||||||
export default async function init(
|
export default async function init(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
args: string[],
|
args: string[]
|
||||||
output: Output
|
|
||||||
) {
|
) {
|
||||||
|
const { output } = ctx;
|
||||||
const [name, dir] = args;
|
const [name, dir] = args;
|
||||||
const force = opts['-f'] || opts['--force'];
|
const force = opts['-f'] || opts['--force'];
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import getArgs from '../util/get-args';
|
|||||||
import buildsList from '../util/output/builds';
|
import buildsList from '../util/output/builds';
|
||||||
import routesList from '../util/output/routes';
|
import routesList from '../util/output/routes';
|
||||||
import indent from '../util/output/indent';
|
import indent from '../util/output/indent';
|
||||||
import createOutput from '../util/output';
|
|
||||||
import Now from '../util';
|
import Now from '../util';
|
||||||
import logo from '../util/output/logo';
|
import logo from '../util/output/logo';
|
||||||
import elapsed from '../util/output/elapsed.ts';
|
import elapsed from '../util/output/elapsed.ts';
|
||||||
@@ -59,9 +58,13 @@ export default async function main(ctx) {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiUrl = ctx.apiUrl;
|
const {
|
||||||
|
apiUrl,
|
||||||
|
output,
|
||||||
|
authConfig: { token },
|
||||||
|
config,
|
||||||
|
} = ctx;
|
||||||
const debugEnabled = argv['--debug'];
|
const debugEnabled = argv['--debug'];
|
||||||
const output = createOutput({ debug: debugEnabled });
|
|
||||||
const { print, log, error } = output;
|
const { print, log, error } = output;
|
||||||
|
|
||||||
// extract the first parameter
|
// extract the first parameter
|
||||||
@@ -73,16 +76,13 @@ export default async function main(ctx) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
|
||||||
authConfig: { token },
|
|
||||||
config,
|
|
||||||
} = ctx;
|
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
apiUrl,
|
apiUrl,
|
||||||
token,
|
token,
|
||||||
currentTeam,
|
currentTeam,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
@@ -90,25 +90,30 @@ export default async function main(ctx) {
|
|||||||
({ contextName } = await getScope(client));
|
({ contextName } = await getScope(client));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||||
output.error(err.message);
|
error(err.message);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = new Now({ apiUrl, token, debug: debugEnabled, currentTeam });
|
const now = new Now({
|
||||||
|
apiUrl,
|
||||||
|
token,
|
||||||
|
debug: debugEnabled,
|
||||||
|
currentTeam,
|
||||||
|
output,
|
||||||
|
});
|
||||||
|
|
||||||
// resolve the deployment, since we might have been given an alias
|
// resolve the deployment, since we might have been given an alias
|
||||||
const depFetchStart = Date.now();
|
const depFetchStart = Date.now();
|
||||||
const cancelWait = output.spinner(
|
output.spinner(
|
||||||
`Fetching deployment "${deploymentIdOrHost}" in ${chalk.bold(contextName)}`
|
`Fetching deployment "${deploymentIdOrHost}" in ${chalk.bold(contextName)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deployment = await now.findDeployment(deploymentIdOrHost);
|
deployment = await now.findDeployment(deploymentIdOrHost);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
cancelWait();
|
|
||||||
if (err.status === 404) {
|
if (err.status === 404) {
|
||||||
error(
|
error(
|
||||||
`Failed to find deployment "${deploymentIdOrHost}" in ${chalk.bold(
|
`Failed to find deployment "${deploymentIdOrHost}" in ${chalk.bold(
|
||||||
@@ -136,7 +141,6 @@ export default async function main(ctx) {
|
|||||||
? await now.fetch(`/v1/now/deployments/${id}/builds`)
|
? await now.fetch(`/v1/now/deployments/${id}/builds`)
|
||||||
: { builds: [] };
|
: { builds: [] };
|
||||||
|
|
||||||
cancelWait();
|
|
||||||
log(
|
log(
|
||||||
`Fetched deployment "${url}" in ${chalk.bold(contextName)} ${elapsed(
|
`Fetched deployment "${url}" in ${chalk.bold(contextName)} ${elapsed(
|
||||||
Date.now() - depFetchStart
|
Date.now() - depFetchStart
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import { NowContext } from '../../types';
|
import { NowContext } from '../../types';
|
||||||
import createOutput from '../../util/output';
|
|
||||||
import getArgs from '../../util/get-args';
|
import getArgs from '../../util/get-args';
|
||||||
import getSubcommand from '../../util/get-subcommand';
|
import getSubcommand from '../../util/get-subcommand';
|
||||||
import handleError from '../../util/handle-error';
|
import handleError from '../../util/handle-error';
|
||||||
@@ -66,8 +65,6 @@ export default async function main(ctx: NowContext) {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const debug = argv['--debug'];
|
|
||||||
const output = createOutput({ debug });
|
|
||||||
const { args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
const { args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
|
||||||
const path = args[0] || process.cwd();
|
const path = args[0] || process.cwd();
|
||||||
const autoConfirm = argv['--confirm'];
|
const autoConfirm = argv['--confirm'];
|
||||||
@@ -75,7 +72,6 @@ export default async function main(ctx: NowContext) {
|
|||||||
|
|
||||||
const link = await setupAndLink(
|
const link = await setupAndLink(
|
||||||
ctx,
|
ctx,
|
||||||
output,
|
|
||||||
path,
|
path,
|
||||||
forceDelete,
|
forceDelete,
|
||||||
autoConfirm,
|
autoConfirm,
|
||||||
|
|||||||
@@ -3,12 +3,10 @@ import ms from 'ms';
|
|||||||
import table from 'text-table';
|
import table from 'text-table';
|
||||||
import Now from '../util';
|
import Now from '../util';
|
||||||
import getArgs from '../util/get-args';
|
import getArgs from '../util/get-args';
|
||||||
import createOutput from '../util/output';
|
|
||||||
import { handleError } from '../util/error';
|
import { handleError } from '../util/error';
|
||||||
import cmd from '../util/output/cmd.ts';
|
import cmd from '../util/output/cmd.ts';
|
||||||
import logo from '../util/output/logo';
|
import logo from '../util/output/logo';
|
||||||
import elapsed from '../util/output/elapsed.ts';
|
import elapsed from '../util/output/elapsed.ts';
|
||||||
import wait from '../util/output/wait';
|
|
||||||
import strlen from '../util/strlen.ts';
|
import strlen from '../util/strlen.ts';
|
||||||
import Client from '../util/client.ts';
|
import Client from '../util/client.ts';
|
||||||
import getScope from '../util/get-scope.ts';
|
import getScope from '../util/get-scope.ts';
|
||||||
@@ -51,12 +49,6 @@ const help = () => {
|
|||||||
|
|
||||||
${chalk.cyan(`$ ${getPkgName()} ls my-app`)}
|
${chalk.cyan(`$ ${getPkgName()} ls my-app`)}
|
||||||
|
|
||||||
${chalk.gray(
|
|
||||||
'–'
|
|
||||||
)} List all deployments and all instances for the app ${chalk.dim('`my-app`')}
|
|
||||||
|
|
||||||
${chalk.cyan(`$ ${getPkgName()} ls my-app --all`)}
|
|
||||||
|
|
||||||
${chalk.gray('–')} Filter deployments by metadata
|
${chalk.gray('–')} Filter deployments by metadata
|
||||||
|
|
||||||
${chalk.cyan(`$ ${getPkgName()} ls -m key1=value1 -m key2=value2`)}
|
${chalk.cyan(`$ ${getPkgName()} ls -m key1=value1 -m key2=value2`)}
|
||||||
@@ -84,11 +76,15 @@ export default async function main(ctx) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const debugEnabled = argv['--debug'];
|
const {
|
||||||
|
authConfig: { token },
|
||||||
|
output,
|
||||||
|
apiUrl,
|
||||||
|
config,
|
||||||
|
} = ctx;
|
||||||
|
|
||||||
const { print, log, error, note, debug } = createOutput({
|
const debugEnabled = argv['--debug'];
|
||||||
debug: debugEnabled,
|
const { print, log, error, note, debug, spinner } = output;
|
||||||
});
|
|
||||||
|
|
||||||
if (argv._.length > 2) {
|
if (argv._.length > 2) {
|
||||||
error(`${getCommandName('ls [app]')} accepts at most one argument`);
|
error(`${getCommandName('ls [app]')} accepts at most one argument`);
|
||||||
@@ -98,24 +94,19 @@ export default async function main(ctx) {
|
|||||||
let app = argv._[1];
|
let app = argv._[1];
|
||||||
let host = null;
|
let host = null;
|
||||||
|
|
||||||
const apiUrl = ctx.apiUrl;
|
|
||||||
|
|
||||||
if (argv['--help']) {
|
if (argv['--help']) {
|
||||||
help();
|
help();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const meta = parseMeta(argv['--meta']);
|
const meta = parseMeta(argv['--meta']);
|
||||||
const {
|
|
||||||
authConfig: { token },
|
|
||||||
config,
|
|
||||||
} = ctx;
|
|
||||||
const { currentTeam, includeScheme } = config;
|
const { currentTeam, includeScheme } = config;
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
apiUrl,
|
apiUrl,
|
||||||
token,
|
token,
|
||||||
currentTeam,
|
currentTeam,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
@@ -137,11 +128,15 @@ export default async function main(ctx) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stopSpinner = wait(
|
spinner(`Fetching deployments in ${chalk.bold(contextName)}`);
|
||||||
`Fetching deployments in ${chalk.bold(contextName)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
const now = new Now({ apiUrl, token, debug: debugEnabled, currentTeam });
|
const now = new Now({
|
||||||
|
apiUrl,
|
||||||
|
token,
|
||||||
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
|
currentTeam,
|
||||||
|
});
|
||||||
const start = new Date();
|
const start = new Date();
|
||||||
|
|
||||||
if (app && !isValidName(app)) {
|
if (app && !isValidName(app)) {
|
||||||
@@ -162,7 +157,6 @@ export default async function main(ctx) {
|
|||||||
const hostParts = asHost.split('-');
|
const hostParts = asHost.split('-');
|
||||||
|
|
||||||
if (hostParts < 2) {
|
if (hostParts < 2) {
|
||||||
stopSpinner();
|
|
||||||
error('Only deployment hostnames are allowed, no aliases');
|
error('Only deployment hostnames are allowed, no aliases');
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -171,19 +165,12 @@ export default async function main(ctx) {
|
|||||||
host = asHost;
|
host = asHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
let response;
|
debug('Fetching deployments');
|
||||||
|
const response = await now.list(app, {
|
||||||
try {
|
version: 6,
|
||||||
debug('Fetching deployments');
|
meta,
|
||||||
response = await now.list(app, {
|
nextTimestamp,
|
||||||
version: 6,
|
});
|
||||||
meta,
|
|
||||||
nextTimestamp,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
stopSpinner();
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
let { deployments, pagination } = response;
|
let { deployments, pagination } = response;
|
||||||
|
|
||||||
@@ -199,7 +186,6 @@ export default async function main(ctx) {
|
|||||||
if (err.status === 404) {
|
if (err.status === 404) {
|
||||||
debug('Ignore findDeployment 404');
|
debug('Ignore findDeployment 404');
|
||||||
} else {
|
} else {
|
||||||
stopSpinner();
|
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,7 +202,6 @@ export default async function main(ctx) {
|
|||||||
deployments = deployments.filter(deployment => deployment.url === host);
|
deployments = deployments.filter(deployment => deployment.url === host);
|
||||||
}
|
}
|
||||||
|
|
||||||
stopSpinner();
|
|
||||||
log(
|
log(
|
||||||
`Deployments under ${chalk.bold(contextName)} ${elapsed(
|
`Deployments under ${chalk.bold(contextName)} ${elapsed(
|
||||||
Date.now() - start
|
Date.now() - start
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import getGlobalPathConfig from '../util/config/global-path';
|
|||||||
import hp from '../util/humanize-path';
|
import hp from '../util/humanize-path';
|
||||||
import logo from '../util/output/logo';
|
import logo from '../util/output/logo';
|
||||||
import exit from '../util/exit';
|
import exit from '../util/exit';
|
||||||
import createOutput from '../util/output';
|
|
||||||
import executeLogin from '../util/login/login.ts';
|
import executeLogin from '../util/login/login.ts';
|
||||||
import { prependEmoji, emoji } from '../util/emoji';
|
import { prependEmoji, emoji } from '../util/emoji';
|
||||||
import { getCommandName, getPkgName } from '../util/pkg-name.ts';
|
import { getCommandName, getPkgName } from '../util/pkg-name.ts';
|
||||||
@@ -141,15 +140,12 @@ const login = async ctx => {
|
|||||||
await exit(0);
|
await exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const debugEnabled = argv['--debug'];
|
const { apiUrl, output } = ctx;
|
||||||
const output = createOutput({ debug: debugEnabled });
|
|
||||||
|
|
||||||
argv._ = argv._.slice(1);
|
argv._ = argv._.slice(1);
|
||||||
|
|
||||||
const apiUrl = ctx.apiUrl;
|
|
||||||
let email;
|
let email;
|
||||||
let emailIsValid = false;
|
let emailIsValid = false;
|
||||||
let stopSpinner;
|
|
||||||
|
|
||||||
const possibleAddress = argv._[0];
|
const possibleAddress = argv._[0];
|
||||||
|
|
||||||
@@ -190,19 +186,18 @@ const login = async ctx => {
|
|||||||
let verificationToken;
|
let verificationToken;
|
||||||
let securityCode;
|
let securityCode;
|
||||||
|
|
||||||
stopSpinner = output.spinner('Sending you an email');
|
output.spinner('Sending you an email');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await executeLogin(apiUrl, email);
|
const data = await executeLogin(apiUrl, email);
|
||||||
verificationToken = data.token;
|
verificationToken = data.token;
|
||||||
securityCode = data.securityCode;
|
securityCode = data.securityCode;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
stopSpinner();
|
output.error(err.message);
|
||||||
console.log(error(err.message));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
stopSpinner();
|
output.stopSpinner();
|
||||||
|
|
||||||
// Clear up `Sending email` success message
|
// Clear up `Sending email` success message
|
||||||
process.stdout.write(eraseLines(possibleAddress ? 1 : 2));
|
process.stdout.write(eraseLines(possibleAddress ? 1 : 2));
|
||||||
@@ -215,7 +210,7 @@ const login = async ctx => {
|
|||||||
)}.\n`
|
)}.\n`
|
||||||
);
|
);
|
||||||
|
|
||||||
stopSpinner = output.spinner('Waiting for your confirmation');
|
output.spinner('Waiting for your confirmation');
|
||||||
|
|
||||||
let token;
|
let token;
|
||||||
|
|
||||||
@@ -228,14 +223,13 @@ const login = async ctx => {
|
|||||||
// /now/registraton is currently returning plain text in that case
|
// /now/registraton is currently returning plain text in that case
|
||||||
// we just wait for the user to click on the link
|
// we just wait for the user to click on the link
|
||||||
} else {
|
} else {
|
||||||
stopSpinner();
|
output.error(err.message);
|
||||||
console.log(err.message);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stopSpinner();
|
output.stopSpinner();
|
||||||
console.log(ok('Email confirmed'));
|
console.log(ok('Email confirmed'));
|
||||||
|
|
||||||
// There's no need to save the user since we always
|
// There's no need to save the user since we always
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
} from '../util/config/files';
|
} from '../util/config/files';
|
||||||
import getArgs from '../util/get-args';
|
import getArgs from '../util/get-args';
|
||||||
import { NowContext } from '../types';
|
import { NowContext } from '../types';
|
||||||
import createOutput, { Output } from '../util/output';
|
import { Output } from '../util/output';
|
||||||
import { getPkgName } from '../util/pkg-name';
|
import { getPkgName } from '../util/pkg-name';
|
||||||
|
|
||||||
const help = () => {
|
const help = () => {
|
||||||
@@ -54,9 +54,7 @@ export default async function main(ctx: NowContext): Promise<number> {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const debugEnabled = argv['--debug'];
|
return logout(ctx.apiUrl, ctx.output);
|
||||||
const output = createOutput({ debug: debugEnabled });
|
|
||||||
return logout(ctx.apiUrl, output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const logout = async (apiUrl: string, output: Output) => {
|
const logout = async (apiUrl: string, output: Output) => {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import mri from 'mri';
|
import mri from 'mri';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import Now from '../util';
|
import Now from '../util';
|
||||||
import createOutput from '../util/output';
|
|
||||||
import logo from '../util/output/logo';
|
import logo from '../util/output/logo';
|
||||||
import elapsed from '../util/output/elapsed.ts';
|
import elapsed from '../util/output/elapsed.ts';
|
||||||
import { maybeURL, normalizeURL } from '../util/url';
|
import { maybeURL, normalizeURL } from '../util/url';
|
||||||
@@ -59,7 +58,6 @@ export default async function main(ctx) {
|
|||||||
let deploymentIdOrURL;
|
let deploymentIdOrURL;
|
||||||
|
|
||||||
let debug;
|
let debug;
|
||||||
let apiUrl;
|
|
||||||
let head;
|
let head;
|
||||||
let limit;
|
let limit;
|
||||||
let follow;
|
let follow;
|
||||||
@@ -87,8 +85,12 @@ export default async function main(ctx) {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const debugEnabled = argv.debug;
|
const {
|
||||||
const output = createOutput({ debug: debugEnabled });
|
authConfig: { token },
|
||||||
|
apiUrl,
|
||||||
|
output,
|
||||||
|
config,
|
||||||
|
} = ctx;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
since = argv.since ? toTimestamp(argv.since) : 0;
|
since = argv.since ? toTimestamp(argv.since) : 0;
|
||||||
@@ -117,7 +119,6 @@ export default async function main(ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
debug = argv.debug;
|
debug = argv.debug;
|
||||||
apiUrl = ctx.apiUrl;
|
|
||||||
|
|
||||||
head = argv.head;
|
head = argv.head;
|
||||||
limit = typeof argv.n === 'number' ? argv.n : 100;
|
limit = typeof argv.n === 'number' ? argv.n : 100;
|
||||||
@@ -125,17 +126,14 @@ export default async function main(ctx) {
|
|||||||
if (follow) until = 0;
|
if (follow) until = 0;
|
||||||
outputMode = argv.output in logPrinters ? argv.output : 'short';
|
outputMode = argv.output in logPrinters ? argv.output : 'short';
|
||||||
|
|
||||||
const {
|
|
||||||
authConfig: { token },
|
|
||||||
config,
|
|
||||||
} = ctx;
|
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const now = new Now({ apiUrl, token, debug, currentTeam });
|
const now = new Now({ apiUrl, token, debug, currentTeam, output });
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
apiUrl,
|
apiUrl,
|
||||||
token,
|
token,
|
||||||
currentTeam,
|
currentTeam,
|
||||||
debug: debugEnabled,
|
debug,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
@@ -206,6 +204,7 @@ export default async function main(ctx) {
|
|||||||
quiet: false,
|
quiet: false,
|
||||||
debug,
|
debug,
|
||||||
findOpts: findOpts1,
|
findOpts: findOpts1,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
|
|
||||||
const printedEventIds = new Set();
|
const printedEventIds = new Set();
|
||||||
@@ -232,6 +231,7 @@ export default async function main(ctx) {
|
|||||||
quiet: false,
|
quiet: false,
|
||||||
debug,
|
debug,
|
||||||
findOpts: findOpts2,
|
findOpts: findOpts2,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@ function printLogRaw(log) {
|
|||||||
|
|
||||||
if (log.object) {
|
if (log.object) {
|
||||||
console.log(log.object);
|
console.log(log.object);
|
||||||
} else {
|
} else if (typeof log.text === 'string') {
|
||||||
console.log(
|
console.log(
|
||||||
log.text
|
log.text
|
||||||
.replace(/\n$/, '')
|
.replace(/\n$/, '')
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import exit from '../util/exit';
|
|||||||
import Client from '../util/client.ts';
|
import Client from '../util/client.ts';
|
||||||
import logo from '../util/output/logo';
|
import logo from '../util/output/logo';
|
||||||
import getScope from '../util/get-scope';
|
import getScope from '../util/get-scope';
|
||||||
import createOutput from '../util/output';
|
|
||||||
import getCommandFlags from '../util/get-command-flags';
|
import getCommandFlags from '../util/get-command-flags';
|
||||||
import wait from '../util/output/wait';
|
import wait from '../util/output/wait';
|
||||||
import { getPkgName, getCommandName } from '../util/pkg-name.ts';
|
import { getPkgName, getCommandName } from '../util/pkg-name.ts';
|
||||||
@@ -76,13 +75,12 @@ const main = async ctx => {
|
|||||||
return exit(2);
|
return exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = createOutput({ debug });
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
config: { currentTeam },
|
config: { currentTeam },
|
||||||
|
output,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
|
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
@@ -288,12 +286,7 @@ function readConfirmation(projectName) {
|
|||||||
process.stdin
|
process.stdin
|
||||||
.on('data', d => {
|
.on('data', d => {
|
||||||
process.stdin.pause();
|
process.stdin.pause();
|
||||||
resolve(
|
resolve(d.toString().trim().toLowerCase() === 'y');
|
||||||
d
|
|
||||||
.toString()
|
|
||||||
.trim()
|
|
||||||
.toLowerCase() === 'y'
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.resume();
|
.resume();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import plural from 'pluralize';
|
|||||||
import table from 'text-table';
|
import table from 'text-table';
|
||||||
import Now from '../util';
|
import Now from '../util';
|
||||||
import getAliases from '../util/alias/get-aliases';
|
import getAliases from '../util/alias/get-aliases';
|
||||||
import createOutput from '../util/output';
|
|
||||||
import logo from '../util/output/logo';
|
import logo from '../util/output/logo';
|
||||||
import elapsed from '../util/output/elapsed.ts';
|
import elapsed from '../util/output/elapsed.ts';
|
||||||
import { normalizeURL } from '../util/url';
|
import { normalizeURL } from '../util/url';
|
||||||
@@ -79,12 +78,16 @@ export default async function main(ctx) {
|
|||||||
|
|
||||||
argv._ = argv._.slice(1);
|
argv._ = argv._.slice(1);
|
||||||
|
|
||||||
const apiUrl = ctx.apiUrl;
|
const {
|
||||||
|
apiUrl,
|
||||||
|
authConfig: { token },
|
||||||
|
output,
|
||||||
|
config,
|
||||||
|
} = ctx;
|
||||||
const hard = argv.hard || false;
|
const hard = argv.hard || false;
|
||||||
const skipConfirmation = argv.yes || false;
|
const skipConfirmation = argv.yes || false;
|
||||||
const ids = argv._;
|
const ids = argv._;
|
||||||
const debugEnabled = argv.debug;
|
const debugEnabled = argv.debug;
|
||||||
const output = createOutput({ debug: debugEnabled });
|
|
||||||
const { success, error, log } = output;
|
const { success, error, log } = output;
|
||||||
|
|
||||||
if (argv.help || ids[0] === 'help') {
|
if (argv.help || ids[0] === 'help') {
|
||||||
@@ -107,16 +110,13 @@ export default async function main(ctx) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
|
||||||
authConfig: { token },
|
|
||||||
config,
|
|
||||||
} = ctx;
|
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
apiUrl,
|
apiUrl,
|
||||||
token,
|
token,
|
||||||
currentTeam,
|
currentTeam,
|
||||||
debug: debugEnabled,
|
debug: debugEnabled,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
@@ -235,11 +235,9 @@ export default async function main(ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!skipConfirmation) {
|
if (!skipConfirmation) {
|
||||||
const confirmation = (await readConfirmation(
|
const confirmation = (
|
||||||
deployments,
|
await readConfirmation(deployments, projects, output)
|
||||||
projects,
|
).toLowerCase();
|
||||||
output
|
|
||||||
)).toLowerCase();
|
|
||||||
|
|
||||||
if (confirmation !== 'y' && confirmation !== 'yes') {
|
if (confirmation !== 'y' && confirmation !== 'yes') {
|
||||||
output.log('Aborted');
|
output.log('Aborted');
|
||||||
@@ -248,7 +246,13 @@ export default async function main(ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = new Now({ apiUrl, token, debug: debugEnabled, currentTeam });
|
const now = new Now({
|
||||||
|
apiUrl,
|
||||||
|
token,
|
||||||
|
debug: debugEnabled,
|
||||||
|
currentTeam,
|
||||||
|
output,
|
||||||
|
});
|
||||||
const start = new Date();
|
const start = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import exit from '../util/exit';
|
|||||||
import logo from '../util/output/logo';
|
import logo from '../util/output/logo';
|
||||||
import Client from '../util/client.ts';
|
import Client from '../util/client.ts';
|
||||||
import getScope from '../util/get-scope.ts';
|
import getScope from '../util/get-scope.ts';
|
||||||
import createOutput from '../util/output';
|
|
||||||
import confirm from '../util/input/confirm';
|
import confirm from '../util/input/confirm';
|
||||||
import getCommandFlags from '../util/get-command-flags';
|
import getCommandFlags from '../util/get-command-flags';
|
||||||
import getPrefixedFlags from '../util/get-prefixed-flags';
|
import getPrefixedFlags from '../util/get-prefixed-flags';
|
||||||
@@ -104,10 +103,10 @@ const main = async ctx => {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config: { currentTeam },
|
config: { currentTeam },
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const output = createOutput({ debug });
|
const client = new Client({ apiUrl, token, currentTeam, debug, output });
|
||||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -139,7 +138,7 @@ export default async ctx => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function run({ output, token, contextName, currentTeam, ctx }) {
|
async function run({ output, token, contextName, currentTeam, ctx }) {
|
||||||
const secrets = new NowSecrets({ apiUrl, token, debug, currentTeam });
|
const secrets = new NowSecrets({ apiUrl, token, debug, currentTeam, output });
|
||||||
const args = argv._.slice(1);
|
const args = argv._.slice(1);
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ const help = () => {
|
|||||||
${chalk.gray('–')} Invite new members (interactively)
|
${chalk.gray('–')} Invite new members (interactively)
|
||||||
|
|
||||||
${chalk.cyan(`$ ${getPkgName()} teams invite`)}
|
${chalk.cyan(`$ ${getPkgName()} teams invite`)}
|
||||||
|
|
||||||
${chalk.gray('–')} Paginate results, where ${chalk.dim(
|
${chalk.gray('–')} Paginate results, where ${chalk.dim(
|
||||||
'`1584722256178`'
|
'`1584722256178`'
|
||||||
)} is the time in milliseconds since the UNIX epoch.
|
)} is the time in milliseconds since the UNIX epoch.
|
||||||
@@ -97,10 +97,11 @@ const main = async ctx => {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
|
|
||||||
return run({ token, config });
|
return run({ token, config, output });
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async ctx => {
|
export default async ctx => {
|
||||||
@@ -112,7 +113,7 @@ export default async ctx => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function run({ token, config }) {
|
async function run({ token, config, output }) {
|
||||||
const { currentTeam } = config;
|
const { currentTeam } = config;
|
||||||
const teams = new NowTeams({ apiUrl, token, debug, currentTeam });
|
const teams = new NowTeams({ apiUrl, token, debug, currentTeam });
|
||||||
const args = argv._;
|
const args = argv._;
|
||||||
@@ -126,6 +127,7 @@ async function run({ token, config }) {
|
|||||||
config,
|
config,
|
||||||
apiUrl,
|
apiUrl,
|
||||||
token,
|
token,
|
||||||
|
output,
|
||||||
argv,
|
argv,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -154,6 +156,7 @@ async function run({ token, config }) {
|
|||||||
config,
|
config,
|
||||||
apiUrl,
|
apiUrl,
|
||||||
token,
|
token,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import success from '../../util/output/success';
|
|||||||
import getUser from '../../util/get-user.ts';
|
import getUser from '../../util/get-user.ts';
|
||||||
import Client from '../../util/client.ts';
|
import Client from '../../util/client.ts';
|
||||||
import { getCommandName } from '../../util/pkg-name.ts';
|
import { getCommandName } from '../../util/pkg-name.ts';
|
||||||
import createOutput from '../../util/output';
|
|
||||||
|
|
||||||
const validateEmail = data => regexEmail.test(data.trim()) || data.length === 0;
|
const validateEmail = data => regexEmail.test(data.trim()) || data.length === 0;
|
||||||
|
|
||||||
@@ -65,8 +64,8 @@ export default async function ({
|
|||||||
noopMsg = 'No changes made',
|
noopMsg = 'No changes made',
|
||||||
apiUrl,
|
apiUrl,
|
||||||
token,
|
token,
|
||||||
|
output,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const output = createOutput();
|
|
||||||
const { currentTeam: currentTeamId } = config;
|
const { currentTeam: currentTeamId } = config;
|
||||||
|
|
||||||
const stopSpinner = wait('Fetching teams');
|
const stopSpinner = wait('Fetching teams');
|
||||||
@@ -77,7 +76,7 @@ export default async function ({
|
|||||||
stopSpinner();
|
stopSpinner();
|
||||||
|
|
||||||
const stopUserSpinner = wait('Fetching user information');
|
const stopUserSpinner = wait('Fetching user information');
|
||||||
const client = new Client({ apiUrl, token });
|
const client = new Client({ apiUrl, token, output });
|
||||||
let user;
|
let user;
|
||||||
try {
|
try {
|
||||||
user = await getUser(client);
|
user = await getUser(client);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import info from '../../util/output/info';
|
|||||||
import error from '../../util/output/error';
|
import error from '../../util/output/error';
|
||||||
import chars from '../../util/output/chars';
|
import chars from '../../util/output/chars';
|
||||||
import table from '../../util/output/table';
|
import table from '../../util/output/table';
|
||||||
import createOutput from '../../util/output';
|
|
||||||
import getUser from '../../util/get-user.ts';
|
import getUser from '../../util/get-user.ts';
|
||||||
import Client from '../../util/client.ts';
|
import Client from '../../util/client.ts';
|
||||||
import getPrefixedFlags from '../../util/get-prefixed-flags';
|
import getPrefixedFlags from '../../util/get-prefixed-flags';
|
||||||
@@ -16,9 +15,8 @@ import { getPkgName } from '../../util/pkg-name.ts';
|
|||||||
import getCommandFlags from '../../util/get-command-flags';
|
import getCommandFlags from '../../util/get-command-flags';
|
||||||
import cmd from '../../util/output/cmd.ts';
|
import cmd from '../../util/output/cmd.ts';
|
||||||
|
|
||||||
export default async function({ teams, config, apiUrl, token, argv }) {
|
export default async function ({ teams, config, apiUrl, token, output, argv }) {
|
||||||
const { next } = argv;
|
const { next } = argv;
|
||||||
const output = createOutput({ debug: argv['--debug'] });
|
|
||||||
|
|
||||||
if (typeof next !== 'undefined' && !Number.isInteger(next)) {
|
if (typeof next !== 'undefined' && !Number.isInteger(next)) {
|
||||||
output.error('Please provide a number for flag --next');
|
output.error('Please provide a number for flag --next');
|
||||||
@@ -36,7 +34,7 @@ export default async function({ teams, config, apiUrl, token, argv }) {
|
|||||||
stopSpinner();
|
stopSpinner();
|
||||||
|
|
||||||
const stopUserSpinner = wait('Fetching user information');
|
const stopUserSpinner = wait('Fetching user information');
|
||||||
const client = new Client({ apiUrl, token, currentTeam });
|
const client = new Client({ apiUrl, token, currentTeam, output });
|
||||||
let user;
|
let user;
|
||||||
try {
|
try {
|
||||||
user = await getUser(client);
|
user = await getUser(client);
|
||||||
|
|||||||
@@ -24,22 +24,21 @@ const updateCurrentTeam = (config, newTeam) => {
|
|||||||
writeToConfigFile(config);
|
writeToConfigFile(config);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function({ apiUrl, token, debug, args, config }) {
|
export default async function ({ apiUrl, token, debug, args, config, output }) {
|
||||||
let stopSpinner = wait('Fetching teams');
|
let stopSpinner;
|
||||||
|
output.spinner('Fetching teams');
|
||||||
|
|
||||||
// We're loading the teams here without `currentTeam`, so that
|
// We're loading the teams here without `currentTeam`, so that
|
||||||
// people can use `vercel switch` in the case that their
|
// people can use `vercel switch` in the case that their
|
||||||
// current team was deleted.
|
// current team was deleted.
|
||||||
const teams = new NowTeams({ apiUrl, token, debug });
|
const teams = new NowTeams({ apiUrl, token, debug, output });
|
||||||
const list = (await teams.ls()).teams;
|
const list = (await teams.ls()).teams;
|
||||||
|
|
||||||
let { currentTeam } = config;
|
let { currentTeam } = config;
|
||||||
const accountIsCurrent = !currentTeam;
|
const accountIsCurrent = !currentTeam;
|
||||||
|
|
||||||
stopSpinner();
|
output.spinner('Fetching user information');
|
||||||
|
const client = new Client({ apiUrl, token, output });
|
||||||
const stopUserSpinner = wait('Fetching user information');
|
|
||||||
const client = new Client({ apiUrl, token });
|
|
||||||
let user;
|
let user;
|
||||||
try {
|
try {
|
||||||
user = await getUser(client);
|
user = await getUser(client);
|
||||||
@@ -52,8 +51,6 @@ export default async function({ apiUrl, token, debug, args, config }) {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
stopUserSpinner();
|
|
||||||
|
|
||||||
if (accountIsCurrent) {
|
if (accountIsCurrent) {
|
||||||
currentTeam = {
|
currentTeam = {
|
||||||
slug: user.username || user.email,
|
slug: user.username || user.email,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import logo from '../util/output/logo';
|
|||||||
import handleError from '../util/handle-error';
|
import handleError from '../util/handle-error';
|
||||||
import getArgs from '../util/get-args';
|
import getArgs from '../util/get-args';
|
||||||
import { NowContext } from '../types';
|
import { NowContext } from '../types';
|
||||||
import createOutput from '../util/output';
|
|
||||||
import getUpdateCommand from '../util/get-update-command';
|
import getUpdateCommand from '../util/get-update-command';
|
||||||
import { getPkgName, getTitleName } from '../util/pkg-name';
|
import { getPkgName, getTitleName } from '../util/pkg-name';
|
||||||
|
|
||||||
@@ -35,6 +34,7 @@ const help = () => {
|
|||||||
|
|
||||||
export default async function main(ctx: NowContext): Promise<number> {
|
export default async function main(ctx: NowContext): Promise<number> {
|
||||||
let argv;
|
let argv;
|
||||||
|
const { output } = ctx;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
argv = getArgs(ctx.argv.slice(2), {
|
argv = getArgs(ctx.argv.slice(2), {
|
||||||
@@ -55,8 +55,6 @@ export default async function main(ctx: NowContext): Promise<number> {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const debugEnabled = argv['--debug'];
|
|
||||||
const output = createOutput({ debug: debugEnabled });
|
|
||||||
output.log(
|
output.log(
|
||||||
`Please run ${cmd(
|
`Please run ${cmd(
|
||||||
await getUpdateCommand()
|
await getUpdateCommand()
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import logo from '../util/output/logo';
|
|||||||
import { handleError } from '../util/error';
|
import { handleError } from '../util/error';
|
||||||
import Client from '../util/client.ts';
|
import Client from '../util/client.ts';
|
||||||
import getScope from '../util/get-scope.ts';
|
import getScope from '../util/get-scope.ts';
|
||||||
import createOutput from '../util/output';
|
|
||||||
import { getPkgName } from '../util/pkg-name.ts';
|
import { getPkgName } from '../util/pkg-name.ts';
|
||||||
|
|
||||||
const help = () => {
|
const help = () => {
|
||||||
@@ -55,10 +54,10 @@ const main = async ctx => {
|
|||||||
const debug = argv['--debug'];
|
const debug = argv['--debug'];
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
output,
|
||||||
apiUrl,
|
apiUrl,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const output = createOutput({ debug });
|
const client = new Client({ apiUrl, token, debug, output });
|
||||||
const client = new Client({ apiUrl, token, debug });
|
|
||||||
let contextName = null;
|
let contextName = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ const main = async argv_ => {
|
|||||||
|
|
||||||
let authConfig = null;
|
let authConfig = null;
|
||||||
|
|
||||||
const subcommandsWithoutToken = ['login', 'help', 'init', 'dev', 'update'];
|
const subcommandsWithoutToken = ['login', 'help', 'init', 'update'];
|
||||||
|
|
||||||
if (authConfigExists) {
|
if (authConfigExists) {
|
||||||
try {
|
try {
|
||||||
@@ -346,6 +346,7 @@ const main = async argv_ => {
|
|||||||
|
|
||||||
// the context object to supply to the providers or the commands
|
// the context object to supply to the providers or the commands
|
||||||
const ctx = {
|
const ctx = {
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
authConfig,
|
authConfig,
|
||||||
localConfig,
|
localConfig,
|
||||||
@@ -536,7 +537,7 @@ const main = async argv_ => {
|
|||||||
!(targetCommand === 'teams' && argv._[3] !== 'invite')
|
!(targetCommand === 'teams' && argv._[3] !== 'invite')
|
||||||
) {
|
) {
|
||||||
let user = null;
|
let user = null;
|
||||||
const client = new Client({ apiUrl, token });
|
const client = new Client({ apiUrl, token, output });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
user = await getUser(client);
|
user = await getUser(client);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { NowConfig } from './util/dev/types';
|
import { NowConfig } from './util/dev/types';
|
||||||
|
import { Output } from './util/output';
|
||||||
|
|
||||||
export type ThenArg<T> = T extends Promise<infer U> ? U : T;
|
export type ThenArg<T> = T extends Promise<infer U> ? U : T;
|
||||||
|
|
||||||
@@ -8,6 +9,7 @@ export interface NowContext {
|
|||||||
authConfig: {
|
authConfig: {
|
||||||
token: string;
|
token: string;
|
||||||
};
|
};
|
||||||
|
output: Output;
|
||||||
config: {
|
config: {
|
||||||
currentTeam: string;
|
currentTeam: string;
|
||||||
updateChannel: string;
|
updateChannel: string;
|
||||||
@@ -231,6 +233,7 @@ export interface ProjectSettings {
|
|||||||
outputDirectory?: string | null;
|
outputDirectory?: string | null;
|
||||||
rootDirectory?: string | null;
|
rootDirectory?: string | null;
|
||||||
autoExposeSystemEnvs?: boolean;
|
autoExposeSystemEnvs?: boolean;
|
||||||
|
directoryListing?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Project extends ProjectSettings {
|
export interface Project extends ProjectSettings {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export default class Client extends EventEmitter {
|
|||||||
forceNew = false,
|
forceNew = false,
|
||||||
withCache = false,
|
withCache = false,
|
||||||
debug = false,
|
debug = false,
|
||||||
|
output = createOutput({ debug }),
|
||||||
}: {
|
}: {
|
||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
token: string;
|
token: string;
|
||||||
@@ -40,13 +41,14 @@ export default class Client extends EventEmitter {
|
|||||||
forceNew?: boolean;
|
forceNew?: boolean;
|
||||||
withCache?: boolean;
|
withCache?: boolean;
|
||||||
debug?: boolean;
|
debug?: boolean;
|
||||||
|
output?: Output;
|
||||||
}) {
|
}) {
|
||||||
super();
|
super();
|
||||||
this._token = token;
|
this._token = token;
|
||||||
this._debug = debug;
|
this._debug = debug;
|
||||||
this._forceNew = forceNew;
|
this._forceNew = forceNew;
|
||||||
this._withCache = withCache;
|
this._withCache = withCache;
|
||||||
this._output = createOutput({ debug });
|
this._output = output;
|
||||||
this._apiUrl = apiUrl;
|
this._apiUrl = apiUrl;
|
||||||
this._onRetry = this._onRetry.bind(this);
|
this._onRetry = this._onRetry.bind(this);
|
||||||
this.currentTeam = currentTeam;
|
this.currentTeam = currentTeam;
|
||||||
|
|||||||
@@ -100,11 +100,7 @@ export default async function processDeployment({
|
|||||||
skipAutoDetectionConfirmation,
|
skipAutoDetectionConfirmation,
|
||||||
};
|
};
|
||||||
|
|
||||||
let queuedSpinner = null;
|
output.spinner(
|
||||||
let buildSpinner = null;
|
|
||||||
let deploySpinner = null;
|
|
||||||
|
|
||||||
const deployingSpinner = output.spinner(
|
|
||||||
isSettingUpProject
|
isSettingUpProject
|
||||||
? 'Setting up project'
|
? 'Setting up project'
|
||||||
: `Deploying ${chalk.bold(`${org.slug}/${projectName}`)}`,
|
: `Deploying ${chalk.bold(`${org.slug}/${projectName}`)}`,
|
||||||
@@ -138,16 +134,7 @@ export default async function processDeployment({
|
|||||||
.map((sha: string) => event.payload.total.get(sha).data.length)
|
.map((sha: string) => event.payload.total.get(sha).data.length)
|
||||||
.reduce((a: number, b: number) => a + b, 0);
|
.reduce((a: number, b: number) => a + b, 0);
|
||||||
|
|
||||||
if (queuedSpinner) {
|
output.stopSpinner();
|
||||||
queuedSpinner();
|
|
||||||
}
|
|
||||||
if (buildSpinner) {
|
|
||||||
buildSpinner();
|
|
||||||
}
|
|
||||||
if (deploySpinner) {
|
|
||||||
deploySpinner();
|
|
||||||
}
|
|
||||||
deployingSpinner();
|
|
||||||
bar = new Progress(`${chalk.gray('>')} Upload [:bar] :percent :etas`, {
|
bar = new Progress(`${chalk.gray('>')} Upload [:bar] :percent :etas`, {
|
||||||
width: 20,
|
width: 20,
|
||||||
complete: '=',
|
complete: '=',
|
||||||
@@ -170,8 +157,6 @@ export default async function processDeployment({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.type === 'created') {
|
if (event.type === 'created') {
|
||||||
deployingSpinner();
|
|
||||||
|
|
||||||
if (bar && !bar.complete) {
|
if (bar && !bar.complete) {
|
||||||
bar.tick(bar.total + 1);
|
bar.tick(bar.total + 1);
|
||||||
}
|
}
|
||||||
@@ -191,63 +176,36 @@ export default async function processDeployment({
|
|||||||
|
|
||||||
now.url = event.payload.url;
|
now.url = event.payload.url;
|
||||||
|
|
||||||
|
output.stopSpinner();
|
||||||
|
|
||||||
printInspectUrl(output, event.payload.url, deployStamp, org.slug);
|
printInspectUrl(output, event.payload.url, deployStamp, org.slug);
|
||||||
|
|
||||||
if (quiet) {
|
if (quiet) {
|
||||||
process.stdout.write(`https://${event.payload.url}`);
|
process.stdout.write(`https://${event.payload.url}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queuedSpinner === null) {
|
output.spinner(
|
||||||
queuedSpinner =
|
event.payload.readyState === 'QUEUED' ? 'Queued' : 'Building',
|
||||||
event.payload.readyState === 'QUEUED'
|
0
|
||||||
? output.spinner('Queued', 0)
|
);
|
||||||
: output.spinner('Building', 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type === 'building') {
|
if (event.type === 'building') {
|
||||||
if (queuedSpinner) {
|
output.spinner('Building', 0);
|
||||||
queuedSpinner();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buildSpinner === null) {
|
|
||||||
buildSpinner = output.spinner('Building', 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type === 'canceled') {
|
if (event.type === 'canceled') {
|
||||||
if (queuedSpinner) {
|
output.stopSpinner();
|
||||||
queuedSpinner();
|
|
||||||
}
|
|
||||||
if (buildSpinner) {
|
|
||||||
buildSpinner();
|
|
||||||
}
|
|
||||||
return event.payload;
|
return event.payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type === 'ready') {
|
if (event.type === 'ready') {
|
||||||
if (queuedSpinner) {
|
output.spinner('Completing', 0);
|
||||||
queuedSpinner();
|
|
||||||
}
|
|
||||||
if (buildSpinner) {
|
|
||||||
buildSpinner();
|
|
||||||
}
|
|
||||||
|
|
||||||
deploySpinner = output.spinner('Completing', 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle error events
|
// Handle error events
|
||||||
if (event.type === 'error') {
|
if (event.type === 'error') {
|
||||||
if (queuedSpinner) {
|
output.stopSpinner();
|
||||||
queuedSpinner();
|
|
||||||
}
|
|
||||||
if (buildSpinner) {
|
|
||||||
buildSpinner();
|
|
||||||
}
|
|
||||||
if (deploySpinner) {
|
|
||||||
deploySpinner();
|
|
||||||
}
|
|
||||||
deployingSpinner();
|
|
||||||
|
|
||||||
const error = await now.handleDeploymentError(event.payload, {
|
const error = await now.handleDeploymentError(event.payload, {
|
||||||
hashes,
|
hashes,
|
||||||
@@ -263,32 +221,12 @@ export default async function processDeployment({
|
|||||||
|
|
||||||
// Handle alias-assigned event
|
// Handle alias-assigned event
|
||||||
if (event.type === 'alias-assigned') {
|
if (event.type === 'alias-assigned') {
|
||||||
if (queuedSpinner) {
|
|
||||||
queuedSpinner();
|
|
||||||
}
|
|
||||||
if (buildSpinner) {
|
|
||||||
buildSpinner();
|
|
||||||
}
|
|
||||||
if (deploySpinner) {
|
|
||||||
deploySpinner();
|
|
||||||
}
|
|
||||||
deployingSpinner();
|
|
||||||
|
|
||||||
event.payload.indications = indications;
|
event.payload.indications = indications;
|
||||||
return event.payload;
|
return event.payload;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (queuedSpinner) {
|
output.stopSpinner();
|
||||||
queuedSpinner();
|
|
||||||
}
|
|
||||||
if (buildSpinner) {
|
|
||||||
buildSpinner();
|
|
||||||
}
|
|
||||||
if (deploySpinner) {
|
|
||||||
deploySpinner();
|
|
||||||
}
|
|
||||||
deployingSpinner();
|
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import chalk from 'chalk';
|
||||||
import execa from 'execa';
|
import execa from 'execa';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import npa from 'npm-package-arg';
|
import npa from 'npm-package-arg';
|
||||||
@@ -8,9 +9,10 @@ import { mkdirp, readJSON, writeJSON } from 'fs-extra';
|
|||||||
import { NowBuildError, PackageJson } from '@vercel/build-utils';
|
import { NowBuildError, PackageJson } from '@vercel/build-utils';
|
||||||
import cliPkg from '../pkg';
|
import cliPkg from '../pkg';
|
||||||
|
|
||||||
import { NoBuilderCacheError } from '../errors-ts';
|
import cmd from '../output/cmd';
|
||||||
import { Output } from '../output';
|
import { Output } from '../output';
|
||||||
import { getDistTag } from '../get-dist-tag';
|
import { getDistTag } from '../get-dist-tag';
|
||||||
|
import { NoBuilderCacheError } from '../errors-ts';
|
||||||
|
|
||||||
import * as staticBuilder from './static-builder';
|
import * as staticBuilder from './static-builder';
|
||||||
import { BuilderWithPackage } from './types';
|
import { BuilderWithPackage } from './types';
|
||||||
@@ -261,7 +263,9 @@ async function npmInstall(
|
|||||||
throw new NowBuildError({
|
throw new NowBuildError({
|
||||||
message:
|
message:
|
||||||
(result as any).code === 'ENOENT'
|
(result as any).code === 'ENOENT'
|
||||||
? '`npm` is not installed'
|
? `Command not found: ${chalk.cyan(
|
||||||
|
'npm'
|
||||||
|
)}\nPlease ensure that ${cmd('npm')} is properly installed`
|
||||||
: 'Failed to install `vercel dev` dependencies',
|
: 'Failed to install `vercel dev` dependencies',
|
||||||
code: 'NPM_INSTALL_ERROR',
|
code: 'NPM_INSTALL_ERROR',
|
||||||
link: 'https://vercel.link/npm-install-failed-dev',
|
link: 'https://vercel.link/npm-install-failed-dev',
|
||||||
|
|||||||
@@ -280,7 +280,6 @@ export async function executeBuild(
|
|||||||
path = extensionless;
|
path = extensionless;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete output[path];
|
|
||||||
output[path] = value;
|
output[path] = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -402,7 +401,7 @@ export async function getBuildMatches(
|
|||||||
const builds = nowConfig.builds || [{ src: '**', use: '@vercel/static' }];
|
const builds = nowConfig.builds || [{ src: '**', use: '@vercel/static' }];
|
||||||
|
|
||||||
for (const buildConfig of builds) {
|
for (const buildConfig of builds) {
|
||||||
let { src = '**', use } = buildConfig;
|
let { src = '**', use, config = {} } = buildConfig;
|
||||||
|
|
||||||
if (!use) {
|
if (!use) {
|
||||||
continue;
|
continue;
|
||||||
@@ -437,6 +436,15 @@ export async function getBuildMatches(
|
|||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
src = relative(cwd, file);
|
src = relative(cwd, file);
|
||||||
|
|
||||||
|
// Remove the output directory prefix
|
||||||
|
if (config.zeroConfig && config.outputDirectory) {
|
||||||
|
const outputMatch = config.outputDirectory + '/';
|
||||||
|
if (src.startsWith(outputMatch)) {
|
||||||
|
src = src.slice(outputMatch.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const builderWithPkg = await getBuilder(use, output);
|
const builderWithPkg = await getBuilder(use, output);
|
||||||
matches.push({
|
matches.push({
|
||||||
...buildConfig,
|
...buildConfig,
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import {
|
|||||||
} from '@vercel/build-utils';
|
} from '@vercel/build-utils';
|
||||||
import _frameworks, { Framework } from '@vercel/frameworks';
|
import _frameworks, { Framework } from '@vercel/frameworks';
|
||||||
|
|
||||||
|
import cmd from '../output/cmd';
|
||||||
import link from '../output/link';
|
import link from '../output/link';
|
||||||
import { Output } from '../output';
|
import { Output } from '../output';
|
||||||
import { relative } from '../path-helpers';
|
import { relative } from '../path-helpers';
|
||||||
@@ -650,7 +651,7 @@ export default class DevServer {
|
|||||||
const cloudEnv = exposeSystemEnvs(
|
const cloudEnv = exposeSystemEnvs(
|
||||||
this.projectEnvs || [],
|
this.projectEnvs || [],
|
||||||
this.systemEnvValues || [],
|
this.systemEnvValues || [],
|
||||||
this.projectSettings && this.projectSettings.autoExposeSystemEnvs,
|
this.projectSettings?.autoExposeSystemEnvs,
|
||||||
new URL(this.address).host
|
new URL(this.address).host
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -667,7 +668,7 @@ export default class DevServer {
|
|||||||
// mirror how VERCEL_REGION is injected in prod/preview
|
// mirror how VERCEL_REGION is injected in prod/preview
|
||||||
// only inject in `runEnvs`, because `allEnvs` is exposed to dev command
|
// only inject in `runEnvs`, because `allEnvs` is exposed to dev command
|
||||||
// and should not contain VERCEL_REGION
|
// and should not contain VERCEL_REGION
|
||||||
if (this.projectSettings && this.projectSettings.autoExposeSystemEnvs) {
|
if (this.projectSettings?.autoExposeSystemEnvs) {
|
||||||
runEnv['VERCEL_REGION'] = 'dev1';
|
runEnv['VERCEL_REGION'] = 'dev1';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -886,7 +887,7 @@ export default class DevServer {
|
|||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
this.updateBuildersPromise = null;
|
this.updateBuildersPromise = null;
|
||||||
this.output.error(`Failed to update builders: ${err.message}`);
|
this.output.prettyError(err);
|
||||||
this.output.debug(err.stack);
|
this.output.debug(err.stack);
|
||||||
});
|
});
|
||||||
}, ms('30s'));
|
}, ms('30s'));
|
||||||
@@ -1681,7 +1682,16 @@ export default class DevServer {
|
|||||||
// `startDevServer()` threw an error. Most likely this means the dev
|
// `startDevServer()` threw an error. Most likely this means the dev
|
||||||
// server process exited before sending the port information message
|
// server process exited before sending the port information message
|
||||||
// (missing dependency at runtime, for example).
|
// (missing dependency at runtime, for example).
|
||||||
debug(`Error starting "${builderPkg.name}" dev server: ${err}`);
|
if (err.code === 'ENOENT') {
|
||||||
|
err.message = `Command not found: ${chalk.cyan(
|
||||||
|
err.path,
|
||||||
|
...err.spawnargs
|
||||||
|
)}\nPlease ensure that ${cmd(err.path)} is properly installed`;
|
||||||
|
err.link = 'https://vercel.link/command-not-found';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.output.prettyError(err);
|
||||||
|
|
||||||
await this.sendError(
|
await this.sendError(
|
||||||
req,
|
req,
|
||||||
res,
|
res,
|
||||||
@@ -1894,6 +1904,12 @@ export default class DevServer {
|
|||||||
requestPath: string,
|
requestPath: string,
|
||||||
nowRequestId: string
|
nowRequestId: string
|
||||||
): boolean {
|
): boolean {
|
||||||
|
// If the "directory listing" feature is disabled in the
|
||||||
|
// Project's settings, then don't render the directory listing
|
||||||
|
if (this.projectSettings?.directoryListing === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let prefix = requestPath;
|
let prefix = requestPath;
|
||||||
if (prefix.length > 0 && !prefix.endsWith('/')) {
|
if (prefix.length > 0 && !prefix.endsWith('/')) {
|
||||||
prefix += '/';
|
prefix += '/';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { basename, extname, join } from 'path';
|
|
||||||
import {
|
import {
|
||||||
FileFsRef,
|
FileFsRef,
|
||||||
BuildOptions,
|
BuildOptions,
|
||||||
|
shouldServe as defaultShouldServe,
|
||||||
ShouldServeOptions,
|
ShouldServeOptions,
|
||||||
} from '@vercel/build-utils';
|
} from '@vercel/build-utils';
|
||||||
import { BuildResult } from './types';
|
import { BuildResult } from './types';
|
||||||
@@ -11,50 +11,32 @@ export const version = 2;
|
|||||||
export function build({
|
export function build({
|
||||||
files,
|
files,
|
||||||
entrypoint,
|
entrypoint,
|
||||||
config,
|
config: { zeroConfig, outputDirectory },
|
||||||
}: BuildOptions): BuildResult {
|
}: BuildOptions): BuildResult {
|
||||||
let path = entrypoint;
|
const path =
|
||||||
const outputDir = config.zeroConfig ? config.outputDirectory : '';
|
zeroConfig && outputDirectory
|
||||||
const outputMatch = outputDir + '/';
|
? `${outputDirectory}/${entrypoint}`
|
||||||
if (outputDir && path.startsWith(outputMatch)) {
|
: entrypoint;
|
||||||
// static output files are moved to the root directory
|
return {
|
||||||
path = path.slice(outputMatch.length);
|
output: {
|
||||||
}
|
[entrypoint]: files[path] as FileFsRef,
|
||||||
const output = {
|
},
|
||||||
[path]: files[entrypoint] as FileFsRef,
|
routes: [],
|
||||||
|
watch: [path],
|
||||||
};
|
};
|
||||||
const watch = [path];
|
|
||||||
|
|
||||||
return { output, routes: [], watch };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function shouldServe({
|
export function shouldServe(_opts: ShouldServeOptions) {
|
||||||
entrypoint,
|
const opts = { ..._opts };
|
||||||
files,
|
let {
|
||||||
requestPath,
|
config: { zeroConfig, outputDirectory },
|
||||||
config = {},
|
} = opts;
|
||||||
}: ShouldServeOptions) {
|
|
||||||
let outputPrefix = '';
|
// Add the output directory prefix
|
||||||
const outputDir = config.zeroConfig ? config.outputDirectory : '';
|
if (zeroConfig && outputDirectory) {
|
||||||
const outputMatch = outputDir + '/';
|
opts.entrypoint = `${outputDirectory}/${opts.entrypoint}`;
|
||||||
if (outputDir && entrypoint.startsWith(outputMatch)) {
|
opts.requestPath = `${outputDirectory}/${opts.requestPath}`;
|
||||||
// static output files are moved to the root directory
|
|
||||||
entrypoint = entrypoint.slice(outputMatch.length);
|
|
||||||
outputPrefix = outputMatch;
|
|
||||||
}
|
}
|
||||||
const isMatch = (f: string) => entrypoint === f && outputPrefix + f in files;
|
|
||||||
|
|
||||||
if (isIndex(entrypoint)) {
|
return defaultShouldServe(opts);
|
||||||
const indexPath = join(requestPath, basename(entrypoint));
|
|
||||||
if (isMatch(indexPath)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isMatch(requestPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isIndex(path: string): boolean {
|
|
||||||
const ext = extname(path);
|
|
||||||
const name = basename(path, ext);
|
|
||||||
return name === 'index';
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,12 @@ type Response = {
|
|||||||
export default async function purchaseDomain(
|
export default async function purchaseDomain(
|
||||||
client: Client,
|
client: Client,
|
||||||
name: string,
|
name: string,
|
||||||
expectedPrice: number
|
expectedPrice: number,
|
||||||
|
renew: boolean = true
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
return await client.fetch<Response>(`/v3/domains/buy`, {
|
return await client.fetch<Response>(`/v3/domains/buy`, {
|
||||||
body: { name, expectedPrice },
|
body: { name, expectedPrice, renew },
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -7,16 +7,21 @@ import { eraseLines } from 'ansi-escapes';
|
|||||||
import jsonlines from 'jsonlines';
|
import jsonlines from 'jsonlines';
|
||||||
import retry from 'async-retry';
|
import retry from 'async-retry';
|
||||||
|
|
||||||
// Utilities
|
|
||||||
import createOutput from './output';
|
|
||||||
|
|
||||||
async function printEvents(
|
async function printEvents(
|
||||||
now,
|
now,
|
||||||
deploymentIdOrURL,
|
deploymentIdOrURL,
|
||||||
currentTeam = null,
|
currentTeam = null,
|
||||||
{ mode, onOpen = () => {}, onEvent, quiet, debugEnabled, findOpts } = {}
|
{
|
||||||
|
mode,
|
||||||
|
onOpen = () => {},
|
||||||
|
onEvent,
|
||||||
|
quiet,
|
||||||
|
debugEnabled,
|
||||||
|
findOpts,
|
||||||
|
output,
|
||||||
|
} = {}
|
||||||
) {
|
) {
|
||||||
const { log, debug } = createOutput({ debug: debugEnabled });
|
const { log, debug } = output;
|
||||||
|
|
||||||
let onOpenCalled = false;
|
let onOpenCalled = false;
|
||||||
function callOnOpenOnce() {
|
function callOnOpenOnce() {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export default class Now extends EventEmitter {
|
|||||||
forceNew = false,
|
forceNew = false,
|
||||||
withCache = false,
|
withCache = false,
|
||||||
debug = false,
|
debug = false,
|
||||||
|
output = createOutput({ debug }),
|
||||||
}) {
|
}) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ export default class Now extends EventEmitter {
|
|||||||
this._debug = debug;
|
this._debug = debug;
|
||||||
this._forceNew = forceNew;
|
this._forceNew = forceNew;
|
||||||
this._withCache = withCache;
|
this._withCache = withCache;
|
||||||
this._output = createOutput({ debug });
|
this._output = output;
|
||||||
this._apiUrl = apiUrl;
|
this._apiUrl = apiUrl;
|
||||||
this._onRetry = this._onRetry.bind(this);
|
this._onRetry = this._onRetry.bind(this);
|
||||||
this.currentTeam = currentTeam;
|
this.currentTeam = currentTeam;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export default async function promptBool(label: string, options: Options = {}) {
|
|||||||
trailing = '',
|
trailing = '',
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise<boolean>(resolve => {
|
||||||
const isRaw = Boolean(stdin && stdin.isRaw);
|
const isRaw = Boolean(stdin && stdin.isRaw);
|
||||||
|
|
||||||
if (stdin) {
|
if (stdin) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import chalk from 'chalk';
|
|||||||
import { remove } from 'fs-extra';
|
import { remove } from 'fs-extra';
|
||||||
import { NowContext, ProjectLinkResult, ProjectSettings } from '../../types';
|
import { NowContext, ProjectLinkResult, ProjectSettings } from '../../types';
|
||||||
import { NowConfig } from '../dev/types';
|
import { NowConfig } from '../dev/types';
|
||||||
import { Output } from '../output';
|
|
||||||
import {
|
import {
|
||||||
getLinkedProject,
|
getLinkedProject,
|
||||||
linkFolderToProject,
|
linkFolderToProject,
|
||||||
@@ -30,7 +29,6 @@ import Now from '../index';
|
|||||||
|
|
||||||
export default async function setupAndLink(
|
export default async function setupAndLink(
|
||||||
ctx: NowContext,
|
ctx: NowContext,
|
||||||
output: Output,
|
|
||||||
path: string,
|
path: string,
|
||||||
forceDelete: boolean,
|
forceDelete: boolean,
|
||||||
autoConfirm: boolean,
|
autoConfirm: boolean,
|
||||||
@@ -39,15 +37,17 @@ export default async function setupAndLink(
|
|||||||
): Promise<ProjectLinkResult> {
|
): Promise<ProjectLinkResult> {
|
||||||
const {
|
const {
|
||||||
authConfig: { token },
|
authConfig: { token },
|
||||||
|
apiUrl,
|
||||||
|
output,
|
||||||
config,
|
config,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
const { apiUrl } = ctx;
|
|
||||||
const debug = output.isDebugEnabled();
|
const debug = output.isDebugEnabled();
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
apiUrl,
|
apiUrl,
|
||||||
token,
|
token,
|
||||||
currentTeam: config.currentTeam,
|
currentTeam: config.currentTeam,
|
||||||
debug,
|
debug,
|
||||||
|
output,
|
||||||
});
|
});
|
||||||
|
|
||||||
const isFile = !isDirectory(path);
|
const isFile = !isDirectory(path);
|
||||||
@@ -161,6 +161,7 @@ export default async function setupAndLink(
|
|||||||
apiUrl,
|
apiUrl,
|
||||||
token,
|
token,
|
||||||
debug,
|
debug,
|
||||||
|
output,
|
||||||
currentTeam: client.currentTeam,
|
currentTeam: client.currentTeam,
|
||||||
});
|
});
|
||||||
const createArgs: any = {
|
const createArgs: any = {
|
||||||
|
|||||||
@@ -3,16 +3,33 @@ import boxen from 'boxen';
|
|||||||
import { format } from 'util';
|
import { format } from 'util';
|
||||||
import { Console } from 'console';
|
import { Console } from 'console';
|
||||||
import renderLink from './link';
|
import renderLink from './link';
|
||||||
import wait from './wait';
|
import wait, { StopSpinner } from './wait';
|
||||||
|
|
||||||
export type Output = ReturnType<typeof createOutput>;
|
export type Output = ReturnType<typeof _createOutput>;
|
||||||
|
|
||||||
|
export interface OutputOptions {
|
||||||
|
debug?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Singleton
|
||||||
|
let instance: Output | null = null;
|
||||||
|
|
||||||
|
export default function createOutput(opts?: OutputOptions) {
|
||||||
|
if (!instance) {
|
||||||
|
instance = _createOutput(opts);
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _createOutput({ debug: debugEnabled = false }: OutputOptions = {}) {
|
||||||
|
let spinner: StopSpinner | null = null;
|
||||||
|
|
||||||
export default function createOutput({ debug: debugEnabled = false } = {}) {
|
|
||||||
function isDebugEnabled() {
|
function isDebugEnabled() {
|
||||||
return debugEnabled;
|
return debugEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
function print(str: string) {
|
function print(str: string) {
|
||||||
|
stopSpinner();
|
||||||
process.stderr.write(str);
|
process.stderr.write(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,18 +111,32 @@ export default function createOutput({ debug: debugEnabled = false } = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function spinner(message: string, delay: number = 300) {
|
function setSpinner(message: string, delay: number = 300): StopSpinner {
|
||||||
if (debugEnabled) {
|
if (debugEnabled) {
|
||||||
debug(`Spinner invoked (${message}) with a ${delay}ms delay`);
|
debug(`Spinner invoked (${message}) with a ${delay}ms delay`);
|
||||||
let isEnded = false;
|
let isEnded = false;
|
||||||
return () => {
|
const stop = (() => {
|
||||||
if (isEnded) return;
|
if (isEnded) return;
|
||||||
isEnded = true;
|
isEnded = true;
|
||||||
debug(`Spinner ended (${message})`);
|
debug(`Spinner ended (${message})`);
|
||||||
};
|
}) as StopSpinner;
|
||||||
|
stop.text = message;
|
||||||
|
return stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
return wait(message, delay);
|
if (spinner) {
|
||||||
|
spinner.text = message;
|
||||||
|
} else {
|
||||||
|
spinner = wait(message, delay);
|
||||||
|
}
|
||||||
|
return spinner;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopSpinner() {
|
||||||
|
if (spinner) {
|
||||||
|
spinner();
|
||||||
|
spinner = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const c = {
|
const c = {
|
||||||
@@ -141,6 +172,7 @@ export default function createOutput({ debug: debugEnabled = false } = {}) {
|
|||||||
dim,
|
dim,
|
||||||
time,
|
time,
|
||||||
note,
|
note,
|
||||||
spinner,
|
spinner: setSpinner,
|
||||||
|
stopSpinner,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
export { default, Output } from './create-output';
|
export { default, Output } from './create-output';
|
||||||
|
export { StopSpinner } from './wait';
|
||||||
|
|||||||
@@ -2,28 +2,50 @@ import ora from 'ora';
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import eraseLines from './erase-lines';
|
import eraseLines from './erase-lines';
|
||||||
|
|
||||||
export default function wait(msg: string, delay: number = 300, _ora = ora) {
|
export interface StopSpinner {
|
||||||
let spinner: ReturnType<typeof _ora>;
|
(): void;
|
||||||
let running = false;
|
text: string;
|
||||||
|
}
|
||||||
|
|
||||||
const planned = setTimeout(() => {
|
export default function wait(
|
||||||
|
msg: string,
|
||||||
|
delay: number = 300,
|
||||||
|
_ora = ora
|
||||||
|
): StopSpinner {
|
||||||
|
let spinner: ReturnType<typeof _ora> | null = null;
|
||||||
|
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
spinner = _ora(chalk.gray(msg));
|
spinner = _ora(chalk.gray(msg));
|
||||||
spinner.color = 'gray';
|
spinner.color = 'gray';
|
||||||
spinner.start();
|
spinner.start();
|
||||||
running = true;
|
|
||||||
}, delay);
|
}, delay);
|
||||||
|
|
||||||
const cancel = () => {
|
const stop = () => {
|
||||||
clearTimeout(planned);
|
clearTimeout(timeout);
|
||||||
if (running) {
|
if (spinner) {
|
||||||
spinner.stop();
|
spinner.stop();
|
||||||
|
spinner = null;
|
||||||
process.stderr.write(eraseLines(1));
|
process.stderr.write(eraseLines(1));
|
||||||
running = false;
|
|
||||||
}
|
}
|
||||||
process.removeListener('nowExit', cancel);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
stop.text = msg;
|
||||||
|
|
||||||
|
// Allow `text` property to update the text while the spinner is in action
|
||||||
|
Object.defineProperty(stop, 'text', {
|
||||||
|
get() {
|
||||||
|
return msg;
|
||||||
|
},
|
||||||
|
|
||||||
|
set(v: string) {
|
||||||
|
msg = v;
|
||||||
|
if (spinner) {
|
||||||
|
spinner.text = chalk.gray(v);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
process.on('nowExit', cancel);
|
process.once('nowExit', stop);
|
||||||
return cancel;
|
return stop;
|
||||||
}
|
}
|
||||||
|
|||||||
2
packages/now-cli/test/dev/fixtures/test-clean-urls-with-output-directory/.gitignore
vendored
Normal file
2
packages/now-cli/test/dev/fixtures/test-clean-urls-with-output-directory/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.vercel
|
||||||
|
!public
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
About Page
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Index Page
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
body { color: green }
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Sub Another Page
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Sub Index Page
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"cleanUrls": true,
|
||||||
|
"trailingSlash": false
|
||||||
|
}
|
||||||
@@ -105,7 +105,8 @@ function validateResponseHeaders(t, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function exec(directory, args = []) {
|
async function exec(directory, args = []) {
|
||||||
return execa(binaryPath, ['dev', directory, ...args], {
|
const token = await fetchCachedToken();
|
||||||
|
return execa(binaryPath, ['dev', directory, '-t', token, ...args], {
|
||||||
reject: false,
|
reject: false,
|
||||||
shell: true,
|
shell: true,
|
||||||
env: { __VERCEL_SKIP_DEV_CMD: 1 },
|
env: { __VERCEL_SKIP_DEV_CMD: 1 },
|
||||||
@@ -166,9 +167,10 @@ async function testPath(
|
|||||||
async function testFixture(directory, opts = {}, args = []) {
|
async function testFixture(directory, opts = {}, args = []) {
|
||||||
await runNpmInstall(directory);
|
await runNpmInstall(directory);
|
||||||
|
|
||||||
|
const token = await fetchCachedToken();
|
||||||
const dev = execa(
|
const dev = execa(
|
||||||
binaryPath,
|
binaryPath,
|
||||||
['dev', directory, '-l', String(port), ...args],
|
['dev', directory, '-t', token, '-l', String(port), ...args],
|
||||||
{
|
{
|
||||||
reject: false,
|
reject: false,
|
||||||
detached: true,
|
detached: true,
|
||||||
@@ -232,7 +234,7 @@ async function testFixture(directory, opts = {}, args = []) {
|
|||||||
function testFixtureStdio(
|
function testFixtureStdio(
|
||||||
directory,
|
directory,
|
||||||
fn,
|
fn,
|
||||||
{ expectedCode = 0, skipDeploy, isExample } = {}
|
{ expectedCode = 0, skipDeploy, isExample, projectSettings } = {}
|
||||||
) {
|
) {
|
||||||
return async t => {
|
return async t => {
|
||||||
const nodeMajor = Number(process.versions.node.split('.')[0]);
|
const nodeMajor = Number(process.versions.node.split('.')[0]);
|
||||||
@@ -249,24 +251,51 @@ function testFixtureStdio(
|
|||||||
|
|
||||||
// Deploy fixture and link project
|
// Deploy fixture and link project
|
||||||
if (!skipDeploy) {
|
if (!skipDeploy) {
|
||||||
const project = join(cwd, '.vercel', 'project.json');
|
const projectJsonPath = join(cwd, '.vercel', 'project.json');
|
||||||
if (await fs.exists(project)) {
|
await fs.remove(projectJsonPath);
|
||||||
await fs.unlink(project);
|
|
||||||
}
|
|
||||||
const gitignore = join(cwd, '.gitignore');
|
const gitignore = join(cwd, '.gitignore');
|
||||||
const gitignoreOrig = await fs.exists(gitignore);
|
const hasGitignore = await fs.exists(gitignore);
|
||||||
let { stdout, stderr, exitCode } = await execa(
|
|
||||||
binaryPath,
|
try {
|
||||||
['-t', token, '--confirm', '--public', '--no-clipboard', '--debug'],
|
// Run `vc link`
|
||||||
{ cwd, reject: false }
|
const { exitCode: linkExitCode } = await execa(
|
||||||
);
|
binaryPath,
|
||||||
console.log({ stdout, stderr, exitCode });
|
['-t', token, 'link', '--confirm'],
|
||||||
if (!gitignoreOrig && (await fs.exists(gitignore))) {
|
{ cwd, stdio: 'inherit', reject: false }
|
||||||
await fs.unlink(gitignore);
|
);
|
||||||
}
|
t.is(linkExitCode, 0);
|
||||||
t.is(exitCode, expectedCode);
|
|
||||||
if (expectedCode === 0) {
|
// Patch the project with any non-default properties
|
||||||
deploymentUrl = new URL(stdout).host;
|
if (projectSettings) {
|
||||||
|
const { projectId } = await fs.readJson(projectJsonPath);
|
||||||
|
const res = await fetch(
|
||||||
|
`https://api.vercel.com/v2/projects/${projectId}`,
|
||||||
|
{
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(projectSettings),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
t.is(res.status, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run `vc deploy`
|
||||||
|
let { exitCode, stdout } = await execa(
|
||||||
|
binaryPath,
|
||||||
|
['-t', token, 'deploy', '--public', '--no-clipboard', '--debug'],
|
||||||
|
{ cwd, stdio: ['ignore', 'pipe', 'inherit'], reject: false }
|
||||||
|
);
|
||||||
|
console.log({ exitCode, stdout });
|
||||||
|
t.is(exitCode, expectedCode);
|
||||||
|
if (expectedCode === 0) {
|
||||||
|
deploymentUrl = new URL(stdout).host;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (!hasGitignore) {
|
||||||
|
await fs.remove(gitignore);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,14 +651,6 @@ test(
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
/*
|
|
||||||
test(
|
|
||||||
'[vercel dev] displays directory listing after miss',
|
|
||||||
testFixtureStdio('handle-miss-display-dir-list', async (testPath) => {
|
|
||||||
await testPath(404, '/post', /one.html/m);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'[vercel dev] does not display directory listing after 404',
|
'[vercel dev] does not display directory listing after 404',
|
||||||
@@ -899,6 +920,32 @@ test(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'[vercel dev] test cleanUrls serve correct content when using `outputDirectory`',
|
||||||
|
testFixtureStdio('test-clean-urls-with-output-directory', async testPath => {
|
||||||
|
await testPath(200, '/', 'Index Page');
|
||||||
|
await testPath(200, '/about', 'About Page');
|
||||||
|
await testPath(200, '/sub', 'Sub Index Page');
|
||||||
|
await testPath(200, '/sub/another', 'Sub Another Page');
|
||||||
|
await testPath(200, '/style.css', 'body { color: green }');
|
||||||
|
await testPath(308, '/index.html', 'Redirecting to / (308)', {
|
||||||
|
Location: '/',
|
||||||
|
});
|
||||||
|
await testPath(308, '/about.html', 'Redirecting to /about (308)', {
|
||||||
|
Location: '/about',
|
||||||
|
});
|
||||||
|
await testPath(308, '/sub/index.html', 'Redirecting to /sub (308)', {
|
||||||
|
Location: '/sub',
|
||||||
|
});
|
||||||
|
await testPath(
|
||||||
|
308,
|
||||||
|
'/sub/another.html',
|
||||||
|
'Redirecting to /sub/another (308)',
|
||||||
|
{ Location: '/sub/another' }
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'[vercel dev] should serve custom 404 when `cleanUrls: true`',
|
'[vercel dev] should serve custom 404 when `cleanUrls: true`',
|
||||||
testFixtureStdio('test-clean-urls-custom-404', async testPath => {
|
testFixtureStdio('test-clean-urls-custom-404', async testPath => {
|
||||||
@@ -1056,12 +1103,16 @@ test(
|
|||||||
|
|
||||||
test(
|
test(
|
||||||
'[vercel dev] 00-list-directory',
|
'[vercel dev] 00-list-directory',
|
||||||
testFixtureStdio('00-list-directory', async testPath => {
|
testFixtureStdio(
|
||||||
await testPath(200, '/', /Files within/m);
|
'00-list-directory',
|
||||||
await testPath(200, '/', /test[0-3]\.txt/m);
|
async testPath => {
|
||||||
await testPath(200, '/', /\.well-known/m);
|
await testPath(200, '/', /Files within/m);
|
||||||
await testPath(200, '/.well-known/keybase.txt', 'proof goes here');
|
await testPath(200, '/', /test[0-3]\.txt/m);
|
||||||
})
|
await testPath(200, '/', /\.well-known/m);
|
||||||
|
await testPath(200, '/.well-known/keybase.txt', 'proof goes here');
|
||||||
|
},
|
||||||
|
{ projectSettings: { directoryListing: true } }
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
test(
|
||||||
|
|||||||
61
packages/now-cli/test/integration.js
vendored
61
packages/now-cli/test/integration.js
vendored
@@ -3,6 +3,7 @@ import path from 'path';
|
|||||||
import { URL, parse as parseUrl } from 'url';
|
import { URL, parse as parseUrl } from 'url';
|
||||||
import test from 'ava';
|
import test from 'ava';
|
||||||
import semVer from 'semver';
|
import semVer from 'semver';
|
||||||
|
import { Readable } from 'stream';
|
||||||
import { homedir } from 'os';
|
import { homedir } from 'os';
|
||||||
import _execa from 'execa';
|
import _execa from 'execa';
|
||||||
import XDGAppPaths from 'xdg-app-paths';
|
import XDGAppPaths from 'xdg-app-paths';
|
||||||
@@ -800,9 +801,9 @@ test('Deploy `api-env` fixture and test `vercel env` command', async t => {
|
|||||||
t.is(homeJson['MY_STDIN_VAR'], '{"expect":"quotes"}');
|
t.is(homeJson['MY_STDIN_VAR'], '{"expect":"quotes"}');
|
||||||
t.is(homeJson['MY_DECRYPTABLE_SECRET_ENV'], 'decryptable value');
|
t.is(homeJson['MY_DECRYPTABLE_SECRET_ENV'], 'decryptable value');
|
||||||
|
|
||||||
// system env vars are not automatically exposed
|
// system env vars are automatically exposed
|
||||||
t.is(apiJson['VERCEL'], undefined);
|
t.is(apiJson['VERCEL'], '1');
|
||||||
t.is(homeJson['VERCEL'], undefined);
|
t.is(homeJson['VERCEL'], '1');
|
||||||
|
|
||||||
vc.kill('SIGTERM', { forceKillAfterTimeout: 2000 });
|
vc.kill('SIGTERM', { forceKillAfterTimeout: 2000 });
|
||||||
|
|
||||||
@@ -1171,11 +1172,11 @@ test('login with unregistered user', async t => {
|
|||||||
console.log(exitCode);
|
console.log(exitCode);
|
||||||
|
|
||||||
const goal = `Error! Please sign up: https://vercel.com/signup`;
|
const goal = `Error! Please sign up: https://vercel.com/signup`;
|
||||||
const lines = stdout.trim().split('\n');
|
const lines = stderr.trim().split('\n');
|
||||||
const last = lines[lines.length - 1];
|
const last = lines[lines.length - 1];
|
||||||
|
|
||||||
t.is(exitCode, 1);
|
t.is(exitCode, 1);
|
||||||
t.is(last, goal);
|
t.true(last.includes(goal));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('ignore files specified in .nowignore', async t => {
|
test('ignore files specified in .nowignore', async t => {
|
||||||
@@ -1249,10 +1250,10 @@ test('list the scopes', async t => {
|
|||||||
|
|
||||||
t.is(exitCode, 0);
|
t.is(exitCode, 0);
|
||||||
|
|
||||||
const include = `✔ ${contextName} ${email}`;
|
const include = new RegExp(`✔ ${contextName}\\s+${email}`);
|
||||||
|
|
||||||
t.true(
|
t.true(
|
||||||
stdout.includes(include),
|
include.test(stdout),
|
||||||
`Expected: ${include}\n\nReceived instead:\n${stdout}\n${stderr}`
|
`Expected: ${include}\n\nReceived instead:\n${stdout}\n${stderr}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1335,12 +1336,23 @@ test('try to purchase a domain', async t => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const stream = new Readable();
|
||||||
|
stream._read = () => {};
|
||||||
|
|
||||||
|
setTimeout(async () => {
|
||||||
|
await sleep(ms('1s'));
|
||||||
|
stream.push('y');
|
||||||
|
await sleep(ms('1s'));
|
||||||
|
stream.push('y');
|
||||||
|
stream.push(null);
|
||||||
|
}, ms('1s'));
|
||||||
|
|
||||||
const { stderr, stdout, exitCode } = await execa(
|
const { stderr, stdout, exitCode } = await execa(
|
||||||
binaryPath,
|
binaryPath,
|
||||||
['domains', 'buy', `${session}-test.org`, ...defaultArgs],
|
['domains', 'buy', `${session}-test.org`, ...defaultArgs],
|
||||||
{
|
{
|
||||||
reject: false,
|
reject: false,
|
||||||
input: 'y',
|
input: stream,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1566,7 +1578,7 @@ test('ensure we render a warning for deployments with no files', async t => {
|
|||||||
t.is(res.status, 404);
|
t.is(res.status, 404);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('output logs of a 2.0 deployment', async t => {
|
test('output logs with "short" output', async t => {
|
||||||
const { stderr, stdout, exitCode } = await execa(
|
const { stderr, stdout, exitCode } = await execa(
|
||||||
binaryPath,
|
binaryPath,
|
||||||
['logs', context.deployment, ...defaultArgs],
|
['logs', context.deployment, ...defaultArgs],
|
||||||
@@ -1583,13 +1595,21 @@ test('output logs of a 2.0 deployment', async t => {
|
|||||||
stderr.includes(`Fetched deployment "${context.deployment}"`),
|
stderr.includes(`Fetched deployment "${context.deployment}"`),
|
||||||
formatOutput({ stderr, stdout })
|
formatOutput({ stderr, stdout })
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// "short" format includes timestamps
|
||||||
|
t.truthy(
|
||||||
|
stdout.match(
|
||||||
|
/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
t.is(exitCode, 0);
|
t.is(exitCode, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('output logs of a 2.0 deployment without annotate', async t => {
|
test('output logs with "raw" output', async t => {
|
||||||
const { stderr, stdout, exitCode } = await execa(
|
const { stderr, stdout, exitCode } = await execa(
|
||||||
binaryPath,
|
binaryPath,
|
||||||
['logs', context.deployment, ...defaultArgs],
|
['logs', context.deployment, ...defaultArgs, '--output', 'raw'],
|
||||||
{
|
{
|
||||||
reject: false,
|
reject: false,
|
||||||
}
|
}
|
||||||
@@ -1599,12 +1619,19 @@ test('output logs of a 2.0 deployment without annotate', async t => {
|
|||||||
console.log(stdout);
|
console.log(stdout);
|
||||||
console.log(exitCode);
|
console.log(exitCode);
|
||||||
|
|
||||||
t.true(!stderr.includes('[now-builder-debug]'));
|
t.true(
|
||||||
t.true(!stderr.includes('START RequestId'));
|
stderr.includes(`Fetched deployment "${context.deployment}"`),
|
||||||
t.true(!stderr.includes('END RequestId'));
|
formatOutput({ stderr, stdout })
|
||||||
t.true(!stderr.includes('REPORT RequestId'));
|
);
|
||||||
t.true(!stderr.includes('Init Duration'));
|
|
||||||
t.true(!stderr.includes('XRAY TraceId'));
|
// "raw" format does not include timestamps
|
||||||
|
t.is(
|
||||||
|
null,
|
||||||
|
stdout.match(
|
||||||
|
/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
t.is(exitCode, 0);
|
t.is(exitCode, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vercel/client",
|
"name": "@vercel/client",
|
||||||
"version": "9.0.5-canary.1",
|
"version": "9.0.6-canary.1",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"homepage": "https://vercel.com",
|
"homepage": "https://vercel.com",
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vercel/build-utils": "2.6.1-canary.1",
|
"@vercel/build-utils": "2.7.1-canary.1",
|
||||||
"@zeit/fetch": "5.2.0",
|
"@zeit/fetch": "5.2.0",
|
||||||
"async-retry": "1.2.3",
|
"async-retry": "1.2.3",
|
||||||
"async-sema": "3.0.0",
|
"async-sema": "3.0.0",
|
||||||
|
|||||||
@@ -285,8 +285,8 @@ Learn more: https://vercel.com/docs/runtimes#official-runtimes/go
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mainModGoContents = modMainGoContents
|
const mainModGoContents = modMainGoContents
|
||||||
.replace('__NOW_HANDLER_PACKAGE_NAME', goPackageName)
|
.replace('__VC_HANDLER_PACKAGE_NAME', goPackageName)
|
||||||
.replace('__NOW_HANDLER_FUNC_NAME', goFuncName);
|
.replace('__VC_HANDLER_FUNC_NAME', goFuncName);
|
||||||
|
|
||||||
if (isGoModExist && isGoModInRootDir) {
|
if (isGoModExist && isGoModInRootDir) {
|
||||||
debug('[mod-root] Write main file to ' + downloadPath);
|
debug('[mod-root] Write main file to ' + downloadPath);
|
||||||
@@ -405,13 +405,13 @@ Learn more: https://vercel.com/docs/runtimes#official-runtimes/go
|
|||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
const mainGoContents = origianlMainGoContents.replace(
|
const mainGoContents = origianlMainGoContents.replace(
|
||||||
'__NOW_HANDLER_FUNC_NAME',
|
'__VC_HANDLER_FUNC_NAME',
|
||||||
handlerFunctionName
|
handlerFunctionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// in order to allow the user to have `main.go`,
|
// in order to allow the user to have `main.go`,
|
||||||
// we need our `main.go` to be called something else
|
// we need our `main.go` to be called something else
|
||||||
const mainGoFileName = 'main__now__go__.go';
|
const mainGoFileName = 'main__vc__go__.go';
|
||||||
|
|
||||||
// Go doesn't like to build files in different directories,
|
// Go doesn't like to build files in different directories,
|
||||||
// so now we place `main.go` together with the user code
|
// so now we place `main.go` together with the user code
|
||||||
@@ -580,9 +580,9 @@ Learn more: https://vercel.com/docs/runtimes#official-runtimes/go`
|
|||||||
};
|
};
|
||||||
} else if (Array.isArray(result)) {
|
} else if (Array.isArray(result)) {
|
||||||
// Got "exit" event from child process
|
// Got "exit" event from child process
|
||||||
throw new Error(
|
const [exitCode, signal] = result;
|
||||||
`Failed to start dev server for "${entrypointWithExt}" (code=${result[0]}, signal=${result[1]})`
|
const reason = signal ? `"${signal}" signal` : `exit code ${exitCode}`;
|
||||||
);
|
throw new Error(`\`go run ${entrypointWithExt}\` failed with ${reason}`);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unexpected result type: ${typeof result}`);
|
throw new Error(`Unexpected result type: ${typeof result}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
vc.Start(http.HandlerFunc(__NOW_HANDLER_FUNC_NAME))
|
vc.Start(http.HandlerFunc(__VC_HANDLER_FUNC_NAME))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"__NOW_HANDLER_PACKAGE_NAME"
|
"__VC_HANDLER_PACKAGE_NAME"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
vc "github.com/vercel/go-bridge/go/bridge"
|
vc "github.com/vercel/go-bridge/go/bridge"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
vc.Start(http.HandlerFunc(__NOW_HANDLER_FUNC_NAME))
|
vc.Start(http.HandlerFunc(__VC_HANDLER_FUNC_NAME))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vercel/go",
|
"name": "@vercel/go",
|
||||||
"version": "1.1.6",
|
"version": "1.1.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "./dist/index",
|
"main": "./dist/index",
|
||||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
|
||||||
|
|||||||
2
packages/now-next/.gitignore
vendored
2
packages/now-next/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
/dist
|
|
||||||
/src/now__bridge.ts
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
bridge_defs="$(dirname $(pwd))/now-node-bridge/src/bridge.ts"
|
|
||||||
|
|
||||||
cp -v "$bridge_defs" src/now__bridge.ts
|
|
||||||
|
|
||||||
tsc
|
|
||||||
|
|
||||||
ncc build src/dev-server.ts -e @vercel/build-utils -e @now/build-utils -o dist/dev
|
|
||||||
mv dist/dev/index.js dist/dev-server.js
|
|
||||||
rm -rf dist/dev
|
|
||||||
|
|
||||||
ncc build src/index.ts -e @vercel/build-utils -e @now/build-utils -o dist/main
|
|
||||||
mv dist/main/index.js dist/index.js
|
|
||||||
rm -rf dist/main
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@vercel/next",
|
|
||||||
"version": "2.7.6",
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "./dist/index",
|
|
||||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
|
||||||
"scripts": {
|
|
||||||
"build": "./build.sh",
|
|
||||||
"test-integration-once": "jest --env node --verbose --runInBand --bail",
|
|
||||||
"prepublishOnly": "./build.sh"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/vercel/vercel.git",
|
|
||||||
"directory": "packages/now-next"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist"
|
|
||||||
],
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/aws-lambda": "8.10.19",
|
|
||||||
"@types/buffer-crc32": "0.2.0",
|
|
||||||
"@types/find-up": "4.0.0",
|
|
||||||
"@types/fs-extra": "8.0.0",
|
|
||||||
"@types/next-server": "8.0.0",
|
|
||||||
"@types/resolve-from": "5.0.1",
|
|
||||||
"@types/semver": "6.0.0",
|
|
||||||
"@types/yazl": "2.4.1",
|
|
||||||
"@vercel/nft": "0.9.4",
|
|
||||||
"async-sema": "3.0.1",
|
|
||||||
"buffer-crc32": "0.2.13",
|
|
||||||
"escape-string-regexp": "2.0.0",
|
|
||||||
"execa": "2.0.4",
|
|
||||||
"find-up": "4.1.0",
|
|
||||||
"fs-extra": "7.0.0",
|
|
||||||
"get-port": "5.0.0",
|
|
||||||
"resolve-from": "5.0.0",
|
|
||||||
"semver": "6.1.1",
|
|
||||||
"set-cookie-parser": "2.4.6",
|
|
||||||
"typescript": "3.9.3",
|
|
||||||
"yazl": "https://github.com/ijjk/yazl#70949c55b482647669ce37023017b1514c42b33c"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
let buildUtils: typeof import('@vercel/build-utils');
|
|
||||||
|
|
||||||
try {
|
|
||||||
buildUtils = require('@vercel/build-utils');
|
|
||||||
} catch (e) {
|
|
||||||
// Fallback for older CLI versions
|
|
||||||
buildUtils = require('@now/build-utils');
|
|
||||||
}
|
|
||||||
|
|
||||||
export default buildUtils;
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user