Beispiel #1
0
        public async Task <IActionResult> GetRecipe(string recipeId, [FromQuery] string?projectPath = null)
        {
            if (string.IsNullOrEmpty(recipeId))
            {
                return(BadRequest($"A Recipe ID was not provided."));
            }

            ProjectDefinition?projectDefinition = null;

            if (!string.IsNullOrEmpty(projectPath))
            {
                projectDefinition = await _projectDefinitionParser.Parse(projectPath);
            }
            var recipeDefinitions = await RecipeHandler.GetRecipeDefinitions(_customRecipeLocator, projectDefinition);

            var selectedRecipeDefinition = recipeDefinitions.FirstOrDefault(x => x.Id.Equals(recipeId));

            if (selectedRecipeDefinition == null)
            {
                return(BadRequest($"Recipe ID {recipeId} not found."));
            }

            var output = new RecipeSummary(
                selectedRecipeDefinition.Id,
                selectedRecipeDefinition.Version,
                selectedRecipeDefinition.Name,
                selectedRecipeDefinition.Description,
                selectedRecipeDefinition.ShortDescription,
                selectedRecipeDefinition.TargetService,
                selectedRecipeDefinition.DeploymentType.ToString(),
                selectedRecipeDefinition.DeploymentBundle.ToString()
                );

            return(Ok(output));
        }
Beispiel #2
0
        public async Task SuggestsValidName(string projectFile)
        {
            // ARRANGE
            var projectPath = _fakeFileManager.AddEmptyProjectFile($"c:\\{projectFile}");

            var projectDefinition = await _projectDefinitionParser.Parse(projectPath);

            var existingApplication = new List <CloudApplication>();

            var recommendation = _cloudApplicationNameGenerator.GenerateValidName(projectDefinition, existingApplication);

            // ACT
            var recommendationIsValid = _cloudApplicationNameGenerator.IsValidName(recommendation);

            // ASSERT
            recommendationIsValid.ShouldBeTrue();
        }
Beispiel #3
0
        public async Task <ProjectDefinition> Parse(string projectPath)
        {
            try
            {
                return(await _projectDefinitionParser.Parse(projectPath));
            }
            catch (ProjectFileNotFoundException ex)
            {
                var files        = _directoryManager.GetFiles(projectPath, "*.sln");
                var errorMessage = string.Empty;

                if (files.Any())
                {
                    errorMessage = "This directory contains a solution file, but the tool requires a project file. " +
                                   "Please run the tool from the directory that contains a .csproj/.fsproj or provide a path to the .csproj/.fsproj via --project-path flag.";
                }
                else
                {
                    errorMessage = $"A project was not found at the path {projectPath}";
                }

                throw new FailedToFindDeployableTargetException(errorMessage, ex);
            }
        }