Skip to content

Commit 942cd77

Browse files
authored
fix link flow when unlinked project exists (#56)
1 parent f471650 commit 942cd77

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/commands/link/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { URL } from "node:url";
1515
import open from "open";
1616

1717
import { ciStr } from "../../util/ci.js";
18-
import { getProjectsByOrgReq, sendCreateProjectRepoReq, sendCreateProjectReq, sendGetRepoIdReq } from "../../util/graphql.js";
18+
import { getProjectsByOrgReq, sendMapRepoAndFinishProjectCreationReq, sendCreateProjectReq, sendGetRepoIdReq } from "../../util/graphql.js";
1919
import { confirmExistingProjectLink, confirmOverwriteCiHypFile, fileExists, getCiHypFilePath, getSettingsFilePath, getGitConfigFilePath, getGitRemoteUrl, getGithubWorkflowDir, promptProjectLinkSelection, promptProjectName, readSettingsJson, writeGithubInstallationIdToSettingsFile } from "../../util/index.js";
2020

2121
export default class LinkIndex extends Command {
@@ -160,7 +160,7 @@ export default class LinkIndex extends Command {
160160

161161
if (confirmExistingProject) {
162162
selectedProject = await promptProjectLinkSelection(projectsNoRepoId);
163-
const completedProject = await sendCreateProjectRepoReq(settings.jwt, selectedProject.id, repoId, repoFullName);
163+
const completedProject = await sendMapRepoAndFinishProjectCreationReq(settings.jwt, selectedProject.id, repoId, repoFullName);
164164

165165
this.log(chalk.green("Successfully linked project " + completedProject.name + " to repo " + repoName + "! 🎉"));
166166
} else {

src/util/graphql.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ export async function sendGraphQLReqToHypermode(jwt: string, query: string): Pro
2828
return data;
2929
}
3030

31-
export async function sendCreateProjectRepoReq(jwt: string, id: string, repoId: string, repoName: string): Promise<Project> {
31+
export async function sendMapRepoAndFinishProjectCreationReq(jwt: string, id: string, repoId: string, repoName: string): Promise<Project> {
3232
const query = `
33-
mutation CreateProjectRepo {
34-
createProjectRepo(input: {id: "${id}", repoName: "${repoName}", repoId: "${repoId}", sourceType: CUSTOM}) {
33+
mutation MapRepoAndFinishProjectCreation {
34+
mapRepoAndFinishProjectCreation(input: {id: "${id}", repoName: "${repoName}", repoId: "${repoId}", sourceType: CUSTOM, defaultBranchName: "main"}) {
3535
id
3636
name
3737
repoId
@@ -40,7 +40,7 @@ export async function sendCreateProjectRepoReq(jwt: string, id: string, repoId:
4040

4141
const data: any = await sendGraphQLReqToHypermode(jwt, query);
4242

43-
const project: Project = data.data.createProjectRepo;
43+
const project: Project = data.data.mapRepoAndFinishProjectCreation;
4444

4545
return project;
4646
}

0 commit comments

Comments
 (0)