forked from kimhyungsik/ax_hub_mcp_tool
60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
import os
|
|
import glob
|
|
import re
|
|
|
|
def replace_in_file(path, replacements):
|
|
with open(path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
original = content
|
|
for old, new in replacements:
|
|
content = content.replace(old, new)
|
|
if original != content:
|
|
with open(path, 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
|
|
# 1. Rename Main Applications
|
|
base_oth = 'c:/egov/workspace/dap-tool/dap-was-oth/src/main/java/io/shinhanlife/dap/mcc/oth/'
|
|
if os.path.exists(base_oth + 'DapToolOthApplication.java'):
|
|
os.rename(base_oth + 'DapToolOthApplication.java', base_oth + 'DapWasOthApplication.java')
|
|
|
|
base_sms = 'c:/egov/workspace/dap-tool/dap-was-sms/src/main/java/io/shinhanlife/dap/mcc/sms/'
|
|
if os.path.exists(base_sms + 'DapToolSmsApplication.java'):
|
|
os.rename(base_sms + 'DapToolSmsApplication.java', base_sms + 'DapWasSmsApplication.java')
|
|
|
|
# Replace DapTool...Application in code
|
|
java_files = glob.glob('c:/egov/workspace/dap-tool/dap-was-*/**/*.java', recursive=True)
|
|
for f in java_files:
|
|
replace_in_file(f, [
|
|
('DapToolOthApplication', 'DapWasOthApplication'),
|
|
('DapToolSmsApplication', 'DapWasSmsApplication'),
|
|
('DapTool%sApplication', 'DapWas%sApplication'),
|
|
('dap-tool-', 'dap-was-'),
|
|
('dap-tool-core', 'dap-was-lib'),
|
|
('[Gateway Not Found]', '[WAS Not Found]'),
|
|
('[Gateway Bad Request]', '[WAS Bad Request]'),
|
|
('[Gateway Internal Error]', '[WAS Internal Error]'),
|
|
('[Gateway Fatal Error]', '[WAS Fatal Error]'),
|
|
('Shinhan MCP Gateway API 명세서', 'Shinhan MCP WAS API 명세서'),
|
|
('Gateway Pod (8081)', 'WAS Pod')
|
|
])
|
|
|
|
# Remove gateway from PodScaffolder.java
|
|
pod = 'c:/egov/workspace/dap-tool/dap-was-lib/src/main/java/io/shinhanlife/dap/lib/util/PodScaffolder.java'
|
|
replace_in_file(pod, [
|
|
(' gateway:\n url: http://localhost:${server.port}/api/gateway\n', '')
|
|
])
|
|
|
|
# 2. Update logback-spring.xml
|
|
xml_files = glob.glob('c:/egov/workspace/dap-tool/**/logback-spring.xml', recursive=True)
|
|
for f in xml_files:
|
|
replace_in_file(f, [('dap-tool-', 'dap-was-')])
|
|
|
|
# 3. Update application.yml (Remove gateway blocks)
|
|
yml_files = glob.glob('c:/egov/workspace/dap-tool/**/*.yml', recursive=True)
|
|
for f in yml_files:
|
|
replace_in_file(f, [
|
|
(' gateway:\n url: http://localhost:${server.port}/api/gateway\n', '')
|
|
])
|
|
|
|
print("Fix applied.")
|