Пример #1
0
        public static void Run(string filePath, string domainDirectory, IFileSystem fileSystem, Verbosity verbosity)
        {
            try
            {
                FileParsingHelper.RunInitialTemplateParsingGuards(filePath);
                var boundedContexts = FileParsingHelper.GetTemplateFromFile <BoundedContextsTemplate>(filePath);
                WriteHelpText($"Your template file was parsed successfully.");

                foreach (var template in boundedContexts.BoundedContexts)
                {
                    ApiScaffolding.ScaffoldApi(domainDirectory, template, fileSystem, verbosity);
                }

                WriteHelpHeader($"{Environment.NewLine}Your bounded contexts have been successfully added. Keep up the good work!");
                StarGithubRequest();
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException ||
                    e is SolutiuonNameEntityMatchException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }
Пример #2
0
        public static void Run(string filePath, string domainDirectory, IFileSystem fileSystem, Verbosity verbosity)
        {
            try
            {
                FileParsingHelper.RunInitialTemplateParsingGuards(filePath);
                Utilities.SolutionGuard(domainDirectory);

                var boundedContexts = FileParsingHelper.GetTemplateFromFile <BoundedContextsTemplate>(filePath);
                WriteHelpText($"Your template file was parsed successfully.");

                foreach (var template in boundedContexts.BoundedContexts)
                {
                    ApiScaffolding.ScaffoldApi(domainDirectory, template, fileSystem);
                }

                // migrations
                Utilities.RunDbMigrations(boundedContexts.BoundedContexts, domainDirectory);

                WriteHelpHeader($"{Environment.NewLine}Your bounded contexts have been successfully added. Keep up the good work!");
                StarGithubRequest();
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException ||
                    e is DataValidationErrorException ||
                    e is SolutiuonNameEntityMatchException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    AnsiConsole.WriteException(e, new ExceptionSettings
                    {
                        Format = ExceptionFormats.ShortenEverything | ExceptionFormats.ShowLinks,
                        Style  = new ExceptionStyle
                        {
                            Exception     = new Style().Foreground(Color.Grey),
                            Message       = new Style().Foreground(Color.White),
                            NonEmphasized = new Style().Foreground(Color.Cornsilk1),
                            Parenthesis   = new Style().Foreground(Color.Cornsilk1),
                            Method        = new Style().Foreground(Color.Red),
                            ParameterName = new Style().Foreground(Color.Cornsilk1),
                            ParameterType = new Style().Foreground(Color.Red),
                            Path          = new Style().Foreground(Color.Red),
                            LineNumber    = new Style().Foreground(Color.Cornsilk1),
                        }
                    });
                }
            }
        }
Пример #3
0
        public static void Run(string filePath, string buildSolutionDirectory, IFileSystem fileSystem, Verbosity verbosity)
        {
            try
            {
                FileParsingHelper.RunInitialTemplateParsingGuards(filePath);
                var domainProject = FileParsingHelper.GetTemplateFromFile <DomainProject>(filePath);
                WriteHelpText($"Your template file was parsed successfully.");

                var domainDirectory = $"{buildSolutionDirectory}{Path.DirectorySeparatorChar}{domainProject.DomainName}";
                fileSystem.Directory.CreateDirectory(domainDirectory);

                foreach (var template in domainProject.BoundedContexts)
                {
                    ApiScaffolding.ScaffoldApi(domainDirectory, template, fileSystem, verbosity);
                }

                //final
                ReadmeBuilder.CreateReadme(domainDirectory, domainProject.DomainName, fileSystem);

                if (domainProject.AddGit)
                {
                    Utilities.GitSetup(domainDirectory);
                }

                WriteHelpHeader($"{Environment.NewLine}Your domain project is ready! Build something amazing.");
                StarGithubRequest();
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException ||
                    e is SolutiuonNameEntityMatchException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }
Пример #4
0
        public static void CreateNewDomainProject(string domainDirectory, IFileSystem fileSystem,
                                                  DomainProject domainProject)
        {
            fileSystem.Directory.CreateDirectory(domainDirectory);
            SolutionBuilder.BuildSolution(domainDirectory, domainProject.DomainName, fileSystem);

            // need this before boundaries to give them something to build against
            DockerBuilders.CreateDockerComposeSkeleton(domainDirectory, fileSystem);

            //Parallel.ForEach(domainProject.BoundedContexts, (template) =>
            //    ApiScaffolding.ScaffoldApi(domainDirectory, template, fileSystem, verbosity));
            foreach (var bc in domainProject.BoundedContexts)
            {
                ApiScaffolding.ScaffoldApi(domainDirectory, bc, fileSystem);
            }

            // auth server
            if (domainProject.AuthServer != null)
            {
                AddAuthServerCommand.AddAuthServer(domainDirectory, fileSystem, domainProject.AuthServer);
            }

            // messages
            if (domainProject.Messages.Count > 0)
            {
                AddMessageCommand.AddMessages(domainDirectory, fileSystem, domainProject.Messages);
            }

            // migrations
            Utilities.RunDbMigrations(domainProject.BoundedContexts, domainDirectory);

            //final
            ReadmeBuilder.CreateReadme(domainDirectory, domainProject.DomainName, fileSystem);

            if (domainProject.AddGit)
            {
                Utilities.GitSetup(domainDirectory, domainProject.UseSystemGitUser);
            }
        }