示例#1
0
        private static async Task <int> Execute(CommandArgument url, CommandOption dataFolder)
        {
            try
            {
                if (string.IsNullOrEmpty(url.Value))
                {
                    Console.WriteLine("Please specify a module url to install from");
                    return(1);
                }

                FoundryDataFolder foundryDataFolder;
                if (dataFolder.HasValue())
                {
                    foundryDataFolder = FoundryDataFolder.FromDirectoryPath(dataFolder.Value());
                }
                else
                {
                    foundryDataFolder = FoundryDataFolder.FromCurrentDirectory();
                }

                if (foundryDataFolder == null)
                {
                    return(1);
                }

                var manifestLoader = new ManifestLoader();
                await foundryDataFolder.ReadAllManifests(manifestLoader);

                var manifest = await manifestLoader.FromUri(new Uri(url.Value));

                if (manifest == null)
                {
                    return(1);
                }

                var dependencyChain = new DependencyChain();
                dependencyChain.AddCurrentlyInstalledDependencies(manifestLoader, foundryDataFolder);
                await dependencyChain.AddDependenciesFromManifest(manifestLoader, manifest);

                foreach (var dependency in dependencyChain.NeededDependencies)
                {
                    Console.WriteLine();
                    var dependencyManifest = await dependency.GetFullManifest(manifestLoader);

                    await dependencyManifest.Install(foundryDataFolder);
                }

                Console.WriteLine();
                return(await manifest.Install(foundryDataFolder));
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
                return(1);
            }
        }
示例#2
0
        private static async Task <int> Execute(CommandOption dataFolder)
        {
            try
            {
                FoundryDataFolder foundryDataFolder;
                if (dataFolder.HasValue())
                {
                    foundryDataFolder = FoundryDataFolder.FromDirectoryPath(dataFolder.Value());
                }
                else
                {
                    foundryDataFolder = FoundryDataFolder.FromCurrentDirectory();
                }

                if (foundryDataFolder == null)
                {
                    return(1);
                }

                var manifestLoader    = new ManifestLoader();
                var manifestsToUpdate = new List <Manifest>();

                foreach (var manifest in await foundryDataFolder.ReadAllManifests(manifestLoader))
                {
                    Console.WriteLine();
                    Console.WriteLine($"Checking {manifest.Name} for updates");
                    var latestManifest = await GetLatestManifest(manifestLoader, manifest);

                    if (latestManifest == null)
                    {
                        continue;
                    }

                    if (latestManifest.GetSemanticVersion() > manifest.GetSemanticVersion())
                    {
                        Console.WriteLine($"Queuing update for {latestManifest.Name} from {manifest.GetSemanticVersion().ToNormalizedString()} to {latestManifest.GetSemanticVersion().ToNormalizedString()}");
                        manifestsToUpdate.Add(latestManifest);
                    }
                }

                var dependencyChain = new DependencyChain();
                dependencyChain.AddCurrentlyInstalledDependencies(manifestLoader, foundryDataFolder);

                foreach (var toUpdate in manifestsToUpdate)
                {
                    await dependencyChain.AddDependenciesFromManifest(manifestLoader, toUpdate);
                }

                foreach (var dependency in dependencyChain.NeededDependencies)
                {
                    Console.WriteLine();
                    var dependencyManifest = await dependency.GetFullManifest(manifestLoader);

                    await dependencyManifest.Install(foundryDataFolder);
                }

                foreach (var toUpdate in manifestsToUpdate)
                {
                    Console.WriteLine();
                    await toUpdate.Install(foundryDataFolder);
                }

                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(1);
            }
        }