Skip to content

Commit

Permalink
[internals] Create @vercel-internals/types (vercel#9608)
Browse files Browse the repository at this point in the history
Moves the type file out of the cli package and into its own standalone
package. utilizes `@vercel/style-guide` too for typescript config,
eslint, and prettier.
  • Loading branch information
Ethan Arrowood authored Mar 7, 2023
1 parent 38244c8 commit af239b5
Show file tree
Hide file tree
Showing 111 changed files with 1,450 additions and 301 deletions.
1 change: 1 addition & 0 deletions packages/cli/src/types.ts → internals/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export interface Secret {
createdAt: number;
}

// TODO (Ethan-Arrowood) - Replace enums
export enum ProjectEnvTarget {
Production = 'production',
Preview = 'preview',
Expand Down
17 changes: 17 additions & 0 deletions internals/types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"private": true,
"name": "@vercel-internals/types",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"scripts": {
"build": "tsc -p tsconfig.json"
},
"dependencies": {
"@vercel/build-utils": "6.3.2",
"@vercel/routing-utils": "2.1.10"
},
"devDependencies": {
"@vercel/style-guide": "4.0.2",
"typescript": "4.9.4"
}
}
8 changes: 8 additions & 0 deletions internals/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@vercel/style-guide/typescript",
"compilerOptions": {
"outDir": "dist",
"declaration": true
},
"include": ["index.ts"]
}
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"@types/which": "1.3.2",
"@types/write-json-file": "2.2.1",
"@types/yauzl-promise": "2.1.0",
"@vercel-internals/types": "*",
"@vercel/client": "12.4.2",
"@vercel/error-utils": "1.0.8",
"@vercel/frameworks": "1.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/alias/ls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import stamp from '../../util/output/stamp';
import strlen from '../../util/strlen';
import getCommandFlags from '../../util/get-command-flags';
import { getCommandName } from '../../util/pkg-name';
import { Alias } from '../../types';
import { Alias } from '@vercel-internals/types';

