//native
type Vercel = {
token: string;
};
/**
* Create a new deployment
* Create a new deployment with all the required and intended data. If the deployment is not a git deployment, all files must be provided with the request, either referenced or inlined. Additionally, a deployment id can be specified to redeploy a previous deployment.
*/
export async function main(
auth: Vercel,
forceNew: "0" | "1" | undefined,
skipAutoDetectionConfirmation: "0" | "1" | undefined,
teamId: string | undefined,
slug: string | undefined,
body: {
customEnvironmentSlugOrId?: string;
deploymentId?: string;
files?:
| { data: string; encoding?: "base64" | "utf-8"; file: string }
| { file: string; sha?: string; size?: number }[];
gitMetadata?: {
remoteUrl?: string;
commitAuthorName?: string;
commitMessage?: string;
commitRef?: string;
commitSha?: string;
dirty?: false | true;
};
gitSource?:
| { ref: string; repoId: string | number; sha?: string; type: "github" }
| { org: string; ref: string; repo: string; sha?: string; type: "github" }
| {
projectId: string | number;
ref: string;
sha?: string;
type: "gitlab";
}
| {
ref: string;
repoUuid: string;
sha?: string;
type: "bitbucket";
workspaceUuid?: string;
}
| {
owner: string;
ref: string;
sha?: string;
slug: string;
type: "bitbucket";
};
meta?: {};
monorepoManager?: string;
name: string;
project?: string;
projectSettings?: {
buildCommand?: string;
commandForIgnoringBuildStep?: string;
devCommand?: string;
framework?:
| "blitzjs"
| "nextjs"
| "gatsby"
| "remix"
| "react-router"
| "astro"
| "hexo"
| "eleventy"
| "docusaurus-2"
| "docusaurus"
| "preact"
| "solidstart-1"
| "solidstart"
| "dojo"
| "ember"
| "vue"
| "scully"
| "ionic-angular"
| "angular"
| "polymer"
| "svelte"
| "sveltekit"
| "sveltekit-1"
| "ionic-react"
| "create-react-app"
| "gridsome"
| "umijs"
| "sapper"
| "saber"
| "stencil"
| "nuxtjs"
| "redwoodjs"
| "hugo"
| "jekyll"
| "brunch"
| "middleman"
| "zola"
| "hydrogen"
| "vite"
| "vitepress"
| "vuepress"
| "parcel"
| "fasthtml"
| "sanity-v3"
| "sanity"
| "storybook";
installCommand?: string;
nodeVersion?:
| "22.x"
| "20.x"
| "18.x"
| "16.x"
| "14.x"
| "12.x"
| "10.x"
| "8.10.x";
outputDirectory?: string;
rootDirectory?: string;
serverlessFunctionRegion?: string;
skipGitConnectDuringLink?: false | true;
sourceFilesOutsideRootDirectory?: false | true;
};
target?: string;
withLatestCommit?: false | true;
},
) {
const url = new URL(`https://api.vercel.com/v13/deployments`);
for (const [k, v] of [
["forceNew", forceNew],
["skipAutoDetectionConfirmation", skipAutoDetectionConfirmation],
["teamId", teamId],
["slug", slug],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago