vercel 64.3.1 → 64.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/chunks/{add-UXOTAL3N.js → add-CG73LA5A.js} +1 -1
  2. package/dist/chunks/{add-RFCYPSPS.js → add-KBBLLPHW.js} +1 -1
  3. package/dist/chunks/{add-5RV75RPG.js → add-U5U56FJR.js} +1 -1
  4. package/dist/chunks/{build-SE3QLNVF.js → build-7EWHBKAN.js} +1 -1
  5. package/dist/chunks/{chunk-VVAZC5IO.js → chunk-2UPVIVAA.js} +1 -1
  6. package/dist/chunks/{chunk-MZLQY2EQ.js → chunk-3DP66SQ4.js} +1 -1
  7. package/dist/chunks/{chunk-AA434KXY.js → chunk-3GUO6F6P.js} +1 -1
  8. package/dist/chunks/{chunk-AQUDXMFH.js → chunk-3NNH2U5M.js} +1 -1
  9. package/dist/chunks/{chunk-FLBI6DY2.js → chunk-5AYB3JRL.js} +1 -1
  10. package/dist/chunks/{chunk-OUTCLR64.js → chunk-5NXYYFRL.js} +1 -1
  11. package/dist/chunks/{chunk-BLAIBYEU.js → chunk-5S2NK6K6.js} +1 -1
  12. package/dist/chunks/{chunk-6JGC4YDH.js → chunk-6CXHR2ND.js} +2 -2
  13. package/dist/chunks/{chunk-ZLWTPS5T.js → chunk-6QRT6USI.js} +1 -1
  14. package/dist/chunks/{chunk-ZVLDGT4O.js → chunk-6UCSM3CZ.js} +1 -1
  15. package/dist/chunks/{chunk-XW4ZWX3I.js → chunk-74QCXPNW.js} +1 -1
  16. package/dist/chunks/{chunk-CN3IVZJO.js → chunk-7NNENHGN.js} +1 -1
  17. package/dist/chunks/{chunk-G2IJOQR3.js → chunk-7QQIWMAT.js} +1 -1
  18. package/dist/chunks/{chunk-HTLGLTKD.js → chunk-ACVDKHVS.js} +1 -1
  19. package/dist/chunks/chunk-BFRDBBSO.js +7 -0
  20. package/dist/chunks/{chunk-YTEZO2SZ.js → chunk-BJXMXDBM.js} +1 -1
  21. package/dist/chunks/{chunk-E6R2QOOR.js → chunk-CITTRAYH.js} +1 -1
  22. package/dist/chunks/{chunk-YUYCSDCO.js → chunk-CMEEAXVV.js} +1 -1
  23. package/dist/chunks/{chunk-3E364MJE.js → chunk-D6REP5QQ.js} +1 -1
  24. package/dist/chunks/chunk-DDLM6CIQ.js +10 -0
  25. package/dist/chunks/{chunk-6ZRULOO3.js → chunk-DRXOTZSJ.js} +1 -1
  26. package/dist/chunks/{chunk-JV6IPUGX.js → chunk-DXLLC7ZM.js} +1 -1
  27. package/dist/chunks/{chunk-IIC2A4YN.js → chunk-GLH4PVMY.js} +1 -1
  28. package/dist/chunks/{chunk-JCTXRR4A.js → chunk-GVUB6QGX.js} +1 -1
  29. package/dist/chunks/{chunk-QAETJRKX.js → chunk-HARXQZV3.js} +1 -1
  30. package/dist/chunks/{chunk-GJP22N6R.js → chunk-JH257EDL.js} +1 -1
  31. package/dist/chunks/{chunk-U3NQZJQ4.js → chunk-JIGCN5QS.js} +3 -3
  32. package/dist/chunks/{chunk-OCOVCC5Q.js → chunk-JZ7FDBS4.js} +1 -1
  33. package/dist/chunks/{chunk-DNTQK2SW.js → chunk-LUJL3KFT.js} +1 -1
  34. package/dist/chunks/{chunk-26Z4U6G4.js → chunk-LYU4MVL5.js} +2 -2
  35. package/dist/chunks/{chunk-KKQL4AKH.js → chunk-MPZFMEVK.js} +1 -1
  36. package/dist/chunks/chunk-MYHJNSCW.js +15 -0
  37. package/dist/chunks/{chunk-IL7X6EKK.js → chunk-N2TNA2FE.js} +1 -1
  38. package/dist/chunks/{chunk-444RE4Z5.js → chunk-OHVPJNGY.js} +1 -1
  39. package/dist/chunks/{chunk-6GIP2YPX.js → chunk-OYMFOCD5.js} +1 -1
  40. package/dist/chunks/{chunk-QCWV7FML.js → chunk-P5BNAP5T.js} +1 -1
  41. package/dist/chunks/{chunk-TCYAAWLB.js → chunk-PAOR4MQZ.js} +1 -1
  42. package/dist/chunks/{chunk-WGOQGKS5.js → chunk-PTI3TP7P.js} +1 -1
  43. package/dist/chunks/{chunk-QC5AMRWR.js → chunk-QEXSF4NA.js} +1 -1
  44. package/dist/chunks/{chunk-KGXW36FQ.js → chunk-QOFK5PKB.js} +2 -2
  45. package/dist/chunks/{chunk-XJXX4QXA.js → chunk-SI7FQJIE.js} +1 -1
  46. package/dist/chunks/{chunk-GF7EG5IA.js → chunk-TCQZFIBR.js} +1 -1
  47. package/dist/chunks/{chunk-A63VVXW2.js → chunk-TE2EE7DR.js} +1 -1
  48. package/dist/chunks/{chunk-WKZ6JSGZ.js → chunk-TKBORMUF.js} +1 -1
  49. package/dist/chunks/{chunk-GLJH35MJ.js → chunk-TLEBLYBS.js} +1 -1
  50. package/dist/chunks/{chunk-MMPQC2N6.js → chunk-U73RXMGU.js} +1 -1
  51. package/dist/chunks/{chunk-BTCKMXWW.js → chunk-UQIVF4Q2.js} +1 -1
  52. package/dist/chunks/{chunk-6HOVHRWJ.js → chunk-V3RDOM3U.js} +3 -3
  53. package/dist/chunks/{chunk-GCSAJUL6.js → chunk-VEMJINMZ.js} +1 -1
  54. package/dist/chunks/{chunk-ELDHGU6N.js → chunk-VLDU2MDL.js} +1 -1
  55. package/dist/chunks/{chunk-QC3HEGFD.js → chunk-VRAMXFRB.js} +1 -1
  56. package/dist/chunks/{chunk-TDDZGUU6.js → chunk-VS7O22ED.js} +1 -1
  57. package/dist/chunks/{chunk-AALI66ML.js → chunk-WCBNKVVG.js} +1 -1
  58. package/dist/chunks/{chunk-GWZ4VPU3.js → chunk-WN7EJWN4.js} +2 -2
  59. package/dist/chunks/{chunk-MV4WHUIC.js → chunk-XEBMH33W.js} +1 -1
  60. package/dist/chunks/chunk-XOETL6DB.js +96 -0
  61. package/dist/chunks/chunk-XXCWQPAH.js +7 -0
  62. package/dist/chunks/{chunk-IYCHAIFZ.js → chunk-YQKURZ5W.js} +1 -1
  63. package/dist/chunks/{chunk-EXPLBM7J.js → chunk-ZDKSDWSO.js} +1 -1
  64. package/dist/chunks/{chunk-YS542RHZ.js → chunk-ZMY3GQBK.js} +1 -1
  65. package/dist/chunks/{clear-2VHJFFMM.js → clear-35NUHHDI.js} +1 -1
  66. package/dist/chunks/{compile-vercel-config-ADKZDUAU.js → compile-vercel-config-UQIYIVA6.js} +1 -1
  67. package/dist/chunks/{config-VAOXMKVX.js → config-FZD3R5VT.js} +1 -1
  68. package/dist/chunks/{config-6YWGF4CO.js → config-IQE5C7PZ.js} +1 -1
  69. package/dist/chunks/{constants-JAB7MRSK.js → constants-ICJL2EO5.js} +1 -1
  70. package/dist/chunks/{delete-FEUSV3JO.js → delete-6LSSOF4X.js} +1 -1
  71. package/dist/chunks/{delete-YW2NH7VG.js → delete-IBRCB3S3.js} +1 -1
  72. package/dist/chunks/{detect-projects-LFEZ7BQU.js → detect-projects-THLTMO7V.js} +1 -1
  73. package/dist/chunks/{detect-services-A2B6KJO5.js → detect-services-GFVD2C3W.js} +1 -1
  74. package/dist/chunks/{disable-KA6PS2CZ.js → disable-4TODXYTB.js} +1 -1
  75. package/dist/chunks/{discard-ZNUPAJTQ.js → discard-WHC5FKWF.js} +1 -1
  76. package/dist/chunks/edit-3DXOWQMF.js +8 -0
  77. package/dist/chunks/edit-R2RUDKC4.js +9 -0
  78. package/dist/chunks/{enable-Q4OCTJIJ.js → enable-2OAHPKCN.js} +1 -1
  79. package/dist/chunks/{export-UX6JVWOD.js → export-KTLACTAJ.js} +1 -1
  80. package/dist/chunks/{future-6UTK4EFE.js → future-JZ3RVO4B.js} +1 -1
  81. package/dist/chunks/{generate-cert-for-deploy-WDKFR34X.js → generate-cert-for-deploy-D4IHTKQS.js} +1 -1
  82. package/dist/chunks/{image-IL7IN7MD.js → image-UW5U6CRJ.js} +1 -1
  83. package/dist/chunks/{import-builders-FX2XXVRT.js → import-builders-JONKAYLL.js} +1 -1
  84. package/dist/chunks/{inspect-E2HPGMNI.js → inspect-2FS4PYBH.js} +1 -1
  85. package/dist/chunks/{inspect-F6NLCWHN.js → inspect-7IZ7M2TX.js} +1 -1
  86. package/dist/chunks/{inspect-UPXTGUJQ.js → inspect-JDSFHP6X.js} +1 -1
  87. package/dist/chunks/{inspect-UNZR445S.js → inspect-PQNECP2Z.js} +1 -1
  88. package/dist/chunks/{inspect-YAMAGNIW.js → inspect-PWLUWUGV.js} +1 -1
  89. package/dist/chunks/{list-G4E6RG3V.js → list-2G2BWD4T.js} +1 -1
  90. package/dist/chunks/{list-GDI5O246.js → list-3N2CBVOG.js} +1 -1
  91. package/dist/chunks/{list-FDYB6GHF.js → list-Y3OA4KFK.js} +1 -1
  92. package/dist/chunks/{login-XYYNIAMM.js → login-LLM3Q6GJ.js} +1 -1
  93. package/dist/chunks/{login-HU5OFS7T.js → login-VQN3F7JU.js} +1 -1
  94. package/dist/chunks/{logs-EWXTZN4W.js → logs-XEJPLFXM.js} +1 -1
  95. package/dist/chunks/{ls-MO3R46TQ.js → ls-2DACOWSU.js} +1 -1
  96. package/dist/chunks/{ls-SZKDUJHV.js → ls-2M7QSW2F.js} +1 -1
  97. package/dist/chunks/{ls-CGZ3NL5R.js → ls-5YLXAARZ.js} +1 -1
  98. package/dist/chunks/{ls-A3HIPTF5.js → ls-7DJWHOK4.js} +1 -1
  99. package/dist/chunks/{ls-TCB7UUPP.js → ls-GY2YLYMD.js} +1 -1
  100. package/dist/chunks/{ls-A4NEYMKP.js → ls-NJEJSYSO.js} +1 -1
  101. package/dist/chunks/{ls-3GNX6IPE.js → ls-OAJKYQEL.js} +1 -1
  102. package/dist/chunks/{mutate-BQAP2S7A.js → mutate-G2I4ISF4.js} +1 -1
  103. package/dist/chunks/notifications-6MXYY2V6.js +7 -0
  104. package/dist/chunks/{open-YPOEUM3S.js → open-YKOYB7PH.js} +1 -1
  105. package/dist/chunks/{openapi-BQSQNXQE.js → openapi-36GMGEXR.js} +1 -1
  106. package/dist/chunks/{permissions-6LOJKL5W.js → permissions-RRP6IEHS.js} +1 -1
  107. package/dist/chunks/{prompt-missing-credentials-IGTCFUA6.js → prompt-missing-credentials-WQUF6X6K.js} +1 -1
  108. package/dist/chunks/{publish-CATCXJZG.js → publish-AQ3FYC3J.js} +1 -1
  109. package/dist/chunks/{pull-CXUNHWAO.js → pull-HT2MQ3ML.js} +1 -1
  110. package/dist/chunks/{purchase-domain-if-available-4YKWAHH5.js → purchase-domain-if-available-NDEUZYHK.js} +1 -1
  111. package/dist/chunks/{push-KZZE3AQ3.js → push-6LE54BCC.js} +1 -1
  112. package/dist/chunks/{query-GHFOZV7K.js → query-SNY42BTX.js} +1 -1
  113. package/dist/chunks/{reauthenticate-W7QIXLZ3.js → reauthenticate-4SGT475I.js} +1 -1
  114. package/dist/chunks/{reorder-XU55LOZ5.js → reorder-SRF3NE5U.js} +1 -1
  115. package/dist/chunks/{reply-B2XOCSZD.js → reply-6HUIX4AX.js} +1 -1
  116. package/dist/chunks/{resolve-H4BZ2QI3.js → resolve-TNBNGA3G.js} +1 -1
  117. package/dist/chunks/{resolve-agent-team-43HZCPF3.js → resolve-agent-team-XSXRT42F.js} +1 -1
  118. package/dist/chunks/{restore-AJLS2N6C.js → restore-HK4SWMZP.js} +1 -1
  119. package/dist/chunks/{rm-2TR2KBDP.js → rm-4VXZ3AIX.js} +1 -1
  120. package/dist/chunks/{rm-ZQUVOC3V.js → rm-ESSU4MS4.js} +1 -1
  121. package/dist/chunks/{rm-OI5VS7GG.js → rm-EWPYZXTX.js} +1 -1
  122. package/dist/chunks/{rm-N6ZUA66Z.js → rm-GNDGYUKQ.js} +1 -1
  123. package/dist/chunks/{rm-IGY6LD6H.js → rm-SKCAZTYN.js} +1 -1
  124. package/dist/chunks/{routes-TCMUHSJF.js → routes-LK2HUGAK.js} +1 -1
  125. package/dist/chunks/{rule-inspect-NLEABBTP.js → rule-inspect-RHHD5UIR.js} +1 -1
  126. package/dist/chunks/{rules-SVLVB6YB.js → rules-FF5FU7BV.js} +1 -1
  127. package/dist/chunks/{schema-KG4RWQBC.js → schema-HIKNWMV2.js} +1 -1
  128. package/dist/chunks/{schema-HWS2SOZS.js → schema-QHZO72DB.js} +1 -1
  129. package/dist/chunks/{select-org-AAB5RBSB.js → select-org-CK5CWC3A.js} +1 -1
  130. package/dist/chunks/{set-AJEMEBZU.js → set-5P44OPZP.js} +1 -1
  131. package/dist/chunks/{setup-and-link-6AIRWXXX.js → setup-and-link-OLSKD2HE.js} +1 -1
  132. package/dist/chunks/{tags-O6R6VWPP.js → tags-35DFWGDC.js} +1 -1
  133. package/dist/chunks/{types-Y3NJROKH.js → types-77UW6BI4.js} +1 -1
  134. package/dist/chunks/{update-C7XR7CHI.js → update-WHBFIV22.js} +1 -1
  135. package/dist/commands/build/index.js +1 -1
  136. package/dist/commands/deploy/index.js +13 -13
  137. package/dist/commands/dev/index.js +14 -101
  138. package/dist/commands/env/index.js +1 -1
  139. package/dist/commands/link/index.js +1 -1
  140. package/dist/commands/list/index.js +1 -1
  141. package/dist/commands-bulk.js +35 -33
  142. package/dist/index.js +2 -2
  143. package/dist/internal-build.js +1 -1
  144. package/dist/root-help-commands.mjs +1 -1
  145. package/dist/version.mjs +1 -1
  146. package/package.json +57 -55
  147. package/dist/chunks/chunk-2FHICLHJ.js +0 -7
  148. package/dist/chunks/chunk-BAT6SDBJ.js +0 -10
  149. package/dist/chunks/chunk-H7CRPXOA.js +0 -14
  150. package/dist/chunks/chunk-ZE53XHAY.js +0 -7
  151. package/dist/chunks/edit-D7VE55ZF.js +0 -9
  152. package/dist/chunks/edit-YTYYBVZN.js +0 -8
  153. package/dist/chunks/notifications-TDSFYYNB.js +0 -7
@@ -16,14 +16,14 @@ import{require_lib}from"./chunk-ROPQIBWJ.js";import{require_graceful_fs}from"./c
16
16
  ${(0,import_error_utils.errorToString)(error)}`);return}let gitConfigPath=join2(gitRoot||directory,".git/config"),remoteUrl;if(project?.link){let{repo}=project.link,remoteUrls=await getRemoteUrls(gitConfigPath);if(remoteUrls)for(let urlValue of Object.values(remoteUrls))urlValue.includes(repo)&&(remoteUrl=urlValue)}remoteUrl||(remoteUrl=await getOriginUrl(gitConfigPath));let[commitResult,dirtyResult]=await metadata;if(commitResult.status==="rejected"){output_manager_default.debug(`Failed to get last commit. The directory is likely not a Git repo, there are no latest commits, or it is corrupted.
17
17
  ${commitResult.reason}`);return}if(dirtyResult.status==="rejected"){output_manager_default.debug(`Failed to determine if Git repo has been modified:
18
18
  ${dirtyResult.reason}`);return}let dirty=dirtyResult.value,commit=commitResult.value;return{remoteUrl:remoteUrl||void 0,commitAuthorName:commit.author.name,commitAuthorEmail:commit.author.email,commitMessage:commit.subject,commitRef:branch,commitSha:commit.hash,dirty,rootDirectory:getRootDirectory(directory,gitRoot)}}function getRootDirectory(directory,gitRoot=getGitRootDirectory({cwd:directory})){if(!gitRoot)return;let rootDirectory=relative(gitRoot,resolve3(directory)).replace(/\\/g,"/");if(!(rootDirectory===".."||rootDirectory.startsWith("../")))return rootDirectory==="."?"":rootDirectory}async function getLastCommit(directory,git){let commit=await execFileAsync(git,["log","-1","--format=%H%x00%s%x00%an%x00%ae"],{cwd:directory});if(commit.stderr)throw new Error(commit.stderr);let[hash,subject,name,email]=commit.stdout.replace(/\r?\n$/,"").split("\0");return{hash,subject,author:{name,email}}}async function isDirty(directory){let git=await getGitExecutable(directory);return new Promise((resolve4,reject)=>{execFile2(git,["--no-optional-locks","status","-s"],{cwd:directory},function(err,stdout,stderr){if(err)return reject(err);if(stderr!==void 0&&stderr.trim().length>0)return reject(new Error(stderr));resolve4(stdout.trim().length>0)})})}async function parseGitConfig(configPath){try{return import_ini.default.parse(await import_fs_extra.default.readFile(configPath,"utf-8"))}catch(err){output_manager_default.debug(`Error while parsing repo data: ${(0,import_error_utils.errorToString)(err)}`)}}function pluckRemoteUrls(gitConfig){let remoteUrls={};for(let key of Object.keys(gitConfig))if(key.includes("remote")){let remoteName=key.match(/(?<=").*(?=")/g)?.[0],remoteUrl=gitConfig[key]?.url;remoteName&&remoteUrl&&(remoteUrls[remoteName]=remoteUrl)}if(Object.keys(remoteUrls).length!==0)return remoteUrls}async function getRemoteUrls(configPath){let config=await parseGitConfig(configPath);return config?pluckRemoteUrls(config):void 0}function pluckOriginUrl(gitConfig){return gitConfig['remote "origin"']?.url}async function getOriginUrl(configPath){let gitConfig=await parseGitConfig(configPath);if(!gitConfig)return null;let originUrl=pluckOriginUrl(gitConfig);return originUrl||null}var import_fs_extra5=__toESM(require_lib2(),1);import os from"os";import{join as join6}from"path";var import_fs_extra4=__toESM(require_lib2(),1);import fs3 from"fs";import{join as join5,relative as relative2}from"path";import{promisify}from"util";async function getOrgById(client,orgId){if(orgId.startsWith("team_"))try{let team=await getTeamByIdOrSlug(client,orgId,{useCurrentTeam:!1});return team?{type:"team",id:team.id,slug:team.slug}:null}catch(err){if(isAPIError(err)&&(err.status===404||err.code==="not_found"||err.code==="mock_unimplemented"))return null;throw err}let user=await getUser(client);return user.id!==orgId?null:{type:"user",id:orgId,slug:user.username}}var import_build_utils2=__toESM(require_build_utils(),1);var import_error_utils2=__toESM(require_dist(),1);var import_chalk=__toESM(require_source(),1),import_pluralize=__toESM(require_pluralize(),1),import_build_utils=__toESM(require_build_utils(),1),import_fs_extra2=__toESM(require_lib2(),1);import{homedir}from"os";import{basename,join as join3}from"path";var home=homedir();async function getRepoLink(client,cwd){let rootPath=await findRepoRoot(cwd);if(!rootPath)return;let repoConfigPath=join3(rootPath,VERCEL_DIR,VERCEL_DIR_REPO),repoConfig=await(0,import_fs_extra2.readJSON)(repoConfigPath).catch(err=>{if(err.code!=="ENOENT")throw err});return{rootPath,repoConfig,repoConfigPath}}async function resolveGitRemote(client,rootPath,{yes,existingRemoteName}){let gitConfigPath=getGitConfigPath({cwd:rootPath})??join3(rootPath,".git/config"),remoteUrls=await getRemoteUrls(gitConfigPath);if(!remoteUrls)return;let remoteName;if(existingRemoteName){if(remoteName=existingRemoteName,!remoteUrls[remoteName])throw new Error(`Git remote "${remoteName}" from repo.json no longer exists`)}else remoteName=await selectGitRemote(client,Object.keys(remoteUrls),yes);return{rootPath,remoteName,repoUrl:remoteUrls[remoteName]}}async function selectGitRemote(client,names,yes=!1){let remoteNames=[...names].sort(),defaultRemote=remoteNames.includes("origin")?"origin":remoteNames[0];return remoteNames.length===1||yes?defaultRemote:client.input.select({message:"Which Git remote should be used?",choices:remoteNames.map(name=>({name,value:name})),default:defaultRemote})}async function fetchProjectsForRepoUrl(client,repoUrl,orgId){let query=new URLSearchParams({repoUrl}),projectsIterator=client.fetchPaginated(`/v9/projects?${query}`,{accountId:orgId}),projects=[];for await(let chunk of projectsIterator)projects=projects.concat(chunk.projects);return projects}async function linkRepoProject(client,cwd,{project,orgId,orgSlug,remoteName,successEmoji="link"}){let repoLink=await getRepoLink(client,cwd);if(!repoLink)throw new Error("Could not determine Git repository root directory");let directory=(0,import_build_utils.normalizePath)(project.rootDirectory||"."),projectConfig={id:project.id,name:project.name,directory,orgId},filteredProjects=(repoLink.repoConfig?.projects??[]).filter(p=>p.id!==project.id&&(0,import_build_utils.normalizePath)(p.directory)!==directory),repoConfig={remoteName,projects:[...filteredProjects,projectConfig]};return await(0,import_fs_extra2.outputJSON)(repoLink.repoConfigPath,repoConfig,{spaces:2}),await writeReadme(repoLink.rootPath),await addToGitIgnore(repoLink.rootPath),output_manager_default.print(`
19
- `),printAlignedLabel("Linked",`${orgSlug}/${project.name}`,{gutter:"\u2713"}),{repoConfig,repoConfigPath:repoLink.repoConfigPath,rootPath:repoLink.rootPath}}async function discoverRepoProjects(client,rootPath,{yes,existingProjectIds,existingDirectories,existingRemoteName}){let{Separator}=await import("./esm-BYG5BWYH.js"),{default:slugify}=await import("./slugify-NMMUASYK.js"),{default:selectOrg}=await import("./select-org-AAB5RBSB.js"),{default:createProject}=await import("./create-project-IKCB6MB2.js"),{repoInfoToUrl}=await import("./repo-info-to-url-XQSULSEO.js"),{connectGitProvider,parseRepoUrl}=await import("./connect-git-provider-2JIBL3ST.js"),detectedProjectsPromise=import("./detect-projects-LFEZ7BQU.js").then(({detectProjects})=>detectProjects(rootPath)).catch(err=>(output_manager_default.debug(`Failed to detect local projects: ${err}`),new Map)),confirmMessage=(existingRemoteName?"add":"link")==="add"?`Add Project(s) for Git repository at ${import_chalk.default.dim(`"${humanizePath(rootPath)}"`)}?`:`Link Git repository at ${import_chalk.default.dim(`"${humanizePath(rootPath)}"`)} to your Project(s)?`;if(!(yes||await client.input.confirm(confirmMessage,!0))){output_manager_default.print(` Canceled. Repository not linked.
19
+ `),printAlignedLabel("Linked",`${orgSlug}/${project.name}`,{gutter:"\u2713"}),{repoConfig,repoConfigPath:repoLink.repoConfigPath,rootPath:repoLink.rootPath}}async function discoverRepoProjects(client,rootPath,{yes,existingProjectIds,existingDirectories,existingRemoteName}){let{Separator}=await import("./esm-BYG5BWYH.js"),{default:slugify}=await import("./slugify-NMMUASYK.js"),{default:selectOrg}=await import("./select-org-CK5CWC3A.js"),{default:createProject}=await import("./create-project-IKCB6MB2.js"),{repoInfoToUrl}=await import("./repo-info-to-url-XQSULSEO.js"),{connectGitProvider,parseRepoUrl}=await import("./connect-git-provider-2JIBL3ST.js"),detectedProjectsPromise=import("./detect-projects-THLTMO7V.js").then(({detectProjects})=>detectProjects(rootPath)).catch(err=>(output_manager_default.debug(`Failed to detect local projects: ${err}`),new Map)),confirmMessage=(existingRemoteName?"add":"link")==="add"?`Add Project(s) for Git repository at ${import_chalk.default.dim(`"${humanizePath(rootPath)}"`)}?`:`Link Git repository at ${import_chalk.default.dim(`"${humanizePath(rootPath)}"`)} to your Project(s)?`;if(!(yes||await client.input.confirm(confirmMessage,!0))){output_manager_default.print(` Canceled. Repository not linked.
20
20
  `);return}let org=await selectOrg(client,"Which team?",yes);client.config.currentTeam=org.type==="team"?org.id:void 0;let remote=await resolveGitRemote(client,rootPath,{yes,existingRemoteName});if(!remote)throw new Error("Could not determine Git remote URLs");let{remoteName,repoUrl}=remote,parsedRepoUrl=parseRepoUrl(repoUrl);if(!parsedRepoUrl)throw new Error(`Failed to parse Git URL: ${repoUrl}`);let repoUrlLink=output_manager_default.link(repoUrl,repoInfoToUrl(parsedRepoUrl),{fallback:()=>link_default(repoUrl)});output_manager_default.spinner(`Fetching Projects for ${repoUrlLink} under ${import_chalk.default.bold(org.slug)}\u2026`);let detectedProjects=await detectedProjectsPromise,projects=await fetchProjectsForRepoUrl(client,repoUrl,org.id);(existingProjectIds||existingDirectories)&&(projects=projects.filter(p=>!(existingProjectIds?.has(p.id)||existingDirectories?.has((0,import_build_utils.normalizePath)(p.rootDirectory||"."))))),projects.length===0?output_manager_default.print(` No Projects are linked to ${repoUrlLink} under ${import_chalk.default.bold(org.slug)}.
21
21
  `):output_manager_default.print(` Found ${(0,import_pluralize.default)("Project",projects.length,!0)} linked to ${repoUrlLink} under ${import_chalk.default.bold(org.slug)}
22
22
  `);for(let project of projects)detectedProjects.delete(project.rootDirectory??"");if(existingDirectories)for(let dir of existingDirectories)detectedProjects.delete(dir==="."?"":dir);let detectedProjectsCount=Array.from(detectedProjects.values()).reduce((o,f)=>o+f.length,0);detectedProjectsCount>0&&output_manager_default.print(` Detected ${(0,import_pluralize.default)("new Project",detectedProjectsCount,!0)} that may be created.
23
23
  `);let selected;if(yes)selected=projects;else{let addSeparators=projects.length>0&&detectedProjectsCount>0;selected=await client.input.checkbox({message:`Which Projects should be ${projects.length?"linked to":"created"}?`,choices:[...addSeparators?[new Separator("----- Existing Projects -----")]:[],...projects.map(project=>{let dir=project.rootDirectory||".";return{name:`${org.slug}/${project.name} ${import_chalk.default.gray(`(${dir})`)}`,value:project,checked:!0}}),...addSeparators?[new Separator("----- New Projects to be created -----")]:[],...Array.from(detectedProjects.entries()).flatMap(([rootDirectory,frameworks])=>frameworks.map((framework,i)=>{let name=slugify([basename(rootDirectory)||basename(rootPath),i>0?framework.slug:""].filter(Boolean).join("-"));return{name:`${org.slug}/${name} ${import_chalk.default.gray(`(${rootDirectory||"."} \xB7 ${framework.name})`)}`,value:{newProject:!0,rootDirectory,name,framework},checked:projects.length===0}}))]})}if(selected.length===0){output_manager_default.print(` No Projects were selected. Repository not linked.
24
24
  `);return}for(let i=0;i<selected.length;i++){let selection=selected[i];if(!("newProject"in selection&&selection.newProject))continue;let orgAndName=`${org.slug}/${selection.name}`;output_manager_default.spinner(`Creating new Project: ${orgAndName}`),delete selection.newProject,selection.rootDirectory||delete selection.rootDirectory;let project=selected[i]=await createProject(client,{...selection,framework:selection.framework.slug});await connectGitProvider(client,project.id,parsedRepoUrl.provider,`${parsedRepoUrl.org}/${parsedRepoUrl.repo}`),output_manager_default.print(` Created new Project: ${output_manager_default.link(orgAndName,`https://vercel.com/${orgAndName}`,{fallback:!1})}
25
25
  `)}let repoProjects=selected.map(project=>{if(!("id"in project))throw new TypeError(`Not a Project: ${JSON.stringify(project)}`);return{id:project.id,name:project.name,directory:(0,import_build_utils.normalizePath)(project.rootDirectory||"."),orgId:org.id}});return{remoteName,projects:repoProjects,orgSlug:org.slug}}async function ensureRepoLink(client,cwd,{yes,overwrite}){let repoLink=await getRepoLink(client,cwd);if(repoLink)output_manager_default.debug(`Found Git repository root directory: ${repoLink.rootPath}`);else throw new Error("Could not determine Git repository root directory");let{rootPath,repoConfig,repoConfigPath}=repoLink;if(overwrite||!repoConfig){let result=await discoverRepoProjects(client,rootPath,{yes});if(!result)return;repoConfig={remoteName:result.remoteName,projects:result.projects},await(0,import_fs_extra2.outputJSON)(repoConfigPath,repoConfig,{spaces:2}),await writeReadme(rootPath),await addToGitIgnore(rootPath),printAlignedLabel("Linked",`${(0,import_pluralize.default)("Project",result.projects.length,!0)} under ${result.orgSlug}`,{gutter:"\u2713"})}return{repoConfig,repoConfigPath,rootPath}}async function addRepoLink(client,cwd,{yes}){let repoLink=await getRepoLink(client,cwd);if(!repoLink)throw new Error("Could not determine Git repository root directory");let{rootPath,repoConfig,repoConfigPath}=repoLink;if(!repoConfig)throw new Error("No existing repository link found. Run `vc link --repo` first to link the repository.");output_manager_default.debug(`Found Git repository root directory: ${rootPath}`);let existingProjectIds=new Set(repoConfig.projects.map(p=>p.id)),existingDirectories=new Set(repoConfig.projects.map(p=>p.directory)),result=await discoverRepoProjects(client,rootPath,{yes,existingProjectIds,existingDirectories,existingRemoteName:repoConfig.remoteName});if(!result)return;if(result.projects.length===0)return output_manager_default.print(` No new Projects were added.
26
- `),{repoConfig,repoConfigPath,rootPath};let mergedProjects=[...repoConfig.projects];for(let project of result.projects)existingProjectIds.has(project.id)||mergedProjects.push(project);let updatedConfig={...repoConfig,projects:mergedProjects};return await(0,import_fs_extra2.outputJSON)(repoConfigPath,updatedConfig,{spaces:2}),printAlignedLabel("Added",`${(0,import_pluralize.default)("Project",result.projects.length,!0)} under ${result.orgSlug}`,{gutter:"\u2713"}),{repoConfig:updatedConfig,repoConfigPath,rootPath}}async function findRepoRoot(start){let{debug}=output_manager_default,REPO_JSON_PATH=join3(VERCEL_DIR,VERCEL_DIR_REPO);for(let current of(0,import_build_utils.traverseUpDirectories)({start})){if(current===home){debug("Arrived at home directory");break}let repoConfigPath=join3(current,REPO_JSON_PATH);if(await(0,import_fs_extra2.lstat)(repoConfigPath).catch(err=>{if(err.code!=="ENOENT")throw err}))return debug(`Found "${REPO_JSON_PATH}" - detected "${current}" as repo root`),current}let gitRoot=getGitRootDirectory({cwd:start});if(gitRoot)return debug(`Found git root via "git rev-parse --show-toplevel" - detected "${gitRoot}" as repo root`),gitRoot;for(let current of(0,import_build_utils.traverseUpDirectories)({start})){if(current===home){debug("Arrived at home directory");break}let gitPath=join3(current,".git");if(await(0,import_fs_extra2.lstat)(gitPath).catch(err=>{if(err.code!=="ENOENT")throw err}))return debug(`Found ".git" - detected "${current}" as repo root`),current}debug("Aborting search for repo root")}function sortByDirectory(a,b){let aParts=a.directory.split("/");return b.directory.split("/").length-aParts.length}function findProjectsFromPath(projects,path){let normalizedPath=(0,import_build_utils.normalizePath)(path),matches=projects.slice().sort(sortByDirectory).filter(project=>project.directory==="."?!0:normalizedPath===project.directory||normalizedPath.startsWith(`${project.directory}/`)),firstMatch=matches[0];return firstMatch?matches.filter(match=>match.directory===firstMatch.directory):[]}var import_chalk2=__toESM(require_source(),1),import_fs_extra3=__toESM(require_lib2(),1);import{stat}from"fs/promises";import{join as join4,dirname}from"path";async function findProjectRoot(startDir){let cwdDev;try{cwdDev=(await stat(startDir)).dev}catch{return null}let dir=dirname(startDir);for(;dirname(dir)!==dir;){try{if((await stat(dir)).dev!==cwdDev)return null}catch{return null}let hasVercelDir=await(0,import_fs_extra3.pathExists)(join4(dir,".vercel")),hasVercelJson=await(0,import_fs_extra3.pathExists)(join4(dir,"vercel.json")),hasVercelToml=await(0,import_fs_extra3.pathExists)(join4(dir,"vercel.toml")),hasGit=await(0,import_fs_extra3.pathExists)(join4(dir,".git"));if(hasVercelDir||hasVercelJson||hasVercelToml||hasGit)return dir;dir=dirname(dir)}return null}async function resolveProjectCwd(cwd){let projectRoot=await findProjectRoot(cwd);if(!projectRoot||projectRoot===cwd)return cwd;let{isExperimentalServicesEnabled,tryDetectServices}=await import("./detect-services-A2B6KJO5.js");if(!await isExperimentalServicesEnabled(projectRoot))return cwd;let result=await tryDetectServices(projectRoot);return result&&(result.services?.length??0)>0?(output_manager_default.debug(`Running from project root: ${import_chalk2.default.cyan(projectRoot)}`),projectRoot):cwd}var readFile=promisify(fs3.readFile),writeFile=promisify(fs3.writeFile),VERCEL_DIR=".vercel",VERCEL_DIR_FALLBACK=".now",VERCEL_DIR_README="README.txt",VERCEL_DIR_PROJECT="project.json",VERCEL_DIR_REPO="repo.json";function isOwnerLookupUnavailableLink(link){return"ownerLookupUnavailable"in link&&link.ownerLookupUnavailable===!0}function isRemoteLookupSkippedLink(link){return"remoteLookupSkipped"in link&&link.remoteLookupSkipped===!0}function isOwnerLookupUnavailableError(error){return isAPIError(error)&&error.status===403&&error.code==="team_unauthorized"}function isValidProjectLink(value){if(!value||typeof value!="object"||Array.isArray(value))return!1;let link=value;return typeof link.projectId=="string"&&link.projectId.length>0&&typeof link.orgId=="string"&&link.orgId.length>0&&(link.projectName===void 0||typeof link.projectName=="string"&&link.projectName.length>0)}function getVercelDirectory(cwd){let possibleDirs=[join5(cwd,VERCEL_DIR),join5(cwd,VERCEL_DIR_FALLBACK)],existingDirs=possibleDirs.filter(d=>isDirectory(d));if(existingDirs.length>1)throw new import_build_utils2.NowBuildError({code:"CONFLICTING_CONFIG_DIRECTORIES",message:"Both `.vercel` and `.now` directories exist. Please remove the `.now` directory.",link:"https://vercel.link/combining-old-and-new-config"});return existingDirs[0]||possibleDirs[0]}async function getProjectLink(client,path,projectName,projectNameIsExplicit){let dirLink=await getLinkFromDir(getVercelDirectory(path));return dirLink&&(!projectNameIsExplicit||!projectName||dirLink.projectId===projectName||dirLink.projectName===projectName)?dirLink:await getProjectLinkFromRepoLink(client,path,projectName,projectNameIsExplicit)}async function getProjectLinkFromRepoLink(client,path,projectName,projectNameIsExplicit){let repoLink=await getRepoLink(client,path);if(!repoLink?.repoConfig)return null;let projects=findProjectsFromPath(repoLink.repoConfig.projects,relative2(repoLink.rootPath,path)),project;if(projectName&&projectNameIsExplicit)project=repoLink.repoConfig.projects.find(p=>p.id===projectName||p.name===projectName);else if(projects.length===1)project=projects[0];else{let selectableProjects=projects.length>0?projects:repoLink.repoConfig.projects;if(projectName&&(project=selectableProjects.find(p=>p.id===projectName||p.name===projectName)),!project)if(client.nonInteractive)if(selectableProjects.length===1)project=selectableProjects[0];else return null;else project=await client.input.select({message:"Please select a Project:",choices:selectableProjects.map(p=>({value:p,name:p.name}))})}if(project){let orgId=project.orgId??repoLink.repoConfig.orgId;if(!orgId){let projectInfo=[project.name?`name: "${project.name}"`:"",project.directory?`directory: "${project.directory}"`:""].filter(Boolean).join(", "),details=projectInfo?` Project: { ${projectInfo} }.`:"";throw new Error(`Could not determine org ID from repo.json config at "${repoLink.repoConfigPath}".${details} Please re-link the repository.`)}return{repoRoot:repoLink.rootPath,orgId,projectId:project.id,projectName:project.name,projectRootDirectory:project.directory}}return null}function getLinkedProjectIdSync(dir){try{let link=JSON.parse(fs3.readFileSync(join5(dir,VERCEL_DIR_PROJECT),"utf8"));return isValidProjectLink(link)?link.projectId:void 0}catch{return}}async function getLinkFromDir(dir){try{let json=await readFile(join5(dir,VERCEL_DIR_PROJECT),"utf8"),link=JSON.parse(json);if(!isValidProjectLink(link)){let raw=link,projectId=raw.projectId,orgId=raw.orgId;if(!(typeof projectId=="string"&&projectId.length>0&&typeof orgId=="string"&&orgId.length>0))return null;throw new Error(`Project Settings are invalid. To link your project again, remove the ${dir} directory.`)}return link}catch(err){if((0,import_error_utils2.isErrnoException)(err)&&err.code&&["ENOENT","ENOTDIR"].includes(err.code))return null;throw(0,import_error_utils2.isError)(err)&&err.name==="SyntaxError"?new Error(`Project Settings could not be retrieved. To link your project again, remove the ${dir} directory.`):err}}async function hasLocalProjectLink(client,cwd){try{if(await getLinkFromDir(getVercelDirectory(cwd)))return!0}catch{}try{let repoLink=await getRepoLink(client,cwd);return repoLink?.repoConfig?findProjectsFromPath(repoLink.repoConfig.projects,relative2(repoLink.rootPath,cwd)).length>0:!1}catch{return!1}}async function hasProjectLink(client,projectLink,path){let VERCEL_ORG_ID=(0,import_build_utils2.getPlatformEnv)("ORG_ID"),VERCEL_PROJECT_ID=(0,import_build_utils2.getPlatformEnv)("PROJECT_ID");if(VERCEL_ORG_ID===projectLink.orgId&&VERCEL_PROJECT_ID===projectLink.projectId)return!0;let repoLink=await getRepoLink(client,path);if(repoLink?.repoConfig){let matchingProject=repoLink.repoConfig.projects.find(p=>p.id===projectLink.projectId);if(matchingProject){let orgId=matchingProject.orgId??repoLink.repoConfig.orgId;if(!orgId)throw new Error(`Invalid "repo.json": missing "orgId" for project "${matchingProject.id}" and no top-level "orgId" is defined.`);if(orgId===projectLink.orgId)return!0}}let link=await getLinkFromDir(getVercelDirectory(path));return!!(link&&link.orgId===projectLink.orgId&&link.projectId===projectLink.projectId)}async function getLinkedProject(client,options={}){let path=options.cwd??client.cwd;options.skipProjectRootResolution||(path=await resolveProjectCwd(path));let VERCEL_ORG_ID=(0,import_build_utils2.getPlatformEnv)("ORG_ID"),VERCEL_PROJECT_ID=(0,import_build_utils2.getPlatformEnv)("PROJECT_ID"),shouldUseEnv=!!(VERCEL_ORG_ID&&VERCEL_PROJECT_ID),projectName=options.projectName,projectNameIsExplicit=options.projectNameIsExplicit===!0,explicitProjectName=projectNameIsExplicit?projectName:void 0,hasExplicitProject=!!explicitProjectName,shouldUseEnvContext=shouldUseEnv&&!hasExplicitProject;if(!hasExplicitProject&&(VERCEL_ORG_ID||VERCEL_PROJECT_ID)&&!shouldUseEnv)return options.quiet||output_manager_default.error(`You specified ${VERCEL_ORG_ID?"`VERCEL_ORG_ID`":"`VERCEL_PROJECT_ID`"} but you forgot to specify ${VERCEL_ORG_ID?"`VERCEL_PROJECT_ID`":"`VERCEL_ORG_ID`"}. You need to specify both to deploy to a custom project.
26
+ `),{repoConfig,repoConfigPath,rootPath};let mergedProjects=[...repoConfig.projects];for(let project of result.projects)existingProjectIds.has(project.id)||mergedProjects.push(project);let updatedConfig={...repoConfig,projects:mergedProjects};return await(0,import_fs_extra2.outputJSON)(repoConfigPath,updatedConfig,{spaces:2}),printAlignedLabel("Added",`${(0,import_pluralize.default)("Project",result.projects.length,!0)} under ${result.orgSlug}`,{gutter:"\u2713"}),{repoConfig:updatedConfig,repoConfigPath,rootPath}}async function findRepoRoot(start){let{debug}=output_manager_default,REPO_JSON_PATH=join3(VERCEL_DIR,VERCEL_DIR_REPO);for(let current of(0,import_build_utils.traverseUpDirectories)({start})){if(current===home){debug("Arrived at home directory");break}let repoConfigPath=join3(current,REPO_JSON_PATH);if(await(0,import_fs_extra2.lstat)(repoConfigPath).catch(err=>{if(err.code!=="ENOENT")throw err}))return debug(`Found "${REPO_JSON_PATH}" - detected "${current}" as repo root`),current}let gitRoot=getGitRootDirectory({cwd:start});if(gitRoot)return debug(`Found git root via "git rev-parse --show-toplevel" - detected "${gitRoot}" as repo root`),gitRoot;for(let current of(0,import_build_utils.traverseUpDirectories)({start})){if(current===home){debug("Arrived at home directory");break}let gitPath=join3(current,".git");if(await(0,import_fs_extra2.lstat)(gitPath).catch(err=>{if(err.code!=="ENOENT")throw err}))return debug(`Found ".git" - detected "${current}" as repo root`),current}debug("Aborting search for repo root")}function sortByDirectory(a,b){let aParts=a.directory.split("/");return b.directory.split("/").length-aParts.length}function findProjectsFromPath(projects,path){let normalizedPath=(0,import_build_utils.normalizePath)(path),matches=projects.slice().sort(sortByDirectory).filter(project=>project.directory==="."?!0:normalizedPath===project.directory||normalizedPath.startsWith(`${project.directory}/`)),firstMatch=matches[0];return firstMatch?matches.filter(match=>match.directory===firstMatch.directory):[]}var import_chalk2=__toESM(require_source(),1),import_fs_extra3=__toESM(require_lib2(),1);import{stat}from"fs/promises";import{join as join4,dirname}from"path";async function findProjectRoot(startDir){let cwdDev;try{cwdDev=(await stat(startDir)).dev}catch{return null}let dir=dirname(startDir);for(;dirname(dir)!==dir;){try{if((await stat(dir)).dev!==cwdDev)return null}catch{return null}let hasVercelDir=await(0,import_fs_extra3.pathExists)(join4(dir,".vercel")),hasVercelJson=await(0,import_fs_extra3.pathExists)(join4(dir,"vercel.json")),hasVercelToml=await(0,import_fs_extra3.pathExists)(join4(dir,"vercel.toml")),hasGit=await(0,import_fs_extra3.pathExists)(join4(dir,".git"));if(hasVercelDir||hasVercelJson||hasVercelToml||hasGit)return dir;dir=dirname(dir)}return null}async function resolveProjectCwd(cwd){let projectRoot=await findProjectRoot(cwd);if(!projectRoot||projectRoot===cwd)return cwd;let{isExperimentalServicesEnabled,tryDetectServices}=await import("./detect-services-GFVD2C3W.js");if(!await isExperimentalServicesEnabled(projectRoot))return cwd;let result=await tryDetectServices(projectRoot);return result&&(result.services?.length??0)>0?(output_manager_default.debug(`Running from project root: ${import_chalk2.default.cyan(projectRoot)}`),projectRoot):cwd}var readFile=promisify(fs3.readFile),writeFile=promisify(fs3.writeFile),VERCEL_DIR=".vercel",VERCEL_DIR_FALLBACK=".now",VERCEL_DIR_README="README.txt",VERCEL_DIR_PROJECT="project.json",VERCEL_DIR_REPO="repo.json";function isOwnerLookupUnavailableLink(link){return"ownerLookupUnavailable"in link&&link.ownerLookupUnavailable===!0}function isRemoteLookupSkippedLink(link){return"remoteLookupSkipped"in link&&link.remoteLookupSkipped===!0}function isOwnerLookupUnavailableError(error){return isAPIError(error)&&error.status===403&&error.code==="team_unauthorized"}function isValidProjectLink(value){if(!value||typeof value!="object"||Array.isArray(value))return!1;let link=value;return typeof link.projectId=="string"&&link.projectId.length>0&&typeof link.orgId=="string"&&link.orgId.length>0&&(link.projectName===void 0||typeof link.projectName=="string"&&link.projectName.length>0)}function getVercelDirectory(cwd){let possibleDirs=[join5(cwd,VERCEL_DIR),join5(cwd,VERCEL_DIR_FALLBACK)],existingDirs=possibleDirs.filter(d=>isDirectory(d));if(existingDirs.length>1)throw new import_build_utils2.NowBuildError({code:"CONFLICTING_CONFIG_DIRECTORIES",message:"Both `.vercel` and `.now` directories exist. Please remove the `.now` directory.",link:"https://vercel.link/combining-old-and-new-config"});return existingDirs[0]||possibleDirs[0]}async function getProjectLink(client,path,projectName,projectNameIsExplicit){let dirLink=await getLinkFromDir(getVercelDirectory(path));return dirLink&&(!projectNameIsExplicit||!projectName||dirLink.projectId===projectName||dirLink.projectName===projectName)?dirLink:await getProjectLinkFromRepoLink(client,path,projectName,projectNameIsExplicit)}async function getProjectLinkFromRepoLink(client,path,projectName,projectNameIsExplicit){let repoLink=await getRepoLink(client,path);if(!repoLink?.repoConfig)return null;let projects=findProjectsFromPath(repoLink.repoConfig.projects,relative2(repoLink.rootPath,path)),project;if(projectName&&projectNameIsExplicit)project=repoLink.repoConfig.projects.find(p=>p.id===projectName||p.name===projectName);else if(projects.length===1)project=projects[0];else{let selectableProjects=projects.length>0?projects:repoLink.repoConfig.projects;if(projectName&&(project=selectableProjects.find(p=>p.id===projectName||p.name===projectName)),!project)if(client.nonInteractive)if(selectableProjects.length===1)project=selectableProjects[0];else return null;else project=await client.input.select({message:"Please select a Project:",choices:selectableProjects.map(p=>({value:p,name:p.name}))})}if(project){let orgId=project.orgId??repoLink.repoConfig.orgId;if(!orgId){let projectInfo=[project.name?`name: "${project.name}"`:"",project.directory?`directory: "${project.directory}"`:""].filter(Boolean).join(", "),details=projectInfo?` Project: { ${projectInfo} }.`:"";throw new Error(`Could not determine org ID from repo.json config at "${repoLink.repoConfigPath}".${details} Please re-link the repository.`)}return{repoRoot:repoLink.rootPath,orgId,projectId:project.id,projectName:project.name,projectRootDirectory:project.directory}}return null}function getLinkedProjectIdSync(dir){try{let link=JSON.parse(fs3.readFileSync(join5(dir,VERCEL_DIR_PROJECT),"utf8"));return isValidProjectLink(link)?link.projectId:void 0}catch{return}}async function getLinkFromDir(dir){try{let json=await readFile(join5(dir,VERCEL_DIR_PROJECT),"utf8"),link=JSON.parse(json);if(!isValidProjectLink(link)){let raw=link,projectId=raw.projectId,orgId=raw.orgId;if(!(typeof projectId=="string"&&projectId.length>0&&typeof orgId=="string"&&orgId.length>0))return null;throw new Error(`Project Settings are invalid. To link your project again, remove the ${dir} directory.`)}return link}catch(err){if((0,import_error_utils2.isErrnoException)(err)&&err.code&&["ENOENT","ENOTDIR"].includes(err.code))return null;throw(0,import_error_utils2.isError)(err)&&err.name==="SyntaxError"?new Error(`Project Settings could not be retrieved. To link your project again, remove the ${dir} directory.`):err}}async function hasLocalProjectLink(client,cwd){try{if(await getLinkFromDir(getVercelDirectory(cwd)))return!0}catch{}try{let repoLink=await getRepoLink(client,cwd);return repoLink?.repoConfig?findProjectsFromPath(repoLink.repoConfig.projects,relative2(repoLink.rootPath,cwd)).length>0:!1}catch{return!1}}async function hasProjectLink(client,projectLink,path){let VERCEL_ORG_ID=(0,import_build_utils2.getPlatformEnv)("ORG_ID"),VERCEL_PROJECT_ID=(0,import_build_utils2.getPlatformEnv)("PROJECT_ID");if(VERCEL_ORG_ID===projectLink.orgId&&VERCEL_PROJECT_ID===projectLink.projectId)return!0;let repoLink=await getRepoLink(client,path);if(repoLink?.repoConfig){let matchingProject=repoLink.repoConfig.projects.find(p=>p.id===projectLink.projectId);if(matchingProject){let orgId=matchingProject.orgId??repoLink.repoConfig.orgId;if(!orgId)throw new Error(`Invalid "repo.json": missing "orgId" for project "${matchingProject.id}" and no top-level "orgId" is defined.`);if(orgId===projectLink.orgId)return!0}}let link=await getLinkFromDir(getVercelDirectory(path));return!!(link&&link.orgId===projectLink.orgId&&link.projectId===projectLink.projectId)}async function getLinkedProject(client,options={}){let path=options.cwd??client.cwd;options.skipProjectRootResolution||(path=await resolveProjectCwd(path));let VERCEL_ORG_ID=(0,import_build_utils2.getPlatformEnv)("ORG_ID"),VERCEL_PROJECT_ID=(0,import_build_utils2.getPlatformEnv)("PROJECT_ID"),shouldUseEnv=!!(VERCEL_ORG_ID&&VERCEL_PROJECT_ID),projectName=options.projectName,projectNameIsExplicit=options.projectNameIsExplicit===!0,explicitProjectName=projectNameIsExplicit?projectName:void 0,hasExplicitProject=!!explicitProjectName,shouldUseEnvContext=shouldUseEnv&&!hasExplicitProject;if(!hasExplicitProject&&(VERCEL_ORG_ID||VERCEL_PROJECT_ID)&&!shouldUseEnv)return options.quiet||output_manager_default.error(`You specified ${VERCEL_ORG_ID?"`VERCEL_ORG_ID`":"`VERCEL_PROJECT_ID`"} but you forgot to specify ${VERCEL_ORG_ID?"`VERCEL_PROJECT_ID`":"`VERCEL_ORG_ID`"}. You need to specify both to deploy to a custom project.
27
27
  `),{status:"error",exitCode:1};let link,explicitlyResolvedProject=null,orgId;if(explicitProjectName){let hasExplicitScope=options.scopeIsExplicit===!0,matchingLocalLink=hasExplicitScope||shouldUseEnv?null:await getProjectLink(client,path,explicitProjectName,!0),fallbackOrgId=shouldUseEnv?VERCEL_ORG_ID:matchingLocalLink?.orgId??client.config.currentTeam,lookupOrgId=hasExplicitScope?client.config.currentTeam:fallbackOrgId;orgId=lookupOrgId;let apiProject=await getProjectByNameOrId(client,explicitProjectName,lookupOrgId);if(explicitlyResolvedProject=apiProject instanceof ProjectNotFound?null:apiProject,explicitlyResolvedProject===null)link=null;else{let resolvedOrgId=explicitlyResolvedProject.accountId??lookupOrgId??matchingLocalLink?.orgId,localLink=matchingLocalLink?.projectId===explicitlyResolvedProject.id?matchingLocalLink:null;if(!localLink)try{localLink=await getProjectLink(client,path,explicitlyResolvedProject.id,!0)}catch(err){output_manager_default.debug(`Ignoring local project metadata after explicit project resolution: ${err}`)}link=resolvedOrgId?{...localLink?.projectId===explicitlyResolvedProject.id&&localLink.orgId===resolvedOrgId?localLink:{},projectId:explicitlyResolvedProject.id,orgId:resolvedOrgId}:null}}else link=shouldUseEnvContext?{orgId:VERCEL_ORG_ID,projectId:VERCEL_PROJECT_ID}:await getProjectLink(client,path,projectName,projectNameIsExplicit),link&&(orgId=link.orgId);if(!link)return{status:"not_linked",org:null,project:null,orgId};if(options.skipRemoteLookup&&link.projectName){let settings=link.settings,localRootDirectory=link.projectRootDirectory??settings?.rootDirectory??null,rootDirectory=localRootDirectory==="."?null:localRootDirectory,project2={...settings,id:link.projectId,accountId:link.orgId,name:link.projectName,createdAt:settings?.createdAt??0,updatedAt:settings?.updatedAt??settings?.createdAt??0,rootDirectory};return{...{status:"linked",org:{type:link.orgId.startsWith("team_")?"team":"user",id:link.orgId,slug:""},project:project2,repoRoot:link.repoRoot,remoteLookupSkipped:!0},projectRootDirectory:link.projectRootDirectory,orgId:link.orgId}}options.quiet||output_manager_default.spinner("Retrieving project\u2026",1e3);let org=null,project=null,ownerLookupUnavailable=!1;try{let[orgResult,projectResult]=await Promise.allSettled([options.skipOwnerLookup?Promise.resolve({type:link.orgId.startsWith("team_")?"team":"user",id:link.orgId,slug:""}):getOrgById(client,link.orgId),explicitlyResolvedProject?Promise.resolve(explicitlyResolvedProject):getProjectByNameOrId(client,link.projectId,link.orgId)]);if(orgResult.status==="fulfilled")org=orgResult.value;else if(isAPIError(orgResult.reason)&&(orgResult.reason.status===404||orgResult.reason.code==="not_found"||orgResult.reason.code==="mock_unimplemented"))org=null;else if(options.allowOwnerLookupFallback&&isOwnerLookupUnavailableError(orgResult.reason))ownerLookupUnavailable=!0;else throw orgResult.reason;if(projectResult.status==="fulfilled")project=projectResult.value;else if(isAPIError(projectResult.reason)&&(projectResult.reason.status===404||projectResult.reason.code==="not_found"||projectResult.reason.code==="mock_unimplemented"))project=new ProjectNotFound(link.projectId);else throw projectResult.reason}catch(err){if(isAPIError(err)&&err.status===403){if(output_manager_default.stopSpinner(),err.missingToken||err.invalidToken)throw new InvalidToken(client.authConfig.tokenSource);if(err.code==="forbidden"||err.code==="team_unauthorized")throw new import_build_utils2.NowBuildError({message:`Could not retrieve Project Settings. To link your Project, remove the ${code(VERCEL_DIR)} directory and deploy again.`,code:"PROJECT_UNAUTHORIZED",link:"https://vercel.link/cannot-load-project-settings"})}throw err}finally{output_manager_default.stopSpinner()}if(ownerLookupUnavailable&&project&&!(project instanceof ProjectNotFound)){let ownerId=project.accountId||link.orgId;return{status:"linked",org:{type:ownerId.startsWith("team_")?"team":"user",id:ownerId,slug:ownerId},project,repoRoot:link.repoRoot,projectRootDirectory:link.projectRootDirectory,orgId:link.orgId,ownerLookupUnavailable:!0}}return!org||!project||project instanceof ProjectNotFound?shouldUseEnvContext?(options.quiet||output_manager_default.error(`Project not found (${JSON.stringify({VERCEL_PROJECT_ID,VERCEL_ORG_ID})})
