From c882d7b9d875c0dbc252ca08e7060bf17686fc93 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 28 Sep 2025 17:26:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArgumentsHelper.cs | 23 +++++++ .../BootstrapBlazor.CssBundler.csproj | 29 ++++++++ .../BootstrapBlazor.CssBundler/Bundler.cs | 68 +++++++++++++++++++ .../BundlerOptions.cs | 22 ++++++ .../BootstrapBlazor.CssBundler/Program.cs | 8 +++ 5 files changed, 150 insertions(+) create mode 100644 src/tools/BootstrapBlazor.CssBundler/ArgumentsHelper.cs create mode 100644 src/tools/BootstrapBlazor.CssBundler/BootstrapBlazor.CssBundler.csproj create mode 100644 src/tools/BootstrapBlazor.CssBundler/Bundler.cs create mode 100644 src/tools/BootstrapBlazor.CssBundler/BundlerOptions.cs create mode 100644 src/tools/BootstrapBlazor.CssBundler/Program.cs diff --git a/src/tools/BootstrapBlazor.CssBundler/ArgumentsHelper.cs b/src/tools/BootstrapBlazor.CssBundler/ArgumentsHelper.cs new file mode 100644 index 00000000..f85a837b --- /dev/null +++ b/src/tools/BootstrapBlazor.CssBundler/ArgumentsHelper.cs @@ -0,0 +1,23 @@ +// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Website: https://www.blazor.zone or https://argozhang.github.io/ + +namespace BootstrapBlazor.CssBundler; + +static class ArgumentsHelper +{ + public static void PrintHelp() + { + Console.ForegroundColor = ConsoleColor.Cyan; + Console.WriteLine("Usage: BootstrapBlazorCssBundler [options]"); + Console.WriteLine("Options:"); + Console.WriteLine(" ConfigFileFullPath D:\\Argo\\src\\BootstrapBlazor\\src\\BootstrapBlazor\\bundler.json"); + Console.WriteLine(); + Console.ForegroundColor = ConsoleColor.Gray; + } + + public static string? ParseOptions(string[] args) + { + return args.Length > 0 ? args[0] : ""; + } +} diff --git a/src/tools/BootstrapBlazor.CssBundler/BootstrapBlazor.CssBundler.csproj b/src/tools/BootstrapBlazor.CssBundler/BootstrapBlazor.CssBundler.csproj new file mode 100644 index 00000000..bbdcfb03 --- /dev/null +++ b/src/tools/BootstrapBlazor.CssBundler/BootstrapBlazor.CssBundler.csproj @@ -0,0 +1,29 @@ + + + + 1.0.0 + Exe + net9.0 + enable + enable + + + + net9.0 + + + + BootstrapBlazor Css Bundler + BootstrapBlazor.CssBundler + true + bb-bundler + Argo Zhang(Argo@live.ca) + Copyright 2025 + Longbow + + + + + + + diff --git a/src/tools/BootstrapBlazor.CssBundler/Bundler.cs b/src/tools/BootstrapBlazor.CssBundler/Bundler.cs new file mode 100644 index 00000000..9e059b41 --- /dev/null +++ b/src/tools/BootstrapBlazor.CssBundler/Bundler.cs @@ -0,0 +1,68 @@ +// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Website: https://www.blazor.zone or https://argozhang.github.io/ + +namespace BootstrapBlazor.CssBundler; + +internal class Bundler +{ + public static void Run(string[] args) + { +#if DEBUG + if (args.Length == 0) + { + args = [ + "C:\\Users\\Argo\\src\\BootstrapBlazor\\src\\BootstrapBlazor\\bundler.json" + ]; + } +#endif + + var bundlerFile = ArgumentsHelper.ParseOptions(args); + + if (string.IsNullOrEmpty(bundlerFile)) + { + ArgumentsHelper.PrintHelp(); + return; + } + + BundlerCore(bundlerFile); + } + + static void BundlerCore(string bundlerFile) + { + var option = BundlerOptions.LoadFromConfigFile(bundlerFile); + + if (string.IsNullOrEmpty(option.OutputFileName)) + { + return; + } + + if (option.InputFiles.Count == 0) + { + return; + } + + var rootFolder = Path.GetDirectoryName(bundlerFile); + if (string.IsNullOrEmpty(rootFolder)) + { + return; + } + + using var writer = File.OpenWrite(Path.Combine(rootFolder, option.OutputFileName)); + foreach (var file in option.InputFiles) + { + var inputFile = Path.Combine(rootFolder, file); + if (!File.Exists(inputFile)) + { + continue; + } + + using var reader = File.OpenText(inputFile); + reader.BaseStream.CopyTo(writer); + reader.Close(); + } + writer.Close(); + + Console.WriteLine($"Bundler Completed .... {option.OutputFileName}"); + } +} diff --git a/src/tools/BootstrapBlazor.CssBundler/BundlerOptions.cs b/src/tools/BootstrapBlazor.CssBundler/BundlerOptions.cs new file mode 100644 index 00000000..6a545a84 --- /dev/null +++ b/src/tools/BootstrapBlazor.CssBundler/BundlerOptions.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License +// See the LICENSE file in the project root for more information. +// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone + +using System.Text.Json; + +namespace BootstrapBlazor.CssBundler; + +sealed class BundlerOptions +{ + public string? OutputFileName { get; set; } + + public List InputFiles { get; set; } = []; + + public static BundlerOptions LoadFromConfigFile(string configFile) + { + var json = File.ReadAllText(configFile); + + return JsonSerializer.Deserialize(json, JsonSerializerOptions.Web) ?? new(); + } +} diff --git a/src/tools/BootstrapBlazor.CssBundler/Program.cs b/src/tools/BootstrapBlazor.CssBundler/Program.cs new file mode 100644 index 00000000..5b86bf17 --- /dev/null +++ b/src/tools/BootstrapBlazor.CssBundler/Program.cs @@ -0,0 +1,8 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License +// See the LICENSE file in the project root for more information. +// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone + +using BootstrapBlazor.CssBundler; + +Bundler.Run(args); From d010270f1e903d9e52391813d7e7f90bff9e2f01 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 28 Sep 2025 17:26:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BootstrapBlazor.Extensions.slnx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BootstrapBlazor.Extensions.slnx b/BootstrapBlazor.Extensions.slnx index eb64485c..8b9db58a 100644 --- a/BootstrapBlazor.Extensions.slnx +++ b/BootstrapBlazor.Extensions.slnx @@ -97,6 +97,9 @@ + + + From 11e9e8ec99b4000979d6dd43278b07d03093dbfe Mon Sep 17 00:00:00 2001 From: Argo Date: Wed, 1 Oct 2025 21:47:27 +0900 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapBlazor.CssBundler.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/BootstrapBlazor.CssBundler/BootstrapBlazor.CssBundler.csproj b/src/tools/BootstrapBlazor.CssBundler/BootstrapBlazor.CssBundler.csproj index bbdcfb03..40de8d43 100644 --- a/src/tools/BootstrapBlazor.CssBundler/BootstrapBlazor.CssBundler.csproj +++ b/src/tools/BootstrapBlazor.CssBundler/BootstrapBlazor.CssBundler.csproj @@ -16,7 +16,7 @@ BootstrapBlazor Css Bundler BootstrapBlazor.CssBundler true - bb-bundler + css-bundler Argo Zhang(Argo@live.ca) Copyright 2025 Longbow