feat: readoorDict 打包按版本轨道替换 IPA 版本号与构建号
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
11f4035da7
commit
311234bd74
@@ -202,6 +202,20 @@ def _apply_dictionary_config(build_dir: Path, config: dict, messages: list[str])
|
||||
messages.append("已替换词典版本配置")
|
||||
|
||||
|
||||
def _apply_dictionary_version(build_dir: Path, config: dict, messages: list[str]):
|
||||
"""词典包的 IPA 版本号与构建号同样按版本轨道写入工程(与 readoor31 一致,替换工程内全部构建配置)。"""
|
||||
project = build_dir / "readoor.xcodeproj" / "project.pbxproj"
|
||||
version, build_version = config.get("VERSION", ""), config.get("BUILD_VERSION", "")
|
||||
replacements = [
|
||||
("MARKETING_VERSION =", f"\t\t\t\tMARKETING_VERSION = {version};"),
|
||||
("CURRENT_PROJECT_VERSION =", f"\t\t\t\tCURRENT_PROJECT_VERSION = {build_version};"),
|
||||
]
|
||||
missing = [keyword for keyword, line in replacements if _replace_lines(project, keyword, line) == 0]
|
||||
if missing:
|
||||
raise ProjectPatchError(f"未找到待替换配置: {', '.join(missing)}")
|
||||
messages.append(f"已替换词典包版本: {version} ({build_version})")
|
||||
|
||||
|
||||
def apply_project_config(build_dir: Path, config: dict, definition: dict = None) -> list[str]:
|
||||
"""写入项目配置,返回适合实时日志展示的变更说明。
|
||||
|
||||
@@ -213,6 +227,7 @@ def apply_project_config(build_dir: Path, config: dict, definition: dict = None)
|
||||
messages: list[str] = []
|
||||
if config.get("SCHEME") == "readoorDict":
|
||||
_apply_dictionary_config(build_dir, config, messages)
|
||||
_apply_dictionary_version(build_dir, config, messages)
|
||||
_write_export_options(build_dir, config)
|
||||
return messages
|
||||
|
||||
|
||||
@@ -145,11 +145,17 @@ def _dict_build(tmp_path):
|
||||
macro = tmp_path / "readoor" / "BookShelf" / "Classes" / "Macro" / "STSConstantsMacro.h"
|
||||
macro.parent.mkdir(parents=True)
|
||||
macro.write_text(_DICT_MACRO, encoding="utf-8")
|
||||
project = tmp_path / "readoor.xcodeproj"
|
||||
project.mkdir()
|
||||
(project / "project.pbxproj").write_text(
|
||||
"\t\t\t\tMARKETING_VERSION = 2.192.3;\n\t\t\t\tCURRENT_PROJECT_VERSION = 2.192.3;\n", encoding="utf-8"
|
||||
)
|
||||
return macro
|
||||
|
||||
|
||||
def _dict_config(**extra):
|
||||
return {"SCHEME": "readoorDict", "VERSION": "2.0.0", "SERVER": "词典测试", "APPID": "1593413622",
|
||||
return {"SCHEME": "readoorDict", "VERSION": "2.0.0", "BUILD_VERSION": "2.0.0.3",
|
||||
"SERVER": "词典测试", "APPID": "1593413622",
|
||||
"NO_CERT": True, "BUILD_TYPE": "Ad_Hoc", **extra}
|
||||
|
||||
|
||||
@@ -159,6 +165,10 @@ def test_dict_env_macros_replaced_only_in_targettype_2(tmp_path):
|
||||
content = macro.read_text()
|
||||
|
||||
assert '#define SOURCE_VERSION @"2.0.0"' in content
|
||||
pbxproj = (tmp_path / "readoor.xcodeproj" / "project.pbxproj").read_text()
|
||||
assert "MARKETING_VERSION = 2.0.0;" in pbxproj
|
||||
assert "CURRENT_PROJECT_VERSION = 2.0.0.3;" in pbxproj
|
||||
assert "2.192.3" not in pbxproj
|
||||
assert '#define APPID @"1593413622"' in content
|
||||
assert '#define SERVERURL @"http://api-stage3/"' in content
|
||||
assert '#define LOGSERVERURL @"http://log-dev/"' in content
|
||||
|
||||
Reference in New Issue
Block a user