Exemple #1
0
        protected override async Task <int> OnExecuteAsync(CommandLineApplication app)
        {
            Identifier = Identifier.ToLower();

            if (Name.IsNullOrWhiteSpace())
            {
                var defaultName = string.Empty;
                var promptText  = string.Empty;
                switch (Identifier)
                {
                case "console":
                    defaultName = Consts.DefaultConsoleName;
                    promptText  = Consts.Descriptions.New.NameConsolePrompt;
                    break;

                case "module":
                    defaultName = Consts.DefaultModuleName;
                    promptText  = Consts.Descriptions.New.NameModulePrompt;
                    break;

                default:
                    break;
                }

                Name = Prompt.GetString(promptText, defaultValue: defaultName);
            }

            var tplFinder = new TemplateFinder(TemplateName);

            var tplFilePath = await tplFinder.Fetch();

            var projectFolder = Path.Combine(Directory.GetCurrentDirectory(),
                                             $".{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}{Name}");

            if (!Directory.Exists(projectFolder))
            {
                Directory.CreateDirectory(projectFolder);
            }

            ExtractHelper.ExtractZipFile(tplFilePath, projectFolder, Identifier);

            if (Identifier == "module")
            {
                Placeholder = $"{Placeholder}.{DefaultModuleNamePlaceholder}";
            }

            RenameHelper.RenameFolders(projectFolder, Placeholder, Name, false, null);

            return(0);
        }
Exemple #2
0
        protected override async Task <int> OnExecuteAsync(CommandLineApplication app)
        {
            if (!Mpa)
            {
                //switch to personball/module-zero-core-template to reduce size of project template zip file
                if (TemplateName == Consts.DefaultProjectTemplateName)
                {
                    TemplateName = Consts.DefaultProjectTemplateForSPA;
                }

                if (string.IsNullOrWhiteSpace(SpaType))
                {
                    SpaType = Prompt.GetString(Consts.Descriptions.Init.SpaTypeDescription, defaultValue: "vue");
                    SpaType = SpaType.ToLower();
                    if ("vue,ng,react".IndexOf(SpaType) == -1)
                    {
                        SpaType = "vue";
                    }
                }
            }

            Console.WriteLine($"TemplateName\t:{TemplateName}");
            Console.WriteLine($"Placeholder\t:{Placeholder}");
            Console.WriteLine($"ProjectName\t:{ProjectName}");
            Console.WriteLine($"MPA\t\t:{Mpa}");
            Console.WriteLine($"SpaType\t\t:{SpaType}");
            Console.WriteLine($"RenameBackup\t:{RenameBackup}");

            //Create Target folder
            var projectFolder = Path.Combine(Directory.GetCurrentDirectory(), ProjectName);

            if (!Directory.Exists(projectFolder))
            {
                Directory.CreateDirectory(projectFolder);
            }

            var tplFinder = new TemplateFinder(TemplateName);

            var tplFilePath = await tplFinder.Fetch();

            ExtractHelper.ExtractZipFile(tplFilePath, projectFolder);

            var excludeFolders = new List <string>();

            InitExcludedFolders.ForEach(s =>
            {
                excludeFolders.Add(s);
            });

            if (!Mpa)
            {
                excludeFolders.Add($"./aspnet-core/src/{Placeholder}.Web.Mvc");
                //TODO@personball remove web.mvc entry in vs solution file(sln).
                switch (SpaType.ToLower())
                {
                case "ng":
                    excludeFolders.Remove("./angular");
                    break;

                case "react":
                    excludeFolders.Remove("./reactjs");
                    break;

                case "vue":
                default:
                    excludeFolders.Remove("./vue");
                    break;
                }
            }

            // Placeholder as AbpCompanyName.AbpProjectName
            // ProjectName as CompanyName.ProjectName or just ProjectName
            RenameHelper.RenameFolders(projectFolder, Placeholder, ProjectName, RenameBackup, excludeFolders);

            Console.WriteLine("Init Completed!");
            return(0);
        }