28
28
  `),{status:"error",exitCode:1,orgId}):(options.quiet||output_manager_default.print(prependEmoji(`Your Project was either deleted, transferred to a new Team, or you don\u2019t have access to it anymore.
29
29
  `,emoji("warning"))),{status:"not_linked",org:null,project:null,orgId:link.orgId}):{status:"linked",org,project,repoRoot:link.repoRoot,projectRootDirectory:link.projectRootDirectory,orgId:link.orgId}}var VERCEL_DIR_README_CONTENT=`> Why do I have a folder named ".vercel" in my project?
@@ -39,6 +39,6 @@ No, you should not share the ".vercel" folder with anyone.
39
39
  Upon creation, it will be automatically added to your ".gitignore" file.
40
40
  `;async function writeReadme(path){await writeFile(join5(path,VERCEL_DIR,VERCEL_DIR_README),VERCEL_DIR_README_CONTENT)}async function linkFolderToProject(client,path,projectLink,projectName,orgSlug,successEmoji="link",autoConfirm=!1,pullEnv=!0,resultLabel="Linked"){if(await hasProjectLink(client,projectLink,path))return;try{await(0,import_fs_extra4.ensureDir)(join5(path,VERCEL_DIR))}catch(err){if((0,import_error_utils2.isErrnoException)(err)&&err.code==="ENOTDIR")return;throw err}if(await writeFile(join5(path,VERCEL_DIR,VERCEL_DIR_PROJECT),JSON.stringify({...projectLink,projectName})),await writeReadme(path),await addToGitIgnore(path),output_manager_default.print(`
