예제 #1
0
        /// <summary>
        /// Runs the command
        /// </summary>
        /// <param name="suite">The current suite model the command is applied to</param>
        /// <param name="parameters">Parameters given to the command (in unprocessed form)</param>
        /// <returns>Returns <c>true</c> if the command succeeded</returns>
        public bool Run(Suite suite, string[] parameters)
        {
            var fileSystem = new ExtendedPhysicalFileSystem(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
            var updater    = new AppUpdaterBuilder(NUGET_PACKAGE_ID)
                             .FileSystemAccessedThrough(fileSystem)
                             .Build();

            output.Message("Checking for updates (current version: {0})...", updater.CurrentVersion);
            var check = updater.CheckForUpdate();

            if (check.UpdateAvailable)
            {
                output.Message("..found update: {0}", check.UpdatePackage.Version);
                output.Message("..preparing update..");
                var preparedUpdate = PrepareUpdate(updater, fileSystem, check.UpdatePackage);

                output.Message("..applying update..");
                updater.ApplyPreparedUpdate(preparedUpdate);

                output.Message("Update completed.");
                output.Warning("You should rebuild your suites with the updated bari before using them!");
            }
            else
            {
                output.Message("No updates available.");
            }
            return(true);
        }
예제 #2
0
        public virtual IProjectParameters Load(Suite suite, string name, YamlNode value, YamlParser parser)
        {
            this.suite = suite;

            var result  = CreateNewParameters(suite);
            var mapping = value as YamlMappingNode;

            if (mapping != null)
            {
                foreach (var pair in parser.EnumerateNodesOf(mapping))
                {
                    var scalarKey = pair.Key as YamlScalarNode;
                    if (scalarKey != null)
                    {
                        TryAddParameter(result, scalarKey.Value, pair.Value, parser);
                    }
                }
            }
            else
            {
                var hints = new List <string>();

                if (value is YamlSequenceNode)
                {
                    hints.Add("Remove the `-` characters to make it a mapping instead of sequence");
                    output.Warning(String.Format("{0} block (line {1}) is not a mapping node", BlockName, value != null ? value.Start.Line.ToString(CultureInfo.InvariantCulture) : "?"), hints.ToArray());
                }
            }

            return(result);
        }
예제 #3
0
 private void CleanWarning(Exception ex)
 {
     output.Warning(String.Format("Failed to clean target root: {0}", ex.Message),
                    new[]
     {
         "A command prompt may have its current directory set there",
         "Maybe the process is running"
     });
 }
예제 #4
0
        /// <summary>
        /// Checks for warnings in the project, and displays them through the given output interface
        /// </summary>
        /// <param name="output">Output interface</param>
        public void CheckForWarnings(IUserOutput output)
        {
            bool hasFiles = sourceSets.Values.Any(sourceSet => sourceSet.Files.Any());

            if (!hasFiles)
            {
                output.Warning(String.Format("{0} has no source files", ToString()),
                               new[]
                {
                    String.Format("The source files must be organized into source sets"),
                    String.Format("The source sets must be placed in {0}", RelativeRootDirectory)
                });
            }
        }
예제 #5
0
        private IEnumerable <Uri> LoadPlugins(YamlNode rootNode)
        {
            var result = new List <Uri>();

            var      rootMapping = (YamlMappingNode)rootNode;
            YamlNode node;

            if (rootMapping.Children.TryGetValue(new YamlScalarNode("plugins"), out node))
            {
                var pluginsNode = node as YamlSequenceNode;
                if (pluginsNode != null)
                {
                    foreach (var item in parser.EnumerateNodesOf(pluginsNode))
                    {
                        var scalar = item as YamlScalarNode;
                        if (scalar != null)
                        {
                            try
                            {
                                result.Add(new Uri(scalar.Value));
                            }
                            catch (UriFormatException)
                            {
                                output.Warning(String.Format("Invalid plugin reference: {0}", scalar.Value));
                            }
                        }
                        else
                        {
                            output.Warning("Invalid child item ");
                        }
                    }
                }
            }

            return(result);
        }
예제 #6
0
        private void LoadProduct(Suite suite, Product product, YamlNode productNode)
        {
            Contract.Requires(product != null);
            Contract.Requires(productNode != null);

            foreach (KeyValuePair <string, YamlNode> item in parser.EnumerateNamedNodesOf(productNode, "modules"))
            {
                if (suite.HasModule(item.Key))
                {
                    var module = suite.GetModule(item.Key);
                    product.AddModule(module);
                }
                else
                {
                    output.Warning(String.Format("The product {0} refers to a non-existing module {1}", product.Name, item.Key));
                }
            }

            SetProjectPostProcessors(suite, product, productNode);
            LoadParameters(suite, product, productNode);
        }
예제 #7
0
파일: CleanCommand.cs 프로젝트: zvrana/bari
        /// <summary>
        /// Runs the command
        /// </summary>
        /// <param name="suite">The current suite model the command is applied to</param>
        /// <param name="parameters">Parameters given to the command (in unprocessed form)</param>
        public bool Run(Suite suite, string[] parameters)
        {
            var cleanParams = new CleanParameters(parameters);

            try
            {
                targetRoot.Delete();
            }
            catch (IOException ex)
            {
                output.Warning(String.Format("Failed to clean target root: {0}", ex.Message),
                               new [] {
                    "A command prompt may have its current directory set there",
                    "Maybe the process is running"
                });
            }

            foreach (var cleanExtension in extensions)
            {
                cleanExtension.Clean(cleanParams);
            }

            return(true);
        }