public string GetReleaseNotes(RepositoryEntityUid uid) { if (uid == null) { throw new ArgumentNullException(nameof(uid)); } return(LoadEntity(uid).ReleaseNotes); }
public RepositoryEntityMetaData GetMetaData(RepositoryEntityUid uid) { if (uid == null) { throw new ArgumentNullException(nameof(uid)); } return(LoadEntity(uid).MetaData); }
public string GetDescription(RepositoryEntityUid uid) { if (uid == null) { throw new ArgumentNullException(nameof(uid)); } return(LoadEntity(uid).Description); }
public string get_file_uri(string uid, string filename) { if (uid == null) { throw new ArgumentNullException(nameof(uid)); } var entityUid = RepositoryEntityUid.Parse(uid); return($"/repository/{entityUid.Id}/{entityUid.Version}/{filename}"); }
public async Task DownloadEntityAsync(RepositoryEntityUid uid) { if (uid == null) { throw new ArgumentNullException(nameof(uid)); } _storageService.TryReadOrCreate(out RepositoryServiceOptions options, "RepositoryServiceConfiguration.json"); var downloader = new GitHubRepositoryEntityDownloader(options, _loggerFactory); await downloader.DownloadAsync(uid, GetEntityRootPath(uid)).ConfigureAwait(false); }
public void DeleteEntity(RepositoryEntityUid uid) { if (uid == null) { throw new ArgumentNullException(nameof(uid)); } var rootPath = GetEntityRootPath(uid); if (!Directory.Exists(rootPath)) { return; } Directory.Delete(rootPath, true); _logger.Log(LogLevel.Information, $"Deleted entity '{uid}'."); }
public RepositoryEntity LoadEntity(RepositoryEntityUid uid) { if (uid == null) { throw new ArgumentNullException(nameof(uid)); } if (string.IsNullOrEmpty(uid.Id)) { throw new ArgumentException("The ID of the RepositoryEntityUid is not set."); } var path = GetEntityRootPath(uid); var source = LoadEntity(uid, path); return(source); }
private static RepositoryEntity LoadEntity(RepositoryEntityUid uid, string path) { if (!Directory.Exists(path)) { throw new WirehomeRepositoryEntityNotFoundException(uid); } var source = new RepositoryEntity(); var metaFile = Path.Combine(path, "meta.json"); if (!File.Exists(metaFile)) { throw new WirehomeException($"Repository entity directory '{path}' contains no 'meta.json'."); } try { var metaData = File.ReadAllText(metaFile, Encoding.UTF8); source.MetaData = JsonConvert.DeserializeObject <RepositoryEntityMetaData>(metaData); } catch (Exception exception) { throw new WirehomeRepositoryException("Unable to parse 'meta.json'.", exception); } source.Uid = new RepositoryEntityUid { Id = Directory.GetParent(path).Name, Version = new DirectoryInfo(path).Name }; source.Description = ReadFileContent(path, "description.md"); source.ReleaseNotes = ReadFileContent(path, "releaseNotes.md"); source.Script = ReadFileContent(path, "script.py"); return(source); }
private string GetEntityRootPath(RepositoryEntityUid uid) { _storageService.TryRead(out RepositoryServiceOptions options, RepositoryServiceOptions.Filename); var rootPath = options.RootPath; if (string.IsNullOrEmpty(rootPath)) { rootPath = Path.Combine(_storageService.DataPath, "Repository"); } var path = rootPath; if (string.IsNullOrEmpty(uid.Version)) { path = GetLatestVersionPath(path, uid.Id); } else { path = Path.Combine(path, uid.Id, uid.Version); } return(path); }