From 942cd77dcd80ebbbce39a8341a7518452a43c803 Mon Sep 17 00:00:00 2001 From: Jai Radhakrishnan <55522316+jairad26@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:06:09 -0800 Subject: [PATCH] fix link flow when unlinked project exists (#56) --- src/commands/link/index.ts | 4 ++-- src/util/graphql.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/commands/link/index.ts b/src/commands/link/index.ts index f0d2524..0142896 100644 --- a/src/commands/link/index.ts +++ b/src/commands/link/index.ts @@ -15,7 +15,7 @@ import { URL } from "node:url"; import open from "open"; import { ciStr } from "../../util/ci.js"; -import { getProjectsByOrgReq, sendCreateProjectRepoReq, sendCreateProjectReq, sendGetRepoIdReq } from "../../util/graphql.js"; +import { getProjectsByOrgReq, sendMapRepoAndFinishProjectCreationReq, sendCreateProjectReq, sendGetRepoIdReq } from "../../util/graphql.js"; import { confirmExistingProjectLink, confirmOverwriteCiHypFile, fileExists, getCiHypFilePath, getSettingsFilePath, getGitConfigFilePath, getGitRemoteUrl, getGithubWorkflowDir, promptProjectLinkSelection, promptProjectName, readSettingsJson, writeGithubInstallationIdToSettingsFile } from "../../util/index.js"; export default class LinkIndex extends Command { @@ -160,7 +160,7 @@ export default class LinkIndex extends Command { if (confirmExistingProject) { selectedProject = await promptProjectLinkSelection(projectsNoRepoId); - const completedProject = await sendCreateProjectRepoReq(settings.jwt, selectedProject.id, repoId, repoFullName); + const completedProject = await sendMapRepoAndFinishProjectCreationReq(settings.jwt, selectedProject.id, repoId, repoFullName); this.log(chalk.green("Successfully linked project " + completedProject.name + " to repo " + repoName + "! 🎉")); } else { diff --git a/src/util/graphql.ts b/src/util/graphql.ts index ecf5f41..ed0e70c 100644 --- a/src/util/graphql.ts +++ b/src/util/graphql.ts @@ -28,10 +28,10 @@ export async function sendGraphQLReqToHypermode(jwt: string, query: string): Pro return data; } -export async function sendCreateProjectRepoReq(jwt: string, id: string, repoId: string, repoName: string): Promise { +export async function sendMapRepoAndFinishProjectCreationReq(jwt: string, id: string, repoId: string, repoName: string): Promise { const query = ` - mutation CreateProjectRepo { - createProjectRepo(input: {id: "${id}", repoName: "${repoName}", repoId: "${repoId}", sourceType: CUSTOM}) { + mutation MapRepoAndFinishProjectCreation { + mapRepoAndFinishProjectCreation(input: {id: "${id}", repoName: "${repoName}", repoId: "${repoId}", sourceType: CUSTOM, defaultBranchName: "main"}) { id name repoId @@ -40,7 +40,7 @@ export async function sendCreateProjectRepoReq(jwt: string, id: string, repoId: const data: any = await sendGraphQLReqToHypermode(jwt, query); - const project: Project = data.data.createProjectRepo; + const project: Project = data.data.mapRepoAndFinishProjectCreation; return project; }