From 61e03c94e35fa8cee58fa96cccb6e677a7d4257f Mon Sep 17 00:00:00 2001 From: Sstark97 Date: Wed, 30 Oct 2024 19:38:30 +0000 Subject: [PATCH] :green_heart: Remove monads dependency --- components/ui/textarea.tsx | 3 +-- package.json | 1 - pnpm-lock.yaml | 8 -------- src/backend/gitRepositoryManager.ts | 5 ++--- src/backend/repositoryManager.ts | 4 +--- src/backend/server.ts | 13 +++++-------- 6 files changed, 9 insertions(+), 25 deletions(-) diff --git a/components/ui/textarea.tsx b/components/ui/textarea.tsx index d1258e4..51e4e41 100644 --- a/components/ui/textarea.tsx +++ b/components/ui/textarea.tsx @@ -2,8 +2,7 @@ import * as React from "react" import { cn } from "@/lib/utils" -export interface TextareaProps - extends React.TextareaHTMLAttributes {} +export type TextareaProps = React.TextareaHTMLAttributes const Textarea = React.forwardRef( ({ className, ...props }, ref) => { diff --git a/package.json b/package.json index a0fcc22..f5c0e88 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "test": "vitest" }, "dependencies": { - "@leanmind/monads": "^1.2.0", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-slot": "^1.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 62e050f..bb612c5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,6 @@ importers: .: dependencies: - '@leanmind/monads': - specifier: ^1.2.0 - version: 1.2.0 '@radix-ui/react-icons': specifier: ^1.3.0 version: 1.3.0(react@18.3.1) @@ -392,9 +389,6 @@ packages: '@kwsites/promise-deferred@1.1.1': resolution: {integrity: sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==} - '@leanmind/monads@1.2.0': - resolution: {integrity: sha512-T4gEdJsEGZMiJuQ++/FTLMGDg1xwVjP6jEdyvuZZmyRopcVpzV03wbvAUs71s7ulJCDOjcjYNE6WATRvo75IYw==} - '@next/env@14.2.15': resolution: {integrity: sha512-S1qaj25Wru2dUpcIZMjxeMVSwkt8BK4dmWHHiBuRstcIyOsMapqT4A4jSB6onvqeygkSSmOkyny9VVx8JIGamQ==} @@ -2856,8 +2850,6 @@ snapshots: '@kwsites/promise-deferred@1.1.1': {} - '@leanmind/monads@1.2.0': {} - '@next/env@14.2.15': {} '@next/eslint-plugin-next@14.2.15': diff --git a/src/backend/gitRepositoryManager.ts b/src/backend/gitRepositoryManager.ts index c4da9b5..eb3d70c 100644 --- a/src/backend/gitRepositoryManager.ts +++ b/src/backend/gitRepositoryManager.ts @@ -1,7 +1,6 @@ import {RepositoryManager} from "@/src/backend/repositoryManager"; import simpleGit from "simple-git"; import {Octokit} from "octokit"; -import {Option} from "@leanmind/monads"; export class GitRepositoryManager implements RepositoryManager { async clone(url: string, path: string): Promise { @@ -20,10 +19,10 @@ export class GitRepositoryManager implements RepositoryManager { description: 'Descripción del repositorio', }); console.log('Repositorio creado con éxito:', response.data); - return Option.of(response.data.clone_url); + return response.data.clone_url; } catch (error) { console.error('Error al crear el repositorio:', error); - return Option.of(null); + throw error; } } diff --git a/src/backend/repositoryManager.ts b/src/backend/repositoryManager.ts index 0878204..47bfd9e 100644 --- a/src/backend/repositoryManager.ts +++ b/src/backend/repositoryManager.ts @@ -1,7 +1,5 @@ -import {Option} from "@leanmind/monads"; - export interface RepositoryManager { clone(url: string, path: string): Promise; push(repoPath: string, newRepoUrl: string): Promise; - createInRemote(repoName: string): Promise>; + createInRemote(repoName: string): Promise; } \ No newline at end of file diff --git a/src/backend/server.ts b/src/backend/server.ts index aaf815e..6a45f53 100644 --- a/src/backend/server.ts +++ b/src/backend/server.ts @@ -24,14 +24,11 @@ export async function execute(repos: string[], repositoryManager: RepositoryMana await cloneRepository(repoPath, repoName, repoUrl, repositoryManager); makeRepositoryAnonymous(repoPath, repoName); - const optionNewRepoUrl = await repositoryManager.createInRemote(`${repoName}-${uuidv4()}`); - if (optionNewRepoUrl.isSome()) { - const newRepoUrl = optionNewRepoUrl.getOrElse("") as string; - await repositoryManager.push(repoPath, newRepoUrl); - const newRepoDevUrl = createCodeSharingUrl(newRepoUrl); - console.log(`Redirigiendo a: ${newRepoDevUrl}`); - redirect(newRepoDevUrl); - } + const newRepoUrl = await repositoryManager.createInRemote(`${repoName}-${uuidv4()}`); + await repositoryManager.push(repoPath, newRepoUrl); + const newRepoDevUrl = createCodeSharingUrl(newRepoUrl); + console.log(`Redirigiendo a: ${newRepoDevUrl}`); + redirect(newRepoDevUrl); } async function cloneRepository(repoPath: string, repoName: string, repoUrl: string, repoCloner: RepositoryManager) {