public async Task <ProjectBuildResult> BuildAsync(ProjectBuildArgs args)
        {
            var moduleInfo = await GetModuleInfoAsync(args);

            var templateFile = await SourceCodeStore.GetAsync(
                args.TemplateName,
                SourceCodeTypes.Module,
                args.Version
                );

            var context = new ProjectBuildContext(
                null,
                moduleInfo,
                templateFile,
                args
                );

            ModuleProjectBuildPipelineBuilder.Build(context).Execute();

            if (!moduleInfo.DocumentUrl.IsNullOrEmpty())
            {
                Logger.LogInformation("Check out the documents at " + moduleInfo.DocumentUrl);
            }

            // Exclude unwanted or known options.
            var options = args.ExtraProperties
                          .Where(x => !x.Key.Equals(CliConsts.Command, 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.Version.Long, StringComparison.InvariantCultureIgnoreCase) &&
                                 !x.Key.Equals(NewCommand.Options.Version.Short, StringComparison.InvariantCultureIgnoreCase))
                          .Select(x => x.Key).ToList();

            return(new ProjectBuildResult(context.Result.ZipContent, args.TemplateName));
        }
Beispiel #2
0
        public async Task <ProjectBuildResult> BuildAsync(ProjectBuildArgs args)
        {
            var moduleInfo = await GetModuleInfoAsync(args);

            var templateFile = await SourceCodeStore.GetAsync(
                args.TemplateName,
                SourceCodeTypes.Module,
                args.Version
                );

            var apiKeyResult = await ApiKeyService.GetApiKeyOrNullAsync();

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

            if (apiKeyResult?.LicenseCode != null)
            {
                args.ExtraProperties["license-code"] = apiKeyResult.LicenseCode;
            }

            var context = new ProjectBuildContext(
                null,
                moduleInfo,
                templateFile,
                args
                );

            ModuleProjectBuildPipelineBuilder.Build(context).Execute();

            if (!moduleInfo.DocumentUrl.IsNullOrEmpty())
            {
                Logger.LogInformation("Check out the documents at " + moduleInfo.DocumentUrl);
            }

            // Exclude unwanted or known options.
            var options = args.ExtraProperties
                          .Where(x => !x.Key.Equals(CliConsts.Command, 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.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 = null,
                IsTiered         = null,
                UiFramework      = null,
                Options          = JsonSerializer.Serialize(options),
                ProjectName      = null,
                TemplateName     = args.TemplateName,
                TemplateVersion  = templateFile.Version
            });

            return(new ProjectBuildResult(context.Result.ZipContent, args.TemplateName));
        }