(
sender: WebContents,
{ organizationId, backendProjectId, remoteId }: PullRemoteBackendProjectOptions,
)
| 149 | }; |
| 150 | |
| 151 | export const pullRemoteBackendProject = async ( |
| 152 | sender: WebContents, |
| 153 | { organizationId, backendProjectId, remoteId }: PullRemoteBackendProjectOptions, |
| 154 | ) => { |
| 155 | return runWithSyncRenderer(sender, async () => { |
| 156 | ensureStoreConfigured(); |
| 157 | const projects = await remoteBackendProjects({ |
| 158 | teamId: organizationId, |
| 159 | teamProjectId: remoteId, |
| 160 | }); |
| 161 | const backendProject = projects.find(project => project.id === backendProjectId) as |
| 162 | | BackendProjectWithTeam |
| 163 | | undefined; |
| 164 | |
| 165 | invariant(backendProject, 'Backend project not found'); |
| 166 | |
| 167 | const project = await services.project.getByRemoteId(remoteId); |
| 168 | invariant(project?.remoteId, 'Project is not a remote project'); |
| 169 | |
| 170 | // backendProject.rootDocumentId is the target workspace's id, so the pull runs on that |
| 171 | // workspace's own VCS instance directly — no need for a separate isolated instance to shield |
| 172 | // a singleton's mutable state from other concurrent sync.invoke calls. |
| 173 | await removeBackendProjectsForRoot(backendProject.rootDocumentId); |
| 174 | const vcs = getVCSForWorkspace(backendProject.rootDocumentId); |
| 175 | const { workspaceId } = await pullBackendProject({ |
| 176 | vcs, |
| 177 | backendProject, |
| 178 | remoteProject: project as RemoteProject, |
| 179 | }); |
| 180 | invariant(typeof workspaceId === 'string', 'Workspace not found after pulling backend project'); |
| 181 | |
| 182 | return { |
| 183 | projectId: project._id, |
| 184 | workspaceId, |
| 185 | }; |
| 186 | }); |
| 187 | }; |
no test coverage detected