elder-yudao-pro/deploy/local/prepare-idea.sh

42 lines
1.7 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
# shellcheck disable=SC1091
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
export ELDER_LOG_FILE="$RUNTIME_DIR/application.log"
mkdir -p "$REPO_DIR/.run"
python3 - "$REPO_DIR/.run/ElderYudaoLocal.run.xml" <<'PY'
import os
import sys
import xml.etree.ElementTree as ET
path = sys.argv[1]
component = ET.Element('component', {'name': 'ProjectRunConfigurationManager'})
config = ET.SubElement(component, 'configuration', {
'default': 'false',
'name': 'ElderYudao Local',
'type': 'SpringBootApplicationConfigurationType',
'factoryName': 'Spring Boot',
})
ET.SubElement(config, 'option', {'name': 'ACTIVE_PROFILES', 'value': 'local,desktop'})
ET.SubElement(config, 'module', {'name': 'yudao-server'})
ET.SubElement(config, 'option', {'name': 'SPRING_BOOT_MAIN_CLASS', 'value': 'cn.iocoder.yudao.server.YudaoServerApplication'})
ET.SubElement(config, 'option', {'name': 'WORKING_DIRECTORY', 'value': '$PROJECT_DIR$'})
ET.SubElement(config, 'option', {'name': 'VM_PARAMETERS', 'value': '-Dfile.encoding=UTF-8'})
envs = ET.SubElement(config, 'envs')
keys = ('ELDER_DB_HOST', 'ELDER_DB_PORT', 'ELDER_DB_NAME', 'ELDER_DB_USER',
'ELDER_DB_PASSWORD', 'ELDER_REDIS_HOST', 'ELDER_REDIS_PORT',
'ELDER_REDIS_DATABASE', 'ELDER_REDIS_PASSWORD', 'ELDER_SERVER_PORT',
'ELDER_LOG_FILE')
for key in keys:
ET.SubElement(envs, 'env', {'name': key, 'value': os.environ.get(key, '')})
ET.SubElement(config, 'method', {'v': '2'})
tree = ET.ElementTree(component)
ET.indent(tree, space=' ')
tree.write(path, encoding='utf-8', xml_declaration=True)
PY
echo "已生成 IDEA 配置:$REPO_DIR/.run/ElderYudaoLocal.run.xml"
echo '在 IDEA 选择 ElderYudao Local,确认使用 local,desktop 后启动。'