Skip to content

Commit

Permalink
[all] Remove more "now" references (vercel#5944)
Browse files Browse the repository at this point in the history
Follow up to vercel#5928 to remove a few more "now" references and replace with "vercel" where appropriate.
  • Loading branch information
styfle authored Mar 8, 2021
1 parent c0d22cf commit f5f07c5
Show file tree
Hide file tree
Showing 78 changed files with 264 additions and 1,080 deletions.
6 changes: 3 additions & 3 deletions api/_lib/util/with-api-handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { NowRequest, NowResponse } from '@vercel/node';
import { VercelRequest, VercelResponse } from '@vercel/node';
import { errorHandler } from './error-handler';

type Handler = (req: NowRequest, res: NowResponse) => Promise<any>;
type Handler = (req: VercelRequest, res: VercelResponse) => Promise<any>;

export function withApiHandler(handler: Handler): Handler {
return async (req: NowRequest, res: NowResponse) => {
return async (req: VercelRequest, res: VercelResponse) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET');
res.setHeader(
Expand Down
8 changes: 4 additions & 4 deletions api/examples/download/[segment].ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs';
// @ts-ignore
import tar from 'tar-fs';
import { extract } from '../../_lib/examples/extract';
import { NowRequest, NowResponse } from '@vercel/node';
import { VercelRequest, VercelResponse } from '@vercel/node';
import { withApiHandler } from '../../_lib/util/with-api-handler';

const TMP_DIR = '/tmp';
Expand All @@ -11,7 +11,7 @@ function isDirectory(path: string) {
return fs.existsSync(path) && fs.lstatSync(path).isDirectory();
}

function notFound(res: NowResponse, message: string) {
function notFound(res: VercelResponse, message: string) {
return res.status(404).send({
error: {
code: 'not_found',
Expand All @@ -36,8 +36,8 @@ function streamToBuffer(stream: any) {
}

export default withApiHandler(async function (
req: NowRequest,
res: NowResponse
req: VercelRequest,
res: VercelResponse
) {
const ext = '.tar.gz';
const { segment = '' } = req.query;
Expand Down
6 changes: 3 additions & 3 deletions api/examples/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

// @ts-ignore
import parseGitUrl from 'parse-github-url';
import { NowRequest, NowResponse } from '@vercel/node';
import { VercelRequest, VercelResponse } from '@vercel/node';
import { withApiHandler } from '../_lib/util/with-api-handler';
import { getGitHubRepoInfo } from '../_lib/examples/github-repo-info';
import { getGitLabRepoInfo } from '../_lib/examples/gitlab-repo-info';

export default withApiHandler(async function (
req: NowRequest,
res: NowResponse
req: VercelRequest,
res: VercelResponse
) {
const repoPath = decodeURIComponent((req.query.repo as string) || '');

Expand Down
6 changes: 3 additions & 3 deletions api/examples/list-all.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { NowRequest, NowResponse } from '@vercel/node';
import { VercelRequest, VercelResponse } from '@vercel/node';
import { getExampleList } from '../_lib/examples/example-list';
import { withApiHandler } from '../_lib/util/with-api-handler';

export default withApiHandler(async function (
req: NowRequest,
res: NowResponse
req: VercelRequest,
res: VercelResponse
) {
res.status(200).json(await getExampleList());
});
6 changes: 3 additions & 3 deletions api/examples/list.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { extract } from '../_lib/examples/extract';
import { summary } from '../_lib/examples/summary';
import { NowRequest, NowResponse } from '@vercel/node';
import { VercelRequest, VercelResponse } from '@vercel/node';
import { mapOldToNew } from '../_lib/examples/map-old-to-new';
import { withApiHandler } from '../_lib/util/with-api-handler';

export default withApiHandler(async function (
req: NowRequest,
res: NowResponse
req: VercelRequest,
res: VercelResponse
) {
await extract('https://github.com/vercel/vercel/archive/master.zip', '/tmp');
const exampleList = summary('/tmp/vercel-master/examples');
Expand Down
6 changes: 3 additions & 3 deletions api/frameworks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NowRequest, NowResponse } from '@vercel/node';
import { VercelRequest, VercelResponse } from '@vercel/node';
import { withApiHandler } from './_lib/util/with-api-handler';
import _frameworks, { Framework } from '../packages/frameworks';

Expand Down Expand Up @@ -27,8 +27,8 @@ const frameworks = (_frameworks as Framework[])
});

export default withApiHandler(async function (
req: NowRequest,
res: NowResponse
req: VercelRequest,
res: VercelResponse
) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET');
Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"devDependencies": {
"@types/node": "13.1.4",
"@types/node-fetch": "2.5.4",
"@vercel/node": "1.7.2",
"@vercel/node": "1.9.0",
"typescript": "3.9.6"
}
}
8 changes: 4 additions & 4 deletions api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@
dependencies:
"@types/node" "*"

"@vercel/node@1.7.2":
version "1.7.2"
resolved "https://registry.yarnpkg.com/@vercel/node/-/node-1.7.2.tgz#85cb8aac661c02dfef6fe752740f5b162e90767b"
integrity sha512-XV5lrLC+K/cxsaFj8H2OoGu1zliOqnxcrOnPInI8HmQjR/Tztt+0nzgpt+7sx8wXcrib0Nu7lK303jP7VjSETw==
"@vercel/node@1.9.0":
version "1.9.0"
resolved "https://registry.yarnpkg.com/@vercel/node/-/node-1.9.0.tgz#6b64f3b9a962ddb1089276fad00f441a1f4b9cf0"
integrity sha512-Vk/ZpuY4Cdc8oUwBi/kf8qETRaJb/KYdFddVkLuS10QwA0yJx+RQ11trhZ1KFUdc27aBr5S2k8/dDxK8sLr+IA==
dependencies:
"@types/node" "*"
ts-node "8.9.1"
Expand Down
2 changes: 0 additions & 2 deletions examples/gatsby/.nowignore

This file was deleted.

4 changes: 2 additions & 2 deletions examples/gatsby/api/date.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NowRequest, NowResponse } from '@vercel/node';
import { VercelRequest, VercelResponse } from '@vercel/node';

export default (_req: NowRequest, res: NowResponse) => {
export default (_req: VercelRequest, res: VercelResponse) => {
const date = new Date().toString();
res.status(200).send(date);
};
2 changes: 1 addition & 1 deletion examples/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react-helmet": "^5.2.0"
},
"devDependencies": {
"@vercel/node": "1.8.5"
"@vercel/node": "1.9.0"
},
"scripts": {
"dev": "gatsby develop",
Expand Down
8 changes: 4 additions & 4 deletions examples/gatsby/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1400,10 +1400,10 @@
dependencies:
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==
"@vercel/node@1.9.0":
version "1.9.0"
resolved "https://registry.yarnpkg.com/@vercel/node/-/node-1.9.0.tgz#6b64f3b9a962ddb1089276fad00f441a1f4b9cf0"
integrity sha512-Vk/ZpuY4Cdc8oUwBi/kf8qETRaJb/KYdFddVkLuS10QwA0yJx+RQ11trhZ1KFUdc27aBr5S2k8/dDxK8sLr+IA==
dependencies:
"@types/node" "*"
ts-node "8.9.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function checkPkgOrThrow(pkgname) {
checkPkgOrThrow('tls-check');
checkPkgOrThrow('exeggcute');

// This is to satisfy `@now/static-build` which needs a `dist` directory.
// This is to satisfy `@vercel/static-build` which needs a `dist` directory.
const { exec } = require('exeggcute');
exec('mkdir dist', __dirname);
exec('echo "node-env:RANDOMNESS_PLACEHOLDER" > dist/index.html', __dirname);
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (development) {
throw new Error('Expected development dependencies to _NOT_ be installed.');
}

// This is to satisfy `@now/static-build` which needs a `dist` directory.
// This is to satisfy `@vercel/static-build` which needs a `dist` directory.
const { execSync } = require('child_process');
execSync('mkdir dist');
execSync('echo "npm-prod:RANDOMNESS_PLACEHOLDER" > dist/index.html');
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (development) {
throw new Error('Expected development dependencies to _NOT_ be installed.');
}

// This is to satisfy `@now/static-build` which needs a `dist` directory.
// This is to satisfy `@vercel/static-build` which needs a `dist` directory.
const { execSync } = require('child_process');
execSync('mkdir dist');
execSync('echo "yarn-prod:RANDOMNESS_PLACEHOLDER" > dist/index.html');
2 changes: 1 addition & 1 deletion packages/cgi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
shouldServe,
createLambda,
getWritableDirectory,
} = require('@now/build-utils');
} = require('@vercel/build-utils');

exports.analyze = ({ files, entrypoint }) => files[entrypoint].digest;

Expand Down
2 changes: 1 addition & 1 deletion packages/cgi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (h *CgiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Env: []string{
"HTTPS=on",
"SERVER_PORT=443",
"SERVER_SOFTWARE=@now/cgi",
"SERVER_SOFTWARE=@vercel/cgi",
},
}
handler.ServeHTTP(w, r)
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/util/deploy/process-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import chalk from 'chalk';
import {
createDeployment,
DeploymentOptions,
NowClientOptions,
VercelClientOptions,
} from '@vercel/client';
import { Output } from '../output';
// @ts-ignore
Expand Down Expand Up @@ -71,7 +71,7 @@ export default async function processDeployment({

const { env = {} } = requestBody;

const nowClientOptions: NowClientOptions = {
const clientOptions: VercelClientOptions = {
teamId: org.type === 'team' ? org.id : undefined,
apiUrl: now._apiUrl,
token: now._token,
Expand All @@ -96,7 +96,7 @@ export default async function processDeployment({

try {
for await (const event of createDeployment(
nowClientOptions,
clientOptions,
requestBody,
nowConfig
)) {
Expand Down
44 changes: 22 additions & 22 deletions packages/cli/test/dev-builder.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,87 +178,87 @@ test('[dev-builder] filter install not bundled tagged, cached tagged', t => {
});

test('[dev-builder] isBundledBuilder() - stable', t => {
const nowCliPkg = {
const cliPkg = {
dependencies: {
'@now/node': '1.5.2',
'@vercel/node': '1.6.1',
},
};

// "canary" tag
{
const parsed = npa('@now/node@canary');
const result = isBundledBuilder(parsed, nowCliPkg);
const parsed = npa('@vercel/node@canary');
const result = isBundledBuilder(parsed, cliPkg);
t.is(result, false);
}

// "latest" tag
{
const parsed = npa('@now/node');
const result = isBundledBuilder(parsed, nowCliPkg);
const parsed = npa('@vercel/node');
const result = isBundledBuilder(parsed, cliPkg);
t.is(result, true);
}

// specific matching version
{
const parsed = npa('@now/node@1.5.2');
const result = isBundledBuilder(parsed, nowCliPkg);
const parsed = npa('@vercel/node@1.6.1');
const result = isBundledBuilder(parsed, cliPkg);
t.is(result, true);
}

// specific non-matching version
{
const parsed = npa('@now/node@1.5.1');
const result = isBundledBuilder(parsed, nowCliPkg);
const parsed = npa('@vercel/node@1.6.0');
const result = isBundledBuilder(parsed, cliPkg);
t.is(result, false);
}

// URL
{
const parsed = npa('https://example.com');
const result = isBundledBuilder(parsed, nowCliPkg);
const result = isBundledBuilder(parsed, cliPkg);
t.is(result, false);
}
});

test('[dev-builder] isBundledBuilder() - canary', t => {
const nowCliPkg = {
const cliPkg = {
dependencies: {
'@now/node': '1.5.2-canary.3',
'@vercel/node': '1.6.1-canary.0',
},
};

// "canary" tag
{
const parsed = npa('@now/node@canary');
const result = isBundledBuilder(parsed, nowCliPkg);
const parsed = npa('@vercel/node@canary');
const result = isBundledBuilder(parsed, cliPkg);
t.is(result, true);
}

// "latest" tag
{
const parsed = npa('@now/node');
const result = isBundledBuilder(parsed, nowCliPkg);
const parsed = npa('@vercel/node');
const result = isBundledBuilder(parsed, cliPkg);
t.is(result, false);
}

// specific matching version
{
const parsed = npa('@now/node@1.5.2-canary.3');
const result = isBundledBuilder(parsed, nowCliPkg);
const parsed = npa('@vercel/node@1.6.1-canary.0');
const result = isBundledBuilder(parsed, cliPkg);
t.is(result, true);
}

// specific non-matching version
{
const parsed = npa('@now/[email protected].2');
const result = isBundledBuilder(parsed, nowCliPkg);
const parsed = npa('@vercel/[email protected].9');
const result = isBundledBuilder(parsed, cliPkg);
t.is(result, false);
}

// URL
{
const parsed = npa('https://example.com');
const result = isBundledBuilder(parsed, nowCliPkg);
const result = isBundledBuilder(parsed, cliPkg);
t.is(result, false);
}
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": 2,
"builds": [
{ "src": "*.js", "use": "@now/node" },
{ "src": "*.html", "use": "@now/static" }
{ "src": "*.js", "use": "@vercel/node" },
{ "src": "*.html", "use": "@vercel/static" }
],
"routes": [
{ "src": "/error.js", "dest": "/error.js", "status": 404 },
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version": 2,
"builds": [
{ "src": "*.js", "use": "@vercel/node" },
{ "src": "*.txt", "use": "@vercel/static" }
]
}
8 changes: 0 additions & 8 deletions packages/cli/test/fixtures/unit/now-dev-headers/now.json

This file was deleted.

8 changes: 8 additions & 0 deletions packages/cli/test/fixtures/unit/now-dev-headers/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 2,
"name": "now-dev-headers",
"builds": [
{ "src": "index.js", "use": "@vercel/node" },
{ "src": "foo.txt", "use": "@vercel/static" }
]
}
Loading

0 comments on commit f5f07c5

Please sign in to comment.