@@ -535,76 +535,6 @@ def import_project() -> flask.Response:
535535 return flask .make_response ({"snapshot" : snapshot }, 200 )
536536
537537
538- @routes .route (
539- schemas_dict ["import_extension" ]["route" ],
540- methods = schemas_dict ["import_extension" ]["methods" ],
541- )
542- def import_extension () -> flask .Response :
543- """Import a .vext extension file and extract its contents."""
544- utils_functions .validate_request (flask .request , schemas_dict ["import_extension" ])
545-
546- if "file" not in flask .request .files :
547- flask .abort (400 , "No .vext file provided under 'file'" )
548-
549- vext_file = flask .request .files ["file" ]
550- assert vext_file .filename is not None
551- filename = werkzeug .utils .secure_filename (os .path .basename (vext_file .filename ))
552-
553- if not filename .lower ().endswith (".vext" ):
554- flask .abort (400 , "Uploaded file must be a .vext" )
555-
556- # Create extensions directory in the data folder
557- extensions_folder = flask .current_app .config ["EXTENSIONS_FOLDER_PATH" ]
558- os .makedirs (extensions_folder , exist_ok = True )
559-
560- extension_name = (
561- filename .rsplit ("-" , 1 )[0 ] if "-" in filename else filename .replace (".vext" , "" )
562- )
563- extension_path = os .path .join (extensions_folder , extension_name )
564-
565- # Remove existing extension if present
566- if os .path .exists (extension_path ):
567- shutil .rmtree (extension_path )
568-
569- os .makedirs (extension_path , exist_ok = True )
570-
571- # Extract the .vext file
572- vext_file .stream .seek (0 )
573- with zipfile .ZipFile (vext_file .stream ) as zip_archive :
574- zip_archive .extractall (extension_path )
575-
576- # Look for the backend executable and frontend JS
577- backend_executable = None
578- frontend_file = None
579-
580- for file in os .listdir (extension_path ):
581- file_path = os .path .join (extension_path , file )
582- if os .path .isfile (file_path ):
583- if file .endswith (".es.js" ):
584- frontend_file = file_path
585- elif not file .endswith (".js" ) and not file .endswith (".css" ):
586- backend_executable = file_path
587- os .chmod (backend_executable , 0o755 )
588-
589- if not frontend_file :
590- flask .abort (400 , "Invalid .vext file: missing frontend JavaScript" )
591- if not backend_executable :
592- flask .abort (400 , "Invalid .vext file: missing backend executable" )
593-
594- assert frontend_file is not None
595- with open (frontend_file , "r" , encoding = "utf-8" ) as f :
596- frontend_content = f .read ()
597-
598- return flask .make_response (
599- {
600- "extension_name" : extension_name ,
601- "frontend_content" : frontend_content ,
602- "backend_path" : backend_executable ,
603- },
604- 200 ,
605- )
606-
607-
608538@routes .route (
609539 schemas_dict ["geode_object_inheritance" ]["route" ],
610540 methods = schemas_dict ["geode_object_inheritance" ]["methods" ],
0 commit comments