예제 #1
0
        public static void ScaffoldApi(string buildSolutionDirectory, ApiTemplate template, IFileSystem fileSystem)
        {
            var projectName = template.ProjectName;

            AnsiConsole.Status()
            .AutoRefresh(true)
            .Spinner(Spinner.Known.Dots2)
            .Start($"[yellow]Creating {template.ProjectName} [/]", ctx =>
            {
                FileParsingHelper.RunPrimaryKeyGuard(template.Entities);
                FileParsingHelper.RunSolutionNameAssignedGuard(projectName);
                FileParsingHelper.SolutionNameDoesNotEqualEntityGuard(projectName, template.Entities);

                // add an accelerate.config.yaml file to the root?
                var bcDirectory   = $"{buildSolutionDirectory}{Path.DirectorySeparatorChar}{projectName}";
                var srcDirectory  = Path.Combine(bcDirectory, "src");
                var testDirectory = Path.Combine(bcDirectory, "tests");
                fileSystem.Directory.CreateDirectory(srcDirectory);
                fileSystem.Directory.CreateDirectory(testDirectory);

                ctx.Spinner(Spinner.Known.BouncingBar);
                ctx.Status($"[bold blue]Building {projectName} Projects [/]");
                SolutionBuilder.AddProjects(buildSolutionDirectory, srcDirectory, testDirectory, template.DbContext.Provider, template.DbContext.DatabaseName, projectName, template.AddJwtAuthentication, fileSystem);

                // add all files based on the given template config
                ctx.Status($"[bold blue]Scaffolding Files for {projectName} [/]");
                RunTemplateBuilders(bcDirectory, srcDirectory, testDirectory, template, fileSystem);
                WriteLogMessage($"File scaffolding for {template.ProjectName} was successful");
            });
        }
예제 #2
0
        public static void ScaffoldApi(string buildSolutionDirectory, ApiTemplate template, IFileSystem fileSystem, Verbosity verbosity)
        {
            if (verbosity == Verbosity.More)
            {
                WriteHelpText($"{Environment.NewLine}Creating {template.SolutionName}...");
            }

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

            // scaffold projects
            // add an accelerate.config.yaml file to the root?
            // solution level stuff

            // ***********will add a root directory read from template here for the entire overarching whatever (Koi Katan Operations, LimsLite, ProfiseePlatform)
            var solutionDirectory = $"{buildSolutionDirectory}{Path.DirectorySeparatorChar}{template.SolutionName}";
            var srcDirectory      = Path.Combine(solutionDirectory, "src");
            var testDirectory     = Path.Combine(solutionDirectory, "tests");

            fileSystem.Directory.CreateDirectory(srcDirectory);
            fileSystem.Directory.CreateDirectory(testDirectory);

            SolutionBuilder.BuildSolution(solutionDirectory, template.SolutionName, fileSystem);
            SolutionBuilder.AddProjects(solutionDirectory, srcDirectory, testDirectory, template.DbContext.Provider, template.DbContext.DatabaseName, template.SolutionName, template.AddJwtAuthentication, fileSystem);
            if (verbosity == Verbosity.More)
            {
                WriteHelpText($"{template.SolutionName} projects were scaffolded successfully.");
            }

            // add all files based on the given template config
            RunTemplateBuilders(solutionDirectory, srcDirectory, testDirectory, template, fileSystem, verbosity);
            if (verbosity == Verbosity.More)
            {
                WriteHelpText($"{template.SolutionName} templates were scaffolded successfully.");
            }

            if (verbosity == Verbosity.More)
            {
                WriteHelpText($"Starting {template.SolutionName} database migrations.");
            }
            RunDbMigration(template, srcDirectory);
            if (verbosity == Verbosity.More)
            {
                WriteHelpText($"{template.SolutionName} migrations are complete.");
            }

            if (verbosity == Verbosity.More)
            {
                WriteHelpText($"Completed {template.SolutionName}.");
            }
        }