@@ -866,6 +866,8 @@ def create_page_package(self, param: CreatePagePackageParam):
866866 file_dumps [file_title ]
867867 )
868868
869+ # bundle.packages[config.name].pages.sort(key=lambda x: x.urlPath)
870+
869871 content = bundle .json (exclude_none = True , indent = 4 , ensure_ascii = False )
870872 # This will create the JSON (e.g., package.json) with the PagePackageConfig,
871873 # which contains the PagePackageBundle
@@ -1927,8 +1929,19 @@ def save_to_file(file_path__, content__):
19271929 with open (os .path .join (file_path__ ), "w" , encoding = "utf-8" ) as f__ :
19281930 f__ .write (content__ )
19291931
1932+ def _sort_json_arrays (obj ):
1933+ """Recursively sort list-of-strings for deterministic serialization."""
1934+ if isinstance (obj , dict ):
1935+ return {k : _sort_json_arrays (v ) for k , v in obj .items ()}
1936+ if isinstance (obj , list ):
1937+ if all (isinstance (v , str ) for v in obj ):
1938+ return sorted (obj )
1939+ return [_sort_json_arrays (v ) for v in obj ]
1940+ return obj
1941+
19301942 def dump_slot_content (slot_key_ , content_type_ , content_ ):
19311943 if isinstance (content_ , dict ):
1944+ content_ = _sort_json_arrays (content_ )
19321945 content_ = json .dumps (content_ , indent = 4 , ensure_ascii = False )
19331946 if content_type_ == "Scribunto" :
19341947 content_type_ = "lua"
@@ -1960,6 +1973,7 @@ def dump_slot_content(slot_key_, content_type_, content_):
19601973 dump_slot_content (slot_key , content_type , content )
19611974
19621975 if self .is_file_page ():
1976+ print ("download " + self .title )
19631977 file = self .wtSite .mw_site .images [self .title .split (":" )[- 1 ]]
19641978 file_name = f"{ page_name } "
19651979 file_path = os .path .join (tar_dir , * file_name .split ("/" )) # handle subpages
0 commit comments