mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-08-02 10:16:00 +08:00
wip: 🧠 初步的框架
This commit is contained in:
6
tools/CloneProjectRefs.ps1
Normal file
6
tools/CloneProjectRefs.ps1
Normal file
@ -0,0 +1,6 @@
|
||||
$refs = ('https://github.com/nsnail/ns-ext.git', 'https://github.com/nsnail/Furion.git', 'https://github.com/nsnail/FreeSql.git')
|
||||
|
||||
foreach ($item in $refs)
|
||||
{
|
||||
git clone --depth 1 --config "http.proxy=http://127.0.0.1:1081" $item "../refs/$( [regex]::Match($item, '/([^/]+)\.git$').Groups[1] )"
|
||||
}
|
44
tools/CodeCleanup.csx
Normal file
44
tools/CodeCleanup.csx
Normal file
@ -0,0 +1,44 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
|
||||
{
|
||||
var files = string.Join(
|
||||
';',
|
||||
Args[0]
|
||||
.Split('\n', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(x => x.Replace('\\', '/').Trim())
|
||||
);
|
||||
|
||||
Console.WriteLine(files);
|
||||
|
||||
using var p = Process.Start(
|
||||
new ProcessStartInfo
|
||||
{
|
||||
CreateNoWindow = true,
|
||||
FileName = "dotnet",
|
||||
Arguments = $"jb cleanupcode --include=\"{files}\" --no-build ../NetAdmin.sln",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true
|
||||
}
|
||||
);
|
||||
p.WaitForExit();
|
||||
Console.WriteLine(p.StandardOutput.ReadToEnd());
|
||||
|
||||
using var p2 = Process.Start(
|
||||
new ProcessStartInfo
|
||||
{
|
||||
CreateNoWindow = true,
|
||||
FileName = "git",
|
||||
Arguments = $"status",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true
|
||||
}
|
||||
);
|
||||
p2.WaitForExit();
|
||||
var content = p2.StandardOutput.ReadToEnd();
|
||||
Console.WriteLine(content);
|
||||
|
||||
return content.Contains("working tree clean") ? 0 : 1;
|
||||
}
|
7
tools/CodeCleanup.ps1
Normal file
7
tools/CodeCleanup.ps1
Normal file
@ -0,0 +1,7 @@
|
||||
$files = $( foreach ($line in $( git diff head origin/dev --stat-width 200 ) | findstr '\|')
|
||||
{
|
||||
$line.split('\|')[0].trim()
|
||||
} ) -join ';'
|
||||
echo $files
|
||||
dotnet jb cleanupcode --no-build --include = "$files" ../NetAdmin.sln
|
||||
dotnet script ../PushSign.csx
|
1
tools/CodeCleanupFull.ps1
Normal file
1
tools/CodeCleanupFull.ps1
Normal file
@ -0,0 +1 @@
|
||||
dotnet jb cleanupcode --no-build ../NetAdmin.sln
|
3
tools/DotClean.cmd
Normal file
3
tools/DotClean.cmd
Normal file
@ -0,0 +1,3 @@
|
||||
dot rbom ../ -w -e refs -e .git -e node_modules
|
||||
dot trim ../ -w -e refs -e .git -e node_modules
|
||||
dot tolf ../ -w -e refs -e .git -e node_modules
|
2
tools/GenerateLn.cmd
Normal file
2
tools/GenerateLn.cmd
Normal file
@ -0,0 +1,2 @@
|
||||
dotnet t4 ./GenerateLnResx.tt -o ../assets/resx/Ln.resx
|
||||
dotnet t4 ./GenerateLnCs.tt -o ../dist/Server/NetAdmin.Infrastructure/Ln.cs
|
78
tools/GenerateLnCs.tt
Normal file
78
tools/GenerateLnCs.tt
Normal file
@ -0,0 +1,78 @@
|
||||
<#@ template language="C#" #>
|
||||
<#@ assembly name="System.Xml" #>
|
||||
<#@ output encoding="utf-8" extension="Designer.cs" #>
|
||||
<#@ import namespace="System.Xml" #>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace NetAdmin.Infrastructure.Languages;
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[DebuggerNonUserCode]
|
||||
[CompilerGenerated]
|
||||
public sealed class Ln
|
||||
{
|
||||
private static ResourceManager _resourceMan;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Ln" /> class.
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
public Ln() { }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
public static ResourceManager ResourceManager {
|
||||
get {
|
||||
if (ReferenceEquals(_resourceMan, null)) {
|
||||
var temp = new ResourceManager("NetAdmin.Infrastructure.Languages.Ln", typeof(Ln).Assembly);
|
||||
_resourceMan = temp;
|
||||
}
|
||||
|
||||
return _resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
public static CultureInfo Culture { get; set; }
|
||||
<#
|
||||
var xml = new XmlDocument();
|
||||
xml.Load("../assets/resx/Ln.resx");
|
||||
foreach (XmlNode data in xml.SelectNodes("//root/data")!)
|
||||
{
|
||||
#>
|
||||
/// <summary>
|
||||
/// <#= data.SelectSingleNode("value")?.InnerText #>
|
||||
/// </summary>
|
||||
public static string <#=
|
||||
data.Attributes!["name"].Value.Replace(" ", "_") #> => ResourceManager.GetString("<#= data.Attributes!["name"].Value #>", Culture);
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
36
tools/GenerateLnResx.tt
Normal file
36
tools/GenerateLnResx.tt
Normal file
@ -0,0 +1,36 @@
|
||||
<#@ template language="C#" #>
|
||||
<#@ output encoding="utf-8" extension="resx" #>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
|
||||
id="root"
|
||||
xmlns="">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
<#
|
||||
var regex = new System.Text.RegularExpressions.Regex(@"^\d", System.Text.RegularExpressions.RegexOptions.Compiled);
|
||||
foreach (var line in System.IO.File.ReadLines("../assets/resx/ln.txt"))
|
||||
{
|
||||
#>
|
||||
<data name="<#= regex.IsMatch(line) ? "_" : "" #><#= line #>" xml:space="preserve"><value><#= line #></value></data>
|
||||
<#
|
||||
}
|
||||
#>
|
||||
</root>
|
26
tools/GitPR.ps1
Normal file
26
tools/GitPR.ps1
Normal file
@ -0,0 +1,26 @@
|
||||
$types = @{
|
||||
'1' = @('FEA', '新增特性')
|
||||
'2' = @('REF', '项目重构')
|
||||
'3' = @('FIX', '缺陷修复')
|
||||
'4' = @('PER', '性能优化')
|
||||
'5' = @('RVT', '还原变更')
|
||||
'6' = @('FMT', '格式整理')
|
||||
'7' = @('DOC', '文档变更')
|
||||
'8' = @('TST', '单元测试')
|
||||
'9' = @('BLD', '工程构建')
|
||||
}
|
||||
git add ../
|
||||
$prefix = ''
|
||||
while ($null -eq $types[$prefix])
|
||||
{
|
||||
$prefix = Read-Host "请选择提交类型`n" $( & { param($i) $i | ForEach-Object { "$_ : $( $types[$_][0] )($( $types[$_][1] ))`n" } } $types.Keys | Sort-Object )
|
||||
}
|
||||
git commit -m "[$($types[$prefix][0])] $(($(Read-Host '是否跳过自动构建?(y/N)') -eq 'y') ? '[SKIP CI] ': '')$(Read-Host '请输入提交消息')"
|
||||
$branch = $(git branch --show-current)
|
||||
& './DotClean.cmd'
|
||||
git add ../
|
||||
git commit --amend --no-edit
|
||||
git pull
|
||||
git push --set-upstream origin $branch
|
||||
Start-Process -FilePath "http://git.shequnpay.com/lingyun/NetAdmin/compare/dev...$branch"
|
||||
Pause
|
6
tools/GitRecreate.ps1
Normal file
6
tools/GitRecreate.ps1
Normal file
@ -0,0 +1,6 @@
|
||||
$branch = $(git branch --show-current)
|
||||
git checkout dev
|
||||
git pull
|
||||
git branch -D $branch
|
||||
git branch $branch
|
||||
git checkout $branch
|
37
tools/IdGenerator.linq
Normal file
37
tools/IdGenerator.linq
Normal file
@ -0,0 +1,37 @@
|
||||
<Query Kind="Program">
|
||||
<NuGetReference>Yitter.IdGenerator</NuGetReference>
|
||||
<Namespace>Yitter.IdGenerator</Namespace>
|
||||
</Query>
|
||||
|
||||
void Main()
|
||||
{
|
||||
//第1步,全局 初始化(应用程序启动时执行一次):
|
||||
|
||||
// 创建 IdGeneratorOptions 对象,可在构造函数中输入 WorkerId:
|
||||
var options = new IdGeneratorOptions();
|
||||
// options.WorkerIdBitLength = 10; // 默认值6,限定 WorkerId 最大值为2^6-1,即默认最多支持64个节点。
|
||||
// options.SeqBitLength = 6; // 默认值6,限制每毫秒生成的ID个数。若生成速度超过5万个/秒,建议加大 SeqBitLength 到 10。
|
||||
// options.BaseTime = Your_Base_Time; // 如果要兼容老系统的雪花算法,此处应设置为老系统的BaseTime。
|
||||
// ...... 其它参数参考 IdGeneratorOptions 定义。
|
||||
|
||||
// 保存参数(务必调用,否则参数设置不生效):
|
||||
YitIdHelper.SetIdGenerator(options);
|
||||
|
||||
// 以上过程只需全局一次,且应在生成ID之前完成。
|
||||
//第2步,生成ID:
|
||||
|
||||
// 初始化后,在任何需要生成ID的地方,调用以下方法:
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
var newId = YitIdHelper.NextId();
|
||||
Console.WriteLine(newId);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
Console.WriteLine(Guid.NewGuid());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// You can define other methods, fields, classes and namespaces here
|
65
tools/ImageOptimize.csx
Normal file
65
tools/ImageOptimize.csx
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
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}");
|
||||
}
|
||||
);
|
2
tools/InstallAsTpl.ps1
Normal file
2
tools/InstallAsTpl.ps1
Normal file
@ -0,0 +1,2 @@
|
||||
dotnet new uninstall ../
|
||||
dotnet new --install ../
|
22
tools/Switcher.FreeSql.json
Normal file
22
tools/Switcher.FreeSql.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"solution": "../NetAdmin.sln",
|
||||
"mappings": {
|
||||
"FreeSql.NS": "../refs/FreeSql/FreeSql/FreeSql.csproj",
|
||||
"FreeSql.DbContext.NS": "../refs/FreeSql/FreeSql.DbContext/FreeSql.DbContext.csproj"
|
||||
},
|
||||
"restore": [
|
||||
{
|
||||
"name": "NetAdmin.Infrastructure",
|
||||
"packages": [
|
||||
{
|
||||
"packageName": "FreeSql.NS",
|
||||
"version": "3.2.700-preview20230726-ns1"
|
||||
},
|
||||
{
|
||||
"packageName": "FreeSql.DbContext.NS",
|
||||
"version": "3.2.700-preview20230726-ns1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
17
tools/Switcher.Furion.json
Normal file
17
tools/Switcher.Furion.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"solution": "../NetAdmin.sln",
|
||||
"mappings": {
|
||||
"Furion.Pure.NS": "../refs/Furion/framework/Furion.Pure/Furion.Pure.csproj"
|
||||
},
|
||||
"restore": [
|
||||
{
|
||||
"name": "NetAdmin.Infrastructure",
|
||||
"packages": [
|
||||
{
|
||||
"packageName": "Furion.Pure.NS",
|
||||
"version": "4.8.8.38-ns1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
17
tools/Switcher.NSExt.json
Normal file
17
tools/Switcher.NSExt.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"solution": "../NetAdmin.sln",
|
||||
"mappings": {
|
||||
"NSExt": "../refs/ns-ext/src/NSExt/NSExt.csproj"
|
||||
},
|
||||
"restore": [
|
||||
{
|
||||
"name": "NetAdmin.Infrastructure",
|
||||
"packages": [
|
||||
{
|
||||
"packageName": "NSExt",
|
||||
"version": "1.0.15-alpha.0.4"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
27
tools/Switcher.ps1
Normal file
27
tools/Switcher.ps1
Normal file
@ -0,0 +1,27 @@
|
||||
# https://github.com/RicoSuter/DNT#switch-to-projects
|
||||
$targets = @{
|
||||
'1' = 'switch-to-projects'
|
||||
'2' = 'switch-to-packages'
|
||||
}
|
||||
$key = ''
|
||||
while ($null -eq $targets[$key])
|
||||
{
|
||||
$key = Read-Host '请选择:1(切换到项目引用) 2(切换到Nuget包引用)'
|
||||
}
|
||||
$files = Get-ChildItem Switcher.*.json
|
||||
$file = 9999
|
||||
while ($null -eq $files[[int]$file - 1])
|
||||
{
|
||||
$i = 0
|
||||
Write-Host '请选择要切换的配置文件文件'
|
||||
foreach ($file in $files)
|
||||
{
|
||||
$i++
|
||||
Write-Host $i $file.Name
|
||||
}
|
||||
$file = Read-Host
|
||||
}
|
||||
$file = [int]$file - 1
|
||||
Copy-Item $files[$file] 'switcher.json' -Force
|
||||
dotnet dnt $targets[$key]
|
||||
Remove-Item switcher.json
|
33
tools/SyncMetaFiles.csx
Normal file
33
tools/SyncMetaFiles.csx
Normal file
@ -0,0 +1,33 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
var slnFile = Directory.GetFiles(@"../", "*.sln").First();
|
||||
var content = File.ReadAllText(slnFile);
|
||||
|
||||
content = Regex.Replace(
|
||||
content,
|
||||
"Project\\(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\"\\) = \"meta\", \"meta\", \"{5198A03D-0CAC-4828-A807-34A693F73859}\"(?:.|\n)*?EndProject",
|
||||
$$"""
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "meta", "meta", "{5198A03D-0CAC-4828-A807-34A693F73859}"
|
||||
{{'\t'}}ProjectSection(SolutionItems) = preProject
|
||||
{{string.Join('\n',
|
||||
Directory.GetFiles(@"../", "*").Where(x => !x.EndsWith(".sln") && !x.EndsWith(".user"))
|
||||
.Select(x=>$"\t\t{Path.GetFileName(x)} = {Path.GetFileName(x)}")
|
||||
)}}
|
||||
{{'\t'}}EndProject
|
||||
"""
|
||||
);
|
||||
content = Regex.Replace(
|
||||
content,
|
||||
"Project\\(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\"\\) = \"tools\", \"tools\", \"{2D81D62C-1B2E-4758-84C6-728343CB734F}\"(?:.|\n)*?EndProject",
|
||||
$$"""
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{2D81D62C-1B2E-4758-84C6-728343CB734F}"
|
||||
{{'\t'}}ProjectSection(SolutionItems) = preProject
|
||||
{{string.Join('\n',
|
||||
Directory.GetFiles(@"../tools", "*").Where(x => !x.EndsWith(".sln") && !x.EndsWith(".user"))
|
||||
.Select(x=>$"\t\t{Path.GetFileName(x)} = tools/{Path.GetFileName(x)}")
|
||||
)}}
|
||||
{{'\t'}}EndProject
|
||||
"""
|
||||
);
|
||||
Console.WriteLine(content);
|
||||
File.WriteAllText(slnFile, content);
|
Reference in New Issue
Block a user