Exemplo n.º 1
0
        public async Task <ProjectBuildResult> BuildAsync(ProjectBuildArgs args)
        {
            var templateInfo = GetTemplateInfo(args);

            args.TemplateName = templateInfo.Name;

            if (args.DatabaseProvider == DatabaseProvider.NotSpecified)
            {
                if (templateInfo.DefaultDatabaseProvider != DatabaseProvider.NotSpecified)
                {
                    args.DatabaseProvider = templateInfo.DefaultDatabaseProvider;
                }
            }

            var templateFile = await TemplateStore.GetAsync(
                args.TemplateName,
                args.DatabaseProvider,
                args.SolutionName.FullName
                );

            var context = new ProjectBuildContext(
                templateInfo,
                templateFile,
                args
                );

            ProjectBuildPipelineBuilder.Build(context).Execute(context);

            return(new ProjectBuildResult(context.Result.ZipContent, args.SolutionName.ProjectName));
        }
Exemplo n.º 2
0
        public async Task <ProjectBuildResult> BuildAsync(ProjectBuildArgs args)
        {
            var templateInfo = GetTemplateInfo(args);

            NormalizeArgs(args, templateInfo);

            var templateFile = await TemplateStore.GetAsync(
                args.TemplateName,
                args.Version
                );

            var apiKey = await ApiKeyService.GetApiKeyOrNullAsync();

            if (apiKey != null)
            {
                args.ExtraProperties["api-key"] = apiKey;
            }

            var context = new ProjectBuildContext(
                templateInfo,
                templateFile,
                args
                );

            ProjectBuildPipelineBuilder.Build(context).Execute();

            if (!templateInfo.DocumentUrl.IsNullOrEmpty())
            {
                Logger.LogInformation("Check the documentation of this template: " + templateInfo.DocumentUrl);
            }

            // Exclude unwanted or known options.
            var options = args.ExtraProperties
                          .Where(x => !x.Key.Equals(CliConsts.Command, StringComparison.InvariantCultureIgnoreCase))
                          .Where(x => !x.Key.Equals("tiered", StringComparison.InvariantCultureIgnoreCase))
                          .Where(x => !x.Key.Equals(NewCommand.Options.DatabaseProvider.Long, StringComparison.InvariantCultureIgnoreCase) &&
                                 !x.Key.Equals(NewCommand.Options.DatabaseProvider.Short, StringComparison.InvariantCultureIgnoreCase))
                          .Where(x => !x.Key.Equals(NewCommand.Options.OutputFolder.Long, StringComparison.InvariantCultureIgnoreCase) &&
                                 !x.Key.Equals(NewCommand.Options.OutputFolder.Short, StringComparison.InvariantCultureIgnoreCase))
                          .Where(x => !x.Key.Equals(NewCommand.Options.UiFramework.Long, StringComparison.InvariantCultureIgnoreCase) &&
                                 !x.Key.Equals(NewCommand.Options.UiFramework.Short, StringComparison.InvariantCultureIgnoreCase))
                          .Where(x => !x.Key.Equals(NewCommand.Options.Version.Long, StringComparison.InvariantCultureIgnoreCase) &&
                                 !x.Key.Equals(NewCommand.Options.Version.Short, StringComparison.InvariantCultureIgnoreCase))
                          .Select(x => x.Key).ToList();

            await CliAnalyticsCollect.CollectAsync(new CliAnalyticsCollectInputDto
            {
                Tool             = Options.ToolName,
                Command          = args.ExtraProperties.ContainsKey(CliConsts.Command) ? args.ExtraProperties[CliConsts.Command] : "",
                DatabaseProvider = args.DatabaseProvider.ToProviderName(),
                IsTiered         = args.ExtraProperties.ContainsKey("tiered"),
                UiFramework      = args.UiFramework.ToFrameworkName(),
                Options          = JsonSerializer.Serialize(options),
                ProjectName      = args.SolutionName.FullName,
                TemplateName     = args.TemplateName,
                TemplateVersion  = templateFile.Version
            });

            return(new ProjectBuildResult(context.Result.ZipContent, args.SolutionName.ProjectName));
        }
Exemplo n.º 3
0
        public async Task <ProjectBuildResult> BuildAsync(ProjectBuildArgs args)
        {
            var templateInfo = GetTemplateInfo(args);

            args.TemplateName = templateInfo.Name;

            if (args.DatabaseProvider == DatabaseProvider.NotSpecified)
            {
                if (templateInfo.DefaultDatabaseProvider != DatabaseProvider.NotSpecified)
                {
                    args.DatabaseProvider = templateInfo.DefaultDatabaseProvider;
                }
            }

            var templateFile = await TemplateStore.GetAsync(
                args.TemplateName,
                args.DatabaseProvider,
                args.SolutionName.FullName
                );

            var context = new ProjectBuildContext(
                templateInfo,
                templateFile,
                args
                );

            ProjectBuildPipelineBuilder.Build(context).Execute(context);

            if (!templateInfo.DocumentUrl.IsNullOrEmpty())
            {
                Logger.LogInformation("Check the documentation of this template: " + templateInfo.DocumentUrl);
            }

            return(new ProjectBuildResult(context.Result.ZipContent, args.SolutionName.ProjectName));
        }
Exemplo n.º 4
0
        public async Task <SolutionBuildResult> BuildAsync(
            TemplateInfo template,
            string companyAndProjectName,
            DatabaseProvider databaseProvider,
            string version,
            bool replaceLocalReferencesToNuget)
        {
            var stopwatch = Stopwatch.StartNew();

            var templateRootPath = _hostingEnvironment.ContentRootPath + "\\TemplateFiles"; //TODO: To another folder that is not in the deployment folder!
            var solutionName     = SolutionName.Parse(companyAndProjectName);

            var context = new ProjectBuildContext(
                template,
                new ProjectBuildRequest(
                    solutionName,
                    databaseProvider,
                    version
                    ),
                templateRootPath
                );

            ProjectBuildPipelineBuilder.Build(context).Execute(context);

            stopwatch.Stop();

            await _downloadRepository.InsertAsync(
                new DownloadInfo(
                    solutionName.FullName,
                    template.Name,
                    databaseProvider,
                    context.Template.Version,
                    Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds)
                    )
                );

            return(new SolutionBuildResult(context.Result.ZipContent, solutionName.ProjectName));
        }