forked from kimhyungsik/ax_hub_mcp_tool
chore: remove legacy migration and refactoring scripts
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
public class RefactorPackage {
|
||||
|
||||
static final String ROOT_DIR = ".";
|
||||
|
||||
static final String[] DIR_RENAMES = {
|
||||
"./axhub-gateway/src/main/java/io/shinhanlife/axhub/biz/mcp/gateway/controller",
|
||||
"./axhub-gateway/src/main/java/io/shinhanlife/axhub/biz/mcp/gateway/presentation",
|
||||
"./axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/controller",
|
||||
"./axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/presentation"
|
||||
};
|
||||
|
||||
static final String[][] STRING_REPLACEMENTS = {
|
||||
{"io.shinhanlife.axhub.biz.mcp.gateway.controller", "io.shinhanlife.axhub.biz.mcp.gateway.presentation"},
|
||||
{"io.shinhanlife.axhub.biz.mcp.tool.controller", "io.shinhanlife.axhub.biz.mcp.tool.presentation"}
|
||||
};
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// 1. Rename Directories
|
||||
for (int i = 0; i < DIR_RENAMES.length; i += 2) {
|
||||
File srcDir = new File(DIR_RENAMES[i]);
|
||||
File destDir = new File(DIR_RENAMES[i+1]);
|
||||
if (srcDir.exists() && srcDir.isDirectory()) {
|
||||
boolean success = srcDir.renameTo(destDir);
|
||||
System.out.println("Renamed " + srcDir.getPath() + " to " + destDir.getPath() + " : " + success);
|
||||
} else {
|
||||
System.out.println("Source dir not found or not a directory: " + srcDir.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Replace string contents in all .java files
|
||||
Files.walkFileTree(Paths.get(ROOT_DIR), new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
|
||||
String name = dir.getFileName().toString();
|
||||
if (name.equals(".git") || name.equals("build") || name.equals(".gradle") || name.equals("out") || name.equals("bin") || name.equals("scratch")) {
|
||||
return FileVisitResult.SKIP_SUBTREE;
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
if (file.toString().endsWith(".java") && !file.getFileName().toString().equals("RefactorPackage.java") && !file.getFileName().toString().equals("AddJavadoc.java")) {
|
||||
processJavaFile(file);
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
System.out.println("Done.");
|
||||
}
|
||||
|
||||
private static void processJavaFile(Path file) throws IOException {
|
||||
String content = new String(Files.readAllBytes(file), "UTF-8");
|
||||
boolean modified = false;
|
||||
|
||||
for (String[] rep : STRING_REPLACEMENTS) {
|
||||
if (content.contains(rep[0])) {
|
||||
content = content.replace(rep[0], rep[1]);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
Files.write(file, content.getBytes("UTF-8"));
|
||||
System.out.println("Updated imports/package in: " + file);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
migrate2.ps1
33
migrate2.ps1
@@ -1,33 +0,0 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$source = "C:\Users\Admin\.gemini\antigravity\scratch\shinhan-mcp-prebuild\src\main\java\com\shinhan\mcp"
|
||||
$dest = "C:\Users\Admin\.gemini\antigravity\scratch\axhub-backend-main\src\main\java\io\shinhanlife\axhub\biz\mcp"
|
||||
$commonDest = "C:\Users\Admin\.gemini\antigravity\scratch\axhub-backend-main\src\main\java\io\shinhanlife\axhub\common\mcp"
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $dest | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path $commonDest | Out-Null
|
||||
|
||||
Copy-Item -Path "$source\gateway" -Destination $dest -Recurse -Force
|
||||
Copy-Item -Path "$source\tool" -Destination $dest -Recurse -Force
|
||||
Copy-Item -Path "$source\adapter" -Destination $dest -Recurse -Force
|
||||
Copy-Item -Path "$source\common\*" -Destination $commonDest -Recurse -Force
|
||||
|
||||
# We also need to delete the leftover Application classes from shinhan-mcp-prebuild
|
||||
Remove-Item -Path "$dest\gateway\GatewayApplication.java" -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "$dest\tool\ToolApplication.java" -ErrorAction SilentlyContinue
|
||||
|
||||
# Replace package names safely with UTF-8
|
||||
$utf8 = New-Object System.Text.UTF8Encoding($false)
|
||||
Get-ChildItem -Path $dest, $commonDest -Filter *.java -Recurse | ForEach-Object {
|
||||
$content = [System.IO.File]::ReadAllText($_.FullName, $utf8)
|
||||
|
||||
$content = $content -replace "package com.shinhan.mcp.common", "package io.shinhanlife.axhub.common.mcp"
|
||||
$content = $content -replace "import com.shinhan.mcp.common", "import io.shinhanlife.axhub.common.mcp"
|
||||
|
||||
$content = $content -replace "package com.shinhan.mcp", "package io.shinhanlife.axhub.biz.mcp"
|
||||
$content = $content -replace "import com.shinhan.mcp", "import io.shinhanlife.axhub.biz.mcp"
|
||||
|
||||
# Do NOT do wild regex replacements for service/util/etc.
|
||||
|
||||
[System.IO.File]::WriteAllText($_.FullName, $content, $utf8)
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
|
||||
|
||||
$files = Get-ChildItem -Recurse -Filter *.java | Where-Object { $_.FullName -match "\\dto\\" -and $_.Name -notmatch "(Request|Response)\.java" -and $_.Name -ne "SampleGlowMessage.java" }
|
||||
|
||||
foreach ($file in $files) {
|
||||
# Read as UTF8 (it usually handles CP949 okay if characters don't conflict, but let's be safe and use raw bytes if needed. Actually Get-Content is fine if the file is already UTF-8 or CP949)
|
||||
$content = Get-Content -Path $file.FullName -Raw -Encoding UTF8
|
||||
|
||||
# 1. Remove @Data if it exists
|
||||
$content = $content -replace '(?m)^\s*@Data\s*\r?\n', ''
|
||||
|
||||
# 2. Check if it's an interface or enum, skip if so
|
||||
if ($content -match 'public interface ' -or $content -match 'public enum ') {
|
||||
continue
|
||||
}
|
||||
|
||||
# 3. Add imports if they don't exist
|
||||
$imports = @("lombok.Getter", "lombok.Setter", "lombok.Builder", "lombok.NoArgsConstructor", "lombok.AllArgsConstructor")
|
||||
$importBlock = ""
|
||||
foreach ($imp in $imports) {
|
||||
if (-not ($content -match "import $imp;")) {
|
||||
$importBlock += "import $imp;`r`n"
|
||||
}
|
||||
}
|
||||
|
||||
if ($importBlock -ne "") {
|
||||
# Insert imports after package declaration
|
||||
$content = $content -replace '(?m)^(package\s+[^;]+;)\r?\n', "`$1`r`n`r`n$importBlock"
|
||||
}
|
||||
|
||||
# 4. Add annotations if they don't exist
|
||||
$annotations = @()
|
||||
if (-not ($content -match '@Getter')) { $annotations += "@Getter" }
|
||||
if (-not ($content -match '@Setter')) { $annotations += "@Setter" }
|
||||
if (-not ($content -match '@Builder')) { $annotations += "@Builder" }
|
||||
if (-not ($content -match '@NoArgsConstructor')) { $annotations += "@NoArgsConstructor" }
|
||||
if (-not ($content -match '@AllArgsConstructor')) { $annotations += "@AllArgsConstructor" }
|
||||
|
||||
if ($annotations.Count -gt 0) {
|
||||
$annoStr = ($annotations -join "`r`n") + "`r`n"
|
||||
# Insert annotations before public class
|
||||
$content = $content -replace '(?m)^(public\s+class\s+)', "$annoStr`$1"
|
||||
}
|
||||
|
||||
# 5. Fix manual constructors
|
||||
$content = $content -replace '(?m)^\s*public\s+ToolMetadata\(\)\s*\{\}\s*\r?\n', ''
|
||||
$content = $content -replace '(?m)^\s*public\s+ZtUsacInDto\(\)\s*\{\s*setPuseYn\("Y"\);\s*\}\s*\r?\n', ''
|
||||
|
||||
# Fix puseYn default
|
||||
if ($file.Name -eq "ZtUsacInDto.java") {
|
||||
$content = $content -replace 'private String puseYn;', '@Builder.Default`r`n private String puseYn = "Y";'
|
||||
}
|
||||
|
||||
# Fix AuditInfo Builder conflict
|
||||
if ($file.Name -eq "AuditInfo.java") {
|
||||
$content = $content -replace '(?m)^@Builder\r?\n', ''
|
||||
}
|
||||
|
||||
# Write without BOM
|
||||
[System.IO.File]::WriteAllText($file.FullName, $content, $Utf8NoBomEncoding)
|
||||
Write-Host "Processed: $($file.Name)"
|
||||
}
|
||||
Reference in New Issue
Block a user