示例#1
0
        static void Main(String[] args)
        {
            if (args == null || args.Length == 0)
            {
                Console.WriteLine("usage: sqlbuilder <input file>");
                return;
            }
            String fileName = Path.GetFullPath(args[0]);

            if (!File.Exists(fileName))
            {
                Console.WriteLine($"file not found: {fileName}");
                return;
            }

            try
            {
                var sb = new SolutionBuilder();
                var mb = new ModelBuilder();
                sb.BuildSolution(fileName, mb);
                Console.WriteLine(mb.ToString());
            } catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                Console.WriteLine(ex.Message);
            }
            Console.ReadKey();
        }
示例#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}");
                }
            }
        }
示例#3
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}.");
            }
        }
示例#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}");
                }
            }
        }
示例#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}");
                }
            }
        }
示例#6
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);
            }
        }