Esempio n. 1
0
        public static void Run(string solutionDirectory, string entityName, EntityProperty prop)
        {
            try
            {
                GlobalSingleton instance = GlobalSingleton.GetInstance();

                var propList = new List <EntityProperty>()
                {
                    prop
                };

                EntityModifier.AddEntityProperties(solutionDirectory, entityName, propList);
                DtoModifier.AddPropertiesToDtos(solutionDirectory, entityName, propList);
                RepositoryModifier.AddInclude(solutionDirectory, entityName, propList);

                WriteHelpHeader($"{Environment.NewLine}The '{prop.Name}' property was successfully added to the '{entityName}' entity and it's associated DTOs. Keep up the good work!");
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException ||
                    e is SolutionNotFoundException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }
Esempio n. 2
0
        public static void Run(string filePath, string buildSolutionDirectory, IFileSystem fileSystem)
        {
            try
            {
                GlobalSingleton instance = GlobalSingleton.GetInstance();

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

                foreach (var micro in template.Microservices)
                {
                    FileParsingHelper.RunPrimaryKeyGuard(micro.Entities);
                }
                FileParsingHelper.RunSolutionNameAssignedGuard(template.SolutionName);

                // solution level stuff
                var solutionDirectory = $"{buildSolutionDirectory}{Path.DirectorySeparatorChar}{template.SolutionName}";
                var srcDirectory      = Path.Combine(solutionDirectory, "src");
                fileSystem.Directory.CreateDirectory(srcDirectory);
                SolutionBuilder.BuildSolution(srcDirectory, template.SolutionName, fileSystem);

                // add all files based on the given template config
                RunMicroTemplateBuilders(srcDirectory, template.Microservices, template.Gateways, fileSystem);

                ReadmeBuilder.CreateReadme(solutionDirectory, template.SolutionName, fileSystem);
                if (template.AddGit)
                {
                    GitSetup(solutionDirectory);
                }

                WriteFileCreatedUpdatedResponse();
                WriteHelpHeader($"{Environment.NewLine}Your API 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 EntityNotFoundException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }
Esempio n. 3
0
        public static void Run(string filePath, string buildSolutionDirectory, IFileSystem fileSystem)
        {
            try
            {
                GlobalSingleton instance = GlobalSingleton.GetInstance();

                FileParsingHelper.RunInitialTemplateParsingGuards(filePath);
                var template = FileParsingHelper.GetApiTemplateFromFile(filePath);
                WriteHelpText($"Your template file was parsed successfully.");

                FileParsingHelper.RunPrimaryKeyGuard(template);
                FileParsingHelper.RunSolutionNameAssignedGuard(template);

                //var rootProjectDirectory = Directory.GetCurrentDirectory().Contains("Debug") ? @"C:\Users\Paul\Documents\testoutput" : Directory.GetCurrentDirectory();
                //var buildSolutionDirectory = @"C:\Users\Paul\Documents\testoutput";

                // scaffold projects
                // should i add an accelerate.config.yaml file to the root?
                CreateNewFoundation(template, buildSolutionDirectory); // todo scaffold this manually instead of using dotnet new foundation
                var solutionDirectory = $"{buildSolutionDirectory}{Path.DirectorySeparatorChar}{template.SolutionName}";


                // remove placeholder valuetoreplace files and directories
                ApiTemplateCleaner.CleanTemplateFilesAndDirectories(solutionDirectory, template);

                // add all files based on the given template config
                RunTemplateBuilders(solutionDirectory, template, fileSystem);

                WriteFileCreatedUpdatedResponse();
                WriteHelpHeader($"{Environment.NewLine}Your API is ready! Build something amazing.");
                WriteGettingStarted(template.SolutionName);
                StarGithubRequest();
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }
Esempio n. 4
0
        public static void Run(string filePath, string buildSolutionDirectory, IFileSystem fileSystem)
        {
            try
            {
                GlobalSingleton instance = GlobalSingleton.GetInstance();

                FileParsingHelper.RunInitialTemplateParsingGuards(filePath);
                var template = FileParsingHelper.GetApiTemplateFromFile(filePath);
                WriteHelpText($"Your template file was parsed successfully.");

                FileParsingHelper.RunPrimaryKeyGuard(template);
                FileParsingHelper.RunSolutionNameAssignedGuard(template);

                // scaffold projects
                // add an accelerate.config.yaml file to the root?
                var solutionDirectory = $"{buildSolutionDirectory}{Path.DirectorySeparatorChar}{template.SolutionName}";

                // adding this for my test auth scaffolding so i don't have to do stuff that might not last manaully. **not officially supported**
                if (template.AuthSetup.AuthMethod == "JWT")
                {
                    CreateNewFoundation(template, buildSolutionDirectory); // todo scaffold this manually instead of using dotnet new foundation
                }
                SolutionBuilder.BuildSolution(solutionDirectory, template, fileSystem);

                // add all files based on the given template config
                RunTemplateBuilders(solutionDirectory, template, fileSystem);

                WriteFileCreatedUpdatedResponse();
                WriteHelpHeader($"{Environment.NewLine}Your API is ready! Build something amazing.");
                WriteGettingStarted(template.SolutionName);
                StarGithubRequest();
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }
Esempio n. 5
0
        public static void Run(string filePath, string buildSolutionDirectory, IFileSystem fileSystem)
        {
            try
            {
                GlobalSingleton instance = GlobalSingleton.GetInstance();

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

                FileParsingHelper.RunPrimaryKeyGuard(template.Entities);
                FileParsingHelper.RunSolutionNameAssignedGuard(template.SolutionName);

                // scaffold projects
                // add an accelerate.config.yaml file to the root?
                var solutionDirectory = $"{buildSolutionDirectory}{Path.DirectorySeparatorChar}{template.SolutionName}";

                SolutionBuilder.BuildSolution(solutionDirectory, template.SolutionName, fileSystem);
                SolutionBuilder.AddProjects(solutionDirectory, solutionDirectory, template.DbContext.Provider, template.SolutionName, template.AddJwtAuthentication, fileSystem);

                // add all files based on the given template config
                RunTemplateBuilders(solutionDirectory, template, fileSystem);

                WriteFileCreatedUpdatedResponse();
                WriteHelpHeader($"{Environment.NewLine}Your API is ready! Build something amazing.");
                WriteGettingStarted(template.SolutionName);
                StarGithubRequest();
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }
Esempio n. 6
0
        public static void Run(string filePath, string solutionDirectory, IFileSystem fileSystem)
        {
            try
            {
                GlobalSingleton instance = GlobalSingleton.GetInstance();

                FileParsingHelper.RunInitialTemplateParsingGuards(filePath);
                var template = FileParsingHelper.GetApiTemplateFromFile(filePath);

                //var solutionDirectory = Directory.GetCurrentDirectory();
                //var solutionDirectory = @"C:\Users\Paul\Documents\testoutput\MyApi.Mine";
                template = SolutionGuard(solutionDirectory, template);
                template = GetDbContext(solutionDirectory, template);

                WriteHelpText($"Your template file was parsed successfully.");

                FileParsingHelper.RunPrimaryKeyGuard(template);

                // add all files based on the given template config
                RunEntityBuilders(solutionDirectory, template, fileSystem);

                WriteFileCreatedUpdatedResponse();
                WriteHelpHeader($"{Environment.NewLine}Your entities have been successfully added. Keep up the good work!");
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException ||
                    e is SolutionNotFoundException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }