farseer-cli 1.0.8 → 1.0.9
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.
- package/dist/commands/app.js +349 -0
- package/dist/commands/app.js.map +7 -0
- package/dist/commands/apps.js +111 -0
- package/dist/commands/apps.js.map +7 -0
- package/dist/commands/checkout.js +142 -0
- package/dist/commands/checkout.js.map +7 -0
- package/dist/commands/config.js +139 -0
- package/dist/commands/config.js.map +7 -0
- package/dist/commands/diff.js +185 -0
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/dimensions.js +145 -0
- package/dist/commands/dimensions.js.map +7 -0
- package/dist/commands/files.js +99 -0
- package/dist/commands/files.js.map +7 -0
- package/dist/commands/install.js +79 -0
- package/dist/commands/install.js.map +7 -0
- package/dist/commands/list.js +92 -0
- package/dist/commands/list.js.map +7 -0
- package/dist/commands/login.js +134 -0
- package/dist/commands/login.js.map +7 -0
- package/dist/commands/logout.js +59 -0
- package/dist/commands/logout.js.map +7 -0
- package/dist/commands/mcp-server.js +41 -0
- package/dist/commands/mcp-server.js.map +7 -0
- package/dist/commands/model.js +189 -0
- package/dist/commands/model.js.map +7 -0
- package/dist/commands/pull.js +258 -0
- package/dist/commands/pull.js.map +7 -0
- package/dist/commands/push.js +213 -0
- package/dist/commands/push.js.map +7 -0
- package/dist/commands/run.js +288 -0
- package/dist/commands/run.js.map +7 -0
- package/dist/commands/status.js +155 -0
- package/dist/commands/status.js.map +7 -0
- package/dist/commands/variables.js +176 -0
- package/dist/commands/variables.js.map +7 -0
- package/dist/commands/whoami.js +63 -0
- package/dist/commands/whoami.js.map +7 -0
- package/dist/index.js +165 -0
- package/dist/index.js.map +7 -0
- package/dist/mcp/index.js +35 -0
- package/dist/mcp/index.js.map +7 -0
- package/dist/mcp/prompts/workflows.js +448 -0
- package/dist/mcp/prompts/workflows.js.map +7 -0
- package/dist/mcp/resources/documentation.js +167 -0
- package/dist/mcp/resources/documentation.js.map +7 -0
- package/dist/mcp/server.js +52 -0
- package/dist/mcp/server.js.map +7 -0
- package/dist/mcp/tools/appTools.js +377 -0
- package/dist/mcp/tools/appTools.js.map +7 -0
- package/dist/mcp/tools/authTools.js +159 -0
- package/dist/mcp/tools/authTools.js.map +7 -0
- package/dist/mcp/tools/dataTools.js +362 -0
- package/dist/mcp/tools/dataTools.js.map +7 -0
- package/dist/mcp/tools/modelTools.js +325 -0
- package/dist/mcp/tools/modelTools.js.map +7 -0
- package/dist/mcp/tools/runTools.js +233 -0
- package/dist/mcp/tools/runTools.js.map +7 -0
- package/dist/mcp/tools/syncTools.js +409 -0
- package/dist/mcp/tools/syncTools.js.map +7 -0
- package/dist/mcp/utils/helpers.js +135 -0
- package/dist/mcp/utils/helpers.js.map +7 -0
- package/dist/services/appSyncService.js +399 -0
- package/dist/services/appSyncService.js.map +7 -0
- package/dist/services/configService.js +196 -0
- package/dist/services/configService.js.map +7 -0
- package/dist/services/farseerApi.js +426 -0
- package/dist/services/farseerApi.js.map +7 -0
- package/dist/services/farseerFactory.js +231 -0
- package/dist/services/farseerFactory.js.map +7 -0
- package/dist/services/farseerService.js +614 -0
- package/dist/services/farseerService.js.map +7 -0
- package/dist/services/syncService.js +689 -0
- package/dist/services/syncService.js.map +7 -0
- package/dist/utils/constants.js +46 -0
- package/dist/utils/constants.js.map +7 -0
- package/dist/utils/helpers.js +413 -0
- package/dist/utils/helpers.js.map +7 -0
- package/dist/utils/logger.js +76 -0
- package/dist/utils/logger.js.map +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/services/syncService.ts"],
|
|
4
|
+
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { IFarseerClient, RemoteFile, DEFAULT_SCRIPT_EXTENSIONS } from './farseerFactory';\nimport { calculateHash, getTenantFilesDir, getSyncFilePath, ensureDirectoryExists, getAllFilesInDir, fetchWithConcurrency } from '../utils/helpers';\nimport { logger } from '../utils/logger';\n\nexport interface SyncFileInfo {\n localHash: string;\n remoteHash: string;\n metadata?: {\n uploadTime?: string;\n uploaderEmail?: string;\n uploaderName?: string;\n lastFetched?: string;\n };\n}\n\nexport interface SyncState {\n lastSync: string;\n files: Record<string, SyncFileInfo>;\n}\n\nexport interface SyncStatus {\n modifiedLocally: string[];\n modifiedRemotely: string[];\n onlyLocal: string[];\n onlyRemote: string[];\n inSync: string[];\n conflicts?: SyncConflict[];\n}\n\n// Three-way comparison types\n\nexport type FileChangeType =\n | 'unchanged'\n | 'local_modified'\n | 'remote_modified'\n | 'remote_deleted'\n | 'local_deleted'\n | 'local_new'\n | 'remote_new'\n | 'conflict_both_modified'\n | 'conflict_local_modified_remote_deleted'\n | 'conflict_local_deleted_remote_modified'\n | 'conflict_both_new';\n\nexport interface FileCompareResult {\n filePath: string;\n changeType: FileChangeType;\n currentLocalHash: string | null;\n currentRemoteHash: string | null;\n baselineLocalHash: string | null;\n baselineRemoteHash: string | null;\n}\n\nexport interface SyncConflict {\n filePath: string;\n type: 'both_modified' | 'local_modified_remote_deleted' | 'local_deleted_remote_modified' | 'both_new';\n description: string;\n}\n\nexport type ConflictResolution = 'keep_local' | 'keep_remote' | 'keep_both';\nexport type ConflictResolutions = Record<string, ConflictResolution>;\n\nexport class SyncService {\n private tenant: string;\n private farseerClient: IFarseerClient;\n\n constructor(tenant: string, farseerClient: IFarseerClient) {\n this.tenant = tenant;\n this.farseerClient = farseerClient;\n }\n\n loadSyncState(): SyncState {\n const syncFilePath = getSyncFilePath(this.tenant);\n\n if (!fs.existsSync(syncFilePath)) {\n return {\n lastSync: '',\n files: {},\n };\n }\n\n try {\n const content = fs.readFileSync(syncFilePath, 'utf-8');\n return JSON.parse(content) as SyncState;\n } catch {\n return {\n lastSync: '',\n files: {},\n };\n }\n }\n\n saveSyncState(state: SyncState): void {\n const syncFilePath = getSyncFilePath(this.tenant);\n ensureDirectoryExists(path.dirname(syncFilePath));\n fs.writeFileSync(syncFilePath, JSON.stringify(state, null, 2), 'utf-8');\n }\n\n /**\n * Fast status check that uses sync state instead of downloading remote file content.\n * This is much faster than getStatus() but may miss changes made by others since last pull.\n * Use this for push operations where we trust the sync state.\n */\n async getStatusFast(options?: { all?: boolean }): Promise<SyncStatus> {\n const syncState = this.loadSyncState();\n const filesDir = getTenantFilesDir(this.tenant);\n\n // Get local files\n let localFiles = getAllFilesInDir(filesDir);\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n localFiles = localFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.toLowerCase().endsWith(ext))\n );\n }\n\n // Get remote file list only (no content download)\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n remoteFiles = remoteFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.name.toLowerCase().endsWith(ext))\n );\n }\n\n const remoteFilePaths = new Set(remoteFiles.map(f => f.path));\n\n const status: SyncStatus = {\n modifiedLocally: [],\n modifiedRemotely: [],\n onlyLocal: [],\n onlyRemote: [],\n inSync: [],\n conflicts: [],\n };\n\n // Check local files\n for (const localFile of localFiles) {\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n const localHash = calculateHash(content);\n const syncInfo = syncState.files[localFile];\n\n if (remoteFilePaths.has(localFile)) {\n // File exists both locally and remotely\n if (syncInfo && localHash === syncInfo.localHash) {\n // Local file hasn't changed since last sync\n status.inSync.push(localFile);\n } else {\n // Local file changed (or no sync info)\n status.modifiedLocally.push(localFile);\n }\n } else {\n // File only exists locally\n if (syncInfo && syncInfo.remoteHash) {\n // Was synced before, deleted on remote\n if (localHash !== syncInfo.localHash) {\n // Local also modified - CONFLICT\n status.conflicts!.push({\n filePath: localFile,\n type: 'local_modified_remote_deleted',\n description: 'File modified locally but deleted on remote',\n });\n } else {\n // Local unchanged, safe to mark as remote change\n status.modifiedRemotely.push(localFile);\n }\n } else {\n status.onlyLocal.push(localFile);\n }\n }\n }\n\n // Check remote files that don't exist locally\n for (const remoteFile of remoteFiles) {\n if (!localFiles.includes(remoteFile.path)) {\n const syncInfo = syncState.files[remoteFile.path];\n if (syncInfo && syncInfo.localHash) {\n // Was synced before, deleted locally\n status.modifiedLocally.push(remoteFile.path);\n } else {\n status.onlyRemote.push(remoteFile.path);\n }\n }\n }\n\n return status;\n }\n\n async getStatus(options?: { all?: boolean }): Promise<SyncStatus> {\n const syncState = this.loadSyncState();\n const filesDir = getTenantFilesDir(this.tenant);\n\n // Get local files and their hashes\n let localFiles = getAllFilesInDir(filesDir);\n if (!options?.all) {\n localFiles = localFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.toLowerCase().endsWith(ext))\n );\n }\n\n const localHashes = new Map<string, string>();\n for (const file of localFiles) {\n const fullPath = path.join(filesDir, file);\n const content = fs.readFileSync(fullPath);\n localHashes.set(file, calculateHash(content));\n }\n\n // Get remote files and their hashes\n let remoteFiles = await this.farseerClient.listFiles();\n if (!options?.all) {\n remoteFiles = remoteFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.name.toLowerCase().endsWith(ext))\n );\n }\n\n const remoteHashes = new Map<string, string>();\n const fileContents = await fetchWithConcurrency(\n remoteFiles,\n async (file) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n return { path: file.path, hash: calculateHash(content) };\n },\n 15\n );\n for (const { path: filePath, hash } of fileContents) {\n remoteHashes.set(filePath, hash);\n }\n\n // Three-way comparison\n const comparisons = this.compareFiles({ localHashes, remoteHashes, syncState, all: options?.all });\n\n const status: SyncStatus = {\n modifiedLocally: [],\n modifiedRemotely: [],\n onlyLocal: [],\n onlyRemote: [],\n inSync: [],\n conflicts: [],\n };\n\n for (const c of comparisons) {\n switch (c.changeType) {\n case 'unchanged':\n status.inSync.push(c.filePath);\n break;\n case 'local_modified':\n status.modifiedLocally.push(c.filePath);\n break;\n case 'remote_modified':\n status.modifiedRemotely.push(c.filePath);\n break;\n case 'local_new':\n status.onlyLocal.push(c.filePath);\n break;\n case 'remote_new':\n status.onlyRemote.push(c.filePath);\n break;\n case 'remote_deleted':\n status.modifiedRemotely.push(c.filePath);\n break;\n case 'local_deleted':\n status.modifiedLocally.push(c.filePath);\n break;\n default:\n // All conflict types\n status.conflicts!.push(\n SyncService.buildConflicts([c])[0]\n );\n break;\n }\n }\n\n return status;\n }\n\n async pull(options?: {\n all?: boolean;\n force?: boolean;\n conflictResolutions?: ConflictResolutions;\n }): Promise<{\n downloaded: string[];\n deleted: string[];\n unchanged: string[];\n conflicts: SyncConflict[];\n conflictFilesWritten: string[];\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n ensureDirectoryExists(filesDir);\n\n const syncState = this.loadSyncState();\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n remoteFiles = remoteFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.name.toLowerCase().endsWith(ext))\n );\n }\n\n // Batch fetch metadata for all files\n remoteFiles = await this.fetchMetadataForFiles(remoteFiles);\n\n const result = {\n downloaded: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n conflicts: [] as SyncConflict[],\n conflictFilesWritten: [] as string[],\n };\n\n // Download file contents in parallel with concurrency limit\n logger.dim(`Fetching ${remoteFiles.length} files in parallel...`);\n const fileContents = await fetchWithConcurrency(\n remoteFiles,\n async (file, index) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n // Show progress every 10 files\n if ((index + 1) % 10 === 0 || index === remoteFiles.length - 1) {\n process.stdout.write(`\\r Progress: ${index + 1}/${remoteFiles.length} files`);\n }\n return { file, content };\n },\n 15\n );\n // Clear progress line\n if (remoteFiles.length > 0) {\n process.stdout.write('\\r' + ' '.repeat(50) + '\\r');\n }\n\n // Build remote content map with hashes\n const remoteContentMap = new Map<string, { file: RemoteFile; content: Buffer; hash: string }>();\n const remoteHashes = new Map<string, string>();\n for (const { file, content } of fileContents) {\n const hash = calculateHash(content);\n remoteContentMap.set(file.path, { file, content, hash });\n remoteHashes.set(file.path, hash);\n }\n\n // Build local hashes\n const localFiles = getAllFilesInDir(filesDir);\n const localHashes = new Map<string, string>();\n for (const localFile of localFiles) {\n if (!options?.all && !DEFAULT_SCRIPT_EXTENSIONS.some(ext => localFile.toLowerCase().endsWith(ext))) {\n continue;\n }\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n localHashes.set(localFile, calculateHash(content));\n }\n\n // Three-way comparison\n const comparisons = this.compareFiles({ localHashes, remoteHashes, syncState, all: options?.all });\n const resolutions = options?.conflictResolutions ?? {};\n\n for (const comparison of comparisons) {\n const { filePath, changeType } = comparison;\n const localPath = path.join(filesDir, filePath);\n const remoteInfo = remoteContentMap.get(filePath);\n\n switch (changeType) {\n case 'unchanged':\n case 'local_modified':\n case 'local_new':\n result.unchanged.push(filePath);\n // Update sync state for remote side if we have remote info\n if (remoteInfo) {\n const existingSync = syncState.files[filePath];\n if (existingSync) {\n existingSync.remoteHash = remoteInfo.hash;\n existingSync.metadata = this.buildMetadata(remoteInfo.file);\n }\n }\n break;\n\n case 'local_deleted':\n // Local deleted, remote unchanged - skip (push will handle)\n result.unchanged.push(filePath);\n break;\n\n case 'remote_modified':\n case 'remote_new':\n // Safe to write\n ensureDirectoryExists(path.dirname(localPath));\n fs.writeFileSync(localPath, remoteInfo!.content);\n result.downloaded.push(filePath);\n syncState.files[filePath] = {\n localHash: remoteInfo!.hash,\n remoteHash: remoteInfo!.hash,\n metadata: this.buildMetadata(remoteInfo!.file),\n };\n break;\n\n case 'remote_deleted':\n // Safe to delete (local is unchanged)\n if (fs.existsSync(localPath)) {\n fs.unlinkSync(localPath);\n }\n result.deleted.push(filePath);\n delete syncState.files[filePath];\n break;\n\n case 'conflict_both_modified':\n case 'conflict_local_modified_remote_deleted':\n case 'conflict_local_deleted_remote_modified':\n case 'conflict_both_new': {\n if (options?.force) {\n // Force: apply remote state\n if (remoteInfo) {\n ensureDirectoryExists(path.dirname(localPath));\n fs.writeFileSync(localPath, remoteInfo.content);\n result.downloaded.push(filePath);\n syncState.files[filePath] = {\n localHash: remoteInfo.hash,\n remoteHash: remoteInfo.hash,\n metadata: this.buildMetadata(remoteInfo.file),\n };\n } else {\n // Remote deleted, force means delete local\n if (fs.existsSync(localPath)) {\n fs.unlinkSync(localPath);\n result.deleted.push(filePath);\n }\n delete syncState.files[filePath];\n }\n break;\n }\n\n const resolution = resolutions[filePath];\n if (!resolution) {\n // No resolution provided - report conflict, skip file\n result.conflicts.push(SyncService.buildConflicts([comparison])[0]);\n break;\n }\n\n switch (resolution) {\n case 'keep_local':\n // Keep local as-is, update sync state to mark conflict resolved\n if (fs.existsSync(localPath)) {\n const localContent = fs.readFileSync(localPath);\n const localHash = calculateHash(localContent);\n syncState.files[filePath] = {\n localHash,\n remoteHash: comparison.currentRemoteHash ?? '',\n metadata: remoteInfo ? this.buildMetadata(remoteInfo.file) : undefined,\n };\n } else {\n // Local was deleted, user wants to keep that decision\n delete syncState.files[filePath];\n }\n result.unchanged.push(filePath);\n break;\n\n case 'keep_remote':\n if (remoteInfo) {\n ensureDirectoryExists(path.dirname(localPath));\n fs.writeFileSync(localPath, remoteInfo.content);\n result.downloaded.push(filePath);\n syncState.files[filePath] = {\n localHash: remoteInfo.hash,\n remoteHash: remoteInfo.hash,\n metadata: this.buildMetadata(remoteInfo.file),\n };\n } else {\n // Remote deleted\n if (fs.existsSync(localPath)) {\n fs.unlinkSync(localPath);\n result.deleted.push(filePath);\n }\n delete syncState.files[filePath];\n }\n break;\n\n case 'keep_both':\n if (remoteInfo) {\n // Write remote version as .remote file alongside local\n const ext = path.extname(filePath);\n const base = filePath.slice(0, -ext.length || undefined);\n const conflictFileName = `${base}.remote${ext}`;\n const conflictPath = path.join(filesDir, conflictFileName);\n ensureDirectoryExists(path.dirname(conflictPath));\n fs.writeFileSync(conflictPath, remoteInfo.content);\n result.conflictFilesWritten.push(conflictFileName);\n }\n // Keep local, update sync state\n if (fs.existsSync(localPath)) {\n const localContent = fs.readFileSync(localPath);\n const localHash = calculateHash(localContent);\n syncState.files[filePath] = {\n localHash,\n remoteHash: comparison.currentRemoteHash ?? '',\n metadata: remoteInfo ? this.buildMetadata(remoteInfo.file) : undefined,\n };\n }\n result.unchanged.push(filePath);\n break;\n }\n break;\n }\n }\n }\n\n syncState.lastSync = new Date().toISOString();\n this.saveSyncState(syncState);\n\n return result;\n }\n\n private buildMetadata(file: RemoteFile): SyncFileInfo['metadata'] {\n if (!file.metadata) return undefined;\n return {\n uploadTime: file.metadata.uploadTime,\n uploaderEmail: file.metadata.uploader?.email,\n uploaderName: file.metadata.uploader\n ? `${file.metadata.uploader.firstName} ${file.metadata.uploader.lastName}`.trim()\n : undefined,\n lastFetched: new Date().toISOString(),\n };\n }\n\n async push(options?: { force?: boolean }): Promise<{\n uploaded: string[];\n updated: string[];\n deleted: string[];\n unchanged: string[];\n conflicts: SyncConflict[];\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n const syncState = this.loadSyncState();\n\n const result = {\n uploaded: [] as string[],\n updated: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n conflicts: [] as SyncConflict[],\n };\n\n // Get current remote files (just the list, not content)\n const remoteFiles = await this.farseerClient.listFiles();\n const remoteFileMap = new Map<string, RemoteFile>();\n for (const file of remoteFiles) {\n remoteFileMap.set(file.path, file);\n }\n\n // Get local files and hashes\n const localFiles = getAllFilesInDir(filesDir);\n const localHashes = new Map<string, string>();\n const localContents = new Map<string, Buffer>();\n for (const localFile of localFiles) {\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n localHashes.set(localFile, calculateHash(content));\n localContents.set(localFile, content);\n }\n\n // Identify candidates that need remote content check for conflict detection\n const candidateFiles: string[] = [];\n for (const localFile of localFiles) {\n const syncInfo = syncState.files[localFile];\n const localHash = localHashes.get(localFile)!;\n if (!syncInfo || localHash !== syncInfo.localHash) {\n // Changed or new locally\n if (remoteFileMap.has(localFile)) {\n candidateFiles.push(localFile);\n }\n }\n }\n // Also check files in sync state that no longer exist locally (local deletions)\n const locallyDeletedFiles = Object.keys(syncState.files).filter(\n f => !localFiles.includes(f) && remoteFileMap.has(f)\n );\n const filesToFetchRemote = [...new Set([...candidateFiles, ...locallyDeletedFiles])];\n\n // Fetch remote content for conflict detection\n const remoteHashes = new Map<string, string>();\n if (filesToFetchRemote.length > 0 && !options?.force) {\n const toFetch = filesToFetchRemote\n .filter(f => remoteFileMap.has(f))\n .map(f => remoteFileMap.get(f)!);\n\n const fetched = await fetchWithConcurrency(toFetch, async (file) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n return { file, hash: calculateHash(content) };\n }, 15);\n\n for (const { file, hash } of fetched) {\n remoteHashes.set(file.path, hash);\n }\n }\n\n // Three-way comparison for conflict detection\n const comparisons = this.compareFiles({ localHashes, remoteHashes, syncState, all: true });\n const conflictPaths = new Set<string>();\n\n if (!options?.force) {\n for (const c of comparisons) {\n if (c.changeType.startsWith('conflict_')) {\n const conflict = SyncService.buildConflicts([c])[0];\n result.conflicts.push(conflict);\n conflictPaths.add(c.filePath);\n }\n }\n }\n\n // Process non-conflicting files\n for (const localFile of localFiles) {\n if (conflictPaths.has(localFile)) continue;\n\n const localPath = path.join(filesDir, localFile);\n const content = localContents.get(localFile)!;\n const localHash = localHashes.get(localFile)!;\n\n const remoteFile = remoteFileMap.get(localFile);\n const syncInfo = syncState.files[localFile];\n\n if (remoteFile) {\n // File exists on remote - check if local changed since last sync\n if (syncInfo && localHash === syncInfo.localHash) {\n result.unchanged.push(localFile);\n } else {\n // Local file changed - needs update\n await this.farseerClient.updateFile(remoteFile.reference, content, path.basename(localFile));\n result.updated.push(localFile);\n syncState.files[localFile] = {\n localHash: localHash,\n remoteHash: localHash,\n };\n }\n } else {\n // File doesn't exist on remote\n if (syncInfo && localHash === syncInfo.localHash) {\n // Local unchanged, was deleted on remote - skip (don't re-upload)\n result.unchanged.push(localFile);\n } else {\n // New or modified local file - upload\n const pathParts = localFile.split('/');\n const fileName = pathParts.pop()!;\n const folderPath = ['Files', ...pathParts];\n await this.farseerClient.createFile(content, fileName, folderPath);\n result.uploaded.push(localFile);\n syncState.files[localFile] = {\n localHash: localHash,\n remoteHash: localHash,\n };\n }\n }\n }\n\n // Delete files on remote that were deleted locally (non-conflicting only)\n const localFileSet = new Set(localFiles);\n for (const [remotePath, remoteFile] of remoteFileMap) {\n if (!localFileSet.has(remotePath) && !conflictPaths.has(remotePath)) {\n const syncInfo = syncState.files[remotePath];\n if (syncInfo) {\n // Was synced before, now deleted locally - delete on remote\n await this.farseerClient.deleteFile(remoteFile.reference);\n result.deleted.push(remotePath);\n delete syncState.files[remotePath];\n }\n }\n }\n\n syncState.lastSync = new Date().toISOString();\n this.saveSyncState(syncState);\n\n return result;\n }\n\n async checkRemoteChanges(): Promise<boolean> {\n const syncState = this.loadSyncState();\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only (same as pull/status) to avoid false positives\n // from non-script files like .json, .png, etc.\n remoteFiles = remoteFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.name.toLowerCase().endsWith(ext))\n );\n\n // Quick check: new files on remote that we don't have in sync state\n for (const file of remoteFiles) {\n const syncInfo = syncState.files[file.path];\n if (!syncInfo) {\n return true; // New file on remote\n }\n }\n\n // Quick check: files deleted on remote that we have in sync state\n for (const filePath of Object.keys(syncState.files)) {\n // Only check script files\n const isScript = DEFAULT_SCRIPT_EXTENSIONS.some(ext => filePath.toLowerCase().endsWith(ext));\n if (!isScript) continue;\n\n const exists = remoteFiles.some(f => f.path === filePath);\n if (!exists && syncState.files[filePath].remoteHash) {\n return true; // File was deleted on remote\n }\n }\n\n // Note: We don't check for content changes here anymore for performance.\n // After a pull, sync state is accurate. Content changes by others\n // between pull and push are a rare edge case - user should pull first.\n return false;\n }\n\n async getFileDiff(filePath: string): Promise<{\n localContent: string | null;\n remoteContent: string | null;\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n const localPath = path.join(filesDir, filePath);\n\n let localContent: string | null = null;\n let remoteContent: string | null = null;\n\n if (fs.existsSync(localPath)) {\n // For diff, read as text (diff only makes sense for text files)\n localContent = fs.readFileSync(localPath, 'utf-8');\n }\n\n const remoteFile = await this.farseerClient.getFileByPath(filePath);\n if (remoteFile) {\n remoteContent = await this.farseerClient.getFileContent(remoteFile.reference);\n }\n\n return { localContent, remoteContent };\n }\n\n /**\n * Three-way comparison of all files.\n * Compares current local state, current remote state, and baseline from sync state.\n */\n compareFiles(options: {\n localHashes: Map<string, string>;\n remoteHashes: Map<string, string>;\n syncState: SyncState;\n all?: boolean;\n }): FileCompareResult[] {\n const { localHashes, remoteHashes, syncState } = options;\n\n // Union of all known file paths\n const allPaths = new Set<string>([\n ...localHashes.keys(),\n ...remoteHashes.keys(),\n ...Object.keys(syncState.files),\n ]);\n\n const results: FileCompareResult[] = [];\n\n for (const filePath of allPaths) {\n // Filter non-script files unless --all\n if (!options.all) {\n if (!DEFAULT_SCRIPT_EXTENSIONS.some(ext => filePath.toLowerCase().endsWith(ext))) {\n continue;\n }\n }\n\n const currentLocalHash = localHashes.get(filePath) ?? null;\n const currentRemoteHash = remoteHashes.get(filePath) ?? null;\n const baseline = syncState.files[filePath];\n const baselineLocalHash = baseline?.localHash ?? null;\n const baselineRemoteHash = baseline?.remoteHash ?? null;\n\n const localExists = currentLocalHash !== null;\n const remoteExists = currentRemoteHash !== null;\n const hadBaseline = baseline != null;\n\n let changeType: FileChangeType;\n\n if (localExists && remoteExists) {\n // Both exist\n if (currentLocalHash === currentRemoteHash) {\n changeType = 'unchanged';\n } else if (!hadBaseline) {\n changeType = 'conflict_both_new';\n } else {\n const localChanged = currentLocalHash !== baselineLocalHash;\n const remoteChanged = currentRemoteHash !== baselineRemoteHash;\n\n if (localChanged && remoteChanged) {\n changeType = 'conflict_both_modified';\n } else if (localChanged) {\n changeType = 'local_modified';\n } else if (remoteChanged) {\n changeType = 'remote_modified';\n } else {\n changeType = 'unchanged';\n }\n }\n } else if (localExists && !remoteExists) {\n // Only local exists\n if (!hadBaseline) {\n changeType = 'local_new';\n } else {\n const localChanged = currentLocalHash !== baselineLocalHash;\n if (localChanged) {\n changeType = 'conflict_local_modified_remote_deleted';\n } else {\n changeType = 'remote_deleted';\n }\n }\n } else if (!localExists && remoteExists) {\n // Only remote exists\n if (!hadBaseline) {\n changeType = 'remote_new';\n } else {\n const remoteChanged = currentRemoteHash !== baselineRemoteHash;\n if (remoteChanged) {\n changeType = 'conflict_local_deleted_remote_modified';\n } else {\n changeType = 'local_deleted';\n }\n }\n } else {\n // Neither exists - both deleted since baseline, clean up\n continue;\n }\n\n results.push({\n filePath,\n changeType,\n currentLocalHash,\n currentRemoteHash,\n baselineLocalHash,\n baselineRemoteHash,\n });\n }\n\n return results;\n }\n\n /**\n * Extract SyncConflict[] from FileCompareResult[].\n */\n static buildConflicts(comparisons: FileCompareResult[]): SyncConflict[] {\n const conflicts: SyncConflict[] = [];\n for (const c of comparisons) {\n switch (c.changeType) {\n case 'conflict_both_modified':\n conflicts.push({\n filePath: c.filePath,\n type: 'both_modified',\n description: 'Both local and remote versions modified since last sync',\n });\n break;\n case 'conflict_local_modified_remote_deleted':\n conflicts.push({\n filePath: c.filePath,\n type: 'local_modified_remote_deleted',\n description: 'File modified locally but deleted on remote',\n });\n break;\n case 'conflict_local_deleted_remote_modified':\n conflicts.push({\n filePath: c.filePath,\n type: 'local_deleted_remote_modified',\n description: 'File deleted locally but modified on remote',\n });\n break;\n case 'conflict_both_new':\n conflicts.push({\n filePath: c.filePath,\n type: 'both_new',\n description: 'File exists both locally and remotely with different content (no sync baseline)',\n });\n break;\n }\n }\n return conflicts;\n }\n\n /**\n * Batch fetch metadata for multiple files in parallel.\n * Fetches metadata in batches of 10 to avoid overwhelming the API.\n * Non-critical operation - failures are silently ignored.\n */\n private async fetchMetadataForFiles(files: RemoteFile[]): Promise<RemoteFile[]> {\n const batchSize = 10;\n\n for (let i = 0; i < files.length; i += batchSize) {\n const batch = files.slice(i, i + batchSize);\n\n await Promise.all(batch.map(async (file) => {\n try {\n const metadata = await this.farseerClient.getFileMetadata(file.reference);\n if (metadata) {\n file.metadata = metadata;\n }\n } catch {\n // Silently ignore metadata fetch errors - non-critical\n }\n }));\n }\n\n return files;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,4BAAsE;AACtE,qBAAiI;AACjI,oBAAuB;AA4DhB,MAAM,YAAY;AAAA,EAIrB,YAAY,QAAgB,eAA+B;AACvD,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACzB;AAAA,EAEA,gBAA2B;AACvB,UAAM,mBAAe,gCAAgB,KAAK,MAAM;AAEhD,QAAI,CAAC,GAAG,WAAW,YAAY,GAAG;AAC9B,aAAO;AAAA,QACH,UAAU;AAAA,QACV,OAAO,CAAC;AAAA,MACZ;AAAA,IACJ;AAEA,QAAI;AACA,YAAM,UAAU,GAAG,aAAa,cAAc,OAAO;AACrD,aAAO,KAAK,MAAM,OAAO;AAAA,IAC7B,QAAQ;AACJ,aAAO;AAAA,QACH,UAAU;AAAA,QACV,OAAO,CAAC;AAAA,MACZ;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,cAAc,OAAwB;AAClC,UAAM,mBAAe,gCAAgB,KAAK,MAAM;AAChD,8CAAsB,KAAK,QAAQ,YAAY,CAAC;AAChD,OAAG,cAAc,cAAc,KAAK,UAAU,OAAO,MAAM,CAAC,GAAG,OAAO;AAAA,EAC1E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAc,SAAkD;AAClE,UAAM,YAAY,KAAK,cAAc;AACrC,UAAM,eAAW,kCAAkB,KAAK,MAAM;AAG9C,QAAI,iBAAa,iCAAiB,QAAQ;AAG1C,QAAI,CAAC,SAAS,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AAC;AAAA,IACN;AAEA,WAAO;AAAA,EACX;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var constants_exports = {};
|
|
19
|
+
__export(constants_exports, {
|
|
20
|
+
CLI_VERSION: () => CLI_VERSION,
|
|
21
|
+
FARSEER_CLIENT_AXIOS_URL: () => FARSEER_CLIENT_AXIOS_URL,
|
|
22
|
+
FARSEER_CLIENT_URL: () => FARSEER_CLIENT_URL,
|
|
23
|
+
KEYCLOAK_CLIENT_ID: () => KEYCLOAK_CLIENT_ID,
|
|
24
|
+
KEYCLOAK_TOKEN_URL: () => KEYCLOAK_TOKEN_URL,
|
|
25
|
+
SCRIPTS_FOLDER_PATH: () => SCRIPTS_FOLDER_PATH,
|
|
26
|
+
SCRIPT_EXTENSIONS: () => SCRIPT_EXTENSIONS
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(constants_exports);
|
|
29
|
+
const CLI_VERSION = "1.0.9";
|
|
30
|
+
const FARSEER_CLIENT_URL = "https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar";
|
|
31
|
+
const FARSEER_CLIENT_AXIOS_URL = "https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client-axios/6898c0cb-5dca-4b2f-b325-119efc7f099e/v1.0.1.tar";
|
|
32
|
+
const KEYCLOAK_TOKEN_URL = "https://login.farseer.io/auth/realms/master/protocol/openid-connect/token";
|
|
33
|
+
const KEYCLOAK_CLIENT_ID = "security-admin-console";
|
|
34
|
+
const SCRIPTS_FOLDER_PATH = ["Files", "Scripts"];
|
|
35
|
+
const SCRIPT_EXTENSIONS = [".ts", ".js", ".mjs", ".cjs"];
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
CLI_VERSION,
|
|
39
|
+
FARSEER_CLIENT_AXIOS_URL,
|
|
40
|
+
FARSEER_CLIENT_URL,
|
|
41
|
+
KEYCLOAK_CLIENT_ID,
|
|
42
|
+
KEYCLOAK_TOKEN_URL,
|
|
43
|
+
SCRIPTS_FOLDER_PATH,
|
|
44
|
+
SCRIPT_EXTENSIONS
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/constants.ts"],
|
|
4
|
+
"sourcesContent": ["// CLI version - update this when publishing new version\nexport const CLI_VERSION = '1.0.9';\n\n// Farseer client package URLs - update these when new versions are released\nexport const FARSEER_CLIENT_URL = 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar';\nexport const FARSEER_CLIENT_AXIOS_URL = 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client-axios/6898c0cb-5dca-4b2f-b325-119efc7f099e/v1.0.1.tar';\n\n// Keycloak auth configuration\nexport const KEYCLOAK_TOKEN_URL = 'https://login.farseer.io/auth/realms/master/protocol/openid-connect/token';\nexport const KEYCLOAK_CLIENT_ID = 'security-admin-console';\n\n// Default paths\nexport const SCRIPTS_FOLDER_PATH = ['Files', 'Scripts'];\n\n// Supported script file extensions\nexport const SCRIPT_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,MAAM,cAAc;AAGpB,MAAM,qBAAqB;AAC3B,MAAM,2BAA2B;AAGjC,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAG3B,MAAM,sBAAsB,CAAC,SAAS,SAAS;AAG/C,MAAM,oBAAoB,CAAC,OAAO,OAAO,QAAQ,MAAM;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var helpers_exports = {};
|
|
29
|
+
__export(helpers_exports, {
|
|
30
|
+
appendToAuditLog: () => appendToAuditLog,
|
|
31
|
+
calculateHash: () => calculateHash,
|
|
32
|
+
ensureDirectoryExists: () => ensureDirectoryExists,
|
|
33
|
+
fetchWithConcurrency: () => fetchWithConcurrency,
|
|
34
|
+
formatDate: () => formatDate,
|
|
35
|
+
formatFileSize: () => formatFileSize,
|
|
36
|
+
getAllFiles: () => getAllFiles,
|
|
37
|
+
getAllFilesInDir: () => getAllFilesInDir,
|
|
38
|
+
getAppsDir: () => getAppsDir,
|
|
39
|
+
getAuditLogPath: () => getAuditLogPath,
|
|
40
|
+
getCredentialsHint: () => getCredentialsHint,
|
|
41
|
+
getRelativePath: () => getRelativePath,
|
|
42
|
+
getSyncFilePath: () => getSyncFilePath,
|
|
43
|
+
getTenantAppsDir: () => getTenantAppsDir,
|
|
44
|
+
getTenantDir: () => getTenantDir,
|
|
45
|
+
getTenantFilesDir: () => getTenantFilesDir,
|
|
46
|
+
getTenantSrcDir: () => getTenantSrcDir,
|
|
47
|
+
hasEmptyFarseerClient: () => hasEmptyFarseerClient,
|
|
48
|
+
hasInjectedCredentials: () => hasInjectedCredentials,
|
|
49
|
+
injectCredentials: () => injectCredentials,
|
|
50
|
+
injectCredentialsInDir: () => injectCredentialsInDir,
|
|
51
|
+
isKnownTenant: () => isKnownTenant,
|
|
52
|
+
isScriptFile: () => isScriptFile,
|
|
53
|
+
isTextFile: () => isTextFile,
|
|
54
|
+
parseAppArgs: () => parseAppArgs,
|
|
55
|
+
resolveOrgAndTenant: () => resolveOrgAndTenant,
|
|
56
|
+
resolveOrgAndTenantOrExit: () => resolveOrgAndTenantOrExit,
|
|
57
|
+
resolveTenant: () => resolveTenant,
|
|
58
|
+
resolveTenantOrExit: () => resolveTenantOrExit,
|
|
59
|
+
resolveTenantWithOrgMapping: () => resolveTenantWithOrgMapping,
|
|
60
|
+
stripCredentials: () => stripCredentials,
|
|
61
|
+
stripCredentialsInDir: () => stripCredentialsInDir
|
|
62
|
+
});
|
|
63
|
+
module.exports = __toCommonJS(helpers_exports);
|
|
64
|
+
var crypto = __toESM(require("crypto"));
|
|
65
|
+
var path = __toESM(require("path"));
|
|
66
|
+
var fs = __toESM(require("fs"));
|
|
67
|
+
var import_configService = require("../services/configService");
|
|
68
|
+
var import_logger = require("./logger");
|
|
69
|
+
function calculateHash(content) {
|
|
70
|
+
return crypto.createHash("md5").update(content).digest("hex");
|
|
71
|
+
}
|
|
72
|
+
function getAppsDir() {
|
|
73
|
+
return path.join(process.cwd(), "farseer-apps");
|
|
74
|
+
}
|
|
75
|
+
function getTenantDir(tenant) {
|
|
76
|
+
return path.join(getAppsDir(), tenant);
|
|
77
|
+
}
|
|
78
|
+
function getTenantFilesDir(tenant) {
|
|
79
|
+
return path.join(getTenantDir(tenant), "files");
|
|
80
|
+
}
|
|
81
|
+
function getTenantSrcDir(tenant) {
|
|
82
|
+
return path.join(getTenantFilesDir(tenant), "Scripts");
|
|
83
|
+
}
|
|
84
|
+
function getSyncFilePath(tenant) {
|
|
85
|
+
return path.join(getTenantDir(tenant), ".farseer-sync.json");
|
|
86
|
+
}
|
|
87
|
+
function getAuditLogPath(tenant) {
|
|
88
|
+
return path.join(getTenantDir(tenant), ".farseer-audit.log");
|
|
89
|
+
}
|
|
90
|
+
function getTenantAppsDir(tenant) {
|
|
91
|
+
return path.join(getTenantDir(tenant), "apps");
|
|
92
|
+
}
|
|
93
|
+
function ensureDirectoryExists(dirPath) {
|
|
94
|
+
if (!fs.existsSync(dirPath)) {
|
|
95
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function getRelativePath(fullPath, basePath) {
|
|
99
|
+
return path.relative(basePath, fullPath);
|
|
100
|
+
}
|
|
101
|
+
function getAllFiles(dirPath, basePath) {
|
|
102
|
+
if (!fs.existsSync(dirPath)) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
const base = basePath || dirPath;
|
|
106
|
+
const files = [];
|
|
107
|
+
const items = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
108
|
+
for (const item of items) {
|
|
109
|
+
const fullPath = path.join(dirPath, item.name);
|
|
110
|
+
if (item.isDirectory()) {
|
|
111
|
+
files.push(...getAllFiles(fullPath, base));
|
|
112
|
+
} else if (item.isFile() && isScriptFile(item.name)) {
|
|
113
|
+
files.push(getRelativePath(fullPath, base));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return files;
|
|
117
|
+
}
|
|
118
|
+
function getAllFilesInDir(dirPath, basePath) {
|
|
119
|
+
if (!fs.existsSync(dirPath)) {
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
const base = basePath || dirPath;
|
|
123
|
+
const files = [];
|
|
124
|
+
const items = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
125
|
+
for (const item of items) {
|
|
126
|
+
const fullPath = path.join(dirPath, item.name);
|
|
127
|
+
if (item.isDirectory()) {
|
|
128
|
+
files.push(...getAllFilesInDir(fullPath, base));
|
|
129
|
+
} else if (item.isFile()) {
|
|
130
|
+
files.push(getRelativePath(fullPath, base));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return files;
|
|
134
|
+
}
|
|
135
|
+
function isScriptFile(filename) {
|
|
136
|
+
const ext = path.extname(filename).toLowerCase();
|
|
137
|
+
return [".ts", ".js", ".mjs", ".cjs"].includes(ext);
|
|
138
|
+
}
|
|
139
|
+
function isTextFile(filename) {
|
|
140
|
+
const ext = path.extname(filename).toLowerCase().slice(1);
|
|
141
|
+
return ["ts", "js", "mjs", "cjs", "json", "txt", "md", "csv", "xml", "html", "css", "yaml", "yml"].includes(ext);
|
|
142
|
+
}
|
|
143
|
+
function formatFileSize(bytes) {
|
|
144
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
145
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
146
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
147
|
+
}
|
|
148
|
+
function formatDate(date) {
|
|
149
|
+
const d = typeof date === "string" ? new Date(date) : date;
|
|
150
|
+
return d.toLocaleString();
|
|
151
|
+
}
|
|
152
|
+
function getCredentialsHint(tenant) {
|
|
153
|
+
return `Use: farseer login
|
|
154
|
+
Or: farseer config set ${tenant} --api-key <key> --org <organisation>`;
|
|
155
|
+
}
|
|
156
|
+
function resolveOrgAndTenant(tenantArg) {
|
|
157
|
+
if (tenantArg) {
|
|
158
|
+
return { organisation: tenantArg, tenant: tenantArg };
|
|
159
|
+
}
|
|
160
|
+
const checkout = (0, import_configService.getCurrentCheckout)();
|
|
161
|
+
if (checkout) {
|
|
162
|
+
if (checkout.organisation === checkout.tenant) {
|
|
163
|
+
import_logger.logger.dim(`Using checked-out tenant: ${checkout.tenant}`);
|
|
164
|
+
} else {
|
|
165
|
+
import_logger.logger.dim(`Using checked-out tenant: ${checkout.tenant} (org: ${checkout.organisation})`);
|
|
166
|
+
}
|
|
167
|
+
return checkout;
|
|
168
|
+
}
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
function resolveTenant(tenantArg) {
|
|
172
|
+
const resolved = resolveOrgAndTenant(tenantArg);
|
|
173
|
+
return resolved?.tenant || null;
|
|
174
|
+
}
|
|
175
|
+
function resolveTenantOrExit(tenantArg) {
|
|
176
|
+
const tenant = resolveTenant(tenantArg);
|
|
177
|
+
if (!tenant) {
|
|
178
|
+
import_logger.logger.error("No tenant specified.");
|
|
179
|
+
import_logger.logger.dim("Either specify a tenant: farseer <command> <tenant>");
|
|
180
|
+
import_logger.logger.dim("Or checkout a tenant: farseer checkout <tenant>");
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
return tenant;
|
|
184
|
+
}
|
|
185
|
+
function resolveTenantWithOrgMapping(arg1, arg2) {
|
|
186
|
+
if (arg1 && arg2) {
|
|
187
|
+
const org = arg1;
|
|
188
|
+
const tenant = arg2;
|
|
189
|
+
(0, import_configService.saveTenantOrgMapping)(tenant, org);
|
|
190
|
+
if (org === tenant) {
|
|
191
|
+
import_logger.logger.dim(`Using tenant: ${tenant}`);
|
|
192
|
+
} else {
|
|
193
|
+
import_logger.logger.dim(`Using tenant: ${tenant} (org: ${org})`);
|
|
194
|
+
}
|
|
195
|
+
return { organisation: org, tenant };
|
|
196
|
+
}
|
|
197
|
+
if (arg1) {
|
|
198
|
+
const tenant = arg1;
|
|
199
|
+
const savedOrg = (0, import_configService.getTenantOrg)(tenant);
|
|
200
|
+
if (savedOrg) {
|
|
201
|
+
if (savedOrg === tenant) {
|
|
202
|
+
import_logger.logger.dim(`Using tenant: ${tenant} (from saved mapping)`);
|
|
203
|
+
} else {
|
|
204
|
+
import_logger.logger.dim(`Using tenant: ${tenant} (org: ${savedOrg}, from saved mapping)`);
|
|
205
|
+
}
|
|
206
|
+
return { organisation: savedOrg, tenant };
|
|
207
|
+
}
|
|
208
|
+
import_logger.logger.error(`Organisation unknown for tenant "${tenant}".`);
|
|
209
|
+
import_logger.logger.dim("Please specify both organisation and tenant:");
|
|
210
|
+
import_logger.logger.dim(` farseer <command> <organisation> <tenant>`);
|
|
211
|
+
import_logger.logger.dim(` Example: farseer pull jgl tt-hotels-hr-dev`);
|
|
212
|
+
import_logger.logger.dim("");
|
|
213
|
+
import_logger.logger.dim("Or checkout the tenant first:");
|
|
214
|
+
import_logger.logger.dim(` farseer checkout <organisation> <tenant>`);
|
|
215
|
+
process.exit(1);
|
|
216
|
+
}
|
|
217
|
+
const checkout = (0, import_configService.getCurrentCheckout)();
|
|
218
|
+
if (checkout) {
|
|
219
|
+
if (checkout.organisation === checkout.tenant) {
|
|
220
|
+
import_logger.logger.dim(`Using checked-out tenant: ${checkout.tenant}`);
|
|
221
|
+
} else {
|
|
222
|
+
import_logger.logger.dim(`Using checked-out tenant: ${checkout.tenant} (org: ${checkout.organisation})`);
|
|
223
|
+
}
|
|
224
|
+
return checkout;
|
|
225
|
+
}
|
|
226
|
+
import_logger.logger.error("No tenant specified.");
|
|
227
|
+
import_logger.logger.dim("Either specify organisation and tenant: farseer <command> <org> <tenant>");
|
|
228
|
+
import_logger.logger.dim("Or checkout a tenant: farseer checkout <org> <tenant>");
|
|
229
|
+
process.exit(1);
|
|
230
|
+
}
|
|
231
|
+
function resolveOrgAndTenantOrExit(tenantArg) {
|
|
232
|
+
const resolved = resolveOrgAndTenant(tenantArg);
|
|
233
|
+
if (!resolved) {
|
|
234
|
+
import_logger.logger.error("No tenant specified.");
|
|
235
|
+
import_logger.logger.dim("Either specify a tenant: farseer <command> <tenant>");
|
|
236
|
+
import_logger.logger.dim("Or checkout a tenant: farseer checkout <tenant>");
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
239
|
+
return resolved;
|
|
240
|
+
}
|
|
241
|
+
function isKnownTenant(name) {
|
|
242
|
+
const { getCredential } = require("../services/configService");
|
|
243
|
+
return !!getCredential(name);
|
|
244
|
+
}
|
|
245
|
+
function parseAppArgs(args) {
|
|
246
|
+
if (args.length === 0) {
|
|
247
|
+
import_logger.logger.error("App name is required.");
|
|
248
|
+
process.exit(1);
|
|
249
|
+
}
|
|
250
|
+
if (args.length >= 2 && isKnownTenant(args[0])) {
|
|
251
|
+
return {
|
|
252
|
+
organisation: args[0],
|
|
253
|
+
tenant: args[0],
|
|
254
|
+
appName: args.slice(1).join(" ")
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
const checkout = (0, import_configService.getCurrentCheckout)();
|
|
258
|
+
if (checkout) {
|
|
259
|
+
if (checkout.organisation === checkout.tenant) {
|
|
260
|
+
import_logger.logger.dim(`Using checked-out tenant: ${checkout.tenant}`);
|
|
261
|
+
} else {
|
|
262
|
+
import_logger.logger.dim(`Using checked-out tenant: ${checkout.tenant} (org: ${checkout.organisation})`);
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
organisation: checkout.organisation,
|
|
266
|
+
tenant: checkout.tenant,
|
|
267
|
+
appName: args.join(" ")
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
if (args.length >= 2) {
|
|
271
|
+
return {
|
|
272
|
+
organisation: args[0],
|
|
273
|
+
tenant: args[0],
|
|
274
|
+
appName: args.slice(1).join(" ")
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
import_logger.logger.error("No tenant specified.");
|
|
278
|
+
import_logger.logger.dim("Either specify a tenant: farseer app show <tenant> <app-name>");
|
|
279
|
+
import_logger.logger.dim("Or checkout a tenant: farseer checkout <tenant>");
|
|
280
|
+
process.exit(1);
|
|
281
|
+
}
|
|
282
|
+
const EMPTY_CLIENT_PATTERNS = [
|
|
283
|
+
/const farseerClient = new farseer\.FarseerClient\(\s*\);/,
|
|
284
|
+
/const fClient = new farseer\.FarseerClient\(\s*\);/
|
|
285
|
+
];
|
|
286
|
+
const INJECTED_CLIENT_PATTERN = /const (farseerClient|fClient) = new farseer\.FarseerClient\(\{[\s\S]*?basePath:[\s\S]*?headers:[\s\S]*?'X-TENANT-ID':[\s\S]*?'X-API-KEY':[\s\S]*?\}\);/;
|
|
287
|
+
function injectCredentials(code, credential) {
|
|
288
|
+
const clientConfig = `{
|
|
289
|
+
basePath: '${credential.basePath}',
|
|
290
|
+
headers: {
|
|
291
|
+
'X-TENANT-ID': '${credential.tenantId}',
|
|
292
|
+
'X-API-KEY': '${credential.apiKey}',
|
|
293
|
+
}
|
|
294
|
+
}`;
|
|
295
|
+
let modified = code;
|
|
296
|
+
modified = modified.replace(
|
|
297
|
+
/const farseerClient = new farseer\.FarseerClient\(\s*\);/g,
|
|
298
|
+
`const farseerClient = new farseer.FarseerClient(${clientConfig});`
|
|
299
|
+
);
|
|
300
|
+
modified = modified.replace(
|
|
301
|
+
/const fClient = new farseer\.FarseerClient\(\s*\);/g,
|
|
302
|
+
`const fClient = new farseer.FarseerClient(${clientConfig});`
|
|
303
|
+
);
|
|
304
|
+
return modified;
|
|
305
|
+
}
|
|
306
|
+
function stripCredentials(code) {
|
|
307
|
+
let modified = code;
|
|
308
|
+
modified = modified.replace(
|
|
309
|
+
/const farseerClient = new farseer\.FarseerClient\(\{[\s\S]*?basePath:[\s\S]*?headers:[\s\S]*?'X-TENANT-ID':[\s\S]*?'X-API-KEY':[\s\S]*?\}\);/g,
|
|
310
|
+
"const farseerClient = new farseer.FarseerClient();"
|
|
311
|
+
);
|
|
312
|
+
modified = modified.replace(
|
|
313
|
+
/const fClient = new farseer\.FarseerClient\(\{[\s\S]*?basePath:[\s\S]*?headers:[\s\S]*?'X-TENANT-ID':[\s\S]*?'X-API-KEY':[\s\S]*?\}\);/g,
|
|
314
|
+
"const fClient = new farseer.FarseerClient();"
|
|
315
|
+
);
|
|
316
|
+
return modified;
|
|
317
|
+
}
|
|
318
|
+
function hasInjectedCredentials(code) {
|
|
319
|
+
return INJECTED_CLIENT_PATTERN.test(code);
|
|
320
|
+
}
|
|
321
|
+
function hasEmptyFarseerClient(code) {
|
|
322
|
+
return EMPTY_CLIENT_PATTERNS.some((pattern) => pattern.test(code));
|
|
323
|
+
}
|
|
324
|
+
function injectCredentialsInDir(srcDir, credential) {
|
|
325
|
+
let count = 0;
|
|
326
|
+
const files = getAllFiles(srcDir);
|
|
327
|
+
for (const file of files) {
|
|
328
|
+
const filePath = path.join(srcDir, file);
|
|
329
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
330
|
+
const modified = injectCredentials(content, credential);
|
|
331
|
+
if (modified !== content) {
|
|
332
|
+
fs.writeFileSync(filePath, modified);
|
|
333
|
+
count++;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return count;
|
|
337
|
+
}
|
|
338
|
+
function stripCredentialsInDir(srcDir) {
|
|
339
|
+
let count = 0;
|
|
340
|
+
const files = getAllFiles(srcDir);
|
|
341
|
+
for (const file of files) {
|
|
342
|
+
const filePath = path.join(srcDir, file);
|
|
343
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
344
|
+
const modified = stripCredentials(content);
|
|
345
|
+
if (modified !== content) {
|
|
346
|
+
fs.writeFileSync(filePath, modified);
|
|
347
|
+
count++;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return count;
|
|
351
|
+
}
|
|
352
|
+
async function fetchWithConcurrency(items, fetcher, concurrency = 15) {
|
|
353
|
+
const results = [];
|
|
354
|
+
for (let i = 0; i < items.length; i += concurrency) {
|
|
355
|
+
const chunk = items.slice(i, i + concurrency);
|
|
356
|
+
const chunkResults = await Promise.all(
|
|
357
|
+
chunk.map((item, chunkIndex) => fetcher(item, i + chunkIndex))
|
|
358
|
+
);
|
|
359
|
+
results.push(...chunkResults);
|
|
360
|
+
}
|
|
361
|
+
return results;
|
|
362
|
+
}
|
|
363
|
+
function appendToAuditLog(tenant, entries) {
|
|
364
|
+
if (entries.length === 0) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const logPath = getAuditLogPath(tenant);
|
|
368
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
369
|
+
let logContent = "";
|
|
370
|
+
for (const entry of entries) {
|
|
371
|
+
const uploaderInfo = entry.uploaderName ? `${entry.uploaderName} (${entry.uploaderEmail})` : entry.uploaderEmail || "Unknown";
|
|
372
|
+
const uploadedAt = entry.uploadTime ? new Date(entry.uploadTime).toLocaleString() : "Unknown";
|
|
373
|
+
logContent += `${timestamp} | ${entry.operation} | ${entry.filePath} | Modified by: ${uploaderInfo} | Uploaded: ${uploadedAt}
|
|
374
|
+
`;
|
|
375
|
+
}
|
|
376
|
+
fs.appendFileSync(logPath, logContent, "utf-8");
|
|
377
|
+
}
|
|
378
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
379
|
+
0 && (module.exports = {
|
|
380
|
+
appendToAuditLog,
|
|
381
|
+
calculateHash,
|
|
382
|
+
ensureDirectoryExists,
|
|
383
|
+
fetchWithConcurrency,
|
|
384
|
+
formatDate,
|
|
385
|
+
formatFileSize,
|
|
386
|
+
getAllFiles,
|
|
387
|
+
getAllFilesInDir,
|
|
388
|
+
getAppsDir,
|
|
389
|
+
getAuditLogPath,
|
|
390
|
+
getCredentialsHint,
|
|
391
|
+
getRelativePath,
|
|
392
|
+
getSyncFilePath,
|
|
393
|
+
getTenantAppsDir,
|
|
394
|
+
getTenantDir,
|
|
395
|
+
getTenantFilesDir,
|
|
396
|
+
getTenantSrcDir,
|
|
397
|
+
hasEmptyFarseerClient,
|
|
398
|
+
hasInjectedCredentials,
|
|
399
|
+
injectCredentials,
|
|
400
|
+
injectCredentialsInDir,
|
|
401
|
+
isKnownTenant,
|
|
402
|
+
isScriptFile,
|
|
403
|
+
isTextFile,
|
|
404
|
+
parseAppArgs,
|
|
405
|
+
resolveOrgAndTenant,
|
|
406
|
+
resolveOrgAndTenantOrExit,
|
|
407
|
+
resolveTenant,
|
|
408
|
+
resolveTenantOrExit,
|
|
409
|
+
resolveTenantWithOrgMapping,
|
|
410
|
+
stripCredentials,
|
|
411
|
+
stripCredentialsInDir
|
|
412
|
+
});
|
|
413
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/helpers.ts"],
|
|
4
|
+
"sourcesContent": ["import * as crypto from 'crypto';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport { getCurrentTenant, getCurrentCheckout, getCurrentOrganisation, getTenantOrg, saveTenantOrgMapping } from '../services/configService';\nimport { logger } from './logger';\n\nexport function calculateHash(content: string | Buffer): string {\n return crypto.createHash('md5').update(content).digest('hex');\n}\n\nexport function getAppsDir(): string {\n return path.join(process.cwd(), 'farseer-apps');\n}\n\nexport function getTenantDir(tenant: string): string {\n return path.join(getAppsDir(), tenant);\n}\n\nexport function getTenantFilesDir(tenant: string): string {\n return path.join(getTenantDir(tenant), 'files');\n}\n\n// Legacy - for backwards compatibility with run command\nexport function getTenantSrcDir(tenant: string): string {\n return path.join(getTenantFilesDir(tenant), 'Scripts');\n}\n\nexport function getSyncFilePath(tenant: string): string {\n return path.join(getTenantDir(tenant), '.farseer-sync.json');\n}\n\nexport function getAuditLogPath(tenant: string): string {\n return path.join(getTenantDir(tenant), '.farseer-audit.log');\n}\n\nexport function getTenantAppsDir(tenant: string): string {\n return path.join(getTenantDir(tenant), 'apps');\n}\n\nexport function ensureDirectoryExists(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n fs.mkdirSync(dirPath, { recursive: true });\n }\n}\n\n\nexport function getRelativePath(fullPath: string, basePath: string): string {\n return path.relative(basePath, fullPath);\n}\n\nexport function getAllFiles(dirPath: string, basePath?: string): string[] {\n if (!fs.existsSync(dirPath)) {\n return [];\n }\n\n const base = basePath || dirPath;\n const files: string[] = [];\n\n const items = fs.readdirSync(dirPath, { withFileTypes: true });\n\n for (const item of items) {\n const fullPath = path.join(dirPath, item.name);\n\n if (item.isDirectory()) {\n files.push(...getAllFiles(fullPath, base));\n } else if (item.isFile() && isScriptFile(item.name)) {\n files.push(getRelativePath(fullPath, base));\n }\n }\n\n return files;\n}\n\n// Get all files in directory (not just scripts)\nexport function getAllFilesInDir(dirPath: string, basePath?: string): string[] {\n if (!fs.existsSync(dirPath)) {\n return [];\n }\n\n const base = basePath || dirPath;\n const files: string[] = [];\n\n const items = fs.readdirSync(dirPath, { withFileTypes: true });\n\n for (const item of items) {\n const fullPath = path.join(dirPath, item.name);\n\n if (item.isDirectory()) {\n files.push(...getAllFilesInDir(fullPath, base));\n } else if (item.isFile()) {\n files.push(getRelativePath(fullPath, base));\n }\n }\n\n return files;\n}\n\nexport function isScriptFile(filename: string): boolean {\n const ext = path.extname(filename).toLowerCase();\n return ['.ts', '.js', '.mjs', '.cjs'].includes(ext);\n}\n\nexport function isTextFile(filename: string): boolean {\n const ext = path.extname(filename).toLowerCase().slice(1); // remove leading dot\n return ['ts', 'js', 'mjs', 'cjs', 'json', 'txt', 'md', 'csv', 'xml', 'html', 'css', 'yaml', 'yml'].includes(ext);\n}\n\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nexport function formatDate(date: Date | string): string {\n const d = typeof date === 'string' ? new Date(date) : date;\n return d.toLocaleString();\n}\n\nexport function getCredentialsHint(tenant: string): string {\n return `Use: farseer login\n Or: farseer config set ${tenant} --api-key <key> --org <organisation>`;\n}\n\n/**\n * Resolve tenant from argument or checkout.\n * If tenant is provided, use it. Otherwise, use checked-out tenant.\n * Returns null if no tenant is available.\n */\nexport interface ResolvedCheckout {\n organisation: string;\n tenant: string;\n}\n\n/**\n * Resolve organisation and tenant from argument or checkout.\n * When only tenant is provided, assumes organisation = tenant.\n */\nexport function resolveOrgAndTenant(tenantArg?: string): ResolvedCheckout | null {\n if (tenantArg) {\n // When tenant is specified as arg, assume org = tenant\n // (User can use checkout for different org/tenant)\n return { organisation: tenantArg, tenant: tenantArg };\n }\n\n const checkout = getCurrentCheckout();\n if (checkout) {\n if (checkout.organisation === checkout.tenant) {\n logger.dim(`Using checked-out tenant: ${checkout.tenant}`);\n } else {\n logger.dim(`Using checked-out tenant: ${checkout.tenant} (org: ${checkout.organisation})`);\n }\n return checkout;\n }\n\n return null;\n}\n\nexport function resolveTenant(tenantArg?: string): string | null {\n const resolved = resolveOrgAndTenant(tenantArg);\n return resolved?.tenant || null;\n}\n\n/**\n * Resolve tenant or exit with error if not available.\n */\nexport function resolveTenantOrExit(tenantArg?: string): string {\n const tenant = resolveTenant(tenantArg);\n if (!tenant) {\n logger.error('No tenant specified.');\n logger.dim('Either specify a tenant: farseer <command> <tenant>');\n logger.dim('Or checkout a tenant: farseer checkout <tenant>');\n process.exit(1);\n }\n return tenant;\n}\n\n/**\n * Resolve organisation and tenant with support for org-tenant mapping.\n *\n * Usage patterns:\n * - <org> <tenant>: Explicit org and tenant, saves mapping for future use\n * - <tenant>: Look up org from saved mapping or use checkout\n * - (no args): Use current checkout\n *\n * @param arg1 - Organisation (if 2 args) or tenant (if 1 arg)\n * @param arg2 - Tenant (if 2 args)\n * @returns ResolvedCheckout or exits with error\n */\nexport function resolveTenantWithOrgMapping(arg1?: string, arg2?: string): ResolvedCheckout {\n // Case 1: Two arguments - <org> <tenant>\n if (arg1 && arg2) {\n const org = arg1;\n const tenant = arg2;\n\n // Save mapping for future use\n saveTenantOrgMapping(tenant, org);\n\n if (org === tenant) {\n logger.dim(`Using tenant: ${tenant}`);\n } else {\n logger.dim(`Using tenant: ${tenant} (org: ${org})`);\n }\n\n return { organisation: org, tenant };\n }\n\n // Case 2: One argument - <tenant>\n if (arg1) {\n const tenant = arg1;\n\n // Try to get org from saved mapping\n const savedOrg = getTenantOrg(tenant);\n if (savedOrg) {\n if (savedOrg === tenant) {\n logger.dim(`Using tenant: ${tenant} (from saved mapping)`);\n } else {\n logger.dim(`Using tenant: ${tenant} (org: ${savedOrg}, from saved mapping)`);\n }\n return { organisation: savedOrg, tenant };\n }\n\n // No saved mapping - show error with helpful message\n logger.error(`Organisation unknown for tenant \"${tenant}\".`);\n logger.dim('Please specify both organisation and tenant:');\n logger.dim(` farseer <command> <organisation> <tenant>`);\n logger.dim(` Example: farseer pull jgl tt-hotels-hr-dev`);\n logger.dim('');\n logger.dim('Or checkout the tenant first:');\n logger.dim(` farseer checkout <organisation> <tenant>`);\n process.exit(1);\n }\n\n // Case 3: No arguments - use current checkout\n const checkout = getCurrentCheckout();\n if (checkout) {\n if (checkout.organisation === checkout.tenant) {\n logger.dim(`Using checked-out tenant: ${checkout.tenant}`);\n } else {\n logger.dim(`Using checked-out tenant: ${checkout.tenant} (org: ${checkout.organisation})`);\n }\n return checkout;\n }\n\n // No checkout either\n logger.error('No tenant specified.');\n logger.dim('Either specify organisation and tenant: farseer <command> <org> <tenant>');\n logger.dim('Or checkout a tenant: farseer checkout <org> <tenant>');\n process.exit(1);\n}\n\n/**\n * Resolve organisation and tenant or exit with error.\n */\nexport function resolveOrgAndTenantOrExit(tenantArg?: string): ResolvedCheckout {\n const resolved = resolveOrgAndTenant(tenantArg);\n if (!resolved) {\n logger.error('No tenant specified.');\n logger.dim('Either specify a tenant: farseer <command> <tenant>');\n logger.dim('Or checkout a tenant: farseer checkout <tenant>');\n process.exit(1);\n }\n return resolved;\n}\n\n/**\n * Check if a string is a known tenant (has credentials configured).\n */\nexport function isKnownTenant(name: string): boolean {\n // Import here to avoid circular dependency\n const { getCredential } = require('../services/configService');\n return !!getCredential(name);\n}\n\nexport interface ParsedAppArgs {\n organisation: string;\n tenant: string;\n appName: string;\n}\n\n/**\n * Parse variadic arguments to extract tenant and app name.\n * If first arg is a known tenant, use it as tenant and rest as app name.\n * Otherwise, use checked-out tenant and all args as app name.\n *\n * @param args Array of arguments (from variadic command)\n * @returns { organisation: string, tenant: string, appName: string }\n */\nexport function parseAppArgs(args: string[]): ParsedAppArgs {\n if (args.length === 0) {\n logger.error('App name is required.');\n process.exit(1);\n }\n\n // Check if first argument is a known tenant\n if (args.length >= 2 && isKnownTenant(args[0])) {\n // First arg is tenant, rest is app name\n // Assume organisation = tenant when specified via command line\n return {\n organisation: args[0],\n tenant: args[0],\n appName: args.slice(1).join(' ')\n };\n }\n\n // Use checked-out tenant, all args are app name\n const checkout = getCurrentCheckout();\n if (checkout) {\n if (checkout.organisation === checkout.tenant) {\n logger.dim(`Using checked-out tenant: ${checkout.tenant}`);\n } else {\n logger.dim(`Using checked-out tenant: ${checkout.tenant} (org: ${checkout.organisation})`);\n }\n return {\n organisation: checkout.organisation,\n tenant: checkout.tenant,\n appName: args.join(' ')\n };\n }\n\n // No checked-out tenant and first arg isn't a known tenant\n // Assume first arg is tenant (will fail later if invalid)\n if (args.length >= 2) {\n return {\n organisation: args[0],\n tenant: args[0],\n appName: args.slice(1).join(' ')\n };\n }\n\n // Only one arg and no checkout - could be tenant or app name\n logger.error('No tenant specified.');\n logger.dim('Either specify a tenant: farseer app show <tenant> <app-name>');\n logger.dim('Or checkout a tenant: farseer checkout <tenant>');\n process.exit(1);\n}\n\n// Credential injection/stripping for local development\n// Matches: const farseerClient = new farseer.FarseerClient();\n// and: const fClient = new farseer.FarseerClient();\n\ninterface CredentialConfig {\n basePath: string;\n tenantId: string;\n apiKey: string;\n}\n\n// Pattern to match empty FarseerClient() constructor (no /g flag to avoid lastIndex issues)\nconst EMPTY_CLIENT_PATTERNS = [\n /const farseerClient = new farseer\\.FarseerClient\\(\\s*\\);/,\n /const fClient = new farseer\\.FarseerClient\\(\\s*\\);/,\n];\n\n// Pattern to match FarseerClient with injected credentials (multiline, no /g flag)\nconst INJECTED_CLIENT_PATTERN = /const (farseerClient|fClient) = new farseer\\.FarseerClient\\(\\{[\\s\\S]*?basePath:[\\s\\S]*?headers:[\\s\\S]*?'X-TENANT-ID':[\\s\\S]*?'X-API-KEY':[\\s\\S]*?\\}\\);/;\n\nexport function injectCredentials(code: string, credential: CredentialConfig): string {\n const clientConfig = `{\n basePath: '${credential.basePath}',\n headers: {\n 'X-TENANT-ID': '${credential.tenantId}',\n 'X-API-KEY': '${credential.apiKey}',\n }\n }`;\n\n let modified = code;\n\n // Pattern 1: const farseerClient = new farseer.FarseerClient();\n modified = modified.replace(\n /const farseerClient = new farseer\\.FarseerClient\\(\\s*\\);/g,\n `const farseerClient = new farseer.FarseerClient(${clientConfig});`\n );\n\n // Pattern 2: const fClient = new farseer.FarseerClient();\n modified = modified.replace(\n /const fClient = new farseer\\.FarseerClient\\(\\s*\\);/g,\n `const fClient = new farseer.FarseerClient(${clientConfig});`\n );\n\n return modified;\n}\n\nexport function stripCredentials(code: string): string {\n // Replace injected credentials back to empty constructor\n let modified = code;\n\n // Match farseerClient with credentials\n modified = modified.replace(\n /const farseerClient = new farseer\\.FarseerClient\\(\\{[\\s\\S]*?basePath:[\\s\\S]*?headers:[\\s\\S]*?'X-TENANT-ID':[\\s\\S]*?'X-API-KEY':[\\s\\S]*?\\}\\);/g,\n 'const farseerClient = new farseer.FarseerClient();'\n );\n\n // Match fClient with credentials\n modified = modified.replace(\n /const fClient = new farseer\\.FarseerClient\\(\\{[\\s\\S]*?basePath:[\\s\\S]*?headers:[\\s\\S]*?'X-TENANT-ID':[\\s\\S]*?'X-API-KEY':[\\s\\S]*?\\}\\);/g,\n 'const fClient = new farseer.FarseerClient();'\n );\n\n return modified;\n}\n\nexport function hasInjectedCredentials(code: string): boolean {\n return INJECTED_CLIENT_PATTERN.test(code);\n}\n\nexport function hasEmptyFarseerClient(code: string): boolean {\n return EMPTY_CLIENT_PATTERNS.some(pattern => pattern.test(code));\n}\n\n// Process all script files in a directory\nexport function injectCredentialsInDir(srcDir: string, credential: CredentialConfig): number {\n let count = 0;\n const files = getAllFiles(srcDir);\n\n for (const file of files) {\n const filePath = path.join(srcDir, file);\n const content = fs.readFileSync(filePath, 'utf-8');\n const modified = injectCredentials(content, credential);\n\n if (modified !== content) {\n fs.writeFileSync(filePath, modified);\n count++;\n }\n }\n\n return count;\n}\n\nexport function stripCredentialsInDir(srcDir: string): number {\n let count = 0;\n const files = getAllFiles(srcDir);\n\n for (const file of files) {\n const filePath = path.join(srcDir, file);\n const content = fs.readFileSync(filePath, 'utf-8');\n const modified = stripCredentials(content);\n\n if (modified !== content) {\n fs.writeFileSync(filePath, modified);\n count++;\n }\n }\n\n return count;\n}\n\n// Audit log helpers\nexport interface AuditLogEntry {\n operation: 'pulled' | 'pushed' | 'deleted';\n filePath: string;\n uploadTime?: string;\n uploaderEmail?: string;\n uploaderName?: string;\n}\n\n/**\n * Execute async operations with limited concurrency.\n * Processes items in chunks to avoid overwhelming the API.\n *\n * @param items Array of items to process\n * @param fetcher Async function to call for each item\n * @param concurrency Maximum number of concurrent requests (default: 15)\n * @returns Array of results in the same order as input items\n */\nexport async function fetchWithConcurrency<T, R>(\n items: T[],\n fetcher: (item: T, index: number) => Promise<R>,\n concurrency: number = 15\n): Promise<R[]> {\n const results: R[] = [];\n\n for (let i = 0; i < items.length; i += concurrency) {\n const chunk = items.slice(i, i + concurrency);\n const chunkResults = await Promise.all(\n chunk.map((item, chunkIndex) => fetcher(item, i + chunkIndex))\n );\n results.push(...chunkResults);\n }\n\n return results;\n}\n\nexport function appendToAuditLog(tenant: string, entries: AuditLogEntry[]): void {\n if (entries.length === 0) {\n return;\n }\n\n const logPath = getAuditLogPath(tenant);\n const timestamp = new Date().toISOString();\n\n let logContent = '';\n for (const entry of entries) {\n const uploaderInfo = entry.uploaderName\n ? `${entry.uploaderName} (${entry.uploaderEmail})`\n : entry.uploaderEmail || 'Unknown';\n\n const uploadedAt = entry.uploadTime\n ? new Date(entry.uploadTime).toLocaleString()\n : 'Unknown';\n\n logContent += `${timestamp} | ${entry.operation} | ${entry.filePath} | Modified by: ${uploaderInfo} | Uploaded: ${uploadedAt}\\n`;\n }\n\n fs.appendFileSync(logPath, logContent, 'utf-8');\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,WAAsB;AACtB,SAAoB;AACpB,2BAAiH;AACjH,oBAAuB;AAEhB,SAAS,cAAc,SAAkC;AAC5D,SAAO,OAAO,WAAW,KAAK,EAAE,OAAO,OA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