MCPcopy Create free account
hub / github.com/vercel/vercel / getProjectLink

Function getProjectLink

packages/cli/src/util/projects/link.ts:78–109  ·  view source on GitHub ↗
(
  client: Client,
  path: string,
  projectName?: string,
  projectNameIsExplicit?: boolean
)

Source from the content-addressed store, hash-verified

76}
77
78export async function getProjectLink(
79 client: Client,
80 path: string,
81 projectName?: string,
82 projectNameIsExplicit?: boolean
83): Promise<ProjectLink | null> {
84 // Prefer an explicit per-directory link (`.vercel/project.json`) over a
85 // repository-level link (`.vercel/repo.json`). This prevents scenarios where
86 // a freshly-created local link (e.g. after `vc link`) is ignored and the
87 // user is re-prompted to select a repo-linked project again.
88 // When `projectNameIsExplicit` is true, the caller is resolving a user-
89 // supplied `--project` value, so mismatched local links must not win.
90 const dirLink = await getLinkFromDir(getVercelDirectory(path));
91 if (dirLink) {
92 if (!projectNameIsExplicit || !projectName) {
93 return dirLink;
94 }
95
96 if (
97 dirLink.projectId === projectName ||
98 dirLink.projectName === projectName
99 ) {
100 return dirLink;
101 }
102 }
103 return await getProjectLinkFromRepoLink(
104 client,
105 path,
106 projectName,
107 projectNameIsExplicit
108 );
109}
110
111async function getProjectLinkFromRepoLink(
112 client: Client,

Callers 2

createFunction · 0.90
getLinkedProjectFunction · 0.85

Calls 3

getLinkFromDirFunction · 0.85
getVercelDirectoryFunction · 0.85

Tested by

no test coverage detected