Exemplo n.º 1
0
        private bool ValidateApplicationPackage(string appFolderFullPath)
        {
            string commandsFolder = Path.Combine(appFolderFullPath, InstallBuilder.CommandsFolderName);

            if (!Directory.Exists(commandsFolder))
            {
                WriteError("The specified package is not an application. The package was added but no commands were installed.");
                return(false);
            }

            var blockedCommands = _commandsRepository.Commands.Where(cmd =>
                                                                     !CommandNameValidator.IsCommandNameValid(cmd) ||
                                                                     CommandNameValidator.ShouldNameBeSkipped(cmd));

            if (blockedCommands.Any())
            {
                WriteError(string.Format(
                               "The application cannot be installed because the following command names are not allowed: {0}.",
                               string.Join(", ", blockedCommands)));

                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        private void WriteCommandsScripts(string applicationFolder)
        {
            var distinctCommands = _project.Commands.Keys.Distinct().ToList();

            var commandsThatWillBeSkipped = distinctCommands.Where(cmd => CommandNameValidator.ShouldNameBeSkipped(cmd));

            IEnumerable <string> commandsToExport;

            if (commandsThatWillBeSkipped.Any())
            {
                _buildReport.Information.WriteLine(
                    string.Format(
                        "The following commands will not be exported for global install: {0}.",
                        string.Join(", ", commandsThatWillBeSkipped))
                    .Yellow());

                commandsToExport = distinctCommands.Where(cmd => !CommandNameValidator.ShouldNameBeSkipped(cmd));
            }
            else
            {
                commandsToExport = distinctCommands;
            }

            foreach (string command in commandsToExport)
            {
                WriteWindowsScript(applicationFolder, command);
                WriteNixScript(applicationFolder, command);

                _buildReport.Information.WriteLine("Exported application command: " + command);
            }
        }
Exemplo n.º 3
0
        private bool ValidateExportedCommands()
        {
            // Get the commands that would conflict with runtime commands
            var invalidExportedCommands = _project.Commands.Keys.Where(exported => !CommandNameValidator.IsCommandNameValid(exported));

            if (invalidExportedCommands.Any())
            {
                _buildReport.Error.WriteLine(
                    string.Format(
                        "The following names are not allowed as commands: {0}.",
                        string.Join(", ", invalidExportedCommands))
                    .Red());

                return(false);
            }

            return(true);
        }