made types optional and, workbench get repo fix

This commit is contained in:
Anirban Kar
2024-11-13 00:03:33 +05:30
parent 5f46a18fba
commit 32699fd809
2 changed files with 22 additions and 17 deletions

View File

@@ -11,7 +11,7 @@ import { PreviewsStore } from './previews';
import { TerminalStore } from './terminal';
import JSZip from 'jszip';
import { saveAs } from 'file-saver';
import { Octokit } from "@octokit/rest";
import { Octokit, type RestEndpointMethodTypes } from "@octokit/rest";
import * as nodePath from 'node:path';
import type { WebContainerProcess } from '@webcontainer/api';
@@ -382,9 +382,10 @@ export class WorkbenchStore {
const octokit = new Octokit({ auth: githubToken });
// Check if the repository already exists before creating it
let repo
let repo: RestEndpointMethodTypes["repos"]["get"]["response"]['data']
try {
repo = await octokit.repos.get({ owner: owner, repo: repoName });
let resp = await octokit.repos.get({ owner: owner, repo: repoName });
repo = resp.data
} catch (error) {
if (error instanceof Error && 'status' in error && error.status === 404) {
// Repository doesn't exist, so create a new one