mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 21:07:46 +00:00
[cli] Remove a bunch of isCanary checks (#9806)
We no longer publish versions that include `-canary` in the package.json `version` field, so these are dead code. Just doing a little bit of cleanup.
This commit is contained in:
@@ -39,7 +39,6 @@
|
|||||||
"version": "pnpm install && git add pnpm-lock.yaml",
|
"version": "pnpm install && git add pnpm-lock.yaml",
|
||||||
"bootstrap": "lerna bootstrap",
|
"bootstrap": "lerna bootstrap",
|
||||||
"publish-stable": "echo 'Run `pnpm changelog` for instructions'",
|
"publish-stable": "echo 'Run `pnpm changelog` for instructions'",
|
||||||
"publish-canary": "git checkout main && git pull && lerna version prerelease --preid canary --message \"Publish Canary\" --exact",
|
|
||||||
"publish-from-github": "./utils/publish.sh",
|
"publish-from-github": "./utils/publish.sh",
|
||||||
"changelog": "node utils/changelog.js",
|
"changelog": "node utils/changelog.js",
|
||||||
"build": "node utils/gen.js && turbo --no-update-notifier run build",
|
"build": "node utils/gen.js && turbo --no-update-notifier run build",
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ import type { AuthConfig, GlobalConfig } from '@vercel-internals/types';
|
|||||||
import { VercelConfig } from '@vercel/client';
|
import { VercelConfig } from '@vercel/client';
|
||||||
import box from './util/output/box';
|
import box from './util/output/box';
|
||||||
|
|
||||||
const isCanary = pkg.version.includes('canary');
|
|
||||||
|
|
||||||
const VERCEL_DIR = getGlobalPathConfig();
|
const VERCEL_DIR = getGlobalPathConfig();
|
||||||
const VERCEL_CONFIG_PATH = configFiles.getConfigFilePath();
|
const VERCEL_CONFIG_PATH = configFiles.getConfigFilePath();
|
||||||
const VERCEL_AUTH_CONFIG_PATH = configFiles.getAuthConfigFilePath();
|
const VERCEL_AUTH_CONFIG_PATH = configFiles.getAuthConfigFilePath();
|
||||||
@@ -70,7 +68,7 @@ sourceMap.install();
|
|||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn: SENTRY_DSN,
|
dsn: SENTRY_DSN,
|
||||||
release: `vercel-cli@${pkg.version}`,
|
release: `vercel-cli@${pkg.version}`,
|
||||||
environment: isCanary ? 'canary' : 'stable',
|
environment: 'stable',
|
||||||
});
|
});
|
||||||
|
|
||||||
let client: Client;
|
let client: Client;
|
||||||
@@ -165,13 +163,7 @@ const main = async () => {
|
|||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
output.print(
|
output.print(`${chalk.grey(`${getTitleName()} CLI ${pkg.version}`)}\n`);
|
||||||
`${chalk.grey(
|
|
||||||
`${getTitleName()} CLI ${pkg.version}${
|
|
||||||
isCanary ? ' — https://vercel.com/feedback' : ''
|
|
||||||
}`
|
|
||||||
)}\n`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle `--version` directly
|
// Handle `--version` directly
|
||||||
@@ -707,7 +699,6 @@ main()
|
|||||||
// Check if an update is available. If so, `latest` will contain a string
|
// Check if an update is available. If so, `latest` will contain a string
|
||||||
// of the latest version, otherwise `undefined`.
|
// of the latest version, otherwise `undefined`.
|
||||||
const latest = getLatestVersion({
|
const latest = getLatestVersion({
|
||||||
distTag: isCanary ? 'canary' : 'latest',
|
|
||||||
output,
|
output,
|
||||||
pkg,
|
pkg,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,10 +51,8 @@ import link from '../output/link';
|
|||||||
import sleep from '../sleep';
|
import sleep from '../sleep';
|
||||||
import { Output } from '../output';
|
import { Output } from '../output';
|
||||||
import { relative } from '../path-helpers';
|
import { relative } from '../path-helpers';
|
||||||
import { getDistTag } from '../get-dist-tag';
|
|
||||||
import getVercelConfigPath from '../config/local-path';
|
import getVercelConfigPath from '../config/local-path';
|
||||||
import { MissingDotenvVarsError } from '../errors-ts';
|
import { MissingDotenvVarsError } from '../errors-ts';
|
||||||
import cliPkg from '../pkg';
|
|
||||||
import { getVercelDirectory } from '../projects/link';
|
import { getVercelDirectory } from '../projects/link';
|
||||||
import { staticFiles as getFiles } from '../get-files';
|
import { staticFiles as getFiles } from '../get-files';
|
||||||
import { validateConfig } from '../validate-config';
|
import { validateConfig } from '../validate-config';
|
||||||
@@ -593,7 +591,7 @@ export default class DevServer {
|
|||||||
rewriteRoutes,
|
rewriteRoutes,
|
||||||
errorRoutes,
|
errorRoutes,
|
||||||
} = await detectBuilders(files, pkg, {
|
} = await detectBuilders(files, pkg, {
|
||||||
tag: getDistTag(cliPkg.version) === 'canary' ? 'canary' : 'latest',
|
tag: 'latest',
|
||||||
functions: vercelConfig.functions,
|
functions: vercelConfig.functions,
|
||||||
projectSettings: projectSettings || this.projectSettings,
|
projectSettings: projectSettings || this.projectSettings,
|
||||||
featHandleMiss,
|
featHandleMiss,
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import semver from 'semver';
|
|
||||||
|
|
||||||
export function getDistTag(version: string): string {
|
|
||||||
const parsed = semver.parse(version);
|
|
||||||
if (parsed && typeof parsed.prerelease[0] === 'string') {
|
|
||||||
return parsed.prerelease[0] as string;
|
|
||||||
}
|
|
||||||
return 'latest';
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Stats } from 'fs';
|
import { Stats } from 'fs';
|
||||||
import { sep, dirname, join, resolve } from 'path';
|
import { sep, dirname, join, resolve } from 'path';
|
||||||
import { lstat, readlink, readFile, realpath } from 'fs-extra';
|
import { lstat, readlink, readFile, realpath } from 'fs-extra';
|
||||||
import { isCanary } from './is-canary';
|
|
||||||
import { getPkgName } from './pkg-name';
|
import { getPkgName } from './pkg-name';
|
||||||
|
|
||||||
async function isYarn(): Promise<boolean> {
|
async function isYarn(): Promise<boolean> {
|
||||||
@@ -99,8 +98,7 @@ async function isGlobal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function getUpdateCommand(): Promise<string> {
|
export default async function getUpdateCommand(): Promise<string> {
|
||||||
const tag = isCanary() ? 'canary' : 'latest';
|
const pkgAndVersion = `${getPkgName()}@latest`;
|
||||||
const pkgAndVersion = `${getPkgName()}@${tag}`;
|
|
||||||
|
|
||||||
if (await isGlobal()) {
|
if (await isGlobal()) {
|
||||||
return (await isYarn())
|
return (await isYarn())
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
import pkg from '../../package.json';
|
|
||||||
|
|
||||||
export function isCanary() {
|
|
||||||
return pkg.version.includes('canary');
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"builds": [
|
"builds": [
|
||||||
{ "src": "entrypoint**", "use": "@vercel/node@canary" },
|
{ "src": "entrypoint**", "use": "@vercel/node" },
|
||||||
{ "src": "type-module-package-json/**/*.js", "use": "@vercel/node@canary" }
|
{ "src": "type-module-package-json/**/*.js", "use": "@vercel/node" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"builds":[{"src":"index.js","use":"@vercel/node@canary"}]}
|
{"builds":[{"src":"index.js","use":"@vercel/node"}]}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"builds": [
|
"builds": [
|
||||||
{
|
{
|
||||||
"src": "package.json",
|
"src": "package.json",
|
||||||
"use": "@vercel/static-build@canary",
|
"use": "@vercel/static-build",
|
||||||
"config": {
|
"config": {
|
||||||
"distDir": "public"
|
"distDir": "public"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ const {
|
|||||||
fetch,
|
fetch,
|
||||||
sleep,
|
sleep,
|
||||||
fixture,
|
fixture,
|
||||||
isCanary,
|
|
||||||
shouldSkip,
|
shouldSkip,
|
||||||
testFixture,
|
testFixture,
|
||||||
fetchWithRetry,
|
fetchWithRetry,
|
||||||
@@ -46,11 +45,7 @@ test('[vercel dev] 02-angular-node', async () => {
|
|||||||
|
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
|
|
||||||
if (isCanary()) {
|
stderr.includes('@now/build-utils@latest');
|
||||||
stderr.includes('@now/build-utils@canary');
|
|
||||||
} else {
|
|
||||||
stderr.includes('@now/build-utils@latest');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ const fetch = require('node-fetch');
|
|||||||
const retry = require('async-retry');
|
const retry = require('async-retry');
|
||||||
const { satisfies } = require('semver');
|
const { satisfies } = require('semver');
|
||||||
const stripAnsi = require('strip-ansi');
|
const stripAnsi = require('strip-ansi');
|
||||||
const { getDistTag } = require('../../src/util/get-dist-tag');
|
|
||||||
const { version: cliVersion } = require('../../package.json');
|
|
||||||
const {
|
const {
|
||||||
fetchCachedToken,
|
fetchCachedToken,
|
||||||
} = require('../../../../test/lib/deployment/now-deploy');
|
} = require('../../../../test/lib/deployment/now-deploy');
|
||||||
@@ -16,7 +14,6 @@ jest.setTimeout(10 * 60 * 1000);
|
|||||||
|
|
||||||
const isCI = !!process.env.CI;
|
const isCI = !!process.env.CI;
|
||||||
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||||
const isCanary = () => getDistTag(cliVersion) === 'canary';
|
|
||||||
|
|
||||||
let port = 3000;
|
let port = 3000;
|
||||||
|
|
||||||
@@ -607,7 +604,6 @@ afterEach(async () => {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
sleep,
|
sleep,
|
||||||
isCanary,
|
|
||||||
testPath,
|
testPath,
|
||||||
testFixture,
|
testFixture,
|
||||||
testFixtureStdio,
|
testFixtureStdio,
|
||||||
|
|||||||
11
packages/cli/test/integration-3.test.ts
vendored
11
packages/cli/test/integration-3.test.ts
vendored
@@ -32,7 +32,6 @@ const binaryPath = path.resolve(__dirname, `../scripts/start.js`);
|
|||||||
const deployHelpMessage = `${logo} vercel [options] <command | path>`;
|
const deployHelpMessage = `${logo} vercel [options] <command | path>`;
|
||||||
let session = 'temp-session';
|
let session = 'temp-session';
|
||||||
let secretName: string | undefined;
|
let secretName: string | undefined;
|
||||||
const isCanary = pkg.version.includes('canary');
|
|
||||||
|
|
||||||
const createFile = (dest: fs.PathLike) => fs.closeSync(fs.openSync(dest, 'w'));
|
const createFile = (dest: fs.PathLike) => fs.closeSync(fs.openSync(dest, 'w'));
|
||||||
|
|
||||||
@@ -1219,8 +1218,6 @@ test('create zero-config deployment', async () => {
|
|||||||
'--yes',
|
'--yes',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
console.log('isCanary', isCanary);
|
|
||||||
|
|
||||||
expect(output.exitCode, formatOutput(output)).toBe(0);
|
expect(output.exitCode, formatOutput(output)).toBe(0);
|
||||||
|
|
||||||
const { host } = new URL(output.stdout);
|
const { host } = new URL(output.stdout);
|
||||||
@@ -1233,13 +1230,11 @@ test('create zero-config deployment', async () => {
|
|||||||
|
|
||||||
expect(data.error).toBe(undefined);
|
expect(data.error).toBe(undefined);
|
||||||
|
|
||||||
const validBuilders = data.builds.every(build =>
|
const validBuilders = data.builds.every(
|
||||||
isCanary ? build.use.endsWith('@canary') : !build.use.endsWith('@canary')
|
build => !build.use.endsWith('@canary')
|
||||||
);
|
);
|
||||||
|
|
||||||
const buildList = JSON.stringify(data.builds.map(b => b.use));
|
expect(validBuilders).toBe(true);
|
||||||
const message = `builders match canary (${isCanary}): ${buildList}`;
|
|
||||||
expect(validBuilders, message).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('next unsupported functions config shows warning link', async () => {
|
test('next unsupported functions config shows warning link', async () => {
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import { isCanary } from '../../../src/util/is-canary';
|
|
||||||
import getUpdateCommand from '../../../src/util/get-update-command';
|
import getUpdateCommand from '../../../src/util/get-update-command';
|
||||||
|
|
||||||
describe('getUpdateCommand', () => {
|
describe('getUpdateCommand', () => {
|
||||||
it('should detect update command', async () => {
|
it('should detect update command', async () => {
|
||||||
const updateCommand = await getUpdateCommand();
|
const updateCommand = await getUpdateCommand();
|
||||||
expect(updateCommand).toEqual(
|
expect(updateCommand).toEqual(`npm i vercel@latest`);
|
||||||
`npm i vercel@${isCanary() ? 'canary' : 'latest'}`
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user