Revert "Merge pull request #1335 from Toddyclipsgg/diff-view-v2"

This reverts commit 871aefbe83, reversing
changes made to 8c72ed76b3.
This commit is contained in:
KevIsDev
2025-02-21 15:01:09 +00:00
parent 871aefbe83
commit bffb8a2a90
16 changed files with 384 additions and 1357 deletions

View File

@@ -10,16 +10,18 @@ import { FilesStore, type FileMap } from './files';
import { PreviewsStore } from './previews';
import { TerminalStore } from './terminal';
import JSZip from 'jszip';
import pkg from 'file-saver';
const { saveAs } = pkg;
import fileSaver from 'file-saver';
import { Octokit, type RestEndpointMethodTypes } from '@octokit/rest';
import * as nodePath from 'node:path';
import { path } from '~/utils/path';
import { extractRelativePath } from '~/utils/diff';
import { description } from '~/lib/persistence';
import Cookies from 'js-cookie';
import { createSampler } from '~/utils/sampler';
import type { ActionAlert } from '~/types/actions';
// Destructure saveAs from the CommonJS module
const { saveAs } = fileSaver;
export interface ArtifactState {
id: string;
title: string;
@@ -32,7 +34,7 @@ export type ArtifactUpdateState = Pick<ArtifactState, 'title' | 'closed'>;
type Artifacts = MapStore<Record<string, ArtifactState>>;
export type WorkbenchViewType = 'code' | 'diff' | 'preview';
export type WorkbenchViewType = 'code' | 'preview';
export class WorkbenchStore {
#previewsStore = new PreviewsStore(webcontainer);
@@ -330,7 +332,7 @@ export class WorkbenchStore {
if (data.action.type === 'file') {
const wc = await webcontainer;
const fullPath = nodePath.join(wc.workdir, data.action.filePath);
const fullPath = path.join(wc.workdir, data.action.filePath);
if (this.selectedFile.value !== fullPath) {
this.setSelectedFile(fullPath);
@@ -435,7 +437,13 @@ export class WorkbenchStore {
return syncedFiles;
}
async pushToGitHub(repoName: string, commitMessage?: string, githubUsername?: string, ghToken?: string) {
async pushToGitHub(
repoName: string,
commitMessage?: string,
githubUsername?: string,
ghToken?: string,
isPrivate: boolean = false,
) {
try {
// Use cookies if username and token are not provided
const githubToken = ghToken || Cookies.get('githubToken');
@@ -459,7 +467,7 @@ export class WorkbenchStore {
// Repository doesn't exist, so create a new one
const { data: newRepo } = await octokit.repos.createForAuthenticatedUser({
name: repoName,
private: false,
private: isPrivate,
auto_init: true,
});
repo = newRepo;
@@ -537,7 +545,7 @@ export class WorkbenchStore {
sha: newCommit.sha,
});
alert(`Repository created and code pushed: ${repo.html_url}`);
return repo.html_url; // Return the URL instead of showing alert
} catch (error) {
console.error('Error pushing to GitHub:', error);
throw error; // Rethrow the error for further handling