<chore>
45
ImageOptimize.csx
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
for %%i in (*.png) do pngquant %%i --force --output %%i --skip-if-larger
|
||||
for %%i in (*.jpg) do jpegtran -copy none -optimize -perfect %%i %%i
|
||||
*
|
||||
*/
|
||||
|
||||
var files = Directory.EnumerateFiles(".", "*.png"
|
||||
, new EnumerationOptions {
|
||||
RecurseSubdirectories = true
|
||||
, AttributesToSkip = FileAttributes.ReparsePoint
|
||||
, IgnoreInaccessible = true
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
|
||||
Parallel.ForEach(files, file => {
|
||||
var startInfo = new ProcessStartInfo {
|
||||
FileName = "pngquant"
|
||||
, Arguments
|
||||
= $"\"{file}\" --force --output \"{file}\" --skip-if-larger"
|
||||
};
|
||||
using var p = Process.Start(startInfo);
|
||||
p.WaitForExit();
|
||||
Console.WriteLine($"{file}: {p.ExitCode}");
|
||||
});
|
||||
|
||||
files = new[] { "*.jpg", "*.jpeg" }
|
||||
.SelectMany(x => Directory.EnumerateFiles(
|
||||
".", x
|
||||
, new EnumerationOptions {
|
||||
RecurseSubdirectories = true
|
||||
, AttributesToSkip = FileAttributes.ReparsePoint
|
||||
, IgnoreInaccessible = true
|
||||
}))
|
||||
.ToArray();
|
||||
|
||||
Parallel.ForEach(files, file => {
|
||||
var startInfo = new ProcessStartInfo {
|
||||
FileName = "jpegtran"
|
||||
, Arguments = $"-copy none -optimize -perfect \"{file}\" \"{file}\""
|
||||
};
|
||||
using var p = Process.Start(startInfo);
|
||||
p.WaitForExit();
|
||||
Console.WriteLine($"{file}: {p.ExitCode}");
|
||||
});
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@ -1,2 +0,0 @@
|
||||
for %%i in (*.png) do pngquant %%i --force --output %%i --skip-if-larger
|
||||
for %%i in (*.jpg) do jpegtran -copy none -optimize -perfect %%i %%i
|
122
build.cake
Normal file
@ -0,0 +1,122 @@
|
||||
var target = Argument("target", "Default");
|
||||
var configuration = Argument("configuration", "Release");
|
||||
var framework = Argument("framework", "net7.0-windows");
|
||||
var runtime = Argument("runtime","win-x64");
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Tasks
|
||||
|
||||
Task("Clean")
|
||||
.Does(context =>
|
||||
{
|
||||
context.CleanDirectory("./build");
|
||||
});
|
||||
|
||||
Task("Build")
|
||||
.IsDependentOn("Clean")
|
||||
.Does(context =>
|
||||
{
|
||||
DotNetPublish("./src/dot.csproj", new DotNetPublishSettings {
|
||||
Configuration = configuration,
|
||||
EnableCompressionInSingleFile = true,
|
||||
Framework = framework,
|
||||
SelfContained = true,
|
||||
Runtime = runtime,
|
||||
PublishSingleFile = true
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Task("Test")
|
||||
// .IsDependentOn("Build")
|
||||
// .Does(context =>
|
||||
// {
|
||||
// DotNetTest("./test/Spectre.Console.Tests/Spectre.Console.Tests.csproj", new DotNetTestSettings {
|
||||
// Configuration = configuration,
|
||||
// NoRestore = true,
|
||||
// NoBuild = true,
|
||||
// });
|
||||
//
|
||||
// DotNetTest("./test/Spectre.Console.Cli.Tests/Spectre.Console.Cli.Tests.csproj", new DotNetTestSettings {
|
||||
// Configuration = configuration,
|
||||
// NoRestore = true,
|
||||
// NoBuild = true,
|
||||
// });
|
||||
//
|
||||
// DotNetTest("./test/Spectre.Console.Analyzer.Tests/Spectre.Console.Analyzer.Tests.csproj", new DotNetTestSettings {
|
||||
// Configuration = configuration,
|
||||
// NoRestore = true,
|
||||
// NoBuild = true,
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
// Task("Publish-GitHub")
|
||||
// .WithCriteria(ctx => BuildSystem.IsRunningOnGitHubActions, "Not running on GitHub Actions")
|
||||
// //.IsDependentOn("Package")
|
||||
// .Does(context =>
|
||||
// {
|
||||
// var apiKey = Argument<string>("github-key", null);
|
||||
// if(string.IsNullOrWhiteSpace(apiKey)) {
|
||||
// throw new CakeException("No GitHub API key was provided.");
|
||||
// }
|
||||
//
|
||||
// // Publish to GitHub Packages
|
||||
// var exitCode = 0;
|
||||
// foreach(var file in context.GetFiles("./.artifacts/*.nupkg"))
|
||||
// {
|
||||
// context.Information("Publishing {0}...", file.GetFilename().FullPath);
|
||||
// exitCode += StartProcess("dotnet",
|
||||
// new ProcessSettings {
|
||||
// Arguments = new ProcessArgumentBuilder()
|
||||
// .Append("gpr")
|
||||
// .Append("push")
|
||||
// .AppendQuoted(file.FullPath)
|
||||
// .AppendSwitchSecret("-k", " ", apiKey)
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// if(exitCode != 0)
|
||||
// {
|
||||
// throw new CakeException("Could not push GitHub packages.");
|
||||
// }
|
||||
// });
|
||||
|
||||
// Task("Publish-NuGet")
|
||||
// //.WithCriteria(ctx => BuildSystem.IsRunningOnGitHubActions, "Not running on GitHub Actions")
|
||||
// //.IsDependentOn("Package")
|
||||
// .Does(context =>
|
||||
// {
|
||||
// var apiKey = Argument<string>("nuget-key", null);
|
||||
// if(string.IsNullOrWhiteSpace(apiKey)) {
|
||||
// throw new CakeException("No NuGet API key was provided.");
|
||||
// }
|
||||
//
|
||||
// // Publish to GitHub Packages
|
||||
// foreach(var file in context.GetFiles("./.artifacts/*.nupkg"))
|
||||
// {
|
||||
// context.Information("Publishing {0}...", file.GetFilename().FullPath);
|
||||
// DotNetNuGetPush(file.FullPath, new DotNetNuGetPushSettings
|
||||
// {
|
||||
// Source = "https://api.nuget.org/v3/index.json",
|
||||
// ApiKey = apiKey,
|
||||
// SkipDuplicate = true
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Targets
|
||||
|
||||
// Task("Publish")
|
||||
// .IsDependentOn("Publish-GitHub")
|
||||
// .IsDependentOn("Publish-NuGet");
|
||||
|
||||
Task("Default")
|
||||
.IsDependentOn("Build");
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Execution
|
||||
|
||||
RunTarget(target)
|
@ -1,4 +0,0 @@
|
||||
dotnet build
|
||||
dotnet publish ./src/dot.csproj -f net7.0-windows -c Release -r win-x64 --sc -p:"PublishSingleFile=true" -o ./build/win-x64
|
||||
dotnet publish ./src/dot.csproj -f net7.0 -c Release -r linux-x64 --sc -p:"PublishSingleFile=true" -o ./build/linux-x64
|
||||
Remove-Item -r ./build/temp
|
16
dot.sln
@ -11,22 +11,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "meta", "meta", "{AD79881E-7
|
||||
.gitattributes = .gitattributes
|
||||
.gitignore = .gitignore
|
||||
.tgitconfig = .tgitconfig
|
||||
add-meta-files-to-sln.csx = add-meta-files-to-sln.csx
|
||||
build.ps1 = build.ps1
|
||||
code-cleanup-on-save.csx = code-cleanup-on-save.csx
|
||||
AddMetaFilesToSln.csx = AddMetaFilesToSln.csx
|
||||
build.cake = build.cake
|
||||
code-format.cmd = code-format.cmd
|
||||
CodeCleanupOnSave.csx = CodeCleanupOnSave.csx
|
||||
Directory.Build.props = Directory.Build.props
|
||||
dot.sln.DotSettings = dot.sln.DotSettings
|
||||
dot.sln.DotSettings.user = dot.sln.DotSettings.user
|
||||
dotnet-tools.json = dotnet-tools.json
|
||||
GenerateResx.targets = GenerateResx.targets
|
||||
git-clean.ps1 = git-clean.ps1
|
||||
git-clean.cmd = git-clean.cmd
|
||||
global.json = global.json
|
||||
ImageOptimize.csx = ImageOptimize.csx
|
||||
LICENSE = LICENSE
|
||||
README.md = README.md
|
||||
README.zh-CN.md = README.zh-CN.md
|
||||
safe-delete-unused-resx.ahk = safe-delete-unused-resx.ahk
|
||||
switch-nuget.ps1 = switch-nuget.ps1
|
||||
switch-project.ps1 = switch-project.ps1
|
||||
SafetyDelUnusedResx.ahk = SafetyDelUnusedResx.ahk
|
||||
switch-nuget.cmd = switch-nuget.cmd
|
||||
switch-project.cmd = switch-project.cmd
|
||||
switcher.json = switcher.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -1,3 +1,9 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Dot;
|
||||
|
||||
// ReSharper disable once UnusedType.Global
|
||||
@ -7,5 +13,51 @@ internal class CsxEditor
|
||||
#pragma warning disable CA1822
|
||||
private void Run()
|
||||
#pragma warning restore CA1822
|
||||
{ }
|
||||
{
|
||||
/*
|
||||
for %%i in (*.png) do pngquant %%i --force --output %%i --skip-if-larger
|
||||
for %%i in (*.jpg) do jpegtran -copy none -optimize -perfect %%i %%i
|
||||
*
|
||||
*/
|
||||
|
||||
var files = Directory.EnumerateFiles(".", "*.png"
|
||||
, new EnumerationOptions {
|
||||
RecurseSubdirectories = true
|
||||
, AttributesToSkip = FileAttributes.ReparsePoint
|
||||
, IgnoreInaccessible = true
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
|
||||
Parallel.ForEach(files, file => {
|
||||
var startInfo = new ProcessStartInfo {
|
||||
FileName = "pngquant"
|
||||
, Arguments
|
||||
= $"\"{file}\" --force --output \"{file}\" --skip-if-larger"
|
||||
};
|
||||
using var p = Process.Start(startInfo);
|
||||
p.WaitForExit();
|
||||
Console.WriteLine(p.ExitCode);
|
||||
});
|
||||
|
||||
files = new[] { "*.jpg", "*.jpeg" }
|
||||
.SelectMany(x => Directory.EnumerateFiles(
|
||||
".", x
|
||||
, new EnumerationOptions {
|
||||
RecurseSubdirectories = true
|
||||
, AttributesToSkip = FileAttributes.ReparsePoint
|
||||
, IgnoreInaccessible = true
|
||||
}))
|
||||
.ToArray();
|
||||
|
||||
Parallel.ForEach(files, file => {
|
||||
var startInfo = new ProcessStartInfo {
|
||||
FileName = "jpegtran"
|
||||
, Arguments = $"-copy none -optimize -perfect \"{file}\" \"{file}\""
|
||||
};
|
||||
using var p = Process.Start(startInfo);
|
||||
p.WaitForExit();
|
||||
Console.WriteLine(p.ExitCode);
|
||||
});
|
||||
}
|
||||
}
|
@ -29,6 +29,6 @@ app.Configure(config => {
|
||||
});
|
||||
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
|
||||
CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
|
||||
// CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
|
||||
// CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
|
||||
return app.Run(args);
|