feat(i18n): 完成 localized patch 发布回滚闭环
bat-rust / Build and test Rust (push) Canceled after 0s
bat-rust / Build and test Go API (push) Canceled after 0s

Closes #45
This commit is contained in:
2026-08-31 00:02:55 +08:00
parent f441f1810e
commit ab21344773
26 changed files with 1916 additions and 140 deletions
+41 -10
View File
@@ -299,13 +299,25 @@ pub(super) fn run_repack(options: &CliOptions) -> anyhow::Result<()> {
print_report(options.output_format, &report)
}
pub(super) fn run_publish_localized(options: &CliOptions) -> anyhow::Result<()> {
let translation_file = options
.translation_file
.as_ref()
.ok_or_else(|| anyhow::anyhow!("publish-localized 必须指定 --translation-file"))?;
pub(super) fn publish_localized_report(
options: &CliOptions,
) -> anyhow::Result<LocalizedPatchReport> {
let (resource_root, official_release_id) = current_official_release(options)?;
let workbench = read_translation_workbench(translation_file)?;
let workbench = if options.translation_from_worker {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?;
runtime.block_on(completed_worker_translation_workbench(
&resource_root,
&official_release_id,
))?
} else {
let translation_file = options
.translation_file
.as_ref()
.ok_or_else(|| anyhow::anyhow!("publish-localized 必须指定 --translation-file"))?;
read_translation_workbench(translation_file)?
};
if workbench.official_release_id != official_release_id {
return Err(anyhow::anyhow!(
"翻译工作台 release={} 与当前官方 release={} 不一致;请重新导出",
@@ -319,7 +331,7 @@ pub(super) fn run_publish_localized(options: &CliOptions) -> anyhow::Result<()>
"翻译工作台资源根目录与当前 release 不一致;请重新导出"
));
}
let patches = localized_text_asset_patches(&resource_root, &workbench)?;
let operations = localized_patch_operations(&resource_root, &workbench)?;
let localized_release_id = options.localized_release_id.clone().or_else(|| {
options
.config
@@ -330,17 +342,36 @@ pub(super) fn run_publish_localized(options: &CliOptions) -> anyhow::Result<()>
resource_root,
options.config.localized_output_root.clone(),
official_release_id,
patches,
Vec::new(),
)
.with_operations(operations)
.with_force(options.config.force);
if let Some(release_id) = localized_release_id {
config = config.with_localized_release_id(release_id);
}
let report = LocalizedPatchService::new().publish(&config)?;
LocalizedPatchService::new().publish(&config)
}
pub(super) fn run_publish_localized(options: &CliOptions) -> anyhow::Result<()> {
let report = publish_localized_report(options)?;
print_report(options.output_format, &report)
}
fn current_official_release(options: &CliOptions) -> anyhow::Result<(PathBuf, String)> {
pub(super) fn localized_rollback_report(
options: &CliOptions,
) -> anyhow::Result<LocalizedRollbackReport> {
LocalizedPatchService::new().rollback(
&options.config.localized_output_root,
options.localized_release_id.as_deref(),
)
}
pub(super) fn run_localized_rollback(options: &CliOptions) -> anyhow::Result<()> {
let report = localized_rollback_report(options)?;
print_report(options.output_format, &report)
}
pub(super) fn current_official_release(options: &CliOptions) -> anyhow::Result<(PathBuf, String)> {
let state = read_version_state(&options.config.version_state_path())?;
let resource_root = if let Some(resource_root) = options.resource_root.clone() {
lexical_absolute(&resource_root).map_err(anyhow::Error::msg)?