41
41
  `),printAlignedLabel(resultLabel,`${orgSlug}/${projectName}`,{gutter:"\u2713"}),!pullEnv||!client.stdin.isTTY||client.nonInteractive)return;if(output_manager_default.print(`
42
- `),autoConfirm||await client.input.confirm("Pull development environment variables into .env.local?",!0)){let originalCwd=client.cwd;try{client.cwd=path;let args=autoConfirm?["--yes"]:[],{default:pull}=await import("./pull-CXUNHWAO.js");await pull(client,args,"vercel-cli:link")!==0&&output_manager_default.error("Failed to pull environment variables. You can run `vc env pull` manually.")}catch{output_manager_default.error("Failed to pull environment variables. You can run `vc env pull` manually.")}finally{client.cwd=originalCwd}}}async function addToGitIgnore(path,ignore=VERCEL_DIR){let isGitIgnoreUpdated=!1;try{let gitIgnorePath=join6(path,".gitignore"),gitIgnore=await(0,import_fs_extra5.readFile)(gitIgnorePath,"utf8").catch(()=>null)??"",EOL=gitIgnore.includes(`\r
42
+ `),autoConfirm||await client.input.confirm("Pull development environment variables into .env.local?",!0)){let originalCwd=client.cwd;try{client.cwd=path;let args=autoConfirm?["--yes"]:[],{default:pull}=await import("./pull-HT2MQ3ML.js");await pull(client,args,"vercel-cli:link")!==0&&output_manager_default.error("Failed to pull environment variables. You can run `vc env pull` manually.")}catch{output_manager_default.error("Failed to pull environment variables. You can run `vc env pull` manually.")}finally{client.cwd=originalCwd}}}async function addToGitIgnore(path,ignore=VERCEL_DIR){let isGitIgnoreUpdated=!1;try{let gitIgnorePath=join6(path,".gitignore"),gitIgnore=await(0,import_fs_extra5.readFile)(gitIgnorePath,"utf8").catch(()=>null)??"",EOL=gitIgnore.includes(`\r
43
43
  `)?`\r
