Skip to content

Commit

Permalink
fix link flow when unlinked project exists (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
jairad26 authored Nov 26, 2024
1 parent f471650 commit 942cd77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/commands/link/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/util/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Project> {
export async function sendMapRepoAndFinishProjectCreationReq(jwt: string, id: string, repoId: string, repoName: string): Promise<Project> {
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
Expand All @@ -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;
}
Expand Down

0 comments on commit 942cd77

Please sign in to comment.