/// <inheritdoc/> public BuildScriptSnippet GenerateBashBuildScriptSnippet( BuildScriptGeneratorContext ctx, PlatformDetectorResult detectorResult) { var rubyPlatformDetectorResult = detectorResult as RubyPlatformDetectorResult; if (rubyPlatformDetectorResult == null) { throw new ArgumentException( $"Expected '{nameof(detectorResult)}' argument to be of type " + $"'{typeof(RubyPlatformDetectorResult)}' but got '{detectorResult.GetType()}'."); } if (!rubyPlatformDetectorResult.GemfileExists && !rubyPlatformDetectorResult.ConfigYmlFileExists) { throw new InvalidUsageException($"No Gemfile found at the root of the repo. Please provide a Gemfile. " + $"For Jekyll apps, make sure it contains a '{RubyConstants.ConfigYmlFileName}' file and set it as a static web app"); } var buildProperties = new Dictionary <string, string>(); if (RubyConstants.ConfigYmlFileName != null) { buildProperties[ManifestFilePropertyKeys.Frameworks] = "jekyll"; this.logger.LogInformation("Detected the following frameworks: jekyll"); Console.WriteLine("Detected the following frameworks: jekyll"); } // Write the platform name and version to the manifest file buildProperties[ManifestFilePropertyKeys.RubyVersion] = rubyPlatformDetectorResult.PlatformVersion; this.logger.LogDebug("Selected Ruby version: {rubyVer}", rubyPlatformDetectorResult.PlatformVersion); var scriptProps = new RubyBashBuildSnippetProperties { UseBundlerToInstallDependencies = true, BundlerVersion = rubyPlatformDetectorResult.BundlerVersion, GemfileExists = rubyPlatformDetectorResult.GemfileExists, ConfigYmlFileExists = rubyPlatformDetectorResult.ConfigYmlFileExists, CustomBuildCommand = this.rubyScriptGeneratorOptions.CustomBuildCommand, }; string script = TemplateHelper.Render( TemplateHelper.TemplateResource.RubyBuildSnippet, scriptProps, this.logger); return(new BuildScriptSnippet { BashBuildScriptSnippet = script, BuildProperties = buildProperties, }); }
/// <inheritdoc/> public BuildScriptSnippet GenerateBashBuildScriptSnippet( BuildScriptGeneratorContext ctx, PlatformDetectorResult detectorResult) { var rubyPlatformDetectorResult = detectorResult as RubyPlatformDetectorResult; if (rubyPlatformDetectorResult == null) { throw new ArgumentException( $"Expected '{nameof(detectorResult)}' argument to be of type " + $"'{typeof(RubyPlatformDetectorResult)}' but got '{detectorResult.GetType()}'."); } if (!rubyPlatformDetectorResult.GemfileExists) { throw new InvalidUsageException($"No Gemfile found at the root of the repo. Please provide a Gemfile."); } var buildProperties = new Dictionary <string, string>(); // Write the platform name and version to the manifest file buildProperties[ManifestFilePropertyKeys.RubyVersion] = rubyPlatformDetectorResult.PlatformVersion; _logger.LogDebug("Selected Ruby version: {rubyVer}", rubyPlatformDetectorResult.PlatformVersion); var scriptProps = new RubyBashBuildSnippetProperties { UseBundlerToInstallDependencies = true, BundlerVersion = rubyPlatformDetectorResult.BundlerVersion, }; string script = TemplateHelper.Render( TemplateHelper.TemplateResource.RubyBuildSnippet, scriptProps, _logger); return(new BuildScriptSnippet { BashBuildScriptSnippet = script, BuildProperties = buildProperties, }); }