44
44
  `:os.EOL,contentModified=!1;gitIgnore.split(EOL).includes(ignore)||(gitIgnore+=`${gitIgnore.endsWith(EOL)||gitIgnore.length===0?"":EOL}${ignore}${EOL}`,contentModified=!0),contentModified&&(await(0,import_fs_extra5.writeFile)(gitIgnorePath,gitIgnore),isGitIgnoreUpdated=!0)}catch{}return isGitIgnoreUpdated}var VERCEL_CONFIG_EXTENSIONS=["ts","mts","js","mjs","cjs"],DEFAULT_VERCEL_CONFIG_FILENAME="Vercel config";export{require_lib2 as require_lib,getProjectByNameOrId,getOrgById,isDirectory,require_pluralize,execFileAsync,getGitExecutable,getGitConfigPath,createGitMeta,parseGitConfig,pluckRemoteUrls,getRemoteUrls,addToGitIgnore,getRepoLink,resolveGitRemote,selectGitRemote,fetchProjectsForRepoUrl,linkRepoProject,ensureRepoLink,addRepoLink,findRepoRoot,findProjectsFromPath,VERCEL_CONFIG_EXTENSIONS,DEFAULT_VERCEL_CONFIG_FILENAME,resolveProjectCwd,VERCEL_DIR,VERCEL_DIR_README,VERCEL_DIR_PROJECT,isOwnerLookupUnavailableLink,isRemoteLookupSkippedLink,getVercelDirectory,getProjectLink,getLinkedProjectIdSync,getLinkFromDir,hasLocalProjectLink,getLinkedProject,linkFolderToProject};
@@ -4,7 +4,7 @@ import { dirname as __dirname_ } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
- import{VERCEL_CONFIG_EXTENSIONS,VERCEL_DIR}from"./chunk-U3NQZJQ4.js";import{ConflictingConfigFiles,DeprecatedNowJson}from"./chunk-XSDAUM4F.js";import{output_manager_default,require_build_utils}from"./chunk-M774HRX5.js";import{__commonJS,__require,__toESM}from"./chunk-BZENIQ7N.js";var require_main=__commonJS({"../../node_modules/.pnpm/dotenv@4.0.0/node_modules/dotenv/lib/main.js"(exports,module){"use strict";var fs=__require("fs");function parse(src){var obj={};return src.toString().split(`
7
+ import{VERCEL_CONFIG_EXTENSIONS,VERCEL_DIR}from"./chunk-JIGCN5QS.js";import{ConflictingConfigFiles,DeprecatedNowJson}from"./chunk-XSDAUM4F.js";import{output_manager_default,require_build_utils}from"./chunk-M774HRX5.js";import{__commonJS,__require,__toESM}from"./chunk-BZENIQ7N.js";var require_main=__commonJS({"../../node_modules/.pnpm/dotenv@4.0.0/node_modules/dotenv/lib/main.js"(exports,module){"use strict";var fs=__require("fs");function parse(src){var obj={};return src.toString().split(`
8
8
  `).forEach(function(line){var keyValueArr=line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/);if(keyValueArr!=null){var key=keyValueArr[1],value=keyValueArr[2]?keyValueArr[2]:"",len=value?value.length:0;len>0&&value.charAt(0)==='"'&&value.charAt(len-1)==='"'&&(value=value.replace(/\\n/gm,`
9
9
  `)),value=value.replace(/(^['"]|['"]$)/g,"").trim(),obj[key]=value}}),obj}function config(options){var path=".env",encoding="utf8";options&&(options.path&&(path=options.path),options.encoding&&(encoding=options.encoding));try{var parsedObj=parse(fs.readFileSync(path,{encoding}));return Object.keys(parsedObj).forEach(function(key){process.env[key]=process.env[key]||parsedObj[key]}),{parsed:parsedObj}}catch(e){return{error:e}}}module.exports.config=config;module.exports.load=config;module.exports.parse=parse}});var import_dotenv=__toESM(require_main(),1);import{mkdir,readFile,writeFile,unlink,access}from"fs/promises";import{join,basename}from"path";import{fork}from"child_process";async function loadEsbuild(){let nativeLoader=Reflect.get(globalThis,Symbol.for("vercel.cli.loadEsbuild"));return typeof nativeLoader=="function"?nativeLoader():import("esbuild")}var import_build_utils=__toESM(require_build_utils(),1);function toRouteFormat(item){if("src"in item)return item;let{source,destination,headers,statusCode,permanent,...rest}=item,route={src:source,...rest};return destination&&(route.dest=destination),headers&&(route.headers=Object.fromEntries(headers.map(h=>[h.key,h.value]))),statusCode!==void 0?route.status=statusCode:permanent!==void 0&&(route.status=permanent?308:307),route}function normalizeConfig(config){let normalized={...config},{rewrites,redirects,headers}=normalized,allRoutes=normalized.routes||[],hasRoutes=allRoutes.length>0,hasRewrites=(rewrites?.length??0)>0,hasRedirects=(redirects?.length??0)>0,hasHeaders=(headers?.length??0)>0;function hasRouteFormat(items){return items?.some(item=>"src"in item)??!1}if(hasRoutes&&(hasRewrites||hasRedirects||hasHeaders))return normalized;let shouldConvertRewrites=hasRewrites&&hasRouteFormat(rewrites),shouldConvertRedirects=hasRedirects&&hasRouteFormat(redirects),shouldConvertHeaders=hasHeaders&&hasRouteFormat(headers);if((shouldConvertRewrites||shouldConvertRedirects||shouldConvertHeaders)&&(hasRewrites&&!shouldConvertRewrites||hasRedirects&&!shouldConvertRedirects||hasHeaders&&!shouldConvertHeaders))throw new import_build_utils.NowBuildError({code:"INVALID_VERCEL_CONFIG",message:"Transforms (e.g., requestHeaders) require the `routes` format, which cannot be used alongside `rewrites`, `redirects`, or `headers`. Move everything into the `routes` array instead.",link:"https://vercel.com/docs/projects/project-configuration#routes"});return rewrites&&shouldConvertRewrites&&(allRoutes=[...allRoutes,...rewrites.map(toRouteFormat)],delete normalized.rewrites),redirects&&shouldConvertRedirects&&(allRoutes=[...allRoutes,...redirects.map(toRouteFormat)],delete normalized.redirects),headers&&shouldConvertHeaders&&(allRoutes=[...allRoutes,...headers.map(toRouteFormat)],delete normalized.headers),allRoutes.length>0&&(normalized.routes=allRoutes.map(toRouteFormat)),normalized}async function fileExists(filePath){try{return await access(filePath),!0}catch{return!1}}async function findAllVercelConfigFiles(workPath){let foundFiles=[];for(let ext of VERCEL_CONFIG_EXTENSIONS){let configPath=join(workPath,`vercel.${ext}`);await fileExists(configPath)&&foundFiles.push(configPath)}return foundFiles}async function findSourceVercelConfigFile(workPath){for(let ext of VERCEL_CONFIG_EXTENSIONS){let configPath=join(workPath,`vercel.${ext}`);if(await fileExists(configPath))return basename(configPath)}let tomlPath=join(workPath,"vercel.toml");return await fileExists(tomlPath)?"vercel.toml":null}async function findVercelConfigFile(workPath){let foundFiles=await findAllVercelConfigFiles(workPath);if(foundFiles.length>1)throw new ConflictingConfigFiles(foundFiles,"Multiple vercel config files found. Please use only one configuration file.","https://vercel.com/docs/projects/project-configuration");return foundFiles[0]||null}function parseConfigLoaderError(stderr){if(!stderr.trim())return"";let moduleNotFoundMatch=stderr.match(/Error \[ERR_MODULE_NOT_FOUND\]: Cannot find package '([^']+)'/);if(moduleNotFoundMatch)return`Cannot find package '${moduleNotFoundMatch[1]}'. Make sure it's installed in your project dependencies.`;let syntaxErrorMatch=stderr.match(/SyntaxError: (.+?)(?:\n|$)/);if(syntaxErrorMatch)return`Syntax error: ${syntaxErrorMatch[1]}`;let errorMatch=stderr.match(/^(?:Error|TypeError|ReferenceError): (.+?)(?:\n|$)/m);return errorMatch?errorMatch[1]:stderr.trim()}async function compileVercelConfig(workPath){let vercelJsonPath=join(workPath,"vercel.json"),nowJsonPath=join(workPath,"now.json"),vercelTomlPath=join(workPath,"vercel.toml"),hasVercelJson=await fileExists(vercelJsonPath),hasNowJson=await fileExists(nowJsonPath),hasVercelToml=await fileExists(vercelTomlPath),vercelConfigPath=await findVercelConfigFile(workPath),vercelDir=join(workPath,VERCEL_DIR),compiledConfigPath=join(vercelDir,"vercel.json");if(hasNowJson)throw new DeprecatedNowJson(nowJsonPath);let foundConfigs=[];if(hasVercelJson&&foundConfigs.push(vercelJsonPath),hasVercelToml&&foundConfigs.push(vercelTomlPath),vercelConfigPath&&foundConfigs.push(vercelConfigPath),foundConfigs.length>1)throw new ConflictingConfigFiles(foundConfigs,`Multiple config files found: ${foundConfigs.map(f=>basename(f)).join(", ")}. Please use only one configuration method.`,"https://vercel.com/docs/projects/project-configuration");if(!vercelConfigPath&&!hasVercelToml)return hasVercelJson?{configPath:vercelJsonPath,wasCompiled:!1}:await fileExists(compiledConfigPath)?{configPath:compiledConfigPath,wasCompiled:!0,sourceFile:await findSourceVercelConfigFile(workPath)??void 0}:{configPath:null,wasCompiled:!1};if(hasVercelToml)try{let{parse:tomlParse}=await import("smol-toml"),tomlContent=await readFile(vercelTomlPath,"utf8"),config=tomlParse(tomlContent),normalizedConfig=normalizeConfig(config);return await mkdir(vercelDir,{recursive:!0}),await writeFile(compiledConfigPath,JSON.stringify(normalizedConfig,null,2),"utf-8"),output_manager_default.debug(`Compiled ${vercelTomlPath} -> ${compiledConfigPath}`),{configPath:compiledConfigPath,wasCompiled:!0,sourceFile:"vercel.toml"}}catch(error){throw new import_build_utils.NowBuildError({code:error.code??"vercel_toml_parse_failed",message:`Failed to parse vercel.toml: ${error.message}`,link:error.link??"https://vercel.com/docs/projects/project-configuration"})}let sourceConfigPath=vercelConfigPath;(0,import_dotenv.config)({path:join(workPath,".env")}),(0,import_dotenv.config)({path:join(workPath,".env.local")});let tempOutPath=join(vercelDir,"vercel-temp.mjs"),loaderPath=join(vercelDir,"vercel-loader.mjs");try{let{build}=await loadEsbuild();await mkdir(vercelDir,{recursive:!0}),await build({entryPoints:[sourceConfigPath],bundle:!0,platform:"node",format:"esm",outfile:tempOutPath,packages:"external",target:"node20",sourcemap:"inline"}),await writeFile(loaderPath,`
10
10
  import { pathToFileURL } from 'url';