Merge in from upstream and resolve conflicts

This commit is contained in:
Chad Curtis committed 2025-09-25 02:33:26 +00:00
commit 5e352e60e9
147 files changed
+10132 -3041

No files matched your search

+53 -5
View File
@@ -3,7 +3,6 @@ import JSZip from 'jszip';
import { Git } from '@/lib/git';
import type { JSRuntimeFS } from '@/lib/JSRuntime';
// Polyfill Buffer for browser
if (typeof window !== 'undefined') {
(window as { Buffer?: typeof Buffer }).Buffer = Buffer;
@@ -19,14 +18,19 @@ export interface Project {
lastModified: Date;
}
export interface ProjectsManagerOptions {
fs: JSRuntimeFS;
git: Git;
}
export class ProjectsManager {
fs: JSRuntimeFS;
git: Git;
dir: string;
constructor(fs: JSRuntimeFS) {
this.fs = fs;
this.git = new Git(fs, 'https://cors.isomorphic-git.org');
constructor(options: ProjectsManagerOptions) {
this.fs = options.fs;
this.git = options.git;
this.dir = '/projects';
}
@@ -281,7 +285,7 @@ export class ProjectsManager {
await this.fs.mkdir(projectPath);
// Clone the repository
// Clone the repository (Git class now handles Nostr URIs automatically)
await this.git.clone({
dir: projectPath,
url: repoUrl,
@@ -438,6 +442,50 @@ export class ProjectsManager {
await this.deleteDirectory(projectPath);
}
async renameProject(oldId: string, newId: string): Promise<Project> {
// Validate that the old project exists
const oldProject = await this.getProject(oldId);
if (!oldProject) {
throw new Error(`Project with ID "${oldId}" does not exist`);
}
// Validate that the new ID doesn't already exist
if (await this.projectExists(newId)) {
throw new Error(`Project with ID "${newId}" already exists`);
}
// Validate the new ID format (same rules as generateUniqueProjectId)
const validatedNewId = newId
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '');
if (validatedNewId !== newId) {
throw new Error(`Project name must contain only lowercase letters, numbers, and hyphens`);
}
if (!validatedNewId) {
throw new Error(`Project name cannot be empty`);
}
const oldPath = `${this.dir}/${oldId}`;
const newPath = `${this.dir}/${newId}`;
// Rename the directory
await this.fs.rename(oldPath, newPath);
// Return the updated project object
const stats = await this.fs.stat(newPath);
const timestamp = stats.mtimeMs ? new Date(stats.mtimeMs) : new Date();
return {
id: newId,
name: this.formatProjectName(newId),
path: newPath,
lastModified: timestamp,
};
}
private async deleteDirectory(dirPath: string): Promise<void> {
const files = await this.fs.readdir(dirPath);