topdata: remove completed legacy-migration cluster
The one-time legacy normalize migration finished; NormalizeProject had no production callers. Delete migrate.go, the 26 *_migrate.go files, the importLegacyItempropsRegistry cluster, loadLegacyTLK, and the 48 test blocks that only exercised them. mergeLegacyTLK moves to tlk_native.go because the live TLK compiler still uses it for base_dialog.json. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -6642,81 +6642,6 @@ func marshalOrderedLockfile(keys []string, lockData map[string]int, formatting j
|
||||
return buffer.Bytes(), nil
|
||||
}
|
||||
|
||||
func loadLegacyTLK(root string) (*legacyTLKData, error) {
|
||||
info, err := os.Stat(root)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
return nil, fmt.Errorf("legacy tlk root must be a directory: %s", root)
|
||||
}
|
||||
|
||||
result := &legacyTLKData{
|
||||
Language: "en",
|
||||
Entries: map[string]tlkEntryData{},
|
||||
Lock: map[string]int{},
|
||||
}
|
||||
|
||||
lockPath := filepath.Join(root, "lock.json")
|
||||
lockData, err := loadLockfile(lockPath)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
for key, id := range lockData {
|
||||
result.Lock[key] = id
|
||||
}
|
||||
|
||||
basePath := filepath.Join(root, "base.json")
|
||||
if _, err := os.Stat(basePath); err == nil {
|
||||
base, err := loadJSONObject(basePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if language, ok := base["language"].(string); ok && language != "" {
|
||||
result.Language = language
|
||||
}
|
||||
if entries, ok := base["entries"].(map[string]any); ok {
|
||||
normalized, err := normalizeLegacyTLKEntries(entries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for key, entry := range normalized {
|
||||
result.Entries[key] = entry
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modulesDir := filepath.Join(root, "modules")
|
||||
modulePaths, err := collectModulePaths(modulesDir)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return result, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
for _, path := range modulePaths {
|
||||
obj, err := loadJSONObject(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
entries, ok := obj["entries"].(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
normalized, err := normalizeLegacyTLKEntries(entries)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %w", path, err)
|
||||
}
|
||||
for key, entry := range normalized {
|
||||
result.Entries[key] = entry
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func normalizeLegacyTLKEntries(entries map[string]any) (map[string]tlkEntryData, error) {
|
||||
normalized := map[string]tlkEntryData{}
|
||||
for _, key := range sortedKeys(entries) {
|
||||
|
||||
Reference in New Issue
Block a user