export default async function ls(
client: Client,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/alias/rm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import strlen from '../../util/strlen';
import confirm from '../../util/input/confirm';
import findAliasByAliasOrId from '../../util/alias/find-alias-by-alias-or-id';

import { Alias } from '../../types';
import { Alias } from '@vercel-internals/types';
import { isValidName } from '../../util/is-valid-name';
import { getCommandName } from '../../util/pkg-name';

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/alias/set.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import { SetDifference } from 'utility-types';
import { AliasRecord } from '../../util/alias/create-alias';
import { Domain } from '../../types';
import { Domain } from '@vercel-internals/types';
import { Output } from '../../util/output';
import * as ERRORS from '../../util/errors-ts';
import assignAlias from '../../util/alias/assign-alias';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/bisect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import logo from '../../util/output/logo';
import getArgs from '../../util/get-args';
import Client from '../../util/client';
import { getPkgName } from '../../util/pkg-name';
import { Deployment, PaginationOptions } from '../../types';
import { Deployment, PaginationOptions } from '@vercel-internals/types';
import { normalizeURL } from '../../util/bisect/normalize-url';
import getScope from '../../util/get-scope';
import getDeployment from '../../util/get-deployment';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/certs/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import stamp from '../../util/output/stamp';
import createCertFromFile from '../../util/certs/create-cert-from-file';
import createCertForCns from '../../util/certs/create-cert-for-cns';
import { getCommandName } from '../../util/pkg-name';
import { Cert } from '../../types';
import { Cert } from '@vercel-internals/types';

interface Options {
'--overwrite'?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/certs/ls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import stamp from '../../util/output/stamp';
import getCerts from '../../util/certs/get-certs';
import strlen from '../../util/strlen';
import { Cert } from '../../types';
import { Cert } from '@vercel-internals/types';
import getCommandFlags from '../../util/get-command-flags';
import { getCommandName } from '../../util/pkg-name';

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/certs/rm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk';
import ms from 'ms';
import plural from 'pluralize';
import table from 'text-table';
import { Cert } from '../../types';
import { Cert } from '@vercel-internals/types';
import * as ERRORS from '../../util/errors-ts';
import { Output } from '../../util/output';
import deleteCertById from '../../util/certs/delete-cert-by-id';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DevServer from '../../util/dev/server';
import { parseListen } from '../../util/dev/parse-listen';
import Client from '../../util/client';
import { getLinkedProject } from '../../util/projects/link';
import { ProjectSettings } from '../../types';
import { ProjectSettings } from '@vercel-internals/types';
import setupAndLink from '../../util/link/setup-and-link';
import { getCommandName } from '../../util/pkg-name';
import param from '../../util/output/param';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/dns/ls.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import ms from 'ms';
import { DomainNotFound } from '../../util/errors-ts';
import { DNSRecord } from '../../types';
import { DNSRecord } from '@vercel-internals/types';
import Client from '../../util/client';
import formatTable from '../../util/format-table';
import getDNSRecords, {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/dns/rm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import ms from 'ms';
import table from 'text-table';
import { DNSRecord } from '../../types';
import { DNSRecord } from '@vercel-internals/types';
import { Output } from '../../util/output';
import Client from '../../util/client';
import deleteDNSRecordById from '../../util/dns/delete-dns-record-by-id';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/domains/ls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import getScope from '../../util/get-scope';
import stamp from '../../util/output/stamp';
import formatTable from '../../util/format-table';
import { formatDateWithoutTime } from '../../util/format-date';
import { Domain } from '../../types';
import { Domain } from '@vercel-internals/types';
import getCommandFlags from '../../util/get-command-flags';
import {
PaginationOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/domains/move.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import plural from 'pluralize';

import { User, Team } from '../../types';
import { User, Team } from '@vercel-internals/types';
import * as ERRORS from '../../util/errors-ts';
import Client from '../../util/client';
import getScope from '../../util/get-scope';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/domains/rm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk';
import plural from 'pluralize';

import { DomainNotFound, DomainPermissionDenied } from '../../util/errors-ts';
import { Domain } from '../../types';
import { Domain } from '@vercel-internals/types';
import { Output } from '../../util/output';
import Client from '../../util/client';
import deleteCertById from '../../util/certs/delete-cert-by-id';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/env/add.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from 'chalk';
import { ProjectEnvTarget, Project, ProjectEnvType } from '../../types';
import { ProjectEnvTarget, Project, ProjectEnvType } from '@vercel-internals/types';
import { Output } from '../../util/output';
import Client from '../../util/client';
import stamp from '../../util/output/stamp';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/env/ls.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import ms from 'ms';
import { Output } from '../../util/output';
import { Project, ProjectEnvVariable, ProjectEnvType } from '../../types';
import { Project, ProjectEnvVariable, ProjectEnvType } from '@vercel-internals/types';
import Client from '../../util/client';
import formatTable from '../../util/format-table';
import getEnvRecords from '../../util/env/get-env-records';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/env/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk';
import { outputFile } from 'fs-extra';
import { closeSync, openSync, readSync } from 'fs';
import { resolve } from 'path';
import { Project, ProjectEnvTarget } from '../../types';
import { Project, ProjectEnvTarget } from '@vercel-internals/types';
import Client from '../../util/client';
import { emoji, prependEmoji } from '../../util/emoji';
import confirm from '../../util/input/confirm';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/env/rm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from 'chalk';
import { Project } from '../../types';
import { Project } from '@vercel-internals/types';
import { Output } from '../../util/output';
import confirm from '../../util/input/confirm';
import removeEnvRecord from '../../util/env/remove-env-record';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/git/connect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Dictionary } from '@vercel/client';
import chalk from 'chalk';
import { join } from 'path';
import { Org, Project, ProjectLinkData } from '../../types';
import { Org, Project, ProjectLinkData } from '@vercel-internals/types';
import Client from '../../util/client';
import { parseGitConfig, pluckRemoteUrls } from '../../util/create-git-meta';
import confirm from '../../util/input/confirm';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/git/disconnect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from 'chalk';
import { Org, Project } from '../../types';
import { Org, Project } from '@vercel-internals/types';
import Client from '../../util/client';
import confirm from '../../util/input/confirm';
import { getCommandName } from '../../util/pkg-name';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import getScope from '../util/get-scope';
import { getPkgName, getCommandName } from '../util/pkg-name';
import Client from '../util/client';
import getDeployment from '../util/get-deployment';
import { Build, Deployment } from '../types';
import { Build, Deployment } from '@vercel-internals/types';
import title from 'title';
import { isErrnoException } from '@vercel/error-utils';
import { URL } from 'url';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/project/list.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import ms from 'ms';
import table from 'text-table';
import { Project } from '../../types';
import { Project } from '@vercel-internals/types';
import Client from '../../util/client';
import getCommandFlags from '../../util/get-command-flags';
import { getCommandName } from '../../util/pkg-name';
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/pull.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import { join } from 'path';
import Client from '../util/client';
import { ProjectEnvTarget } from '../types';
import type { Project, ProjectEnvTarget } from '@vercel-internals/types';
import { emoji, prependEmoji } from '../util/emoji';
import getArgs from '../util/get-args';
import logo from '../util/output/logo';
Expand All @@ -10,7 +10,6 @@ import { getPkgName } from '../util/pkg-name';
import { VERCEL_DIR, VERCEL_DIR_PROJECT } from '../util/projects/link';
import { writeProjectSettings } from '../util/projects/project-settings';
import envPull from './env/pull';
import type { Project } from '../types';
import {
isValidEnvTarget,
getEnvTargetPlaceholder,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import getArgs from '../util/get-args';
import handleError from '../util/handle-error';
import type Client from '../util/client';
import { Output } from '../util/output';
import { Alias, Deployment, Project } from '../types';
import { Alias, Deployment, Project } from '@vercel-internals/types';
import { NowError } from '../util/now-error';

type DeploymentWithAliases = Deployment & {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/teams/switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { emoji } from '../../util/emoji';
import getUser from '../../util/get-user';
import getTeams from '../../util/teams/get-teams';
import listInput from '../../util/input/list';
import { Team, GlobalConfig } from '../../types';
import { Team, GlobalConfig } from '@vercel-internals/types';
import { writeToConfigFile } from '../../util/config/files';

const updateCurrentTeam = (config: GlobalConfig, team?: Team) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import getUpdateCommand from './util/get-update-command';
import { metrics, shouldCollectMetrics } from './util/metrics';
import { getCommandName, getTitleName } from './util/pkg-name';
import doLoginPrompt from './util/login/prompt';
import { AuthConfig, GlobalConfig } from './types';
import { AuthConfig, GlobalConfig } from '@vercel-internals/types';
import { VercelConfig } from '@vercel/client';
import box from './util/output/box';

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/alias/assign-alias.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Deployment } from '../../types';
import type { Deployment } from '@vercel-internals/types';
import { Output } from '../output';
import Client from '../client';
import createAlias from './create-alias';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/alias/create-alias.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Deployment } from '../../types';
import type { Deployment } from '@vercel-internals/types';
import { Output } from '../output';
import * as ERRORS from '../errors-ts';
import Client from '../client';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/alias/find-alias-by-alias-or-id.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Output } from '../output';
import { Alias } from '../../types';
import { Alias } from '@vercel-internals/types';

import Client from '../client';

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/alias/get-aliases.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Alias, PaginationOptions } from '../../types';
import { Alias, PaginationOptions } from '@vercel-internals/types';
import Client from '../client';

type Response = {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/alias/get-deployment-by-alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import chalk from 'chalk';
import Client from '../client';
import { Output } from '../output';
import { User } from '../../types';
import { User } from '@vercel-internals/types';
import { VercelConfig } from '../dev/types';
import getDeploymentsByAppName from '../deploy/get-deployments-by-appname';
import getDeployment from '../get-deployment';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/alias/get-domain-aliases.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Client from '../client';
import getAliases from './get-aliases';
import { Alias } from '../../types';
import { Alias } from '@vercel-internals/types';

export default async function getDomainAliases(client: Client, domain: string) {
const { aliases } = await getAliases(client);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/build-state.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Build } from '../types';
import { Build } from '@vercel-internals/types';

export const isReady = ({ readyState }: Pick<Build, 'readyState'>) =>
readyState === 'READY';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/certs/create-cert-from-file.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFileSync } from 'fs';
import { resolve } from 'path';
import Client from '../client';
import { Cert } from '../../types';
import { Cert } from '@vercel-internals/types';
import { isErrnoException } from '@vercel/error-utils';
import { isAPIError } from '../errors-ts';

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/certs/finish-cert-order.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chalk from 'chalk';

import { Cert } from '../../types';
import { Cert } from '@vercel-internals/types';
import * as ERRORS from '../errors-ts';
import Client from '../client';
import mapCertError from './map-cert-error';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/certs/get-cert-by-id.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cert } from '../../types';
import { Cert } from '@vercel-internals/types';
import Client from '../client';
import * as ERRORS from '../errors-ts';

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/certs/get-certs-for-cn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stringify } from 'querystring';
import { Cert } from '../../types';
import { Cert } from '@vercel-internals/types';
import Client from '../client';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/certs/get-certs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Client from '../client';
import { Cert, PaginationOptions } from '../../types';
import { Cert, PaginationOptions } from '@vercel-internals/types';

