@scriptdb/storage 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// TypeScript Sandbox Storage module\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { simpleGit, SimpleGit } from 'simple-git';\n\nexport interface GitConfig {\n userName?: string;\n userEmail?: string;\n options?: Record<string, string>;\n}\n\nexport interface RepoStatus {\n staged: string[];\n unstaged: string[];\n untracked: string[];\n clean: boolean;\n error?: string;\n}\n\nexport interface RemoteInfo {\n name: string;\n refs: string;\n pushUrl: string;\n}\n\nexport interface CommitHistory {\n hash: string;\n message: string;\n date: string;\n author: string;\n}\n\nexport class Storage {\n private repoPath: string;\n private gitRoot: string;\n private repo: SimpleGit | null = null;\n\n constructor(repoPath: string, gitRoot?: string) {\n this.repoPath = repoPath;\n this.gitRoot = gitRoot || repoPath; // Default to repoPath if gitRoot not specified\n }\n\n async initialize(repoPath: string | null = null): Promise<SimpleGit> {\n try {\n // Update repoPath if provided\n if (repoPath) {\n this.repoPath = repoPath;\n }\n \n // Create repository directory if it doesn't exist\n if (!fs.existsSync(this.repoPath)) {\n fs.mkdirSync(this.repoPath, { recursive: true });\n }\n\n // Initialize simple-git at gitRoot (not repoPath)\n this.repo = simpleGit(this.gitRoot);\n\n // Check if it's already a git repository at gitRoot\n if (!fs.existsSync(path.join(this.gitRoot, '.git'))) {\n // Initialize a new repository at gitRoot\n try {\n await this.repo.init();\n // Set up basic configuration\n await this.setupBasicConfig();\n } catch (error: any) {\n throw new Error(`Failed to initialize git repository: ${error.message}`);\n }\n }\n \n return this.repo;\n } catch (error: any) {\n throw new Error(`Failed to initialize repository: ${error.message}`);\n }\n }\n\n async addFile(filePath: string, content: string): Promise<{ success: boolean; message: string; path?: string }> {\n try {\n const fullPath = path.join(this.repoPath, filePath);\n const dir = path.dirname(fullPath);\n \n // Create directory if it doesn't exist\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n \n // Write file content\n fs.writeFileSync(fullPath, content);\n \n // Add file to git using relative path from gitRoot\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n const gitRelativePath = path.relative(this.gitRoot, fullPath);\n await this.repo.add(gitRelativePath);\n \n return {\n success: true,\n message: `File ${filePath} added successfully`,\n path: fullPath\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Failed to add file: ${error.message}`\n };\n }\n }\n\n async updateFile(filePath: string, content: string): Promise<{ success: boolean; message: string; path?: string }> {\n try {\n const fullPath = path.join(this.repoPath, filePath);\n \n if (!fs.existsSync(fullPath)) {\n return {\n success: false,\n message: `File ${filePath} does not exist`\n };\n }\n \n // Update file content\n fs.writeFileSync(fullPath, content);\n \n // Stage the changes using relative path from gitRoot\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n const gitRelativePath = path.relative(this.gitRoot, fullPath);\n await this.repo.add(gitRelativePath);\n \n return {\n success: true,\n message: `File ${filePath} updated successfully`,\n path: fullPath\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Failed to update file: ${error.message}`\n };\n }\n }\n\n async getFile(filePath: string): Promise<{ success: boolean; content?: string; path?: string; message?: string }> {\n try {\n const fullPath = path.join(this.repoPath, filePath);\n \n if (!fs.existsSync(fullPath)) {\n return {\n success: false,\n message: `File ${filePath} does not exist`\n };\n }\n \n const content = fs.readFileSync(fullPath, 'utf8');\n \n return {\n success: true,\n content: content,\n path: fullPath\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Failed to read file: ${error.message}`\n };\n }\n }\n\n async deleteFile(filePath: string): Promise<{ success: boolean; message: string }> {\n try {\n const fullPath = path.join(this.repoPath, filePath);\n \n if (!fs.existsSync(fullPath)) {\n return {\n success: false,\n message: `File ${filePath} does not exist`\n };\n }\n \n // Remove file\n fs.unlinkSync(fullPath);\n \n // Stage the deletion using relative path from gitRoot\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n const gitRelativePath = path.relative(this.gitRoot, fullPath);\n await this.repo.add(gitRelativePath);\n \n return {\n success: true,\n message: `File ${filePath} deleted successfully`\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Failed to delete file: ${error.message}`\n };\n }\n }\n\n async commit(message: string): Promise<{ success: boolean; message: string }> {\n try {\n // Check if there are staged changes\n const status = await this.getStatus();\n if (status.staged.length === 0) {\n return {\n success: false,\n message: 'No staged changes to commit'\n };\n }\n \n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n await this.repo.commit(message);\n \n return {\n success: true,\n message: 'Changes committed successfully'\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Failed to commit changes: ${error.message}`\n };\n }\n }\n\n async getStatus(): Promise<RepoStatus> {\n try {\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n \n const status = await this.repo.status();\n \n const staged: string[] = [];\n const unstaged: string[] = [];\n const untracked: string[] = [];\n \n // Process modified files\n status.modified.forEach(file => {\n unstaged.push(file);\n });\n \n // Process created files\n status.created.forEach(file => {\n staged.push(file);\n });\n \n // Process deleted files\n status.deleted.forEach(file => {\n unstaged.push(file);\n });\n \n // Process renamed files\n status.renamed.forEach(file => {\n staged.push(file.to);\n });\n \n // Process untracked files\n status.not_added.forEach(file => {\n untracked.push(file);\n });\n \n // Process staged files\n status.staged.forEach(file => {\n staged.push(file);\n });\n \n return {\n staged,\n unstaged,\n untracked,\n clean: status.isClean()\n };\n } catch (error: any) {\n return {\n staged: [],\n unstaged: [],\n untracked: [],\n clean: false,\n error: error.message\n };\n }\n }\n\n async getHistory(filePath: string): Promise<CommitHistory[]> {\n try {\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n \n const log = await this.repo.log({ file: filePath });\n \n return log.all.map(commit => ({\n hash: commit.hash.substring(0, 7),\n message: commit.message || '',\n date: commit.date || '',\n author: commit.author_name || ''\n }));\n } catch (error: any) {\n return [];\n }\n }\n\n /**\n * Set Git configuration values\n * @param config - Configuration object\n * @param scope - Configuration scope ('local', 'global', 'system')\n * @returns Result of the operation\n */\n async setConfig(config: GitConfig, scope: 'local' | 'global' | 'system' = 'local'): Promise<{ success: boolean; message: string; changes?: any[] }> {\n try {\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n \n const results: any[] = [];\n \n // Set user name if provided\n if (config.userName) {\n await this.repo.raw(['config', `--${scope}`, 'user.name', config.userName]);\n results.push({ key: 'user.name', value: config.userName, scope });\n }\n \n // Set user email if provided\n if (config.userEmail) {\n await this.repo.raw(['config', `--${scope}`, 'user.email', config.userEmail]);\n results.push({ key: 'user.email', value: config.userEmail, scope });\n }\n \n // Set additional options if provided\n if (config.options && typeof config.options === 'object') {\n for (const [key, value] of Object.entries(config.options)) {\n await this.repo.raw(['config', `--${scope}`, key, value]);\n results.push({ key, value, scope });\n }\n }\n \n return {\n success: true,\n message: `Configuration updated successfully`,\n changes: results\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Failed to set configuration: ${error.message}`\n };\n }\n }\n\n /**\n * Get Git configuration value\n * @param key - Configuration key (e.g., 'user.name')\n * @param scope - Configuration scope ('local', 'global', 'system')\n * @returns Result containing the configuration value\n */\n async getConfig(key: string, scope: 'local' | 'global' | 'system' = 'local'): Promise<{ success: boolean; key?: string; value?: string; scope?: string; message?: string }> {\n try {\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n \n const result = await this.repo.raw(['config', `--${scope}`, '--get', key]);\n \n return {\n success: true,\n key,\n value: result.trim(),\n scope\n };\n } catch (error: any) {\n // If the key doesn't exist, return a more helpful message\n if (error.message.includes('exit code: 1')) {\n return {\n success: false,\n message: `Configuration key '${key}' not found in ${scope} scope`\n };\n }\n \n return {\n success: false,\n message: `Failed to get configuration for ${key}: ${error.message}`\n };\n }\n }\n\n /**\n * Get all Git configuration values\n * @param scope - Configuration scope ('local', 'global', 'system')\n * @returns Result containing all configuration values\n */\n async listConfig(scope: 'local' | 'global' | 'system' = 'local'): Promise<{ success: boolean; scope: string; config?: any; message?: string }> {\n try {\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n \n const result = await this.repo.raw(['config', `--${scope}`, '--list']);\n const lines = result.trim().split('\\n');\n const config: any = {};\n \n lines.forEach(line => {\n const [key, value] = line.split('=');\n if (key) {\n config[key] = value || '';\n }\n });\n \n return {\n success: true,\n scope,\n config\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Failed to list configuration: ${error.message}`,\n scope\n };\n }\n }\n\n /**\n * Set up a basic configuration for the repository\n * @param userName - User name (optional, defaults to 'Sandbox Storage')\n * @param userEmail - User email (optional, defaults to 'sandbox@example.com')\n * @param additionalConfig - Additional configuration options (optional)\n * @returns Result of the operation\n */\n async setupBasicConfig(userName = 'Sandbox Storage', userEmail = 'sandbox@example.com', additionalConfig: Record<string, string> = {}): Promise<{ success: boolean; message: string }> {\n const config: GitConfig = {\n userName,\n userEmail,\n options: {\n 'core.autocrlf': 'false', // Important for cross-platform compatibility\n 'core.filemode': 'false', // Important for cross-platform compatibility\n ...additionalConfig\n }\n };\n \n return this.setConfig(config, 'local');\n }\n\n /**\n * Add a remote repository\n * @param name - Remote name (e.g., 'origin')\n * @param url - Remote repository URL\n * @returns Result of the operation\n */\n async addRemote(name: string, url: string): Promise<{ success: boolean; message: string; name?: string; url?: string }> {\n try {\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n \n await this.repo.addRemote(name, url);\n \n return {\n success: true,\n message: `Remote '${name}' added successfully`,\n name,\n url\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Failed to add remote '${name}': ${error.message}`\n };\n }\n }\n\n /**\n * Remove a remote repository\n * @param name - Remote name to remove\n * @returns Result of the operation\n */\n async removeRemote(name: string): Promise<{ success: boolean; message: string; name?: string }> {\n try {\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n \n await this.repo.removeRemote(name);\n \n return {\n success: true,\n message: `Remote '${name}' removed successfully`,\n name\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Failed to remove remote '${name}': ${error.message}`\n };\n }\n }\n\n /**\n * List all remote repositories\n * @returns Result containing the list of remotes\n */\n async listRemotes(): Promise<{ success: boolean; remotes: RemoteInfo[]; message?: string }> {\n try {\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n \n const remotes = await this.repo.getRemotes(true);\n \n return {\n success: true,\n remotes: remotes.map(remote => ({\n name: remote.name,\n refs: remote.refs.fetch,\n pushUrl: remote.refs.push\n }))\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Failed to list remotes: ${error.message}`,\n remotes: []\n };\n }\n }\n\n /**\n * Push changes to a remote repository\n * @param remote - Remote name (defaults to 'origin')\n * @param branch - Branch to push (defaults to current branch)\n * @param options - Additional options\n * @returns Result of the operation\n */\n async push(remote = 'origin', branch = 'main', options: { force?: boolean; setUpstream?: boolean } = {}): Promise<{ success: boolean; message: string; remote?: string; branch?: string }> {\n try {\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n \n // Check if remote exists\n const remotes = await this.listRemotes();\n const remoteExists = remotes.remotes.some(r => r.name === remote);\n \n if (!remoteExists) {\n return {\n success: false,\n message: `Remote '${remote}' does not exist`\n };\n }\n\n // Get current branch if branch not specified\n if (!branch || branch === 'current') {\n try {\n const status = await this.repo.status();\n branch = status.current || 'main';\n } catch {\n branch = 'main';\n }\n }\n\n // Prepare push options\n const pushOptions: any = {};\n \n if (options.force) {\n pushOptions['--force'] = null;\n }\n \n // For first push, set upstream\n if (options.setUpstream !== false) {\n pushOptions['-u'] = null;\n }\n\n // Execute push\n await this.repo.push(remote, branch, pushOptions);\n \n return {\n success: true,\n message: `Successfully pushed to ${remote}/${branch}`,\n remote,\n branch\n };\n } catch (error: any) {\n // Handle specific errors\n if (error.message.includes('could not find remote') || error.message.includes('does not appear to be a git repository')) {\n return {\n success: false,\n message: `Remote '${remote}' does not exist or is not a valid git repository`\n };\n }\n \n if (error.message.includes('authentication failed')) {\n return {\n success: false,\n message: `Authentication failed. Please check your credentials.`\n };\n }\n \n return {\n success: false,\n message: `Failed to push to ${remote}/${branch}: ${error.message}`\n };\n }\n }\n\n /**\n * Pull changes from a remote repository\n * @param remote - Remote name (defaults to 'origin')\n * @param branch - Branch to pull from (defaults to current branch)\n * @param options - Additional options\n * @returns Result of the operation\n */\n async pull(remote = 'origin', branch = 'main', options: { allowUnrelatedHistories?: boolean } = {}): Promise<{ success: boolean; message: string; remote?: string; branch?: string }> {\n try {\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n \n // Check if remote exists\n const remotes = await this.listRemotes();\n const remoteExists = remotes.remotes.some(r => r.name === remote);\n \n if (!remoteExists) {\n return {\n success: false,\n message: `Remote '${remote}' does not exist`\n };\n }\n\n // Get current branch if branch not specified\n if (!branch || branch === 'current') {\n try {\n const status = await this.repo.status();\n branch = status.current || 'main';\n } catch {\n branch = 'main';\n }\n }\n\n // Prepare pull options\n const pullOptions: any = [];\n \n if (options.allowUnrelatedHistories) {\n pullOptions.push('--allow-unrelated-histories');\n }\n\n // Execute pull\n await this.repo.pull(remote, branch, pullOptions);\n \n return {\n success: true,\n message: `Successfully pulled from ${remote}/${branch}`,\n remote,\n branch\n };\n } catch (error: any) {\n // Handle specific errors\n if (error.message.includes('could not find remote')) {\n return {\n success: false,\n message: `Remote '${remote}' does not exist`\n };\n }\n \n if (error.message.includes('authentication failed')) {\n return {\n success: false,\n message: `Authentication failed. Please check your credentials.`\n };\n }\n \n if (error.message.includes('conflict')) {\n return {\n success: false,\n message: `Merge conflict occurred. Please resolve conflicts manually.`\n };\n }\n \n return {\n success: false,\n message: `Failed to pull from ${remote}/${branch}: ${error.message}`\n };\n }\n }\n\n /**\n * Fetch changes from a remote repository without merging\n * @param remote - Remote name (defaults to 'origin')\n * @param branch - Branch to fetch (defaults to 'main')\n * @param options - Additional options\n * @returns Result of the operation\n */\n async fetch(remote = 'origin', branch = 'main', options: { prune?: boolean } = {}): Promise<{ success: boolean; message: string; remote?: string; branch?: string }> {\n try {\n if (!this.repo) {\n throw new Error('Repository not initialized. Call initialize() first.');\n }\n \n // Check if remote exists\n const remotes = await this.listRemotes();\n const remoteExists = remotes.remotes.some(r => r.name === remote);\n \n if (!remoteExists) {\n return {\n success: false,\n message: `Remote '${remote}' does not exist`\n };\n }\n\n // Prepare fetch options\n const fetchOptions: any = {};\n \n if (options.prune) {\n fetchOptions['--prune'] = null;\n }\n\n // Execute fetch\n await this.repo.fetch(remote, branch, fetchOptions);\n \n return {\n success: true,\n message: `Successfully fetched from ${remote}/${branch}`,\n remote,\n branch\n };\n } catch (error: any) {\n // Handle specific errors\n if (error.message.includes('could not find remote')) {\n return {\n success: false,\n message: `Remote '${remote}' does not exist`\n };\n }\n \n if (error.message.includes('authentication failed')) {\n return {\n success: false,\n message: `Authentication failed. Please check your credentials.`\n };\n }\n \n return {\n success: false,\n message: `Failed to fetch from ${remote}/${branch}: ${error.message}`\n };\n }\n }\n\n /**\n * Clone a remote repository\n * @param url - Repository URL to clone\n * @param targetPath - Directory to clone into (optional)\n * @param options - Additional options\n * @returns Result of the operation\n */\n async clone(url: string, targetPath: string | null = null, options: { bare?: boolean; branch?: string; depth?: number } = {}): Promise<{ success: boolean; message: string; url?: string; path?: string }> {\n try {\n // Use provided target path or the current repo path\n const clonePath = targetPath || this.repoPath;\n \n // Clone the repository using simple-git\n const cloneOptions: any = {};\n \n if (options.bare) {\n cloneOptions['--bare'] = null;\n }\n \n if (options.branch) {\n cloneOptions['--branch'] = options.branch;\n }\n \n if (options.depth) {\n cloneOptions['--depth'] = options.depth.toString();\n }\n \n // Use simple-git's clone method\n const git = simpleGit();\n await git.clone(url, clonePath, cloneOptions);\n \n // Update the repoPath if we used the default path\n if (!targetPath) {\n this.repoPath = clonePath;\n this.repo = simpleGit(clonePath);\n }\n \n return {\n success: true,\n message: `Repository cloned successfully from ${url}`,\n url,\n path: clonePath\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Failed to clone repository from ${url}: ${error.message}`\n };\n }\n }\n\n listFiles(): Promise<string[]> {\n return new Promise((resolve) => {\n try {\n const files: string[] = [];\n \n const traverse = (dir: string, relativePath = '') => {\n const items = fs.readdirSync(dir);\n \n items.forEach(item => {\n const itemPath = path.join(dir, item);\n const itemRelativePath = path.join(relativePath, item);\n \n if (fs.statSync(itemPath).isDirectory()) {\n traverse(itemPath, itemRelativePath);\n } else {\n files.push(itemRelativePath);\n }\n });\n };\n \n traverse(this.repoPath);\n \n // Filter out .git files\n resolve(files.filter(file => !file.startsWith('.git')));\n } catch (error) {\n resolve([]);\n }\n });\n }\n\n \n}\n\nexport default Storage;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AACpB,WAAsB;AACtB,wBAAqC;AA6B9B,IAAM,UAAN,MAAc;AAAA,EAKnB,YAAY,UAAkB,SAAkB;AAFhD,SAAQ,OAAyB;AAG/B,SAAK,WAAW;AAChB,SAAK,UAAU,WAAW;AAAA,EAC5B;AAAA,EAEA,MAAM,WAAW,WAA0B,MAA0B;AACnE,QAAI;AAEF,UAAI,UAAU;AACZ,aAAK,WAAW;AAAA,MAClB;AAGA,UAAI,CAAI,cAAW,KAAK,QAAQ,GAAG;AACjC,QAAG,aAAU,KAAK,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,MACjD;AAGA,WAAK,WAAO,6BAAU,KAAK,OAAO;AAGlC,UAAI,CAAI,cAAgB,UAAK,KAAK,SAAS,MAAM,CAAC,GAAG;AAEnD,YAAI;AACF,gBAAM,KAAK,KAAK,KAAK;AAErB,gBAAM,KAAK,iBAAiB;AAAA,QAC9B,SAAS,OAAY;AACnB,gBAAM,IAAI,MAAM,wCAAwC,MAAM,OAAO,EAAE;AAAA,QACzE;AAAA,MACF;AAEA,aAAO,K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