internal void Remove(ScopedRegistry registry) { JObject manifestJSON = JObject.Parse(File.ReadAllText(manifest)); JArray Jregistries = (JArray)manifestJSON["scopedRegistries"]; foreach (var JRegistryElement in Jregistries) { if (JRegistryElement["name"] != null && JRegistryElement["url"] != null) { JRegistryElement.Remove(); break; } } write(manifestJSON); }
public void Remove(ScopedRegistry registry) { JObject manifestJSON = JObject.Parse(File.ReadAllText(manifest)); JArray Jregistries = (JArray)manifestJSON["scopedRegistries"]; foreach (var JRegistryElement in Jregistries) { if (JRegistryElement["name"] != null && JRegistryElement["url"] != null && JRegistryElement["name"].Value <string>().Equals(registry.name, StringComparison.Ordinal) && JRegistryElement["url"].Value <string>().Equals(registry.url, StringComparison.Ordinal)) { JRegistryElement.Remove(); break; } } write(manifestJSON); }
public void Save(ScopedRegistry registry) { JObject manifestJSON = JObject.Parse(File.ReadAllText(manifest)); JToken manifestRegistry = GetOrCreateScopedRegistry(registry, manifestJSON); if (!string.IsNullOrEmpty(registry.token)) { credentialManager.SetCredential(registry.url, registry.auth, registry.token); } else { credentialManager.RemoveCredential(registry.url); } write(manifestJSON); credentialManager.Write(); }
private ScopedRegistry LoadRegistry(JObject Jregistry) { ScopedRegistry registry = new ScopedRegistry(); registry.name = (string)Jregistry["name"]; registry.url = (string)Jregistry["url"]; List <string> scopes = new List <string>(); foreach (var scope in (JArray)Jregistry["scopes"]) { scopes.Add((string)scope); } registry.scopes = scopes.ToArray(); if (credentialManager.HasRegistry(registry.url)) { NPMCredential credential = credentialManager.GetCredential(registry.url); registry.auth = credential.alwaysAuth; registry.token = credential.token; } return(registry); }