type Response = {
certs: Cert[];
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/certs/get-custom-certs-for-domain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stringify } from 'querystring';
import { Cert } from '../../types';
import { Cert } from '@vercel-internals/types';
import * as ERRORS from '../errors-ts';
import Client from '../client';

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/certs/issue-cert.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import retry from 'async-retry';
import { Cert } from '../../types';
import { Cert } from '@vercel-internals/types';
import Client from '../client';
import { isAPIError } from '../errors-ts';
import { isError } from '@vercel/error-utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
Stdio,
ReadableTTY,
WritableTTY,
} from '../types';
} from '@vercel-internals/types';
import { sharedPromise } from './promise';
import { APIError } from './errors-ts';
import { normalizeError } from '@vercel/error-utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/config/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NowError } from '../now-error';
import error from '../output/error';
import highlight from '../output/highlight';
import { VercelConfig } from '../dev/types';
import { AuthConfig, GlobalConfig } from '../../types';
import { AuthConfig, GlobalConfig } from '@vercel-internals/types';
import { isErrnoException, isError } from '@vercel/error-utils';

const VERCEL_DIR = getGlobalPathConfig();
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/config/get-default.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AuthConfig, GlobalConfig } from '../../types';
import { AuthConfig, GlobalConfig } from '@vercel-internals/types';

export const defaultGlobalConfig: GlobalConfig = {
'// Note':
Expand Down
Loading

0 comments on commit af239b5

Please sign in to comment.