private IEnumerable <ILibraryInstallationState> ValidateParametersAndGetLibrariesToUninstall( Manifest manifest) { var errors = new List <string>(); if (string.IsNullOrWhiteSpace(LibraryId.Value)) { errors.Add(Resources.Text.LibraryIdRequiredForUnInstall); } IProvider provider = null; if (Provider.HasValue()) { provider = ManifestDependencies.GetProvider(Provider.Value()); if (provider == null) { errors.Add(string.Format(Resources.Text.ProviderNotInstalled, Provider.Value())); } } if (errors.Any()) { throw new InvalidOperationException(string.Join(Environment.NewLine, errors)); } return(LibraryResolver.Resolve(LibraryId.Value, manifest, provider)); }
private void InitializeDirectiveResolver(ScriptingEngine engine, RuntimeEnvironment env, string libRoot, string[] additionals) { var libResolver = new LibraryResolver(engine, env); libResolver.LibraryRoot = libRoot; if (additionals != null) { libResolver.SearchDirectories.AddRange(additionals); } engine.DirectiveResolvers.Add(libResolver); }
protected async override Task <int> ExecuteInternalAsync() { Manifest manifest = await GetManifestAsync(); IEnumerable <ILibraryInstallationState> installedLibraries = ValidateParametersAndGetLibrariesToUninstall(manifest); if (installedLibraries == null || !installedLibraries.Any()) { Logger.Log(string.Format(Resources.Text.NoLibraryToUninstall, LibraryId.Value), LogLevel.Operation); return(0); } ILibraryInstallationState libraryToUninstall = null; if (installedLibraries.Count() > 1) { Logger.Log(string.Format(Resources.Text.MoreThanOneLibraryFoundToUninstall, LibraryId.Value), LogLevel.Operation); libraryToUninstall = LibraryResolver.ResolveLibraryByUserChoice(installedLibraries, HostEnvironment); } else { libraryToUninstall = installedLibraries.First(); } Task <bool> deleteFileAction(IEnumerable <string> s) => HostInteractions.DeleteFilesAsync(s, CancellationToken.None); string libraryId = LibraryIdToNameAndVersionConverter.Instance.GetLibraryId(libraryToUninstall.Name, libraryToUninstall.Version, libraryToUninstall.ProviderId); ILibraryOperationResult result = await manifest.UninstallAsync(libraryToUninstall.Name, libraryToUninstall.Version, deleteFileAction, CancellationToken.None); if (result.Success) { await manifest.SaveAsync(Settings.ManifestFileName, CancellationToken.None); Logger.Log(string.Format(Resources.Text.UninstalledLibrary, libraryId), LogLevel.Operation); } else { Logger.Log(string.Format(Resources.Text.UninstallFailed, libraryId), LogLevel.Error); foreach (IError error in result.Errors) { Logger.Log($"[{error.Code}]: {error.Message}", LogLevel.Error); } } return(0); }
public async Task TestResolveByUserChoiceAsync() { string libmanjsonPath = Path.Combine(WorkingDir, "libman.json"); File.WriteAllText(libmanjsonPath, _manifestContents); Manifest manifest = await Manifest.FromFileAsync( libmanjsonPath, _dependencies, CancellationToken.None); var inputReader = HostEnvironment.InputReader as TestInputReader; string outputStr = "Select an option:\r\n-----------------\r\n1. {[email protected], cdnjs, wwwroot}\r\n2. {[email protected], cdnjs, lib}\r\n3. {jquery, filesystem, wwwroot}"; inputReader.Inputs[outputStr] = "1"; ILibraryInstallationState result = LibraryResolver.ResolveLibraryByUserChoice(manifest.Libraries, HostEnvironment); Assert.AreEqual("[email protected]", result.LibraryId); }
private void InitializeDirectiveResolver(ScriptingEngine engine, RuntimeEnvironment env, string libRoot, string[] additionals) { var ignoreDirectiveResolver = new DirectiveIgnorer(); ignoreDirectiveResolver.Add("Region", "Область"); ignoreDirectiveResolver.Add("EndRegion", "КонецОбласти"); var resolversCollection = new DirectiveMultiResolver(); resolversCollection.Add(ignoreDirectiveResolver); var libResolver = new LibraryResolver(engine, env); libResolver.LibraryRoot = libRoot; if (additionals != null) { libResolver.SearchDirectories.AddRange(additionals); } resolversCollection.Add(libResolver); engine.DirectiveResolver = resolversCollection; }
static PreboardNativeMethods() { LibraryResolver.EnsureRegistered(); }
static MobileBackup2NativeMethods() { LibraryResolver.EnsureRegistered(); }
static DiagnosticsRelayNativeMethods() { LibraryResolver.EnsureRegistered(); }
static HeartBeatNativeMethods() { LibraryResolver.EnsureRegistered(); }
static MobileactivationNativeMethods() { LibraryResolver.EnsureRegistered(); }
static HouseArrestNativeMethods() { LibraryResolver.EnsureRegistered(); }
static MobileSyncNativeMethods() { LibraryResolver.EnsureRegistered(); }
static iDeviceNativeMethods() { LibraryResolver.EnsureRegistered(); }
static LockdownNativeMethods() { LibraryResolver.EnsureRegistered(); }
static DebugServerNativeMethods() { LibraryResolver.EnsureRegistered(); }
static NotificationProxyNativeMethods() { LibraryResolver.EnsureRegistered(); }
static LibcupsNative() { LibraryResolver.EnsureRegistered(); }
static CompanionProxyNativeMethods() { LibraryResolver.EnsureRegistered(); }
static WebInspectorNativeMethods() { LibraryResolver.EnsureRegistered(); }
static InstallationProxyNativeMethods() { LibraryResolver.EnsureRegistered(); }
static UsbmuxdNativeMethods() { LibraryResolver.EnsureRegistered(); }
public async Task TestResolveLibraryAsync() { string libmanjsonPath = Path.Combine(WorkingDir, "libman.json"); File.WriteAllText(libmanjsonPath, _manifestContents); Manifest manifest = await Manifest.FromFileAsync( libmanjsonPath, _dependencies, CancellationToken.None); // Matches jquery for all providers. IReadOnlyList <ILibraryInstallationState> result = LibraryResolver.Resolve( "jquery", manifest, null); Assert.AreEqual(3, result.Count); Assert.AreEqual("jquery", result[0].Name); Assert.AreEqual("", result[0].Version); Assert.AreEqual("jquery", result[1].Name); Assert.AreEqual("3.3.1", result[1].Version); Assert.AreEqual("jquery", result[2].Name); Assert.AreEqual("2.2.0", result[2].Version); // Matches jquery for cdnjs provider result = LibraryResolver.Resolve( "jquery", manifest, _dependencies.GetProvider("cdnjs")); Assert.AreEqual(2, result.Count); Assert.AreEqual("jquery", result[0].Name); Assert.AreEqual("3.3.1", result[0].Version); Assert.AreEqual("jquery", result[1].Name); Assert.AreEqual("2.2.0", result[1].Version); // Matches only one result. result = LibraryResolver.Resolve( "[email protected]", manifest, null); Assert.AreEqual(1, result.Count); Assert.AreEqual("jquery", result[0].Name); Assert.AreEqual("3.3.1", result[0].Version); // Does not match library for a different provider. result = LibraryResolver.Resolve( "[email protected]", manifest, _dependencies.GetProvider("filesystem")); Assert.AreEqual(0, result.Count); // Does not return partial matches. result = LibraryResolver.Resolve( "[email protected]", manifest, null); Assert.AreEqual(0, result.Count); result = LibraryResolver.Resolve( "jquer", manifest, null); Assert.AreEqual(0, result.Count); }
static SpringBoardServicesNativeMethods() { LibraryResolver.EnsureRegistered(); }
static ScreenshotrNativeMethods() { LibraryResolver.EnsureRegistered(); }
static PropertyListServiceNativeMethods() { LibraryResolver.EnsureRegistered(); }
static PinvokeNativeMethods() { LibraryResolver.EnsureRegistered(); }
protected override async Task <int> ExecuteInternalAsync() { Manifest manifest = await GetManifestAsync(); IEnumerable <ILibraryInstallationState> installedLibraries = ValidateParametersAndGetLibrariesToUpdate(manifest); if (installedLibraries == null || !installedLibraries.Any()) { Logger.Log(string.Format(Resources.NoLibraryFoundToUpdate, LibraryName.Value), LogLevel.Operation); return(0); } ILibraryInstallationState libraryToUpdate = null; if (installedLibraries.Count() > 1) { Logger.Log(string.Format(Resources.MoreThanOneLibraryFoundToUpdate, LibraryName.Value), LogLevel.Operation); libraryToUpdate = LibraryResolver.ResolveLibraryByUserChoice(installedLibraries, HostEnvironment); } else { libraryToUpdate = installedLibraries.First(); } string newLibraryId = null; if (ToVersion.HasValue()) { newLibraryId = LibraryIdToNameAndVersionConverter.Instance.GetLibraryId(libraryToUpdate.Name, ToVersion.Value(), libraryToUpdate.ProviderId); } else { string latestVersion = await GetLatestVersionAsync(libraryToUpdate, CancellationToken.None); if (!string.IsNullOrEmpty(latestVersion)) { newLibraryId = LibraryIdToNameAndVersionConverter.Instance.GetLibraryId(libraryToUpdate.Name, latestVersion, libraryToUpdate.ProviderId); } } if (newLibraryId == null || newLibraryId == libraryToUpdate.LibraryId) { Logger.Log(string.Format(Resources.LatestVersionAlreadyInstalled, libraryToUpdate.LibraryId), LogLevel.Operation); return(0); } Manifest backup = manifest.Clone(); string oldLibraryName = libraryToUpdate.Name; manifest.ReplaceLibraryId(libraryToUpdate, newLibraryId); // Delete files from old version of the library. await backup.RemoveUnwantedFilesAsync(manifest, CancellationToken.None); IEnumerable <ILibraryOperationResult> results = await manifest.RestoreAsync(CancellationToken.None); ILibraryOperationResult result = null; foreach (ILibraryOperationResult r in results) { if (!r.Success && r.Errors.Any(e => e.Message.Contains(libraryToUpdate.LibraryId))) { result = r; break; } else if (r.Success && r.InstallationState.LibraryId == libraryToUpdate.LibraryId && r.InstallationState.ProviderId == libraryToUpdate.ProviderId && r.InstallationState.DestinationPath == libraryToUpdate.DestinationPath) { result = r; break; } } if (result.Success) { await manifest.SaveAsync(HostEnvironment.EnvironmentSettings.ManifestFileName, CancellationToken.None); Logger.Log(string.Format(Resources.LibraryUpdated, oldLibraryName, newLibraryId), LogLevel.Operation); } else if (result.Errors != null) { if (ToVersion.HasValue()) { Logger.Log(string.Format(Resources.UpdateLibraryFailed, oldLibraryName, ToVersion.Value()), LogLevel.Error); } else { Logger.Log(string.Format(Resources.UpdateLibraryToLatestFailed, oldLibraryName), LogLevel.Error); } foreach (IError error in result.Errors) { Logger.Log(string.Format("[{0}]: {1}", error.Code, error.Message), LogLevel.Error); } } return(0); }
static SyslogRelayNativeMethods() { LibraryResolver.EnsureRegistered(); }
static MobileImageMounterNativeMethods() { LibraryResolver.EnsureRegistered(); }
static AfcNativeMethods() { LibraryResolver.EnsureRegistered(); }