Browse Source

Merge pull request #8162 from abpframework/bundle-command-improvement

Use default values for bundle command if there is no config specified.
pull/8170/head
Halil İbrahim Kalkan 6 years ago
committed by GitHub
parent
commit
8163cb93c0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundleConfig.cs
  2. 7
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs
  3. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/AbpCliConfig.cs
  4. 24
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/ConfigReader.cs

6
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundleConfig.cs

@ -5,8 +5,8 @@ namespace Volo.Abp.Cli.Bundling
{
public class BundleConfig
{
public BundlingMode Mode { get; set; }
public string Name { get; set; }
public BundleParameterDictionary Parameters { get; set; }
public BundlingMode Mode { get; set; } = BundlingMode.BundleAndMinify;
public string Name { get; set; } = "global";
public BundleParameterDictionary Parameters { get; set; } = new();
}
}

7
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Bundling/BundlingService.cs

@ -41,12 +41,7 @@ namespace Volo.Abp.Cli.Bundling
var projectFilePath = projectFiles[0];
var config = ConfigReader.Read(PathHelper.GetWwwRootPath(directory));
var bundleConfig = config?.Bundle;
if (bundleConfig == null)
{
throw new BundlingException("Bundle section is missing in the appsettings.json configuration file.");
}
var bundleConfig = config.Bundle;
if (forceBuild)
{

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/AbpCliConfig.cs

@ -4,6 +4,6 @@ namespace Volo.Abp.Cli.Configuration
{
public class AbpCliConfig
{
public BundleConfig Bundle { get; set; }
public BundleConfig Bundle { get; set; } = new();
}
}

24
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/ConfigReader.cs

@ -30,18 +30,24 @@ namespace Volo.Abp.Cli.Configuration
using (var document = JsonDocument.Parse(settingsFileContent,documentOptions))
{
var element = document.RootElement.GetProperty("AbpCli");
var configText = element.GetRawText();
var options = new JsonSerializerOptions
if (document.RootElement.TryGetProperty("AbpCli", out var element))
{
Converters =
var configJson = element.GetRawText();
var options = new JsonSerializerOptions
{
new JsonStringEnumConverter()
},
ReadCommentHandling = JsonCommentHandling.Skip
};
Converters =
{
new JsonStringEnumConverter()
},
ReadCommentHandling = JsonCommentHandling.Skip
};
return JsonSerializer.Deserialize<AbpCliConfig>(configText, options);
return JsonSerializer.Deserialize<AbpCliConfig>(configJson, options);
}
else
{
return new AbpCliConfig();
}
}
}
}

Loading…
Cancel
Save