mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: cleanup git provider router
This commit is contained in:
@@ -79,7 +79,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
|
|||||||
const githubId = form.watch("githubId");
|
const githubId = form.watch("githubId");
|
||||||
|
|
||||||
const { data: repositories, isLoading: isLoadingRepositories } =
|
const { data: repositories, isLoading: isLoadingRepositories } =
|
||||||
api.gitProvider.getRepositories.useQuery({
|
api.gitProvider.getGithubRepositories.useQuery({
|
||||||
githubId,
|
githubId,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
|
|||||||
data: branches,
|
data: branches,
|
||||||
fetchStatus,
|
fetchStatus,
|
||||||
status,
|
status,
|
||||||
} = api.gitProvider.getBranches.useQuery(
|
} = api.gitProvider.getGithubBranches.useQuery(
|
||||||
{
|
{
|
||||||
owner: repository?.owner,
|
owner: repository?.owner,
|
||||||
repo: repository?.repo,
|
repo: repository?.repo,
|
||||||
|
|||||||
74
apps/dokploy/drizzle/0055_nice_king_cobra.sql
Normal file
74
apps/dokploy/drizzle/0055_nice_king_cobra.sql
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
ALTER TABLE "bitbucket_provider" RENAME TO "bitbucket";--> statement-breakpoint
|
||||||
|
ALTER TABLE "github_provider" RENAME TO "github";--> statement-breakpoint
|
||||||
|
ALTER TABLE "gitlab_provider" RENAME TO "gitlab";--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" DROP CONSTRAINT "application_githubId_github_provider_githubId_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" DROP CONSTRAINT "application_gitlabId_gitlab_provider_gitlabId_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" DROP CONSTRAINT "application_bitbucketId_bitbucket_provider_bitbucketId_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "compose" DROP CONSTRAINT "compose_githubId_github_provider_githubId_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "compose" DROP CONSTRAINT "compose_gitlabId_gitlab_provider_gitlabId_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "compose" DROP CONSTRAINT "compose_bitbucketId_bitbucket_provider_bitbucketId_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "bitbucket" DROP CONSTRAINT "bitbucket_provider_gitProviderId_git_provider_gitProviderId_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "github" DROP CONSTRAINT "github_provider_gitProviderId_git_provider_gitProviderId_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "gitlab" DROP CONSTRAINT "gitlab_provider_gitProviderId_git_provider_gitProviderId_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "application" ADD CONSTRAINT "application_githubId_github_githubId_fk" FOREIGN KEY ("githubId") REFERENCES "public"."github"("githubId") ON DELETE set null ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "application" ADD CONSTRAINT "application_gitlabId_gitlab_gitlabId_fk" FOREIGN KEY ("gitlabId") REFERENCES "public"."gitlab"("gitlabId") ON DELETE set null ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "application" ADD CONSTRAINT "application_bitbucketId_bitbucket_bitbucketId_fk" FOREIGN KEY ("bitbucketId") REFERENCES "public"."bitbucket"("bitbucketId") ON DELETE set null ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "compose" ADD CONSTRAINT "compose_githubId_github_githubId_fk" FOREIGN KEY ("githubId") REFERENCES "public"."github"("githubId") ON DELETE set null ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "compose" ADD CONSTRAINT "compose_gitlabId_gitlab_gitlabId_fk" FOREIGN KEY ("gitlabId") REFERENCES "public"."gitlab"("gitlabId") ON DELETE set null ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "compose" ADD CONSTRAINT "compose_bitbucketId_bitbucket_bitbucketId_fk" FOREIGN KEY ("bitbucketId") REFERENCES "public"."bitbucket"("bitbucketId") ON DELETE set null ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "bitbucket" ADD CONSTRAINT "bitbucket_gitProviderId_git_provider_gitProviderId_fk" FOREIGN KEY ("gitProviderId") REFERENCES "public"."git_provider"("gitProviderId") ON DELETE cascade ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "github" ADD CONSTRAINT "github_gitProviderId_git_provider_gitProviderId_fk" FOREIGN KEY ("gitProviderId") REFERENCES "public"."git_provider"("gitProviderId") ON DELETE cascade ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "gitlab" ADD CONSTRAINT "gitlab_gitProviderId_git_provider_gitProviderId_fk" FOREIGN KEY ("gitProviderId") REFERENCES "public"."git_provider"("gitProviderId") ON DELETE cascade ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
3539
apps/dokploy/drizzle/meta/0055_snapshot.json
Normal file
3539
apps/dokploy/drizzle/meta/0055_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -386,6 +386,13 @@
|
|||||||
"when": 1725238308102,
|
"when": 1725238308102,
|
||||||
"tag": "0054_short_hellfire_club",
|
"tag": "0054_short_hellfire_club",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 55,
|
||||||
|
"version": "6",
|
||||||
|
"when": 1725240886749,
|
||||||
|
"tag": "0055_nice_king_cobra",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -3,14 +3,23 @@ import { db } from "@/server/db";
|
|||||||
import {
|
import {
|
||||||
apiCreateBitbucket,
|
apiCreateBitbucket,
|
||||||
apiCreateGitlab,
|
apiCreateGitlab,
|
||||||
apiGetBranches,
|
apiFindBitbucketBranches,
|
||||||
|
apiFindGithubBranches,
|
||||||
|
apiFindGitlabBranches,
|
||||||
|
apiFindOneBitbucket,
|
||||||
|
apiFindOneGithub,
|
||||||
|
apiFindOneGitlab,
|
||||||
|
apiRemoveGitProvider,
|
||||||
} from "@/server/db/schema";
|
} from "@/server/db/schema";
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import {
|
import {
|
||||||
createBitbucket,
|
createBitbucket,
|
||||||
createGitlab,
|
createGitlab,
|
||||||
|
findBitbucketById,
|
||||||
|
findGithubById,
|
||||||
|
findGitlabById,
|
||||||
haveGithubRequirements,
|
haveGithubRequirements,
|
||||||
removeGithub,
|
removeGitProvider,
|
||||||
} from "../services/git-provider";
|
} from "../services/git-provider";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import {
|
import {
|
||||||
@@ -37,11 +46,26 @@ export const gitProvider = createTRPCRouter({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
oneGithub: protectedProcedure
|
||||||
|
.input(apiFindOneGithub)
|
||||||
|
.query(async ({ input }) => {
|
||||||
|
return await findGithubById(input.githubId);
|
||||||
|
}),
|
||||||
|
oneGitlab: protectedProcedure
|
||||||
|
.input(apiFindOneGitlab)
|
||||||
|
.query(async ({ input }) => {
|
||||||
|
return await findGitlabById(input.gitlabId);
|
||||||
|
}),
|
||||||
|
oneBitbucket: protectedProcedure
|
||||||
|
.input(apiFindOneBitbucket)
|
||||||
|
.query(async ({ input }) => {
|
||||||
|
return await findBitbucketById(input.bitbucketId);
|
||||||
|
}),
|
||||||
remove: protectedProcedure
|
remove: protectedProcedure
|
||||||
.input(z.object({ gitProviderId: z.string() }))
|
.input(apiRemoveGitProvider)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
try {
|
try {
|
||||||
return await removeGithub(input.gitProviderId);
|
return await removeGitProvider(input.gitProviderId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
@@ -127,64 +151,34 @@ export const gitProvider = createTRPCRouter({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
getGitlabRepositories: protectedProcedure
|
getGitlabRepositories: protectedProcedure
|
||||||
.input(
|
.input(apiFindOneGitlab)
|
||||||
z.object({
|
|
||||||
gitlabId: z.string().optional(),
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
return await getGitlabRepositories(input);
|
return await getGitlabRepositories(input.gitlabId);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
getGitlabBranches: protectedProcedure
|
getGitlabBranches: protectedProcedure
|
||||||
.input(
|
.input(apiFindGitlabBranches)
|
||||||
z.object({
|
|
||||||
id: z.number().nullable(),
|
|
||||||
owner: z.string(),
|
|
||||||
repo: z.string(),
|
|
||||||
gitlabId: z.string().optional(),
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
return await getGitlabBranches(input);
|
return await getGitlabBranches(input);
|
||||||
}),
|
}),
|
||||||
getBitbucketRepositories: protectedProcedure
|
getBitbucketRepositories: protectedProcedure
|
||||||
.input(
|
.input(apiFindOneBitbucket)
|
||||||
z.object({
|
|
||||||
bitbucketId: z.string().optional(),
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
return await getBitbucketRepositories(input);
|
return await getBitbucketRepositories(input.bitbucketId);
|
||||||
}),
|
}),
|
||||||
getBitbucketBranches: protectedProcedure
|
getBitbucketBranches: protectedProcedure
|
||||||
.input(
|
.input(apiFindBitbucketBranches)
|
||||||
z.object({
|
|
||||||
owner: z.string(),
|
|
||||||
repo: z.string(),
|
|
||||||
bitbucketId: z.string().optional(),
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
return await getBitbucketBranches(input);
|
return await getBitbucketBranches(input);
|
||||||
}),
|
}),
|
||||||
getRepositories: protectedProcedure
|
getGithubRepositories: protectedProcedure
|
||||||
.input(
|
.input(apiFindOneGithub)
|
||||||
z.object({
|
|
||||||
githubId: z.string().optional(),
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
return await getGithubRepositories(input);
|
return await getGithubRepositories(input.githubId);
|
||||||
}),
|
}),
|
||||||
getBranches: protectedProcedure
|
getGithubBranches: protectedProcedure
|
||||||
.input(apiGetBranches)
|
.input(apiFindGithubBranches)
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
return await getGithubBranches(input);
|
return await getGithubBranches(input);
|
||||||
}),
|
}),
|
||||||
// getGithub: protectedProcedure
|
|
||||||
// .input(apiGetGithub)
|
|
||||||
// .query(async ({ input }) => {
|
|
||||||
// return await findGithub(input);
|
|
||||||
// }),
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export const createBitbucket = async (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const removeGithub = async (gitProviderId: string) => {
|
export const removeGitProvider = async (gitProviderId: string) => {
|
||||||
const result = await db
|
const result = await db
|
||||||
.delete(gitProvider)
|
.delete(gitProvider)
|
||||||
.where(eq(gitProvider.gitProviderId, gitProviderId))
|
.where(eq(gitProvider.gitProviderId, gitProviderId))
|
||||||
|
|||||||
@@ -68,11 +68,6 @@ export const apiTraefikConfig = z.object({
|
|||||||
traefikConfig: z.string().min(1),
|
traefikConfig: z.string().min(1),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiGetBranches = z.object({
|
|
||||||
repo: z.string().min(1),
|
|
||||||
owner: z.string().min(1),
|
|
||||||
githubId: z.string().optional(),
|
|
||||||
});
|
|
||||||
export const apiModifyTraefikConfig = z.object({
|
export const apiModifyTraefikConfig = z.object({
|
||||||
path: z.string().min(1),
|
path: z.string().min(1),
|
||||||
traefikConfig: z.string().min(1),
|
traefikConfig: z.string().min(1),
|
||||||
|
|||||||
@@ -115,6 +115,12 @@ export const bitbucketProviderRelations = relations(bitbucket, ({ one }) => ({
|
|||||||
|
|
||||||
const createSchema = createInsertSchema(gitProvider);
|
const createSchema = createInsertSchema(gitProvider);
|
||||||
|
|
||||||
|
export const apiRemoveGitProvider = createSchema
|
||||||
|
.extend({
|
||||||
|
gitProviderId: z.string().min(1),
|
||||||
|
})
|
||||||
|
.pick({ gitProviderId: true });
|
||||||
|
|
||||||
export const apiCreateGithub = createSchema.extend({
|
export const apiCreateGithub = createSchema.extend({
|
||||||
githubAppName: z.string().optional(),
|
githubAppName: z.string().optional(),
|
||||||
githubAppId: z.number().optional(),
|
githubAppId: z.number().optional(),
|
||||||
@@ -126,6 +132,18 @@ export const apiCreateGithub = createSchema.extend({
|
|||||||
gitProviderId: z.string().optional(),
|
gitProviderId: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const apiFindGithubBranches = z.object({
|
||||||
|
repo: z.string().min(1),
|
||||||
|
owner: z.string().min(1),
|
||||||
|
githubId: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const apiFindOneGithub = createSchema
|
||||||
|
.extend({
|
||||||
|
githubId: z.string().min(1),
|
||||||
|
})
|
||||||
|
.pick({ githubId: true });
|
||||||
|
|
||||||
export const apiCreateGitlab = createSchema.extend({
|
export const apiCreateGitlab = createSchema.extend({
|
||||||
applicationId: z.string().optional(),
|
applicationId: z.string().optional(),
|
||||||
secret: z.string().optional(),
|
secret: z.string().optional(),
|
||||||
@@ -134,9 +152,45 @@ export const apiCreateGitlab = createSchema.extend({
|
|||||||
redirectUri: z.string().optional(),
|
redirectUri: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const apiFindOneGitlab = createSchema
|
||||||
|
.extend({
|
||||||
|
gitlabId: z.string().min(1),
|
||||||
|
})
|
||||||
|
.pick({ gitlabId: true });
|
||||||
|
|
||||||
|
export const apiFindGitlabBranches = z.object({
|
||||||
|
id: z.number().nullable(),
|
||||||
|
owner: z.string(),
|
||||||
|
repo: z.string(),
|
||||||
|
gitlabId: z.string().optional(),
|
||||||
|
});
|
||||||
export const apiCreateBitbucket = createSchema.extend({
|
export const apiCreateBitbucket = createSchema.extend({
|
||||||
bitbucketUsername: z.string().optional(),
|
bitbucketUsername: z.string().optional(),
|
||||||
appPassword: z.string().optional(),
|
appPassword: z.string().optional(),
|
||||||
bitbucketWorkspaceName: z.string().optional(),
|
bitbucketWorkspaceName: z.string().optional(),
|
||||||
gitProviderId: z.string().optional(),
|
gitProviderId: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const apiFindOneBitbucket = createSchema
|
||||||
|
.extend({
|
||||||
|
bitbucketId: z.string().min(1),
|
||||||
|
})
|
||||||
|
.pick({ bitbucketId: true });
|
||||||
|
|
||||||
|
export const apiFindBitbucketBranches = z.object({
|
||||||
|
owner: z.string(),
|
||||||
|
repo: z.string(),
|
||||||
|
bitbucketId: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const apiUpdateBitbucket = createSchema.extend({
|
||||||
|
bitbucketUsername: z.string().optional(),
|
||||||
|
bitbucketWorkspaceName: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const apiUpdateGitlab = createSchema.extend({
|
||||||
|
applicationId: z.string().optional(),
|
||||||
|
secret: z.string().optional(),
|
||||||
|
groupName: z.string().optional(),
|
||||||
|
redirectUri: z.string().optional(),
|
||||||
|
});
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { spawnAsync } from "../process/spawnAsync";
|
|||||||
import type { InferResultType } from "@/server/types/with";
|
import type { InferResultType } from "@/server/types/with";
|
||||||
import { findBitbucketById } from "@/server/api/services/git-provider";
|
import { findBitbucketById } from "@/server/api/services/git-provider";
|
||||||
import type { Compose } from "@/server/api/services/compose";
|
import type { Compose } from "@/server/api/services/compose";
|
||||||
|
import type { apiFindBitbucketBranches } from "@/server/db/schema";
|
||||||
|
|
||||||
export type ApplicationWithBitbucket = InferResultType<
|
export type ApplicationWithBitbucket = InferResultType<
|
||||||
"applications",
|
"applications",
|
||||||
@@ -113,17 +114,11 @@ export const cloneRawBitbucketRepository = async (entity: Compose) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
interface GetBitbucketRepositories {
|
export const getBitbucketRepositories = async (bitbucketId?: string) => {
|
||||||
bitbucketId?: string;
|
if (!bitbucketId) {
|
||||||
}
|
|
||||||
|
|
||||||
export const getBitbucketRepositories = async (
|
|
||||||
input: GetBitbucketRepositories,
|
|
||||||
) => {
|
|
||||||
if (!input.bitbucketId) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const bitbucketProvider = await findBitbucketById(input.bitbucketId);
|
const bitbucketProvider = await findBitbucketById(bitbucketId);
|
||||||
|
|
||||||
const username =
|
const username =
|
||||||
bitbucketProvider.bitbucketWorkspaceName ||
|
bitbucketProvider.bitbucketWorkspaceName ||
|
||||||
@@ -169,13 +164,9 @@ export const getBitbucketRepositories = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
interface GetBitbucketBranches {
|
export const getBitbucketBranches = async (
|
||||||
owner: string;
|
input: typeof apiFindBitbucketBranches._type,
|
||||||
repo: string;
|
) => {
|
||||||
bitbucketId?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getBitbucketBranches = async (input: GetBitbucketBranches) => {
|
|
||||||
if (!input.bitbucketId) {
|
if (!input.bitbucketId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
type Github,
|
type Github,
|
||||||
} from "@/server/api/services/git-provider";
|
} from "@/server/api/services/git-provider";
|
||||||
import type { Compose } from "@/server/api/services/compose";
|
import type { Compose } from "@/server/api/services/compose";
|
||||||
|
import type { apiFindGithubBranches } from "@/server/db/schema";
|
||||||
|
|
||||||
export const authGithub = (githubProvider: Github) => {
|
export const authGithub = (githubProvider: Github) => {
|
||||||
if (!haveGithubRequirements(githubProvider)) {
|
if (!haveGithubRequirements(githubProvider)) {
|
||||||
@@ -176,16 +177,12 @@ export const cloneRawGithubRepository = async (entity: Compose) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
interface GetGithubRepositories {
|
export const getGithubRepositories = async (githubId?: string) => {
|
||||||
githubId?: string;
|
if (!githubId) {
|
||||||
}
|
|
||||||
|
|
||||||
export const getGithubRepositories = async (input: GetGithubRepositories) => {
|
|
||||||
if (!input.githubId) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const githubProvider = await findGithubById(input.githubId);
|
const githubProvider = await findGithubById(githubId);
|
||||||
|
|
||||||
const octokit = new Octokit({
|
const octokit = new Octokit({
|
||||||
authStrategy: createAppAuth,
|
authStrategy: createAppAuth,
|
||||||
@@ -205,13 +202,9 @@ export const getGithubRepositories = async (input: GetGithubRepositories) => {
|
|||||||
return repositories;
|
return repositories;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface GetGithubBranches {
|
export const getGithubBranches = async (
|
||||||
owner: string;
|
input: typeof apiFindGithubBranches._type,
|
||||||
repo: string;
|
) => {
|
||||||
githubId?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getGithubBranches = async (input: GetGithubBranches) => {
|
|
||||||
if (!input.githubId) {
|
if (!input.githubId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,16 +150,14 @@ export const cloneGitlabRepository = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getGitlabRepositories = async (input: {
|
export const getGitlabRepositories = async (gitlabId?: string) => {
|
||||||
gitlabId?: string;
|
if (!gitlabId) {
|
||||||
}) => {
|
|
||||||
if (!input.gitlabId) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
await refreshGitlabToken(input.gitlabId);
|
await refreshGitlabToken(gitlabId);
|
||||||
|
|
||||||
const gitlabProvider = await findGitlabById(input.gitlabId);
|
const gitlabProvider = await findGitlabById(gitlabId);
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://gitlab.com/api/v4/projects?membership=true&owned=true&page=${0}&per_page=${100}`,
|
`https://gitlab.com/api/v4/projects?membership=true&owned=true&page=${0}&per_page=${100}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user